Cannot derive functional induction principle: failed to transform matcher, type error when constructing new pre-splitter motive
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
This code:
def bla (a : Nat) (h : 0 < a) : Nat :=
if h : a ≤ 1 then
0
else
have : 0 ≠ a := by omega
match a with
| 0 => False.elim (by contradiction)
| a + 1 => bla a (by omega)
termination_by structural a
theorem blub {a : Nat} {h : 0 < a} : bla a h ≤ 1 := by
fun_induction bla
generates this error message
Failed to realize constant bla.induct_unfolding:
Cannot derive functional induction principle (please report this issue)
failed to transform matcher, type error when constructing new pre-splitter motive:
bla.match_1
(fun a h h_1 this_1 =>
t = a →
∀ (x : Nat.below (motive := fun a => ∀ (h : 0 < a), motive a h (bla a h)) a),
motive a h
(match a, h, h_1, this with
| 0, h, h_2, this => (bla._proof_1 h).elim
| a.succ, h, h_2, this => bla a (bla._proof_2 a h_2)))
t h✝ h this
failed with
Application type mismatch: The argument
this✝
has type
0 ≠ t
but is expected to have type
0 ≠ a✝
in the application
bla.match_1 (fun a h h_1 this => Nat) a✝ h✝ h this✝
Context
Minimized from a similar function in the String API.
Steps to Reproduce
- Copy the above code into live.lean-lang.org
Expected behavior: No error
Actual behavior: See above
Versions
Lean 4.25.0-nightly-2025-09-22
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimized example in live.lean-lang.org with the specified Lean nightly version and the fun_induction bla entry point. Trace the reported transformation around bla.induct_unfolding and bla.match_1, especially the pre-splitter motive type mismatch. Done means the example derives the functional induction principle without an error.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100