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.

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).

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

type FarkasWitness

 type FarkasWitness

type Hypotheses

 type Hypotheses

struct LinearAtom

 struct LinearAtom
   ?
   ?
   ?

enum Relation

 enum Relation
   LessOrEqual
   LessThan

type Valuation

 type Valuation

Functions

add_atoms(left: LinearAtom, right: LinearAtom) -> Option(LinearAtom)

 fn add_atoms(left: LinearAtom, right: LinearAtom) -> Option(LinearAtom)

Normalize and add two LinearAtom inequalities, returning None() on a dimension mismatch.

add_coefficients(left: List(Int), right: List(Int)) -> Option(List(Int))

 fn add_coefficients(left: List(Int), right: List(Int)) -> Option(List(Int))

Pointwise sum of two coefficient lists, returning None() if their lengths differ.

all_zero(coefficients: List(Int)) -> Bool

 fn all_zero(coefficients: List(Int)) -> Bool

Return True() when every coefficient in coefficients is zero.

append_goal(hypotheses: Hypotheses, goal: LinearAtom) -> List(LinearAtom)

 fn append_goal(hypotheses: Hypotheses, goal: LinearAtom) -> List(LinearAtom)

Append the negated goal to hypotheses to form the refutation system.

atoms_match_dimension(atoms: List(LinearAtom), dimension: Nat) -> Bool

 fn atoms_match_dimension(atoms: List(LinearAtom), dimension: Nat) -> Bool

Check whether every atom in atoms has coefficient length equal to dimension.

check_lia_candidate(hypotheses: Hypotheses, goal: LinearAtom, witness: FarkasWitness) -> Bool

 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.

coefficients_match_dimension(coefficients: List(Int), dimension: Nat) -> Bool

 fn coefficients_match_dimension(coefficients: List(Int), dimension: Nat) -> Bool

Check whether coefficients has length equal to dimension.

combine(dimension: Nat, atoms: List(LinearAtom), witness: FarkasWitness) -> Option(LinearAtom)

 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.

dot(coefficients: List(Int), valuation: List(Int)) -> Int

 fn dot(coefficients: List(Int), valuation: List(Int)) -> Int

Integer dot product of a coefficient list and a valuation list.

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)))

 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.

dot_empty(valuation: List(Int)) -> Equivalent(Int, dot(Nil(), valuation), int_zero())

 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.

evaluate_atom(atom: LinearAtom, valuation: Valuation) -> Bool

 fn evaluate_atom(atom: LinearAtom, valuation: Valuation) -> Bool

Evaluate a LinearAtom at valuation without checking dimension alignment.

evaluate_atom_checked(atom: LinearAtom, valuation: Valuation) -> Option(Bool)

 fn evaluate_atom_checked(atom: LinearAtom, valuation: Valuation) -> Option(Bool)

Evaluate a LinearAtom at valuation, returning None() on a dimension mismatch.

evaluate_normalized_relation(relation: Relation, left: Int, right: Int) -> Bool

 fn evaluate_normalized_relation(relation: Relation, left: Int, right: Int) -> Bool

Evaluate a Relation in normalized <= form (left < right as left <= pred_int(right)).

evaluate_relation(relation: Relation, left: Int, right: Int) -> Bool

 fn evaluate_relation(relation: Relation, left: Int, right: Int) -> Bool

Evaluate a Relation (<= or <) on two integers.

is_manifest_contradiction(atom: LinearAtom) -> Bool

 fn is_manifest_contradiction(atom: LinearAtom) -> Bool

Return True() when atom has the form 0 <= c with c < 0.

linear_atom(coefficients: List(Int), constant: Int, relation: Relation) -> LinearAtom

 fn linear_atom(coefficients: List(Int), constant: Int, relation: Relation) -> LinearAtom

Construct a LinearAtom from its coefficient vector, right-hand constant, and relation.

nat_equal(left: Nat, right: Nat) -> Bool

 fn nat_equal(left: Nat, right: Nat) -> Bool

Total structural Boolean equality on inductive Nat values.

nat_length(a: Type, values: List(a)) -> Nat

 fn nat_length(a: Type, values: List(a)) -> Nat

Total length of a list as an inductive Nat.

negate_atom(atom: LinearAtom) -> LinearAtom

 fn negate_atom(atom: LinearAtom) -> LinearAtom

Negating lhs<=c gives -lhs < -c; negating lhs<c gives -lhs <= -c.

negate_coefficients(coefficients: List(Int)) -> List(Int)

 fn negate_coefficients(coefficients: List(Int)) -> List(Int)

Negate every integer in a coefficient list.

normalize_atom(atom: LinearAtom) -> LinearAtom

 fn normalize_atom(atom: LinearAtom) -> LinearAtom

Discrete-integer normalization: lhs<c iff lhs<=pred(c).

normalize_relation_preserves_evaluation(relation: Relation, left: Int, right: Int) -> Equivalent(Bool, evaluate_normalized_relation(relation, left, right), evaluate_relation(relation, left, right))

 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.

scale_atom(scalar: Nat, atom: LinearAtom) -> LinearAtom

 fn scale_atom(scalar: Nat, atom: LinearAtom) -> LinearAtom

Normalize atom to <= form and scale its coefficients and constant by scalar.

scale_coefficients(scalar: Nat, coefficients: List(Int)) -> List(Int)

 fn scale_coefficients(scalar: Nat, coefficients: List(Int)) -> List(Int)

Multiply every coefficient in coefficients by the nonnegative scalar.

zero_atom(dimension: Nat) -> LinearAtom

 fn zero_atom(dimension: Nat) -> LinearAtom

Build the trivial 0 <= 0 atom of length dimension.

zeros(dimension: Nat) -> List(Int)

 fn zeros(dimension: Nat) -> List(Int)

Build a coefficient list of dimension zeros.