Zee3.StdLib (zee3 v0.3.0)

Copy Markdown

Defines the functions and macros which are available inside the body of the Zee3.program/2 macro.

The functions of this module are all pure in the sense that they don't mutate the state of the solver. All the functions (but not necessarily the macros) return a Zee3.Smt2 term which will be handled correctly by the stateful special forms inside the program. The result of these functions can always be serialized into syntactically correct SMT-LIB2 code, which can be sent directly to the Z3 solver using the low-level API.

Summary

Functions

Multiplication (compiles to variadic chain if possible).

Addition (compiles to variadic chain if possible).

Unary arithmetic negation.

Binary/variadic subtraction.

Division (compiles to variadic chain if possible).

Check that two terms are distinct.

Less than (compiles to variadic chain if possible).

Less than or equal (compiles to variadic chain if possible).

Check that two terms are equal.

Greater than (compiles to variadic chain if possible).

Greater than or equal (compiles to variadic chain if possible).

Absolute value.

Checks that all the arguments are distinct.

Check if all the arguments are equal.

Logical AND (compiles to variadic chain if possible).

Addition.

Bitwise AND.

Arithmetic shift right.

Bit vector comparison.

Logical shift right.

Multiplication.

Bitwise NAND.

Two's complement negation.

Bitwise NOR.

Bitwise NOT.

Bitwise OR.

Signed division.

Signed greater than or equal.

Signed greater than.

Logical shift left.

Signed less than or equal.

Signed less than.

Signed modulo.

Signed remainder.

Subtraction.

Unsigned division.

Unsigned greater than or equal.

Unsigned greater than.

Unsigned less than or equal.

Unsigned less than.

Unsigned remainder.

Bitwise XNOR.

Bitwise XOR.

Concatenate two bitvectors.

Mutually distinct (variadic).

Euclidean integer division.

Extract sub-vector (indices passed in symbol).

Floating point constructor from BVs.

Absolute value.

Addition (requires rounding mode).

Division (requires rounding mode).

Equality.

Fused multiply-add (requires rounding mode).

Greater than or equal.

Greater than.

Is infinite.

Is Not a Number.

Is negative.

Is normal.

Is positive.

Is subnormal.

Is zero.

Less than or equal.

Less than.

Maximum.

Minimum.

Multiplication (requires rounding mode).

Negation.

Remainder.

Round to integral (requires rounding mode).

Square root (requires rounding mode).

Subtraction (requires rounding mode).

Convert to real.

Convert to signed bitvector (requires rounding mode).

Convert to unsigned bitvector (requires rounding mode).

A reimplementation of the Kernel.if/2 macro that raises an error if one tries to pick a branch based on a Zee3.Smt2 value.

Convert integer to string.

Check if real is an integer.

If-then-else conditional.

Euclidean integer remainder.

Logical negation.

Logical OR (variadic).

Multiply the arguments.

Regex language of all strings.

Regex matching any single character.

Regex complement.

Regex concatenation (variadic).

Regex intersection (variadic).

Kleene plus.

Kleene star.

Empty regex language.

Optional regex.

Character range.

Regex union (variadic).

Read value from array at index.

Write value to array at index.

String concatenation (variadic).

Lexicographical less than.

Lexicographical less than or equal.

Check if string contains substring.

Check if string matches regex.

Find index of substring after offset.

String length.

Check if string is prefix.

Replace first occurrence.

Replace all occurrences.

Replace first regex match.

Replace all regex matches.

Extract substring (string, offset, length).

Check if string is suffix.

Convert string to integer.

Convert string to regex.

Sum the arguments.

Convert to float (requires rounding mode).

Convert unsigned BV to float.

Cast real to integer.

Cast integer to real.

Logical exclusive OR (variadic).

Functions

lhs * rhs

Multiplication (compiles to variadic chain if possible).

Theories: Ints, Reals.

lhs + rhs

Addition (compiles to variadic chain if possible).

Theories: Ints, Reals.

-arg

Unary arithmetic negation.

Theories: Ints, Reals.

lhs - rhs

Binary/variadic subtraction.

Theories: Ints, Reals.

lhs / rhs

Division (compiles to variadic chain if possible).

Theories: Reals.

a != b

Check that two terms are distinct.

lhs < rhs

Less than (compiles to variadic chain if possible).

Theories: Ints, Reals.

lhs <= rhs

Less than or equal (compiles to variadic chain if possible).

Theories: Ints, Reals.

a == b

Check that two terms are equal.

lhs > rhs

Greater than (compiles to variadic chain if possible).

Theories: Ints, Reals.

lhs >= rhs

Greater than or equal (compiles to variadic chain if possible).

Theories: Ints, Reals.

abs(arg)

@spec abs(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Absolute value.

Theories: Ints.

all_distinct(args)

@spec all_distinct([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Checks that all the arguments are distinct.

all_equal(args)

@spec all_equal([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Check if all the arguments are equal.

lhs and rhs

Logical AND (compiles to variadic chain if possible).

Theories: Core.

bvadd(lhs, rhs)

Addition.

Theories: FixedSizeBitVectors.

bvand(lhs, rhs)

Bitwise AND.

Theories: FixedSizeBitVectors.

bvashr(lhs, rhs)

Arithmetic shift right.

Theories: FixedSizeBitVectors.

bvcomp(lhs, rhs)

Bit vector comparison.

Theories: FixedSizeBitVectors.

bvlshr(lhs, rhs)

Logical shift right.

Theories: FixedSizeBitVectors.

bvmul(lhs, rhs)

Multiplication.

Theories: FixedSizeBitVectors.

bvnand(lhs, rhs)

Bitwise NAND.

Theories: FixedSizeBitVectors.

bvneg(arg)

@spec bvneg(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Two's complement negation.

Theories: FixedSizeBitVectors.

bvnor(lhs, rhs)

Bitwise NOR.

Theories: FixedSizeBitVectors.

bvnot(arg)

@spec bvnot(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Bitwise NOT.

Theories: FixedSizeBitVectors.

bvor(lhs, rhs)

Bitwise OR.

Theories: FixedSizeBitVectors.

bvsdiv(lhs, rhs)

Signed division.

Theories: FixedSizeBitVectors.

bvsge(lhs, rhs)

Signed greater than or equal.

Theories: FixedSizeBitVectors.

bvsgt(lhs, rhs)

Signed greater than.

Theories: FixedSizeBitVectors.

bvshl(lhs, rhs)

Logical shift left.

Theories: FixedSizeBitVectors.

bvsle(lhs, rhs)

Signed less than or equal.

Theories: FixedSizeBitVectors.

bvslt(lhs, rhs)

Signed less than.

Theories: FixedSizeBitVectors.

bvsmod(lhs, rhs)

Signed modulo.

Theories: FixedSizeBitVectors.

bvsrem(lhs, rhs)

Signed remainder.

Theories: FixedSizeBitVectors.

bvsub(lhs, rhs)

Subtraction.

Theories: FixedSizeBitVectors.

bvudiv(lhs, rhs)

Unsigned division.

Theories: FixedSizeBitVectors.

bvuge(lhs, rhs)

Unsigned greater than or equal.

Theories: FixedSizeBitVectors.

bvugt(lhs, rhs)

Unsigned greater than.

Theories: FixedSizeBitVectors.

bvule(lhs, rhs)

Unsigned less than or equal.

Theories: FixedSizeBitVectors.

bvult(lhs, rhs)

Unsigned less than.

Theories: FixedSizeBitVectors.

bvurem(lhs, rhs)

Unsigned remainder.

Theories: FixedSizeBitVectors.

bvxnor(lhs, rhs)

Bitwise XNOR.

Theories: FixedSizeBitVectors.

bvxor(lhs, rhs)

Bitwise XOR.

Theories: FixedSizeBitVectors.

concat(lhs, rhs)

Concatenate two bitvectors.

Theories: FixedSizeBitVectors.

distinct(args)

@spec distinct([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Mutually distinct (variadic).

Theories: Core.

div(lhs, rhs)

Euclidean integer division.

Theories: Ints.

extract(arg)

@spec extract(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Extract sub-vector (indices passed in symbol).

Theories: FixedSizeBitVectors.

fp(a, b, c)

Floating point constructor from BVs.

Theories: FloatingPoint.

fp_abs(arg)

@spec fp_abs(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Absolute value.

Theories: FloatingPoint.

fp_add(a, b, c)

Addition (requires rounding mode).

Theories: FloatingPoint.

fp_div(a, b, c)

Division (requires rounding mode).

Theories: FloatingPoint.

fp_eq(lhs, rhs)

Equality.

Theories: FloatingPoint.

fp_fma(a, b, c, d)

Fused multiply-add (requires rounding mode).

Theories: FloatingPoint.

fp_geq(lhs, rhs)

Greater than or equal.

Theories: FloatingPoint.

fp_gt(lhs, rhs)

Greater than.

Theories: FloatingPoint.

fp_isInfinite(arg)

@spec fp_isInfinite(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is infinite.

Theories: FloatingPoint.

fp_isNaN(arg)

@spec fp_isNaN(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is Not a Number.

Theories: FloatingPoint.

fp_isNegative(arg)

@spec fp_isNegative(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is negative.

Theories: FloatingPoint.

fp_isNormal(arg)

@spec fp_isNormal(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is normal.

Theories: FloatingPoint.

fp_isPositive(arg)

@spec fp_isPositive(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is positive.

Theories: FloatingPoint.

fp_isSubnormal(arg)

@spec fp_isSubnormal(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is subnormal.

Theories: FloatingPoint.

fp_isZero(arg)

@spec fp_isZero(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Is zero.

Theories: FloatingPoint.

fp_leq(lhs, rhs)

Less than or equal.

Theories: FloatingPoint.

fp_lt(lhs, rhs)

Less than.

Theories: FloatingPoint.

fp_max(lhs, rhs)

Maximum.

Theories: FloatingPoint.

fp_min(lhs, rhs)

Minimum.

Theories: FloatingPoint.

fp_mul(a, b, c)

Multiplication (requires rounding mode).

Theories: FloatingPoint.

fp_neg(arg)

@spec fp_neg(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Negation.

Theories: FloatingPoint.

fp_rem(lhs, rhs)

Remainder.

Theories: FloatingPoint.

fp_roundToIntegral(lhs, rhs)

@spec fp_roundToIntegral(Zee3.Smt2.smt2_like(), Zee3.Smt2.smt2_like()) ::
  Zee3.Smt2.t()

Round to integral (requires rounding mode).

Theories: FloatingPoint.

fp_sqrt(lhs, rhs)

Square root (requires rounding mode).

Theories: FloatingPoint.

fp_sub(a, b, c)

Subtraction (requires rounding mode).

Theories: FloatingPoint.

fp_to_real(arg)

@spec fp_to_real(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Convert to real.

Theories: FloatingPoint.

fp_to_sbv(lhs, rhs)

Convert to signed bitvector (requires rounding mode).

Theories: FloatingPoint.

fp_to_ubv(lhs, rhs)

Convert to unsigned bitvector (requires rounding mode).

Theories: FloatingPoint.

if(condition, branches)

(macro)

A reimplementation of the Kernel.if/2 macro that raises an error if one tries to pick a branch based on a Zee3.Smt2 value.

If you're trying to pick a branch based on a Zee3.Smt2 value, you're probably making a mistake because all Zee3.Smt2 terms are considered true by the normal Kernel.if/2 macro.

If you want to pick a branch based on a condition inside Z3, you want to use the ite/3 function instead.

This macro is automatically imported inside the body of the Zee3.program do ... end macro. Apart from raising an error on Zee3.Smt2 terms, it behaves exactly as the Kernel.if/2 macro.

int_to_str(arg)

@spec int_to_str(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Convert integer to string.

Theories: Strings.

is_int(arg)

@spec is_int(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Check if real is an integer.

Theories: Reals_Ints.

ite(a, b, c)

If-then-else conditional.

Theories: Core.

mod(lhs, rhs)

Euclidean integer remainder.

Theories: Ints.

not arg

@spec not Zee3.Smt2.smt2_like() :: Zee3.Smt2.t()

Logical negation.

Theories: Core.

or(args)

@spec or([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Logical OR (variadic).

Theories: Core.

product(args)

@spec product([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Multiply the arguments.

re_all()

Regex language of all strings.

Theories: Strings.

re_allchar()

Regex matching any single character.

Theories: Strings.

re_comp(arg)

@spec re_comp(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Regex complement.

Theories: Strings.

re_concat(args)

@spec re_concat([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Regex concatenation (variadic).

Theories: Strings.

re_inter(args)

@spec re_inter([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Regex intersection (variadic).

Theories: Strings.

re_kleene_plus(arg)

@spec re_kleene_plus(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Kleene plus.

Theories: Strings.

re_kleene_star(arg)

@spec re_kleene_star(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Kleene star.

Theories: Strings.

re_none()

Empty regex language.

Theories: Strings.

re_opt(arg)

@spec re_opt(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Optional regex.

Theories: Strings.

re_range(lhs, rhs)

Character range.

Theories: Strings.

re_union(args)

@spec re_union([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Regex union (variadic).

Theories: Strings.

select(lhs, rhs)

Read value from array at index.

Theories: ArraysEx.

store(a, b, c)

Write value to array at index.

Theories: ArraysEx.

str_++(args)

@spec str_ ++ [Zee3.Smt2.smt2_like()] :: Zee3.Smt2.t()

String concatenation (variadic).

Theories: Strings.

str_<(lhs, rhs)

Lexicographical less than.

Theories: Strings.

str_<=(lhs, rhs)

Lexicographical less than or equal.

Theories: Strings.

str_contains(lhs, rhs)

@spec str_contains(Zee3.Smt2.smt2_like(), Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Check if string contains substring.

Theories: Strings.

str_in_re(lhs, rhs)

Check if string matches regex.

Theories: Strings.

str_indexof(a, b, c)

Find index of substring after offset.

Theories: Strings.

str_len(arg)

@spec str_len(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

String length.

Theories: Strings.

str_prefixof(lhs, rhs)

@spec str_prefixof(Zee3.Smt2.smt2_like(), Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Check if string is prefix.

Theories: Strings.

str_replace(a, b, c)

Replace first occurrence.

Theories: Strings.

str_replace_all(a, b, c)

Replace all occurrences.

Theories: Strings.

str_replace_re(a, b, c)

Replace first regex match.

Theories: Strings.

str_replace_re_all(a, b, c)

@spec str_replace_re_all(
  Zee3.Smt2.smt2_like(),
  Zee3.Smt2.smt2_like(),
  Zee3.Smt2.smt2_like()
) ::
  Zee3.Smt2.t()

Replace all regex matches.

Theories: Strings.

str_substr(a, b, c)

Extract substring (string, offset, length).

Theories: Strings.

str_suffixof(lhs, rhs)

@spec str_suffixof(Zee3.Smt2.smt2_like(), Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Check if string is suffix.

Theories: Strings.

str_to_int(arg)

@spec str_to_int(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Convert string to integer.

Theories: Strings.

str_to_re(arg)

@spec str_to_re(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Convert string to regex.

Theories: Strings.

sum(args)

@spec sum([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Sum the arguments.

to_fp(lhs, rhs)

Convert to float (requires rounding mode).

Theories: FloatingPoint.

to_fp_unsigned(lhs, rhs)

@spec to_fp_unsigned(Zee3.Smt2.smt2_like(), Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Convert unsigned BV to float.

Theories: FloatingPoint.

to_int(arg)

@spec to_int(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Cast real to integer.

Theories: Reals_Ints.

to_real(arg)

@spec to_real(Zee3.Smt2.smt2_like()) :: Zee3.Smt2.t()

Cast integer to real.

Theories: Reals_Ints.

xor(args)

@spec xor([Zee3.Smt2.smt2_like()]) :: Zee3.Smt2.t()

Logical exclusive OR (variadic).

Theories: Core.