Documentation

Complexitylib.SAT.Tseitin.Internal.Streaming

Streaming specification for the CNF-to-3CNF transformation #

This file gives a token-level specification of a machine-friendly Tseitin transducer. It reads the existing EncToken stream from left to right, keeps at most three decoded literals, and emits completed exact-width-three clauses as soon as a fourth source literal arrives. A literal body is represented only by its sign and a unary counter, matching the data a concrete TM can retain in finite control plus registers.

The formula-level entry point chooses the first fresh variable to be one more than the source bit length. This is deliberately easier for a TM to obtain than CNF.maxVar, and CNF.maxVar_le_encode_length ensures that the resulting variables are fresh. On a valid CNF.tokens stream, the emitted tokens and bits are exactly the encoding produced by CNF.to3Aux at that start value.

The source literals retained for the current clause. Three literals are enough: seeing a fourth emits one chain clause and rolls the window forward.

Instances For
    Equations
    Instances For

      Token-parser state for a raw literal. The first data bit is its sign; every later data bit must be true and increments the unary variable counter.

      Instances For

        State of the streaming transducer. emitted is an append-only token accumulator, and next is the first unused auxiliary-variable index.

        • next :

          First unused auxiliary-variable index.

        • pending : Pending

          At most three source literals waiting to be emitted.

        • scan : Scan

          Current raw-literal parser state.

        • emitted : List EncToken

          Append-only output-token accumulator.

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

            State at the beginning of a formula, before any token has been read.

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

              Incorporate a decoded source literal. The first three literals are kept; each later literal emits the next link of the Tseitin chain.

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

                Finish the current source clause. The bounded pending clause is handled by the same short-clause cases as Clause.to3CNF; the empty case consumes one fresh variable for its contradiction gadget.

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

                  One token transition. It rejects malformed raw literals and separators in the middle of a literal. On valid CNF.tokens streams these cases are absent.

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

                    Accept a completed formula only at a clause boundary with no pending literals. Valid CNF.tokens streams always have this shape.

                    Equations
                    Instances For

                      Transform a token stream using the supplied first fresh variable.

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

                        Transform a token stream, choosing the first fresh variable as one more than the concrete source bit length.

                        Equations
                        Instances For

                          Bit-level output of transformTokens?, retaining the final fresh counter for the machine-level invariant.

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

                            On a valid encoded CNF token stream, the streaming transducer agrees exactly with CNF.to3Aux, including its final fresh-variable counter.

                            transformTokens? uses source bit length plus one as its fresh start and emits exactly the corresponding typed Tseitin transformation.

                            Bit-level correctness of the streaming transducer on every valid CNF token stream.

                            The bit-length-derived start is strictly above every source variable.