Skip to content

Improve check error message and document query-based semantics for constructor terms#843

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-materialize-constructors-checks
Draft

Improve check error message and document query-based semantics for constructor terms#843
Copilot wants to merge 3 commits intomainfrom
copilot/fix-materialize-constructors-checks

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 9, 2026

check runs a query against existing e-graph state — constructor terms must already be present for a check to succeed, unlike primitives. This mismatch between expectation and behavior produced unhelpful errors with no indication of the root cause.

Changes

  • Clearer error message: CheckError now reads "Check failed (are the relevant terms present in the e-graph?)" instead of the bare "Check failed".
  • Documentation: Command::Check doc comment now explicitly states that eqsort constructor terms must be pre-existing in the e-graph, with a before/after example contrasting in-graph vs. out-of-graph term behavior.
  • New test (check-constructor-not-in-egraph.egg): Covers the failing case from the issue, successful check after let-binding, equality between two variables pointing to the same constructor term, and continued failure for unintroduced terms.

Example

(datatype Math)
(constructor Num (i64) Math)

(fail (check (= (Num 6) (Num 6))))  ;; (Num 6) not in e-graph yet

(let x (Num 6))
(check (= x (Num 6)))               ;; now succeeds

(let y (Num 6))
(check (= x y))                     ;; same term, equality holds

Error before introducing the term:

In 3:1-27 of stdin: (check (= (Num 6) (Num 6)))
Check failed (are the relevant terms present in the e-graph?): 
(= (Num 6) (Num 6))

Copilot AI and others added 2 commits April 9, 2026 20:54
…m behavior

Agent-Logs-Url: https://github.com/egraphs-good/egglog/sessions/7ca6f621-bd4b-4430-89c1-ef6dc4f7e6a7

Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
…or term

Agent-Logs-Url: https://github.com/egraphs-good/egglog/sessions/7ca6f621-bd4b-4430-89c1-ef6dc4f7e6a7

Co-authored-by: saulshanabrook <1186124+saulshanabrook@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix materialize checks for constructors to ensure correctness Improve check error message and document query-based semantics for constructor terms Apr 9, 2026
Copilot AI requested a review from saulshanabrook April 9, 2026 20:59
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.

Should Check Materialize Constructors?

2 participants