Skip to content

Add Hillel Wayne's two-thread counter as a first refinement example - #247

Closed
lemmy wants to merge 1 commit into
tlaplus:masterfrom
lemmy:mku-refinement
Closed

lemmy wants to merge 1 commit into
tlaplus:masterfrom
lemmy:mku-refinement

Conversation

@lemmy

@lemmy lemmy commented Oct 29, 2026

Copy link
Copy Markdown
Member

The refinement examples in this repository are too large to show what a refinement mapping is in a few minutes. @hwayne's two-thread counter from his blog post Specification Refinement fits on a page, and he agreed to add it here.

  • abstract.tla: two threads each increment a shared counter in one atomic step.
  • bad.tla: splits the increment into a read and a write. TLC finds the lost update, where both threads read 0 and both write 1, as a violation of Refinement.
  • good.tla: adds a lock. TLC verifies that it refines both abstract.tla and bad.tla.
  • good_proof.tla: proves both refinements with TLAPS (19 obligations).

Co-authored-by: Hillel Wayne 2660212+hwayne@users.noreply.github.com

The refinement examples in this repository are too large to show what a
refinement mapping is in a few minutes. Hillel Wayne's two-thread counter
from his blog post fits on a page. TLC finds the lost update when bad.tla
splits the increment into a read and a write, and verifies that good.tla,
which adds a lock, refines both abstract.tla and bad.tla. good_proof.tla
proves both refinements with TLAPS.

https://www.hillelwayne.com/post/refinement/

Co-authored-by: Hillel Wayne <2660212+hwayne@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Markus Alexander Kuppe <github.com@lemmster.de>
@lemmy

lemmy commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

dupe of #248

@lemmy lemmy closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant