Documentation

HexGraphIso.Nauty.Search.Bits

The index of the least set bit, or 0 for the empty set (callers guard on nonemptiness). Structurally recursive on an always-sufficient fuel so the kernel can replay it.

Equations
Instances For
    Equations
    Instances For
      theorem Hex.GraphIso.Nauty.lowBit_go_congr (f₁ : Nat) {f₂ s : Nat} :
      s < f₁s < f₂lowBit.go f₁ s = lowBit.go f₂ s
      theorem Hex.GraphIso.Nauty.lowBit_eq (s : Nat) :
      lowBit s = if s = 0 then 0 else if s % 2 = 1 then 0 else 1 + lowBit (s / 2)

      The unconditional unfolding of lowBit.

      lowBit of every nonzero byte, by the specification itself.

      Equations
      Instances For
        @[irreducible]
        Equations
        Instances For
          theorem Hex.GraphIso.Nauty.lowBit_mod_pow (k : Nat) {s : Nat} :
          s % 2 ^ k 0lowBit s = lowBit (s % 2 ^ k)

          lowBit looks only at the low bits while they are not all zero.

          theorem Hex.GraphIso.Nauty.lowBit_shift_pow (k : Nat) {s : Nat} :
          s 0s % 2 ^ k = 0lowBit s = k + lowBit (s / 2 ^ k)

          lowBit steps over all-zero low bits.

          theorem Hex.GraphIso.Nauty.lowBitGo_eq (s shift : Nat) :
          lowBitGo s shift = if s = 0 then 0 else shift + lowBit s

          The number of set bits. Structurally recursive on an always-sufficient fuel so the kernel can replay it.

          Equations
          Instances For
            theorem Hex.GraphIso.Nauty.popCount_go_congr (f₁ : Nat) {f₂ s : Nat} :
            s < f₁s < f₂popCount.go f₁ s = popCount.go f₂ s

            The unconditional unfolding of popCount: also valid at zero.

            popCount of every byte, by the specification itself.

            Equations
            Instances For

              popCount splits at any power-of-two boundary.

              popCount splits at the byte boundary.

              @[irreducible]
              def Hex.GraphIso.Nauty.toListByteGo (b base cnt k : Nat) (acc : List Nat) :

              One byte of toList: prepend the set positions base + k, k < min 8 cnt, in ascending order (so the whole accumulator is descending and one final reverse restores order).

              Equations
              Instances For
                def Hex.GraphIso.Nauty.toListByte (b base cnt : Nat) (acc : List Nat) :
                Equations
                Instances For
                  @[irreducible]
                  def Hex.GraphIso.Nauty.toListGo (base cnt s : Nat) (acc : List Nat) :

                  The byte-chunked toList walk: one big-number shift per byte, with an early exit once the remainder is empty. It accumulates in reverse, and one final reverse restores ascending order.

                  Equations
                  Instances For
                    theorem Hex.GraphIso.Nauty.toListByteGo_eq (b base cnt k : Nat) (acc : List Nat) :
                    toListByteGo b base cnt k acc = (List.map (fun (x : Nat) => base + x) (List.filter b.testBit (List.range' k (min 8 cnt - k)))).reverse ++ acc
                    theorem Hex.GraphIso.Nauty.toListGo_eq (base cnt s : Nat) (acc : List Nat) :
                    toListGo base cnt s acc = (List.map (fun (x : Nat) => base + x) (List.filter s.testBit (List.range cnt))).reverse ++ acc

                    The number of set bits below n.

                    Equations
                    Instances For

                      popCount counts exactly the bits below any bound dominating the set.

                      theorem Hex.GraphIso.Nauty.testBit_one_shift (v w : Nat) :
                      (1 <<< v).testBit w = (v == w)

                      The single-bit set.

                      The least set bit is a member.

                      theorem Hex.GraphIso.Nauty.lt_two_pow_of_bits {s n : Nat} (h : ∀ (i : Nat), n is.testBit i = false) :
                      s < 2 ^ n

                      A set whose bits all lie below n is bounded by 2 ^ n.

                      theorem Hex.GraphIso.Nauty.or_shift_lt {x : Nat} (hx : x < 2 ^ 63) {j : Nat} (hj : j < 63) :
                      x ||| 1 <<< j < 2 ^ 63

                      Entry bound after an insertion.

                      theorem Hex.GraphIso.Nauty.lowBit_eq_of {s d : Nat} (hd : s.testBit d = true) (hlow : ∀ (i : Nat), i < ds.testBit i = false) :
                      lowBit s = d
                      theorem Hex.GraphIso.Nauty.xor_ne_zero_of_ne {a b : Nat} (hab : a b) :
                      a ^^^ b 0

                      Insertion, a no-op outside the vertex range.

                      Equations
                      Instances For

                        Deletion, a no-op outside the vertex range.

                        Equations
                        Instances For

                          The least element strictly after the cursor (none starts from the least element): nauty's nextelement.

                          Equations
                          Instances For

                            nauty's row order: the least differing vertex decides, and the row holding it is the greater.

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

                              The image of a bitset under a vertex map.

                              Equations
                              Instances For
                                theorem Hex.GraphIso.Nauty.testBit_shiftUp (x a w : Nat) :
                                (x >>> a <<< a).testBit w = (decide (a w) && x.testBit w)