Datatypes¶
You declare an algebraic datatype with DatatypeDecl and
DatatypeConstructorDecl, and the term manager turns the declaration into
a sort. Datatype, DatatypeConstructor, and DatatypeSelector describe
the result.
DatatypeDecl¶
A cvc5 datatype declaration. A datatype declaration is not itself a datatype (see Datatype), but a specification for creating a datatype sort.
The interface for a datatype declaration coincides with the syntax for
the SMT-LIB 2.6 command declare-datatype, or a single datatype within
the declare-datatypes command.
Datatype sorts can be constructed from DatatypeDecl using
the methods:
Solver.mkDatatypeSort()Solver.mkDatatypeSorts()
Wrapper class for DatatypeDecl.
7 of the 7 mirrored methods of DatatypeDecl are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
addConstructor |
Add a datatype constructor declaration. | auto | ✓ |
getNumConstructors |
Returns the number of constructors (so far) for this datatype declaration. | auto | ✓ |
isParametric |
Returns true if this datatype declaration is parametric. | auto | ✓ |
getName |
Returns the name of this datatype declaration. | auto | ✓ |
isNull |
Returns true if this DatatypeDecl is a null object. | rule | ✓ |
__str__ |
auto | ✓ | |
__repr__ |
auto | ✓ |
DatatypeDecl.addConstructor¶
Mojo declaration:
def addConstructor(self, ctor: DatatypeConstructorDecl) raises
Upstream Python signature:
DatatypeDecl.addConstructor(ctor: DatatypeConstructorDecl)
Add a datatype constructor declaration.
Parameters
ctor: The datatype constructor declaration to add.
Binding: Generated from cvc5_dt_decl_add_constructor.
DatatypeDecl.getNumConstructors¶
Mojo declaration:
def getNumConstructors(self) raises -> Int
Upstream Python signature:
DatatypeDecl.getNumConstructors()
Returns
The number of constructors (so far) for this datatype declaration.
Binding: Generated from cvc5_dt_decl_get_num_constructors.
DatatypeDecl.isParametric¶
Mojo declaration:
def isParametric(self) raises -> Bool
Upstream Python signature:
DatatypeDecl.isParametric()
Warning
This function is experimental and may change in future versions.
Returns
True if this datatype declaration is parametric.
Binding: Generated from cvc5_dt_decl_is_parametric.
DatatypeDecl.getName¶
Mojo declaration:
def getName(self) raises -> String
Upstream Python signature:
DatatypeDecl.getName()
Returns
The name of this datatype declaration.
Binding: Generated from cvc5_dt_decl_get_name.
DatatypeDecl.isNull¶
Mojo declaration:
def isNull(self) -> Bool
Upstream Python signature:
DatatypeDecl.isNull()
Returns
True if this DatatypeDecl is a null object.
Binding: Generated by a rule: a check for a NULL handle, which is how the C API represents a null object.
DatatypeDecl.__str__¶
Mojo declaration:
def toString(self) -> String
def write_to(self, mut writer: Some[Writer])
Upstream Python signature:
DatatypeDecl.__str__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_decl_to_string.
DatatypeDecl.__repr__¶
Mojo declaration:
Upstream Python signature:
DatatypeDecl.__repr__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_decl_to_string.
DatatypeConstructorDecl¶
A cvc5 datatype constructor declaration. A datatype constructor declaration is a specification used for creating a datatype constructor.
Wrapper class for DatatypeConstructorDecl.
6 of the 6 mirrored methods of DatatypeConstructorDecl are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
addSelector |
Add datatype selector declaration. | auto | ✓ |
addSelectorSelf |
Add datatype selector declaration whose codomain sort is the datatype itself. | auto | ✓ |
addSelectorUnresolved |
Add datatype selector declaration whose codomain sort is an unresolved datatype with the given name. | auto | ✓ |
isNull |
Returns true if this DatatypeConstructorDecl is a null object. | rule | ✓ |
__str__ |
auto | ✓ | |
__repr__ |
auto | ✓ |
DatatypeConstructorDecl.addSelector¶
Mojo declaration:
def addSelector(self, name: String, sort: Sort) raises
Upstream Python signature:
DatatypeConstructorDecl.addSelector(name: str, sort: Sort)
Add datatype selector declaration.
Parameters
name: The name of the datatype selector declaration to add.sort: The codomain sort of the datatype selector declaration to add.
Binding: Generated from cvc5_dt_cons_decl_add_selector.
DatatypeConstructorDecl.addSelectorSelf¶
Mojo declaration:
def addSelectorSelf(self, name: String) raises
Upstream Python signature:
DatatypeConstructorDecl.addSelectorSelf(name: str)
Add datatype selector declaration whose codomain sort is the datatype itself.
Parameters
name: The name of the datatype selector declaration to add.
Binding: Generated from cvc5_dt_cons_decl_add_selector_self.
DatatypeConstructorDecl.addSelectorUnresolved¶
Mojo declaration:
def addSelectorUnresolved(self, name: String, unresDatatypeName: String) raises
Upstream Python signature:
DatatypeConstructorDecl.addSelectorUnresolved(name: str, unresDatatypeName: str)
Add datatype selector declaration whose codomain sort is an unresolved datatype with the given name.
Parameters
name: The name of the datatype selector declaration to add.unresDataypeName: The name of the unresolved datatype. The codomain of the selector will be the resolved datatype with the given name.
Binding: Generated from cvc5_dt_cons_decl_add_selector_unresolved.
DatatypeConstructorDecl.isNull¶
Mojo declaration:
def isNull(self) -> Bool
Upstream Python signature:
DatatypeConstructorDecl.isNull()
Returns
True if this DatatypeConstructorDecl is a null object.
Binding: Generated by a rule: a check for a NULL handle, which is how the C API represents a null object.
DatatypeConstructorDecl.__str__¶
Mojo declaration:
def toString(self) -> String
def write_to(self, mut writer: Some[Writer])
Upstream Python signature:
DatatypeConstructorDecl.__str__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_cons_decl_to_string.
DatatypeConstructorDecl.__repr__¶
Mojo declaration:
Upstream Python signature:
DatatypeConstructorDecl.__repr__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_cons_decl_to_string.
Datatype¶
A cvc5 datatype.
Wrapper class for the C++ class Datatype.
16 of the 16 mirrored methods of Datatype are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
__getitem__ |
Get the datatype constructor with the given index, where index can be either a numeric id starting with zero, or the name of the constructor. | override | ✓ |
getConstructor |
Returns a constructor by name. | auto | ✓ |
getSelector |
Returns a selector by name. | auto | ✓ |
getName |
Returns the name of the datatype. | auto | ✓ |
getNumConstructors |
Returns the number of constructors in this datatype. | auto | ✓ |
getParameters |
Returns the parameters of this datatype, if it is parametric. | auto | ✓ |
isParametric |
Returns true if this datatype is parametric. | auto | ✓ |
isCodatatype |
Returns true if this datatype corresponds to a co-datatype. | auto | ✓ |
isTuple |
Returns true if this datatype corresponds to a tuple. | auto | ✓ |
isRecord |
Returns true if this datatype corresponds to a record. | auto | ✓ |
isFinite |
Returns true if this datatype is finite. | auto | ✓ |
isWellFounded |
Determine if this datatype is well-founded. | auto | ✓ |
isNull |
Returns true if this Datatype is a null object. | rule | ✓ |
__str__ |
auto | ✓ | |
__repr__ |
auto | ✓ | |
__iter__ |
Iterate over all constructors. | override | ✓ |
Datatype.__getitem__¶
Mojo declaration:
def __getitem__(self, index: Int) raises -> DatatypeConstructor
def __getitem__(self, index: IntLiteral) raises -> DatatypeConstructor
def __getitem__(self, index: String) raises -> DatatypeConstructor
Upstream Python signature:
Datatype.__getitem__(index)
Get the datatype constructor with the given index, where index can be either a numeric id starting with zero, or the name of the constructor. In the latter case, this is a linear search through the constructors, so in case of multiple, similarly-named constructors, the first is returned.
Parameters
index: The id or name of the datatype constructor.
Returns
The matching datatype constructor.
Binding: Bound to cvc5_dt_get_constructor, cvc5_dt_get_constructor_by_name by bindgen/overrides.toml.
Datatype.getConstructor¶
Mojo declaration:
def getConstructor(self, name: String) raises -> DatatypeConstructor
Upstream Python signature:
Datatype.getConstructor(name: str)
Parameters
name: The name of the constructor.
Returns
A constructor by name.
Binding: Generated from cvc5_dt_get_constructor_by_name.
Datatype.getSelector¶
Mojo declaration:
def getSelector(self, name: String) raises -> DatatypeSelector
Upstream Python signature:
Datatype.getSelector(name: str)
Parameters
name: The name of the selector..
Returns
A selector by name.
Binding: Generated from cvc5_dt_get_selector.
Datatype.getName¶
Mojo declaration:
def getName(self) raises -> String
Upstream Python signature:
Datatype.getName()
Returns
The name of the datatype.
Binding: Generated from cvc5_dt_get_name.
Datatype.getNumConstructors¶
Mojo declaration:
def getNumConstructors(self) raises -> Int
Upstream Python signature:
Datatype.getNumConstructors()
Returns
The number of constructors in this datatype.
Binding: Generated from cvc5_dt_get_num_constructors.
Datatype.getParameters¶
Mojo declaration:
def getParameters(self) raises -> List[Sort]
Upstream Python signature:
Datatype.getParameters()
Returns
The parameters of this datatype, if it is parametric. An exception is thrown if this datatype is not parametric.
Binding: Generated from cvc5_dt_get_parameters.
Datatype.isParametric¶
Mojo declaration:
def isParametric(self) raises -> Bool
Upstream Python signature:
Datatype.isParametric()
Warning
This function is experimental and may change in future versions.
Returns
True if this datatype is parametric.
Binding: Generated from cvc5_dt_is_parametric.
Datatype.isCodatatype¶
Mojo declaration:
def isCodatatype(self) raises -> Bool
Upstream Python signature:
Datatype.isCodatatype()
Returns
True if this datatype corresponds to a co-datatype.
Binding: Generated from cvc5_dt_is_codatatype.
Datatype.isTuple¶
Mojo declaration:
def isTuple(self) raises -> Bool
Upstream Python signature:
Datatype.isTuple()
Returns
True if this datatype corresponds to a tuple.
Binding: Generated from cvc5_dt_is_tuple.
Datatype.isRecord¶
Mojo declaration:
def isRecord(self) raises -> Bool
Upstream Python signature:
Datatype.isRecord()
Warning
This function is experimental and may change in future versions.
Returns
True if this datatype corresponds to a record.
Binding: Generated from cvc5_dt_is_record.
Datatype.isFinite¶
Mojo declaration:
def isFinite(self) raises -> Bool
Upstream Python signature:
Datatype.isFinite()
Returns
True if this datatype is finite.
Binding: Generated from cvc5_dt_is_finite.
Datatype.isWellFounded¶
Mojo declaration:
def isWellFounded(self) raises -> Bool
Upstream Python signature:
Datatype.isWellFounded()
Determine if this datatype is well-founded.
If this datatype is not a codatatype, this returns false if there are no values of this datatype that are of finite size.
Returns
True if this datatype is well-founded
Binding: Generated from cvc5_dt_is_well_founded.
Datatype.isNull¶
Mojo declaration:
def isNull(self) -> Bool
Upstream Python signature:
Datatype.isNull()
Returns
True if this Datatype is a null object.
Binding: Generated by a rule: a check for a NULL handle, which is how the C API represents a null object.
Datatype.__str__¶
Mojo declaration:
def toString(self) -> String
def write_to(self, mut writer: Some[Writer])
Upstream Python signature:
Datatype.__str__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_to_string.
Datatype.__repr__¶
Mojo declaration:
Upstream Python signature:
Datatype.__repr__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_to_string.
Datatype.__iter__¶
Mojo declaration:
def __iter__(self) raises -> OwnedIterator[DatatypeConstructor]
Upstream Python signature:
Datatype.__iter__()
Iterate over all constructors.
Binding: Bound to cvc5_dt_get_num_constructors, cvc5_dt_get_constructor by bindgen/overrides.toml.
DatatypeConstructor¶
A cvc5 datatype constructor.
Wrapper class for DatatypeConstructor.
11 of the 11 mirrored methods of DatatypeConstructor are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
__getitem__ |
Get the datatype selector with the given index, where index can be either a numeric id starting with zero, or the name of the selector. | override | ✓ |
getName |
Returns the name of the constructor. | auto | ✓ |
getTerm |
Get the constructor term of this datatype constructor. | auto | ✓ |
getInstantiatedTerm |
Get the constructor term of this datatype constructor whose return type is retSort. | auto | ✓ |
getTesterTerm |
Get the tester term of this datatype constructor. | auto | ✓ |
getNumSelectors |
Returns the number of selecters (so far) of this Datatype constructor. | auto | ✓ |
getSelector |
Returns the first datatype selector with the given name. | auto | ✓ |
isNull |
Returns true if this DatatypeConstructor is a null object. | rule | ✓ |
__str__ |
auto | ✓ | |
__repr__ |
auto | ✓ | |
__iter__ |
Iterate over all datatype selectors. | override | ✓ |
DatatypeConstructor.__getitem__¶
Mojo declaration:
def __getitem__(self, index: Int) raises -> DatatypeSelector
def __getitem__(self, index: IntLiteral) raises -> DatatypeSelector
def __getitem__(self, index: String) raises -> DatatypeSelector
Upstream Python signature:
DatatypeConstructor.__getitem__(index)
Get the datatype selector with the given index, where index can be either a numeric id starting with zero, or the name of the selector. In the latter case, this is a linear search through the selectors, so in case of multiple, similarly-named selectors, the first is returned.
Parameters
index: The id or name of the datatype selector.
Returns
The matching datatype selector.
Binding: Bound to cvc5_dt_cons_get_selector, cvc5_dt_cons_get_selector_by_name by bindgen/overrides.toml.
DatatypeConstructor.getName¶
Mojo declaration:
def getName(self) raises -> String
Upstream Python signature:
DatatypeConstructor.getName()
Returns
The name of the constructor.
Binding: Generated from cvc5_dt_cons_get_name.
DatatypeConstructor.getTerm¶
Mojo declaration:
def getTerm(self) raises -> Term
Upstream Python signature:
DatatypeConstructor.getTerm()
Get the constructor term of this datatype constructor.
Datatype constructors are a special class of function-like terms
whose sort is datatype constructor
(Sort.isDatatypeConstructor()). All datatype
constructors, including nullary ones, should be used as the first
argument to Terms whose kind is
APPLY_CONSTRUCTOR.
For example, the nil list can be constructed via
TermManager.mkTerm(APPLY_CONSTRUCTOR, [nil]), where nil is the
Term returned by this method.
Note
This function should not be used for parametric datatypes.
Instead, use the method
DatatypeConstructor.getInstantiatedTerm() below.
Returns
The constructor term.
Binding: Generated from cvc5_dt_cons_get_term.
DatatypeConstructor.getInstantiatedTerm¶
Mojo declaration:
def getInstantiatedTerm(self, retSort: Sort) raises -> Term
Upstream Python signature:
DatatypeConstructor.getInstantiatedTerm(retSort: Sort)
Get the constructor term of this datatype constructor whose return type is retSort. This function is intended to be used on constructors of parametric datatypes and can be seen as returning the constructor term that has been explicitly cast to the given sort.
This function is required for constructors of parametric datatypes whose return type cannot be determined by type inference. For example, given:
(declare-datatype List
(par (T) ((nil) (cons (head T) (tail (List T))))))
The type of nil terms must be provided by the user. In SMT version 2.6, this is done via the syntax for qualified identifiers:
(as nil (List Int))
This function is equivalent of applying the above, where this
DatatypeConstructor is the one corresponding to nil, and retSort is
(List Int).
Note
The returned constructor term t is used to construct the
above (nullary) application of nil with
TermManager.mkTerm(APPLY_CONSTRUCTOR, t).
Warning
This function is experimental and may change in future versions.
Parameters
retSort: The desired return sort of the constructor.
Returns
The constructor term.
Binding: Generated from cvc5_dt_cons_get_instantiated_term.
DatatypeConstructor.getTesterTerm¶
Mojo declaration:
def getTesterTerm(self) raises -> Term
Upstream Python signature:
DatatypeConstructor.getTesterTerm()
Get the tester term of this datatype constructor.
Similar to constructors, testers are a class of function-like terms
of tester sort (Sort.isDatatypeTester), and should
be used as the first argument of Terms of kind
Kind.APPLY_TESTER.
Returns
The tester term for this constructor.
Binding: Generated from cvc5_dt_cons_get_tester_term.
DatatypeConstructor.getNumSelectors¶
Mojo declaration:
def getNumSelectors(self) raises -> Int
Upstream Python signature:
DatatypeConstructor.getNumSelectors()
Returns
The number of selecters (so far) of this Datatype constructor.
Binding: Generated from cvc5_dt_cons_get_num_selectors.
DatatypeConstructor.getSelector¶
Mojo declaration:
def getSelector(self, name: String) raises -> DatatypeSelector
Upstream Python signature:
DatatypeConstructor.getSelector(name: str)
Parameters
name: The name of the datatype selector.
Returns
The first datatype selector with the given name.
Binding: Generated from cvc5_dt_cons_get_selector_by_name.
DatatypeConstructor.isNull¶
Mojo declaration:
def isNull(self) -> Bool
Upstream Python signature:
DatatypeConstructor.isNull()
Returns
True if this DatatypeConstructor is a null object.
Binding: Generated by a rule: a check for a NULL handle, which is how the C API represents a null object.
DatatypeConstructor.__str__¶
Mojo declaration:
def toString(self) -> String
def write_to(self, mut writer: Some[Writer])
Upstream Python signature:
DatatypeConstructor.__str__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_cons_to_string.
DatatypeConstructor.__repr__¶
Mojo declaration:
Upstream Python signature:
DatatypeConstructor.__repr__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_cons_to_string.
DatatypeConstructor.__iter__¶
Mojo declaration:
def __iter__(self) raises -> OwnedIterator[DatatypeSelector]
Upstream Python signature:
DatatypeConstructor.__iter__()
Iterate over all datatype selectors.
Binding: Bound to cvc5_dt_cons_get_num_selectors, cvc5_dt_cons_get_selector by bindgen/overrides.toml.
DatatypeSelector¶
A cvc5 datatype selector.
Wrapper class for DatatypeSelector.
7 of the 7 mirrored methods of DatatypeSelector are generated.
| Method | Summary | Binding | Mojo |
|---|---|---|---|
getName |
Returns the name of this datatype selector. | auto | ✓ |
getTerm |
Get the selector term of this datatype selector. | auto | ✓ |
getUpdaterTerm |
Get the updater term of this datatype selector. | auto | ✓ |
getCodomainSort |
Returns the codomain sort of this selector. | auto | ✓ |
isNull |
Returns true if this DatatypeSelector is a null object. | rule | ✓ |
__str__ |
auto | ✓ | |
__repr__ |
auto | ✓ |
DatatypeSelector.getName¶
Mojo declaration:
def getName(self) raises -> String
Upstream Python signature:
DatatypeSelector.getName()
Returns
The name of this datatype selector.
Binding: Generated from cvc5_dt_sel_get_name.
DatatypeSelector.getTerm¶
Mojo declaration:
def getTerm(self) raises -> Term
Upstream Python signature:
DatatypeSelector.getTerm()
Get the selector term of this datatype selector.
Selector terms are a class of function-like terms of selector
sort (Sort.isDatatypeSelector()), and should be used as
the first argument of Terms of kind
APPLY_SELECTOR.
Returns
The selector term of this datatype selector.
Binding: Generated from cvc5_dt_sel_get_term.
DatatypeSelector.getUpdaterTerm¶
Mojo declaration:
def getUpdaterTerm(self) raises -> Term
Upstream Python signature:
DatatypeSelector.getUpdaterTerm()
Get the updater term of this datatype selector.
Similar to selectors, updater terms are a class of function-like
terms of updater Sort (Sort.isDatatypeUpdater()), and
should be used as the first argument of Terms of kind
APPLY_UPDATER.
Returns
The updater term of this datatype selector.
Binding: Generated from cvc5_dt_sel_get_updater_term.
DatatypeSelector.getCodomainSort¶
Mojo declaration:
def getCodomainSort(self) raises -> Sort
Upstream Python signature:
DatatypeSelector.getCodomainSort()
Returns
The codomain sort of this selector.
Binding: Generated from cvc5_dt_sel_get_codomain_sort.
DatatypeSelector.isNull¶
Mojo declaration:
def isNull(self) -> Bool
Upstream Python signature:
DatatypeSelector.isNull()
Returns
True if this DatatypeSelector is a null object.
Binding: Generated by a rule: a check for a NULL handle, which is how the C API represents a null object.
DatatypeSelector.__str__¶
Mojo declaration:
def toString(self) -> String
def write_to(self, mut writer: Some[Writer])
Upstream Python signature:
DatatypeSelector.__str__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_sel_to_string.
DatatypeSelector.__repr__¶
Mojo declaration:
Upstream Python signature:
DatatypeSelector.__repr__()
Mojo uses the Writable protocol here: call String(value), repr(value), or print(value).
Binding: Generated from cvc5_dt_sel_to_string.