Documentation

LeanPool.BeyondBethe.BeyondBethe.MachineBetheFloorScan

Finite-word row-major scan of all Bethe floor constraints #

The scan keeps unary row and column counters, a one-bit found flag, a one-bit done flag, and the immutable input payload. It examines the recovered (m+1)-by-(m+1) matrix in row-major order and freezes at the first strict floor violation. Its iteration ruler is constructed, in polynomial time, as exactly (m+1)^2 unary bits on canonical inputs.

Input and state layout #

Extracts the unary dimension parameter from the floor-scan input.

Equations
Instances For

    Extracts the paired threshold and coordinate vector from the floor-scan input.

    Equations
    Instances For

      Extracts the encoded rational floor threshold from the scan input.

      Equations
      Instances For

        Extracts the encoded rational coordinate vector from the scan input.

        Equations
        Instances For
          def BeyondBethe.machineBetheFloorScanPack (row column found done payload : List Bool) :

          Encodes a floor-scan state as row, column, found flag, done flag, and input payload.

          Equations
          Instances For

            Extracts the current unary row index from the floor-scan state.

            Equations
            Instances For

              Extracts the current unary column index from the floor-scan state.

              Equations
              Instances For

                Extracts the flag recording discovery of an entry below the floor threshold.

                Equations
                Instances For

                  Tests whether the current column ruler equals the dimension ruler, marking the last column.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Assembles the dimension, current indices, and coordinate vector for an affine-entry query.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Tests whether the current affine matrix entry violates the floor constraint.

                      Equations
                      Instances For

                        Increments the current unary row index by appending one bit.

                        Equations
                        Instances For

                          Increments the current unary column index by appending one bit.

                          Equations
                          Instances For

                            Sets the found flag while retaining the current indices and input payload.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Sets the done flag while retaining the current indices and input payload.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Advances to the next row and resets the column index to zero.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Advances the column index while retaining the current row and flags.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    Advances in row-major order, marking completion after the final matrix entry.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For

                                      Marks a floor violation at the current entry or advances to the next entry.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For

                                        Performs one floor-scan step, leaving found or completed states fixed.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For

                                          Initializes the floor scan at row and column zero with both flags false.

                                          Equations
                                          Instances For

                                            Exact polynomial iteration ruler #

                                            Computes the square of one plus the dimension-ruler length as binary bits.

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For

                                              Supplies the binary-multiplication width bound used to construct the scan ruler.

                                              Equations
                                              Instances For

                                                Converts the square of the matrix order to a unary iteration ruler within the guard bound.

                                                Equations
                                                Instances For

                                                  Applies the binary-multiplication width bound twice to bound encoded scan components.

                                                  Equations
                                                  Instances For

                                                    Packs five copies of the state envelope to provide an encoded-state width bound.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For

                                                      The public result is a found bit followed by the unary row and column of the first violation. When the bit is false the two counters are ignored.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For

                                                        Polynomial-time closure #

                                                        A global state envelope for the Cobham iteration #

                                                        @[simp]
                                                        theorem BeyondBethe.machineBetheFloorScanRow_pack (row column found done payload : List Bool) :
                                                        machineBetheFloorScanRow (machineBetheFloorScanPack row column found done payload) = row
                                                        @[simp]
                                                        theorem BeyondBethe.machineBetheFloorScanColumn_pack (row column found done payload : List Bool) :
                                                        machineBetheFloorScanColumn (machineBetheFloorScanPack row column found done payload) = column
                                                        @[simp]
                                                        theorem BeyondBethe.machineBetheFloorScanFound_pack (row column found done payload : List Bool) :
                                                        machineBetheFloorScanFound (machineBetheFloorScanPack row column found done payload) = found
                                                        @[simp]
                                                        theorem BeyondBethe.machineBetheFloorScanDone_pack (row column found done payload : List Bool) :
                                                        machineBetheFloorScanDone (machineBetheFloorScanPack row column found done payload) = done
                                                        @[simp]
                                                        theorem BeyondBethe.machineBetheFloorScanPayload_pack (row column found done payload : List Bool) :
                                                        machineBetheFloorScanPayload (machineBetheFloorScanPack row column found done payload) = payload
                                                        def BeyondBethe.MachineBetheFloorScanStateBound (word : List Bool) (iterations : ℕ) (state : List Bool) :

                                                        Bounds a canonically packed scan state's index lengths, single-bit flags, and payload length.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          @[simp]
                                                          theorem BeyondBethe.machineIfHead_nil_floorScan (whenTrue whenFalse : List Bool) :
                                                          machineIfHead [] whenTrue whenFalse = []
                                                          theorem BeyondBethe.machineBetheFloorScanFinish_bound {word state : List Bool} {iterations : ℕ} (hs : MachineBetheFloorScanStateBound word iterations state) :
                                                          theorem BeyondBethe.machineBetheFloorScanAdvance_bound {word state : List Bool} {iterations : ℕ} (hs : MachineBetheFloorScanStateBound word iterations state) :
                                                          theorem BeyondBethe.machineBetheFloorScanProcess_bound {word state : List Bool} {iterations : ℕ} (hs : MachineBetheFloorScanStateBound word iterations state) :
                                                          theorem BeyondBethe.machineBetheFloorScanStep_bound {word state : List Bool} {iterations : ℕ} (hs : MachineBetheFloorScanStateBound word iterations state) :

                                                          Canonical ruler semantics #

                                                          Encodes a dimension, rational threshold, and coordinate vector as a canonical floor-scan input.

                                                          Equations
                                                          Instances For

                                                            Exact state semantics on canonical inputs #

                                                            def BeyondBethe.betheFloorScanNextFin {m : ℕ} (i : Fin (m + 1)) :
                                                            Fin (m + 1)

                                                            Successor inside Fin (m+1), fixing the last element. The scan invokes this operation only away from the last element.

                                                            Equations
                                                            Instances For
                                                              @[simp]
                                                              theorem BeyondBethe.betheFloorScanNextFin_val {m : ℕ} (i : Fin (m + 1)) (hi : i ≠ Fin.last m) :
                                                              ↑(betheFloorScanNextFin i) = ↑i + 1

                                                              Typed semantic state mirrored by the finite-word scan.

                                                              • row : Fin (m + 1)

                                                                Current row of the affine matrix, whose indices range from zero through m.

                                                              • column : Fin (m + 1)

                                                                Current column of the affine matrix, whose indices range from zero through m.

                                                              • found : Bool

                                                                Records whether the scan has found an entry below the floor threshold.

                                                              • done : Bool

                                                                Records whether the scan has examined all matrix entries without stopping at a violation.

                                                              Instances For

                                                                Initializes the semantic floor scan at the first matrix entry with both flags false.

                                                                Equations
                                                                Instances For

                                                                  Scans one affine matrix entry in row-major order, stopping at a floor violation or completion.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For

                                                                    Encodes a semantic scan state with unary indices, Boolean flags, and its canonical input.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      @[simp]
                                                                      theorem BeyondBethe.machineBetheFloorScanMarkFound_canonicalState {m : ℕ} (delta : RawRat) (y : Fin (m * m) → ℚ) (state : BetheFloorScanSemanticState m) :
                                                                      machineBetheFloorScanMarkFound (machineBetheFloorScanCanonicalState delta y state) = machineBetheFloorScanCanonicalState delta y { row := state.row, column := state.column, found := true, done := state.done }
                                                                      @[simp]
                                                                      theorem BeyondBethe.machineBetheFloorScanFinish_canonicalState {m : ℕ} (delta : RawRat) (y : Fin (m * m) → ℚ) (state : BetheFloorScanSemanticState m) :
                                                                      machineBetheFloorScanFinish (machineBetheFloorScanCanonicalState delta y state) = machineBetheFloorScanCanonicalState delta y { row := state.row, column := state.column, found := state.found, done := true }
                                                                      @[simp]
                                                                      theorem BeyondBethe.machineBetheFloorScanAdvanceRow_canonicalState {m : ℕ} (delta : RawRat) (y : Fin (m * m) → ℚ) (state : BetheFloorScanSemanticState m) (hrow : state.row ≠ Fin.last m) :
                                                                      @[simp]
                                                                      theorem BeyondBethe.machineBetheFloorScanAdvanceColumn_canonicalState {m : ℕ} (delta : RawRat) (y : Fin (m * m) → ℚ) (state : BetheFloorScanSemanticState m) (hcolumn : state.column ≠ Fin.last m) :

                                                                      Runs the semantic scan for (m + 1)^2 steps, enough to examine every matrix entry.

                                                                      Equations
                                                                      Instances For

                                                                        Encodes the found flag and the row and column at which the semantic scan stopped.

                                                                        Equations
                                                                        Instances For

                                                                          Mathematical correctness of the row-major semantic scan #

                                                                          def BeyondBethe.betheFloorScanOrdinal {m : ℕ} (i j : Fin (m + 1)) :

                                                                          Numbers matrix entries in row-major order by i * (m + 1) + j.

                                                                          Equations
                                                                          Instances For
                                                                            def BeyondBethe.BetheFloorScanInvariant {m : ℕ} (delta : RawRat) (y : Fin (m * m) → ℚ) (k : ℕ) (state : BetheFloorScanSemanticState m) :

                                                                            Records either the first violating entry, successful completion, or the next unchecked ordinal.

                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For
                                                                              theorem BeyondBethe.betheFloorScanExtendPrior {m k : ℕ} {delta : RawRat} {y : Fin (m * m) → ℚ} {row column : Fin (m + 1)} (hordinal : betheFloorScanOrdinal row column = k) (hprior : ∀ (i j : Fin (m + 1)), betheFloorScanOrdinal i j < k → delta.value ≤ betheAffineMatrixQ y i j) (hcurrent : delta.value ≤ betheAffineMatrixQ y row column) (i j : Fin (m + 1)) :
                                                                              theorem BeyondBethe.betheFloorScanSemanticStep_invariant {m k : ℕ} (delta : RawRat) (y : Fin (m * m) → ℚ) (state : BetheFloorScanSemanticState m) (hinvariant : BetheFloorScanInvariant delta y k state) :