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 + Int.Linear.Expr.denote ctx b
- Int.Linear.Expr.denote ctx (a.sub b) = Int.Linear.Expr.denote ctx a - Int.Linear.Expr.denote ctx b
- Int.Linear.Expr.denote ctx a.neg = -Int.Linear.Expr.denote ctx a
- 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 * Int.Linear.Expr.denote ctx e
- Int.Linear.Expr.denote ctx (e.mulR k) = Int.Linear.Expr.denote ctx e * k
Instances For
Equations
- Int.Linear.instBEqPoly = { beq := Int.Linear.beqPoly✝ }
Equations
- One or more equations did not get rendered due to their size.
Instances For
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 * Int.Linear.Var.denote ctx v + 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
- One or more equations did not get rendered due to their size.
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
- p.addConst_k k = Int.Linear.Poly.rec (fun (k' : Int) => Int.Linear.Poly.num (k.add k')) (fun (k' : Int) (v' : Int.Linear.Var) (x ih : Int.Linear.Poly) => Int.Linear.Poly.add k' v' ih) p
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' Int.Linear.hugeFuel 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
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- Int.Linear.norm_eq_cert lhs rhs p = p.beq' (lhs.sub rhs).norm
Instances For
Equations
- Int.Linear.norm_eq_var_cert lhs rhs x y = (lhs.sub rhs).norm.beq' (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.beq' (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 = (Int.blt' 0 k).and' ((Int.Linear.Poly.divCoeffs k (lhs.sub rhs).norm).and' (p.beq' (Int.Linear.Poly.div k (lhs.sub rhs).norm)))
Instances For
Equations
- p.isUnsatEq_k = Int.Linear.Poly.rec (fun (k : Int) => (k.beq' 0).not') (fun (x : Int) (x : Int.Linear.Var) (x : Int.Linear.Poly) (x : Bool) => false) p
Instances For
Equations
- Int.Linear.unsatEqDivCoeffCert lhs rhs k = (Int.Linear.Poly.divCoeffs k (lhs.sub rhs).norm).and' ((Int.blt' 0 k).and' (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 ↑(k'.gcd 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.le_coeff_cert p₁ p₂ k = (Int.blt' 0 k).and' ((Int.Linear.Poly.divCoeffs k p₁).and' (p₂.beq' (Int.Linear.Poly.div k p₁)))
Instances For
Equations
- Int.Linear.le_neg_cert p₁ p₂ = p₂.beq' ((p₁.mul_k (-1)).addConst_k 1)
Instances For
Equations
- (Int.Linear.Poly.add a v p_2).leadCoeff = a
- p.leadCoeff = 1
Instances For
Equations
- Int.Linear.le_combine_cert p₁ p₂ p₃ = p₃.beq' (Int.Linear.Poly.combine_mul_k (↑p₂.leadCoeff.natAbs) (↑p₁.leadCoeff.natAbs) p₁ p₂)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Int.Linear.eq_unsat_coeff_cert p k = (Int.Linear.Poly.divCoeffs k p).and' ((Int.blt' 0 k).and' (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
- p.coeff_k x = Int.Linear.Poly.rec (fun (x : Int) => 0) (fun (a : Int) (y : Int.Linear.Var) (x_1 : Int.Linear.Poly) (ih : Int) => Bool.rec ih a (Nat.beq x y)) p
Instances For
Equations
- Int.Linear.dvd_of_eq_cert x p₁ d₂ p₂ = (d₂.beq' (Int.Linear.abs (p₁.coeff_k x))).and' (p₂.beq' (Int.Linear.Poly.insert (-p₁.coeff_k x) x p₁))
Instances For
Equations
- Int.Linear.eq_eq_subst_cert x p₁ p₂ p₃ = p₃.beq' (Int.Linear.Poly.combine_mul_k (p₂.coeff_k x) (-p₁.coeff_k x) p₁ p₂)
Instances For
Equations
- Int.Linear.eq_eq_subst'_cert a b p₁ p₂ p₃ = p₃.beq' (Int.Linear.Poly.combine_mul_k b (-a) p₁ p₂)
Instances For
Equations
- Int.Linear.eq_le_subst_nonneg_cert x p₁ p₂ p₃ = (Int.ble' 0 (p₁.coeff x)).and' (p₃.beq' (Int.Linear.Poly.combine_mul_k (p₁.coeff x) (-p₂.coeff x) p₂ p₁))
Instances For
Equations
- Int.Linear.eq_le_subst_nonpos_cert x p₁ p₂ p₃ = ((p₁.coeff x).ble' 0).and' (p₃.beq' (Int.Linear.Poly.combine_mul_k (p₂.coeff x) (-p₁.coeff x) p₁ p₂))
Instances For
Equations
- Int.Linear.eq_of_core_cert p₁ p₂ p₃ = p₃.beq' (Int.Linear.Poly.combine_mul_k 1 (-1) p₁ p₂)
Instances For
Equations
Instances For
Equations
- p.isUnsatDiseq_k = Int.Linear.Poly.rec (fun (k : Int) => k.beq' 0) (fun (x : Int) (x : Int.Linear.Var) (x : Int.Linear.Poly) (x : Bool) => false) p
Instances For
Equations
- Int.Linear.eq_of_le_ge_cert p₁ p₂ = p₂.beq' (p₁.mul_k (-1))
Instances For
Equations
- Int.Linear.le_of_le_diseq_cert p₁ p₂ p₃ = (p₂.beq' p₁ || p₂.beq' (p₁.mul_k (-1))).and' (p₃.beq' (p₁.addConst_k 1))
Instances For
Equations
- Int.Linear.diseq_split_cert p₁ p₂ p₃ = (p₂.beq' (p₁.addConst_k 1)).and' (p₃.beq' ((p₁.mul_k (-1)).addConst_k 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.OrOver_cases_type 0 p = p 0
- Int.Linear.OrOver_cases_type fuel_1.succ p = (¬p (fuel_1 + 1) → Int.Linear.OrOver_cases_type fuel_1 p)
Instances For
Equations
- (Int.Linear.Poly.add a v p_2).tail = p_2
- p.tail = p
Instances For
Equations
- Int.Linear.cooper_dvd_left_split_ineq_cert p₁ p₂ k b p' = (p₂.leadCoeff.beq' b).and' (p'.beq' ((Int.Linear.Poly.combine_mul_k b (-p₁.leadCoeff) p₁.tail p₂.tail).addConst_k (b * k)))
Instances For
Equations
- Int.Linear.cooper_dvd_left_split_dvd1_cert p₁ p' a k = (a.beq' p₁.leadCoeff).and' (p'.beq' (p₁.tail.addConst_k k))
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Int.Linear.cooper_left_split_ineq_cert p₁ p₂ k b p' = (p₂.leadCoeff.beq' b).and' (p'.beq' ((Int.Linear.Poly.combine_mul_k b (-p₁.leadCoeff) p₁.tail p₂.tail).addConst_k (b * k)))
Instances For
Equations
- Int.Linear.cooper_left_split_dvd_cert p₁ p' a k = (a.beq' p₁.leadCoeff).and' (p'.beq' (p₁.tail.addConst_k k))
Instances For
Equations
- Int.Linear.cooper_dvd_right_split_ineq_cert p₁ p₂ k a p' = (p₁.leadCoeff.beq' a).and' (p'.beq' ((Int.Linear.Poly.combine_mul_k p₂.leadCoeff (-a) p₁.tail p₂.tail).addConst_k (-a * k)))
Instances For
Equations
- Int.Linear.cooper_dvd_right_split_dvd1_cert p₂ p' b k = (b.beq' p₂.leadCoeff).and' (p'.beq' (p₂.tail.addConst_k k))
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Int.Linear.cooper_right_split_ineq_cert p₁ p₂ k a p' = (p₁.leadCoeff.beq' a).and' (p'.beq' ((Int.Linear.Poly.combine_mul_k p₂.leadCoeff (-a) p₁.tail p₂.tail).addConst_k (-a * k)))
Instances For
Equations
- Int.Linear.cooper_right_split_dvd_cert p₂ p' b k = (b.beq' p₂.leadCoeff).and' (p'.beq' (p₂.tail.addConst_k k))
Instances For
Equations
- p.casesOnAdd k = Int.Linear.Poly.casesOn p (fun (x : Int) => false) k
Instances For
Equations
- p.casesOnNum k = Int.Linear.Poly.casesOn p k fun (x : Int) (x : Int.Linear.Var) (x : Int.Linear.Poly) => false
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.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Int.Linear.not_le_norm_expr_cert lhs rhs p = p.beq' (((lhs.sub rhs).norm.mul_k (-1)).addConst_k 1)
Instances For
Equations
- Int.Linear.eq_def_cert x xPoly p = p.beq' (Int.Linear.Poly.add (-1) x xPoly)
Instances For
Equations
- Int.Linear.eq_def'_cert x e p = p.beq' (Int.Linear.Poly.add (-1) x e.norm)
Instances For
Equations
- Int.Linear.eq_def'_norm_cert x e ePoly ePoly' p = (ePoly.beq' e.norm).and' (p.beq' (Int.Linear.Poly.add (-1) x ePoly'))
Instances For
Constraint propagation helper theorems.
Equations
- Int.Linear.le_of_le_cert (Int.Linear.Poly.add k v p) (Int.Linear.Poly.num k_1) = false
- Int.Linear.le_of_le_cert (Int.Linear.Poly.num k) (Int.Linear.Poly.add k_1 v p) = false
- Int.Linear.le_of_le_cert (Int.Linear.Poly.num c₁) (Int.Linear.Poly.num c₂) = decide (c₁ ≥ c₂)
- Int.Linear.le_of_le_cert (Int.Linear.Poly.add a₁ x₁ p₁_2) (Int.Linear.Poly.add a₂ x₂ p₂_2) = (a₁ == a₂ && x₁ == x₂ && Int.Linear.le_of_le_cert p₁_2 p₂_2)
Instances For
Equations
- Int.Linear.not_le_of_le_cert (Int.Linear.Poly.add k v p) (Int.Linear.Poly.num k_1) = false
- Int.Linear.not_le_of_le_cert (Int.Linear.Poly.num k) (Int.Linear.Poly.add k_1 v p) = false
- Int.Linear.not_le_of_le_cert (Int.Linear.Poly.num c₁) (Int.Linear.Poly.num c₂) = decide (c₁ ≥ 1 - c₂)
- Int.Linear.not_le_of_le_cert (Int.Linear.Poly.add a₁ x₁ p₁_2) (Int.Linear.Poly.add a₂ x₂ p₂_2) = (a₁ == -a₂ && x₁ == x₂ && Int.Linear.not_le_of_le_cert p₁_2 p₂_2)