lean4-htt/tests/elab/simproc1.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

37 lines
1 KiB
Text

import Lean.Meta.Tactic.Simp.BuiltinSimprocs
import Lean.Elab.Command
def foo (x : Nat) : Nat :=
x + 10
open Lean Meta
/-- doc-comment for reduceFoo -/
simproc reduceFoo (foo _) := fun e => do
unless e.isAppOfArity ``foo 1 do return .continue
let some n ← Nat.fromExpr? e.appArg! | return .continue
return .done { expr := mkNatLit (n+10) }
run_meta do
guard <| (← findDocString? (← getEnv) ``reduceFoo) = some "doc-comment for reduceFoo "
example : x + foo 2 = 12 + x := by
set_option simprocs false in fail_if_success simp
simp +arith
example : x + foo 2 = 12 + x := by
-- `simp only` must not use the default simproc set
fail_if_success simp only
simp +arith
example : x + foo 2 = 12 + x := by
-- `simp only` does not use the default simproc set, but we can provide simprocs as arguments
simp only [reduceFoo]
simp +arith
example : x + foo 2 = 12 + x := by
-- We can use `-` to disable `simproc`s
fail_if_success simp [-reduceFoo]
simp +arith
example (x : Nat) (h : x < 86) : ¬100 ≤ x + 14 := by simp; exact h