lean4-htt/tests/lean/run/sym_simp_4.lean
Leonardo de Moura 45862d5486
feat: improves simpArrowTelescope simproc (#12153)
This PR improves the `simpArrowTelescope` simproc that simplifies
non-dependent arrow telescopes: `p₁ → p₂ → ... → q`.

The simproc now also applies telescope-specific simplifications:
- `False → q` to `True` (when `q : Prop`)
- `True → q` to `q` (when `q : Prop`)
- `p → True` to `True`
2026-01-25 22:29:38 +00:00

96 lines
2.1 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
open Lean Meta Elab Tactic
elab "sym_simp" "[" declNames:ident,* "]" : tactic => do
let rewrite ← Sym.mkSimprocFor (← declNames.getElems.mapM fun s => realizeGlobalConstNoOverload s.raw) Sym.Simp.dischargeSimpSelf
let methods : Sym.Simp.Methods := {
pre := Sym.Simp.simpControl.andThen Sym.Simp.simpArrowTelescope
post := Sym.Simp.evalGround.andThen rewrite
}
liftMetaTactic1 fun mvarId => Sym.SymM.run do
let mvarId ← Sym.preprocessMVar mvarId
(← Sym.simpGoal mvarId methods).toOption
example : (if true then a else b) = a := by
sym_simp []
example : (if True then a else b) = a := by
sym_simp []
example : (if False then a else b) = b := by
sym_simp []
/--
trace: α✝ : Sort u_1
x : α✝
p q : Prop
h : p → q
⊢ p → q
-/
#guard_msgs in
example (p q : Prop) (h : p → q) : True → p → x = x → q := by
sym_simp []
trace_state
exact h
example (p q : Prop) : q → p → True := by
sym_simp []
example (p q : Prop) : q → p → x = x := by
sym_simp []
example (q : Prop) : q → x ≠ x → True := by
sym_simp []
example (α : Type) (p : Prop) : α → p → x = x := by
sym_simp []
example (q : Prop) (α : Type) (p : Prop) : q → α → p → x = x := by
sym_simp []
example (α β : Type) (p q : Prop) : q → β → p → α → True := by
sym_simp []
/--
trace: α✝ : Sort ?u.1893
x : α✝
α : Type
p : Prop
h : α → p → True → α
α → p → True → α
-/
#guard_msgs in
example (α : Type) (p : Prop) (h : α → p → True → α) : α → p → x = x → α := by
sym_simp []
trace_state
exact h
set_option linter.unusedVariables false
/--
trace: α✝ : Sort u_1
x : α✝
α : Type
q : Prop
h : False
⊢ ∀ (a b : α), q
-/
#guard_msgs in
example (α : Type) (q : Prop) (h : False) : (a : α) → x = x → (b : α) → True → q := by
sym_simp []
trace_state
cases h
/--
trace: α✝ : Sort u_1
x : α✝
α : Type
p q : Prop
h : False
⊢ ∀ (a : α) {b : α}, q
-/
#guard_msgs in
example (α : Type) (p q : Prop) (h : False) : (a : α) → x = x → {b : α} → True → (q ∧ True) := by
sym_simp [and_true]
trace_state
cases h