Skip to content

Commit

Permalink
Merge PR coq#19801: make Zeq_bool an alias for Z.eqb, deprecate ZArit…
Browse files Browse the repository at this point in the history
…h_base

Reviewed-by: proux01
Co-authored-by: proux01 <[email protected]>
  • Loading branch information
coqbot-app[bot] and proux01 authored Jan 9, 2025
2 parents bc8831b + 9af8e67 commit f1fc014
Show file tree
Hide file tree
Showing 93 changed files with 562 additions and 480 deletions.
4 changes: 4 additions & 0 deletions dev/ci/user-overlays/19801-andres-erbsen-Zeq_bool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
overlay flocq https://github.com/proux01/flocq coq_19801 19801
overlay vst https://github.com/andres-erbsen/VST less-ZArith_base 19801
overlay compcert https://github.com/andres-erbsen/CompCert less-ZArith_base 19801
overlay coquelicot https://github.com/proux01/coquelicot coq_19801 19801
10 changes: 10 additions & 0 deletions doc/changelog/11-standard-library/19801-less-ZArith_base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- **Deprecated:** module :g:`ZArith_Base`, module :g:`Ztac`, and :g:`Zeq_bool`.
Use :g:`ZArith` (or :g:`BinInt`), :g:`Lia`, and :g:`Z.eqb` instead.
Reducing use of the deprecated modules in stdlib **changed** the transitive
dependencies of several stdlib files; you may now need to ``Require`` or
``Import`` :g:`ZArith` or :g:`Lia`.
The definition of :g:`Zeq_bool` was also **changed** to be an alias for
:g:`Z.eqb`; this is expected to simplify simultaneous compatibility with 8.20
and 9.0
(`#19801 <https://github.com/coq/coq/pull/19801>`_,
by Andres Erbsen).
4 changes: 2 additions & 2 deletions plugins/micromega/certificate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let z_spec =
; zero = Mc.Z0
; unit = Mc.Zpos Mc.XH
; mult = Mc.Z.mul
; eqb = Mc.zeq_bool }
; eqb = Mc.Z.eqb }

let q_spec =
{ bigint_to_number = (fun x -> {Mc.qnum = Ml2C.bigint x; Mc.qden = Mc.XH})
Expand Down Expand Up @@ -677,7 +677,7 @@ let rec term_to_z_expr = function

let term_to_z_pol e =
Mc.norm_aux (Ml2C.z 0) (Ml2C.z 1) Mc.Z.add Mc.Z.mul Mc.Z.sub Mc.Z.opp
Mc.zeq_bool (term_to_z_expr e)
Mc.Z.eqb (term_to_z_expr e)

let z_cert_of_pos pos =
let s, pos = scale_certificate pos in
Expand Down
2 changes: 1 addition & 1 deletion plugins/micromega/coq_micromega.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ let zz_domain_spec =
; undump_coeff = parse_z
; proof_typ = Lazy.force rocq_proofTerm
; dump_proof = dump_proof_term
; coeff_eq = Mc.zeq_bool }
; coeff_eq = Mc.Z.eqb }

let qq_domain_spec =
lazy
Expand Down
53 changes: 37 additions & 16 deletions plugins/micromega/micromega.ml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,20 @@ module Coq_Pos =
| Gt -> p
| _ -> p'

(** val eqb : positive -> positive -> bool **)

let rec eqb p q0 =
match p with
| XI p2 -> (match q0 with
| XI q1 -> eqb p2 q1
| _ -> false)
| XO p2 -> (match q0 with
| XO q1 -> eqb p2 q1
| _ -> false)
| XH -> (match q0 with
| XH -> true
| _ -> false)

(** val leb : positive -> positive -> bool **)

let leb x y =
Expand Down Expand Up @@ -486,6 +500,20 @@ module Z =
| Gt -> true
| _ -> false

(** val eqb : z -> z -> bool **)

let eqb x y =
match x with
| Z0 -> (match y with
| Z0 -> true
| _ -> false)
| Zpos p -> (match y with
| Zpos q0 -> Coq_Pos.eqb p q0
| _ -> false)
| Zneg p -> (match y with
| Zneg q0 -> Coq_Pos.eqb p q0
| _ -> false)

(** val max : z -> z -> z **)

let max n0 m =
Expand Down Expand Up @@ -581,13 +609,6 @@ module Z =
| Zneg b0 -> Zpos (Coq_Pos.gcd a0 b0))
end

(** val zeq_bool : z -> z -> bool **)

let zeq_bool x y =
match Z.compare x y with
| Eq -> true
| _ -> false

type 'c pExpr =
| PEc of 'c
| PEX of positive
Expand Down Expand Up @@ -2045,7 +2066,7 @@ type q = { qnum : z; qden : positive }
(** val qeq_bool : q -> q -> bool **)

let qeq_bool x y =
zeq_bool (Z.mul x.qnum (Zpos y.qden)) (Z.mul y.qnum (Zpos x.qden))
Z.eqb (Z.mul x.qnum (Zpos y.qden)) (Z.mul y.qnum (Zpos x.qden))

(** val qle_bool : q -> q -> bool **)

Expand Down Expand Up @@ -2153,12 +2174,12 @@ type zWitness = z psatz
(** val zWeakChecker : z nFormula list -> z psatz -> bool **)

let zWeakChecker =
check_normalised_formulas Z0 (Zpos XH) Z.add Z.mul zeq_bool Z.leb
check_normalised_formulas Z0 (Zpos XH) Z.add Z.mul Z.eqb Z.leb

(** val psub1 : z pol -> z pol -> z pol **)

let psub1 =
psub0 Z0 Z.add Z.sub Z.opp zeq_bool
psub0 Z0 Z.add Z.sub Z.opp Z.eqb

(** val popp1 : z pol -> z pol **)

Expand All @@ -2168,22 +2189,22 @@ let popp1 =
(** val padd1 : z pol -> z pol -> z pol **)

let padd1 =
padd0 Z0 Z.add zeq_bool
padd0 Z0 Z.add Z.eqb

(** val normZ : z pExpr -> z pol **)

let normZ =
norm Z0 (Zpos XH) Z.add Z.mul Z.sub Z.opp zeq_bool
norm Z0 (Zpos XH) Z.add Z.mul Z.sub Z.opp Z.eqb

(** val zunsat : z nFormula -> bool **)

let zunsat =
check_inconsistent Z0 zeq_bool Z.leb
check_inconsistent Z0 Z.eqb Z.leb

(** val zdeduce : z nFormula -> z nFormula -> z nFormula option **)

let zdeduce =
nformula_plus_nformula Z0 Z.add zeq_bool
nformula_plus_nformula Z0 Z.add Z.eqb

(** val xnnormalise : z formula -> z nFormula **)

Expand Down Expand Up @@ -2300,7 +2321,7 @@ let genCuttingPlane = function
| Equal ->
let g,c = zgcd_pol e in
if (&&) (Z.gtb g Z0)
((&&) (negb (zeq_bool c Z0)) (negb (zeq_bool (Z.gcd g c) g)))
((&&) (negb (Z.eqb c Z0)) (negb (Z.eqb (Z.gcd g c) g)))
then None
else Some ((makeCuttingPlane e),Equal)
| NonEqual -> Some ((e,Z0),op)
Expand All @@ -2323,7 +2344,7 @@ let is_pol_Z0 = function
(** val eval_Psatz0 : z nFormula list -> zWitness -> z nFormula option **)

let eval_Psatz0 =
eval_Psatz Z0 (Zpos XH) Z.add Z.mul zeq_bool Z.leb
eval_Psatz Z0 (Zpos XH) Z.add Z.mul Z.eqb Z.leb

(** val valid_cut_sign : op1 -> bool **)

Expand Down
4 changes: 2 additions & 2 deletions plugins/micromega/micromega.mli
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ module Z :

val compare : z -> z -> comparison

val eqb : z -> z -> bool

val leb : z -> z -> bool

val ltb : z -> z -> bool
Expand All @@ -168,8 +170,6 @@ module Z :
val gcd : z -> z -> z
end

val zeq_bool : z -> z -> bool

type 'c pExpr =
| PEc of 'c
| PEX of positive
Expand Down
2 changes: 2 additions & 0 deletions stdlib/test-suite/bugs/bug_4187.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Axiom proof_admitted : False.
Tactic Notation "admit" := case proof_admitted.
From Stdlib Require Import List.
From Stdlib Require Import Setoid.
From Stdlib Require Import BinNat.
From Stdlib Require Import Sumbool.
Global Set Implicit Arguments.
Global Generalizable All Variables.
Coercion is_true : bool >-> Sortclass.
Expand Down
2 changes: 2 additions & 0 deletions stdlib/test-suite/bugs/bug_5359.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
From Stdlib Require Import Nsatz.
From Stdlib Require Import BinNat.

Goal False.

(* the first (succeeding) goal was reached by clearing one hypothesis in the second goal which overflows 6GB of stack space *)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/test-suite/output/Fixpoint.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Check
end
in f 0.

From Stdlib Require Import ZArith_base Lia.
From Stdlib Require Import BinInt Lia.
Open Scope Z_scope.

Inductive even: Z -> Prop :=
Expand Down
2 changes: 1 addition & 1 deletion stdlib/test-suite/output/Intuition.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From Stdlib Require Import ZArith_base.
From Stdlib Require Import BinInt.
Goal forall m n : Z, (m >= n)%Z -> (m >= m)%Z /\ (m >= n)%Z.
intros; intuition.
Show.
Expand Down
53 changes: 37 additions & 16 deletions stdlib/test-suite/output/MExtraction.out
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ module Pos =
let compare =
compare_cont Eq

(** val eqb : positive -> positive -> bool **)

let rec eqb p q0 =
match p with
| XI p2 -> (match q0 with
| XI q1 -> eqb p2 q1
| _ -> false)
| XO p2 -> (match q0 with
| XO q1 -> eqb p2 q1
| _ -> false)
| XH -> (match q0 with
| XH -> true
| _ -> false)

(** val of_succ_nat : nat -> positive **)

let rec of_succ_nat = function
Expand Down Expand Up @@ -560,6 +574,20 @@ module Z =
| Lt -> true
| _ -> false

(** val eqb : z -> z -> bool **)

let eqb x y =
match x with
| Z0 -> (match y with
| Z0 -> true
| _ -> false)
| Zpos p -> (match y with
| Zpos q0 -> Pos.eqb p q0
| _ -> false)
| Zneg p -> (match y with
| Zneg q0 -> Pos.eqb p q0
| _ -> false)

(** val max : z -> z -> z **)

let max n0 m =
Expand Down Expand Up @@ -662,13 +690,6 @@ module Z =
| Zneg b0 -> Zpos (Coq_Pos.gcd a0 b0))
end

(** val zeq_bool : z -> z -> bool **)

let zeq_bool x y =
match Z.compare x y with
| Eq -> true
| _ -> false

type 'c pExpr =
| PEc of 'c
| PEX of positive
Expand Down Expand Up @@ -2126,7 +2147,7 @@ type q = { qnum : z; qden : positive }
(** val qeq_bool : q -> q -> bool **)

let qeq_bool x y =
zeq_bool (Z.mul x.qnum (Zpos y.qden)) (Z.mul y.qnum (Zpos x.qden))
Z.eqb (Z.mul x.qnum (Zpos y.qden)) (Z.mul y.qnum (Zpos x.qden))

(** val qle_bool : q -> q -> bool **)

Expand Down Expand Up @@ -2234,12 +2255,12 @@ type zWitness = z psatz
(** val zWeakChecker : z nFormula list -> z psatz -> bool **)

let zWeakChecker =
check_normalised_formulas Z0 (Zpos XH) Z.add Z.mul zeq_bool Z.leb
check_normalised_formulas Z0 (Zpos XH) Z.add Z.mul Z.eqb Z.leb

(** val psub1 : z pol -> z pol -> z pol **)

let psub1 =
psub0 Z0 Z.add Z.sub Z.opp zeq_bool
psub0 Z0 Z.add Z.sub Z.opp Z.eqb

(** val popp1 : z pol -> z pol **)

Expand All @@ -2249,22 +2270,22 @@ let popp1 =
(** val padd1 : z pol -> z pol -> z pol **)

let padd1 =
padd0 Z0 Z.add zeq_bool
padd0 Z0 Z.add Z.eqb

(** val normZ : z pExpr -> z pol **)

let normZ =
norm Z0 (Zpos XH) Z.add Z.mul Z.sub Z.opp zeq_bool
norm Z0 (Zpos XH) Z.add Z.mul Z.sub Z.opp Z.eqb

(** val zunsat : z nFormula -> bool **)

let zunsat =
check_inconsistent Z0 zeq_bool Z.leb
check_inconsistent Z0 Z.eqb Z.leb

(** val zdeduce : z nFormula -> z nFormula -> z nFormula option **)

let zdeduce =
nformula_plus_nformula Z0 Z.add zeq_bool
nformula_plus_nformula Z0 Z.add Z.eqb

(** val xnnormalise : z formula -> z nFormula **)

Expand Down Expand Up @@ -2381,7 +2402,7 @@ let genCuttingPlane = function
| Equal ->
let g,c = zgcd_pol e in
if (&&) (Z.gtb g Z0)
((&&) (negb (zeq_bool c Z0)) (negb (zeq_bool (Z.gcd g c) g)))
((&&) (negb (Z.eqb c Z0)) (negb (Z.eqb (Z.gcd g c) g)))
then None
else Some ((makeCuttingPlane e),Equal)
| NonEqual -> Some ((e,Z0),op)
Expand All @@ -2404,7 +2425,7 @@ let is_pol_Z0 = function
(** val eval_Psatz0 : z nFormula list -> zWitness -> z nFormula option **)

let eval_Psatz0 =
eval_Psatz Z0 (Zpos XH) Z.add Z.mul zeq_bool Z.leb
eval_Psatz Z0 (Zpos XH) Z.add Z.mul Z.eqb Z.leb

(** val valid_cut_sign : op1 -> bool **)

Expand Down
2 changes: 1 addition & 1 deletion stdlib/test-suite/output/MExtraction.v
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Recursive Extraction
ZMicromega.cnfZ ZMicromega.Zeval_const QMicromega.cnfQ
List.map simpl_cone (*map_cone indexes*)
denorm QArith_base.Qpower vm_add
normZ normQ normQ n_of_Z N.of_nat ZTautoChecker ZWeakChecker QTautoChecker RTautoChecker find.
normZ normQ normQ Z.to_N N.of_nat ZTautoChecker ZWeakChecker QTautoChecker RTautoChecker find.

(* Local Variables: *)
(* coding: utf-8 *)
Expand Down
1 change: 1 addition & 0 deletions stdlib/test-suite/success/Nsatz.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

(* compile en user 3m39.915s sur cachalot *)
From Stdlib Require Import BinNat.
From Stdlib Require Import Nsatz.
From Stdlib Require List.
Import List.ListNotations.
Expand Down
3 changes: 1 addition & 2 deletions stdlib/theories/Floats/FloatLemmas.v
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ Proof.
rewrite Bool.andb_true_iff.
intro H'.
destruct H' as (H1,H2).
rewrite Z.eqb_compare in H1.
apply Zeq_bool_eq in H1.
apply Z.eqb_eq in H1.
apply Z.max_case_strong.
1:apply Z.min_case_strong.
- reflexivity.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/theories/Lists/ListTactics.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)

Require Import BinPos.
Require Import BinPosDef.
Require Import List.

Ltac list_fold_right fcons fnil l :=
Expand Down
1 change: 1 addition & 0 deletions stdlib/theories/Numbers/DecimalQ.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
are bijections. *)

Require Import Decimal DecimalFacts DecimalPos DecimalN DecimalZ QArith.
Import PeanoNat.

Lemma of_IQmake_to_decimal num den :
match IQmake_to_decimal num den with
Expand Down
1 change: 1 addition & 0 deletions stdlib/theories/Numbers/DecimalR.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
are bijections. *)

Require Import Decimal DecimalFacts DecimalPos DecimalZ DecimalQ Rdefinitions.
Require Import PeanoNat.

Lemma of_IQmake_to_decimal num den :
match IQmake_to_decimal num den with
Expand Down
Loading

0 comments on commit f1fc014

Please sign in to comment.