Skip to content

Instantly share code, notes, and snippets.

@cmungall
Created April 7, 2018 02:03
Show Gist options
  • Select an option

  • Save cmungall/67e9b6e58d747d784759d0ddff0dee53 to your computer and use it in GitHub Desktop.

Select an option

Save cmungall/67e9b6e58d747d784759d0ddff0dee53 to your computer and use it in GitHub Desktop.
fact(is_a(a,b)).
fact(is_a(b,c)).
rule((is_aT(A,B) :- is_a(A,B))).
rule((is_aT(A,B) :- is_a(A,Z),is_aT(Z,B))).
prove(Goal,[Goal]) :-
fact(Goal).
prove(Goal, [Rule|Steps]) :-
Rule = rule( (Goal :- Body) ),
Rule,
prove(Body, Steps).
prove((A,B), Steps) :-
prove(A,Steps1),
prove(B,Steps2),
% append is ugly - should really return a proof tree not list
append(Steps1,Steps2,Steps).
prove((G;_), Steps) :-
prove(G,Steps).
prove((_;G), Steps) :-
prove(G,Steps).
t :-
prove(is_aT(a,c),Steps),
writeln(proof=Steps).
@cmungall
Copy link
Copy Markdown
Author

cmungall commented Apr 7, 2018

To test:

$ swipl -l metalog.pl -g t
proof=[rule((is_aT(a,c):-is_a(a,b),is_aT(b,c))),is_a(a,b),rule((is_aT(b,c):-is_a(b,c))),is_a(b,c)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment