Skip to content

Commit

Permalink
fix Expr.instanceOf? issue??
Browse files Browse the repository at this point in the history
  • Loading branch information
PratherConid committed Dec 19, 2024
1 parent e6d6330 commit 5efc8ad
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Auto/Lib/ExprExtra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,19 @@ def Expr.whnfIfNotForall (e : Expr) : MetaM Expr := do
def Expr.instanceOf? (e₁ e₂ : Expr) : MetaM (Option (Expr × Expr)) := do
let ty₁ ← Meta.inferType e₁
let ty₂ ← Meta.inferType e₂
Meta.forallTelescope ty fun xs _ => do
let (ms, _, _) ← Meta.forallMetaTelescope ty
let e₁app := mkAppN e₁ xs
let e₂app := mkAppN e₂ ms
Meta.forallTelescope ty fun xs _ => do
let (ms, _, _) ← Meta.forallMetaTelescope ty
let e₁app := mkAppN e₁ ms
let e₂app := mkAppN e₂ xs
if ← Meta.isDefEq e₁app e₂app then
let e₂app ← instantiateMVars e₂app
let (e₂app, s) := AbstractMVars.abstractExprMVars e₂app { mctx := (← getMCtx), lctx := (← getLCtx), ngen := (← getNGen)}
let e₁app ← instantiateMVars e₁app
-- **TODO:** Why is this necessary?
if !(← Meta.isTypeCorrect e₁app) then
return .none
let (e₁app, s) := AbstractMVars.abstractExprMVars e₁app { mctx := (← getMCtx), lctx := (← getLCtx), ngen := (← getNGen)}
setNGen s.ngen; setMCtx s.mctx
Meta.withLCtx s.lctx (← Meta.getLocalInstances) <| do
let proof ← Meta.mkLambdaFVars (xs ++ s.fvars) (← Meta.mkAppM ``Eq.refl #[eapp])
let proof ← Meta.mkLambdaFVars (xs ++ s.fvars) (← Meta.mkAppM ``Eq.refl #[eapp])
let eq ← Meta.mkForallFVars (xs ++ s.fvars) (← Meta.mkAppM ``Eq #[e₁app, e₂app])
return (proof, eq)
else
Expand Down

0 comments on commit 5efc8ad

Please sign in to comment.