Logo: Nw Formal Verification Tlaplus

Nw Formal Verification Tlaplus

Organisatioun
nWave-ai
nw-formal-verification-tlaplus

TLA+ and PlusCal for specifying distributed system invariants. Decision heuristics for when formal verification adds value, key patterns, state explosion management, and alternatives comparison.

Iwwersiicht

EditeurnWave-ai
RepositorynWave
Skill-Nummnw-formal-verification-tlaplus
Stären
616
Forks
65
Matgeliwwert Dateien
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    nWave-ai huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Nw Formal Verification Tlaplus an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/nWave-ai/nWave/tree/main/nWave/skills/nw-formal-verification-tlaplus
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nWave-ai/nWave.git /tmp/nWave
mkdir -p .claude/skills
cp -r /tmp/nWave/nWave/skills/nw-formal-verification-tlaplus .claude/skills/nw-formal-verification-tlaplus
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Nw Formal Verification Tlaplus an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Nw Formal Verification Tlaplus automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Nw Formal Verification Tlaplus net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Formal Verification with TLA+

When to Recommend Formal Verification

Decision Tree

Is the system distributed or concurrent?
|
+-- No --> Complex state machine with high failure cost?
|          +-- No --> NOT cost-effective. Use property-based testing.
|          +-- Yes --> CONSIDER TLA+
|
+-- Yes --> Consensus, coordination, or distributed transactions?
|           +-- Yes --> RECOMMEND TLA+
|           +-- No --> Could concurrency bug cause data loss or safety issues?
|                      +-- Yes --> RECOMMEND TLA+
|                      +-- No --> OFFER as option

Strong Indicators (Recommend)

DomainWhy TLA+ Adds ValueEvidence
Distributed consensus (Paxos, Raft)Subtle interleaving bugs in leader electionRaft TLA+ spec ~400 lines, found implementation bugs
Financial distributed transactionsAtomicity violations cause monetary lossAWS DynamoDB replication verified
Leader election, distributed lockingSplit-brain, deadlock, stale-lockAWS lock manager verified
Eventual consistency / CRDTsConvergence proofs requiredTLA+ CRDT framework verifies SEC
Safety-critical state machinesRegulatory requirementsDO-178C, CENELEC recognize formal methods
Multi-party coordination (sagas, 2PC)Compensation ordering, partial failure2PC is canonical TLA+ example
Data replication protocolsOrdering, consistency under failureElasticsearch, MongoDB, Cosmos DB verified

When NOT to Use

  • Simple CRUD (bugs are in implementation, not design)
  • Single-process without complex state machines
  • Prototypes/MVPs (design will change before verification completes)
  • Performance optimization (TLA+ models correctness, not performance)

Cost-Benefit Reference

  • Learning curve: 2-3 weeks to useful results (AWS engineers, all levels)
  • Typical spec effort: 2-4 weeks part-time for a distributed protocol
  • ROI highest when: bug cost is high, system is long-lived, protocol is novel, concurrency testing is impractical

Core Concepts for Architects

What TLA+ Specifies

TLA+ describes what a system should do (allowed behaviors), not how to implement it. Specifications are mathematical objects checked for correctness before any code exists.

Safety vs. Liveness

Property TypeMeaningExpressionExample
SafetyNothing bad happensInvariant: predicate true in every reachable state"Two processes never hold same lock"
LivenessSomething good eventually happensTemporal: <> (eventually), []<> (infinitely often)"Every request eventually gets response"

Safety violations produce counterexample traces (the debugging artifact). Liveness requires fairness conditions.

PlusCal vs. Raw TLA+

PlusCal compiles to TLA+ with programming-like syntax. Start with PlusCal for first 2-3 specs, then learn raw TLA+ for cases PlusCal cannot express.

Key PlusCal constructs: variables (state) | labels (atomic action boundaries) | either/or (nondeterministic choice) | await (blocking) | process \in 1..N (concurrent processes) | fair process (weak fairness)

Labels define concurrency granularity: everything between two labels is one atomic step. Two processes interleave only at label boundaries.

State Explosion Management

State space grows exponentially: (states per node)^(nodes) x (message permutations).

Containment Strategies

StrategyTechniqueImpact
Bound parametersStart with 2-3 nodes, 2-4 messagesMost bugs appear at small N
Symmetry reductionSYMMETRY Permutations(Nodes)Up to N! reduction
Reduce labelsMerge labels where fine-grained atomicity unnecessaryOrders of magnitude
State constraintsCONSTRAINT Len(log[n]) < MaxLogLengthPrune uninteresting states
AbstractionModel protocol not implementation (TCP -> message set)Dramatic reduction
DecompositionMultiple focused specs, not one monolithEach independently checkable
Progressive refinement2 nodes -> 3 nodes -> add failures -> add livenessIncremental verification
Simulation modejava -jar tla2tools.jar -simulate -depth 100Trades completeness for speed

Memory and Time Budgets

Unique StatesExpected TimeMemoryApproach
< 10KSeconds< 1 GBExhaustive, single thread
10K - 1MMinutes1-4 GBExhaustive, -workers auto
1M - 100MHours4-32 GBExhaustive with constraints
100M - 1BDays32-64 GBLarge instance or simulation
> 1BWeeks60+ GBSimulation, TLAPS, or decompose

Estimation Before Running

  1. Count distinct variable values in model
  2. Multiply domains together for baseline
  3. Start TLC with smallest parameters, observe state count
  4. Extrapolate: doubling a parameter typically squares or cubes the space

Key Specification Patterns

Two-Phase Commit (2PC)

  • Variables: rmState, tmState, tmPrepared, msgs
  • Safety: no RM commits while another aborts (Consistency)
  • State space: 3 RMs ~718 states, 5 RMs ~21,488 states
  • Common mistake: not modeling RM spontaneous abort or unreliable network

Distributed Consensus (Raft)

  • Variables: currentTerm, votedFor, log, state, votesGranted, msgs
  • Safety: at most one leader per term (ElectionSafety)
  • Safety: logs with same index+term are identical (LogMatching)
  • State space: 3 nodes, MaxTerm=2 ~10K-100K states

Saga (Compensating Transactions)

  • Variables: stepState, sagaState, compensateIdx
  • Safety: steps execute in order, compensations in reverse (OrderInvariant)
  • Safety: no completed steps remain after abort (CompensationComplete)
  • Common mistake: not enforcing reverse compensation order

Distributed Lock with Lease

  • Variables: lockHolder, leaseExpiry, clock, nodeState
  • Safety: at most one holder (MutualExclusion)
  • Models crash (node loses awareness) and lease expiry
  • Common mistake: not distinguishing server-side lock state from node belief

CRDT Convergence (G-Counter)

  • Variables: counters (vector per node)
  • Safety: counters monotonically non-decreasing
  • Liveness: all nodes eventually converge after merge
  • Common mistake: merge not commutative, associative, and idempotent

Alternatives Comparison

ToolBest ForLearningDistributed SystemsTemporal Properties
TLA+/PlusCalDistributed protocols, consensus2-3 weeksExcellentNative
AlloyData models, structural properties1-2 weeksAdequateLimited (Alloy 6)
Property-Based TestingImplementation correctnessHours-daysWith stateful testingNone
XState/StatechartsUI workflows, single-processDaysNot applicableNone
Session Types/ScribbleCommunication patternsModerateGood (message patterns)Implicit
TLAPS (proofs)Critical certificationMonthsExcellentFull

Combined Workflow (TLA+ + PBT)

  1. Write TLA+ spec during DESIGN wave; identify invariants
  2. Model-check with TLC to verify design
  3. Implement code during DELIVER wave
  4. Reuse TLA+ invariants as PBT properties
  5. PBT verifies implementation conforms to verified design

Architecture Decision Record Template

markdown
## Decision: Use TLA+ for [Component Name]

### Context
[Component] implements [protocol] with [N] participants
and [concurrency/distribution characteristics].

### Problem
Informal reasoning about [failure/interleaving scenario]
is insufficient because [reason].

### Decision
Formally specify [component] in TLA+/PlusCal and verify:
- Safety: [specific invariants]
- Liveness: [specific temporal properties]

### Model Parameters
- Nodes: [2-3 for initial verification]
- Messages: [bounded to N]
- Failure modes: [crash, partition, message loss]

### Estimated Effort
- Specification: [1-2 weeks]
- Model checking: [hours to days]

### Not Modeling (out of scope)
- [performance, serialization, UI, etc.]

Architect's Checklist

  1. Identify components with concurrency, distribution, or complex state machines
  2. Determine safety properties (what must NEVER happen)
  3. Determine liveness properties (what must EVENTUALLY happen)
  4. Estimate model parameters and state space
  5. Assess cost-effectiveness vs. alternatives (decision tree above)
  6. Document decision in ADR with specific invariants and properties
  7. Scope verification: focused specs per subsystem, not one monolith

Industry Precedent

OrganizationSystems VerifiedOutcome
AWS14 projects across 10 systems (DynamoDB, S3, EBS)Found subtle bugs in every system; management actively encourages adoption
Azure Cosmos DBAll 5 consistency levelsSpecs became authoritative reference, replaced ambiguous docs
MongoDBReplication, reconfiguration, transactionsLogless reconfig deployed since 4.4, no protocol bugs
ElasticsearchCluster coordination, data replication4 TLA+ specs + Isabelle proofs, open-sourced
CockroachDBTransaction layerTLA+ specs in repository under docs/tla-plus/

Heefeg gestallte Froen

Wat mécht de KI-Skill Nw Formal Verification Tlaplus?

TLA+ and PlusCal for specifying distributed system invariants. Decision heuristics for when formal verification adds value, key patterns, state explosion management, and alternatives comparison.

Firwat Nw Formal Verification Tlaplus op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Nw Formal Verification Tlaplus besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Nw Formal Verification Tlaplus an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/nWave-ai/nWave/tree/main/nWave/skills/nw-formal-verification-tlaplus an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Nw Formal Verification Tlaplus benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Nw Formal Verification Tlaplus benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Nw Formal Verification Tlaplus domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Nw Formal Verification Tlaplus gratis?

Jo. nWave-ai huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇