Skip to content

Commit c4877e1

Browse files
committed
update skills
1 parent 0c11475 commit c4877e1

File tree

4 files changed

+58
-11
lines changed

4 files changed

+58
-11
lines changed

.claude/skills/find-problem/SKILL.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ Step 3: Rank and Present (table ranked by effective complexity, web search for a
3333
Step 4: Generate Solution Doc (docs/solutions/<name>.md)
3434
```
3535

36+
## Prerequisites
37+
38+
Build the CLI tools before starting: `make cli` (builds `pred` and `pred-sym`). All commands below assume `pred` and `pred-sym` are available via `cargo run -p problemreductions-cli --bin pred --` and `cargo run -p problemreductions-cli --bin pred-sym --` respectively.
39+
3640
## CRITICAL: Output Visibility
3741

38-
Bash tool results are hidden from the user in the Claude Code UI. **After every `pred` command, you MUST copy-paste the full stdout/stderr into your response as text.** The pattern for every command is:
42+
Bash tool results are hidden from the user in the Claude Code UI. **After every `pred` / `pred-sym` command, you MUST copy-paste the full stdout/stderr into your response as text.** The pattern for every command is:
3943

4044
1. Announce the command and why: "Let me run `pred to MIS --hops 3` to discover all problems that can reduce to MIS:"
4145
2. Run the command via the Bash tool
@@ -73,20 +77,23 @@ Never skip step 1 or 3.
7377

7478
2. **For each discovered problem**, run:
7579
- `pred path <source> <model>` — get the cheapest witness-capable reduction path
80+
- **IMPORTANT:** Use the exact variant-qualified name from `pred to` output (e.g., `SpinGlass/SimpleGraph/f64`, not bare `SpinGlass`). Bare names resolve to the default variant, which may differ from the reachable variant and cause false "no path" errors.
7681
- `pred show <source>` — get best-known brute-force complexity
7782

7883
3. **Compute effective complexity** for each source problem:
7984
- Take the user's solver complexity expression (e.g., `O(1.1996^num_vertices)`)
8085
- Substitute the overhead expressions from the reduction path into the solver's variables
8186
- Example: if MVC→MIS has overhead `num_vertices = num_vertices`, then solving MVC via MIS costs `O(1.1996^num_vertices)` — same as MIS
8287
- Example: if overhead is `num_vertices = num_clauses * 3`, then effective complexity is `O(1.1996^(3 * num_clauses))`
88+
- **Use `pred-sym` to verify:** after manual substitution, run `pred-sym big-o "<effective_expr>"` to normalize the expression. Use `pred-sym eval --vars <bindings> "<expr>"` at a concrete size (e.g., n=20) to numerically verify the simplification.
8389

8490
4. **Compare to best-known**: for each source, compare effective complexity to the source's own best-known complexity from `pred show`. Classify as:
8591
- **Better** — effective complexity has a smaller base or exponent than best-known
8692
- **Similar** — comparable asymptotic behavior
8793
- **Worse** — effective complexity exceeds best-known (reduction overhead makes it impractical)
94+
- **When effective and best-known use different variables** (e.g., `O(1.5^num_subsets)` vs `O(2^universe_size)`): this happens when a problem has multiple independent size fields and the best-known algorithm's dominant variable differs from the reduction overhead's. In this case, use `pred-sym eval` at representative concrete values to determine the comparison. State the result conditionally: "Better when num_subsets ≤ c·universe_size" with the crossover ratio.
8895

89-
5. **Web search** each discovered source problem + "applications" or "real-world" to find practical use cases. Use `WebSearch` tool.
96+
5. **Web search** only the **Better** and **Similar** candidates for real-world applications (not the Worse ones). Use `WebSearch` tool with query "<problem name> real-world applications".
9097

9198
**If `--hops 3` returns more than 15 results:** present only the top 10 by effective complexity and mention the rest are available if the user wants to see them.
9299

@@ -98,12 +105,12 @@ Never skip step 1 or 3.
98105

99106
**Goal:** Show all discovered problems ranked by practical usefulness.
100107

101-
Present a ranked table (most practical first):
108+
Present a ranked table (most practical first). **Mark a recommendation** — highlight the "Better" entries as the most valuable discoveries:
102109

103110
| # | Problem | Hops | Overhead | Effective Complexity | vs Best-Known | Applications |
104111
|---|---------|------|----------|---------------------|---------------|--------------|
105-
| 1 | MinimumVertexCover | 1 | same size | O(1.1996^n) | Better | Network monitoring |
106-
| 2 | MaximumClique | 2 | complement graph | O(1.1996^n) | Better | Social network cliques |
112+
| 1 | **MinimumVertexCover** | 1 | same size | O(1.1996^n) | **Better** | Network monitoring |
113+
| 2 | **MaximumClique** | 2 | complement graph | O(1.1996^n) | **Better** | Social network cliques |
107114
| 3 | GraphColoring | 3 | n^2 vars | O(1.1996^(n^2)) | Worse | Register allocation |
108115

109116
Ask using `AskUserQuestion`: "Which problems would you like included in the solution doc? Pick numbers, or 'all practical' for only the Better/Similar ones."
@@ -124,6 +131,8 @@ Where:
124131

125132
Ask the user to confirm the filename before writing.
126133

134+
**Before writing the doc**, run `pred create <Source> --help` for each selected problem to verify the correct CLI flag names. Use the flags exactly as shown in the help output.
135+
127136
**Doc template — write all sections:**
128137

129138
```markdown
@@ -168,16 +177,19 @@ pred solve bundle.json --solver ilp --timeout 60
168177
**After writing the doc:**
169178

170179
1. Show the user the generated filename and a brief summary of what's in it.
171-
2. Ask if they want to make any changes before finishing.
180+
2. **If a built-in solver covers the model** (brute-force or ILP), offer to run a live demo with one of the "Better" problems: "Want me to run an example end-to-end so you can see it in action?"
181+
3. Ask if they want to make any changes before finishing.
172182

173183
---
174184

175185
## Key Behaviors
176186

177187
- **One question at a time.** Never ask multiple questions in one message. Use `AskUserQuestion` for every decision point.
178-
- **Web search before presenting applications.** In Step 2, web search each discovered problem for real-world use cases. Never guess applications from internal knowledge alone.
188+
- **Web search only Better/Similar candidates.** In Step 2, web search only the problems classified as Better or Similar for real-world use cases. Skip Worse ones unless the user asks for all. Never guess applications from internal knowledge alone.
179189
- **Show full output.** After every Bash tool call, copy-paste the COMPLETE output into your text response as a fenced code block. Bash tool results are hidden in the UI.
180190
- **Announce every command.** Before running, say what command you're using and why.
191+
- **Always use variant-qualified names in `pred path`.** When `pred to` returns names like `SpinGlass/SimpleGraph/f64`, use that exact string in subsequent `pred path` calls. Bare names (e.g., `SpinGlass`) resolve to the default variant, which may differ from the reachable variant and cause false "no path" errors.
192+
- **Recommend, don't just list.** When presenting the ranked table in Step 3, bold the "Better" entries as the most valuable discoveries. The user can still pick freely.
181193
- **Compact formatting.** Write explanations as plain paragraphs. Do not use blockquote `>` syntax for explanations. Keep tight: command announcement, code block output, 1-3 sentence explanation.
182194
- **Conversational tone.** Guided consultation, not a lecture.
183195
- **Live execution.** Every `pred` command runs for real. No fake output.

.claude/skills/find-solver/SKILL.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,16 @@ Use `AskUserQuestion` for each question. Format options as **(a)**/**(b)**/**(c)
9696
| 2 | ... | ... | ... |
9797
| 3 | ... | ... | ... |
9898

99+
**Include a recommendation:** Bold or mark the option you think is the best fit, with a brief reason why.
100+
99101
4. For each candidate, run `pred show <model>` and show the output — fields, complexity, available reductions. This helps the user see what data they would need to provide.
100102

101-
5. **Ask the user to pick one** using `AskUserQuestion`. If none fit, ask the user for more detail and re-run the web search with refined keywords.
103+
5. **Check optimization vs decision mismatch.** If the user's goal is "minimize X" or "maximize X" but the matched model is a decision/feasibility problem (Value = `Or`, fields include a `deadline`/`bound`), explain the gap:
104+
- "This model checks feasibility ('can it be done within bound D?'), not optimization directly."
105+
- "To find the optimum, we'll binary search on the bound parameter."
106+
- This is common for scheduling problems (deadline), knapsack (bound), etc.
107+
108+
6. **Ask the user to pick one** using `AskUserQuestion`. If none fit, ask the user for more detail and re-run the web search with refined keywords.
102109

103110
**Proceed to Step 3 with the chosen model.**
104111

@@ -114,17 +121,20 @@ Use `AskUserQuestion` for each question. Format options as **(a)**/**(b)**/**(c)
114121

115122
2. **For each reachable problem**, gather info:
116123
- Run `pred path <model> <target>` to get the cheapest witness-capable reduction path and composed overhead
124+
- **IMPORTANT:** Use the exact variant-qualified name from `pred from` output (e.g., `SpinGlass/SimpleGraph/f64`, not bare `SpinGlass`). Bare names resolve to the default variant, which may differ from the reachable variant and cause false "no path" errors.
117125
- Run `pred show <target>` to get its best-known complexity
118126
- Check if it's a solver-ready target (ILP, QUBO, SAT) or has a path to one via `pred path <target> ILP`
119127

120-
3. **Present a ranked table** (most practical paths first — fewest hops, lowest overhead):
128+
3. **Present a ranked table** (most practical paths first — fewest hops, lowest overhead). **Mark a recommendation** for the most practical path:
121129

122130
| # | Target | Hops | Composed Overhead | Target Complexity | Solver-Ready? |
123131
|---|--------|------|-------------------|-------------------|---------------|
124132
| 1 | ILP | 2 | num_vars = 2*n + m | O(2^num_vars) | Yes (is ILP) |
125133
| 2 | QUBO | 1 | num_vars = n | O(2^num_vars) | Yes (is QUBO) |
126134
| 3 | MaxSetPacking | 1 | num_sets = n | O(2^num_sets) | Yes (ILP in 2 steps) |
127135

136+
When overhead grows significantly between options (e.g., linear vs quadratic), note the practical implication: "QUBO adds quadratic variable blowup — prefer this only if targeting quantum/annealing hardware."
137+
128138
4. **Ask the user** using `AskUserQuestion`: "Which reduction path would you like to use? Pick a number."
129139

130140
**If `pred from --hops 3` returns more than 15 results:** present only the top 10 by overhead and mention the rest are available.
@@ -222,7 +232,23 @@ pred solve step_N.json --solver ilp --timeout 60
222232
```
223233

224234
<Explain what the output means for the user's original problem.
225-
E.g., "Max(3) means the maximum independent set has 3 vertices.">
235+
E.g., "Max(3) means the maximum independent set has 3 vertices."
236+
For decision problems: "Or(true) means a feasible solution exists within the bound.">
237+
238+
## Finding the Optimum (decision models only)
239+
240+
<Include this section when the matched model is a decision/feasibility problem (Value = Or)
241+
with a bound parameter like `deadline`, `bound`, or `capacity`.>
242+
243+
The model checks feasibility ("can it be done within bound D?"), not optimization directly.
244+
To find the minimum/maximum, binary search on the bound parameter:
245+
246+
```bash
247+
# Binary search for minimum deadline
248+
# Upper bound: sum of all task lengths (trivially feasible with 1 processor)
249+
# Lower bound: max(longest task, ceil(total / num_processors))
250+
# Try midpoint, narrow based on Or(true)/Or(false)
251+
```
226252

227253
## Solution Extraction
228254

@@ -269,7 +295,8 @@ pred evaluate input.json --config <solution_vector>
269295
**After writing the doc:**
270296

271297
1. Show the user the generated filename and a brief summary of what's in it.
272-
2. Ask if they want to make any changes before finishing.
298+
2. **If a built-in solver covers the chosen path** (brute-force or ILP), offer to run a live demo with the example instance: "Want me to run the example end-to-end so you can see it in action?"
299+
3. Ask if they want to make any changes before finishing.
273300

274301
---
275302

@@ -279,9 +306,12 @@ pred evaluate input.json --config <solution_vector>
279306
- **Web search before recommendations.** In Step 2 (model matching) and Step 4 (solver recommendation), always web search first. Never rely on internal knowledge alone.
280307
- **Show full output.** After every Bash tool call, copy-paste the COMPLETE output into your text response as a fenced code block. Bash tool results are hidden in the UI.
281308
- **Announce every command.** Before running, say what command you're using and why.
309+
- **Always use variant-qualified names in `pred path`.** When `pred from` returns names like `SpinGlass/SimpleGraph/f64`, use that exact string in subsequent `pred path` calls. Bare names (e.g., `SpinGlass`) resolve to the default variant, which may differ from the reachable variant and cause false "no path" errors.
310+
- **Recommend, don't just list.** When presenting options (models in Step 2, paths in Step 3, solvers in Step 4), always bold or mark your recommended choice with a brief reason. The user can still pick freely.
282311
- **Compact formatting.** Write explanations as plain paragraphs. Do not use blockquote `>` syntax for explanations. Keep tight: command announcement, code block output, 1-3 sentence explanation.
283312
- **Conversational tone.** Guided consultation, not a lecture.
284313
- **Live execution.** Every `pred` command runs for real. No fake output.
285314
- **Graceful fallbacks.** If a path doesn't exist or a command fails, explain what happened and suggest alternatives (try another model, use brute-force, backtrack).
286315
- **Adapt to user level.** If the user gives a formal problem name, skip clarification. If they describe a fuzzy real-world problem, ask follow-ups one at a time.
287316
- **Use `--timeout 30`** with `pred solve` in any live demos during the session.
317+
- **Doc template sections are conditional.** "Finding the Optimum" only applies to decision models. "External Solver Alternatives" only applies when external solvers were chosen. "Solution Extraction" can be folded into "Solving" when the bundle workflow handles it automatically.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ docs/superpowers/
9393
docs/src/reductions/*.json
9494
.claude/projects/
9595
docs/research/
96+
docs/solutions/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ make cli # builds target/release/pred
4242

4343
See the [Getting Started](https://codingthrust.github.io/problem-reductions/getting-started.html) guide for usage examples, the reduction workflow, and [CLI usage](https://codingthrust.github.io/problem-reductions/cli.html).
4444

45+
**Have a problem and looking for a solver?** Run `/find-solver` — it matches your real-world problem to a library model, explores reduction paths, and recommends solvers.
46+
47+
**Have a solver and wondering what it can solve?** Run `/find-problem` — given a solver for a specific model, it discovers all other problems reachable via incoming reductions, ranked by effective complexity.
48+
4549
Try a model directly from the CLI:
4650

4751
```bash

0 commit comments

Comments
 (0)