Lean4
/-- Erase proofs in an expression by replacing them with `sorry`s.
This function replaces all proofs in the expression
and in the types that appear in the expression
by `sorryAx`s.
The resulting expression has the same type as the old one.
It is useful, e.g., to verify if the proof-irrelevant part of a definition depends on a variable.
-/
def eraseProofs (e : Expr) : MetaM Expr :=
Meta.transform (skipConstInApp := true) e (pre := fun e => do
if (← Meta.isProof e) then
return .continue (← mkSorry (← inferType e) true)
else
return .continue)