Documentation

Trestle.Data.ICnf.Defs

The implementation type of DIMACS variables (hence the "I" in IVar).

In DIMACS, variables are represented by strictly positive integers. We attach the positivity-hypothesis as a subtype here.

This type is the exact same as the one for PNat in Mathlib (see Data.PNat.Defs.lean). We redefine it here to avoid the dependency on Mathlib, and also in case we want to change the backing type to UInt64 in the future.

Equations
Instances For

    The implementation type of DIMACS literals (hence the "I" in ILit).

    In DIMACS, literals are non-zero integers, with negative numbers variables with an optional negation. We represent them as integers, with the invariant that they are non-zero.

    Equations
    Instances For

      index #

      @[always_inline]

      Converts an IVar into a 0-indexed Nat.

      DIMACS variables are 1-indexed, but arrays are 0-indexed, so index subtracts one and does the coercion.

      Equations
      Instances For
        @[always_inline]

        Converts a 0-indexed Nat into an IVar.

        Equations
        Instances For
          @[simp]
          theorem Trestle.IVar.ofIndex_inj (n m : Nat) :
          @[simp]
          Equations
          Equations
          theorem Trestle.IVar.lt_def (a b : IVar) :
          (a < b) = (a.val < b.val)
          @[simp]
          theorem Trestle.IVar.lt_ofIndex (a b : Nat) :
          Equations
          theorem Trestle.IVar.le_def (a b : IVar) :
          (a b) = (a.val b.val)
          @[simp]
          theorem Trestle.IVar.le_refl (a : IVar) :
          a a
          @[simp]
          Equations
          @[simp]
          theorem Trestle.IVar.val_addNat (v : IVar) (x : Nat) :
          (v + x).val = v.val + x
          @[simp]
          theorem Trestle.IVar.index_addNat (v : IVar) (x : Nat) :
          (v + x).index = v.index + x
          theorem Trestle.IVar.add_lt_of_pos {x : Nat} (pos : 0 < x) (v : IVar) :
          v < v + x
          @[simp]
          theorem Trestle.IVar.add_lt_add_left (v : IVar) (x y : Nat) :
          v + x < v + y x < y
          Equations
          Instances For
            Equations
            Instances For
              Equations
              Instances For
                instance Trestle.IVar.instOfNat {n : Nat} :
                OfNat IVar (n + 1)
                Equations
                Equations
                Equations
                Instances For
                  Equations
                  Instances For
                    instance Trestle.ILit.instOfNat {n : Nat} :
                    OfNat ILit (n + 1)
                    Equations
                    Equations
                    Instances For

                      Returns true iff the literal is positive.

                      Equations
                      Instances For
                        Equations
                        Instances For
                          Equations
                          • One or more equations did not get rendered due to their size.
                          theorem Trestle.ILit.polarity_eq {l₁ l₂ : ILit} :
                          LitVar.polarity l₁ = LitVar.polarity l₂ (0 < l₁.val 0 < l₂.val)

                          index #

                          @[always_inline]

                          Converts an ILit into a 0-indexed Nat.

                          DIMACS literals are 1-indexed (ignoring sign), but arrays are 0-indexed, so index subtracts one and does the coercion.

                          Equations
                          Instances For
                            @[always_inline]

                            Converts a 0-indexed Nat into an ILit.

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

                                    Finds the maximum DIMACS variable in a clause. If the clause is empty, then 0 is returned.

                                    Equations
                                    Instances For

                                      Finds the maximum DIMACS variable in the CNF. If there are no variables in the formula, then 0 is returned.

                                      Equations
                                      Instances For