Skip to content

Commit

Permalink
test: grind test with many equalities
Browse files Browse the repository at this point in the history
  • Loading branch information
leodemoura committed Dec 24, 2024
1 parent 983784a commit 16a4e4d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/lean/run/grind_many_eqs.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Lean

def f (a : Nat) := a + a + a
def g (a : Nat) := a + a
def h (n : Nat) : Prop :=
match n with
| 0 => f 0 = f 1
| n+1 => f (n+1) = f n ∧ g (2*n + 1) = g (2*n) ∧ h n

-- Prints the equivalence class containing a `f` application
open Lean Meta Elab Tactic Grind in
elab "grind_test" n:num : tactic => withMainContext do
let n := n.getNat
let declName := (← Term.getDeclName?).getD `_main
Meta.Grind.preprocessAndProbe (← getMainGoal) declName do
let f0 ← Grind.shareCommon (mkApp (mkConst ``f) (mkNatLit 0))
-- The `f 0` equivalence class contains `n+1` elements
assert! (← getEqc f0).length == n + 1
forEachENode fun node => do
if node.self.isAppOf ``g then
-- Any equivalence class containing a `g`-application contains 2 elements
assert! (← getEqc (← getRoot node.self)).length == 2

set_option grind.debug true in
example : h 5 → False := by
simp [h]
grind_test 5
sorry

set_option maxRecDepth 2048
example : h 100 → False := by
simp [h]
grind_test 100
sorry

0 comments on commit 16a4e4d

Please sign in to comment.