cana.primes.cascade module

Expression-only prime cascade: syntactic ROF, then PySAT Primer-B.

Does not build a dense LUT or run Quine–McCluskey; callers that need a LUT/QM fallback (e.g. get_one_symbol_schemata()) handle that separately after an unsuccessful cascade.

When the Primer-B path is reached but pysat (python-sat) is missing, a UserWarning is emitted before returning status="unsuccessful" (so LUT/QM fallback is not silent about the skipped Primer attempt).

No wall-clock timeout — structural caps only (max_primes, nesting).

class cana.primes.cascade.PrimesResult(status, method=None, on_primes=None, off_primes=None, n_on=None, n_off=None, message='')[source]

Bases: object

Outcome of on_off_primes_from_expression().

Parameters:
  • status (Literal['ok', 'too_many', 'refused', 'error', 'unsuccessful'])

  • method (Literal['rof', 'primer'] | None)

  • on_primes (List[Dict[str, bool]] | None)

  • off_primes (List[Dict[str, bool]] | None)

  • n_on (int | None)

  • n_off (int | None)

  • message (str)

status: Literal['ok', 'too_many', 'refused', 'error', 'unsuccessful']
method: Literal['rof', 'primer'] | None = None
on_primes: List[Dict[str, bool]] | None = None
off_primes: List[Dict[str, bool]] | None = None
n_on: int | None = None
n_off: int | None = None
message: str = ''
property ok: bool
as_on_off()[source]
Return type:

Tuple[List[Dict[str, bool]], List[Dict[str, bool]]]

cana.primes.cascade.on_off_primes_from_expression(expr, *, max_primes=1000000)[source]

Try syntactic ROF, then Primer-B; never builds a LUT or runs QM.

Parameters:
  • expr (str) – Boolean expression (python or symbolic operators).

  • max_primes (int) – Cap on ON+OFF (ROF) or per-polarity (Primer) prime counts.

Returns:

Soft guardrail hits use status rather than raising, so callers can fall through to a LUT/QM path.

Return type:

PrimesResult