Documentation

HexGraphIso.Nauty.Search.VSet.Basic

The number of 63-bit limbs holding n vertices.

Equations
Instances For
    theorem Hex.GraphIso.Nauty.lt_limbCount_mul {n v : Nat} (h : v < n) :
    v / 63 < limbCount n

    A vertex renaming: injective everywhere and range-preserving in both directions. Images under renamings are the equivariance the search theory works with.

    • toFun : NatNat

      The underlying vertex map.

    • inj (a b : Nat) : self.toFun a = self.toFun ba = b

      Global injectivity.

    • maps (v : Nat) : v < n self.toFun v < n

      The vertex range is preserved in both directions.

    Instances For

      A vertex set over n vertices: limbCount n limbs, each an unboxed 63-bit word, with no vertex at or above n.

      Instances For
        @[inline]
        def Hex.GraphIso.Nauty.VSet.mem {n : Nat} (s : VSet n) (v : Nat) :

        Membership: the specification lens of the whole interface.

        Equations
        Instances For
          theorem Hex.GraphIso.Nauty.VSet.mem_lt {n : Nat} {s : VSet n} {v : Nat} (h : s.mem v = true) :
          v < n
          theorem Hex.GraphIso.Nauty.VSet.mem_of_ge {n : Nat} {s : VSet n} {v : Nat} (h : n v) :
          s.mem v = false
          theorem Hex.GraphIso.Nauty.VSet.limbs_ext {n : Nat} {s t : VSet n} (h : s.limbs = t.limbs) :
          s = t
          @[instance_reducible]

          Equality compares the limb arrays. Hex.instDecidableEqArray keeps the comparison kernel-reducible across the module boundary.

          Equations
          theorem Hex.GraphIso.Nauty.VSet.ext {n : Nat} {s t : VSet n} (h : ∀ (v : Nat), s.mem v = t.mem v) :
          s = t

          Sets with the same members are equal.

          theorem Hex.GraphIso.Nauty.VSet.ext_iff {n : Nat} {s t : VSet n} :
          s = t ∀ (v : Nat), s.mem v = t.mem v
          structure Hex.GraphIso.Nauty.VSet.Wf (n : Nat) (limbs : Array Nat) :

          A limb array is well formed for n vertices when it has limbCount n limbs, every limb is a 63-bit word, and no bit at or above n is set. The runtime never checks this. Each operation preserves it by proof.

          Instances For
            @[inline]
            def Hex.GraphIso.Nauty.VSet.ofLimbs {n : Nat} (limbs : Array Nat) (h : Wf n limbs) :

            Assemble a set from a well-formed limb array.

            Equations
            Instances For
              theorem Hex.GraphIso.Nauty.VSet.wf {n : Nat} (s : VSet n) :
              Wf n s.limbs
              @[simp]
              theorem Hex.GraphIso.Nauty.VSet.limbs_ofLimbs {n : Nat} (limbs : Array Nat) (h : Wf n limbs) :
              (ofLimbs limbs h).limbs = limbs
              theorem Hex.GraphIso.Nauty.VSet.mem_ofLimbs {n : Nat} (limbs : Array Nat) (h : Wf n limbs) (v : Nat) :
              (ofLimbs limbs h).mem v = limbs[v / 63]!.testBit (v % 63)
              theorem Hex.GraphIso.Nauty.VSet.eq_empty_iff {n : Nat} {s : VSet n} :
              s = empty ∀ (v : Nat), s.mem v = false
              theorem Hex.GraphIso.Nauty.VSet.wf_set_or {n : Nat} {limbs : Array Nat} (h : Wf n limbs) {v : Nat} (hv : v < n) :
              Wf n (limbs.set! (v / 63) (limbs[v / 63]! ||| 1 <<< (v % 63)))
              def Hex.GraphIso.Nauty.VSet.insert {n : Nat} (s : VSet n) (v : Nat) :

              Insert a vertex.

              Equations
              Instances For
                theorem Hex.GraphIso.Nauty.VSet.mem_insert {n : Nat} (s : VSet n) (v w : Nat) :
                (s.insert v).mem w = (s.mem w || v == w && decide (v < n))
                theorem Hex.GraphIso.Nauty.VSet.mem_insert_of_lt {n : Nat} (s : VSet n) {v : Nat} (hv : v < n) (w : Nat) :
                (s.insert v).mem w = (s.mem w || v == w)
                theorem Hex.GraphIso.Nauty.VSet.mem_insert_self {n : Nat} (s : VSet n) {v : Nat} (hv : v < n) :
                (s.insert v).mem v = true
                theorem Hex.GraphIso.Nauty.VSet.mem_insert_mono {n : Nat} (s : VSet n) {u : Nat} (w : Nat) (h : s.mem u = true) :
                (s.insert w).mem u = true
                theorem Hex.GraphIso.Nauty.VSet.insert_of_ge {n : Nat} (s : VSet n) {v : Nat} (hv : n v) :
                s.insert v = s
                theorem Hex.GraphIso.Nauty.VSet.wf_erase_step {n : Nat} {limbs : Array Nat} (h : Wf n limbs) {v : Nat} (hv : v < n) :
                Wf n (limbs.set! (v / 63) (limbs[v / 63]! ^^^ 1 <<< (v % 63)))
                def Hex.GraphIso.Nauty.VSet.erase {n : Nat} (s : VSet n) (v : Nat) :

                Delete a vertex.

                Equations
                Instances For
                  theorem Hex.GraphIso.Nauty.VSet.mem_erase {n : Nat} (s : VSet n) (v w : Nat) :
                  (s.erase v).mem w = (s.mem w && !v == w)
                  def Hex.GraphIso.Nauty.VSet.zipLimbs {n : Nat} (op : NatNatNat) (s t : VSet n) :

                  The limbwise combination of two packed sets. Hex.Array.zipWith' reduces in the kernel where Lean's own Array.zipWith stalls, and compiles to the same loop.

                  Equations
                  Instances For
                    theorem Hex.GraphIso.Nauty.VSet.size_zipLimbs {n : Nat} (op : NatNatNat) (s t : VSet n) :
                    theorem Hex.GraphIso.Nauty.VSet.getElem!_zipLimbs {n : Nat} (op : NatNatNat) (s t : VSet n) (i : Nat) (hi : i < limbCount n) :
                    (zipLimbs op s t)[i]! = op s.limbs[i]! t.limbs[i]!
                    theorem Hex.GraphIso.Nauty.VSet.getElem!_zipLimbs_of_ge {n : Nat} (op : NatNatNat) (s t : VSet n) (i : Nat) (hi : limbCount n i) :
                    (zipLimbs op s t)[i]! = 0
                    theorem Hex.GraphIso.Nauty.VSet.wf_zipLimbs {n : Nat} (op : NatNatNat) (hop : ∀ (a b : Nat), a < 2 ^ 63b < 2 ^ 63op a b < 2 ^ 63) (hbit : ∀ (a b j : Nat), (op a b).testBit j = truea.testBit j = true b.testBit j = true) (s t : VSet n) :
                    Wf n (zipLimbs op s t)

                    Intersection.

                    Equations
                    Instances For
                      theorem Hex.GraphIso.Nauty.VSet.mem_inter {n : Nat} (s t : VSet n) (w : Nat) :
                      (s.inter t).mem w = (s.mem w && t.mem w)

                      Union.

                      Equations
                      Instances For
                        theorem Hex.GraphIso.Nauty.VSet.mem_union {n : Nat} (s t : VSet n) (w : Nat) :
                        (s.union t).mem w = (s.mem w || t.mem w)
                        def Hex.GraphIso.Nauty.VSet.xor {n : Nat} (s t : VSet n) :

                        Symmetric difference.

                        Equations
                        Instances For
                          theorem Hex.GraphIso.Nauty.VSet.mem_xor {n : Nat} (s t : VSet n) (w : Nat) :
                          (s.xor t).mem w = (s.mem w ^^ t.mem w)
                          theorem Hex.GraphIso.Nauty.VSet.mem_eq {n : Nat} (s : VSet n) (v : Nat) :
                          s.mem v = s.limbs[v / 63]!.testBit (v % 63)
                          theorem Hex.GraphIso.Nauty.VSet.testBit_limb {n : Nat} (s : VSet n) (i j : Nat) (hj : j < 63) :
                          s.limbs[i]!.testBit j = s.mem (63 * i + j)
                          theorem Hex.GraphIso.Nauty.VSet.testBit_limb_of_ge {n : Nat} (s : VSet n) (i j : Nat) (hj : 63 j) :
                          theorem Hex.GraphIso.Nauty.VSet.limb_eq_of_mem {n : Nat} {s t : VSet n} (i : Nat) (h : ∀ (j : Nat), j < 63s.mem (63 * i + j) = t.mem (63 * i + j)) :
                          theorem Hex.GraphIso.Nauty.VSet.limb_eq_zero_iff {n : Nat} (s : VSet n) (i : Nat) :
                          s.limbs[i]! = 0 ∀ (j : Nat), j < 63s.mem (63 * i + j) = false
                          theorem Hex.GraphIso.Nauty.VSet.mem_of_ge_limbCount {n : Nat} (s : VSet n) {v : Nat} (h : limbCount n v / 63) :
                          s.mem v = false

                          The members of limb i, in order, as vertex numbers.

                          Equations
                          Instances For

                            The members below 63 * k, as the concatenation of the limb blocks.

                            @[specialize #[]]
                            def Hex.GraphIso.Nauty.VSet.foldLimbs {n : Nat} {α : Sort u_1} (f : NatNatαα) (s t : VSet n) (init : α) :
                            α

                            Fold a function of corresponding limb pairs over all limbs.

                            Equations
                            Instances For
                              def Hex.GraphIso.Nauty.VSet.foldLimbs.go {n : Nat} {α : Sort u_1} (f : NatNatαα) (s t : VSet n) :
                              NatNatαα
                              Equations
                              Instances For
                                @[specialize #[]]
                                def Hex.GraphIso.Nauty.VSet.allLimbs {n : Nat} (p : NatNatBool) (s t : VSet n) :

                                Whether every limb satisfies a predicate of the limb pair, with early exit.

                                Equations
                                Instances For
                                  def Hex.GraphIso.Nauty.VSet.allLimbs.go {n : Nat} (p : NatNatBool) (s t : VSet n) :
                                  NatNatBool
                                  Equations
                                  Instances For

                                    The number of members.

                                    Equations
                                    Instances For

                                      card (s.inter t) without materializing the intersection.

                                      Equations
                                      Instances For

                                        Emptiness.

                                        Equations
                                        Instances For

                                          isEmpty (s.inter t) without materializing the intersection.

                                          Equations
                                          Instances For

                                            Containment: every member of s is a member of t.

                                            Equations
                                            Instances For

                                              The number of members below a bound: the counting specification of card.

                                              Equations
                                              Instances For
                                                theorem Hex.GraphIso.Nauty.VSet.allLimbs_iff {n : Nat} (p : NatNatBool) (s t : VSet n) :
                                                allLimbs p s t = true ∀ (i : Nat), i < limbCount np s.limbs[i]! t.limbs[i]! = true
                                                theorem Hex.GraphIso.Nauty.VSet.subset_iff {n : Nat} {s t : VSet n} :
                                                s.subset t = true ∀ (v : Nat), s.mem v = truet.mem v = true

                                                The least vertex at or after limb i, if any.

                                                Equations
                                                Instances For

                                                  The least member, or 0 for the empty set (callers guard on nonemptiness). This is nauty's FIRSTBITNZ over the words.

                                                  Equations
                                                  Instances For

                                                    The least member greater than pos, or none: nauty's nextelement, iterating a set in ascending vertex order. pos = none starts from the least member.

                                                    Equations
                                                    Instances For
                                                      theorem Hex.GraphIso.Nauty.VSet.lowBit_lt_of_lt {x k : Nat} (hx : x < 2 ^ k) (h0 : x 0) :
                                                      lowBit x < k
                                                      theorem Hex.GraphIso.Nauty.VSet.firstFrom_some {n : Nat} (s : VSet n) (fuel i v : Nat) :
                                                      s.firstFrom fuel i = some vs.mem v = true 63 * i v ∀ (w : Nat), 63 * i ww < vs.mem w = false

                                                      What a firstFrom hit is: a member at or after the start limb with no member in between.

                                                      theorem Hex.GraphIso.Nauty.VSet.firstFrom_none {n : Nat} (s : VSet n) (fuel i : Nat) :
                                                      s.firstFrom fuel i = none∀ (w : Nat), 63 * i ww < 63 * (i + fuel) → s.mem w = false

                                                      A firstFrom miss: no member from the start limb to the fuel's end.

                                                      theorem Hex.GraphIso.Nauty.VSet.minElem_eq_of {n : Nat} {s : VSet n} {d : Nat} (hd : s.mem d = true) (hlow : ∀ (i : Nat), i < ds.mem i = false) :

                                                      The scan property: v is the least member at or after a.

                                                      Equations
                                                      Instances For
                                                        theorem Hex.GraphIso.Nauty.VSet.IsNextFrom.unique {n : Nat} {s : VSet n} {a v v' : Nat} (h : s.IsNextFrom a v) (h' : s.IsNextFrom a v') :
                                                        v = v'
                                                        theorem Hex.GraphIso.Nauty.VSet.nextElem_some {n : Nat} {s : VSet n} {pos : Option Nat} {v : Nat} (h : s.nextElem pos = some v) :
                                                        theorem Hex.GraphIso.Nauty.VSet.nextElem_none {n : Nat} {s : VSet n} {pos : Option Nat} (h : s.nextElem pos = none) (w : Nat) :
                                                        scanStart pos ws.mem w = false
                                                        theorem Hex.GraphIso.Nauty.VSet.nextElem_eq_some_iff {n : Nat} {s : VSet n} {pos : Option Nat} {v : Nat} :
                                                        s.nextElem pos = some v s.mem v = true scanStart pos v ∀ (w : Nat), scanStart pos ww < vs.mem w = false
                                                        theorem Hex.GraphIso.Nauty.VSet.nextElem_eq_none_iff {n : Nat} {s : VSet n} {pos : Option Nat} :
                                                        s.nextElem pos = none ∀ (w : Nat), scanStart pos ws.mem w = false
                                                        theorem Hex.GraphIso.Nauty.VSet.nextElem_mem {n : Nat} {s : VSet n} {pos : Option Nat} {v : Nat} (h : s.nextElem pos = some v) :
                                                        s.mem v = true

                                                        The members in ascending order, one byte-chunked word walk per limb.

                                                        Equations
                                                        Instances For
                                                          Equations
                                                          Instances For

                                                            The row order.

                                                            Equations
                                                            Instances For
                                                              Equations
                                                              Instances For
                                                                theorem Hex.GraphIso.Nauty.VSet.rowCmp_go_eq_of {n : Nat} {s t : VSet n} (fuel i : Nat) :
                                                                (∀ (k : Nat), k < fuels.limbs[i + k]! = t.limbs[i + k]!)rowCmp.go s t fuel i = Ordering.eq

                                                                The outcome of the limb scan from i with fuel limbs. Equal prefixes give .eq. Otherwise the first differing limb decides, by its least differing bit.

                                                                theorem Hex.GraphIso.Nauty.VSet.rowCmp_go_ne_of {n : Nat} {s t : VSet n} (fuel i k : Nat) :
                                                                k < fuel(∀ (k' : Nat), k' < ks.limbs[i + k']! = t.limbs[i + k']!)s.limbs[i + k]! t.limbs[i + k]!rowCmp.go s t fuel i = if s.limbs[i + k]!.testBit (lowBit (s.limbs[i + k]! ^^^ t.limbs[i + k]!)) = true then Ordering.gt else Ordering.lt
                                                                theorem Hex.GraphIso.Nauty.VSet.rowCmp_gt_iff {n : Nat} {s t : VSet n} :
                                                                s.rowCmp t = Ordering.gt (d : Nat), s.mem d = true t.mem d = false ∀ (i : Nat), i < ds.mem i = t.mem i
                                                                theorem Hex.GraphIso.Nauty.VSet.rowCmp_lt_iff {n : Nat} {s t : VSet n} :
                                                                s.rowCmp t = Ordering.lt (d : Nat), s.mem d = false t.mem d = true ∀ (i : Nat), i < ds.mem i = t.mem i

                                                                The row order is transitive.

                                                                The set of vertices below n satisfying a predicate.

                                                                Equations
                                                                Instances For
                                                                  theorem Hex.GraphIso.Nauty.VSet.mem_foldl_insert_if {n : Nat} (f : NatBool) (l : List Nat) (init : VSet n) (w : Nat) :
                                                                  (List.foldl (fun (s : VSet n) (v : Nat) => if f v = true then s.insert v else s) init l).mem w = (init.mem w || l.contains w && f w && decide (w < n))

                                                                  Membership after a guarded insertion fold.

                                                                  theorem Hex.GraphIso.Nauty.VSet.mem_ofFn {n : Nat} (f : NatBool) (v : Nat) :
                                                                  (ofFn f).mem v = (decide (v < n) && f v)
                                                                  theorem Hex.GraphIso.Nauty.VSet.mem_foldl_insert {n : Nat} (l : List Nat) (init : VSet n) (w : Nat) :
                                                                  (List.foldl insert init l).mem w = (init.mem w || l.contains w && decide (w < n))
                                                                  theorem Hex.GraphIso.Nauty.VSet.mem_ofList {n : Nat} (l : List Nat) (v : Nat) :
                                                                  (ofList l).mem v = (decide (v < n) && l.contains v)
                                                                  def Hex.GraphIso.Nauty.VSet.ofFnLimb {n : Nat} (f : NatBool) (base : Nat) :
                                                                  NatNatNat

                                                                  One limb of ofFn: Horner accumulation over the limb's vertices, most significant first, so the accumulator stays a scalar throughout.

                                                                  Equations
                                                                  Instances For

                                                                    The limbs of ofFn, least significant first.

                                                                    Equations
                                                                    Instances For
                                                                      theorem Hex.GraphIso.Nauty.VSet.mem_ofFnFast_limbs {n : Nat} (f : NatBool) (v : Nat) :
                                                                      (ofFnLimbs f (limbCount n) #[])[v / 63]!.testBit (v % 63) = (decide (v < n) && f v)

                                                                      ofFn built one limb at a time: allocation-free and without the List.range fold.

                                                                      Equations
                                                                      Instances For
                                                                        def Hex.GraphIso.Nauty.VSet.image {n : Nat} (σ : NatNat) (s : VSet n) :

                                                                        The image of a set under a vertex map, dropping targets outside the range: nauty's permset.

                                                                        Equations
                                                                        Instances For
                                                                          theorem Hex.GraphIso.Nauty.VSet.mem_foldl_image {n : Nat} (σ : NatNat) (s : VSet n) (l : List Nat) (init : VSet n) (w : Nat) :
                                                                          (List.foldl (fun (t : VSet n) (v : Nat) => if s.mem v = true then t.insert (σ v) else t) init l).mem w = (init.mem w || l.any fun (v : Nat) => s.mem v && σ v == w && decide (σ v < n))
                                                                          theorem Hex.GraphIso.Nauty.VSet.mem_image {n : Nat} (σ : NatNat) (s : VSet n) (w : Nat) :
                                                                          (image σ s).mem w = (List.range n).any fun (v : Nat) => s.mem v && σ v == w && decide (σ v < n)
                                                                          def Hex.GraphIso.Nauty.VSet.imageLimb {n : Nat} (σ : NatNat) (base : Nat) :
                                                                          NatNatVSet nVSet n

                                                                          The set bits of one limb, by repeated lowest-bit extraction, each inserted through σ.

                                                                          Equations
                                                                          Instances For
                                                                            def Hex.GraphIso.Nauty.VSet.imageFast {n : Nat} (σ : NatNat) (s : VSet n) :

                                                                            image walking the set bits of each limb by repeated lowest-bit extraction, so the cost is proportional to the members and the limbs, never to n bit tests.

                                                                            Equations
                                                                            Instances For
                                                                              @[inline]
                                                                              def Hex.GraphIso.Nauty.VSet.permset {n : Nat} (s : VSet n) (perm : Array Nat) :

                                                                              The image under a permutation array: nauty's permset.

                                                                              Equations
                                                                              Instances For
                                                                                @[simp]
                                                                                theorem Hex.GraphIso.Nauty.VSet.mem_image_apply {n : Nat} (σ : Renaming n) (s : VSet n) {v : Nat} (hv : v < n) :
                                                                                (image σ.toFun s).mem (σ.toFun v) = s.mem v

                                                                                Membership transports along a renaming.

                                                                                theorem Hex.GraphIso.Nauty.VSet.image_insert {n : Nat} (σ : Renaming n) (s : VSet n) {v : Nat} (hv : v < n) :
                                                                                image σ.toFun (s.insert v) = (image σ.toFun s).insert (σ.toFun v)

                                                                                Images commute with insertion of a vertex.

                                                                                theorem Hex.GraphIso.Nauty.VSet.image_inter {n : Nat} (σ : Renaming n) (s t : VSet n) :
                                                                                image σ.toFun (s.inter t) = (image σ.toFun s).inter (image σ.toFun t)

                                                                                Images commute with intersection, for a renaming.

                                                                                theorem Hex.GraphIso.Nauty.VSet.image_inj {n : Nat} (σ : Renaming n) {s t : VSet n} (h : image σ.toFun s = image σ.toFun t) :
                                                                                s = t

                                                                                Images under a renaming are injective.

                                                                                Emptiness of an intersection is preserved by a renaming.

                                                                                theorem Hex.GraphIso.Nauty.VSet.subset_image {n : Nat} (σ : Renaming n) (s t : VSet n) :
                                                                                (image σ.toFun s).subset (image σ.toFun t) = s.subset t

                                                                                Containment is preserved by a renaming.

                                                                                theorem Hex.GraphIso.Nauty.VSet.card_image {n : Nat} (σ : Renaming n) (s : VSet n) :
                                                                                (image σ.toFun s).card = s.card

                                                                                The member count is preserved by a renaming.