Logo van Nw Formal Verification Tlaplus

Nw Formal Verification Tlaplus

Organisatie
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.

Overzicht

UitgevernWave-ai
RepositorynWave
Skillnaamnw-formal-verification-tlaplus
Sterren
616
Forks
65
Meegeleverde bestanden
Alleen instructies
LicentieMIT
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Compleet zonder extra bestanden

    Alles wat het model nodig heeft, staat in de instructies — geen extra bestanden om te synchroniseren.

  • Open source

    Gepubliceerd door nWave-ai op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Nw Formal Verification Tlaplus in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/nWave-ai/nWave/tree/main/nWave/skills/nw-formal-verification-tlaplus
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die 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 na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Nw Formal Verification Tlaplus in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Nw Formal Verification Tlaplus automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Nw Formal Verification Tlaplus niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

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/

Veelgestelde vragen

Wat doet de AI-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.

Waarom Nw Formal Verification Tlaplus gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Nw Formal Verification Tlaplus bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Nw Formal Verification Tlaplus in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/nWave-ai/nWave/tree/main/nWave/skills/nw-formal-verification-tlaplus. TypingMind leest het bestand SKILL.md en installeert het als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Nw Formal Verification Tlaplus gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Nw Formal Verification Tlaplus gebruiken?

Zoveel als je wilt. Je kunt Nw Formal Verification Tlaplus gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Nw Formal Verification Tlaplus gratis?

Ja. Deze skill is door nWave-ai op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇