lean4-htt/tests/lean/run/grind_nested_proofs.lean
Kim Morrison bd14e7079b
fix: make Array.size not reducible (#8513)
This PR removes the `@[reducible]` annotation on `Array.size`. This is
probably best gone anyway in order to keep separation between the `List`
and `Array` APIs, but it also helps avoid uselessly instantiating
`Array` theorems when `grind` is working on `List` problems.
2025-05-28 12:37:24 +00:00

38 lines
1.3 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
def f (α : Type) [Add α] (a : α) := a + a + a
open Lean Meta Grind in
def fallback : Fallback := do
let nodes ← filterENodes fun e => return e.self.isAppOf ``Lean.Grind.nestedProof
trace[Meta.debug] "{nodes.toList.map (·.self)}"
let nodes ← filterENodes fun e => return e.self.isApp && e.self.isAppOf ``GetElem.getElem
let [_, n, _] := nodes.toList | unreachable!
trace[Meta.debug] "{← getEqc n.self}"
(← get).mvarId.admit
set_option trace.Meta.debug true
set_option grind.debug true
set_option grind.debug.proofs true
/-
Recall that array access terms, such as `a[i]`, have nested proofs.
The following test relies on `grind` `nestedProof` wrapper to
detect equalities between array access terms.
-/
/--
trace: [Meta.debug] [i < a.size, j < a.size, j < b.size]
[Meta.debug] [a[i], b[j], a[j]]
-/
#guard_msgs (trace) in
example (i j : Nat) (a b : Array Nat) (h1 : j < a.size) (h : j < b.size) (h2 : i ≤ j) : a[i] < a[j] + b[j] → i = j → a = b → False := by
grind -mbtc on_failure fallback
/--
trace: [Meta.debug] [i < a.size, j < a.size, j < b.size]
[Meta.debug] [a[i], a[j]]
-/
#guard_msgs (trace) in
example (i j : Nat) (a b : Array Nat) (h1 : j < a.size) (h : j < b.size) (h2 : i ≤ j) : a[i] < a[j] + b[j] → i = j → False := by
grind -mbtc on_failure fallback