Performs AllSat over the important atoms of the conjunction of all formulas asserted in e (see msat_assert_formula). When used in incremental mode, a backtrack point should be pushed before calling this function, and popped after this call has completed. Not doing this changes the satisfiability of the formula. More...

Typedef Documentation

This callback function can be used to be notified about the models found by the AllSat algorithm. Such models contain the truth values of the important atoms, as specified with msat_all_sat. Each term in the model array is either an important atom or its negation, according to the truth value in the model. Notice that the model array is read-only, and will be valid only until the callback function returns. If the function returns zero, then the current search is aborted

The function accepts as input an array of integers representing the input problem in DIMACS format (with different clauses separated by a 0) and an array of group indices (positive integers, with index 0 reserved for the "background" group), and it must modify the array of groups in-place for storing the indices of the groups in the unsat core. The parameter size_in_out gives the number of clauses in the input cnf, and should be modified to store the number of groups in the computed core. The function should return a non-zero value to signal an error. See also http://www.satcompetition.org/2011/rules.pdf (MUS track)

This callback function gets called by the term visitor for each visited subterm. The preorder flag tells whether the function is called before or after visiting the subterms. The return value of this function determines how the visit should continue (see msat_visit_status)

Performs AllSat over the important atoms of the conjunction of all formulas asserted in e (see msat_assert_formula). When used in incremental mode, a backtrack point should be pushed before calling this function, and popped after this call has completed. Not doing this changes the satisfiability of the formula.

Parameters

e

The environment to use

important

An array of important atoms. If NULL, all atoms are considered important

num_important

The size of the important array. If important is NULL, set this to zero

Generic data pointer which will be passed to func. Can be anything, its value will not be interpreted

Returns

The number of models found, or -1 on error. If the solver detects that the formula is a tautology, -2 is returned. Note however that:

not all tautologies are detected by the solver. I.e., sometimes the solver will explicitly enumerate all the models of the formula even for tautologies

the number returned might be an over-approximation of the actual number of models. This can happen because the solver might sometimes report the same model more than once. In these cases, the callback function will be called multiple times with the same input.

int msat_annotated_list_from_smtlib2

(

msat_env

e,

const char *

data,

size_t *

out_n,

msat_term **

out_terms,

char ***

out_annots

)

Parses a list of annotated terms from a string in SMT-LIB v2 format.

Given a string in SMT-LIB v2 format, collect and return all and only the terms with an annotation.

Parameters

e

Then environment in which terms are created

data

The input string in SMT-LIBv2 format

out_n

On success, the number of terms is stored here. Must not be NULL. Notice that terms with multiple annotations are counted multiple times (see out_names below)

out_terms

On success, the parsed annotated terms are stored here. Must not be NULL. The array is dynamically allocated, and must be deallocated by the user with msat_free(). If a term contains multiple annotations, it will occur multiple times here (once for each annotation).

out_annots

On success, the annotations of the parsed terms are stored here. Must not be NULL. Both the array and its elements are dynamically allocated, and must be deallocated by the user with msat_free(). For each term at index i in out_terms, the corresponding annotation is stored as a key, value pair at indices 2*i and 2*i+1 in out_annots.

Given a FILE in SMT-LIB v2 format, collect and return all and only the terms with an annotation.

Parameters

e

Then environment in which terms are created

data

The input string in SMT-LIBv2 format

out_n

On success, the number of terms is stored here. Must not be NULL. Notice that terms with multiple annotations are counted multiple times (see out_names below)

out_terms

On success, the parsed annotated terms are stored here. Must not be NULL. The array is dynamically allocated, and must be deallocated by the user with msat_free(). If a term contains multiple annotations, it will occur multiple times here (once for each annotation).

out_annots

On success, the annotations of the parsed terms are stored here. Must not be NULL. Both the array and its elements are dynamically allocated, and must be deallocated by the user with msat_free(). For each term at index i in out_terms, the corresponding annotation is stored as a key, value pair at indices 2*i and 2*i+1 in out_annots.

Returns

zero on success, nonzero on error.

char* msat_annotated_list_to_smtlib2

(

msat_env

e,

size_t

n,

msat_term *

terms,

const char **

annots

)

Converts the given list of annotated terms to SMT-LIB v2 format.

Parameters

e

The environment in which the terms are defined

n

The number of terms to dump

terms

The terms to convert

annots

An array of annotations for the terms. For each term at index i in terms, the corresponding (key, value) annotation is stored at indices 2*i and 2*i+1 in annots. Terms with multiple annotations should be listed multiple times in terms (once for each annotation).

Returns

a string in SMT-LIB v2 format storing all the annotated input terms, or NULL in case of errors. If not NULL, the returned string must be deallocated by the user with msat_free().

An array of annotations for the terms. For each term at index i in terms, the corresponding (key, value) annotation is stored at indices 2*i and 2*i+1 in annots. Terms with multiple annotations should be listed multiple times in terms (once for each annotation).

When computing an interpolant, formulas are organized into several groups, which are partitioned into two sets GA and GB. The conjuction of formulas in GA will play the role of A, and that of formulas in GB will play the role of B (see msat_set_itp_group, msat_get_interpolant).

This function will perform garbage collection on the given environment. All the internal caches of the environment will be cleared (including those in the active solvers and preprocessors). If the environment is not shared, all the terms that are not either in tokeep or in the current asserted formulas will be deleted.

Parameters

env

The environment in which to operate.

tokeep

List of terms to not delete.

num_tokeep

Size of the tokeep array.

Returns

zero on success, nonzero on error.

msat_type msat_get_array_type

(

msat_env

env,

msat_type

itp,

msat_type

etp

)

returns the data type for arrays with indices of itp type and elements of etp type.

msat_term* msat_get_asserted_formulas

(

msat_env

e,

size_t *

num_asserted

)

Returns the list of formulas in the assertion stack.

The return value is a dynamically-allocated array of *num_asserted elements, which must be deallocated by the user. NULL is returned in case of errors. The array elements are formulas that are logically equivalent to the one asserted using msat_assert_formula

Parameters

e

The environment in which to operate.

num_asserted

Pointer to a valid address for storing the number of formulas currently in the assertion stack.

Returns

An array with the asserted formulas, or NULL in case of errors. The array is must be deallocated by allocated the user with msat_free().

msat_type msat_get_bool_type

(

msat_env

env

)

returns the data type for Booleans in the given env.

msat_type msat_get_bv_type

(

msat_env

env,

size_t

width

)

returns the data type for bit-vectors of the given width.

msat_type msat_get_fp_roundingmode_type

(

msat_env

env

)

returns the type for float rounding modes in the given env.

msat_type msat_get_fp_type

(

msat_env

env,

size_t

exp_width,

size_t

mant_width

)

returns the data type for floats with the given exponent and significand/mantissa width.

msat_type msat_get_function_type

(

msat_env

env,

msat_type *

param_types,

size_t

num_params,

msat_type

return_type

)

returns a function type in the given env.

Parameters

env

The environment in which to operate

param_types

The types of the function arguments

num_params

The arity of the function type

return_type

The type of the return value

Returns

a function type

msat_type msat_get_integer_type

(

msat_env

env

)

returns the data type for integers in the given env.

msat_term msat_get_interpolant

(

msat_env

e,

int *

groups_of_a,

size_t

n

)

Computes an interpolant for a pair (A, B) of formulas.

A is the conjucntion of all the assumed formulas in the groups_of_a groups (see msat_create_itp_group), and B is the rest of assumed formulas.

This function must be called only after msat_solve, and only if MSAT_UNSAT was returned. Moreover, interpolation must have been enabled in the configuration for the environment

The model value for term. If an error occurs, the return value ret is such that MSAT_ERROR_TERM(ret) is true

msat_proof msat_get_proof

(

msat_proof_manager

m

)

Returns a proof of unsatisfiability.

a proof is recursively defined as:

msat_proof ::= msat_term | name msat_proof*

i.e., it is either a term or a list of a name and children proofs. Proofs can be distinguished by their name, or by whether they are terms. Relevant proofs include:

"clause-hyp", which are the clauses of the (CNF conversion of the) input problem. They have a list of terms as children

"res-chain", representing Boolean resolution chains. The children are an interleaving of proofs and terms, where terms are the pivots for the resolution. For example: "res-chain p1 v p2" represents a resolution step between p1 and p2 on the pivot v

"theory-lemma", representing theory lemmas. They have as children a list of terms that consititute the lemma, plus an optional last element which is a more detailed proof produced by a theory solver.

The manager must be destroyed by the user, with msat_destroy_proof_manager. In order to obtain a non-error result, the option "proof_generation" must be set to "true" in the configuration used for creating the environment.

Parameters

e

The environment in which to operate.

Returns

A proof manager for the environment. MSAT_ERROR_PROOF_MANAGER can be used to check whether an error occurred.

msat_type msat_get_rational_type

(

msat_env

env

)

returns the data type for rationals in the given env.

char* msat_get_search_stats

(

msat_env

e

)

Returns a string with search statistics for the given environment.

The returned string will contain newline-separated statistics for the DPLL engine and the active theory solvers in the given environment.

Parameters

e

The environment in which to operate.

Returns

A string with search statistics, or NULL in case of errors. The string must be deallocated by the user with msat_free().

This is different from ::make_fp_to_bv in that the latter takes the integer part of the FP number and stores it in a bit-vector, while this function simply takes the bits of the representation of the input and interprets them as a bit-vector (of size 1+ width of exponent + width of mantissa).

Parameters

e

The environment of the definition

t

The argument to convert.

Returns

The term representing the conversion, or a t s.t. MSAT_ERROR_TERM(t) is true in case of errors.

Notice that the best thing to do is set options right after having created a configuration, before creating an environment with it. The library tries to capture and report errors, but it does not always succeed.

Parameters

cfg

The configuration in which to operate.

option

The name of the option to set.

value

The value for the option. For boolean options, use "true" or "false" (case matters). For flags, the value can be anything.

Checks the satisfiability of the conjunction of all the formulas asserted in e (see msat_assert_formula). Before calling this function, the right theory solvers must have been enabled (see ::msat_add_theory).

Parameters

e

The environment to check.

Returns

MSAT_SAT if the problem is satisfiable, MSAT_UNSAT if it is unsatisfiable, and MSAT_UNKNOWN if there was some error or if the satisfiability can't be determined.

Can only be called when model generation is on and proof generation is off.

Notice that this function changes the asserted formula in order to generate the diverse models, by adding clauses based on the diversifiers. When used in incremental mode a backtrack point should be pushed before calling this function, and popped after this call has completed. Not doing this changes the satisfiability of the formula.

Parameters

e

The environment to use

diversifiers

the terms over which to diversify. On each succesive model, at least one of these terms will have a different value.

Checks the satiafiability of the given environment under the given assumptions.

Checks the satisfiability of the conjunction of all the formulas asserted in e (see msat_assert_formula), plus the conjunction of the given assumptions, which can only be (negated) Boolean constants. If MSAT_UNSAT is returned, the function msat_get_unsat_assumptions() can be used to retrieve the list of assumptions responsible for the inconsistency.

Parameters

e

The environment to check.

assumptions

The list of assumptions. Can only be (negated) Boolean constants

num_assumptions

The number of assumptions.

Returns

MSAT_SAT if the problem is satisfiable, MSAT_UNSAT if it is unsatisfiable, and MSAT_UNKNOWN if there was some error or if the satisfiability can't be determined.

size_t msat_term_arity

(

msat_term

t

)

Returns the arity of t.

Parameters

t

A term.

Returns

The number of arguments of t

msat_term msat_term_get_arg

(

msat_term

t,

size_t

n

)

Returns the nth argument of t.

Parameters

t

A term.

n

The index of the argument. Must be lower than the arity of t

Returns

The nth argument of arguments of t

msat_decl msat_term_get_decl

(

msat_term

t

)

Returns the declaration associated to t (if any)

If t is not a constant or a function application, the returned value ret will be s.t. MSAT_ERROR_DECL(ret) is true

Parameters

t

The term for which to retrieve the declaration

Returns

If t is a constant, its declaration is returned; if it is an uif, the declaration of the function is returned; otherwise, a ret s.t. MSAT_ERROR_DECL(ret) is true is returned

msat_type msat_term_get_type

(

msat_term

t

)

Returns the type of t.

Parameters

t

A term.

Returns

The type of t

size_t msat_term_id

(

msat_term

t

)

Returns a numeric identifier for t.

The returned value is guaranteed to be unique within the environment in which t was defined. Therefore, it can be used to test two terms for equality, as well as a hash value.

Parameters

t

A term.

Returns

a unique (within the defining env) numeric identifier

int msat_term_is_and

(

msat_env

e,

msat_term

t

)

Checks whether t is an AND.

Parameters

t

A term.

Returns

nonzero if t is an AND

int msat_term_is_array_const

(

msat_env

e,

msat_term

t

)

Checks whether t is a constant array.

Parameters

e

The environment in which to operate

t

A term.

Returns

nonzero if t is a constant array

int msat_term_is_array_read

(

msat_env

e,

msat_term

t

)

Checks whether t is an array read.

Parameters

e

The environment in which to operate

t

A term.

Returns

nonzero if t is an array read

int msat_term_is_array_write

(

msat_env

e,

msat_term

t

)

Checks whether t is an array write.

Parameters

e

The environment in which to operate

t

A term.

Returns

nonzero if t is an array write

int msat_term_is_asin

(

msat_env

e,

msat_term

t

)

Checks whether t is a (asin t1) expression.

Parameters

e

The environment in which to operate

t

A term.

Returns

nonzero if t is a asin expression

int msat_term_is_atom

(

msat_env

e,

msat_term

t

)

Checks whether t is an atom.

Parameters

t

A term.

Returns

nonzero if t is an atom, i.e. either a boolean constant or a relation between terms

Checks the satisfiability (possibly under assumptions) of the list of added clauses.

Parameters

self

Pointer to the SAT solver.

assumptions

array of literals in DIMACS format, terminated by 0.

out_conflicting_assumptions

if the problem is unsatisfiable, this pointer should be set to a (zero-terminated) list of the assumptions responsible for the unsatisfiability. The solver should use its own internal storage for the array.