ch:dimension-types: ch:dimension-types
Problem and result. Build one syntax-directed inferencer that normalizes dimensions, traverses source terms, solves its mixed equation store, and replays every returned substitution. The completed run infers polymorphic square, performs coherent unit addition, solves a coupled Smith row, and rejects both mismatched dimensions and an odd Smith pivot. The bundled corpus.kp runs the empty-environment cases. On the row Unsupported; the completed project reduces
Representation. Let solveDimSystem returns a solved substitution and unused supply or a divisibility certificate; inferW returns the inferred type, composed substitution, equation store, and unused supplies; evalCore returns a numeral or aritherr.
First complete version. Implement exponent-map normalization, multiplication, inverse, power, and substitution first. Then replace the bundled divisibility selector by Smith reduction while recording every row and column operation for replay. For a fresh dimension parameter Unsupported. Next implement variables, annotated literals, lambdas, and multiplication in Algorithm W’s left-to-right order. On
Remaining cases. Add application and let with the exact substitution order from definition 6.16. Add addition, multiplication, division, and power; addition must apply the right-operand substitution to the left inferred type before creating its two numeric equations. The mixed solver first eliminates ordinary variables with an occurs check, then sends its complete residual numeric store to the deterministic Smith routine. Name free Smith columns left to right from the remaining dimension supply. Generalize both ordinary and dimension variables after subtracting the free variables of the substituted environment. The fixture
A failing version. Change only the pivot test so that exponent one is accepted at pivot two. This check-clean mutation admits
Acceptance test. Require a silent check, an empty audit, and computed trace lines for the generalized square scheme, successful equation replay, the canonical result artifacts/ch6-dimension-inferencer/, run kappa check corpus.kp, kappa test corpus.kp, kappa run corpus.kp, and kappa audit corpus.kp. Require the completed corpus to pass and the odd-pivot mutant to fail its test oracle.
Mathematical boundary. The run checks a finite set of generated certificates. It does not prove the Smith theorem, mixed-unifier principality, type safety, or unit-change invariance.