semiring.py¶
from pymwp.semiring import KEYS, ZERO_MWP, UNIT_MWP, prod_mwp, sum_mwp
INFTY_MWP
module-attribute
¶
INFTY_MWP: str = 'i'
Scalar that represents failure in the analysis ('i'
), \(\infty\).
KEYS
module-attribute
¶
Different scalar values: "o", "m", "w", "p", "i"
POLY_MWP
module-attribute
¶
POLY_MWP: str = 'p'
Scalar that represents a polynomial flow in the analysis ('p'
).
UNIT_MWP
module-attribute
¶
UNIT_MWP: str = 'm'
Scalar that represents maximally linear flow in the analysis ('m'
).
WEAK_MWP
module-attribute
¶
WEAK_MWP: str = 'w'
Scalar that represents weak polynomial flow in the analysis ('w'
).
ZERO_MWP
module-attribute
¶
ZERO_MWP: str = 'o'
Scalar that represents no dependency (0) in the analysis ('o'
).
prod_mwp
¶
prod_mwp(scalar1: str, scalar2: str) -> str
Compute product of two scalars.
\(\times\) | \(0\) | \(m\) | \(w\) | \(p\) | \(\infty\) |
---|---|---|---|---|---|
\(0\) | \(0\) | \(0\) | \(0\) | \(0\) | \(\infty\) |
\(m\) | \(0\) | \(m\) | \(w\) | \(p\) | \(\infty\) |
\(w\) | \(0\) | \(w\) | \(w\) | \(p\) | \(\infty\) |
\(p\) | \(0\) | \(p\) | \(p\) | \(p\) | \(\infty\) |
\(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scalar1 |
str
|
scalar value. |
required |
scalar2 |
str
|
scalar value. |
required |
Raises:
Type | Description |
---|---|
Exception
|
if |
Returns:
Type | Description |
---|---|
str
|
Product of scalar1 * scalar2. |
sum_mwp
¶
sum_mwp(scalar1: str, scalar2: str) -> str
Compute sum of two scalars.
\(+\) | \(0\) | \(m\) | \(w\) | \(p\) | \(\infty\) |
---|---|---|---|---|---|
\(0\) | \(0\) | \(m\) | \(w\) | \(p\) | \(\infty\) |
\(m\) | \(m\) | \(m\) | \(w\) | \(p\) | \(\infty\) |
\(w\) | \(w\) | \(w\) | \(w\) | \(p\) | \(\infty\) |
\(p\) | \(p\) | \(p\) | \(p\) | \(p\) | \(\infty\) |
\(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) | \(\infty\) |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scalar1 |
str
|
scalar value. |
required |
scalar2 |
str
|
scalar value. |
required |
Raises:
Type | Description |
---|---|
Exception
|
if |
Returns:
Type | Description |
---|---|
str
|
Sum of scalar1 + scalar2. |