Add documentation for egg subpackage - #159
Conversation
- Created README.md for egg subpackage with detailed API and usage examples - Added docs/support-packages/egg.md documentation page - Updated main README.md to include link to egg subpackage - Updated mkdocs.yml to include egg documentation in navigation Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
- Simplify GitHub repository link in egg/README.md - Clarify hash-consing terminology in docs/support-packages/egg.md - Expand Items and Variables explanation with examples Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
- Updated all occurrences to use lowercase 'c' for consistency with source code - Fixed variable example formatting in documentation Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
| ## Support Packages | ||
|
|
||
| - **BNF Conversion Library** ([apyds-bnf](https://pypi.org/project/apyds-bnf/), [atsds-bnf](https://www.npmjs.com/package/atsds-bnf)): Bidirectional conversion between DS syntax formats. See [/bnf](/bnf) for details. | ||
| - **E-Graph Library** ([apyds-egg](https://pypi.org/project/apyds-egg/)): E-Graph implementation for efficient equality reasoning and term rewriting. See [/egg](/egg) for details. |
There was a problem hiding this comment.
这个只支持equality reasoning, 没有rewriting功能.
There was a problem hiding this comment.
Removed "term rewriting" mention in c2c9475.
|
|
||
| An E-Graph (Equality Graph) implementation for the DS deductive system, providing efficient management and manipulation of equivalence classes of terms. | ||
|
|
||
| This package implements the egg-style E-Graph data structure with deferred congruence closure, enabling efficient equality reasoning and term rewriting. |
|
|
||
| An E-Graph (Equality Graph) implementation for the DS deductive system, providing efficient management and manipulation of equivalence classes of terms. | ||
|
|
||
| This package implements the egg-style E-Graph data structure with deferred congruence closure, enabling efficient equality reasoning and term rewriting. |
There was a problem hiding this comment.
加一下 egg 的链接: https://egraphs-good.github.io/ 我们是照着他实现的
There was a problem hiding this comment.
Added egg library reference link in c2c9475.
| - **Union-Find**: Data structure for managing E-class equivalence | ||
| - **Congruence**: Two terms are congruent if they have the same operator and their children are in equivalent E-classes | ||
|
|
||
| ### Union-Find |
There was a problem hiding this comment.
union find 不需要在core concepts里介绍
There was a problem hiding this comment.
Removed Union-Find section from Core Concepts in c2c9475.
| assert uf.find(a) == uf.find(b) | ||
| ``` | ||
|
|
||
| ### E-Nodes |
There was a problem hiding this comment.
Removed E-Nodes section from Core Concepts in c2c9475.
| - `find(x: T) -> T`: Find canonical representative with path compression | ||
| - `union(a: T, b: T) -> T`: Union two sets | ||
|
|
||
| ### ENode |
There was a problem hiding this comment.
Removed ENode from API Overview in c2c9475.
| uv build | ||
|
|
||
| # Run tests | ||
| pytest |
There was a problem hiding this comment.
应该是uv run pytest 和 uv run pytest --cov
There was a problem hiding this comment.
Updated to use "uv run pytest" and "uv run pytest --cov" in c2c9475.
| pytest --cov | ||
| ``` | ||
|
|
||
| ### Running Tests |
There was a problem hiding this comment.
Removed "Running Tests" section in c2c9475.
|
|
||
| ## Repository | ||
|
|
||
| - **GitHub**: [USTC-KnowledgeComputingLab/ds](https://github.com/USTC-KnowledgeComputingLab/ds) |
There was a problem hiding this comment.
加一下 (in /egg directory) 的说法在这里
There was a problem hiding this comment.
Added "(in /egg directory)" to repository link in c2c9475.
| @@ -0,0 +1,167 @@ | |||
| # E-Graph Support Package | |||
There was a problem hiding this comment.
这个文件还没检查, 但是参考我对README的评论先修改一版
There was a problem hiding this comment.
Applied similar changes to docs/support-packages/egg.md in c2c9475: removed Union-Find example, removed UnionFind/ENode/EClassId API sections, and added egg library reference.
- Remove "term rewriting" mentions (only supports equality reasoning) - Add egg library reference link (https://egraphs-good.github.io/) - Remove Union-Find and E-Nodes sections from Core Concepts - Remove UnionFind, ENode, and EClassId from API Overview - Update test commands to use "uv run pytest" - Remove "Running Tests" section - Add "(in /egg directory)" to repository link Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
|
|
||
| An E-Graph (Equality Graph) implementation for the DS deductive system, providing efficient management and manipulation of equivalence classes of terms. | ||
|
|
||
| This package implements the egg-style E-Graph data structure with deferred congruence closure, enabling efficient equality reasoning. Based on the [egg library](https://egraphs-good.github.io/). |
| @@ -0,0 +1,123 @@ | |||
| # E-Graph Support Package | |||
There was a problem hiding this comment.
Updated docs/support-packages/egg.md with the same "Inspired by" wording in de8116b. The file already had all the simplifications from the README (no Union-Find/E-Nodes sections in Core Concepts, no UnionFind/ENode/EClassId in API Reference).
The implementation references the egg library but is not directly based on it. Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive documentation for the egg subpackage (E-Graph library), following the structure and granularity established by the bnf subpackage. The documentation covers installation, usage examples, core concepts (E-Graph structure, congruence closure, deferred rebuilding), and API reference.
Key changes:
- Complete package documentation with examples demonstrating equality reasoning and congruence closure
- Documentation site integration under "Support Packages" section
- Main repository README updated to reference the new package
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| egg/README.md | New comprehensive README covering features, installation, usage examples, core concepts, API overview, and build instructions for the egg package |
| docs/support-packages/egg.md | New documentation site page with detailed usage patterns, core concepts explanation, and API reference for the E-Graph support package |
| README.md | Added egg package entry in the Support Packages section linking to apyds-egg on PyPI |
| mkdocs.yml | Added E-Graph navigation entry under Support Packages section |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| Terms are converted to E-Nodes and added to the E-Graph: | ||
|
|
||
| - **Items (constants/functors) and Variables**: Atomic terms like `a`, `b`, or backtick-prefixed variables like `x` are represented as E-Nodes with no children |
There was a problem hiding this comment.
The example for backtick-prefixed variables is missing the backtick prefix. Change "like x" to "like `x" to correctly demonstrate the backtick prefix syntax for variables.
| - **Items (constants/functors) and Variables**: Atomic terms like `a`, `b`, or backtick-prefixed variables like `x` are represented as E-Nodes with no children | |
| - **Items (constants/functors) and Variables**: Atomic terms like `a`, `b`, or backtick-prefixed variables like `` `x `` are represented as E-Nodes with no children |
The egg subpackage (E-Graph library for DS) was missing documentation. Added comprehensive docs following bnf subpackage structure.
Changes
/egg/README.md: Full package documentation with installation, usage examples, API reference, and core concepts (E-Graph and congruence closure). Includes reference to the egg library as inspiration for this implementation./docs/support-packages/egg.md: Documentation site page with usage patterns and streamlined API reference/README.md: Added egg package link in "Support Packages" section (equality reasoning only)/mkdocs.yml: Added egg navigation entry under "Support Packages"Example Usage
Documentation Scope
The documentation focuses on the core E-Graph functionality for equality reasoning. Internal implementation details (Union-Find, E-Nodes) are not exposed in the user-facing API documentation. Test commands use
uv run pytestto match the project's build system.Documentation follows E-class (lowercase) terminology consistent with source code.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.