lean4-htt/tests/lean/run/issue9846.lean
Joachim Breitner 8655f7706f
refactor: structural recursion: prove .eq_def directly (#10606)
This PR changes how Lean proves the equational theorems for structural
recursion. The core idea is to let-bind the `f` argument to `brecOn` and
rewriting `.brecOn` with an unfolding theorem. This means no extra case
split for the `.rec` in `.brecOn` is needed, and `simp` doesn't change
the `f` argument which can break the definitional equality with the
defined function. With this, we can prove the unfolding theorem first,
and derive the equational theorems from that, like for all other ways of
defining recursive functions.

Backs out the changes from #10415, the old strategy works well with the
new goals.

Fixes #5667
Fixes #10431
Fixes #10195
Fixes #2962
2025-10-07 12:53:09 +00:00

21 lines
662 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.

def testMatch : Array α → Unit
| #[_] => ()
| _ => ()
/--
error: Failed to realize constant testMatch.match_1.eq_1:
failed to generate equality theorems for `match` expression `testMatch.match_1`
case isTrue
α✝ : Type u_1
motive✝ : Array α✝ → Sort u_2
x✝¹ : Array α✝
h_1✝ : (head : α✝) → motive✝ #[head]
h_2✝ : (x : Array α✝) → motive✝ x
x✝ : ∀ (head : α✝), x✝¹ = #[head] → False
h✝ : x✝¹.size = 1
⊢ (⋯ ▸ fun h => ⋯ ▸ h_1✝ (x✝¹.getLit 0 ⋯ ⋯)) ⋯ = h_2✝ x✝¹
---
error: Unknown constant `testMatch.match_1.eq_1`
-/
#guard_msgs in
#print testMatch.match_1.eq_1