cs-formal
Formal methods: type theory HoTT/System F, logic, Hoare triples, TLA+, Coq/Lean verification
What this skill does
# cs-formal
## Purpose
This skill provides tools for applying formal methods in computer science, including type theory (HoTT and System F), logic systems, Hoare triples, TLA+ for model checking, and verification in Coq or Lean. Use it to prove program correctness and verify specifications.
## When to Use
Apply this skill when verifying software properties, such as concurrency bugs in distributed systems (e.g., with TLA+), proving theorems in dependent types (e.g., HoTT), or checking code invariants via Hoare triples. Use it for safety-critical code, academic proofs, or integrating formal verification into development workflows.
## Key Capabilities
- Parse and verify Hoare triples: e.g., {P} C {Q} for pre/post conditions.
- Generate TLA+ specifications for model checking concurrent systems.
- Interact with Coq/Lean for theorem proving, including inductive types and tactics.
- Evaluate type theory constructs, like System F polymorphic functions.
- Export proofs or models as JSON for integration, using OpenClaw's API.
## Usage Patterns
Invoke this skill via OpenClaw's CLI for interactive sessions or API for scripted workflows. For CLI, prefix commands with `openclaw cs-formal`. Use API endpoints like `/api/cs-formal/verify` with JSON payloads. Always specify the tool (e.g., --tool coq) and input file. For pipelines, chain with other skills by piping output, e.g., verify a TLA+ model then analyze results.
## Common Commands/API
Use OpenClaw's CLI for direct execution:
- `openclaw cs-formal verify --tool coq --file proof.v --tactic induction`: Runs a Coq proof on proof.v using the induction tactic.
- `openclaw cs-formal check-hoare --pre "{x > 0}" --code "x = x + 1" --post "{x > 1}"`: Verifies a Hoare triple.
- `openclaw cs-formal model --tool tla --spec "Init == ... Next == ..."`: Generates and checks a TLA+ model.
For API calls, use POST requests to `https://api.openclaw.ai/cs-formal/verify` with a JSON body like:
```json
{"tool": "lean", "file": "theorem.lean", "options": {"tactic": "simp"}}
```
Set authentication via environment variable: `$OPENCLAW_API_KEY` in headers, e.g., `Authorization: Bearer $OPENCLAW_API_KEY`. Config files should be in YAML format, e.g.:
```yaml
tool: coq
file: proof.v
tactics:
- intro
- apply
```
## Integration Notes
Integrate with IDEs like VS Code by adding OpenClaw as a plugin, configuring it in your .openclawrc file with: `cs-formal: { apiKey: $OPENCLAW_API_KEY, defaultTool: "tla" }`. For CI/CD, use scripts like `export OPENCLAW_API_KEY=your_key; openclaw cs-formal verify --tool lean --file path/to/file`. Combine with other skills, e.g., pipe output to a "debugging" skill for error analysis. Ensure dependencies like Coq or TLA+ are installed via `apt install coq` or similar.
## Error Handling
Check for common errors like syntax issues in TLA+ specs (e.g., missing operators) by running `openclaw cs-formal lint --tool tla --file spec.tla`, which returns JSON with error codes (e.g., "TLA001: Undefined constant"). For proof failures in Coq, parse the output for "stuck" states and retry with adjusted tactics, e.g., if a tactic fails, use `openclaw cs-formal retry --tactic alternative`. Handle API errors by checking HTTP status codes (e.g., 401 for auth issues) and fallback to local mode if network fails. Always validate inputs, like ensuring Hoare triple conditions are well-formed strings.
## Concrete Usage Examples
1. **Verify a simple Hoare triple for a loop:** Use `openclaw cs-formal check-hoare --pre "{n >= 0}" --code "WHILE n > 0 INVARIANT n >= 0 DO n := n - 1 END" --post "{n = 0}"` to confirm the invariant holds, then export results for further analysis.
2. **Model check a concurrent system with TLA+:** Run `openclaw cs-formal model --tool tla --spec "CONSTANT N \\n VARIABLE x \\n Init == x = 0 \\n Next == x' = x + 1"` to detect deadlocks, and integrate the output into a testing pipeline.
## Graph Relationships
- Related to: "algorithms" (for logical proofs in algorithm design), "software-engineering" (for verification in code reviews), "data-structures" (for type theory applications in data modeling).
- Clusters: Connected via "computer-science" cluster for shared CS tools.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.