MCP HubMCP Hub
스킬 목록으로 돌아가기

evaluate-boolean-expression

pjt222
업데이트됨 2 days ago
1 조회
17
2
17
GitHub에서 보기
디자인aidesign

정보

이 Claude 스킬은 최대 6개의 변수를 가진 부울 표현식을 진리표, 대수적 법칙, 카르노 맵을 사용하여 평가하고 단순화합니다. 표현식을 최소 곱의 합 또는 합의 곱 형태로 축소하고 논리적 동등성을 검증하도록 설계되었습니다. 개발자는 게이트 수준 구현을 위해 최소화된 함수를 준비하거나 디지털 논리의 형식적 검증이 필요할 때 사용해야 합니다.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/evaluate-boolean-expression

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Evaluate Boolean Expression

Shrink Boolean expression to smallest form: parse into canonical shape, build truth table, apply algebra laws, do Karnaugh map min (up to six vars), check new expression same logic as old.

When Use

  • Shrink Boolean expression before map to logic gates
  • Check two Boolean expressions are same logic
  • Make smallest sum-of-products (SOP) or product-of-sums (POS) form
  • Teach or review Boolean algebra rules and shrink moves
  • Prep input for design-logic-circuit skill

Inputs

  • Required: Boolean expression in any common form (e.g., A AND (B OR NOT C), A * (B + C'), A & (B | ~C))
  • Required: Target form -- min SOP, min POS, or both
  • Optional: Var order pick for Karnaugh map
  • Optional: Don't-care cases (minterms or maxterms left undefined)
  • Optional: Second expression to check same-logic against

Steps

Step 1: Parse and Normalize to Canonical Form

Turn input expression into standard inner shape:

  1. Tokenize: Spot vars (single letters or short names), ops (AND, OR, NOT, XOR, NAND, NOR), and grouping (parens).
  2. Set op notation: Pick one notation all through -- * for AND, + for OR, ' for NOT (complement), ^ for XOR.
  3. Count vars: List all unique vars. Give each bit position (A = MSB, ... Z = LSB by default, or use given order).
  4. Expand to canonical SOP: Expand expression to sum of all minterms by adding missing vars via rule X = X*(Y + Y').
  5. Expand to canonical POS: Or expand to 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]

Got: Expression turned to canonical SOP and/or POS with all minterms/maxterms listed clear and don't-care cases kept apart.

If fail: Expression has syntax errors or vague op precedence? Ask for clarity. Standard precedence: NOT (highest) > AND > XOR > OR (lowest). Var count over 6? Note K-map step will need Quine-McCluskey algorithm instead.

Step 2: Construct Truth Table

Build full truth table to pin function behavior over all input combos:

  1. List rows: Make all 2^n input combos in binary count order (000, 001, 010, ...).
  2. Evaluate output: For each row, plug values into old expression and compute output (0 or 1).
  3. Mark don't-cares: If don't-care cases given, mark those rows with X not 0 or 1.
  4. Cross-check with minterms: Confirm rows giving output 1 match minterm list from Step 1.
## Truth Table
| A | B | C | F |
|---|---|---|---|
| 0 | 0 | 0 | _ |
| 0 | 0 | 1 | _ |
| ... | ... | ... | ... |

Got: Full truth table with 2^n rows, outputs matching canonical form, don't-cares marked right.

If fail: Truth table clash with canonical form? Recheck expand in Step 1. Common slip: De Morgan's law mis-applied during canonical expand -- check each expand step one by one.

Step 3: Apply Algebraic Simplification

Shrink expression with Boolean algebra rules:

  1. Identity and null laws: A + 0 = A, A * 1 = A, A + 1 = 1, A * 0 = 0.
  2. Idempotent law: A + A = A, A * A = A.
  3. Complement law: A + A' = 1, A * A' = 0.
  4. Absorption law: A + A*B = A, A * (A + B) = A.
  5. De Morgan's theorems: (A * B)' = A' + B', (A + B)' = A' * B'.
  6. Distributive law: A * (B + C) = A*B + A*C, A + B*C = (A + B) * (A + C).
  7. Consensus theorem: A*B + A'*C + B*C = A*B + A'*C (the B*C term is extra).
  8. XOR shrink: Spot patterns like A*B' + A'*B = A ^ B.
  9. Log each step: Write expression after each law apply, name law used.
## Algebraic Simplification Trace
1. Original: [expression]
2. Apply [law name]: [result]
3. Apply [law name]: [result]
...
n. Final algebraic form: [simplified expression]

Got: Step-by-step shrink with each law apply named, going to simpler expression. Trace is checkable proof of same-logic.

If fail: Expression won't shrink more but still feels not-min? Go to Step 4 (K-map). Algebra moves not guaranteed to find global min -- depend on order of law apply.

Step 4: Minimize via Karnaugh Map

Use K-map to find provably min SOP or POS form (for up to 6 vars):

  1. Draw K-map: Set map using Gray code order 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)
  2. Fill cells: Place 1s (minterms), 0s (maxterms), Xs (don't-cares) in matching cells.
  3. Group adjacent 1s: Form rectangular groups of 1, 2, 4, 8, 16, or 32 adjacent cells (powers of 2 only). Groups can wrap around edges. Add don't-cares to groups if they make group bigger.
  4. Pull prime implicants: Each group gives product term. Vars constant across group stay in term; vars that change drop out.
  5. Pick essential prime implicants: Spot minterms covered by only one prime implicant -- those implicants are essential.
  6. Cover remaining minterms: Use fewest extra prime implicants to cover any uncovered minterms (Petrick's method if need).
  7. Write min expression: Mix picked prime implicants into min SOP. For min POS, group 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]

Got: Min SOP (and/or POS) with fewest literals, all prime implicants and essential prime implicants logged.

If fail: Groupings vague (many min covers exist)? List all same-value min forms. Var count over 6? Switch to Quine-McCluskey tabular method or Espresso heuristic; note the swap.

Step 5: Verify Simplified Expression Matches Original

Check same logic between shrunk and original expressions:

  1. Truth table compare: Eval shrunk expression for all 2^n input combos and compare vs truth table from Step 2. Every non-don't-care row must match.
  2. Algebraic proof (optional): Pull original from shrunk form (or reverse) using laws from Step 3.
  3. Spot-check key cases: Check all-zeros input, all-ones input, and any input tied to tricky shrink step.
  4. Log result: State whether same-logic holds and write final min 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]

Got: Shrunk expression matches original on all non-don't-care inputs. Final min form stated clear.

If fail: Any row mismatch? Trace error back through Steps 3-4. Common causes: wrong K-map grouping (non-rectangular or non-power-of-2 group), forget wrap-around adjacency, or slip grouping a 0 cell.

Validation

  • All vars in original expression counted
  • Canonical SOP/POS lists right minterms/maxterms
  • Truth table has exactly 2^n rows with right outputs
  • Don't-care cases handled right (added to groups but not in cover rule)
  • Algebraic steps each name a specific law and can be checked one by one
  • K-map uses Gray code order on both axes
  • All groups in K-map are rectangular and power-of-2 size
  • Essential prime implicants picked right
  • Shrunk expression matches original on all non-don't-care inputs
  • Final form has smallest number of literals

Pitfalls

  • Wrong K-map adjacency: Forget leftmost and rightmost columns (and top and bottom rows) are adjacent in K-map. This wrap-around is key for finding biggest groups.
  • Non-power-of-2 groups: Grouping 3 or 5 cells together. Every K-map group must have exactly 1, 2, 4, 8, 16, or 32 cells. Odd group not match any product term.
  • Ignore don't-cares: Treat don't-care as 0s, not use them to grow groups. Don't-cares should join groups when doing so shrinks expression, but must not be needed for cover.
  • Op precedence slip: Assume AND and OR have same precedence. Standard Boolean precedence is NOT > AND > OR. Misread A + B * C as (A + B) * C not A + (B * C) changes function full.
  • Stop at algebra shrink: Algebra moves may find local min, not global min. Always cross-check with K-map (or Quine-McCluskey for >6 vars) to confirm smallest.
  • Mix minterms and maxterms: Minterms are AND terms (product terms) in SOP; maxterms are OR terms (sum terms) in POS. Minterm m3 for 3 vars is A'BC; maxterm M3 is A+B'+C'.

See Also

  • design-logic-circuit -- map shrunk expression to gate-level circuit
  • argumentation -- structured logic reason that shares formal logic base

GitHub 저장소

pjt222/agent-almanac
경로: i18n/caveman/skills/evaluate-boolean-expression
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

연관 스킬

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 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.

스킬 보기