Documentation

CsdLean4.Empirical.CSD.Algorithms.ShorFlow

Empirical/CSD: Shor's period finding as a flow on Σ #

Category: 3-Local (CSD-side twin of Empirical/QM/Algorithms/ShorCore.lean).

ShorCore.lean proves the order-finding circuit on the QM side: on the joint register Fin T × ZMod N, the modular-exponentiation oracle followed by the inverse Fourier transform on the counting register sends the prepared state uniformCount ⊗ |1⟩ to a state whose counting register reads each multiple s·(T/r) of the order's phase with probability 1/r, and nothing else (shor_order_distribution, shor_order_distribution_zero, the ideal case r ∣ T). This file is the same circuit on the CSD side: the oracle is the permutation matrix of (c, y) ↦ (c, (a^c)⁻¹ y), the inverse Fourier transform is the Kronecker factor (qftMatrix T)ᴴ ⊗ 1, their product is a Circuit and hence a flow on the joint register's sector, and the readout of the counting register is the union of the record basins of the joint outcomes (c, y) over the work register.

⚠️ Honest scope. The QM-side theorems carry the mathematics, in the ideal case r ∣ T; this file adds the ontic reading and no new analysis. The circuit is one unitary; no gate decomposition of the modular exponentiation and no Hamiltonian generating it is modelled (R-015). The classical post-processing (continued fractions, the random base) is ShorRecovery.lean / ShorCapstone.lean on the QM side and is not restated here.

References: Empirical/QM/Algorithms/ShorCore.lean; Empirical/CSD/Algorithms/CircuitFlow.lean; specs/BACKLOG.md #34; specs/future-work.md.

Permutation matrices are unitary #

The conjugate transpose of a permutation matrix is its transpose (its entries are 0 and 1).

The transpose of a permutation matrix is the matrix of the inverse permutation.

The oracle and the inverse Fourier transform as matrices #

noncomputable def CSD.Empirical.CSDBridge.Algorithms.modexpPerm {N : ℕ} (T : ℕ) (a : (ZMod N)ˣ) :

The permutation (c, y) ↦ (c, (a^c)⁻¹ · y) whose pullback is the modular-exponentiation oracle jointModexp.

Equations
Instances For
    theorem CSD.Empirical.CSDBridge.Algorithms.modexpPerm_apply {N : ℕ} (T : ℕ) (a : (ZMod N)ˣ) (p : Fin T × ZMod N) :
    (modexpPerm T a) p = (p.1, ↑(a ^ ↑p.1)⁻¹ * p.2)
    noncomputable def CSD.Empirical.CSDBridge.Algorithms.modexpMatrix {N : ℕ} (T : ℕ) (a : (ZMod N)ˣ) :
    Matrix (Fin T × ZMod N) (Fin T × ZMod N) ℂ

    The oracle as a matrix: the permutation matrix of modexpPerm.

    Equations
    Instances For

      The oracle matrix acts as jointModexp.

      noncomputable def CSD.Empirical.CSDBridge.Algorithms.qftInvJoint {N : ℕ} (T : ℕ) :
      Matrix (Fin T × ZMod N) (Fin T × ZMod N) ℂ

      The inverse Fourier transform on the counting register as a matrix on the joint register: (qftMatrix T)ᴴ ⊗ 1.

      Equations
      Instances For

        The joint inverse-Fourier matrix acts as qftInvCount.

        The joint inverse-Fourier matrix is unitary.

        Period finding as a circuit and as a flow #

        noncomputable def CSD.Empirical.CSDBridge.Algorithms.shorMatrix {N : ℕ} [NeZero N] (T : ℕ) (a : (ZMod N)ˣ) :
        Matrix (Fin T × ZMod N) (Fin T × ZMod N) ℂ

        Shor's period-finding circuit as a matrix: the oracle, then the inverse Fourier transform on the counting register.

        Equations
        Instances For

          The circuit matrix acts as the circuit.

          The circuit matrix is unitary.

          noncomputable def CSD.Empirical.CSDBridge.Algorithms.shorCircuit {N : ℕ} [NeZero N] (T : ℕ) [NeZero T] (a : (ZMod N)ˣ) :

          Period finding as a circuit on the joint register.

          Equations
          Instances For

            The prepared state uniformCount ⊗ |1⟩ is a unit vector.

            The ready point: the prepared state uniformCount ⊗ |1⟩ as a point of the sector.

            Equations
            Instances For

              The Born weight of the joint outcome (c, y)'s basin at the flowed ready point is the circuit's output amplitude squared.

              ★★ Shor on Σ. In the ideal case r ∣ T, at the point reached from the ready point by the flow, the counting-register outcome s·(T/r) — the union over the work register of the record basins of the joint outcomes (s·(T/r), y) — has Born weight 1/r.

              theorem CSD.Empirical.CSDBridge.Algorithms.shor_flow_born_count_zero {N : ℕ} [NeZero N] (T : ℕ) [NeZero T] (a : (ZMod N)ˣ) (hr : 0 < QM.Shor.ord a) (hT : 0 < T) (hdvd : QM.Shor.ord a ∣ T) (c : Fin T) (hc : ∀ (s : Fin (QM.Shor.ord a)), ↑c ≠ ↑s * (T / QM.Shor.ord a)) :

              ★ The other counting outcomes have weight zero on Σ.