Documentation

LeanPool.FourAP.Words

Finite safe words #

This file formalizes the parity restrictions of π’ž(P) used in the Extension Lemma, and Lemma 1 (reverse binary order is safe). The two arithmetic-progression equations used below include both increasing and decreasing progressions.

The words Pβ‚€ and P₁ in the Extension Lemma: retain one parity and rescale it by 2x+p ↦ x.

Equations
Instances For
    @[simp]

    Parity restriction respects the order of concatenated words, as used when the proof forms the extension Q = P O E.

    @[simp]
    theorem FourAP.parityWord_cons (p n : β„•) (P : List β„•) :
    parityWord p (n :: P) = if n % 2 = p then n / 2 :: parityWord p P else parityWord p P

    The recursive description of the parity-restricted word in Lemma 2.

    theorem FourAP.mem_parityWord_iff {p x : β„•} (hp : p < 2) (P : List β„•) :

    A number occurs in Pβ‚š exactly when its original, unscaled value occurs in P. This is the membership assertion implicit in the parity split.

    theorem FourAP.nodup_parityWord {p : β„•} (hp : p < 2) {P : List β„•} (hP : P.Nodup) :

    Rescaling one parity preserves distinctness; hence the parity words appearing in the Extension Lemma are again words without repetitions.

    theorem FourAP.nodup_of_parityWord {Q : List β„•} (h0 : (parityWord 0 Q).Nodup) (h1 : (parityWord 1 Q).Nodup) :

    If both parity words have distinct entries, the original word does too. This is the distinctness argument for the new word Q = P O E in Lemma 2.

    theorem FourAP.completion_parity {p : β„•} (hp : p < 2) (P : List β„•) (a b : β„•) :
    Completion bits P (2 * a + p) (2 * b + p) ↔ Completion bits (parityWord p P) a b

    Restricting π’ž(P) to parity p and rescaling gives exactly π’ž(Pβ‚š). This formalizes the self-similarity argument in the first inductive paragraph of the Extension Lemma.

    theorem FourAP.safe_parity {p : β„•} (hp : p < 2) {P : List β„•} (hP : Safe bits P) :

    The parity words of a safe word are safe (Extension Lemma, paragraph beginning β€œBoth Pβ‚€ and P₁ are safe”).

    @[simp]
    theorem FourAP.parityWord_map_same {p : β„•} (hp : p < 2) (P : List β„•) :
    parityWord p (List.map (fun (x : β„•) => 2 * x + p) P) = P

    Normalizing a word already rescaled into parity p recovers the original word, as in the construction of the suffixes E and O.

    @[simp]
    theorem FourAP.parityWord_map_other {p q : β„•} (hq : q < 2) (hpq : p β‰  q) (P : List β„•) :
    parityWord p (List.map (fun (x : β„•) => 2 * x + q) P) = []

    Projecting a word of the other parity yields the empty word. This justifies separating the new odd and even suffixes of Q = P O E.

    theorem FourAP.reverse_bits_of_completion {P : List β„•} (hs : List.Pairwise (fun (a b : β„•) => bits b a) P) {a b : β„•} (hab : Completion bits P a b) (hb : b ∈ P) :
    bits b a

    Inside a word listed in reverse ◁ order, an earlier entry is later in ◁. This is the first comparison used in the two-prefix-term case of Lemma 1.

    theorem FourAP.safe_of_reverse_pairwise {P : List β„•} (hn : P.Nodup) (hs : List.Pairwise (fun (a b : β„•) => bits b a) P) :

    Lemma 1 of the paper. Every finite word of distinct integers listed in reverse ◁ order is safe. The proof separates the cases of at least three, exactly two, and at most one progression term in the finite prefix.

    The non-strict reverse of ◁, used solely for sorting the finite set in Lemma 1 and in the base case of the Extension Lemma.

    Equations
    Instances For
      @[instance_reducible]

      The finite sorting relation in Lemma 1 has a computable comparison.

      Equations

      Transitivity permits sorting in the reverse order used in Lemma 1.

      Antisymmetry makes the reverse listing of a finite set unique.

      Any two integers can be compared when forming the reverse listing.

      List a finite set in reverse ◁ order, exactly as prescribed in Lemma 1. This definition is computable, using mathlib's finite-set merge sort.

      Equations
      Instances For
        @[simp]

        The reverse listing contains each and only each prescribed entry.

        The reverse listing contains no repeated entry, as required of a word.

        The reverse listing has the strict reverse order required in Lemma 1.

        Lemma 1 specialized to the canonical reverse listing of a finite set.

        If zero belongs to a finite set, its reverse binary listing begins with zero. This is the sorting observation in the base case of Lemma 2.

        theorem FourAP.reverseWord_union_prefix {P : List β„•} (hP : P.Nodup) (hzero : βˆ€ x ∈ P, x = 0) (T : Finset β„•) :

        Canonical form of the base-case extension in Lemma 2. Sorting P βˆͺ T in reverse binary order preserves the old prefix whenever all its entries are zero. This also connects the executable construction to the proof.