Git Product home page Git Product logo

tlaplus_repl's Introduction

TLA+ REPL

August 2023 Update: In addition to the REPL that is now included in TLC, see also the web-based REPL prototype, which provides most of the same functionality with faster evaluation speed and without a need to install any TLA+ tools locally.

June 2020 Update: The newest versions of TLC include a built in REPL that provides most of the same functionality provided in this Python tool with considerably lower evaluation latency. You can use it by running java -cp tla2tools.jar tlc2.REPL from the command line.


This is a Python based REPL for evaluating TLA+ expressions. It provides an easy, interactive way to debug TLA+ expressions and can help when learning or experimenting with the language. It uses the TLC model checker to evaluate TLA+ expressions.

Usage:

$ python tla_repl.py

Here is an example of evaluating expressions in a REPL session:

-------------------------------------------------------------------------------------
 Welcome to the TLA+ REPL! This REPL uses the TLC model checker
 to evaluate TLA+ expressions interactively. It is meant as an
 aid for learning TLA+ and debugging TLA+ specs.
-------------------------------------------------------------------------------------
(TLA+REPL) >>> 2 + 2
4
(TLA+REPL) >>> {1,2,3} \X {3,4,5}
{ <<1, 3>>,
  <<1, 4>>,
  <<1, 5>>,
  <<2, 3>>,
  <<2, 4>>,
  <<2, 5>>,
  <<3, 3>>,
  <<3, 4>>,
  <<3, 5>> }
(TLA+REPL) >>> CHOOSE x \in {1,2,3,4} : x > 2
3
(TLA+REPL) >>> S == {1,2,3}
(TLA+REPL) >>> T == {4,5,6}
(TLA+REPL) >>> S \cup T
{1, 2, 3, 4, 5, 6}
(TLA+REPL) >>> quit
Goodbye!

Note that you can define variables that can be used later on in the session, by using the standard TLA+ syntax for definitions i.e. var == <some_expr>.

The evaluation of expressions in the interactive REPL is a bit slow, since it starts up a new instance of the TLC model checker each time. The feedback loop for experimentation is still considerably better than what is currently provided by the TLA+ Toolbox IDE. Eventually TLC may support some kind of "interactive" mode natively, which would make it much easier to build a performant and robust REPL.

Setup

In order to use the REPL, you must have the TLA+ tools installed and they must be present in your CLASSPATH environment variable. There is a helper script that will download the tools and add their directory to your CLASSPATH for the current running shell. You can run:

$ source setup_tlc.sh

to set up the tools. After that, you should be able to start up the REPL and it should work correctly. You can always test if you have the TLA+ tools installed correctly by running the following command, which invokes the TLC model checker:

$ java tlc2.TLC

You should get an output like the following:

TLC2 Version 2.11 of 05 January 2018
Error: Error: Missing input TLA+ module.
Usage: java tlc2.TLC [-option] inputfile

tlaplus_repl's People

Contributors

will62794 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tlaplus_repl's Issues

On Windows 2+2 evaluates to error

I just tried the REPL on Windows.
2+2 evaluates to an error.

In function tlc_eval, changing from
lines = raw_out.split("\n")
to
lines = raw_out.split("\r\n")

solved my issue.

S.

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.