AngouriMath
AngouriMath.Functions.Algebra.MonoidAlgebra
Classes within the AngouriMath.Functions.Algebra.MonoidAlgebra namespace
IBasisOps`1
Summary
What a basis has to be able to do for its terms to be factorable: it is a monoid, and
its elements have a greatest common part that can be divided out.
Type parameter "TBasis"
An exponent vector for a polynomial, a rational exponent for a series, a basis ket for a
quantum state.
Remarks
Passed as an instance rather than fixed by a type parameter withnew() . The
codebase does it the other way in
PolynomialSolver.GatherMonomialInformation<T, TPrimitive> , and that shape
is harder to test in isolation for no gain here, since these operations are stateless
and one instance serves every call.
**Meet(`0,`0) is what makes factoring one operation across features.** Dividing
out the meet of the support is simultaneously "take the common monomial out of a
polynomial" and "detect that a quantum state is separable":
x^2*y + x^2 meet of (2,1) and (2,0) is (2,0), leaving y + 1 |001> + |011> meet of 001 and 011 is 0-1, leaving |0> + |1>
The two look different only because a polynomial's basis is ordered -- so the meet is a
componentwise minimum -- while a ket's is flat, and the meet keeps a position only where
every element agrees. Both are the meet in a product of semilattices.
Semiring
Summary
The arithmetic the coefficients of a SparseTerms`1 obey.
Remarks
Coefficients are always Entity; what changes between features is what
adding and multiplying two of them means. A polynomial adds them in a field, a boolean
expression joins them in a lattice, and everything else about the representation is the
same.
**IsIdempotent is the whole reason this is a type rather than a pair of
delegates.**a or a = a holds in the boolean semiring and fails in the complex
one, where|x> + |x> is2|x> -- and that single difference is
what separates *covering* from *superposition*. Quine-McCluskey's merge step is
absorption, and it is sound only because a minterm may be covered twice for free; a
procedure that assumed the same of amplitudes would double them. Anything reading this
flag is asking whether it may cover the same basis element more than once.
SparseTerms`1
Summary
A finitely-supported map from a basis into a coefficient semiring -- the shape shared by
a polynomial, an asymptotic series, a boolean expression's minterms and a quantum state.
Type parameter "TBasis"
The basis element. An exponent vector, a rational exponent, a basis ket.
**It must compare by value.** The terms are keyed on it, so a basis with reference
equality would leave every element distinct and quietly stop collecting like terms --
which is not an error anywhere, just a wrong answer. Use a struct or a record.
Remarks
Immutable by construction: every operation returns a new instance, and the dictionary
handed in is copied rather than adopted. It is not
System.Collections.Immutable because that would be a new package reference on a
library that has none, which is a packaging decision rather than a design one.
The invariant is that **no term carries a zero coefficient**. That is what makes the
count of terms meaningful, and it is where an idempotent semiring quietly pays for
itself: adding a boolean term to itself collapses to one term by
Add(AngouriMath.Entity,AngouriMath.Entity) alone, so absorption needs no special case here.
See *One structure under several features* in AGENTS.md for what this is for and,
as importantly, what must not be built on it -- cover selection, factorisation into
irreducibles and series truncation are each specific to one feature and belong in it.
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1953 pages online