lean4-htt/tests/elab/letrecWFIssue.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

34 lines
1.1 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.

mutual
inductive Tree (α : Type u) where
| node : TreeList α → Tree α
| leaf : α → Tree α
inductive TreeList (α : Type u) where
| nil : TreeList α
| cons : Tree α → TreeList α → TreeList α
end
def Tree.size : Tree α → Nat
| Tree.node l =>
-- see "TODO: linarith" in Init.WFTactics
have : sizeOf l < 1 + sizeOf l := by
rw [Nat.add_comm]
apply Nat.lt_succ_self
sizeList l
| Tree.leaf _ => 1
-- use automatically synthesized size function, which is not quite the number of leaves
termination_by t => sizeOf t
where
sizeList : TreeList α → Nat
| TreeList.nil => 0
| TreeList.cons t l =>
have : sizeOf t < 1 + sizeOf t + sizeOf l := by
rw [Nat.add_comm 1, Nat.add_assoc, Nat.add_comm 1, ← Nat.add_assoc]
apply Nat.lt_succ_of_le
apply Nat.le_add_right
have : sizeOf l < 1 + sizeOf t + sizeOf l := by
rw [Nat.add_comm 1, Nat.add_assoc, Nat.add_comm 1, ← Nat.add_assoc]
apply Nat.lt_succ_of_le
apply Nat.le_add_left
t.size + sizeList l
termination_by l => sizeOf l