egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
417 stars 46 forks source link

Adding type annotations to intermediate representation #320

Closed yihozhang closed 7 months ago

yihozhang commented 9 months ago

This PR implements some important refactoring. At a high level, this PR gets rid of many legacy code and use a set of generic IRs which allows greater code sharing (thus reduced codebase size).

The current compilation workflow is

  1. Command -[desugar]-> NCommand: does some lightweight desugaring, e.g., turns a function into a relation
  2. Rule in NCommand -[lower]-> CoreRule: lowering to CoreRule for typechecking
  3. (Rule, CoreRule) -[typecheck]-> ResolvedRule: ResolvedRule is a Rule with all its function symbols and variables type annotated.
  4. Other planned transformations (e.g. proofs) over ResolvedRule
  5. ResolvedRule -[lower]-> ResolvedCoreRule
  6. ResolvedCoreRule -[compilation]-> Program

Fixes #80, fixes #113, fixes #196.