cana.function_outputs.one_symbol module
One-symbol (wildcard) schemata helpers.
Schemata are thin dict maps polarity 0/1 → sets of length-k
strings over {0,1,2} (2 = don’t-care). No wrapper class.
This is the public representation of prime covers for
BooleanFunction. Named PrimeDict cubes
remain algorithm-internal inside cana.primes; convert at the boundary
with primes_to_one_symbol() /
one_symbol_to_primes().
- cana.function_outputs.one_symbol.reorder(schemata, old_labels, new_labels)[source]
Return a copy with schema character positions remapped to
new_labels.Labels identify the
kinput variables in MSB-first bit order (same convention asreorder()).new_labelsmust be a permutation ofold_labels. If the orders already match, returnsschemataunchanged.- Parameters:
schemata (Dict[int, Set[str]])
old_labels (Sequence[object])
new_labels (Sequence[object])
- Return type:
Dict[int, Set[str]]
- cana.function_outputs.one_symbol.one_symbol_to_bit_lut(schemata, k)[source]
Build a
BitLutfrom one-symbol schemata.- Raises:
ValueError – If
kexceedsMAX_DENSE_LUT_K, or on polarity conflicts or incomplete coverage of the2**krows. Incomplete covers are not filled with a default output value.- Parameters:
schemata (Dict[int, Set[str]])
k (int)
- Return type:
- cana.function_outputs.one_symbol.bit_lut_to_one_symbol(bit_lut)[source]
Run Quine-McCluskey on
bit_lut; return one-symbol schemata.- Parameters:
bit_lut (BitLut)
- Return type:
Dict[int, Set[str]]
- cana.function_outputs.one_symbol.primes_to_one_symbol(on_primes, off_primes, *, input_names=None, k=None)[source]
Convert named ON/OFF prime cubes to positional one-symbol schemata.
input_names defaults to
positional_names(k). When k is omitted it is inferred from input_names, else from the union of prime keys (sorted).- Parameters:
on_primes (List[Dict[str, bool]])
off_primes (List[Dict[str, bool]])
input_names (Sequence[str] | None)
k (int | None)
- Return type:
Dict[int, Set[str]]
- cana.function_outputs.one_symbol.one_symbol_to_primes(schemata, input_names)[source]
Convert one-symbol schemata to named ON/OFF prime-cube lists.
- Parameters:
schemata (Dict[int, Set[str]])
input_names (Sequence[str])
- Return type:
Tuple[List[Dict[str, bool]], List[Dict[str, bool]]]
- cana.function_outputs.one_symbol.positional_expression_to_one_symbol(expr, k)[source]
Derive one-symbol schemata from a positional boolean expression.
Tries the expression cascade (syntactic ROF, then Primer-B) without building a dense LUT. On cascade failure, falls back to building a BitLut (subject to
MAX_DENSE_LUT_K) then Quine–McCluskey.- Parameters:
expr (str)
k (int)
- Return type:
Dict[int, Set[str]]
- cana.function_outputs.one_symbol.one_symbol_to_expression(input_names, schemata, style='python')[source]
Build a DNF expression from a one-symbol ON cover (polarity
1).Schema characters:
1→ literal,0→ negated literal,2→ don’t-care (omitted). Incomplete covers are still exported as the positive DNF of whatever ON schemas are present (no LUT materialization).Positional vs named is chosen by
input_names: passpositional_names()(k)for positional IR, or input names for a named expression.- Parameters:
input_names (Sequence[str]) – Variable names in schema bit order (MSB first).
schemata (Dict[int, Set[str]]) – One-symbol map polarity → set of length-
kschemas.style (str) –
"python"or"symbolic".
- Return type:
str