coq.scm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
  3. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2019 Dan Frumin <dfrumin@cs.ru.nl>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  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.
  12. ;;;
  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.
  17. ;;;
  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/>.
  20. (define-module (gnu packages coq)
  21. #:use-module (gnu packages)
  22. #:use-module (gnu packages base)
  23. #:use-module (gnu packages bison)
  24. #:use-module (gnu packages boost)
  25. #:use-module (gnu packages emacs)
  26. #:use-module (gnu packages flex)
  27. #:use-module (gnu packages multiprecision)
  28. #:use-module (gnu packages ocaml)
  29. #:use-module (gnu packages perl)
  30. #:use-module (gnu packages python)
  31. #:use-module (gnu packages texinfo)
  32. #:use-module (guix build-system gnu)
  33. #:use-module (guix build-system ocaml)
  34. #:use-module (guix download)
  35. #:use-module (guix git-download)
  36. #:use-module ((guix licenses) #:prefix license:)
  37. #:use-module (guix packages)
  38. #:use-module (guix utils)
  39. #:use-module ((srfi srfi-1) #:hide (zip)))
  40. (define-public coq
  41. (package
  42. (name "coq")
  43. (version "8.8.2")
  44. (source
  45. (origin
  46. (method git-fetch)
  47. (uri (git-reference
  48. (url "https://github.com/coq/coq.git")
  49. (commit (string-append "V" version))))
  50. (file-name (git-file-name name version))
  51. (sha256
  52. (base32 "03v8b57mz3ivsijwxy51avzwiyhla5ijaf98a5a2q29yabdq8dkp"))))
  53. (native-search-paths
  54. (list (search-path-specification
  55. (variable "COQPATH")
  56. (files (list "lib/coq/user-contrib")))))
  57. (build-system ocaml-build-system)
  58. (inputs
  59. `(("lablgtk" ,lablgtk)
  60. ("python" ,python-2)
  61. ("camlp5" ,camlp5)
  62. ("ocaml-num" ,ocaml-num)))
  63. (arguments
  64. `(#:phases
  65. (modify-phases %standard-phases
  66. (add-after 'unpack 'make-git-checkout-writable
  67. (lambda _
  68. (for-each make-file-writable (find-files "."))
  69. #t))
  70. (replace 'configure
  71. (lambda* (#:key outputs #:allow-other-keys)
  72. (let* ((out (assoc-ref outputs "out"))
  73. (mandir (string-append out "/share/man"))
  74. (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
  75. (invoke "./configure"
  76. "-prefix" out
  77. "-mandir" mandir
  78. "-browser" browser
  79. "-coqide" "opt"))))
  80. (replace 'build
  81. (lambda _
  82. (invoke "make"
  83. "-j" (number->string (parallel-job-count))
  84. "world")))
  85. (delete 'check)
  86. (add-after 'install 'check
  87. (lambda _
  88. (with-directory-excursion "test-suite"
  89. ;; These two tests fail.
  90. ;; This one fails because the output is not formatted as expected.
  91. (delete-file-recursively "coq-makefile/timing")
  92. ;; This one fails because we didn't build coqtop.byte.
  93. (delete-file-recursively "coq-makefile/findlib-package")
  94. (invoke "make")))))))
  95. (home-page "https://coq.inria.fr")
  96. (synopsis "Proof assistant for higher-order logic")
  97. (description
  98. "Coq is a proof assistant for higher-order logic, which allows the
  99. development of computer programs consistent with their formal specification.
  100. It is developed using Objective Caml and Camlp5.")
  101. ;; The code is distributed under lgpl2.1.
  102. ;; Some of the documentation is distributed under opl1.0+.
  103. (license (list license:lgpl2.1 license:opl1.0+))))
  104. (define-public proof-general
  105. (package
  106. (name "proof-general")
  107. (version "4.2")
  108. (source (origin
  109. (method url-fetch)
  110. (uri (string-append
  111. "http://proofgeneral.inf.ed.ac.uk/releases/"
  112. "ProofGeneral-" version ".tgz"))
  113. (sha256
  114. (base32
  115. "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm"))))
  116. (build-system gnu-build-system)
  117. (native-inputs
  118. `(("which" ,which)
  119. ("emacs" ,emacs-minimal)
  120. ("texinfo" ,texinfo)))
  121. (inputs
  122. `(("host-emacs" ,emacs)
  123. ("perl" ,perl)
  124. ("coq" ,coq)))
  125. (arguments
  126. `(#:tests? #f ; no check target
  127. #:make-flags (list (string-append "PREFIX=" %output)
  128. (string-append "DEST_PREFIX=" %output))
  129. #:modules ((guix build gnu-build-system)
  130. (guix build utils)
  131. (guix build emacs-utils))
  132. #:imported-modules (,@%gnu-build-system-modules
  133. (guix build emacs-utils))
  134. #:phases
  135. (modify-phases %standard-phases
  136. (delete 'configure)
  137. (add-after 'unpack 'disable-byte-compile-error-on-warn
  138. (lambda _
  139. (substitute* "Makefile"
  140. (("\\(setq byte-compile-error-on-warn t\\)")
  141. "(setq byte-compile-error-on-warn nil)"))
  142. #t))
  143. (add-after 'unpack 'patch-hardcoded-paths
  144. (lambda* (#:key inputs outputs #:allow-other-keys)
  145. (let ((out (assoc-ref outputs "out"))
  146. (coq (assoc-ref inputs "coq"))
  147. (emacs (assoc-ref inputs "host-emacs")))
  148. (define (coq-prog name)
  149. (string-append coq "/bin/" name))
  150. (emacs-substitute-variables "coq/coq.el"
  151. ("coq-prog-name" (coq-prog "coqtop"))
  152. ("coq-compiler" (coq-prog "coqc"))
  153. ("coq-dependency-analyzer" (coq-prog "coqdep")))
  154. (substitute* "Makefile"
  155. (("/sbin/install-info") "install-info"))
  156. (substitute* "bin/proofgeneral"
  157. (("^PGHOMEDEFAULT=.*" all)
  158. (string-append all
  159. "PGHOME=$PGHOMEDEFAULT\n"
  160. "EMACS=" emacs "/bin/emacs")))
  161. #t)))
  162. (add-after 'unpack 'clean
  163. (lambda _
  164. ;; Delete the pre-compiled elc files for Emacs 23.
  165. (invoke "make" "clean")))
  166. (add-after 'install 'install-doc
  167. (lambda* (#:key make-flags #:allow-other-keys)
  168. ;; XXX FIXME avoid building/installing pdf files,
  169. ;; due to unresolved errors building them.
  170. (substitute* "Makefile"
  171. ((" [^ ]*\\.pdf") ""))
  172. (apply invoke "make" "install-doc" make-flags))))))
  173. (home-page "http://proofgeneral.inf.ed.ac.uk/")
  174. (synopsis "Generic front-end for proof assistants based on Emacs")
  175. (description
  176. "Proof General is a major mode to turn Emacs into an interactive proof
  177. assistant to write formal mathematical proofs using a variety of theorem
  178. provers.")
  179. (license license:gpl2+)))
  180. (define-public coq-flocq
  181. (package
  182. (name "coq-flocq")
  183. (version "2.6.1")
  184. (source (origin
  185. (method url-fetch)
  186. ;; Use the ‘Latest version’ link for a stable URI across releases.
  187. (uri (string-append "https://gforge.inria.fr/frs/download.php/"
  188. "file/37454/flocq-" version ".tar.gz"))
  189. (sha256
  190. (base32
  191. "06msp1fwpqv6p98a3i1nnkj7ch9rcq3rm916yxq8dxf51lkghrin"))))
  192. (build-system gnu-build-system)
  193. (native-inputs
  194. `(("ocaml" ,ocaml)
  195. ("which" ,which)
  196. ("coq" ,coq)))
  197. (arguments
  198. `(#:configure-flags
  199. (list (string-append "--libdir=" (assoc-ref %outputs "out")
  200. "/lib/coq/user-contrib/Flocq"))
  201. #:phases
  202. (modify-phases %standard-phases
  203. (add-before 'configure 'fix-remake
  204. (lambda _
  205. (substitute* "remake.cpp"
  206. (("/bin/sh") (which "sh")))
  207. #t))
  208. (replace 'build
  209. (lambda _
  210. (invoke "./remake")
  211. #t))
  212. (replace 'check
  213. (lambda _
  214. (invoke "./remake" "check")
  215. #t))
  216. ;; TODO: requires coq-gappa and coq-interval.
  217. ;(invoke "./remake" "check-more")
  218. (replace 'install
  219. (lambda _
  220. (invoke "./remake" "install")
  221. #t)))))
  222. (home-page "http://flocq.gforge.inria.fr/")
  223. (synopsis "Floating-point formalization for the Coq system")
  224. (description "Flocq (Floats for Coq) is a floating-point formalization for
  225. the Coq system. It provides a comprehensive library of theorems on a multi-radix
  226. multi-precision arithmetic. It also supports efficient numerical computations
  227. inside Coq.")
  228. (license license:lgpl3+)))
  229. (define-public coq-gappa
  230. (package
  231. (name "coq-gappa")
  232. (version "1.3.2")
  233. (source (origin
  234. (method url-fetch)
  235. (uri (string-append "https://gforge.inria.fr/frs/download.php/file/36397/gappa-"
  236. version ".tar.gz"))
  237. (sha256
  238. (base32
  239. "19kg2zldaqs4smy7bv9hp650sqg46xbx1ss7jnyagpxdscwn9apd"))))
  240. (build-system gnu-build-system)
  241. (native-inputs
  242. `(("ocaml" ,ocaml)
  243. ("which" ,which)
  244. ("coq" ,coq)
  245. ("bison" ,bison)
  246. ("flex" ,flex)))
  247. (inputs
  248. `(("gmp" ,gmp)
  249. ("mpfr" ,mpfr)
  250. ("boost" ,boost)))
  251. (arguments
  252. `(#:configure-flags
  253. (list (string-append "--libdir=" (assoc-ref %outputs "out")
  254. "/lib/coq/user-contrib/Gappa"))
  255. #:phases
  256. (modify-phases %standard-phases
  257. (add-before 'configure 'fix-remake
  258. (lambda _
  259. (substitute* "remake.cpp"
  260. (("/bin/sh") (which "sh")))
  261. #t))
  262. (replace 'build
  263. (lambda _ (invoke "./remake")))
  264. (replace 'check
  265. (lambda _ (invoke "./remake" "check")))
  266. (replace 'install
  267. (lambda _ (invoke "./remake" "install"))))))
  268. (home-page "http://gappa.gforge.inria.fr/")
  269. (synopsis "Verify and formally prove properties on numerical programs")
  270. (description "Gappa is a tool intended to help verifying and formally proving
  271. properties on numerical programs dealing with floating-point or fixed-point
  272. arithmetic. It has been used to write robust floating-point filters for CGAL
  273. and it is used to certify elementary functions in CRlibm. While Gappa is
  274. intended to be used directly, it can also act as a backend prover for the Why3
  275. software verification plateform or as an automatic tactic for the Coq proof
  276. assistant.")
  277. (license (list license:gpl2+ license:cecill))));either gpl2+ or cecill
  278. (define-public coq-mathcomp
  279. (package
  280. (name "coq-mathcomp")
  281. (version "1.7.0")
  282. (source
  283. (origin
  284. (method git-fetch)
  285. (uri (git-reference
  286. (url "https://github.com/math-comp/math-comp.git")
  287. (commit (string-append "mathcomp-" version))))
  288. (file-name (git-file-name name version))
  289. (sha256
  290. (base32 "1cdzi67jj440xkdpxm10aly80zpn56vjzj2ygb67iq3xpljlv95h"))))
  291. (build-system gnu-build-system)
  292. (native-inputs
  293. `(("ocaml" ,ocaml)
  294. ("which" ,which)
  295. ("coq" ,coq)))
  296. (arguments
  297. `(#:tests? #f ; no need to test formally-verified programs :)
  298. #:phases
  299. (modify-phases %standard-phases
  300. (delete 'configure)
  301. (add-before 'build 'chdir
  302. (lambda _ (chdir "mathcomp") #t))
  303. (replace 'install
  304. (lambda* (#:key outputs #:allow-other-keys)
  305. (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
  306. (invoke "make" "-f" "Makefile.coq"
  307. (string-append "COQLIB=" (assoc-ref outputs "out")
  308. "/lib/coq/")
  309. "install"))))))
  310. (home-page "https://math-comp.github.io/math-comp/")
  311. (synopsis "Mathematical Components for Coq")
  312. (description "Mathematical Components for Coq has its origins in the formal
  313. proof of the Four Colour Theorem. Since then it has grown to cover many areas
  314. of mathematics and has been used for large scale projects like the formal proof
  315. of the Odd Order Theorem.
  316. The library is written using the Ssreflect proof language that is an integral
  317. part of the distribution.")
  318. (license license:cecill-b)))
  319. (define-public coq-coquelicot
  320. (package
  321. (name "coq-coquelicot")
  322. (version "3.0.1")
  323. (source (origin
  324. (method url-fetch)
  325. (uri (string-append "https://gforge.inria.fr/frs/download.php/"
  326. "file/37045/coquelicot-" version ".tar.gz"))
  327. (sha256
  328. (base32
  329. "0hsyhsy2lwqxxx2r8xgi5csmirss42lp9bkb9yy35mnya0w78c8r"))))
  330. (build-system gnu-build-system)
  331. (native-inputs
  332. `(("ocaml" ,ocaml)
  333. ("which" ,which)
  334. ("coq" ,coq)))
  335. (propagated-inputs
  336. `(("mathcomp" ,coq-mathcomp)))
  337. (arguments
  338. `(#:configure-flags
  339. (list (string-append "--libdir=" (assoc-ref %outputs "out")
  340. "/lib/coq/user-contrib/Coquelicot"))
  341. #:phases
  342. (modify-phases %standard-phases
  343. (add-before 'configure 'fix-coq8.8
  344. (lambda _
  345. ; appcontext has been removed from coq 8.8
  346. (substitute* "theories/AutoDerive.v"
  347. (("appcontext") "context"))
  348. #t))
  349. (add-before 'configure 'fix-remake
  350. (lambda _
  351. (substitute* "remake.cpp"
  352. (("/bin/sh") (which "sh")))
  353. #t))
  354. (replace 'build
  355. (lambda _ (invoke "./remake")))
  356. (replace 'check
  357. (lambda _ (invoke "./remake" "check")))
  358. (replace 'install
  359. (lambda _ (invoke "./remake" "install"))))))
  360. (home-page "http://coquelicot.saclay.inria.fr/index.html")
  361. (synopsis "Coq library for Reals")
  362. (description "Coquelicot is an easier way of writing formulas and theorem
  363. statements, achieved by relying on total functions in place of dependent types
  364. for limits, derivatives, integrals, power series, and so on. To help with the
  365. proof process, the library comes with a comprehensive set of theorems that cover
  366. not only these notions, but also some extensions such as parametric integrals,
  367. two-dimensional differentiability, asymptotic behaviors. It also offers some
  368. automations for performing differentiability proofs. Moreover, Coquelicot is a
  369. conservative extension of Coq's standard library and provides correspondence
  370. theorems between the two libraries.")
  371. (license license:lgpl3+)))
  372. (define-public coq-bignums
  373. (package
  374. (name "coq-bignums")
  375. (version "8.8.0")
  376. (source (origin
  377. (method url-fetch)
  378. (uri (string-append "https://github.com/coq/bignums/archive/V"
  379. version ".tar.gz"))
  380. (file-name (string-append name "-" version ".tar.gz"))
  381. (sha256
  382. (base32
  383. "08m1cmq4hkaf4sb0vy978c11rgzvds71cphyadmr2iirpr5815r0"))))
  384. (build-system gnu-build-system)
  385. (native-inputs
  386. `(("ocaml" ,ocaml)
  387. ("coq" ,coq)))
  388. (inputs
  389. `(("camlp5" ,camlp5)))
  390. (arguments
  391. `(#:tests? #f; No test target
  392. #:make-flags
  393. (list (string-append "COQLIBINSTALL=" (assoc-ref %outputs "out")
  394. "/lib/coq/user-contrib"))
  395. #:phases
  396. (modify-phases %standard-phases
  397. (delete 'configure))))
  398. (home-page "https://github.com/coq/bignums")
  399. (synopsis "Coq library for arbitrary large numbers")
  400. (description "Bignums is a coq library of arbitrary large numbers. It
  401. provides BigN, BigZ, BigQ that used to be part of Coq standard library.")
  402. (license license:lgpl2.1+)))
  403. (define-public coq-interval
  404. (package
  405. (name "coq-interval")
  406. (version "3.3.0")
  407. (source (origin
  408. (method url-fetch)
  409. (uri (string-append "https://gforge.inria.fr/frs/download.php/"
  410. "file/37077/interval-" version ".tar.gz"))
  411. (sha256
  412. (base32
  413. "08fdcf3hbwqphglvwprvqzgkg0qbimpyhnqsgv3gac4y1ap0f903"))))
  414. (build-system gnu-build-system)
  415. (native-inputs
  416. `(("ocaml" ,ocaml)
  417. ("which" ,which)
  418. ("coq" ,coq)))
  419. (propagated-inputs
  420. `(("flocq" ,coq-flocq)
  421. ("bignums" ,coq-bignums)
  422. ("coquelicot" ,coq-coquelicot)
  423. ("mathcomp" ,coq-mathcomp)))
  424. (arguments
  425. `(#:configure-flags
  426. (list (string-append "--libdir=" (assoc-ref %outputs "out")
  427. "/lib/coq/user-contrib/Gappa"))
  428. #:phases
  429. (modify-phases %standard-phases
  430. (add-before 'configure 'fix-remake
  431. (lambda _
  432. (substitute* "remake.cpp"
  433. (("/bin/sh") (which "sh")))
  434. #t))
  435. (replace 'build
  436. (lambda _ (invoke "./remake")))
  437. (replace 'check
  438. (lambda _ (invoke "./remake" "check")))
  439. (replace 'install
  440. (lambda _ (invoke "./remake" "install"))))))
  441. (home-page "http://coq-interval.gforge.inria.fr/")
  442. (synopsis "Coq tactics to simplify inequality proofs")
  443. (description "Interval provides vernacular files containing tactics for
  444. simplifying the proofs of inequalities on expressions of real numbers for the
  445. Coq proof assistant.")
  446. (license license:cecill-c)))
  447. (define-public coq-autosubst
  448. ;; Latest commit on that branch, where work on supporting coq 8.6 and
  449. ;; more recent versions of coq happen.
  450. (let ((branch "coq86-devel")
  451. (commit "d0d73557979796b3d4be7aac72135581c33f26f7"))
  452. (package
  453. (name "coq-autosubst")
  454. (version (git-version "1" branch commit))
  455. (source (origin
  456. (method git-fetch)
  457. (uri (git-reference
  458. (url "git://github.com/uds-psl/autosubst.git")
  459. (commit commit)))
  460. (file-name (git-file-name name version))
  461. (sha256
  462. (base32 "1852xb5cwkjw3dlc0lp2sakwa40bjzw37qmwz4bn3vqazg1hnh6r"))))
  463. (build-system gnu-build-system)
  464. (arguments
  465. `(#:tests? #f
  466. #:phases
  467. (modify-phases %standard-phases
  468. (delete 'configure)
  469. (replace 'install
  470. (lambda* (#:key outputs #:allow-other-keys)
  471. (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
  472. (invoke "make"
  473. (string-append "COQLIB=" (assoc-ref outputs "out")
  474. "/lib/coq/")
  475. "install"))))))
  476. (native-inputs
  477. `(("coq" ,coq)))
  478. (home-page "https://www.ps.uni-saarland.de/autosubst/")
  479. (synopsis "Coq library for parallel de Bruijn substitutions")
  480. (description "Formalizing syntactic theories with variable binders is
  481. not easy. Autosubst is a library for the Coq proof assistant to
  482. automate this process. Given an inductive definition of syntactic objects in
  483. de Bruijn representation augmented with binding annotations, Autosubst
  484. synthesizes the parallel substitution operation and automatically proves the
  485. basic lemmas about substitutions. This library contains an automation
  486. tactic that solves equations involving terms and substitutions. This makes the
  487. usage of substitution lemmas unnecessary. The tactic is based on our current
  488. work on a decision procedure for the equational theory of an extension of the
  489. sigma-calculus by Abadi et al. The library is completely written in Coq and
  490. uses Ltac to synthesize the substitution operation.")
  491. (license license:bsd-3))))
  492. (define-public coq-equations
  493. (package
  494. (name "coq-equations")
  495. (version "1.1")
  496. (source (origin
  497. (method git-fetch)
  498. (uri (git-reference
  499. (url "https://github.com/mattam82/Coq-Equations.git")
  500. (commit (string-append "v" version "-8.8"))))
  501. (file-name (git-file-name name version))
  502. (sha256
  503. (base32
  504. "129rxsdsf88vjcw0xhm74yax1hmnk6f8n9ksg0hcyyjq1ijddiwa"))))
  505. (build-system gnu-build-system)
  506. (native-inputs
  507. `(("ocaml" ,ocaml)
  508. ("coq" ,coq)
  509. ("camlp5" ,camlp5)))
  510. (arguments
  511. `(#:test-target "test-suite"
  512. #:phases
  513. (modify-phases %standard-phases
  514. (replace 'configure
  515. (lambda* (#:key outputs #:allow-other-keys)
  516. (invoke "coq_makefile" "-f" "_CoqProject" "-o" "Makefile")))
  517. (replace 'install
  518. (lambda* (#:key outputs #:allow-other-keys)
  519. (setenv "COQLIB" (string-append (assoc-ref outputs "out") "/lib/coq/"))
  520. (invoke "make"
  521. (string-append "COQLIB=" (assoc-ref outputs "out")
  522. "/lib/coq/")
  523. "install"))))))
  524. (home-page "https://mattam82.github.io/Coq-Equations/")
  525. (synopsis "Function definition plugin for Coq")
  526. (description "Equations provides a notation for writing programs
  527. by dependent pattern-matching and (well-founded) recursion in Coq. It
  528. compiles everything down to eliminators for inductive types, equality
  529. and accessibility, providing a definitional extension to the Coq
  530. kernel.")
  531. (license license:lgpl2.1)))