Skip to content

feature(coq): composition of installed theories#7047

Merged
Alizter merged 7 commits intoocaml:mainfrom
Alizter:ps/rr/feature_coq___composition_of_installed_theories
Apr 20, 2023
Merged

feature(coq): composition of installed theories#7047
Alizter merged 7 commits intoocaml:mainfrom
Alizter:ps/rr/feature_coq___composition_of_installed_theories

Conversation

@Alizter
Copy link
Copy Markdown
Collaborator

@Alizter Alizter commented Feb 11, 2023

We add support for composition with installed theories to the Coq rules.

This allows people to use Dune even if their project depends on an installed project built using make.

This works by first checking if coq lang is enabled, then scanning user-contrib and directories in COQPATH for potential theories. Then a database is constructed allowing users to write (thories foo.bar) and Dune will look for the Coq_lib_name foo.bar. The database would have an entry for user-contrib/foo/bar say and would in turn be able to describe a Coq theory.

Closes #6982

Any testing would be appreciated.

Tasks:

  • pass -boot to every coqc. We probably need to make a :standard for plugins if we do this.
  • coq lang version bump to 0.8
  • investigate performance in presence of a larger user-contrib (my scanning is probably terrible atm)
  • composition with plugins
    • Stop linking plugin tutorial
    • Sort flags when printing to make tests repro
  • fix extraction
  • fix dune coq top
  • make sure compatibility with < 0.8
    • Nice warning when trying to compose but dune lang < 0.8
  • Coq Universe testing - When using 0.8, projects are able to compose with non-dune projects and install and build.
  • Documentation: doc(coq): Add documentation for composition with installed theories #7384
  • Changelog

@ejgallego
Copy link
Copy Markdown
Collaborator

Very nice!

I'm unsure if we should introduce a Coq_lib.Legacy.t type tho, I guess there is no need as the abstraction we have works.

A pain in the ass regarding plugins is that Coq by default will add anything under user-contrib to -I, we need to do the same for the sub-tree in question (tho maybe only the top level happens in practice)?

How are the meta files installed for plugins in 8.16?

Some test ideas:

  • test with installed coq (and requiring the Coq library to be added explicitly)
  • test with some true opam package
  • mock tests can be done setting COQLIB, not sure if we need to pass -require Coq.Init.Prelude tho?
  • we should test with a plugin installed in user-contrib, mock version

@Alizter Alizter added this to the 3.8.0 milestone Feb 12, 2023
@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch from c011353 to 3630520 Compare February 14, 2023 21:00
@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch 2 times, most recently from c8116b5 to 1b44109 Compare February 20, 2023 19:01
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 20, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 20, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 20, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 20, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch from 1b44109 to 69476db Compare February 20, 2023 23:30
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 21, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 21, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit to ejgallego/dune that referenced this pull request Feb 21, 2023
This will be important once we have installed_theories in ocaml#7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit that referenced this pull request Feb 21, 2023
This will be important once we have installed_theories in #7047

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch from 69476db to c88aece Compare March 7, 2023 20:09
@Alizter
Copy link
Copy Markdown
Collaborator Author

Alizter commented Mar 7, 2023

I've pushed a bunch of commits for the current WIP. There is now support for composition with installed plugins and also -boot is being passed everywhere. There is a lot of clean up we can do now.

There are a few commits in here I will cherry pick and make into their own PRs. I don't plan to keep the testing of equations and mathcomp in the CI, that is just for show.

@ejgallego
Copy link
Copy Markdown
Collaborator

Amazing work @Alizter !

@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch from c88aece to 5ebaf6b Compare March 8, 2023 14:13
@ejgallego
Copy link
Copy Markdown
Collaborator

@ejgallego Yes, we need to version to boot flags unfortunately.

We could version that, or keep boot and add then user-contrib + coqpath by default if the lang version is less than 0.8

I guess the second apporach may be easier.

@ejgallego
Copy link
Copy Markdown
Collaborator

Let's deprecate up to 0.4 to start with.

@ejgallego
Copy link
Copy Markdown
Collaborator

Also coq-stdlib installs Ltac2 in user-contrib so that can be used to make a quick test.

@Blaisorblade
Copy link
Copy Markdown
Contributor

(thories something.installed)

But spelling out whether something is installed prevents dune composition, doesn't it?

@ejgallego
Copy link
Copy Markdown
Collaborator

But spelling out whether something is installed prevents dune composition, doesn't it?

I guess @Alizter just meant that name as a token, the installed part has no relevance.

With this PR, things work for Coq like in OCaml, theories are looked locally (in scope, so both private and public are visible), then in the workspace, then in the installed_db which is built from COQLIB and COQPATH

@Alizter
Copy link
Copy Markdown
Collaborator Author

Alizter commented Apr 7, 2023

(thories something.installed)

But spelling out whether something is installed prevents dune composition, doesn't it?

Yeah it was just a name. I should have said foo.bar instead.

@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch 2 times, most recently from ce5651b to 3d8a217 Compare April 8, 2023 17:47
@Alizter Alizter force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch 2 times, most recently from 615f06f to 46b1503 Compare April 17, 2023 22:31
@Alizter
Copy link
Copy Markdown
Collaborator Author

Alizter commented Apr 17, 2023

@ejgallego The tests are now passing. We no longer pass -boot if we are < 0.8. Please have a look through and let me know if there is anything left, otherwise we should be ready to merge.

@Alizter
Copy link
Copy Markdown
Collaborator Author

Alizter commented Apr 17, 2023

I've also tested this in a docker container with coq 8.17 and the tests all pass.

Alizter added 6 commits April 20, 2023 18:36
Signed-off-by: Ali Caglayan <alizter@gmail.com>
This is some preliminary refactoring for the introduction of a legeacy
library later on when we introduce library composition.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
When we start considering installed libraries we need to have a
general path.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
We turn a polymorphic variant into a few regular datatypes, so stages
of resolution have a totally separate typing, not sharing constructors
anymore.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
Added:
- Coq_lib.equal (from compare)
- Coq_lib.empty (convenience for mapping lib names to dirs)
- Coq_lib.stdlib (name of the Coq standrad library)
- Coq_lib.to_list (perhaps should be renamed explode)
- Coq_lib.append

Signed-off-by: Ali Caglayan <alizter@gmail.com>
@ejgallego ejgallego force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch from 4d0c4bc to 129d082 Compare April 20, 2023 17:22
This commit introduces a new database for "installed" theories present
in `user-contrib` and `COQPATH`.

The above paths are scanned and the database of theories is populated
based on the subdirectories found.

In order to keep compatibility, we add to the database all possible
theory names (so for example, given a directory `A/B` we will register
two Coq theories `A` and `A.B`).

Changes in the code are as expected, main new things are:

- `Coq_lib.t` now can represent two kind of objects: theories with an
  associated dune stanza, and theories found in the system and for
  whom no stanza is available.

- A new`Coq_path.t` type, which represents an inferred "stanza" for
  libraries that are installed in the `user-contrib` / `COQPATH`
  scheme. The list of such paths is then used to build the database.

Starting with `(coq lang 0.8)` Coq will not see any theory, even if
globally installed, unless that theory was declared in the
corresponding `theories` field in the stanzas.

This solves a longstanding problem due to users being not able to
compose with a theory that could present either locally or in
installed form.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>
@ejgallego ejgallego force-pushed the ps/rr/feature_coq___composition_of_installed_theories branch from 129d082 to 49c35b0 Compare April 20, 2023 17:27
Copy link
Copy Markdown
Collaborator

@ejgallego ejgallego left a comment

Choose a reason for hiding this comment

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

Ready to merge!

@Alizter Alizter merged commit 98de950 into ocaml:main Apr 20, 2023
@Alizter Alizter deleted the ps/rr/feature_coq___composition_of_installed_theories branch April 20, 2023 17:51
ejgallego added a commit to ejgallego/dune that referenced this pull request Apr 21, 2023
Since ocaml#6409 we automatically infer rules for coq-native, and in
general this requires at least Coq 8.10 due to the need of
command-line option flags added in that version for native.

Also, since ocaml#7047 and `(coq lang 0.8)` we detect installed theories,
correcting a longstanding problem, we require all users to migrate.

The recommended path for most projects is just to upgrade their dune
file and Coq version file. Coq 8.10 will likely be the base we support
in `(lang coq 1.0)`.

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
ejgallego added a commit to ejgallego/dune that referenced this pull request Apr 21, 2023
Since ocaml#6409 we automatically infer rules for coq-native, and in
general this requires at least Coq 8.10 due to the need of
command-line option flags added in that version for native.

Also, since ocaml#7047 and `(coq lang 0.8)` we detect installed theories,
correcting a longstanding problem, we require all users to migrate.

The recommended path for most projects is just to upgrade their dune
file and Coq version file. Coq 8.10 will likely be the base we support
in `(lang coq 1.0)`.

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[meta] [coq] Support for installed theories coordination issue.

4 participants