Repository navigation
v0.3.0 — Karnaugh-map layout (logic_kmap)
logic_minimize tells you the answer; logic_kmap now shows you the map it came from. The new tool
lays the function out on Gray-coded axes (1–4 variables, cells 1 / x / 0) and maps every term
of the minimal cover back to the cells it circles — so a hand grouping can be reproduced and checked
instead of trusted:
logic_kmap { expr: "a & !b | a & c" }
K-map of a & !b | a & c over 3 variable(s) (rows a | cols b, c)
00 01 11 10
0 | 0 0 0 0
1 | 1 1 1 0
minimal cover: a & !b | a & c
a & !b: 2 cell(s) — r1c0(m4) r1c1(m5) [essential, contiguous]
a & c: 2 cell(s) — r1c1(m5) r1c2(m7) [essential, contiguous]
- Groups are the cover, not the catalogue: each group is one term of the returned minimal cover,
withrow/col/mintermfor every cell, anessentialflag, and awrapsflag for groups that
leave one edge and re-enter on the opposite one (that is why!cis a single 4-cell group). - Don't-cares are drawn, not hidden:
dontCarecells appear asxand groups may circle them
(a & !b & c | a & !b & !cwithdontCare [6, 7]collapses toaover 4 cells). AdontCareentry
that is already true is drawn as1and the result says so. - Honest limits: 5+ variables are refused by name (a map grid stops being readable) with a pointer to
logic_minimize; a contradiction is an all-zero map with no groups; a tautology is one all-free group. logic_minimizealso reportscoverTerms— which prime implicants actually form the answer, in answer
order — so the two tools can be cross-checked term by term.
Tests 144 → 168, coverage 96.32% → 96.95% (baseline ratcheted up). The in-repo oracle
(test/oracle/anchors.py) gained a K-map section that lays the map out independently in Python plus
--check invariants: every minterm appears exactly once, groups only circle cells inside on ∪ dc,
the groups cover the on-set, a wrapping group's cell count matches its cube, and Gray order changes
exactly one bit per step including the wrap.
v0.3.0 — 卡诺图布局(logic_kmap)
logic_minimize 给答案,logic_kmap 现在把答案画回图上:新工具把函数铺到格雷码坐标(1–4 变量,
格子里是 1 / x / 0),并把最小覆盖的每一项反查回它圈到的格子——手画的圈可以被复现和核对,
而不是只能凭信任。
- 圈的是覆盖,不是目录:每组对应返回覆盖里的一项,逐格给出
row/col/minterm,附essential
标记;跨边界折返的组标wraps(!c在三变量下就是一个 4 格组)。 - 无关项画出来、不藏起来:
dontCare画成x,圈组可以把它们圈进来;本来就已为真的无关项画成1
并在结果里说明。 - 限制如实报:5 变量以上直接点名拒绝(网格不再可读)并指向
logic_minimize;矛盾式是全 0 图、
无圈组;重言式是一个覆盖全图的组。 logic_minimize同时给出coverTerms(到底用了哪几项素蕴含项,按答案顺序),两个工具可逐项对账。
测试 144 → 168,覆盖率 96.32% → 96.95%(基线已上抬)。随仓 oracle 增加卡诺图区(Python 独立布局)
与 --check 不变量:每个最小项恰好出现一次、圈组只圈 on ∪ dc 内的格子、圈组覆盖全部最小项、
折返组的格数等于其立方体大小、格雷码每一步(含折返)只变一位。