Skip to content

Releases: TYEclipse/dsh-boolean

v0.3.0

Choose a tag to compare

@TYEclipse TYEclipse released this 23 Oct 21:52

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,
    with row / col / minterm for every cell, an essential flag, and a wraps flag for groups that
    leave one edge and re-enter on the opposite one (that is why !c is a single 4-cell group).
  • Don't-cares are drawn, not hidden: dontCare cells appear as x and groups may circle them
    (a & !b & c | a & !b & !c with dontCare [6, 7] collapses to a over 4 cells). A dontCare entry
    that is already true is drawn as 1 and 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_minimize also reports coverTerms — 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 内的格子、圈组覆盖全部最小项、
折返组的格数等于其立方体大小、格雷码每一步(含折返)只变一位。

v0.2.0 — logic_minimize (minimum sum of products, don't-cares)

Choose a tag to compare

@TYEclipse TYEclipse released this 05 Oct 21:55

v0.2.0 — 最小和之积(含无关项)

新工具 logic_minimize:把布尔表达式最小化到和之积(Quine–McCluskey)。

  • 输出素蕴含项(含覆盖的最小项与无关项)、必要素蕴含项,以及项数最少的覆盖
  • 并列时按「项数 → 文字数 → 字典序」固定判定,并用 unique 如实报告是否存在并列
  • 可选 dontCare(无关项最小项下标)=卡诺图那一招:a & !b & c | a & !b & !c 配 dontCare: [6, 7] 化简为 a
  • 恒假函数返回 ""、常数覆盖返回 1;搜索穷尽(带节点预算),预算耗尽时标 exact: false 并回退到「必要素蕴含项 + 贪心」,绝不谎称已最小
logic_minimize { expr: "((a & b) | (a & c)) | (b & c)" }
→ a & b | a & c | b & c   (3 项、6 文字,已证明最小、唯一)

logic_minimize { expr: "a & !b & c | a & !b & !c", dontCare: [6, 7] }
→ a   (1 项、1 文字;覆盖 m[4,5] 并跨过无关项 dc[6,7])

其余变更:期望值出处迁移到仓内 test/oracle/anchors.py(真值表 itertools 暴力枚举 + 最小化的穷尽集合覆盖搜索,与插件不共享任何 QMC 代码,--check 自检、--write-fixture 可逐字节重建 fixture);测试 97 → 144,覆盖率 94.57% → 96.32%。


v0.2.0 — Minimum sum of products (with don't-cares)

New tool logic_minimize: minimize a boolean expression to a sum of products (Quine–McCluskey).

  • Returns the prime implicants (with the minterms and don't-cares each one spans), the essential ones, and a cover with the fewest terms
  • Ties are broken deterministically (fewest terms → fewest literals → reading order) and reported honestly through unique
  • Optional dontCare minterm indices are the Karnaugh-map move: a & !b & c | a & !b & !c with dontCare: [6, 7] collapses to a
  • A function that is false everywhere returns "", a constant cover returns 1; the search is exhaustive under a node budget, and if the budget is ever hit the result is flagged exact: false with an essentials + greedy cover instead of a false minimality claim

Also in this release: test anchors moved into the repository (test/oracle/anchors.py) — itertools enumeration for the truth-table fixture and an exhaustive set-cover search over all cubes for minimization, sharing no Quine–McCluskey code with the plugin (--check re-verifies, --write-fixture regenerates byte-identically). Tests 97 → 144, coverage 94.57% → 96.32%.

Install

dsh plugin --profile web add github:TYEclipse/dsh-boolean

v0.1.0

Choose a tag to compare

@TYEclipse TYEclipse released this 09 Sep 21:57

dsh-boolean v0.1.0 — boolean algebra toolbox for DeepSeek Harness

Tools (4):

  • truth_table — full truth table over up to 8 variables: per-row results, minterm/maxterm indices, tautology/contradiction/satisfiability flags, canonical DNF + CNF strings
  • logic_eval — evaluate an expression under one complete assignment (trueVars / falseVars), strict about missing variables
  • logic_equiv — equivalence check over the combined table with a concrete counterexample when expressions differ
  • logic_convert — canonical conversion: nnf / dnf / cnf / nand-only / nor-only (gate networks in NAND(...)/NOR(...) call syntax)

Syntax: symbols (! & ^ | -> <->), words (not and xor or implies iff) or unicode (¬ ∧ ⊕ ∨ → ↔); single-letter variables a–z; NOT > AND > XOR > OR > IMPLIES > IFF precedence, left-associative; parentheses supported.
Zero runtime dependencies, 99 tests (anchors from an independent Python oracle), MIT.

安装 / Install: dsh plugin --profile web add github:TYEclipse/dsh-boolean