Helper definitions and theorems for constructing linear arithmetic proofs.
@[reducible, inline]
Equations
Instances For
When encoding polynomials. We use fixedVar
for encoding numerals.
The denotation of fixedVar
is always 1
.
Equations
- Nat.Linear.fixedVar = 100000000
Instances For
Equations
- Nat.Linear.Var.denote ctx v = bif v == Nat.Linear.fixedVar then 1 else Lean.RArray.get ctx v
Instances For
Equations
- Nat.Linear.instInhabitedExpr = { default := Nat.Linear.Expr.num default }
Equations
- Nat.Linear.Expr.denote ctx (a.add b) = (Nat.Linear.Expr.denote ctx a).add (Nat.Linear.Expr.denote ctx b)
- Nat.Linear.Expr.denote ctx (Nat.Linear.Expr.num k) = k
- Nat.Linear.Expr.denote ctx (Nat.Linear.Expr.var v) = Nat.Linear.Var.denote ctx v
- Nat.Linear.Expr.denote ctx (Nat.Linear.Expr.mulL k e) = k.mul (Nat.Linear.Expr.denote ctx e)
- Nat.Linear.Expr.denote ctx (e.mulR k) = (Nat.Linear.Expr.denote ctx e).mul k
Instances For
@[reducible, inline]
Equations
Instances For
Equations
- Nat.Linear.Poly.denote ctx [] = 0
- Nat.Linear.Poly.denote ctx ((k, v) :: p_2) = (k.mul (Nat.Linear.Var.denote ctx v)).add (Nat.Linear.Poly.denote ctx p_2)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Nat.Linear.Poly.insert k v [] = [(k, v)]
Instances For
Equations
- p.norm = Nat.Linear.Poly.norm.go p []
Instances For
Equations
- Nat.Linear.Poly.norm.go [] r = r
- Nat.Linear.Poly.norm.go ((k, v) :: p_2) r = Nat.Linear.Poly.norm.go p_2 (Nat.Linear.Poly.insert k v r)
Instances For
Equations
- Nat.Linear.Poly.mul k p = bif k == 0 then [] else bif k == 1 then p else Nat.Linear.Poly.mul.go k p
Instances For
Equations
- Nat.Linear.Poly.mul.go k [] = []
- Nat.Linear.Poly.mul.go k ((k_1, v) :: p_1) = (k.mul k_1, v) :: Nat.Linear.Poly.mul.go k p_1
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Nat.Linear.Poly.cancelAux 0 m₁ m₂ r₁ r₂ = (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂)
- Nat.Linear.Poly.cancelAux fuel_2.succ m₁ [] r₁ r₂ = (List.reverse r₁ ++ m₁, List.reverse r₂)
- Nat.Linear.Poly.cancelAux fuel_2.succ [] m₂ r₁ r₂ = (List.reverse r₁, List.reverse r₂ ++ m₂)
Instances For
Equations
- p₁.cancel p₂ = Nat.Linear.Poly.cancelAux Nat.Linear.hugeFuel p₁ p₂ [] []
Instances For
Equations
- Nat.Linear.Poly.isNum? [] = some 0
- Nat.Linear.Poly.isNum? [(k, v)] = bif v == Nat.Linear.fixedVar then some k else none
- p.isNum? = none
Instances For
Equations
- Nat.Linear.Poly.isZero [] = true
- p.isZero = false
Instances For
Equations
- Nat.Linear.Poly.isNonZero [] = false
- Nat.Linear.Poly.isNonZero ((k, v) :: p_2) = bif v == Nat.Linear.fixedVar then decide (k > 0) else Nat.Linear.Poly.isNonZero p_2
Instances For
Equations
- Nat.Linear.Poly.denote_eq ctx mp = (Nat.Linear.Poly.denote ctx mp.fst = Nat.Linear.Poly.denote ctx mp.snd)
Instances For
Equations
- Nat.Linear.Poly.denote_le ctx mp = (Nat.Linear.Poly.denote ctx mp.fst ≤ Nat.Linear.Poly.denote ctx mp.snd)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Nat.Linear.Poly.combineAux 0 p₁ p₂ = p₁ ++ p₂
- Nat.Linear.Poly.combineAux fuel_2.succ p₁ [] = p₁
- Nat.Linear.Poly.combineAux fuel_2.succ [] p₂ = p₂
Instances For
Equations
- p₁.combine p₂ = Nat.Linear.Poly.combineAux Nat.Linear.hugeFuel p₁ p₂
Instances For
Equations
- e.toPoly = Nat.Linear.Expr.toPoly.go 1 e []
Instances For
Equations
- Nat.Linear.Expr.toPoly.go coeff (Nat.Linear.Expr.num k) = bif k == 0 then id else fun (x : Nat.Linear.Poly) => (coeff * k, Nat.Linear.fixedVar) :: x
- Nat.Linear.Expr.toPoly.go coeff (Nat.Linear.Expr.var i) = fun (x : Nat.Linear.Poly) => (coeff, i) :: x
- Nat.Linear.Expr.toPoly.go coeff (a.add b) = Nat.Linear.Expr.toPoly.go coeff a ∘ Nat.Linear.Expr.toPoly.go coeff b
- Nat.Linear.Expr.toPoly.go coeff (Nat.Linear.Expr.mulL k a) = bif k == 0 then id else Nat.Linear.Expr.toPoly.go (coeff * k) a
- Nat.Linear.Expr.toPoly.go coeff (a.mulR k) = bif k == 0 then id else Nat.Linear.Expr.toPoly.go (coeff * k) a
Instances For
Equations
- e.toNormPoly = e.toPoly.norm
Instances For
Equations
- e.inc = e.add (Nat.Linear.Expr.num 1)
Instances For
Equations
- Nat.Linear.instBEqPolyCnstr = { beq := Nat.Linear.beqPolyCnstr✝ }
Equations
- Nat.Linear.PolyCnstr.mul k c = { eq := c.eq, lhs := Nat.Linear.Poly.mul k c.lhs, rhs := Nat.Linear.Poly.mul k c.rhs }
Instances For
Equations
- Nat.Linear.PolyCnstr.denote ctx c = bif c.eq then Nat.Linear.Poly.denote_eq ctx (c.lhs, c.rhs) else Nat.Linear.Poly.denote_le ctx (c.lhs, c.rhs)
Instances For
Equations
- c.norm = match c.lhs.norm.cancel c.rhs.norm with | (lhs, rhs) => { eq := c.eq, lhs := lhs, rhs := rhs }
Instances For
Equations
- Nat.Linear.ExprCnstr.denote ctx c = bif c.eq then Nat.Linear.Expr.denote ctx c.lhs = Nat.Linear.Expr.denote ctx c.rhs else Nat.Linear.Expr.denote ctx c.lhs ≤ Nat.Linear.Expr.denote ctx c.rhs
Instances For
Equations
- c.toPoly = { eq := c.eq, lhs := c.lhs.toPoly, rhs := c.rhs.toPoly }
Instances For
Equations
- c.toNormPoly = match c.lhs.toNormPoly.cancel c.rhs.toNormPoly with | (lhs, rhs) => { eq := c.eq, lhs := lhs, rhs := rhs }
Instances For
@[reducible, inline]
Equations
Instances For
Equations
- Nat.Linear.Certificate.combineHyps c [] = c
- Nat.Linear.Certificate.combineHyps c ((k, c') :: hs_2) = Nat.Linear.Certificate.combineHyps (c.combine (Nat.Linear.PolyCnstr.mul (k.add 1) c'.toNormPoly)) hs_2
Instances For
Equations
- Nat.Linear.Certificate.combine [] = { eq := true, lhs := [], rhs := [] }
- Nat.Linear.Certificate.combine ((k, c') :: hs_2) = Nat.Linear.Certificate.combineHyps (Nat.Linear.PolyCnstr.mul (k.add 1) c'.toNormPoly) hs_2
Instances For
Equations
- Nat.Linear.Certificate.denote ctx [] = False
- Nat.Linear.Certificate.denote ctx ((k, c') :: hs_1) = (Nat.Linear.ExprCnstr.denote ctx c' → Nat.Linear.Certificate.denote ctx hs_1)
Instances For
Equations
- Nat.Linear.monomialToExpr k v = bif v == Nat.Linear.fixedVar then Nat.Linear.Expr.num k else bif k == 1 then Nat.Linear.Expr.var v else Nat.Linear.Expr.mulL k (Nat.Linear.Expr.var v)
Instances For
Equations
- Nat.Linear.Poly.toExpr [] = Nat.Linear.Expr.num 0
- Nat.Linear.Poly.toExpr ((k, v) :: p_2) = Nat.Linear.Poly.toExpr.go (Nat.Linear.monomialToExpr k v) p_2
Instances For
Equations
- Nat.Linear.Poly.toExpr.go e [] = e
- Nat.Linear.Poly.toExpr.go e ((k, v) :: p_2) = Nat.Linear.Poly.toExpr.go (e.add (Nat.Linear.monomialToExpr k v)) p_2
Instances For
Equations
- c.toExpr = { eq := c.eq, lhs := c.lhs.toExpr, rhs := c.rhs.toExpr }
Instances For
theorem
Nat.Linear.Poly.denote_reverseAux
(ctx : Context)
(p q : Poly)
:
denote ctx (List.reverseAux p q) = denote ctx (p ++ q)
theorem
Nat.Linear.Poly.denote_reverse
(ctx : Context)
(p : Poly)
:
denote ctx (List.reverse p) = denote ctx p
theorem
Nat.Linear.Poly.denote_eq_cancelAux
(ctx : Context)
(fuel : Nat)
(m₁ m₂ r₁ r₂ : Poly)
(h : denote_eq ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂))
:
theorem
Nat.Linear.Poly.of_denote_eq_cancelAux
(ctx : Context)
(fuel : Nat)
(m₁ m₂ r₁ r₂ : Poly)
(h : denote_eq ctx (cancelAux fuel m₁ m₂ r₁ r₂))
:
denote_eq ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂)
theorem
Nat.Linear.Poly.denote_le_cancelAux
(ctx : Context)
(fuel : Nat)
(m₁ m₂ r₁ r₂ : Poly)
(h : denote_le ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂))
:
theorem
Nat.Linear.Poly.of_denote_le_cancelAux
(ctx : Context)
(fuel : Nat)
(m₁ m₂ r₁ r₂ : Poly)
(h : denote_le ctx (cancelAux fuel m₁ m₂ r₁ r₂))
:
denote_le ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂)
theorem
Nat.Linear.Expr.denote_toPoly_go
{k : Nat}
{p : Poly}
(ctx : Context)
(e : Expr)
:
Poly.denote ctx (toPoly.go k e p) = k * denote ctx e + Poly.denote ctx p
theorem
Nat.Linear.Expr.denote_toPoly
(ctx : Context)
(e : Expr)
:
Poly.denote ctx e.toPoly = denote ctx e
theorem
Nat.Linear.ExprCnstr.denote_toPoly
(ctx : Context)
(c : ExprCnstr)
:
PolyCnstr.denote ctx c.toPoly = denote ctx c
theorem
Nat.Linear.ExprCnstr.denote_toNormPoly
(ctx : Context)
(c : ExprCnstr)
:
PolyCnstr.denote ctx c.toNormPoly = denote ctx c
theorem
Nat.Linear.Certificate.of_combineHyps
(ctx : Context)
(c : PolyCnstr)
(cs : Certificate)
(h : PolyCnstr.denote ctx (combineHyps c cs) → False)
:
PolyCnstr.denote ctx c → denote ctx cs
theorem
Nat.Linear.Certificate.of_combine
(ctx : Context)
(cs : Certificate)
(h : PolyCnstr.denote ctx cs.combine → False)
:
denote ctx cs
theorem
Nat.Linear.Certificate.of_combine_isUnsat
(ctx : Context)
(cs : Certificate)
(h : cs.combine.isUnsat = true)
:
denote ctx cs
theorem
Nat.Linear.denote_monomialToExpr
(ctx : Context)
(k : Nat)
(v : Var)
:
Expr.denote ctx (monomialToExpr k v) = k * Var.denote ctx v
theorem
Nat.Linear.Poly.denote_toExpr_go
(ctx : Context)
(e : Expr)
(p : Poly)
:
Expr.denote ctx (toExpr.go e p) = Expr.denote ctx e + denote ctx p
theorem
Nat.Linear.Poly.denote_toExpr
(ctx : Context)
(p : Poly)
:
Expr.denote ctx p.toExpr = denote ctx p