Documentation

LeanPool.BeyondBethe.BeyondBethe.MachineBinaryAdd

A composed polynomial-time binary adder #

The adder uses little-endian words, matching Nat.bits. Its state is pair x (pair y (pair carry accRev)). One verified FP step consumes at most one bit from each operand and prepends one result bit to accRev. Complexitylib's proved bounded-iteration machine runs this step for the length of a linear ruler; the final reversal restores little-endian order.

Encodes binary-addition state as two remaining operands, carry, and reversed accumulated bits.

Equations
Instances For

    Extracts the unprocessed bits of the first addition operand.

    Equations
    Instances For

      Extracts the unprocessed bits of the second addition operand.

      Equations
      Instances For
        theorem BeyondBethe.machineBinaryAddPack_mem_FP {x y carry accRev : List Bool → List Bool} (hx : x ∈ Complexity.FP) (hy : y ∈ Complexity.FP) (hcarry : carry ∈ Complexity.FP) (hacc : accRev ∈ Complexity.FP) :
        (fun (word : List Bool) => machineBinaryAddPack (x word) (y word) (carry word) (accRev word)) ∈ Complexity.FP
        @[simp]
        theorem BeyondBethe.machineBinaryAddX_pack (x y carry accRev : List Bool) :
        @[simp]
        theorem BeyondBethe.machineBinaryAddY_pack (x y carry accRev : List Bool) :
        @[simp]
        theorem BeyondBethe.machineBinaryAddCarry_pack (x y carry accRev : List Bool) :
        @[simp]
        theorem BeyondBethe.machineBinaryAddAccRev_pack (x y carry accRev : List Bool) :

        One-bit flag saying that an addition step remains: an operand is nonempty, or both operands are empty and the carry is true.

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

          Computes the next sum bit from the two operand heads and the carry.

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

            Computes the next carry from the two operand heads and the current carry.

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

              Consumes one bit from each operand, updates the carry, and prepends the new sum bit.

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

                Total addition transition. A completed state is a fixed point.

                Equations
                Instances For

                  A quadratic-width zero word. This is intentionally generous and makes the bounded-iteration proof independent of fine constant accounting.

                  Equations
                  Instances For

                    States reachable from the canonical pack retain a one-bit carry.

                    Equations
                    Instances For

                      Machine-level binary addition. The final accumulator is reversed from the transition-friendly most-recent-bit-first representation.

                      Equations
                      Instances For