Tlaplus Specs Save

Different TLA+ specifications, mostly for learning purposes

Project README

Different TLA+ specifications, mostly for learning purposes

CigaretteSmokers.tla

A specification of the Cigarette smokers problem. The generated state graph is very small:

spec1

fig1

Blinker.tla

Simple spec simulating, more or less, this application. Three state machines controlling three LEDs. With 100ms resolution (model run with BC <- <<3, 5, 7>>) model checker finds 384 distinct states:

spec2

fig2

Just a humble reminder to never underestimate even the simplest concurrent programs, I guess :smiley:

GameOfLife.tla

Conway's Game of Life

spec3

All the 'attractors' for a 3x3 grid

fig3

State space for a 4x4 grid - original image generated by Graphviz is around 300MB :smiley::

fig4

The same with some colors based on number of occupied cells:

fig5

Zoom on two of the smaller clusters:

fig6

fig7

Under 'symmetry group of the square' (D4) view in TLC the state space shrinks to ... 27 states. Under this view it's even possible to run TLC on 5x5 grid and get 486 states (reduction from 33554432):

fig8

Base Graphviz parameters:

dot -Tpng -Nstyle=filled -Npenwidth=5 -Epenwidth=8 -Ksfdp -Goverlap=prism -Goverlap_scaling=-10

Requirements.tla

Experimental specification aimed at mechanising verification of written requirements documents.

spec4

spec5

Checking CheckRequirements spec produces:

fig9

SlidingPuzzles.tla

Solution to a variation of sliding block puzzle most commonly known as Klotski.

spec6

TLC finds 25955 distinct states. Green node is the starting position. Red nodes are the goal nodes - with the biggest piece in center-bottom position.

fig10

The Pennant variation has significantly smaller state space of 'only' 1398 states. Raymond Hettinger talked about this puzzle and the state graph here.

W == 4 H == 5

Pennant == {{<<0, 0>>, <<0, 1>>, <<1, 0>>, <<1, 1>>},
            {<<2, 0>>, <<3, 0>>}, {<<2, 1>>, <<3, 1>>},
            {<<0, 2>>}, {<<1, 2>>},
            {<<0, 3>>, <<0, 4>>}, {<<1, 3>>, <<1, 4>>},
            {<<2, 3>>, <<3, 3>>}, {<<2, 4>>, <<3, 4>>}}
            
PennantGoal == {<<0, 3>>, <<0, 4>>, <<1, 3>>, <<1, 4>>} \in board

fig11

Ma's Puzzle has 110804 distinct states.

W == 5 H == 5

Mas == {{<<0, 0>>, <<1, 0>>, <<2, 0>>},
        {<<3, 0>>, <<4, 0>>,<<4, 1>>},
        {<<0, 1>>, <<1, 1>>}, {<<2, 1>>, <<3, 1>>},
        {<<0, 2>>, <<0, 3>>, <<1, 3>>},
        {<<1, 2>>, <<2, 2>>}, {<<3, 2>>, <<4, 2>>},
        {<<2, 3>>, <<3, 3>>, <<4, 3>>},
        {<<2, 4>>}}
        
MasGoal == {{<<3, 0>>, <<4, 0>>,<<4, 1>>}, {<<3, 1>>, <<3, 2>>, <<4, 2>>}} \subseteq board

fig12

Chameneos.tla

A specification of a 'concurrency game' requiring concurrent and symmetrical cooperation - link

fig13

For N=3 there are 522 distinct states:

fig14

The lattices at the edges are due to the possible orders in which the chameneoses fade.

For N=4 there are 6652 distinct states:

fig15

All the above graphs are for single initial permutation of chameneoses. Here is a full graph for N=2, M=4 (4843 distinct states).

fig16

Watchdog.tla

fig17

fig18

Scheduler.tla

fig19

State diagram for 3-task configuration:

fig20

Sample trace rendered graphically. Can you spot when the sequence starts repeating?

fig21

Open Source Agenda is not affiliated with "Tlaplus Specs" Project. README Source: mryndzionek/tlaplus_specs
Stars
29
Open Issues
0
Last Commit
1 month ago

Open Source Agenda Badge

Open Source Agenda Rating