-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f306626
commit 2e2253b
Showing
10 changed files
with
314 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,5 @@ deps/CVC4/ | |
deps/ | ||
|
||
local/ | ||
.cache/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
#include "z3++.h" | ||
#include "datatype.h" | ||
#include "exceptions.h" | ||
|
||
namespace smt { | ||
|
||
class Z3DatatypeDecl : public AbsDatatypeDecl | ||
{ | ||
public: | ||
Z3DatatypeDecl(std::string name) : name(name){}; | ||
|
||
protected: | ||
friend class Z3Solver; | ||
std::string name; | ||
std::vector<DatatypeConstructorDecl> consvec {}; | ||
}; | ||
|
||
class Z3DatatypeConstructorDecl : public AbsDatatypeConstructorDecl | ||
{ | ||
public: | ||
Z3DatatypeConstructorDecl(z3::context & c, std::string name) | ||
: c(c), constructorname(name){}; | ||
bool compare(const DatatypeConstructorDecl &) const override; | ||
|
||
protected: | ||
friend class Z3Solver; | ||
|
||
z3::context & c; | ||
std::string constructorname, datatypename; | ||
std::vector<z3::symbol> fieldnames {}; | ||
std::vector<z3::sort> sorts {}; | ||
}; | ||
|
||
class Z3Datatype : public AbsDatatype | ||
{ | ||
public: | ||
Z3Datatype(z3::context & c, z3::sort s) : c(c), datatype(s) {} | ||
std::string get_name() const override { return datatype.name().str(); } | ||
int get_num_constructors() const override | ||
{ | ||
return Z3_get_datatype_sort_num_constructors(c, datatype); | ||
} | ||
int get_num_selectors(std::string name) const override | ||
{ | ||
for (size_t i = 0; i < get_num_constructors(); i++) | ||
{ | ||
z3::func_decl cons{ c, Z3_get_datatype_sort_constructor(c, datatype, i) }; | ||
if (cons.name().str() == name) return cons.arity(); | ||
} | ||
throw InternalSolverException(datatype.name().str() + "." + name | ||
+ " not found"); | ||
} | ||
|
||
private: | ||
z3::context & c; | ||
|
||
z3::sort datatype; | ||
friend class Z3Solver; | ||
}; | ||
|
||
} // namespace smt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "z3_datatype.h" | ||
|
||
namespace z3 { | ||
const bool operator==(const z3::sort & lhs, const z3::sort & rhs) | ||
{ | ||
return z3::eq(lhs, rhs); | ||
} | ||
const bool operator==(const z3::symbol & lhs, const z3::symbol & rhs) | ||
{ | ||
return lhs.str() == rhs.str(); | ||
} | ||
} // namespace z3 | ||
|
||
namespace smt { | ||
bool Z3DatatypeConstructorDecl::compare( | ||
const DatatypeConstructorDecl & other) const | ||
{ | ||
auto cast = std::static_pointer_cast<Z3DatatypeConstructorDecl>(other); | ||
return std::tie(constructorname, fieldnames, sorts) | ||
== std::tie(cast->constructorname, cast->fieldnames, cast->sorts); | ||
} | ||
|
||
} // namespace smt |
Oops, something went wrong.