How to write a query contains fact in Prolog -


i implementing program need somehow add facts "prolog" query. don't know how it. example: in "prolog" database, have rule:

engineer(x) :-     employee(x,department_a). 

now want check if jack engineer, query be: engineer(jack).

to make query success, there should fact as: employee(jack,department_a). in database. in program, don't want add (or assert) fact database, reason program working on distributed system department jack belongs unknown database. in other words, looking way can make prolog engine deduct based on own database , given facts (the given fact not stored in database along query).

is there way how can it? suggestions appreciated.

you can put facts , rules in different prolog text files if want to. , freely mix different prolog text files command line while loading.

for example following:

file 1: foo.p

engineer(x) :-     employee(x,department_a). 

file 2: bar.p

employee(jack,department_a) 

then can on command line:

?- [foo, bar]. yes ?- engineer(jack). yes ?- engineer(jill). no 

of course if load different facts same rules, might different results in query.

if don't want consult in command line, instead temporarily assert facts during query execution, should hypothetical reasoning.

here example:

bonner's example
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/15_min/10_docu/02_reference/04_examples/01_bonner.html

bye


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -