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

Model #

@[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

      Literal #

      @[unbox]

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

      Instances For
        def Validator.Formula.instDecidableEqLiteral.decEq {n✝ : } (x✝ x✝¹ : Literal n✝) :
        Decidable (x✝ = x✝¹)
        Equations
        Instances For
          Equations
          Instances For
            Equations
            Instances For

              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
                  @[simp]
                  theorem Validator.Formula.Clause.mem_vars {n : } (γ : Clause n) {i : Fin n} :
                  i γ.vars lγ, l.var = i
                  @[simp]

                  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
                      @[simp]
                      theorem Validator.Formula.Cube.mem_vars {n : } (δ : Cube n) (i : Fin n) :
                      i δ.vars lδ, i = l.var
                      @[simp]
                      theorem Validator.Formula.Cube.vars_append {n : } (δ δ' : Cube n) :
                      (δ ++ δ').vars = δ.vars δ'.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 γφ, M γ.models
                                @[simp]
                                theorem Validator.Formula.CNF.models_cons {n : } (φ : CNF n) {γ : Clause n} :
                                models (γ :: φ) = γ.models φ.models
                                @[simp]
                                theorem Validator.Formula.CNF.models_append {n : } (φ ψ : CNF n) :
                                (φ ++ ψ).models = φ.models ψ.models
                                Equations
                                Instances For
                                  @[simp]
                                  theorem Validator.Formula.CNF.mem_vars {n : } (φ : CNF n) {i : Fin n} :
                                  i φ.vars γφ, i γ.vars
                                  @[simp]
                                  theorem Validator.Formula.CNF.vars_cons {n : } {γ : Clause n} {φ : CNF n} :
                                  vars (γ :: φ) = γ.vars φ.vars
                                  @[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 δφ, M δ.models
                                      @[simp]
                                      theorem Validator.Formula.DNF.exists_iff_models_subset {n : } {φ : DNF n} {Ms : Models n} :
                                      (∀ δφ, δ.modelsMs) φ.modelsMs

                                      PartialModel #

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

                                      Instances For
                                        def Validator.Formula.instDecidableEqPartialModel.decEq {n✝ : } (x✝ x✝¹ : PartialModel n✝) :
                                        Decidable (x✝ = x✝¹)
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          @[implicit_reducible]
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          @[simp]
                                          theorem Validator.Formula.PartialModel.mem_def {n : } (M : PartialModel n) (x✝ : Literal n) :
                                          (x✝ M) = match x✝ with | { var := i, isPos := true } => i M.pos | { var := i, isPos := false } => i M.neg
                                          @[implicit_reducible]
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Equations
                                          Instances For
                                            theorem Validator.Formula.PartialModel.mem_vars {n : } {i : Fin n} {M : PartialModel n} :
                                            i M.vars lM, l.var = i

                                            All models corresponding to to partial model M.

                                            Equations
                                            Instances For
                                              theorem Validator.Formula.PartialModel.mem_models' {n : } (M : PartialModel n) {M' : Model n} :
                                              M' M.models (∀ iM.pos, M' i) iM.neg, ¬M' i
                                              theorem Validator.Formula.PartialModel.mem_models {n : } {M : PartialModel n} {M' : Model n} :
                                              M' M.models lM, M' l.models
                                              Equations
                                              Instances For

                                                Returns none if the negation of the literal already occurs in M

                                                Equations
                                                Instances For
                                                  @[simp]
                                                  theorem Validator.Formula.PartialModel.insert_eq_some_iff {n : } {M M' : PartialModel n} {l : Literal n} :
                                                  M.insert l = some M' l.negateM ∀ (l' : Literal n), l' M' l' M l' = l
                                                  def Validator.Formula.PartialModel.foldl {α : Sort u_1} {n : } (f : αLiteral nα) (init : α) (M : PartialModel n) :
                                                  α
                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    theorem Validator.Formula.PartialModel.foldl_cons {α : Type u_1} {n : } {M : PartialModel n} {f : Literal nα} {a : α} :
                                                    a foldl (fun (a : List α) (l : Literal n) => f l :: a) [] M lM, a = f l
                                                    theorem Validator.Formula.PartialModel.mem_toCNF {n : } {M : PartialModel n} {γ : Clause n} :
                                                    γ M.toCNF lM, γ = [l]

                                                    Translate δ to a partial model. Returns none if δ is inconsistent.

                                                    Equations
                                                    Instances For

                                                      Formula #

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

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

                                                      • vars (φ : R) : STRIPS.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) : (∀ ivars φ, 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 : ivars φ, 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.models_andList {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.models_orList {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
                                                                              Instances For
                                                                                theorem Validator.Formula.Renaming.ne {n : } {dom : STRIPS.VarSet n} {r : Renaming dom} (i : Fin n) :
                                                                                i domjdom, i jr.rename i r.rename j
                                                                                def Validator.Formula.Model.rename {n : } {dom : STRIPS.VarSet n} (r : Renaming dom) (M : Model n) :
                                                                                Equations
                                                                                Instances For
                                                                                  Equations
                                                                                  Instances For
                                                                                    @[simp]
                                                                                    theorem Validator.Formula.CNF.mem_vars_rename {n : } {dom : STRIPS.VarSet n} {r : Renaming dom} {φ : CNF n} {i : Fin n} :
                                                                                    i (rename r φ).vars jφ.vars, i = r.rename j
                                                                                    @[simp]
                                                                                    theorem Validator.Formula.CNF.models_rename {n : } {dom : STRIPS.VarSet n} {r : Renaming dom} {φ : CNF n} :
                                                                                    @[simp]
                                                                                    theorem Validator.Formula.VarSet.mem_rename {n : } {dom : STRIPS.VarSet n} {r : Renaming dom} {V : STRIPS.VarSet n} {i : Fin n} :
                                                                                    i rename r V jV, i = r.rename j
                                                                                    @[simp]
                                                                                    theorem Validator.Formula.PartialModel.mem_vars_rename {n : } {dom : STRIPS.VarSet n} {r : Renaming dom} {M : PartialModel n} {h1 : M.vars dom} {i : Fin n} :
                                                                                    i (rename r M h1).vars jM.vars, i = r.rename j
                                                                                    @[simp]
                                                                                    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 : STRIPS.VarSet n} {r : Renaming V} {h : vars φ V} {M : Model n} :
                                                                                      class Validator.Formula.ToCNF (n : ) (R : Type) [F : Formula n R] :
                                                                                      Instances
                                                                                        theorem Validator.Formula.ToCNF.models_disjunctionToCNF {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.models_negToDNF {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.models_conjunctionToDnF {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.models_negToCNF {n : } {R : Type} [F : Formula n R] [h : ToDNF n R] {φ : R} :