lean-crush

5.3. Direct Symbol Mappings🔗

crush_map recursively translates the arguments and applies an existing SMT symbol:

def addInt (x y : Int) : Int := x + y crush_map addInt => "+" example (x y : Int) : addInt x y = y + x := x:Inty:Int⊢ addInt x y = y + x All goals completed! 🐙

This command is appropriate only when every elaborated application of the Lean constant has the same SMT meaning. It provides no argument-shape or typeclass-instance guard. Use register_lowering term for structural argument and type checks, or a full @[crush_lower] handler for overloaded operations and dynamic guards.

crush_map_sort maps a Lean type constructor to an existing nullary SMT sort. The Lean type and SMT sort must represent the same values. It gives a .full encoding, which crush refuses for an alias whose normal form already uses that sort, such as an alias of Int mapped to Int; a sort handler returning .sameAs shares the normal form's encoding instead. For example, a one-field structure over Int is representation-isomorphic to SMT Int; its projection and operation can then use identity and arithmetic lowerings:

open Crush structure MappedInt where value : Int namespace MappedInt def next (x : MappedInt) : MappedInt := ⟨x.value + 1⟩ end MappedInt crush_map_sort MappedInt => "Int" register_lowering term << (MappedInt.value (term x)) => (smt| $x) >> register_lowering term << (MappedInt.next (term x)) => (smt| (+ $x 1)) >> example (x : MappedInt) : (MappedInt.next x).value = x.value + 1 := x:MappedInt⊢ x.next.value = x.value + 1 All goals completed! 🐙

crush_map_sort and crush_map solve different problems. The former chooses the representation of values of a Lean type; the latter chooses the operation applied to already translated values. After mapping a custom type to Int, its constructors, projections, and operations still need compatible term lowerings as the example demonstrates.

Both commands resolve the Lean constant where they are written, so the current namespace and open declarations apply, and an unknown name is an error. The target is emitted verbatim and is not declared. These commands are therefore appropriate only for solver theory symbols or sorts already declared elsewhere. Use a full handler when a fresh declaration is required.