Skip to content

[build] Add support for building a lessons coq-pkg package #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
node_modules
*.html
coqdoc.css
coq-pkgs
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean serve
.PHONY: all clean serve docker-setup

COQDOC_AUTO=coqdoc.css

Expand All @@ -11,13 +11,23 @@ all: $(FILES_HTML)
./jscoqdoc $<

%.glob: %.v
coqc $<
npx jscoq sdk coqc -R . MyCourse $<

clean:
rm -f *.vo *.vok .*.aux *.glob *.vos $(FILES_HTML) $(COQDOC_AUTO)

node_modules: package.json package-lock.json
npm i

serve: node_modules
serve: node_modules coq-pkgs/my_course.coq-pkg
./node_modules/.bin/http-server .

coq-pkgs/my_course.coq-pkg: $(FILES_HTML) docker-setup
npx jscoq build . --top MyCourse --package $@
cp -a coq-pkgs/* node_modules/jscoq/coq-pkgs/

SDK_VERSION=v8.17

docker-setup:
docker pull jscoq/jscoq:$(SDK_VERSION)-sdk
docker tag jscoq/jscoq:$(SDK_VERSION)-sdk jscoq:sdk
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ $ make serve # Open a web server with the jsCoq files
Note that `make serve` doesn't need to be restarted after a regular
`make`.

# Building multiple files with the jsCoq SDK

This is WIP, for now you can do:

- `make coq-pkgs/my_course.coq-pkg`

## TODO / Known issues

- Auto-import is not working, you'll have to click on the package
manager
- the jsCoq SDK cannot locate external libs, such as math-comp

# Tweaks from official distro

We have customized the following files from the oficial distro:
Expand Down
2 changes: 1 addition & 1 deletion jscoq-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var jscoq_opts = {
// editor: { mode: { 'company-coq': true }, className: 'jscoq code-tight' },
editor: { className: 'jscoq code-tight' },
init_pkgs: ['init'],
all_pkgs: { '+': ['coq', 'mathcomp'] },
all_pkgs: { '+': ['coq', 'mathcomp', 'my_course'] },
init_import: ['utf8'],
implicit_libs: true
};
Expand Down
4 changes: 3 additions & 1 deletion lesson_1.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ In this course, we will use a mature Coq library, "The Mathematical
Components Library" which will provide us with a rich theory on data
types and mathematics. *)

From mathcomp Require Import all_ssreflect.
(* From mathcomp Require Import all_ssreflect. *)

From Coq Require Import ssreflect.

Set Implicit Arguments.
Unset Strict Implicit.
Expand Down
25 changes: 15 additions & 10 deletions lesson_2.v
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
(** * Lesson 2: Data Structures and Class Hierarchies *)
From mathcomp Require Import all_ssreflect.
From Coq Require Import ssreflect.
(* From mathcomp Require Import all_ssreflect. *)

Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

From MyCourse Require Import lesson_1.

About x_implies_x.

Definition sorry {T} : T. Admitted.
(** ** Reflection and proving with computation

Expand All @@ -24,23 +29,23 @@ Coq Standard library vs as it is defined in math-comp: *)
About le.
Print le.

About leq.
Print leq.
(* About leq. *)
(* Print leq. *)

Lemma le_1 : 100 <= 200.
Proof. Admitted.

Print le_1.

Lemma le_2 : (100 <= 200)%coq_nat.
Proof. Admitted.
(* Lemma le_2 : (100 <= 200)%coq_nat. *)
(* Proof. Admitted. *)

Print le_2.
(* Print le_2. *)

Lemma lt_1 n : ~~ (n < n).
Proof. Admitted.
(* Lemma lt_1 n : ~~ (n < n). *)
(* Proof. Admitted. *)

Lemma lt_2 n : ~ (n < n)%coq_nat.
Proof. Admitted.
(* Lemma lt_2 n : ~ (n < n)%coq_nat. *)
(* Proof. Admitted. *)
(** Moreover, the math-comp version, by virtue of being in [bool],
inherits some nice properties, like decidability, for free. *)