Record Class Polynomial
java.lang.Object
java.lang.Record
com.darkcollective.relix.provenance.Polynomial
- Record Components:
terms- canonical monomial → positive-coefficient map; nevernulltruncated- whether terms were dropped to stay within the representation bound
A provenance polynomial — an element of the lineage semiring
ℕ[X]. It is a sum of monomials, each
with a positive BigInteger coefficient, recording the full
why-provenance of a tuple: every distinct derivation (monomial) and its
multiplicity (coefficient).
Held in canonical form: a sorted map of monomial → non-zero coefficient (a
coefficient of zero means that derivation is absent, so it is never a key). The
empty polynomial is 0. The truncated flag records that a
PolynomialSemiring operation hit the monomial cap and dropped some terms —
the degraded mode (a sound under-approximation; the surviving terms are real
derivations, but the polynomial is incomplete).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisZero()Returns whether this is the zero polynomial.static Polynomialone()Returns the constant polynomial1(the multiplicative identity).render(boolean detailed) Returns this polynomial rendered with variables optionally enriched by their captured source columns.intsize()Returns the number of distinct monomials (derivations) — the representation size.terms()Returns the value of thetermsrecord component.toString()Returns the rendered polynomial, e.g.2·Orders#1·Customers#1 + Orders#2.booleanReturns the value of thetruncatedrecord component.static PolynomialReturns the single-variable polynomialxfor a structured source.static PolynomialReturns the single-variable polynomialx.static Polynomialzero()Returns the zero polynomial0(no derivations — an absent tuple).
-
Constructor Details
-
Polynomial
Canonicalisesterms: defensively copies into aTreeMap(so iteration is in the deterministicMonomialorder) and drops any zero-coefficient term. Negative coefficients are rejected — ℕ[X] has natural-number coefficients.- Parameters:
terms- monomial → coefficient map; nevernulltruncated- whether some terms were dropped to honour the bound
-
-
Method Details
-
zero
Returns the zero polynomial0(no derivations — an absent tuple).- Returns:
- the zero polynomial
0(no derivations — an absent tuple)
-
one
Returns the constant polynomial1(the multiplicative identity).- Returns:
- the constant polynomial
1(the multiplicative identity)
-
variable
Returns the single-variable polynomialx. The lift token for one base-tuple occurrence.- Parameters:
name- the variable label (by convention<relation>#<ordinal>)- Returns:
- the single-variable polynomial
x
-
variable
Returns the single-variable polynomialxfor a structured source. The lift token for one base-tuple occurrence, carrying itscaptured columnsso the resulting lineage is machine-actionable.- Parameters:
ref- the structured source identity; nevernull- Returns:
- the single-variable polynomial
xfor a structured source
-
isZero
public boolean isZero()Returns whether this is the zero polynomial.- Returns:
- whether this is the zero polynomial
-
size
public int size()Returns the number of distinct monomials (derivations) — the representation size.- Returns:
- the number of distinct monomials (derivations) — the representation size
-
toString
Returns the rendered polynomial, e.g.2·Orders#1·Customers#1 + Orders#2.0for the zero polynomial; a trailing+ ⋯whentruncated(). -
render
Returns this polynomial rendered with variables optionally enriched by their captured source columns.render(false)is the compact form (thetoString()default, e.g.2·Orders#1·Customers#1 + Orders#2);render(true)expands each variable to itsdetailed label, e.g.Orders#1{id: 42}, when structured source columns are present.- Parameters:
detailed- whether to append captured source columns to each variable- Returns:
- this polynomial rendered with variables optionally enriched by their captured source columns
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
terms
Returns the value of thetermsrecord component.- Returns:
- the value of the
termsrecord component
-
truncated
public boolean truncated()Returns the value of thetruncatedrecord component.- Returns:
- the value of the
truncatedrecord component
-