Std. Proof. LinearArithmetic
(Cure Standard Library v0.37.2)
View Source
Executable affine syntax and Boolean candidate checking for LIA. This module is total and deliberately rejects malformed dimensions instead of inheriting List.zip_with's truncating semantics.
Examples
use Std.Bool
use Std.Int
use Std.Proof.IntOrder
use Std.Proof.LinearArithmetic
fn eval_example() -> Bool =
let atom = linear_atom([int_one()], int_zero(), LessThan())
evaluate_atom(atom, [int_negative_one()])
Summary
Functions
Normalize and add two LinearAtom inequalities, returning None() on a dimension mismatch.
Pointwise sum of two coefficient lists, returning None() if their lengths differ.
Return True() when every coefficient in coefficients is zero.
Append the negated goal to hypotheses to form the refutation system.
Check whether every atom in atoms has coefficient length equal to dimension.
Executable candidate check only. A general proof-relevant certificate and checker-to-goal soundness theorem remain separate, unfinished work.
Check whether coefficients has length equal to dimension.
Compute the weighted nonnegative linear combination of atoms using witness,
returning None() on any length or dimension mismatch.
Integer dot product of a coefficient list and a valuation list.
Defining equation for dot on non-empty coefficient and valuation lists.
Public defining equations: downstream proof modules consume these instead of relying on eager δ-unfolding of the recursive global on open terms.
Evaluate a LinearAtom at valuation without checking dimension alignment.
Evaluate a LinearAtom at valuation, returning None() on a dimension mismatch.
Evaluate a Relation in normalized <= form (left < right as left <= pred_int(right)).
Evaluate a Relation (<= or <) on two integers.
Return True() when atom has the form 0 <= c with c < 0.
Construct a LinearAtom from its coefficient vector, right-hand constant, and relation.
Total structural Boolean equality on inductive Nat values.
Total length of a list as an inductive Nat.
Negating lhs<=c gives -lhs < -c; negating lhs<c gives -lhs <= -c.
Negate every integer in a coefficient list.
Discrete-integer normalization: lhs<c iff lhs<=pred(c).
Normalized relation evaluation equals direct relation evaluation for all integers.
Normalize atom to <= form and scale its coefficients and constant by scalar.
Multiply every coefficient in coefficients by the nonnegative scalar.
Build the trivial 0 <= 0 atom of length dimension.
Build a coefficient list of dimension zeros.
Types
Functions
fn add_atoms(left: LinearAtom, right: LinearAtom) -> Option(LinearAtom)
Normalize and add two LinearAtom inequalities, returning None() on a dimension mismatch.
fn add_coefficients(left: List(Int), right: List(Int)) -> Option(List(Int))
Pointwise sum of two coefficient lists, returning None() if their lengths differ.
fn all_zero(coefficients: List(Int)) -> Bool
Return True() when every coefficient in coefficients is zero.
fn append_goal(hypotheses: Hypotheses, goal: LinearAtom) -> List(LinearAtom)
Append the negated goal to hypotheses to form the refutation system.
fn atoms_match_dimension(atoms: List(LinearAtom), dimension: Nat) -> Bool
Check whether every atom in atoms has coefficient length equal to dimension.
fn check_lia_candidate(hypotheses: Hypotheses, goal: LinearAtom, witness: FarkasWitness) -> Bool
Executable candidate check only. A general proof-relevant certificate and checker-to-goal soundness theorem remain separate, unfinished work.
@reducible publishes the body for certified candidate validation, not an
unchecked route from a Bool to a goal. Certification is still required.
by omega also reconstructs actual evidence from checked order lemmas.
fn coefficients_match_dimension(coefficients: List(Int), dimension: Nat) -> Bool
Check whether coefficients has length equal to dimension.
fn combine(dimension: Nat, atoms: List(LinearAtom), witness: FarkasWitness) -> Option(LinearAtom)
Compute the weighted nonnegative linear combination of atoms using witness,
returning None() on any length or dimension mismatch.
fn dot(coefficients: List(Int), valuation: List(Int)) -> Int
Integer dot product of a coefficient list and a valuation list.
fn dot_cons(coefficient: Int, coefficients: List(Int), value: Int, valuation: List(Int)) -> Equivalent(Int, dot(Cons(coefficient, coefficients), Cons(value, valuation)), add_int(multiply_int(coefficient, value), dot(coefficients, valuation)))
Defining equation for dot on non-empty coefficient and valuation lists.
fn dot_empty(valuation: List(Int)) -> Equivalent(Int, dot(Nil(), valuation), int_zero())
Public defining equations: downstream proof modules consume these instead of relying on eager δ-unfolding of the recursive global on open terms.
fn evaluate_atom(atom: LinearAtom, valuation: Valuation) -> Bool
Evaluate a LinearAtom at valuation without checking dimension alignment.
fn evaluate_atom_checked(atom: LinearAtom, valuation: Valuation) -> Option(Bool)
Evaluate a LinearAtom at valuation, returning None() on a dimension mismatch.
fn evaluate_normalized_relation(relation: Relation, left: Int, right: Int) -> Bool
Evaluate a Relation in normalized <= form (left < right as left <= pred_int(right)).
fn evaluate_relation(relation: Relation, left: Int, right: Int) -> Bool
Evaluate a Relation (<= or <) on two integers.
fn is_manifest_contradiction(atom: LinearAtom) -> Bool
Return True() when atom has the form 0 <= c with c < 0.
fn linear_atom(coefficients: List(Int), constant: Int, relation: Relation) -> LinearAtom
Construct a LinearAtom from its coefficient vector, right-hand constant, and relation.
fn nat_equal(left: Nat, right: Nat) -> Bool
Total structural Boolean equality on inductive Nat values.
fn nat_length(a: Type, values: List(a)) -> Nat
Total length of a list as an inductive Nat.
fn negate_atom(atom: LinearAtom) -> LinearAtom
Negating lhs<=c gives -lhs < -c; negating lhs<c gives -lhs <= -c.
fn negate_coefficients(coefficients: List(Int)) -> List(Int)
Negate every integer in a coefficient list.
fn normalize_atom(atom: LinearAtom) -> LinearAtom
Discrete-integer normalization: lhs<c iff lhs<=pred(c).
fn normalize_relation_preserves_evaluation(relation: Relation, left: Int, right: Int) -> Equivalent(Bool, evaluate_normalized_relation(relation, left, right), evaluate_relation(relation, left, right))
Normalized relation evaluation equals direct relation evaluation for all integers.
fn scale_atom(scalar: Nat, atom: LinearAtom) -> LinearAtom
Normalize atom to <= form and scale its coefficients and constant by scalar.
fn scale_coefficients(scalar: Nat, coefficients: List(Int)) -> List(Int)
Multiply every coefficient in coefficients by the nonnegative scalar.
fn zero_atom(dimension: Nat) -> LinearAtom
Build the trivial 0 <= 0 atom of length dimension.
fn zeros(dimension: Nat) -> List(Int)
Build a coefficient list of dimension zeros.