lean4-htt/tests/lean/run/1024.lean
Leonardo de Moura 16bc6ebcb6
fix: ensure simp and dsimp do not unfold too much (#6397)
This PR ensures that `simp` and `dsimp` do not unfold definitions that
are not intended to be unfolded by the user. See issue #5755 for an
example affected by this issue.

Closes #5755

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
2024-12-21 04:16:15 +00:00

29 lines
930 B
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.

inductive Vector' (α : Type u): Nat → Type u where
| nil : Vector' α 0
| cons (head : α) (tail : Vector' α n) : Vector' α (n+1)
namespace Vector'
def nth : ∀{n}, Vector' α n → Fin n → α
| n+1, cons x xs, ⟨ 0, _⟩ => x
| n+1, cons x xs, ⟨k+1, h⟩ => xs.nth ⟨k, sorry⟩
def snoc : ∀{n : Nat} (xs : Vector' α n) (x : α), Vector' α (n+1)
| _, nil, x' => cons x' nil
| _, cons x xs, x' => cons x (snoc xs x')
theorem nth_snoc_eq (k: Fin (n+1))(v : Vector' α n)
(h: k.val = n):
(v.snoc x).nth k = x := by
cases k; rename_i k hk
induction v generalizing k <;> subst h
· simp only [nth, snoc]
· simp! [*, nth]
theorem nth_snoc_eq_works (k: Fin (n+1))(v : Vector' α n)
(h: k.val = n):
(v.snoc x).nth k = x := by
cases k; rename_i k hk
induction v generalizing k <;> subst h
· simp only [nth, snoc]
· simp [*, nth, snoc]
end Vector'