Skip to content

Commit

Permalink
coq-hierarchy-builder-shim
Browse files Browse the repository at this point in the history
  • Loading branch information
gares committed Feb 15, 2021
1 parent 208ad7a commit c3e83b1
Show file tree
Hide file tree
Showing 54 changed files with 119 additions and 94 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Expand Up @@ -53,8 +53,12 @@ jobs:
mkdir /home/coq/workspace
cp -ra . /home/coq/workspace
cd /home/coq/workspace
COQ_ELPI_ATTRIBUTES=log_hb make -j2
opam install ./coq-hierarchy-builder.opam
COQ_ELPI_ATTRIBUTES=log_hb make test-suite -j2
make patch
make -j2
make clean
opem remove coq-hierarchy-builder.opam
opam install ./coq-hierarchy-builder-shim.opam
make test-suite -j2
make reset
git diff --exit-code
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -34,6 +34,9 @@ nra.cache
Makefile.coq
Makefile.coq.conf
.coqdeps.d
Makefile.test-suite.coq
Makefile.test-suite.coq.conf
.coqdeps.test-suite
*.v.hb
*.v.hb.old
hb
Expand Down
41 changes: 9 additions & 32 deletions Makefile.common
Expand Up @@ -25,13 +25,13 @@ TGTS?=
######################################################################

# local context: -----------------------------------------------------
.PHONY: all config build only test-suite clean distclean doc doc-clean __always__
.PHONY: all config build only test-suite clean distclean __always__
.SUFFIXES:

H:= $(if $(VERBOSE),,@) # not used yet
TOP = $(dir $(lastword $(MAKEFILE_LIST)))
COQMAKE = $(MAKE) -f Makefile.coq $(COQMAKEOPTIONS)
COQMAKE_TESTSUITE = $(MAKE) -f Makefile.test-suite.coq VDFILE=".coqdeps.test-suite" $(COQMAKEOPTIONS)
COQMAKE_TESTSUITE = $(MAKE) -f Makefile.test-suite.coq $(COQMAKEOPTIONS)
BRANCH_coq:= $(shell $(COQBIN)coqtop -v | head -1 | grep -E '(trunk|master)' \
| wc -l | sed 's/ *//g')

Expand All @@ -46,7 +46,7 @@ COQV:= $(shell echo $(COQVVV) | cut -d"." -f1)
COQVV:= $(shell echo $(COQVVV) | cut -d"." -f1-2)

# all: ---------------------------------------------------------------
all: config build
all: config build test-suite

# Makefile.coq: ------------------------------------------------------
.PHONY: pre-makefile
Expand All @@ -56,12 +56,8 @@ Makefile.coq: pre-makefile $(COQPROJECT) Makefile

# Test suite ---------------------------------------------------------

test_suite/hierarchy_test.v: build
mkdir -p test_suite
COQBIN=$(COQBIN) ocaml ../etc/utils/hierarchy.ml -verify -R . mathcomp -lib all.all > test_suite/hierarchy_test.v

Makefile.test-suite.coq: test_suite/hierarchy_test.v
$(COQMAKEFILE) $(COQMAKEFILEOPTIONS) -f Make.test-suite -o Makefile.test-suite.coq
Makefile.test-suite.coq: $(COQPROJECT).test-suite Makefile
$(COQMAKEFILE) $(COQMAKEFILEOPTIONS) -f $(COQPROJECT).test-suite -o Makefile.test-suite.coq

# Global config, build, clean and distclean --------------------------
config: sub-config this-config
Expand All @@ -72,7 +68,7 @@ only: sub-only this-only

test-suite: sub-test-suite this-test-suite

clean: sub-clean this-clean doc-clean
clean: sub-clean this-clean

distclean: sub-distclean this-distclean

Expand Down Expand Up @@ -125,33 +121,14 @@ sub-%: __always__
endif

# Make of individual .vo ---------------------------------------------
%.vo: __always__ Makefile.coq
structures.vo : %.vo: __always__ Makefile.coq
+$(COQMAKE) $@

hb: __always__ Makefile.coq
+$(COQMAKE) $@

reset: hb
./hb reset `find . -name \*.v`
patch: hb
./hb patch `find . -name \*.v`

doc: __always__ Makefile.coq
mkdir -p _build_doc/
cp -r $(COQFILES) -t _build_doc/ --parents
cp Make Makefile* _build_doc
mkdir -p _build_doc/htmldoc
. ../etc/utils/builddoc_lib.sh; \
cd _build_doc && mangle_sources $(COQFILES)
+cd _build_doc && $(COQMAKE)
cd _build_doc && if [ ! -f .Makefile.coq.d ] ; then cp .coqdeps.d .Makefile.coq.d ; fi #can be removed when coq-8.10 compatibility is dropped
cd _build_doc && grep -v vio: .Makefile.coq.d > depend
cd _build_doc && cat depend | ../../etc/buildlibgraph $(COQFILES) > htmldoc/depend.js
cd _build_doc && $(COQBIN)coqdoc -t "Mathematical Components" \
-g --utf8 -R . mathcomp \
--parse-comments \
--multi-index $(COQFILES) -d htmldoc
cp ../etc/artwork/coqdoc.css _build_doc/htmldoc

doc-clean:
rm -rf _build_doc/
$(wildcard readme.v examples/*.v tests/*.v:%.v=%.vo): __always__ Makefile.test-suite.coq
+$(COQMAKE_TESTSUITE) $@
55 changes: 1 addition & 54 deletions _CoqProject
@@ -1,56 +1,3 @@
structures.v

readme.v

demo1/hierarchy_0.v
demo1/hierarchy_1.v
demo1/hierarchy_2.v
demo1/hierarchy_3.v
demo1/hierarchy_4.v
demo1/hierarchy_5.v
demo1/test_0_0.v
demo1/test_1_0.v
demo1/test_2_0.v
demo1/test_3_0.v
demo1/test_3_3.v
demo1/test_4_0.v
demo1/test_4_3.v
demo1/test_5_0.v
demo1/test_5_3.v

demo2/classical.v
demo2/stage10.v
demo2/stage11.v

demo3/hierarchy_0.v
demo3/hierarchy_1.v
demo3/hierarchy_2.v
demo3/test_0_0.v
demo3/test_1_0.v
demo3/test_2_0.v

demo4/hierarchy_0.v

demo5/hierarchy_0.v

FSCD2020_material/V1.v
FSCD2020_material/V2.v
FSCD2020_material/V3.v
FSCD2020_material/V4.v

FSCD2020_talk/V1.v
FSCD2020_talk/V2.v
FSCD2020_talk/V3.v

Coq2020_material/CoqWS_demo.v
Coq2020_material/CoqWS_abstract.v
Coq2020_material/CoqWS_expansion/withHB.v
Coq2020_material/CoqWS_expansion/withoutHB.v

tests/type_of_exported_ops.v
tests/duplicate_structure.v
tests/instance_params_no_type.v
tests/test_CS_db_filtering.v
tests/subtype.v

-R . HB
-Q . HB
56 changes: 56 additions & 0 deletions _CoqProject.test-suite
@@ -0,0 +1,56 @@
readme.v

examples/demo1/hierarchy_0.v
examples/demo1/hierarchy_1.v
examples/demo1/hierarchy_2.v
examples/demo1/hierarchy_3.v
examples/demo1/hierarchy_4.v
examples/demo1/hierarchy_5.v
examples/demo1/test_0_0.v
examples/demo1/test_1_0.v
examples/demo1/test_2_0.v
examples/demo1/test_3_0.v
examples/demo1/test_3_3.v
examples/demo1/test_4_0.v
examples/demo1/test_4_3.v
examples/demo1/test_5_0.v
examples/demo1/test_5_3.v

examples/demo2/classical.v
examples/demo2/stage10.v
examples/demo2/stage11.v

examples/demo3/hierarchy_0.v
examples/demo3/hierarchy_1.v
examples/demo3/hierarchy_2.v
examples/demo3/test_0_0.v
examples/demo3/test_1_0.v
examples/demo3/test_2_0.v

examples/demo4/hierarchy_0.v

examples/demo5/hierarchy_0.v

examples/FSCD2020_material/V1.v
examples/FSCD2020_material/V2.v
examples/FSCD2020_material/V3.v
examples/FSCD2020_material/V4.v

examples/FSCD2020_talk/V1.v
examples/FSCD2020_talk/V2.v
examples/FSCD2020_talk/V3.v

examples/Coq2020_material/CoqWS_demo.v
examples/Coq2020_material/CoqWS_abstract.v
examples/Coq2020_material/CoqWS_expansion/withHB.v
examples/Coq2020_material/CoqWS_expansion/withoutHB.v

tests/type_of_exported_ops.v
tests/duplicate_structure.v
tests/instance_params_no_type.v
tests/test_CS_db_filtering.v
tests/subtype.v

-R tests HB.tests
-R examples HB.examples
-Q . HB
19 changes: 19 additions & 0 deletions coq-hierarchy-builder-shim.opam
@@ -0,0 +1,19 @@
opam-version: "2.0"
name: "coq-hierarchy-builder"
version: "dev"
maintainer: "Enrico Tassi <enrico.tassi@inria.fr>"
authors: [ "Cyril Cohen" "Kazuhiko Sakaguchi" "Enrico Tassi" ]
license: "MIT"
homepage: "https://github.com/math-comp/hierarchy-builder"
bug-reports: "https://github.com/math-comp/hierarchy-builder/issues"
dev-repo: "git+https://github.com/math-comp/hierarchy-builder"

build: [ make "-C" "shim" ]
install: [ make "-C" "shim" "install" ]
conflicts: [ "coq-hierarchy-builder" ]
synopsis: "Shim package for HB"
description: """
This package provide the support constants one can use to compile files
generated by HB.
"""
tags: [ "logpath:HB" ]
7 changes: 5 additions & 2 deletions coq-hierarchy-builder.opam
Expand Up @@ -8,9 +8,12 @@ homepage: "https://github.com/math-comp/hierarchy-builder"
bug-reports: "https://github.com/math-comp/hierarchy-builder/issues"
dev-repo: "git+https://github.com/math-comp/hierarchy-builder"

build: [ make ]
install: [ make "install" "VFILES=structures.v" ]
build: [ [ make "build"]
[ make "test-suite" ] # {with-test} waiting https://github.com/coq-community/docker-coq-action/pull/48
]
install: [ make "install" ]
depends: [ "coq-elpi" {>= "1.9.1" & < "1.10~"} ]
conflicts: [ "coq-hierarchy-builder-shim" ]
synopsis: "High level commands to declare and evolve a hierarchy based on packed classes"
description: """
Hierarchy Builder is a high level language to build hierarchies of algebraic structures and make these
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions shim/Makefile
@@ -0,0 +1 @@
include ../Makefile.common
3 changes: 3 additions & 0 deletions shim/_CoqProject
@@ -0,0 +1,3 @@
-R . HB

structures.v
10 changes: 10 additions & 0 deletions shim/structures.v
@@ -0,0 +1,10 @@
From Coq Require Import String ssreflect ssrfun.
Export String.StringSyntax.

Definition unify T1 T2 (t1 : T1) (t2 : T2) (s : option (string * Type)) :=
phantom T1 t1 -> phantom T2 t2.
Definition id_phant {T} {t : T} (x : phantom T t) := x.
Definition nomsg : option (string * Type) := None.
Definition is_not_canonically_a : string := "is not canonically a".
Definition indexed {T} (x : T) := x.
Definition new {T} (x : T) := x.
10 changes: 6 additions & 4 deletions structures.v
@@ -1,13 +1,17 @@
(* Support constants, to be kept in sync with shim/structures.v *)
From Coq Require Import String ssreflect ssrfun.
From elpi Require Import elpi.
Export String.StringSyntax.

(** Technical definition from /Canonical Structures for the working Coq user/ *)
Definition unify T1 T2 (t1 : T1) (t2 : T2) (s : option (string * Type)) :=
phantom T1 t1 -> phantom T2 t2.
Definition id_phant {T} {t : T} (x : phantom T t) := x.
Definition nomsg : option (string * Type) := None.
Definition is_not_canonically_a : string := "is not canonically a".
Definition indexed {T} (x : T) := x.
Definition new {T} (x : T) := x.

(* ********************* structures ****************************** *)
From elpi Require Import elpi.

Register unify as hb.unify.
Register id_phant as hb.id.
Expand All @@ -18,10 +22,8 @@ Register Coq.Init.Datatypes.Some as hb.some.
Register Coq.Init.Datatypes.pair as hb.pair.
Register Coq.Init.Datatypes.prod as hb.prod.
Register Coq.Init.Specif.sigT as hb.sigT.
Definition indexed {T} (x : T) := x.
Bind Scope type_scope with indexed.
Register indexed as hb.indexed.
Definition new {T} (x : T) := x.
Register new as hb.new.

Declare Scope HB_scope.
Expand Down

0 comments on commit c3e83b1

Please sign in to comment.