lean4-htt/tests/lean/run/grind_propagate_connectives.lean
Leonardo de Moura aa95a1c03f
chore: cleaunp grind tests (#6616)
Tests using `logInfo` were taking an additional two seconds on my
machine. This is a performance issue with the old code generator, where
we spend all this time specializing the logging functions for `GoalM`. I
have not checked whether the new code generator is also affected by this
performance issue.

Here is a small example that exposes the issue:
```lean
import Lean

set_option profiler true
open Lean Meta Grind in
def test (e : Expr): GoalM Unit := do
  logInfo e
```

cc @zwarich
2025-01-13 00:07:48 +00:00

99 lines
2.5 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean.Meta.Tactic.Grind
set_option trace.Meta.debug true
open Lean Meta Grind in
def fallback : Fallback := do
let trueExprs := (← filterENodes fun e => return e.self.isFVar && (← isEqTrue e.self)).toList.map (·.self)
let falseExprs := (← filterENodes fun e => return e.self.isFVar && (← isEqFalse e.self)).toList.map (·.self)
trace[Meta.debug] "true: {trueExprs}"
trace[Meta.debug] "false: {falseExprs}"
forEachEqcRoot fun n => do
unless (← isProp n.self) || (← isType n.self) || n.size == 1 do
let eqc ← getEqc n.self
trace[Meta.debug] eqc
(← get).mvarId.admit
set_option grind.debug true
set_option grind.debug.proofs true
/--
info: [Meta.debug] true: [q, w]
[Meta.debug] false: [p, r]
-/
#guard_msgs (info) in
example : (p (q ∧ ¬r ∧ w)) → ¬p → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [r]
[Meta.debug] false: [p, q]
-/
#guard_msgs (info) in
example : (p q r) → (p ¬q) → ¬p → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [r]
[Meta.debug] false: [p₁, q]
-/
#guard_msgs (info) in
example : ((p₁ ∧ p₂) q r) → (p₁ ¬q) → p₁ = False → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [r]
[Meta.debug] false: [p₂, q]
-/
#guard_msgs (info) in
example : ((p₁ ∧ p₂) q r) → ((p₂ ∧ p₁) ¬q) → p₂ = False → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [q, r]
[Meta.debug] false: [p]
-/
#guard_msgs (info) in
example (p q r : Prop) : p (q ↔ r) → p = False → q → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [r]
[Meta.debug] false: [p, s]
-/
#guard_msgs (info) in
example (p q r : Prop) : p ¬(s (p ↔ r)) → p = False → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [p]
[Meta.debug] false: []
[Meta.debug] [a, b]
-/
#guard_msgs (info) in
example (p : Prop) (a : Vector Nat 5) (b : Vector Nat 6) : (p → HEq a b) → p → False := by
grind on_failure fallback
/--
info: [Meta.debug] true: [p, q]
[Meta.debug] false: [r]
-/
#guard_msgs (info) in
example (p q r : Prop) : p (q ↔ r) → q → ¬r → False := by
grind on_failure fallback
/--
info: [Meta.debug] hello world
[Meta.debug] true: [p, q]
[Meta.debug] false: [r]
-/
#guard_msgs (info) in
example (p q r : Prop) : p (q ↔ r) → ¬r → q → False := by
grind on_failure do
trace[Meta.debug] "hello world"
fallback
example (a b : Nat) : (a = b) = (b = a) := by
grind