Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusrossel committed Apr 18, 2024
1 parent b2b05e9 commit 925dda7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Lean/Egg/Tests/EndOfInput 2.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import Egg
-- "Unexpected end of input".

example : 0 = 0 := by
egg (config := { optimizeExpl := true })
egg (config := { })
11 changes: 6 additions & 5 deletions Lean/Egg/Tests/EraseForallDomains.lean
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Egg

set_option egg.eraseForallDomains true

set_option egg.eraseForallDomains false in
example (h : ∀ x y : Nat, x = y ↔ y = x) : (∀ x y : Nat, x = y) ↔ (∀ a b : Nat, b = a + 0) := by
egg (config := { eraseForallDomains := false }) [h, Nat.add_zero]
egg [h, Nat.add_zero]

set_option egg.eraseForallDomains true in
example (h : ∀ x y : Nat, x = y ↔ y = x) : (∀ x y : Nat, x = y) ↔ (∀ a b : Nat, b = a + 0) := by
egg [h, Nat.add_zero]

-- BUG: the rewrite is actually bidirectional, but the domain is the only reference to the mvar for
-- `α` on the rhs.
-- BUG: The rewrite is actually bidirectional, but the domain is the only reference to the mvar for
-- `α` on the rhs. You can only see this in `trace.egg.encoded`, not `trace.egg.rewrites`.
variable (h : ∀ (α : Type), (α = α) ↔ (∀ (_ : α), 0 = 0))
set_option egg.eraseForallDomains true in
example : True = True := by
sorry -- egg [h]
8 changes: 5 additions & 3 deletions Lean/Egg/Tests/EraseLambdaDomains.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ import Egg

set_option egg.eraseLambdaDomains true

set_option egg.eraseLambdaDomains false in
example : (fun x => x) = (fun x => 0 + 0 + x) := by
egg (config := { eraseLambdaDomains := false }) [Nat.zero_add]
egg [Nat.zero_add]

example : (fun x => x) = (fun x => 0 + 0 + x) := by
egg [Nat.zero_add]

set_option egg.eraseLambdaDomains false in
example : (fun x => x) = (fun x => 0 + x) := by
egg (config := { eraseLambdaDomains := false }) [Nat.zero_add]
egg [Nat.zero_add]

example : (fun x => x) = (fun x => 0 + x) := by
egg [Nat.zero_add]

-- BUG: the rewrite is actually bidirectional, but the domain is the only reference to the mvar for
-- BUG: The rewrite is actually bidirectional, but the domain is the only reference to the mvar for
-- `α` on the rhs.
variable (h : ∀ α : Type, (fun (_ : List α) => 0) = (fun _ => ([] : List α).length))
example : True = True := by
Expand Down
5 changes: 3 additions & 2 deletions Lean/Egg/Tests/EraseProofs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import Egg

set_option egg.eraseProofs true

set_option egg.eraseProofs false in
example (i : Nat) (h : i < 10) : (Fin.mk i h).val = i := by
have : ∀ n m (g : n < m), (Fin.mk n g).val = n := by simp
egg (config := { eraseProofs := false }) [this]
egg [this]

example (i : Nat) (h : i < 10) : (Fin.mk i h).val = i := by
have : ∀ n m (g : n < m), (Fin.mk n g).val = n := by simp
Expand All @@ -16,7 +17,7 @@ example (i : Nat) (h : ∀ i : Nat, i < 10) : (Fin.mk i (h i)).val = i := by
have : ∀ n m (g : n < m), (Fin.mk n g).val = n := by simp
egg [this]

-- BUG: the rewrite is actually bidirectional, but the proof is the only reference to the mvar for
-- BUG: The rewrite is actually bidirectional, but the proof is the only reference to the mvar for
-- `x` on the rhs.
variable (h : ∀ x : Nat, x = (Exists.intro x x.zero_le).choose)
example : True = True := by
Expand Down
10 changes: 5 additions & 5 deletions Lean/Egg/Tests/Eta.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Egg
set_option egg.genEtaRw true
set_option egg.genBetaRw false

set_option egg.genEtaRw false in
example : (fun x => Nat.succ x) = Nat.succ := by
fail_if_success egg (config := { genEtaRw := false })
fail_if_success egg
rfl

example : (fun x => Nat.succ x) = Nat.succ := by
Expand Down Expand Up @@ -42,8 +43,9 @@ example : id (eta 2 Nat.succ Nat) = id Nat.succ := by
example : (eta 10 Nat.succ Nat) = Nat.succ := by
egg

set_option egg.genEtaRw false in
example (a : Nat) (h : ∀ b : Nat, b.succ.add a = 0) : (10 |> fun x => Nat.succ x).add a = 0 := by
fail_if_success egg (config := { genEtaRw := false }) [h]
fail_if_success egg [h]
apply h

example (a : Nat) (h : ∀ b : Nat, b.succ.add a = 0) : (10 |> fun x => Nat.succ x).add a = 0 := by
Expand All @@ -53,7 +55,7 @@ example (a : Nat) (h : ∀ b : Nat, b.succ.add a = 0) : (10 |> fun x => Nat.succ
example : (fun x => x) = Add.add 0 := by
sorry -- egg [Nat.zero_add]

/- BUG: Why is proof reconstruction failing here? The explanation seems totally fine:
/- TODO: Why is proof reconstruction failing here? The explanation seems totally fine:
(app (app (λ (const Nat) (app f (bvar 0))) y) y)
(app (app (Rewrite=> ≡η f) y) y)
Expand All @@ -65,8 +67,6 @@ Even stranger, if you flip the LHS and RHS of the goal, it suddenly works. The p
in that case is the same just backwards. So a hacky fix would be to always obtain explanations from
egg in both directions and if one fails try the other.
-/
set_option trace.egg true in
set_option egg.optimizeExpl true in
example (f i : Nat → Nat → Nat) (h₁ : f y = g) (h₂ : g y = i y (nat_lit 0)) :
(f ·) y y = (i ·) y (nat_lit 0) := by
sorry -- egg [h₁, h₂]
1 change: 0 additions & 1 deletion Lean/Egg/Tests/Groups.lean
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ theorem inv_inv : -(-a) = a := by
theorem neg_add' : -(a + b) = -b + -a := by
group using -a + (a + b) + -(a + b)

-- BUG: Try adding a hypothesis. This should cause the backend to crash.
theorem inv_inv' : -(-a) = a := by
group using -a + a

0 comments on commit 925dda7

Please sign in to comment.