java.lang.Object
java.lang.Record
com.darkcollective.relix.provenance.Monomial
Record Components:
exponents - canonical variable → positive-exponent map; never null
All Implemented Interfaces:
Comparable<Monomial>

public record Monomial(SortedMap<ProvenanceVariable,Integer> exponents) extends Record implements Comparable<Monomial>
A monomial in the polynomial-lineage semiring ℕ[X] — a product of provenance variables with positive integer exponents (a multiset of variables). It records one joint derivation: the set of base tuples that were combined (by ⊗/join), with an exponent counting how many times each was used.

The empty monomial is the multiplicative constant 1 (a derivation that uses no input — the semiring's one). Monomials are held in canonical form (a sorted map of variable → positive exponent), so equal products compare equal regardless of construction order.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Monomial
    The constant monomial 1 (no variables).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Canonicalises exponents: defensively copies into a TreeMap and rejects non-positive exponents (a zero/negative exponent is not representable — absent variables are simply not keys).
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Orders monomials deterministically — by ascending total degree, then lexicographically by their (variable, exponent) entries.
    int
    Returns the total degree (sum of exponents); 0 for the constant monomial.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the exponents record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether this is the constant monomial 1.
    static Monomial
    Returns the single-variable monomial x.
    render(boolean detailed)
    Returns the rendered product, with each variable optionally enriched by its captured source columns.
    times(Monomial other)
    Multiplies this monomial by other: the exponents of shared variables add (the ⊗ on the variable level).
    Returns the rendered product, e.g. Orders#1·Customers#1^2; 1 when constant.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CONSTANT

      public static final Monomial CONSTANT
      The constant monomial 1 (no variables).
  • Constructor Details

    • Monomial

      public Monomial(SortedMap<ProvenanceVariable,Integer> exponents)
      Canonicalises exponents: defensively copies into a TreeMap and rejects non-positive exponents (a zero/negative exponent is not representable — absent variables are simply not keys).
      Parameters:
      exponents - variable → exponent map; never null, all exponents > 0
  • Method Details

    • of

      public static Monomial of(ProvenanceVariable variable)
      Returns the single-variable monomial x.
      Returns:
      the single-variable monomial x
    • times

      public Monomial times(Monomial other)
      Multiplies this monomial by other: the exponents of shared variables add (the ⊗ on the variable level).
      Parameters:
      other - the monomial to multiply by; never null
      Returns:
      the product monomial
    • degree

      public int degree()
      Returns the total degree (sum of exponents); 0 for the constant monomial.
      Returns:
      the total degree (sum of exponents); 0 for the constant monomial
    • isConstant

      public boolean isConstant()
      Returns whether this is the constant monomial 1.
      Returns:
      whether this is the constant monomial 1
    • compareTo

      public int compareTo(Monomial other)
      Orders monomials deterministically — by ascending total degree, then lexicographically by their (variable, exponent) entries. This is the stable order used to render a polynomial and to choose which terms survive a PolynomialSemiring truncation.
      Specified by:
      compareTo in interface Comparable<Monomial>
    • toString

      public String toString()
      Returns the rendered product, e.g. Orders#1·Customers#1^2; 1 when constant.
      Specified by:
      toString in class Record
      Returns:
      the rendered product, e.g. Orders#1·Customers#1^2; 1 when constant
    • render

      public String render(boolean detailed)
      Returns the rendered product, with each variable optionally enriched by its captured source columns. render(false) renders each variable by its bare name (the toString() default); render(true) uses its detailed label, e.g. Orders#1{id: 42}·Customers#1{id: 7}.
      Parameters:
      detailed - whether to append captured source columns to each variable
      Returns:
      the rendered product, with each variable optionally enriched by its 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • exponents

      public SortedMap<ProvenanceVariable,Integer> exponents()
      Returns the value of the exponents record component.
      Returns:
      the value of the exponents record component