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>
5 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages coq)
23 #:use-module (gnu packages)
24 #:use-module (gnu packages autotools)
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages bison)
27 #:use-module (gnu packages boost)
28 #:use-module (gnu packages emacs)
29 #:use-module (gnu packages flex)
30 #:use-module (gnu packages gawk)
31 #:use-module (gnu packages multiprecision)
32 #:use-module (gnu packages ocaml)
33 #:use-module (gnu packages perl)
34 #:use-module (gnu packages python)
35 #:use-module (gnu packages texinfo)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system ocaml)
38 #:use-module (guix download)
39 #:use-module (guix git-download)
40 #:use-module ((guix licenses) #:prefix license:)
41 #:use-module (guix packages)
42 #:use-module (guix utils)
43 #:use-module ((srfi srfi-1) #:hide (zip)))
53 (url "https://github.com/coq/coq.git")
54 (commit (string-append "V" version))))
55 (file-name (git-file-name name version))
58 "0ji2rzd70b3hcwfw97qk7rv3m2977ylqnq82l1555dp3njr8nm3q"))))
60 (list (search-path-specification
62 (files (list "lib/coq/user-contrib")))))
63 (build-system ocaml-build-system)
64 (outputs '("out" "ide"))
66 `(("lablgtk" ,lablgtk3)
69 ("ocaml-num" ,ocaml-num)))
71 `(("ocaml-ounit" ,ocaml-ounit)))
74 (modify-phases %standard-phases
75 (add-after 'unpack 'make-git-checkout-writable
77 (for-each make-file-writable (find-files "."))
80 (lambda* (#:key outputs #:allow-other-keys)
81 (let* ((out (assoc-ref outputs "out"))
82 (mandir (string-append out "/share/man"))
83 (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
92 "-j" (number->string (parallel-job-count))
95 (add-after 'install 'remove-duplicate
96 (lambda* (#:key outputs #:allow-other-keys)
97 (let* ((out (assoc-ref outputs "out"))
98 (bin (string-append out "/bin")))
99 ;; These files are exact copies without `.opt` extension.
100 ;; Removing these saves 35 MiB in the resulting package.
101 (delete-file (string-append bin "/coqtop.opt"))
102 (delete-file (string-append bin "/coqidetop.opt")))
104 (add-after 'install 'install-ide
105 (lambda* (#:key outputs #:allow-other-keys)
106 (let ((out (assoc-ref outputs "out"))
107 (ide (assoc-ref outputs "ide")))
108 (mkdir-p (string-append ide "/bin"))
109 (rename-file (string-append out "/bin/coqide")
110 (string-append ide "/bin/coqide")))
112 (add-after 'install 'check
114 (with-directory-excursion "test-suite"
115 ;; These two tests fail.
116 ;; Fails because the output is not formatted as expected.
117 (delete-file-recursively "coq-makefile/timing")
118 ;; Fails because we didn't build coqtop.byte.
119 (delete-file-recursively "coq-makefile/findlib-package")
120 (invoke "make")))))))
121 (home-page "https://coq.inria.fr")
122 (synopsis "Proof assistant for higher-order logic")
124 "Coq is a proof assistant for higher-order logic, which allows the
125 development of computer programs consistent with their formal specification.
126 It is developed using Objective Caml and Camlp5.")
127 ;; The source code is distributed under lgpl2.1.
128 ;; Some of the documentation is distributed under opl1.0+.
129 (license (list license:lgpl2.1 license:opl1.0+))))
131 (define-public proof-general
133 (name "proof-general")
138 "http://proofgeneral.inf.ed.ac.uk/releases/"
139 "ProofGeneral-" version ".tgz"))
142 "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm"))))
143 (build-system gnu-build-system)
146 ("emacs" ,emacs-minimal)
147 ("texinfo" ,texinfo)))
149 `(("host-emacs" ,emacs)
153 `(#:tests? #f ; no check target
154 #:make-flags (list (string-append "PREFIX=" %output)
155 (string-append "DEST_PREFIX=" %output))
156 #:modules ((guix build gnu-build-system)
158 (guix build emacs-utils))
159 #:imported-modules (,@%gnu-build-system-modules
160 (guix build emacs-utils))
162 (modify-phases %standard-phases
164 (add-after 'unpack 'disable-byte-compile-error-on-warn
166 (substitute* "Makefile"
167 (("\\(setq byte-compile-error-on-warn t\\)")
168 "(setq byte-compile-error-on-warn nil)"))
170 (add-after 'unpack 'patch-hardcoded-paths
171 (lambda* (#:key inputs outputs #:allow-other-keys)
172 (let ((out (assoc-ref outputs "out"))
173 (coq (assoc-ref inputs "coq"))
174 (emacs (assoc-ref inputs "host-emacs")))
175 (define (coq-prog name)
176 (string-append coq "/bin/" name))
177 (emacs-substitute-variables "coq/coq.el"
178 ("coq-prog-name" (coq-prog "coqtop"))
179 ("coq-compiler" (coq-prog "coqc"))
180 ("coq-dependency-analyzer" (coq-prog "coqdep")))
181 (substitute* "Makefile"
182 (("/sbin/install-info") "install-info"))
183 (substitute* "bin/proofgeneral"
184 (("^PGHOMEDEFAULT=.*" all)
186 "PGHOME=$PGHOMEDEFAULT\n"
187 "EMACS=" emacs "/bin/emacs")))
189 (add-after 'unpack 'clean
191 ;; Delete the pre-compiled elc files for Emacs 23.
192 (invoke "make" "clean")))
193 (add-after 'install 'install-doc
194 (lambda* (#:key make-flags #:allow-other-keys)
195 ;; XXX FIXME avoid building/installing pdf files,
196 ;; due to unresolved errors building them.
197 (substitute* "Makefile"
198 ((" [^ ]*\\.pdf") ""))
199 (apply invoke "make" "install-doc" make-flags))))))
200 (home-page "http://proofgeneral.inf.ed.ac.uk/")
201 (synopsis "Generic front-end for proof assistants based on Emacs")
203 "Proof General is a major mode to turn Emacs into an interactive proof
204 assistant to write formal mathematical proofs using a variety of theorem
206 (license license:gpl2+)))
208 (define-public coq-flocq
216 (url "https://gitlab.inria.fr/flocq/flocq.git")
217 (commit (string-append "flocq-" version))))
218 (file-name (git-file-name name version))
221 "15bi36x7zj0glsb3s2gwqd4wswhfzh36rbp7imbyff53a7nna95l"))))
222 (build-system gnu-build-system)
224 `(("autoconf" ,autoconf)
225 ("automake" ,automake)
231 (list (string-append "--libdir=" (assoc-ref %outputs "out")
232 "/lib/coq/user-contrib/Flocq"))
234 (modify-phases %standard-phases
235 (add-after 'unpack 'remove-failing-examples
237 (substitute* "Remakefile.in"
238 ;; Fails on a union error.
239 (("Double_rounding_odd_radix.v") ""))
241 (add-before 'configure 'fix-remake
243 (substitute* "remake.cpp"
244 (("/bin/sh") (which "sh")))
248 (invoke "./remake")))
251 (invoke "./remake" "check")))
252 ;; TODO: requires coq-gappa and coq-interval.
253 ;(invoke "./remake" "check-more")
256 (invoke "./remake" "install"))))))
257 (home-page "https://flocq.gforge.inria.fr/")
258 (synopsis "Floating-point formalization for the Coq system")
259 (description "Flocq (Floats for Coq) is a floating-point formalization for
260 the Coq system. It provides a comprehensive library of theorems on a multi-radix
261 multi-precision arithmetic. It also supports efficient numerical computations
263 (license license:lgpl3+)))
265 (define-public coq-gappa
273 (url "https://gitlab.inria.fr/gappa/coq.git")
274 (commit (string-append "gappalib-coq-" version))))
275 (file-name (git-file-name name version))
278 "0r7jwp5xssdfzivs2flp7mzrscqhgl63mryhhf1cvndpgzqwfk2f"))))
279 (build-system gnu-build-system)
281 `(("autoconf" ,autoconf)
282 ("automake" ,automake)
294 `(("coq-flocq" ,coq-flocq)))
297 (list (string-append "--libdir=" (assoc-ref %outputs "out")
298 "/lib/coq/user-contrib/Gappa"))
300 (modify-phases %standard-phases
301 (add-before 'configure 'fix-remake
303 (substitute* "remake.cpp"
304 (("/bin/sh") (which "sh")))
307 (lambda _ (invoke "./remake")))
308 ;; FIXME: Figure out why failures occur, and re-enable check phase.
311 ;; (lambda _ (invoke "./remake" "check")))
313 (lambda _ (invoke "./remake" "install"))))))
314 (home-page "http://gappa.gforge.inria.fr/")
315 (synopsis "Verify and formally prove properties on numerical programs")
316 (description "Gappa is a tool intended to help verifying and formally proving
317 properties on numerical programs dealing with floating-point or fixed-point
318 arithmetic. It has been used to write robust floating-point filters for CGAL
319 and it is used to certify elementary functions in CRlibm. While Gappa is
320 intended to be used directly, it can also act as a backend prover for the Why3
321 software verification plateform or as an automatic tactic for the Coq proof
323 (license (list license:gpl2+ license:cecill))));either gpl2+ or cecill
325 (define-public coq-mathcomp
327 (name "coq-mathcomp")
333 (url "https://github.com/math-comp/math-comp.git")
334 (commit (string-append "mathcomp-" version))))
335 (file-name (git-file-name name version))
337 (base32 "1h5h1c2025r1ms5qryvwy6pikxmpmmjav6yl127xpzmqdi6w732d"))))
338 (build-system gnu-build-system)
344 `(#:tests? #f ; No tests.
346 (modify-phases %standard-phases
348 (add-before 'build 'chdir
349 (lambda _ (chdir "mathcomp") #t))
351 (lambda* (#:key outputs #:allow-other-keys)
352 (invoke "make" "-f" "Makefile.coq"
353 (string-append "COQLIB=" (assoc-ref outputs "out")
356 (home-page "https://math-comp.github.io/math-comp/")
357 (synopsis "Mathematical Components for Coq")
358 (description "Mathematical Components for Coq has its origins in the formal
359 proof of the Four Colour Theorem. Since then it has grown to cover many areas
360 of mathematics and has been used for large scale projects like the formal proof
361 of the Odd Order Theorem.
363 The library is written using the Ssreflect proof language that is an integral
364 part of the distribution.")
365 (license license:cecill-b)))
367 (define-public coq-coquelicot
369 (name "coq-coquelicot")
373 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
374 "file/37523/coquelicot-" version ".tar.gz"))
377 "1biia7nfqf7vaqq5gmykl4rwjyvrcwss6r2jdf0in5pvp2rnrj2w"))))
378 (build-system gnu-build-system)
384 `(("mathcomp" ,coq-mathcomp)))
387 (list (string-append "--libdir=" (assoc-ref %outputs "out")
388 "/lib/coq/user-contrib/Coquelicot"))
390 (modify-phases %standard-phases
391 (add-before 'configure 'fix-remake
393 (substitute* "remake.cpp"
394 (("/bin/sh") (which "sh")))
397 (lambda _ (invoke "./remake")))
399 (lambda _ (invoke "./remake" "check")))
401 (lambda _ (invoke "./remake" "install"))))))
402 (home-page "http://coquelicot.saclay.inria.fr/index.html")
403 (synopsis "Coq library for Reals")
404 (description "Coquelicot is an easier way of writing formulas and theorem
405 statements, achieved by relying on total functions in place of dependent types
406 for limits, derivatives, integrals, power series, and so on. To help with the
407 proof process, the library comes with a comprehensive set of theorems that cover
408 not only these notions, but also some extensions such as parametric integrals,
409 two-dimensional differentiability, asymptotic behaviors. It also offers some
410 automations for performing differentiability proofs. Moreover, Coquelicot is a
411 conservative extension of Coq's standard library and provides correspondence
412 theorems between the two libraries.")
413 (license license:lgpl3+)))
415 (define-public coq-bignums
422 (url "https://github.com/coq/bignums.git")
423 (commit (string-append "V" version))))
424 (file-name (git-file-name name version))
427 "03qz1w2xb2j5p06liz5yyafl0fl9vprcqm6j0iwi7rxwghl00p01"))))
428 (build-system gnu-build-system)
433 `(("camlp5" ,camlp5)))
435 `(#:tests? #f; No test target
437 (list (string-append "COQLIBINSTALL=" (assoc-ref %outputs "out")
438 "/lib/coq/user-contrib"))
440 (modify-phases %standard-phases
441 (delete 'configure))))
442 (home-page "https://github.com/coq/bignums")
443 (synopsis "Coq library for arbitrary large numbers")
444 (description "Bignums is a coq library of arbitrary large numbers. It
445 provides BigN, BigZ, BigQ that used to be part of Coq standard library.")
446 (license license:lgpl2.1+)))
448 (define-public coq-interval
450 (name "coq-interval")
454 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
455 "file/37524/interval-" version ".tar.gz"))
458 "023j9sd64brqvjdidqkn5m8d7a93zd9r86ggh573z9nkjm2m7vvg"))))
459 (build-system gnu-build-system)
465 `(("flocq" ,coq-flocq)
466 ("bignums" ,coq-bignums)
467 ("coquelicot" ,coq-coquelicot)
468 ("mathcomp" ,coq-mathcomp)))
471 (list (string-append "--libdir=" (assoc-ref %outputs "out")
472 "/lib/coq/user-contrib/Gappa"))
474 (modify-phases %standard-phases
475 (add-before 'configure 'fix-remake
477 (substitute* "remake.cpp"
478 (("/bin/sh") (which "sh")))
481 (lambda _ (invoke "./remake")))
483 (lambda _ (invoke "./remake" "check")))
485 (lambda _ (invoke "./remake" "install"))))))
486 (home-page "http://coq-interval.gforge.inria.fr/")
487 (synopsis "Coq tactics to simplify inequality proofs")
488 (description "Interval provides vernacular files containing tactics for
489 simplifying the proofs of inequalities on expressions of real numbers for the
490 Coq proof assistant.")
491 (license license:cecill-c)))
493 (define-public coq-autosubst
494 ;; Latest commit on that branch, where work on supporting coq 8.6 and
495 ;; more recent versions of coq happen.
496 (let ((branch "coq86-devel")
497 (commit "fa6ef30664511ffa659cbcf3c962715cbee03572"))
499 (name "coq-autosubst")
500 (version (git-version "1" branch commit))
504 (url "git://github.com/uds-psl/autosubst.git")
506 (file-name (git-file-name name version))
508 (base32 "1cl0bp96bk6lplbl7n5c703vd3gvbs5mvf2qrf8q333kkqd7jqq4"))))
509 (build-system gnu-build-system)
513 (modify-phases %standard-phases
516 (lambda* (#:key outputs #:allow-other-keys)
517 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
519 (string-append "COQLIB=" (assoc-ref outputs "out")
524 (home-page "https://www.ps.uni-saarland.de/autosubst/")
525 (synopsis "Coq library for parallel de Bruijn substitutions")
526 (description "Formalizing syntactic theories with variable binders is
527 not easy. Autosubst is a library for the Coq proof assistant to
528 automate this process. Given an inductive definition of syntactic objects in
529 de Bruijn representation augmented with binding annotations, Autosubst
530 synthesizes the parallel substitution operation and automatically proves the
531 basic lemmas about substitutions. This library contains an automation
532 tactic that solves equations involving terms and substitutions. This makes the
533 usage of substitution lemmas unnecessary. The tactic is based on our current
534 work on a decision procedure for the equational theory of an extension of the
535 sigma-calculus by Abadi et al. The library is completely written in Coq and
536 uses Ltac to synthesize the substitution operation.")
537 (license license:bsd-3))))
539 (define-public coq-equations
541 (name "coq-equations")
546 (url "https://github.com/mattam82/Coq-Equations.git")
547 (commit (string-append "v" version "-8.9"))))
548 (file-name (git-file-name name version))
551 "1q3wvicr43bgy7xn1diwh4j43mnrhprrc2xd22qlbz9cl6bhf8bj"))))
552 (build-system gnu-build-system)
558 `(#:test-target "test-suite"
560 (modify-phases %standard-phases
562 (lambda* (#:key outputs #:allow-other-keys)
563 (invoke "coq_makefile" "-f" "_CoqProject" "-o" "Makefile")))
565 (lambda* (#:key outputs #:allow-other-keys)
566 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
568 (string-append "COQLIB=" (assoc-ref outputs "out")
571 (home-page "https://mattam82.github.io/Coq-Equations/")
572 (synopsis "Function definition plugin for Coq")
573 (description "Equations provides a notation for writing programs
574 by dependent pattern-matching and (well-founded) recursion in Coq. It
575 compiles everything down to eliminators for inductive types, equality
576 and accessibility, providing a definitional extension to the Coq
578 (license license:lgpl2.1)))
580 (define-public coq-stdpp
584 (synopsis "Alternative Coq standard library std++")
588 (url "https://gitlab.mpi-sws.org/iris/stdpp.git")
589 (commit (string-append "coq-stdpp-" version))))
590 (file-name (git-file-name name version))
592 (base32 "11m7kqxsbxygk41v2wsi3npdzwin9fcnzc1gn0gq0rd57wnqk83i"))))
593 (build-system gnu-build-system)
597 `(#:tests? #f ;; the tests are being run automaticlly as part of `make all`
599 (modify-phases %standard-phases
602 (lambda* (#:key outputs #:allow-other-keys)
603 (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
605 (string-append "COQLIB=" (assoc-ref outputs "out")
608 (description "This project contains an extended \"Standard Library\" for
609 Coq called coq-std++. The key features are:
611 @item Great number of definitions and lemmas for common data structures such
612 as lists, finite maps, finite sets, and finite multisets.
614 @item Type classes for common notations (like ∅, ∪, and Haskell-style monad
615 notations) so that these can be overloaded for different data structures.
617 @item It uses type classes to keep track of common properties of types, like
618 it having decidable equality or being countable or finite.
620 @item Most data structures are represented in canonical ways so that Leibniz
621 equality can be used as much as possible (for example, for maps we have m1 =
622 m2 iff ∀ i, m1 !! i = m2 !! i). On top of that, the library provides setoid
623 instances for most types and operations.
625 @item Various tactics for common tasks, like an ssreflect inspired done tactic
626 for finishing trivial goals, a simple breadth-first solver naive_solver, an
627 equality simplifier simplify_eq, a solver solve_proper for proving
628 compatibility of functions with respect to relations, and a solver set_solver
629 for goals involving set operations.
631 @item The library is dependency- and axiom-free.
633 (home-page "https://gitlab.mpi-sws.org/iris/stdpp")
634 (license license:bsd-3)))