Skip to content

Commit 8b623f8

Browse files
Merge pull request #23 from AdrienChampion/master
v1.7
2 parents ca0ba17 + 50ec01d commit 8b623f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+43903
-30729
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ env:
1818
global:
1919
- RUSTFLAGS="-C link-dead-code"
2020

21-
cache: cargo
22-
2321
addons:
2422
apt:
2523
packages:

Cargo.lock

Lines changed: 63 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hoice"
3-
version = "1.5.0"
3+
version = "1.7.0"
44
authors = ["Adrien Champion <adrien.champion@email.com>"]
55
description = "A ICE-based Horn clause solver."
66
homepage = "https://github.com/hopv/hoice"
@@ -31,14 +31,15 @@ panic = 'unwind'
3131
bench = [ ]
3232

3333
[dependencies]
34+
libc = "*"
3435
lazy_static = "*"
3536
clap = "*"
3637
hashconsing = { git = "https://github.com/AdrienChampion/hashconsing" }
3738
error-chain = "*"
3839
ansi_term = "*"
39-
rsmt2 = { git = "https://github.com/kino-mc/rsmt2" }
40+
rsmt2 = "^0.9.11"
4041
num = "*"
4142
mylib = { git = "https://github.com/AdrienChampion/mylib" }
4243
either = "*"
4344
rand = "*"
44-
isatty = "*"
45+
atty = "*"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(set-logic HORN)
2+
3+
(declare-fun Concat ((List Int) (List Int) (List Int)) Bool)
4+
5+
(assert (forall ((y (List Int)))
6+
(Concat nil y y)))
7+
8+
(assert (forall ((x (List Int))(y (List Int))(r (List Int))(i Int))
9+
(=> (Concat x y r) (Concat (Cons i x) y (Cons i r)) )))
10+
11+
(assert (forall ((x (List Int))(y (List Int))(r (List Int))(i Int))
12+
(=> (Concat x y r) (Concat x y (Cons i r)) )))
13+
14+
(assert (forall ((x (List Int))(y (List Int))(r (List Int)))
15+
(=> (and (not (= r nil)) (Concat x y r)) (or (= (head r) (head x)) (= (head r) (head y)) ))))
16+
17+
(assert (forall ((x (List Int))(y (List Int))(r (List Int))(nx Int)(ny Int)(nr Int))
18+
(=> (and (Concat x y r) (= nx (_size x)) (= ny (_size y)) (= nr (_size r))) (= (+ nr 1) (+ nx ny)))))
19+
20+
(check-sat)

rsc/inactive/adt/list-synasc.smt2

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(set-logic HORN)
2+
3+
(declare-datatypes () (
4+
(IList Nil (Cons (head Int) (tail IList)) )
5+
))
6+
7+
(declare-fun Concat (IList IList IList) Bool)
8+
9+
(assert (forall ((y IList))
10+
(Concat Nil y y)))
11+
12+
(assert (forall ((x IList)(y IList)(r IList)(i Int))
13+
(=> (Concat x y r) (Concat (Cons i x) y (Cons i r)) )))
14+
15+
(assert (forall ((x IList)(y IList)(r IList))
16+
(=> (and (not (= r Nil)) (Concat x y r)) (or (= (head r) (head x)) (= (head r) (head y)) ))))
17+
18+
(assert (forall ((x IList)(y IList)(r IList)(nx Int)(ny Int)(nr Int))
19+
(=> (and (Concat x y r) (= nx (_size x)) (= ny (_size y)) (= nr (_size r))) (= (+ nr 1) (+ nx ny)))))
20+
21+
(check-sat)

rsc/inactive/adt/record-cex.smt2

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
(set-logic HORN)
2+
3+
(declare-datatypes () (
4+
(ArRec0 (new (dflt Int)) )
5+
) )
6+
7+
(define-fun storeRec0 ((new ArRec0) (old ArRec0) (ind Int) (val Int)) Bool
8+
(and (= val (dflt old)) (= old new))
9+
)
10+
(define-fun selectRec0 ((rec ArRec0) (ind Int)) Int
11+
(dflt rec)
12+
)
13+
14+
(declare-fun p0 ( Int ArRec0 ArRec0) Bool)
15+
(declare-fun p1 ( Int ArRec0 ArRec0 Int) Bool)
16+
(declare-fun p2 ( Int ArRec0 ArRec0 Int) Bool)
17+
(declare-fun p3 ( Int ArRec0 ArRec0 Int) Bool)
18+
(declare-fun p4 ( Int ArRec0 ArRec0 Int) Bool)
19+
(declare-fun p5 ( Int ArRec0 ArRec0) Bool)
20+
(declare-fun p6 ( Int ArRec0 ArRec0 Int) Bool)
21+
(declare-fun p7 ( Int ArRec0 ArRec0 Int) Bool)
22+
(declare-fun p8 ( Int ArRec0 ArRec0) Bool)
23+
24+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0))(=> (= n 1) (p0 n a1 a2))))
25+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (and (p0 n a1 a2) (= a 0)) (p1 n a1 a2 a))))
26+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (and (p1 n a1 a2 a) (<= a (- n 1))) (p2 n a1 a2 a))))
27+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int) (a1_p ArRec0))(=> (and (p2 n a1 a2 a) (storeRec0 a1_p a1 a 1)) (p3 n a1_p a2 a))))
28+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int) (a2_p ArRec0))(=> (and (p3 n a1 a2 a) (storeRec0 a2_p a2 a 1)) (p4 n a1 a2_p a))))
29+
30+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (p4 n a1 a2 a) (let ((ap (+ a 1))) (p1 n a1 a2 ap)))))
31+
32+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (and (p1 n a1 a2 a) (>= a n)) (p5 n a1 a2))))
33+
34+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (and (p5 n a1 a2) (= a 0)) (p6 n a1 a2 a))))
35+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (and (p6 n a1 a2 a) (<= a (- n 1))) (p7 n a1 a2 a))))
36+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (p7 n a1 a2 a) (not (= (selectRec0 a1 a) (selectRec0 a2 a))))))
37+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (and (p6 n a1 a2 a) (>= a n)) (p8 n a1 a2))))
38+
39+
(assert (forall ( (n Int) (a1 ArRec0) (a2 ArRec0) (a Int))(=> (p7 n a1 a2 a) (let ((ap (+ a 1))) (p6 n a1 a2 ap)))))
40+
41+
(check-sat)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(set-logic HORN)
2+
3+
(declare-datatypes () (
4+
(Pair (P (left Int) (right Bool)) )
5+
) )
6+
7+
(declare-fun I1 (Pair) Bool)
8+
(declare-fun I2 (Pair) Bool)
9+
10+
(assert (forall ((unused Bool)) (I1 (P 0 true))))
11+
(assert (forall ((p Pair))
12+
(=> (I1 p) (I2 (P (+ (left p) 1) (not (right p)))))))
13+
(assert (forall ((p Pair))
14+
(=> (I2 p) (I1 (P (* (left p) 2) (not (right p)))))))
15+
16+
(assert (forall ((p Pair))
17+
(=> (I1 p) (and (>= (left p) 0) (right p)))))
18+
19+
(check-sat)
20+
(get-model)

rsc/inactive/adt/sorted.smt2

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
(set-logic HORN)
2+
3+
(declare-datatypes () (
4+
(Lst nil (cons (head Int) (tail Lst)))
5+
) )
6+
7+
8+
; let rev =
9+
; let rec loop acc = function
10+
; | [] -> acc
11+
; | h :: t -> loop (h :: acc) t
12+
; in
13+
; loop []
14+
15+
; Post-condition.
16+
(declare-fun
17+
rev_pst ( Lst Lst Lst ) Bool
18+
)
19+
; Terminal case.
20+
(assert
21+
(forall ( (acc Lst) )
22+
(rev_pst acc nil acc)
23+
) )
24+
; Recursive case.
25+
(assert
26+
(forall ( (acc Lst) (lst Lst) (res Lst) )
27+
(=>
28+
(and
29+
(not (= lst nil))
30+
(rev_pst
31+
(cons (head lst) acc)
32+
(tail lst)
33+
res
34+
)
35+
)
36+
(rev_pst acc lst res)
37+
)
38+
) )
39+
40+
41+
; let rec sorted = function
42+
; | nil | _ :: nil => true
43+
; | h1 :: h2 :: t => (h1 < h2) and (sorted (h2 :: t))
44+
; (* STRICTLY sorted~~~~~^ *)
45+
46+
; Post-condition.
47+
(declare-fun
48+
srt_pst ( Lst Bool ) Bool
49+
)
50+
; Terminal cases.
51+
(assert
52+
(forall ( (unused Bool) )
53+
(srt_pst nil true)
54+
) )
55+
(assert
56+
(forall ( (hd Int) )
57+
(srt_pst (cons hd nil) true)
58+
) )
59+
(assert
60+
(forall ( (lst Lst) )
61+
(=>
62+
(and
63+
(not (= lst nil))
64+
(not (= (tail lst) nil))
65+
(not (< (head lst) (head (tail lst))))
66+
)
67+
(srt_pst lst false)
68+
)
69+
) )
70+
; Recursive case.
71+
(assert
72+
(forall ( (lst Lst) (res Bool) )
73+
(=>
74+
(and
75+
(not (= lst nil))
76+
(not (= (tail lst) nil))
77+
(< (head lst) (head (tail lst)))
78+
(srt_pst (tail lst) res)
79+
)
80+
(srt_pst lst res)
81+
)
82+
) )
83+
84+
85+
; let main lst =
86+
; if lst = (rev lst)
87+
; and (sorted lst)
88+
; and (sorted (rev lst))
89+
; then match lst
90+
; | nil | _ :: nil => ()
91+
; | _ => assert false
92+
(assert
93+
(forall ( (lst1 Lst) (lst2 Lst) )
94+
(=>
95+
(and
96+
(rev_pst nil lst1 lst2)
97+
(srt_pst lst1 true)
98+
(srt_pst lst2 true)
99+
(not (= lst1 nil))
100+
(not (= (tail lst1) nil))
101+
)
102+
false
103+
)
104+
) )
105+
106+
107+
(check-sat)
108+
(get-model)

0 commit comments

Comments
 (0)