Logic Query
Scannednpx machina-cli add skill NewJerseyStyle/plugin-logic-llm/logic-query --openclaw/logic-query
Query symbolic knowledge bases using natural language or formal logic syntax.
Description
This skill enables querying knowledge bases that have been created through /logic-convert or manually. It translates natural language questions into formal queries and returns human-readable answers using the appropriate solver.
Supported Solvers
| Solver | MCP Server | Query Types |
|---|---|---|
| Prolog | prolog-mcp | Yes/no, find values, find all |
| Clingo | clingo-mcp | Answer sets, optimization |
| Z3 | z3smt-mcp | Satisfiability, models, proofs |
| FOL | folprover-mcp | Theorem proving |
| Pyke | pyke-mcp | Goal proving, variable bindings |
Usage
/logic-query [options] <question>
Options
--format <prolog|clingo|z3|fol|pyke>- Query format (auto-detected if KB loaded)--kb <path>- Path to knowledge base file(s) to load--session <name>- Use named session (persists loaded facts/rules)--explain- Show reasoning trace/proof--all- Return all solutions/answer sets/models--timeout <ms>- Query timeout in milliseconds
Examples
/logic-query "Is John allowed to access the confidential files?"
/logic-query --kb ./legal/rules.pl --explain "Can contractors view salary data?"
/logic-query --format clingo --all "What are the valid schedules?"
/logic-query --format z3 "Is it possible to assign all tasks within budget?"
/logic-query --format fol --explain "Does mortality follow from the premises?"
/logic-query --format pyke --session hr "Who reports to the CEO?"
Query Types by Solver
Prolog Queries
# Yes/No
?- can_access(john, file_a).
# Find values
?- can_access(john, What).
# Find all
?- findall(X, can_access(X, confidential), People).
Clingo Queries
# Check satisfiability (answer sets exist?)
# Find all answer sets
# Optimization (minimize/maximize)
Z3 Queries
# Satisfiability check
s.check()
# Get model
s.model()
# Prove theorem
prove(theorem)
FOL Queries
# Prove from premises
prove(premises, conclusion)
# Check validity
Pyke Queries
# Test fact
query("Mortal(socrates, True)")
# Find bindings
prove_goal("Descendant(tom, $who, True)")
Behavior
- Session Management: Load or create query session
- Knowledge Base Loading: Load specified KB files if not in session
- Query Translation: Convert natural language to formal query
- Registry Lookup: Use registry to resolve predicate names
- Solver Selection: Choose appropriate solver based on format
- Execution: Run query through MCP server
- Result Interpretation: Translate formal results to natural language
Output
The skill returns:
- Answer to the query (yes/no, values, or explanations)
- Reasoning trace if
--explainis used - Multiple solutions if
--allis specified - Confidence indicator when translation is ambiguous
Session Persistence
Sessions are stored in data/sessions/ and can be resumed across conversations:
- Use
--session myprojectto name a session - Sessions preserve loaded facts, rules, and query history
- Sessions support incremental knowledge base updates
- Each solver has its own session namespace
Integration
This skill uses:
prolog-mcp: runPrologQuery, loadProgramclingo-mcp: solve, getProgramz3smt-mcp: check_sat, solve, provefolprover-mcp: prove, add_premisepyke-mcp: query, prove_goallogic-registryfor predicate resolution
Notes
- Natural language queries are mapped to formal queries using the registry's predicate descriptions
- Complex queries may be decomposed into sub-queries for better accuracy
- The skill handles negation appropriately for each solver type
- Timeout helps prevent long-running queries from blocking
Source
git clone https://github.com/NewJerseyStyle/plugin-logic-llm/blob/main/skills/logic-query/SKILL.mdView on GitHub Overview
Logic Query lets you ask questions against knowledge bases built via /logic-convert or manual entries. It translates natural-language questions into formal queries and returns human-readable results using the appropriate solver (Prolog, Clingo, Z3, FOL, or Pyke). This makes symbolic reasoning accessible from conversational prompts.
How This Skill Works
It loads the target KB (from a session or --kb path), translates NL questions into a formal query using the registry, then selects the correct solver via the --format or auto-detected format. The MCP server executes the query and the skill translates the solver results into natural-language answers, optionally including explanations with --explain.
When to Use It
- When you have a knowledge base built with /logic-convert or manual facts and rules
- When you need yes/no answers, specific values, or all answer sets from a Prolog/Clingo/Z3/FOL/Pyke query
- When you require explanations or proofs of a query with --explain
- When you need all solutions or models (--all) or optimizations
- When you want to persist work in a named session and reuse loaded KBs across conversations
Quick Start
- Step 1: Load or create a session and load your KB with --kb <path> or --session <name>
- Step 2: Run a query using natural language or a specified --format (e.g., /logic-query --format clingo --explain ...)
- Step 3: Optional - add --explain for reasoning trace or --all to retrieve all solutions
Best Practices
- Load the KB into a named session (or use --kb) before querying repeatedly
- Choose the correct --format corresponding to your KB's solver for accurate results
- Use --explain to get a reasoning trace only when debugging or validating logic
- Use --all when you need multiple solutions, but be mindful of output verbosity
- Ensure predicates are resolved via the logic-registry to avoid missing or renamed predicates
Example Use Cases
- "Is John allowed to access the confidential files?"
- "Can contractors view salary data?"
- "What are the valid schedules?"
- "Is it possible to assign all tasks within budget?"
- "Does mortality follow from the premises?"