Enum Class CountingSemiring
- All Implemented Interfaces:
Semiring<BigInteger>,Serializable,Comparable<CountingSemiring>,Constable
The counting semiring
(ℕ, +, ×, 0, 1) — bag semantics (row
multiplicity) and, over a weighted closure, path counting.
⊕ adds the multiplicities of alternative derivations,
⊗ multiplies the multiplicities of a join's inputs,
0 is 0 (absent), and 1 is 1.
Annotations are BigInteger rather than a fixed-width integer because
multiplicities and path counts can grow without bound (a dense reachability
graph has exponentially many paths); arbitrary precision avoids silent overflow,
consistent with the engine's BigInteger-backed generators.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionReturns the tuple's multiplicity.one()Returns the multiplicative identity1.plus(BigInteger a, BigInteger b) Combines two annotations with⊕— the way alternative derivations of the same tuple (union, projection) are merged.times(BigInteger a, BigInteger b) Combines two annotations with⊗— the way the joint requirements of a tuple (join, product) are merged.static CountingSemiringReturns the enum constant of this class with the specified name.static CountingSemiring[]values()Returns an array containing the constants of this enum class, in the order they are declared.zero()Returns the additive identity0.
-
Enum Constant Details
-
INSTANCE
The singleton instance.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
zero
Description copied from interface:SemiringReturns the additive identity0. It is the identity ofSemiring.plus(K, K)and the annihilator ofSemiring.times(K, K), and denotes an absent tuple.- Specified by:
zeroin interfaceSemiring<BigInteger>- Returns:
- the additive identity
0
-
one
Description copied from interface:SemiringReturns the multiplicative identity1. It is the identity ofSemiring.times(K, K).- Specified by:
onein interfaceSemiring<BigInteger>- Returns:
- the multiplicative identity
1
-
plus
Description copied from interface:SemiringCombines two annotations with⊕— the way alternative derivations of the same tuple (union, projection) are merged. Associative and commutative, with identitySemiring.zero().- Specified by:
plusin interfaceSemiring<BigInteger>- Parameters:
a- the first annotationb- the second annotation- Returns:
a ⊕ b
-
times
Description copied from interface:SemiringCombines two annotations with⊗— the way the joint requirements of a tuple (join, product) are merged. Associative and commutative, with identitySemiring.one(), annihilated bySemiring.zero().- Specified by:
timesin interfaceSemiring<BigInteger>- Parameters:
a- the first annotationb- the second annotation- Returns:
a ⊗ b
-
base
Returns the tuple's multiplicity. A numeric weight is read as a whole number of occurrences, truncating any fractional part; a tuple with no numeric weight countsonce, which is what makes an unweighted graph's annotation its path count.- Specified by:
basein interfaceSemiring<BigInteger>- Parameters:
tuple- the base tuple; nevernull- Returns:
- the tuple's multiplicity
-