Counting a zero followed by ones
Lax100001.Rows · concepts/Lax100001/Rows.lean · lax-100001
Natural Language Statement
Theorem
The ones of a binary word cut its zeros into groups. Group holds the zeros that have exactly ones before them. A word with ones has the groups . The number of occurrences of followed by ones is determined by the sizes of these groups: a zero in group has ones after it, and it starts as many occurrences as there are ways to choose of those ones.
Concept map
Preparing this local graph with the browser’s fonts…
Evidence
Each proof establishes this claim relative to its assumptions.
-
no assumptions
thm✓Lax100001.Rows
In the paper
- page 4 of this submission's paper
Lean source
| 1 | /- |
| 2 | Copyright (c) 2026 Anonymous. All rights reserved. |
| 3 | Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | Authors: ChatGPT (OpenAI), Claude (Anthropic) |
| 5 | -/ |
| 6 | import Lax100001.Counting |
| 7 | import Mathlib.Algebra.BigOperators.Group.Finset.Basic |
| 8 | import Mathlib.Data.Nat.Choose.Basic |
| 9 | |
| 10 | /-! |
| 11 | --- |
| 12 | title: Counting a zero followed by ones |
| 13 | type: theorem |
| 14 | --- |
| 15 | The ones of a binary word cut its zeros into groups. Group holds the zeros that have exactly |
| 16 | ones before them. A word with ones has the groups . The number of |
| 17 | occurrences of followed by ones is determined by the sizes of these groups: a zero |
| 18 | in group has ones after it, and it starts as many occurrences as there are ways to |
| 19 | choose of those ones. |
| 20 | -/ |
| 21 | |
| 22 | namespace Lax100001.Rows |
| 23 | |
| 24 | open Counting |
| 25 | |
| 26 | /-- The sizes of the groups of zeros of . |
| 27 | |
| 28 | Entry counts the zeros of that have exactly ones before them, and the list |
| 29 | has one entry for each of the groups, where is the number of ones. For example, |
| 30 | : the word |
| 31 | has one zero before the first one, one between the first and second ones, none between the second |
| 32 | and third ones, and one after the third one. -/ |
| 33 | def groups : Word → List ℕ |
| 34 | | [] => [0] |
| 35 | | true :: tail => 0 :: groups tail |
| 36 | | false :: tail => |
| 37 | match groups tail with |
| 38 | | [] => [1] |
| 39 | | a :: rest => (a + 1) :: rest |
| 40 | |
| 41 | /-- The number of occurrences of followed by ones in a word is the sum over the |
| 42 | groups of the size of group times , where is the number of ones and |
| 43 | is the number of groups. For the word and the groups are |
| 44 | . The sum is |
| 45 | , which |
| 46 | is . |
| 47 | -/ |
| 48 | axiom count_zero_ones (word : Word) (r : ℕ) : |
| 49 | count word (false :: List.replicate r true) = |
| 50 | ∑ s ∈ Finset.range (groups word).length, |
| 51 | (groups word)[s]! * ((groups word).length - 1 - s).choose r |
| 52 | |
| 53 | end Lax100001.Rows |
| 54 |
Builds on
Used by
none