Ott is a tool for writing definitions of programming languages and calculi. It takes as input a definition of a language syntax and semantics, in a concise and readable ASCII notation that is close to what one would write in informal mathematics. With appropriate annotations, it can then generate output:
- a LaTeX source file that defines commands to build a typeset version of the definition;
- a Coq version of the definition;
- a HOL version of the definition;
- an Isabelle/HOL version of the definition;
- a Lem version of the definition;
- an OCaml version of the syntax of the definition; and
- (experimental) a menhir parser and crude pretty printer for the syntax.
Additionally, it can be run as a filter, taking a LaTeX/Coq/Isabelle/HOL/Lem/OCaml source file with embedded (symbolic) terms of the defined language, parsing them and replacing them by typeset terms.
Most simply, Ott can be used to aid informal LaTeX mathematics. Here it permits the definition, and terms within proofs and exposition, to be written in a clear, editable, ASCII notation, without LaTeX noise. It generates good-quality typeset output. By parsing (and so sort-checking) this input, it quickly catches a range of simple errors, e.g. inconsistent use of judgement forms or metavariable naming conventions.
That same input can be used to generate formal definitions, for Coq, HOL, Isabelle, and Lem. It should thereby enable a smooth transition between use of informal and formal mathematics. Additionally, the tool can automatically generate definitions of functions for free variables, single and multiple substitutions, subgrammar checks (e.g. for value subgrammars), and binding auxiliary functions. At present only a fully concrete representation of binding, without quotienting by alpha equivalence, is fully supported. An experimental backend generates a locally-nameless representation of terms for a subset of the Ott metalanguage: details can be found at http://moscova.inria.fr/~zappa/projects/ln_ott.
The distribution includes several examples, in varying levels of completeness: untyped and simply typed lambda-calculus, a calculus with ML polymorphism, the POPLmark Fsub with and without records, an ML module system taken from (Leroy, JFP 1996) and equipped with an operational semantics, and LJ, a lightweight Java fragment. More substantially, Ott has been used for work on iJAM and LJAM, Java Module Systems, by Rok Strnisa, and semantics for OCaml light, by Scott Owens.
As of 2020, Ott remains in continuous use.
Binding and Substitution. Susmit Sarkar, Peter Sewell, Francesco Zappa Nardelli. Note, 2007.
The experimental Coq locally-nameless backend (html). Francesco Zappa Nardelli. Note, 2009.
Ott: Effective Tool Support for the Working Semanticist. Peter Sewell, Francesco Zappa Nardelli, Scott Owens, Gilles Peskine, Thomas Ridge, Susmit Sarkar, Rok Strnisa. Journal of Functional Programming 20(1):71-122, 2010
Ott: Effective Tool Support for the Working Semanticist. Peter Sewell, Francesco Zappa Nardelli, Scott Owens, Gilles Peskine, Thomas Ridge, Susmit Sarkar, Rok Strnisa. In ICFP 2007
Ott has been principally devloped by Peter Sewell, Francesco Zappa Nardelli, and Scott Owens, with contributions from many others including Joey Eremondi, Hannes Mehnert, Karl Palmskog, Matthew Parkinson, Thibaut Perami, Gilles Peskine, Alastair Reid, Tom Ridge, Susmit Sarkar, Rok Strnisa, Viktor Vafeiadis.
To install and build
With OPAM (released version)
First, ensure you have opam (the OCaml package manager) installed,
version 2.0 or greater (opam 1 versions of ott are no longer
supported). You can use your system's package manager e.g.
sudo apt-get install opam (e.g. on Ubuntu 20.04) or follow the
instructions from the opam website.
On older Ubuntu versions you will not be able to use their package
manager's opam 1 version, and will need to install opam 2 following the
instructions on the opam website.
opam install ott will install the latest Ott version. The
Emacs mode will be in
$(opam config var prefix)/share/emacs/site-lisp, and documentation in
$(opam config var prefix)/doc/ott.
If you want to use Ott with the Coq proof assistant, to install the
Ott auxiliary files for Coq, first activate the
opam repo add coq-released https://coq.inria.fr/opam/released
and then run
opam install coq-ott.
With OPAM (github checkout)
In the checkout directory, run
opam pin add ott ..
To rebuild and reinstall after local changes, run
opam upgrade --working-dir ott (or
opam upgrade -w ott).
Ott depends on OCaml version 4.00.0 or later. It builds with (at least) OCaml 4.02.3 and 4.10.0.
make world) builds the
ott binary in the
This will compile Ott using
ocamlopt. To force it to
ocamlc (which may give significantly slower execution
of Ott), do
To build the Ott auxiliary files for Coq, go to the
make. To install the resulting files in Coq's
Ott runs as a command-line tool. Executing
ott shows the
usage and options. To run Ott on the test file
tests/test10.ott, generating LaTeX in
ott -i tests/test10.ott -o test10.tex -o test10.v
Isabelle, HOL, and Lem can be generated with options
-o test10Script.sml, and
-o test10.lem, respectively.
The Makefile has various sample targets,
make test7, etc. Typically they generate:
||LaTeX source for a definition|
||the postscript built from that|
test8.ott, etc., in
emacs/ott-mode.el defines a very simple Emacs mode for syntax
highlighting of Ott source files. It can be used by, for example,
adding the following to your
.emacs file, replacing
PATH by a path to your
Ott Emacs directory.
(setq load-path (cons (expand-file-name "PATH") load-path)) (require 'ott-mode)
For installations using OPAM on *nix systems, it is sufficient to use the following code, which will call
opam config var prefix at load-time.
(setq opam-share (substring (shell-command-to-string "opam config var share") 0 -1)) (add-to-list 'load-path (concat opam-share "/emacs/site-lisp")) (require 'ott-mode)
Visual Studio Code
There is a plugin for VSCode, which features syntax highlighting and inline error reporting.
- Please now use the github issue tracker (though our resources for fixing issues are very limited)
- The previous issue tracker is here
||auxiliary code (y2l) used to build the user guide|
||the Ott binary|
||the user guide, in html, pdf, and ps|
||auxiliary files for Coq|
||the user guide sources|
||an Ott Emacs mode|
||some larger example Ott files|
||auxiliary files for LaTeX|
||auxiliary files for HOL|
||auxiliary files for menhir|
||a copy of the ocamlgraph library|
||various small example Ott files|
||the (OCaml) Ott sources|
||a Makefile for the examples|
||the BSD-style licence terms|
||this file (Section 2 of the user guide)|
||the revision history|
The following LaTeX, Coq, HOL, and Isabelle files, except the proof scripts, are all automatically generated from the Ott sources.
|Untyped CBV lambda||3||
|Simply typed CBV lambda||6||
|TAPL roughly-full-simple||63||(sources)||(ps)||(Coq (including records))||(HOL)||(script)||(Isabelle)||(script)|
|POPLmark Fsub (*)||48||(sources)||(latex)||(pdf) (ps)|
|Leroy JFP96 module system (*)||67||
|LJ: Lightweight Java||85||(sources)||(pdf)||(Isabelle)||(zip)|
|LJAM: Java Module System||163||(sources)||(pdf)||(Isabelle)||(zip)|
(*) These systems would need explicit alpha conversion in the rules to capture the intended semantics using the fully concrete representation.
The ocamlgraph library is distributed under the LGPL (from http://www.lri.fr/~filliatr/ftp/ocamlgraph/); we include a snapshot for convenience. For its authorship and copyright information see the files therein.
All other files are distributed under the BSD-style licence in LICENCE.