[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ASD9B05QVHHWNKHNT3B94E":3,"skill-same:01M7ASD9B05QVHHWNKHNT3B94E":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7ASD9B05QVHHWNKHNT3B94E","toc-computability-and-complexity",null,"Use when you need to know whether a problem is solvable and how hard it is: the halting problem, Rice's theorem and why static analysis has false positives, reductions as the most transferable skill here, complexity classes and the P versus NP map, recognizing NP-hardness and the escape hatches in order of usefulness, and SAT and SMT solvers and why 'NP-complete' is not a verdict.","the-vibey-project\u002Fvibey","the-vibey-project","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F329298758?v=4","01M7AJHGZ9722CTJ4JNQZVRH0Q","the vibey project","01M7AJHGZVMG2K7TGXQ6XFHVG3",5,"MIT","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Ftheory-of-computation\u002Fskills\u002Ftoc-computability-and-complexity\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: toc-computability-and-complexity\ndescription: \"Use when you need to know whether a problem is solvable and how hard it is: the halting problem, Rice's theorem and why static analysis has false positives, reductions as the most transferable skill here, complexity classes and the P versus NP map, recognizing NP-hardness and the escape hatches in order of usefulness, and SAT and SMT solvers and why 'NP-complete' is not a verdict.\"\n---\n\n# Theory of Computation: Computability, Complexity Classes, NP-Hardness, and Solvers\n\n> **Part 2 of 5** of the *Theory of Computation* reference (plugin `theory-of-computation`), covering §4–§7. Sibling skills: `toc-automata-regex-and-parsing` (§0–§3), `toc-beyond-np-space-and-distributed-limits` (§8–§11), `toc-type-systems-and-randomization` (§12–§13), `toc-reference` (§14–§19). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §16 → `toc-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not a course. Three markers:\n> - **[DURABLE]** — proven theorems and stable practice. **This is most of the document,\n>   and it does not expire.**\n> - **[VERSIONED]** — the small moving parts: recent results, solver capability, open\n>   problems.\n> - **[CONTESTED]** — genuine disagreement, mostly about pedagogy and practical relevance.\n>\n> **⚠️ GOTCHA** boxes mark places where ignorance of the theory produces a specific,\n> expensive production failure — which is the whole argument for learning it.\n>\n> **The three framings that organize everything below:**\n> 1. **This is the only branch of CS that tells you what you cannot do.** Everything else\n>    teaches techniques. Theory tells you when to stop looking — and **knowing a problem is\n>    undecidable or NP-hard is more valuable than any algorithm**, because it redirects\n>    you from an impossible goal to a tractable approximation of it.\n> 2. **You already use it; you may not know the names.** Regex is finite automata.\n>    Your parser is a pushdown automaton. Your state machine is a DFA. Your build system's\n>    cycle detection is graph theory. **The theory isn't an addition to your practice — it's\n>    a description of it**, and knowing the description tells you where the edges are.\n> 3. **\"Hard\" is not \"impossible,\" and this is the most consequential practical point.**\n>    NP-complete problems with thousands of variables are solved routinely (§9 → `toc-beyond-np-space-and-distributed-limits`). The\n>    theory tells you *no algorithm is fast on all inputs* — it says nothing about\n>    **your** inputs, which are usually structured. **Treating NP-hardness as a verdict\n>    rather than a warning is the single most common misapplication of this material.**\n\n---\n\n## §4. Computability — What You Cannot Do\n\n### 4.1 The halting problem and what follows\n\n**[DURABLE] There is no program that takes an arbitrary program and input and correctly\ndecides whether it halts.** The proof is a two-line diagonalization, and its consequences\nare everywhere in your tooling.\n\n**Rice's theorem generalizes it, and this is the version engineers should know:**\n**every non-trivial semantic property of programs is undecidable.** Not \"hard\" —\n**undecidable.** Does this program ever throw? Is this variable ever null? Are these two\nfunctions equivalent? Is this code dead? Does this ever access out of bounds?\n**All undecidable in general.**\n\n> **⚠️ GOTCHA — this is why your tools behave the way they do, and knowing it changes how\n> you use them.** A static analyzer cannot be simultaneously **sound** (no false negatives)\n> and **complete** (no false positives) and **terminating**. It must pick two. So:\n> - **Linters and most analyzers choose \"terminating + roughly useful\"** and accept both\n>   false positives and false negatives.\n> - **Sound analyzers** (used in avionics, automotive) accept **false positives** — they'll\n>   flag safe code — because missing a real bug is unacceptable.\n> - **Type systems** are decidable approximations that reject some correct programs.\n>   **When the compiler rejects code you know is fine, that is the theory, not a bug.**\n>\n> **The engineering consequence: stop asking for a tool with no false positives.** You are\n> asking for a solution to the halting problem. Ask instead which side of the trade-off the\n> tool sits on, and whether that matches your risk.\n\n### 4.2 Reductions — the most transferable skill here\n\n**[DURABLE] \"If I could solve B, I could solve A; A is impossible; therefore B is\nimpossible.\"** This is how nearly every undecidability and hardness result is proved, and\n**it is a reasoning pattern you can apply directly at work.**\n\nThe practical version: when a stakeholder asks for a feature, ask whether it reduces to\nsomething known impossible or known hard. *\"Detect all infinite loops before deployment\"*\nreduces to halting. *\"Find the optimal assignment across all these constraints\"* frequently\nreduces to something NP-hard (§6). **Recognizing the reduction saves you a quarter.**\n\n### 4.3 Other undecidable things you may encounter\nProgram equivalence. Whether a CFG is ambiguous. Whether two CFGs generate the same\nlanguage. The Post Correspondence Problem (the standard tool for proving other things\nundecidable). Type inference for some sufficiently expressive systems (§12 → `toc-type-systems-and-randomization`). Whether an\narbitrary Diophantine equation has a solution (Hilbert's 10th). **Some tile-matching and\nconfiguration problems** — which is why certain package-resolution and layout problems are\ngenuinely, formally hard.\n\n**[DURABLE] Undecidable does not mean useless.** Every practical tool works on a decidable\n*subset*, or accepts approximation, or uses a timeout. **Termination checkers, model\ncheckers, and dependent type systems all exist and work** — by restricting the problem, not\nby solving the impossible one.\n\n---\n\n## §5. Complexity Classes\n\n### 5.1 The map\n\n```\n    P  ⊆  NP  ⊆  PSPACE  ⊆  EXPTIME\n    │      │       │\n    │      │       └── games, quantified formulas, some planning\n    │      └────────── verifiable in poly time (SAT, TSP-decision, scheduling…)\n    └───────────────── solvable in poly time\n    \n  ⚠️ We know P ≠ EXPTIME (time hierarchy theorem).\n     We do NOT know whether P = NP, NP = PSPACE, or P = PSPACE.\n```\n\n**[DURABLE] The definition of NP that actually helps engineers**: not \"solvable by a\nnondeterministic machine\" but **\"a proposed solution can be checked quickly.\"** If someone\nhands you an assignment, can you verify it in polynomial time? Then it's in NP. **That\nframing makes NP-membership obvious for most problems you'll meet.**\n\n**NP-hard**: at least as hard as everything in NP. **NP-complete**: in NP *and* NP-hard —\nthe hardest problems in NP, all equivalent under polynomial reduction.\n**⚠️ NP-hard problems need not be in NP** — optimization versions and problems outside NP\nare often NP-hard without being NP-complete, and the distinction matters when someone\nclaims a \"solution.\"\n\n**co-NP** contains problems whose *no*-instances are easily verified. **Tautology checking\nis co-NP-complete** — which is why proving a formula always true is structurally harder to\ncertify than finding a counterexample.\n\n### 5.2 Some honest cautions\n\n**⚠️ Polynomial ≠ fast.** An O(n¹⁰⁰) algorithm is polynomial and useless. Galactic\nalgorithms with enormous constants are polynomial and never run. **P is a robust\ntheoretical boundary, not a promise about your latency budget.**\n\n**⚠️ Asymptotics hide constants and cache behaviour.** For real n, an O(n log n) algorithm\nwith terrible locality routinely loses to an O(n²) one that fits in cache. **Measure**\n(§9 → `toc-beyond-np-space-and-distributed-limits` makes this precise in the other direction).\n\n**⚠️ Worst case ≠ your case.** Quicksort is O(n²) worst case and the practical default.\nSimplex is exponential worst case and dominates linear programming in practice.\n**This gap is the entire subject of §6.3.**\n\n---\n\n## §6. Your Problem Is NP-Hard. Now What?\n\n**[DURABLE] This is the section with the most direct daily value, and the one most\nengineers get wrong in both directions** — either despairing, or not recognizing the\nhardness at all and shipping something that falls over at scale.\n\n### 6.1 Recognizing it\n\n**The canonical problems worth knowing by sight**, because your problem is usually one of\nthem wearing a business costume:\n\n| Problem | Shows up as |\n|---|---|\n| **SAT \u002F 3-SAT** | Configuration, feature flags, dependency resolution |\n| **Knapsack \u002F Subset Sum** | Budget allocation, resource packing, cart optimization |\n| **Bin Packing** | VM placement, container scheduling, shipping |\n| **Graph Coloring** | Register allocation, scheduling with conflicts, frequency assignment |\n| **TSP \u002F Vehicle Routing** | Delivery, tool-path, sequencing anything |\n| **Set Cover** | Minimum test suite, sensor placement, feature selection |\n| **Clique \u002F Independent Set** | Compatibility groups, conflict-free selection |\n| **Scheduling with constraints** | Almost every scheduling problem you'll be handed |\n| **Integer Programming** | ⚠️ **The general form of most of the above** |\n\n**[DURABLE] The tell**: you're choosing a subset or an ordering, constraints interact, and\na greedy choice early can be shown to force a bad outcome later. **When a problem has that\nshape, look for the reduction before you start optimizing.**\n\n### 6.2 The escape hatches, in order of usefulness\n\n```\n1. IS THE INPUT SMALL?           n=20 exhaustive search is instant. Check first.\n2. IS IT ACTUALLY THE HARD CASE? Real inputs are structured; §6.3\n3. USE A SOLVER                  SAT\u002FSMT\u002FMIP\u002FCP — §7. Often the right answer\n4. APPROXIMATE                   Many NP-hard problems have provable ratio bounds\n5. HEURISTIC                     Greedy, local search, simulated annealing, GA\n6. FIXED-PARAMETER TRACTABLE     f(k)·poly(n) — exponential only in a small parameter\n7. PSEUDO-POLYNOMIAL             Knapsack is O(nW) — fine if W is small\n8. SPECIAL CASE                  Is your graph a tree? planar? bounded treewidth?\n9. RELAX THE PROBLEM             ⚠️ Often the real answer: does the business need OPTIMAL?\n10. CHANGE THE PROBLEM           Ditto\n```\n\n**[DURABLE] #9 and #10 deserve more attention than they get.** \"Optimal\" is usually a\nrequirement someone assumed rather than one the business stated. **A solution within 2% of\noptimal, computed in 100 ms, beats an optimal one computed in six hours** for nearly every\nreal application — and asking that question is often worth more than any algorithm.\n\n**Approximation with guarantees** is genuinely useful: Vertex Cover has a simple 2-approx;\nSet Cover has a ln(n) approximation and **that's provably the best possible unless P = NP**;\nMetric TSP has classical constant-factor results. **⚠️ Some problems are hard even to\napproximate** — that's the PCP theorem's practical legacy, and it means \"just approximate\nit\" is not always available.\n\n### 6.3 The most important practical caveat\n\n**[DURABLE] NP-hardness is a statement about worst-case inputs over all instances. It says\nnothing about yours.**\n\nReal instances have structure: dependency graphs are sparse and near-acyclic, schedules\nhave natural clustering, configuration constraints are mostly independent. **Modern SAT\nsolvers routinely handle industrial instances with millions of variables** (§7) — instances\nthat are formally NP-complete and empirically easy.\n\n**⚠️ The failure mode in both directions:**\n- **Giving up because it's NP-hard**, when a solver would have done it in a second.\n- **Assuming it'll be fine because it worked in testing**, when your test data was\n  structured and production data isn't. **The exponential is still there and it will find\n  you.** Set timeouts, have a fallback, and monitor solve times.\n\n---\n\n## §7. SAT, SMT, and Solvers\n\n**[DURABLE] The single most useful practical lesson in complexity for working engineers:\nNP-complete does not mean unsolvable, and there is mature, free tooling that will do it\nfor you.**\n\n**SAT** — Boolean satisfiability. The first problem proved NP-complete (Cook–Levin), and\nthe one where the gap between theory and practice is widest. Modern **CDCL** solvers\n(conflict-driven clause learning, with unit propagation, watched literals, restarts,\nclause learning) have made SAT solving one of the great practical successes in CS — the\nliterature's own phrase for it is **\"the unreasonable effectiveness of SAT solvers.\"**\n\n**SMT** — SAT plus theories: integers and reals, bit-vectors, arrays, strings, algebraic\ndatatypes, uninterpreted functions. **This is what makes it useful for software**, because\nyour constraints aren't Boolean.\n\n**[VERSIONED] The tools**: **Z3** (Microsoft — general-purpose, the default, especially\nstrong on quantifier-free arithmetic and arrays), **cvc5** (strings, algebraic datatypes,\nadvanced arithmetic), **Bitwuzla** (bit-vectors and floating point; successor to\nBoolector), **Yices 2** (fast on linear arithmetic and bit-vectors), **MathSAT**\n(interpolation, model generation), and **CaDiCaL**\u002F**Kissat** on the pure-SAT side.\n**MiniZinc\u002FOR-Tools** for constraint programming; **Gurobi\u002FCPLEX\u002FHiGHS** for MIP.\n\n**Where they're actually used**: **program verification** (Dafny, Verus, F\\*, Viper,\nCreusot, and the whole bounded-model-checking family), **symbolic execution** and test\ngeneration, **type checking** for refinement types, **package dependency resolution**\n(PubGrub and friends), **scheduling and configuration**, and **hardware verification**,\nwhich is where the money was that built these tools.\n\n> **⚠️ GOTCHA — the practical failure modes of solvers, which nobody warns you about:**\n> - **Encoding dominates everything.** The same problem stated two ways can differ by\n>   orders of magnitude. **Move as much of the problem outside the solver as you can** —\n>   the solver is the scalability bottleneck, so preprocessing pays enormously.\n> - **⚠️ Instability is real and under-appreciated.** Semantically identical queries can\n>   flip between solved and timed-out based on trivial syntactic differences — variable\n>   naming, term ordering, formula shape. Research on program-verification workloads has\n>   measured this directly and built tooling specifically to normalize queries and\n>   stabilize solve times. **If your CI intermittently fails a verification step, this may\n>   be why, and it is not your logic being wrong.**\n> - **Non-linear arithmetic is where solvers fall over**, and disabling the non-linear\n>   solver is a known stabilization technique in production verification work.\n> - **Always set a timeout and handle `unknown`.** `unknown` is a real answer, not an error.\n> - **Solvers disagree**, and portfolio approaches (dispatch to whichever solver suits the\n>   theory) are standard in serious tools for exactly that reason.\n","# Theory of Computation: Computability, Complexity Classes, NP-Hardness, and Solvers\n\n> **Part 2 of 5** of the *Theory of Computation* reference (plugin `theory-of-computation`), covering §4–§7. Sibling skills: `toc-automata-regex-and-parsing` (§0–§3), `toc-beyond-np-space-and-distributed-limits` (§8–§11), `toc-type-systems-and-randomization` (§12–§13), `toc-reference` (§14–§19). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §16 → `toc-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not a course. Three markers:\n> - **[DURABLE]** — proven theorems and stable practice. **This is most of the document,\n>   and it does not expire.**\n> - **[VERSIONED]** — the small moving parts: recent results, solver capability, open\n>   problems.\n> - **[CONTESTED]** — genuine disagreement, mostly about pedagogy and practical relevance.\n>\n> **⚠️ GOTCHA** boxes mark places where ignorance of the theory produces a specific,\n> expensive production failure — which is the whole argument for learning it.\n>\n> **The three framings that organize everything below:**\n> 1. **This is the only branch of CS that tells you what you cannot do.** Everything else\n>    teaches techniques. Theory tells you when to stop looking — and **knowing a problem is\n>    undecidable or NP-hard is more valuable than any algorithm**, because it redirects\n>    you from an impossible goal to a tractable approximation of it.\n> 2. **You already use it; you may not know the names.** Regex is finite automata.\n>    Your parser is a pushdown automaton. Your state machine is a DFA. Your build system's\n>    cycle detection is graph theory. **The theory isn't an addition to your practice — it's\n>    a description of it**, and knowing the description tells you where the edges are.\n> 3. **\"Hard\" is not \"impossible,\" and this is the most consequential practical point.**\n>    NP-complete problems with thousands of variables are solved routinely (§9 → `toc-beyond-np-space-and-distributed-limits`). The\n>    theory tells you *no algorithm is fast on all inputs* — it says nothing about\n>    **your** inputs, which are usually structured. **Treating NP-hardness as a verdict\n>    rather than a warning is the single most common misapplication of this material.**\n\n---\n\n## §4. Computability — What You Cannot Do\n\n### 4.1 The halting problem and what follows\n\n**[DURABLE] There is no program that takes an arbitrary program and input and correctly\ndecides whether it halts.** The proof is a two-line diagonalization, and its consequences\nare everywhere in your tooling.\n\n**Rice's theorem generalizes it, and this is the version engineers should know:**\n**every non-trivial semantic property of programs is undecidable.** Not \"hard\" —\n**undecidable.** Does this program ever throw? Is this variable ever null? Are these two\nfunctions equivalent? Is this code dead? Does this ever access out of bounds?\n**All undecidable in general.**\n\n> **⚠️ GOTCHA — this is why your tools behave the way they do, and knowing it changes how\n> you use them.** A static analyzer cannot be simultaneously **sound** (no false negatives)\n> and **complete** (no false positives) and **terminating**. It must pick two. So:\n> - **Linters and most analyzers choose \"terminating + roughly useful\"** and accept both\n>   false positives and false negatives.\n> - **Sound analyzers** (used in avionics, automotive) accept **false positives** — they'll\n>   flag safe code — because missing a real bug is unacceptable.\n> - **Type systems** are decidable approximations that reject some correct programs.\n>   **When the compiler rejects code you know is fine, that is the theory, not a bug.**\n>\n> **The engineering consequence: stop asking for a tool with no false positives.** You are\n> asking for a solution to the halting problem. Ask instead which side of the trade-off the\n> tool sits on, and whether that matches your risk.\n\n### 4.2 Reductions — the most transferable skill here\n\n**[DURABLE] \"If I could solve B, I could solve A; A is impossible; therefore B is\nimpossible.\"** This is how nearly every undecidability and hardness result is proved, and\n**it is a reasoning pattern you can apply directly at work.**\n\nThe practical version: when a stakeholder asks for a feature, ask whether it reduces to\nsomething known impossible or known hard. *\"Detect all infinite loops before deployment\"*\nreduces to halting. *\"Find the optimal assignment across all these constraints\"* frequently\nreduces to something NP-hard (§6). **Recognizing the reduction saves you a quarter.**\n\n### 4.3 Other undecidable things you may encounter\nProgram equivalence. Whether a CFG is ambiguous. Whether two CFGs generate the same\nlanguage. The Post Correspondence Problem (the standard tool for proving other things\nundecidable). Type inference for some sufficiently expressive systems (§12 → `toc-type-systems-and-randomization`). Whether an\narbitrary Diophantine equation has a solution (Hilbert's 10th). **Some tile-matching and\nconfiguration problems** — which is why certain package-resolution and layout problems are\ngenuinely, formally hard.\n\n**[DURABLE] Undecidable does not mean useless.** Every practical tool works on a decidable\n*subset*, or accepts approximation, or uses a timeout. **Termination checkers, model\ncheckers, and dependent type systems all exist and work** — by restricting the problem, not\nby solving the impossible one.\n\n---\n\n## §5. Complexity Classes\n\n### 5.1 The map\n\n```\n    P  ⊆  NP  ⊆  PSPACE  ⊆  EXPTIME\n    │      │       │\n    │      │       └── games, quantified formulas, some planning\n    │      └────────── verifiable in poly time (SAT, TSP-decision, scheduling…)\n    └───────────────── solvable in poly time\n    \n  ⚠️ We know P ≠ EXPTIME (time hierarchy theorem).\n     We do NOT know whether P = NP, NP = PSPACE, or P = PSPACE.\n```\n\n**[DURABLE] The definition of NP that actually helps engineers**: not \"solvable by a\nnondeterministic machine\" but **\"a proposed solution can be checked quickly.\"** If someone\nhands you an assignment, can you verify it in polynomial time? Then it's in NP. **That\nframing makes NP-membership obvious for most problems you'll meet.**\n\n**NP-hard**: at least as hard as everything in NP. **NP-complete**: in NP *and* NP-hard —\nthe hardest problems in NP, all equivalent under polynomial reduction.\n**⚠️ NP-hard problems need not be in NP** — optimization versions and problems outside NP\nare often NP-hard without being NP-complete, and the distinction matters when someone\nclaims a \"solution.\"\n\n**co-NP** contains problems whose *no*-instances are easily verified. **Tautology checking\nis co-NP-complete** — which is why proving a formula always true is structurally harder to\ncertify than finding a counterexample.\n\n### 5.2 Some honest cautions\n\n**⚠️ Polynomial ≠ fast.** An O(n¹⁰⁰) algorithm is polynomial and useless. Galactic\nalgorithms with enormous constants are polynomial and never run. **P is a robust\ntheoretical boundary, not a promise about your latency budget.**\n\n**⚠️ Asymptotics hide constants and cache behaviour.** For real n, an O(n log n) algorithm\nwith terrible locality routinely loses to an O(n²) one that fits in cache. **Measure**\n(§9 → `toc-beyond-np-space-and-distributed-limits` makes this precise in the other direction).\n\n**⚠️ Worst case ≠ your case.** Quicksort is O(n²) worst case and the practical default.\nSimplex is exponential worst case and dominates linear programming in practice.\n**This gap is the entire subject of §6.3.**\n\n---\n\n## §6. Your Problem Is NP-Hard. Now What?\n\n**[DURABLE] This is the section with the most direct daily value, and the one most\nengineers get wrong in both directions** — either despairing, or not recognizing the\nhardness at all and shipping something that falls over at scale.\n\n### 6.1 Recognizing it\n\n**The canonical problems worth knowing by sight**, because your problem is usually one of\nthem wearing a business costume:\n\n| Problem | Shows up as |\n|---|---|\n| **SAT \u002F 3-SAT** | Configuration, feature flags, dependency resolution |\n| **Knapsack \u002F Subset Sum** | Budget allocation, resource packing, cart optimization |\n| **Bin Packing** | VM placement, container scheduling, shipping |\n| **Graph Coloring** | Register allocation, scheduling with conflicts, frequency assignment |\n| **TSP \u002F Vehicle Routing** | Delivery, tool-path, sequencing anything |\n| **Set Cover** | Minimum test suite, sensor placement, feature selection |\n| **Clique \u002F Independent Set** | Compatibility groups, conflict-free selection |\n| **Scheduling with constraints** | Almost every scheduling problem you'll be handed |\n| **Integer Programming** | ⚠️ **The general form of most of the above** |\n\n**[DURABLE] The tell**: you're choosing a subset or an ordering, constraints interact, and\na greedy choice early can be shown to force a bad outcome later. **When a problem has that\nshape, look for the reduction before you start optimizing.**\n\n### 6.2 The escape hatches, in order of usefulness\n\n```\n1. IS THE INPUT SMALL?           n=20 exhaustive search is instant. Check first.\n2. IS IT ACTUALLY THE HARD CASE? Real inputs are structured; §6.3\n3. USE A SOLVER                  SAT\u002FSMT\u002FMIP\u002FCP — §7. Often the right answer\n4. APPROXIMATE                   Many NP-hard problems have provable ratio bounds\n5. HEURISTIC                     Greedy, local search, simulated annealing, GA\n6. FIXED-PARAMETER TRACTABLE     f(k)·poly(n) — exponential only in a small parameter\n7. PSEUDO-POLYNOMIAL             Knapsack is O(nW) — fine if W is small\n8. SPECIAL CASE                  Is your graph a tree? planar? bounded treewidth?\n9. RELAX THE PROBLEM             ⚠️ Often the real answer: does the business need OPTIMAL?\n10. CHANGE THE PROBLEM           Ditto\n```\n\n**[DURABLE] #9 and #10 deserve more attention than they get.** \"Optimal\" is usually a\nrequirement someone assumed rather than one the business stated. **A solution within 2% of\noptimal, computed in 100 ms, beats an optimal one computed in six hours** for nearly every\nreal application — and asking that question is often worth more than any algorithm.\n\n**Approximation with guarantees** is genuinely useful: Vertex Cover has a simple 2-approx;\nSet Cover has a ln(n) approximation and **that's provably the best possible unless P = NP**;\nMetric TSP has classical constant-factor results. **⚠️ Some problems are hard even to\napproximate** — that's the PCP theorem's practical legacy, and it means \"just approximate\nit\" is not always available.\n\n### 6.3 The most important practical caveat\n\n**[DURABLE] NP-hardness is a statement about worst-case inputs over all instances. It says\nnothing about yours.**\n\nReal instances have structure: dependency graphs are sparse and near-acyclic, schedules\nhave natural clustering, configuration constraints are mostly independent. **Modern SAT\nsolvers routinely handle industrial instances with millions of variables** (§7) — instances\nthat are formally NP-complete and empirically easy.\n\n**⚠️ The failure mode in both directions:**\n- **Giving up because it's NP-hard**, when a solver would have done it in a second.\n- **Assuming it'll be fine because it worked in testing**, when your test data was\n  structured and production data isn't. **The exponential is still there and it will find\n  you.** Set timeouts, have a fallback, and monitor solve times.\n\n---\n\n## §7. SAT, SMT, and Solvers\n\n**[DURABLE] The single most useful practical lesson in complexity for working engineers:\nNP-complete does not mean unsolvable, and there is mature, free tooling that will do it\nfor you.**\n\n**SAT** — Boolean satisfiability. The first problem proved NP-complete (Cook–Levin), and\nthe one where the gap between theory and practice is widest. Modern **CDCL** solvers\n(conflict-driven clause learning, with unit propagation, watched literals, restarts,\nclause learning) have made SAT solving one of the great practical successes in CS — the\nliterature's own phrase for it is **\"the unreasonable effectiveness of SAT solvers.\"**\n\n**SMT** — SAT plus theories: integers and reals, bit-vectors, arrays, strings, algebraic\ndatatypes, uninterpreted functions. **This is what makes it useful for software**, because\nyour constraints aren't Boolean.\n\n**[VERSIONED] The tools**: **Z3** (Microsoft — general-purpose, the default, especially\nstrong on quantifier-free arithmetic and arrays), **cvc5** (strings, algebraic datatypes,\nadvanced arithmetic), **Bitwuzla** (bit-vectors and floating point; successor to\nBoolector), **Yices 2** (fast on linear arithmetic and bit-vectors), **MathSAT**\n(interpolation, model generation), and **CaDiCaL**\u002F**Kissat** on the pure-SAT side.\n**MiniZinc\u002FOR-Tools** for constraint programming; **Gurobi\u002FCPLEX\u002FHiGHS** for MIP.\n\n**Where they're actually used**: **program verification** (Dafny, Verus, F\\*, Viper,\nCreusot, and the whole bounded-model-checking family), **symbolic execution** and test\ngeneration, **type checking** for refinement types, **package dependency resolution**\n(PubGrub and friends), **scheduling and configuration**, and **hardware verification**,\nwhich is where the money was that built these tools.\n\n> **⚠️ GOTCHA — the practical failure modes of solvers, which nobody warns you about:**\n> - **Encoding dominates everything.** The same problem stated two ways can differ by\n>   orders of magnitude. **Move as much of the problem outside the solver as you can** —\n>   the solver is the scalability bottleneck, so preprocessing pays enormously.\n> - **⚠️ Instability is real and under-appreciated.** Semantically identical queries can\n>   flip between solved and timed-out based on trivial syntactic differences — variable\n>   naming, term ordering, formula shape. Research on program-verification workloads has\n>   measured this directly and built tooling specifically to normalize queries and\n>   stabilize solve times. **If your CI intermittently fails a verification step, this may\n>   be why, and it is not your logic being wrong.**\n> - **Non-linear arithmetic is where solvers fall over**, and disabling the non-linear\n>   solver is a known stabilization technique in production verification work.\n> - **Always set a timeout and handle `unknown`.** `unknown` is a real answer, not an error.\n> - **Solvers disagree**, and portfolio approaches (dispatch to whichever solver suits the\n>   theory) are standard in serious tools for exactly that reason.\n",{"name":5,"description":7},"develop","ae32736a1aabddabca5d2c96d665aa0ebc7d8700","src\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Ftheory-of-computation\u002Fskills\u002Ftoc-computability-and-complexity",3,"https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey","https:\u002F\u002Fthe-vibey-project.github.io\u002Fvibey\u002F","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project","https:\u002F\u002Fvibewithadam.matthewsteinberger.com","freedom for software engineers","2026-11-15 05:47:42",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add the-vibey-project\u002Fvibey --skill toc-computability-and-complexity",{"tool":40,"command":41},"bunx","bunx skills add the-vibey-project\u002Fvibey --skill toc-computability-and-complexity",{"tool":43,"command":44},"pnpm","pnpm dlx skills add the-vibey-project\u002Fvibey --skill toc-computability-and-complexity","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Ftheory-of-computation\u002Fskills\u002Ftoc-computability-and-complexity\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7AT1FQJAE1FQYAMDTF490Y4","white-paper-writing","Use when writing white papers, technical reports, policy documents, thought leadership pieces, or any long-form authoritative document. Triggers on requests to write, structure, outline, or review white papers, technical reports, position papers, policy briefs, or evidence-driven arguments. Also use for B2B content marketing strategy, technical documentation requiring authority, academic-style reports, or any document that must educate while persuading. Use when someone asks \"how should I structure this\" for a long-form document.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fwhite-paper-writing\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7AT16BJRJJKK2MASXRZS76G","prose-technical-mechanics","Use when editing or writing prose at a technical\u002Fmechanical level: choosing between Anglo-Saxon and Latinate diction, placing information in topic vs stress positions, writing periodic vs cumulative sentences, handling sentence rhythm, punctuation as logic, transitions, paragraph structure, or phonesthetics. Use when someone wants to understand WHY prose works or doesn't, not just surface-level style advice. Triggers on word choice, sentence structure, emphasis, rhythm, diction, or any deep writing mechanics question.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-technical-mechanics\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7AT0W9HT0ZZ9Y287NW99MR3","prose-mechanics","Use when writing, editing, or analyzing prose style; when trying to avoid generic AI-sounding writing; when applying specific prose styles such as journalistic, academic, narrative, KJV biblical, Hemingway plain, Latinate\u002FJamesian, Orwellian, Augustan, Victorian, Early Modern (Bacon, Browne, Milton), or free indirect discourse; or when coaching someone on writing voice and mechanics. Triggers on any request to improve, analyze, or write in a specific prose style, to fix \"AI-sounding\" writing, to make prose more vivid or concrete, to vary sentence rhythm, or to understand how a particular writer achieves their effects.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-mechanics\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7AT0KR635JX66X2X6F3E2CP","narrative-structure","Use when structuring stories, pitches, presentations, white papers, or any persuasive narrative; analyzing the hero's journey in fiction or non-fiction; applying StoryBrand for business communication; designing narrative arcs for thought leadership; or understanding Vogler, Snyder, Propp, or Campbell frameworks. Triggers on any narrative structure, storytelling, pitch structure, StoryBrand, hero's journey, three-act structure, Freytag, Save the Cat, narrative arc, or \"how should I structure this story\u002Fpitch\u002Fpresentation\" request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fnarrative-structure\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7AT0AKGW09NKKZDYBT8VRDE","legal-brief-writing","Use when writing legal briefs, motions, or any court filing; when analyzing judicial cognition and persuasion; when applying elite brief-writing techniques from Roberts, Clement, Kagan, Garner; or when structuring legal arguments for maximum persuasion. Also use for autistic\u002Fneurodivergent advocates who need to understand how their natural communication style maps to elite legal advocacy. Triggers on any legal writing, brief drafting, motion preparation, or legal argument structuring request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Flegal-brief-writing\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7AT00VWPS4Q8B5VEMXX9NQT","journal-publishability-criteria","Use whenever a research paper, article or preprint is being written, revised, reviewed or published, and specifically before every publication of docs\u002Fpaper.md. Covers what legitimate journals actually gate on, in order of gating — the editor's desk screen (scope, novelty, package problems), what reviewers judge (methodological soundness, claims the evidence can carry, statistical and qualitative reporting), EQUATOR reporting guidelines, the ICMJE authorship criteria, COPE's view of text recycling, the near-universal generative-AI policy (no AI author, disclosure, author responsibility), TOP 2025 transparency standards, how to verify a journal is legitimate, submitting without an institution, and a pre-submission checklist. Triggers on requests to evaluate, review, prepare or submit a paper, to judge publishability, to write a declarations or data-availability section, to disclose AI use, or to check a journal.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fjournal-publishability-criteria\u002FSKILL.md",[],[]]