5.7. Declaring SMT Symbols
ctx.declare emits declarations once per key and returns the allocated symbol.
This handler gives an opaque Lean function an equally opaque SMT function:
open Crush
opaque externalToken : Int → Int
@[crush_lower externalToken]
def translateExternalToken :
LoweringHandler := fun ctx => do
let .const ``externalToken _ := ctx.fn
| return none
let #[x] := ctx.args | return none
let intSort : SMT.SSort :=
.app (.symb "Int") #[]
let fn ← ctx.declare "docs.externalToken"
"external_token" fun name => do
return #[.declFun name #[intSort] intSort]
let sx ← ctx.emitTerm x
return some (.app (.symb fn) #[sx])
example (x y : Int) (h : x = y) :
externalToken x = externalToken y := x:Inty:Inth:x = y⊢ externalToken x = externalToken y
All goals completed! 🐙