Documentation

LeanPool.MatrixMultiplicationAllFields.LinearAlgebra.MatrixMultiplication.Arithmetic.Programs

Division-free arithmetic programs over a field and their operation counts.

def MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Gate.mapRegister {F : Type u_1} {Input : Type u_2} {R : Type u_3} {S : Type u_4} (f : R → S) :
Gate F Input R → Gate F Input S

Relabel a gate's register references without changing its input wires.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Gate.eval_mapRegister {F : Type u_1} [Field F] {Input : Type u_2} {R : Type u_3} {S : Type u_4} (g : Gate F Input R) (f : R → S) (inputs : Input → F) (registers : S → F) :
    eval inputs registers (mapRegister f g) = eval inputs (fun (i : R) => registers (f i)) g
    @[simp]
    theorem MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Gate.cost_mapRegister {F : Type u_1} {Input : Type u_2} {R : Type u_3} {S : Type u_4} (g : Gate F Input R) (f : R → S) :

    Locate an earlier program's registers after appending a second program.

    Equations
    Instances For

      Locate the appended program's registers in the combined register space.

      Equations
      Instances For
        def MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Program.append {F : Type u_1} {Input : Type u_2} {r : ℕ} (p : Program F Input r) {s : ℕ} :
        Program F Input s → Program F Input (r + s)

        Concatenate independent programs, relabelling the second program's register references.

        Equations
        Instances For
          theorem MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Program.eval_append_new {F : Type u_1} [Field F] {Input : Type u_2} {r s : ℕ} (p : Program F Input r) (q : Program F Input s) (inputs : Input → F) (i : Fin s) :
          (p.append q).eval inputs (newIndex r s i) = q.eval inputs i
          theorem MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Program.eval_append_old {F : Type u_1} [Field F] {Input : Type u_2} {r s : ℕ} (p : Program F Input r) (q : Program F Input s) (inputs : Input → F) (i : Fin r) :
          (p.append q).eval inputs (oldIndex r s i) = p.eval inputs i
          @[simp]
          theorem MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Program.cost_append {F : Type u_1} {Input : Type u_2} {r s : ℕ} (p : Program F Input r) (q : Program F Input s) :
          (p.append q).cost = p.cost + q.cost

          Division-free arithmetic expressions built from inputs, scalars, addition, subtraction and multiplication.

          Instances For
            structure MatrixMultiplicationAllFields.MatrixMultiplication.Arithmetic.Expression.Compiled {F : Type u_1} [Field F] {Input : Type u_2} (e : Expression F Input) :
            Type (max u_1 u_2)

            A compiled expression with certified semantics and exact operation count.

            • registers : ℕ

              Number of registers allocated for the compiled expression.

            • program : Program F Input self.registers

              The straight-line program computing the expression.

            • output : Fin self.registers

              Register containing the expression's value.

            • correct (inputs : Input → F) : self.program.eval inputs self.output = eval inputs e
            • cost_eq : self.program.cost = e.cost
            Instances For

              Compile an expression while certifying its evaluation and operation count.

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