Skip to content

Correctly detect body for module-type-locked constants#173

Open
JasonGross wants to merge 3 commits into
coq-masterfrom
module-type-locked-body
Open

Correctly detect body for module-type-locked constants#173
JasonGross wants to merge 3 commits into
coq-masterfrom
module-type-locked-body

Conversation

@JasonGross

Copy link
Copy Markdown
Member

When a module is constrained by a module type using :, the constant bodies appear as Undef in the global environment but still exist in the module structure. This caused dpdgraph to incorrectly report body=no for such constants.

Following the approach used by Print Assumptions in vernac/assumptions.ml, implement a ModLookup module that traverses the module structure to find the actual constant body when the environment lookup returns Undef.

This ensures that module-type-locked constants like:
Module Foo : FooT. Definition T := O. End Foo.
correctly report body=yes instead of body=no.

Add test case ModuleTypeLocked.v to verify the behavior.

Fixes #172

@JasonGross JasonGross requested a review from ybertot February 3, 2026 02:28
@JasonGross JasonGross force-pushed the module-type-locked-body branch 2 times, most recently from e3f8281 to 5051e0a Compare February 6, 2026 02:09
@ybertot

ybertot commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

I am opposed to considering Anthropic's Claude as a co-author of this code, because this is not a person. You, @JasonGross, are the author, and any risk associated with this code is your responsibility. Whether you are using an advanced tool to suggest code that works is your problem, but in the end you have to check that you are using existing OCaml functionalities and examples from the code base in an appropriate manner.

@JasonGross

Copy link
Copy Markdown
Member Author

Let me mark this as a draft until I am satisfied with it

@JasonGross JasonGross marked this pull request as draft February 6, 2026 09:36
@JasonGross JasonGross force-pushed the module-type-locked-body branch 3 times, most recently from 413d078 to 4e5f748 Compare February 7, 2026 02:43
JasonGross added a commit that referenced this pull request Feb 7, 2026
@JasonGross JasonGross force-pushed the module-type-locked-body branch 2 times, most recently from 2704633 to 64c5552 Compare February 7, 2026 08:22
@JasonGross JasonGross marked this pull request as ready for review February 7, 2026 08:22
@JasonGross

Copy link
Copy Markdown
Member Author

I am now satisfied with this. Most of the code is taken verbatim from Rocq's source (and should be kept in sync with any updates that are made there, presumably).

When a module is constrained by a module type using `:`, the constant
bodies appear as Undef in the global environment but still exist in
the module structure. This caused dpdgraph to incorrectly report
body=no for such constants.

Following the approach used by Print Assumptions in vernac/assumptions.ml,
implement a ModLookup module that traverses the module structure to find
the actual constant body when the environment lookup returns Undef.

This ensures that module-type-locked constants like:
  Module Foo : FooT. Definition T := O. End Foo.
correctly report body=yes instead of body=no.

We need to add fallback behaviors for doing anything with names that
might not be in the nametab.

Add test cases to verify the behavior.
@JasonGross JasonGross force-pushed the module-type-locked-body branch from 64c5552 to 40cec6d Compare March 22, 2026 16:13
JasonGross added a commit to JasonGross/coq-dpdgraph that referenced this pull request Mar 22, 2026
ebmoon pushed a commit to theorem-labs/coq-dpdgraph that referenced this pull request Apr 15, 2026
@JasonGross

Copy link
Copy Markdown
Member Author

CI now passes, what do you think @ybertot ?

@JasonGross

Copy link
Copy Markdown
Member Author

@ybertot @Karmaki ping

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.

dpdgraph disagrees with Print Assumptions on module-locked opaque constants

2 participants