Skip to main content

pluscal

PlusCal AST and builder in Python

What Is This?

PlusCal is an algorithm language that compiles into a TLA+ specification. This library defines Python types that form an abstract syntax tree (AST) of the PlusCal P-Syntax grammar as well as a builder API for fluently constructing algorithms. The implementation leans heavily on Python dataclasses and type-hinting; a type checker (e.g. mypy) can be used to validate the grammar.

It is anticipated that this library will be used both by humans and by programs to construct grammatically correct specifications and run them through the TLC model checker.

Usage

Install from pip:

pip install pluscal

Create an algorithm:

>>> from pluscal.api import Algorithm, Print, Variable

>>> algorithm = Algorithm(
    "hello_world",
).declare(
    Variable("s").in_set("Hello", "World!"),
).do(
    Print("s", label="A"),
)

>>> print(algorithm)
--algorithm hello_world
variable s \in {"Hello", "World!"};
begin
  A:
    print s;
end algorithm

Limitations

This library is not complete. Some known limitations include:

  1. The lower-level TLA+ grammar used by the Expr, Field, Label, Name, and Variable types are neither modeled nor validated fully. These types are essentially strings at this time.

  2. The validation logic does not express the full nuances of PlusCal, especially as it relates to label placement.

    See section 3.7 of the PlusCal manual.

  3. Some of the fainess operations are not yet yet implemented.

    See section 4.6 of the PlusCal manual.

Release files for pluscal 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pluscal 0.4.2
File Size Uploaded
pluscal-0.4.2.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pluscal 0.4.2
File Interpreter ABI Platform
pluscal-0.4.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size:43.1 kB

Release files / pluscal-0.4.2.tar.gz

Download URL pluscal-0.4.2.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
abe07ded72b331ba06b8ac33a3f87e864766758ab1b176b463774e07ada8d6ea
BLAKE2b-256 checksum
How to use checksums
a3188b5ad29469f5ccbc4e540fc1d9cbeae0b718fc3791c916d8f7b98d4c254b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / pluscal-0.4.2-py2.py3-none-any.whl

Download URL pluscal-0.4.2-py2.py3-none-any.whl
Size 30.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
dc015083f8d1c9070abac394e2e2644689c60bf829c48b06b0d64e425eadceaf
BLAKE2b-256 checksum
How to use checksums
fec6da8abfef6943e085a6ec31b47f61b1515eb596846956a70d9473389fdf76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page