AgentSkillsCN

smt-solver-interface

与SMT求解器对接,实现程序正确性的自动化推理。

SKILL.md
--- frontmatter
name: smt-solver-interface
description: "Interface with SMT solvers for automated reasoning about program correctness."
version: "1.0.0"
tags: [verification, smt, z3, popl]
difficulty: intermediate
languages: [python, c++, rust]
dependencies: [hoare-logic-verifier, model-checker]

SMT Solver Interface

SMT (Satisfiability Modulo Theories) solvers combine SAT solving with decision procedures for theories like arrays, bitvectors, and arithmetic. They are essential tools for program verification and synthesis.

When to Use This Skill

  • Verifying program correctness
  • Solving constraint problems
  • Automated theorem proving
  • Program synthesis
  • Test generation

What This Skill Does

  1. Constraint Encoding: Translate program properties to SMT formulas
  2. Solver Invocation: Call SMT solvers (Z3, CVC5, etc.)
  3. Model Extraction: Get satisfying assignments
  4. Unsat Cores: Identify conflicting constraints
  5. Incremental Solving: Reuse solver state

Key Concepts

ConceptDescription
SATBoolean satisfiability
SMTSAT + theories (arrays, bitvectors, etc.)
TheoryDecision procedure for specific domain
ModelSatisfying assignment
Unsat CoreMinimal unsatisfiable subset

Tips

  • Use incremental solving for efficiency
  • Choose appropriate theories for your domain
  • Use quantifiers sparingly (expensive)
  • Extract unsat cores for debugging
  • Profile solver time for large problems

Common Use Cases

  • Program verification
  • Test generation
  • Program synthesis
  • Configuration analysis
  • Security analysis

Related Skills

  • hoare-logic-verifier - Uses SMT for verification
  • model-checker - Alternative verification approach
  • symbolic-execution-engine - Generates SMT constraints
  • refinement-type-checker - SMT-based checking

Canonical References

ReferenceWhy It Matters
De Moura, Bjørner "Z3: An efficient SMT solver"Z3 paper
Barrett, Tinelli "Satisfiability Modulo Theories"SMT overview
Kroening, Strichman "Decision Procedures"Comprehensive book

Tradeoffs and Limitations

Approach Tradeoffs

ApproachProsCons
Z3Powerful, well-documentedCan be slow
CVC5Good for theoriesLess common
Mono-solvingSimpleNot incremental

When NOT to Use This Skill

  • Decidable problems (use specialized algorithms)
  • When model checking is more appropriate
  • Very large formulas (may not scale)

Limitations

  • Quantifiers can cause undecidability
  • Non-linear arithmetic is hard
  • Solver performance varies

Assessment Criteria

A high-quality implementation should have:

CriterionWhat to Look For
CorrectnessSound encoding
EfficiencyAppropriate theory selection
UsabilityClear error messages
RobustnessHandles solver timeouts

Quality Indicators

Good: Correct encoding, incremental solving, model extraction ⚠️ Warning: Incorrect encoding, no timeout handling ❌ Bad: Soundness bugs, crashes on large inputs

Research Tools & Artifacts

Real-world SMT solvers:

ToolWhy It Matters
Z3Microsoft SMT solver
CVC5SMT solver
BoolectorBitvector solver
Alt-ErgoProof assistant

Key Solvers

  • Z3: Production SMT
  • CVC5: Research solver

Research Frontiers

Current SMT research:

DirectionKey PapersChallenge
Arithmetic"Nonlinear SMT"Reals
Quantifiers"Quantifier Instantiation"Automation

Hot Topics

  1. SMT for verification: Program verification
  2. SMT for synthesis: Program synthesis

Implementation Pitfalls

Common SMT bugs:

PitfallReal ExamplePrevention
EncodingWrong encodingVerify
TimeoutSolver timeoutTimeout