Skip to content

Add tentative auto-generated EasyCrypt language documentation#976

Draft
strub wants to merge 2 commits intomainfrom
doc-language
Draft

Add tentative auto-generated EasyCrypt language documentation#976
strub wants to merge 2 commits intomainfrom
doc-language

Conversation

@strub
Copy link
Copy Markdown
Member

@strub strub commented Apr 12, 2026

This is a first draft covering: types, operators, predicates, expressions, formulas, programs, modules, module types, theories, sections, cloning, hints, printing, and standard library tour.

strub added 2 commits April 11, 2026 07:30
Add two new flags for the `easycrypt` CLI to support LLM coding agents:
- `-upto <pos>`: compile up to a given position and print goals there
- `-lastgoals`: print the last unproven goals

Also add a dedicated `llm` command mode and an LLM agent guide
(doc/llm/CLAUDE.md) documenting EasyCrypt tactics and workflow for
use with AI coding assistants.
This is a first draft covering: types, operators, predicates,
expressions, formulas, programs, modules, module types, theories,
sections, cloning, hints, printing, and standard library tour.
@strub
Copy link
Copy Markdown
Member Author

strub commented Apr 12, 2026

Of course, it has to be reviewed, extended, amended, etc, etc... but this gives a basis.

Copy link
Copy Markdown
Member

@fdupress fdupress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial review; not meant to be human-consumed :)


require import AllCore.

(* An abstract type with decidable equality *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not an ideal comment here.

File structure
------------------------------------------------------------------------

An EasyCrypt source file has the extension ``.ec``. A file consists of
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EasyCrypt source files can also have the extension .eca for abstract theories. (Add a cross-ref to relevant section?)

require import AllCore List FSet.

The ``import`` and ``export`` keywords can also be used standalone to
import or export a theory that has already been required:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain/Given an example to show that this can be used to import theories without importing their parent theory?

Comment thread doc/language/02-types.rst
scope (defined in the ``Pervasive`` prelude).

``unit``
The unit type. It has a single value, written ``tt``. It is used
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tt is also often displayed as ()

Comment thread doc/language/02-types.rst

All types in EasyCrypt are *inhabited*: there is a polymorphic
constant ``witness : 'a`` that provides a default value for any type.
This means there is no empty type.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The witness value is never specified: you will be unable to prove that it is equal to (or different from) any other value in the same type. To extend a type with a distinguished symbol (typically denoted $$\bot$$ on paper), the option type constructor is a much better choice.

Comment thread doc/language/02-types.rst
``'a distr``
The type of (sub-)distributions over a type ``'a``. A value of
type ``'a distr`` assigns a probability (a non-negative real) to
each value of type ``'a``, with the total probability at most 1.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a parameterized type. (Add a cross-ref to the following section.)

Comment thread doc/language/02-types.rst
.. code-block:: easycrypt

(1, true) (* : int * bool *)
(1, true, 42) (* : int * bool * int *)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types (t1 * t2) * t3, t1 * (t2 * t3) and t1 * t2 * t3 are isomorphic, but distinct. This is a common source of errors and should be highlighted here.

Comment thread doc/language/02-types.rst
Node 1 (Node 2 Leaf Leaf) Leaf.

Pattern matching is the primary way to inspect algebraic datatypes.
See :ref:`language-expressions` for the ``match`` expression and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also cross-ref to the match statement?

Comment thread doc/language/02-types.rst

.. code-block:: easycrypt

subtype nat AS Nat = { x : int | 0 <= x }.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is AS in capitals?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants