Expand description
Symbolic algebra — a small computer-algebra system (CAS).
Expression trees over rationals/reals + variables, with simplify,
differentiate, numeric eval, and symbolic equation solving. This is the
ALGEBRA_MANIFOLD_PLAN.md Phase 3 module and is DELIBERATELY distinct from
solvers/symbolic_logic (which is SAT / defeasible LOGIC, not computer algebra).
The CAS is an authoring / tooling path and may allocate (Box, String); it must
NOT be used on an NQuin/SlgArena hot path. Results can be bridged back into the
graph via expr_citation_hash for provenance.
Enums§
- Expr
- A symbolic expression over real constants and named variables.
Constants§
- CAS_
INT_ CONST_ TAG - Predicate tag string for an exact 64-bit signed integer CAS leaf (
Q42-08). - RNS_
CRT_ PRIMES_ 4 - Four pairwise-coprime 31-bit primes for zero-heap RNS / CRT verification (
∏ m_i ≈ 2^124 > 2B).
Functions§
- add
a + bnode.- c
- Constant leaf
Expr::Const(v). - cos
cos anode.- decode_
int_ const_ quin - Extract the exact 64-bit signed integer from a
cas:int_constQuin leaf. - differentiate
- Symbolic derivative of
exprwith respect to variablewrt. The result is NOT auto-simplified — callsimplifyon it for a compact form. - div
a / bnode.- exp
e^anode.- expand
- Distribute every product over sums and expand small positive integer powers, so the
result contains no
Mul/Pownode with an additive child. Semantically equal to the input (verify by evaluation). Powers above 8 are left unexpanded to bound blow-up. - expr_
citation_ hash - A stable provenance hash of an expression’s canonical form, for citing symbolic
results back into the graph (Phase 3.8 bridge). Two structurally-equal expressions
hash equally; this is
q_hashover the canonicalDisplaystring. - factor_
quadratic - Factor a real quadratic
a·x² + b·x + cintoa·(x − r₁)·(x − r₂)when it has real roots. ReturnsNonewhen the discriminant is negative (no real factorisation) ora = 0. Root constants are snapped to integers/halves when numerically close, so the common rational case factors cleanly. - from_
quins - Reconstruct an expression from a post-order
Vec<NQuin>produced byto_quins. - has_
sum_ of_ three_ cubes_ mod9_ obstruction - Returns
trueiffk ≡ 4 or 5 (mod 9)(k ≡ ±4 (mod 9)), proving global algebraic impossibility ofx^3 + y^3 + z^3 = koverℤ^3(Q42-08/ §6.2.3). - int_c
- Exact integer constant leaf constructor (
Q42-08). - ln
ln anode.- mul
a · bnode.- neg
- Unary
−anode. - parse
- Parse a textual expression like
"x^3 - 2*x^2 + 5"or"sqrt(b^2 - 4*a*c)"into anExpr. Supports+ - * / ^, parentheses,sqrt(...), numbers and identifiers. - pow
a^enode with integer exponent.- push_
int_ const_ node - Encode
epost-order intoout(children before parents, index-linked); returns the root node index. Append an exact 64-bit signed integer constant leaf Quin (cas:int_const) with 5-field parity. - reduce_
sum_ of_ three_ cubes_ divisor_ discriminant - Zero-heap
i128Divisor / Discriminant reduction cascade forx^3 + y^3 + z^3 = k: Given(k, z)and divisors = x + yofr = k - z^3 = s(x^2 - xy + y^2): - rns_
4prime_ cubic_ residuals - Zero-heap 4-prime RNS residual
(x^3 + y^3 + z^3 - k) mod m_iacrossRNS_CRT_PRIMES_4. By CRT, all 4 lanes are0iff∏ m_idividesx^3 + y^3 + z^3 - k(exact for|residual| < ∏ m_i / 2). - simplify
- Simplify an expression: constant folding, identity elimination (
x+0,x·1,x·0,x⁰,x¹,−(−x),x/1,x−x,x/x) and collection of an identicalx+x → 2·x. Applied to a fixpoint (bounded). - sin
sin anode.- solve_
quadratic_ symbolic - Symbolic roots of
a·x² + b·x + c = 0with real coefficients, as exactExprs(-b ± √(b²−4ac)) / (2a). Returns the two root expressions (simplified). Fora = 0returns the single linear root-c/b. - sqrt
√anode.- sub
a − bnode.- sum_
of_ three_ cubes_ expr - Canonical symbolic expression for
x^3 + y^3 + z^3 - kusing exactExpr::IntConst(k). - sum_
of_ three_ cubes_ quins - Encode
x^3 + y^3 + z^3 - kinto a post-orderVec<NQuin>with canonical 5-field XOR parity and an exactcas:int_constleaf fork. - tan
tan anode.- to_
quins - Serialise an expression into a post-order
Vec<NQuin>(the root is the last element). - var
- Variable leaf
Expr::Var(name)(names > 8 bytes are truncated at Quin encode time). - verify_
divisor_ discriminant_ cascade_ bigint - Arbitrary-precision Divisor / Discriminant cascade verifier over
BigInt(Q42-08/ §6.2.3), capable of verifying 170-bit witnesses such as Booker & Sutherland’sk = 42solution:r = k - z^3,s = x + y,q = r / s,p = (s^2 - q) / 3,D = s^2 - 4p = (x - y)^2 = u^2. - verify_
sum_ of_ three_ cubes_ exact - Zero-heap exact signed 256-bit verification of
x^3 + y^3 + z^3 == kover[u64; 4]stack limbs. - verify_
sum_ of_ three_ cubes_ rns_ 4prime - Returns
trueiff(x, y, z, k)vanishes in all 4 RNS prime lanes (RNS_CRT_PRIMES_4).