Giter Club home page Giter Club logo

tlaplustocubicle's Introduction

Overview

TlaplusToCubicle is a software to translate a spec written in a fragment of TLA+ producing an equivalent spec in Cubicle input language. Such a translator is useful for TLA+ specs that are defined by parametrized transition systems with states represented as arrays indexed by an arbitrary number of processes. For checking this type of classes, Cubicle model checker shows good results.

Assumptions and Limitations

We assume that the input spec is written by a TLA+ fragment described by the grammer defined by a Menhir-generated parser.

Example

To translate the Berkeley spec described below, we save it in a .tla file Berkeley.tla

-------------------------- MODULE Berkeley --------------------------
EXTENDS  TLC
CONSTANTS  Proc
VARIABLES A 
TypeOk == A \in [Proc ->  { "Idle"  , "Wait" , "Crit",  "Crash" } ] 
Init ==  A = [obj \in Proc |-> "Idle"] 
Safety(z1,z2) ==   z1 # z2 => (~(A[z1] = "Crit") \/ ~(A[z2] = "Crit")) 
tr1(z) ==  A[z] = "Idle"
           /\ A' = [ j \in Proc |-> CASE  j=z -> "Wait"
                                           [] j < z -> A[j] 
                                           []  z<j /\ A[j]="Idle" ->  A[j]
                                           [] OTHER -> "Crash" ] 

tr2(z) ==  A[z] = "Wait"
          /\ A' = [ j \in Proc |-> CASE  j=z -> "Crit"
                                           [] j> z -> A[j] 
                                           []  z>j /\ A[j]="Idle" -> "Idle"
                                           [] OTHER -> "Crash" ]                              
tr3(z) ==  A[z] = "Crit"
          /\ A'=[A EXCEPT ![z]="Idle"]

Next== \E z \in Proc :  tr1(z)
                       \/ tr2(z)
                       \/ tr3(z)  

     
===============================

Then, we run the following commands:

make
./Tla2Cubicle <Berkeley.tla>

The file output.cub is then generated containing the translation of the specification:

type string_type =Idle | Wait | Crit | Crash
 array A[proc] : string_type 

init (z) {A[z]=Idle} 
unsafe (z1 z2) {(A[z1] = Crit) && (A[z2] = Crit) } 

transition Next_1 (z) 
requires {
A[z] = Idle}
{
A[j] := case 
| j = z : Wait 
| j  <  z : A[j] 
| ( z  <  j ) && ( A[j] = Idle ) : A[j] 
| _ : Crash ; 
}

transition Next_2 (z) 
requires {
A[z] = Wait}
{
A[j] := case 
| j = z : Crit 
| j  >  z : A[j] 
| ( z  >  j ) && ( A[j] = Idle ) : Idle 
| _ : Crash ; 
}

transition Next_3 (z) 
requires {
A[z] = Crit}
{
A[j] := case | j = z : Idle | _ :  A[j]; }

tlaplustocubicle's People

Contributors

gkrait avatar muenchnerkindl avatar

Watchers

 avatar  avatar

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.