Pfc pack (forward chaining) -- can't get to work

Hello,

I am trying to use the pfc pack. I managed to install the pack, but i am unsure how to get to use it.

There is no example that shows what use_module to use to import it, and when i try:

:- use_module(library(pfc)).

I get odd compilation problems related to the jpl – java interface. I assume its unlikely that pfc uses the java runtime – or is it?

any suggestions on how to get pfc to work would be greatly appreciated,

thank you,

Dan

1 Like

You walk the path but are alone. You see footsteps on the path that have been marked by the passage of time and wonder, whom has preceded me? Not me I say but my trusty friend of the clan German Shepherd races ahead and calls back with a bark to come forward.

As we follow along we come to the town of Git which has a local pub called Hub, the locals know of it as GitHub. So we ask those in the pub and they direct us to bar maid Gwendolyn Marie Issues . We ask Gwendolyn for help and she recalls a traveler of a time ago who asked the same. He went by the name of reverendpaco but sadly Gwendolyn knew not of the answer. She did know enough to tac the answer beside the door so that others whom should stop by might reply. As we seek for the post we find that it does exist and not only that, aindilis has added to the post. It was not much but others do recall of him and how to find him.

HTH

1 Like

Good idea.

Let me see if i can get the source working as published on github.

Dan

I was hoping for the next verse in the tale.

whope, missed the link :slight_smile:

Yes, i was contemplating adding it in verse form – but, then, the engineer in me got the better of me … :slight_smile:

hmm, but the example doesn’t work either.

Its also unclear – what does ain/1 do, and how does test/1 work.

Dan

:- use_module(library(pfc)).

:- ain(gender(P,male) ==> male(P)).
:- ain(gender(joe,male)).

test(X) :-
        male(X).

It seems that the post was enchanted with a magic spell that caused it to transform over time.

A while back Jack Sketch was seen doing his work while in the pub, one of them included the post by reverendpaco but in his drawing the word post looks different. Then a patron who happened to overhear our puzzlement noted that someone he had never seen before did read the post and with some arm waving the post had some magical looking stars jump forth. He notes that some don’t believe in magic, but if you do then surely this solves your riddle.

Upon talking to Gwendolyn she ask if we could write up a new query as she would be happy to tac it by the others near the door.

It seems my friend of the clan German Shepard has been about for which upon his return is intent that we come with him.

As we follow along in to the wilderness while still in the region of TeamSPoon we find ourselves passing a sign post with the faded words of pfc and some words underneath. There are a few words with each word having an arrow indicating a direction, but one word has had the dust brushed away and reads examples.

It seems this to is a word of magic for as we say the word examples we are whisked away.

We find ourselves among others who speak words we know but some of the words and phrases are unknown to us. We must take some time and learn these new words and phrases and see if these might be what we seek.

I have a feeling that i will need to find an alternative or implement my own light weight forward chaining … the pfc code seems very odd – not sure its a good idea to include in a project.

Are there any alternative comparable forward chaining libraries out there … that could work in swi-prolog?

Dan

I gave it a try myself and failed. This is currently the most critical error

ERROR: Unknown procedure: jpl:win_add_dll_directory/1

but I am thinking it might be related to the autoload changes.

thank you for trying it out.

Do you think that this is something you can overcome.

Dan

Possibly.

If you see in the extended error message

ERROR: c:/program files/swipl/library/jpl.pl:4546: Initialization goal raised exception:
ERROR: Unknown procedure: jpl:win_add_dll_directory/1
ERROR:   However, there are definitions for:
ERROR:         win_add_dll_directory/2
ERROR: 
ERROR: In:
ERROR:   [92] jpl:win_add_dll_directory('c:/Program Files/Java/jdk-12/bin/server')
ERROR:   [91] jpl:extend_dll_search_path('c:/Program Files/Java/jdk-12/bin/server') at c:/program files/swipl/library/jpl.pl:4215
ERROR:   [90] jpl:'__aux_maplist/2_extend_dll_search_path+0'(['c:/Program Files/Java/jdk-12/bin/server','c:/Program Files/Java/jdk-12/bin']) at c:/program files/swipl/library/jpl.pl:4194
ERROR:   [88] jpl:setup_jvm at c:/program files/swipl/library/jpl.pl:4326
ERROR:   [87] '$run_init_goal'(jpl:setup_jvm) at c:/program files/swipl/boot/init.pl:712
ERROR:   [86] catch(system:'$run_init_goal'(jpl:setup_jvm),error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67048)),system:'$initialization_error'(error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67104)),jpl:setup_jvm,'c:/program files/swipl/library/jpl.pl':4546)) at c:/program files/swipl/boot/init.pl:480
ERROR:   [85] catch_with_backtrace(system:'$run_init_goal'(jpl:setup_jvm),error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67208)),system:'$initialization_error'(error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67264)),jpl:setup_jvm,'c:/program files/swipl/library/jpl.pl':4546)) at c:/program files/swipl/boot/init.pl:530
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
ERROR: c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfc_lib_2_0.pl:91:
ERROR:    Exported procedure jpl:jpl_c_lib_version/1 is not defined

that SWI-Prolog found win_add_dll_directory/2 but not win_add_dll_directory/1.

However
win_add_dll_directory/1 is in shlib.pl and
win_add_dll_directory/2 is in pl-nt.c

My quick guess is that jpl might need to autoload the missing one, but that is just a guess.

why is jpl at all involved?

What does java have to do with this …

Do you know why its there.

Don’t know, don’t care. :ok_hand:

The goal is to get the code working, can worry about why later.

I have no idea how to resolve this …

I don’t either but that should not stop one.

Rely on your problem solving skills and think of the problems as holes you need to fill. Take the bigger holes and figure out way to break them apart into smaller problems/holes. Rinse and repeat until all of the holes are filled or you know for a fact that there is no solution in any of the combinations to the problem. Just keep working on it until you have searched the problem space.

If we are lucky it will only take an hour or less. :wink:

Complete dump of what I have done up to this point.

Details
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.4-11-g1db629e24)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- ?- pack_install('https://github.com/TeamSPoon/pfc.git').
ERROR: Unknown procedure: (?-)/1
ERROR:   ?- is the Prolog prompt
ERROR:   See FAQ at https://www.swi-prolog.org/FAQ/ToplevelMode.txt
ERROR: In:
ERROR:    [9] throw(error(existence_error(procedure,...),_17648))
ERROR:    [8] '$dwim':dwim_existence_error(error,user:(?-)/1) at c:/program files/swipl/boot/dwim.pl:113
ERROR:    [6] '$dwim':correct_goal((?-pack_install('https://github.com/TeamSPoon/pfc.git')),user,[],_17734) at c:/program files/swipl/boot/dwim.pl:85
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?- pack_install('https://github.com/TeamSPoon/pfc.git').
% Cloning into 'c:/users/eric/appdata/local/swi-prolog/pack/pfc'...
Verify package status (anonymously)
        at "https://www.swi-prolog.org/pack/query" Y/n? 
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Warning: Package depends on the following:
Warning:   "logicmoo_utils", provided by logicmoo_utils@1.5.666 from https://github.com/TeamSPoon/logicmoo_utils.git
Warning:     "gvar_syntax", provided by gvar_syntax@1.5.666 from https://github.com/TeamSPoon/gvar_syntax.git
Warning:     "predicate_streams", provided by predicate_streams@1.5.666 from http://github.com/TeamSPoon/predicate_streams.git

What do you wish to do
   (1) * Install proposed dependencies
   (2)   Only install requested package
   (3)   Cancel

Your choice? 
% "pfc.git" was downloaded 2 times
% Cloning into 'c:/users/eric/appdata/local/swi-prolog/pack/logicmoo_utils'...
i logicmoo_utils@1.5.666    - Common predicates that are used throughout LogicMOO Software
% Updating index for library c:/users/eric/appdata/local/swi-prolog/pack/logicmoo_utils/prolog/
% Cloning into 'c:/users/eric/appdata/local/swi-prolog/pack/gvar_syntax'...
i gvar_syntax@1.5.666       - Global Variable Syntax
Warning: Cloning into 'c:/users/eric/appdata/local/swi-prolog/pack/predicate_streams'...
Warning: warning: redirecting to https://github.com/TeamSPoon/predicate_streams.git/
i predicate_streams@1.5.666 - Implement your own Abstract Predicate Streams
% Updating index for library c:/users/eric/appdata/local/swi-prolog/pack/predicate_streams/prolog/
Package:                pfc
Title:                  Pfc -- a package for forward chaining in Prolog
Installed version:      1.4.111
Author:                 Douglas R. Miles <logicmoo@gmail.com>
Packager:               TeamSPoon/LogicMoo <https://github.com/TeamSPoon/>
Home page:              https://github.com/TeamSPoon/pfc
Download URL:           https://github.com/TeamSPoon/pfc/releases/*.zip
Requires:               logicmoo_utils
Activate pack "pfc" Y/n? Y
true.

?- pack_install('https://github.com/TeamSPoon/pfc.git').
ERROR: Pack `pfc' is already installed. Package info:
Package:                pfc
Title:                  Pfc -- a package for forward chaining in Prolog
Installed version:      1.4.111
Installed in directory: c:/users/eric/appdata/local/swi-prolog/pack/pfc
Author:                 Douglas R. Miles <logicmoo@gmail.com>
Packager:               TeamSPoon/LogicMoo <https://github.com/TeamSPoon/>
Home page:              https://github.com/TeamSPoon/pfc
Download URL:           https://github.com/TeamSPoon/pfc/releases/*.zip
Requires:               logicmoo_utils
Provided libraries:     pfc, pfc_dcg, pfc_lib, pfc_lib_2_0, pfc_syntax, pfc_test, pfc_toplevel, prolog_syntax
% The package can be removed using: ?- pack_remove(pfc).
false.



?- use_module(pfc).
ERROR: source_sink `pfc' does not exist
ERROR: In:
ERROR:   [19] throw(error(existence_error(source_sink,pfc),_2696))
ERROR:   [15] '$resolve_source_path'(pfc,_2728,[if(not_loaded),...]) at c:/program files/swipl/boot/init.pl:2265
ERROR:   [14] '$load_file'(pfc,user,[if(not_loaded),...]) at c:/program files/swipl/boot/init.pl:2239
ERROR:    [9] <user>
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?- use_module(library(pfc)).
% Disabled autoloading (loaded 154 files)
% Disabled autoloading (loaded 11 files)
% Disabled autoloading (loaded 0 files)
% Extended DLL search path with
%   'c:/Program Files/Java/jdk-12/bin/server'
%   'c:/Program Files/Java/jdk-12/bin'
ERROR: c:/program files/swipl/library/jpl.pl:4546: Initialization goal raised exception:
ERROR: Unknown procedure: jpl:win_add_dll_directory/1
ERROR:   However, there are definitions for:
ERROR:         win_add_dll_directory/2
ERROR: 
ERROR: In:
ERROR:   [92] jpl:win_add_dll_directory('c:/Program Files/Java/jdk-12/bin/server')
ERROR:   [91] jpl:extend_dll_search_path('c:/Program Files/Java/jdk-12/bin/server') at c:/program files/swipl/library/jpl.pl:4215
ERROR:   [90] jpl:'__aux_maplist/2_extend_dll_search_path+0'(['c:/Program Files/Java/jdk-12/bin/server','c:/Program Files/Java/jdk-12/bin']) at c:/program files/swipl/library/jpl.pl:4194
ERROR:   [88] jpl:setup_jvm at c:/program files/swipl/library/jpl.pl:4326
ERROR:   [87] '$run_init_goal'(jpl:setup_jvm) at c:/program files/swipl/boot/init.pl:712
ERROR:   [86] catch(system:'$run_init_goal'(jpl:setup_jvm),error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67154)),system:'$initialization_error'(error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67210)),jpl:setup_jvm,'c:/program files/swipl/library/jpl.pl':4546)) at c:/program files/swipl/boot/init.pl:480
ERROR:   [85] catch_with_backtrace(system:'$run_init_goal'(jpl:setup_jvm),error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67314)),system:'$initialization_error'(error(existence_error(procedure,jpl:win_add_dll_directory/1),context(jpl:extend_dll_search_path/1,_67370)),jpl:setup_jvm,'c:/program files/swipl/library/jpl.pl':4546)) at c:/program files/swipl/boot/init.pl:530
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
ERROR: c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfc_lib_2_0.pl:91:
ERROR:    Exported procedure jpl:jpl_c_lib_version/1 is not defined
ERROR: c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfc2.0/mpred_loader.pl:199:
ERROR:    source_sink `library(dictoo_lib)' does not exist
Warning: c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfc2.0/mpred_loader.pl:199:
Warning:    Goal (directive) failed: pfc_lib:use_module(library(dictoo_lib))
% c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfclib/system_base.pfc.pl:152 
% loading_system_base.
% c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfclib/system_mdefault.pfc.pl:38 
% nop(mpred_unload_file('c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfclib/system_mdefault.pfc.pl')).
% c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfclib/system_mdefault.pfc.pl:40 
% debugm(baseKB, show_success(baseKB, set_fileAssertMt(baseKB))).
% c:/users/eric/appdata/local/swi-prolog/pack/pfc/prolog/pfc.pl:16 
% warn(mtHybrid(user)).
% debugm(not_is_pfc_file, show_success(not_is_pfc_file, ensure_abox(user))).
true.

?- halt.

Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.4-11-g1db629e24)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- pack_list_installed.
Installed packages (11):

i edcg@0.9.1.2              - Extended DCG
i fileutils@0.3.5           - Utilities for reading, writing and finding files
i func@0.4.2                - Function application and composition
i function_expansion@0.1.2  - Help for writing function-like macros
i gvar_syntax@1.5.666       - Global Variable Syntax
i list_util@0.13.0          - Predicates for working with lists
i logicmoo_utils@1.5.666    - Common predicates that are used throughout LogicMOO Software
i pfc@1.4.111               - Pfc -- a package for forward chaining in Prolog
i predicate_streams@1.5.666 - Implement your own Abstract Predicate Streams
i quickcheck@0.3.0          - QuickCheck randomized testing
i sldnfdraw@1.61            - SLDNF Draw is a Prolog program that draws SLDNF Trees in LaTeX
true.

?- pack_search(dictoo).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
p dictoo@1.4.111            - Dict-like OO Syntax
true.

?- pack_install(dictoo).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install dictoo@1.4.111 from GIT at https://github.com/TeamSPoon/dictoo.git Y/n? 
% Cloning into 'c:/users/eric/appdata/local/swi-prolog/pack/dictoo'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "dictoo.git" was downloaded 1 times
Package:                dictoo
Title:                  Dict-like OO Syntax
Installed version:      1.4.111
Author:                 Douglas R. Miles <logicmoo@gmail.com>
Maintainer:             TeamSPoon <https://github.com/TeamSPoon/>
Packager:               TeamSPoon/LogicMoo <https://github.com/TeamSPoon/>
Home page:              https://github.com/TeamSPoon/dictoo
Download URL:           https://github.com/TeamSPoon/dictoo/releases/*.zip
Requires:               gvar_syntax
Activate pack "dictoo" Y/n? 
true.

?- halt.

I am starting to wonder if JPL was built for Linux and we are on Windows. I am on Windows 10, what OS are you running?

Switching to WSL 2 with Unbuntu 18.04 to see if that works.

also on win10