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

49 lines
1.8 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.

@[simp] def List.count' [DecidableEq α] : List αα → Nat
| [], _ => 0
| a::as, b => if a = b then as.count' b + 1 else as.count' b
inductive StarsAndBars : Nat → Nat → Type where
| nil : StarsAndBars 0 0
| star : StarsAndBars s b → StarsAndBars (s+1) b
| bar : StarsAndBars s b → StarsAndBars s (b+1)
namespace StarsAndBars
namespace Ex1
def toList : StarsAndBars s b → { bs : List Bool // bs.count' false = s ∧ bs.count' true = b }
| nil => ⟨[], by simp⟩
| star h => ⟨false :: toList h, by simp [(toList h).2]⟩
| bar h => ⟨true :: toList h, by simp [(toList h).2]⟩
theorem toList_star (h : StarsAndBars s b) (h') : toList (star h) = ⟨false :: toList h, h'⟩ := by
rfl
theorem toList_bar (h : StarsAndBars s b) (h') : toList (bar h) = ⟨true :: toList h, h'⟩ := by
rfl
end Ex1
/- Same example with explicit proofs -/
namespace Ex2
theorem toList_star_proof (h : bs.count' false = s ∧ bs.count' true = b) : (false :: bs).count' false = s.succ ∧ (false :: bs).count' true = b := by
simp [*]
theorem toList_bar_proof (h : bs.count' false = s ∧ bs.count' true = b) : (true :: bs).count' false = s ∧ (true :: bs).count' true = b.succ := by
simp [*]
def toList : StarsAndBars s b → { bs : List Bool // bs.count' false = s ∧ bs.count' true = b }
| nil => ⟨[], by simp⟩
| star h => ⟨false :: toList h, toList_star_proof (toList h).property⟩
| bar h => ⟨true :: toList h, toList_bar_proof (toList h).property⟩
theorem toList_star (h : StarsAndBars s b) : toList (star h) = ⟨false :: toList h, toList_star_proof (toList h).property⟩ := by
rfl
theorem toList_bar (h : StarsAndBars s b) : toList (bar h) = ⟨true :: toList h, toList_bar_proof (toList h).property⟩ := by
rfl
end Ex2
end StarsAndBars