3.6. Supported Data
The built-in translator handles:
-
propositional and equality reasoning;
-
NatandIntarithmetic, including canonical divisibility; -
bitvectors with statically known widths, Booleans, strings (length, append, emptiness, and String-pattern prefix/suffix/containment), and supported inductive datatypes;
-
function values through defunctionalization, or native higher-order cvc5;
-
finite Lean arrays with logical length and SMT array data.
Nat uses SMT integers with nonnegativity constraints and guards preserving
natural subtraction and division semantics. A BitVec n whose width is not a
literal is refused; n > 0 alone does not give SMT a concrete bitvector width.
Dependent types are refused with the error cannot translate the dependent type.
This covers a type that depends on a value, such as Fin n, Fin 5 or BitVec k,
and a function type whose result type depends on its argument, such as
(n : Nat) → β n. An SMT sort cannot change with the value of a variable, so
translating these types could produce false proofs. Types that depend only on
other types, such as List α, are supported. So is DecidableEq α, which looks
dependent but has its own sound translation.
A structure or inductive whose field has such a type is not refused: it becomes
an opaque SMT sort, guarded unless it is known to be inhabited, so equality
reasoning about it still works but its fields are uninterpreted.
structure Wrap where val : Fin 5, Option (Fin 5) and Array (Fin 5) are
examples. The decision is made per query by translating the field sorts, so a
@[crush_translate_sort] handler for the field type makes the structure a
datatype again. A structure whose field type mentions an earlier field, such as
structure Sig where α : Type; x : α, is always opaque, because an SMT selector
has a single sort. The fallback is local: a structure with an opaque structure
as a field remains a datatype.
String and concrete-width bitvector operations use their SMT theories:
example (start suffix : String) :
start.length ≤ (start ++ suffix).length := start:Stringsuffix:String⊢ start.length ≤ (start ++ suffix).length
All goals completed! 🐙
example (x : BitVec 16) : x ^^^ x = 0 := x:BitVec 16⊢ x ^^^ x = 0
All goals completed! 🐙
Finite arrays support replicate, size, bounded/defaulting/optional indexing,
set, setIfInBounds, set!, push, pop, swap,
swapIfInBounds, isEmpty, back!, and back?.
Their read-over-write behavior is handled directly by SMT array theory:
example (xs : Array Int) (i : Nat) (value : Int)
(_hi : i < xs.size) :
(xs.set! i value)[i]! = value := xs:Array Inti:Natvalue:Int_hi:i < xs.size⊢ (xs.set! i value)[i]! = value
All goals completed! 🐙
example (xs : Array Int) (value : Int) :
(xs.push value).size = xs.size + 1 := xs:Array Intvalue:Int⊢ (xs.push value).size = xs.size + 1
All goals completed! 🐙
Operations that copy a symbolic range, such as append, extract, map, and
filter, generally require a lemma or a custom lowering because their exact
encoding is quantified element-by-element.