Documentation

Init.Grind.ToInt

Typeclasses for types that can be embedded into an interval of Int. #

The typeclass ToInt α lo? hi? carries the data of a function ToInt.toInt : α → Int which is injective, lands between the (optional) lower and upper bounds lo? and hi?.

The function ToInt.wrap is the identity if either bound is none, and otherwise wraps the integers into the interval [lo, hi).

The typeclass ToInt.Add α lo? hi? then asserts that toInt (x + y) = wrap lo? hi? (toInt x + toInt y). There are many variants for other operations.

These typeclasses are used solely in the grind tactic to lift linear inequalities into Int.

An interval in the integers (either finite, half-infinite, or infinite).

Instances For
    @[reducible, inline]

    The interval [0, 2^n).

    Equations
    Instances For
      @[reducible, inline]

      The interval [-2^(n-1), 2^(n-1)).

      Equations
      Instances For
        @[simp]
        theorem Lean.Grind.IntInterval.mem_co (lo hi x : Int) :
        x co lo hi lo x x < hi
        @[simp]
        theorem Lean.Grind.IntInterval.mem_ci (lo x : Int) :
        x ci lo lo x
        @[simp]
        theorem Lean.Grind.IntInterval.mem_io (hi x : Int) :
        x io hi x < hi
        theorem Lean.Grind.IntInterval.wrap_add {i : IntInterval} (h : i.isFinite = true) (x y : Int) :
        i.wrap (x + y) = i.wrap (i.wrap x + i.wrap y)
        theorem Lean.Grind.IntInterval.wrap_mul {i : IntInterval} (h : i.isFinite = true) (x y : Int) :
        i.wrap (x * y) = i.wrap (i.wrap x * i.wrap y)
        theorem Lean.Grind.IntInterval.wrap_eq_bmod {x i : Int} (h : 0 i) :
        (co (-i) i).wrap x = x.bmod (2 * i).toNat
        theorem Lean.Grind.IntInterval.wrap_eq_wrap_iff {lo hi x y : Int} :
        (co lo hi).wrap x = (co lo hi).wrap y (x - y) % (hi - lo) = 0
        class Lean.Grind.ToInt (α : Type u) (range : outParam IntInterval) :

        ToInt α I asserts that α can be embedded faithfully into an interval I in the integers.

        • toInt : αInt

          The embedding function.

        • toInt_inj (x y : α) : x = yx = y

          The embedding function is injective.

        • toInt_mem (x : α) : x range

          The embedding function lands in the interval.

        Instances

          The embedding into the integers takes 0 to 0.

          • toInt_zero : 0 = 0

            The embedding takes 0 to 0.

          Instances
            class Lean.Grind.ToInt.OfNat (α : Type u) [(n : Nat) → _root_.OfNat α n] (I : outParam IntInterval) [ToInt α I] :

            The embedding into the integers takes numerals in the range interval to themselves.

            Instances

              The embedding into the integers takes addition to addition, wrapped into the range interval.

              • toInt_add (x y : α) : (x + y) = IntInterval.wrap I (x + y)

                The embedding takes addition to addition, wrapped into the range interval.

              Instances

                The embedding into the integers takes negation to negation, wrapped into the range interval.

                • toInt_neg (x : α) : (-x) = IntInterval.wrap I (-x)

                  The embedding takes negation to negation, wrapped into the range interval.

                Instances

                  The embedding into the integers takes subtraction to subtraction, wrapped into the range interval.

                  • toInt_sub (x y : α) : (x - y) = IntInterval.wrap I (x - y)

                    The embedding takes subtraction to subtraction, wrapped into the range interval.

                  Instances

                    The embedding into the integers takes multiplication to multiplication, wrapped into the range interval.

                    • toInt_mul (x y : α) : (x * y) = IntInterval.wrap I (x * y)

                      The embedding takes multiplication to multiplication, wrapped into the range interval.

                    Instances
                      class Lean.Grind.ToInt.Pow (α : Type u) [HPow α Nat α] (I : outParam IntInterval) [ToInt α I] :

                      The embedding into the integers takes exponentiation to exponentiation, wrapped into the range interval.

                      • toInt_pow (x : α) (n : Nat) : (x ^ n) = IntInterval.wrap I (x ^ n)

                        The embedding takes exponentiation to exponentiation, wrapped into the range interval.

                      Instances

                        The embedding into the integers takes modulo to modulo (without needing to wrap into the range interval).

                        • toInt_mod (x y : α) : (x % y) = x % y

                          The embedding takes modulo to modulo (without needing to wrap into the range interval). One might expect a wrap on the right hand side, but in practice this stronger statement is usually true.

                        Instances

                          The embedding into the integers takes division to division, wrapped into the range interval.

                          • toInt_div (x y : α) : (x / y) = x / y

                            The embedding takes division to division (without needing to wrap into the range interval). One might expect a wrap on the right hand side, but in practice this stronger statement is usually true.

                          Instances
                            class Lean.Grind.ToInt.LE (α : Type u) [_root_.LE α] (I : outParam IntInterval) [ToInt α I] :

                            The embedding into the integers is monotone.

                            • le_iff (x y : α) : x y x y

                              The embedding is monotone with respect to .

                            Instances
                              class Lean.Grind.ToInt.LT (α : Type u) [_root_.LT α] (I : outParam IntInterval) [ToInt α I] :

                              The embedding into the integers is strictly monotone.

                              • lt_iff (x y : α) : x < y x < y

                                The embedding is strictly monotone with respect to <.

                              Instances

                                Helper theorems #

                                theorem Lean.Grind.ToInt.Zero.wrap_zero {α : Type u_1} (I : IntInterval) [_root_.Zero α] [ToInt α I] [Zero α I] :
                                I.wrap 0 = 0
                                @[simp]
                                theorem Lean.Grind.ToInt.wrap_toInt {α : Type u_1} (I : IntInterval) [ToInt α I] (x : α) :
                                def Lean.Grind.ToInt.Sub.of_sub_eq_add_neg {α : Type u} [_root_.Add α] [_root_.Neg α] [_root_.Sub α] (sub_eq_add_neg : ∀ (x y : α), x - y = x + -y) {I : IntInterval} (h : I.isFinite = true) [ToInt α I] [Add α I] [Neg α I] :
                                Sub α I

                                Construct a ToInt.Sub instance from a ToInt.Add and ToInt.Neg instance and a sub_eq_add_neg assumption.

                                Equations
                                • =
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For