Helper definitions and theorems for constructing linear arithmetic proofs.
Equations
Instances For
Equations
- Int.Linear.Var.denote ctx v = Lean.RArray.get ctx v
Instances For
Equations
- Int.Linear.instInhabitedExpr = { default := Int.Linear.Expr.num default }
Equations
- Int.Linear.instBEqExpr = { beq := Int.Linear.beqExpr✝ }
Equations
- Int.Linear.Expr.denote ctx (a.add b) = (Int.Linear.Expr.denote ctx a).add (Int.Linear.Expr.denote ctx b)
- Int.Linear.Expr.denote ctx (a.sub b) = (Int.Linear.Expr.denote ctx a).sub (Int.Linear.Expr.denote ctx b)
- Int.Linear.Expr.denote ctx a.neg = (Int.Linear.Expr.denote ctx a).neg
- Int.Linear.Expr.denote ctx (Int.Linear.Expr.num k) = k
- Int.Linear.Expr.denote ctx (Int.Linear.Expr.var v) = Int.Linear.Var.denote ctx v
- Int.Linear.Expr.denote ctx (Int.Linear.Expr.mulL k e) = k.mul (Int.Linear.Expr.denote ctx e)
- Int.Linear.Expr.denote ctx (e.mulR k) = (Int.Linear.Expr.denote ctx e).mul k
Instances For
Equations
- Int.Linear.instBEqPoly = { beq := Int.Linear.beqPoly✝ }
Equations
- Int.Linear.Poly.denote ctx (Int.Linear.Poly.num k) = k
- Int.Linear.Poly.denote ctx (Int.Linear.Poly.add k v p_2) = (k.mul (Int.Linear.Var.denote ctx v)).add (Int.Linear.Poly.denote ctx p_2)
Instances For
Similar to Poly.denote
, but produces a denotation better for simp +arith
.
Remark: we used to convert Poly
back into Expr
to achieve that.
Equations
- Int.Linear.Poly.denote' ctx (Int.Linear.Poly.num k) = k
- Int.Linear.Poly.denote' ctx (Int.Linear.Poly.add 1 v p_2) = Int.Linear.Poly.denote'.go ctx (Int.Linear.Var.denote ctx v) p_2
- Int.Linear.Poly.denote' ctx (Int.Linear.Poly.add k v p_2) = Int.Linear.Poly.denote'.go ctx (k.mul (Int.Linear.Var.denote ctx v)) p_2
Instances For
Equations
- Int.Linear.Poly.denote'.go ctx r (Int.Linear.Poly.num 0) = r
- Int.Linear.Poly.denote'.go ctx r (Int.Linear.Poly.num k) = r.add k
- Int.Linear.Poly.denote'.go ctx r (Int.Linear.Poly.add 1 v p_2) = Int.Linear.Poly.denote'.go ctx (r.add (Int.Linear.Var.denote ctx v)) p_2
- Int.Linear.Poly.denote'.go ctx r (Int.Linear.Poly.add k v p_2) = Int.Linear.Poly.denote'.go ctx (r.add (k.mul (Int.Linear.Var.denote ctx v))) p_2
Instances For
Equations
- (Int.Linear.Poly.num k_1).addConst k = Int.Linear.Poly.num (k + k_1)
- (Int.Linear.Poly.add k_1 v p_2).addConst k = Int.Linear.Poly.add k_1 v (p_2.addConst k)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Int.Linear.Poly.insert k v (Int.Linear.Poly.num k_1) = Int.Linear.Poly.add k v (Int.Linear.Poly.num k_1)
Instances For
Normalizes the given polynomial by fusing monomial and constants.
Equations
- (Int.Linear.Poly.num k).norm = Int.Linear.Poly.num k
- (Int.Linear.Poly.add k v p_2).norm = Int.Linear.Poly.insert k v p_2.norm
Instances For
Equations
- (Int.Linear.Poly.num k).append p₂ = p₂.addConst k
- (Int.Linear.Poly.add k v p_1).append p₂ = Int.Linear.Poly.add k v (p_1.append p₂)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Int.Linear.Poly.combine' 0 p₁ p₂ = p₁.append p₂
- Int.Linear.Poly.combine' fuel_2.succ (Int.Linear.Poly.num k₁) (Int.Linear.Poly.num k₂) = Int.Linear.Poly.num (k₁ + k₂)
- Int.Linear.Poly.combine' fuel_2.succ (Int.Linear.Poly.num k₁) (Int.Linear.Poly.add a x p) = Int.Linear.Poly.add a x (Int.Linear.Poly.combine' fuel_2 (Int.Linear.Poly.num k₁) p)
- Int.Linear.Poly.combine' fuel_2.succ (Int.Linear.Poly.add a x p) (Int.Linear.Poly.num k₂) = Int.Linear.Poly.add a x (Int.Linear.Poly.combine' fuel_2 p (Int.Linear.Poly.num k₂))
Instances For
Equations
- p₁.combine p₂ = Int.Linear.Poly.combine' 100000000 p₁ p₂
Instances For
Converts the given expression into a polynomial.
Equations
Instances For
Equations
- Int.Linear.Expr.toPoly'.go coeff (Int.Linear.Expr.num k) = bif k == 0 then id else fun (x : Int.Linear.Poly) => x.addConst (coeff.mul k)
- Int.Linear.Expr.toPoly'.go coeff (Int.Linear.Expr.var v) = fun (x : Int.Linear.Poly) => Int.Linear.Poly.add coeff v x
- Int.Linear.Expr.toPoly'.go coeff (a.add b) = Int.Linear.Expr.toPoly'.go coeff a ∘ Int.Linear.Expr.toPoly'.go coeff b
- Int.Linear.Expr.toPoly'.go coeff (a.sub b) = Int.Linear.Expr.toPoly'.go coeff a ∘ Int.Linear.Expr.toPoly'.go (-coeff) b
- Int.Linear.Expr.toPoly'.go coeff (Int.Linear.Expr.mulL k a) = bif k == 0 then id else Int.Linear.Expr.toPoly'.go (coeff.mul k) a
- Int.Linear.Expr.toPoly'.go coeff (a.mulR k) = bif k == 0 then id else Int.Linear.Expr.toPoly'.go (coeff.mul k) a
- Int.Linear.Expr.toPoly'.go coeff a.neg = Int.Linear.Expr.toPoly'.go (-coeff) a
Instances For
Returns the ceiling-compatible remainder of the division a / b
.
This function ensures that the remainder is consistent with cdiv
, meaning:
a = b * cdiv a b + cmod a b
See theorem cdiv_add_cmod
. We also have
-b < cmod a b ≤ 0
Equations
- Int.Linear.cmod a b = -(-a % b)
Instances For
Returns the constant of the given linear polynomial.
Equations
- (Int.Linear.Poly.num k).getConst = k
- (Int.Linear.Poly.add k v p_1).getConst = p_1.getConst
Instances For
p.div k
divides all coefficients of the polynomial p
by k
, but
rounds up the constant using cdiv
.
Notes:
- We only use this function with
k
s that divides all coefficients. - We use
cdiv
for the constant to implement the inequality tightening rule.
Equations
- Int.Linear.Poly.div k (Int.Linear.Poly.num k_1) = Int.Linear.Poly.num (Int.Linear.cdiv k_1 k)
- Int.Linear.Poly.div k (Int.Linear.Poly.add k_1 v p_1) = Int.Linear.Poly.add (k_1 / k) v (Int.Linear.Poly.div k p_1)
Instances For
Returns true
if k
divides all coefficients and the constant of the given
linear polynomial.
Equations
- Int.Linear.Poly.divAll k (Int.Linear.Poly.num k_1) = (k_1 % k == 0)
- Int.Linear.Poly.divAll k (Int.Linear.Poly.add k_1 v p_1) = (k_1 % k == 0 && Int.Linear.Poly.divAll k p_1)
Instances For
Returns true
if k
divides all coefficients of the given linear polynomial.
Equations
- Int.Linear.Poly.divCoeffs k (Int.Linear.Poly.num k_1) = true
- Int.Linear.Poly.divCoeffs k (Int.Linear.Poly.add k_1 v p_1) = (k_1 % k == 0 && Int.Linear.Poly.divCoeffs k p_1)
Instances For
p.mul k
multiplies all coefficients and constant of the polynomial p
by k
.
Equations
- (Int.Linear.Poly.num k_1).mul k = Int.Linear.Poly.num (k * k_1)
- (Int.Linear.Poly.add k_1 v p_2).mul k = Int.Linear.Poly.add (k * k_1) v (p_2.mul k)
Instances For
Equations
- Int.Linear.norm_eq_cert lhs rhs p = (p == (lhs.sub rhs).norm)
Instances For
Equations
- Int.Linear.norm_eq_var_cert lhs rhs x y = ((lhs.sub rhs).norm == Int.Linear.Poly.add 1 x (Int.Linear.Poly.add (-1) y (Int.Linear.Poly.num 0)))
Instances For
Equations
- Int.Linear.norm_eq_var_const_cert lhs rhs x k = ((lhs.sub rhs).norm == Int.Linear.Poly.add 1 x (Int.Linear.Poly.num (-k)))
Instances For
Equations
- Int.Linear.norm_le_coeff_tight_cert lhs rhs p k = (decide (k > 0) && (Int.Linear.Poly.divCoeffs k (lhs.sub rhs).norm && p == Int.Linear.Poly.div k (lhs.sub rhs).norm))
Instances For
Equations
- Int.Linear.unsatEqDivCoeffCert lhs rhs k = (Int.Linear.Poly.divCoeffs k (lhs.sub rhs).norm && decide (k > 0) && decide (Int.Linear.cmod (lhs.sub rhs).norm.getConst k < 0))
Instances For
Equations
- (Int.Linear.Poly.num k).gcdCoeffs x✝ = x✝
- (Int.Linear.Poly.add k' v p).gcdCoeffs x✝ = p.gcdCoeffs (Int.Linear.gcd✝ k' x✝)
Instances For
Equations
- Int.Linear.norm_dvd_gcd_cert k₁ e₁ k₂ p₂ k = Int.Linear.dvd_coeff_cert k₁ e₁.norm k₂ p₂ k
Instances For
Equations
- Int.Linear.dvd_elim_cert k₁ (Int.Linear.Poly.add a v p) k₂ p₂ = (k₂ == Int.Linear.gcd✝ k₁ a && p₂ == p)
- Int.Linear.dvd_elim_cert k₁ p₁ k₂ p₂ = false
Instances For
Equations
- Int.Linear.le_coeff_cert p₁ p₂ k = (decide (k > 0) && (Int.Linear.Poly.divCoeffs k p₁ && p₂ == Int.Linear.Poly.div k p₁))
Instances For
Equations
- Int.Linear.le_neg_cert p₁ p₂ = (p₂ == (p₁.mul (-1)).addConst 1)
Instances For
Equations
- (Int.Linear.Poly.add a v p_1).leadCoeff = a
- p.leadCoeff = 1
Instances For
Equations
- Int.Linear.eq_unsat_coeff_cert p k = (Int.Linear.Poly.divCoeffs k p && decide (k > 0) && decide (Int.Linear.cmod p.getConst k < 0))
Instances For
Equations
- (Int.Linear.Poly.add a y p_2).coeff x = bif x == y then a else p_2.coeff x
- (Int.Linear.Poly.num k).coeff x = 0
Instances For
Equations
- Int.Linear.dvd_of_eq_cert x p₁ d₂ p₂ = (d₂ == Int.Linear.abs✝ (p₁.coeff x) && p₂ == Int.Linear.Poly.insert (-p₁.coeff x) x p₁)
Instances For
Equations
- Int.Linear.eq_of_core_cert p₁ p₂ p₃ = (p₃ == p₁.combine (p₂.mul (-1)))
Instances For
Equations
Instances For
Equations
- Int.Linear.eq_of_le_ge_cert p₁ p₂ = (p₂ == p₁.mul (-1))
Instances For
Equations
- Int.Linear.OrOver 0 p = False
- Int.Linear.OrOver fuel_1.succ p = (p fuel_1 ∨ Int.Linear.OrOver fuel_1 p)
Instances For
Equations
- (Int.Linear.Poly.add a v p_1).tail = p_1
- p.tail = p
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.