leanprover / leanprover/lean4

"Cannot derive functional induction principle" for function involving mutual inductives

Open
#11,540 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

Consider the following MWE with a custom Vector (Term s) n inlined (live)

mutual
inductive Term : Unit → Type where
| con : (con : Nat) → ConArgs con s → Term s

inductive ConArgs : (n:Nat) → Unit → Type where
| nil : ConArgs 0 s
| cons : Term s → ConArgs n s → ConArgs (n+1) s
end

def ConArgs.toList : ConArgs n s → List (Term s)
| nil => []
| cons e args => e :: args.toList

private theorem ConArgs.length_toList_eq {args : ConArgs n s} : args.toList.length = n := by
  fun_induction ConArgs.toList
Steps to Reproduce

Elaborate the example

Expected behavior: I would expect the fun_induction tactic to do its thing

Actual behavior: fun_induction tactic says

Failed to realize constant ConArgs.toList.induct_unfolding:
  Cannot derive functional induction principle (please report this issue)
    type (∀ (n : Nat) (a : Unit) (t : ConArgs n a) (f : t.below), motive t t.toList) → True does not have 2 parameters
Versions

Lean 4.27.0-nightly-2025-11-30
Target: x86_64-unknown-linux-gnu

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal mutual-inductive example with ConArgs.toList and fun_induction from the issue, using the linked Lean nightly case. Read the reported ConArgs.toList.induct_unfolding failure and trace how the functional induction principle is derived. Done means the example elaborates and the length_toList_eq theorem can use fun_induction without the reported 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.