1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
3 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2019 Dan Frumin <dfrumin@cs.ru.nl>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages coq)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages base)
24 #:use-module (gnu packages bison)
25 #:use-module (gnu packages boost)
26 #:use-module (gnu packages emacs)
27 #:use-module (gnu packages flex)
28 #:use-module (gnu packages gawk)
29 #:use-module (gnu packages multiprecision)
30 #:use-module (gnu packages ocaml)
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages python)
33 #:use-module (gnu packages texinfo)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system ocaml)
36 #:use-module (guix download)
37 #:use-module (guix git-download)
38 #:use-module ((guix licenses) #:prefix license:)
39 #:use-module (guix packages)
40 #:use-module (guix utils)
41 #:use-module ((srfi srfi-1) #:hide (zip)))
51 (url "https://github.com/coq/coq.git")
52 (commit (string-append "V" version))))
53 (file-name (git-file-name name version))
55 (base32 "1p4z967s18wkblayv12ygqsrqlyk5ax1pz40yf4kag8pva6gblhk"))))
57 (list (search-path-specification
59 (files (list "lib/coq/user-contrib")))))
60 (build-system ocaml-build-system)
61 (outputs '("out" "ide"))
63 `(("lablgtk" ,lablgtk)
66 ("ocaml-num" ,ocaml-num)))
68 `(("ocaml-ounit" ,ocaml-ounit)))
71 (modify-phases %standard-phases
72 (add-after 'unpack 'make-git-checkout-writable
74 (for-each make-file-writable (find-files "."))
76 (add-after 'unpack 'remove-lablgtk-references
78 ;; This is not used anywhere, but creates a reference to lablgtk in
80 (substitute* '("config/coq_config.mli" "configure.ml")
81 ((".*coqideincl.*") ""))
84 (lambda* (#:key outputs #:allow-other-keys)
85 (let* ((out (assoc-ref outputs "out"))
86 (mandir (string-append out "/share/man"))
87 (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
96 "-j" (number->string (parallel-job-count))
99 (add-after 'install 'remove-duplicate
100 (lambda* (#:key outputs #:allow-other-keys)
101 (let* ((out (assoc-ref outputs "out"))
102 (bin (string-append out "/bin")))
103 ;; These are exact copies of the version without the .opt suffix.
104 ;; Remove them to save 35 MiB in the result
105 (delete-file (string-append bin "/coqtop.opt"))
106 (delete-file (string-append bin "/coqidetop.opt")))
108 (add-after 'install 'install-ide
109 (lambda* (#:key outputs #:allow-other-keys)
110 (let ((out (assoc-ref outputs "out"))
111 (ide (assoc-ref outputs "ide")))
112 (mkdir-p (string-append ide "/bin"))
113 (rename-file (string-append out "/bin/coqide")
114 (string-append ide "/bin/coqide")))
116 (add-after 'install 'check
118 (with-directory-excursion "test-suite"
119 ;; These two tests fail.
120 ;; This one fails because the output is not formatted as expected.
121 (delete-file-recursively "coq-makefile/timing")
122 ;; This one fails because we didn't build coqtop.byte.
123 (delete-file-recursively "coq-makefile/findlib-package")
124 (invoke "make")))))))
125 (home-page "https://coq.inria.fr")
126 (synopsis "Proof assistant for higher-order logic")
128 "Coq is a proof assistant for higher-order logic, which allows the
129 development of computer programs consistent with their formal specification.
130 It is developed using Objective Caml and Camlp5.")
131 ;; The code is distributed under lgpl2.1.
132 ;; Some of the documentation is distributed under opl1.0+.
133 (license (list license:lgpl2.1 license:opl1.0+))))
135 (define-public proof-general
137 (name "proof-general")
142 "http://proofgeneral.inf.ed.ac.uk/releases/"
143 "ProofGeneral-" version ".tgz"))
146 "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm"))))
147 (build-system gnu-build-system)
150 ("emacs" ,emacs-minimal)
151 ("texinfo" ,texinfo)))
153 `(("host-emacs" ,emacs)
157 `(#:tests? #f ; no check target
158 #:make-flags (list (string-append "PREFIX=" %output)
159 (string-append "DEST_PREFIX=" %output))
160 #:modules ((guix build gnu-build-system)
162 (guix build emacs-utils))
163 #:imported-modules (,@%gnu-build-system-modules
164 (guix build emacs-utils))
166 (modify-phases %standard-phases
168 (add-after 'unpack 'disable-byte-compile-error-on-warn
170 (substitute* "Makefile"
171 (("\\(setq byte-compile-error-on-warn t\\)")
172 "(setq byte-compile-error-on-warn nil)"))
174 (add-after 'unpack 'patch-hardcoded-paths
175 (lambda* (#:key inputs outputs #:allow-other-keys)
176 (let ((out (assoc-ref outputs "out"))
177 (coq (assoc-ref inputs "coq"))
178 (emacs (assoc-ref inputs "host-emacs")))
179 (define (coq-prog name)
180 (string-append coq "/bin/" name))
181 (emacs-substitute-variables "coq/coq.el"
182 ("coq-prog-name" (coq-prog "coqtop"))
183 ("coq-compiler" (coq-prog "coqc"))
184 ("coq-dependency-analyzer" (coq-prog "coqdep")))
185 (substitute* "Makefile"
186 (("/sbin/install-info") "install-info"))
187 (substitute* "bin/proofgeneral"
188 (("^PGHOMEDEFAULT=.*" all)
190 "PGHOME=$PGHOMEDEFAULT\n"
191 "EMACS=" emacs "/bin/emacs")))
193 (add-after 'unpack 'clean
195 ;; Delete the pre-compiled elc files for Emacs 23.
196 (invoke "make" "clean")))
197 (add-after 'install 'install-doc
198 (lambda* (#:key make-flags #:allow-other-keys)
199 ;; XXX FIXME avoid building/installing pdf files,
200 ;; due to unresolved errors building them.
201 (substitute* "Makefile"
202 ((" [^ ]*\\.pdf") ""))
203 (apply invoke "make" "install-doc" make-flags))))))
204 (home-page "http://proofgeneral.inf.ed.ac.uk/")
205 (synopsis "Generic front-end for proof assistants based on Emacs")
207 "Proof General is a major mode to turn Emacs into an interactive proof
208 assistant to write formal mathematical proofs using a variety of theorem
210 (license license:gpl2+)))
212 (define-public coq-flocq
218 ;; Use the ‘Latest version’ link for a stable URI across releases.
219 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
220 "file/37901/flocq-" version ".tar.gz"))
223 "02szrgz9m0ac51la1lqpiv6i2g0zbgx9gz5rp0q1g00ajldyna5c"))))
224 (build-system gnu-build-system)
231 (list (string-append "--libdir=" (assoc-ref %outputs "out")
232 "/lib/coq/user-contrib/Flocq"))
234 (modify-phases %standard-phases
235 (add-before 'configure 'fix-remake
237 (substitute* "remake.cpp"
238 (("/bin/sh") (which "sh")))
242 (invoke "./remake")))
245 (invoke "./remake" "check")))
246 ;; TODO: requires coq-gappa and coq-interval.
247 ;(invoke "./remake" "check-more")
250 (invoke "./remake" "install"))))))
251 (home-page "http://flocq.gforge.inria.fr/")
252 (synopsis "Floating-point formalization for the Coq system")
253 (description "Flocq (Floats for Coq) is a floating-point formalization for
254 the Coq system. It provides a comprehensive library of theorems on a multi-radix
255 multi-precision arithmetic. It also supports efficient numerical computations
257 (license license:lgpl3+)))
259 (define-public coq-gappa
265 (uri (string-append "https://gforge.inria.fr/frs/download.php/file/37918/gappa-"
269 "1wdg07dk4lbq7dr80ywzna0lclwgi8bddzc6yfx19z1zn9yljzxh"))))
270 (build-system gnu-build-system)
283 (list (string-append "--libdir=" (assoc-ref %outputs "out")
284 "/lib/coq/user-contrib/Gappa"))
286 (modify-phases %standard-phases
287 (add-before 'configure 'fix-remake
289 (substitute* "remake.cpp"
290 (("/bin/sh") (which "sh")))
293 (lambda _ (invoke "./remake")))
295 (lambda _ (invoke "./remake" "check")))
297 (lambda _ (invoke "./remake" "install"))))))
298 (home-page "http://gappa.gforge.inria.fr/")
299 (synopsis "Verify and formally prove properties on numerical programs")
300 (description "Gappa is a tool intended to help verifying and formally proving
301 properties on numerical programs dealing with floating-point or fixed-point
302 arithmetic. It has been used to write robust floating-point filters for CGAL
303 and it is used to certify elementary functions in CRlibm. While Gappa is
304 intended to be used directly, it can also act as a backend prover for the Why3
305 software verification plateform or as an automatic tactic for the Coq proof
307 (license (list license:gpl2+ license:cecill))));either gpl2+ or cecill
309 (define-public coq-mathcomp
311 (name "coq-mathcomp")
317 (url "https://github.com/math-comp/math-comp.git")
318 (commit (string-append "mathcomp-" version))))
319 (file-name (git-file-name name version))
321 (base32 "1sdrw3b6lc8crz02lp90a863rvyzhc9vcfsrdvc9m311yiaad4xv"))))
322 (build-system gnu-build-system)
328 `(#:tests? #f ; no need to test formally-verified programs :)
330 (modify-phases %standard-phases
332 (add-before 'build 'chdir
333 (lambda _ (chdir "mathcomp") #t))
335 (lambda* (#:key outputs #:allow-other-keys)
336 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
337 (invoke "make" "-f" "Makefile.coq"
338 (string-append "COQLIB=" (assoc-ref outputs "out")
341 (home-page "https://math-comp.github.io/math-comp/")
342 (synopsis "Mathematical Components for Coq")
343 (description "Mathematical Components for Coq has its origins in the formal
344 proof of the Four Colour Theorem. Since then it has grown to cover many areas
345 of mathematics and has been used for large scale projects like the formal proof
346 of the Odd Order Theorem.
348 The library is written using the Ssreflect proof language that is an integral
349 part of the distribution.")
350 (license license:cecill-b)))
352 (define-public coq-coquelicot
354 (name "coq-coquelicot")
358 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
359 "file/37523/coquelicot-" version ".tar.gz"))
362 "1biia7nfqf7vaqq5gmykl4rwjyvrcwss6r2jdf0in5pvp2rnrj2w"))))
363 (build-system gnu-build-system)
369 `(("mathcomp" ,coq-mathcomp)))
372 (list (string-append "--libdir=" (assoc-ref %outputs "out")
373 "/lib/coq/user-contrib/Coquelicot"))
375 (modify-phases %standard-phases
376 (add-before 'configure 'fix-remake
378 (substitute* "remake.cpp"
379 (("/bin/sh") (which "sh")))
382 (lambda _ (invoke "./remake")))
384 (lambda _ (invoke "./remake" "check")))
386 (lambda _ (invoke "./remake" "install"))))))
387 (home-page "http://coquelicot.saclay.inria.fr/index.html")
388 (synopsis "Coq library for Reals")
389 (description "Coquelicot is an easier way of writing formulas and theorem
390 statements, achieved by relying on total functions in place of dependent types
391 for limits, derivatives, integrals, power series, and so on. To help with the
392 proof process, the library comes with a comprehensive set of theorems that cover
393 not only these notions, but also some extensions such as parametric integrals,
394 two-dimensional differentiability, asymptotic behaviors. It also offers some
395 automations for performing differentiability proofs. Moreover, Coquelicot is a
396 conservative extension of Coq's standard library and provides correspondence
397 theorems between the two libraries.")
398 (license license:lgpl3+)))
400 (define-public coq-bignums
407 (url "https://github.com/coq/bignums.git")
408 (commit (string-append "V" version))))
409 (file-name (git-file-name name version))
412 "03qz1w2xb2j5p06liz5yyafl0fl9vprcqm6j0iwi7rxwghl00p01"))))
413 (build-system gnu-build-system)
418 `(("camlp5" ,camlp5)))
420 `(#:tests? #f; No test target
422 (list (string-append "COQLIBINSTALL=" (assoc-ref %outputs "out")
423 "/lib/coq/user-contrib"))
425 (modify-phases %standard-phases
426 (delete 'configure))))
427 (home-page "https://github.com/coq/bignums")
428 (synopsis "Coq library for arbitrary large numbers")
429 (description "Bignums is a coq library of arbitrary large numbers. It
430 provides BigN, BigZ, BigQ that used to be part of Coq standard library.")
431 (license license:lgpl2.1+)))
433 (define-public coq-interval
435 (name "coq-interval")
439 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
440 "file/37524/interval-" version ".tar.gz"))
443 "023j9sd64brqvjdidqkn5m8d7a93zd9r86ggh573z9nkjm2m7vvg"))))
444 (build-system gnu-build-system)
450 `(("flocq" ,coq-flocq)
451 ("bignums" ,coq-bignums)
452 ("coquelicot" ,coq-coquelicot)
453 ("mathcomp" ,coq-mathcomp)))
456 (list (string-append "--libdir=" (assoc-ref %outputs "out")
457 "/lib/coq/user-contrib/Gappa"))
459 (modify-phases %standard-phases
460 (add-before 'configure 'fix-remake
462 (substitute* "remake.cpp"
463 (("/bin/sh") (which "sh")))
466 (lambda _ (invoke "./remake")))
468 (lambda _ (invoke "./remake" "check")))
470 (lambda _ (invoke "./remake" "install"))))))
471 (home-page "http://coq-interval.gforge.inria.fr/")
472 (synopsis "Coq tactics to simplify inequality proofs")
473 (description "Interval provides vernacular files containing tactics for
474 simplifying the proofs of inequalities on expressions of real numbers for the
475 Coq proof assistant.")
476 (license license:cecill-c)))
478 (define-public coq-autosubst
479 ;; Latest commit on that branch, where work on supporting coq 8.6 and
480 ;; more recent versions of coq happen.
481 (let ((branch "coq86-devel")
482 (commit "fa6ef30664511ffa659cbcf3c962715cbee03572"))
484 (name "coq-autosubst")
485 (version (git-version "1" branch commit))
489 (url "git://github.com/uds-psl/autosubst.git")
491 (file-name (git-file-name name version))
493 (base32 "1cl0bp96bk6lplbl7n5c703vd3gvbs5mvf2qrf8q333kkqd7jqq4"))))
494 (build-system gnu-build-system)
498 (modify-phases %standard-phases
501 (lambda* (#:key outputs #:allow-other-keys)
502 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
504 (string-append "COQLIB=" (assoc-ref outputs "out")
509 (home-page "https://www.ps.uni-saarland.de/autosubst/")
510 (synopsis "Coq library for parallel de Bruijn substitutions")
511 (description "Formalizing syntactic theories with variable binders is
512 not easy. Autosubst is a library for the Coq proof assistant to
513 automate this process. Given an inductive definition of syntactic objects in
514 de Bruijn representation augmented with binding annotations, Autosubst
515 synthesizes the parallel substitution operation and automatically proves the
516 basic lemmas about substitutions. This library contains an automation
517 tactic that solves equations involving terms and substitutions. This makes the
518 usage of substitution lemmas unnecessary. The tactic is based on our current
519 work on a decision procedure for the equational theory of an extension of the
520 sigma-calculus by Abadi et al. The library is completely written in Coq and
521 uses Ltac to synthesize the substitution operation.")
522 (license license:bsd-3))))
524 (define-public coq-equations
526 (name "coq-equations")
531 (url "https://github.com/mattam82/Coq-Equations.git")
532 (commit (string-append "v" version "-8.9"))))
533 (file-name (git-file-name name version))
536 "1q3wvicr43bgy7xn1diwh4j43mnrhprrc2xd22qlbz9cl6bhf8bj"))))
537 (build-system gnu-build-system)
543 `(#:test-target "test-suite"
545 (modify-phases %standard-phases
547 (lambda* (#:key outputs #:allow-other-keys)
548 (invoke "coq_makefile" "-f" "_CoqProject" "-o" "Makefile")))
550 (lambda* (#:key outputs #:allow-other-keys)
551 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
553 (string-append "COQLIB=" (assoc-ref outputs "out")
556 (home-page "https://mattam82.github.io/Coq-Equations/")
557 (synopsis "Function definition plugin for Coq")
558 (description "Equations provides a notation for writing programs
559 by dependent pattern-matching and (well-founded) recursion in Coq. It
560 compiles everything down to eliminators for inductive types, equality
561 and accessibility, providing a definitional extension to the Coq
563 (license license:lgpl2.1)))
565 (define-public coq-stdpp
569 (synopsis "Alternative Coq standard library std++")
573 (url "https://gitlab.mpi-sws.org/iris/stdpp.git")
574 (commit (string-append "coq-stdpp-" version))))
575 (file-name (git-file-name name version))
577 (base32 "11m7kqxsbxygk41v2wsi3npdzwin9fcnzc1gn0gq0rd57wnqk83i"))))
578 (build-system gnu-build-system)
582 `(#:tests? #f ;; the tests are being run automaticlly as part of `make all`
584 (modify-phases %standard-phases
587 (lambda* (#:key outputs #:allow-other-keys)
588 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
590 (string-append "COQLIB=" (assoc-ref outputs "out")
593 (description "This project contains an extended \"Standard Library\" for
594 Coq called coq-std++. The key features are:
596 @item Great number of definitions and lemmas for common data structures such
597 as lists, finite maps, finite sets, and finite multisets.
599 @item Type classes for common notations (like ∅, ∪, and Haskell-style monad
600 notations) so that these can be overloaded for different data structures.
602 @item It uses type classes to keep track of common properties of types, like
603 it having decidable equality or being countable or finite.
605 @item Most data structures are represented in canonical ways so that Leibniz
606 equality can be used as much as possible (for example, for maps we have m1 =
607 m2 iff ∀ i, m1 !! i = m2 !! i). On top of that, the library provides setoid
608 instances for most types and operations.
610 @item Various tactics for common tasks, like an ssreflect inspired done tactic
611 for finishing trivial goals, a simple breadth-first solver naive_solver, an
612 equality simplifier simplify_eq, a solver solve_proper for proving
613 compatibility of functions with respect to relations, and a solver set_solver
614 for goals involving set operations.
616 @item The library is dependency- and axiom-free.
618 (home-page "https://gitlab.mpi-sws.org/iris/stdpp")
619 (license license:bsd-3)))