Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed Jul 28, 2024
1 parent 51f6243 commit 6c241c4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/lean/run/starsAndBars.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@[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
Expand All @@ -7,7 +11,7 @@ namespace StarsAndBars

namespace Ex1

def toList : StarsAndBars s b → { bs : List Bool // bs.count false = s ∧ bs.count true = b }
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]⟩
Expand All @@ -23,13 +27,13 @@ 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
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
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 }
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⟩
Expand Down

0 comments on commit 6c241c4

Please sign in to comment.