The Fourier-Motzkin elimination procedure #
The Fourier-Motzkin procedure is a variable elimination method for linear inequalities. https://en.wikipedia.org/wiki/Fourier%E2%80%93Motzkin_elimination
Given a set of linear inequalities comps = {tᵢ Rᵢ 0}
,
we aim to eliminate a single variable a
from the set.
We partition comps
into comps_pos
, comps_neg
, and comps_zero
,
where comps_pos
contains the comparisons tᵢ Rᵢ 0
in which
the coefficient of a
in tᵢ
is positive, and similar.
For each pair of comparisons tᵢ Rᵢ 0 ∈ comps_pos
, tⱼ Rⱼ 0 ∈ comps_neg
,
we compute coefficients vᵢ, vⱼ ∈ ℕ
such that vᵢ*tᵢ + vⱼ*tⱼ
cancels out a
.
We collect these sums vᵢ*tᵢ + vⱼ*tⱼ R' 0
in a set S
and set comps' = S ∪ comps_zero
,
a new set of comparisons in which a
has been eliminated.
Theorem: comps
and comps'
are equisatisfiable.
We recursively eliminate all variables from the system. If we derive an empty clause 0 < 0
,
we conclude that the original system was unsatisfiable.
Datatypes #
The comp_source
and pcomp
datatypes are specific to the FM elimination routine;
they are not shared with other components of linarith
.
- assump : ℕ → linarith.comp_source
- add : linarith.comp_source → linarith.comp_source → linarith.comp_source
- scale : ℕ → linarith.comp_source → linarith.comp_source
comp_source
tracks the source of a comparison.
The atomic source of a comparison is an assumption, indexed by a natural number.
Two comparisons can be added to produce a new comparison,
and one comparison can be scaled by a natural number to produce a new comparison.
Instances for linarith.comp_source
- linarith.comp_source.has_sizeof_inst
- linarith.comp_source.inhabited
- linarith.comp_source.has_to_format
Formats a comp_source
for printing.