Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Deep-embed graph #45

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alxest
Copy link

@alxest alxest commented Sep 28, 2024

Hi all! Thank you for initiating this extremely exciting project.
This PR is my attempt to simplify & give more principled approach to maintain the implication graph.

[Syntactic data]
Each axiom (equation) is now has a concrete, syntactic term, named Equation type. A graph, Graph type, is defined as Equation -> Equation -> Status where Status denotes the current state for the corresponding edge. For example, a concrete instance for the subgraph of our interest is given as a term subgraph: Graph.

[Semantic interpretation]
The validity of this graph object is enforced with Graph.valid definition - e.g., subgraph_valid would be the final theorem for the subgraph. The Graph.valid requires corresponding semantic proof for each syntactic edges. Notably, Edge is defined with typeclass and has few benefits below.

Benefits are as follows:

  • Compared to doing metaprogramming (with Python script or lean) to (re)construct the graph from the Lean code, deep-embedding the graph from the first place should be more direct, less error-prone, and robust.
  • Smaller TCB: the final theorem like subgraph_valid ensures the correctness of the whole graph (that is to be extracted and processed by tools like image-generators later) inside Lean.
  • Simplification: (1) the repeated (G: Type*) [Magma G] for each theorem is now omitted, and (2) we don't have to give explicit names to theorems thanks to typeclass mechanism. (e.g., instance : (Edge true .e2 .e4) where instead of theorem Equation2_implies_Equation4 (G: Type*) [Magma G] (h: Equation2 G) : Equation4 G :=)
  • Edge Synthesis: see Edge.trans_true, Edge.abduct_false0 and Edge.abduct_false1: the typeclass mechanism allows us to nicely derive some facts from existing facts. This is tested in the code.

One caveat would be performance scalability issue, especially for the final theorem (like subgraph_valid). If typeclass resolution mechanism takes O(n) (where n is the number of instances), it would take prohibitively long. If it takes O(log n), it should (I think) compile in time.

If you find this useful, I can make it a mergeable state quickly.

@alxest alxest changed the title Deep-embed graph [DO NOT MERGE] Deep-embed graph Sep 28, 2024
@pitmonticone pitmonticone marked this pull request as draft September 28, 2024 14:39
@teorth
Copy link
Owner

teorth commented Sep 28, 2024

I like this idea but it needs to be coordinated with #36 , perhaps one can discuss it on the Lean Zulip thread https://leanprover.zulipchat.com/#narrow/stream/458659-Equational/topic/Syntax ?

@pitmonticone pitmonticone added do-not-merge This PR is not meant to be merged and removed do-not-merge This PR is not meant to be merged labels Sep 29, 2024
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