summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAina Niemetz <aina.niemetz@gmail.com>2021-06-09 13:44:13 -0700
committerGitHub <noreply@github.com>2021-06-09 20:44:13 +0000
commit226244a0bdb68655c06d6d1b55b31be013bf7fa6 (patch)
treead19605834d8d30fd086581814c611d87c22df7a /examples
parent6017579ab78cbc1390274290736ef311208a251b (diff)
docs: Migrate sets and relations theory reference. (#6698)
This migrates page https://cvc4.github.io/sets-and-relations. It further adds the SMT2 version of examples/api/cpp/sets.cpp and adds test/regress/regress0/rels/relations-ops.smt2 as smtlib example for relations.
Diffstat (limited to 'examples')
-rw-r--r--examples/api/cpp/sets.cpp2
-rw-r--r--examples/api/smtlib/relations.smt241
-rw-r--r--examples/api/smtlib/sets.smt234
3 files changed, 76 insertions, 1 deletions
diff --git a/examples/api/cpp/sets.cpp b/examples/api/cpp/sets.cpp
index 5c9652707..c1eded4a4 100644
--- a/examples/api/cpp/sets.cpp
+++ b/examples/api/cpp/sets.cpp
@@ -10,7 +10,7 @@
* directory for licensing information.
* ****************************************************************************
*
- * A simple demonstration of reasoning about sets with CVC4.
+ * A simple demonstration of reasoning about sets with cvc5.
*/
#include <cvc5/cvc5.h>
diff --git a/examples/api/smtlib/relations.smt2 b/examples/api/smtlib/relations.smt2
new file mode 100644
index 000000000..11801a868
--- /dev/null
+++ b/examples/api/smtlib/relations.smt2
@@ -0,0 +1,41 @@
+(set-logic ALL)
+(set-info :status sat)
+
+(declare-fun r1 () (Set (Tuple String Int)))
+(declare-fun r2 () (Set (Tuple Int String)))
+(declare-fun r () (Set (Tuple String String)))
+(declare-fun s () (Set (Tuple String String)))
+(declare-fun t () (Set (Tuple String Int Int String)))
+(declare-fun lt1 () (Set (Tuple Int Int)))
+(declare-fun lt2 () (Set (Tuple Int Int)))
+(declare-fun i () Int)
+
+(assert
+ (= r1
+ (insert
+ (mkTuple "a" 1)
+ (mkTuple "b" 2)
+ (mkTuple "c" 3)
+ (singleton (mkTuple "d" 4)))))
+(assert
+ (= r2
+ (insert
+ (mkTuple 1 "1")
+ (mkTuple 2 "2")
+ (mkTuple 3 "3")
+ (singleton (mkTuple 17 "17")))))
+(assert (= r (join r1 r2)))
+(assert (= s (transpose r)))
+(assert (= t (product r1 r2)))
+(assert
+ (=
+ lt1
+ (insert
+ (mkTuple 1 2)
+ (mkTuple 2 3)
+ (mkTuple 3 4)
+ (singleton (mkTuple 4 5)))))
+(assert (= lt2 (tclosure lt1)))
+(assert (= i (card t)))
+
+(check-sat)
diff --git a/examples/api/smtlib/sets.smt2 b/examples/api/smtlib/sets.smt2
new file mode 100644
index 000000000..437c285e2
--- /dev/null
+++ b/examples/api/smtlib/sets.smt2
@@ -0,0 +1,34 @@
+(set-logic QF_UFLIAFS)
+(set-option :produce-models true)
+(set-option :incremental true)
+(declare-const A (Set Int))
+(declare-const B (Set Int))
+(declare-const C (Set Int))
+(declare-const x Int)
+
+; Verify union distributions over intersection
+(check-sat-assuming
+ (
+ (distinct
+ (intersection (union A B) C)
+ (union (intersection A C) (intersection B C)))
+ )
+)
+
+; Verify emptset is a subset of any set
+(check-sat-assuming
+ (
+ (not (subset (as emptyset (Set Int)) A))
+ )
+)
+
+; Find an element in {1, 2} intersection {2, 3}, if there is one.
+(check-sat-assuming
+ (
+ (member
+ x
+ (intersection
+ (union (singleton 1) (singleton 2))
+ (union (singleton 2) (singleton 3))))
+ )
+)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback