Skip to content

Semantics

opulse.core.semantics

Value domain and base operations (docs/reference/semantics.md, sections 1-3).

Every backend gets its base operations from :class:Semantics, so there is a single implementation of the arithmetic. Values are Python ints or the undefined value :data:NAN.

Semantics dataclass

Numeric mode, bound and optional modulus; builds base operations.

check

check(value: int)

Apply the bound to a base-operation result (section 2).

operations

operations() -> dict[str, Callable]

Semantic name -> function on V (section 3); defined is the NaN exception.

trunc_div

trunc_div(a: int, b: int) -> int

Quotient rounded toward zero; b must be non-zero.

reverse_digits

reverse_digits(n: int) -> int

Decimal digits of a non-negative n reversed (leading zeros dropped).