Record Class TruthRelationNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.TruthRelationNode
Record Components:
holdsTuple - true for UNIT/DEE (one empty tuple), false for EMPTY/DUM (no tuples)
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record TruthRelationNode(boolean holdsTuple, SourceLocation location) extends Record implements RelNode
A nullary truth relation literal — a leaf node denoting one of the two relations whose heading is the empty (closed, zero-column) schema.

A zero-column relation can hold at most one tuple — the empty tuple — so there are exactly two of them, and they behave as truth values:

  • UNIT (alias DEE) — holds the empty tuple: true, and the identity of Cartesian product (R × UNIT = R).
  • EMPTY (alias DUM) — holds no tuple: false. R × EMPTY is empty, but it keeps R's heading, so it is not EMPTY itself.

These are Tutorial D's TABLE_DEE / TABLE_DUM (Date & Darwen, The Third Manifesto). Relix leads with the descriptive UNIT/EMPTY spellings — the lineage names are recognised aliases, in the same spirit as the glyph↔keyword duality of the operators.

The empty schema this node infers to (Schema.empty()) is the same one the no-key whole-relation universal quantifier ∀ : P (R) already produces, so every phase below is width-0 tolerant by construction.

  • Field Details

    • UNIT_KEYWORD

      public static final String UNIT_KEYWORD
      The keyword spelling of the one-tuple truth relation.
      See Also:
    • EMPTY_KEYWORD

      public static final String EMPTY_KEYWORD
      The keyword spelling of the zero-tuple truth relation.
      See Also:
  • Constructor Details

    • TruthRelationNode

      public TruthRelationNode(boolean holdsTuple, SourceLocation location)
      Creates an instance of a TruthRelationNode record class.
      Parameters:
      holdsTuple - the value for the holdsTuple record component
      location - the value for the location record component
  • Method Details

    • unit

      public static TruthRelationNode unit(SourceLocation location)
      Creates the one-tuple truth relation (UNIT / DEE).
      Parameters:
      location - the source location; must not be null
      Returns:
      a UNIT node
    • empty

      public static TruthRelationNode empty(SourceLocation location)
      Creates the zero-tuple truth relation (EMPTY / DUM).
      Parameters:
      location - the source location; must not be null
      Returns:
      an EMPTY node
    • keyword

      public String keyword()
      Returns the canonical keyword for this literal — "UNIT" or "EMPTY" — as printed by every tree renderer.
      Returns:
      the canonical keyword; never null
    • cardinality

      public long cardinality()
      The number of tuples this literal denotes: 1 for UNIT, 0 for EMPTY. Both cardinalities are exact, not estimates.
      Returns:
      1 or 0
    • accept

      public <R> R accept(RelNodeVisitor<R> visitor)
      Specified by:
      accept in interface RelNode
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • holdsTuple

      public boolean holdsTuple()
      Returns the value of the holdsTuple record component.
      Returns:
      the value of the holdsTuple record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface RelNode
      Returns:
      the value of the location record component