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

55 lines
1.5 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.

namespace Std.Stream
variable [Std.Stream ρ τ] (s : ρ)
def take (s : ρ) : Nat → List τ × ρ
| 0 => ([], s)
| n+1 =>
match next? s with
| none => ([], s)
| some (x,rest) =>
let (L,rest) := take rest n
(x::L, rest)
def isEmpty : Bool :=
Option.isNone (next? s)
def lengthBoundedBy (n : Nat) : Prop :=
isEmpty (take s n).2
def hasNext : ρρ → Prop
:= λ s1 s2 => ∃ x, next? s1 = some ⟨x,s2⟩
def isFinite : Prop :=
∃ n, lengthBoundedBy s n
instance hasNextWF : WellFoundedRelation {s : ρ // isFinite s} where
rel := λ s1 s2 => hasNext s2.val s1.val
wf := ⟨λ ⟨s,h⟩ => ⟨Subtype.mk s h, by
simp only [Subtype.forall]
cases h with | intro w h
induction w generalizing s
case zero =>
intro s' h' h_next
simp [hasNext] at h_next
cases h_next with | intro x h_next
simp [lengthBoundedBy, isEmpty, Option.isNone, take, h_next] at h
case succ n ih =>
intro s' h' h_next
simp [hasNext] at h_next
cases h_next with | intro x h_next
simp [lengthBoundedBy, take, h_next] at h
have := ih s' h
exact Acc.intro (⟨s',h'⟩ : {s : ρ // isFinite s}) (by simpa only [Subtype.forall])
⟩⟩
def mwe [Stream ρ τ] (acc : α) : {l : ρ // isFinite l} → α
| ⟨l,h⟩ =>
match h:next? l with
| none => acc
| some (x,xs) =>
have h_next : hasNext l xs := by exists x
mwe acc ⟨xs, by sorry⟩
termination_by l => l
end Std.Stream