skills/verification/specification-to-temporal-logic-generator/SKILL.md
Translates specifications into temporal logic formulas (LTL, CTL, or TLA) by matching the specification's shape to the right logic and operators. Use when formalizing requirements for any model checker, when choosing between LTL and CTL for a property, or when the user has a temporal claim and doesn't know which operators express it.
npx skillsauth add santosomar/general-secure-coding-agent-skills specification-to-temporal-logic-generatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Three logics, one job: saying precisely what "always" and "eventually" mean. The choice of logic is mostly dictated by your checker; the choice of formula is the craft.
| Logic | Time model | Checker | When it's the right fit |
| ----- | ----------------------- | ----------------- | ------------------------------------------------ |
| LTL | Linear — one future | Spin, NuSMV, most | "On every execution, X eventually holds" |
| CTL | Branching — many futures| NuSMV, nuXmv | "There exists an execution where..." / "on all branches..." |
| TLA | Linear + actions | TLC, TLAPS | Distributed systems; → requirement-to-tlaplus-property-generator |
LTL vs CTL: LTL quantifies over paths implicitly (every path). CTL quantifies explicitly (A = all paths, E = some path). The formula AG EF reset ("from any state, it's possible to reach reset") is CTL-only — LTL can't say "possible."
| English | LTL | CTL | Intuition |
| ---------------------- | ---------- | ------------- | ----------------------------------------------- |
| Always P | G P | AG P | P holds in every state (of every path) |
| Eventually P | F P | AF P / EF P | P holds in some future state |
| Next P | X P | AX P / EX P | P holds in the very next state |
| P until Q | P U Q | A[P U Q] | P keeps holding until Q does (and Q does happen)|
| P weak-until Q | P W Q | — | P until Q, OR P forever (Q optional) |
| Infinitely often P | G F P | AG AF P | P keeps recurring |
| Eventually always P | F G P | AF AG P | P stabilizes — becomes permanently true |
| It's possible to reach P | — | EF P | CTL-only. Some path reaches P. |
| P is always reachable | — | AG EF P | CTL-only. From anywhere, P is still possible.|
| Spec pattern | Formula | Logic |
| --------------------------------------------- | ---------------------------- | ----- |
| "P is an invariant" | G P | LTL |
| "Every request gets a response" | G (req → F resp) | LTL |
| "P never happens before Q" | ¬P W Q | LTL |
| "Between Q and R, P always holds" | G (Q → (P W R)) | LTL |
| "The system can always be reset" | AG EF reset | CTL |
| "There's no deadlock" | AG EX true | CTL |
| "Once P, always P" (stable) | G (P → G P) | LTL |
| "P and Q alternate" | G (P → X(¬P U Q)) ∧ G (Q → X(¬Q U P)) | LTL |
Spec: "After a successful login, the session token remains valid until logout or timeout, and it must become invalid immediately after either."
Decompose:
login_okU (strong until — one of the terminators must happen)logout ∨ timeoutX (next state)LTL:
G ( login_ok →
( valid U (logout ∨ timeout) ) -- valid until one fires
∧
( (logout ∨ timeout) → X ¬valid ) -- and then immediately invalid
)
Caveat: The second conjunct is subtle — it says "whenever logout/timeout is true, next state is invalid." But that's global, not scoped to this session. If logout can happen without a preceding login, the formula is too strong. Tighter:
G ( login_ok →
( valid ∧ ¬logout ∧ ¬timeout ) U ( (logout ∨ timeout) ∧ X ¬valid )
)
Now the "and then invalid" is part of the Until's right-hand side — it only applies to this session's termination.
After writing a formula, ask: is it trivially true?
G (false → P) is always true — false never holds.G (req → F resp) — if req never occurs in the model, this passes. Meaningless.F P — if P is true in the initial state, this says nothing about the future.Run the checker with a "witness" property too: F req should be satisfiable, confirming req actually happens.
E.G F P with F G P. "Infinitely often" ≠ "eventually always." A blinking light satisfies G F on but not F G on.U when you mean W. P U Q requires Q to eventually hold. If Q might never happen and that's okay, use W (weak until).## Spec (as given)
<verbatim>
## Logic
<LTL | CTL | TLA> — <why this logic>
## Formula
<temporal logic>
## Decomposition
<english phrase> ↦ <sub-formula>
## Vacuity check
<witness property that should also hold — confirms the antecedent fires>
development
Extracts human-readable pseudocode from a verified formal artifact (Dafny, Lean, TLA+) while preserving the verified properties as annotations, so the proof-carrying logic can be reimplemented in a production language. Use when porting verified code to an unverified target, when documenting what a formal spec actually does, or when handing a verified algorithm to an implementer.
development
Translates natural-language or pseudocode descriptions of concurrent and distributed systems into TLA+ specifications ready for the TLC model checker. Identifies state variables, actions, type invariants, safety properties, and liveness properties from the description. Use when formalizing a protocol, when the user describes a distributed algorithm to verify, when designing a consensus or locking scheme, or when starting formal verification of a concurrent system.
testing
Reduces a TLA+ model so TLC can actually check it — shrinks constants, adds state constraints, abstracts data, or applies symmetry — when the state space is too large to enumerate. Use when TLC runs out of memory, when checking takes hours, or when a spec works at N=2 and you need confidence at larger scale.
development
TLA+-specific instance of model-guided repair — reads a TLC error trace, identifies the enabling condition that should have been false, strengthens the corresponding action, and maps the fix to source code. Use when TLC reports an invariant violation or deadlock and you have the code-to-TLA+ mapping from extraction.