Documentation

Complexitylib.Algebraic.LowerBound.AC0.NormalForm

Literals and bounded-width normal forms #

This module supplies the finite syntax used by switching arguments. A literal stores the value that makes it true. A LiteralSet stores at most one literal per variable by using a partial assignment, so contradictory terms and tautological clauses are excluded by construction. Ordered lists of such sets form DNF and CNF formulas; the order will later make the canonical decision tree deterministic.

Restriction keeps the original variable names. A term falsified by a fixed literal is dropped from a DNF, while a clause satisfied by a fixed literal is dropped from a CNF. Empty terms and clauses represent the Boolean constants true and false respectively.

structure Algebraic.AC0.Literal (n : ℕ) :

A signed Boolean variable, represented by the value that makes the literal true. Thus value = true is a positive literal and value = false is a negative literal.

  • index : Fin n

    The input coordinate read by the literal.

  • value : Bool

    The Boolean value that satisfies the literal.

Instances For
    def Algebraic.AC0.instDecidableEqLiteral.decEq {n✝ : ℕ} (x✝ x✝¹ : Literal n✝) :
    Decidable (x✝ = x✝¹)
    Equations
    Instances For
      def Algebraic.AC0.Literal.eval {n : ℕ} (literal : Literal n) (input : Fin n → Bool) :

      Evaluate a literal on a complete Boolean input.

      Equations
      Instances For
        @[simp]
        theorem Algebraic.AC0.Literal.eval_eq_true {n : ℕ} (literal : Literal n) (input : Fin n → Bool) :
        literal.eval input = true ↔ input literal.index = literal.value
        def Algebraic.AC0.Literal.negate {n : ℕ} (literal : Literal n) :

        Boolean negation of a literal.

        Equations
        Instances For
          @[simp]
          theorem Algebraic.AC0.Literal.negate_index {n : ℕ} (literal : Literal n) :
          literal.negate.index = literal.index
          @[simp]
          theorem Algebraic.AC0.Literal.negate_value {n : ℕ} (literal : Literal n) :
          literal.negate.value = !literal.value
          @[simp]
          theorem Algebraic.AC0.Literal.negate_negate {n : ℕ} (literal : Literal n) :
          literal.negate.negate = literal
          @[simp]
          theorem Algebraic.AC0.Literal.eval_negate {n : ℕ} (literal : Literal n) (input : Fin n → Bool) :
          literal.negate.eval input = !literal.eval input

          A finite, noncontradictory collection of literals. The partial assignment records the truth value required of each variable that occurs.

          • requirements : PartialAssignment n

            Partial map from occurring variables to their satisfying values.

          Instances For
            def Algebraic.AC0.instDecidableEqLiteralSet.decEq {n✝ : ℕ} (x✝ x✝¹ : LiteralSet n✝) :
            Decidable (x✝ = x✝¹)
            Equations
            Instances For

              The empty collection of literals.

              Equations
              Instances For

                The one-element collection containing a literal.

                Equations
                Instances For

                  Variables occurring in a literal collection.

                  Equations
                  Instances For
                    @[simp]
                    theorem Algebraic.AC0.LiteralSet.mem_support {n : ℕ} (set : LiteralSet n) (index : Fin n) :
                    index ∈ set.support ↔ set.requirements index ≠ none

                    Width of a literal collection.

                    Equations
                    Instances For

                      Remove the literals whose variables have been fixed by rho. This operation does not itself check whether those fixed values satisfy or falsify the removed literals.

                      Equations
                      Instances For
                        @[simp]
                        theorem Algebraic.AC0.LiteralSet.residual_requirements_of_live {n : ℕ} (set : LiteralSet n) (rho : PartialAssignment n) {index : Fin n} (live : rho index = none) :
                        (set.residual rho).requirements index = set.requirements index
                        @[simp]
                        theorem Algebraic.AC0.LiteralSet.residual_requirements_of_fixed {n : ℕ} (set : LiteralSet n) (rho : PartialAssignment n) {index : Fin n} {value : Bool} (fixed : rho index = some value) :
                        (set.residual rho).requirements index = none

                        Restriction only removes variables from a literal collection.

                        Every literal remaining after restriction is on a variable left live by the restriction.

                        Restriction cannot increase the width of a literal collection.

                        Some fixed literal of set is falsified by rho.

                        Equations
                        Instances For
                          theorem Algebraic.AC0.LiteralSet.ConflictsWith.refine {n : ℕ} {set : LiteralSet n} {rho : PartialAssignment n} (conflict : set.ConflictsWith rho) (extension : PartialAssignment n) :
                          set.ConflictsWith (rho.refine extension)

                          A conflict witnessed by an existing fixed variable persists under every later refinement.

                          Some fixed literal of set is satisfied by rho.

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

                            A conjunction of distinct-variable literals.

                            Equations
                            Instances For
                              def Algebraic.AC0.Term.SatisfiedBy {n : ℕ} (term : Term n) (input : Fin n → Bool) :

                              A complete input satisfies a term when it gives every occurring literal its required value.

                              Equations
                              Instances For
                                @[instance_reducible]
                                instance Algebraic.AC0.Term.satisfiedByDecidable {n : ℕ} (term : Term n) (input : Fin n → Bool) :
                                Decidable (term.SatisfiedBy input)
                                Equations
                                def Algebraic.AC0.Term.eval {n : ℕ} (term : Term n) (input : Fin n → Bool) :

                                Boolean semantics of a term. The empty term is true.

                                Equations
                                Instances For
                                  @[simp]
                                  theorem Algebraic.AC0.Term.eval_eq_true {n : ℕ} (term : Term n) (input : Fin n → Bool) :
                                  term.eval input = true ↔ term.SatisfiedBy input
                                  @[simp]
                                  theorem Algebraic.AC0.Term.eval_empty {n : ℕ} (input : Fin n → Bool) :
                                  def Algebraic.AC0.Term.restrict {n : ℕ} (term : Term n) (rho : PartialAssignment n) :

                                  Restrict a term. none denotes a term made constantly false by a conflicting fixed literal; otherwise the remaining live literals are returned.

                                  Equations
                                  Instances For
                                    theorem Algebraic.AC0.Term.eval_apply_eq_false_of_conflicts {n : ℕ} (term : Term n) (rho : PartialAssignment n) (input : Fin n → Bool) (conflict : LiteralSet.ConflictsWith term rho) :
                                    term.eval (rho.apply input) = false

                                    A conflicting partial assignment makes a term false under every completion.

                                    theorem Algebraic.AC0.Term.eval_residual_eq_eval_apply_of_not_conflicts {n : ℕ} (term : Term n) (rho : PartialAssignment n) (input : Fin n → Bool) (noConflict : ¬LiteralSet.ConflictsWith term rho) :
                                    eval (LiteralSet.residual term rho) input = term.eval (rho.apply input)

                                    In the absence of a conflict, evaluating the residual term is exactly evaluation of the original term under the partial assignment.

                                    theorem Algebraic.AC0.Term.restrict_sound {n : ℕ} (term : Term n) (rho : PartialAssignment n) (input : Fin n → Bool) :
                                    ((term.restrict rho).elim false fun (residual : Term n) => residual.eval input) = term.eval (rho.apply input)

                                    Total semantic specification of term restriction.

                                    theorem Algebraic.AC0.Term.width_restrict_le {n : ℕ} (term residual : Term n) (rho : PartialAssignment n) (restricted : term.restrict rho = some residual) :

                                    Any residual returned by term restriction has no greater width than the source term.

                                    @[reducible, inline]

                                    A disjunction of distinct-variable literals.

                                    Equations
                                    Instances For
                                      def Algebraic.AC0.Clause.SatisfiedBy {n : ℕ} (clause : Clause n) (input : Fin n → Bool) :

                                      A complete input satisfies a clause when it satisfies at least one occurring literal.

                                      Equations
                                      Instances For
                                        @[instance_reducible]
                                        instance Algebraic.AC0.Clause.satisfiedByDecidable {n : ℕ} (clause : Clause n) (input : Fin n → Bool) :
                                        Decidable (clause.SatisfiedBy input)
                                        Equations
                                        def Algebraic.AC0.Clause.eval {n : ℕ} (clause : Clause n) (input : Fin n → Bool) :

                                        Boolean semantics of a clause. The empty clause is false.

                                        Equations
                                        Instances For
                                          @[simp]
                                          theorem Algebraic.AC0.Clause.eval_eq_true {n : ℕ} (clause : Clause n) (input : Fin n → Bool) :
                                          clause.eval input = true ↔ clause.SatisfiedBy input
                                          @[simp]

                                          Restrict a clause. none denotes a clause made constantly true by a satisfied fixed literal; otherwise the remaining live literals are returned.

                                          Equations
                                          Instances For
                                            theorem Algebraic.AC0.Clause.eval_apply_eq_true_of_hit {n : ℕ} (clause : Clause n) (rho : PartialAssignment n) (input : Fin n → Bool) (hit : LiteralSet.HitBy clause rho) :
                                            clause.eval (rho.apply input) = true

                                            A fixed literal satisfying a clause makes it true under every completion.

                                            theorem Algebraic.AC0.Clause.eval_residual_eq_eval_apply_of_not_hit {n : ℕ} (clause : Clause n) (rho : PartialAssignment n) (input : Fin n → Bool) (noHit : ¬LiteralSet.HitBy clause rho) :
                                            eval (LiteralSet.residual clause rho) input = clause.eval (rho.apply input)

                                            If no fixed literal satisfies a clause, evaluating the residual clause is exactly evaluation of the original clause under the partial assignment.

                                            theorem Algebraic.AC0.Clause.restrict_sound {n : ℕ} (clause : Clause n) (rho : PartialAssignment n) (input : Fin n → Bool) :
                                            ((clause.restrict rho).elim true fun (residual : Clause n) => residual.eval input) = clause.eval (rho.apply input)

                                            Total semantic specification of clause restriction.

                                            theorem Algebraic.AC0.Clause.width_restrict_le {n : ℕ} (clause residual : Clause n) (rho : PartialAssignment n) (restricted : clause.restrict rho = some residual) :

                                            Any residual returned by clause restriction has no greater width than the source clause.

                                            structure Algebraic.AC0.DNF (n : ℕ) :

                                            An ordered disjunction of terms. Ordering is semantically irrelevant but is retained for the canonical decision-tree construction.

                                            • terms : List (Term n)

                                              Terms in the deterministic order used by canonical constructions.

                                            Instances For
                                              def Algebraic.AC0.instDecidableEqDNF.decEq {n✝ : ℕ} (x✝ x✝¹ : DNF n✝) :
                                              Decidable (x✝ = x✝¹)
                                              Equations
                                              Instances For
                                                def Algebraic.AC0.DNF.eval {n : ℕ} (formula : DNF n) (input : Fin n → Bool) :

                                                Boolean semantics of a DNF. The empty list is false.

                                                Equations
                                                Instances For
                                                  @[simp]
                                                  theorem Algebraic.AC0.DNF.eval_eq_true {n : ℕ} (formula : DNF n) (input : Fin n → Bool) :
                                                  formula.eval input = true ↔ ∃ term ∈ formula.terms, term.SatisfiedBy input

                                                  The constantly false DNF.

                                                  Equations
                                                  Instances For

                                                    The constantly true DNF, represented by one empty term.

                                                    Equations
                                                    Instances For
                                                      @[simp]
                                                      theorem Algebraic.AC0.DNF.eval_bottom {n : ℕ} (input : Fin n → Bool) :
                                                      @[simp]
                                                      theorem Algebraic.AC0.DNF.eval_top {n : ℕ} (input : Fin n → Bool) :
                                                      top.eval input = true
                                                      def Algebraic.AC0.DNF.WidthAtMost {n : ℕ} (formula : DNF n) (bound : ℕ) :

                                                      Every term in the DNF has width at most bound.

                                                      Equations
                                                      Instances For
                                                        def Algebraic.AC0.DNF.restrict {n : ℕ} (formula : DNF n) (rho : PartialAssignment n) :
                                                        DNF n

                                                        Restrict each term and discard those made constantly false.

                                                        Equations
                                                        Instances For
                                                          theorem Algebraic.AC0.DNF.restrict_sound {n : ℕ} (formula : DNF n) (rho : PartialAssignment n) (input : Fin n → Bool) :
                                                          (formula.restrict rho).eval input = formula.eval (rho.apply input)

                                                          Restricting a DNF preserves its Boolean function exactly.

                                                          theorem Algebraic.AC0.DNF.widthAtMost_restrict {n : ℕ} (formula : DNF n) (rho : PartialAssignment n) {bound : ℕ} (bounded : formula.WidthAtMost bound) :
                                                          (formula.restrict rho).WidthAtMost bound

                                                          Restriction preserves an upper bound on DNF term width.

                                                          theorem Algebraic.AC0.DNF.WidthAtMost.mono {n : ℕ} {formula : DNF n} {smaller larger : ℕ} (bounded : formula.WidthAtMost smaller) (le : smaller ≤ larger) :
                                                          formula.WidthAtMost larger

                                                          A DNF width bound remains valid after increasing the allowance.

                                                          structure Algebraic.AC0.CNF (n : ℕ) :

                                                          An ordered conjunction of clauses. Ordering is retained so dual arguments can use the same canonical conventions as DNF.

                                                          • clauses : List (Clause n)

                                                            Clauses in a retained deterministic order.

                                                          Instances For
                                                            def Algebraic.AC0.instDecidableEqCNF.decEq {n✝ : ℕ} (x✝ x✝¹ : CNF n✝) :
                                                            Decidable (x✝ = x✝¹)
                                                            Equations
                                                            Instances For
                                                              def Algebraic.AC0.CNF.eval {n : ℕ} (formula : CNF n) (input : Fin n → Bool) :

                                                              Boolean semantics of a CNF. The empty list is true.

                                                              Equations
                                                              Instances For
                                                                @[simp]
                                                                theorem Algebraic.AC0.CNF.eval_eq_true {n : ℕ} (formula : CNF n) (input : Fin n → Bool) :
                                                                formula.eval input = true ↔ ∀ clause ∈ formula.clauses, clause.SatisfiedBy input

                                                                The constantly true CNF.

                                                                Equations
                                                                Instances For

                                                                  The constantly false CNF, represented by one empty clause.

                                                                  Equations
                                                                  Instances For
                                                                    @[simp]
                                                                    theorem Algebraic.AC0.CNF.eval_top {n : ℕ} (input : Fin n → Bool) :
                                                                    top.eval input = true
                                                                    @[simp]
                                                                    theorem Algebraic.AC0.CNF.eval_bottom {n : ℕ} (input : Fin n → Bool) :
                                                                    def Algebraic.AC0.CNF.WidthAtMost {n : ℕ} (formula : CNF n) (bound : ℕ) :

                                                                    Every clause in the CNF has width at most bound.

                                                                    Equations
                                                                    Instances For
                                                                      def Algebraic.AC0.CNF.restrict {n : ℕ} (formula : CNF n) (rho : PartialAssignment n) :
                                                                      CNF n

                                                                      Restrict each clause and discard those made constantly true.

                                                                      Equations
                                                                      Instances For
                                                                        theorem Algebraic.AC0.CNF.restrict_sound {n : ℕ} (formula : CNF n) (rho : PartialAssignment n) (input : Fin n → Bool) :
                                                                        (formula.restrict rho).eval input = formula.eval (rho.apply input)

                                                                        Restricting a CNF preserves its Boolean function exactly.

                                                                        theorem Algebraic.AC0.CNF.widthAtMost_restrict {n : ℕ} (formula : CNF n) (rho : PartialAssignment n) {bound : ℕ} (bounded : formula.WidthAtMost bound) :
                                                                        (formula.restrict rho).WidthAtMost bound

                                                                        Restriction preserves an upper bound on CNF clause width.

                                                                        theorem Algebraic.AC0.CNF.WidthAtMost.mono {n : ℕ} {formula : CNF n} {smaller larger : ℕ} (bounded : formula.WidthAtMost smaller) (le : smaller ≤ larger) :
                                                                        formula.WidthAtMost larger

                                                                        A CNF width bound remains valid after increasing the allowance.