lean4-htt/tests/lean/run/split1.lean
Joachim Breitner af6d2077a0
refactor: use match compilation to generate splitter (#11220)
This PR changes how match splitters are generated: Rather than rewriting
the match statement, the match compilation pipeline is used again.


The benefits are:

* Re-doing the match compilation means we can do more intelligent book
keeping, e.g. prove overlap assumptions only once and re-use the proof,
or prune the context of the MVar to speed up `contradiction`. This may
have allowed a different solution than #11200.
 
* It would unblock #11105, as the existing splitter implementation would
have trouble dealing with the matchers produced that way.
 
* It provides the necessary machinery also for source-exposed “none of
the above” bindings, a feature that we probably want at some point (and
we mostly need to find good syntax for, see #3136, although maybe I
should open a dedicated RFC).

* It allows us to skip costly things during matcher creation that would
only be useful for the splitter, and thus allows performance
improvements like #11508.
 
 * We can drop the existing implementation.
 
It’s not entirely free:

* We have to run `simpH` twice, once for the match equations and once
for the splitter.
2025-12-04 15:03:13 +00:00

26 lines
641 B
Text

-- set_option trace.Meta.Match.match true
-- set_option trace.Meta.Match.matchEqs true
def f (xs : List Nat) : Nat :=
match xs with
| [] => 1
| [a, b] => (a + b).succ
| _ => 2
theorem ex1 (xs : List Nat) (hr : xs.reverse = xs) (ys : Nat) : ys > 0 → f xs > 0 := by
simp [f]
split
next => intro hys; decide
next => intro hys; apply Nat.zero_lt_succ
next zs n₁ n₂ => intro hys; decide
def g (xs : List Nat) : Nat :=
match xs with
| [a, b, c, d, e] => a + e + 1
| _ => 1
theorem ex2 (xs : List Nat) : g xs > 0 := by
simp [g]
split
next a b c d e => apply Nat.zero_lt_succ
next h => decide