evaluate-boolean-expression
정보
이 스킬은 최대 6개의 변수를 가진 논리식을 진리표, 대수 법칙, 카르노 맵을 사용하여 평가하고 간소화합니다. 개발자가 논리식을 최소 곱의 합 또는 합의 곱 형태로 축소하고, 표현식 간의 논리적 동등성을 검증하는 데 도움을 줍니다. 디지털 논리 설계에서 게이트 수준 구현을 위해 최소화된 함수를 준비할 때 사용하세요.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/evaluate-boolean-expressionClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Evaluate Boolean Expression
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.
适用场景
- Simplifying a Boolean expression before mapping it to logic gates
- Verifying that two Boolean expressions are logically equivalent
- Generating a minimal sum-of-products (SOP) or product-of-sums (POS) form
- Teaching or reviewing Boolean algebra identities and reduction techniques
- Preparing input for the design-logic-circuit skill
输入
- 必需: Boolean expression in any common notation (e.g.,
A AND (B OR NOT C),A * (B + C'),A & (B | ~C)) - 必需: Target form -- minimal SOP, minimal POS, or both
- 可选: Variable ordering preference for the Karnaugh map
- 可选: Don't-care conditions (minterms or maxterms that are unspecified)
- 可选: A second expression to check equivalence against
步骤
第 1 步:Parse and Normalize to Canonical Form
Convert the input expression into a standard internal representation:
- Tokenize: Identify variables (single letters or short names), operators (AND, OR, NOT, XOR, NAND, NOR), and grouping (parentheses).
- Establish operator notation: Adopt a consistent notation throughout --
*for AND,+for OR,'for NOT (complement),^for XOR. - Determine variable count: List all unique variables. Assign each a bit position (A = MSB, ... Z = LSB by default, or use the provided ordering).
- Expand to canonical SOP: Expand the expression into a sum of all minterms by introducing missing variables via the identity
X = X*(Y + Y'). - Expand to canonical POS: Alternatively, expand into a product of all maxterms via
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]
预期结果: The expression is converted to canonical SOP and/or POS with all minterms/maxterms explicitly listed and don't-care conditions separated.
失败处理: 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.
第 2 步:Construct Truth Table
Build the complete truth table to establish the function's behavior over all input combinations:
- Enumerate rows: Generate all 2^n input combinations in binary counting order (000, 001, 010, ...).
- Evaluate output: For each row, substitute values into the original expression and compute the output (0 or 1).
- Mark don't-cares: If don't-care conditions were provided, mark those rows with
Xinstead of 0 or 1. - Cross-check with minterms: Verify that the rows producing output 1 match the minterm list from Step 1.
## Truth Table
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | _ |
| 0 | 0 | 1 | _ |
| ... | ... | ... | ... |
预期结果: A complete truth table with 2^n rows, outputs matching the canonical form, and don't-cares properly marked.
失败处理: 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.
第 3 步:Apply Algebraic Simplification
Reduce the expression using Boolean algebra identities:
- Identity and null laws:
A + 0 = A,A * 1 = A,A + 1 = 1,A * 0 = 0. - Idempotent law:
A + A = A,A * A = A. - Complement law:
A + A' = 1,A * A' = 0. - Absorption law:
A + A*B = A,A * (A + B) = A. - De Morgan's theorems:
(A * B)' = A' + B',(A + B)' = A' * B'. - Distributive law:
A * (B + C) = A*B + A*C,A + B*C = (A + B) * (A + C). - Consensus theorem:
A*B + A'*C + B*C = A*B + A'*C(the B*C term is redundant). - XOR simplification: Recognize patterns like
A*B' + A'*B = A ^ B. - Document each step: Write out the expression after each law application, citing the law used.
## Algebraic Simplification Trace
1. Original: [expression]
2. Apply [law name]: [result]
3. Apply [law name]: [result]
...
n. Final algebraic form: [simplified expression]
预期结果: A step-by-step reduction with each law application cited, converging on a simpler expression. The trace provides a verifiable proof of equivalence.
失败处理: 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.
第 4 步:Minimize via Karnaugh Map
Use a K-map to find the provably minimal SOP or POS form (for up to 6 variables):
- Draw the K-map: Arrange the map using Gray code ordering on axes.
- 2 variables: 2x2 grid
- 3 variables: 2x4 grid
- 4 variables: 4x4 grid
- 5 variables: two 4x4 grids (stacked)
- 6 variables: four 4x4 grids (stacked)
- Fill cells: Place 1s (minterms), 0s (maxterms), and Xs (don't-cares) in the corresponding cells.
- Group adjacent 1s: Form rectangular groups of 1, 2, 4, 8, 16, or 32 adjacent cells (powers of 2 only). Groups may wrap around edges. Include don't-cares in groups if they enlarge the group.
- Extract prime implicants: Each group yields a product term. Variables that are constant across the group appear in the term; variables that change are eliminated.
- Select essential prime implicants: Identify minterms covered by only one prime implicant -- those implicants are essential.
- Cover remaining minterms: Use the fewest additional prime implicants to cover any uncovered minterms (Petrick's method if needed).
- Write minimal expression: Combine selected prime implicants into the minimal SOP. For minimal POS, group the 0s instead.
## 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]
预期结果: A minimal SOP (and/or POS) with the fewest literals possible, with all prime implicants and essential prime implicants documented.
失败处理: 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.
第 5 步:Verify Simplified Expression Matches Original
Confirm logical equivalence between the simplified and original expressions:
- Truth table comparison: Evaluate the simplified expression for all 2^n input combinations and compare against the truth table from Step 2. Every non-don't-care row must match.
- Algebraic proof (optional): Derive the original from the simplified form (or vice versa) using the laws from Step 3.
- Spot-check critical cases: Verify the all-zeros input, all-ones input, and any input that was involved in a tricky simplification step.
- Document result: State whether equivalence holds and record the final minimal form.
## 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]
预期结果: The simplified expression matches the original on all non-don't-care inputs. The final minimal form is stated clearly.
失败处理: 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.
验证清单
- All variables in the original expression are accounted for
- Canonical SOP/POS lists the correct minterms/maxterms
- Truth table has exactly 2^n rows with correct outputs
- Don't-care conditions are handled correctly (included in groups but not in coverage requirements)
- Algebraic steps each cite a specific law and are individually verifiable
- K-map uses Gray code ordering on both axes
- All groups in the K-map are rectangular and have power-of-2 size
- Essential prime implicants are correctly identified
- Simplified expression matches the original on all non-don't-care inputs
- The final form has the minimum number of literals
常见问题
- Incorrect K-map adjacency: Forgetting that the leftmost and rightmost columns (and top and bottom rows) are adjacent in a K-map. This wrap-around is essential for finding the largest possible groups.
- Non-power-of-2 groups: Grouping 3 or 5 cells together. Every K-map group must contain exactly 1, 2, 4, 8, 16, or 32 cells. An irregular group does not correspond to a valid product term.
- Ignoring don't-cares: Treating don't-care conditions as 0s instead of using them to enlarge groups. Don't-cares should be included in groups when doing so reduces the expression, but they must not be required for coverage.
- Operator precedence errors: Assuming AND and OR have equal precedence. Standard Boolean precedence is NOT > AND > OR. Misreading
A + B * Cas(A + B) * Cinstead ofA + (B * C)changes the function entirely. - Stopping at algebraic simplification: Algebraic methods may find a local minimum, not the global minimum. Always cross-check with a K-map (or Quine-McCluskey for >6 variables) to confirm minimality.
- Confusing minterms and maxterms: Minterms are AND terms (product terms) that appear in SOP; maxterms are OR terms (sum terms) that appear in POS. Minterm m3 for 3 variables is A'BC; maxterm M3 is A+B'+C'.
相关技能
design-logic-circuit-- map the minimized expression to a gate-level circuitargumentation-- structured logical reasoning that shares formal logic foundations
GitHub 저장소
연관 스킬
executing-plans
디자인executing-plans 스킬은 검토 체크포인트가 포함된 통제된 배치로 실행할 완전한 구현 계획이 있을 때 사용합니다. 이 스킬은 계획을 불러와 비판적으로 검토한 후, 소규모 배치(기본값 3개 작업)로 작업을 실행하면서 각 배치 사이에 진행 상황을 아키텍트 검토를 위해 보고합니다. 이를 통해 내재된 품질 관리 체크포인트를 갖춘 체계적인 구현이 보장됩니다.
requesting-code-review
디자인이 스킬은 코드 변경 사항을 요구 사항에 따라 분석하기 위해 코드 리뷰어 하위 에이전트를 호출합니다. 작업 완료 후, 주요 기능 구현 후, 또는 메인 브랜치에 병합하기 전에 사용해야 합니다. 이 리뷰는 현재 구현체와 원래 계획을 비교하여 문제를 조기에 발견하는 데 도움이 됩니다.
connect-mcp-server
디자인이 스킬은 개발자들이 HTTP, stdio 또는 SSE 전송 방식을 통해 MCP 서버를 Claude Code에 연결하는 포괄적인 가이드를 제공합니다. GitHub, Notion 및 사용자 정의 API와 같은 외부 서비스를 통합하기 위한 설치, 구성, 인증 및 보안을 다룹니다. MCP 통합 설정, 외부 도구 구성 또는 Claude의 모델 컨텍스트 프로토콜 작업 시 활용하세요.
web-cli-teleport
디자인이 스킬은 작업 분석을 기반으로 개발자가 Claude Code 웹 인터페이스와 CLI 인터페이스 중 선택할 수 있도록 돕고, 두 환경 간 원활한 세션 텔레포트를 가능하게 합니다. 웹, CLI 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.
