Skip to content

Tools to use Elpi in Lambdapi + type classes#1378

Open
agontard wants to merge 39 commits into
Deducteam:masterfrom
agontard:elpi-rebase
Open

Tools to use Elpi in Lambdapi + type classes#1378
agontard wants to merge 39 commits into
Deducteam:masterfrom
agontard:elpi-rebase

Conversation

@agontard
Copy link
Copy Markdown
Contributor

@agontard agontard commented May 23, 2026

Up-to-date version of #418, with important help from Enrico Tassi.
Draft adding tools to convert Lambdapi terms to and from Elpi, used to write a typeclass solver in Elpi, which is now called in tac_solve to help with inference.

How to use

  • We found and fixed a bug in Elpi, so it is required to use the master branch of Elpi

Added syntax

  • Symbol declaration modifiers: "typeclass" and "instance".
  • Declaring existing symbols as tc or tc instance: typeclass s or instance s
  • Note that currently, a class must have type A → TYPE for some A

Example

An example of use is in tests/OK/elpi_isa_test.lp, which mimics the construction of groups from the Isabelle Group.thy file from the HOL session. It looks a bit overcomplicated without proper syntax for record types, I did not even use inductive syntax.

TODO

When changing the syntax of Lambdapi, make sure to update the
following files:

  • doc/lambdapi.bnf
  • src/core/lpLexer.ml
  • src/core/lpParser.ml
  • src/core/pretty.ml
  • src/core/print.ml
  • editors/vim/syntax/lambdapi.vim
  • editors/emacs/lambdapi-vars.el (syntax coloring)
  • editors/emacs/lambdapi-smie.el (grammar and indentation)
  • editors/vscode/lp.configuration.json (comments configuration),
  • editors/vscode/syntaxes/lp.tmLanguage.json (syntax highlighting),
  • misc/lambdapi.tex
  • the User Manual files in the doc/ repository (do make doc to generate and check the Sphynx documentation).

@agontard agontard marked this pull request as draft May 23, 2026 19:23
@agontard agontard marked this pull request as ready for review May 31, 2026 11:57
@agontard
Copy link
Copy Markdown
Contributor Author

agontard commented Jun 2, 2026

@fblanqui are the following two files contradicting each other? Or perhaps it would be clearer if the second one explained how the file should be updated?

lambdapi/doc/README.md

Lines 58 to 60 in 1e3b2ba

**Note:** BNF grammars are auto generated using
[Obelisk](https://github.com/Lelio-Brun/Obelisk). They should not be edited
directly.

lambdapi/CONTRIBUTING.md

Lines 67 to 69 in 1e3b2ba

When changing the syntax of Lambdapi, make sure to update the
following files:
- `doc/lambdapi.bnf`

@fblanqui
Copy link
Copy Markdown
Member

fblanqui commented Jun 2, 2026

Fixed in 7c36a3f . The BNF grammar is not generated anymore. It is written by hand.

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.

3 participants