Skip to content

Commit 3192158

Browse files
authored
update to rocq 9.0, lambdapi 3.0.0 and hol_light 3.1.0 (#179)
1 parent 36d773a commit 3192158

37 files changed

Lines changed: 157 additions & 188 deletions

.github/workflows/main.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ on:
22
pull_request:
33
types: [opened, synchronize, reopened]
44
push:
5-
paths-ignore:
6-
- '**/*.md'
5+
paths:
6+
- '*.ml'
7+
- 'Makefile'
8+
- 'dune'
9+
- 'dune-project'
10+
- 'config'
11+
- 'patch'
12+
- 'unpatch'
713
workflow_dispatch:
814
jobs:
915
ci:
1016
strategy:
1117
fail-fast: false
1218
matrix:
13-
ocaml-version: [5.2.1]
19+
ocaml-version: [5.3.0]
1420
dune-version: [3.19.1]
15-
camlp5-version: [8.03.01]
16-
hol-light-version: [3.0.0]
17-
hol-light-commit: [master] # Release-3.0.0]
21+
camlp5-version: [8.03.06]
22+
hol-light-version: [3.1.0]
23+
hol-light-commit: [master]
1824
lambdapi-version: [master] # >= 31aef37c > 2.5.1
1925
dedukti-version: [2.7]
20-
mapping: [mappings_nat, mappings_N]
26+
mapping: [mappings_N]
2127
runs-on: ubuntu-latest
2228
steps:
2329
# actions/checkout must be done BEFORE avsm/setup-ocaml
@@ -60,7 +66,7 @@ jobs:
6066
eval `opam env`
6167
export HOL2DK_DIR=`pwd`
6268
export HOLLIGHT_DIR=`pwd`/hol-light
63-
cp hol_upto_arith.ml hol_lib_upto_arith.ml hol-light/
69+
cp test/hol_upto_arith.ml test/hol_lib_upto_arith.ml hol-light/
6470
cd hol-light
6571
hol2dk dump-simp-before-hol hol_upto_arith.ml
6672
- name: Test single-threaded dk output
@@ -70,7 +76,7 @@ jobs:
7076
export HOLLIGHT_DIR=`pwd`/hol-light
7177
mkdir -p output1
7278
cd output1
73-
hol2dk config hol_upto_arith.ml HOLLight ../${{ matrix.mapping }}.v ../${{ matrix.mapping }}.lp
79+
hol2dk config hol_upto_arith.ml HOLLight ../test/${{ matrix.mapping }}.v ../test/${{ matrix.mapping }}.lp
7480
hol2dk hol_upto_arith.dk
7581
dk check hol_upto_arith.dk
7682
- name: Test single-threaded lp output
@@ -80,7 +86,7 @@ jobs:
8086
export HOLLIGHT_DIR=`pwd`/hol-light
8187
mkdir -p output2
8288
cd output2
83-
hol2dk config hol_upto_arith.ml HOLLight ../${{ matrix.mapping }}.v ../${{ matrix.mapping }}.lp
89+
hol2dk config hol_upto_arith.ml HOLLight ../test/${{ matrix.mapping }}.v ../test/${{ matrix.mapping }}.lp
8490
hol2dk hol_upto_arith.lp
8591
lambdapi check hol_upto_arith.lp
8692
- name: Test multi-threaded dk output with mk
@@ -90,7 +96,7 @@ jobs:
9096
export HOLLIGHT_DIR=`pwd`/hol-light
9197
mkdir -p output3
9298
cd output3
93-
hol2dk config hol_upto_arith.ml HOLLight ../${{ matrix.mapping }}.v ../${{ matrix.mapping }}.lp
99+
hol2dk config hol_upto_arith.ml HOLLight ../test/${{ matrix.mapping }}.v ../test/${{ matrix.mapping }}.lp
94100
hol2dk mk 3 hol_upto_arith
95101
make -f hol_upto_arith.mk -j3 dk
96102
dk check hol_upto_arith.dk
@@ -101,7 +107,7 @@ jobs:
101107
export HOLLIGHT_DIR=`pwd`/hol-light
102108
mkdir -p output4
103109
cd output4
104-
hol2dk config hol_upto_arith.ml HOLLight ../${{ matrix.mapping }}.v ../${{ matrix.mapping }}.lp
110+
hol2dk config hol_upto_arith.ml HOLLight ../test/${{ matrix.mapping }}.v ../test/${{ matrix.mapping }}.lp
105111
hol2dk mk 3 hol_upto_arith
106112
make -f hol_upto_arith.mk -j3 lp
107113
make -f hol_upto_arith.mk -j3 lpo
@@ -113,7 +119,7 @@ jobs:
113119
export HOLLIGHT_DIR=`pwd`/hol-light
114120
mkdir -p output5
115121
cd output5
116-
hol2dk config hol_upto_arith.ml HOLLight ../${{ matrix.mapping }}.v ../${{ matrix.mapping }}.lp
122+
hol2dk config hol_upto_arith.ml HOLLight ../test/${{ matrix.mapping }}.v ../test/${{ matrix.mapping }}.lp
117123
make split
118124
make -j3 lp
119125
make -j3 lpo

.gitignore

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
11
_build/
2-
\#*
3-
*.vo
4-
*.conf
5-
*.d
6-
*.vman
7-
*.vok
8-
*.vos
9-
.lia.cache
10-
.nia.cache
11-
.*.aux
12-
*.glob
13-
*.lpo
14-
*.dko
15-
16-
Spec_With_N.v
17-
Spec_mappings_N.v
18-
check-spec.mk

Makefile

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ lpo.mk: $(LPO_MK_FILES)
231231
find . -maxdepth 1 -name '*.lpo.mk' | xargs cat > $@
232232

233233
theory_hol.lpo.mk: theory_hol.lp
234-
$(HOL2DK_DIR)/dep-lpo $< > $@
234+
echo 'theory_hol.lpo:' > $@
235235
endif
236236

237237
.PHONY: lpo
@@ -376,19 +376,3 @@ clean-votodo: votodo
376376
.PHONY: lpsize
377377
lpsize:
378378
find . -maxdepth 1 -name '*.lp' -print0 | du --files0-from=- --total -s -h | tail -1
379-
380-
.PHONY: check-spec
381-
check-spec: check-spec.mk
382-
$(MAKE) -f check-spec.mk
383-
384-
HOL2DK_COQ_MODULES := type mappings_N Sig_mappings_N Check_mappings_N With_N Sig_With_N Check_With_N Spec_mappings_N Spec_With_N
385-
HOL2DK_VFILES := $(HOL2DK_COQ_MODULES:%=%.v)
386-
387-
check-spec.mk: $(HOL2DK_VFILES)
388-
coq_makefile -R . HOLLight $+ -o $@
389-
390-
Spec_With_N.v: Spec_mappings_N.v Sig_With_N.v
391-
cat $+ | sed -e '/^Require Export HOLLight_Real_With_N.type./d' -e '/^Require HOLLight.Spec_mappings_N./d' -e '/^Module Type Spec./d' -e '/^Include HOLLight.Spec_mappings_N.Spec./d' -e '/^End Spec./d' -e '/^Include Spec./d' > $@
392-
393-
Spec_mappings_N.v: type.v Sig_mappings_N.v
394-
cat $+ | sed -e '/^Require Export HOLLight_Real_With_N.type./d' -e '/^Module Type Spec./d' -e '/^End Spec./d' -e '/^Include Spec./d' > $@

README.md

Lines changed: 42 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Export HOL-Light proofs to Dedukti, Lambdapi and Coq
2-
====================================================
1+
Export HOL-Light proofs to Dedukti, Lambdapi and Rocq
2+
=====================================================
33

4-
This project provides a tool, hol2dk, to translate [HOL-Light](https://github.com/jrh13/hol-light) proofs to [Dedukti](https://github.com/Deducteam/Dedukti/), [Lambdapi](https://github.com/Deducteam/lambdapi) and [Coq](https://coq.inria.fr/).
4+
This project provides a tool, hol2dk, to translate [HOL-Light](https://github.com/jrh13/hol-light) proofs to [Dedukti](https://github.com/Deducteam/Dedukti/), [Lambdapi](https://github.com/Deducteam/lambdapi) and [Rocq](https://rocq-prover.org/).
55

66
[HOL-Light](https://github.com/jrh13/hol-light) is a proof assistant
77
based on higher-order logic, aka simple type theory.
@@ -15,78 +15,55 @@ rewriting rules).
1515
based on the λΠ-calculus modulo rewriting that can read and generate
1616
Dedukti proofs.
1717

18-
[Coq](https://coq.inria.fr/) is a proof assistant based on the
18+
[Rocq](https://rocq-prover.org/) is a proof assistant based on the
1919
Calculus of Inductive Constructions.
2020

21-
Usability of translated libraries
22-
---------------------------------
21+
Examples:
22+
---------
2323

24-
For the obtained theorems to be readily usable in Coq, we need to
25-
align the type and functions of HOL-Light with those used in the Coq
26-
standard library. We already did this for various types and functions
27-
(see [With_N.lp](https://github.com/Deducteam/hol2dk/blob/main/With_N.lp)):
28-
29-
- types: unit, prod, list, option, sum, ascii, N, R, Z
30-
- functions on N: pred, add, mul, pow, le, lt, ge, gt, max, min, sub, div, modulo
31-
- functions on list: app, rev, map, removelast, In, hd, tl
32-
- functions on R: Rle, Rplus, Rmult, Rinv, Ropp, Rabs, Rdiv, Rminus, Rge, Rgt, Rlt, Rmax, Rmin, IZR
33-
34-
Your help is welcome to align more functions!
35-
36-
The correctness of the mappings for types defined before real
37-
numbers (e.g. natural numbers and lists) is proved in
38-
[mappings_N.v](https://github.com/Deducteam/hol2dk/blob/main/mappings_N.v). The
39-
correctness of the mappings for the other types, including real
40-
numbers, is proved here in
41-
[With_N.v](https://github.com/Deducteam/hol2dk/blob/main/With_N.v).
42-
43-
The resulting theorems are gathered in the Opam package
44-
[coq-hol-light](https://github.com/Deducteam/coq-hol-light) available
45-
in the Coq Opam repository [released](https://github.com/coq/opam). It
46-
currently contains a translation of the
24+
hol2dk has been used to translate to Rocq the
4725
[Multivariate](https://github.com/jrh13/hol-light/blob/master/Multivariate/make_complex.ml)
48-
library with more than 20,000 theorems on arithmetic, wellfounded
49-
relations, lists, real numbers, integers, basic set theory,
50-
permutations, group theory, matroids, metric spaces, homology,
51-
vectors, determinants, topology, convex sets and functions, paths,
52-
polytopes, Brouwer degree, derivatives, Clifford algebra, integration,
53-
measure theory, complex numbers and analysis, transcendental numbers,
54-
real analysis, complex line integrals, etc.
55-
56-
Coq axioms used to encode HOL-Light proofs
57-
------------------------------------------
58-
59-
HOL-Light is based on classical higher-order logic with functional and propositional extensionality. We use the following Coq axioms to encode them:
60-
```
61-
Axiom classic : forall P:Prop, P \/ ~ P.
62-
Axiom constructive_indefinite_description : forall (A : Type) (P : A->Prop), (exists x, P x) -> { x : A | P x }.
63-
Axiom fun_ext : forall {A B : Type} {f g : A -> B}, (forall x, (f x) = (g x)) -> f = g.
64-
Axiom prop_ext : forall {P Q : Prop}, (P -> Q) -> (Q -> P) -> P = Q.
65-
Axiom proof_irrelevance : forall (P:Prop) (p1 p2:P), p1 = p2.
66-
```
26+
library of HOL-Light which contains more than 20,000 theorems on
27+
arithmetic, wellfounded relations, lists, real numbers, integers,
28+
basic set theory, permutations, group theory, matroids, metric spaces,
29+
homology, vectors, determinants, topology, convex sets and functions,
30+
paths, polytopes, Brouwer degree, derivatives, Clifford algebra,
31+
integration, measure theory, complex numbers and analysis,
32+
transcendental numbers, real analysis, complex line integrals,
33+
etc. The resulting Rocq theorems are provided in the Opam package
34+
[coq-hol-light](https://github.com/Deducteam/coq-hol-light). Various
35+
HOL-Light types and functions have been mapped to the corresponding
36+
types and functions of the Rocq standard library so that, for
37+
instance, a HOL-Light theorem on HOL-Light real numbers is translated
38+
to a Rocq theorem on Rocq real numbers. The provided theorems can
39+
therefore be readily used within other Rocq developments based on the
40+
Rocq standard library.
6741

6842
Bibliography
6943
------------
7044

71-
- [Translating HOL-Light proofs to Coq](https://files.inria.fr/blanqui/lpar24.pdf), Frédéric Blanqui, 4 April 2024
45+
- [Translating HOL-Light proofs to Coq](https://doi.org/10.29007/6k4x), Frédéric Blanqui, 25th International Conference on Logic for Programming, Artificial Intelligence and Reasoning (LPAR), 2024.
46+
47+
Dependencies
48+
------------
49+
50+
- ocaml >= 4.13
51+
- hol_light >= 3.0.0
52+
- lambdapi >= 3.0.0
53+
- rocq >= 9.0
7254

7355
Installing HOL-Light sources
7456
----------------------------
7557

76-
**Requirement:** hol_light >= 3.0.0
77-
7858
```
59+
opam install -y --deps-only hol_light.3.0.0
7960
git clone https://github.com/jrh13/hol-light
8061
make -C hol-light
8162
```
8263

8364
Installing hol2dk
8465
-----------------
8566

86-
**Requirements:**
87-
- ocaml >= 4.13
88-
- dune >= 3.7
89-
9067
hol2dk is available on [Opam](https://opam.ocaml.org/). To install it, simply do:
9168
```
9269
opam install hol2dk
@@ -187,16 +164,8 @@ The command `purge` compute in `file.use` all the theorems that do not need to b
187164

188165
The command `simp` is the sequential composition of `rewrite` and `purge`.
189166

190-
Translating HOL-Light proofs to Lambdapi and Coq
191-
------------------------------------------------
192-
193-
**Requirements:**
194-
- lambdapi commit >= 21ee7f3d (21/01/25)
195-
- coq >= 8.19
196-
- [coq-hol-light-real-with-N](https://github.com/Deducteam/coq-hol-light-real-with-N)
197-
- [coq-fourcolor-reals](https://github.com/coq-community/fourcolor/blob/master/coq-fourcolor-reals.opam)
198-
199-
**Procedure after dumping:**
167+
Translating HOL-Light proofs to Lambdapi and Rocq
168+
-------------------------------------------------
200169

201170
- create a directory where all files will be generated:
202171
```
@@ -206,26 +175,24 @@ mkdir output
206175
- configure the directory with all the required files:
207176
```
208177
cd output
209-
hol2dk config $hollight_file.ml $root_path [coq_file_or_module] ... [$mapping.mk] [$mapping.lp]
178+
hol2dk config $hollight_file.ml $root_path [rocq_file_or_module] ... [$mapping.mk] [$mapping.lp]
210179
```
211180
Do `hol2dk config` to get more details.
212181

213-
For instance, to translate the Multivariate library using the Coq type N for natural numbers, we use [CONFIG](https://github.com/Deducteam/coq-hol-light/blob/main/CONFIG).
214-
215182
- You can then do in order:
216183
* `make` to get the list of targets and variables
217184
* `make split` to generate a file for each theorem
218185
* `make -j$jobs lp` to translate HOL-Light proofs to Lambdapi
219186
* `make -j$jobs lpo` to check Lambdapi files (optional)
220-
* `make -j$jobs v` to translate Lambdapi files to Coq files
187+
* `make -j$jobs v` to translate Lambdapi files to Rocq files
221188
* `make -j$jobs spec` to merge all small spec files into a single one
222189
* `make -j$jobs rm-empty-deps` to remove `theory_hol.v`, `${base}_types.v` and `${base}_axioms.v` (to use when these files are empty only)
223-
* `make -j$jobs vo` to check Coq files
190+
* `make -j$jobs vo` to check Rocq files
224191

225192
To speed up lp file generation for some theorems with very big proofs, you can write in a file named `BIG_FILES` a list of theorem names (lines starting with `#` are ignored). See for instance [BIG_FILES](https://github.com/Deducteam/hol2dk/blob/main/BIG_FILES). You can also change the default values of the options `--max-proof-size` and `--max-abbrev-size` as follows:
226193
- `make -j$jobs MAX_PROOF=500_000 MAX_ABBREV=2_000_000 lp`
227194

228-
**Remark:** for the checking of generated Coq files to not fail because of lack of RAM, we generate for each theorem `${thm}.lp` one or several files for its proof, and a file `${thm}_spec.lp` declaring this theorem as an axiom. Moreover, each other theorem proof using `${thm}` requires `${thm}_spec` instead of `${thm}`.
195+
**Remark:** for the checking of generated Rocq files to not fail because of lack of RAM, we generate for each theorem `${thm}.lp` one or several files for its proof, and a file `${thm}_spec.lp` declaring this theorem as an axiom. Moreover, each other theorem proof using `${thm}` requires `${thm}_spec` instead of `${thm}`.
229196

230197
Performances
231198
------------
@@ -340,23 +307,23 @@ b.prf: proof steps
340307

341308
b.sig: signature (types, constants, axioms, definitions)
342309

343-
b.thm: map from proof step index to theorem name
310+
b.thm: map from theorem indexes having a name to their name
344311

345312
b.thp: map every useful theorem index to its name and position (similar to f.thm but with position)
346313

347314
f.nbp: number of proof steps
348315

349-
f.pos: array providing the positions in b.prf of each proof step index
316+
f.pos: array providing the positions in b.prf of each theorem index
350317

351-
f.use: array lastuse such that lastuse.(i) = 0 if i is a named theorem, the highest proof step index using i if there is one, and -1 otherwise
318+
f.use: array lastuse such that lastuse.(i) = 0 if i is a named theorem, the highest theorem index using i if there is one, and -1 otherwise
352319

353320
n.sti: starting index (in f.prf) of theorem n
354321

355322
n.siz: estimation of the size of the proof of n
356323

357324
`n_part_k.idx`: min and max index (in n.prf) of part k proof steps
358325

359-
n.max: array of max proof step indexes of each part of n
326+
n.max: array of max theorem indexes of each part of n
360327

361328
n.typ: map from type expression strings to digests and number of type variables
362329

TODO.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ TODO
33

44
- replace variables like _1718 by better names
55

6-
- align functions and predicates on int with those of Z
7-
8-
- always share closed subterms ?
6+
- always share closed subterms
97

108
- automatically rename type names that are used as symbol names too
119

_CoqProject

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)