homebrew-core/Formula/math-comp.rb

54 lines
1.6 KiB
Ruby

class MathComp < Formula
desc "Mathematical Components for the Coq proof assistant"
homepage "https://math-comp.github.io/math-comp/"
url "https://github.com/math-comp/math-comp/archive/mathcomp-1.11.0.tar.gz"
sha256 "b16108320f77d15dd19ecc5aad90775b576edfa50c971682a1a439f6d364fef6"
license "CECILL-B"
revision 1
head "https://github.com/math-comp/math-comp.git"
bottle do
cellar :any_skip_relocation
sha256 "edb89d858da73c96db674081d8e4ae7928c1e8ba84aa6d1b094d8f3ecdf9e3da" => :catalina
sha256 "909e8d31ba453c301dbb60429dbd34c762fc8e2d17429db26dede12baa7c78ed" => :mojave
sha256 "60fbe12a151b31cedb075a81e352b63f130ee01e17b3ea47bc04430be006a9b5" => :high_sierra
end
depends_on "ocaml" => :build
depends_on "coq"
def install
coqlib = "#{lib}/coq/"
(buildpath/"mathcomp/Makefile.coq.local").write <<~EOS
COQLIB=#{coqlib}
EOS
cd "mathcomp" do
system "make", "Makefile.coq"
system "make", "-f", "Makefile.coq", "MAKEFLAGS=#{ENV["MAKEFLAGS"]}"
system "make", "install", "MAKEFLAGS=#{ENV["MAKEFLAGS"]}"
elisp.install "ssreflect/pg-ssr.el"
end
doc.install Dir["docs/*"]
end
test do
(testpath/"testing.v").write <<~EOS
From mathcomp Require Import ssreflect seq.
Parameter T: Type.
Theorem test (s1 s2: seq T): size (s1 ++ s2) = size s1 + size s2.
Proof. by elim : s1 =>//= x s1 ->. Qed.
Check test.
EOS
coqc = Formula["coq"].opt_bin/"coqc"
cmd = "#{coqc} -R #{lib}/coq/user-contrib/mathcomp mathcomp testing.v"
assert_match /\Atest\s+: forall/, shell_output(cmd)
end
end