Documentation

Std.Sat.CNF.Basic

structure Std.Sat.CNF.Clause (α : Type u) :

A clause in a CNF.

The literal (i, b) is satisfied if the assignment to i agrees with b.

Instances For
    structure Std.Sat.CNF (α : Type u) :

    A CNF formula.

    Literals are identified by members of α.

    Instances For
      @[instance_reducible]
      @[inline]
      Instances For
        @[instance_reducible]
        @[inline]
        def Std.Sat.CNF.Clause.size {α : Type u_1} (c : Clause α) :
        Instances For
          @[simp]
          @[inline]
          def Std.Sat.CNF.Clause.add {α : Type u_1} (c : Clause α) (atom : α) (pol : Bool) :
          Instances For
            @[simp]
            theorem Std.Sat.CNF.Clause.add_ne_empty {α : Type u_1} (c : Clause α) (atom : α) (pol : Bool) :
            c.add atom pol ≠ empty
            @[simp]
            theorem Std.Sat.CNF.Clause.Internal.atoms_add {α : Type u_1} {atom : α} {pol : Bool} {c : Clause α} :
            (c.add atom pol).atoms = c.atoms.push atom
            @[simp]
            theorem Std.Sat.CNF.Clause.size_add {α : Type u_1} (c : Clause α) (atom : α) (pol : Bool) :
            (c.add atom pol).size = c.size + 1
            def Std.Sat.CNF.Clause.polarity {α : Type u_1} (c : Clause α) (i : Nat) :

            The polarity of the literal at index i of c; false if i is out of bounds.

            Instances For
              theorem Std.Sat.CNF.Clause.polarity_add {α : Type u_1} {atom : α} {pol : Bool} {c : Clause α} {i : Nat} :
              (c.add atom pol).polarity i = if i = c.size then pol else c.polarity i
              def Std.Sat.CNF.Clause.literals {α : Type u_1} (c : Clause α) :

              The literals of a Clause as a list of atom/polarity pairs, used to state specifications. This function runs in O(n) and allocates all of the List and the Literal objects fresh. For this reason it is not useful for performance sensitive contexts.

              Instances For
                @[simp]
                theorem Std.Sat.CNF.Clause.literals_add {α : Type u_1} {atom : α} {pol : Bool} {c : Clause α} :
                (c.add atom pol).literals = c.literals ++ [(atom, pol)]
                theorem Std.Sat.CNF.Clause.ext {α : Type u_1} {c1 c2 : Clause α} (h : c1.literals = c2.literals) :
                c1 = c2
                def Std.Sat.CNF.Clause.ofLiterals {α : Type u_1} (l : List (Literal α)) :

                Build a Clause from a list of literals.

                Instances For
                  theorem Std.Sat.CNF.Clause.literals_foldl_add {α : Type u_1} {l : List (Literal α)} {init : Clause α} :
                  (List.foldl (fun (c : Clause α) (x : Literal α) => match x with | (atom, pol) => c.add atom pol) init l).literals = init.literals ++ l
                  theorem Std.Sat.CNF.Clause.exists_eq_add_of_ne_empty {α : Type u_1} {c : Clause α} (h : c ≠ empty) :
                  ∃ (c' : Clause α), ∃ (atom : α), ∃ (pol : Bool), c = c'.add atom pol
                  @[instance_reducible]
                  theorem Std.Sat.CNF.Clause.mem_literals_iff {α : Type u_1} {c : Clause α} {l : Literal α} :
                  theorem Std.Sat.CNF.Clause.Internal.getElem_mem {α : Type u_1} {c : Clause α} {i : Nat} (h : i < c.atoms.size) :
                  theorem Std.Sat.CNF.Clause.ne_of_mem_of_negate_mem {α : Type u_1} {l l' : Literal α} {c : Clause α} (h1 : l ∈ c) (h2 : ¬l' ∈ c) (h3 : ¬l'.negate ∈ c) :
                  l.fst ≠ l'.fst
                  @[inline]
                  def Std.Sat.CNF.Clause.contains {α : Type u_1} [BEq α] (c : Clause α) (lit : Literal α) :
                  Instances For
                    theorem Std.Sat.CNF.Clause.contains_iff_mem {α : Type u_1} [BEq α] [LawfulBEq α] {c : Clause α} {lit : Literal α} :
                    c.contains lit = true ↔ lit ∈ c
                    @[instance_reducible]
                    @[inline]
                    unsafe def Std.Sat.CNF.Clause.forIn'ImplUnsafe {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (c : Clause α) (b : β) (f : (l : Literal α) → l ∈ c → β → m (ForInStep β)) :
                    m β

                    See comment at Array.forIn'Unsafe.

                    Instances For
                      @[implemented_by Std.Sat.CNF.Clause.forIn'ImplUnsafe]
                      def Std.Sat.CNF.Clause.forIn'Impl {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (c : Clause α) (b : β) (f : (l : Literal α) → l ∈ c → β → m (ForInStep β)) :
                      m β

                      Reference implementation for forIn' on Clause, iterating directly over the packed representation without materializing literals.

                      Instances For
                        @[instance_reducible]
                        @[simp]
                        @[simp]
                        theorem Std.Sat.CNF.Clause.mem_add {α : Type u_1} {atom : α} {pol : Bool} {c : Clause α} {l1 : Literal α} :
                        l1 ∈ c.add atom pol ↔ l1 = (atom, pol) ∨ l1 ∈ c
                        theorem Std.Sat.CNF.Clause.forIn'_eq_forIn'_literals {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] {c : Clause α} {init : β} {f : (l : Literal α) → l ∈ c → β → m (ForInStep β)} :
                        forIn' c init f = forIn' c.literals init fun (l : Literal α) (h : l ∈ c.literals) (b : β) => f l ⋯ b
                        @[inline]
                        def Std.Sat.CNF.Clause.erase {α : Type u_1} [BEq α] (c : Clause α) (lit : Literal α) :

                        Erase all occurrences of lit from c.

                        Instances For
                          @[simp]
                          theorem Std.Sat.CNF.Clause.literals_erase {α : Type u_1} [BEq α] [LawfulBEq α] {c : Clause α} {lit : Literal α} :
                          (c.erase lit).literals = List.filter (fun (l : Literal α) => l != lit) c.literals
                          @[simp]
                          theorem Std.Sat.CNF.Clause.mem_erase_iff {α : Type u_1} {lit lit' : Literal α} [BEq α] [LawfulBEq α] {c : Clause α} :
                          lit' ∈ c.erase lit ↔ lit ≠ lit' ∧ lit' ∈ c
                          def Std.Sat.CNF.Clause.append {α : Type u_1} (c1 c2 : Clause α) :

                          The disjunction of two clauses, obtained by concatenating their literals.

                          Instances For
                            @[instance_reducible]
                            @[simp]
                            theorem Std.Sat.CNF.Clause.Internal.atoms_append {α : Type u_1} {c1 c2 : Clause α} :
                            (c1 ++ c2).atoms = c1.atoms ++ c2.atoms
                            theorem Std.Sat.CNF.Clause.polarity_append {α : Type u_1} {c1 c2 : Clause α} {i : Nat} :
                            (c1 ++ c2).polarity i = if i < c1.size then c1.polarity i else c2.polarity (i - c1.size)
                            @[simp]
                            theorem Std.Sat.CNF.Clause.size_append {α : Type u_1} {c1 c2 : Clause α} :
                            (c1 ++ c2).size = c1.size + c2.size
                            @[simp]
                            theorem Std.Sat.CNF.Clause.literals_append {α : Type u_1} {c1 c2 : Clause α} :
                            @[simp]
                            theorem Std.Sat.CNF.Clause.empty_append {α : Type u_1} {c : Clause α} :
                            empty ++ c = c
                            @[simp]
                            theorem Std.Sat.CNF.Clause.append_empty {α : Type u_1} {c : Clause α} :
                            c ++ empty = c
                            @[simp]
                            theorem Std.Sat.CNF.Clause.append_assoc {α : Type u_1} {c1 c2 c3 : Clause α} :
                            c1 ++ c2 ++ c3 = c1 ++ (c2 ++ c3)
                            @[simp]
                            theorem Std.Sat.CNF.Clause.append_add {α : Type u_1} {atom : α} {pol : Bool} {c1 c2 : Clause α} :
                            c1 ++ c2.add atom pol = (c1 ++ c2).add atom pol
                            @[simp]
                            theorem Std.Sat.CNF.Clause.append_eq_empty_iff {α : Type u_1} {c1 c2 : Clause α} :
                            c1 ++ c2 = empty ↔ c1 = empty ∧ c2 = empty
                            @[simp]
                            theorem Std.Sat.CNF.Clause.mem_append {α : Type u_1} {c1 c2 : Clause α} {l : Literal α} :
                            l ∈ c1 ++ c2 ↔ l ∈ c1 ∨ l ∈ c2
                            @[inline]
                            def Std.Sat.CNF.empty {α : Type u_1} :
                            CNF α
                            Instances For
                              @[inline]
                              def Std.Sat.CNF.emptyWithCapacity {α : Type u_1} (n : Nat) :
                              CNF α
                              Instances For
                                @[inline]
                                def Std.Sat.CNF.add {α : Type u_1} (f : CNF α) (c : Clause α) :
                                CNF α
                                Instances For
                                  @[inline]
                                  def Std.Sat.CNF.append {α : Type u_1} (f1 f2 : CNF α) :
                                  CNF α
                                  Instances For
                                    @[instance_reducible]
                                    instance Std.Sat.CNF.instAppend {α : Type u_1} :
                                    Append (CNF α)
                                    def Std.Sat.CNF.Clause.VarMem {α : Type u_1} (v : α) (c : Clause α) :

                                    Variable v occurs in Clause c.

                                    Instances For
                                      @[instance_reducible]
                                      @[simp]
                                      theorem Std.Sat.CNF.Clause.VarMem_add_self {α : Type u_1} {atom : α} {pol : Bool} {c : Clause α} :
                                      VarMem atom (c.add atom pol)
                                      theorem Std.Sat.CNF.Clause.VarMem_add_ne_self {α : Type u_1} {pol : Bool} {c : Clause α} {atom1 atom2 : α} (h : atom1 ≠ atom2) :
                                      VarMem atom1 (c.add atom2 pol) ↔ VarMem atom1 c
                                      @[simp]
                                      theorem Std.Sat.CNF.Clause.VarMem_add {α : Type u_1} {atom : α} {c : Clause α} {pol : Bool} {v : α} :
                                      VarMem v (c.add atom pol) ↔ v = atom ∨ VarMem v c
                                      @[simp]
                                      theorem Std.Sat.CNF.Clause.VarMem_append {α : Type u_1} {v : α} {c1 c2 : Clause α} :
                                      VarMem v (c1 ++ c2) ↔ VarMem v c1 ∨ VarMem v c2
                                      theorem Std.Sat.CNF.Clause.inductionOn {α : Type u_1} {motive : Clause α → Prop} (empty : motive empty) (add : ∀ (c : Clause α) (atom : α) (pol : Bool), motive c → motive (c.add atom pol)) (c : Clause α) :
                                      motive c
                                      def Std.Sat.CNF.Mem {α : Type u_1} (f : CNF α) (c : Clause α) :

                                      Clause c occurs in CNF formula f.

                                      Instances For
                                        @[instance_reducible]
                                        @[instance_reducible]
                                        instance Std.Sat.CNF.instDecidableMemClauseOfDecidableEq {α : Type u_1} {c : Clause α} {f : CNF α} [DecidableEq α] :
                                        theorem Std.Sat.CNF.Internal.mem_iff {α : Type u_1} {c : Clause α} {f : CNF α} :
                                        c ∈ f ↔ c ∈ f.clauses
                                        theorem Std.Sat.CNF.Internal.clauses_append {α : Type u_1} {f1 f2 : CNF α} :
                                        (f1 ++ f2).clauses = f1.clauses ++ f2.clauses
                                        @[simp]
                                        theorem Std.Sat.CNF.not_mem_empty {α : Type u_1} {c : Clause α} :
                                        @[simp]
                                        theorem Std.Sat.CNF.mem_add {α : Type u_1} {f : CNF α} {c1 c2 : Clause α} :
                                        c1 ∈ f.add c2 ↔ c1 = c2 ∨ c1 ∈ f
                                        @[simp]
                                        theorem Std.Sat.CNF.mem_append {α : Type u_1} {f1 f2 : CNF α} {c : Clause α} :
                                        c ∈ f1 ++ f2 ↔ c ∈ f1 ∨ c ∈ f2
                                        def Std.Sat.CNF.VarMem {α : Type u_1} (v : α) (f : CNF α) :

                                        Variable v occurs in CNF formula f.

                                        Instances For
                                          @[instance_reducible]
                                          instance Std.Sat.CNF.instDecidableVarMemOfDecidableEq {α : Type u_1} {v : α} {f : CNF α} [DecidableEq α] :
                                          @[instance_reducible]
                                          theorem Std.Sat.CNF.not_VarMem_empty {α : Type u_1} {v : α} :
                                          theorem Std.Sat.CNF.VarMem_add {α : Type u_1} {v : α} {c : Clause α} {f : CNF α} :
                                          theorem Std.Sat.CNF.VarMem_of {α✝ : Type u_1} {f : CNF α✝} {c : Clause α✝} {v : α✝} (h : c ∈ f) (w : Clause.VarMem v c) :
                                          VarMem v f
                                          theorem Std.Sat.CNF.Internal.ext_iff {α : Type u_1} {f1 f2 : CNF α} :
                                          f1 = f2 ↔ f1.clauses = f2.clauses
                                          @[simp]
                                          theorem Std.Sat.CNF.append_empty {α : Type u_1} {f : CNF α} :
                                          f ++ empty = f
                                          @[simp]
                                          theorem Std.Sat.CNF.empty_append {α : Type u_1} {f : CNF α} :
                                          empty ++ f = f
                                          @[simp]
                                          theorem Std.Sat.CNF.append_assoc {α : Type u_1} {f1 f2 f3 : CNF α} :
                                          f1 ++ f2 ++ f3 = f1 ++ (f2 ++ f3)
                                          @[simp]
                                          theorem Std.Sat.CNF.VarMem_append {α : Type u_1} {v : α} {f1 f2 : CNF α} :
                                          VarMem v (f1 ++ f2) ↔ VarMem v f1 ∨ VarMem v f2