Repository navigation
Description
Problem
term_cases cannot close a goal that needs constructor disjointness or injectivity. SPEC.md lines 2678 to 2700 (SM-35) lower it to:
cases llCase : <term> <;> simp (config := {decide := true}) only [<definitions>, llCase, ite_true, ite_false]
decide := true decides only closed propositions. After the split, a case that equates two different constructors over a variable is left open, for example Verdict.good = Verdict.bad p or none = some p. So is a case that equates the same constructor over different fields, Verdict.bad x = Verdict.bad p.
The everyday statement "if the check returns bad p, the report names p" therefore cannot be proved. The workaround is to restate theorems over Nat class flags, so every case is closed (UOR-Foundation/mcp#20, JsonGate).
Reproduced at release/v0.4 9796067, Lean 4.32.1:
\begin{lexlean}{Main}
\useglossary{lexlean.std.nat@1.2.0}
\title{Natural number addition}
\begin{semanticmodule}
inductive{name: Verdict, type_parameters: [], parameters: [], constructors: [{name: good, fields: []}, {name: bad, fields: [Nat]}]}
definition{
name: check,
parameters: [n : Nat],
result: Verdict,
body: (if (n =? 0) then (ctor Verdict.good) else (ctor Verdict.bad n))
}
definition{
name: report,
parameters: [n : Nat],
result: (Option Nat),
body: (match (check n)
| Verdict.good => (ctor Option.none [Nat])
| Verdict.bad at => (ctor Option.some [Nat] at))
}
theorem{
name: report_names_the_bad_value,
parameters: [n : Nat, p : Nat],
statement: (((check n) = (ctor Verdict.bad p)) -> ((report n) = (ctor Option.some [Nat] p))),
proof: term_cases{scrutinee: (check n), definitions: [report]},
axioms: [propext]
}
\end{semanticmodule}
\end{lexlean}
error[LLV7002]: Lean rejected `Repro.Main` (error): unsolved goals
case good
n p : Nat
llCase : check n = Verdict.good
⊢ Verdict.good = Verdict.bad p → none = some p
case bad
n p x✝ : Nat
llCase : check n = Verdict.bad x✝
⊢ Verdict.bad x✝ = Verdict.bad p → some x✝ = some p
Item
term_cases (or a sibling proof form with its own row) closes constructor disjointness and injectivity, for the inductives of the module and for Option, Result and List. For example, it could add the generated <Ctor>.injEq lemmas and reduceCtorEq to the fixed simp set. The set stays fixed, so the proof form stays closed.
Accepted when
- The theorem above verifies with an exact axiom policy.
- A false variant is still rejected.
SM-35, or a new row, states the extended simp set.
Found while building UOR-Foundation/mcp#18.
Generated by Claude Code
Activity
humuhumu33 commentedon Oct 22, 2026
Claiming this. Plan: reproduce, then extend the fixed simp set of SM-35 (constructor injectivity and no-confusion lemmas, nothing from simp's default set), register first (row or SM-35 amendment, scenario, failing cases: the module above, an Option case, an injectivity case, and a false variant that must stay open), then the lowering change.
term_casesand SM-35 are onrelease/v0.4only (release/v0.5has SM-01..SM-34 and no forward merge yet), so the branch is cut fromrelease/v0.4; say if you want it on another line.humuhumu33 commentedon Oct 23, 2026
Draft PR #299 against release/v0.4. It amends SM-35 with no new row: the fixed simp set gains
reduceCtorEq,false_implies,imp_self,and_true,true_and, theOption/Except/Listinjectivity lemmas, and<T>.<c>.injEqfor each constructor with a field of the module's inductives. The module above verifies with[propext], and the false variant is still rejected. No compiler-semantics identity moves.Merge pull request #299 from UOR-Foundation/claude/issue-280-term-cas…
afflom commentedon Oct 31, 2026
Fixed by #299 (SM-35), merged into
release/v0.5on 2026-10-27. Closing.Generated by Claude Code