Skip to content

Commit

Permalink
Add verify command.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedretaber committed Oct 26, 2024
1 parent ec0e384 commit 57ce5e1
Show file tree
Hide file tree
Showing 11 changed files with 601 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@
(modules removebottom)
(libraries birds))

(executable
(public_name verify)
(name verify)
(modules verify)
(libraries birds))

8 changes: 8 additions & 0 deletions bin/verify.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
open Birds

let _ =
let filename = Sys.argv.(1) in
let chan = open_in filename in
let lexbuf = Lexing.from_channel chan in
let ast = Parser.main Lexer.token lexbuf in
Verify.verify true 600 ast
9 changes: 9 additions & 0 deletions examples/verify_invalid_getput1.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source tracks2('TRACK':string,'RATING':int,'ALBUM':string,'QUANTITY':int).
view tracks3('TRACK':string,'RATING':int,'ALBUM':string,'QUANTITY':int).
% view definition:
tracks3(T,R,A,Q) :- tracks2(T,R,A,Q),Q > 2.
% putdelta
+tracks2(T,R,A,Q) :- tracks3(T,R,A,Q), not tracks2(T,R,A,Q).
-tracks2(T,R,A,Q) :- tracks2(T,R,A,Q), not tracks3(T,R,A,Q).
% constraints
_|_ :- tracks3(T,R,A,Q), Q <= 2.
13 changes: 13 additions & 0 deletions examples/verify_invalid_getput2.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source a('A':int, 'B':int).
source b('B':int, 'C':int).
view s('A':int, 'B':int, 'C':int).
% view definition
s(A,B,C) :- a(A,B), b(B,C).
% putdelta
-a(A,B) :- a(A,B), not s(A,B,_).
+a(A,B) :- s(A,B,_), not a(A,B).
-b(B,C) :- b(B,C), s(_,B,_), not s(_,B,C).
+b(B,C) :- s(_,B,C), not b(B,C).
% constraints
%_|_ :- a(_,B), not b(B,_).
_|_ :- s(_,B,C1), s(_,B,C2), C1<>C2.
9 changes: 9 additions & 0 deletions examples/verify_invalid_putget1.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source tracks2('TRACK':string,'RATING':int,'ALBUM':string,'QUANTITY':int).
view tracks3('TRACK':string,'RATING':int,'ALBUM':string,'QUANTITY':int).
% view definition:
tracks3(T,R,A,Q) :- tracks2(T,R,A,Q),Q > 2.
% putdelta
+tracks2(T,R,A,Q) :- tracks3(T,R,A,Q), not tracks2(T,R,A,Q).
-tracks2(T,R,A,Q) :- tracks2(T,R,A,Q), not tracks3(T,R,A,Q).
% constraints
%_|_ :- tracks3(T,R,A,Q), Q <= 2.
13 changes: 13 additions & 0 deletions examples/verify_invalid_putget2.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source a('A':int, 'B':int).
source b('B':int, 'C':int).
view s('A':int, 'B':int, 'C':int).
% view definition
s(A,B,C) :- a(A,B), b(B,C).
% putdelta
%-a(A,B) :- a(A,B), not s(A,B,_).
+a(A,B) :- s(A,B,_), not a(A,B).
-b(B,C) :- b(B,C), s(_,B,_), not s(_,B,C).
+b(B,C) :- s(_,B,C), not b(B,C).
% constraints
_|_ :- a(_,B), not b(B,_).
_|_ :- s(_,B,C1), s(_,B,C2), C1<>C2.
9 changes: 9 additions & 0 deletions examples/verify_valid1.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source tracks2('TRACK':string,'RATING':int,'ALBUM':string,'QUANTITY':int).
view tracks3('TRACK':string,'RATING':int,'ALBUM':string,'QUANTITY':int).
% view definition:
tracks3(T,R,A,Q) :- tracks2(T,R,A,Q),Q > 2.
% putdelta
+tracks2(T,R,A,Q) :- tracks3(T,R,A,Q), not tracks2(T,R,A,Q).
-tracks2(T,R,A,Q) :- tracks2(T,R,A,Q), not tracks3(T,R,A,Q), Q > 2.
% constraints
_|_ :- tracks3(T,R,A,Q), Q <= 2.
13 changes: 13 additions & 0 deletions examples/verify_valid2.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source a('A':int, 'B':int).
source b('B':int, 'C':int).
view s('A':int, 'B':int, 'C':int).
% view definition
s(A,B,C) :- a(A,B), b(B,C).
% putdelta
-a(A,B) :- a(A,B), not s(A,B,_).
+a(A,B) :- s(A,B,_), not a(A,B).
-b(B,C) :- b(B,C), s(_,B,_), not s(_,B,C).
+b(B,C) :- s(_,B,C), not b(B,C).
% constraints
_|_ :- a(_,B), not b(B,_).
_|_ :- s(_,B,C1), s(_,B,C2), C1<>C2.
Loading

0 comments on commit 57ce5e1

Please sign in to comment.