{"id":14128509,"url":"https://github.com/LPCIC/elpi","last_synced_at":"2025-08-03T23:31:20.374Z","repository":{"id":39422659,"uuid":"85563307","full_name":"LPCIC/elpi","owner":"LPCIC","description":"Embeddable Lambda Prolog Interpreter","archived":false,"fork":false,"pushed_at":"2024-10-29T12:57:40.000Z","size":39677,"stargazers_count":286,"open_issues_count":54,"forks_count":36,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T15:24:01.973Z","etag":null,"topics":["constraints","extension-language","lambda-prolog","ocaml-library"],"latest_commit_sha":null,"homepage":null,"language":"Prolog","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LPCIC.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-20T10:22:28.000Z","updated_at":"2024-10-29T10:25:38.000Z","dependencies_parsed_at":"2023-12-07T17:38:08.188Z","dependency_job_id":"3d051558-f4d4-44c3-abd4-f57128931ae9","html_url":"https://github.com/LPCIC/elpi","commit_stats":null,"previous_names":[],"tags_count":80,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LPCIC%2Felpi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LPCIC%2Felpi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LPCIC%2Felpi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LPCIC%2Felpi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LPCIC","download_url":"https://codeload.github.com/LPCIC/elpi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228571844,"owners_count":17938772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constraints","extension-language","lambda-prolog","ocaml-library"],"created_at":"2024-08-15T16:01:46.961Z","updated_at":"2025-08-03T23:31:20.319Z","avatar_url":"https://github.com/LPCIC.png","language":"Prolog","funding_links":[],"categories":["Prolog","Interpreters"],"sub_categories":[],"readme":"[![Main workflow](https://github.com/LPCIC/elpi/actions/workflows/main.yml/badge.svg)](https://github.com/LPCIC/elpi/actions/workflows/main.yml)\n[![Users workflow](https://github.com/LPCIC/elpi/actions/workflows/users.yml/badge.svg)](https://github.com/LPCIC/elpi/actions/workflows/users.yml)\n# ELPI - Embeddable λProlog Interpreter\n\nELPI implements a variant of λProlog enriched with Constraint Handling Rules,\na programming language well suited to manipulate syntax trees with binders.\n\nELPI is designed to be embedded into larger applications written in OCaml as\nan extension language. It comes with an API to drive the interpreter and \nwith an FFI for defining built-in predicates and data types, as well as\nquotations and similar goodies that come in handy to adapt the language to the host\napplication.\n\nELPI is free software released under LGPL version 2.1 or above.\n\n## How to install ELPI\n\nELPI runs on Linux, MacOS and Windows.\n\nThe simplest way is to use [OPAM](http://opam.ocaml.org/) and type\n```\nopam install elpi\n```\nThis command gives you the command line tool `elpi` as well as the findlib\n`-package elpi` switch.\n\nTo install the development version of elpi directly from github\nyou can type\n```\nopam pin add elpi https://github.com/LPCIC/elpi.git\n```\nYou can also clone this repository and type `make build`.\n\nFinally, each CI run builds statically linked binaries for the\nthree supported operating systems, click on any\njob from the [Actions](https://github.com/LPCIC/elpi/actions/workflows/main.yml) tab\nto download them.\n\n### Syntax highlight in Visual studio code\n\nThe [extension for vscode](https://github.com/LPCIC/elpi-lang) is available in the\nmarket place, just look for Elpi.\n\n### Syntax highlight in vim\n\nWe recommend to add the following lines to `~/.vimrc`\n\u003cdetails\u003e\u003csummary\u003e(click to expand)\u003c/summary\u003e\n\u003cp\u003e\n  \n```vim\n\"elpi\nautocmd BufRead,BufNewFile *.elpi set filetype=lprolog\n\nautocmd FileType lprolog syn match   lprologIdentifier  \"\\\u003c\\l[-a-zA-Z\\.+*/\\\\^\u003c\u003e=`'~?@#$\u0026!_]*\\\u003e\"\nautocmd FileType lprolog syn region  lprologClause start=\"^\\\u003c\\l[-a-zA-Z\\.+*/\\\\^\u003c\u003e=`'~?@#$\u0026!_]*\\\u003e\" end=\" \\|:-\\|\\.\"\nautocmd FileType lprolog syn match lprologClauseSymbols \":-\"\nautocmd FileType lprolog syn match lprologClauseSymbols \"\\.\"\nautocmd FileType lprolog hi def link lprologClauseSymbols Type\n\nautocmd FileType lprolog syn keyword elpiKeyword mode macro type pred namespace rule constraint uvar shorten\nautocmd FileType lprolog syn match elpiKeyword \":before\"\nautocmd FileType lprolog syn match elpiKeyword \":after\"\nautocmd FileType lprolog syn match elpiKeyword \":name\"\nautocmd FileType lprolog syn match elpiMacro \"@\\(\\w\\|-\\)\\+\"\nautocmd FileType lprolog syn match elpiSpill \"{\"\nautocmd FileType lprolog syn match elpiSpill \"}\"\nautocmd FileType lprolog syn region elpiQuotation start=\"{{\" end=\"}}\" contains=@elpiAntiQuotation\nautocmd FileType lprolog hi def link elpiKeyword Keyword\nautocmd FileType lprolog hi def link elpiMacro Special\nautocmd FileType lprolog hi def link elpiSpill Special\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Documentation\n\nThe language is quite compatible with standard\n[λProlog](http://www.lix.polytechnique.fr/Labo/Dale.Miller/lProlog/)\nand ELPI is known to be able to run most of the λProlog programs out there\n(see the list of [known incompatibilities](INCOMPATIBILITIES.md) \nwith the [Teyjus](https://github.com/teyjus/teyjus) system).\nReading [Programming with Higher-Order Logic](https://sites.google.com/site/proghol/)\nby Miller and Nadathur is highly recommended and covers standard λProlog.\n\nThe extensions to λProlog implemented in ELPI are described in the\n[ELPI](ELPI.md) file, built-in predicates are documented in\n[builtin](src/builtin.elpi).\n\nThere is a [short paper](https://hal.inria.fr/hal-01176856/) describing\nthe implementation of the interpreter, in particular how it deals with\nbinder mobility.\n\nA [longer paper](https://hal.inria.fr/hal-01410567v2) describes, among other\nthings, the part of the language\nfor declaring and manipulating constraints.\n\nFor a lightweight introduction to Elpi one can look at the\n[slides](https://github.com/gares/mlws18/blob/master/slides.pdf) of \nthe talk given at the ML Family workshop 2018 titled \"Elpi: an extension \nlanguage with binders and unification variables\". The companion\ncode of [toyml](https://github.com/gares/mlws18/tree/master/toyml)\nthat implements W (ML type inference) in Elpi is also available.\n\n### How to embed ELPI in your software\n\nThe easiest way of embedding ELPI is by linking it using\n[findlib](http://projects.camlcity.org/projects/findlib.html)\nas in `ocamlfind opt -package elpi -linkpkg mycode.ml -o myprogram`.\nThe API the host application can use to drive ELPI is documented in the\n[API.mli](src/API.mli) file ([html rendering](https://lpcic.github.io/elpi/index.html)). The \n[Builtin.ml](src/builtin.ml) file contains example of\n(basic) built-in predicates declaration via ELPI's FFI.\n\nThe [command line](elpi_REPL.ml) interface to ELPI is a very simple\nexample of a client using ELPI as a library.\nThe most complex example of embedding of ELPI is\n[coq-elpi](https://github.com/LPCIC/coq-elpi).\n\n## Why ELPI?\n\nELPI is a research project aimed at providing a programming platform\nfor the so called *elaborator* component of an interactive theorem prover.\n\n### What's an elaborator and what's so special about it?\n\nThe elaborator of an interactive prover is the component in\ncharge of turning a term as input by the user into a well\ntyped one.  In a prover like Coq it performs type inference\nand is typically extended by the user.\n\nThe elaborator manipulates terms with binders and holes \n(unification variables) representing missing piece of \ninformation.  Some of them have to be filled in order \nto make the term well typed. Some others are filled in because \nthe user has programmed the elaborator to do so, e.g. ad-hoc polymorphism.\n\nSuch software component is characterized by an high complexity\ncoming from the interplay of binders, reduction and unification,\nthe heuristics to make it work in practice and the user extensions\nto customize its behavior.\n\n### What problem does ELPI solve and how?\n\nThe programming language has the following features\n- Native support for variable binding and substitution, via an Higher Order\n  Abstract Syntax (HOAS) embedding of the object language.\n  The programmer does not need to care about technical devices to handle \n  bound variables, like De Bruijn indices.\n- Native support for hypothetical context. When moving under a binder one can\n  attach to the bound variable extra information that is collected when the\n  variable gets out of scope. For example when writing a type-checker the\n  programmer needs not to care about managing the typing context.\n- Native support for higher order unification variables, again via HOAS.\n  Unification variables of the meta-language (λProlog) can be reused to\n  represent the unification variables of the object language. The programmer\n  does not need to care about the unification-variable assignment map and\n  cannot assign to a unification variable a term containing variables out of\n  scope, or build a circular assignment.\n- Native support for syntactic constraints and their meta-level handling rules.\n  The generative semantics of Prolog can be disabled by turning a goal into a\n  syntactic constraint (suspended goal). A syntactic constraint is resumed as\n  soon as relevant variables gets assigned. Syntactic constraints can be\n  manipulated by constraint handling rules (CHR).\n- Native support for backtracking. To ease implementation of search.\n- The constraint store is extensible.  The host application can declare\n  non-syntactic constraints and use custom constraint solvers to check their\n  consistency.\n- Clauses are graftable. The user is free to extend an existing program by\n  inserting/removing clauses, both at runtime (using implication) and at\n  \"compilation\" time by accumulating files.\n\nMost of these feature come with λProlog.  Constraints and propagation rules are novel in ELPI.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLPCIC%2Felpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLPCIC%2Felpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLPCIC%2Felpi/lists"}