Executable completeness of unit declarations #
Consistency (LambdaS.Declare) says some valuation satisfies the declarations.
Running a program needs more: every conversion between two units of the same
dimension must have a factor the declarations fix. By
Decl.determined_iff_mem_span (LambdaS.Determinacy), a consistent set fixes a
factor exactly when its ratio lies in the ℚ-span of the declared ratios. The
ratios of same-dimension pairs are exactly the dimensionless unit vectors, the
kernel of the dimension map, so completeness is the condition that the declared
ratios span that kernel.
check decides this without computing a kernel basis. It appends one row per
base dimension (dimensionRows) to the declared ratio vectors (combined) and
asks whether the result spans all of B → ℚ; checkSpan answers by solving one
rational system per standard basis vector with RationalSolver.solve. For
sound declarations the two spanning conditions agree
(Decl.combined_span_eq_top_iff).
The theorems, from the linear-algebra form to the one the checker uses:
check_iff_span_dimensionless: for sound declarations,checkholds exactly when every dimensionless ratio lies inDecl.ratioSpan.check_iff_determined: if the set is also consistent, exactly when every dimensionless ratio isDecl.Determined.check_iff_all_conversions_determined: the same, stated for every same-dimension pair; Section 3 of our paper cites it, andDeclSolver.checkrelies on it.
Consistency itself is checked separately, by DeclSolver.solve.
One row per dimension, over the base-unit coordinates.
Equations
Instances For
Declaration vectors followed by dimension rows, explicitly enumerated.
Equations
- LambdaS.DeclarationComplete.combined dims ds i = Sum.elim (fun (j : Fin n) => (ds j).ratio.base) (fun (e : Fin d) => LambdaS.DeclarationComplete.dimensionRows (dims e)) (finSumFinEquiv.symm i)
Instances For
True when the declaration vectors and dimension rows span all unit coordinates.
Equations
- LambdaS.DeclarationComplete.check enum dims ds = LambdaS.DeclarationComplete.checkSpan enum (LambdaS.DeclarationComplete.combined dims ds)
Instances For
Sound declarations make the executable combined-span check equivalent to covering the full kernel of the dimension map.
For consistent sound declarations, completeness means every dimensionless ratio has the same factor in every satisfying valuation.
Global completeness, decided. For sound and consistent declarations,
check returns true exactly when every legal conversion (every pair u, v
of the same dimension) has a factor fixed by the declarations. Section 3 of our
paper cites this form; DeclSolver.check relies on it.
Executable boundary checks for the standard-basis solving loop.
Equations
- LambdaS.DeclarationComplete.instUnitSysFinOfNatNat = { dim := fun (x : Fin 2) => LambdaS.Term.ofBase 0 }