Documentation

Complexity.Computability.Circuit.Boolean.Iteration.PrimeCycles

Permutations with one prime cycle per hash class #

This module formalizes the combinatorial and circuit-complexity structure of permutations on BitString (m + K) that act as a disjoint union of prime-length cycles indexed by m-bit hash classes. States of BitString (m + K) are pairs (r, b) of an m-bit class word r and a K-bit position word b. Given a cycle length ℓ r < 2 ^ K for each class r, the step map advances b by 1 modulo ℓ r when b < ℓ r and fixes every other state.

Main definitions #

Main results #

References #

Disjoint prime-cycle permutations indexed by hash classes #

The m-bit class word in the first m coordinates.

Instances For

    The K-bit position word in the last K coordinates.

    Instances For

      Pack an m-bit class word and a K-bit position word into BitString (m + K).

      Instances For
        @[simp]

        Extracting the class word from pack r b recovers r.

        @[simp]

        Extracting the position word from pack r b recovers b.

        @[simp]

        Repacking the class and position words of x recovers x.

        def Cslib.Circuits.Boolean.Iteration.PrimeCycles.power {m K : ℕ} (ℓ : BitVec m → ℕ) (T : ℕ) (x : BitString (m + K)) :
        BitString (m + K)

        The T-th power: advance the position by T modulo ℓ r on the cycle b < ℓ r, and fix every other state (in particular every state with ℓ r ≤ 1).

        Instances For

          The single-step permutation power ℓ 1.

          Instances For
            @[simp]

            The 0-th power power ℓ 0 is the identity map.

            theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.iterate_step {m K : ℕ} (ℓ : BitVec m → ℕ) (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (T : ℕ) :
            (step ℓ)^[T] = power ℓ T

            The T-th iterate of step ℓ is power ℓ T.

            theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.power_apply_mod {m K : ℕ} (ℓ : BitVec m → ℕ) (T : ℕ) (r : BitVec m) (b : BitVec K) :
            power ℓ T (pack r b) = pack r (BitVec.ofNat K (if 0 < ℓ r ∧ b.toNat < ℓ r then (b.toNat + T % ℓ r) % ℓ r else b.toNat))

            (step ℓ)^[T] (pack r b) depends on T only through T % ℓ r.

            theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.step_bijective {m K : ℕ} (ℓ : BitVec m → ℕ) (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) :

            When every cycle length is below 2 ^ K, step ℓ is a bijection on BitString (m + K).

            theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.power_eq_power_iff {m K : ℕ} (ℓ : BitVec m → ℕ) (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (S T : ℕ) :
            power ℓ S = power ℓ T ↔ ∀ (r : BitVec m), 1 < ℓ r → S ≡ T [MOD ℓ r]

            Two powers agree iff the exponents agree modulo every nontrivial cycle length.

            The nontrivial classes (1 < ℓ r).

            Instances For

              The common-period product of the nontrivial cycle lengths (which equals the exact permutation order under LengthsCoprime).

              Instances For

                The common-period product order ℓ of the nontrivial cycle lengths is positive.

                Pairwise coprimality of the nontrivial cycle lengths.

                Instances For
                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.modEq_order_iff {m : ℕ} {ℓ : BitVec m → ℕ} (hc : LengthsCoprime ℓ) (S T : ℕ) :
                  S ≡ T [MOD order ℓ] ↔ ∀ (r : BitVec m), 1 < ℓ r → S ≡ T [MOD ℓ r]

                  Under LengthsCoprime ℓ, two exponents are congruent modulo order ℓ iff they are congruent modulo every nontrivial cycle length ℓ r.

                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.iterate_eq_iterate_iff {m K : ℕ} {ℓ : BitVec m → ℕ} (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (hc : LengthsCoprime ℓ) (S T : ℕ) :
                  (step ℓ)^[S] = (step ℓ)^[T] ↔ S ≡ T [MOD order ℓ]

                  With pairwise coprime nontrivial lengths, (step ℓ)^[S] = (step ℓ)^[T] iff S ≡ T [MOD order ℓ].

                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.iterate_eq_id_iff {m K : ℕ} {ℓ : BitVec m → ℕ} (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (hc : LengthsCoprime ℓ) (T : ℕ) :
                  (step ℓ)^[T] = id ↔ order ℓ ∣ T

                  (step ℓ)^[T] = id iff order ℓ ∣ T.

                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.iterate_injective {m K : ℕ} {ℓ : BitVec m → ℕ} (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (hc : LengthsCoprime ℓ) :
                  Function.Injective fun (T : Fin (order ℓ)) => (step ℓ)^[↑T]

                  Distinct residues modulo order ℓ yield distinct powers.

                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.card_range_iterate {m K : ℕ} {ℓ : BitVec m → ℕ} (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (hc : LengthsCoprime ℓ) :
                  Nat.card ↑(Set.range fun (T : ℕ) => (step ℓ)^[T]) = order ℓ

                  The number of distinct powers of step ℓ is order ℓ.

                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.exists_hard_power_of_budget_lt {m K : ℕ} {ℓ : BitVec m → ℕ} (hℓ : ∀ (r : BitVec m), ℓ r < 2 ^ K) (hc : LengthsCoprime ℓ) (q : ℕ) (large : signature.orderedBudget (m + K) (m + K) q < order ℓ) :
                  ∃ T < order ℓ, ∀ (out : Circuit signature (m + K) (m + K)), out.Computes interpretation (step ℓ)^[T] → q < out.size

                  If the ordered-syntax budget for q gates is below order ℓ, some power below order ℓ requires more than q gates.

                  Hash-class prime candidates #

                  The z-th candidate of class r: 2 ^ (m + g) + (r xor f z) * 2 ^ g + z.

                  Instances For

                    The class length: the prime candidate with least z < 2 ^ g, or 1 if there is none.

                    Instances For
                      theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.candidate_injective {m g : ℕ} (f : ℕ → ℕ) {r s : BitVec m} {y z : ℕ} (hy : y < 2 ^ g) (hz : z < 2 ^ g) (h : candidate g f r y = candidate g f s z) :
                      r = s

                      Different classes have disjoint candidate sets.

                      theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.classPrime_bounds {m g : ℕ} {f : ℕ → ℕ} (hf : ∀ (z : ℕ), f z < 2 ^ m) (r : BitVec m) :
                      classPrime m g f r < 2 ^ (m + g + 1) ∧ (1 < classPrime m g f r → 2 ^ (m + g) ≤ classPrime m g f r ∧ Nat.Prime (classPrime m g f r))

                      Every classPrime m g f r is below 2 ^ (m + g + 1), and any nontrivial classPrime m g f r is a prime at least 2 ^ (m + g).

                      Nontrivial class lengths are distinct primes, hence pairwise coprime.

                      theorem Cslib.Circuits.Boolean.Iteration.PrimeCycles.near_landau_lower_bound (m g : ℕ) (f : ℕ → ℕ) (hf : ∀ (z : ℕ), f z < 2 ^ m) (q h : ℕ) (hw : m + (m + g + 1) + q + 1 ≤ 2 ^ h) (large : 3 * q + h * (2 * q + (m + (m + g + 1)) + 1) < (m + g) * (active (classPrime m g f)).card) :
                      Function.Bijective (step (classPrime m g f)) ∧ 2 ^ ((m + g) * (active (classPrime m g f)).card) ≤ order (classPrime m g f) ∧ ∃ T < order (classPrime m g f), ∀ (out : Circuit signature (m + (m + g + 1)) (m + (m + g + 1))), out.Computes interpretation (step (classPrime m g f))^[T] → q < out.size

                      Lower bound for the hash-class permutation: for any mixing function f with values below 2 ^ m, put K = m + g + 1 and let ℓ r be the least-index prime candidate of class r. The step is a bijection of BitString (m + K), its order is at least 2 ^ ((m + g) * c) where c is the number of active classes, and if the ordered-syntax exponent for q gates is below (m + g) * c, some power F^[T] with T < order requires more than q gates.

                      Bundled prime-cycle permutation data and circuit synthesis #

                      Bundled cycle-length specification for m-bit hash classes and K-bit cycle positions, with pairwise coprime nontrivial cycle lengths.

                      Instances For

                        The effective cycle length of class r, equal to D.length r when 1 < D.length r and 1 otherwise.

                        Instances For

                          Natural-number position update for class r in one step.

                          Instances For

                            Single-step map on BitString (m + K).

                            Instances For

                              The single-step map D.step is a bijection on BitString (m + K).

                              The permutation of BitString (m + K) induced by D.step.

                              Instances For

                                The order of D.step, equal to the product of the nontrivial cycle lengths.

                                Instances For

                                  D.step^[T] is the identity iff D.period divides T.

                                  Powers D.step^[T] for T < D.period are pairwise distinct.

                                  theorem Cslib.Circuits.Boolean.Iteration.PrimeCycleData.exists_hard_power {m K : ℕ} (D : PrimeCycleData m K) (q : ℕ) (large : signature.orderedBudget (m + K) (m + K) q < D.period) :
                                  ∃ T < D.period, ∀ (out : Circuit signature (m + K) (m + K)), out.Computes interpretation D.step^[T] → q < out.size

                                  If the ordered-syntax budget for q gates is strictly below D.period, some power D.step^[T] with T < D.period requires more than q gates.

                                  The number of states moved by D.step is at most 2 ^ (m + K).

                                  The K-bit cycle-length map on BitString m associated with D.

                                  Instances For
                                    @[simp]

                                    Packing D.lengthBits r into a BitVec K gives BitVec.ofNat K (D.length (word r)).

                                    The K-bit remainder map r ↦ T % D.length r (or 0 when D.length r = 0) on BitString m.

                                    Instances For
                                      @[simp]

                                      Packing D.remainderBits T r into a BitVec K gives T % D.length (word r) (or 0 when D.length (word r) = 0).

                                      theorem Cslib.Circuits.Boolean.Iteration.PrimeCycleData.step_circuit {m K : ℕ} (D : PrimeCycleData m K) (cLen : Circuit signature m K) (hLen : cLen.Computes interpretation D.lengthBits) :
                                      ∃ (out : Circuit signature (m + K) (m + K)), out.Computes interpretation D.step ∧ out.size ≤ cLen.size + 50 * K + 20

                                      Given a circuit cLen computing the K-bit class length D.lengthBits, the single-step permutation D.step has a circuit of size at most cLen.size + 50 * K + 20.

                                      theorem Cslib.Circuits.Boolean.Iteration.PrimeCycleData.power_circuit {m K : ℕ} (D : PrimeCycleData m K) (T : ℕ) (cLen cRem : Circuit signature m K) (hLen : cLen.Computes interpretation D.lengthBits) (hRem : cRem.Computes interpretation (D.remainderBits T)) :
                                      ∃ (out : Circuit signature (m + K) (m + K)), out.Computes interpretation D.step^[T] ∧ out.size ≤ cLen.size + cRem.size + 100 * (K + 1)

                                      Given circuits cLen for D.lengthBits and cRem for D.remainderBits T, the T-th power D.step^[T] has a circuit of size at most cLen.size + cRem.size + 100 * (K + 1).

                                      def Cslib.Circuits.Boolean.Iteration.PrimeCycleData.ofHash (m g : ℕ) (f : ℕ → ℕ) (hf : ∀ (z : ℕ), f z < 2 ^ m) :
                                      PrimeCycleData m (m + g + 1)

                                      Construct PrimeCycleData from the hash-class prime construction PrimeCycles.classPrime.

                                      Instances For