All Projects → ret → specifica

ret / specifica

Licence: other
Basic TLA+ related Haskell libraries (parser, evaluator, pretty-printer)

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to specifica

Tlaplus
TLC is an explicit state model checker for specifications written in TLA+. The TLA+Toolbox is an IDE for TLA+.
Stars: ✭ 1,618 (+8415.79%)
Mutual labels:  specifications, mit-license
dwarlixir
A dwarf-fortress clone / MUD / side project in Elixir
Stars: ✭ 46 (+142.11%)
Mutual labels:  mit-license
Poetic-License
Limerick Open License in the spirit of OpenBSD, ISC, BSD0, and MIT Licenses
Stars: ✭ 36 (+89.47%)
Mutual labels:  mit-license
tla-tools
TLA+ tools for Emacs
Stars: ✭ 27 (+42.11%)
Mutual labels:  tlaplus
iris
Lightweight Component Model and Messaging Framework based on ØMQ
Stars: ✭ 50 (+163.16%)
Mutual labels:  mit-license
svut
SVUT is a simple framework to create Verilog/SystemVerilog unit tests. Just focus on your tests!
Stars: ✭ 48 (+152.63%)
Mutual labels:  mit-license
taylor
Measure twice, cut once. Lisp-like functional language for computable & immutable specifications, interpreted by WebAssembly & the Ethereum Virtual Machine.
Stars: ✭ 30 (+57.89%)
Mutual labels:  specifications
tlaplus-graph-explorer
A static web application to explore and animate a TLA+ state graph.
Stars: ✭ 188 (+889.47%)
Mutual labels:  tlaplus
libite
That missing frog DNA you've been looking for
Stars: ✭ 50 (+163.16%)
Mutual labels:  mit-license
JustAnotherVoiceChat-Server
Server for the JustAnotherVoiceChat TeamSpeak 3 plugin
Stars: ✭ 17 (-10.53%)
Mutual labels:  mit-license
comic-sans-everything
Chrome Extension | Changes All Text to Comic Sans
Stars: ✭ 32 (+68.42%)
Mutual labels:  mit-license
Mathematical-Mesh
The Mesh is an infrastructure that makes the Internet easier to use by making it more secure.
Stars: ✭ 39 (+105.26%)
Mutual labels:  mit-license
validation-selective
💂‍♂️ Lightweight pure validation based on Applicative and Selective functors
Stars: ✭ 61 (+221.05%)
Mutual labels:  haskell-libraries
cmus-control
Control cmus with Media Keys ⏪ ▶️ ⏩ under OS X.
Stars: ✭ 51 (+168.42%)
Mutual labels:  mit-license
Entia
Entia is a free, open-source, data-oriented, highly performant, parallelizable and extensible Entity-Component-System (ECS) framework written in C# especially for game development.
Stars: ✭ 28 (+47.37%)
Mutual labels:  mit-license
Naos
A mildly opiniated modern cloud service architecture blueprint + reference implementation
Stars: ✭ 19 (+0%)
Mutual labels:  specifications
react-advertising
A JavaScript library for display ads in React applications.
Stars: ✭ 50 (+163.16%)
Mutual labels:  mit-license
ocat
The Open Capture and Analytics Tool (OCAT) provides an FPS overlay and performance measurement for D3D11, D3D12, and Vulkan
Stars: ✭ 233 (+1126.32%)
Mutual labels:  mit-license
academia-hugo
Academia is a Hugo resume theme. You can showcase your academic resume, publications and talks using this theme.
Stars: ✭ 165 (+768.42%)
Mutual labels:  mit-license
restaurant-hugo
The restaurant is a creative and responsive restaurant website theme in Hugo environment. It is very well decorated theme which will make your website building easier.
Stars: ✭ 50 (+163.16%)
Mutual labels:  mit-license

Specifica Build Status

Specifica is a collection of TLA+ related Haskell libraries comprising a tlaplus parser, pretty printer, and expression evaluator. The code here is meant to serve as a starting point for developers who wish to build small TLA+ related utilities quickly.

Installation

Follow these steps to install and invoke a simple sample application called tle to evaluate a TLA+ expression from stdin.

  1. Install the Haskell tool stack utility

  2. add ~/.local/bin/ to your path (this is where stack installs binaries)

  3. clone this repo with git clone https://github.com/ret/specifica

  4. cd specifica

  5. stack install

The source for the tle sample is just 32 lines of code. Check it out!

Tests

Invoke stack test to run the test-suite (see tlaplus-tests).

A Few Commandline Examples

These steps will build the tle utility and copy it to ~/.local/bin/tle. Now, we're ready to try out tle like so:

$ echo 'LET a == 1 b == {a} \cup {42} IN [x \in b |-> SUBSET {x}]' | tle

which prints the following to the terminal:

** INPUT (pretty-printed):
LET a ==
      1
    b ==
      {a} \cup {42}
 IN [x \in b |-> SUBSET ({x})]

** RESULT:
[1 |-> {{},{1}},
 42 |-> {{},{42}}]

Define and Evaluate a Function

Here's another simple example. This time involving a function:

$ echo 'LET Nat == 0..3 factorial[n \in Nat] == IF n = 0 THEN 1 ELSE n * factorial[n-1] IN factorial[3]' | tle

and tle prints:

** INPUT (pretty-printed):
LET Nat ==
      0..3
    factorial[n \in Nat] == IF n = 0 THEN 1 ELSE n * factorial[n-1]
 IN factorial[3]

** RESULT:
6

When Things Go Wrong ...

This is also a good example to show the type of runtime errors we might encounter during evaluation. Let's say we don't get the Nat set quite right and leave out 0. So, instead of Nat == 0..3, we use Nat == 1..3:

$ echo 'LET Nat == 1..3 factorial[n \in Nat] == IF n = 0 THEN 1 ELSE n * factorial[n-1] IN factorial[3]' | tle

in this case, tle prints the following error message:

** INPUT (pretty-printed):
LET Nat ==
      1..3
    factorial[n \in Nat] == IF n = 0 THEN 1 ELSE n * factorial[n-1]
 IN factorial[3]
** EVALUATION ERROR **
:1:27:
    value of (n) violated range Nat
    in expression factorial[n-1] at: :1:75
    where (n) was bound to
        0
    in context
        n ==> 1
        n ==> 2
        n ==> 3
        factorial ==> factorial[n \in Nat] == IF n = 0
                                              THEN 1
                                              ELSE n * factorial[n-1]
        Nat ==> Nat ==
          1..3

We can see that the evaluator counted down from 3,2,1, but ultimately the expression n \in Nat in the function's domain failed since 0 wasn't in the Nat set.

Speed Bumps (the evaluator is very naive about powersets)

The following expression calculates the sum of the numbers 1,2,3:

$ echo 'LET Nat == 1..3 sum[ss \in SUBSET Nat] == IF ss = {} THEN 0 ELSE LET p == CHOOSE any \in ss: TRUE IN p + sum[ss \ {p}] IN sum[1..3]' | tle

and yields the expected 6:

** INPUT (pretty-printed):
LET Nat ==
      1..3
    sum[ss \in SUBSET (Nat)] == IF ss = {}
                                THEN 0
                                ELSE LET p ==
                                           CHOOSE any \in ss: TRUE
                                      IN p+sum[ss \ {p}]
 IN sum[1..3]

** RESULT:
6

Our evaluator is super simple and re-computes the powerset (SUBSET) in each recursion to check that ss \in SUBSET Nat holds. Because tle evaluates eagerly and the size of the powerset grows with O(2^n), picking a larger Nat set will slow down tle rapidly!

More Examples - Cross Products

Lastly, here's a fun example showing a cross product:

$ echo 'LET S==1..3 IN S \X S' | tle

resulting in the following output:

** INPUT (pretty-printed):
LET S ==
      1..3
 IN S \X S

** RESULT:
{<<1,1>>,
 <<1,2>>,
 <<1,3>>,
 <<2,1>>,
 <<2,2>>,
 <<2,3>>,
 <<3,1>>,
 <<3,2>>,
 <<3,3>>}

Quasiquoter (Haskell specific)

We use Quasiquoters to embed TLA+ expressions and specifications in Haskell code. The test suite uses this feature heavily and may serve as an example to build on for other tool developers.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].