Helper definitions and theorems for constructing linear arithmetic proofs.
Equations
- Nat.Linear.Var.denote.go [] x = 0
- Nat.Linear.Var.denote.go (a :: tail) 0 = a
- Nat.Linear.Var.denote.go (head :: as) (Nat.succ i) = Nat.Linear.Var.denote.go as i
Instances For
- num: Nat → Nat.Linear.Expr
- var: Nat.Linear.Var → Nat.Linear.Expr
- add: Nat.Linear.Expr → Nat.Linear.Expr → Nat.Linear.Expr
- mulL: Nat → Nat.Linear.Expr → Nat.Linear.Expr
- mulR: Nat.Linear.Expr → Nat → Nat.Linear.Expr
Instances For
Equations
- Nat.Linear.Expr.denote ctx (Nat.Linear.Expr.add a b) = Nat.add (Nat.Linear.Expr.denote ctx a) (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) = Nat.mul k (Nat.Linear.Expr.denote ctx e)
- Nat.Linear.Expr.denote ctx (Nat.Linear.Expr.mulR e k) = Nat.mul (Nat.Linear.Expr.denote ctx e) k
Instances For
Equations
- Nat.Linear.Poly.denote ctx [] = 0
- Nat.Linear.Poly.denote ctx ((k, v) :: p_2) = Nat.add (Nat.mul k (Nat.Linear.Var.denote ctx v)) (Nat.Linear.Poly.denote ctx p_2)
Instances For
Equations
- Nat.Linear.Poly.insertSorted k v [] = [(k, v)]
- Nat.Linear.Poly.insertSorted k v ((k_1, v_1) :: p_2) = bif Nat.blt v v_1 then (k, v) :: (k_1, v_1) :: p_2 else (k_1, v_1) :: Nat.Linear.Poly.insertSorted k v p_2
Instances For
Equations
- Nat.Linear.Poly.sort.go [] r = r
- Nat.Linear.Poly.sort.go ((k, v) :: p_2) r = Nat.Linear.Poly.sort.go p_2 (Nat.Linear.Poly.insertSorted k v r)
Instances For
Equations
- Nat.Linear.Poly.fuse [] = []
- Nat.Linear.Poly.fuse ((k, v) :: p_2) = match Nat.Linear.Poly.fuse p_2 with | [] => [(k, v)] | (k', v') :: p' => bif v == v' then (Nat.add k k', v) :: p' else (k, v) :: (k', v') :: p'
Instances For
Equations
- Nat.Linear.Poly.mul.go k [] = []
- Nat.Linear.Poly.mul.go k ((k_1, v) :: p_1) = (Nat.mul k k_1, v) :: Nat.Linear.Poly.mul.go k p_1
Instances For
def
Nat.Linear.Poly.cancelAux
(fuel : Nat)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
(r₁ : Nat.Linear.Poly)
(r₂ : Nat.Linear.Poly)
:
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₂)
Instances For
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
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Nat.Linear.Poly.combineAux 0 p₁ p₂ = p₁ ++ p₂
Instances For
Instances For
Equations
- Nat.Linear.Expr.toPoly (Nat.Linear.Expr.num k) = bif k == 0 then [] else [(k, Nat.Linear.fixedVar)]
- Nat.Linear.Expr.toPoly (Nat.Linear.Expr.var i) = [(1, i)]
- Nat.Linear.Expr.toPoly (Nat.Linear.Expr.add a b) = Nat.Linear.Expr.toPoly a ++ Nat.Linear.Expr.toPoly b
- Nat.Linear.Expr.toPoly (Nat.Linear.Expr.mulL k a) = Nat.Linear.Poly.mul k (Nat.Linear.Expr.toPoly a)
- Nat.Linear.Expr.toPoly (Nat.Linear.Expr.mulR a k) = Nat.Linear.Poly.mul k (Nat.Linear.Expr.toPoly a)
Instances For
- eq : Bool
- lhs : Nat.Linear.Poly
- rhs : Nat.Linear.Poly
Instances For
Instances For
Instances For
- eq : Bool
- lhs : Nat.Linear.Expr
- rhs : Nat.Linear.Expr
Instances For
Instances For
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Nat.Linear.Certificate.combineHyps c [] = c
Instances For
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.Poly.toExpr.go e [] = e
- Nat.Linear.Poly.toExpr.go e ((k, v) :: p_2) = Nat.Linear.Poly.toExpr.go (Nat.Linear.Expr.add e (Nat.Linear.monomialToExpr k v)) p_2
Instances For
theorem
Nat.Linear.Poly.denote_insertSorted
(ctx : Nat.Linear.Context)
(k : Nat)
(v : Nat.Linear.Var)
(p : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.insertSorted k v p) = Nat.Linear.Poly.denote ctx p + k * Nat.Linear.Var.denote ctx v
theorem
Nat.Linear.Poly.denote_sort_go
(ctx : Nat.Linear.Context)
(p : Nat.Linear.Poly)
(r : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.sort.go p r) = Nat.Linear.Poly.denote ctx p + Nat.Linear.Poly.denote ctx r
theorem
Nat.Linear.Poly.denote_sort
(ctx : Nat.Linear.Context)
(m : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.sort m) = Nat.Linear.Poly.denote ctx m
theorem
Nat.Linear.Poly.denote_append
(ctx : Nat.Linear.Context)
(p : Nat.Linear.Poly)
(q : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (p ++ q) = Nat.Linear.Poly.denote ctx p + Nat.Linear.Poly.denote ctx q
theorem
Nat.Linear.Poly.denote_cons
(ctx : Nat.Linear.Context)
(k : Nat)
(v : Nat.Linear.Var)
(p : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx ((k, v) :: p) = k * Nat.Linear.Var.denote ctx v + Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.Poly.denote_reverseAux
(ctx : Nat.Linear.Context)
(p : Nat.Linear.Poly)
(q : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (List.reverseAux p q) = Nat.Linear.Poly.denote ctx (p ++ q)
theorem
Nat.Linear.Poly.denote_reverse
(ctx : Nat.Linear.Context)
(p : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (List.reverse p) = Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.Poly.denote_fuse
(ctx : Nat.Linear.Context)
(p : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.fuse p) = Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.Poly.denote_mul
(ctx : Nat.Linear.Context)
(k : Nat)
(p : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.mul k p) = k * Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.Poly.denote_eq_cancelAux
(ctx : Nat.Linear.Context)
(fuel : Nat)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
(r₁ : Nat.Linear.Poly)
(r₂ : Nat.Linear.Poly)
(h : Nat.Linear.Poly.denote_eq ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂))
:
Nat.Linear.Poly.denote_eq ctx (Nat.Linear.Poly.cancelAux fuel m₁ m₂ r₁ r₂)
theorem
Nat.Linear.Poly.of_denote_eq_cancelAux
(ctx : Nat.Linear.Context)
(fuel : Nat)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
(r₁ : Nat.Linear.Poly)
(r₂ : Nat.Linear.Poly)
(h : Nat.Linear.Poly.denote_eq ctx (Nat.Linear.Poly.cancelAux fuel m₁ m₂ r₁ r₂))
:
Nat.Linear.Poly.denote_eq ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂)
theorem
Nat.Linear.Poly.denote_eq_cancel
{ctx : Nat.Linear.Context}
{m₁ : Nat.Linear.Poly}
{m₂ : Nat.Linear.Poly}
(h : Nat.Linear.Poly.denote_eq ctx (m₁, m₂))
:
Nat.Linear.Poly.denote_eq ctx (Nat.Linear.Poly.cancel m₁ m₂)
theorem
Nat.Linear.Poly.of_denote_eq_cancel
{ctx : Nat.Linear.Context}
{m₁ : Nat.Linear.Poly}
{m₂ : Nat.Linear.Poly}
(h : Nat.Linear.Poly.denote_eq ctx (Nat.Linear.Poly.cancel m₁ m₂))
:
Nat.Linear.Poly.denote_eq ctx (m₁, m₂)
theorem
Nat.Linear.Poly.denote_eq_cancel_eq
(ctx : Nat.Linear.Context)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote_eq ctx (Nat.Linear.Poly.cancel m₁ m₂) = Nat.Linear.Poly.denote_eq ctx (m₁, m₂)
theorem
Nat.Linear.Poly.denote_le_cancelAux
(ctx : Nat.Linear.Context)
(fuel : Nat)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
(r₁ : Nat.Linear.Poly)
(r₂ : Nat.Linear.Poly)
(h : Nat.Linear.Poly.denote_le ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂))
:
Nat.Linear.Poly.denote_le ctx (Nat.Linear.Poly.cancelAux fuel m₁ m₂ r₁ r₂)
theorem
Nat.Linear.Poly.of_denote_le_cancelAux
(ctx : Nat.Linear.Context)
(fuel : Nat)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
(r₁ : Nat.Linear.Poly)
(r₂ : Nat.Linear.Poly)
(h : Nat.Linear.Poly.denote_le ctx (Nat.Linear.Poly.cancelAux fuel m₁ m₂ r₁ r₂))
:
Nat.Linear.Poly.denote_le ctx (List.reverse r₁ ++ m₁, List.reverse r₂ ++ m₂)
theorem
Nat.Linear.Poly.denote_le_cancel
{ctx : Nat.Linear.Context}
{m₁ : Nat.Linear.Poly}
{m₂ : Nat.Linear.Poly}
(h : Nat.Linear.Poly.denote_le ctx (m₁, m₂))
:
Nat.Linear.Poly.denote_le ctx (Nat.Linear.Poly.cancel m₁ m₂)
theorem
Nat.Linear.Poly.of_denote_le_cancel
{ctx : Nat.Linear.Context}
{m₁ : Nat.Linear.Poly}
{m₂ : Nat.Linear.Poly}
(h : Nat.Linear.Poly.denote_le ctx (Nat.Linear.Poly.cancel m₁ m₂))
:
Nat.Linear.Poly.denote_le ctx (m₁, m₂)
theorem
Nat.Linear.Poly.denote_le_cancel_eq
(ctx : Nat.Linear.Context)
(m₁ : Nat.Linear.Poly)
(m₂ : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote_le ctx (Nat.Linear.Poly.cancel m₁ m₂) = Nat.Linear.Poly.denote_le ctx (m₁, m₂)
theorem
Nat.Linear.Poly.denote_combineAux
(ctx : Nat.Linear.Context)
(fuel : Nat)
(p₁ : Nat.Linear.Poly)
(p₂ : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.combineAux fuel p₁ p₂) = Nat.Linear.Poly.denote ctx p₁ + Nat.Linear.Poly.denote ctx p₂
theorem
Nat.Linear.Poly.denote_combine
(ctx : Nat.Linear.Context)
(p₁ : Nat.Linear.Poly)
(p₂ : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.combine p₁ p₂) = Nat.Linear.Poly.denote ctx p₁ + Nat.Linear.Poly.denote ctx p₂
theorem
Nat.Linear.Expr.denote_toPoly
(ctx : Nat.Linear.Context)
(e : Nat.Linear.Expr)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Expr.toPoly e) = Nat.Linear.Expr.denote ctx e
theorem
Nat.Linear.Expr.eq_of_toNormPoly
(ctx : Nat.Linear.Context)
(a : Nat.Linear.Expr)
(b : Nat.Linear.Expr)
(h : Nat.Linear.Expr.toNormPoly a = Nat.Linear.Expr.toNormPoly b)
:
Nat.Linear.Expr.denote ctx a = Nat.Linear.Expr.denote ctx b
theorem
Nat.Linear.Expr.of_cancel_eq
(ctx : Nat.Linear.Context)
(a : Nat.Linear.Expr)
(b : Nat.Linear.Expr)
(c : Nat.Linear.Expr)
(d : Nat.Linear.Expr)
(h : Nat.Linear.Poly.cancel (Nat.Linear.Expr.toNormPoly a) (Nat.Linear.Expr.toNormPoly b) = (Nat.Linear.Expr.toPoly c, Nat.Linear.Expr.toPoly d))
:
(Nat.Linear.Expr.denote ctx a = Nat.Linear.Expr.denote ctx b) = (Nat.Linear.Expr.denote ctx c = Nat.Linear.Expr.denote ctx d)
theorem
Nat.Linear.Expr.of_cancel_le
(ctx : Nat.Linear.Context)
(a : Nat.Linear.Expr)
(b : Nat.Linear.Expr)
(c : Nat.Linear.Expr)
(d : Nat.Linear.Expr)
(h : Nat.Linear.Poly.cancel (Nat.Linear.Expr.toNormPoly a) (Nat.Linear.Expr.toNormPoly b) = (Nat.Linear.Expr.toPoly c, Nat.Linear.Expr.toPoly d))
:
(Nat.Linear.Expr.denote ctx a ≤ Nat.Linear.Expr.denote ctx b) = (Nat.Linear.Expr.denote ctx c ≤ Nat.Linear.Expr.denote ctx d)
theorem
Nat.Linear.Expr.of_cancel_lt
(ctx : Nat.Linear.Context)
(a : Nat.Linear.Expr)
(b : Nat.Linear.Expr)
(c : Nat.Linear.Expr)
(d : Nat.Linear.Expr)
(h : Nat.Linear.Poly.cancel (Nat.Linear.Expr.toNormPoly (Nat.Linear.Expr.inc a)) (Nat.Linear.Expr.toNormPoly b) = (Nat.Linear.Expr.toPoly (Nat.Linear.Expr.inc c), Nat.Linear.Expr.toPoly d))
:
(Nat.Linear.Expr.denote ctx a < Nat.Linear.Expr.denote ctx b) = (Nat.Linear.Expr.denote ctx c < Nat.Linear.Expr.denote ctx d)
theorem
Nat.Linear.ExprCnstr.denote_toNormPoly
(ctx : Nat.Linear.Context)
(c : Nat.Linear.ExprCnstr)
:
theorem
Nat.Linear.Poly.mul.go_denote
(ctx : Nat.Linear.Context)
(k : Nat)
(p : Nat.Linear.Poly)
:
Nat.Linear.Poly.denote ctx (Nat.Linear.Poly.mul.go k p) = k * Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.PolyCnstr.denote_mul
(ctx : Nat.Linear.Context)
(k : Nat)
(c : Nat.Linear.PolyCnstr)
:
Nat.Linear.PolyCnstr.denote ctx (Nat.Linear.PolyCnstr.mul (k + 1) c) = Nat.Linear.PolyCnstr.denote ctx c
theorem
Nat.Linear.PolyCnstr.denote_combine
{ctx : Nat.Linear.Context}
{c₁ : Nat.Linear.PolyCnstr}
{c₂ : Nat.Linear.PolyCnstr}
(h₁ : Nat.Linear.PolyCnstr.denote ctx c₁)
(h₂ : Nat.Linear.PolyCnstr.denote ctx c₂)
:
theorem
Nat.Linear.Poly.isNum?_eq_some
(ctx : Nat.Linear.Context)
{p : Nat.Linear.Poly}
{k : Nat}
:
Nat.Linear.Poly.isNum? p = some k → Nat.Linear.Poly.denote ctx p = k
theorem
Nat.Linear.Poly.of_isZero
(ctx : Nat.Linear.Context)
{p : Nat.Linear.Poly}
(h : Nat.Linear.Poly.isZero p = true)
:
Nat.Linear.Poly.denote ctx p = 0
theorem
Nat.Linear.Poly.of_isNonZero
(ctx : Nat.Linear.Context)
{p : Nat.Linear.Poly}
(h : Nat.Linear.Poly.isNonZero p = true)
:
Nat.Linear.Poly.denote ctx p > 0
theorem
Nat.Linear.PolyCnstr.eq_false_of_isUnsat
(ctx : Nat.Linear.Context)
{c : Nat.Linear.PolyCnstr}
:
theorem
Nat.Linear.PolyCnstr.eq_true_of_isValid
(ctx : Nat.Linear.Context)
{c : Nat.Linear.PolyCnstr}
:
theorem
Nat.Linear.ExprCnstr.eq_false_of_isUnsat
(ctx : Nat.Linear.Context)
(c : Nat.Linear.ExprCnstr)
(h : Nat.Linear.PolyCnstr.isUnsat (Nat.Linear.ExprCnstr.toNormPoly c) = true)
:
theorem
Nat.Linear.ExprCnstr.eq_true_of_isValid
(ctx : Nat.Linear.Context)
(c : Nat.Linear.ExprCnstr)
(h : Nat.Linear.PolyCnstr.isValid (Nat.Linear.ExprCnstr.toNormPoly c) = true)
:
Nat.Linear.ExprCnstr.denote ctx c = True
theorem
Nat.Linear.Certificate.of_combineHyps
(ctx : Nat.Linear.Context)
(c : Nat.Linear.PolyCnstr)
(cs : Nat.Linear.Certificate)
(h : Nat.Linear.PolyCnstr.denote ctx (Nat.Linear.Certificate.combineHyps c cs) → False)
:
Nat.Linear.PolyCnstr.denote ctx c → Nat.Linear.Certificate.denote ctx cs
theorem
Nat.Linear.Certificate.of_combine
(ctx : Nat.Linear.Context)
(cs : Nat.Linear.Certificate)
(h : Nat.Linear.PolyCnstr.denote ctx (Nat.Linear.Certificate.combine cs) → False)
:
theorem
Nat.Linear.Certificate.of_combine_isUnsat
(ctx : Nat.Linear.Context)
(cs : Nat.Linear.Certificate)
(h : Nat.Linear.PolyCnstr.isUnsat (Nat.Linear.Certificate.combine cs) = true)
:
theorem
Nat.Linear.denote_monomialToExpr
(ctx : Nat.Linear.Context)
(k : Nat)
(v : Nat.Linear.Var)
:
Nat.Linear.Expr.denote ctx (Nat.Linear.monomialToExpr k v) = k * Nat.Linear.Var.denote ctx v
theorem
Nat.Linear.Poly.denote_toExpr_go
(ctx : Nat.Linear.Context)
(e : Nat.Linear.Expr)
(p : Nat.Linear.Poly)
:
Nat.Linear.Expr.denote ctx (Nat.Linear.Poly.toExpr.go e p) = Nat.Linear.Expr.denote ctx e + Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.Poly.denote_toExpr
(ctx : Nat.Linear.Context)
(p : Nat.Linear.Poly)
:
Nat.Linear.Expr.denote ctx (Nat.Linear.Poly.toExpr p) = Nat.Linear.Poly.denote ctx p
theorem
Nat.Linear.ExprCnstr.eq_of_toNormPoly_eq
(ctx : Nat.Linear.Context)
(c : Nat.Linear.ExprCnstr)
(d : Nat.Linear.ExprCnstr)
(h : (Nat.Linear.ExprCnstr.toNormPoly c == Nat.Linear.ExprCnstr.toPoly d) = true)
:
Nat.Linear.ExprCnstr.denote ctx c = Nat.Linear.ExprCnstr.denote ctx d
theorem
Nat.Linear.Expr.eq_of_toNormPoly_eq
(ctx : Nat.Linear.Context)
(e : Nat.Linear.Expr)
(e' : Nat.Linear.Expr)
(h : (Nat.Linear.Expr.toNormPoly e == Nat.Linear.Expr.toPoly e') = true)
:
Nat.Linear.Expr.denote ctx e = Nat.Linear.Expr.denote ctx e'