Skip to content

Commit

Permalink
Adapt to coq/coq#19530
Browse files Browse the repository at this point in the history
  • Loading branch information
proux01 committed Sep 20, 2024
1 parent 9ce24ee commit 55837a9
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/Algebra/IntegralDomain.v
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ End IntegralDomain.

(** Tactics for polynomial equations over integral domains *)

Require Coq.nsatz.Nsatz.
From Coq Require NsatzTactic.

Ltac dropAlgebraSyntax :=
cbv beta delta [
Expand Down
35 changes: 9 additions & 26 deletions src/Algebra/Nsatz.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,17 @@
periodically check whether we still need it -- once enough bugs get fixed
in mailine, we hope to drop this implementation *)

Require Coq.nsatz.Nsatz.
Require Import Coq.Lists.List.
From Coq Require NsatzTactic.
From Coq Require Import List.
Require Export Crypto.Util.FixCoqMistakes.

(** For compat with https://github.com/coq/coq/pull/12073 *)
Module Nsatz.
Import nsatz.Nsatz.
Notation check_correct := check_correct.
Ltac Nsatz_nsatz := nsatz.
Ltac nsatz := Nsatz_nsatz.
Notation PEevalR := PEevalR.
Notation psos_r1 := psos_r1.
Notation psos_r1b := psos_r1b.
End Nsatz.

Generalizable All Variables.
Lemma cring_sub_diag_iff {R zero eq sub} `{cring:Cring.Cring (R:=R) (ring0:=zero) (ring_eq:=eq) (sub:=sub)}
: forall x y, eq (sub x y) zero <-> eq x y.
Proof.
split;intros Hx.
{ eapply Nsatz.psos_r1b. eapply Hx. }
{ eapply Nsatz.psos_r1. eapply Hx. }
{ eapply NsatzTactic.psos_r1b. eapply Hx. }
{ eapply NsatzTactic.psos_r1. eapply Hx. }
Qed.

Ltac get_goal := lazymatch goal with |- ?g => g end.
Expand Down Expand Up @@ -54,15 +43,9 @@ Ltac nsatz_get_reified_goal reified_package :=
lazymatch reified_package with (_, _, ?goal) => goal end.

Require Import Coq.setoid_ring.Ring_polynom.
(* Kludge for 8.4/8.5 compatibility *)
Module Import mynsatz_compute.
Import nsatz.Nsatz.
Global Ltac mynsatz_compute x := nsatz_compute x.
End mynsatz_compute.
Ltac nsatz_compute x := mynsatz_compute x.

Ltac nsatz_compute_to_goal sugar nparams reified_goal power reified_givens :=
nsatz_compute (PEc sugar :: PEc nparams :: PEpow reified_goal power :: reified_givens).
NsatzTactic.nsatz_compute (PEc sugar :: PEc nparams :: PEpow reified_goal power :: reified_givens).

Ltac nsatz_compute_get_leading_coefficient :=
lazymatch goal with
Expand Down Expand Up @@ -111,15 +94,15 @@ Ltac nsatz_domain_sugar_power domain sugar power :=
nsatz_rewrite_and_revert domain;
let reified_package := nsatz_reify_equations eq zero in
let fv := nsatz_get_free_variables reified_package in
let interp := constr:(@Nsatz.PEevalR _ _ _ _ _ _ _ _ Fops fv) in
let interp := constr:(@NsatzTactic.PEevalR _ _ _ _ _ _ _ _ Fops fv) in
let reified_givens := nsatz_get_reified_givens reified_package in
let reified_goal := nsatz_get_reified_goal reified_package in
nsatz_compute_to_goal sugar nparams reified_goal power reified_givens;
let a := nsatz_compute_get_leading_coefficient in
let crt := nsatz_compute_get_certificate in
intros _ (* discard [nsatz_compute] output *); intros;
apply (fun Haa refl cond => @Integral_domain.Rintegral_domain_pow _ _ _ _ _ _ _ _ _ _ _ domain (interp a) _ (BinNat.N.to_nat power) Haa (@Nsatz.check_correct _ _ _ _ _ _ _ _ _ _ FCring fv reified_givens (PEmul a (PEpow reified_goal power)) crt refl cond));
[ nsatz_nonzero; cbv iota beta delta [Nsatz.PEevalR PEeval InitialRing.gen_phiZ InitialRing.gen_phiPOS]
apply (fun Haa refl cond => @Integral_domain.Rintegral_domain_pow _ _ _ _ _ _ _ _ _ _ _ domain (interp a) _ (BinNat.N.to_nat power) Haa (@NsatzTactic.check_correct _ _ _ _ _ _ _ _ _ _ FCring fv reified_givens (PEmul a (PEpow reified_goal power)) crt refl cond));
[ nsatz_nonzero; cbv iota beta delta [NsatzTactic.PEevalR PEeval InitialRing.gen_phiZ InitialRing.gen_phiPOS]
| solve [vm_cast_no_check (eq_refl true)] (* if this fails, the prover returned a bad certificate *)
| solve [repeat (split; [assumption|]); exact I] ]
end.
Expand Down Expand Up @@ -182,7 +165,7 @@ Module Export Hints.
Ncring_initial.gen_phiZ_morph
Ncring_initial.multiplication_phi_ring
.
Import nsatz.Nsatz.
Import NsatzTactic.
Global Existing Instances
Qops
Qri
Expand Down
8 changes: 4 additions & 4 deletions src/Arithmetic/ModularArithmeticTheorems.v
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Require Import Coq.micromega.Lia Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
From Coq Require Import Lia Morphisms Morphisms_Prop.
Require Import Crypto.Spec.ModularArithmetic.
Require Import Crypto.Arithmetic.ModularArithmeticPre.

Require Import Coq.ZArith.BinInt Coq.ZArith.Zdiv Coq.ZArith.Znumtheory Coq.NArith.NArith. (* import Zdiv before Znumtheory *)
Require Import Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop Coq.Setoids.Setoid.
Require Export Coq.setoid_ring.Ring_theory Coq.setoid_ring.Ring_tac.
From Coq Require Import BinInt Zdiv Znumtheory NArith. (* import Zdiv before Znumtheory *)
From Coq Require Import Morphisms Morphisms_Prop Setoid.
From Coq Require Export InitialRing Ring_theory Ring_tac NArithRing.

Require Import Crypto.Algebra.Hierarchy Crypto.Algebra.ScalarMult.
Require Crypto.Algebra.Ring Crypto.Algebra.Field.
Expand Down
2 changes: 1 addition & 1 deletion src/Arithmetic/PrimeFieldTheorems.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Require Export Crypto.Spec.ModularArithmetic.
Require Export Crypto.Arithmetic.ModularArithmeticTheorems.
Require Export Coq.setoid_ring.Ring_theory Coq.setoid_ring.Field_theory Coq.setoid_ring.Field_tac.

Require Import Coq.nsatz.Nsatz.
From Coq Require Import NsatzTactic.
Require Import Coq.micromega.Lia Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
Require Import Crypto.Arithmetic.ModularArithmeticPre.
Require Import Crypto.Util.NumTheoryUtil.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/MapBaseType.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Crypto.Compilers.SmartMap.
Require Import Crypto.Compilers.Syntax.
Require Import Crypto.Compilers.ExprInversion.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/MapBaseTypeWf.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Crypto.Compilers.SmartMap.
Require Import Crypto.Compilers.Syntax.
Require Import Crypto.Compilers.Wf.
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/Named/AListContext.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(** * Context made from an associative list, without modules *)
Require Import Coq.Bool.Sumbool.
Require Import Coq.Lists.List.
From Coq Require Import Sumbool.
From Coq Require Import List.
Require Import Crypto.Compilers.Named.Context.
Require Import Crypto.Compilers.Named.ContextDefinitions.
Require Import Crypto.Util.Tactics.BreakMatch.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Named/FMapContext.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Coq.FSets.FMapInterface.
Require Import Coq.FSets.FMapFacts.
Require Import Crypto.Compilers.Named.Context.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Named/MapCast.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Crypto.Compilers.SmartMap.
Require Import Crypto.Compilers.Syntax.
Require Import Crypto.Compilers.Named.Context.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Named/MapCastInterp.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.Classes.RelationClasses Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Coq.Logic.Eqdep_dec.
Require Import Crypto.Compilers.SmartMap.
Require Import Crypto.Compilers.Relations.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Named/MapCastWf.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.Classes.RelationClasses Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Coq.Logic.Eqdep_dec.
Require Import Crypto.Compilers.SmartMap.
Require Import Crypto.Compilers.Relations.
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Named/MapType.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Crypto.Compilers.SmartMap.
Require Import Crypto.Compilers.Syntax.
Require Import Crypto.Compilers.Named.Syntax.
Expand Down
2 changes: 1 addition & 1 deletion src/Primitives/MxDHRepChange.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Require Import Coq.Lists.SetoidList.
From Coq Require Import SetoidList.
Require Import Crypto.Spec.MxDH.
Require Import Crypto.Algebra.Monoid Crypto.Algebra.Group Crypto.Algebra.Ring Crypto.Algebra.Field.
Require Import Crypto.Util.Tuple Crypto.Util.Prod.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/AdditionChainExponentiation.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.funind.FunInd.
Require Import Coq.Lists.List Coq.Lists.SetoidList. Import ListNotations.
From Coq Require Import List SetoidList. Import ListNotations.
Require Import Coq.Numbers.BinNums Coq.NArith.BinNat.
Require Import Crypto.Util.ListUtil.
Require Import Crypto.Algebra.Monoid Crypto.Algebra.ScalarMult.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Factorize.v
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Require Import Coq.Bool.Sumbool.
From Coq Require Import Sumbool.
Require Import Coq.micromega.Psatz Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
Require Import Coq.NArith.NArith.
Require Import Coq.PArith.PArith.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ListUtil.v
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ Hint Rewrite <- @firstn_update_nth : pull_firstn.
#[global]
Hint Rewrite <- @firstn_update_nth : push_update_nth.

Require Import Coq.Lists.SetoidList.
From Coq Require Import SetoidList.
Global Instance Proper_nth_default : forall A eq,
Proper (eq==>eqlistA eq==>Logic.eq==>eq) (nth_default (A:=A)).
Proof.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ListUtil/SetoidList.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Require Import Coq.Lists.List.
Require Import Coq.Setoids.Setoid.
Require Import Coq.Lists.SetoidList.
From Coq Require Import SetoidList.
Require Import Crypto.Util.Option.

Import ListNotations.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/MSetPositive/Facts.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Require Import Coq.Setoids.Setoid.
Require Import Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop.
Require Import Coq.Lists.List.
Require Import Coq.Lists.SetoidList.
From Coq Require Import SetoidList.
Require Import Coq.MSets.MSetPositive.
Require Import Coq.MSets.MSetFacts.
Require Import Crypto.Util.Tactics.BreakMatch.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Tuple.v
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ Proof.
repeat intro; subst; auto; reflexivity.
Qed.

Require Import Coq.Lists.SetoidList.
From Coq Require Import SetoidList.

Global Instance fieldwise'_Proper
: forall {n A B}, Proper (pointwise_relation _ (pointwise_relation _ impl) ==> eq ==> eq ==> impl) (@fieldwise' A B n) | 10.
Expand Down

0 comments on commit 55837a9

Please sign in to comment.