MindFormal v1.0.0One Mind

MindFormal.Tools.A705SupportPrograms.NorCompile

25.7 part 4's finite syntactic compilation: every Boolean map of k ≥ 1 input bits to o output bits compiles, by disjunctive normal form and the NOR identities, into a straight-line NOR program on registers, with at most o(4k+4)2^k gates (PAGE2's loose bound).

A NOR instruction: read registers a, b; write their NOR to d.

Instances For
    theorem MindFormal.A705SupportPrograms.runGates_append (R : ℕ → Bool) (l₁ l₂ : List Gate) :
    runGates R (l₁ ++ l₂) = runGates (runGates R l₁) l₂

    A gate list writes only registers in S.

    Equations
    Instances For
      theorem MindFormal.A705SupportPrograms.runGates_other (R : ℕ → Bool) (gs : List Gate) (S : ℕ → Prop) (h : WritesIn gs S) (r : ℕ) (hr : ¬S r) :
      runGates R gs r = R r
      @[reducible, inline]

      Registers for k inputs: inputs 0…k-1, the constant zero k, scratch k+1…k+4.

      Equations
      Instances For
        @[reducible, inline]
        Equations
        Instances For
          @[reducible, inline]
          Equations
          Instances For
            @[reducible, inline]
            Equations
            Instances For
              @[reducible, inline]
              Equations
              Instances For

                The mismatch literal x_i ≠ v_i into dst, using tmp.

                Equations
                Instances For
                  theorem MindFormal.A705SupportPrograms.mismatch_run (R : ℕ → Bool) (i : ℕ) (vi : Bool) (dst tmp : ℕ) :
                  runGates R (mismatchGates i vi dst tmp) dst = (R i != vi) ∧ ∀ (r : ℕ), r ≠ dst → r ≠ tmp → runGates R (mismatchGates i vi dst tmp) r = R r

                  The OR of the mismatch literals of indices < i, accumulated in rOr.

                  Equations
                  Instances For
                    theorem MindFormal.A705SupportPrograms.writesIn_append {l₁ l₂ : List Gate} {S : ℕ → Prop} (h₁ : WritesIn l₁ S) (h₂ : WritesIn l₂ S) :
                    WritesIn (l₁ ++ l₂) S
                    theorem MindFormal.A705SupportPrograms.mismatch_writes (i : ℕ) (vi : Bool) (dst tmp : ℕ) {S : ℕ → Prop} (hd : S dst) (ht : S tmp) :
                    WritesIn (mismatchGates i vi dst tmp) S
                    theorem MindFormal.A705SupportPrograms.orChain_writes (k : ℕ) (v : ℕ → Bool) (i : ℕ) :
                    WritesIn (orChain k v i) fun (r : ℕ) => r = rOr k ∨ r = rT k ∨ r = rM k
                    theorem MindFormal.A705SupportPrograms.or_step (R : ℕ → Bool) (o m t : ℕ) :
                    runGates R [{ a := o, b := m, d := t }, { a := t, b := t, d := o }] o = (R o || R m)
                    theorem MindFormal.A705SupportPrograms.minterm_tail (R : ℕ → Bool) (a o t m : ℕ) (hat : a ≠ t) :
                    runGates R [{ a := o, b := o, d := t }, { a := a, b := t, d := m }, { a := m, b := m, d := a }] a = (R a || !R o)
                    theorem MindFormal.A705SupportPrograms.orChain_run (k : ℕ) (v R : ℕ → Bool) (i : ℕ) (hi : i < k) :
                    runGates R (orChain k v i) (rOr k) = decide (∃ j ≤ i, R j ≠ v j)

                    One minterm x = v OR-ed into rAcc.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem MindFormal.A705SupportPrograms.minterm_writes (k : ℕ) (v : ℕ → Bool) :
                      WritesIn (mintermGates k v) fun (r : ℕ) => r = rAcc k ∨ r = rOr k ∨ r = rT k ∨ r = rM k
                      theorem MindFormal.A705SupportPrograms.minterm_run (k : ℕ) (hk : 1 ≤ k) (v R : ℕ → Bool) :
                      runGates R (mintermGates k v) (rAcc k) = (R (rAcc k) || decide (∀ j < k, R j = v j))

                      Inputs as a register file prefix.

                      Equations
                      Instances For

                        The assignment read as a register predicate.

                        Equations
                        Instances For
                          noncomputable def MindFormal.A705SupportPrograms.outGates (k : ℕ) (f : (Fin k → Bool) → Bool) (o : ℕ) :

                          One output f, compiled into register o.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem MindFormal.A705SupportPrograms.minterms_run (k : ℕ) (hk : 1 ≤ k) (vs : List (Fin k → Bool)) (R : ℕ → Bool) :
                            runGates R (List.flatMap (fun (v : Fin k → Bool) => mintermGates k (asReg k v)) vs) (rAcc k) = (R (rAcc k) || decide (∃ v ∈ vs, ∀ j < k, R j = asReg k v j)) ∧ ∀ j < k, runGates R (List.flatMap (fun (v : Fin k → Bool) => mintermGates k (asReg k v)) vs) j = R j
                            theorem MindFormal.A705SupportPrograms.outGates_writes (k : ℕ) (f : (Fin k → Bool) → Bool) (o : ℕ) :
                            WritesIn (outGates k f o) fun (r : ℕ) => r = rAcc k ∨ r = rOr k ∨ r = rT k ∨ r = rM k ∨ r = o
                            theorem MindFormal.A705SupportPrograms.outGates_run (k : ℕ) (hk : 1 ≤ k) (f : (Fin k → Bool) → Bool) (o : ℕ) (ho : k + 5 ≤ o) (R : ℕ → Bool) (hz : R (rZero k) = false) :
                            (runGates R (outGates k f o) o = f fun (i : Fin k) => R ↑i) ∧ ∀ j ≤ k, runGates R (outGates k f o) j = R j
                            noncomputable def MindFormal.A705SupportPrograms.compile (k m : ℕ) (Δ : (Fin k → Bool) → Fin m → Bool) :

                            The compiled circuit of a Boolean map Δ on k ≥ 1 inputs: output j into register k + 5 + j.

                            Equations
                            Instances For
                              theorem MindFormal.A705SupportPrograms.compile_run (k m : ℕ) (hk : 1 ≤ k) (Δ : (Fin k → Bool) → Fin m → Bool) (R : ℕ → Bool) (hz : R (rZero k) = false) (j : Fin m) :
                              runGates R (compile k m Δ) (k + 5 + ↑j) = Δ (fun (i : Fin k) => R ↑i) j
                              theorem MindFormal.A705SupportPrograms.compile_length (k m : ℕ) (hk : 1 ≤ k) (Δ : (Fin k → Bool) → Fin m → Bool) :
                              (compile k m Δ).length ≤ m * ((4 * k + 4) * 2 ^ k)

                              PAGE2's loose bound: at most m(4k+4)2^k gates.