• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    OCaml
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automated reasoning for React/ReasonML

VerifiedReact

Build Status

Welcome to VerifiedReact! This is work in progress - stay in touch via @VerifiedByAI, or come chat with us on Discord.

For an overview, read our Medium post Introducing Verified React.

Verified React logo

Ideas, aims and progress so far

  • Stage 1 (Counter, TicTacToe)

    • Simpler automation of Imandra:
      • added imandra-http-server as an alternative to imandra-repl to allow automation via an HTTP api, bundled with the Imandra installer. Previously you could automate our imandra-repl process via stdin/stdout, but having an HTTP interface to the Imandra client naturally makes life a lot easier. imandra-http-server is built using our Imandra_client OCaml library, which we're hoping to make available as an opam package in the future, so OCaml users can use the Imandra client directly from their code.
      • added bs-imandra-client - bucklescript bindings to that HTTP api to be used when running on Node
    • Allow export of export of core logic verified with Imandra to code that can be compiled to executable JS
      • Imandra comes with a prelude of pre-verified functions for use from .iml (Imandra-ml) or .ire (Imandra-reason) code. When you're done reasoning and want to compile the verified module into a larger program, you need a .ml version of the prelude to compile alongside your module. Previously this was available to compile as native OCaml package, but we've now also included an initial amended version that compiles to javascript via the bucklescript compiler too, which can be npm installed from the imandra-prelude repo.
    • Automation of verification goals via jest, via imandra-http-server. See:
      • examples/simple/__tests__/Counter_Goals.ml
      • examples/tictactoe/__tests__/TicTacToe_Logic_Goals.re
      • examples/todomvc/__tests__/TodoMvc_Model_Goals.re
    • Hook verified state machine up to React reducer component. See:
      • examples/tictactoe/TicTacToe.re
  • Stage 2

  • Stage 3

    • Collecting React reducer events from React unit test runs
    • Map reducer events back to state machine events, and visualise coverage on the decomposition
    • Coverage report of state space as hit by your jest tests

Setup

Make sure you have the latest version of imandra-repl installed via the Imandra Installer, then run

imandra-repl

and make sure it starts up successfully (i.e. all updates are installed). Once it's started, quit it again with Ctrl-D. Next:

npm install

to install the bucklescript compiler, imandra-prelude and Imandra client bindings for bucklescript. Then:

npm run watch

You may see a few errors the first time you run watch - this I believe is due to an issue with components in bsb.exe as they are a WIP. However, if you run npm run watch multiple times, you should stop seeing errors after a few builds, and from then on incremental compilation will work sucessfully.

The compilation chain

For runtime:

  • .iml and .ire files are compiled to .ml files using imandra-extract (which is bundled with the Imandra Installer), and integrated into the build via bsb components.
  • .ml and .re files are compiled to .bs.js via bsb itself.
  • Imandra_prelude is available automatically inside imandra-http-server
  • When compiling to javascript, Imandra_prelude is provided by imandra-prelude, added as an npm/bucklescript dependency.

Verification tests:

  • Tests are run via Jest on node.js using the compiled runtime JS files.
  • As part of the test run, the Imandra client bucklescript bindings (bs-imandra-client) are used to spin up imandra-http-server (which is bundled as part of the Imandra Installer), which is an OCaml binary talking to Imandra's reasoning engine in the cloud.
  • The HTTP Imandra client API is used to load .iml and .ire files into the running imandra-http-server OCaml process, and perform verification statements.
  • The verification results are captured and reported back as part of the Jest test run.

To run the verification goals:

npm run test

Viewing instances

Read our post about viewing instances in your UIs with Imandra.

The TicTacToe example is hooked up to Imandra to allow querying and viewing instances. To start it, from the verified-react repo root run:

imandra-http-server -reason

to start Imandra's http server with reason syntax loaded. Then for bucklescript compilation, (in another terminal) run:

npm install
npm run watch

Then, to start the parcel.js dev server, (in another terminal) run:

npm run watch-tictactoe

You should now be able to visit http://localhost:1234 to see/play the TicTacToe game (verified via the npm run test Jest tests), and also query for instances from Imandra.

How it works

The TicTacToe UI is wrapped in an InstanceBrowser component, which loads the game logic into Imandra (along with some JSON encoders and decoders) via examples/tictactoe/Setup.ire.

The TicTacToe UI component has been edited slightly to allow a default intial state to be passed from its parent via the customInitialLogicState prop.

When the instance query box's contents change, the query is sent to imandra-http-server's /instance/by-src endpoint as a lambda expression, x : game_state => <constraint>, so an instance of type game_state matching the constraint is returned, printed to a JSON string via a serialisation function (instancePrinterFn).

This returned instance is then passed to the customInitialLogicState prop and rendered by the UI component.

More Repositories

1

fix-engine

Imandra FIX Engine
OCaml
51
star
2

minisat-ml

Faithful reimplementation of Minisat 2.2 in OCaml.
OCaml
38
star
3

ocaml-opentelemetry

Instrumentation for https://opentelemetry.io
OCaml
33
star
4

contracts

Imandra Contracts - Formal verification of smart contracts
OCaml
32
star
5

ocaml-tracy

Bindings to the Tracy profiler.
OCaml
26
star
6

ocaml-gcloud

OCaml bindings to Google Cloud Platform APIs
OCaml
26
star
7

reasonml-tic-tac-toe

Reason
19
star
8

imandra-ros

Imandra ROS
OCaml
17
star
9

vega-lite

OCaml library to produce vega-lite visualizations (as json objects)
OCaml
16
star
10

ocaml-cimgui

[wip] bindings to Dear Imgui for OCaml.
OCaml
15
star
11

cme-mdp

Imandra Modelling Language CME MDP Model
Jupyter Notebook
13
star
12

ocaml-pltp

OCaml PLTP: An independent reproduction of the Boyer-Moore Pure Lisp Theorem Prover
OCaml
13
star
13

imandra-prelude

Extracted version of imandra's prelude
OCaml
12
star
14

ipl-examples

Imandra Protocol Language example models
11
star
15

batsmt

[wip] Modular SMT solver in rust
SMT
10
star
16

mhash

hashing library that is generic on the hashing function, and a ppx deriving plugin for type-directer hashers
OCaml
10
star
17

catapult

Tracing library for OCaml with catapult/TEF export.
OCaml
10
star
18

ipl-vscode

Imandra Protocol Language VS Code Plugin
8
star
19

imandra-docs

Imandra Documentation
Jupyter Notebook
7
star
20

imandra-starter-template

Example layout for an Imandra project
OCaml
6
star
21

iex-auction-model

An Imandra model of the IEX Opening/Closing auction logic
OCaml
6
star
22

imandra-stdlib

Standard library for [Imandra](https://imandra.ai)
Makefile
5
star
23

opam-repository

opam repository for AI
5
star
24

socket.io-client-ocaml

OCaml socket.io client
OCaml
5
star
25

imandrakit

Core utils library for Imandra
OCaml
4
star
26

imandra-examples

Imandra/IML examples
OCaml
4
star
27

bs-imandra-client

Imandra client in Bucklescript (via child process)
OCaml
4
star
28

iml-vscode

location of the vsix file for the iml-vscode (imandra IDE) plugin
3
star
29

demo-smart-constructors

demo intended to show the power of smart constructors and private aliases in OCaml
OCaml
3
star
30

batrpc

RPC framework on top of protobuf.
OCaml
3
star
31

imandra-reason-parser

Reason parser for Imandra (fork of reason's parser)
OCaml
3
star
32

ocyaml

OCaml bindings for libyaml
OCaml
3
star
33

cbor-pack

OCaml library + ppx for CBOR-pack: a serialization layer with sharing on top of CBOR
OCaml
3
star
34

ocaml-engineio-client

OCaml
3
star
35

ipl-spacemacs-layer

Emacs Lisp
3
star
36

batsmt-ocaml

OCaml bindings for batsmt
Rust
3
star
37

bs-jest-expect-imandra

Jest helpers for asserting against Imandra client responses
OCaml
2
star
38

imandra-vscode

VSCode extension for developing imandra
TypeScript
2
star
39

imandra-ptime

IML-compatible version of the Ptime library
OCaml
2
star
40

behavior-planning

Formally reasoning about autonomous vehicle behavior planning with Imandra
OCaml
2
star
41

imandra-http-api-client

Interact with Imandra via http from within OCaml.
OCaml
2
star
42

imandra-client-http-server

OCaml
2
star
43

tutorials

Imandra tutorials
2
star
44

pa_do

unofficial fork of pa_do
OCaml
1
star
45

verified-metitarski

Work on fully expansive verification of MetiTarski proofs
Standard ML
1
star
46

imandra-stats-experiments

Experiments combining Imandra with statistical or probabilistic models
Jupyter Notebook
1
star
47

imandra-mode

Emacs mode for Imandra
Emacs Lisp
1
star
48

abstract-transition-systems

[alpha] An implementation of several classic transition systems that describe algorithms for SAT or SMT, for interactive exploration
OCaml
1
star
49

seating-planner

JavaScript
1
star
50

itr-ast

JavaScript
1
star
51

imandra-ast

Simple AST exportable from Imandra
OCaml
1
star
52

imandra-issues

Public repo for tracking issues/feature requests for Imandra
1
star
53

imandra-merlin

Merlin reader for imandra files
OCaml
1
star
54

regions-rl

Collection of examples for reinforcement learning
Jupyter Notebook
1
star