-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement reflect/reify for binary operations, implement transform.
- Loading branch information
Showing
12 changed files
with
358 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
% tagging of input ast elements | ||
ast(rule(H,B)) :- rule(H,B). | ||
ast(literal_tuple(I,P,E)) :- literal_tuple(I,P,E). | ||
ast(term_tuple(I,P,E)) :- term_tuple(I,P,E). | ||
|
||
final(A) :- ast(A), not delete(A), not replace(A,_). | ||
final(R) :- replace(_,R). | ||
final(N) :- new(N). | ||
|
||
#show final/1. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
good(X) :- person(X). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
good(X) :- person(X); not bad(X). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
new(literal_tuple(L,M+1,literal(1,function("bad",term_tuple(T))))) | ||
:- rule(literal(0,function("good",term_tuple(T))), | ||
literal_tuple(L)), | ||
M = #max{ P : literal_tuple(L,P,_) }. | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sad(robot(X)) :- prev(sad(robot(X))), not cheer_up(robot(X)). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sad(robot(X),T) :- sad(robot(X),(T-1)); not cheer_up(robot(X),T). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
rule(literal(0,function("sad",term_tuple(0))) | ||
,literal_tuple(0)). | ||
|
||
literal_tuple(0,0,literal(0,function("prev",term_tuple(2)))). | ||
literal_tuple(0,1,literal(1,function("cheer_up",term_tuple(5)))). | ||
|
||
|
||
term_tuple(0,0,function("robot",term_tuple(1))). | ||
term_tuple(1,0,variable("X")). | ||
|
||
term_tuple(2,0,function("sad",term_tuple(3))). | ||
term_tuple(3,0,function("robot",term_tuple(4))). | ||
term_tuple(4,0,variable("X")). | ||
|
||
term_tuple(5,0,function("robot",term_tuple(6))). | ||
term_tuple(6,0,variable("X")). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
% helper predicates | ||
max_index(T,M) :- M = #max{ P : term_tuple(T,P,_) }, term_tuple(T,_,_). | ||
|
||
|
||
% head literal (assume that prev is not allowed in the head). | ||
|
||
new(term_tuple(T,M+1,variable("T"))) | ||
:- rule(literal(S,function(N,term_tuple(T))),_), | ||
max_index(T,M). | ||
|
||
% body literal with prev operator | ||
|
||
replace(literal_tuple(L,P,literal(S,function("prev",term_tuple(T)))), | ||
literal_tuple(L,P,literal(S,function(FN,term_tuple(T'))))) | ||
:- literal_tuple(L,P,literal(S,function("prev",term_tuple(T)))), | ||
term_tuple(T,0,function(FN, term_tuple(T'))), | ||
not term_tuple(T,1,_). | ||
|
||
new(term_tuple(T',M+1,binary_operation("-",variable("T"),number(1)))) | ||
:- literal_tuple(L,P,literal(S,function("prev",term_tuple(T)))), | ||
term_tuple(T,0,function(FN, term_tuple(T'))), | ||
not term_tuple(T,1,_), | ||
max_index(T',M). | ||
|
||
% body literal without prev operator | ||
|
||
new(term_tuple(T,M+1,variable("T"))) | ||
:- literal_tuple(L,P,literal(S,function(N,term_tuple(T)))), | ||
N != "prev", | ||
max_index(T,M). |
This file contains 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
Oops, something went wrong.