Skip to content

Inline binder_constr#21671

Open
SkySkimmer wants to merge 5 commits intorocq-prover:masterfrom
SkySkimmer:binder-constr
Open

Inline binder_constr#21671
SkySkimmer wants to merge 5 commits intorocq-prover:masterfrom
SkySkimmer:binder-constr

Conversation

@SkySkimmer
Copy link
Contributor

cf #21670

However this is not backwards compatible AFAICT so not sure how to work from here.

@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 24, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 24, 2026
@proux01
Copy link
Contributor

proux01 commented Feb 26, 2026

Maybe we should just add the warning for now (something like "due to a bug, this notation at level 200 is actually put at level 10, the bug will be fixed in a future version, use an 'at level 10' to keep the current level 10") and then go through the usual deprecation process to fix the error?

@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 26, 2026
@SkySkimmer SkySkimmer added this to the 9.3+rc1 milestone Feb 26, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 26, 2026
@SkySkimmer
Copy link
Contributor Author

I think this works (I ran the test suite and it passed on the first commit ie with only 1 real change needed (and 2 Print Grammar output changes))

@SkySkimmer SkySkimmer marked this pull request as ready for review February 26, 2026 14:44
@SkySkimmer SkySkimmer requested review from a team as code owners February 26, 2026 14:44
@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 26, 2026
@SkySkimmer SkySkimmer requested review from a team as code owners February 26, 2026 14:57
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 26, 2026
@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 27, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 27, 2026
@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 27, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 27, 2026
@SkySkimmer
Copy link
Contributor Author

fcl is defining some weird notations that conflict with application

@coqbot ci minimize ci-mtac2 ci-mathcomp

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 27, 2026

I am now running minimization at commit 7ed94dd on requested targets ci-mtac2, ci-mathcomp. I'll come back to you with the results once it's done.

@JasonGross
Copy link
Member

fcl is defining some weird notations that conflict with application

My guess is the notations can be made only printing without causing much issue.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 27, 2026

Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/mtac2/theories/tactics/TacticsBase.v in 25m 32s (from ci-mtac2) (full log on GitHub Actions - verbose log)

We are collecting data on the user experience of the Coq Bug Minimizer.
If you haven't already filled the survey for this PR, please fill out our short survey!

🌟 Minimized Coq File (consider adding this file to the test-suite)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-bt" "-w" "-unrecognized-unicode" "-w" "-deprecated-native-compiler-option" "-native-compiler" "ondemand" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/mtac2/theories" "Mtac2" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/mtac2/tests" "Mtac2Tests" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2" "Ltac2" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Stdlib" "Stdlib" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Unicoq" "Unicoq" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/mtac2/src" "-top" "Mtac2.tactics.TacticsBase") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 582 lines to 8 lines, then from 22 lines to 182 lines, then from 188 lines to 14 lines, then from 28 lines to 1258 lines, then from 1253 lines to 52 lines, then from 67 lines to 52 lines, then from 67 lines to 23 lines, then from 38 lines to 22 lines *)
(* coqc version 9.3+alpha compiled with OCaml 4.14.2
   coqtop version 9.3+alpha
   Expected coqc runtime on this file: 0.092 sec
   Expected coqc peak memory usage on this file: 106536.0 kb *)
CoInductive t (a : Type) : Prop := mkt : t a.

Definition bind : forall {A : Type} {B : Type}, t A -> (A -> t B) -> t B.
Admitted.

Declare Scope M_scope.
  Open Scope M_scope.

  Notation "r '<-' t1 ';' t2" := (bind t1 (fun r=> t2))
    (at level 20, t1 at level 100, t2 at level 200,
     right associativity, format "'[' r  '<-'  '[' t1 ;  ']' ']' '/' t2 ") : M_scope.

  Notation "'mif' b 'then' t 'else' u" :=
    (cond <- b; if cond then t else u)
      (at level 200,
       format "'[hv' 'mif'  '/  ' '[' b ']'  '/' 'then'  '/  ' '[' t ']'  '/' 'else'  '/  ' '[' u ']' ']'"
      ) : M_scope.

  Notation "'mif' b 'then' t 'else' u" :=
    (cond <- b; if cond then t else u) (at level 200) : tactic_scope.
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 6.0MiB file on GitHub Actions Artifacts under build.log)
characters 4-20
Called from Stm.process_transaction in file "stm/stm.ml", line 2541, characters 25-92
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Stm.handle_failure in file "stm/stm.ml", line 2389, characters 2-26
Called from Vernac.interp_vernac in file "toplevel/vernac.ml", line 80, characters 28-90
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Flags.with_modified_ref.scope in file "lib/flags.ml" (inlined), line 20, characters 32-35
Called from Memprof_coq.Masking.with_resource.(fun) in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 58-65
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 33, characters 8-15
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Flags.with_modified_ref in file "lib/flags.ml" (inlined), line 21, characters 2-62
Called from Flags.with_modified_ref in file "lib/flags.ml" (inlined), line 21, characters 2-62
Called from Flags.with_option in file "lib/flags.ml" (inlined), line 23, characters 24-78
Called from Flags.silently in file "lib/flags.ml", line 50, characters 19-40
Re-raised at Stdlib__Fun.protect in file "fun.ml" (inlined), line 38, characters 6-52
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Flags.with_modified_ref in file "lib/flags.ml" (inlined), line 21, characters 2-62
Called from Flags.with_option in file "lib/flags.ml" (inlined), line 23, characters 24-78
Called from Flags.silently in file "lib/flags.ml", line 50, characters 19-40
Called from Util.try_finally in file "lib/util.ml" (inlined), line 140, characters 2-5
Called from Memprof_coq.Masking.with_resource.(fun) in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 58-65
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 33, characters 8-15
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Memprof_coq.Resource_bind.let& in file "clib/memprof_coq.std.ml" (inlined), line 4, characters 25-33
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Memprof_coq.Resource_bind.let& in file "clib/memprof_coq.std.ml" (inlined), line 4, characters 25-33
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Vernac.load_vernac_core.loop in file "toplevel/vernac.ml" (inlined), line 135, characters 8-774
Called from Vernac.load_vernac_core.loop in file "toplevel/vernac.ml", line 135, characters 8-774
Re-raised at Stdlib__Fun.protect in file "fun.ml" (inlined), line 38, characters 6-52
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Memprof_coq.Resource_bind.let& in file "clib/memprof_coq.std.ml" (inlined), line 4, characters 25-33
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Vernac.load_vernac_core.loop in file "toplevel/vernac.ml", line 135, characters 8-774
Called from Vernac.load_vernac_core.loop in file "toplevel/vernac.ml" (inlined), line 111, characters 15-1023
Called from Vernac.load_vernac_core.loop in file "toplevel/vernac.ml" (inlined), line 111, characters 15-1023
Called from Vernac.load_vernac_core in file "toplevel/vernac.ml", line 158, characters 6-16
Re-raised at Exninfo.iraise in file "clib/exninfo.ml", line 81, characters 4-38
Called from Util.try_finally in file "lib/util.ml" (inlined), line 140, characters 2-5
Called from Memprof_coq.Masking.with_resource.(fun) in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 58-65
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 33, characters 8-15
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Memprof_coq.Resource_bind.let& in file "clib/memprof_coq.std.ml" (inlined), line 4, characters 25-33
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Memprof_coq.Resource_bind.let& in file "clib/memprof_coq.std.ml" (inlined), line 4, characters 25-33
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.try_finally in file "lib/util.ml", line 139, characters 2-43
Re-raised at Stdlib__Fun.protect in file "fun.ml" (inlined), line 38, characters 6-52
Called from Memprof_coq.Masking.with_resource in file "clib/memprof_coq.std.ml" (inlined), line 51, characters 4-66
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Util.with_finally in file "lib/util.ml" (inlined), line 135, characters 2-56
Called from Memprof_coq.Resource_bind.let& in file "clib/memprof_coq.std.ml" (inlined), line 4, characters 25-33
Called from Util.try_finally in file "lib/util.ml" (inlined), line 139, characters 2-43
Called from Util.try_finally in file "lib/util.ml", line 139, characters 2-43
Called from Ccompile.compile in file "toplevel/ccompile.ml", line 64, characters 18-82
Called from Coqc.coqc_main in file "toplevel/coqc.ml", line 38, characters 2-100


Command exited with non-zero status 1
theories/tactics/TacticsBase.vo (real: 0.37, user: 0.28, sys: 0.09, mem: 415956 ko)
make[1]: *** [Makefile:815: theories/tactics/TacticsBase.vo] Error 1
make[1]: *** [theories/tactics/TacticsBase.vo] Deleting file 'theories/tactics/TacticsBase.glob'
make: *** [Makefile:411: all] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' mtac2 2
+ '[' mtac2 '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real _build_ci/mtac2.log
    Time |  Peak Mem | File Name                   
---------------------------------------------------
0m03.28s | 415956 ko | Total Time / Peak Mem       
---------------------------------------------------
0m00.77s |  67224 ko | meta/MTeleMatch.vo.native   
0m00.59s |  67508 ko | meta/MTeleMatchDef.vo.native
0m00.37s | 415956 ko | tactics/TacticsBase.vo      
0m00.34s |  68608 ko | meta/MFixDef.vo.native      
0m00.30s | 297080 ko | meta/MTeleMatch.vo          
0m00.27s |  69444 ko | Base.vo.native              
0m00.23s | 266972 ko | meta/MTeleMatchDef.vo       
0m00.21s | 211624 ko | Base.vo                     
0m00.20s | 220664 ko | meta/MFixDef.vo             
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 932KiB file on GitHub Actions Artifacts under bug.log)
definitions
One-line definition splitting unsuccessful.

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to remove all lines, one at a time
Line removal successful

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to remove modules
�[92m
Module removal successful.�[0m
Failed to do everything at once; trying one at a time.
Module removal unsuccessful.
No successful changes.

I will now attempt to remove sections
�[92m
Section removal successful.�[0m
Failed to do everything at once; trying one at a time.
Section removal unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined.
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined. with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to add Proof using lines
�[92m
Adding Proof using lines successful.�[0m
Failed to do everything at once; trying one at a time.
Adding Proof using lines unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to remove all lines, one at a time
Line removal unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to remove modules
�[92m
Module removal successful.�[0m
Failed to do everything at once; trying one at a time.
Module removal unsuccessful.
No successful changes.

I will now attempt to remove sections
�[92m
Section removal successful.�[0m
Failed to do everything at once; trying one at a time.
Section removal unsuccessful.
No successful changes.

I will now attempt to remove empty sections

No empty sections to remove.

I will now attempt to remove the admit tactic header

No admit tactic header to remove

Now, I will attempt to strip repeated newlines and trailing spaces from this file...

No strippable newlines or spaces.

Completed second minimization pass.

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 27, 2026

Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.v in 5h 15m 8s (from ci-mathcomp) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-w" "+duplicate-clear" "-w" "+non-primitive-record" "-w" "+undeclared-scope" "-w" "+deprecated-hint-without-locality" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-projection-no-head-constant" "-w" "-redundant-canonical-projection" "-w" "-notation-overridden" "-w" "-ambiguous-paths" "-w" "-elpi.add-const-for-axiom-or-sectionvar" "-w" "-mathcomp-subset-itv" "-w" "+level-tolerance" "-w" "-notation-for-abbreviation" "-w" "-deprecated-native-compiler-option" "-native-compiler" "ondemand" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "mathcomp" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/HB" "HB" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2" "Ltac2" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi" "elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_elpi" "elpi_elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_examples" "elpi_examples" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "-top" "mathcomp.algebra.num_theory.numdomain") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2712 lines to 251 lines *)
(* coqc version 9.3+alpha compiled with OCaml 4.14.2
   coqtop version 9.3+alpha
   Expected coqc runtime on this file: 13.314 sec
   Expected coqc peak memory usage on this file: 1015924.0 kb *)











Require Corelib.ssr.ssreflect.
Require Corelib.BinNums.PosDef.
Require Corelib.ssr.ssrfun.
Require Corelib.ssr.ssrbool.
Require Corelib.Init.Ltac.
Require elpi_elpi.dummy.
Require mathcomp.boot.ssrnotations.
Require elpi.elpi.
Require mathcomp.boot.ssreflect.
Require elpi.apps.locker.locker.
Require mathcomp.boot.ssrfun.
Require HB.structures.
Require mathcomp.boot.ssrbool.
Require mathcomp.boot.eqtype.
Require mathcomp.boot.ssrnat.
Require mathcomp.boot.seq.
Require mathcomp.boot.choice.
Require mathcomp.boot.div.
Require mathcomp.boot.path.
Require mathcomp.boot.fintype.
Require mathcomp.boot.tuple.
Require mathcomp.boot.finfun.
Require mathcomp.boot.bigop.
Require mathcomp.boot.finset.
Require mathcomp.boot.monoid.
Require mathcomp.boot.prime.
Require mathcomp.boot.nmodule.
Require mathcomp.boot.binomial.
Require mathcomp.order.preorder.
Require mathcomp.fingroup.fingroup.
Require mathcomp.order.order.
Require mathcomp.algebra.alg.algebra.
Require mathcomp.algebra.alg.divalg.
Require mathcomp.algebra.interval.
Require mathcomp.algebra.alg.decfield.
Require mathcomp.algebra.alg.ssralg.
Require mathcomp.algebra.num_theory.orderedzmod.
Require mathcomp.algebra.countalg.
Require mathcomp.algebra.poly.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.
Import HB.structures.
Import mathcomp.boot.ssreflect.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.ssrnat.
Import mathcomp.boot.seq.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.bigop.
Import mathcomp.boot.finset.
Import mathcomp.fingroup.fingroup.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.interval.
Import mathcomp.algebra.alg.algebra.
Import mathcomp.algebra.alg.divalg.
Import mathcomp.algebra.poly.
Import mathcomp.algebra.num_theory.orderedzmod.



































Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Local Open Scope ring_scope.
Import Order.TTheory.
Import GRing.Theory.
Import orderedzmod.Num.

Module Export Num.

HB.mixin Record Zmodule_isSemiNormed (R : POrderZmodule.type) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.

#[short(type="semiNormedZmodType")]
HB.structure Definition SemiNormedZmodule (R : porderZmodType) :=
  { M of Zmodule_isSemiNormed R M & GRing.Zmodule M }.

HB.mixin Record SemiNormedZmodule_isPositiveDefinite
    (R : POrderZmodule.type) M & @SemiNormedZmodule R M := {
  normr0_eq0 : forall x : M, norm x = 0 -> x = 0;
}.

#[short(type="normedZmodType")]
HB.structure Definition NormedZmodule (R : porderZmodType) :=
  { M of SemiNormedZmodule_isPositiveDefinite R M & SemiNormedZmodule R M }.
Arguments norm {R M} x : rename.

HB.factory Record Zmodule_isNormed (R : porderZmodType) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normr0_eq0 : forall x, norm x = 0 -> x = 0;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.
HB.builders Context (R : POrderZmodule.type) M & Zmodule_isNormed R M.
  HB.instance Definition _ :=
    Zmodule_isSemiNormed.Build R M ler_normD normrMn normrN.
  HB.instance Definition _ :=
    SemiNormedZmodule_isPositiveDefinite.Build R M normr0_eq0.
HB.end.

Module Export NormedZmoduleExports.
Bind Scope ring_scope with NormedZmodule.sort.

End NormedZmoduleExports.
HB.export NormedZmoduleExports.

HB.structure Definition POrderSemiNormedZmodule (R : porderZmodType) :=
  { M of POrderZmodule M & Zmodule_isSemiNormed R M}.

HB.structure Definition POrderNormedZmodule (R : porderZmodType) :=
  { M of POrderZmodule M & Zmodule_isNormed R M}.

HB.structure Definition POrderedSemiNormedZmodule (R : porderZmodType) :=
  { M of POrderedZmodule M & Zmodule_isSemiNormed R M}.

HB.structure Definition POrderedNormedZmodule (R : porderZmodType) :=
  { M of POrderedZmodule M & Zmodule_isNormed R M}.

HB.mixin Record NumZmod_isNumRing R & GRing.NzRing R & POrderZmodule R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.

#[short(type="numDomainType")]
HB.structure Definition NumDomain := { R of
     GRing.IntegralDomain R &
     NumZmodule R &
     NormedZmodule (POrderZmodule.clone R _) R &
     NumZmod_isNumRing R
  }.
Arguments addr_gt0 {_} [x y] : rename.
Arguments ger_leVge {_} [x y] : rename.

HB.factory Record isNumRing R & GRing.NzRing R & POrderZmodule R
  & GRing.IntegralDomain R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.
HB.builders Context R & isNumRing R.

Fact ler_wD2l (x : R) : {homo +%R x : y z / y <= z}.
Admitted.

HB.instance Definition _ := Add_isHomo.Build R ler_wD2l.
HB.end.

Section NumDomainDef.

End NumDomainDef.

Section ExtensionAxioms.

End ExtensionAxioms.

Section NumDomain.

End NumDomain.

Section NumIntegralDomainTheory.

Section SemiNormedZmoduleTheory.

End SemiNormedZmoduleTheory.

Section NormedZmoduleTheory.

End NormedZmoduleTheory.

End NumIntegralDomainTheory.

Section NumDomainOperationTheory.

Variable R : numDomainType.

Section RealDomainArgExtremum.

End RealDomainArgExtremum.

Lemma leif_AGM_scaled (I : finType) (A : {pred I}) (E : I -> R) (n := #|A|) :
    {in A, forall i, 0 <= E i *+ n} ->
  \prod_(i in A) (E i *+ n) <= (\sum_(i in A) E i) ^+ n
                            ?= iff [forall i in A, forall j in A, E i == E j].
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 4.0MiB file on GitHub Actions Artifacts under build.log)
 '[' '' ']'
+ COQ_CI_COLOR=
+ export GIT_PAGER=
+ GIT_PAGER=
+ '[' '' = 1 ']'
+ '[' '' = 1 ']'
+ bash /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-mathcomp.sh
+ tee _build_ci/mathcomp.log
++ set -e
++ : 2
++ export NJOBS
+++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-common.sh
++ . /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ which cygpath
+++ OCAMLFINDSEP=:
+++ '[' /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh ']'
++++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ root=/github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ cd /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ echo /builds/coq/coq
+++ root=/builds/coq/coq
+++ '[' -n 1 ']'
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ export OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
+++ export CI_BRANCH=
+++ CI_BRANCH=
+++ [[ '' =~ ^[0-9]*$ ]]
+++ export CI_PULL_REQUEST=
+++ CI_PULL_REQUEST=
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ declare -A overlays
++ set +x
+ git_download mathcomp
+ local project=mathcomp
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local giturl_var=mathcomp_CI_GITURL
+ local giturl=https://github.com/math-comp/math-comp
+ local ref_var=mathcomp_CI_REF
+ local ref=master
+ local parent_project_var=mathcomp_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=mathcomp_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp ']'
+ echo 'Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.'
Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.
+ '[' '' ']'
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ make
+ '[' -z x ']'
+ command make
"/github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq" makefile  -f Make -o Makefile.coq
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
         use ROCQRUNTIMELIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
make -f Makefile.coq --no-print-directory
ROCQ compile algebra/num_theory/numdomain.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////rocq
MINIMIZER_DEBUG_EXTRA: original invocation: '' 
MINIMIZER_DEBUG_EXTRA: new invocation: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: ocamlpath: /github/workspace/builds/coq/coq-failing/_install_ci/lib:
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqlib: Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.U1FCX7L1qx
MINIMIZER_DEBUG: files:  algebra/num_theory/numdomain.v /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.vWarning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]Warning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "./algebra/num_theory/numdomain.v", line 1904, characters 63-76:
Error: In term, tolerating this expression at a higher level than expected by
the notation started on the left. This tolerance will be eventually removed.
Insert parentheses or try to lower the level at which the top symbol of this
expression is parsed.
[level-tolerance,deprecated-since-9.2,deprecated,parsing,default]

Command exited with non-zero status 1
algebra/num_theory/numdomain.vo (real: 18.65, user: 18.41, sys: 0.17, mem: 1085240 ko)
make[2]: *** [Makefile.coq:815: algebra/num_theory/numdomain.vo] Error 1
make[2]: *** [algebra/num_theory/numdomain.vo] Deleting file 'algebra/num_theory/numdomain.glob'
make[1]: *** [Makefile.coq:411: all] Error 2
make: *** [Makefile.common:99: this-build] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' mathcomp 2
+ '[' mathcomp '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real _build_ci/mathcomp.log
    Time |   Peak Mem | File Name                      
-------------------------------------------------------
0m18.65s | 1085240 ko | Total Time / Peak Mem          
-------------------------------------------------------
0m18.65s | 1085240 ko | algebra/num_theory/numdomain.vo
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 59KiB file on GitHub Actions Artifacts under bug.log)
ne 57, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmphlyj0nfq/mathcomp/algebra/num_theory/numdomain.v", line 141, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds
�[92m
Admitting Qeds successful.�[0m
Success!

I will now attempt to replace Qeds with admit. Defined.
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined. with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 57, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 141, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 57, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 141, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 57, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 141, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 57, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpovrhtz46/mathcomp/algebra/num_theory/numdomain.v", line 141, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to add Proof using lines
�[92m
Adding Proof using lines successful.�[0m
Failed to do everything at once; trying one at a time.
Adding Proof using lines unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation successful

I will now attempt to split imports and exports
Import/Export splitting successful

I will now attempt to split := definitions
One-line definition splitting successful

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to remove all lines, one at a time

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 28, 2026

Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.v in 5h 15m 7s (from ci-mathcomp) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout) (truncated to first and last 32KiB; full 41KiB file on GitHub Actions Artifacts under bug.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-w" "+duplicate-clear" "-w" "+non-primitive-record" "-w" "+undeclared-scope" "-w" "+deprecated-hint-without-locality" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-projection-no-head-constant" "-w" "-redundant-canonical-projection" "-w" "-notation-overridden" "-w" "-ambiguous-paths" "-w" "-elpi.add-const-for-axiom-or-sectionvar" "-w" "-mathcomp-subset-itv" "-w" "+level-tolerance" "-w" "-notation-for-abbreviation" "-w" "-deprecated-native-compiler-option" "-native-compiler" "ondemand" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "mathcomp" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/HB" "HB" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2" "Ltac2" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi" "elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_elpi" "elpi_elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_examples" "elpi_examples" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2712 lines to 251 lines, then from 218 lines to 96 lines, then from 110 lines to 1271 lines, then from 1278 lines to 204 lines, then from 218 lines to 1752 lines, then from 1759 lines to 1577 lines *)
(* coqc version 9.3+alpha compiled with OCaml 4.14.2
   coqtop version 9.3+alpha
   Expected coqc runtime on this file: 30.372 sec
   Expected coqc peak memory usage on this file: 1444632.0 kb *)









Require Corelib.Init.Ltac.
Require Corelib.ssr.ssrbool.
Require Corelib.ssr.ssrfun.
Require Corelib.ssr.ssreflect.
Require Corelib.BinNums.PosDef.
Require elpi_elpi.dummy.
Require mathcomp.boot.ssrnotations.
Require elpi.elpi.
Require mathcomp.boot.ssreflect.
Require elpi.apps.locker.locker.
Require mathcomp.boot.ssrfun.
Require HB.structures.
Require mathcomp.boot.ssrbool.
Require mathcomp.boot.eqtype.
Require mathcomp.boot.ssrnat.
Require mathcomp.boot.seq.
Require mathcomp.boot.choice.
Require mathcomp.boot.div.
Require mathcomp.boot.path.
Require mathcomp.boot.fintype.
Require mathcomp.boot.tuple.
Require mathcomp.boot.finfun.
Require mathcomp.boot.bigop.
Require mathcomp.boot.finset.
Require mathcomp.boot.monoid.
Require mathcomp.boot.prime.
Require mathcomp.boot.nmodule.
Require mathcomp.boot.binomial.
Require mathcomp.order.preorder.
Require mathcomp.order.order.
Require mathcomp.algebra.alg.algebra.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.

Module mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Module Export divalg.


Import HB.structures.
Import mathcomp.boot.ssreflect.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.ssrnat.
Import mathcomp.boot.seq.
Import mathcomp.boot.div.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.bigop.
Import mathcomp.boot.prime.
Import mathcomp.boot.nmodule.
Import mathcomp.algebra.alg.algebra.



































































































Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Local Open Scope ring_scope.

Module Import GRing.


Export GRing.

HB.mixin Record NzRing_hasMulInverse R & NzRing R := {
  unit_subdef : pred R;
  inv : R -> R;
  mulVr_subproof : {in unit_subdef, left_inverse 1 inv *%R};
  divrr_subproof : {in unit_subdef, right_inverse 1 inv *%R};
  unitrP_subproof : forall x y, y * x = 1 /\ x * y = 1 -> unit_subdef x;
  invr_out_subproof : {in [predC unit_subdef], inv =1 id}
}.

#[short(type="unitRingType")]
HB.structure Definition UnitRing := {R of NzRing_hasMulInverse R & NzRing R}.

Module Export UnitRingExports.
Bind Scope ring_scope with UnitRing.sort.
End UnitRingExports.
HB.export UnitRingExports.

Definition unit_pred {R : unitRingType} :=
  Eval cbv [ unit_subdef NzRing_hasMulInverse.unit_subdef ] in
    (fun u : R => unit_subdef u).
Arguments unit_pred _ _ /.
Definition unit {R : unitRingType} := [qualify a u : R | unit_pred u].

Local Notation "x ^-1" := (inv x).
Local Notation "x / y" := (x * y^-1).
Local Notation "x ^- n" := ((x ^+ n)^-1).

Section UnitRingTheory.

Variable R : unitRingType.
Implicit Types x y : R.

Lemma divrr : {in unit, right_inverse 1 (@inv R) *%R}.
Admitted.
Definition mulrV := divrr.

Lemma mulVr : {in unit, left_inverse 1 (@inv R) *%R}.
Admitted.

Lemma invr_out x : x \isn't a unit -> x^-1 = x.
Admitted.

Lemma unitrP x : reflect (exists y, y * x = 1 /\ x * y = 1) (x \is a unit).
Admitted.

Lemma mulKr : {in unit, left_loop (@inv R) *%R}.
Admitted.

Lemma mulVKr : {in unit, rev_left_loop (@inv R) *%R}.
Admitted.

Lemma mulrK : {in unit, right_loop (@inv R) *%R}.
Admitted.

Lemma mulrVK : {in unit, rev_right_loop (@inv R) *%R}.
Admitted.
Definition divrK := mulrVK.

Lemma mulrI : {in @unit R, right_injective *%R}.
Admitted.

Lemma mulIr : {in @unit R, left_injective *%R}.
Admitted.


Lemma telescope_prodr n m (f : nat -> R) :
    (forall k, n < k < m -> f k \is a unit) -> n < m ->
  \prod_(n <= k < m) (f k / f k.+1) = f n / f m.
Admitted.

Lemma telescope_prodr_eq n m (f u : nat -> R) : n < m ->
    (forall k, n < k < m -> f k \is a unit) ->
    (forall k, (n <= k < m)%N -> u k = f k / f k.+1) ->
  \prod_(n <= k < m) u k = f n / f m.
Admitted.

Lemma commrV x y : comm x y -> comm x y^-1.
Admitted.

Lemma unitrE x : (x \is a unit) = (x / x == 1).
Admitted.

Lemma invrK : involutive (@inv R).
Admitted.

Lemma invr_inj : injective (@inv R).
Admitted.

Lemma unitrV x : (x^-1 \in unit) = (x \in unit).
Admitted.

Lemma unitr1 : 1 \in @unit R.
Admitted.

Lemma invr1 : 1^-1 = 1 :> R.
Admitted.

Lemma div1r x : 1 / x = x^-1.
Admitted.
Lemma divr1 x : x / 1 = x.
Admitted.

Lemma natr_div m d :
  d %| m -> d%:R \is a @unit R -> (m %/ d)%:R = m%:R / d%:R :> R.
Admitted.

Lemma divrI : {in unit, right_injective (fun x y => x / y)}.
Admitted.

Lemma divIr : {in unit, left_injective (fun x y => x / y)}.
Admitted.

Lemma unitr0 : (0 \is a @unit R) = false.
Admitted.

Lemma invr0 : 0^-1 = 0 :> R.
Admitted.

Lemma unitrN1 : -1 \is a @unit R.
Admitted.

Lemma invrN1 : (-1)^-1 = -1 :> R.
Admitted.

Lemma invr_sign n : ((-1) ^- n) = (-1) ^+ n :> R.
Admitted.

Lemma unitrMl x y : y \is a unit -> (x * y \is a unit) = (x \is a unit).
Admitted.

Lemma unitrMr x y : x \is a unit -> (x * y \is a unit) = (y \is a unit).
Admitted.

Lemma unitr_prod {I : Type} (P : pred I) (E : I -> R) (r : seq I) :
  (forall i, P i -> E i \is a GRing.unit) ->
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma unitr_prod_in {I : eqType} (P : pred I) (E : I -> R) (r : seq I) :
  {in r, forall i, P i -> E i \is a GRing.unit} ->
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma invrM : {in unit &, forall x y, (x * y)^-1 = y^-1 * x^-1}.
Admitted.

Lemma unitrM_comm x y :
  comm x y -> (x * y \is a unit) = (x \is a unit) && (y \is a unit).
Admitted.

Lemma unitrX x n : x \is a unit -> x ^+ n \is a unit.
Admitted.

Lemma unitrX_pos x n : n > 0 -> (x ^+ n \in unit) = (x \in unit).
Admitted.

Lemma exprVn x n : x^-1 ^+ n = x ^- n.
Admitted.

Lemma exprB m n x : n <= m -> x \is a unit -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma invr_neq0 x : x != 0 -> x^-1 != 0.
Admitted.

Lemma invr_eq0 x : (x^-1 == 0) = (x == 0).
Admitted.

Lemma invr_eq1 x : (x^-1 == 1) = (x == 1).
Admitted.

Lemma rev_unitrP (x y : R^c) : y * x = 1 /\ x * y = 1 -> x \is a unit.
Admitted.

#[export]
HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R^c mulrV mulVr rev_unitrP invr_out.

#[export]
HB.instance Definition _ := UnitRing.on R^o.

End UnitRingTheory.

Arguments invrK {R}.
Arguments invr_inj {R} [x1 x2].
Arguments telescope_prodr_eq {R n m} f u.

Lemma rev_prodrV (R : unitRingType)
  (I : Type) (r : seq I) (P : pred I) (E : I -> R) :
  (forall i, P i -> E i \is a GRing.unit) ->
  \prod_(i <- r | P i) (E i)^-1 = ((\prod_(i <- r | P i) (E i : R^c))^-1).
Admitted.

Section UnitRingClosedPredicates.

Variables (R : unitRingType) (S : {pred R}).

Definition invr_closed := {in S, forall x, x^-1 \in S}.
Definition divr_2closed := {in S &, forall x y, x / y \in S}.
Definition divr_closed := 1 \in S /\ divr_2closed.
Definition sdivr_closed := -1 \in S /\ divr_2closed.
Definition divring_closed := [/\ 1 \in S, subr_closed S & divr_2closed].

Lemma divr_closedV : divr_closed -> invr_closed.
Admitted.

Lemma divr_closedM : divr_closed -> mulr_closed S.
Admitted.

Lemma sdivr_closed_div : sdivr_closed -> divr_closed.
Admitted.

Lemma sdivr_closedM : sdivr_closed -> smulr_closed S.
Admitted.

Lemma divring_closedBM : divring_closed -> subring_closed S.
Admitted.

Lemma divring_closed_div : divring_closed -> sdivr_closed.
Admitted.

End UnitRingClosedPredicates.

Section UnitRingMorphism.

Variables (R S : unitRingType) (f : {rmorphism R -> S}).

Lemma rmorph_unit x : x \in unit -> f x \in unit.
Admitted.

Lemma rmorphV : {in unit, {morph f: x / x^-1}}.
Admitted.

Lemma rmorph_div x y : y \in unit -> f (x / y) = f x / f y.
Admitted.

End UnitRingMorphism.

#[short(type="comUnitRingType")]
HB.structure Definition ComUnitRing := {R of ComNzRing R & UnitRing R}.

Module Export ComUnitRingExports.
Bind Scope ring_scope with ComUnitRing.sort.
End ComUnitRingExports.
HB.export ComUnitRingExports.


HB.factory Record ComNzRing_hasMulInverse R & ComNzRing R := {
  unit : {pred R};
  inv : R -> R;
  mulVx : {in unit, left_inverse 1 inv *%R};
  unitPl : forall x y, y * x = 1 -> unit x;
  invr_out : {in [predC unit], inv =1 id}
}.

HB.builders Context R & ComNzRing_hasMulInverse R.

Fact mulC_mulrV : {in unit, right_inverse 1 inv *%R}.
Admitted.

Fact mulC_unitP x y : y * x = 1 /\ x * y = 1 -> unit x.
Admitted.

HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R mulVx mulC_mulrV mulC_unitP invr_out.

HB.end.

#[short(type="unitAlgType")]
HB.structure Definition UnitAlgebra R := {V of NzAlgebra R V & UnitRing V}.

Module Export UnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End UnitAlgebraExports.
HB.export UnitAlgebraExports.

#[short(type="comUnitAlgType")]
HB.structure Definition ComUnitAlgebra R :=
  {V of ComNzAlgebra R V & UnitRing V}.

Module Export ComUnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End ComUnitAlgebraExports.
HB.export ComUnitAlgebraExports.

Section ComUnitRingTheory.

Variable R : comUnitRingType.
Implicit Types x y : R.

Lemma unitrM x y : (x * y \in unit) = (x \in unit) && (y \in unit).
Admitted.

Lemma unitrPr x : reflect (exists y, x * y = 1) (x \in unit).
Admitted.

Lemma mulr1_eq x y : x * y = 1 -> x^-1 = y.
Admitted.

Lemma divr1_eq x y : x / y = 1 -> x = y.
Admitted.

Lemma divKr x : x \is a unit -> {in unit, involutive (fun y => x / y)}.
Admitted.

Lemma expr_div_n x y n : (x / y) ^+ n = x ^+ n / y ^+ n.
Admitted.

Lemma unitr_prodP (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
  reflect {in r, forall i, P i -> E i \is a GRing.unit}
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma prodrV (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
  (forall i, P i -> E i \is a GRing.unit) ->
  \prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Admitted.


#[export] HB.instance Definition _ := ComUnitRing.on R^c.
#[export] HB.instance Definition _ := ComUnitRing.on R^o.


End ComUnitRingTheory.

Section UnitAlgebraTheory.

Variable (R : comUnitRingType) (A : unitAlgType R).
Implicit Types (k : R) (x y : A).

Lemma scaler_injl : {in unit, @right_injective R A A *:%R}.
Admitted.

Lemma scaler_unit k x : k \in unit -> (k *: x \in unit) = (x \in unit).
Admitted.

Lemma invrZ k x : k \in unit -> x \in unit -> (k *: x)^-1 = k^-1 *: x^-1.
Admitted.

Section ClosedPredicates.

Variables S : {pred A}.

Definition divalg_closed := [/\ 1 \in S, linear_closed S & divr_2closed S].

Lemma divalg_closedBdiv : divalg_closed -> divring_closed S.
Admitted.

Lemma divalg_closedZ : divalg_closed -> subalg_closed S.
Admitted.

End ClosedPredicates.

End UnitAlgebraTheory.

Module Export ClosedExports.

Notation invr_closed := invr_closed.
Notation divr_2closed := divr_2closed.
Notation divr_closed := divr_closed.
Notation sdivr_closed := sdivr_closed.
Notation divring_closed := divring_closed.
Notation divalg_closed := divalg_closed.

Coercion divr_closedV : divr_closed >-> invr_closed.
Coercion divr_closedM : divr_closed >-> mulr_closed.
Coercion sdivr_closed_div : sdivr_closed >-> divr_closed.
Coercion sdivr_closedM : sdivr_closed >-> smulr_closed.
Coercion divring_closedBM : divring_closed >-> subring_closed.
Coercion divring_closed_div : divring_closed >-> sdivr_closed.
Coercion divalg_closedBdiv : divalg_closed >-> divring_closed.
Coercion divalg_closedZ : divalg_closed >-> subalg_closed.

End ClosedExports.

Definition integral_domain_axiom (R : pzRingType) :=
  forall x y : R, x * y = 0 -> (x == 0) || (y == 0).

HB.mixin Record ComUnitRing_isIntegral R & ComUnitRing R := {
  mulf_eq0_subproof : integral_domain_axiom R;
}.

#[mathcomp(axiom="integral_domain_axiom"), short(type="idomainType")]
HB.structure Definition IntegralDomain :=
  {R of ComUnitRing_isIntegral R & ComUnitRing R}.

Module Export IntegralDomainExports.
Bind Scope ring_scope with IntegralDomain.sort.
End IntegralDomainExports.
HB.export IntegralDomainExports.

Section IntegralDomainTheory.

Variable R : idomainType.
Implicit Types x y : R.

Lemma mulf_eq0 x y : (x * y == 0) = (x == 0) || (y == 0).
Admitted.

Lemma prodf_eq0 (I : finType) (P : pred I) (F : I -> R) :
  reflect (exists2 i, P i & (F i == 0)) (\prod_(i | P i) F i == 0).
Admitted.

Lemma prodf_seq_eq0 I r (P : pred I) (F : I -> R) :
  (\prod_(i <- r | P i) F i == 0) = has (fun i => P i && (F i == 0)) r.
Admitted.

Lemma mulf_neq0 x y : x != 0 -> y != 0 -> x * y != 0.
Admitted.

Lemma prodf_neq0 (I : finType) (P : pred I) (F : I -> R) :
  reflect (forall i, P i -> (F i != 0)) (\prod_(i | P i) F i != 0).
Admitted.

Lemma prodf_seq_neq0 I r (P : pred I) (F : I -> R) :
  (\prod_(i <- r | P i) F i != 0) = all (fun i => P i ==> (F i != 0)) r.
Admitted.

Lemma expf_eq0 x n : (x ^+ n == 0) = (n > 0) && (x == 0).
Admitted.

Lemma sqrf_eq0 x : (x ^+ 2 == 0) = (x == 0).
Admitted.

Lemma expf_neq0 x m : x != 0 -> x ^+ m != 0.
Admitted.

Lemma natf_neq0_pchar n : (n%:R != 0 :> R) = (pchar R)^'.-nat n.
Admitted.

Lemma natf0_pchar n : n > 0 -> n%:R == 0 :> R -> exists p, p \in pchar R.
Admitted.

Lemma pcharf'_nat n : (pchar R)^'.-nat n = (n%:R != 0 :> R).
Admitted.

Lemma pcharf0P : pchar R =i pred0 <-> (forall n, (n%:R == 0 :> R) = (n == 0)%N).
Admitted.

Lemma eqf_sqr x y : (x ^+ 2 == y ^+ 2) = (x == y) || (x == - y).
Admitted.

Lemma mulfI x : x != 0 -> injective ( *%R x).
Admitted.

Lemma mulIf x : x != 0 -> injective ( *%R^~ x).
Admitted.

Lemma divfI x : x != 0 -> injective (fun y => x / y).
Admitted.

Lemma divIf y : y != 0 -> injective (fun x => x / y).
Admitted.

Lemma sqrf_eq1 x : (x ^+ 2 == 1) = (x == 1) || (x == -1).
Admitted.

Lemma expfS_eq1 x n :
  (x ^+ n.+1 == 1) = (x == 1) || (\sum_(i < n.+1) x ^+ i == 0).
Admitted.

Lemma lregP x : reflect (lreg x) (x != 0).
Admitted.

Lemma rregP x : reflect (rreg x) (x != 0).
Admitted.

#[export]
HB.instance Definition _ := IntegralDomain.on R^o.

End IntegralDomainTheory.

Arguments lregP {R x}.
Arguments rregP {R x}.

Definition field_axiom (R : unitRingType) := forall x : R, x != 0 -> x \in unit.

HB.mixin Record UnitRing_isField R & UnitRing R := {
  fieldP : field_axiom R;
}.

#[mathcomp(axiom="field_axiom"), short(type="fieldType")]
HB.structure Definition Field := { R of IntegralDomain R & UnitRing_isField R }.

Module Export FieldExports.
Bind Scope ring_scope with Field.sort.
End FieldExports.
HB.export FieldExports.

#[export] HB.instance Definition regular_field (F : fieldType) := Field.on F^o.

Lemma IdomainMixin (R : unitRingType): Field.axiom R -> IntegralDomain.axiom R.
Admitted.

HB.factory Record ComUnitRing_isField R & ComUnitRing R := {
  fieldP : field_axiom R;
}.
HB.builders Context R & ComUnitRing_isField R.
HB.instance Definition _ :=
  ComUnitRing_isIntegral.Build R (IdomainMixin fieldP).
HB.instance Definition _ := UnitRing_isField.Build R fieldP.
HB.end.

HB.factory Record ComNzRing_isField R & ComNzRing R := {
  inv : R -> R;
  mulVf : forall x, x != 0 -> inv x * x = 1;
  invr0 : inv 0 = 0;
}.

HB.builders Context R & ComNzRing_isField R.

Fact intro_unit (x y : R) : y * x = 1 -> x != 0.
Admitted.

Fact inv_out : {in predC (predC1 0), inv =1 id}.
Admitted.

HB.instance Definition _ : ComNzRing_hasMulInverse R :=
  ComNzRing_hasMulInverse.Build R mulVf intro_unit inv_out.

HB.instance Definition _ : ComUnitRing_isField R :=
  ComUnitRing_isField.Build R (fun x x_neq_0 => x_neq_0).

HB.end.

Section FieldTheory.

Variable F : fieldType.
Implicit Types x y : F.

Lemma unitfE x : (x \in unit) = (x != 0).
Admitted.

Lemma mulVf x : x != 0 -> x^-1 * x = 1.
Admitted.
Lemma divff x : x != 0 -> x / x = 1.
Admitted.
Definition mulfV := divff.
Lemma mulKf x : x != 0 -> cancel ( *%R x) ( *%R x^-1).
Admitted.
Lemma mulVKf x : x != 0 -> cancel ( *%R x^-1) ( *%R x).
Admitted.
Lemma mulfK x : x != 0 -> cancel ( *%R^~ x) ( *%R^~ x^-1).
Admitted.
Lemma mulfVK x : x != 0 -> cancel ( *%R^~ x^-1) ( *%R^~ x).
Admitted.
Definition divfK := mulfVK.

Lemma invfM : {morph @inv F : x y / x * y}.
Admitted.

Lemma invf_div x y : (x / y)^-1 = y / x.
Admitted.

Lemma divKf x : x != 0 -> involutive (fun y => x / y).
Admitted.

Lemma expfB_cond m n x : (x == 0) + n <= m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma expfB m n x : n < m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma prodfV I r (P : pred I) (E : I -> F) :
  \prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Admitted.

Lemma prodf_div I r (P : pred I) (E D : I -> F) :
  \prod_(i <- r | P i) (E i / D i) =
     \prod_(i <- r | P i) E i / \prod_(i <- r | P i) D i.
Admitted.

Lemma telescope_prodf n m (f : nat -> F) :
    (forall k, n < k < m -> f k != 0) -> n < m ->
  \prod_(n <= k < m) (f k.+1 / f k) = f m / f n.
Admitted.

Lemma telescope_prodf_eq n m (f u : nat -> F) :
    (forall k, n < k < m -> f k != 0) -> n < m ->
    (forall k, n <= k < m -> u k = f k.+1 / f k) ->
  \prod_(n <= k < m) u k = f m / f n.
Admitted.

Lemma addf_div x1 y1 x2 y2 :
  y1 != 0 -> y2 != 0 -> x1 / y1 + x2 / y2 = (x1 * y2 + x2 * y1) / (y1 * y2).
Admitted.

Lemma mulf_div x1 y1 x2 y2 : (x1 / y1) * (x2 / y2) = (x1 * x2) / (y1 * y2).
Admitted.

Lemma eqr_div x y z t : y != 0 -> t != 0 -> (x / y == z / t) = (x * t == z * y).
Admitted.

Lemma eqr_sum_div I r P (f : I -> F) c a : c != 0 ->
  (\big[+%R/0]_(x <- r | P x) (f x / c) == a)
  = (\big[+%R/0]_(x <- r | P x) f x == a * c).
Admitted.

Lemma pchar0_natf_div :
  pchar F =i pred0 -> forall m d, d %| m -> (m %/ d)%:R = m%:R / d%:R :> F.
Admitted.

Section FieldMorphismInj.

Variables (R : nzRingType) (f : {rmorphism F -> R}).

Lemma fmorph_eq0 x : (f x == 0) = (x == 0).
Admitted.

Lemma fmorph_inj : injective f.
Admitted.

Lemma fmorph_eq : {mono f : x y / x == y}.
Admitted.

Lemma fmorph_eq1 x : (f x == 1) = (x == 1).
Admitted.

Lemma fmorph_pchar : pchar R =i pchar F.
Admitted.

End FieldMorphismInj.

Section FieldMorphismInv.

Variables (R : unitRingType) (f : {rmorphism F -> R}).

Lemma fmorph_unit x : (f x \in unit) = (x != 0).
Admitted.

Lemma fmorphV : {morph f: x / x^-1}.
Admitted.

Lemma fmorph_div : {morph f : x y / x / y}.
Admitted.

End FieldMorphismInv.

Section ModuleTheory.

Variable V : lmodType F.
Implicit Types (a : F) (v : V).

Lemma scalerK a : a != 0 -> cancel ( *:%R a : V -> V) ( *:%R a^-1).
Admitted.

Lemma scalerKV a : a != 0 -> cancel ( *:%R a^-1 : V -> V) ( *:%R a).
Admitted.

Lemma scalerI a : a != 0 -> injective ( *:%R a : V -> V).
Admitted.

Lemma scaler_eq0 a v : (a *: v == 0) = (a == 0) || (v == 0).
Admitted.

End ModuleTheory.

Lemma pchar_lalg (A : nzLalgType F) : pchar A =i pchar F.
Admitted.

End FieldTheory.

Arguments fmorph_inj {F R} f [x1 x2].
Arguments telescope_prodf_eq {F n m} f u.



HB.mixin Record isInvClosed (R : unitRingType) (S : {pred R}) := {
  rpredVr : invr_closed S
}.



#[short(type="divClosed")]
HB.structure Definition DivClosed (R : unitRingType) :=
  {S of MulClosed R S & isInvClosed R S}.

#[short(type="sdivClosed")]
HB.structure Definition SdivClosed (R : unitRingType) :=
  {S of SmulClosed R S & isInvClosed R S}.

#[short(type="divringClosed")]
HB.structure Definition DivringClosed (R : unitRingType) :=
  {S of SubringClosed R S & isInvClosed R S}.

#[short(type="divalgClosed")]
HB.structure Definition DivalgClosed (R : nzRingType) (A : unitAlgType R) :=
  {S of DivringClosed A S & isScaleClosed R A S}.



HB.factory Record isDivClosed (R : unitRingType) (S : R -> bool) := {
  divr_closed_subproof : divr_closed S
}.

HB.builders Context R S & isDivClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
  (divr_closedM divr_closed_subproof).
HB.instance Definition _ := isInvClosed.Build R S
  (divr_closedV divr_closed_subproof).
HB.end.

HB.factory Record isSdivClosed (R : unitRingType) (S : R -> bool) := {
  sdivr_closed_subproof : sdivr_closed S
}.

HB.builders Context R S & isSdivClosed R S.
HB.instance Definition _ := isDivClosed.Build R S
  (sdivr_closed_div sdivr_closed_subproof).
HB.instance Definition _ := isSmulClosed.Build R S
  (sdivr_closedM sdivr_closed_subproof).
HB.end.

HB.factory Record isDivringClosed (R : unitRingType) (S : R -> bool) := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S & isDivringClosed R S.
HB.instance Definition _ := isSubringClosed.Build R S
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := isSdivClosed.Build R S
  (divring_closed_div divring_closed_subproof).
HB.end.

HB.factory Record isDivalgClosed (R : comUnitRingType) (A : unitAlgType R)
    (S : A -> bool) := {
  divalg_closed_subproof : divalg_closed S
}.

HB.builders Context R A S & isDivalgClosed R A S.
HB.instance Definition _ := isDivringClosed.Build A S
  (divalg_closedBdiv divalg_closed_subproof).
HB.instance Definition _ := isSubalgClosed.Build R A S
  (subalg_closed_semi (divalg_closedZ divalg_closed_subproof)).
HB.end.

Section UnitRingPred.

Variable R : unitRingType.

Section Div.

Variable S : divClosed R.

Lemma rpredV x : (x^-1 \in S) = (x \in S).
Admitted.

Lemma rpred_div : {in S &, forall x y, x / y \in S}.
Admitted.

Lemma rpredXN n : {in S, forall x, x ^- n \in S}.
Admitted.

Lemma rpredMl x y : x \in S -> x \is a unit-> (x * y \in S) = (y \in S).
Admitted.

Lemma rpredMr x y : x \in S -> x \is a unit -> (y * x \in S) = (y \in S).
Admitted.

Lemma rpred_divr x y : x \in S -> x \is a unit -> (y / x \in S) = (y \in S).
Admitted.

Lemma rpred_divl x y : x \in S -> x \is a unit -> (x / y \in S) = (y \in S).
Admitted.

End Div.

Lemma divringClosedP (divS : divringClosed R) : divring_closed divS.
Admitted.

Fact unitr_sdivr_closed : @sdivr_closed R unit.
Admitted.

#[export]
HB.instance Definition _ := isSdivClosed.Build R unit_pred unitr_sdivr_closed.

Implicit Type x : R.

Lemma unitrN x : (- x \is a unit) = (x \is a unit).
Admitted.

Lemma invrN x : (- x)^-1 = - x^-1.
Admitted.

Lemma divrNN x y : (- x) / (- y) = x / y.
Admitted.

Lemma divrN x y : x / (- y) = - (x / y).
Admitted.

Lemma invr_signM n x : ((-1) ^+ n * x)^-1 = (-1) ^+ n * x^-1.
Admitted.

Lemma divr_signM (b1 b2 : bool) x1 x2:
  ((-1) ^+ b1 * x1) / ((-1) ^+ b2 * x2) = (-1) ^+ (b1 (+) b2) * (x1 / x2).
Admitted.

End UnitRingPred.

Section FieldPred.

Variable F : fieldType.
Implicit Types x y : F.

Section ModuleTheory.

Variable V : lmodType F.
Implicit Types (a : F) (v : V).

Lemma rpredZeq (S : submodClosed V) a v :
  (a *: v \in S) = (a == 0) || (v \in S).
Admitted.

End ModuleTheory.

Section Predicates.

Context (S : divClosed F).

Lemma fpredMl x y : x \in S -> x != 0 -> (x * y \in S) = (y \in S).
Admitted.

Lemma fpredMr x y : x \in S -> x != 0 -> (y * x \in S) = (y \in S).
Admitted.

Lemma fpred_divl x y : x \in S -> x != 0 -> (x / y \in S) = (y \in S).
Admitted.

Lemma fpred_divr x y : x \in S -> x != 0 -> (y / x \in S) = (y \in S).
Admitted.

End Predicates.

End FieldPred.

#[short(type="subUnitRingType")]
HB.structure Definition SubUnitRing (R : nzRingType) (S : pred R) :=
  {U of SubNzRing R S U & UnitRing U}.

HB.factory Record SubNzRing_isSubUnitRing (R : unitRingType) S U
    & SubNzRing R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubNzRing_isSubUnitRing R S U.

HB.instance Definition _ := isDivringClosed.Build R S divring_closed_subproof.

Let inU v Sv : U := Sub v Sv.
Let invU (u : U) := inU (rpredVr _ (valP u)).

Lemma mulVr : {in [pred x | val x \is a unit], left_inverse 1 invU *%R}.
Admitted.
Lemma divrr : {in [pred x | val x \is a unit], right_inverse 1 invU *%R}.
Admitted.
Lemma unitrP (x y : U) : y * x = 1 /\ x * y = 1 -> val x \is a unit.
Admitted.
Lemma invr_out : {in [pred x | val x \isn't a unit], invU =1 id}.
Admitted.
HB.instance Definition _ := NzRing_hasMulInverse.Build U
  mulVr divrr unitrP invr_out.
HB.end.

#[short(type="subComUnitRingType")]
HB.structure Definition SubComUnitRing (R : comUnitRingType) (S : pred R) :=
  {U of SubComNzRing R S U & SubUnitRing R S U}.

#[short(type="subIdomainType")]
HB.structure Definition SubIntegralDomain (R : idomainType) (S : pred R) :=
  {U of SubComNzRing R S U & IntegralDomain U}.

HB.factory Record SubComUnitRing_isSubIntegralDomain (R : idomainType) S U
  & SubComUnitRing R S U := {}.

HB.builders Context R S U & SubComUnitRing_isSubIntegralDomain R S U.
Lemma id : IntegralDomain.axiom U.
Admitted.
HB.instance Definition _ := ComUnitRing_isIntegral.Build U id.
HB.end.

#[short(type="subFieldType")]
HB.structure Definition SubField (F : fieldType) (S : pred F) :=
  {U of SubIntegralDomain F S U & Field U}.

HB.factory Record SubIntegralDomain_isSubField (F : fieldType) S U
    & SubIntegralDomain F S U := {
  subfield_subproof : {mono (val : U -> F) : u / u \in unit}
}.

HB.builders Context F S U & SubIntegralDomain_isSubField F S U.
Lemma fieldP : Field.axiom U.
Admitted.
HB.instance Definition _ := UnitRing_isField.Build U fieldP.
HB.end.

HB.factory Record SubChoice_isSubUnitRing (R : unitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := SubNzRing_isSubUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

HB.factory Record SubChoice_isSubComUnitRing (R : comUnitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubComUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubComNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := SubNzRing_isSubUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

HB.factory Record SubChoice_isSubIntegralDomain (R : idomainType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubIntegralDomain R S U.
HB.instance Definition _ := SubChoice_isSubComUnitRing.Build R S U
  divring_closed_subproof.
HB.instance Definition _ := SubComUnitRing_isSubIntegralDomain.Build R S U.
HB.end.

Module Export SubExports.

Notation "[ 'SubNzRing_isSubUnitRing' 'of' U 'by' <: ]" :=
  (SubNzRing_isSubUnitRing.Build _ _ U (divringClosedP _))
  (format "[ 'SubNzRing_isSubUnitRing'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubChoice_isSubUnitRing' 'of' U 'by' <: ]" :=
  (SubChoice_isSubUnitRing.Build _ _ U (divringClosedP _))
  (format "[ 'SubChoice_isSubUnitRing'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubChoice_isSubComUnitRing' 'of' U 'by' <: ]" :=
  (SubChoice_isSubComUnitRing.Build _ _ U (divringClosedP _))
  (format "[ 'SubChoice_isSubComUnitRing'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubComUnitRing_isSubIntegralDomain' 'of' U 'by' <: ]" :=
  (SubComUnitRing_isSubIntegralDomain.Build _ _ U)
  (format "[ 'SubComUnitRing_isSubIntegralDomain'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubChoice_isSubIntegralDomain' 'of' U 'by' <: ]" :=
  (SubChoice_isSubIntegralDomain.Build _ _ U (divringClosedP _))
  (format "[ 'SubChoice_isSubIntegralDomain'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubIntegralDomain_isSubField' 'of' U 'by' <: ]" :=
  (SubIntegralDomain_isSubField.Build _ _ U (frefl _))
  (format "[ 'SubIntegralDomain_isSubField'  'of'  U  'by'  <: ]")
  : form_scope.

End SubExports.
HB.export SubExports.

Module Export Theory.

Export GRing.Theory.

Definition lregP {R x} := @lregP R x.
Definition rregP {R x} := @rregP R x.
Definition mulrV := mulrV.
Definition divrr := divrr.
Definition mulVr := mulVr.
Definition invr_out := invr_out.
Definition unitrP {R x} := @unitrP R x.
Definition mulKr := mulKr.
Definition mulVKr := mulVKr.
Definition mulrK := mulrK.
Definition mulrVK := mulrVK.
Definition divrK := divrK.
Definition mulrI := mulrI.
Definition mulIr := mulIr.
Definition divrI := divrI.
Definition divIr := divIr.
Definition telescope_prodr := telescope_prodr.
Definition telescope_prodr_eq := @telescope_prodr_eq.
Arguments telescope_prodr_eq {R n m} f u.
Definition commrV := commrV.
Definition unitrE := unitrE.
Definition invrK := @invrK.
Arguments invrK {R}.
Definition invr_inj := @invr_inj.
Arguments invr_inj {R} [x1 x2].
Definition unitrV := unitrV.
Definition unitr1 := unitr1.
Definition invr1 := invr1.
Definition divr1 := divr1.
Definition div1r := div1r.
Definition natr_div := natr_div.
Definition unitr0 := unitr0.
Definition invr0 := invr0.
Definition unitrN1 := unitrN1.
Definition unitrN := unitrN.
Definition invrN1 := invrN1.
Definition invrN := invrN.
Definition divrNN := divrNN.
Definition divrN := divrN.
Definition invr_sign := invr_sign.
Definition unitrMl := unitrMl.
Definition unitrMr := unitrMr.
Definition invrM := invrM.
Definition unitr_prod := unitr_prod.
Definition unitr_prod_in := unitr_prod_in.
Definition invr_eq0 := invr_eq0.
Definition invr_eq1 := invr_eq1.
Definition invr_neq0 := invr_neq0.
Definition rev_unitrP := rev_unitrP.
Definition rev_prodrV := rev_prodrV.
Definition unitrM_comm := unitrM_comm.
Definition unitrX := unitrX.
Definition unitrX_pos := unitrX_pos.
Definition exprVn := exprVn.
Definition exprB := exprB.
Definition invr_signM := invr_signM.
Definition divr_signM := divr_signM.
Definition rpredVr := @rpredVr.
Definition rpredV := rpredV.
Definition rpred_div := rpred_div.
Definition rpredXN := rpredXN.
Definition rpredZeq := rpredZeq.
Definition pchar_lalg := pchar_lalg.
Definition rpredMr := rpredMr.
Definition rpredMl := rpredMl.
Definition rpred_divr := rpred_divr.
Definition rpred_divl := rpred_divl.
Definition divringClosedP := divringClosedP.
Definition unitrM := unitrM.
Definition unitr_prodP := unitr_prodP.
Definition prodrV := prodrV.
Definition unitrPr {R x} := @unitrPr R x.
Definition expr_div_n := expr_div_n.
Definition mulr1_eq := mulr1_eq.
Definition divr1_eq := divr1_eq.
Definition divKr := divKr.
Definition mulf_eq0 := mulf_eq0.
Definition prodf_eq0 := prodf_eq0.
Definition prodf_seq_eq0 := prodf_seq_eq0.
Definition mulf_neq0 := mulf_neq0.
Definition prodf_neq0 := prodf_neq0.
Definition prodf_seq_neq0 := prodf_seq_neq0.
Definition expf_eq0 := expf_eq0.
Definition sqrf_eq0 := sqrf_eq0.
Definition expf_neq0 := expf_neq0.
Definition natf_neq0_pchar := natf_neq0_pchar.
Definition natf0_pchar := natf0_pchar.
Definition pcharf'_nat := pcharf'_nat.
Definition pcharf0P := pcharf0P.
Definition eqf_sqr := eqf_sqr.
Definition mulfI := mulfI.
Definition mulIf := mulIf.
Definition divfI := divfI.
Definition divIf := divIf.
Definition sqrf_eq1 := sqrf_eq1.
Definition expfS_eq1 := expfS_eq1.
Definition fieldP := @fieldP.
Definition unitfE := unitfE.
Definition mulVf := mulVf.
Definition mulfV := mulfV.
Definition divff := divff.
Definition mulKf := mulKf.
Definition mulVKf := mulVKf.
Definition mulfK := mulfK.
Definition mulfVK := mulfVK.
Definition divfK := divfK.
Definition divKf := divKf.
Definition invfM := invfM.
Definition invf_div := invf_div.
Definition expfB_cond := expfB_cond.
Definition expfB := expfB.
Definition prodfV := prodfV.
Definition prodf_d

[...]

divr_closed -> smulr_closed S.
Admitted.

Lemma divring_closedBM : divring_closed -> subring_closed S.
Admitted.

Lemma divring_closed_div : divring_closed -> sdivr_closed.
Admitted.

End UnitRingClosedPredicates.

Section UnitRingMorphism.

Variables (R S : unitRingType) (f : {rmorphism R -> S}).

Lemma rmorph_unit x : x \in unit -> f x \in unit.
Admitted.

Lemma rmorphV : {in unit, {morph f: x / x^-1}}.
Admitted.

Lemma rmorph_div x y : y \in unit -> f (x / y) = f x / f y.
Admitted.

End UnitRingMorphism.

#[short(type="comUnitRingType")]
HB.structure Definition ComUnitRing := {R of ComNzRing R & UnitRing R}.

Module Export ComUnitRingExports.
Bind Scope ring_scope with ComUnitRing.sort.
End ComUnitRingExports.
HB.export ComUnitRingExports.


HB.factory Record ComNzRing_hasMulInverse R & ComNzRing R := {
  unit : {pred R};
  inv : R -> R;
  mulVx : {in unit, left_inverse 1 inv *%R};
  unitPl : forall x y, y * x = 1 -> unit x;
  invr_out : {in [predC unit], inv =1 id}
}.

HB.builders Context R & ComNzRing_hasMulInverse R.

Fact mulC_mulrV : {in unit, right_inverse 1 inv *%R}.
Admitted.

Fact mulC_unitP x y : y * x = 1 /\ x * y = 1 -> unit x.
Admitted.

HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R mulVx mulC_mulrV mulC_unitP invr_out.

HB.end.

#[short(type="unitAlgType")]
HB.structure Definition UnitAlgebra R := {V of NzAlgebra R V & UnitRing V}.

Module Export UnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End UnitAlgebraExports.
HB.export UnitAlgebraExports.

#[short(type="comUnitAlgType")]
HB.structure Definition ComUnitAlgebra R :=
  {V of ComNzAlgebra R V & UnitRing V}.

Module Export ComUnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End ComUnitAlgebraExports.
HB.export ComUnitAlgebraExports.

Section ComUnitRingTheory.

Variable R : comUnitRingType.
Implicit Types x y : R.

Lemma unitrM x y : (x * y \in unit) = (x \in unit) && (y \in unit).
Admitted.

Lemma unitrPr x : reflect (exists y, x * y = 1) (x \in unit).
Admitted.

Lemma mulr1_eq x y : x * y = 1 -> x^-1 = y.
Admitted.

Lemma divr1_eq x y : x / y = 1 -> x = y.
Admitted.

Lemma divKr x : x \is a unit -> {in unit, involutive (fun y => x / y)}.
Admitted.

Lemma expr_div_n x y n : (x / y) ^+ n = x ^+ n / y ^+ n.
Admitted.

Lemma unitr_prodP (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
  reflect {in r, forall i, P i -> E i \is a GRing.unit}
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma prodrV (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
  (forall i, P i -> E i \is a GRing.unit) ->
  \prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Admitted.


#[export] HB.instance Definition _ := ComUnitRing.on R^c.
#[export] HB.instance Definition _ := ComUnitRing.on R^o.


End ComUnitRingTheory.

Section UnitAlgebraTheory.

Variable (R : comUnitRingType) (A : unitAlgType R).
Implicit Types (k : R) (x y : A).

Lemma scaler_injl : {in unit, @right_injective R A A *:%R}.
Admitted.

Lemma scaler_unit k x : k \in unit -> (k *: x \in unit) = (x \in unit).
Admitted.

Lemma invrZ k x : k \in unit -> x \in unit -> (k *: x)^-1 = k^-1 *: x^-1.
Admitted.

Section ClosedPredicates.

Variables S : {pred A}.

Definition divalg_closed := [/\ 1 \in S, linear_closed S & divr_2closed S].

Lemma divalg_closedBdiv : divalg_closed -> divring_closed S.
Admitted.

Lemma divalg_closedZ : divalg_closed -> subalg_closed S.
Admitted.

End ClosedPredicates.

End UnitAlgebraTheory.

Module Export ClosedExports.

Notation invr_closed := invr_closed.
Notation divr_2closed := divr_2closed.
Notation divr_closed := divr_closed.
Notation sdivr_closed := sdivr_closed.
Notation divring_closed := divring_closed.
Notation divalg_closed := divalg_closed.

Coercion divr_closedV : divr_closed >-> invr_closed.
Coercion divr_closedM : divr_closed >-> mulr_closed.
Coercion sdivr_closed_div : sdivr_closed >-> divr_closed.
Coercion sdivr_closedM : sdivr_closed >-> smulr_closed.
Coercion divring_closedBM : divring_closed >-> subring_closed.
Coercion divring_closed_div : divring_closed >-> sdivr_closed.
Coercion divalg_closedBdiv : divalg_closed >-> divring_closed.
Coercion divalg_closedZ : divalg_closed >-> subalg_closed.

End ClosedExports.

Definition integral_domain_axiom (R : pzRingType) :=
  forall x y : R, x * y = 0 -> (x == 0) || (y == 0).

HB.mixin Record ComUnitRing_isIntegral R & ComUnitRing R := {
  mulf_eq0_subproof : integral_domain_axiom R;
}.

#[mathcomp(axiom="integral_domain_axiom"), short(type="idomainType")]
HB.structure Definition IntegralDomain :=
  {R of ComUnitRing_isIntegral R & ComUnitRing R}.

Module Export IntegralDomainExports.
Bind Scope ring_scope with IntegralDomain.sort.
End IntegralDomainExports.
HB.export IntegralDomainExports.

Section IntegralDomainTheory.

Variable R : idomainType.
Implicit Types x y : R.

Lemma mulf_eq0 x y : (x * y == 0) = (x == 0) || (y == 0).
Admitted.

Lemma prodf_eq0 (I : finType) (P : pred I) (F : I -> R) :
  reflect (exists2 i, P i & (F i == 0)) (\prod_(i | P i) F i == 0).
Admitted.

Lemma prodf_seq_eq0 I r (P : pred I) (F : I -> R) :
  (\prod_(i <- r | P i) F i == 0) = has (fun i => P i && (F i == 0)) r.
Admitted.

Lemma mulf_neq0 x y : x != 0 -> y != 0 -> x * y != 0.
Admitted.

Lemma prodf_neq0 (I : finType) (P : pred I) (F : I -> R) :
  reflect (forall i, P i -> (F i != 0)) (\prod_(i | P i) F i != 0).
Admitted.

Lemma prodf_seq_neq0 I r (P : pred I) (F : I -> R) :
  (\prod_(i <- r | P i) F i != 0) = all (fun i => P i ==> (F i != 0)) r.
Admitted.

Lemma expf_eq0 x n : (x ^+ n == 0) = (n > 0) && (x == 0).
Admitted.

Lemma sqrf_eq0 x : (x ^+ 2 == 0) = (x == 0).
Admitted.

Lemma expf_neq0 x m : x != 0 -> x ^+ m != 0.
Admitted.

Lemma natf_neq0_pchar n : (n%:R != 0 :> R) = (pchar R)^'.-nat n.
Admitted.

Lemma natf0_pchar n : n > 0 -> n%:R == 0 :> R -> exists p, p \in pchar R.
Admitted.

Lemma pcharf'_nat n : (pchar R)^'.-nat n = (n%:R != 0 :> R).
Admitted.

Lemma pcharf0P : pchar R =i pred0 <-> (forall n, (n%:R == 0 :> R) = (n == 0)%N).
Admitted.

Lemma eqf_sqr x y : (x ^+ 2 == y ^+ 2) = (x == y) || (x == - y).
Admitted.

Lemma mulfI x : x != 0 -> injective ( *%R x).
Admitted.

Lemma mulIf x : x != 0 -> injective ( *%R^~ x).
Admitted.

Lemma divfI x : x != 0 -> injective (fun y => x / y).
Admitted.

Lemma divIf y : y != 0 -> injective (fun x => x / y).
Admitted.

Lemma sqrf_eq1 x : (x ^+ 2 == 1) = (x == 1) || (x == -1).
Admitted.

Lemma expfS_eq1 x n :
  (x ^+ n.+1 == 1) = (x == 1) || (\sum_(i < n.+1) x ^+ i == 0).
Admitted.

Lemma lregP x : reflect (lreg x) (x != 0).
Admitted.

Lemma rregP x : reflect (rreg x) (x != 0).
Admitted.

#[export]
HB.instance Definition _ := IntegralDomain.on R^o.

End IntegralDomainTheory.

Arguments lregP {R x}.
Arguments rregP {R x}.

Definition field_axiom (R : unitRingType) := forall x : R, x != 0 -> x \in unit.

HB.mixin Record UnitRing_isField R & UnitRing R := {
  fieldP : field_axiom R;
}.

#[mathcomp(axiom="field_axiom"), short(type="fieldType")]
HB.structure Definition Field := { R of IntegralDomain R & UnitRing_isField R }.

Module Export FieldExports.
Bind Scope ring_scope with Field.sort.
End FieldExports.
HB.export FieldExports.

#[export] HB.instance Definition regular_field (F : fieldType) := Field.on F^o.

Lemma IdomainMixin (R : unitRingType): Field.axiom R -> IntegralDomain.axiom R.
Admitted.

HB.factory Record ComUnitRing_isField R & ComUnitRing R := {
  fieldP : field_axiom R;
}.
HB.builders Context R & ComUnitRing_isField R.
HB.instance Definition _ :=
  ComUnitRing_isIntegral.Build R (IdomainMixin fieldP).
HB.instance Definition _ := UnitRing_isField.Build R fieldP.
HB.end.

HB.factory Record ComNzRing_isField R & ComNzRing R := {
  inv : R -> R;
  mulVf : forall x, x != 0 -> inv x * x = 1;
  invr0 : inv 0 = 0;
}.

HB.builders Context R & ComNzRing_isField R.

Fact intro_unit (x y : R) : y * x = 1 -> x != 0.
Admitted.

Fact inv_out : {in predC (predC1 0), inv =1 id}.
Admitted.

HB.instance Definition _ : ComNzRing_hasMulInverse R :=
  ComNzRing_hasMulInverse.Build R mulVf intro_unit inv_out.

HB.instance Definition _ : ComUnitRing_isField R :=
  ComUnitRing_isField.Build R (fun x x_neq_0 => x_neq_0).

HB.end.

Section FieldTheory.

Variable F : fieldType.
Implicit Types x y : F.

Lemma unitfE x : (x \in unit) = (x != 0).
Admitted.

Lemma mulVf x : x != 0 -> x^-1 * x = 1.
Admitted.
Lemma divff x : x != 0 -> x / x = 1.
Admitted.
Definition mulfV := divff.
Lemma mulKf x : x != 0 -> cancel ( *%R x) ( *%R x^-1).
Admitted.
Lemma mulVKf x : x != 0 -> cancel ( *%R x^-1) ( *%R x).
Admitted.
Lemma mulfK x : x != 0 -> cancel ( *%R^~ x) ( *%R^~ x^-1).
Admitted.
Lemma mulfVK x : x != 0 -> cancel ( *%R^~ x^-1) ( *%R^~ x).
Admitted.
Definition divfK := mulfVK.

Lemma invfM : {morph @inv F : x y / x * y}.
Admitted.

Lemma invf_div x y : (x / y)^-1 = y / x.
Admitted.

Lemma divKf x : x != 0 -> involutive (fun y => x / y).
Admitted.

Lemma expfB_cond m n x : (x == 0) + n <= m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma expfB m n x : n < m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma prodfV I r (P : pred I) (E : I -> F) :
  \prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Admitted.

Lemma prodf_div I r (P : pred I) (E D : I -> F) :
  \prod_(i <- r | P i) (E i / D i) =
     \prod_(i <- r | P i) E i / \prod_(i <- r | P i) D i.
Admitted.

Lemma telescope_prodf n m (f : nat -> F) :
    (forall k, n < k < m -> f k != 0) -> n < m ->
  \prod_(n <= k < m) (f k.+1 / f k) = f m / f n.
Admitted.

Lemma telescope_prodf_eq n m (f u : nat -> F) :
    (forall k, n < k < m -> f k != 0) -> n < m ->
    (forall k, n <= k < m -> u k = f k.+1 / f k) ->
  \prod_(n <= k < m) u k = f m / f n.
Admitted.

Lemma addf_div x1 y1 x2 y2 :
  y1 != 0 -> y2 != 0 -> x1 / y1 + x2 / y2 = (x1 * y2 + x2 * y1) / (y1 * y2).
Admitted.

Lemma mulf_div x1 y1 x2 y2 : (x1 / y1) * (x2 / y2) = (x1 * x2) / (y1 * y2).
Admitted.

Lemma eqr_div x y z t : y != 0 -> t != 0 -> (x / y == z / t) = (x * t == z * y).
Admitted.

Lemma eqr_sum_div I r P (f : I -> F) c a : c != 0 ->
  (\big[+%R/0]_(x <- r | P x) (f x / c) == a)
  = (\big[+%R/0]_(x <- r | P x) f x == a * c).
Admitted.

Lemma pchar0_natf_div :
  pchar F =i pred0 -> forall m d, d %| m -> (m %/ d)%:R = m%:R / d%:R :> F.
Admitted.

Section FieldMorphismInj.

Variables (R : nzRingType) (f : {rmorphism F -> R}).

Lemma fmorph_eq0 x : (f x == 0) = (x == 0).
Admitted.

Lemma fmorph_inj : injective f.
Admitted.

Lemma fmorph_eq : {mono f : x y / x == y}.
Admitted.

Lemma fmorph_eq1 x : (f x == 1) = (x == 1).
Admitted.

Lemma fmorph_pchar : pchar R =i pchar F.
Admitted.

End FieldMorphismInj.

Section FieldMorphismInv.

Variables (R : unitRingType) (f : {rmorphism F -> R}).

Lemma fmorph_unit x : (f x \in unit) = (x != 0).
Admitted.

Lemma fmorphV : {morph f: x / x^-1}.
Admitted.

Lemma fmorph_div : {morph f : x y / x / y}.
Admitted.

End FieldMorphismInv.

Section ModuleTheory.

Variable V : lmodType F.
Implicit Types (a : F) (v : V).

Lemma scalerK a : a != 0 -> cancel ( *:%R a : V -> V) ( *:%R a^-1).
Admitted.

Lemma scalerKV a : a != 0 -> cancel ( *:%R a^-1 : V -> V) ( *:%R a).
Admitted.

Lemma scalerI a : a != 0 -> injective ( *:%R a : V -> V).
Admitted.

Lemma scaler_eq0 a v : (a *: v == 0) = (a == 0) || (v == 0).
Admitted.

End ModuleTheory.

Lemma pchar_lalg (A : nzLalgType F) : pchar A =i pchar F.
Admitted.

End FieldTheory.

Arguments fmorph_inj {F R} f [x1 x2].
Arguments telescope_prodf_eq {F n m} f u.



HB.mixin Record isInvClosed (R : unitRingType) (S : {pred R}) := {
  rpredVr : invr_closed S
}.



#[short(type="divClosed")]
HB.structure Definition DivClosed (R : unitRingType) :=
  {S of MulClosed R S & isInvClosed R S}.

#[short(type="sdivClosed")]
HB.structure Definition SdivClosed (R : unitRingType) :=
  {S of SmulClosed R S & isInvClosed R S}.

#[short(type="divringClosed")]
HB.structure Definition DivringClosed (R : unitRingType) :=
  {S of SubringClosed R S & isInvClosed R S}.

#[short(type="divalgClosed")]
HB.structure Definition DivalgClosed (R : nzRingType) (A : unitAlgType R) :=
  {S of DivringClosed A S & isScaleClosed R A S}.



HB.factory Record isDivClosed (R : unitRingType) (S : R -> bool) := {
  divr_closed_subproof : divr_closed S
}.

HB.builders Context R S & isDivClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
  (divr_closedM divr_closed_subproof).
HB.instance Definition _ := isInvClosed.Build R S
  (divr_closedV divr_closed_subproof).
HB.end.

HB.factory Record isSdivClosed (R : unitRingType) (S : R -> bool) := {
  sdivr_closed_subproof : sdivr_closed S
}.

HB.builders Context R S & isSdivClosed R S.
HB.instance Definition _ := isDivClosed.Build R S
  (sdivr_closed_div sdivr_closed_subproof).
HB.instance Definition _ := isSmulClosed.Build R S
  (sdivr_closedM sdivr_closed_subproof).
HB.end.

HB.factory Record isDivringClosed (R : unitRingType) (S : R -> bool) := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S & isDivringClosed R S.
HB.instance Definition _ := isSubringClosed.Build R S
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := isSdivClosed.Build R S
  (divring_closed_div divring_closed_subproof).
HB.end.

HB.factory Record isDivalgClosed (R : comUnitRingType) (A : unitAlgType R)
    (S : A -> bool) := {
  divalg_closed_subproof : divalg_closed S
}.

HB.builders Context R A S & isDivalgClosed R A S.
HB.instance Definition _ := isDivringClosed.Build A S
  (divalg_closedBdiv divalg_closed_subproof).
HB.instance Definition _ := isSubalgClosed.Build R A S
  (subalg_closed_semi (divalg_closedZ divalg_closed_subproof)).
HB.end.

Section UnitRingPred.

Variable R : unitRingType.

Section Div.

Variable S : divClosed R.

Lemma rpredV x : (x^-1 \in S) = (x \in S).
Admitted.

Lemma rpred_div : {in S &, forall x y, x / y \in S}.
Admitted.

Lemma rpredXN n : {in S, forall x, x ^- n \in S}.
Admitted.

Lemma rpredMl x y : x \in S -> x \is a unit-> (x * y \in S) = (y \in S).
Admitted.

Lemma rpredMr x y : x \in S -> x \is a unit -> (y * x \in S) = (y \in S).
Admitted.

Lemma rpred_divr x y : x \in S -> x \is a unit -> (y / x \in S) = (y \in S).
Admitted.

Lemma rpred_divl x y : x \in S -> x \is a unit -> (x / y \in S) = (y \in S).
Admitted.

End Div.

Lemma divringClosedP (divS : divringClosed R) : divring_closed divS.
Admitted.

Fact unitr_sdivr_closed : @sdivr_closed R unit.
Admitted.

#[export]
HB.instance Definition _ := isSdivClosed.Build R unit_pred unitr_sdivr_closed.

Implicit Type x : R.

Lemma unitrN x : (- x \is a unit) = (x \is a unit).
Admitted.

Lemma invrN x : (- x)^-1 = - x^-1.
Admitted.

Lemma divrNN x y : (- x) / (- y) = x / y.
Admitted.

Lemma divrN x y : x / (- y) = - (x / y).
Admitted.

Lemma invr_signM n x : ((-1) ^+ n * x)^-1 = (-1) ^+ n * x^-1.
Admitted.

Lemma divr_signM (b1 b2 : bool) x1 x2:
  ((-1) ^+ b1 * x1) / ((-1) ^+ b2 * x2) = (-1) ^+ (b1 (+) b2) * (x1 / x2).
Admitted.

End UnitRingPred.

Section FieldPred.

Variable F : fieldType.
Implicit Types x y : F.

Section ModuleTheory.

Variable V : lmodType F.
Implicit Types (a : F) (v : V).

Lemma rpredZeq (S : submodClosed V) a v :
  (a *: v \in S) = (a == 0) || (v \in S).
Admitted.

End ModuleTheory.

Section Predicates.

Context (S : divClosed F).

Lemma fpredMl x y : x \in S -> x != 0 -> (x * y \in S) = (y \in S).
Admitted.

Lemma fpredMr x y : x \in S -> x != 0 -> (y * x \in S) = (y \in S).
Admitted.

Lemma fpred_divl x y : x \in S -> x != 0 -> (x / y \in S) = (y \in S).
Admitted.

Lemma fpred_divr x y : x \in S -> x != 0 -> (y / x \in S) = (y \in S).
Admitted.

End Predicates.

End FieldPred.

#[short(type="subUnitRingType")]
HB.structure Definition SubUnitRing (R : nzRingType) (S : pred R) :=
  {U of SubNzRing R S U & UnitRing U}.

HB.factory Record SubNzRing_isSubUnitRing (R : unitRingType) S U
    & SubNzRing R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubNzRing_isSubUnitRing R S U.

HB.instance Definition _ := isDivringClosed.Build R S divring_closed_subproof.

Let inU v Sv : U := Sub v Sv.
Let invU (u : U) := inU (rpredVr _ (valP u)).

Lemma mulVr : {in [pred x | val x \is a unit], left_inverse 1 invU *%R}.
Admitted.
Lemma divrr : {in [pred x | val x \is a unit], right_inverse 1 invU *%R}.
Admitted.
Lemma unitrP (x y : U) : y * x = 1 /\ x * y = 1 -> val x \is a unit.
Admitted.
Lemma invr_out : {in [pred x | val x \isn't a unit], invU =1 id}.
Admitted.
HB.instance Definition _ := NzRing_hasMulInverse.Build U
  mulVr divrr unitrP invr_out.
HB.end.

#[short(type="subComUnitRingType")]
HB.structure Definition SubComUnitRing (R : comUnitRingType) (S : pred R) :=
  {U of SubComNzRing R S U & SubUnitRing R S U}.

#[short(type="subIdomainType")]
HB.structure Definition SubIntegralDomain (R : idomainType) (S : pred R) :=
  {U of SubComNzRing R S U & IntegralDomain U}.

HB.factory Record SubComUnitRing_isSubIntegralDomain (R : idomainType) S U
  & SubComUnitRing R S U := {}.

HB.builders Context R S U & SubComUnitRing_isSubIntegralDomain R S U.
Lemma id : IntegralDomain.axiom U.
Admitted.
HB.instance Definition _ := ComUnitRing_isIntegral.Build U id.
HB.end.

#[short(type="subFieldType")]
HB.structure Definition SubField (F : fieldType) (S : pred F) :=
  {U of SubIntegralDomain F S U & Field U}.

HB.factory Record SubIntegralDomain_isSubField (F : fieldType) S U
    & SubIntegralDomain F S U := {
  subfield_subproof : {mono (val : U -> F) : u / u \in unit}
}.

HB.builders Context F S U & SubIntegralDomain_isSubField F S U.
Lemma fieldP : Field.axiom U.
Admitted.
HB.instance Definition _ := UnitRing_isField.Build U fieldP.
HB.end.

HB.factory Record SubChoice_isSubUnitRing (R : unitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := SubNzRing_isSubUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

HB.factory Record SubChoice_isSubComUnitRing (R : comUnitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubComUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubComNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := SubNzRing_isSubUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

HB.factory Record SubChoice_isSubIntegralDomain (R : idomainType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubIntegralDomain R S U.
HB.instance Definition _ := SubChoice_isSubComUnitRing.Build R S U
  divring_closed_subproof.
HB.instance Definition _ := SubComUnitRing_isSubIntegralDomain.Build R S U.
HB.end.

Module Export SubExports.

Notation "[ 'SubNzRing_isSubUnitRing' 'of' U 'by' <: ]" :=
  (SubNzRing_isSubUnitRing.Build _ _ U (divringClosedP _))
  (format "[ 'SubNzRing_isSubUnitRing'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubChoice_isSubUnitRing' 'of' U 'by' <: ]" :=
  (SubChoice_isSubUnitRing.Build _ _ U (divringClosedP _))
  (format "[ 'SubChoice_isSubUnitRing'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubChoice_isSubComUnitRing' 'of' U 'by' <: ]" :=
  (SubChoice_isSubComUnitRing.Build _ _ U (divringClosedP _))
  (format "[ 'SubChoice_isSubComUnitRing'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubComUnitRing_isSubIntegralDomain' 'of' U 'by' <: ]" :=
  (SubComUnitRing_isSubIntegralDomain.Build _ _ U)
  (format "[ 'SubComUnitRing_isSubIntegralDomain'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubChoice_isSubIntegralDomain' 'of' U 'by' <: ]" :=
  (SubChoice_isSubIntegralDomain.Build _ _ U (divringClosedP _))
  (format "[ 'SubChoice_isSubIntegralDomain'  'of'  U  'by'  <: ]")
  : form_scope.
Notation "[ 'SubIntegralDomain_isSubField' 'of' U 'by' <: ]" :=
  (SubIntegralDomain_isSubField.Build _ _ U (frefl _))
  (format "[ 'SubIntegralDomain_isSubField'  'of'  U  'by'  <: ]")
  : form_scope.

End SubExports.
HB.export SubExports.

Module Export Theory.

Export GRing.Theory.

Definition lregP {R x} := @lregP R x.
Definition rregP {R x} := @rregP R x.
Definition mulrV := mulrV.
Definition divrr := divrr.
Definition mulVr := mulVr.
Definition invr_out := invr_out.
Definition unitrP {R x} := @unitrP R x.
Definition mulKr := mulKr.
Definition mulVKr := mulVKr.
Definition mulrK := mulrK.
Definition mulrVK := mulrVK.
Definition divrK := divrK.
Definition mulrI := mulrI.
Definition mulIr := mulIr.
Definition divrI := divrI.
Definition divIr := divIr.
Definition telescope_prodr := telescope_prodr.
Definition telescope_prodr_eq := @telescope_prodr_eq.
Arguments telescope_prodr_eq {R n m} f u.
Definition commrV := commrV.
Definition unitrE := unitrE.
Definition invrK := @invrK.
Arguments invrK {R}.
Definition invr_inj := @invr_inj.
Arguments invr_inj {R} [x1 x2].
Definition unitrV := unitrV.
Definition unitr1 := unitr1.
Definition invr1 := invr1.
Definition divr1 := divr1.
Definition div1r := div1r.
Definition natr_div := natr_div.
Definition unitr0 := unitr0.
Definition invr0 := invr0.
Definition unitrN1 := unitrN1.
Definition unitrN := unitrN.
Definition invrN1 := invrN1.
Definition invrN := invrN.
Definition divrNN := divrNN.
Definition divrN := divrN.
Definition invr_sign := invr_sign.
Definition unitrMl := unitrMl.
Definition unitrMr := unitrMr.
Definition invrM := invrM.
Definition unitr_prod := unitr_prod.
Definition unitr_prod_in := unitr_prod_in.
Definition invr_eq0 := invr_eq0.
Definition invr_eq1 := invr_eq1.
Definition invr_neq0 := invr_neq0.
Definition rev_unitrP := rev_unitrP.
Definition rev_prodrV := rev_prodrV.
Definition unitrM_comm := unitrM_comm.
Definition unitrX := unitrX.
Definition unitrX_pos := unitrX_pos.
Definition exprVn := exprVn.
Definition exprB := exprB.
Definition invr_signM := invr_signM.
Definition divr_signM := divr_signM.
Definition rpredVr := @rpredVr.
Definition rpredV := rpredV.
Definition rpred_div := rpred_div.
Definition rpredXN := rpredXN.
Definition rpredZeq := rpredZeq.
Definition pchar_lalg := pchar_lalg.
Definition rpredMr := rpredMr.
Definition rpredMl := rpredMl.
Definition rpred_divr := rpred_divr.
Definition rpred_divl := rpred_divl.
Definition divringClosedP := divringClosedP.
Definition unitrM := unitrM.
Definition unitr_prodP := unitr_prodP.
Definition prodrV := prodrV.
Definition unitrPr {R x} := @unitrPr R x.
Definition expr_div_n := expr_div_n.
Definition mulr1_eq := mulr1_eq.
Definition divr1_eq := divr1_eq.
Definition divKr := divKr.
Definition mulf_eq0 := mulf_eq0.
Definition prodf_eq0 := prodf_eq0.
Definition prodf_seq_eq0 := prodf_seq_eq0.
Definition mulf_neq0 := mulf_neq0.
Definition prodf_neq0 := prodf_neq0.
Definition prodf_seq_neq0 := prodf_seq_neq0.
Definition expf_eq0 := expf_eq0.
Definition sqrf_eq0 := sqrf_eq0.
Definition expf_neq0 := expf_neq0.
Definition natf_neq0_pchar := natf_neq0_pchar.
Definition natf0_pchar := natf0_pchar.
Definition pcharf'_nat := pcharf'_nat.
Definition pcharf0P := pcharf0P.
Definition eqf_sqr := eqf_sqr.
Definition mulfI := mulfI.
Definition mulIf := mulIf.
Definition divfI := divfI.
Definition divIf := divIf.
Definition sqrf_eq1 := sqrf_eq1.
Definition expfS_eq1 := expfS_eq1.
Definition fieldP := @fieldP.
Definition unitfE := unitfE.
Definition mulVf := mulVf.
Definition mulfV := mulfV.
Definition divff := divff.
Definition mulKf := mulKf.
Definition mulVKf := mulVKf.
Definition mulfK := mulfK.
Definition mulfVK := mulfVK.
Definition divfK := divfK.
Definition divKf := divKf.
Definition invfM := invfM.
Definition invf_div := invf_div.
Definition expfB_cond := expfB_cond.
Definition expfB := expfB.
Definition prodfV := prodfV.
Definition prodf_div := prodf_div.
Definition telescope_prodf := telescope_prodf.
Definition telescope_prodf_eq := @telescope_prodf_eq.
Arguments telescope_prodf_eq {F n m} f u.
Definition addf_div := addf_div.
Definition mulf_div := mulf_div.
Definition eqr_div := eqr_div.
Definition eqr_sum_div := eqr_sum_div.
Definition pchar0_natf_div := pchar0_natf_div.
Definition fpredMr := fpredMr.
Definition fpredMl := fpredMl.
Definition fpred_divr := fpred_divr.
Definition fpred_divl := fpred_divl.
Definition rmorph_unit := rmorph_unit.
Definition rmorphV := rmorphV.
Definition rmorph_div := rmorph_div.
Definition fmorph_eq0 := fmorph_eq0.
Definition fmorph_inj := @fmorph_inj.
Arguments fmorph_inj {F R} f [x1 x2].
Definition fmorph_eq := fmorph_eq.
Definition fmorph_eq1 := fmorph_eq1.
Definition fmorph_pchar := fmorph_pchar.
Definition fmorph_unit := fmorph_unit.
Definition fmorphV := fmorphV.
Definition fmorph_div := fmorph_div.
Definition scaler_eq0 := scaler_eq0.
Definition scalerK := scalerK.
Definition scalerKV := scalerKV.
Definition scalerI := scalerI.
Definition scaler_injl := scaler_injl.
Definition scaler_unit := scaler_unit.
Definition invrZ := invrZ.

End Theory.

Module Export AllExports.
HB.reexport.
End AllExports.

End GRing.

Export AllExports.
Export ClosedExports.

Notation "x ^-1" := (inv x) : ring_scope.
Notation "x ^- n" := (inv (x ^+ n)) : ring_scope.
Notation "x / y" := (mul x y^-1) : ring_scope.

Section PairUnitRing.

Variables R1 R2 : unitRingType.

Definition pair_unitr :=
  [qualify a x : R1 * R2 | (x.1 \is a GRing.unit) && (x.2 \is a GRing.unit)].
Definition pair_invr x :=
  if x \is a pair_unitr then (x.1^-1, x.2^-1) else x.

Lemma pair_mulVl : {in pair_unitr, left_inverse 1 pair_invr *%R}.
Admitted.

Lemma pair_mulVr : {in pair_unitr, right_inverse 1 pair_invr *%R}.
Admitted.

Lemma pair_unitP x y : y * x = 1 /\ x * y = 1 -> x \is a pair_unitr.
Admitted.

Lemma pair_invr_out : {in [predC pair_unitr], pair_invr =1 id}.
Admitted.

#[export]
HB.instance Definition _ := NzRing_hasMulInverse.Build (R1 * R2)%type
  pair_mulVl pair_mulVr pair_unitP pair_invr_out.

End PairUnitRing.


#[export]
HB.instance Definition _ (R1 R2 : comUnitRingType) :=
  UnitRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R : nzRingType) (A1 A2 : unitAlgType R) :=
  NzAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : nzRingType) (A1 A2 : comUnitAlgType R) :=
  NzAlgebra.on (A1 * A2)%type.




Fact mulVb (b : bool) : b != 0 -> b * b = 1.
Admitted.

Fact invb_out (x y : bool) : y * x = 1 -> x != 0.
Admitted.

HB.instance Definition _ := ComNzRing_hasMulInverse.Build bool
  mulVb invb_out (fun x => fun => erefl x).

Lemma bool_fieldP : Field.axiom bool.
Admitted.

HB.instance Definition _ := ComUnitRing_isField.Build bool bool_fieldP.

End divalg.

End mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Module Export mathcomp_DOT_algebra_DOT_alg_DOT_divalg.
Module Export mathcomp.
Module Export algebra.
Module Export alg.
Module Export divalg.
Include mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.divalg.
End divalg.

End alg.

End algebra.

End mathcomp.

End mathcomp_DOT_algebra_DOT_alg_DOT_divalg.

Module mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Module Export orderedzmod.

Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Local Open Scope ring_scope.

Fact ring_display : Order.disp_t.
Admitted.

Module Export Num.

#[short(type="porderNmodType")]
HB.structure Definition POrderNmodule :=
  { R of Order.isPOrder ring_display R & GRing.Nmodule R}.

#[short(type="porderZmodType")]
HB.structure Definition POrderZmodule :=
  { R of POrderNmodule R & GRing.Zmodule R }.

HB.mixin Record Add_isHomo R & POrderNmodule R := {
  ler_wD2l : forall x : R, {homo +%R x : y z / (y <= z)%O}
}.

#[short(type="porderedNmodType")]
HB.structure Definition POrderedNmodule :=
  { R of POrderNmodule R & Add_isHomo R}.

#[short(type="porderedZmodType")]
HB.structure Definition POrderedZmodule :=
  { R of GRing.Zmodule R & POrderedNmodule R}.

HB.factory Record ZmodulePositiveCone R & GRing.Zmodule R := {
  nonneg : {pred R};
  nonneg0 : nonneg 0;
  nonnegD : forall x y, nonneg x -> nonneg y -> nonneg (x + y);
  nonneg_definite : forall x, nonneg x -> nonneg (- x) -> x = 0;
}.

HB.builders Context R & ZmodulePositiveCone R.

Definition le x y := nonneg (y - x).

Fact le_refl : reflexive le.
Admitted.

Fact le_anti : antisymmetric le.
Admitted.

Fact le_trans : transitive le.
Admitted.

HB.instance Definition _ := Order.Le_isPOrder.Build ring_display R
  le_refl le_anti le_trans.

HB.end.

HB.mixin Record POrderedZmodule_hasTransCmp R & GRing.Nmodule R
    & Order.isPOrder ring_display R := {
  comparabler_trans : transitive (Order.comparable : rel R)
}.

#[short(type="numZmodType")]
HB.structure Definition NumZmodule :=
  {R of POrderedZmodule_hasTransCmp R & POrderedZmodule R}.

Notation ler := (@Order.le ring_display _) (only parsing).
Notation ltr := (@Order.lt ring_display _) (only parsing).
Notation lerif := (@Order.leif ring_display _) (only parsing).

Notation le := ler (only parsing).
Notation lt := ltr (only parsing).

Module Import Syntax.

Notation "x <= y" := (le x y) : ring_scope.

Notation "x < y"  := (lt x y) : ring_scope.

Notation "x <= y ?= 'iff' C" := (lerif x y C) : ring_scope.

End Syntax.
End Num.
Export Num.Syntax.

End orderedzmod.

End mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Module Export mathcomp.
Module Export algebra.
Module Export num_theory.
Module Export orderedzmod.
Include mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.orderedzmod.
End orderedzmod.

End num_theory.

End algebra.

End mathcomp.
Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.
Import mathcomp.algebra.alg.divalg.
Import mathcomp.algebra.num_theory.orderedzmod.

Set Implicit Arguments.
Unset Strict Implicit.

Local Open Scope ring_scope.
Import orderedzmod.Num.

HB.mixin Record Zmodule_isSemiNormed (R : POrderZmodule.type) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.

#[short(type="semiNormedZmodType")]
HB.structure Definition SemiNormedZmodule (R : porderZmodType) :=
  { M of Zmodule_isSemiNormed R M & GRing.Zmodule M }.

HB.mixin Record SemiNormedZmodule_isPositiveDefinite
    (R : POrderZmodule.type) M & @SemiNormedZmodule R M := {
  normr0_eq0 : forall x : M, norm x = 0 -> x = 0;
}.

#[short(type="normedZmodType")]
HB.structure Definition NormedZmodule (R : porderZmodType) :=
  { M of SemiNormedZmodule_isPositiveDefinite R M & SemiNormedZmodule R M }.

HB.factory Record Zmodule_isNormed (R : porderZmodType) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normr0_eq0 : forall x, norm x = 0 -> x = 0;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.
HB.builders Context (R : POrderZmodule.type) M & Zmodule_isNormed R M.
  HB.instance Definition _ :=
    Zmodule_isSemiNormed.Build R M ler_normD normrMn normrN.
HB.end.

HB.mixin Record NumZmod_isNumRing R & GRing.NzRing R & POrderZmodule R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.

#[short(type="numDomainType")]
HB.structure Definition NumDomain := { R of
     GRing.IntegralDomain R &
     NumZmodule R &
     NormedZmodule (POrderZmodule.clone R _) R &
     NumZmod_isNumRing R
  }.

HB.factory Record isNumRing R & GRing.NzRing R & POrderZmodule R
  & GRing.IntegralDomain R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.
HB.builders Context R & isNumRing R.

Fact ler_wD2l (x : R) : {homo +%R x : y z / y <= z}.
Admitted.

HB.instance Definition _ := Add_isHomo.Build R ler_wD2l.
HB.end.

Section NumDomainOperationTheory.

Variable R : numDomainType.

Lemma leif_AGM_scaled (I : finType) (A : {pred I}) (E : I -> R) (n := #|A|) :
    {in A, forall i, 0 <= E i *+ n} ->
  \prod_(i in A) (E i *+ n) <= (\sum_(i in A) E i) ^+ n
                            ?= iff [forall i in A, forall j in A, E i == E j].
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 4.0MiB file on GitHub Actions Artifacts under build.log)
 '[' '' ']'
+ COQ_CI_COLOR=
+ export GIT_PAGER=
+ GIT_PAGER=
+ '[' '' = 1 ']'
+ '[' '' = 1 ']'
+ bash /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-mathcomp.sh
+ tee _build_ci/mathcomp.log
++ set -e
++ : 2
++ export NJOBS
+++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-common.sh
++ . /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ which cygpath
+++ OCAMLFINDSEP=:
+++ '[' /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh ']'
++++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ root=/github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ cd /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ echo /builds/coq/coq
+++ root=/builds/coq/coq
+++ '[' -n 1 ']'
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ export OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
+++ export CI_BRANCH=
+++ CI_BRANCH=
+++ [[ '' =~ ^[0-9]*$ ]]
+++ export CI_PULL_REQUEST=
+++ CI_PULL_REQUEST=
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ declare -A overlays
++ set +x
+ git_download mathcomp
+ local project=mathcomp
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local giturl_var=mathcomp_CI_GITURL
+ local giturl=https://github.com/math-comp/math-comp
+ local ref_var=mathcomp_CI_REF
+ local ref=master
+ local parent_project_var=mathcomp_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=mathcomp_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp ']'
+ echo 'Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.'
Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.
+ '[' '' ']'
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ make
+ '[' -z x ']'
+ command make
"/github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq" makefile  -f Make -o Makefile.coq
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
         use ROCQRUNTIMELIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
make -f Makefile.coq --no-print-directory
ROCQ compile algebra/num_theory/numdomain.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////rocq
MINIMIZER_DEBUG_EXTRA: original invocation: '' 
MINIMIZER_DEBUG_EXTRA: new invocation: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: ocamlpath: /github/workspace/builds/coq/coq-failing/_install_ci/lib:
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqlib: Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.CEvC78szHi
MINIMIZER_DEBUG: files:  algebra/num_theory/numdomain.v /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.vWarning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]Warning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "./algebra/num_theory/numdomain.v", line 1904, characters 63-76:
Error: In term, tolerating this expression at a higher level than expected by
the notation started on the left. This tolerance will be eventually removed.
Insert parentheses or try to lower the level at which the top symbol of this
expression is parsed.
[level-tolerance,deprecated-since-9.2,deprecated,parsing,default]

Command exited with non-zero status 1
algebra/num_theory/numdomain.vo (real: 19.12, user: 18.22, sys: 0.16, mem: 1084980 ko)
make[2]: *** [Makefile.coq:815: algebra/num_theory/numdomain.vo] Error 1
make[2]: *** [algebra/num_theory/numdomain.vo] Deleting file 'algebra/num_theory/numdomain.glob'
make[1]: *** [Makefile.coq:411: all] Error 2
make: *** [Makefile.common:99: this-build] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' mathcomp 2
+ '[' mathcomp '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real _build_ci/mathcomp.log
    Time |   Peak Mem | File Name                      
-------------------------------------------------------
0m19.12s | 1084980 ko | Total Time / Peak Mem          
-------------------------------------------------------
0m19.12s | 1084980 ko | algebra/num_theory/numdomain.vo
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 614KiB file on GitHub Actions Artifacts under bug.log)
code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpq9f8d2n2/Top/bug_01.v", line 47, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpq9f8d2n2/Top/bug_01.v", line 459, characters 0-76:
Error:
Cannot apply lemma (big_morph_in unit _ _ (unitr1 R^c) 
                      (invrM (R:=_)) (invr1 _))


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds
�[92m
Admitting Qeds successful.�[0m
Success!

I will now attempt to replace Qeds with admit. Defined.
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined. with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 47, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 422, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 47, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 422, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 47, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 422, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 47, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbj4nx06t/Top/bug_01.v", line 422, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to add Proof using lines
�[92m
Adding Proof using lines successful.�[0m
Failed to do everything at once; trying one at a time.
Adding Proof using lines unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation successful

I will now attempt to split imports and exports
Import/Export splitting successful

I will now attempt to split := definitions

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 28, 2026

Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.v in 5h 15m 7s (from ci-mathcomp) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-w" "+duplicate-clear" "-w" "+non-primitive-record" "-w" "+undeclared-scope" "-w" "+deprecated-hint-without-locality" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-projection-no-head-constant" "-w" "-redundant-canonical-projection" "-w" "-notation-overridden" "-w" "-ambiguous-paths" "-w" "-elpi.add-const-for-axiom-or-sectionvar" "-w" "-mathcomp-subset-itv" "-w" "+level-tolerance" "-w" "-notation-for-abbreviation" "-w" "-deprecated-native-compiler-option" "-native-compiler" "ondemand" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "mathcomp" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/HB" "HB" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2" "Ltac2" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi" "elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_elpi" "elpi_elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_examples" "elpi_examples" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2712 lines to 251 lines, then from 218 lines to 96 lines, then from 110 lines to 1271 lines, then from 1278 lines to 204 lines, then from 218 lines to 1752 lines, then from 1759 lines to 1577 lines, then from 1465 lines to 1176 lines *)
(* coqc version 9.3+alpha compiled with OCaml 4.14.2
   coqtop version 9.3+alpha
   Expected coqc runtime on this file: 27.839 sec
   Expected coqc peak memory usage on this file: 1301832.0 kb *)













Require Corelib.BinNums.PosDef.
Require Corelib.ssr.ssrfun.
Require Corelib.ssr.ssreflect.
Require Corelib.ssr.ssrbool.
Require Corelib.Init.Ltac.
Require elpi_elpi.dummy.
Require mathcomp.boot.ssrnotations.
Require elpi.elpi.
Require mathcomp.boot.ssreflect.
Require elpi.apps.locker.locker.
Require mathcomp.boot.ssrfun.
Require HB.structures.
Require mathcomp.boot.ssrbool.
Require mathcomp.boot.eqtype.
Require mathcomp.boot.ssrnat.
Require mathcomp.boot.seq.
Require mathcomp.boot.choice.
Require mathcomp.boot.div.
Require mathcomp.boot.path.
Require mathcomp.boot.fintype.
Require mathcomp.boot.tuple.
Require mathcomp.boot.finfun.
Require mathcomp.boot.bigop.
Require mathcomp.boot.finset.
Require mathcomp.boot.monoid.
Require mathcomp.boot.prime.
Require mathcomp.boot.nmodule.
Require mathcomp.boot.binomial.
Require mathcomp.order.preorder.
Require mathcomp.order.order.
Require mathcomp.algebra.alg.algebra.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.
Module mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Module Export divalg.

Import HB.structures.
Import mathcomp.boot.ssreflect.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.ssrnat.
Import mathcomp.boot.seq.
Import mathcomp.boot.div.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.bigop.
Import mathcomp.boot.prime.
Import mathcomp.boot.nmodule.
Import mathcomp.algebra.alg.algebra.

Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Local Open Scope ring_scope.

Module Import GRing.

Export GRing.

HB.mixin Record NzRing_hasMulInverse R & NzRing R := {
  unit_subdef : pred R;
  inv : R -> R;
  mulVr_subproof : {in unit_subdef, left_inverse 1 inv *%R};
  divrr_subproof : {in unit_subdef, right_inverse 1 inv *%R};
  unitrP_subproof : forall x y, y * x = 1 /\ x * y = 1 -> unit_subdef x;
  invr_out_subproof : {in [predC unit_subdef], inv =1 id}
}.

#[short(type="unitRingType")]
HB.structure Definition UnitRing := {R of NzRing_hasMulInverse R & NzRing R}.

Module Export UnitRingExports.
Bind Scope ring_scope with UnitRing.sort.
End UnitRingExports.
HB.export UnitRingExports.

Definition unit_pred {R : unitRingType} :=
  Eval cbv [ unit_subdef NzRing_hasMulInverse.unit_subdef ] in
    (fun u : R => unit_subdef u).
Arguments unit_pred _ _ /.
Definition unit {R : unitRingType} := [qualify a u : R | unit_pred u].

Local Notation "x ^-1" := (inv x).
Local Notation "x / y" := (x * y^-1).
Local Notation "x ^- n" := ((x ^+ n)^-1).

Section UnitRingTheory.

Variable R : unitRingType.
Implicit Types x y : R.

Lemma divrr : {in unit, right_inverse 1 (@inv R) *%R}.
Admitted.
Definition mulrV := divrr.

Lemma mulVr : {in unit, left_inverse 1 (@inv R) *%R}.
Admitted.

Lemma invr_out x : x \isn't a unit -> x^-1 = x.
Admitted.

Lemma unitrP x : reflect (exists y, y * x = 1 /\ x * y = 1) (x \is a unit).
Admitted.

Lemma mulKr : {in unit, left_loop (@inv R) *%R}.
Admitted.

Lemma mulVKr : {in unit, rev_left_loop (@inv R) *%R}.
Admitted.

Lemma mulrK : {in unit, right_loop (@inv R) *%R}.
Admitted.

Lemma mulrVK : {in unit, rev_right_loop (@inv R) *%R}.
Admitted.
Definition divrK := mulrVK.

Lemma mulrI : {in @unit R, right_injective *%R}.
Admitted.

Lemma mulIr : {in @unit R, left_injective *%R}.
Admitted.

Lemma telescope_prodr n m (f : nat -> R) :
    (forall k, n < k < m -> f k \is a unit) -> n < m ->
  \prod_(n <= k < m) (f k / f k.+1) = f n / f m.
Admitted.

Lemma telescope_prodr_eq n m (f u : nat -> R) : n < m ->
    (forall k, n < k < m -> f k \is a unit) ->
    (forall k, (n <= k < m)%N -> u k = f k / f k.+1) ->
  \prod_(n <= k < m) u k = f n / f m.
Admitted.

Lemma commrV x y : comm x y -> comm x y^-1.
Admitted.

Lemma unitrE x : (x \is a unit) = (x / x == 1).
Admitted.

Lemma invrK : involutive (@inv R).
Admitted.

Lemma invr_inj : injective (@inv R).
Admitted.

Lemma unitrV x : (x^-1 \in unit) = (x \in unit).
Admitted.

Lemma unitr1 : 1 \in @unit R.
Admitted.

Lemma invr1 : 1^-1 = 1 :> R.
Admitted.

Lemma div1r x : 1 / x = x^-1.
Admitted.
Lemma divr1 x : x / 1 = x.
Admitted.

Lemma natr_div m d :
  d %| m -> d%:R \is a @unit R -> (m %/ d)%:R = m%:R / d%:R :> R.
Admitted.

Lemma divrI : {in unit, right_injective (fun x y => x / y)}.
Admitted.

Lemma divIr : {in unit, left_injective (fun x y => x / y)}.
Admitted.

Lemma unitr0 : (0 \is a @unit R) = false.
Admitted.

Lemma invr0 : 0^-1 = 0 :> R.
Admitted.

Lemma unitrN1 : -1 \is a @unit R.
Admitted.

Lemma invrN1 : (-1)^-1 = -1 :> R.
Admitted.

Lemma invr_sign n : ((-1) ^- n) = (-1) ^+ n :> R.
Admitted.

Lemma unitrMl x y : y \is a unit -> (x * y \is a unit) = (x \is a unit).
Admitted.

Lemma unitrMr x y : x \is a unit -> (x * y \is a unit) = (y \is a unit).
Admitted.

Lemma unitr_prod {I : Type} (P : pred I) (E : I -> R) (r : seq I) :
  (forall i, P i -> E i \is a GRing.unit) ->
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma unitr_prod_in {I : eqType} (P : pred I) (E : I -> R) (r : seq I) :
  {in r, forall i, P i -> E i \is a GRing.unit} ->
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma invrM : {in unit &, forall x y, (x * y)^-1 = y^-1 * x^-1}.
Admitted.

Lemma unitrM_comm x y :
  comm x y -> (x * y \is a unit) = (x \is a unit) && (y \is a unit).
Admitted.

Lemma unitrX x n : x \is a unit -> x ^+ n \is a unit.
Admitted.

Lemma unitrX_pos x n : n > 0 -> (x ^+ n \in unit) = (x \in unit).
Admitted.

Lemma exprVn x n : x^-1 ^+ n = x ^- n.
Admitted.

Lemma exprB m n x : n <= m -> x \is a unit -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma invr_neq0 x : x != 0 -> x^-1 != 0.
Admitted.

Lemma invr_eq0 x : (x^-1 == 0) = (x == 0).
Admitted.

Lemma invr_eq1 x : (x^-1 == 1) = (x == 1).
Admitted.

Lemma rev_unitrP (x y : R^c) : y * x = 1 /\ x * y = 1 -> x \is a unit.
Admitted.

#[export]
HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R^c mulrV mulVr rev_unitrP invr_out.

#[export]
HB.instance Definition _ := UnitRing.on R^o.

End UnitRingTheory.

Arguments invrK {R}.
Arguments invr_inj {R} [x1 x2].
Arguments telescope_prodr_eq {R n m} f u.

Lemma rev_prodrV (R : unitRingType)
  (I : Type) (r : seq I) (P : pred I) (E : I -> R) :
  (forall i, P i -> E i \is a GRing.unit) ->
  \prod_(i <- r | P i) (E i)^-1 = ((\prod_(i <- r | P i) (E i : R^c))^-1).
Admitted.

Section UnitRingClosedPredicates.

Variables (R : unitRingType) (S : {pred R}).

Definition invr_closed := {in S, forall x, x^-1 \in S}.
Definition divr_2closed := {in S &, forall x y, x / y \in S}.
Definition divr_closed := 1 \in S /\ divr_2closed.
Definition sdivr_closed := -1 \in S /\ divr_2closed.
Definition divring_closed := [/\ 1 \in S, subr_closed S & divr_2closed].

Lemma divr_closedV : divr_closed -> invr_closed.
Admitted.

Lemma divr_closedM : divr_closed -> mulr_closed S.
Admitted.

Lemma sdivr_closed_div : sdivr_closed -> divr_closed.
Admitted.

Lemma sdivr_closedM : sdivr_closed -> smulr_closed S.
Admitted.

Lemma divring_closedBM : divring_closed -> subring_closed S.
Admitted.

Lemma divring_closed_div : divring_closed -> sdivr_closed.
Admitted.

End UnitRingClosedPredicates.

Section UnitRingMorphism.

Variables (R S : unitRingType) (f : {rmorphism R -> S}).

Lemma rmorph_unit x : x \in unit -> f x \in unit.
Admitted.

Lemma rmorphV : {in unit, {morph f: x / x^-1}}.
Admitted.

Lemma rmorph_div x y : y \in unit -> f (x / y) = f x / f y.
Admitted.

End UnitRingMorphism.

#[short(type="comUnitRingType")]
HB.structure Definition ComUnitRing := {R of ComNzRing R & UnitRing R}.

Module Export ComUnitRingExports.
Bind Scope ring_scope with ComUnitRing.sort.
End ComUnitRingExports.
HB.export ComUnitRingExports.

HB.factory Record ComNzRing_hasMulInverse R & ComNzRing R := {
  unit : {pred R};
  inv : R -> R;
  mulVx : {in unit, left_inverse 1 inv *%R};
  unitPl : forall x y, y * x = 1 -> unit x;
  invr_out : {in [predC unit], inv =1 id}
}.

HB.builders Context R & ComNzRing_hasMulInverse R.

Fact mulC_mulrV : {in unit, right_inverse 1 inv *%R}.
Admitted.

Fact mulC_unitP x y : y * x = 1 /\ x * y = 1 -> unit x.
Admitted.

HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R mulVx mulC_mulrV mulC_unitP invr_out.

HB.end.

#[short(type="unitAlgType")]
HB.structure Definition UnitAlgebra R := {V of NzAlgebra R V & UnitRing V}.

Module Export UnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End UnitAlgebraExports.
HB.export UnitAlgebraExports.

#[short(type="comUnitAlgType")]
HB.structure Definition ComUnitAlgebra R :=
  {V of ComNzAlgebra R V & UnitRing V}.

Module Export ComUnitAlgebraExports.
Bind Scope ring_scope with UnitAlgebra.sort.
End ComUnitAlgebraExports.
HB.export ComUnitAlgebraExports.

Section ComUnitRingTheory.

Variable R : comUnitRingType.
Implicit Types x y : R.

Lemma unitrM x y : (x * y \in unit) = (x \in unit) && (y \in unit).
Admitted.

Lemma unitrPr x : reflect (exists y, x * y = 1) (x \in unit).
Admitted.

Lemma mulr1_eq x y : x * y = 1 -> x^-1 = y.
Admitted.

Lemma divr1_eq x y : x / y = 1 -> x = y.
Admitted.

Lemma divKr x : x \is a unit -> {in unit, involutive (fun y => x / y)}.
Admitted.

Lemma expr_div_n x y n : (x / y) ^+ n = x ^+ n / y ^+ n.
Admitted.

Lemma unitr_prodP (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
  reflect {in r, forall i, P i -> E i \is a GRing.unit}
    (\prod_(i <- r | P i) E i \is a GRing.unit).
Admitted.

Lemma prodrV (I : eqType) (r : seq I) (P : pred I) (E : I -> R) :
  (forall i, P i -> E i \is a GRing.unit) ->
  \prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Admitted.

#[export] HB.instance Definition _ := ComUnitRing.on R^c.
#[export] HB.instance Definition _ := ComUnitRing.on R^o.

End ComUnitRingTheory.

Section UnitAlgebraTheory.

Variable (R : comUnitRingType) (A : unitAlgType R).
Implicit Types (k : R) (x y : A).

Lemma scaler_injl : {in unit, @right_injective R A A *:%R}.
Admitted.

Lemma scaler_unit k x : k \in unit -> (k *: x \in unit) = (x \in unit).
Admitted.

Lemma invrZ k x : k \in unit -> x \in unit -> (k *: x)^-1 = k^-1 *: x^-1.
Admitted.

Section ClosedPredicates.

Variables S : {pred A}.

Definition divalg_closed := [/\ 1 \in S, linear_closed S & divr_2closed S].

Lemma divalg_closedBdiv : divalg_closed -> divring_closed S.
Admitted.

Lemma divalg_closedZ : divalg_closed -> subalg_closed S.
Admitted.

End ClosedPredicates.

End UnitAlgebraTheory.

Module Export ClosedExports.

Notation invr_closed := invr_closed.
Notation divr_2closed := divr_2closed.
Notation divr_closed := divr_closed.
Notation sdivr_closed := sdivr_closed.
Notation divring_closed := divring_closed.
Notation divalg_closed := divalg_closed.

Coercion divr_closedV : divr_closed >-> invr_closed.
Coercion divr_closedM : divr_closed >-> mulr_closed.
Coercion sdivr_closed_div : sdivr_closed >-> divr_closed.
Coercion sdivr_closedM : sdivr_closed >-> smulr_closed.
Coercion divring_closedBM : divring_closed >-> subring_closed.
Coercion divring_closed_div : divring_closed >-> sdivr_closed.
Coercion divalg_closedBdiv : divalg_closed >-> divring_closed.
Coercion divalg_closedZ : divalg_closed >-> subalg_closed.

End ClosedExports.

Definition integral_domain_axiom (R : pzRingType) :=
  forall x y : R, x * y = 0 -> (x == 0) || (y == 0).

HB.mixin Record ComUnitRing_isIntegral R & ComUnitRing R := {
  mulf_eq0_subproof : integral_domain_axiom R;
}.

#[mathcomp(axiom="integral_domain_axiom"), short(type="idomainType")]
HB.structure Definition IntegralDomain :=
  {R of ComUnitRing_isIntegral R & ComUnitRing R}.

Module Export IntegralDomainExports.
Bind Scope ring_scope with IntegralDomain.sort.
End IntegralDomainExports.
HB.export IntegralDomainExports.

Section IntegralDomainTheory.

Variable R : idomainType.
Implicit Types x y : R.

Lemma mulf_eq0 x y : (x * y == 0) = (x == 0) || (y == 0).
Admitted.

Lemma prodf_eq0 (I : finType) (P : pred I) (F : I -> R) :
  reflect (exists2 i, P i & (F i == 0)) (\prod_(i | P i) F i == 0).
Admitted.

Lemma prodf_seq_eq0 I r (P : pred I) (F : I -> R) :
  (\prod_(i <- r | P i) F i == 0) = has (fun i => P i && (F i == 0)) r.
Admitted.

Lemma mulf_neq0 x y : x != 0 -> y != 0 -> x * y != 0.
Admitted.

Lemma prodf_neq0 (I : finType) (P : pred I) (F : I -> R) :
  reflect (forall i, P i -> (F i != 0)) (\prod_(i | P i) F i != 0).
Admitted.

Lemma prodf_seq_neq0 I r (P : pred I) (F : I -> R) :
  (\prod_(i <- r | P i) F i != 0) = all (fun i => P i ==> (F i != 0)) r.
Admitted.

Lemma expf_eq0 x n : (x ^+ n == 0) = (n > 0) && (x == 0).
Admitted.

Lemma sqrf_eq0 x : (x ^+ 2 == 0) = (x == 0).
Admitted.

Lemma expf_neq0 x m : x != 0 -> x ^+ m != 0.
Admitted.

Lemma natf_neq0_pchar n : (n%:R != 0 :> R) = (pchar R)^'.-nat n.
Admitted.

Lemma natf0_pchar n : n > 0 -> n%:R == 0 :> R -> exists p, p \in pchar R.
Admitted.

Lemma pcharf'_nat n : (pchar R)^'.-nat n = (n%:R != 0 :> R).
Admitted.

Lemma pcharf0P : pchar R =i pred0 <-> (forall n, (n%:R == 0 :> R) = (n == 0)%N).
Admitted.

Lemma eqf_sqr x y : (x ^+ 2 == y ^+ 2) = (x == y) || (x == - y).
Admitted.

Lemma mulfI x : x != 0 -> injective ( *%R x).
Admitted.

Lemma mulIf x : x != 0 -> injective ( *%R^~ x).
Admitted.

Lemma divfI x : x != 0 -> injective (fun y => x / y).
Admitted.

Lemma divIf y : y != 0 -> injective (fun x => x / y).
Admitted.

Lemma sqrf_eq1 x : (x ^+ 2 == 1) = (x == 1) || (x == -1).
Admitted.

Lemma expfS_eq1 x n :
  (x ^+ n.+1 == 1) = (x == 1) || (\sum_(i < n.+1) x ^+ i == 0).
Admitted.

Lemma lregP x : reflect (lreg x) (x != 0).
Admitted.

Lemma rregP x : reflect (rreg x) (x != 0).
Admitted.

#[export]
HB.instance Definition _ := IntegralDomain.on R^o.

End IntegralDomainTheory.

Arguments lregP {R x}.
Arguments rregP {R x}.

Definition field_axiom (R : unitRingType) := forall x : R, x != 0 -> x \in unit.

HB.mixin Record UnitRing_isField R & UnitRing R := {
  fieldP : field_axiom R;
}.

#[mathcomp(axiom="field_axiom"), short(type="fieldType")]
HB.structure Definition Field := { R of IntegralDomain R & UnitRing_isField R }.

Module Export FieldExports.
Bind Scope ring_scope with Field.sort.
End FieldExports.
HB.export FieldExports.

#[export] HB.instance Definition regular_field (F : fieldType) := Field.on F^o.

Lemma IdomainMixin (R : unitRingType): Field.axiom R -> IntegralDomain.axiom R.
Admitted.

HB.factory Record ComUnitRing_isField R & ComUnitRing R := {
  fieldP : field_axiom R;
}.
HB.builders Context R & ComUnitRing_isField R.
HB.instance Definition _ :=
  ComUnitRing_isIntegral.Build R (IdomainMixin fieldP).
HB.instance Definition _ := UnitRing_isField.Build R fieldP.
HB.end.

HB.factory Record ComNzRing_isField R & ComNzRing R := {
  inv : R -> R;
  mulVf : forall x, x != 0 -> inv x * x = 1;
  invr0 : inv 0 = 0;
}.

HB.builders Context R & ComNzRing_isField R.

Fact intro_unit (x y : R) : y * x = 1 -> x != 0.
Admitted.

Fact inv_out : {in predC (predC1 0), inv =1 id}.
Admitted.

HB.instance Definition _ : ComNzRing_hasMulInverse R :=
  ComNzRing_hasMulInverse.Build R mulVf intro_unit inv_out.

HB.instance Definition _ : ComUnitRing_isField R :=
  ComUnitRing_isField.Build R (fun x x_neq_0 => x_neq_0).

HB.end.

Section FieldTheory.

Variable F : fieldType.
Implicit Types x y : F.

Lemma unitfE x : (x \in unit) = (x != 0).
Admitted.

Lemma mulVf x : x != 0 -> x^-1 * x = 1.
Admitted.
Lemma divff x : x != 0 -> x / x = 1.
Admitted.
Definition mulfV := divff.
Lemma mulKf x : x != 0 -> cancel ( *%R x) ( *%R x^-1).
Admitted.
Lemma mulVKf x : x != 0 -> cancel ( *%R x^-1) ( *%R x).
Admitted.
Lemma mulfK x : x != 0 -> cancel ( *%R^~ x) ( *%R^~ x^-1).
Admitted.
Lemma mulfVK x : x != 0 -> cancel ( *%R^~ x^-1) ( *%R^~ x).
Admitted.
Definition divfK := mulfVK.

Lemma invfM : {morph @inv F : x y / x * y}.
Admitted.

Lemma invf_div x y : (x / y)^-1 = y / x.
Admitted.

Lemma divKf x : x != 0 -> involutive (fun y => x / y).
Admitted.

Lemma expfB_cond m n x : (x == 0) + n <= m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma expfB m n x : n < m -> x ^+ (m - n) = x ^+ m / x ^+ n.
Admitted.

Lemma prodfV I r (P : pred I) (E : I -> F) :
  \prod_(i <- r | P i) (E i)^-1 = (\prod_(i <- r | P i) E i)^-1.
Admitted.

Lemma prodf_div I r (P : pred I) (E D : I -> F) :
  \prod_(i <- r | P i) (E i / D i) =
     \prod_(i <- r | P i) E i / \prod_(i <- r | P i) D i.
Admitted.

Lemma telescope_prodf n m (f : nat -> F) :
    (forall k, n < k < m -> f k != 0) -> n < m ->
  \prod_(n <= k < m) (f k.+1 / f k) = f m / f n.
Admitted.

Lemma telescope_prodf_eq n m (f u : nat -> F) :
    (forall k, n < k < m -> f k != 0) -> n < m ->
    (forall k, n <= k < m -> u k = f k.+1 / f k) ->
  \prod_(n <= k < m) u k = f m / f n.
Admitted.

Lemma addf_div x1 y1 x2 y2 :
  y1 != 0 -> y2 != 0 -> x1 / y1 + x2 / y2 = (x1 * y2 + x2 * y1) / (y1 * y2).
Admitted.

Lemma mulf_div x1 y1 x2 y2 : (x1 / y1) * (x2 / y2) = (x1 * x2) / (y1 * y2).
Admitted.

Lemma eqr_div x y z t : y != 0 -> t != 0 -> (x / y == z / t) = (x * t == z * y).
Admitted.

Lemma eqr_sum_div I r P (f : I -> F) c a : c != 0 ->
  (\big[+%R/0]_(x <- r | P x) (f x / c) == a)
  = (\big[+%R/0]_(x <- r | P x) f x == a * c).
Admitted.

Lemma pchar0_natf_div :
  pchar F =i pred0 -> forall m d, d %| m -> (m %/ d)%:R = m%:R / d%:R :> F.
Admitted.

Section FieldMorphismInj.

Variables (R : nzRingType) (f : {rmorphism F -> R}).

Lemma fmorph_eq0 x : (f x == 0) = (x == 0).
Admitted.

Lemma fmorph_inj : injective f.
Admitted.

Lemma fmorph_eq : {mono f : x y / x == y}.
Admitted.

Lemma fmorph_eq1 x : (f x == 1) = (x == 1).
Admitted.

Lemma fmorph_pchar : pchar R =i pchar F.
Admitted.

End FieldMorphismInj.

Section FieldMorphismInv.

Variables (R : unitRingType) (f : {rmorphism F -> R}).

Lemma fmorph_unit x : (f x \in unit) = (x != 0).
Admitted.

Lemma fmorphV : {morph f: x / x^-1}.
Admitted.

Lemma fmorph_div : {morph f : x y / x / y}.
Admitted.

End FieldMorphismInv.

Section ModuleTheory.

Variable V : lmodType F.
Implicit Types (a : F) (v : V).

Lemma scalerK a : a != 0 -> cancel ( *:%R a : V -> V) ( *:%R a^-1).
Admitted.

Lemma scalerKV a : a != 0 -> cancel ( *:%R a^-1 : V -> V) ( *:%R a).
Admitted.

Lemma scalerI a : a != 0 -> injective ( *:%R a : V -> V).
Admitted.

Lemma scaler_eq0 a v : (a *: v == 0) = (a == 0) || (v == 0).
Admitted.

End ModuleTheory.

Lemma pchar_lalg (A : nzLalgType F) : pchar A =i pchar F.
Admitted.

End FieldTheory.

Arguments fmorph_inj {F R} f [x1 x2].
Arguments telescope_prodf_eq {F n m} f u.

HB.mixin Record isInvClosed (R : unitRingType) (S : {pred R}) := {
  rpredVr : invr_closed S
}.

#[short(type="divClosed")]
HB.structure Definition DivClosed (R : unitRingType) :=
  {S of MulClosed R S & isInvClosed R S}.

#[short(type="sdivClosed")]
HB.structure Definition SdivClosed (R : unitRingType) :=
  {S of SmulClosed R S & isInvClosed R S}.

#[short(type="divringClosed")]
HB.structure Definition DivringClosed (R : unitRingType) :=
  {S of SubringClosed R S & isInvClosed R S}.

#[short(type="divalgClosed")]
HB.structure Definition DivalgClosed (R : nzRingType) (A : unitAlgType R) :=
  {S of DivringClosed A S & isScaleClosed R A S}.

HB.factory Record isDivClosed (R : unitRingType) (S : R -> bool) := {
  divr_closed_subproof : divr_closed S
}.

HB.builders Context R S & isDivClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
  (divr_closedM divr_closed_subproof).
HB.instance Definition _ := isInvClosed.Build R S
  (divr_closedV divr_closed_subproof).
HB.end.

HB.factory Record isSdivClosed (R : unitRingType) (S : R -> bool) := {
  sdivr_closed_subproof : sdivr_closed S
}.

HB.builders Context R S & isSdivClosed R S.
HB.instance Definition _ := isDivClosed.Build R S
  (sdivr_closed_div sdivr_closed_subproof).
HB.instance Definition _ := isSmulClosed.Build R S
  (sdivr_closedM sdivr_closed_subproof).
HB.end.

HB.factory Record isDivringClosed (R : unitRingType) (S : R -> bool) := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S & isDivringClosed R S.
HB.instance Definition _ := isSubringClosed.Build R S
  (divring_closedBM divring_closed_subproof).
HB.instance Definition _ := isSdivClosed.Build R S
  (divring_closed_div divring_closed_subproof).
HB.end.

HB.factory Record isDivalgClosed (R : comUnitRingType) (A : unitAlgType R)
    (S : A -> bool) := {
  divalg_closed_subproof : divalg_closed S
}.

HB.builders Context R A S & isDivalgClosed R A S.
HB.instance Definition _ := isDivringClosed.Build A S
  (divalg_closedBdiv divalg_closed_subproof).
HB.instance Definition _ := isSubalgClosed.Build R A S
  (subalg_closed_semi (divalg_closedZ divalg_closed_subproof)).
HB.end.

Section UnitRingPred.

Variable R : unitRingType.

Section Div.

Variable S : divClosed R.

Lemma rpredV x : (x^-1 \in S) = (x \in S).
Admitted.

Lemma rpred_div : {in S &, forall x y, x / y \in S}.
Admitted.

Lemma rpredXN n : {in S, forall x, x ^- n \in S}.
Admitted.

Lemma rpredMl x y : x \in S -> x \is a unit-> (x * y \in S) = (y \in S).
Admitted.

Lemma rpredMr x y : x \in S -> x \is a unit -> (y * x \in S) = (y \in S).
Admitted.

Lemma rpred_divr x y : x \in S -> x \is a unit -> (y / x \in S) = (y \in S).
Admitted.

Lemma rpred_divl x y : x \in S -> x \is a unit -> (x / y \in S) = (y \in S).
Admitted.

End Div.

Lemma divringClosedP (divS : divringClosed R) : divring_closed divS.
Admitted.

Fact unitr_sdivr_closed : @sdivr_closed R unit.
Admitted.

#[export]
HB.instance Definition _ := isSdivClosed.Build R unit_pred unitr_sdivr_closed.

Implicit Type x : R.

Lemma unitrN x : (- x \is a unit) = (x \is a unit).
Admitted.

Lemma invrN x : (- x)^-1 = - x^-1.
Admitted.

Lemma divrNN x y : (- x) / (- y) = x / y.
Admitted.

Lemma divrN x y : x / (- y) = - (x / y).
Admitted.

Lemma invr_signM n x : ((-1) ^+ n * x)^-1 = (-1) ^+ n * x^-1.
Admitted.

End UnitRingPred.

Section FieldPred.

Section ModuleTheory.

End ModuleTheory.

Section Predicates.

End Predicates.

End FieldPred.

#[short(type="subUnitRingType")]
HB.structure Definition SubUnitRing (R : nzRingType) (S : pred R) :=
  {U of SubNzRing R S U & UnitRing U}.

HB.factory Record SubNzRing_isSubUnitRing (R : unitRingType) S U
    & SubNzRing R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubNzRing_isSubUnitRing R S U.

HB.instance Definition _ := isDivringClosed.Build R S divring_closed_subproof.

Let inU v Sv : U := Sub v Sv.
Let invU (u : U) := inU (rpredVr _ (valP u)).

Lemma mulVr : {in [pred x | val x \is a unit], left_inverse 1 invU *%R}.
Admitted.
Lemma divrr : {in [pred x | val x \is a unit], right_inverse 1 invU *%R}.
Admitted.
Lemma unitrP (x y : U) : y * x = 1 /\ x * y = 1 -> val x \is a unit.
Admitted.
Lemma invr_out : {in [pred x | val x \isn't a unit], invU =1 id}.
Admitted.
HB.instance Definition _ := NzRing_hasMulInverse.Build U
  mulVr divrr unitrP invr_out.
HB.end.

#[short(type="subComUnitRingType")]
HB.structure Definition SubComUnitRing (R : comUnitRingType) (S : pred R) :=
  {U of SubComNzRing R S U & SubUnitRing R S U}.

#[short(type="subIdomainType")]
HB.structure Definition SubIntegralDomain (R : idomainType) (S : pred R) :=
  {U of SubComNzRing R S U & IntegralDomain U}.

HB.factory Record SubComUnitRing_isSubIntegralDomain (R : idomainType) S U
  & SubComUnitRing R S U := {}.

HB.builders Context R S U & SubComUnitRing_isSubIntegralDomain R S U.
Lemma id : IntegralDomain.axiom U.
Admitted.
HB.instance Definition _ := ComUnitRing_isIntegral.Build U id.
HB.end.

HB.factory Record SubIntegralDomain_isSubField (F : fieldType) S U
    & SubIntegralDomain F S U := {
  subfield_subproof : {mono (val : U -> F) : u / u \in unit}
}.

HB.builders Context F S U & SubIntegralDomain_isSubField F S U.
Lemma fieldP : Field.axiom U.
Admitted.
HB.instance Definition _ := UnitRing_isField.Build U fieldP.
HB.end.

HB.factory Record SubChoice_isSubUnitRing (R : unitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.end.

HB.factory Record SubChoice_isSubComUnitRing (R : comUnitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubComUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubComNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.end.

HB.factory Record SubChoice_isSubIntegralDomain (R : idomainType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubIntegralDomain R S U.
HB.instance Definition _ := SubChoice_isSubComUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

Module Export SubExports.

End SubExports.

Module Export Theory.

End Theory.

Module Export AllExports.
HB.reexport.
End AllExports.

End GRing.

Export AllExports.

Section PairUnitRing.

End PairUnitRing.

End divalg.

End mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Include mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.divalg.

Module mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Module Export orderedzmod.

Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Local Open Scope ring_scope.

Fact ring_display : Order.disp_t.
Admitted.

Module Export Num.

#[short(type="porderNmodType")]
HB.structure Definition POrderNmodule :=
  { R of Order.isPOrder ring_display R & GRing.Nmodule R}.

#[short(type="porderZmodType")]
HB.structure Definition POrderZmodule :=
  { R of POrderNmodule R & GRing.Zmodule R }.

HB.mixin Record Add_isHomo R & POrderNmodule R := {
  ler_wD2l : forall x : R, {homo +%R x : y z / (y <= z)%O}
}.

#[short(type="porderedNmodType")]
HB.structure Definition POrderedNmodule :=
  { R of POrderNmodule R & Add_isHomo R}.

#[short(type="porderedZmodType")]
HB.structure Definition POrderedZmodule :=
  { R of GRing.Zmodule R & POrderedNmodule R}.

HB.factory Record ZmodulePositiveCone R & GRing.Zmodule R := {
  nonneg : {pred R};
  nonneg0 : nonneg 0;
  nonnegD : forall x y, nonneg x -> nonneg y -> nonneg (x + y);
  nonneg_definite : forall x, nonneg x -> nonneg (- x) -> x = 0;
}.

HB.builders Context R & ZmodulePositiveCone R.

Definition le x y := nonneg (y - x).

Fact le_refl : reflexive le.
Admitted.

Fact le_anti : antisymmetric le.
Admitted.

Fact le_trans : transitive le.
Admitted.

HB.instance Definition _ := Order.Le_isPOrder.Build ring_display R
  le_refl le_anti le_trans.

HB.end.

HB.mixin Record POrderedZmodule_hasTransCmp R & GRing.Nmodule R
    & Order.isPOrder ring_display R := {
  comparabler_trans : transitive (Order.comparable : rel R)
}.

#[short(type="numZmodType")]
HB.structure Definition NumZmodule :=
  {R of POrderedZmodule_hasTransCmp R & POrderedZmodule R}.

Notation ler := (@Order.le ring_display _) (only parsing).
Notation ltr := (@Order.lt ring_display _) (only parsing).
Notation lerif := (@Order.leif ring_display _) (only parsing).

Notation le := ler (only parsing).
Notation lt := ltr (only parsing).

Module Import Syntax.

Notation "x <= y" := (le x y) : ring_scope.

Notation "x < y"  := (lt x y) : ring_scope.

Notation "x <= y ?= 'iff' C" := (lerif x y C) : ring_scope.

End Syntax.
End Num.
Export Num.Syntax.

End orderedzmod.

End mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Include mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.orderedzmod.
Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Set Implicit Arguments.
Unset Strict Implicit.

Local Open Scope ring_scope.

HB.mixin Record Zmodule_isSemiNormed (R : POrderZmodule.type) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.

#[short(type="semiNormedZmodType")]
HB.structure Definition SemiNormedZmodule (R : porderZmodType) :=
  { M of Zmodule_isSemiNormed R M & GRing.Zmodule M }.

HB.mixin Record SemiNormedZmodule_isPositiveDefinite
    (R : POrderZmodule.type) M & @SemiNormedZmodule R M := {
  normr0_eq0 : forall x : M, norm x = 0 -> x = 0;
}.

#[short(type="normedZmodType")]
HB.structure Definition NormedZmodule (R : porderZmodType) :=
  { M of SemiNormedZmodule_isPositiveDefinite R M & SemiNormedZmodule R M }.

HB.factory Record Zmodule_isNormed (R : porderZmodType) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normr0_eq0 : forall x, norm x = 0 -> x = 0;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.
HB.builders Context (R : POrderZmodule.type) M & Zmodule_isNormed R M.
  HB.instance Definition _ :=
    Zmodule_isSemiNormed.Build R M ler_normD normrMn normrN.
HB.end.

HB.mixin Record NumZmod_isNumRing R & GRing.NzRing R & POrderZmodule R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.

#[short(type="numDomainType")]
HB.structure Definition NumDomain := { R of
     GRing.IntegralDomain R &
     NumZmodule R &
     NormedZmodule (POrderZmodule.clone R _) R &
     NumZmod_isNumRing R
  }.

HB.factory Record isNumRing R & GRing.NzRing R & POrderZmodule R
  & GRing.IntegralDomain R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.
HB.builders Context R & isNumRing R.

Fact ler_wD2l (x : R) : {homo +%R x : y z / y <= z}.
Admitted.

HB.instance Definition _ := Add_isHomo.Build R ler_wD2l.
HB.end.

Section NumDomainOperationTheory.

Variable R : numDomainType.

Lemma leif_AGM_scaled (I : finType) (A : {pred I}) (E : I -> R) (n := #|A|) :
    {in A, forall i, 0 <= E i *+ n} ->
  \prod_(i in A) (E i *+ n) <= (\sum_(i in A) E i) ^+ n
                            ?= iff [forall i in A, forall j in A, E i == E j].
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 4.0MiB file on GitHub Actions Artifacts under build.log)
 '[' '' ']'
+ COQ_CI_COLOR=
+ export GIT_PAGER=
+ GIT_PAGER=
+ '[' '' = 1 ']'
+ '[' '' = 1 ']'
+ bash /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-mathcomp.sh
+ tee _build_ci/mathcomp.log
++ set -e
++ : 2
++ export NJOBS
+++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-common.sh
++ . /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ which cygpath
+++ OCAMLFINDSEP=:
+++ '[' /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh ']'
++++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ root=/github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ cd /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ echo /builds/coq/coq
+++ root=/builds/coq/coq
+++ '[' -n 1 ']'
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ export OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
+++ export CI_BRANCH=
+++ CI_BRANCH=
+++ [[ '' =~ ^[0-9]*$ ]]
+++ export CI_PULL_REQUEST=
+++ CI_PULL_REQUEST=
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ declare -A overlays
++ set +x
+ git_download mathcomp
+ local project=mathcomp
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local giturl_var=mathcomp_CI_GITURL
+ local giturl=https://github.com/math-comp/math-comp
+ local ref_var=mathcomp_CI_REF
+ local ref=master
+ local parent_project_var=mathcomp_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=mathcomp_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp ']'
+ echo 'Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.'
Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.
+ '[' '' ']'
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ make
+ '[' -z x ']'
+ command make
"/github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq" makefile  -f Make -o Makefile.coq
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
         use ROCQRUNTIMELIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
make -f Makefile.coq --no-print-directory
ROCQ compile algebra/num_theory/numdomain.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////rocq
MINIMIZER_DEBUG_EXTRA: original invocation: '' 
MINIMIZER_DEBUG_EXTRA: new invocation: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: ocamlpath: /github/workspace/builds/coq/coq-failing/_install_ci/lib:
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqlib: Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.Ig4sPPdwBR
MINIMIZER_DEBUG: files:  algebra/num_theory/numdomain.v /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.vWarning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]Warning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "./algebra/num_theory/numdomain.v", line 1904, characters 63-76:
Error: In term, tolerating this expression at a higher level than expected by
the notation started on the left. This tolerance will be eventually removed.
Insert parentheses or try to lower the level at which the top symbol of this
expression is parsed.
[level-tolerance,deprecated-since-9.2,deprecated,parsing,default]

Command exited with non-zero status 1
algebra/num_theory/numdomain.vo (real: 19.32, user: 18.45, sys: 0.17, mem: 1087172 ko)
make[2]: *** [Makefile.coq:815: algebra/num_theory/numdomain.vo] Error 1
make[2]: *** [algebra/num_theory/numdomain.vo] Deleting file 'algebra/num_theory/numdomain.glob'
make[1]: *** [Makefile.coq:411: all] Error 2
make: *** [Makefile.common:99: this-build] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' mathcomp 2
+ '[' mathcomp '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real _build_ci/mathcomp.log
    Time |   Peak Mem | File Name                      
-------------------------------------------------------
0m19.32s | 1087172 ko | Total Time / Peak Mem          
-------------------------------------------------------
0m19.32s | 1087172 ko | algebra/num_theory/numdomain.vo
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 56KiB file on GitHub Actions Artifacts under bug.log)
B,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 51, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 192, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined.
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined. with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 51, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 192, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 51, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 192, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 51, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 192, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 51, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpld4eb7_8/Top/bug_01.v", line 192, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to add Proof using lines
�[92m
Adding Proof using lines successful.�[0m
Failed to do everything at once; trying one at a time.
Adding Proof using lines unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to remove all lines, one at a time

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 28, 2026

Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.v in 5h 15m 8s (from ci-mathcomp) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-w" "+duplicate-clear" "-w" "+non-primitive-record" "-w" "+undeclared-scope" "-w" "+deprecated-hint-without-locality" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-projection-no-head-constant" "-w" "-redundant-canonical-projection" "-w" "-notation-overridden" "-w" "-ambiguous-paths" "-w" "-elpi.add-const-for-axiom-or-sectionvar" "-w" "-mathcomp-subset-itv" "-w" "+level-tolerance" "-w" "-notation-for-abbreviation" "-w" "-deprecated-native-compiler-option" "-native-compiler" "ondemand" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "mathcomp" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/HB" "HB" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2" "Ltac2" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi" "elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_elpi" "elpi_elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_examples" "elpi_examples" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2712 lines to 251 lines, then from 218 lines to 96 lines, then from 110 lines to 1271 lines, then from 1278 lines to 204 lines, then from 218 lines to 1752 lines, then from 1759 lines to 1577 lines, then from 1465 lines to 1176 lines, then from 1175 lines to 534 lines *)
(* coqc version 9.3+alpha compiled with OCaml 4.14.2
   coqtop version 9.3+alpha
   Expected coqc runtime on this file: 24.974 sec
   Expected coqc peak memory usage on this file: 1299628.0 kb *)
Require mathcomp.order.order.
Require mathcomp.algebra.alg.algebra.
Module mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Module Export divalg.

Import HB.structures.
Import mathcomp.boot.ssreflect.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.algebra.alg.algebra.

Set Implicit Arguments.
Unset Strict Implicit.

Local Open Scope ring_scope.

Module Import GRing.

Export GRing.

HB.mixin Record NzRing_hasMulInverse R & NzRing R := {
  unit_subdef : pred R;
  inv : R -> R;
  mulVr_subproof : {in unit_subdef, left_inverse 1 inv *%R};
  divrr_subproof : {in unit_subdef, right_inverse 1 inv *%R};
  unitrP_subproof : forall x y, y * x = 1 /\ x * y = 1 -> unit_subdef x;
  invr_out_subproof : {in [predC unit_subdef], inv =1 id}
}.

#[short(type="unitRingType")]
HB.structure Definition UnitRing := {R of NzRing_hasMulInverse R & NzRing R}.

Module Export UnitRingExports.
End UnitRingExports.

Definition unit_pred {R : unitRingType} :=
  Eval cbv [ unit_subdef NzRing_hasMulInverse.unit_subdef ] in
    (fun u : R => unit_subdef u).
Definition unit {R : unitRingType} := [qualify a u : R | unit_pred u].

Local Notation "x ^-1" := (inv x).
Local Notation "x / y" := (x * y^-1).

Section UnitRingClosedPredicates.

Variables (R : unitRingType) (S : {pred R}).

Definition invr_closed := {in S, forall x, x^-1 \in S}.
Definition divr_2closed := {in S &, forall x y, x / y \in S}.
Definition divr_closed := 1 \in S /\ divr_2closed.
Definition sdivr_closed := -1 \in S /\ divr_2closed.
Definition divring_closed := [/\ 1 \in S, subr_closed S & divr_2closed].

Lemma divr_closedV : divr_closed -> invr_closed.
Admitted.

Lemma divr_closedM : divr_closed -> mulr_closed S.
Admitted.

Lemma sdivr_closed_div : sdivr_closed -> divr_closed.
Admitted.

Lemma divring_closedBM : divring_closed -> subring_closed S.
Admitted.

Lemma divring_closed_div : divring_closed -> sdivr_closed.
Admitted.

End UnitRingClosedPredicates.

#[short(type="comUnitRingType")]
HB.structure Definition ComUnitRing := {R of ComNzRing R & UnitRing R}.

Module Export ComUnitRingExports.
End ComUnitRingExports.

HB.factory Record ComNzRing_hasMulInverse R & ComNzRing R := {
  unit : {pred R};
  inv : R -> R;
  mulVx : {in unit, left_inverse 1 inv *%R};
  unitPl : forall x y, y * x = 1 -> unit x;
  invr_out : {in [predC unit], inv =1 id}
}.

HB.builders Context R & ComNzRing_hasMulInverse R.

Fact mulC_mulrV : {in unit, right_inverse 1 inv *%R}.
Admitted.

Fact mulC_unitP x y : y * x = 1 /\ x * y = 1 -> unit x.
Admitted.

HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R mulVx mulC_mulrV mulC_unitP invr_out.

HB.end.

#[short(type="unitAlgType")]
HB.structure Definition UnitAlgebra R := {V of NzAlgebra R V & UnitRing V}.

Module Export UnitAlgebraExports.
End UnitAlgebraExports.

Module Export ComUnitAlgebraExports.
End ComUnitAlgebraExports.

Section UnitAlgebraTheory.

Variable (R : comUnitRingType) (A : unitAlgType R).

Variables S : {pred A}.

Definition divalg_closed := [/\ 1 \in S, linear_closed S & divr_2closed S].

Lemma divalg_closedBdiv : divalg_closed -> divring_closed S.
Admitted.

End UnitAlgebraTheory.

Module Export ClosedExports.

End ClosedExports.

Definition integral_domain_axiom (R : pzRingType) :=
  forall x y : R, x * y = 0 -> (x == 0) || (y == 0).

HB.mixin Record ComUnitRing_isIntegral R & ComUnitRing R := {
  mulf_eq0_subproof : integral_domain_axiom R;
}.

#[mathcomp(axiom="integral_domain_axiom"), short(type="idomainType")]
HB.structure Definition IntegralDomain :=
  {R of ComUnitRing_isIntegral R & ComUnitRing R}.

Module Export IntegralDomainExports.
End IntegralDomainExports.

Definition field_axiom (R : unitRingType) := forall x : R, x != 0 -> x \in unit.

HB.mixin Record UnitRing_isField R & UnitRing R := {
  fieldP : field_axiom R;
}.

#[mathcomp(axiom="field_axiom"), short(type="fieldType")]
HB.structure Definition Field := { R of IntegralDomain R & UnitRing_isField R }.

Module Export FieldExports.
End FieldExports.

Lemma IdomainMixin (R : unitRingType): Field.axiom R -> IntegralDomain.axiom R.
Admitted.

HB.factory Record ComUnitRing_isField R & ComUnitRing R := {
  fieldP : field_axiom R;
}.
HB.builders Context R & ComUnitRing_isField R.
HB.instance Definition _ :=
  ComUnitRing_isIntegral.Build R (IdomainMixin fieldP).
HB.end.

HB.factory Record ComNzRing_isField R & ComNzRing R := {
  inv : R -> R;
  mulVf : forall x, x != 0 -> inv x * x = 1;
  invr0 : inv 0 = 0;
}.

HB.builders Context R & ComNzRing_isField R.

Fact intro_unit (x y : R) : y * x = 1 -> x != 0.
Admitted.

Fact inv_out : {in predC (predC1 0), inv =1 id}.
Admitted.

HB.instance Definition _ : ComNzRing_hasMulInverse R :=
  ComNzRing_hasMulInverse.Build R mulVf intro_unit inv_out.

HB.end.

HB.mixin Record isInvClosed (R : unitRingType) (S : {pred R}) := {
  rpredVr : invr_closed S
}.

#[short(type="divClosed")]
HB.structure Definition DivClosed (R : unitRingType) :=
  {S of MulClosed R S & isInvClosed R S}.

HB.factory Record isDivClosed (R : unitRingType) (S : R -> bool) := {
  divr_closed_subproof : divr_closed S
}.

HB.builders Context R S & isDivClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
  (divr_closedM divr_closed_subproof).
HB.instance Definition _ := isInvClosed.Build R S
  (divr_closedV divr_closed_subproof).
HB.end.

HB.factory Record isSdivClosed (R : unitRingType) (S : R -> bool) := {
  sdivr_closed_subproof : sdivr_closed S
}.

HB.builders Context R S & isSdivClosed R S.
HB.instance Definition _ := isDivClosed.Build R S
  (sdivr_closed_div sdivr_closed_subproof).
HB.end.

HB.factory Record isDivringClosed (R : unitRingType) (S : R -> bool) := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S & isDivringClosed R S.
HB.instance Definition _ := isSdivClosed.Build R S
  (divring_closed_div divring_closed_subproof).
HB.end.

HB.factory Record isDivalgClosed (R : comUnitRingType) (A : unitAlgType R)
    (S : A -> bool) := {
  divalg_closed_subproof : divalg_closed S
}.

HB.builders Context R A S & isDivalgClosed R A S.
HB.instance Definition _ := isDivringClosed.Build A S
  (divalg_closedBdiv divalg_closed_subproof).
HB.end.

Section ModuleTheory.

End ModuleTheory.

Section Predicates.

End Predicates.

#[short(type="subUnitRingType")]
HB.structure Definition SubUnitRing (R : nzRingType) (S : pred R) :=
  {U of SubNzRing R S U & UnitRing U}.

HB.factory Record SubNzRing_isSubUnitRing (R : unitRingType) S U
    & SubNzRing R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubNzRing_isSubUnitRing R S U.

HB.instance Definition _ := isDivringClosed.Build R S divring_closed_subproof.

Let inU v Sv : U := Sub v Sv.
Let invU (u : U) := inU (rpredVr _ (valP u)).

Lemma mulVr : {in [pred x | val x \is a unit], left_inverse 1 invU *%R}.
Admitted.
Lemma divrr : {in [pred x | val x \is a unit], right_inverse 1 invU *%R}.
Admitted.
Lemma unitrP (x y : U) : y * x = 1 /\ x * y = 1 -> val x \is a unit.
Admitted.
Lemma invr_out : {in [pred x | val x \isn't a unit], invU =1 id}.
Admitted.
HB.instance Definition _ := NzRing_hasMulInverse.Build U
  mulVr divrr unitrP invr_out.
HB.end.

#[short(type="subComUnitRingType")]
HB.structure Definition SubComUnitRing (R : comUnitRingType) (S : pred R) :=
  {U of SubComNzRing R S U & SubUnitRing R S U}.

#[short(type="subIdomainType")]
HB.structure Definition SubIntegralDomain (R : idomainType) (S : pred R) :=
  {U of SubComNzRing R S U & IntegralDomain U}.

HB.factory Record SubComUnitRing_isSubIntegralDomain (R : idomainType) S U
  & SubComUnitRing R S U := {}.

HB.builders Context R S U & SubComUnitRing_isSubIntegralDomain R S U.
Lemma id : IntegralDomain.axiom U.
Admitted.
HB.instance Definition _ := ComUnitRing_isIntegral.Build U id.
HB.end.

HB.factory Record SubIntegralDomain_isSubField (F : fieldType) S U
    & SubIntegralDomain F S U := {
  subfield_subproof : {mono (val : U -> F) : u / u \in unit}
}.

HB.builders Context F S U & SubIntegralDomain_isSubField F S U.
Lemma fieldP : Field.axiom U.
Admitted.
HB.instance Definition _ := UnitRing_isField.Build U fieldP.
HB.end.

HB.factory Record SubChoice_isSubUnitRing (R : unitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.end.

HB.factory Record SubChoice_isSubComUnitRing (R : comUnitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubComUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubComNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.end.

HB.factory Record SubChoice_isSubIntegralDomain (R : idomainType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubIntegralDomain R S U.
HB.instance Definition _ := SubChoice_isSubComUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

Module Export SubExports.

End SubExports.

Module Export Theory.

End Theory.

Module Export AllExports.
HB.reexport.
End AllExports.

End GRing.

Export AllExports.

Section PairUnitRing.

End PairUnitRing.

End divalg.

End mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Include mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.divalg.

Module mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Module Export orderedzmod.

Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Local Open Scope ring_scope.

Fact ring_display : Order.disp_t.
Admitted.

Module Export Num.

#[short(type="porderNmodType")]
HB.structure Definition POrderNmodule :=
  { R of Order.isPOrder ring_display R & GRing.Nmodule R}.

#[short(type="porderZmodType")]
HB.structure Definition POrderZmodule :=
  { R of POrderNmodule R & GRing.Zmodule R }.

HB.mixin Record Add_isHomo R & POrderNmodule R := {
  ler_wD2l : forall x : R, {homo +%R x : y z / (y <= z)%O}
}.

#[short(type="porderedNmodType")]
HB.structure Definition POrderedNmodule :=
  { R of POrderNmodule R & Add_isHomo R}.

#[short(type="porderedZmodType")]
HB.structure Definition POrderedZmodule :=
  { R of GRing.Zmodule R & POrderedNmodule R}.

HB.factory Record ZmodulePositiveCone R & GRing.Zmodule R := {
  nonneg : {pred R};
  nonneg0 : nonneg 0;
  nonnegD : forall x y, nonneg x -> nonneg y -> nonneg (x + y);
  nonneg_definite : forall x, nonneg x -> nonneg (- x) -> x = 0;
}.

HB.builders Context R & ZmodulePositiveCone R.

Definition le x y := nonneg (y - x).

Fact le_refl : reflexive le.
Admitted.

Fact le_anti : antisymmetric le.
Admitted.

Fact le_trans : transitive le.
Admitted.

HB.instance Definition _ := Order.Le_isPOrder.Build ring_display R
  le_refl le_anti le_trans.

HB.end.

HB.mixin Record POrderedZmodule_hasTransCmp R & GRing.Nmodule R
    & Order.isPOrder ring_display R := {
  comparabler_trans : transitive (Order.comparable : rel R)
}.

#[short(type="numZmodType")]
HB.structure Definition NumZmodule :=
  {R of POrderedZmodule_hasTransCmp R & POrderedZmodule R}.

Notation ler := (@Order.le ring_display _) (only parsing).
Notation ltr := (@Order.lt ring_display _) (only parsing).
Notation lerif := (@Order.leif ring_display _) (only parsing).

Notation le := ler (only parsing).
Notation lt := ltr (only parsing).

Module Import Syntax.

Notation "x <= y" := (le x y) : ring_scope.

Notation "x < y"  := (lt x y) : ring_scope.

Notation "x <= y ?= 'iff' C" := (lerif x y C) : ring_scope.

End Syntax.
End Num.
Export Num.Syntax.

End orderedzmod.

End mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Include mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.orderedzmod.
Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Set Implicit Arguments.
Unset Strict Implicit.

Local Open Scope ring_scope.

HB.mixin Record Zmodule_isSemiNormed (R : POrderZmodule.type) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.

#[short(type="semiNormedZmodType")]
HB.structure Definition SemiNormedZmodule (R : porderZmodType) :=
  { M of Zmodule_isSemiNormed R M & GRing.Zmodule M }.

HB.mixin Record SemiNormedZmodule_isPositiveDefinite
    (R : POrderZmodule.type) M & @SemiNormedZmodule R M := {
  normr0_eq0 : forall x : M, norm x = 0 -> x = 0;
}.

#[short(type="normedZmodType")]
HB.structure Definition NormedZmodule (R : porderZmodType) :=
  { M of SemiNormedZmodule_isPositiveDefinite R M & SemiNormedZmodule R M }.

HB.factory Record Zmodule_isNormed (R : porderZmodType) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normr0_eq0 : forall x, norm x = 0 -> x = 0;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.
HB.builders Context (R : POrderZmodule.type) M & Zmodule_isNormed R M.
  HB.instance Definition _ :=
    Zmodule_isSemiNormed.Build R M ler_normD normrMn normrN.
HB.end.

HB.mixin Record NumZmod_isNumRing R & GRing.NzRing R & POrderZmodule R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.

#[short(type="numDomainType")]
HB.structure Definition NumDomain := { R of
     GRing.IntegralDomain R &
     NumZmodule R &
     NormedZmodule (POrderZmodule.clone R _) R &
     NumZmod_isNumRing R
  }.

HB.factory Record isNumRing R & GRing.NzRing R & POrderZmodule R
  & GRing.IntegralDomain R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.
HB.builders Context R & isNumRing R.

Fact ler_wD2l (x : R) : {homo +%R x : y z / y <= z}.
Admitted.

HB.instance Definition _ := Add_isHomo.Build R ler_wD2l.
HB.end.

Section NumDomainOperationTheory.

Variable R : numDomainType.

Lemma leif_AGM_scaled (I : finType) (A : {pred I}) (E : I -> R) (n := #|A|) :
    {in A, forall i, 0 <= E i *+ n} ->
  \prod_(i in A) (E i *+ n) <= (\sum_(i in A) E i) ^+ n
                            ?= iff [forall i in A, forall j in A, E i == E j].
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 4.0MiB file on GitHub Actions Artifacts under build.log)
 '[' '' ']'
+ COQ_CI_COLOR=
+ export GIT_PAGER=
+ GIT_PAGER=
+ '[' '' = 1 ']'
+ '[' '' = 1 ']'
+ bash /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-mathcomp.sh
+ tee _build_ci/mathcomp.log
++ set -e
++ : 2
++ export NJOBS
+++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-common.sh
++ . /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ which cygpath
+++ OCAMLFINDSEP=:
+++ '[' /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh ']'
++++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ root=/github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ cd /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ echo /builds/coq/coq
+++ root=/builds/coq/coq
+++ '[' -n 1 ']'
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ export OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
+++ export CI_BRANCH=
+++ CI_BRANCH=
+++ [[ '' =~ ^[0-9]*$ ]]
+++ export CI_PULL_REQUEST=
+++ CI_PULL_REQUEST=
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ declare -A overlays
++ set +x
+ git_download mathcomp
+ local project=mathcomp
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local giturl_var=mathcomp_CI_GITURL
+ local giturl=https://github.com/math-comp/math-comp
+ local ref_var=mathcomp_CI_REF
+ local ref=master
+ local parent_project_var=mathcomp_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=mathcomp_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp ']'
+ echo 'Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.'
Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.
+ '[' '' ']'
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ make
+ '[' -z x ']'
+ command make
"/github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq" makefile  -f Make -o Makefile.coq
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
         use ROCQRUNTIMELIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
make -f Makefile.coq --no-print-directory
ROCQ compile algebra/num_theory/numdomain.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////rocq
MINIMIZER_DEBUG_EXTRA: original invocation: '' 
MINIMIZER_DEBUG_EXTRA: new invocation: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: ocamlpath: /github/workspace/builds/coq/coq-failing/_install_ci/lib:
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqlib: Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.sgfywwWe29
MINIMIZER_DEBUG: files:  algebra/num_theory/numdomain.v /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.vWarning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]Warning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "./algebra/num_theory/numdomain.v", line 1904, characters 63-76:
Error: In term, tolerating this expression at a higher level than expected by
the notation started on the left. This tolerance will be eventually removed.
Insert parentheses or try to lower the level at which the top symbol of this
expression is parsed.
[level-tolerance,deprecated-since-9.2,deprecated,parsing,default]

Command exited with non-zero status 1
algebra/num_theory/numdomain.vo (real: 19.66, user: 18.45, sys: 0.17, mem: 1085352 ko)
make[2]: *** [Makefile.coq:815: algebra/num_theory/numdomain.vo] Error 1
make[2]: *** [algebra/num_theory/numdomain.vo] Deleting file 'algebra/num_theory/numdomain.glob'
make[1]: *** [Makefile.coq:411: all] Error 2
make: *** [Makefile.common:99: this-build] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' mathcomp 2
+ '[' mathcomp '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real _build_ci/mathcomp.log
    Time |   Peak Mem | File Name                      
-------------------------------------------------------
0m19.66s | 1085352 ko | Total Time / Peak Mem          
-------------------------------------------------------
0m19.66s | 1085352 ko | algebra/num_theory/numdomain.vo
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 67KiB file on GitHub Actions Artifacts under bug.log)
g in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpprum45cq/Top/bug_01.v", line 74, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpprum45cq/Top/bug_01.v", line 74, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined.
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined. with Proof using
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpprum45cq/Top/bug_01.v", line 74, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpprum45cq/Top/bug_01.v", line 74, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpprum45cq/Top/bug_01.v", line 74, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpprum45cq/Top/bug_01.v", line 74, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined with Proof using
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined with Proof using
�[92m
Admitting definitions successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to add Proof using lines
�[92m
Adding Proof using lines successful.�[0m
Failed to do everything at once; trying one at a time.
Adding Proof using lines unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to remove all lines, one at a time

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 28, 2026

Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.v in 5h 15m 7s (from ci-mathcomp) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout) (truncated to first and last 32KiB; full 142KiB file on GitHub Actions Artifacts under bug.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-w" "+duplicate-clear" "-w" "+non-primitive-record" "-w" "+undeclared-scope" "-w" "+deprecated-hint-without-locality" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-projection-no-head-constant" "-w" "-redundant-canonical-projection" "-w" "-notation-overridden" "-w" "-ambiguous-paths" "-w" "-elpi.add-const-for-axiom-or-sectionvar" "-w" "-mathcomp-subset-itv" "-w" "+level-tolerance" "-w" "-notation-for-abbreviation" "-w" "-deprecated-native-compiler-option" "-native-compiler" "ondemand" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "mathcomp" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/HB" "HB" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2" "Ltac2" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi" "elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_elpi" "elpi_elpi" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_examples" "elpi_examples" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2712 lines to 251 lines, then from 218 lines to 96 lines, then from 110 lines to 1271 lines, then from 1278 lines to 204 lines, then from 218 lines to 1752 lines, then from 1759 lines to 1577 lines, then from 1465 lines to 1176 lines, then from 1175 lines to 534 lines, then from 554 lines to 492 lines, then from 506 lines to 5041 lines, then from 5048 lines to 5520 lines *)
(* coqc version 9.3+alpha compiled with OCaml 4.14.2
   coqtop version 9.3+alpha
   Expected coqc runtime on this file: 63.479 sec
   Expected coqc peak memory usage on this file: 1829740.0 kb *)









Require Corelib.ssr.ssrfun.
Require Corelib.BinNums.PosDef.
Require Corelib.Init.Ltac.
Require Corelib.ssr.ssrbool.
Require Corelib.ssr.ssreflect.
Require elpi_elpi.dummy.
Require mathcomp.boot.ssrnotations.
Require elpi.elpi.
Require mathcomp.boot.ssreflect.
Require elpi.apps.locker.locker.
Require mathcomp.boot.ssrfun.
Require HB.structures.
Require mathcomp.boot.ssrbool.
Require mathcomp.boot.eqtype.
Require mathcomp.boot.ssrnat.
Require mathcomp.boot.seq.
Require mathcomp.boot.choice.
Require mathcomp.boot.div.
Require mathcomp.boot.path.
Require mathcomp.boot.fintype.
Require mathcomp.boot.tuple.
Require mathcomp.boot.finfun.
Require mathcomp.boot.bigop.
Require mathcomp.boot.finset.
Require mathcomp.boot.monoid.
Require mathcomp.boot.prime.
Require mathcomp.boot.nmodule.
Require mathcomp.boot.binomial.
Require mathcomp.order.preorder.
Require mathcomp.order.order.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.

Module Export mathcomp_DOT_algebra_DOT_alg_DOT_algebra.
Module Export mathcomp.
Module Export algebra.
Module Export alg.
Module algebra.


Import HB.structures.
Import mathcomp.boot.ssreflect mathcomp.boot.ssrfun mathcomp.boot.ssrbool mathcomp.boot.eqtype mathcomp.boot.ssrnat mathcomp.boot.div mathcomp.boot.seq.
Import mathcomp.boot.choice mathcomp.boot.fintype mathcomp.boot.finfun mathcomp.boot.bigop mathcomp.boot.prime mathcomp.boot.binomial.
Import mathcomp.boot.nmodule.




































































































































































































































































































































































































































































































































Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Local Open Scope ring_scope.

Reserved Notation "+%R".
Reserved Notation "-%R".
Reserved Notation "*%R" (format " *%R").
Reserved Notation "*:%R" (format " *:%R").
Reserved Notation "n %:R" (left associativity, format "n %:R").
Reserved Notation "k %:A" (left associativity, format "k %:A").
Reserved Notation "[ 'pchar' F ]" (format "[ 'pchar'  F ]").
Reserved Notation "[ 'char' F ]" (format "[ 'char'  F ]").

Reserved Notation "x %:T" (left associativity, format "x %:T").
Reserved Notation "''X_' i" (at level 8, i at level 2, format "''X_' i").


Reserved Notation "''exists' ''X_' i , f"
  (at level 199, i at level 2, right associativity,
   format "'[hv' ''exists'  ''X_' i , '/ '  f ']'").
Reserved Notation "''forall' ''X_' i , f"
  (at level 199, i at level 2, right associativity,
   format "'[hv' ''forall'  ''X_' i , '/ '  f ']'").

Reserved Notation "x ^f" (left associativity, format "x ^f").

Reserved Notation "\0".
Reserved Notation "f \+ g" (at level 50, left associativity).
Reserved Notation "f \- g" (at level 50, left associativity).
Reserved Notation "\- f" (at level 35, f at level 35).
Reserved Notation "a \*o f" (at level 40).
Reserved Notation "a \o* f" (at level 40).
Reserved Notation "a \*: f" (at level 40).
Reserved Notation "f \* g" (at level 40, left associativity).

Reserved Notation "'{' 'additive' U '->' V '}'"
  (U at level 98, V at level 99, format "{ 'additive'  U  ->  V }").
Reserved Notation "'{' 'rmorphism' U '->' V '}'"
  (U at level 98, V at level 99, format "{ 'rmorphism'  U  ->  V }").
Reserved Notation "'{' 'lrmorphism' U '->' V '|' s '}'"
  (U at level 98, V at level 99, format "{ 'lrmorphism'  U  ->  V  |  s }").
Reserved Notation "'{' 'lrmorphism' U '->' V '}'"
  (U at level 98, V at level 99, format "{ 'lrmorphism'  U  ->  V }").
Reserved Notation "'{' 'linear' U '->' V '|' s '}'"
  (U at level 98, V at level 99, format "{ 'linear'  U  ->  V  |  s }").
Reserved Notation "'{' 'linear' U '->' V '}'"
  (U at level 98, V at level 99,
   format "{ 'linear'  U  ->  V }").
Reserved Notation "'{' 'scalar' U '}'" (format "{ 'scalar'  U }").

Reserved Notation "R ^c" (format "R ^c").
Reserved Notation "R ^o" (format "R ^o").

Module Export Dummy.
Module GRing := Algebra.
End Dummy.

Module Import GRing.


Export Algebra.

Import Monoid.Theory.

HB.mixin Record Nmodule_isPzSemiRing R & Nmodule R := {
  one : R;
  mul : R -> R -> R;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul +%R;
  mulrDr : right_distributive mul +%R;
  mul0r : left_zero zero mul;
  mulr0 : right_zero zero mul;
}.

#[short(type="pzSemiRingType")]
HB.structure Definition PzSemiRing :=
  { R of Nmodule_isPzSemiRing R & Nmodule R }.

HB.factory Record isPzSemiRing R & Choice R := {
  zero : R;
  add : R -> R -> R;
  one : R;
  mul : R -> R -> R;
  addrA : associative add;
  addrC : commutative add;
  add0r : left_id zero add;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul add;
  mulrDr : right_distributive mul add;
  mul0r : left_zero zero mul;
  mulr0 : right_zero zero mul;
}.

HB.builders Context R & isPzSemiRing R.
  HB.instance Definition _ := @isNmodule.Build R
    zero add addrA addrC add0r.
  HB.instance Definition _ := @Nmodule_isPzSemiRing.Build R
    one mul mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
HB.end.

Module PzSemiRingExports.
Bind Scope ring_scope with PzSemiRing.sort.
End PzSemiRingExports.
HB.export PzSemiRingExports.

HB.mixin Record PzSemiRing_isNonZero R & PzSemiRing R := {
  oner_neq0 : @one R != 0
}.

#[short(type="nzSemiRingType")]
HB.structure Definition NzSemiRing :=
  { R of PzSemiRing_isNonZero R & PzSemiRing R }.

HB.factory Record Nmodule_isNzSemiRing R & Nmodule R := {
  one : R;
  mul : R -> R -> R;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul +%R;
  mulrDr : right_distributive mul +%R;
  mul0r : left_zero zero mul;
  mulr0 : right_zero zero mul;
  oner_neq0 : one != 0
}.

HB.builders Context R & Nmodule_isNzSemiRing R.
  HB.instance Definition _ :=
    Nmodule_isPzSemiRing.Build R mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
  HB.instance Definition _ := PzSemiRing_isNonZero.Build R oner_neq0.
HB.end.

HB.factory Record isNzSemiRing R & Choice R := {
  zero : R;
  add : R -> R -> R;
  one : R;
  mul : R -> R -> R;
  addrA : associative add;
  addrC : commutative add;
  add0r : left_id zero add;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul add;
  mulrDr : right_distributive mul add;
  mul0r : left_zero zero mul;
  mulr0 : right_zero zero mul;
  oner_neq0 : one != zero
}.

HB.builders Context R & isNzSemiRing R.
  HB.instance Definition _ := @isNmodule.Build R
    zero add addrA addrC add0r.
  HB.instance Definition _ := @Nmodule_isNzSemiRing.Build R
    one mul mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0 oner_neq0.
HB.end.

Module NzSemiRingExports.
Bind Scope ring_scope with NzSemiRing.sort.
End NzSemiRingExports.
HB.export NzSemiRingExports.

Definition exp R x n := iterop n (@mul R) x (@one R).
Arguments exp : simpl never.
Definition comm R x y := @mul R x y = mul y x.
Definition lreg R x := injective (@mul R x).
Definition rreg R x := injective ((@mul R)^~ x).

Local Notation "1" := (@one _) : ring_scope.
Local Notation "n %:R" := (1 *+ n) : ring_scope.
Local Notation "*%R" := (@mul _) : function_scope.
Local Notation "x * y" := (mul x y) : ring_scope.
Local Notation "x ^+ n" := (exp x n) : ring_scope.

Local Notation "\prod_ ( i <- r | P ) F" := (\big[*%R/1]_(i <- r | P) F).
Local Notation "\prod_ ( i | P ) F" := (\big[*%R/1]_(i | P) F).
Local Notation "\prod_ ( i 'in' A ) F" := (\big[*%R/1]_(i in A) F).
Local Notation "\prod_ ( m <= i < n ) F" := (\big[*%R/1%R]_(m <= i < n) F%R).




Definition pchar (R : nzSemiRingType) : nat_pred :=
  [pred p | prime p & p%:R == 0 :> R].

Local Notation has_pchar0 L := (pchar L =i pred0).


Definition converse R : Type := R.
Local Notation "R ^c" := (converse R) : type_scope.

Section PzSemiRingTheory.

Variable R : pzSemiRingType.
Implicit Types x y : R.

#[export]
HB.instance Definition _ := Monoid.isLaw.Build R 1 *%R mulrA mul1r mulr1.
#[export]
HB.instance Definition _ := Monoid.isMulLaw.Build R 0 *%R mul0r mulr0.
#[export]
HB.instance Definition _ := Monoid.isAddLaw.Build R *%R +%R mulrDl mulrDr.

Lemma mulr_suml I r P (F : I -> R) x :
  (\sum_(i <- r | P i) F i) * x = \sum_(i <- r | P i) F i * x.
Proof.
exact: big_distrl.
Qed.

Lemma mulr_sumr I r P (F : I -> R) x :
  x * (\sum_(i <- r | P i) F i) = \sum_(i <- r | P i) x * F i.
Proof.
exact: big_distrr.
Qed.

Lemma mulrnAl x y n : (x *+ n) * y = (x * y) *+ n.
Proof.
by elim: n => [|n IHn]; rewrite ?mul0r // !mulrS mulrDl IHn.
Qed.

Lemma mulrnAr x y n : x * (y *+ n) = (x * y) *+ n.
Proof.
by elim: n => [|n IHn]; rewrite ?mulr0 // !mulrS mulrDr IHn.
Qed.

Lemma mulr_natl x n : n%:R * x = x *+ n.
Proof.
by rewrite mulrnAl mul1r.
Qed.

Lemma mulr_natr x n : x * n%:R = x *+ n.
Proof.
by rewrite mulrnAr mulr1.
Qed.

Lemma natrD m n : (m + n)%:R = m%:R + n%:R :> R.
Proof.
exact: mulrnDr.
Qed.
Lemma natr1 n : n%:R + 1 = n.+1%:R :> R.
Proof.
by rewrite mulrSr.
Qed.
Lemma nat1r n : 1 + n%:R = n.+1%:R :> R.
Proof.
by rewrite mulrS.
Qed.

Definition natr_sum := big_morph (natmul 1) natrD (mulr0n 1).

Lemma natrM m n : (m * n)%:R = m%:R * n%:R :> R.
Proof.
by rewrite mulrnA mulr_natr.
Qed.

Lemma expr0 x : x ^+ 0 = 1.
Proof.
by [].
Qed.
Lemma expr1 x : x ^+ 1 = x.
Proof.
by [].
Qed.
Lemma expr2 x : x ^+ 2 = x * x.
Proof.
by [].
Qed.

Lemma exprS x n : x ^+ n.+1 = x * x ^+ n.
Proof.
by case: n => //; rewrite mulr1.
Qed.

Lemma expr0n n : 0 ^+ n = (n == 0%N)%:R :> R.
Proof.
by case: n => // n; rewrite exprS mul0r.
Qed.

Lemma expr1n n : 1 ^+ n = 1 :> R.
Proof.
by elim: n => // n IHn; rewrite exprS mul1r.
Qed.

Lemma exprD x m n : x ^+ (m + n) = x ^+ m * x ^+ n.
Proof.
by elim: m => [|m IHm]; rewrite ?mul1r // !exprS -mulrA -IHm.
Qed.

Lemma exprSr x n : x ^+ n.+1 = x ^+ n * x.
Proof.
by rewrite -addn1 exprD expr1.
Qed.

Lemma expr_sum x (I : Type) (s : seq I) (P : pred I) F :
  x ^+ (\sum_(i <- s | P i) F i) = \prod_(i <- s | P i) x ^+ F i :> R.
Proof.
exact: (big_morph _ (exprD _)).
Qed.

Lemma commr_sym x y : comm x y -> comm y x.
Proof.
by [].
Qed.
Lemma commr_refl x : comm x x.
Proof.
by [].
Qed.

Lemma commr0 x : comm x 0.
Proof.
by rewrite /comm mulr0 mul0r.
Qed.

Lemma commr1 x : comm x 1.
Proof.
by rewrite /comm mulr1 mul1r.
Qed.

Lemma commrD x y z : comm x y -> comm x z -> comm x (y + z).
Proof.
by rewrite /comm mulrDl mulrDr => -> ->.
Qed.

Lemma commr_sum (I : Type) (s : seq I) (P : pred I) (F : I -> R) x :
  (forall i, P i -> comm x (F i)) -> comm x (\sum_(i <- s | P i) F i).
Proof.
move=> comm_x_F; rewrite /comm mulr_suml mulr_sumr.
by apply: eq_bigr => i /comm_x_F.
Qed.

Lemma commrMn x y n : comm x y -> comm x (y *+ n).
Proof.
rewrite /comm => com_xy.
by elim: n => [|n IHn]; rewrite ?commr0 // mulrS commrD.
Qed.

Lemma commrM x y z : comm x y -> comm x z -> comm x (y * z).
Proof.
by move=> com_xy; rewrite /comm mulrA com_xy -!mulrA => ->.
Qed.

Lemma commr_prod (I : Type) (s : seq I) (P : pred I) (F : I -> R) x :
  (forall i, P i -> comm x (F i)) -> comm x (\prod_(i <- s | P i) F i).
Proof.
exact: (big_ind _ (commr1 x) (@commrM x)).
Qed.

Lemma commr_nat x n : comm x n%:R.
Proof.
exact/commrMn/commr1.
Qed.

Lemma commrX x y n : comm x y -> comm x (y ^+ n).
Proof.
rewrite /comm => com_xy.
by elim: n => [|n IHn]; rewrite ?commr1 // exprS commrM.
Qed.

Lemma exprMn_comm x y n : comm x y -> (x * y) ^+ n = x ^+ n * y ^+ n.
Proof.
move=> com_xy; elim: n => /= [|n IHn]; first by rewrite mulr1.
by rewrite !exprS IHn !mulrA; congr (_ * _); rewrite -!mulrA -commrX.
Qed.

Lemma exprMn_n x m n : (x *+ m) ^+ n = x ^+ n *+ (m ^ n) :> R.
Proof.
elim: n => [|n IHn]; first by rewrite mulr1n.
by rewrite exprS IHn mulrnAl mulrnAr -mulrnA exprS expnSr.
Qed.

Lemma exprM x m n : x ^+ (m * n) = x ^+ m ^+ n.
Proof.
elim: m => [|m IHm]; first by rewrite expr1n.
by rewrite mulSn exprD IHm exprS exprMn_comm //; apply: commrX.
Qed.

Lemma exprAC x m n : (x ^+ m) ^+ n = (x ^+ n) ^+ m.
Proof.
by rewrite -!exprM mulnC.
Qed.

Lemma expr_mod n x i : x ^+ n = 1 -> x ^+ (i %% n) = x ^+ i.
Proof.
move=> xn1; rewrite {2}(divn_eq i n) exprD mulnC exprM xn1.
by rewrite expr1n mul1r.
Qed.

Lemma expr_dvd n x i : x ^+ n = 1 -> n %| i -> x ^+ i = 1.
Proof.
by move=> xn1 dvd_n_i; rewrite -(expr_mod i xn1) (eqnP dvd_n_i).
Qed.

Lemma natrX n k : (n ^ k)%:R = n%:R ^+ k :> R.
Proof.
by rewrite exprMn_n expr1n.
Qed.

Lemma mulrI_eq0 x y : lreg x -> (x * y == 0) = (y == 0).
Proof.
by move=> reg_x; rewrite -{1}(mulr0 x) (inj_eq reg_x).
Qed.

Lemma lreg1 : lreg (1 : R).
Proof.
by move=> x y; rewrite !mul1r.
Qed.

Lemma lregM x y : lreg x -> lreg y -> lreg (x * y).
Proof.
by move=> reg_x reg_y z t; rewrite -!mulrA => /reg_x/reg_y.
Qed.

Lemma lregMl (a b: R) : lreg (a * b) -> lreg b.
Proof.
by move=> rab c c' eq_bc; apply/rab; rewrite -!mulrA eq_bc.
Qed.

Lemma rregMr (a b: R) : rreg (a * b) -> rreg a.
Proof.
by move=> rab c c' eq_ca; apply/rab; rewrite !mulrA eq_ca.
Qed.

Lemma lregX x n : lreg x -> lreg (x ^+ n).
Proof.
by move=> reg_x; elim: n => [|n]; [apply: lreg1 | rewrite exprS; apply: lregM].
Qed.

Lemma iter_mulr n x y : iter n ( *%R x) y = x ^+ n * y.
Proof.
by elim: n => [|n ih]; rewrite ?expr0 ?mul1r //= ih exprS -mulrA.
Qed.

Lemma iter_mulr_1 n x : iter n ( *%R x) 1 = x ^+ n.
Proof.
by rewrite iter_mulr mulr1.
Qed.

Lemma prodr_const (I : finType) (A : pred I) x : \prod_(i in A) x = x ^+ #|A|.
Proof.
by rewrite big_const -iteropE.
Qed.

Lemma prodr_const_nat n m x : \prod_(n <= i < m) x = x ^+ (m - n).
Proof.
by rewrite big_const_nat -iteropE.
Qed.

Lemma prodrXr x I r P (F : I -> nat) :
  \prod_(i <- r | P i) x ^+ F i = x ^+ (\sum_(i <- r | P i) F i).
Proof.
by rewrite (big_morph _ (exprD _) (erefl _)).
Qed.

Lemma prodrM_comm {I : eqType} r (P : pred I) (F G : I -> R) :
    (forall i j, P i -> P j -> comm (F i) (G j)) ->
  \prod_(i <- r | P i) (F i * G i) =
    \prod_(i <- r | P i) F i * \prod_(i <- r | P i) G i.
Proof.
move=> FG; elim: r => [|i r IHr]; rewrite !(big_nil, big_cons) ?mulr1//.
case: ifPn => // Pi; rewrite IHr !mulrA; congr (_ * _); rewrite -!mulrA.
by rewrite commr_prod // => j Pj; apply/commr_sym/FG.
Qed.

Lemma prodrMl_comm {I : finType} (A : pred I) (x : R) F :
    (forall i, A i -> comm x (F i)) ->
  \prod_(i in A) (x * F i) = x ^+ #|A| * \prod_(i in A) F i.
Proof.
by move=> xF; rewrite prodrM_comm ?prodr_const// => i j _ /xF.
Qed.

Lemma prodrMr_comm {I : finType} (A : pred I) (x : R) F :
    (forall i, A i -> comm x (F i)) ->
  \prod_(i in A) (F i * x) = \prod_(i in A) F i * x ^+ #|A|.
Proof.
by move=> xF; rewrite prodrM_comm ?prodr_const// => i j /xF.
Qed.

Lemma prodrMn (I : Type) (s : seq I) (P : pred I) (F : I -> R) (g : I -> nat) :
  \prod_(i <- s | P i) (F i *+ g i) =
  \prod_(i <- s | P i) (F i) *+ \prod_(i <- s | P i) g i.
Proof.
by elim/big_rec3: _ => // i y1 y2 y3 _ ->; rewrite mulrnAr mulrnAl -mulrnA.
Qed.

Lemma prodrMn_const n (I : finType) (A : pred I) (F : I -> R) :
  \prod_(i in A) (F i *+ n) = \prod_(i in A) F i *+ n ^ #|A|.
Proof.
by rewrite prodrMn prod_nat_const.
Qed.

Lemma natr_prod I r P (F : I -> nat) :
  (\prod_(i <- r | P i) F i)%:R = \prod_(i <- r | P i) (F i)%:R :> R.
Proof.
exact: (big_morph _ natrM).
Qed.

Lemma exprDn_comm x y n (cxy : comm x y) :
  (x + y) ^+ n = \sum_(i < n.+1) (x ^+ (n - i) * y ^+ i) *+ 'C(n, i).
Proof.
elim: n => [|n IHn]; rewrite big_ord_recl mulr1 ?big_ord0 ?addr0 //=.
rewrite exprS {}IHn /= mulrDl !big_distrr /= big_ord_recl mulr1 subn0.
rewrite !big_ord_recr /= !binn !subnn !mul1r !subn0 bin0 !exprS -addrA.
congr (_ + _); rewrite addrA -big_split /=; congr (_ + _).
apply: eq_bigr => i _; rewrite !mulrnAr !mulrA -exprS -subSn ?(valP i) //.
by rewrite subSS (commrX _ (commr_sym cxy)) -mulrA -exprS -mulrnDr.
Qed.

Lemma exprD1n x n : (x + 1) ^+ n = \sum_(i < n.+1) x ^+ i *+ 'C(n, i).
Proof.
rewrite addrC (exprDn_comm n (commr_sym (commr1 x))).
by apply: eq_bigr => i _; rewrite expr1n mul1r.
Qed.

Lemma sqrrD1 x : (x + 1) ^+ 2 = x ^+ 2 + x *+ 2 + 1.
Proof.
rewrite exprD1n !big_ord_recr big_ord0 /= add0r.
by rewrite addrC addrA addrAC.
Qed.

Section ClosedPredicates.

Variable S : {pred R}.

Definition mulr_2closed := {in S &, forall u v, u * v \in S}.
Definition mulr_closed := 1 \in S /\ mulr_2closed.
Definition semiring_closed := nmod_closed S /\ mulr_closed.

Lemma semiring_closedD : semiring_closed -> nmod_closed S.
Proof.
by case.
Qed.

Lemma semiring_closedM : semiring_closed -> mulr_closed.
Proof.
by case.
Qed.

End ClosedPredicates.

End PzSemiRingTheory.

Section NzSemiRingTheory.

Variable R : nzSemiRingType.
Implicit Types x y : R.

Lemma oner_eq0 : (1 == 0 :> R) = false.
Proof.
exact: negbTE oner_neq0.
Qed.

Lemma lastr_eq0 (s : seq R) x : x != 0 -> (last x s == 0) = (last 1 s == 0).
Proof.
by case: s => [|y s] /negPf // ->; rewrite oner_eq0.
Qed.

Lemma lreg_neq0 x : lreg x -> x != 0.
Proof.
by move=> reg_x; rewrite -[x]mulr1 mulrI_eq0 ?oner_eq0.
Qed.

Definition pFrobenius_aut p & p \in pchar R := fun x => x ^+ p.


Section FrobeniusAutomorphism.

Variable p : nat.
Hypothesis pcharFp : p \in pchar R.

Lemma pcharf0 : p%:R = 0 :> R.
Proof.
by apply/eqP; case/andP: pcharFp.
Qed.

Lemma pcharf_prime : prime p.
Proof.
by case/andP: pcharFp.
Qed.
Hint Resolve pcharf_prime : core.

Lemma mulrn_pchar x : x *+ p = 0.
Proof.
by rewrite -mulr_natl pcharf0 mul0r.
Qed.

Lemma natr_mod_pchar n : (n %% p)%:R = n%:R :> R.
Proof.
by rewrite {2}(divn_eq n p) natrD mulrnA mulrn_pchar add0r.
Qed.

Lemma dvdn_pcharf n : (p %| n)%N = (n%:R == 0 :> R).
Proof.
apply/idP/eqP=> [/dvdnP[n' ->]|n0]; first by rewrite natrM pcharf0 mulr0.
apply/idPn; rewrite -prime_coprime // => /eqnP pn1.
have [a _ /dvdnP[b]] := Bezoutl n (prime_gt0 pcharf_prime).
move/(congr1 (fun m => m%:R : R))/eqP.
by rewrite natrD !natrM pcharf0 n0 !mulr0 pn1 addr0 oner_eq0.
Qed.

Lemma pcharf_eq : pchar R =i (p : nat_pred).
Proof.
move=> q; apply/andP/eqP=> [[q_pr q0] | ->]; last by rewrite pcharf0.
by apply/eqP; rewrite eq_sym -dvdn_prime2 // dvdn_pcharf.
Qed.

Lemma bin_lt_pcharf_0 k : 0 < k < p -> 'C(p, k)%:R = 0 :> R.
Proof.
by move=> lt0kp; apply/eqP; rewrite -dvdn_pcharf prime_dvd_bin.
Qed.

Local Notation "x ^f" := (pFrobenius_aut pcharFp x).

Lemma pFrobenius_autE x : x^f = x ^+ p.
Proof.
by [].
Qed.
Local Notation f'E := pFrobenius_autE.

Lemma pFrobenius_aut0 : 0^f = 0.
Proof.
by rewrite f'E -(prednK (prime_gt0 pcharf_prime)) exprS mul0r.
Qed.

Lemma pFrobenius_aut1 : 1^f = 1.
Proof.
by rewrite f'E expr1n.
Qed.

Lemma pFrobenius_autD_comm x y (cxy : comm x y) : (x + y)^f = x^f + y^f.
Proof.
have defp := prednK (prime_gt0 pcharf_prime).
rewrite !f'E exprDn_comm // big_ord_recr subnn -defp big_ord_recl /= defp.
rewrite subn0 mulr1 mul1r bin0 binn big1 ?addr0 // => i _.
by rewrite -mulr_natl bin_lt_pcharf_0 ?mul0r //= -{2}defp ltnS (valP i).
Qed.

Lemma pFrobenius_autMn x n : (x *+ n)^f = x^f *+ n.
Proof.
elim: n => [|n IHn]; first exact: pFrobenius_aut0.
by rewrite !mulrS pFrobenius_autD_comm ?IHn //; apply: commrMn.
Qed.

Lemma pFrobenius_aut_nat n : (n%:R)^f = n%:R.
Proof.
by rewrite pFrobenius_autMn pFrobenius_aut1.
Qed.

Lemma pFrobenius_autM_comm x y : comm x y -> (x * y)^f = x^f * y^f.
Proof.
exact: exprMn_comm.
Qed.

Lemma pFrobenius_autX x n : (x ^+ n)^f = x^f ^+ n.
Proof.
by rewrite !f'E -!exprM mulnC.
Qed.

End FrobeniusAutomorphism.

Section Char2.

Hypothesis pcharR2 : 2 \in pchar R.

Lemma addrr_pchar2 x : x + x = 0.
Proof.
by rewrite -mulr2n mulrn_pchar.
Qed.

End Char2.

End NzSemiRingTheory.

#[short(type="pzRingType")]
HB.structure Definition PzRing := { R of PzSemiRing R & Zmodule R }.

HB.factory Record Zmodule_isPzRing R & Zmodule R := {
  one : R;
  mul : R -> R -> R;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul +%R;
  mulrDr : right_distributive mul +%R;
}.

HB.builders Context R & Zmodule_isPzRing R.
  Local Notation "1" := one.
  Local Notation "x * y" := (mul x y).
  Lemma mul0r : @left_zero R R 0 mul.
  Proof.
by move=> x; apply: (addIr (1 * x)); rewrite -mulrDl !add0r mul1r.
Qed.
  Lemma mulr0 : @right_zero R R 0 mul.
  Proof.
by move=> x; apply: (addIr (x * 1)); rewrite -mulrDr !add0r mulr1.
Qed.
  HB.instance Definition _ := Nmodule_isPzSemiRing.Build R
    mulrA mul1r mulr1 mulrDl mulrDr mul0r mulr0.
HB.end.

HB.factory Record isPzRing R & Choice R := {
  zero : R;
  opp : R -> R;
  add : R -> R -> R;
  one : R;
  mul : R -> R -> R;
  addrA : associative add;
  addrC : commutative add;
  add0r : left_id zero add;
  addNr : left_inverse zero opp add;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul add;
  mulrDr : right_distributive mul add;
}.

HB.builders Context R & isPzRing R.
  HB.instance Definition _ := @isZmodule.Build R
    zero opp add addrA addrC add0r addNr.
  HB.instance Definition _ := @Zmodule_isPzRing.Build R
    one mul mulrA mul1r mulr1 mulrDl mulrDr.
HB.end.

Module PzRingExports.
Bind Scope ring_scope with PzRing.sort.
End PzRingExports.
HB.export PzRingExports.

#[short(type="nzRingType")]
HB.structure Definition NzRing := { R of NzSemiRing R & Zmodule R }.

HB.factory Record Zmodule_isNzRing R & Zmodule R := {
  one : R;
  mul : R -> R -> R;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul +%R;
  mulrDr : right_distributive mul +%R;
  oner_neq0 : one != 0
}.

HB.builders Context R & Zmodule_isNzRing R.
  HB.instance Definition _ := Zmodule_isPzRing.Build R
    mulrA mul1r mulr1 mulrDl mulrDr.
  HB.instance Definition _ := PzSemiRing_isNonZero.Build R oner_neq0.
HB.end.

HB.factory Record isNzRing R & Choice R := {
  zero : R;
  opp : R -> R;
  add : R -> R -> R;
  one : R;
  mul : R -> R -> R;
  addrA : associative add;
  addrC : commutative add;
  add0r : left_id zero add;
  addNr : left_inverse zero opp add;
  mulrA : associative mul;
  mul1r : left_id one mul;
  mulr1 : right_id one mul;
  mulrDl : left_distributive mul add;
  mulrDr : right_distributive mul add;
  oner_neq0 : one != zero
}.

HB.builders Context R & isNzRing R.
  HB.instance Definition _ := @isZmodule.Build R
    zero opp add addrA addrC add0r addNr.
  HB.instance Definition _ := @Zmodule_isNzRing.Build R
    one mul mulrA mul1r mulr1 mulrDl mulrDr oner_neq0.
HB.end.

Module NzRingExports.
Bind Scope ring_scope with NzRing.sort.
End NzRingExports.
HB.export NzRingExports.

Notation sign R b := (exp (- @one R) (nat_of_bool b)) (only parsing).

Local Notation "- 1" := (- (1)) : ring_scope.

Section PzRingTheory.

Variable R : pzRingType.
Implicit Types x y : R.

Lemma mulrN x y : x * (- y) = - (x * y).
Proof.
by apply: (addrI (x * y)); rewrite -mulrDr !subrr mulr0.
Qed.
Lemma mulNr x y : (- x) * y = - (x * y).
Proof.
by apply: (addrI (x * y)); rewrite -mulrDl !subrr mul0r.
Qed.
Lemma mulrNN x y : (- x) * (- y) = x * y.
Proof.
by rewrite mulrN mulNr opprK.
Qed.
Lemma mulN1r x : -1 * x = - x.
Proof.
by rewrite mulNr mul1r.
Qed.
Lemma mulrN1 x : x * -1 = - x.
Proof.
by rewrite mulrN mulr1.
Qed.

Lemma mulrBl x y z : (y - z) * x = y * x - z * x.
Proof.
by rewrite mulrDl mulNr.
Qed.

Lemma mulrBr x y z : x * (y - z) = x * y - x * z.
Proof.
by rewrite mulrDr mulrN.
Qed.

Lemma natrB m n : n <= m -> (m - n)%:R = m%:R - n%:R :> R.
Proof.
exact: mulrnBr.
Qed.

Lemma commrN x y : comm x y -> comm x (- y).
Proof.
by move=> com_xy; rewrite /comm mulrN com_xy mulNr.
Qed.

Lemma commrN1 x : comm x (-1).
Proof.
exact/commrN/commr1.
Qed.

Lemma commrB x y z : comm x y -> comm x z -> comm x (y - z).
Proof.
by move=> com_xy com_xz; apply: commrD => //; apply: commrN.
Qed.

Lemma commr_sign x n : comm x ((-1) ^+ n).
Proof.
exact: (commrX n (commrN1 x)).
Qed.

Lemma signr_odd n : (-1) ^+ (odd n) = (-1) ^+ n :> R.
Proof.
elim: n => //= n IHn; rewrite exprS -{}IHn.
by case/odd: n; rewrite !mulN1r ?opprK.
Qed.

Lemma mulr_sign (b : bool) x : (-1) ^+ b * x = (if b then - x else x).
Proof.
by case: b; rewrite ?mulNr mul1r.
Qed.

Lemma signr_addb b1 b2 : (-1) ^+ (b1 (+) b2) = (-1) ^+ b1 * (-1) ^+ b2 :> R.
Proof.
by rewrite mulr_sign; case: b1 b2 => [] []; rewrite ?opprK.
Qed.

Lemma signrE (b : bool) : (-1) ^+ b = 1 - b.*2%:R :> R.
Proof.
by case: b; rewrite ?subr0 // opprD addNKr.
Qed.

Lemma signrN b : (-1) ^+ (~~ b) = - (-1) ^+ b :> R.
Proof.
by case: b; rewrite ?opprK.
Qed.

Lemma mulr_signM (b1 b2 : bool) x1 x2 :
  ((-1) ^+ b1 * x1) * ((-1) ^+ b2 * x2) = (-1) ^+ (b1 (+) b2) * (x1 * x2).
Proof.
by rewrite signr_addb -!mulrA; congr (_ * _); rewrite !mulrA commr_sign.
Qed.

Lemma exprNn x n : (- x) ^+ n = (-1) ^+ n * x ^+ n :> R.
Proof.
by rewrite -mulN1r exprMn_comm // /comm mulN1r mulrN mulr1.
Qed.

Lemma sqrrN x : (- x) ^+ 2 = x ^+ 2.
Proof.
exact: mulrNN.
Qed.

Lemma sqrr_sign n : ((-1) ^+ n) ^+ 2 = 1 :> R.
Proof.
by rewrite exprAC sqrrN !expr1n.
Qed.

Lemma signrMK n : @involutive R ( *%R ((-1) ^+ n)).
Proof.
by move=> x; rewrite mulrA -expr2 sqrr_sign mul1r.
Qed.

Lemma mulrI0_lreg x : (forall y, x * y = 0 -> y = 0) -> lreg x.
Proof.
move=> reg_x y z eq_xy_xz; apply/eqP; rewrite -subr_eq0 [y - z]reg_x //.
by rewrite mulrBr eq_xy_xz subrr.
Qed.

Lemma lregN x : lreg x -> lreg (- x).
Proof.
by move=> reg_x y z; rewrite !mulNr => /oppr_inj/reg_x.
Qed.

Lemma lreg_sign n : lreg ((-1) ^+ n : R).
Proof.
exact/lregX/lregN/lreg1.
Qed.

Lemma prodrN (I : finType) (A : pred I) (F : I -> R) :
  \prod_(i in A) - F i = (- 1) ^+ #|A| * \prod_(i in A) F i.
Proof.
rewrite -sum1_card; elim/big_rec3: _ => [|i x n _ _ ->]; first by rewrite mulr1.
by rewrite exprS !mulrA mulN1r !mulNr commrX //; apply: commrN1.
Qed.

Lemma exprBn_comm x y n (cxy : comm x y) :
  (x - y) ^+ n =
    \sum_(i < n.+1) ((-1) ^+ i * x ^+ (n - i) * y ^+ i) *+ 'C(n, i).
Proof.
rewrite exprDn_comm; last exact: commrN.
by apply: eq_bigr => i _; congr (_ *+ _); rewrite -commr_sign -mulrA -exprNn.
Qed.

Lemma subrXX_comm x y n (cxy : comm x y) :
  x ^+ n - y ^+ n = (x - y) * (\sum_(i < n) x ^+ (n.-1 - i) * y ^+ i).
Proof.
case: n => [|n]; first by rewrite big_ord0 mulr0 subrr.
rewrite mulrBl !big_distrr big_ord_recl big_ord_recr /= subnn mulr1 mul1r.
rewrite subn0 -!exprS opprD -!addrA; congr (_ + _); rewrite addrA -sumrB.
rewrite big1 ?add0r // => i _; rewrite !mulrA -exprS -subSn ?(valP i) //.
by rewrite subSS (commrX _ (commr_sym cxy)) -mulrA -exprS subrr.
Qed.

Lemma subrX1 x n : x ^+ n - 1 = (x - 1) * (\sum_(i < n) x ^+ i).
Proof.
rewrite -!(opprB 1) mulNr -{1}(expr1n _ n).
rewrite (subrXX_comm _ (commr_sym (commr1 x))); congr (- (_ * _)).
by apply: eq_bigr => i _; rewrite expr1n mul1r.
Qed.

Lemma sqrrB1 x : (x - 1) ^+ 2 = x ^+ 2 - x *+ 2 + 1.
Proof.
by rewrite -sqrrN opprB addrC sqrrD1 sqrrN mulNrn.
Qed.

Lemma subr_sqr_1 x : x ^+ 2 - 1 = (x - 1) * (x + 1).
Proof.
by rewrite subrX1 !big_ord_recr big_ord0 /= addrAC add0r.
Qed.

Section ClosedPredicates.

Variable S : {pred R}.

Definition smulr_closed := -1 \in S /\ mulr_2closed S.
Definition subring_closed := [/\ 1 \in S, subr_closed S & mulr_2closed S].

Lemma smulr_closedM : smulr_closed -> mulr_closed S.
Proof.
by case=> SN1 SM; split=> //; rewrite -[1]mulr1 -mulrNN SM.
Qed.

Lemma smulr_closedN : smulr_closed -> oppr_closed S.
Proof.
by case=> SN1 SM x Sx; rewrite -mulN1r SM.
Qed.

Lemma subring_closedB : subring_closed -> zmod_closed S.
Proof.
by case=> S1 SB _; split; rewrite // -(subrr 1) SB.
Qed.

Lemma subring_closedM : subring_closed -> smulr_closed.
Proof.
by case=> S1 SB SM; split; rewrite ?(zmod_closedN (subring_closedB _)).
Qed.

Lemma subring_closed_semi : subring_closed -> semiring_closed S.
Proof.
by move=> ringS; split; [apply/zmod_closed0D/subring_closedB | case: ringS].
Qed.

End ClosedPredicates.

End PzRingTheory.

Section NzRingTheory.

Variable R : nzRingType.
Implicit Types x y : R.

Lemma signr_eq0 n : ((-1) ^+ n == 0 :> R) = false.
Proof.
by rewrite -signr_odd; case: odd; rewrite ?oppr_eq0 oner_eq0.
Qed.


Section FrobeniusAutomorphism.

Variable p : nat.
Hypothesis pcharFp : p \in pchar R.

Hint Resolve pcharf_prime : core.

Local Notation "x ^f" := (pFrobenius_aut pcharFp x).

Lemma pFrobenius_autN x : (- x)^f = - x^f.
Proof.
apply/eqP; rewrite -subr_eq0 opprK addrC.
by rewrite -(pFrobenius_autD_comm _ (commrN _)) // subrr pFrobenius_aut0.
Qed.

Lemma pFrobenius_autB_comm x y : comm x y -> (x - y)^f = x^f - y^f.
Proof.
by move/commrN/pFrobenius_autD_comm->; rewrite pFrobenius_autN.
Qed.

End FrobeniusAutomorphism.

Lemma exprNn_pchar x n : (pchar R).-nat n -> (- x) ^+ n = - (x ^+ n).
Proof.
pose p := pdiv n; have [|n_gt1 pcharRn] := leqP n 1; first by case: (n) => [|[]].
have pcharRp: p \in pchar R by rewrite (pnatPpi pcharRn) // pi_pdiv.
have /p_natP[e ->]: p.-nat n by rewrite -(eq_pnat _ (pcharf_eq pcharRp)).
elim: e => // e IHe; rewrite expnSr !exprM {}IHe.
by rewrite -pFrobenius_autE pFrobenius_autN.
Qed.

Section Char2.

Hypothesis pcharR2 : 2 \in pchar R.

Lemma oppr_pchar2 x : - x = x.
Proof.
by apply/esym/eqP; rewrite -addr_eq0 addrr_pchar2.
Qed.

Lemma subr_pchar2 x y : x - y = x + y.
Proof.
by rewrite oppr_pchar2.
Qed.

Lemma addrK_pchar2 x : involutive (+%R^~ x).
Proof.
by move=> y; rewrite /= -subr_pchar2 addrK.
Qed.

Lemma addKr_pchar2 x : involutive (+%R x).
Proof.
by move=> y; rewrite -{1}[x]oppr_pchar2 addKr.
Qed.

End Char2.

End NzRingTheory.

Section ConverseRing.
#[export]
HB.instance Definition _ (T : eqType) := Equality.on T^c.
#[export]
HB.instance Definition _ (T : choiceType) := Choice.on T^c.
#[export]
HB.instance Definition _ (U : nmodType) := Nmodule.on U^c.
#[export]
HB.instance Definition _ (U : zmodType) := Zmodule.on U^c.
#[export]
HB.instance Definition _ (R : pzSemiRingType) :=
  let mul' (x y : R) := y * x in
  let mulrA' x y z := esym (mulrA z y x) in
  let mulrDl' x y z := mulrDr z x y in
  let mulrDr' x y z := mulrDl y z x in
  Nmodule_isPzSemiRing.Build R^c
    mulrA' mulr1 mul1r mulrDl' mulrDr' mulr0 mul0r.
#[export]
HB.instance Definition _ (R : pzRingType) := PzSemiRing.on R^c.
#[export]
HB.instance Definition _ (R : nzSemiRingType) :=
  PzSemiRing_isNonZero.Build R^c oner_neq0.
#[export]
HB.instance Definition _ (R : nzRingType) := NzSemiRing.on R^c.
End ConverseRing.

Lemma rev_prodr (R : pzSemiRingType)
  (I : Type) (r : seq I) (P : pred I) (E : I -> R) :
  \prod_(i <- r | P i) (E i : R^c) = \prod_(i <- rev r | P i) E i.
Proof.
by rewrite rev_big_rev.
Qed.

Section

[...]

n_pchar.
Definition rpred0D := @rpred0D.
Definition rpred0 := rpred0.
Definition rpredD := rpredD.
Definition rpredNr := @rpredNr.
Definition rpred_sum := rpred_sum.
Definition rpredMn := rpredMn.
Definition rpredN := rpredN.
Definition rpredB := rpredB.
Definition rpredBC := rpredBC.
Definition rpredMNn := rpredMNn.
Definition rpredDr := rpredDr.
Definition rpredDl := rpredDl.
Definition rpredBr := rpredBr.
Definition rpredBl := rpredBl.
Definition zmodClosedP := zmodClosedP.
Definition rpredMsign := rpredMsign.
Definition rpred1M := @rpred1M.
Definition rpred1 := @rpred1.
Definition rpredM := @rpredM.
Definition rpred_prod := rpred_prod.
Definition rpredX := rpredX.
Definition rpred_nat := rpred_nat.
Definition rpredN1 := rpredN1.
Definition rpred_sign := rpred_sign.
Definition semiringClosedP := semiringClosedP.
Definition subringClosedP := subringClosedP.
Definition rpredZsign := rpredZsign.
Definition rpredZnat := rpredZnat.
Definition submodClosedP := submodClosedP.
Definition subalgClosedP := subalgClosedP.
Definition rpredZ := @rpredZ.
Definition nmod_morphism := nmod_morphism.
Definition zmod_morphism := zmod_morphism.
Definition raddf0 := raddf0.
Definition raddf_eq0 := raddf_eq0.
Definition raddf_inj := raddf_inj.
Definition raddfN := raddfN.
Definition raddfD := raddfD.
Definition raddfB := raddfB.
Definition raddf_sum := raddf_sum.
Definition raddfMn := raddfMn.
Definition raddfMNn := raddfMNn.
Definition raddfMnat := raddfMnat.
Definition raddfMsign := raddfMsign.
Definition can2_nmod_morphism := can2_nmod_morphism.
Definition can2_zmod_morphism := can2_zmod_morphism.
Definition monoid_morphism := monoid_morphism.
Definition rmorph0 := rmorph0.
Definition rmorphN := rmorphN.
Definition rmorphD := rmorphD.
Definition rmorphB := rmorphB.
Definition rmorph_sum := rmorph_sum.
Definition rmorphMn := rmorphMn.
Definition rmorphMNn := rmorphMNn.
Definition rmorphism_monoidP := rmorphism_monoidP.
Definition rmorph1 := rmorph1.
Definition rmorph_eq1 := rmorph_eq1.
Definition rmorphM := rmorphM.
Definition rmorphMsign := rmorphMsign.
Definition rmorph_nat := rmorph_nat.
Definition rmorph_eq_nat := rmorph_eq_nat.
Definition rmorph_prod := rmorph_prod.
Definition rmorphXn := rmorphXn.
Definition rmorphN1 := rmorphN1.
Definition rmorph_sign := rmorph_sign.
Definition rmorph_pchar := rmorph_pchar.
Definition can2_monoid_morphism := can2_monoid_morphism.
Definition rmorph_comm := rmorph_comm.
Definition scalerA := scalerA.
Definition scale1r := @scale1r.
Definition scalerDr := @scalerDr.
Definition scalerDl := @scalerDl.
Definition scaler0 := scaler0.
Definition scale0r := @scale0r.
Definition scaleNr := scaleNr.
Definition scaleN1r := scaleN1r.
Definition scalerN := scalerN.
Definition scalerBl := scalerBl.
Definition scalerBr := scalerBr.
Definition scaler_nat := scaler_nat.
Definition scalerMnl := scalerMnl.
Definition scalerMnr := scalerMnr.
Definition scaler_suml := scaler_suml.
Definition scaler_sumr := scaler_sumr.
Definition scalerAl := @scalerAl.
Definition mulr_algl := mulr_algl.
Definition scaler_sign := scaler_sign.
Definition signrZK := signrZK.
Definition scalerCA := scalerCA.
Definition scalerAr := @scalerAr.
Definition mulr_algr := mulr_algr.
Definition comm_alg := comm_alg.
Definition exprZn := exprZn.
Definition scaler_prodl := scaler_prodl.
Definition scaler_prodr := scaler_prodr.
Definition scaler_prod := scaler_prod.
Definition raddfZnat := raddfZnat.
Definition raddfZsign := raddfZsign.
Definition in_algE := in_algE.
Definition scalable_for := scalable_for.
Definition semilinear_for := semilinear_for.
Definition linear_for := linear_for.
Definition nmod_morphism_semilinear := nmod_morphism_semilinear.
Definition zmod_morphism_linear := zmod_morphism_linear.
Definition scalable_semilinear := scalable_semilinear.
Definition scalable_linear := scalable_linear.
Definition linear0 := linear0.
Definition linearN := linearN.
Definition linearD := linearD.
Definition linearB := linearB.
Definition linear_sum := linear_sum.
Definition linearMn := linearMn.
Definition linearMNn := linearMNn.
Definition semilinearP := semilinearP.
Definition linearP := linearP.
Definition linearZ_LR := linearZ_LR.
Definition linearZ := linearZ.
Definition semilinearPZ := semilinearPZ.
Definition linearPZ := linearPZ.
Definition linearZZ := linearZZ.
Definition semiscalarP := semiscalarP.
Definition scalarP := scalarP.
Definition scalarZ := scalarZ.
Definition can2_scalable := can2_scalable.
Definition can2_linear := can2_linear.
Definition can2_semilinear := can2_semilinear.
Definition rmorph_alg := rmorph_alg.

Definition raddf := (raddf0, raddfN, raddfD, raddfMn).

Definition rmorphE :=
  (rmorphD, rmorph0, rmorphB, rmorphN, rmorphMNn, rmorphMn, rmorph1, rmorphXn).

Definition linearE :=
  (linearD, linear0, linearB, linearMNn, linearMn, linearZ).

Notation null_fun V := (null_fun V) (only parsing).
Notation in_alg A := (in_alg A) (only parsing).

End Theory.

Module AllExports.
HB.reexport.
End AllExports.

End GRing.

Export AllExports.
Export Scale.Exports.
Export ClosedExports.

Variant Ione := IOne : Ione.
Inductive Inatmul :=
  | INatmul : Ione -> nat -> Inatmul
  | IOpp : Inatmul -> Inatmul.
Variant Idummy_placeholder :=.

Definition parse (x : Number.int) : Inatmul :=
  match x with
  | Number.IntDecimal (Decimal.Pos u) => INatmul IOne (Nat.of_uint u)
  | Number.IntDecimal (Decimal.Neg u) => IOpp (INatmul IOne (Nat.of_uint u))
  | Number.IntHexadecimal (Hexadecimal.Pos u) =>
      INatmul IOne (Nat.of_hex_uint u)
  | Number.IntHexadecimal (Hexadecimal.Neg u) =>
      IOpp (INatmul IOne (Nat.of_hex_uint u))
  end.

Definition print (x : Inatmul) : option Number.int :=
  match x with
  | INatmul IOne n =>
      Some (Number.IntDecimal (Decimal.Pos (Nat.to_uint n)))
  | IOpp (INatmul IOne n) =>
      Some (Number.IntDecimal (Decimal.Neg (Nat.to_uint n)))
  | _ => None
  end.

Arguments GRing.one {_}.
Set Warnings "-via-type-remapping,-via-type-mismatch".
Number Notation Idummy_placeholder parse print (via Inatmul
  mapping [[natmul] => INatmul, [opp] => IOpp, [one] => IOne])
  : ring_scope.
Set Warnings "via-type-remapping,via-type-mismatch".
Arguments GRing.one : clear implicits.

Notation "0" := (@zero _) : ring_scope.
Notation "-%R" := (@opp _) : ring_scope.
Notation "- x" := (opp x) : ring_scope.
Notation "+%R" := (@add _) : function_scope.
Notation "x + y" := (add x y) : ring_scope.
Notation "x - y" := (add x (- y)) : ring_scope.
Arguments natmul : simpl never.
Notation "x *+ n" := (natmul x n) : ring_scope.
Notation "x *- n" := (opp (x *+ n)) : ring_scope.
Notation "s `_ i" := (seq.nth 0%R s%R i) : ring_scope.
Notation support := 0.-support.

Notation "1" := (@one _) : ring_scope.
Notation "- 1" := (opp 1) : ring_scope.

Notation "n %:R" := (natmul 1 n) : ring_scope.
Arguments GRing.pchar R%_type.
Notation "[ 'pchar' R ]" := (GRing.pchar R) : ring_scope.
Notation has_pchar0 R := (GRing.pchar R =i pred0).
Notation pFrobenius_aut chRp := (pFrobenius_aut chRp).
Notation "*%R" := (@mul _) : function_scope.
Notation "x * y" := (mul x y) : ring_scope.
Arguments exp : simpl never.
Notation "x ^+ n" := (exp x n) : ring_scope.

Notation "*:%R" := (@scale _ _) : function_scope.
Notation "a *: m" := (scale a m) : ring_scope.
Notation "k %:A" := (scale k 1) : ring_scope.
Notation "\0" := (null_fun _) : ring_scope.
Notation "f \+ g" := (add_fun f g) : ring_scope.
Notation "f \- g" := (sub_fun f g) : ring_scope.
Notation "\- f" := (opp_fun f) : ring_scope.
Notation "a \*: f" := (scale_fun a f) : ring_scope.
Notation "x \*o f" := (mull_fun x f) : ring_scope.
Notation "x \o* f" := (mulr_fun x f) : ring_scope.
Notation "f \* g" := (mul_fun f g) : ring_scope.

Arguments mull_fun {_ _}  a f _ /.
Arguments mulr_fun {_ _} a f _ /.
Arguments scale_fun {_ _ _} a f _ /.
Arguments mul_fun {_ _} f g _ /.

Notation "\sum_ ( i <- r | P ) F" :=
  (\big[+%R/0%R]_(i <- r | P%B) F%R) : ring_scope.
Notation "\sum_ ( i <- r ) F" :=
  (\big[+%R/0%R]_(i <- r) F%R) : ring_scope.
Notation "\sum_ ( m <= i < n | P ) F" :=
  (\big[+%R/0%R]_(m <= i < n | P%B) F%R) : ring_scope.
Notation "\sum_ ( m <= i < n ) F" :=
  (\big[+%R/0%R]_(m <= i < n) F%R) : ring_scope.
Notation "\sum_ ( i | P ) F" :=
  (\big[+%R/0%R]_(i | P%B) F%R) : ring_scope.
Notation "\sum_ i F" :=
  (\big[+%R/0%R]_i F%R) : ring_scope.
Notation "\sum_ ( i : t | P ) F" :=
  (\big[+%R/0%R]_(i : t | P%B) F%R) (only parsing) : ring_scope.
Notation "\sum_ ( i : t ) F" :=
  (\big[+%R/0%R]_(i : t) F%R) (only parsing) : ring_scope.
Notation "\sum_ ( i < n | P ) F" :=
  (\big[+%R/0%R]_(i < n | P%B) F%R) : ring_scope.
Notation "\sum_ ( i < n ) F" :=
  (\big[+%R/0%R]_(i < n) F%R) : ring_scope.
Notation "\sum_ ( i 'in' A | P ) F" :=
  (\big[+%R/0%R]_(i in A | P%B) F%R) : ring_scope.
Notation "\sum_ ( i 'in' A ) F" :=
  (\big[+%R/0%R]_(i in A) F%R) : ring_scope.

Notation "\prod_ ( i <- r | P ) F" :=
  (\big[*%R/1%R]_(i <- r | P%B) F%R) : ring_scope.
Notation "\prod_ ( i <- r ) F" :=
  (\big[*%R/1%R]_(i <- r) F%R) : ring_scope.
Notation "\prod_ ( m <= i < n | P ) F" :=
  (\big[*%R/1%R]_(m <= i < n | P%B) F%R) : ring_scope.
Notation "\prod_ ( m <= i < n ) F" :=
  (\big[*%R/1%R]_(m <= i < n) F%R) : ring_scope.
Notation "\prod_ ( i | P ) F" :=
  (\big[*%R/1%R]_(i | P%B) F%R) : ring_scope.
Notation "\prod_ i F" :=
  (\big[*%R/1%R]_i F%R) : ring_scope.
Notation "\prod_ ( i : t | P ) F" :=
  (\big[*%R/1%R]_(i : t | P%B) F%R) (only parsing) : ring_scope.
Notation "\prod_ ( i : t ) F" :=
  (\big[*%R/1%R]_(i : t) F%R) (only parsing) : ring_scope.
Notation "\prod_ ( i < n | P ) F" :=
  (\big[*%R/1%R]_(i < n | P%B) F%R) : ring_scope.
Notation "\prod_ ( i < n ) F" :=
  (\big[*%R/1%R]_(i < n) F%R) : ring_scope.
Notation "\prod_ ( i 'in' A | P ) F" :=
  (\big[*%R/1%R]_(i in A | P%B) F%R) : ring_scope.
Notation "\prod_ ( i 'in' A ) F" :=
  (\big[*%R/1%R]_(i in A) F%R) : ring_scope.

Notation "R ^c" := (converse R) : type_scope.
Notation "R ^o" := (regular R) : type_scope.



Section Sum.

Variables (aT : finType) (rT : nmodType).
Variables (I : Type) (r : seq I) (P : pred I) (F : I -> {ffun aT -> rT}).

Lemma sum_ffunE x : (\sum_(i <- r | P i) F i) x = \sum_(i <- r | P i) F i x.
Admitted.

Lemma sum_ffun :
  \sum_(i <- r | P i) F i = [ffun x => \sum_(i <- r | P i) F i x].
Admitted.

End Sum.

Section FinFunSemiRing.




Variable (aT : finType) (R : pzSemiRingType).

Definition ffun_one : {ffun aT -> R} := [ffun => 1].
Definition ffun_mul (f g : {ffun aT -> R}) := [ffun x => f x * g x].

Fact ffun_mulA : associative ffun_mul.
Admitted.
Fact ffun_mul_1l : left_id ffun_one ffun_mul.
Admitted.
Fact ffun_mul_1r : right_id ffun_one ffun_mul.
Admitted.
Fact ffun_mul_addl :  left_distributive ffun_mul (@ffun_add _ _).
Admitted.
Fact ffun_mul_addr :  right_distributive ffun_mul (@ffun_add _ _).
Admitted.
Fact ffun_mul_0l :  left_zero (@ffun_zero _ _) ffun_mul.
Admitted.
Fact ffun_mul_0r :  right_zero (@ffun_zero _ _) ffun_mul.
Admitted.

#[export]
HB.instance Definition _ := Nmodule_isPzSemiRing.Build {ffun aT -> R}
  ffun_mulA ffun_mul_1l ffun_mul_1r ffun_mul_addl ffun_mul_addr
  ffun_mul_0l ffun_mul_0r.
Definition ffun_semiring : pzSemiRingType := {ffun aT -> R}.
End FinFunSemiRing.

Section FinFunSemiRing.

Variable (aT : finType) (R : nzSemiRingType) (a : aT).

Fact ffun1_nonzero : ffun_one aT R != 0.
Admitted.



End FinFunSemiRing.

HB.instance Definition _ (aT : finType) (R : pzRingType) :=
  Zmodule_isPzRing.Build {ffun aT -> R}
  (@ffun_mulA _ _) (@ffun_mul_1l _ _) (@ffun_mul_1r _ _)
  (@ffun_mul_addl _ _) (@ffun_mul_addr _ _).




Section FinFunRing.

Variable (aT : finType) (R : nzRingType) (a : aT).


HB.instance Definition _ :=
  PzSemiRing_isNonZero.Build {ffun aT -> R} (@ffun1_nonzero _ _ a).

Definition ffun_ring : nzRingType := {ffun aT -> R}.

End FinFunRing.


Section FinFunComRing.

Variable (aT : finType) (R : comPzRingType) (a : aT).

Fact ffun_mulC : commutative (@ffun_mul aT R).
Admitted.



End FinFunComRing.

Section FinFunLSemiMod.

Variable (R : pzSemiRingType) (aT : finType) (rT : lSemiModType R).

Implicit Types f g : {ffun aT -> rT}.

Definition ffun_scale k f := [ffun a => k *: f a].

Fact ffun_scaleA k1 k2 f :
  ffun_scale k1 (ffun_scale k2 f) = ffun_scale (k1 * k2) f.
Admitted.
Fact ffun_scale0r f : ffun_scale 0 f = 0.
Admitted.
Fact ffun_scale1 : left_id 1 ffun_scale.
Admitted.
Fact ffun_scale_addr k : {morph (ffun_scale k) : x y / x + y}.
Admitted.
Fact ffun_scale_addl u : {morph (ffun_scale)^~ u : k1 k2 / k1 + k2}.
Admitted.

#[export]
HB.instance Definition _ := Nmodule_isLSemiModule.Build R {ffun aT -> rT}
  ffun_scaleA ffun_scale0r ffun_scale1 ffun_scale_addr ffun_scale_addl.

End FinFunLSemiMod.

#[export]
HB.instance Definition _ (R : pzRingType) (aT : finType) (rT : lmodType R) :=
  LSemiModule.on {ffun aT -> rT}.





Section PairSemiRing.

Variables R1 R2 : pzSemiRingType.

Definition mul_pair (x y : R1 * R2) := (x.1 * y.1, x.2 * y.2).

Fact pair_mulA : associative mul_pair.
Admitted.

Fact pair_mul1l : left_id (1, 1) mul_pair.
Admitted.

Fact pair_mul1r : right_id (1, 1) mul_pair.
Admitted.

Fact pair_mulDl : left_distributive mul_pair +%R.
Admitted.

Fact pair_mulDr : right_distributive mul_pair +%R.
Admitted.

Fact pair_mul0r : left_zero 0 mul_pair.
Admitted.

Fact pair_mulr0 : right_zero 0 mul_pair.
Admitted.

#[export]
HB.instance Definition _ := Nmodule_isPzSemiRing.Build (R1 * R2)%type
  pair_mulA pair_mul1l pair_mul1r pair_mulDl pair_mulDr pair_mul0r pair_mulr0.

Fact fst_is_monoid_morphism : monoid_morphism fst.
Admitted.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build (R1 * R2)%type R1 fst
  fst_is_monoid_morphism.
Fact snd_is_monoid_morphism : monoid_morphism snd.
Admitted.
#[export]
HB.instance Definition _ := isMonoidMorphism.Build (R1 * R2)%type R2 snd
  snd_is_monoid_morphism.

End PairSemiRing.

Section PairSemiRing.

Variables R1 R2 : nzSemiRingType.

Fact pair_one_neq0 : 1 != 0 :> R1 * R2.
Admitted.

#[export]
HB.instance Definition _ := PzSemiRing_isNonZero.Build (R1 * R2)%type
  pair_one_neq0.

End PairSemiRing.

Section PairComSemiRing.

Variables R1 R2 : comPzSemiRingType.

Fact pair_mulC : commutative (@mul_pair R1 R2).
Admitted.

#[export]
HB.instance Definition _ := SemiRing_hasCommutativeMul.Build (R1 * R2)%type
  pair_mulC.

End PairComSemiRing.


#[export]
HB.instance Definition _ (R1 R2 : comNzSemiRingType) :=
  NzSemiRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : pzRingType) := PzSemiRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : nzRingType) := NzSemiRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : comPzRingType) := PzRing.on (R1 * R2)%type.
#[export]
HB.instance Definition _ (R1 R2 : comNzRingType) := NzRing.on (R1 * R2)%type.


Section PairLSemiMod.

Variables (R : pzSemiRingType) (V1 V2 : lSemiModType R).

Definition scale_pair a (v : V1 * V2) : V1 * V2 := (a *: v.1, a *: v.2).

Fact pair_scaleA a b u : scale_pair a (scale_pair b u) = scale_pair (a * b) u.
Admitted.

Fact pair_scale0 u : scale_pair 0 u = 0.
Admitted.

Fact pair_scale1 u : scale_pair 1 u = u.
Admitted.

Fact pair_scaleDr : right_distributive scale_pair +%R.
Admitted.

Fact pair_scaleDl u : {morph scale_pair^~ u: a b / a + b}.
Admitted.

#[export]
HB.instance Definition _ := Nmodule_isLSemiModule.Build R (V1 * V2)%type
  pair_scaleA pair_scale0 pair_scale1 pair_scaleDr pair_scaleDl.

Fact fst_is_scalable : scalable fst.
Admitted.
#[export]
HB.instance Definition _ :=
  isScalable.Build R (V1 * V2)%type V1 *:%R fst fst_is_scalable.
Fact snd_is_scalable : scalable snd.
Admitted.
#[export]
HB.instance Definition _ :=
  isScalable.Build R (V1 * V2)%type V2 *:%R snd snd_is_scalable.

End PairLSemiMod.

Section PairLSemiAlg.

Variables (R : pzSemiRingType) (A1 A2 : pzLSemiAlgType R).

Fact pair_scaleAl a (u v : A1 * A2) : a *: (u * v) = (a *: u) * v.
Admitted.

#[export]
HB.instance Definition _ := LSemiModule_isLSemiAlgebra.Build R (A1 * A2)%type
  pair_scaleAl.


#[export]
HB.instance Definition _ := RMorphism.on (@fst A1 A2).
#[export]
HB.instance Definition _ := RMorphism.on (@snd A1 A2).


End PairLSemiAlg.

Section PairSemiAlg.

Variables (R : pzSemiRingType) (A1 A2 : pzSemiAlgType R).

Fact pair_scaleAr a (u v : A1 * A2) : a *: (u * v) = u * (a *: v).
Admitted.

#[export]
HB.instance Definition _ := LSemiAlgebra_isSemiAlgebra.Build R (A1 * A2)%type
  pair_scaleAr.

End PairSemiAlg.


#[export]
HB.instance Definition _ (R : pzSemiRingType) (A1 A2 : comPzSemiAlgType R) :=
  PzSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : nzSemiRingType) (A1 A2 : nzLSemiAlgType R) :=
  PzLSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : nzSemiRingType) (A1 A2 : nzSemiAlgType R) :=
  PzSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (V1 V2 : lmodType R) :=
  LSemiModule.on (V1 * V2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : pzLalgType R) :=
  PzLSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : nzRingType) (A1 A2 : nzLalgType R) :=
  NzLSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : pzAlgType R) :=
  PzSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : nzRingType) (A1 A2 : nzAlgType R) :=
  NzSemiAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : pzRingType) (A1 A2 : comPzAlgType R) :=
  PzAlgebra.on (A1 * A2)%type.
#[export]
HB.instance Definition _ (R : nzRingType) (A1 A2 : comNzAlgType R) :=
  NzAlgebra.on (A1 * A2)%type.


Lemma pairMnE (M1 M2 : zmodType) (x : M1 * M2) n :
  x *+ n = (x.1 *+ n, x.2 *+ n).
Admitted.



HB.instance Definition _ := Zmodule_isComNzRing.Build bool
  andbA andbC andTb andb_addl isT.



HB.instance Definition _ := Nmodule_isComNzSemiRing.Build nat
  mulnA mulnC mul1n mulnDl mul0n erefl.

HB.instance Definition _ (R : pzSemiRingType) :=
  isMonoidMorphism.Build nat R (natmul 1) (mulr1n 1, natrM R).

Lemma natr0E : 0 = 0%N.
Admitted.
Lemma natr1E : 1 = 1%N.
Admitted.
Lemma natn n : n%:R = n.
Admitted.
Lemma natrDE n m : n + m = (n + m)%N.
Admitted.
Lemma natrME n m : n * m = (n * m)%N.
Admitted.
Lemma natrXE n m : n ^+ m = (n ^ m)%N.
Admitted.
Definition natrE := (natr0E, natr1E, natn, natrDE, natrME, natrXE).

End algebra.

End alg.

End algebra.

End mathcomp.

End mathcomp_DOT_algebra_DOT_alg_DOT_algebra.
Module mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Module Export divalg.

Import HB.structures.
Import mathcomp.boot.ssreflect.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.algebra.alg.algebra.

Set Implicit Arguments.
Unset Strict Implicit.

Local Open Scope ring_scope.

Module Import GRing.

Export GRing.

HB.mixin Record NzRing_hasMulInverse R & NzRing R := {
  unit_subdef : pred R;
  inv : R -> R;
  mulVr_subproof : {in unit_subdef, left_inverse 1 inv *%R};
  divrr_subproof : {in unit_subdef, right_inverse 1 inv *%R};
  unitrP_subproof : forall x y, y * x = 1 /\ x * y = 1 -> unit_subdef x;
  invr_out_subproof : {in [predC unit_subdef], inv =1 id}
}.

#[short(type="unitRingType")]
HB.structure Definition UnitRing := {R of NzRing_hasMulInverse R & NzRing R}.

Definition unit_pred {R : unitRingType} :=
  Eval cbv [ unit_subdef NzRing_hasMulInverse.unit_subdef ] in
    (fun u : R => unit_subdef u).
Definition unit {R : unitRingType} := [qualify a u : R | unit_pred u].

Local Notation "x ^-1" := (inv x).
Local Notation "x / y" := (x * y^-1).

Section UnitRingClosedPredicates.

Variables (R : unitRingType) (S : {pred R}).

Definition invr_closed := {in S, forall x, x^-1 \in S}.
Definition divr_2closed := {in S &, forall x y, x / y \in S}.
Definition divr_closed := 1 \in S /\ divr_2closed.
Definition sdivr_closed := -1 \in S /\ divr_2closed.
Definition divring_closed := [/\ 1 \in S, subr_closed S & divr_2closed].

Lemma divr_closedV : divr_closed -> invr_closed.
Admitted.

Lemma divr_closedM : divr_closed -> mulr_closed S.
Admitted.

Lemma sdivr_closed_div : sdivr_closed -> divr_closed.
Admitted.

Lemma divring_closedBM : divring_closed -> subring_closed S.
Admitted.

Lemma divring_closed_div : divring_closed -> sdivr_closed.
Admitted.

End UnitRingClosedPredicates.

#[short(type="comUnitRingType")]
HB.structure Definition ComUnitRing := {R of ComNzRing R & UnitRing R}.

HB.factory Record ComNzRing_hasMulInverse R & ComNzRing R := {
  unit : {pred R};
  inv : R -> R;
  mulVx : {in unit, left_inverse 1 inv *%R};
  unitPl : forall x y, y * x = 1 -> unit x;
  invr_out : {in [predC unit], inv =1 id}
}.

HB.builders Context R & ComNzRing_hasMulInverse R.

Fact mulC_mulrV : {in unit, right_inverse 1 inv *%R}.
Admitted.

Fact mulC_unitP x y : y * x = 1 /\ x * y = 1 -> unit x.
Admitted.

HB.instance Definition _ :=
  NzRing_hasMulInverse.Build R mulVx mulC_mulrV mulC_unitP invr_out.

HB.end.

#[short(type="unitAlgType")]
HB.structure Definition UnitAlgebra R := {V of NzAlgebra R V & UnitRing V}.

Section UnitAlgebraTheory.

Variable (R : comUnitRingType) (A : unitAlgType R).

Variables S : {pred A}.

Definition divalg_closed := [/\ 1 \in S, linear_closed S & divr_2closed S].

Lemma divalg_closedBdiv : divalg_closed -> divring_closed S.
Admitted.

End UnitAlgebraTheory.

Definition integral_domain_axiom (R : pzRingType) :=
  forall x y : R, x * y = 0 -> (x == 0) || (y == 0).

HB.mixin Record ComUnitRing_isIntegral R & ComUnitRing R := {
  mulf_eq0_subproof : integral_domain_axiom R;
}.

#[mathcomp(axiom="integral_domain_axiom"), short(type="idomainType")]
HB.structure Definition IntegralDomain :=
  {R of ComUnitRing_isIntegral R & ComUnitRing R}.

Definition field_axiom (R : unitRingType) := forall x : R, x != 0 -> x \in unit.

HB.mixin Record UnitRing_isField R & UnitRing R := {
  fieldP : field_axiom R;
}.

#[mathcomp(axiom="field_axiom"), short(type="fieldType")]
HB.structure Definition Field := { R of IntegralDomain R & UnitRing_isField R }.

Lemma IdomainMixin (R : unitRingType): Field.axiom R -> IntegralDomain.axiom R.
Admitted.

HB.factory Record ComUnitRing_isField R & ComUnitRing R := {
  fieldP : field_axiom R;
}.
HB.builders Context R & ComUnitRing_isField R.
HB.instance Definition _ :=
  ComUnitRing_isIntegral.Build R (IdomainMixin fieldP).
HB.end.

HB.factory Record ComNzRing_isField R & ComNzRing R := {
  inv : R -> R;
  mulVf : forall x, x != 0 -> inv x * x = 1;
  invr0 : inv 0 = 0;
}.

HB.builders Context R & ComNzRing_isField R.

Fact intro_unit (x y : R) : y * x = 1 -> x != 0.
Admitted.

Fact inv_out : {in predC (predC1 0), inv =1 id}.
Admitted.

HB.instance Definition _ : ComNzRing_hasMulInverse R :=
  ComNzRing_hasMulInverse.Build R mulVf intro_unit inv_out.

HB.end.

HB.mixin Record isInvClosed (R : unitRingType) (S : {pred R}) := {
  rpredVr : invr_closed S
}.

#[short(type="divClosed")]
HB.structure Definition DivClosed (R : unitRingType) :=
  {S of MulClosed R S & isInvClosed R S}.

HB.factory Record isDivClosed (R : unitRingType) (S : R -> bool) := {
  divr_closed_subproof : divr_closed S
}.

HB.builders Context R S & isDivClosed R S.
HB.instance Definition _ := isMulClosed.Build R S
  (divr_closedM divr_closed_subproof).
HB.instance Definition _ := isInvClosed.Build R S
  (divr_closedV divr_closed_subproof).
HB.end.

HB.factory Record isSdivClosed (R : unitRingType) (S : R -> bool) := {
  sdivr_closed_subproof : sdivr_closed S
}.

HB.builders Context R S & isSdivClosed R S.
HB.instance Definition _ := isDivClosed.Build R S
  (sdivr_closed_div sdivr_closed_subproof).
HB.end.

HB.factory Record isDivringClosed (R : unitRingType) (S : R -> bool) := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S & isDivringClosed R S.
HB.instance Definition _ := isSdivClosed.Build R S
  (divring_closed_div divring_closed_subproof).
HB.end.

HB.factory Record isDivalgClosed (R : comUnitRingType) (A : unitAlgType R)
    (S : A -> bool) := {
  divalg_closed_subproof : divalg_closed S
}.

HB.builders Context R A S & isDivalgClosed R A S.
HB.instance Definition _ := isDivringClosed.Build A S
  (divalg_closedBdiv divalg_closed_subproof).
HB.end.

#[short(type="subUnitRingType")]
HB.structure Definition SubUnitRing (R : nzRingType) (S : pred R) :=
  {U of SubNzRing R S U & UnitRing U}.

HB.factory Record SubNzRing_isSubUnitRing (R : unitRingType) S U
    & SubNzRing R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubNzRing_isSubUnitRing R S U.

HB.instance Definition _ := isDivringClosed.Build R S divring_closed_subproof.

Let inU v Sv : U := Sub v Sv.
Let invU (u : U) := inU (rpredVr _ (valP u)).

Lemma mulVr : {in [pred x | val x \is a unit], left_inverse 1 invU *%R}.
Admitted.
Lemma divrr : {in [pred x | val x \is a unit], right_inverse 1 invU *%R}.
Admitted.
Lemma unitrP (x y : U) : y * x = 1 /\ x * y = 1 -> val x \is a unit.
Admitted.
Lemma invr_out : {in [pred x | val x \isn't a unit], invU =1 id}.
Admitted.
HB.instance Definition _ := NzRing_hasMulInverse.Build U
  mulVr divrr unitrP invr_out.
HB.end.

#[short(type="subComUnitRingType")]
HB.structure Definition SubComUnitRing (R : comUnitRingType) (S : pred R) :=
  {U of SubComNzRing R S U & SubUnitRing R S U}.

#[short(type="subIdomainType")]
HB.structure Definition SubIntegralDomain (R : idomainType) (S : pred R) :=
  {U of SubComNzRing R S U & IntegralDomain U}.

HB.factory Record SubComUnitRing_isSubIntegralDomain (R : idomainType) S U
  & SubComUnitRing R S U := {}.

HB.builders Context R S U & SubComUnitRing_isSubIntegralDomain R S U.
Lemma id : IntegralDomain.axiom U.
Admitted.
HB.instance Definition _ := ComUnitRing_isIntegral.Build U id.
HB.end.

HB.factory Record SubIntegralDomain_isSubField (F : fieldType) S U
    & SubIntegralDomain F S U := {
  subfield_subproof : {mono (val : U -> F) : u / u \in unit}
}.

HB.builders Context F S U & SubIntegralDomain_isSubField F S U.
Lemma fieldP : Field.axiom U.
Admitted.
HB.instance Definition _ := UnitRing_isField.Build U fieldP.
HB.end.

HB.factory Record SubChoice_isSubUnitRing (R : unitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.end.

HB.factory Record SubChoice_isSubComUnitRing (R : comUnitRingType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubComUnitRing R S U.
HB.instance Definition _ := SubChoice_isSubComNzRing.Build R S U
  (divring_closedBM divring_closed_subproof).
HB.end.

HB.factory Record SubChoice_isSubIntegralDomain (R : idomainType) S U
    & SubChoice R S U := {
  divring_closed_subproof : divring_closed S
}.

HB.builders Context R S U & SubChoice_isSubIntegralDomain R S U.
HB.instance Definition _ := SubChoice_isSubComUnitRing.Build R S U
  divring_closed_subproof.
HB.end.

Module Export AllExports.
HB.reexport.
End AllExports.

End GRing.

Export AllExports.

End divalg.

End mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.
Include mathcomp_DOT_algebra_DOT_alg_DOT_divalg_WRAPPED.divalg.

Module mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Module Export orderedzmod.

Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Local Open Scope ring_scope.

Fact ring_display : Order.disp_t.
Admitted.

Module Export Num.

#[short(type="porderNmodType")]
HB.structure Definition POrderNmodule :=
  { R of Order.isPOrder ring_display R & GRing.Nmodule R}.

#[short(type="porderZmodType")]
HB.structure Definition POrderZmodule :=
  { R of POrderNmodule R & GRing.Zmodule R }.

HB.mixin Record Add_isHomo R & POrderNmodule R := {
  ler_wD2l : forall x : R, {homo +%R x : y z / (y <= z)%O}
}.

#[short(type="porderedNmodType")]
HB.structure Definition POrderedNmodule :=
  { R of POrderNmodule R & Add_isHomo R}.

#[short(type="porderedZmodType")]
HB.structure Definition POrderedZmodule :=
  { R of GRing.Zmodule R & POrderedNmodule R}.

HB.factory Record ZmodulePositiveCone R & GRing.Zmodule R := {
  nonneg : {pred R};
  nonneg0 : nonneg 0;
  nonnegD : forall x y, nonneg x -> nonneg y -> nonneg (x + y);
  nonneg_definite : forall x, nonneg x -> nonneg (- x) -> x = 0;
}.

HB.builders Context R & ZmodulePositiveCone R.

Definition le x y := nonneg (y - x).

Fact le_refl : reflexive le.
Admitted.

Fact le_anti : antisymmetric le.
Admitted.

Fact le_trans : transitive le.
Admitted.

HB.instance Definition _ := Order.Le_isPOrder.Build ring_display R
  le_refl le_anti le_trans.

HB.end.

HB.mixin Record POrderedZmodule_hasTransCmp R & GRing.Nmodule R
    & Order.isPOrder ring_display R := {
  comparabler_trans : transitive (Order.comparable : rel R)
}.

#[short(type="numZmodType")]
HB.structure Definition NumZmodule :=
  {R of POrderedZmodule_hasTransCmp R & POrderedZmodule R}.

Notation ler := (@Order.le ring_display _) (only parsing).
Notation ltr := (@Order.lt ring_display _) (only parsing).
Notation lerif := (@Order.leif ring_display _) (only parsing).

Notation le := ler (only parsing).
Notation lt := ltr (only parsing).

Module Import Syntax.

Notation "x <= y" := (le x y) : ring_scope.

Notation "x < y"  := (lt x y) : ring_scope.

Notation "x <= y ?= 'iff' C" := (lerif x y C) : ring_scope.

End Syntax.
End Num.
Export Num.Syntax.

End orderedzmod.

End mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.
Include mathcomp_DOT_algebra_DOT_num_theory_DOT_orderedzmod_WRAPPED.orderedzmod.
Import HB.structures.
Import mathcomp.boot.ssrfun.
Import mathcomp.boot.ssrbool.
Import mathcomp.boot.eqtype.
Import mathcomp.boot.choice.
Import mathcomp.boot.fintype.
Import mathcomp.boot.nmodule.
Import mathcomp.order.order.
Import mathcomp.algebra.alg.algebra.

Set Implicit Arguments.
Unset Strict Implicit.

Local Open Scope ring_scope.

HB.mixin Record Zmodule_isSemiNormed (R : POrderZmodule.type) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.

#[short(type="semiNormedZmodType")]
HB.structure Definition SemiNormedZmodule (R : porderZmodType) :=
  { M of Zmodule_isSemiNormed R M & GRing.Zmodule M }.

HB.mixin Record SemiNormedZmodule_isPositiveDefinite
    (R : POrderZmodule.type) M & @SemiNormedZmodule R M := {
  normr0_eq0 : forall x : M, norm x = 0 -> x = 0;
}.

#[short(type="normedZmodType")]
HB.structure Definition NormedZmodule (R : porderZmodType) :=
  { M of SemiNormedZmodule_isPositiveDefinite R M & SemiNormedZmodule R M }.

HB.factory Record Zmodule_isNormed (R : porderZmodType) M
         & GRing.Zmodule M := {
  norm : M -> R;
  ler_normD : forall x y, norm (x + y) <= norm x + norm y;
  normr0_eq0 : forall x, norm x = 0 -> x = 0;
  normrMn : forall x n, norm (x *+ n) = norm x *+ n;
  normrN : forall x, norm (- x) = norm x;
}.
HB.builders Context (R : POrderZmodule.type) M & Zmodule_isNormed R M.
  HB.instance Definition _ :=
    Zmodule_isSemiNormed.Build R M ler_normD normrMn normrN.
HB.end.

HB.mixin Record NumZmod_isNumRing R & GRing.NzRing R & POrderZmodule R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.

#[short(type="numDomainType")]
HB.structure Definition NumDomain := { R of
     GRing.IntegralDomain R &
     NumZmodule R &
     NormedZmodule (POrderZmodule.clone R _) R &
     NumZmod_isNumRing R
  }.

HB.factory Record isNumRing R & GRing.NzRing R & POrderZmodule R
  & GRing.IntegralDomain R
  & NormedZmodule (POrderZmodule.clone R _) R := {
 addr_gt0 : forall x y : R, 0 < x -> 0 < y -> 0 < (x + y);
 ger_leVge : forall x y : R, 0 <= x -> 0 <= y -> (x <= y) || (y <= x);
 normrM : {morph (norm : R -> R) : x y / x * y};
 ler_def : forall x y : R, (x <= y) = (norm (y - x) == (y - x));
}.
HB.builders Context R & isNumRing R.

Fact ler_wD2l (x : R) : {homo +%R x : y z / y <= z}.
Admitted.

HB.instance Definition _ := Add_isHomo.Build R ler_wD2l.
HB.end.

Section NumDomainOperationTheory.

Variable R : numDomainType.

Lemma leif_AGM_scaled (I : finType) (A : {pred I}) (E : I -> R) (n := #|A|) :
    {in A, forall i, 0 <= E i *+ n} ->
  \prod_(i in A) (E i *+ n) <= (\sum_(i in A) E i) ^+ n
                            ?= iff [forall i in A, forall j in A, E i == E j].
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 4.0MiB file on GitHub Actions Artifacts under build.log)
 '[' '' ']'
+ COQ_CI_COLOR=
+ export GIT_PAGER=
+ GIT_PAGER=
+ '[' '' = 1 ']'
+ '[' '' = 1 ']'
+ bash /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-mathcomp.sh
+ tee _build_ci/mathcomp.log
++ set -e
++ : 2
++ export NJOBS
+++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/ci-common.sh
++ . /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ which cygpath
+++ OCAMLFINDSEP=:
+++ '[' /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh ']'
++++ dirname /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../ci-env.sh
+++ root=/github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ cd /github/workspace/builds/coq/coq-failing/dev/ci/scripts/../../..
++++ echo /builds/coq/coq
+++ root=/builds/coq/coq
+++ '[' -n 1 ']'
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
+++ export OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
+++ export CI_BRANCH=
+++ CI_BRANCH=
+++ [[ '' =~ ^[0-9]*$ ]]
+++ export CI_PULL_REQUEST=
+++ CI_PULL_REQUEST=
+++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.2+flambda/bin:/github/workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
+++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ declare -A overlays
++ set +x
+ git_download mathcomp
+ local project=mathcomp
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local giturl_var=mathcomp_CI_GITURL
+ local giturl=https://github.com/math-comp/math-comp
+ local ref_var=mathcomp_CI_REF
+ local ref=master
+ local parent_project_var=mathcomp_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=mathcomp_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp ']'
+ echo 'Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.'
Warning: download and unpacking of mathcomp skipped because /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp already exists.
+ '[' '' ']'
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
+ make
+ '[' -z x ']'
+ command make
"/github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq" makefile  -f Make -o Makefile.coq
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
         use ROCQRUNTIMELIB instead.
         [deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
make -f Makefile.coq --no-print-directory
ROCQ compile algebra/num_theory/numdomain.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////rocq
MINIMIZER_DEBUG_EXTRA: original invocation: '' 
MINIMIZER_DEBUG_EXTRA: new invocation: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: ocamlpath: /github/workspace/builds/coq/coq-failing/_install_ci/lib:
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/mathcomp
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp algebra/num_theory/numdomain.v 
MINIMIZER_DEBUG_EXTRA: coqlib: Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.VZZyDgWkPu
MINIMIZER_DEBUG: files:  algebra/num_theory/numdomain.v /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp/algebra/num_theory/numdomain.vWarning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]Warning, feedback message received but no listener to handle it!
Warning: Deprecated environment variable COQLIB, use ROCQLIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "./algebra/num_theory/numdomain.v", line 1904, characters 63-76:
Error: In term, tolerating this expression at a higher level than expected by
the notation started on the left. This tolerance will be eventually removed.
Insert parentheses or try to lower the level at which the top symbol of this
expression is parsed.
[level-tolerance,deprecated-since-9.2,deprecated,parsing,default]

Command exited with non-zero status 1
algebra/num_theory/numdomain.vo (real: 20.48, user: 19.16, sys: 0.18, mem: 1085184 ko)
make[2]: *** [Makefile.coq:815: algebra/num_theory/numdomain.vo] Error 1
make[2]: *** [algebra/num_theory/numdomain.vo] Deleting file 'algebra/num_theory/numdomain.glob'
make[1]: *** [Makefile.coq:411: all] Error 2
make: *** [Makefile.common:99: this-build] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' mathcomp 2
+ '[' mathcomp '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real _build_ci/mathcomp.log
    Time |   Peak Mem | File Name                      
-------------------------------------------------------
0m20.48s | 1085184 ko | Total Time / Peak Mem          
-------------------------------------------------------
0m20.48s | 1085184 ko | algebra/num_theory/numdomain.vo
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 2.4MiB file on GitHub Actions Artifacts under bug.log)
nstant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -coqlib /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq// -R /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp mathcomp -Q /github/workspace/cwd Top -Q /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/HB HB -Q /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Ltac2 Ltac2 -Q /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi elpi -Q /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_elpi elpi_elpi -Q /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/elpi_examples elpi_examples -I /github/workspace/builds/coq/coq-failing/_build_ci/mathcomp -top Top.bug_01 -o /tmp/bug_01.vo -dump-glob /tmp/bug_01.glob bug_01.v
Moving '/tmp/bug_01.glob' to 'bug_01.glob'
/github/workspace/builds/coq/coq-passing/_install_ci/bin/coqc.orig -q -R /github/workspace/builds/coq/coq-passing/_build_ci/mathcomp mathcomp -Q /github/workspace/cwd Top -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/HB HB -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/Ltac2 Ltac2 -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/elpi elpi -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/elpi_elpi elpi_elpi -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/elpi_examples elpi_examples -I /github/workspace/builds/coq/coq-passing/_build_ci/mathcomp -q -w +duplicate-clear -w +non-primitive-record -w +undeclared-scope -w +deprecated-hint-without-locality -w +deprecated-hint-rewrite-without-locality -w -projection-no-head-constant -w -redundant-canonical-projection -w -notation-overridden -w -ambiguous-paths -w -elpi.add-const-for-axiom-or-sectionvar -w -mathcomp-subset-itv -w +level-tolerance -w -notation-for-abbreviation -w -deprecated-native-compiler-option -native-compiler ondemand -coqlib /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq// -R /github/workspace/builds/coq/coq-passing/_build_ci/mathcomp mathcomp -Q /github/workspace/cwd Top -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/HB HB -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/Ltac2 Ltac2 -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/elpi elpi -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/elpi_elpi elpi_elpi -Q /github/workspace/builds/coq/coq-passing/_install_ci/lib/coq///user-contrib/elpi_examples elpi_examples -I /github/workspace/builds/coq/coq-passing/_build_ci/mathcomp -top Top.bug_01 -o /tmp/bug_01.vo -dump-glob /tmp/bug_01.glob bug_01.v
WARNING: Clobbering 'bug_01.glob' (1772290369.4573658) from 'bug_01.v' (1772290304.6296422) despite failure of coqc
Taking the passing bug_01.glob file (25018 lines) because the failing version (24939 lines) is longer
getting bug_01.glob (/github/workspace/cwd/bug_01.glob)
getting bug_01.glob (/github/workspace/cwd/bug_01.glob)
�[92m
Succeeded in normalizing Requires (sorting by component).�[0m

Now, I will attempt to split up [Require] statements...
getting /github/workspace/cwd/bug_01.v
getting /github/workspace/cwd/bug_01.glob
getting /github/workspace/cwd/bug_01.glob

No Requires to split.

In order to efficiently manipulate the file, I have to break it into statements.  I will attempt to do this by matching on periods.
�[92m
Splitting successful.�[0m

I will now attempt to remove any lines after the line which generates the error.
�[92m
Trimming successful.  We removed all lines after 5696; the error was on line 5696.�[0m

In order to efficiently manipulate the file, I have to break it into definitions.  I will now attempt to do this.
Sending statements to coqtop...
Done.  Splitting to definitions...
�[92m
Splitting to definitions successful.�[0m

I will now attempt to remove duplicate Requires

No change.

I will now attempt to lift Requires and custom entry declarations while inserting option settings to the top of the file

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires and custom entry declarations to the top of the file

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to lift Requires while inserting option settings to the top of the file

I will now attempt to lift Requires to the top of the file while inserting option settings

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmp1d9xj6vv/Top/bug_01.v", line 46, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmp1d9xj6vv/Top/bug_01.v", line 677, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmp1d9xj6vv/Top/bug_01.v", line 46, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmp1d9xj6vv/Top/bug_01.v", line 677, characters 0-7:
Error: No builders to declare, did you forget HB.instance?


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds

Non-fatal error: Failed to admit Qeds and preserve the error.  
The new error was:
Deprecated environment variable COQCORELIB, use ROCQRUNTIMELIB instead.
Warning: Deprecated environment variable COQCORELIB,
use ROCQRUNTIMELIB instead.
[deprecated-coq-env-var,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpg0ohpsts/Top/bug_01.v", line 46, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Corelib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpg0ohpsts/Top/bug_01.v", line 2384, characters 0-62:
Error:
builtin coq.env.add-const: 2th argument: expected: closed_term got: app
   [global (const «RMorphism.class»), 
    app
     [global (const «GRing_PzLSemiAlgebra__to__GRing_PzSemiRing»), 
      global (const «R»), global (const «A»)], 
    app
     [global (const «GRing_PzLSemiAlgebra__to__GRing_PzSemiRing»), 
      global (const «R»), global (const «A»)], 
    app
     [global (const «ssrfun_idfun__canonical__GRing_RMorphism»), 
      app
       [global (const «GRing_PzLSemiAlgebra__to__GRing_PzSemiRing»), 
        global (const «R»), global (const «A»)], X0, X1, X2, X3]]


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

@SkySkimmer
Copy link
Contributor Author

Going to interrupt that, I don't think it's going anywhere

@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Mar 3, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Mar 3, 2026
@SkySkimmer
Copy link
Contributor Author

I can get the level tolerance warning like mathcomp by doing

Reserved Notation ", F" (at level 200).

Reserved Notation "[ 'forall' x 'in' A B ]".

Reserved Notation ", 'forall' x B"
  (at level 200, x at level 99).

Reserved Notation ", 'forall' x 'in' A B".

Set Warnings "+level-tolerance".
Fail Check [forall i in A, forall j in A, _].
(* doesn't parse, Fail can catch "unknown interpretation for notation" but can't catch parsing errors *)

@SkySkimmer SkySkimmer added the needs: progress Work in progress: awaiting action from the author. label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: progress Work in progress: awaiting action from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants