Difference between revisions of "Datatypes"
Line 1: | Line 1: | ||
+ | =Finite Relations= | ||
+ | |||
+ | {| class="wikitable" cellpadding="5" border="0" style="border-collapse:collapse" | ||
+ | |- | ||
+ | ! | ||
+ | ! CVC language | ||
+ | ! SMTLIB language | ||
+ | ! C++ API | ||
+ | |- | ||
+ | | Logic string | ||
+ | | Not needed | ||
+ | | <code>(set-logic QF_'''DT''')</code> | ||
+ | | <code>smt.setLogic("QF_'''DT'''");</code> | ||
+ | |- | ||
+ | | Tuple Sort | ||
+ | | [<Sort_1>, ..., <Sort_n>] | ||
+ | | (Tuple <Sort_1>, ..., <Sort_n>) | ||
+ | | CVC4::ExprManager::mkTupleType(std::vector<CVC4::Type>& types) | ||
+ | |- | ||
+ | | | ||
+ | | <code>t: '''[INT, INT]''';</code> | ||
+ | | <code> (declare-fun t () '''(Tuple Int Int)''') </code> | ||
+ | | <code>em.'''mkTupleType'''( em.integerType(), em.integerType() );</code> | ||
+ | |- | ||
+ | | Tuple constructor | ||
+ | | <code>'''(t1, ..., tn)'''</code> | ||
+ | | <code>('''mkTuple''' t1, ..., tn)</code> | ||
+ | | <code>DatatypeType tt = em.mkTupleType(types);</code> | ||
+ | <code>const Datatype& dt = tt.getDatatype();</code><br> | ||
+ | <code>Expr c = dt[0].getConstructor();</code><br> | ||
+ | <code>em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);</code> | ||
+ | |- | ||
+ | | Tuple selector | ||
+ | | <code>'''t.i'''</code> | ||
+ | | <code>('''(_ tupSel i)''' t)</code> | ||
+ | | <code>DatatypeType tt = em.mkTupleType(types);</code> | ||
+ | <code>const Datatype& dt = tt.getDatatype();</code><br> | ||
+ | <code>Expr s = dt[0][i].getSelector();</code><br> | ||
+ | <code>em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);</code> | ||
+ | |- | ||
+ | | Record Sort | ||
+ | | [# f1:<Sort_1>, ..., fn:<Sort_n> #] | ||
+ | | n/a | ||
+ | | CVC4::ExprManager::mkRecordType(const Record& r) | ||
+ | |- | ||
+ | | | ||
+ | | <code>t: '''[#''' f1:'''INT''', f2:'''INT]''';</code> | ||
+ | | | ||
+ | | <code>em.'''mkRecordType'''( em.integerType(), em.integerType() );</code> | ||
+ | |- | ||
+ | | Record constructor | ||
+ | | <code>'''(# f1 := t1, ..., fn := tn #)'''</code> | ||
+ | | n/a | ||
+ | | <code>std::vector< std::pair<std::string, Type> > vec;</code> | ||
+ | <code>...</code> | ||
+ | <code>Record r(vec);</code> | ||
+ | <code>DatatypeType tt = em.mkRecordType(r);</code> | ||
+ | <code>const Datatype& dt = tt.getDatatype();</code><br> | ||
+ | <code>Expr c = dt[0].getConstructor();</code><br> | ||
+ | <code>em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);</code> | ||
+ | |- | ||
+ | | Record selector | ||
+ | | <code>'''t.i'''</code> | ||
+ | | n/a | ||
+ | | <code>std::vector< std::pair<std::string, Type> > vec;</code> | ||
+ | <code>...</code> | ||
+ | <code>Record r(vec);</code> | ||
+ | <code>DatatypeType tt = em.mkRecordType(r);</code> | ||
+ | <code>const Datatype& dt = tt.getDatatype();</code><br> | ||
+ | <code>Expr s = dt[0][i].getSelector();</code><br> | ||
+ | <code>em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);</code> | ||
+ | |- | ||
+ | |||
=Logic= | =Logic= | ||
To enable CVC4's decision procedure for datatypes, include "DT" in the logic: | To enable CVC4's decision procedure for datatypes, include "DT" in the logic: |
Revision as of 05:44, 8 May 2018
Contents
Finite Relations
CVC language | SMTLIB language | C++ API | |
---|---|---|---|
Logic string | Not needed | (set-logic QF_DT)
|
smt.setLogic("QF_DT");
|
Tuple Sort | [<Sort_1>, ..., <Sort_n>] | (Tuple <Sort_1>, ..., <Sort_n>) | CVC4::ExprManager::mkTupleType(std::vector<CVC4::Type>& types) |
t: [INT, INT];
|
(declare-fun t () (Tuple Int Int))
|
em.mkTupleType( em.integerType(), em.integerType() );
| |
Tuple constructor | (t1, ..., tn)
|
(mkTuple t1, ..., tn)
|
DatatypeType tt = em.mkTupleType(types);
|
Tuple selector | t.i
|
((_ tupSel i) t)
|
DatatypeType tt = em.mkTupleType(types);
|
Record Sort | [# f1:<Sort_1>, ..., fn:<Sort_n> #] | n/a | CVC4::ExprManager::mkRecordType(const Record& r) |
t: [# f1:INT, f2:INT];
|
em.mkRecordType( em.integerType(), em.integerType() );
| ||
Record constructor | (# f1 := t1, ..., fn := tn #)
|
n/a | std::vector< std::pair<std::string, Type> > vec;
|
Record selector | t.i
|
n/a | std::vector< std::pair<std::string, Type> > vec;
|