prolog - Is it possible to view all implications of a given predicate being true or false? -


i trying build machine can answer user-given questions have problem don't know how resolve, boils down following:

imagine following program:

friendlycat(x)  :- cat(x), friendly(x). cat("felix"). 

we want know if felix friendly cat, use friendlycat("felix"). problem we, programmer, don't know if felix friendly cat or not. there way automatically see implications if friendly(x) true of false given x?

for example, can output looks this?

felix (friendly("felix") = true) false (friendly("felix") = false) 

i recommend check out constraint handling rules (chr).

this may best bet reason such constraints , implications.

for example:

 :- use_module(library(chr)).  :- chr_constraint cat/1, friendly/1, friendlycat/1.  cat(x), friendly(x) ==> friendlycat(x). 

sample queries:

 ?- cat(felix), friendly(felix). cat(felix), friendly(felix), friendlycat(felix).  ?- cat(x), friendly(x). cat(x), friendly(x), friendlycat(x). 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo