Skip to content

Commit

Permalink
initial support for polymorphic ADTs
Browse files Browse the repository at this point in the history
  • Loading branch information
pruemmer committed Nov 8, 2021
1 parent 074084a commit 85c3a20
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions regression-tests/horn-adt/Answers
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ unsat
5: p1(Pair(2, 1), 4) -> 6
6: p1(Pair(1, 2), 5)

polymorphicTuple.smt2
sat
(define-fun p1 ((A (Pair Int Int)) (B Int)) Bool (and (and (>= (first A) 1) (<= (second A) 2)) (>= B 42)))

list-synasc-unsat.smt2
unsat
15 changes: 15 additions & 0 deletions regression-tests/horn-adt/polymorphicTuple.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

(set-logic HORN)

(declare-datatypes ( ( Pair 2 ) ) (
(par (S T) ( ( Pair ( first S ) ( second T ) )))))

(declare-fun p1 ((Pair Int Int) Int) Bool)

(assert (p1 (Pair 1 2) 42))
(assert (forall ((p (Pair Int Int)) (x Int))
(=> (p1 p x) (p1 (Pair (+ (first p) 1) (- (second p) 1)) (+ x 1)))))
(assert (forall ((p (Pair Int Int)) (x Int))
(=> (p1 p x) (> x 0))))

(check-sat)
3 changes: 2 additions & 1 deletion regression-tests/horn-adt/runtests
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ TESTS="simple-adt-horn.smt2 \
strings2-unsat.smt2 \
testers.smt2 \
tuple.smt2 \
tuple2.smt2"
tuple2.smt2 \
polymorphicTuple.smt2"

for name in $TESTS; do
echo
Expand Down
2 changes: 1 addition & 1 deletion src/lazabs/viewer/HornSMTPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object HornSMTPrinter {
}

def type2String(t: Type) : String = t match {
case AdtType(s) => s.name
case AdtType(s) => SMTLineariser.sort2SMTString(s)
case BooleanType() => "Bool"
case BVType(n) => "(_ BitVec " + n + ")"
case ArrayType(index, obj) => "(Array " + type2String(index) + " " + type2String(obj) + ")"
Expand Down

0 comments on commit 85c3a20

Please sign in to comment.