-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from FissoreD/scope-term
[functionality] add functionality field to program
- Loading branch information
Showing
58 changed files
with
1,311 additions
and
228 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,41 @@ | ||
# Functionality | ||
|
||
## About the tests | ||
|
||
### Success | ||
|
||
test2.elpi: functional ctx + functional premises (FO) | ||
test4.elpi: loading local clauses (with and without local pi) | ||
test6.elpi: nested local clauses | ||
test12.elpi: non overlapping heads using uvar keyword | ||
test15.elpi: non functional premise followed by bang | ||
test16.elpi: non functional premise using variable not used in the head | ||
test17.elpi: functional predicate with functional argument + nested | ||
test20.elpi: functional predicate with non functional argument declaration | ||
test22.elpi: functional ho output of a premise used to build the output of the rule | ||
test28.elpi: non functional prop in functional ctx call (do') | ||
test29.elpi: similar to previous | ||
|
||
|
||
### Failure | ||
|
||
test1.elpi: overlapping heads no bang rigid terms | ||
test3.elpi: non functional premise | ||
test5.elpi: local non functional clause | ||
test6.elpi: nested local non-functional clauses | ||
test7.elpi: local non-functional clauses | ||
test8.elpi: local non-functional clauses | ||
test9.elpi: local nested non-functional premises | ||
test10.elpi: local nested non-functional premises | ||
test11.elpi: overlapping heads using uvars | ||
test13.elpi: overlapping heads with two rules using the uvar keyword | ||
test14.elpi: non-functional variable used in variable used in the clause head | ||
test18.elpi: functional predicate with non functional argument | ||
test19.elpi: nested functional predicate with non functional argument | ||
test21.elpi: wrong-if: non-declared functional argument used in non functional ctx | ||
test23.elpi: similar to test14 | ||
test24.elpi: ho output used in two different calls with different functionality relation | ||
test25.elpi: non functional ho output used to produce output of the rule | ||
test26.elpi: overlap with as operator | ||
test27.elpi: overlap with HO term in PF (B x) against (A x y) | ||
test30.elpi: non functional pred pass instead of functional, makes the premise non functional |
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,11 @@ | ||
:functional pred q. | ||
|
||
:functional pred p i:(:functional pred). | ||
|
||
% THIS IS OK: | ||
% functionality relation of q is (Functional []) | ||
% functionality of first arg of p is (Functional []) | ||
% Functional [] ⊆ Functional [] | ||
p q. | ||
|
||
main. |
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,11 @@ | ||
pred q. | ||
|
||
:functional pred p i:(:functional pred). | ||
|
||
% THIS FAILS: | ||
% functionality relation of q is (Relational []) | ||
% functionality of first arg of p is (Functional []) | ||
% Relational [] ⊈ Functional [] | ||
p q. | ||
|
||
main. |
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,13 @@ | ||
:functional pred p i:(:functional pred i:(pred)). | ||
:functional pred r i:(:functional pred). | ||
|
||
% THIS IS OK: | ||
% functionality relation of p is (Functional [Functional [Relational []]]) | ||
% functionality of r is (Functional [Functional []]) | ||
% (p r) is GOOD since first arg of p is `Functional [Relational []]` | ||
% and Functional [Functional []] ⊆ Functional [Relational []] | ||
% r (p r) is GOOD is first arg of r is `Functional []` and | ||
% Functional [Functional [Relational []] ⊆ Functional [] | ||
r (p r). | ||
|
||
main. |
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,11 @@ | ||
:functional pred p i:(:functional pred i:(:functional pred)). | ||
:functional pred r i:(pred). | ||
|
||
% THIS FAILS: | ||
% functionality relation of p is (Functional [Functional [Relational []]]) | ||
% functionality of r is (Functional [Functional []]) | ||
% (p r) is WRONG since first arg of p is `Functional [Functional []]` | ||
% and Functional [Relational []] ⊈ Functional [Functional []] | ||
r (p r). | ||
|
||
main. |
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,7 @@ | ||
:functional pred p i:(pred i:(pred)) i:(:functional pred i:(pred)) . | ||
|
||
% THIS FAILS: first A is relational. The second A is functional. | ||
% However relational ⊈ functional | ||
p A A. | ||
|
||
main. |
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,7 @@ | ||
:functional pred p i:(:functional pred i:(pred)) i:(pred i:(pred)). | ||
|
||
% THIS IS OK: first A is functional. The second A is relation. | ||
% functional ⊆ relational | ||
p A A. | ||
|
||
main. |
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 @@ | ||
:functional pred p i:(int -> (:functional pred) -> prop). | ||
|
||
pred q i:int, o:(:functional pred). | ||
|
||
% THIS IS OK: | ||
% functionality relation of q is | ||
% (Relational [NoProp, Functional[]]) ⊆ (Relational [NoProp, Functional[]]) | ||
p q. | ||
|
||
main. |
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,9 @@ | ||
:functional pred p i:((:functional pred) -> prop). | ||
|
||
pred q o:(pred). | ||
|
||
% functionality relation of q is | ||
% (Relational [Relational]) ⊈ (Relational [Functional]) | ||
p q. | ||
|
||
main. |
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,7 @@ | ||
:functional pred p i:((:functional pred) -> (:functional pred)). | ||
|
||
:functional pred q i:(:functional pred). | ||
|
||
p (x\q x). | ||
|
||
main. |
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 @@ | ||
:functional | ||
pred p i:int, o:int. | ||
|
||
p 1 3. | ||
p 2 3. | ||
|
||
% The following rule hinders functionality, since `p 2 X` has two solutions for X | ||
p 2 4. | ||
|
||
main. |
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,15 @@ | ||
:- module test1. | ||
|
||
:- interface. | ||
:- import_module io. | ||
:- pred main(io::di, io::uo) is det. | ||
:- pred p(int::in, int::out) is nondet. | ||
|
||
:- implementation. | ||
:- import_module int. | ||
|
||
|
||
p(1,2). | ||
p(2,X) :- X = 3; X = 4. | ||
|
||
main(!IO). |
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,11 @@ | ||
:functional | ||
pred p i:int, o:int. | ||
|
||
:functional | ||
pred q i:int, o:int. | ||
|
||
q 1 1. | ||
|
||
p 4 X :- pi x\ sigma Y\ q x Y => q x Y => q 1 X. | ||
|
||
main. |
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 @@ | ||
:functional | ||
pred p i:int, o:int. | ||
|
||
% here we have variables in input position, overlap detection, | ||
% makes the predicate not functional... | ||
% NOTE: the query p 1 Y has two solution for Y | ||
p 1 2. | ||
p X 3. | ||
|
||
main. |
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,12 @@ | ||
:functional | ||
pred p i:int, o:int. | ||
|
||
/* this slightly differs from test11.elpi since | ||
* we explicitly put the uvar keyword in place of a unification variable | ||
* the input mode will therefore prevent the query `p 1 Y` to unify with | ||
* `p uvar 3. | ||
*/ | ||
p 1 2. | ||
p uvar 3. | ||
|
||
main. |
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,12 @@ | ||
:functional | ||
pred p i:int, o:int. | ||
|
||
/* another version of test11.elpi and test12.elpi | ||
* here the query `p 1 X` has clearly one distinct solution, | ||
* but `p X Y` has two. Therefore, p is not guaranteed to be functional | ||
*/ | ||
p 1 2. | ||
p (uvar as X_) 3. | ||
p (uvar as Y_) 4. | ||
|
||
main. |
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,22 @@ | ||
:functional | ||
pred f i:int, o:int. | ||
|
||
pred q o:int. | ||
|
||
:functional | ||
pred r i:int, o:int. | ||
|
||
q 1. | ||
q 2. | ||
|
||
r X X. | ||
|
||
% Recall: q is not functional! | ||
% Note: in warren, the following rule is considered functional | ||
% since the input X should be ground, and therefore, q X does not | ||
% create any choice point for `r X Y` where Y can be assinged to 2 distinct | ||
% values. | ||
% In the implementation using the input mode of elpi this is no more true. | ||
f X Y :- q X, r X Y. | ||
|
||
main :- std.findall (f _ _) L, print L. |
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,22 @@ | ||
:functional | ||
pred f i:int, o:int. | ||
|
||
pred q o:int. | ||
|
||
:functional | ||
pred r i:int, o:int. | ||
|
||
q 1. | ||
q 2. | ||
|
||
r X X. | ||
|
||
% Recall: q is not functional! | ||
% This is similar to test14, but in this case, | ||
% the output of q is Y (which can have several distinct assignments). | ||
% However Y is functionally determined by then 1 Y :- q Y, r 1 Y. | ||
|
||
% Here the bang ensures that `Y` is functionally determined by the call to q | ||
f 2 Y :- q Y, !. | ||
|
||
main. |
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,13 @@ | ||
:functional | ||
pred p i:int, o:int. | ||
|
||
pred f o:int, o:int, o:int. | ||
|
||
% the variables of f are not used in the output, therefore, p remains functional | ||
p 4 Y :- f Z X W, Y = 4. | ||
|
||
% case similar to the previous one, where the output is not instantiated | ||
% all the variables in the body are never returned | ||
p 5 Y :- f Z X W, f X Z T. | ||
|
||
main. |
Oops, something went wrong.