lean4-htt/tests/elab/issue2102.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

79 lines
2.3 KiB
Text
Raw Permalink 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 x1 x2 => x1 < x2) (fun x => PSigma.casesOn x fun T ls => sizeOf ls) 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 x1 x2 => x1 < x2) (fun x => PSigma.casesOn x fun T ls => sizeOf ls) 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