Compare commits

...

1 Commits

Author SHA1 Message Date
Leonardo de Moura
be5db4c3ec fix: isDefEq when zetaDelta := false
This PR fixes a bug at `isDefEq` when `zetaDelta := false`.
See new test for a small example that exposes the issue.
2024-11-19 12:04:13 -08:00
3 changed files with 22 additions and 7 deletions

View File

@@ -1674,11 +1674,12 @@ private partial def isDefEqQuick (t s : Expr) : MetaM LBool :=
-- | Expr.mdata _ t _, s => isDefEqQuick t s
-- | t, Expr.mdata _ s _ => isDefEqQuick t s
| .fvar fvarId₁, .fvar fvarId₂ => do
if ( fvarId₁.isLetVar <||> fvarId₂.isLetVar) then
return LBool.undef
else if fvarId₁ == fvarId₂ then
return LBool.true
if fvarId₁ == fvarId₂ then
return .true
else if ( fvarId₁.isLetVar <||> fvarId₂.isLetVar) then
return .undef
else
-- If `t` and `s` are not proofs or let-variables, we still return `.undef` and let other rules (e.g., unit-like) kick in.
isDefEqProofIrrel t s
| t, s =>
isDefEqQuickOther t s

View File

@@ -175,13 +175,13 @@ def Array.toBinaryHeap (lt : αα → Bool) (a : Array α) : BinaryHeap α
attribute [simp] Array.heapSort.loop
/--
info: Array.heapSort.loop.eq_1.{u_1} {α : Type u_1} (lt : αα → Bool) (a : BinaryHeap α fun y x => lt x y) (out : Array α) :
Array.heapSort.loop lt a out =
info: Array.heapSort.loop.eq_1.{u_1} {α : Type u_1} (gt : αα → Bool) (a : BinaryHeap α gt) (out : Array α) :
Array.heapSort.loop gt a out =
match e : a.max with
| none => out
| some x =>
let_fun this := ⋯;
Array.heapSort.loop lt a.popMax (out.push x)
Array.heapSort.loop gt a.popMax (out.push x)
-/
#guard_msgs in
#check Array.heapSort.loop.eq_1

View File

@@ -0,0 +1,14 @@
import Lean
/--
info: true
true
-/
#guard_msgs in
open Lean Meta in
run_meta do
withLetDecl `x (mkConst ``Nat) (mkNatLit 10) fun x => do
IO.println ( isDefEq x x)
withConfig (fun c => { c with zeta := false, zetaDelta := false }) do
IO.println ( isDefEq x x) -- Should return `true` even if `zetaDelta := false`
return ()