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).
- co
(lo hi : Int)
: IntInterval
The finite interval
[lo, hi). - ci
(lo : Int)
: IntInterval
The half-infinite interval
[lo, ∞). - io
(hi : Int)
: IntInterval
The half-infinite interval
(-∞, hi). - ii : IntInterval
The infinite interval
(-∞, ∞).
Instances For
Equations
Equations
- Lean.Grind.instBEqIntInterval.beq (Lean.Grind.IntInterval.co a a_1) (Lean.Grind.IntInterval.co b b_1) = (a == b && a_1 == b_1)
- Lean.Grind.instBEqIntInterval.beq (Lean.Grind.IntInterval.ci a) (Lean.Grind.IntInterval.ci b) = (a == b)
- Lean.Grind.instBEqIntInterval.beq (Lean.Grind.IntInterval.io a) (Lean.Grind.IntInterval.io b) = (a == b)
- Lean.Grind.instBEqIntInterval.beq Lean.Grind.IntInterval.ii Lean.Grind.IntInterval.ii = true
- Lean.Grind.instBEqIntInterval.beq x✝¹ x✝ = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.co lo hi) (Lean.Grind.IntInterval.ci lo_1) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.co lo hi) (Lean.Grind.IntInterval.io hi_1) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.co lo hi) Lean.Grind.IntInterval.ii = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.ci lo) (Lean.Grind.IntInterval.co lo_1 hi) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.ci a) (Lean.Grind.IntInterval.ci b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.ci lo) (Lean.Grind.IntInterval.io hi) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.ci lo) Lean.Grind.IntInterval.ii = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.io hi) (Lean.Grind.IntInterval.co lo hi_1) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.io hi) (Lean.Grind.IntInterval.ci lo) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.io a) (Lean.Grind.IntInterval.io b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq (Lean.Grind.IntInterval.io hi) Lean.Grind.IntInterval.ii = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq Lean.Grind.IntInterval.ii (Lean.Grind.IntInterval.co lo hi) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq Lean.Grind.IntInterval.ii (Lean.Grind.IntInterval.ci lo) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq Lean.Grind.IntInterval.ii (Lean.Grind.IntInterval.io hi) = isFalse ⋯
- Lean.Grind.instDecidableEqIntInterval.decEq Lean.Grind.IntInterval.ii Lean.Grind.IntInterval.ii = isTrue ⋯
Instances For
Equations
The interval [0, 2^n).
Equations
Instances For
The interval [-2^(n-1), 2^(n-1)).
Equations
- Lean.Grind.IntInterval.sint n = Lean.Grind.IntInterval.co (-2 ^ (n - 1)) (2 ^ (n - 1))
Instances For
The lower bound of the interval, if finite.
Equations
- (Lean.Grind.IntInterval.co lo hi).lo? = some lo
- (Lean.Grind.IntInterval.ci lo).lo? = some lo
- (Lean.Grind.IntInterval.io hi).lo? = none
- Lean.Grind.IntInterval.ii.lo? = none
Instances For
The upper bound of the interval, if finite.
Equations
- (Lean.Grind.IntInterval.co lo hi).hi? = some hi
- (Lean.Grind.IntInterval.ci lo).hi? = none
- (Lean.Grind.IntInterval.io hi).hi? = some hi
- Lean.Grind.IntInterval.ii.hi? = none
Instances For
Equations
- (Lean.Grind.IntInterval.co lo hi).nonEmpty = decide (lo < hi)
- (Lean.Grind.IntInterval.ci lo).nonEmpty = true
- (Lean.Grind.IntInterval.io hi).nonEmpty = true
- Lean.Grind.IntInterval.ii.nonEmpty = true
Instances For
Equations
Instances For
Equations
- (Lean.Grind.IntInterval.co lo hi).mem x = (lo ≤ x ∧ x < hi)
- (Lean.Grind.IntInterval.ci lo).mem x = (lo ≤ x)
- (Lean.Grind.IntInterval.io hi).mem x = (x < hi)
- Lean.Grind.IntInterval.ii.mem x = True
Instances For
Equations
- (Lean.Grind.IntInterval.co lo hi).wrap x = (x - lo) % (hi - lo) + lo
- (Lean.Grind.IntInterval.ci lo).wrap x = max x lo
- (Lean.Grind.IntInterval.io hi).wrap x = min x (hi - 1)
- Lean.Grind.IntInterval.ii.wrap x = x
Instances For
The embedding into the integers takes 0 to 0.
The embedding takes
0to0.
Instances
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.
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.
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.
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.
The embedding takes multiplication to multiplication, wrapped into the range interval.
Instances
The embedding into the integers takes exponentiation to exponentiation, wrapped into the range interval.
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).
The embedding takes modulo to modulo (without needing to wrap into the range interval). One might expect a
wrapon 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.
The embedding takes division to division (without needing to wrap into the range interval). One might expect a
wrapon the right hand side, but in practice this stronger statement is usually true.
Instances
Helper theorems #
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.