opinionated-software-engineering/skills/logic-programmer/SKILL.md
Logic programming thinking patterns and relational design principles. Use when working with logic languages (Prolog, miniKanren, Datalog, OWL2, Answer Set Programming) or applying declarative, constraint-based approaches in multi-paradigm systems.
npx skillsauth add pyroxin/opinionated-claude-skills logic-programmerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
Use this skill when:
<core_philosophy>
<relational_thinking_decision>
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:
Relational thinking obscures when:
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>
Express what must be true, not how to compute it. Describe the problem constraints and let the system find solutions.
Declarative thinking:
When declarative specifications win:
When procedural algorithms win:
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
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. </bidirectionality> </core_philosophy>
Closed World Assumption (CWA): What is not known to be true is false.
Open World Assumption (OWA): Unknown is unknown, not false.
Design question: What does absence of information mean in your domain?
Monotonic: Adding facts never invalidates previous conclusions.
Non-monotonic: New facts can retract previous conclusions.
Design question: Does your domain require defaults and exceptions?
Declarative semantics: What the program means (logical interpretation)
Operational/procedural semantics: How the program executes
Fully declarative systems: Datalog, OWL2, Answer Set Programming separate logic from control
Procedural systems: Prolog, miniKanren require considering execution
Staff insight: Know whether your logic language is declarative or procedural. Declarative systems free you from execution concerns; procedural systems require understanding search behavior.
Problem characteristics that favor logic programming:
Constraint satisfaction and combinatorial search:
Knowledge representation and inference:
Relational queries over structured data:
Symbolic computation and pattern matching:
When specification is more important than algorithm:
Avoid logic programming when:
Clear procedural algorithm exists:
Performance-critical numeric computation:
Stateful, imperative operations:
Large-scale data transformation:
<paradigm_selection>
| 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):
<description_logics> Description Logics (OWL2, etc.):
<answer_set_programming> Answer Set Programming (ASP):
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>
Not all modes of a relation work equally well. Some modes may not terminate, some may be inefficient.
Design considerations:
Example: List concatenation
Guideline: Design for modes you need. Don't sacrifice clarity or efficiency for modes you'll never use.
Negation-as-failure (closed world):
\+ Goal succeeds if Goal failsClassical negation (open world):
Answer Set Programming:
Staff insight: Understand what negation means in your logic language. Closed-world negation is pragmatic but unsound; open-world negation is sound but incomplete.
Extend logic programming with constraint domains for more efficient problem solving.
Key domains:
When CLP matters:
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.
Pure logic programming separates logic from control. Pragmatic systems offer control features for efficiency.
Purity sacrifices:
When to sacrifice purity:
When to maintain purity:
Staff insight: Start pure, add pragmatic features when profiling shows need. Measure before optimizing. Consider if performance problems indicate wrong paradigm choice.
Different logic languages have different execution models. Understanding these helps orient when working with a new system:
Prolog-style (top-down, depth-first):
Datalog-style (bottom-up, set-oriented):
OWL2/Description Logics:
Answer Set Programming:
When learning a new logic language: Identify its execution model to understand what you control vs what the system controls.
<common_mistakes_by_background>
Programmers from procedural or object-oriented backgrounds often struggle with relational thinking:
<from_imperative_background> Writing procedural code in declarative language:
Not thinking relationally:
Using assert/retract for state instead of relations:
Not leveraging backtracking for search:
Sequential thinking instead of declarative specification:
Not using pattern matching effectively:
Writing deterministic predicates when nondeterminism would work:
<from_oop_background> From Object-Oriented Backgrounds:
Trying to create class-like structures:
Thinking about methods instead of relations:
user.getName() thinking instead of userName(User, Name) relationsNot leveraging unification:
=. Use it
</from_oop_background><from_fp_background> From Functional Programming Backgrounds:
Forcing functional patterns when relations are clearer:
Not using search and constraint solving:
Thinking about transformations instead of relations:
<related_skills>
Documentation:
For SWI-Prolog-specific guidance (testing, tooling, libraries), see the swi-prolog-programmer skill. </resources>
Logic programming emphasizes:
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.
data-ai
--- name: interactive-research description: Multi-source research orchestrated across a persistent agent team. Use for queries asking for research-style investigation of a topic — comparing, contrasting, surveying, investigating, evaluating, deeply researching, doing a literature review, or any similar research intent — or that ask what people are saying publicly about a topic (discourse, expert opinion, industry consensus, and related framings). Example phrasings (illustrative, not exhaustive):
development
Expert-level guidance for creating high-quality Claude Code skills. Use alongside Anthropic's skill-creator when creating new skills, improving existing skills, or needing guidance on skill content quality. Complements basic skill mechanics with research-driven content development, XML tag structuring, decision frameworks over mechanics, cross-references between skills, and systematic validation.
development
--- name: deep-research description: Deprecated name; the skill formerly here is now opinionated-research:interactive-research. Retained as a context-level notice because Claude Code now ships a built-in deep-research workflow that runs one-shot, non-interactive fan-out research (no conversation after the report). interactive-research instead runs a persistent agent team you can keep questioning once the report lands. Guidance for Claude: when the user makes a research request, ask whether they
development
Pedagogical framework for teaching programming through Socratic dialogue. Use when a learner wants to LEARN programming rather than have code written for them. Triggers include "teach me", "help me understand", "I'm learning", "tutor mode", or requests to not provide solutions. Emphasizes productive struggle, graduated hints, metacognitive scaffolding, and emotional support.