cana.function_generation package

Builders that generate Boolean update functions.

Cohorts mirror high-k taxonomy:

  • rof — syntactic read-once expressions

  • unate — unate but not ROF expressions

  • other — general / biased LUT generators

Expression builders produce variables a0…a{k-1} with symbolic & / |. Wrap with high_k as_bnet when a one-rule .bnet string is needed.

cana.function_generation.and_chain(k)[source]
Parameters:

k (int)

Return type:

str

cana.function_generation.or_chain(k)[source]
Parameters:

k (int)

Return type:

str

cana.function_generation.half_or_half_and(k)[source]

(a0 | … | a{k/2-1}) & a{k/2} & … & a{k-1} (even k).

Parameters:

k (int)

Return type:

str

cana.function_generation.pairwise_and_or(k)[source]

(a0 & a1) | (a2 & a3) | … (even k).

Parameters:

k (int)

Return type:

str

cana.function_generation.pairwise_or_and(k)[source]

(a0 | a1) & (a2 | a3) & … (even k).

Parameters:

k (int)

Return type:

str

cana.function_generation.majority(k)[source]

Majority-of-k: OR of every AND of size ⌊k/2⌋+1 over a0…a{k-1}.

Output is 1 iff strictly more than half of the inputs are 1. Variables repeat across terms (not a syntactic ROF). Expression size is C(k, ⌊k/2⌋+1) clauses — keep k modest.

Parameters:

k (int)

Return type:

str

cana.function_generation.makino_ibaraki(k)[source]

Makino–Ibaraki-style product-of-sums: (a0|a1|a2) & (a3|a4|a5) & ….

Width-3 rows give the classic O(3^{k/3}) prime-implicant growth for this unate / read-once family. Requires k divisible by 3.

Parameters:

k (int)

Return type:

str

cana.function_generation.random_rof(k, seed=None)[source]

Random read-once formula over a0…a{k-1} (each var once).

Parameters:
  • k (int)

  • seed (int | None)

Return type:

str

cana.function_generation.random_automata_table(indegree, bias, bias_constraint='soft')[source]

Return a random Boolean lookup table as a BitLut.

Parameters:
  • indegree (int) – Number of inputs (LUT has 2**indegree rows).

  • bias (float) – Probability of a 1 under soft / soft_no_constant, or the target fraction of ones under hard.

  • bias_constraint ({"soft", "hard", "soft_no_constant"}) – Sampling regime for the output column.

cana.function_generation.builder_accepts_k(name, k)[source]

Whether builder name is defined for input size k.

Parameters:
  • name (str)

  • k (int)

Return type:

bool

Submodules