5. From Encoding to Logic
The previous pages showed how to encode a polynomial as a box. Now we use those boxes to make assertions — to check that a condition holds rather than just compute a value.
The simplest such assertion is a proportion: . Box arithmetic has no fractions, so it lives entirely as a product identity:
Example — three is to four as six is to eight:
const ad = new Polynumber(3n, []).evaluate([]) * new Polynumber(8n, []).evaluate([]);
const bc = new Polynumber(4n, []).evaluate([]) * new Polynumber(6n, []).evaluate([]);
ad === bc; // 24n === 24n ✓
No division, no fraction — just two products that must match. This is the pattern that scales up to invariants: instead of computing a ratio and storing it, define the relationship as an equality of natural numbers and check it.
A proportion in one variable — if should be of , express it as :
const lhs = new Multinumber([new Polynumber(4n, [0, 1])]); // 4y
const rhs = new Multinumber([new Polynumber(3n, [1])]); // 3x
const x = 8n;
const y = 6n;
lhs.evaluate([x, y]) === rhs.evaluate([x, y]); // 24n === 24n ✓
The division only becomes necessary if you need to solve for given , and then it is exact precisely when . If you need it exact for all inputs, choose a unit for that is always a multiple of — see Precision vs Exactness.