Alpha equivalence checker for arbitrary lambda terms
7

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 44.7%
Nim 44.1%
Python 11.1%
Dune 0.1%
Other 0.1%
1 1 0

Clone this repository

https://vm.fail/vm.fail/ego https://vm.fail/did:plc:suvvk3rj6l236p2dkj3b2w6a
ssh://git@knot.vm.fail:2222/vm.fail/ego ssh://git@knot.vm.fail:2222/did:plc:suvvk3rj6l236p2dkj3b2w6a

For self-hosted knots, clone URLs may differ based on your setup.


README.md

ego#

Analyzes alpha equivalence in untyped lambda calculus terms. The OCaml and Nim implementations keep the 4 binding representations independent:

  • named variables
  • de bruijn indices
  • locally nameless terms
  • explicit substitutions

each representation implements parsing conversion, pretty printing, free variable analysis, alpha equivalence, capture avoiding substitution and normalisation according to its own binding semantics

Surface syntax#

x                  variable
\x. x              abstraction
\x. \y. x y        nested abstraction
(\x. x) y          application
[x := y] t         explicit substitution

Application is left associative and abstraction bodies extend to the right while names match [a-zA-Z][a-zA-Z0-9_'-]* accordingly

Representation contracts#

Named terms store textual binders and resolve references through explicit environments whereas substitution performs freshness generation and capture checks

De Bruijn terms encode bound references as lexical indices and retain free variables separately and shifting is required when terms cross binder boundaries.

Locally nameless terms encode bound references as indices and free references as names. Opening and closing enforce scope transitions; conversion and operations reject terms that are not locally closed.

Explicit substitution terms retain substitutions in the syntax tree and reduction propagates substitutions through variables, applications as well abstractions while preserving alpha equivalence and delayed capture avoidance

interfaces#

All 4 implementations expose the same semantic operations:

parse
pretty_print
free_variables
alpha_equivalent
substitute
normalize
convert_from_named
convert_to_named

The OCaml modules are Named, Debruijn, Locally_nameless, and Explicit_subst. The Nim modules use distinct variant types for each term representation and expose equivalent operations

Automata renderer#

This will convert automaton and transducer JSON into Graphviz DOT, SVG, PNG, or PDF. Input states may be plain identifiers or objects with labels and accepting state metadata. Transitions also accept explicit labels or read, write and action