logic-programmer skill
논리 기반 프로그래밍 언어를 위한 관계형 설계 원칙과 선언적 사고 패턴에 대한 가이드를 제공합니다.
- GitHub 스타
- 9
- 파일
- 1
- 마지막 커밋
- 2026년 10월 13일
- 라이선스
- EPL-2.0
- 허용된 도구
- —
logic-programmer skill은 무엇을 하나요?
logic-programmer은(는) agent skill입니다. 논리 기반 프로그래밍 언어를 위한 관계형 설계 원칙과 선언적 사고 패턴에 대한 가이드를 제공합니다.
skill의 SKILL.md에서 생성된 요약입니다.
logic-programmer skill 정보
논리 기반 언어를 사용하는 개발자는 이 SKILL을 활용하여 코드에 관계형 설계 원칙과 선언적 사고 패턴을 적용할 수 있습니다. Prolog, miniKanren, Datalog, OWL2, Mercury 또는 Answer Set Programming을 사용하는 개발자에게 가이드를 제공합니다. 특히 제약 충족 문제나 조합 탐색 문제를 다룰 때, 문제가 절차적 알고리즘보다 선언적 명세에 더 적합한지 판단하는 데 도움을 줍니다.
사용자는 이 SKILL을 통해 Open World Assumption 대 Closed World Assumption, 또는 단조 추론(monotonic reasoning) 대 비단조 추론(non-monotonic reasoning)과 같은 복잡한 개념을 파악할 수 있습니다. 또한 양방향 관계를 설계하고 선언적 의미론과 실행 의미론의 차이를 이해하는 데 도움을 줍니다. 이 SKILL을 로드하면 에이전트가 확장 가능한 재귀 쿼리를 위한 Datalog 사용이나 계획 및 구성 작업을 위한 Answer Set Programming 사용 등 개발자가 올바른 패러다임을 선택할 수 있도록 지원합니다.
agent가 수행할 수 있는 작업
- 1논리 프로그래밍 패러다임 선택특정 프로젝트 요구 사항에 따라 Prolog, Datalog, OWL2 또는 Answer Set Programming 중 무엇을 사용할지 결정하도록 도와줍니다.
- 2관계형 설계 적합성 평가문제를 관계형 사고로 해결해야 하는지 또는 표준 절차적 알고리즘으로 해결해야 하는지 판단합니다.
- 3양방향 관계 설계검사, 순방향 또는 역방향 모드와 같이 여러 계산 방향으로 사용될 수 있도록 관계를 설계하는 방법을 조언합니다.
- 4지식 베이스 가정 관리데이터의 완전성을 바탕으로 시스템이 Closed World 또는 Open World Assumption 중 무엇을 사용해야 하는지 설명합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
logic-programmer skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.플러그인에 logic-programmer skill 설치
/plugin marketplace add Pyroxin/opinionated-claude-skills /plugin install opinionated-software-engineering@opinionated-claude-skills
Claude Code에 logic-programmer skill 설치
~/.claude/skills/logic-programmer/SKILL.md
$ npx degit Pyroxin/opinionated-claude-skills/opinionated-software-engineering/skills/logic-programmer ~/.claude/skills/logic-programmerClaude Code (project)에 logic-programmer skill 설치
.claude/skills/logic-programmer/SKILL.md
$ npx degit Pyroxin/opinionated-claude-skills/opinionated-software-engineering/skills/logic-programmer .claude/skills/logic-programmerCodex에 logic-programmer skill 설치
~/.agents/skills/logic-programmer/SKILL.md
$ npx degit Pyroxin/opinionated-claude-skills/opinionated-software-engineering/skills/logic-programmer ~/.agents/skills/logic-programmerGemini CLI에 logic-programmer skill 설치
~/.gemini/skills/logic-programmer/SKILL.md
$ npx degit Pyroxin/opinionated-claude-skills/opinionated-software-engineering/skills/logic-programmer ~/.gemini/skills/logic-programmerClaude.ai에 logic-programmer skill 설치
npx degit Pyroxin/opinionated-claude-skills/opinionated-software-engineering/skills/logic-programmer logic-programmer && zip -r logic-programmer.zip logic-programmer # claude.ai → Customize → Skills → + → Create skill → Upload a skill → logic-programmer.zip
SKILL.md
GitHub에서 보기Logic Programmer
Purpose
This skill provides guidance on logic programming thinking patterns and when relational, declarative approaches clarify problems. Logic programming expresses computation as logical inference over relations rather than procedural steps. This skill focuses on recognizing when problems are naturally relational, designing declarative specifications, and understanding the trade-offs of different logic programming approaches.
When to Use This Skill
Use this skill when:
- Working with logic languages (Prolog, miniKanren, Datalog, OWL2, Mercury, Answer Set Programming)
- Solving constraint satisfaction or combinatorial search problems
- Designing knowledge bases, ontologies, or inference systems
- Applying relational thinking to queries and pattern matching
- Recognizing when declarative specification clarifies over procedural algorithm
<core_philosophy>
Core Philosophy
<relational_thinking_decision>
Relational Thinking: When It Clarifies vs When It Obscures
Logic programming thinks in terms of relationships that must hold, not steps to execute. The key question: does relational thinking make the problem clearer?
Relational thinking clarifies when:
- Problem is naturally expressed as constraints (what must be true, not how to compute)
- Multiple computational directions needed (bidirectional relations)
- Specification is more important than algorithm (declarative rules)
- Querying relationships in structured data
- Generating multiple solutions from constraints
Relational thinking obscures when:
- Clear, efficient procedural algorithm exists
- Single computational direction suffices
- Stateful, imperative operations required
- Performance-critical numeric computation
- Procedural version is obviously simpler
Staff insight: Don't force problems into relational form. The power of logic programming is clarity through declarative specification. If the relational version is harder to understand than the procedural version, you're using the wrong paradigm. </relational_thinking_decision>
"Algorithm = Logic + Control" — Robert Kowalski (1979)
An algorithm consists of logic (what to compute) and control (how to compute it). Ideal logic programming separates these; pragmatic logic programming often requires considering both.
<declarative_vs_procedural>
Declarative Specification Over Procedural Algorithm
Express what must be true, not how to compute it. Describe the problem constraints and let the system find solutions.
Declarative thinking:
- State facts and rules
- Define relationships and constraints
- Specify valid solutions
- Let inference engine/solver find them
When declarative specifications win:
- Problem is easier to specify than to solve algorithmically
- Multiple solving strategies could work (system can choose/optimize)
- Specification itself is valuable documentation
- Constraints change more often than solving strategy
When procedural algorithms win:
- Algorithm is well-understood and efficient
- Declarative version doesn't provide insight
- Performance matters and declarative overhead isn't justified
- System can't efficiently solve the declarative formulation </declarative_vs_procedural>
Relations can work in multiple computational directions. The same logical specification can answer different questions.
Example: append(Xs, Ys, Zs) defines relationship between three lists
- Forward: Given Xs and Ys, what is Zs?
- Backward: Given Zs, what are all ways to split into Xs and Ys?
- Checking: Does this (Xs, Ys, Zs) triple satisfy the relation?
Design question: Which computational directions are actually useful?
Don't over-design: Not all relations need to work in all directions. Design for modes you'll use. Document restrictions if they exist. </core_philosophy>
Fundamental Principles
Open vs Closed World Assumption
Closed World Assumption (CWA): What is not known to be true is false.
- Prolog, Datalog: If a fact isn't derivable, it's false
- Enables negation-as-failure
- Practical for databases and closed systems
Open World Assumption (OWA): Unknown is unknown, not false.
- OWL2, description logics: Absence of information means unknown
- Cannot conclude negatives from missing information
- Appropriate for incomplete knowledge (web, distributed systems)
Design question: What does absence of information mean in your domain?
Monotonic vs Non-Monotonic Reasoning
Monotonic: Adding facts never invalidates previous conclusions.
- First-order logic, Datalog, OWL2
- Conclusions remain valid as knowledge grows
- Reasoning is sound and complete within the logic
Non-monotonic: New facts can retract previous conclusions.
- Prolog with negation-as-failure
- Answer Set Programming (stable model semantics)
- Default reasoning, exceptions
- More flexible but more complex semantics
Design question: Does your domain require defaults and exceptions?
Declarative Semantics vs Operational Semantics
Declarative semantics: What the program means (logical interpretation)
- Independent of execution strategy
- Focus on correctness of specification
- Easier to reason about
Operational/procedural semantics: How the program executes
- Search strategy, evaluation order
- Performance characteristics
- Implementation-dependent
Fully declarative systems: Datalog, OWL2, Answer Set Programming separate logic from control
- Programmer specifies logic
- System chooses evaluation strategy
- Order doesn't affect meaning (only efficiency)
Procedural systems: Prolog, miniKanren require considering execution
- Clause order, goal order affect termination and efficiency
- Same logical meaning, different operational behavior
- Programmer must understand search strategy
Staff insight: Know whether your logic language is declarative or procedural. Declarative systems free you from execution concerns; procedural systems require understanding search behavior.
When Logic Programming Works Well
Problem characteristics that favor logic programming:
Constraint satisfaction and combinatorial search:
- Problem defined by constraints on valid solutions
- Multiple solutions exist
- Search or optimization required
- Examples: Scheduling, puzzles, configuration, planning
Knowledge representation and inference:
- Rules and facts model domain knowledge
- Inference derives implicit information
- Querying relationships
- Examples: Expert systems, semantic web (OWL2), business rules
Relational queries over structured data:
- Data represents entities and relationships
- Queries involve joins, filtering, graph traversal
- Datalog for recursive queries
- Examples: Graph databases, dependency analysis, program analysis
Symbolic computation and pattern matching:
- Structural pattern matching
- Term rewriting
- Parsing and grammar-based processing
- Examples: Definite Clause Grammars, type inference
When specification is more important than algorithm:
- Domain experts can write/verify rules
- Requirements change frequently
- Correctness matters more than peak performance
- Declarative specification serves as executable documentation
When Logic Programming Struggles
Avoid logic programming when:
Clear procedural algorithm exists:
- Well-understood, efficient algorithm
- Single computational direction
- Procedural version is simpler
- Examples: Sorting, hashing, standard algorithms
Performance-critical numeric computation:
- Arithmetic-heavy, tight loops
- Matrix operations, scientific computing
- Logic programming overhead not justified
- Examples: Graphics, signal processing, machine learning
Stateful, imperative operations:
- Mutable state, I/O, side effects
- Event-driven systems
- Imperative frameworks
- Examples: GUI programming, file systems, most I/O
Large-scale data transformation:
- ETL pipelines, data processing
- Streaming data
- Functional or SQL better suited
- Examples: Big data analytics, data warehousing
Staff-Level Insights
<paradigm_selection>
Understanding Different Logic Programming Paradigms
| Paradigm | Execution Model | Best For |
|---|---|---|
| Prolog | Top-down, depth-first | Control matters, parsing, expert systems |
| Datalog | Bottom-up, set-oriented | Scalable queries, program analysis |
| OWL2/Description Logics | Tableau algorithms | Ontologies, semantic web, open-world |
| Answer Set Programming | Stable model semantics | Planning, configuration, non-monotonic |
<prolog_family> Prolog family (procedural logic programming):
- Top-down, depth-first search with backtracking
- Programmer must consider search order, termination
- Cuts commit to choices, break declarative purity
- Requires understanding operational semantics
- Use for: Symbolic AI, parsing, expert systems where control matters </prolog_family>
<description_logics> Description Logics (OWL2, etc.):
- Open world assumption
- Decidable fragments of first-order logic
- Focus on classification and subsumption
- Reasoning services (consistency, entailment)
- Use for: Ontologies, semantic web, knowledge graphs </description_logics>
<answer_set_programming> Answer Set Programming (ASP):
- Stable model semantics
- Non-monotonic reasoning (defaults, exceptions)
- Declarative problem solving
- Use for: Planning, configuration, complex constraint problems </answer_set_programming>
Staff insight: Choose the right logic paradigm for your problem. Prolog when you need control, Datalog for scalable queries, OWL2 for open-world reasoning, ASP for non-monotonic domains. </paradigm_selection>
Designing for Bidirectionality
Not all modes of a relation work equally well. Some modes may not terminate, some may be inefficient.
Design considerations:
- Which computational directions are actually needed?
- Does the relation terminate in all intended modes?
- Are some modes inherently less efficient?
- Should mode restrictions be documented?
Example: List concatenation
- append(+List1, +List2, -Result): Efficient, deterministic
- append(-List1, -List2, +Result): Generates all splits, nondeterministic
- append(-X, -Y, -Z): Generates infinite triples (often not useful)
Guideline: Design for modes you need. Don't sacrifice clarity or efficiency for modes you'll never use.
Negation and Its Complexities
Negation-as-failure (closed world):
- Prolog:
\+ Goalsucceeds if Goal fails - Not true logical negation (lacks soundness)
- Depends on search order
- Can give unexpected results
Classical negation (open world):
- OWL2: Explicit negative assertions
- Sound but incomplete (unknown ≠ false)
- Cannot conclude negatives from absence
Answer Set Programming:
- Both classical negation and negation-as-failure
- Stable model semantics
- More expressive but more complex
Staff insight: Understand what negation means in your logic language. Closed-world negation is pragmatic but unsound; open-world negation is sound but incomplete.
Constraint Logic Programming (CLP)
Extend logic programming with constraint domains for more efficient problem solving.
Key domains:
- CLP(FD): Finite domains (integers with constraints)
- CLP(R/Q): Real/rational arithmetic
- CHR: Constraint Handling Rules (custom constraint solvers)
When CLP matters:
- Constraint satisfaction problems
- Optimization (minimize/maximize objectives)
- Complex domain constraints
- Search is too slow without constraint propagation
Staff insight: CLP moves constraint solving from search (generate-and-test) to propagation (constraint narrowing). For constraint-heavy problems, this is orders of magnitude faster.
The Purity vs Efficiency Trade-off
Pure logic programming separates logic from control. Pragmatic systems offer control features for efficiency.
Purity sacrifices:
- Control features (cuts in Prolog, goal ordering)
- Procedural predicates (assert/retract)
- Extra-logical features (I/O, arithmetic evaluation)
- Mode-specific optimizations
When to sacrifice purity:
- Performance bottlenecks identified through profiling
- Deterministic code paths where backtracking wastes work
- Integration with imperative systems (I/O, external calls)
When to maintain purity:
- Reusable, multi-mode relations
- Correctness is paramount
- Code clarity and maintainability
- Using fully declarative systems (Datalog, OWL2)
Staff insight: Start pure, add pragmatic features when profiling shows need. Measure before optimizing. Consider if performance problems indicate wrong paradigm choice.
Execution Model Orientation (Brief)
Different logic languages have different execution models. Understanding these helps orient when working with a new system:
Prolog-style (top-down, depth-first):
- Depth-first search with backtracking
- Left-to-right goal selection
- Clause order and goal order matter
- Requires understanding search behavior
- Can diverge (infinite loops)
Datalog-style (bottom-up, set-oriented):
- Bottom-up evaluation (materialization)
- Order-independent
- Terminates on finite data
- Optimized for large datasets
- More restricted but more declarative
OWL2/Description Logics:
- Tableau algorithms, resolution
- Decidable reasoning (sound and complete for fragments)
- Open world assumption
- Classification and subsumption reasoning
- Optimized for ontological reasoning
Answer Set Programming:
- Stable model semantics
- Find models that satisfy constraints
- Non-monotonic (defaults, exceptions)
- Declarative problem encoding
When learning a new logic language: Identify its execution model to understand what you control vs what the system controls.
<common_mistakes_by_background>
Common Mistakes from Imperative and Procedural Backgrounds
Programmers from procedural or object-oriented backgrounds often struggle with relational thinking:
<from_imperative_background> Writing procedural code in declarative language:
- Mistake: Step-by-step instructions instead of logical constraints
- Fix: Describe what must be true, not how to compute it. Specify relations, not procedures
Not thinking relationally:
- Mistake: Functions that work one direction when bidirectional relations would work
- Fix: Ask: "What are all the ways this relationship could hold?" Design for useful modes
Using assert/retract for state instead of relations:
- Mistake: Mutating fact database like global variables
- Fix: Thread state through relations or use constraint solving. Assert/retract breaks declarativeness
Not leveraging backtracking for search:
- Mistake: Explicitly coding search and pruning
- Fix: Specify constraints, let backtracking search. Generate-and-test is a valid pattern
Sequential thinking instead of declarative specification:
- Mistake: Ordering goals as if they're sequential steps
- Fix: In fully declarative systems (Datalog, ASP), order doesn't matter. In Prolog, order affects efficiency not correctness
Not using pattern matching effectively:
- Mistake: Testing and extracting parts manually
- Fix: Pattern match in clause heads. Let unification do the work
Writing deterministic predicates when nondeterminism would work:
- Mistake: Forcing single-solution code when multiple solutions are natural
- Fix: Embrace nondeterminism. Backtracking generates solutions automatically </from_imperative_background>
<from_oop_background> From Object-Oriented Backgrounds:
Trying to create class-like structures:
- Mistake: Complex predicate bundles mimicking objects
- Fix: Relations are not methods. Data structures are terms, operations are relations over terms
Thinking about methods instead of relations:
- Mistake:
user.getName()thinking instead ofuserName(User, Name)relations - Fix: Relations connect entities. No owner, just participants
Not leveraging unification:
- Mistake: Explicit equality tests and variable assignment
- Fix: Unification happens automatically in clause heads and
=. Use it </from_oop_background>
<from_fp_background> From Functional Programming Backgrounds:
Forcing functional patterns when relations are clearer:
- Mistake: map/filter/reduce when relational query is more direct
- Fix: If problem is naturally relational, use relations. Don't transform to functional style
Not using search and constraint solving:
- Mistake: Writing explicit search algorithms
- Fix: Specify constraints, use CLP or built-in search. Let solver handle combinatorics
Thinking about transformations instead of relations:
- Mistake: Pipeline thinking when bidirectional relations work
- Fix: Relations aren't functions. They describe what holds, not what transforms to what </from_fp_background> </common_mistakes_by_background>
<related_skills>
Related Skills
- software-engineer — Core engineering philosophy and system design
- swi-prolog-programmer — SWI-Prolog-specific tooling, PlUnit testing, DCGs
- functional-programmer — When functional approaches are clearer (transformations, pipelines)
- object-oriented-programmer — When stateful entities need encapsulation </related_skills>
Documentation:
- SWI-Prolog: https://www.swi-prolog.org/pldoc/
- W3C OWL2: https://www.w3.org/TR/owl2-overview/
- Clingo (ASP): https://potassco.org/clingo/
For SWI-Prolog-specific guidance (testing, tooling, libraries), see the swi-prolog-programmer skill.
Summary
Logic programming emphasizes:
- Relational thinking — When it clarifies problems vs when procedural is simpler
- Declarative specification — What must be true, not how to compute
- Bidirectional computation — Relations work in multiple modes (when useful)
- Constraints over algorithms — Let solver find solutions
Apply logic programming when problems are naturally relational, require constraint solving, benefit from declarative specification, or involve knowledge representation and inference. Use other paradigms when algorithms are deterministic, performance-critical, stateful, or when procedural thinking is clearer. Success comes from recognizing problem characteristics that match the paradigm's strengths.
이 스킬의 파일
1logic-programmer skill 질문
Claude Code에 logic-programmer skill을 어떻게 설치하나요?
npx degit Pyroxin/opinionated-claude-skills/opinionated-software-engineering/skills/logic-programmer ~/.claude/skills/logic-programmer를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
logic-programmer skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
절차적 알고리즘 대신 관계형 사고를 사용해야 하는 경우는 언제인가요?
문제가 자연스럽게 제약 조건으로 표현되거나, 여러 방향의 계산이 필요하거나, 알고리즘보다 명세(specification)가 더 중요한 경우에 관계형 사고가 유용합니다.