leanprover-community / leanprover-community/mathlib4

`cases` and `induction` don't respect `Multiplicative`

Open
#31,213 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
4.2k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Trying to add a recursor for WithZero (Multiplicative M), I discovered that my recursor was actually firing on WithZero M because Multiplicative is too reducible for induction.

import Mathlib

open scoped WithZero

variable {M : Type*}

@[induction_eliminator, cases_eliminator]
def expRecOn {motive : Mᵐ⁰ → Sort*} (x : Mᵐ⁰) (zero : motive 0) (exp : ∀ a, motive (.exp a)) :
    motive x := Option.recOn x zero exp

example (a : WithZero M) : a = a := by
  induction a with
  | zero => rfl
  -- This should be `coe` instead.
  | exp => rfl

example (a : WithZero M) : a = a := by
  cases a with
  | zero => rfl
  -- This should be `coe` instead.
  | exp => rfl

It is not clear to me whether this is intended on the part of cases and induction. If so, that means we need to make Multiplicative into a one-field structure, which looks like a big undertaking...

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 two examples with Mathlib, focusing on the expRecOn eliminator and how cases and induction handle WithZero (Multiplicative M). Read the behavior around Multiplicative, WithZero, and the cases/induction entry points; done means the examples select the expected constructor behavior or the intended limitation is documented.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.