Skip to content

rocq 9.0.0 (renamed formula) #216253

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/autobump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ cookiecutter
copa
copier
copilot
coq
core-lightning
coredns
coreutils
Expand Down Expand Up @@ -2977,6 +2976,7 @@ robin-map
roblox-ts
robot-framework
rocksdb
rocq
rogcat
rojo
rollup
Expand Down
49 changes: 49 additions & 0 deletions Formula/c/coq-hierarchy-builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class CoqHierarchyBuilder < Formula
desc "High level commands to declare a hierarchy based on packed classes"
homepage "https://github.com/math-comp/hierarchy-builder"
url "https://github.com/math-comp/hierarchy-builder/releases/download/v1.8.1/hierarchy-builder-1.8.1.tar.gz"
sha256 "9295185ac7e6c2222951a0706edeeb0de23763939ca033a3956d23c0f6c30fe8"
license "MIT"

livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end

depends_on "rocq"
depends_on "rocq-elpi"

def install
ENV["OCAMLFIND_CONF"] = Formula["rocq-elpi"].libexec/"lib/findlib.conf"
system "make", "build"
system "make", "install", "HB_INSTALLDIR=#{bin}", "COQLIB=#{lib}/ocaml/coq"
end

test do
(testpath/"test.v").write <<~EOS
From HB Require Import structures.
From Stdlib Require Import ssreflect ZArith.

HB.mixin Record IsAddComoid A := {
zero : A;
add : A -> A -> A;
addrA : forall x y z, add x (add y z) = add (add x y) z;
addrC : forall x y, add x y = add y x;
add0r : forall x, add zero x = x;
}.

HB.structure Definition AddComoid := { A of IsAddComoid A }.

Notation "0" := zero.
Infix "+" := add.

Check forall (M : AddComoid.type) (x : M), x + x = 0.
EOS

ENV["OCAMLFIND_CONF"] = Formula["rocq-elpi"].libexec/"lib/findlib.conf"
assert_equal <<~EOS, shell_output("#{Formula["rocq"].bin}/rocq compile test.v")
forall (M : AddComoid.type) (x : M), x + x = 0
: Prop
EOS
end
end
47 changes: 18 additions & 29 deletions Formula/m/math-comp.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
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/refs/tags/mathcomp-1.19.0.tar.gz"
sha256 "786db902d904347f2108ffceae15ba29037ff8e63a6c58b87928f08671456394"
url "https://github.com/math-comp/math-comp/archive/refs/tags/mathcomp-2.3.0.tar.gz"
sha256 "19e13c8765007f95b4656d8902bc66e10b072ab94ab51031c5efb860827d05ec"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license "CECILL-B"
revision 6
head "https://github.com/math-comp/math-comp.git", branch: "master"

bottle do
Expand All @@ -19,37 +18,28 @@ class MathComp < Formula

depends_on "ocaml" => :build
depends_on "ocaml-findlib" => :build
depends_on "coq"
depends_on "coq-hierarchy-builder"
depends_on "rocq"
depends_on "rocq-elpi"

def install
# Work around for https://github.com/Homebrew/homebrew-test-bot/issues/805
if ENV["HOMEBREW_GITHUB_ACTIONS"] && !(Formula["ocaml-findlib"].etc/"findlib.conf").exist?
ENV["OCAMLFIND_CONF"] = Formula["ocaml-findlib"].opt_libexec/"findlib.conf"
end

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"]}"

ENV["OCAMLFIND_CONF"] = Formula["rocq-elpi"].libexec/"lib/findlib.conf"

args = []
if build.stable?
args += %w[-C mathcomp]
(buildpath/"mathcomp/Makefile.coq.local").write "COQLIB=#{lib}/ocaml/coq\n"
elisp.install "mathcomp/ssreflect/pg-ssr.el"
else
(buildpath/"Makefile.coq.local").append_lines "COQLIB=#{lib}/ocaml/coq\n"
elisp.install "ssreflect/pg-ssr.el"
end

doc.install Dir["docs/*"]
system "make", *args
system "make", *args, "install"
end

test do
# Work around for https://github.com/Homebrew/homebrew-test-bot/issues/805
if ENV["HOMEBREW_GITHUB_ACTIONS"] && !(Formula["ocaml-findlib"].etc/"findlib.conf").exist?
ENV["OCAMLFIND_CONF"] = Formula["ocaml-findlib"].opt_libexec/"findlib.conf"
end

(testpath/"testing.v").write <<~EOS
From mathcomp Require Import ssreflect seq.

Expand All @@ -60,8 +50,7 @@ def install
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))
ENV["OCAMLFIND_CONF"] = Formula["rocq-elpi"].libexec/"lib/findlib.conf"
assert_match(/\Atest\s+: forall/, shell_output("#{Formula["rocq"].bin}/rocq compile testing.v"))
end
end
85 changes: 85 additions & 0 deletions Formula/r/rocq-elpi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
class RocqElpi < Formula
desc "Elpi extension language for Coq"
homepage "https://github.com/LPCIC/coq-elpi"
# Update resources based on https://github.com/LPCIC/coq-elpi/blob/v#{version}/rocq-elpi.opam#L18-L26
url "https://github.com/LPCIC/coq-elpi/releases/download/v2.5.0/rocq-elpi-2.5.0.tar.gz"
sha256 "0352cee8fc0a0224f8d8043d7c0f4daf217842e0dc46d5795537bdec737006ae"
license "LGPL-2.1-or-later"

livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end

depends_on "dune" => :build
depends_on "ocaml" => :build
depends_on "opam" => :build
depends_on "ocaml-findlib"
depends_on "rocq"

# NOTE: Resources are just used to provide version numbers for `opam install`
# since we hit a build error when trying to install from tarball directly.
# The result is similar to using `--deps-only` in other formulae. We can't
# run that here as it installs a duplicate copy of `rocq`.

resource "elpi" do
url "https://raw.githubusercontent.com/LPCIC/elpi/refs/tags/v2.0.7/elpi.opam"
sha256 "25a4d6bafd404d6067bd95227e7bd29de82d887f3789ac80ade7489b995edc1f"
end

resource "ppx_optcomp" do
url "https://raw.githubusercontent.com/janestreet/ppx_optcomp/refs/tags/v0.17.0/ppx_optcomp.opam"
sha256 "9ddda7e28dabea043a0187acf3d0ff378084e0ef75c9e2003bd0350b83f4dd41"
end

def install
with_env(OPAMROOT: buildpath/".opam", OPAMYES: "1", OPAMNODEPEXTS: "1", OPAMNOSELFUPGRADE: "1") do
system "opam", "init", "--disable-sandboxing", "--no-setup"
system "opam", "install", "elpi.#{resource("elpi").version}", "ppx_optcomp.v#{resource("ppx_optcomp").version}"
end

# Move packages needed at runtime into libexec
libexec.install buildpath.glob(".opam/default/*")
inreplace [libexec/"lib/findlib.conf", libexec/"lib/toplevel/topfind"], buildpath/".opam/default", libexec

# Replace findlib package with formula
inreplace libexec/"lib/toplevel/topfind", libexec/"lib/findlib", Formula["ocaml-findlib"].opt_lib/"ocaml/findlib"
rm_r(libexec/"lib/findlib")

ENV["OCAMLFIND_CONF"] = libexec/"lib/findlib.conf"
system "make", "dune-files"
system "dune", "build", "-p", name, "@install"
system "dune", "install", name, "--prefix=#{prefix}",
"--libdir=#{lib}/ocaml",
"--mandir=#{man}",
"--docdir=#{doc.parent}"
pkgshare.install "examples/example_data_base.v"
end

def caveats
<<~CAVEATS
Rocq needs the path to ML files installed inside `#{opt_libexec}/lib`.
This can be done by passing `-I #{opt_libexec}/lib` as an argument.
Alternatively, you can add the directory to OCAMLPATH, e.g.
export OCAMLPATH="#{opt_libexec}/lib:$OCAMLPATH"
or use the included findlib configuration file, e.g.
export OCAMLFIND_CONF="#{opt_libexec}/lib/findlib.conf"
CAVEATS
end

test do
ENV["OCAMLFIND_CONF"] = libexec/"lib/findlib.conf"
cp pkgshare/"example_data_base.v", testpath
space = " "
assert_equal <<~EOS, shell_output("#{Formula["rocq"].bin}/rocq compile example_data_base.v")
The Db contains [phone_prefix USA 1]
Phone prefix for USA is 1
The Db contains#{space}
[phone_prefix USA 1, phone_prefix France 33, phone_prefix Italy 39]
Phone prefix for France is 33
sweet!
brr
yummy!
EOS
end
end
63 changes: 38 additions & 25 deletions Formula/c/coq.rb → Formula/r/rocq.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
class Coq < Formula
class Rocq < Formula
desc "Proof assistant for higher-order logic"
homepage "https://coq.inria.fr/"
url "https://github.com/coq/coq/releases/download/V8.20.1/coq-8.20.1.tar.gz"
sha256 "09ad238cc7930d59564b032be2a8a1fd10d6ef845364d739072d04090a6d3cc2"
homepage "https://rocq-prover.org/"
license "LGPL-2.1-only"
head "https://github.com/coq/coq.git", branch: "master"

stable do
url "https://github.com/coq/coq/releases/download/V9.0.0/rocq-9.0.0.tar.gz"
sha256 "82f86646fd3d047f760837648195c73374beee667b1c9592d31c5426e3b43a51"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url "https://github.com/coq/coq/releases/download/V9.0.0/rocq-9.0.0.tar.gz"
url "https://github.com/rocq-prover/rocq/releases/download/V9.0.0/rocq-9.0.0.tar.gz"


resource "stdlib" do
url "https://github.com/coq/stdlib/releases/download/V9.0.0/stdlib-9.0.0.tar.gz"
sha256 "1ab6adc42dfc651ddc909604bae1a54ff5623cda837f93677a8b12aab9eec711"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url "https://github.com/coq/stdlib/releases/download/V9.0.0/stdlib-9.0.0.tar.gz"
url "https://github.com/rocq-prover/stdlib/releases/download/V9.0.0/stdlib-9.0.0.tar.gz"

end
end

livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end

bottle do
sha256 arm64_sequoia: "65a6d3984df7191476d584bf10ad5a20f7f5b79985f3b2550ede68ee9c84204c"
sha256 arm64_sonoma: "f0fbf43c5369353ec0b2ca64b5132bb81b34c1ed2e3dc3e51aefb35232807873"
sha256 arm64_ventura: "6a647ecd4b7562cac8cf430dc897db55cad68aa2f41f727491c9d25a9528f1da"
sha256 sonoma: "37910c96de115af903170ebc56447092de187c4e1eda11c44be0fdc77bf0881e"
sha256 ventura: "3d1168df2643f5ab98fd7a721ca12bd3dff10f447918d6f3962d1867abfdc1ff"
sha256 arm64_linux: "1d2e24d6e8d829cf454df015d3b03a86e0779639825b5cfe60800bcc03fe6d3f"
sha256 x86_64_linux: "df412ed51c3f13261aa40bd9cccf2544ffcc6993ede2371f334e63d0ad8ff473"
head do
url "https://github.com/coq/coq.git", branch: "master"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url "https://github.com/coq/coq.git", branch: "master"
url "https://github.com/rocq-prover/rocq.git", branch: "master"

resource "stdlib" do
url "https://github.com/coq/stdlib.git", branch: "master"
end
Copy link
Contributor

@tchajed tchajed Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url "https://github.com/coq/stdlib.git", branch: "master"
url "https://github.com/rocq-prover/stdlib.git", branch: "master"

end

depends_on "dune" => :build
Expand All @@ -37,19 +42,27 @@ def install
end
ENV.prepend_path "OCAMLPATH", Formula["ocaml-zarith"].opt_lib/"ocaml"
ENV.prepend_path "OCAMLPATH", Formula["ocaml-findlib"].opt_lib/"ocaml"

packages = %w[rocq-runtime coq-core rocq-core coq coqide-server]

system "./configure", "-prefix", prefix,
"-mandir", man,
"-libdir", HOMEBREW_PREFIX/"lib/ocaml/coq",
"-docdir", pkgshare/"latex"
system "make", "dunestrap"
system "dune", "build", "-p", "coq-core,coq-stdlib,coqide-server,coq"
system "dune", "build", "-p", packages.join(",")
system "dune", "install", "--prefix=#{prefix}",
"--mandir=#{man}",
"--libdir=#{lib}/ocaml",
"coq-core",
"coq-stdlib",
"coqide-server",
"coq"
"--docdir=#{doc.parent}",
*packages

resource("stdlib").stage do
ENV.prepend_path "PATH", bin
ENV["ROCQLIB"] = lib/"ocaml/coq"
system "make"
system "make", "install"
end
end

test do
Expand All @@ -58,8 +71,8 @@ def install
ENV["OCAMLFIND_CONF"] = Formula["ocaml-findlib"].opt_libexec/"findlib.conf"
end
(testpath/"testing.v").write <<~EOS
Require Coq.micromega.Lia.
Require Coq.ZArith.ZArith.
Require Stdlib.micromega.Lia.
Require Stdlib.ZArith.ZArith.

Inductive nat : Set :=
| O : nat
Expand All @@ -74,17 +87,17 @@ def install
intros n; induction n; simpl; auto; rewrite IHn; auto.
Qed.

Import Coq.micromega.Lia.
Import Coq.ZArith.ZArith.
Import Stdlib.micromega.Lia.
Import Stdlib.ZArith.ZArith.
Open Scope Z.
Lemma add_O_r_Z : forall (n: Z), n + 0 = n.
Proof.
intros; lia.
Qed.
EOS
system bin/"coqc", testpath/"testing.v"
system bin/"rocq", "compile", testpath/"testing.v"
# test ability to find plugin files
output = shell_output("#{Formula["ocaml-findlib"].bin}/ocamlfind query coq-core.plugins.ltac")
assert_equal "#{HOMEBREW_PREFIX}/lib/ocaml/coq-core/plugins/ltac", output.chomp
output = shell_output("#{Formula["ocaml-findlib"].bin}/ocamlfind query rocq-runtime.plugins.ltac")
assert_equal "#{HOMEBREW_PREFIX}/lib/ocaml/rocq-runtime/plugins/ltac", output.chomp
end
end
1 change: 1 addition & 0 deletions formula_renames.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"cloog018": "cloog",
"cloudflare-wrangler2": "cloudflare-wrangler",
"commonmark": "cmark",
"coq": "rocq",
"corepack": "node",
"cppformat": "fmt",
"crystal-lang": "crystal",
Expand Down
Loading