lean4-htt/tests/lean/run/issue2102.lean
Joachim Breitner 50c19f704b
fix: Let MVarId.cleanup chase local declarations (#10712)
This PR lets `MVarId.cleanup` chase local declarations (a bit as if they
were equalities). Fixes #10710.
2025-10-08 10:49:14 +00:00

77 lines
2.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

set_option linter.unusedVariables false
-- works
def g' (T : Type) (ls : List T) : (Option (List T)) :=
match ls with
| _::tl =>
let res := Option.attach (g' T tl)
res.bind fun x => x.val
| [] => .none
-- doesn't
/--
error: fail to show termination for
g''
with errors
failed to infer structural recursion:
Not considering parameter T of g'':
its type is not an inductive
Not considering parameter ls of g'':
its type is an inductive datatype
List T
and the datatype parameter
T
depends on the function parameter
T
which is not fixed.
no parameters suitable for structural recursion
failed to prove termination, possible solutions:
- Use `have`-expressions to prove the remaining goals
- Use `termination_by` to specify a different well-founded relation
- Use `decreasing_by` to specify your own tactic for discharging this kind of goal
T✝ : Type
head✝ : T✝
tl : List T✝
x✝ :
(y : (T : Type) ×' List T) →
(invImage (fun x => PSigma.casesOn x fun T ls => sizeOf ls) sizeOfWFRel).1 y ⟨T✝, head✝ :: tl⟩ → Option (List y.1)
res : Option { x // x✝ ⟨T✝, tl⟩ ⋯ = some x } := (x✝ ⟨T✝, tl⟩ ⋯).attach
T : Type
ls : List T
⊢ sizeOf ls < 1 + sizeOf tl
-/
#guard_msgs in
def g'' (T : Type) (ls : List T) : (Option (List T)) :=
match ls with
| _::tl =>
let res := Option.attach (g'' T tl)
res.bind fun ⟨x,h⟩ => x
| [] => .none
/--
error: failed to prove termination, possible solutions:
- Use `have`-expressions to prove the remaining goals
- Use `termination_by` to specify a different well-founded relation
- Use `decreasing_by` to specify your own tactic for discharging this kind of goal
T✝ : Type
head✝ : T✝
tl : List T✝
x✝ :
(y : (T : Type) ×' List T) →
(invImage (fun x => PSigma.casesOn x fun T ls => sizeOf ls) sizeOfWFRel).1 y ⟨T✝, head✝ :: tl⟩ → Option (List y.1)
res : Option { x // x✝ ⟨T✝, tl⟩ ⋯ = some x } := (x✝ ⟨T✝, tl⟩ ⋯).attach
T : Type
ls : List T
⊢ sizeOf ls < 1 + sizeOf tl
-/
#guard_msgs in
def g''' (T : Type) (ls : List T) : (Option (List T)) :=
match ls with
| _::tl =>
let res := Option.attach (g''' T tl)
res.bind fun ⟨x,h⟩ => x
| [] => .none
termination_by sizeOf ls