Last active
November 8, 2018 23:07
-
-
Save jarble/be75ad57bbbbe6578f5d435dc9ed221a to your computer and use it in GitHub Desktop.
This is an attempt to write a meta-interpreter for Constraint Handling Rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- initialization(main). | |
| :- set_prolog_flag('double_quotes','chars'). | |
| :- use_module(library(chr)). | |
| :- chr_constraint is_true/1. | |
| is_true(X) \ is_true(X) <=> true. | |
| is_true(X ==> Y),is_true(X1) ==> copy_term((X -> Y),(X2 -> Y1)),(X2=X1,(is_true(X1)->is_true(Y1));X2\=X1),writeln(Y). | |
| is_true((X;Y)) ==> is_true(X);is_true(Y). | |
| is_true((X,Y)) ==> is_true(X),is_true(Y). | |
| is_true(is_true(X)) ==> is_true(X). | |
| is_true(X),is_true(\+X) ==> false. | |
| main :- | |
| is_true(is_person(A)==>is_mammal(A)), | |
| is_true(is_mammal(A)==>is_animal(A)), | |
| is_true(is_person(sue)),is_true(is_person(bob)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment