Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guidanoli/peg-coq
Formalizing PEGs and a well-formedness algorithm in Coq
https://github.com/guidanoli/peg-coq
coq lpeg parsing-expression-grammars well-formed
Last synced: about 2 months ago
JSON representation
Formalizing PEGs and a well-formedness algorithm in Coq
- Host: GitHub
- URL: https://github.com/guidanoli/peg-coq
- Owner: guidanoli
- License: gpl-3.0
- Created: 2023-04-04T20:05:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-12T13:40:47.000Z (about 2 months ago)
- Last Synced: 2024-12-12T14:32:38.550Z (about 2 months ago)
- Topics: coq, lpeg, parsing-expression-grammars, well-formed
- Language: Coq
- Homepage:
- Size: 431 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
## Formalization of PEGs using the Coq proof assistant
This repository formalizes the syntax and the semantics of [PEGs]
using the [Coq] proof assistant.
It also formalizes the algorithm implemented in [LPeg]
for detecting well-formed PEGs,
and proves that it terminates and is correct.
Correctness here implies in termination of the parsing procedure.## Syntax
We define use the desugared syntax of PEGs
first established by Ford.
It contains the empty pattern, terminals,
non-terminals, repetitions, not-predicates,
sequences, and choices.
From these, we can construct more complex patterns
such as character classes from choices,
and and-predicates from not-predicates.
This simplification helps us formalize PEGs
without losing expressiveness.## Semantics
We define the match procedure both
as a fixed point function which takes
a gas counter and returns an optional result,
and an inductive predicate.
The fixed point definition is interesting
for proving termination,
and the inductive predicate is useful
for proving correctness,
and other complex results
which may benefit from proofs by induction.## Well-formedness
We define the algorithm implemented in [LPeg]
that detects well-formed PEGs,
a subset of complete PEGs whose
detection is decidable.
Ford proved that, in the general case,
the problem of identifying complete PEGs
is undecidable, so this is a conservative
approach that ensures termination.## Files
The main files are:
- `Syntax.v`: PEG syntax
- `Match.v`: PEG semantics
- `Coherent.v`: valid nonterminals
- `Verifyrule.v`: left-recursive rules
- `Nullable.v`: nullable patterns
- `Checkloops.v`: degenerate loops
- `Verifygrammar.v`: well-formednessAuxiliar files are:
- `Tactics.v`: auxiliary proof tactics
- `Pigeonhole.v`: states and proves the pigeonhole principle
- `Strong.v`: states and proves the strong induction primitive
- `Suffix.v`: defines the suffix and proper suffix relations, and proves some results about them## Building the project
In order to build the project, you first need to make sure you have the following dependencies installed on your system.
- Coq 8.18.0 or later
- GNU MakeThen, you can build the project by running `make` on the root of the project.
[PEGs]: https://doi.org/10.1145/964001.964011
[Coq]: https://coq.inria.fr/
[LPeg]: https://www.inf.puc-rio.br/~roberto/lpeg/