Documentation

Validator.StateSetFormalism.Formula

Formulas #

This file provides typeclasses for formulas and different operations these formulas can support. Note that this file does not implement any of these operations, but it formalizes what these operations should do. More specifically the file contains

VarSet' #

def Validator.VarSet'.union {n : } (V V' : VarSet' n) :
Equations
Instances For
    @[simp]
    theorem Validator.VarSet'.mem_union {n : } {V V' : VarSet' n} {i : Fin n} :
    i (V.union V') i V i V'
    def Validator.VarSet'.insert {n : } (V : VarSet' n) (v : Fin n) :
    Equations
    Instances For
      @[simp]
      theorem Validator.VarSet'.mem_insert {n : } {V : VarSet' n} {v i : Fin n} :
      i (V.insert v) i V i = v
      def Validator.VarSet'.diff {n : } (V V' : VarSet' n) :
      Equations
      Instances For
        @[simp]
        theorem Validator.VarSet'.mem_diff {n : } {V V' : VarSet' n} {i : Fin n} :
        i (V.diff V') i V iV'

        Model and PartialModel #

        @[reducible, inline]

        Model is usually in the in the context of a formula, where it represents a model of this formula, i.e. an assignment of variables making the formula true. It is used to show the correctness of operations.

        Equations
        Instances For
          @[reducible, inline]

          A set of models.

          Equations
          Instances For
            @[reducible, inline]

            Partial models are partial assignments. In contrast to Model, these are used at runtime.

            Equations
            Instances For

              All models corresponding to to partial model M.

              Equations
              Instances For

                Literal #

                A Literal is a variable i (represented by (i, true)) or its negation (represented by (i, false)).

                Equations
                Instances For
                  theorem Validator.Formula.Literal.mem_models {n : } (l : Literal n) (M : Model n) :
                  M l.models (M l.1 l.2 = true)

                  Clause #

                  @[reducible, inline]

                  A clause is a disjuction of literals.

                  Equations
                  Instances For
                    Equations
                    Instances For
                      @[simp]
                      theorem Validator.Formula.Clause.mem_models {n : } (γ : Clause n) (M : Model n) :
                      M γ.models lγ, M l.models
                      @[simp]
                      theorem Validator.Formula.Clause.models_append {n : } (γ1 γ2 : Clause n) :
                      (γ1 ++ γ2).models = γ1.models γ2.models

                      Cube #

                      @[reducible, inline]

                      A cube is a conjunction of literals.

                      Equations
                      Instances For
                        Equations
                        Instances For
                          @[simp]
                          theorem Validator.Formula.Cube.mem_models {n : } (δ : Cube n) (M : Model n) :
                          M δ.models lδ, M l.models
                          @[simp]
                          theorem Validator.Formula.Cube.models_append {n : } (δ1 δ2 : Cube n) :
                          (δ1 ++ δ2).models = δ1.models δ2.models
                          @[simp]
                          theorem Validator.Formula.Cube.models_cons {n : } {l : Literal n} (δ : Cube n) :
                          models (l :: δ) = l.models δ.models
                          Equations
                          Instances For
                            @[simp]
                            theorem Validator.Formula.Cube.vars_cons {n : } (δ : Cube n) {l : Literal n} :
                            vars (l :: δ) = {l.1} δ.vars
                            Equations
                            Instances For

                              The negation of a clause

                              Equations
                              Instances For

                                The negation of a cube

                                Equations
                                Instances For

                                  CNF #

                                  @[reducible, inline]

                                  A CNF-formula is a conjunction of clauses.

                                  Equations
                                  Instances For
                                    Equations
                                    Instances For
                                      @[simp]
                                      theorem Validator.Formula.CNF.mem_models {n : } (φ : CNF n) {M : Model n} :
                                      M φ.models γφ, lγ, M l.models
                                      Equations
                                      Instances For
                                        @[simp]
                                        theorem Validator.Formula.CNF.mem_vars {n : } (φ : CNF n) {i : Fin n} :
                                        i φ.vars γφ, vγ, v.1 = i
                                        @[simp]
                                        theorem Validator.Formula.CNF.forall_iff_subset_models {n : } {φ : CNF n} {Ms : Models n} :
                                        (∀ γφ, Ms γ.models) Ms φ.models
                                        theorem Validator.Formula.CNF.models_equiv_right {n : } {φ : CNF n} {M M' : Model n} :
                                        (∀ iφ.vars, M i = M' i)M φ.modelsM' φ.models

                                        DNF #

                                        @[reducible, inline]

                                        A DNF-formula is a conjunction of cubes.

                                        Equations
                                        Instances For
                                          Equations
                                          Instances For
                                            @[simp]
                                            theorem Validator.Formula.DNF.mem_models {n : } (φ : DNF n) {M : Model n} :
                                            M φ.models δφ, lδ, M l.models
                                            @[simp]
                                            theorem Validator.Formula.DNF.exists_iff_models_subset {n : } {φ : DNF n} {Ms : Models n} :
                                            (∀ δφ, δ.models Ms) φ.models Ms

                                            Formula #

                                            class Validator.Formula (n : ) (R : Type) :

                                            Type class for formulas with variables Fin n. The variables are ordered by ordering <.

                                            • vars (φ : R) : VarSet' n

                                              The variables associated with the formula φ. Note that not all of these variables need to 'appear' in φ.

                                            • models (φ : R) : Models n

                                              The models of the formula φ

                                            • models_equiv_right (φ : R) (M M' : Model n) : (∀ i(vars φ), M i = M' i)M models φM' models φ

                                              If two assignments coincide on the variables of φ, then the second is a model of φ if the first one is a model of φ.

                                            Instances
                                              theorem Validator.Formula.models_equiv {n : } {R : Type} [h : Formula n R] {φ : R} {M M' : Model n} (h1 : i(vars φ), M i = M' i) :
                                              M models φ M' models φ

                                              If two assignments M and M' coincide on the variables of φ, then M is a model of φ iff M' is a model of φ.

                                              Operations on Formulas #

                                              class Validator.Formula.Top (n : ) (R : Type) [F : Formula n R] :
                                              Instances
                                                class Validator.Formula.Bot (n : ) (R : Type) [F : Formula n R] :
                                                Instances
                                                  class Validator.Formula.Consistency (n : ) (R : Type) [F : Formula n R] :
                                                  Instances
                                                    Instances
                                                      class Validator.Formula.Implicant (n : ) (R : Type) [F : Formula n R] :
                                                      Instances
                                                        Instances
                                                          Instances

                                                            The time complexity of andList is generally bad, therefore it should only be used if the number of conjuncts is bounded.

                                                            Equations
                                                            Instances For
                                                              theorem Validator.Formula.BoundedConjuction.andList_correct {n : } {R : Type} [F : Formula n R] [Top n R] [h : BoundedConjuction n R] {l : List R} :
                                                              models (andList l) = {M : Model n | φl, M models φ}
                                                              Instances

                                                                The timecomplexity of andList is generally bad, therefore it should only be used if the number of conjuncts is bounded.

                                                                Equations
                                                                Instances For
                                                                  theorem Validator.Formula.BoundedDisjunction.orList_correct {n : } {R : Type} [F : Formula n R] [Bot n R] [h : BoundedDisjunction n R] {l : List R} :
                                                                  models (orList l) = {M : Model n | φl, M models φ}
                                                                  Instances
                                                                    structure Validator.Formula.Renaming {n : } (dom : VarSet' n) :
                                                                    Instances For
                                                                      def Validator.Formula.Model.rename {n : } {V : VarSet' n} (r : Renaming V) (M : Model n) :
                                                                      Equations
                                                                      Instances For
                                                                        Equations
                                                                        Instances For
                                                                          def Validator.Formula.VarSet'.rename {n : } {V : VarSet' n} (r : Renaming V) (V' : VarSet' n) :
                                                                          Equations
                                                                          Instances For
                                                                            theorem Validator.Formula.VarSet'.mem_rename {n : } {V : VarSet' n} {r : Renaming V} {V' : VarSet' n} {i : Fin n} :
                                                                            i (rename r V') i V' iV jV, i = r.rename j
                                                                            class Validator.Formula.Rename (n : ) (R : Type) [F : Formula n R] :

                                                                            Renaming consistent with order

                                                                            Instances
                                                                              theorem Validator.Formula.Rename.mem_rename_models {n : } {R : Type} [F : Formula n R] [Rename n R] {φ : R} {V : VarSet' n} {r : Renaming V} {M : Model n} :
                                                                              class Validator.Formula.RenamingOld (n : ) (R : Type) [F : Formula n R] :

                                                                              Renaming consistent with order

                                                                              Instances
                                                                                def Validator.Formula.RenamingOld.renameModel {n : } (V V' : VarSet' n) (h : (↑V').length = (↑V).length) (M : Model n) :
                                                                                Equations
                                                                                Instances For
                                                                                  theorem Validator.Formula.RenamingOld.mem_rename_models {n : } {R : Type} [F : Formula n R] [RenamingOld n R] {φ : R} {vars' : VarSet' n} {h : (↑vars').length = (↑(vars φ)).length} {M : Model n} :
                                                                                  M models (rename φ vars' h) renameModel (vars φ) vars' M models φ
                                                                                  def Validator.Formula.RenamingOld.renameLiteral {n : } (V V' : VarSet' n) (h : (↑V').length = (↑V).length) (l : Literal n) :
                                                                                  Equations
                                                                                  Instances For
                                                                                    class Validator.Formula.ToCNF (n : ) (R : Type) [F : Formula n R] :
                                                                                    Instances
                                                                                      theorem Validator.Formula.ToCNF.disjunctionToCNF_correct {n : } {R : Type} [F : Formula n R] [h : ToCNF n R] {φs : List R} :
                                                                                      (disjunctionToCNF φs).models = {M : Model n | φφs, M models φ}
                                                                                      def Validator.Formula.ToCNF.negToDNF {n : } {R : Type} [Formula n R] [h : ToCNF n R] (φ : R) :
                                                                                      DNF n

                                                                                      Transform ¬x to a DNF formula by translating x to a CNF-formula and applying De Morgans laws.

                                                                                      Equations
                                                                                      Instances For
                                                                                        theorem Validator.Formula.ToCNF.negToDNF_correct {n : } {R : Type} [F : Formula n R] [h : ToCNF n R] {φ : R} :
                                                                                        class Validator.Formula.ToDNF (n : ) (R : Type) [F : Formula n R] :
                                                                                        Instances
                                                                                          theorem Validator.Formula.ToDNF.conjunctionToDnF_correct {n : } {R : Type} [F : Formula n R] [h : ToDNF n R] {φs : List R} :
                                                                                          (conjunctionToDNF φs).models = {M : Model n | φφs, M models φ}
                                                                                          def Validator.Formula.ToDNF.negToCNF {n : } {R : Type} [Formula n R] [h : ToDNF n R] (φ : R) :
                                                                                          CNF n

                                                                                          Transform ¬x to a CNF formula by translating x to a DNF-formula and applying De Morgans laws.

                                                                                          Equations
                                                                                          Instances For
                                                                                            theorem Validator.Formula.ToDNF.negToCNF_correct {n : } {R : Type} [F : Formula n R] [h : ToDNF n R] {φ : R} :