Coder Social home page Coder Social logo

tlaplus_specs's Introduction

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 ๐Ÿ˜ƒ

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 ๐Ÿ˜ƒ:

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

tlaplus_specs's People

Contributors

mryndzionek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

lemmy

tlaplus_specs's Issues

State graphs with Graphviz

Hi, it is a very nice job. I am wondering how did you generate the fancy state graphs, such as this and this? I failed to reproduce them using the built-in Graphviz tool of TLC Toolbox. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.