cana.primes.rof_primes module

Prime-implicant count / generation for syntactic read-once formulas.

Prime count / generate use the syntactic-ROF product-over-AND / sum-over-OR rules (AST is only the evaluation vehicle). count_rof_primes() and generate_rof_primes() assert syntactic ROF on every call via cana.function_properties.rof.

AND prime generation streams recursively (no intermediate product lists).

cana.primes.rof_primes.count_rof_primes(node)[source]

Count primes of a syntactic-ROF formula (no enumeration).

Asserts syntactic ROF. Formulas that are only semantic ROF after simplification are rejected. The AST is only the evaluation vehicle.

Parameters:

node (LogicNode | None)

Return type:

int

cana.primes.rof_primes.generate_rof_primes(node)[source]

Yield ON-set (or dualized OFF-set) primes as {var: True/False}.

Asserts syntactic ROF (AND merge via dict.update assumes disjoint variable sets). Formulas that are only semantic ROF after simplification are rejected. The AST is only the evaluation vehicle.

AND children are combined recursively without materializing full child lists via itertools.product.

Parameters:

node (LogicNode | None)

Return type:

Iterator[Dict[str, bool]]

cana.primes.rof_primes.count_on_off_primes(expr)[source]

Return (n_on_primes, n_off_primes) for expression expr.

expr must be a syntactic ROF; asserted via count_rof_primes().

Parameters:

expr (str)

Return type:

Tuple[int, int]

cana.primes.rof_primes.iter_on_off_primes(expr, polarity='on')[source]

Yield prime implicants for the ON or OFF set of expr.

expr must be a syntactic ROF; asserted via generate_rof_primes().

Parameters:
  • expr (str)

  • polarity (Literal['on', 'off'])

Return type:

Iterator[Dict[str, bool]]

class cana.primes.rof_primes.SafeNetworkPrimes(bnet_content_or_path)[source]

Bases: object

Parse a .bnet string/path and expose per-node PI counts / generators.

Count ON/OFF primes eagerly; expose lazy generators so callers can skip huge enumerations.

Each update rule must be a syntactic ROF; enforced by count_rof_primes() / generate_rof_primes().

Parameters:

bnet_content_or_path (Union[str, Path])

get_on_generator(var_name)[source]
Parameters:

var_name (str)

Return type:

Iterator[Dict[str, bool]] | None

get_off_generator(var_name)[source]
Parameters:

var_name (str)

Return type:

Iterator[Dict[str, bool]] | None

summary()[source]
Return type:

None