Skip to content

Conversation

@rlepigre-skylabs-ai
Copy link
Contributor

This PR is an attempt at the first necessary steps to implement rocq-prover/rfcs#101, whose aim is to add proper package management to Rocq (piggy-backing on findlib). This was discussed in this week's Rocq Call.

Current state

In the current version, the following two changes are done:

  • The rocq dep command is extended with a -package <pkg> argument (similar to that of ocamlfind).
  • A rocqfind tool is added: given a list of package names, it returns the necessary -Q / -I options to use them.

Both seem to work as I expect them to, at least on the small-ish tests I ran.

More work is obviously needed, for instance adding a similar -package option to other commands, but argument handling is not fully shared between commands (rocqchk, rocq doc, ...) if I understand correctly, so I'd prefer to agree on some kind of plan (maybe involving refactoring) before doing changes in several places.

Testing done

My testing setup was constructed as follows:

dune build
mkdir -p fake-lib-dir/rocq-core/ltac2
cp -r _build/install/default/lib/coq/theories other-fake-lib-dir/rocq-core/rocq.d
cp -r _build/install/default/lib/coq/user-contrib/Ltac2 other-fake-lib-dir/rocq-core/ltac2/rocq.d

And writing the following to file fake-lib-dir/rocq-core/META.

version = "dev"
description = "The Rocq Prover's prelude."
rocqpath = "Corelib"
requires = "rocq-runtime.plugins.ltac"
requires += "rocq-runtime.plugins.tauto"
requires += "rocq-runtime.plugins.cc"
requires += "rocq-runtime.plugins.firstorder"
requires += "rocq-runtime.plugins.number_string_notation"
requires += "rocq-runtime.plugins.btauto"
requires += "rocq-runtime.plugins.rtauto"
requires += "rocq-runtime.plugins.ring"
requires += "rocq-runtime.plugins.nsatz"
requires += "rocq-runtime.plugins.zify"
requires += "rocq-runtime.plugins.micromega"
requires += "rocq-runtime.plugins.funind"
requires += "rocq-runtime.plugins.ssreflect"
requires += "rocq-runtime.plugins.derive"

package "ltac2" (
  directory = "ltac2"
  version = "dev"
  description = "The Rocq Prover's Ltac2 standard library."
  rocqpath = "Ltac2"
  requires = "rocq-core"
  requires += "rocq-runtime.plugins.ltac2_ltac1"
  requires += "rocq-runtime.plugins.ltac2"
)

With this setup, I could then for example run:

$ OCAMLPATH=fake-lib-dir:_build/install/default/lib _build/install/default/bin/rocqfind -I -Q rocq-core.ltac2
-I '_build/install/default/lib/rocq-runtime/plugins/ltac'
-I '_build/install/default/lib/rocq-runtime/plugins/tauto'
-I '_build/install/default/lib/rocq-runtime/plugins/cc_core'
-I '_build/install/default/lib/rocq-runtime/plugins/cc'
-I '_build/install/default/lib/rocq-runtime/plugins/firstorder_core'
-I '_build/install/default/lib/rocq-runtime/plugins/firstorder'
-I '_build/install/default/lib/rocq-runtime/plugins/number_string_notation'
-I '_build/install/default/lib/rocq-runtime/plugins/btauto'
-I '_build/install/default/lib/rocq-runtime/plugins/rtauto'
-I '_build/install/default/lib/rocq-runtime/plugins/ring'
-I '_build/install/default/lib/rocq-runtime/plugins/nsatz_core'
-I '_build/install/default/lib/rocq-runtime/plugins/nsatz'
-I '_build/install/default/lib/rocq-runtime/plugins/zify'
-I '_build/install/default/lib/rocq-runtime/plugins/micromega_core'
-I '_build/install/default/lib/rocq-runtime/plugins/micromega'
-I '_build/install/default/lib/rocq-runtime/plugins/extraction'
-I '_build/install/default/lib/rocq-runtime/plugins/funind'
-I '_build/install/default/lib/rocq-runtime/plugins/ssrmatching'
-I '_build/install/default/lib/rocq-runtime/plugins/ssreflect'
-I '_build/install/default/lib/rocq-runtime/plugins/derive'
-I '_build/install/default/lib/rocq-runtime/plugins/ltac2'
-I '_build/install/default/lib/rocq-runtime/plugins/ltac2_ltac1'
-Q 'fake-lib-dir/rocq-core/rocq.d' Corelib
-Q 'fake-lib-dir/rocq-core/ltac2/rocq.d' Ltac2

I also tested the rocq dep by writing the following to file test.v:

Require Import Corelib.Init.Prelude.
Require Import Ltac2.Ltac2.

And the running the following command.

$ OCAMLPATH=fake-lib-dir:_build/install/default/lib _build/install/default/bin/rocq dep -boot -package rocq-core -package rocq-core.ltac2 some-test/test.v
some-test/test.vo some-test/test.glob some-test/test.v.beautified some-test/test.required_vo: some-test/test.v fake-lib-dir/rocq-core/ltac2/rocq.d/Ltac2.vo fake-lib-dir/rocq-core/rocq.d/Init/Prelude.vo _build/install/default/lib/rocq-runtime/rocqworker

TODO

  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.

@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jan 29, 2026
@rlepigre-skylabs-ai
Copy link
Contributor Author

rlepigre-skylabs-ai commented Jan 29, 2026

Regarding the adaptation of rocq makefile, I believe that we wouldn't even need the -package options to the various commands, and that rocqfind would be sufficient for compilation (provided that install packages follow the expected installation scheme). All we'd need to do is ask the user to give a list of package dependencies in a variable ROCQ_PACKAGES, and then we could do something like the following in the generated Makefile:

DEPS_ARGS := $(shell rocqfind -Q -I ${ROCQ_PACKAGES} | tr '\n' ' ')

We would then add ${DEPS_ARGS} to all invoked rocq commands, in addition to the -Q / -R / -I that are needed for the local plugins / theories, and things would just work.

Of course, we'd still need to make sure that make install respects the installation scheme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant