Skip to content

Conversation

@loutr
Copy link
Contributor

@loutr loutr commented Apr 4, 2025

This pull request adds a global keyword that ensures that

global clone A as Ab ...

gives public visibility to newly-cloned items from theory A. This might be useful in patterns like

local clone A as Ab.
global clone Ab.some.interesting.subtheory as B with ...

in order to reexport only specific parts of interest from a given theory A. It does not change the standard behaviour
that clone A as B preserves the visibility of A for items of B. Commit df336f8 provides an information message when this happens when cloning a local theory (with clone and not local clone), and also informs on the existence of the global keyword.

This also addresses issue #747, because it gives the right visibility to the new theory itself, and not only its items; which properly clears the theory and escapes the assertion failure.

This has been tested on the standard library successfully but was not otherwise submitted to more tests; I will of course try to fix errors if they arise.

@fdupress
Copy link
Member

fdupress commented Apr 4, 2025

Thanks! Running CI now.

I am not sure about the addition of a keyword. Could this be done without?

As a broader thing to consider (not for this PR), I think we don't need locality or globality information until typing, so perhaps they could be passed in using the option mechanism instead of blocking a keyword? This may then make it simpler to also extend locality to the case of nested sections (a longstanding grumble), for example as lemma [local=SectionName] toto: ...

@strub what do we think? Follow-up issue?

@loutr , please do run locally on the examples as well. (Make check should take care of those once stdlib is done.) It is not your responsibility to fix proofs in the external CI, only to liaise with their maintainer. (I think I'll add "write contributor guidelines" up as an issue, and add a maintainer field to the external CI config.)

@loutr
Copy link
Contributor Author

loutr commented Apr 7, 2025

Sorry for the weekend delay.. It would be best indeed to incorporate this new "global" semantics within the existing syntax, but it is so user-directed that I don't see how to do it in a consistent way. I don't know about this option mechanism but I'd be glad to adapt this PR to it.

Otherwise, this little work started from a discussion with @bgregoir, which we shared later on with @strub.

As for the examples, I forgot to mention it but I also did run them successfully (apart from the old/ and to-port/ ones, of course), but indeed I should have just used the Makefile

@fdupress fdupress requested a review from strub April 8, 2025 06:29
@bgregoir
Copy link
Contributor

bgregoir commented Apr 9, 2025

I agree with you Francois we can/should certainly use something like #[global] but for uniformity we should also replace local with #[local] and what about "declare". And do we want to do this in the same PR ?

@fdupress
Copy link
Member

fdupress commented Apr 9, 2025

Not in the same PR for sure. Given that this does not break external CI (I was worried about introducing global as a keyword), I think we can merge as is and unify and simplify later.

@strub
Copy link
Member

strub commented Apr 14, 2025

For the global keyword, you can add it to the ident rule of the parser so that it is not reserved.

Copy link
Member

@strub strub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a single commit policy. Please, squash your PR.

Copy link
Member

@strub strub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a simple unit test in tests/?

@strub
Copy link
Member

strub commented Apr 14, 2025

I added a few comments. Otherwise, we are good to go.

Provides a new `global` keyword that can be used with theory cloning
(as opposed to local), that typically allows to reexport (sub)theories
of an otherwise local theory.

feat: added global keyword and control flow modification
fix: fix local overriding behaviour
fix: use correct (relocalised) item for checking
feat(printing): display theory locality
feat: apply correct locality to cloned _theories_
style(add_item hook): reduce passing around of the `override_locality` parameter
fix: still change locality when within local scope
feat(cloning): notify change on visibility
style(section): more readable `generalize_ctheorem` function
feat(parser): make the `global` keyword non-reserved
test: unit test for the `global` keyword cloning functionality
@loutr loutr force-pushed the global-clone-keyword branch from 5c08a51 to bfdf4da Compare April 15, 2025 13:55
@loutr
Copy link
Contributor Author

loutr commented Apr 15, 2025

We have a single commit policy. Please, squash your PR.

Sorry, I thought it would be done automatically upon rebase, it's done.

Could you add a simple unit test in tests/

Done, I deem it satisfactory but feel free to also make comments about it.

@strub strub self-assigned this Apr 17, 2025
@strub strub merged commit 7259c58 into EasyCrypt:main Apr 17, 2025
15 checks passed
@loutr loutr deleted the global-clone-keyword branch July 3, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants