Skip to content

Instantly share code, notes, and snippets.

@gaxiiiiiiiiiiii
Created December 6, 2025 10:58
Show Gist options
  • Select an option

  • Save gaxiiiiiiiiiiii/03b490ea554ae7a45ab9bebd2c69e168 to your computer and use it in GitHub Desktop.

Select an option

Save gaxiiiiiiiiiiii/03b490ea554ae7a45ab9bebd2c69e168 to your computer and use it in GitHub Desktop.
variable {α : Type}
/-- リストの長さが偶数であることを表す述語 -/
@[grind]
inductive EvenLength : List α → Prop
| nil : EvenLength []
| cons_cons {a b : α} {l : List α} (h : EvenLength l) :
EvenLength (a :: b :: l)
example (xs : List α) : EvenLength xs ↔ xs.length % 2 = 0 := by
revert xs
suffices
(∀ (xs : List α)(a : α), ((EvenLength xs ↔ xs.length % 2 = 0) ∧ (EvenLength (a :: xs) ↔ (a :: xs).length % 2 = 0))) by {
intro xs
rcases xs with _ | ⟨a, xs⟩<;> grind
-- simp; constructor; simp
-- exact (this xs a).2
}
intro xs
induction xs with
| nil =>
grind
-- intro x
-- simp; constructor; constructor
-- intro F; rcases F
| cons y l IH =>
intro x; simp
rcases IH y with ⟨IHl, IHy⟩
grind
-- constructor; assumption
-- rw [Nat.add_assoc]; simp
-- rw [<- IHl]
-- constructor<;> intro H
-- · rcases H; assumption
-- · constructor; assumption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment