Skip to main content

Module symbolic_algebra

Module symbolic_algebra 

Source
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 + b node.
c
Constant leaf Expr::Const(v).
cos
cos a node.
decode_int_const_quin
Extract the exact 64-bit signed integer from a cas:int_const Quin leaf.
differentiate
Symbolic derivative of expr with respect to variable wrt. The result is NOT auto-simplified — call simplify on it for a compact form.
div
a / b node.
exp
e^a node.
expand
Distribute every product over sums and expand small positive integer powers, so the result contains no Mul/Pow node 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_hash over the canonical Display string.
factor_quadratic
Factor a real quadratic a·x² + b·x + c into a·(x − r₁)·(x − r₂) when it has real roots. Returns None when the discriminant is negative (no real factorisation) or a = 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 by to_quins.
has_sum_of_three_cubes_mod9_obstruction
Returns true iff k ≡ 4 or 5 (mod 9) (k ≡ ±4 (mod 9)), proving global algebraic impossibility of x^3 + y^3 + z^3 = k over ℤ^3 (Q42-08 / §6.2.3).
int_c
Exact integer constant leaf constructor (Q42-08).
ln
ln a node.
mul
a · b node.
neg
Unary −a node.
parse
Parse a textual expression like "x^3 - 2*x^2 + 5" or "sqrt(b^2 - 4*a*c)" into an Expr. Supports + - * / ^, parentheses, sqrt(...), numbers and identifiers.
pow
a^e node with integer exponent.
push_int_const_node
Encode e post-order into out (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 i128 Divisor / Discriminant reduction cascade for x^3 + y^3 + z^3 = k: Given (k, z) and divisor s = x + y of r = 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_i across RNS_CRT_PRIMES_4. By CRT, all 4 lanes are 0 iff ∏ m_i divides x^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 identical x+x → 2·x. Applied to a fixpoint (bounded).
sin
sin a node.
solve_quadratic_symbolic
Symbolic roots of a·x² + b·x + c = 0 with real coefficients, as exact Exprs (-b ± √(b²−4ac)) / (2a). Returns the two root expressions (simplified). For a = 0 returns the single linear root -c/b.
sqrt
√a node.
sub
a − b node.
sum_of_three_cubes_expr
Canonical symbolic expression for x^3 + y^3 + z^3 - k using exact Expr::IntConst(k).
sum_of_three_cubes_quins
Encode x^3 + y^3 + z^3 - k into a post-order Vec<NQuin> with canonical 5-field XOR parity and an exact cas:int_const leaf for k.
tan
tan a node.
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’s k = 42 solution: 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 == k over [u64; 4] stack limbs.
verify_sum_of_three_cubes_rns_4prime
Returns true iff (x, y, z, k) vanishes in all 4 RNS prime lanes (RNS_CRT_PRIMES_4).