Skip to content

[declare] Refactor constant information into a record. - #12372

Merged
SkySkimmer merged 28 commits into
rocq-prover:masterfrom
ejgallego:proof+info
Jun 29, 2020
Merged

[declare] Refactor constant information into a record.#12372
SkySkimmer merged 28 commits into
rocq-prover:masterfrom
ejgallego:proof+info

Conversation

@ejgallego

@ejgallego ejgallego commented May 19, 2020

Copy link
Copy Markdown
Contributor

We refactor and consolidate handling of constant information in the Declare interface.

This improves the interface, enforces some more invariants, and allows a significant sealing of the API.

The PR is large as it was a bit of titanic work to have everything fall in place and stabilize the API, no point on doing overlays for an interim version of the API IMO. Future PRs will rework the internals of declare and hopefully consolidate them, in particular regarding proof involving many constants, side-effects, etc...

I will also allow #12539 and #9004

Overlays:

@ejgallego ejgallego added kind: cleanup Code removal, deprecation, refactorings, etc. kind: internal API, ML documentation... labels May 19, 2020
@ejgallego
ejgallego force-pushed the proof+info branch 3 times, most recently from fe87400 to 5e41e10 Compare May 25, 2020 13:12
@ejgallego
ejgallego force-pushed the proof+info branch 5 times, most recently from bf9b69d to 5ac2c3e Compare June 23, 2020 19:50
@ejgallego ejgallego added the needs: overlay This is breaking external developments we track in CI. label Jun 23, 2020
@ejgallego

Copy link
Copy Markdown
Contributor Author

This is ready for review, overlays in preparation.

@ejgallego
ejgallego marked this pull request as ready for review June 23, 2020 21:01
@ejgallego
ejgallego requested review from a team as code owners June 23, 2020 21:01
ejgallego added 27 commits June 26, 2020 14:38
At this point the record in lemmas was just a stub; next commit will
stop exposing the internals of mutual information, and pave the way
for the refactoring of `Info.t` handling in the Declare interface.
We move the advanced proof initialization routine to Declare, and stop
exposing implementation internals in `Info.t` constructor.
The module is now a stub. We choose to be explicit on the parameters
for now, this will improve in next commits with the refactoring of
proof / constant information.
This improves the interface, and allows even more sealing of the API.

This is yet work in progress.
This hides even more internals; we will reduce the API even more
shortly.
The previous refactoring in `Declare` to add `CInfo.t` makes this a
good moment to clean overlays up w.r.t. deprecation.

All cases but one is just a matter of simple renaming, for the other
the use of an internal API is replaced by newer API.
This is in preparation for the next commit which will clean-up the
current API flow in `Declare`.
Step towards merging `Info  / `CInfo`; the presentation order is now
"final" in the sense of that we propose this API for the medium-term.
When declaring a lemma, the code path is quite different depending on
whether the lemma is inferred to be a mutually-defined lemma or not.

We refactor the code path in declare to reflect that; this will allow
to better organize constant information and to reuse the `Recthm.t`
type in particular.
This removes so ad-hoc tuples, and encapsulates the API a bit.

It is a step towards:

- Pushing some `to_constr` from the upper layers to the declare code
  itself [which will remove code duplication, in particular making the
  interactive / non-interactive path more uniform, and make the API
  easier to use]

- Further refactoring of the constant information, as `Recthm.t`
  contains almost now what we would call "primitive constant
  information"; thus we will be able to distinguish next better between
  mutual declarations and single-constant ones.
We unify information about constants so it is shared among all the
paths [interactive, NI, obligations].

IMHO the current setup looks pretty good, with information split into
a per-constant record `CInfo.t` and variables affecting mutual
definitions at once, which live in `Info.t`.

Main information outside our `Info` record is `opaque`, which is
provided at different moments in several cases.

There are a few nits regarding interactive proofs, which will go away
in the next commits.
Now that the interface has mostly stabilized, we move code around to
respect internal dependency order.

This will allow us to start sharing more code in the 4 principal
cases, and also paves the way for the full merging of obligations and
the removal of the Proof_ending type in favor of stronger type
abstraction.
This allows us to remove a large chunk of the internal API, and is the
pre-requisite to get rid of [Proof_ending], and even more refactoring
on the declare path.
This completes the refactoring [for now] of the core `Declare`
interface, and will allow much internal refactoring in the future.

In particular, we remove the low-level Proof_ending type, and instead
introduce higher-level constructors for the several declare users.

Future PRs will change the internal representation of proof handling
to better enforce some invariants that should hold for specific
proofs.
This is needed in rewriter as to avoid hack; indeed it makes sense to
propagate this information to the callers of save.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: cleanup Code removal, deprecation, refactorings, etc. kind: internal API, ML documentation...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants