Documentation

CslibFrontier.Computability.Circuit.Arithmetic.Separation.Tape.RunSum

The certificates of a run as an assignment on a finite domain #

A certificate of a run of a multi-tape automaton (M1's Tape.Good) consists of the letters, the states, the head places and the tape contents. Here they are one function g : RunAssignment on the finite domain RunVar: a letter for every step, a state for every time, a place for every channel and time, and a content for every tape cell. Its one-hot bits, together with the code bits of the input, are the bits RunBit of a clause sum.

Two families of clauses check a certificate:

Main definitions #

Main results #

References #

The hidden variables of a certificate: a letter for every step, a state for every time, a place for every channel and time, and a content for every tape cell.

  • letter {S : Type} {n t M : ℕ} (τ : Fin t) : RunVar S n t M

    the letter of step τ

  • state {S : Type} {n t M : ℕ} (τ : Fin (t + 1)) : RunVar S n t M

    the state at time τ

  • place {S : Type} {n t M : ℕ} (z : Ch S (Fin n)) (τ : Fin (t + 1)) : RunVar S n t M

    the place of channel z at time τ

  • content {S : Type} {n t M : ℕ} (s : S) (p : Fin M) : RunVar S n t M

    the content of cell p of tape s

Instances For
    def Cslib.Circuits.Arithmetic.Separation.Tape.instDecidableEqRunVar.decEq {S✝ : Type} {n✝ t✝ M✝ : ℕ} [DecidableEq S✝] (x✝ x✝¹ : RunVar S✝ n✝ t✝ M✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    instance Cslib.Circuits.Arithmetic.Separation.Tape.instDecidableEqRunVar {S✝ : Type} {n✝ t✝ M✝ : ℕ} [DecidableEq S✝] :
    DecidableEq (RunVar S✝ n✝ t✝ M✝)
    @[instance_reducible]
    instance Cslib.Circuits.Arithmetic.Separation.Tape.instFintypeRunVar {S✝ : Type} {n✝ t✝ M✝ : ℕ} [Fintype S✝] :
    Fintype (RunVar S✝ n✝ t✝ M✝)
    def Cslib.Circuits.Arithmetic.Separation.Tape.RunVar.equivSum (S : Type) (n t M : ℕ) :
    RunVar S n t M ≃ Fin t ⊕ Fin (t + 1) ⊕ Ch S (Fin n) × Fin (t + 1) ⊕ S × Fin M

    RunVar as a sum.

    @[reducible]

    The values of the variables: letters, states, places and contents.

    Instances For
      @[instance_reducible]
      instance Cslib.Circuits.Arithmetic.Separation.Tape.instFintypeDom {Γ S Q : Type} {n t M : ℕ} [Fintype Γ] [Fintype S] [Fintype Q] (d : RunVar S n t M) :
      @[instance_reducible]
      @[reducible, inline]

      An assignment of the hidden variables.

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunAssignment.letter {Γ S Q : Type} {n t M : ℕ} (g : RunAssignment Γ S Q n t M) (τ : Fin t) :
      Letter S (Fin n) Γ

      The letters.

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunAssignment.state {Γ S Q : Type} {n t M : ℕ} (g : RunAssignment Γ S Q n t M) (τ : Fin (t + 1)) :
      Q

      The states.

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunAssignment.place {Γ S Q : Type} {n t M : ℕ} (g : RunAssignment Γ S Q n t M) (z : Ch S (Fin n)) (τ : Fin (t + 1)) :
      Fin M

      The places.

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunAssignment.content {Γ S Q : Type} {n t M : ℕ} (g : RunAssignment Γ S Q n t M) (s : S) (p : Fin M) :

      The contents.

      @[reducible, inline]

      The bits of the clause sum: the code bits of the input, and the one-hot bits of the hidden variables.

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.letter {Γ S Q : Type} {n t M N : ℕ} (τ : Fin t) (a : Letter S (Fin n) Γ) :
      RunBit Γ S Q n t M N

      The bit "the letter of step τ is a".

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.state {Γ S Q : Type} {n t M N : ℕ} (τ : Fin (t + 1)) (q : Q) :
      RunBit Γ S Q n t M N

      The bit "the state at time τ is q".

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.place {Γ S Q : Type} {n t M N : ℕ} (z : Ch S (Fin n)) (τ : Fin (t + 1)) (m : Fin M) :
      RunBit Γ S Q n t M N

      The bit "the place of z at time τ is m".

      def Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.content {Γ S Q : Type} {n t M N : ℕ} (s : S) (p : Fin M) (y : Option Γ) :
      RunBit Γ S Q n t M N

      The bit "cell p of tape s holds y".

      @[simp]
      theorem Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.elim_letter {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) (τ : Fin t) (a : Letter S (Fin n) Γ) :
      Sum.elim x (Pi.oneHot g) (letter τ a) = decide (g.letter τ = a)
      @[simp]
      theorem Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.elim_state {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) (τ : Fin (t + 1)) (q : Q) :
      Sum.elim x (Pi.oneHot g) (state τ q) = decide (g.state τ = q)
      @[simp]
      theorem Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.elim_place {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) (z : Ch S (Fin n)) (τ : Fin (t + 1)) (m : Fin M) :
      Sum.elim x (Pi.oneHot g) (place z τ m) = decide (g.place z τ = m)
      @[simp]
      theorem Cslib.Circuits.Arithmetic.Separation.Tape.RunBit.elim_content {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) (s : S) (p : Fin M) (y : Option Γ) :
      Sum.elim x (Pi.oneHot g) (content s p y) = decide (g.content s p = y)

      The weighted clauses: one for every step, letter and pair of states.

      • time : Fin t

        the step

      • letter : Letter S (Fin n) Γ

        the letter read and written

      • src : Q

        the state before the step

      • dst : Q

        the state after the step

      Instances For
        @[instance_reducible]
        instance Cslib.Circuits.Arithmetic.Separation.Tape.instDecidableEqRunStep {Γ✝ S✝ Q✝ : Type} {n✝ t✝ : ℕ} [DecidableEq Γ✝] [DecidableEq S✝] [DecidableEq Q✝] :
        DecidableEq (RunStep Γ✝ S✝ Q✝ n✝ t✝)
        def Cslib.Circuits.Arithmetic.Separation.Tape.instDecidableEqRunStep.decEq {Γ✝ S✝ Q✝ : Type} {n✝ t✝ : ℕ} [DecidableEq Γ✝] [DecidableEq S✝] [DecidableEq Q✝] (x✝ x✝¹ : RunStep Γ✝ S✝ Q✝ n✝ t✝) :
        Decidable (x✝ = x✝¹)
        @[instance_reducible]
        instance Cslib.Circuits.Arithmetic.Separation.Tape.instFintypeRunStep {Γ✝ S✝ Q✝ : Type} {n✝ t✝ : ℕ} [Fintype Γ✝] [Fintype S✝] [Fintype Q✝] :
        Fintype (RunStep Γ✝ S✝ Q✝ n✝ t✝)

        RunStep as a product.

        def Cslib.Circuits.Arithmetic.Separation.Tape.stepLits {Γ S Q : Type} {n t M N : ℕ} (r : RunStep Γ S Q n t) :
        List (RunBit Γ S Q n t M N × Bool)

        The literals of a weighted clause: the letter of the step and the two states.

        The forbidding clauses.

        • initState {Γ S : Type} {n t M : ℕ} : RunRule Γ S n t M

          the first state is the initial one

        • finalState {Γ S : Type} {n t M : ℕ} : RunRule Γ S n t M

          the last state is the final one

        • startPlace {Γ S : Type} {n t M : ℕ} (z : Ch S (Fin n)) : RunRule Γ S n t M

          a starting channel begins at place 0

        • move {Γ S : Type} {n t M : ℕ} (z : Ch S (Fin n)) (τ : Fin t) (m : Fin M) (a : Letter S (Fin n) Γ) : RunRule Γ S n t M

          the place of z advances by what step τ emits on z

        • nextInput {Γ S : Type} {n t M : ℕ} (j j' : Fin n) (m : Fin M) : RunRule Γ S n t M

          input j' starts one place after the end of input j

        • readTape {Γ S : Type} {n t M : ℕ} (s : S) (b : Bool) (τ : Fin t) (γ : Γ) (m : Fin M) : RunRule Γ S n t M

          a tape write agrees with the content

        • blankTape {Γ S : Type} {n t M : ℕ} (s : S) (b : Bool) (m p : Fin M) : RunRule Γ S n t M

          the cells beyond the last place of a tape side are blank

        • readInput {Γ S : Type} {n t M : ℕ} (j : Fin n) (τ : Fin t) (γ : Γ) (m : Fin M) : RunRule Γ S n t M

          an input read agrees with the code

        • endInput {Γ S : Type} {n t M : ℕ} (j : Fin n) (m : Fin M) : RunRule Γ S n t M

          an input ends with the separator

        Instances For
          @[instance_reducible]
          instance Cslib.Circuits.Arithmetic.Separation.Tape.instDecidableEqRunRule {Γ✝ S✝ : Type} {n✝ t✝ M✝ : ℕ} [DecidableEq Γ✝] [DecidableEq S✝] :
          DecidableEq (RunRule Γ✝ S✝ n✝ t✝ M✝)
          def Cslib.Circuits.Arithmetic.Separation.Tape.instDecidableEqRunRule.decEq {Γ✝ S✝ : Type} {n✝ t✝ M✝ : ℕ} [DecidableEq Γ✝] [DecidableEq S✝] (x✝ x✝¹ : RunRule Γ✝ S✝ n✝ t✝ M✝) :
          Decidable (x✝ = x✝¹)
          def Cslib.Circuits.Arithmetic.Separation.Tape.RunRule.equivSum (Γ S : Type) (n t M : ℕ) :
          RunRule Γ S n t M ≃ Bool ⊕ Ch S (Fin n) ⊕ Ch S (Fin n) × Fin t × Fin M × Letter S (Fin n) Γ ⊕ Fin n × Fin n × Fin M ⊕ S × Bool × Fin t × Γ × Fin M ⊕ S × Bool × Fin M × Fin M ⊕ Fin n × Fin t × Γ × Fin M ⊕ Fin n × Fin M

          RunRule as a sum.

          @[instance_reducible]

          deriving Fintype does not see through Letter, so the instance comes from equivSum.

          theorem Cslib.Circuits.Arithmetic.Separation.Tape.RunRule.card {Γ S : Type} {n t M : ℕ} [Fintype Γ] [Fintype S] :
          Fintype.card (RunRule Γ S n t M) = 2 + (2 * Fintype.card S + n) + (2 * Fintype.card S + n) * (t * (M * Fintype.card (Letter S (Fin n) Γ))) + n * (n * M) + Fintype.card S * (2 * (t * (Fintype.card Γ * M))) + Fintype.card S * (2 * (M * M)) + n * (t * (Fintype.card Γ * M)) + n * M
          def Cslib.Circuits.Arithmetic.Separation.Tape.ruleLits {Γ S Q : Type} [DecidableEq S] {n t M N : ℕ} (i e : Q) :
          RunRule Γ S n t M → List (RunBit Γ S Q n t M N × Bool)

          The literals of a forbidding clause, for the initial state i and the final state e.

          The forbidding clauses that are in force; the others have weight 1.

          Instances For
            def Cslib.Circuits.Arithmetic.Separation.Tape.RespectsRules {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} (i e : Q) (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) :

            No forbidding clause in force has all its literals true.

            theorem Cslib.Circuits.Arithmetic.Separation.Tape.respectsRules_iff_good {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} (i e : Q) (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) :

            The forbidding clauses check certificates: an assignment respects the rules in force exactly when it is a certificate of a run from i to e on the input with code x.

            def Cslib.Circuits.Arithmetic.Separation.Tape.runLits {Γ S Q : Type} [DecidableEq S] {n t M N : ℕ} (i e : Q) :
            RunStep Γ S Q n t ⊕ RunRule Γ S n t M → List (RunBit Γ S Q n t M N × Bool)

            The literals of all clauses.

            def Cslib.Circuits.Arithmetic.Separation.Tape.runWeights {F : Type u_1} [CommSemiring F] {Γ S Q : Type} {n t M : ℕ} (mu : Letter S (Fin n) Γ → Matrix Q Q F) :
            RunStep Γ S Q n t ⊕ RunRule Γ S n t M → F

            The weights of all clauses: the matrix entry of a step, and 0 for a rule in force.

            theorem Cslib.Circuits.Arithmetic.Separation.Tape.prod_stepLits {F : Type u_1} [CommSemiring F] {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} [Fintype Γ] [Fintype S] [Fintype Q] (mu : Letter S (Fin n) Γ → Matrix Q Q F) (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) :
            (∏ r : RunStep Γ S Q n t, if ∀ l ∈ stepLits r, Sum.elim x (Pi.oneHot g) l.1 = l.2 then mu r.letter r.src r.dst else 1) = ∏ τ : Fin t, mu (g.letter τ) (g.state τ.castSucc) (g.state τ.succ)

            The weighted clauses carry the matrix entries of the run of the assignment.

            theorem Cslib.Circuits.Arithmetic.Separation.Tape.prod_ruleLits {F : Type u_1} [CommSemiring F] {Γ S Q : Type} [DecidableEq Γ] [DecidableEq S] [DecidableEq Q] {n t M N : ℕ} [Fintype Γ] [Fintype S] (i e : Q) (x : Fin N × Option Γ → Bool) (g : RunAssignment Γ S Q n t M) :
            (∏ r : RunRule Γ S n t M, if ∀ l ∈ ruleLits i e r, Sum.elim x (Pi.oneHot g) l.1 = l.2 then if r.InForce then 0 else 1 else 1) = if Good i e x g.letter g.state g.place g.content then 1 else 0

            The forbidding clauses select the certificates: their product is 1 on a certificate and 0 otherwise.