I am trying to build a machine which can answer user-given questions but I have a problem which I don't know how to resolve, it boils down to the following:
Imagine the following program:
friendlycat(X) :- cat(X), friendly(X).
cat("Felix").
We want to know if Felix is a friendly cat, so we use friendlycat("Felix"). The problem is that we, the programmer, don't know if Felix is a friendly cat or not. Is there a way to automatically see the implications if friendly(X) would be true of false given a certain X?
For example, can we get output which looks like this?
Felix (friendly("Felix") = True)
False (friendly("Felix") = False)
I recommend you check out Constraint Handling Rules (CHR).
This may be your best bet to quickly reason about such constraints and their 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).