From agent-almanac
Evaluates and simplifies Boolean expressions to minimal SOP/POS forms using truth tables, algebraic laws, Karnaugh maps (up to 6 variables), and verifies logical equivalence.
npx claudepluginhub pjt222/agent-almanacThis skill uses the workspace's default tool permissions.
---
Designs combinational logic circuits from truth tables, Boolean expressions, or specs into gate-level schematics using AND/OR/NOT/XOR and adders; supports NAND/NOR universality and exhaustive simulation verification.
Performs symbolic mathematics in Python using SymPy: algebraic equation solving, calculus (derivatives, integrals, limits), expression manipulation, matrices, physics, code generation. Use for exact symbolic results.
Performs symbolic math in Python using SymPy: solves equations algebraically, computes derivatives/integrals/limits, simplifies expressions, handles matrices, physics, and generates code.
Share bugs, ideas, or general feedback.
Reduce a Boolean expression to its minimal form by parsing it into canonical notation, constructing a truth table, applying algebraic simplification laws, performing Karnaugh map minimization (up to six variables), and verifying that the simplified expression is logically equivalent to the original.
A AND (B OR NOT C), A * (B + C'), A & (B | ~C))Convert the input expression into a standard internal representation:
* for AND, + for OR, ' for NOT (complement), ^ for XOR.X = X*(Y + Y').X = X + Y*Y'.## Normalized Expression
- **Variables**: [A, B, C, ...]
- **Variable count**: [n]
- **Original expression**: [as given]
- **Canonical SOP (minterms)**: Sigma m(i, j, k, ...)
- **Canonical POS (maxterms)**: Pi M(i, j, k, ...)
- **Don't-care set**: d(i, j, ...) [if any]
Expected: The expression is converted to canonical SOP and/or POS with all minterms/maxterms explicitly listed and don't-care conditions separated.
On failure: If the expression contains syntax errors or ambiguous operator precedence, request clarification. Standard precedence is: NOT (highest) > AND > XOR > OR (lowest). If the variable count exceeds 6, note that the K-map step will require the Quine-McCluskey algorithm instead.
Build the complete truth table to establish the function's behavior over all input combinations:
X instead of 0 or 1.## Truth Table
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | _ |
| 0 | 0 | 1 | _ |
| ... | ... | ... | ... |
Expected: A complete truth table with 2^n rows, outputs matching the canonical form, and don't-cares properly marked.
On failure: If the truth table disagrees with the canonical form, recheck the expansion in Step 1. A common error is misapplying De Morgan's law during the canonical expansion -- verify each expansion step individually.
Reduce the expression using Boolean algebra identities:
A + 0 = A, A * 1 = A, A + 1 = 1, A * 0 = 0.A + A = A, A * A = A.A + A' = 1, A * A' = 0.A + A*B = A, A * (A + B) = A.(A * B)' = A' + B', (A + B)' = A' * B'.A * (B + C) = A*B + A*C, A + B*C = (A + B) * (A + C).A*B + A'*C + B*C = A*B + A'*C (the B*C term is redundant).A*B' + A'*B = A ^ B.## Algebraic Simplification Trace
1. Original: [expression]
2. Apply [law name]: [result]
3. Apply [law name]: [result]
...
n. Final algebraic form: [simplified expression]
Expected: A step-by-step reduction with each law application cited, converging on a simpler expression. The trace provides a verifiable proof of equivalence.
On failure: If the expression does not simplify further but appears non-minimal, proceed to Step 4 (K-map). Algebraic methods are not guaranteed to find the global minimum -- they depend on the order in which laws are applied.
Use a K-map to find the provably minimal SOP or POS form (for up to 6 variables):
## K-map Result
- **Prime implicants**: [list with covered minterms]
- **Essential prime implicants**: [list]
- **Minimal SOP**: [expression]
- **Minimal POS**: [expression, if requested]
- **Literal count**: [number of literals in minimal form]
Expected: A minimal SOP (and/or POS) with the fewest literals possible, with all prime implicants and essential prime implicants documented.
On failure: If groupings are ambiguous (multiple minimal covers exist), list all equivalent minimal forms. If the variable count exceeds 6, switch to the Quine-McCluskey tabular method or Espresso heuristic and note the change in approach.
Confirm logical equivalence between the simplified and original expressions:
## Equivalence Verification
- **Method**: [truth table comparison / algebraic proof / both]
- **Mismatched rows**: [none, or list row numbers]
- **Verdict**: [Equivalent / Not equivalent]
- **Final minimal expression**: [the verified result]
Expected: The simplified expression matches the original on all non-don't-care inputs. The final minimal form is stated clearly.
On failure: If any row mismatches, trace the error back through Steps 3-4. Common causes: incorrect K-map grouping (non-rectangular or non-power-of-2 group), forgetting wrap-around adjacency, or accidentally grouping a 0 cell.
A + B * C as (A + B) * C instead of A + (B * C) changes the function entirely.design-logic-circuit -- map the minimized expression to a gate-level circuitargumentation -- structured logical reasoning that shares formal logic foundations