Skip to content

Delete mod_delta - #22954

Open
SkySkimmer wants to merge 8 commits into
rocq-prover:masterfrom
SkySkimmer:aliasing2
Open

SkySkimmer wants to merge 8 commits into
rocq-prover:masterfrom
SkySkimmer:aliasing2

Conversation

@SkySkimmer

@SkySkimmer SkySkimmer commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Depends:

Delta resolvers are now only used in substitutions. When we need a
delta resolver to build a substitution, we infer it from the module structure.

This simplifies data at rest, reducing the attack surface of crafted
.vo files.

@SkySkimmer SkySkimmer added the needs: merge of dependency This PR depends on another PR being merged first. label Nov 30, 2026
@coqbot-app coqbot-app Bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Nov 30, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@coqbot run full ci

@coqbot-app coqbot-app Bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Nov 30, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@coqbot bench

@coqbot-app

coqbot-app Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🏁 Bench results:

┌─────────────────────────────────────┬─────────────────────────┬───────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]      │           CPU instructions            │  max resident mem [KB]  │
│                                     │                         │                                       │                         │
│            package_name             │   NEW      OLD    PDIFF │      NEW             OLD        PDIFF │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼─────────────────────────┼───────────────────────────────────────┼─────────────────────────┤
│ coq-neural-net-interp-computed-lite │  248.05   253.52  -2.16 │  2321495634545   2321521326751  -0.00 │  948028   944372   0.39 │
│                 rocq-metarocq-utils │   19.36    19.56  -1.02 │   122554978599    122206341458   0.29 │  621764   621504   0.04 │
│                         coq-unimath │ 1586.76  1602.24  -0.97 │ 13338448218234  13338075657018   0.00 │ 1921280  1921080   0.01 │
│                            coq-core │    5.90     5.94  -0.67 │    42630762149     42684402049  -0.13 │  110096   110036   0.05 │
│                    coq-fiat-parsers │  267.39   268.91  -0.57 │  2023660383701   2022395678699   0.06 │ 2298068  2291036   0.31 │
│                        rocq-bignums │   21.93    22.03  -0.45 │   136375428582    136222109098   0.11 │  511820   508860   0.58 │
│                        coq-coqprime │   58.10    58.36  -0.45 │   383621140346    383657245385  -0.01 │  914244   913808   0.05 │
│                             coq-vst │  704.94   708.03  -0.44 │  5149634443857   5150004961668  -0.01 │ 2229108  2225296   0.17 │
│                      rocq-equations │   14.25    14.31  -0.42 │   100380465898    100402043032  -0.02 │  417984   417956   0.01 │
│                         coq-coqutil │   43.87    44.01  -0.32 │   266441188370    266544770802  -0.04 │  522476   521844   0.12 │
│                            coq-hott │  162.34   162.73  -0.24 │  1022418979100   1022864079118  -0.04 │  488312   494140  -1.18 │
│                       coq-fiat-core │   62.86    62.97  -0.17 │   397497141117    397772199074  -0.07 │  535972   535656   0.06 │
│                        coq-bedrock2 │  244.61   245.01  -0.16 │  1816628831759   1816933565390  -0.02 │  937256   935876   0.15 │
│               coq-engine-bench-lite │  114.19   114.22  -0.03 │   876195683088    879324561285  -0.36 │ 1047112  1044524   0.25 │
│                        coq-compcert │  281.69   281.72  -0.01 │  1763849548696   1765289498640  -0.08 │ 1375488  1438004  -4.35 │
│                         coq-ext-lib │   12.25    12.25   0.00 │    78866738658     78881965518  -0.02 │  426196   426100   0.02 │
│                          rocq-stdpp │   64.28    64.25   0.05 │   365986185479    366044737335  -0.02 │  773268   772376   0.12 │
│                        rocq-runtime │  272.41   272.14   0.10 │  2003979507713   2005488987227  -0.08 │  590224   592808  -0.44 │
│                           coq-flocq │   79.07    78.96   0.14 │   445153991007    445151251525   0.00 │  943104   938828   0.46 │
│                           coq-color │  222.13   221.78   0.16 │  1357674658984   1357585116084   0.01 │ 1326684  1282432   3.45 │
│                         rocq-stdlib │  241.03   240.60   0.18 │  1461937328768   1461374230114   0.04 │  809716   809788  -0.01 │
│                 coq-category-theory │ 1215.22  1209.91   0.44 │  8485714765569   8486377325021  -0.01 │ 1225656  1225660  -0.00 │
│          coq-performance-tests-lite │  748.15   744.88   0.44 │  5903912348073   5899045898276   0.08 │ 1792560  1782156   0.58 │
│                    coq-math-classes │   76.75    76.35   0.52 │   438422392611    438472791776  -0.01 │  546800   546488   0.06 │
│                rocq-metarocq-common │  124.91   124.18   0.59 │   781666735988    771617066264   1.30 │ 2287608  2287104   0.02 │
│                           rocq-core │   11.39    11.32   0.62 │    74009959455     74006266348   0.00 │  451292   450656   0.14 │
│                 rocq-metarocq-pcuic │  602.99   595.61   1.24 │  3689014325969   3630655633956   1.61 │ 2950300  2900960   1.70 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

INFO: failed to install
rocq-elpi (in NEW)
rocq-metarocq-template (in NEW)
coq-rewriter (in NEW)

rocq-mathcomp-boot (dependency rocq-elpi failed)
rocq-mathcomp-order (dependency rocq-elpi failed)
rocq-mathcomp-ssreflect (dependency rocq-elpi failed)
rocq-mathcomp-finite-group (dependency rocq-elpi failed)
rocq-mathcomp-algebra (dependency rocq-elpi failed)
rocq-mathcomp-solvable (dependency rocq-elpi failed)
rocq-mathcomp-field (dependency rocq-elpi failed)
rocq-mathcomp-group-representation (dependency rocq-elpi failed)
coq-mathcomp-odd-order (dependency rocq-elpi failed)
rocq-mathcomp-bigenough (dependency rocq-elpi failed)
rocq-mathcomp-finmap (dependency rocq-elpi failed)
rocq-mathcomp-classical (dependency rocq-elpi failed)
rocq-mathcomp-reals (dependency rocq-elpi failed)
rocq-mathcomp-analysis (dependency rocq-elpi failed)
coq-corn (dependency rocq-elpi failed)
rocq-metarocq-safechecker (dependency rocq-metarocq-template failed)
rocq-metarocq-template-pcuic (dependency rocq-metarocq-template failed)
rocq-metarocq-erasure (dependency rocq-metarocq-template failed)
rocq-metarocq-translations (dependency rocq-metarocq-template failed)
coq-fiat-crypto-with-bedrock (dependency coq-rewriter failed)
coq-coquelicot (dependency rocq-elpi failed)
rocq-iris (dependency rocq-elpi failed)
rocq-iris-heap-lang (dependency rocq-elpi failed)
rocq-iris-examples (dependency rocq-elpi failed)
coq-fourcolor-reals (dependency rocq-elpi failed)
coq-fourcolor (dependency rocq-elpi failed)
coq-rewriter-perf-SuperFast (dependency coq-rewriter failed)

🐢 Top 25 slow downs
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                        TOP 25 SLOW DOWNS                                                        │
│                                                                                                                                 │
│ OLD   NEW    DIFF   %DIFF    Ln                    FILE                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 38.6  39.5  0.8801   2.28%   224  coq-performance-tests-lite/PerformanceExperiments/rewrite_lift_lets_map.v.html                │
│ 13.2  13.6  0.4292   3.25%   832  coq-unimath/UniMath/CategoryTheory/ComprehensionCats/CwfFromCompCatWithUniv.v.html            │
│ 7.30  7.66  0.3646   5.00%  1016  coq-unimath/UniMath/CategoryTheory/ComprehensionCats/CwfFromCompCatWithUniv.v.html            │
│ 7.68  8.03  0.3499   4.56%   976  coq-category-theory/Instance/Grp/Colimit/Presentation.v.html                                  │
│ 8.43  8.72  0.2943   3.49%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_1_SuperFast.v.html      │
│ 9.02  9.31  0.2919   3.24%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_6_SuperFast.v.html      │
│ 38.8  39.0  0.2851   0.74%   116  coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html                                    │
│ 9.03  9.30  0.2665   2.95%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_3_SuperFast.v.html      │
│ 8.16  8.41  0.2515   3.08%    31  coq-performance-tests-lite/src/pattern.v.html                                                 │
│ 18.4  18.6  0.2324   1.26%    32  coq-performance-tests-lite/src/pattern.v.html                                                 │
│ 8.43  8.65  0.2191   2.60%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_2_SuperFast.v.html      │
│ 1.25  1.45  0.2083  16.71%     3  rocq-metarocq-pcuic/_build/default/theories/PCUIC/PCUICGeneration.v.html                      │
│ 9.12  9.32  0.2075   2.28%   669  coq-category-theory/Theory/Multicategory/Endomorphism.v.html                                  │
│ 1.22  1.41  0.1904  15.66%     4  rocq-metarocq-pcuic/_build/default/theories/PCUIC/PCUICSigmaCalculus.v.html                   │
│ 7.81  8.00  0.1898   2.43%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/Parametricity/_3_SuperFast.v.html     │
│ 1.22  1.40  0.1846  15.15%     5  rocq-metarocq-pcuic/_build/default/theories/PCUIC/Syntax/PCUICViews.v.html                    │
│ 8.18  8.36  0.1773   2.17%   415  coq-category-theory/Theory/Metacategory.v.html                                                │
│ 1.20  1.37  0.1710  14.21%     4  rocq-metarocq-pcuic/_build/default/theories/PCUIC/Syntax/PCUICInduction.v.html                │
│ 2.92  3.08  0.1643   5.63%  1461  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERNaturals.v.html            │
│ 16.7  16.9  0.1629   0.97%   670  coq-performance-tests-lite/src/Nia.v.html                                                     │
│ 1.21  1.37  0.1577  12.99%     3  rocq-metarocq-pcuic/_build/default/theories/PCUIC/utils/PCUICPretty.v.html                    │
│ 8.59  8.75  0.1571   1.83%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_5_SuperFast.v.html      │
│ 1.21  1.37  0.1561  12.86%     4  rocq-metarocq-pcuic/_build/default/theories/PCUIC/PCUICReduction.v.html                       │
│ 1.10  1.26  0.1554  14.14%     4  rocq-metarocq-pcuic/_build/default/theories/PCUIC/Conversion/PCUICUnivSubstitutionConv.v.html │
│ 1.23  1.38  0.1550  12.60%     6  rocq-metarocq-pcuic/_build/default/theories/PCUIC/Syntax/PCUICOnFreeVars.v.html               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                TOP 25 SPEED UPS                                                                 │
│                                                                                                                                                 │
│  OLD     NEW     DIFF     %DIFF    Ln                      FILE                                                                                 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│    222     217  -5.6228   -2.53%     8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html           │
│   60.1    59.0  -1.0935   -1.82%     3  coq-performance-tests-lite/PerformanceExperiments/typeclass_reification_let_in_HOAS/_0_SuperFast.v.html │
│   13.7    12.9  -0.7955   -5.81%   512  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Universal.v.html                  │
│   14.3    13.6  -0.7859   -5.48%   391  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html                │
│   7.39    6.90  -0.4883   -6.61%  1018  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html                   │
│   18.7    18.2  -0.4573   -2.45%    31  coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html                                               │
│   5.65    5.21  -0.4457   -7.88%   820  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERNaturals.v.html                      │
│   13.5    13.0  -0.4454   -3.31%     3  coq-performance-tests-lite/PerformanceExperiments/sieve_of_eratosthenes/_1_SuperFast.v.html             │
│   45.8    45.4  -0.3785   -0.83%   376  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│  6.773   6.413  -0.3600   -5.32%   192  coq-vst/veric/binop_lemmas5.v.html                                                                      │
│ 29.741  29.391  -0.3500   -1.18%    97  coq-vst/veric/binop_lemmas5.v.html                                                                      │
│   4.91    4.60  -0.3091   -6.29%   785  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html                   │
│   4.18    3.88  -0.3046   -7.28%   122  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html                   │
│   3.67    3.39  -0.2788   -7.59%   451  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERNaturals.v.html                      │
│  5.522   5.254  -0.2680   -4.85%   888  coq-vst/veric/binop_lemmas4.v.html                                                                      │
│   3.30    3.04  -0.2608   -7.91%   802  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialLam.v.html                   │
│   38.9    38.7  -0.2344   -0.60%   139  coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html                                            │
│   2.98    2.75  -0.2293   -7.69%   470  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERSubobjectClassifier.v.html           │
│ 31.798  31.578  -0.2200   -0.69%   834  coq-vst/veric/binop_lemmas4.v.html                                                                      │
│   24.6    24.4  -0.2010   -0.82%   374  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│ 25.531  25.345  -0.1860   -0.73%   147  coq-vst/veric/expr_lemmas4.v.html                                                                       │
│   7.71    7.53  -0.1826   -2.37%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_7_SuperFast.v.html                │
│   11.3    11.1  -0.1816   -1.61%   119  coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html                                            │
│   24.5    24.4  -0.1745   -0.71%   375  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                             │
│  0.366   0.194  -0.1721  -47.01%   267  coq-category-theory/Instance/Mod/Quotient/Isomorphism.v.html                                            │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@SkySkimmer SkySkimmer closed this Dec 1, 2026
@SkySkimmer SkySkimmer reopened this Dec 1, 2026
@coqbot-app coqbot-app Bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Dec 1, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

some vo sizes are exploding

rocq-metarocq-common/./_build/default/theories/Common/LoopChecking/UnivLoopChecking.vo 4429581 6735602 2306021 52%
rocq-stdlib/./theories/PArith/POrderedType.vo 132396 176916 44520 33%
rocq-metarocq-utils/./_build/default/theories/Utils/NonEmptyLevelExprSet.vo 461374 588036 126662 27%
rocq-stdlib/./theories/Structures/OrdersEx.vo 1270842 1587562 316720 24%
rocq-stdlib/./theories/Numbers/Integer/Binary/ZBinary.vo 188241 232637 44396 23%
rocq-stdlib/./theories/Numbers/Natural/Binary/NBinary.vo 175453 217428 41975 23%
coq-fiat-parsers/./src/Parsers/AbstractInterpretation/NonTerminalMapWf.vo 645019 777606 132587 20%
rocq-metarocq-common/./_build/default/theories/Common/LoopChecking/Models.vo 2036201 2389593 353392 17%
coq-fiat-parsers/./src/Parsers/ContextFreeGrammar/Fix/Fix.vo 764732 897715 132983 17%
rocq-metarocq-common/./_build/default/theories/Common/LoopChecking/PartialLoopChecking.vo 2599883 3012300 412417 15%
rocq-metarocq-common/./_build/default/theories/Common/Kernames.vo 1801946 2081456 279510 15%
rocq-metarocq-common/./_build/default/theories/Common/LoopChecking/HornSemilatticeEquiv.vo 1785623 2053715 268092 15%
coq-color/./MatrixInt/AArcticBZInt.vo 140095 162452 22357 15%
coq-color/./MatrixInt/AArcticInt.vo 147503 169655 22152 15%
coq-color/./Term/Lambda/LSystemT.vo 6896027 7856705 960678 13%
rocq-metarocq-common/./_build/default/theories/Common/Universes.vo 2974086 3369460 395374 13%
coq-fiat-parsers/./src/Parsers/ContextFreeGrammar/Fix/AsciiLattice.vo 252054 285109 33055 13%
coq-color/./MatrixInt/ATropicalInt.vo 165112 187948 22836 13%
coq-compcert/./backend/Allocproof.vo 1380437 1558721 178284 12%
rocq-metarocq-common/./_build/default/theories/Common/LoopChecking/Model.vo 2609331 2902153 292822 11%
coq-color/./Util/FSet/FSetUtil.vo 249074 274798 25724 10%

@SkySkimmer SkySkimmer added needs: progress Work in progress: awaiting action from the author. request: full CI Use this label when you want your next push to trigger a full CI. and removed needs: merge of dependency This PR depends on another PR being merged first. labels Dec 1, 2026
@coqbot-app coqbot-app Bot removed request: full CI Use this label when you want your next push to trigger a full CI. needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. labels Dec 1, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@coqbot bench

@SkySkimmer SkySkimmer added the needs: fixing The proposed code change is broken. label Dec 1, 2026
@coqbot-app

coqbot-app Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🏁 Bench results:

┌─────────────────────────────────────┬─────────────────────────┬───────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]      │           CPU instructions            │  max resident mem [KB]  │
│                                     │                         │                                       │                         │
│            package_name             │   NEW      OLD    PDIFF │      NEW             OLD        PDIFF │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼─────────────────────────┼───────────────────────────────────────┼─────────────────────────┤
│                            coq-core │    5.92     5.99  -1.17 │    42395988421     42454773522  -0.14 │  112604   112456   0.13 │
│                      rocq-equations │   13.91    14.07  -1.14 │   100980563061    100994390007  -0.01 │  424976   423436   0.36 │
│                          rocq-stdpp │   62.77    63.14  -0.59 │   371729879657    371941540193  -0.06 │  778264   778664  -0.05 │
│                       coq-fiat-core │   60.61    60.92  -0.51 │   397634906930    398197466129  -0.14 │  542556   542452   0.02 │
│                         coq-unimath │ 1559.45  1566.42  -0.44 │ 13477882834404  13478917514236  -0.01 │ 1928240  1928212   0.00 │
│                         rocq-stdlib │  231.98   232.45  -0.20 │  1483463223308   1484140729810  -0.05 │  813712   813864  -0.02 │
│                        rocq-bignums │   21.23    21.27  -0.19 │   137876071521    137928947689  -0.04 │  515944   513940   0.39 │
│                    coq-fiat-parsers │  264.01   264.42  -0.16 │  2091238789323   2091934390119  -0.03 │ 2299272  2301928  -0.12 │
│                        coq-coqprime │   57.29    57.34  -0.09 │   391268519811    391359920798  -0.02 │  920208   919092   0.12 │
│                    coq-math-classes │   73.85    73.90  -0.07 │   442921328599    443149579586  -0.05 │  553112   554872  -0.32 │
│                 rocq-metarocq-utils │   18.54    18.55  -0.05 │   124164680704    124284490253  -0.10 │  625172   625100   0.01 │
│          coq-performance-tests-lite │  728.56   728.51   0.01 │  5996529050140   5993722236212   0.05 │ 1829560  1828224   0.07 │
│                        rocq-runtime │  274.38   274.36   0.01 │  2002150989519   2003109190049  -0.05 │  595268   595416  -0.02 │
│                        coq-rewriter │  284.62   284.58   0.01 │  2143103713978   2143384004832  -0.01 │ 1533764  1531480   0.15 │
│                             coq-vst │  692.46   692.28   0.03 │  5215720261192   5216508726715  -0.02 │ 2232988  2232524   0.02 │
│                            coq-hott │  154.07   154.01   0.04 │  1035078736995   1035170096416  -0.01 │  494580   493256   0.27 │
│         coq-rewriter-perf-SuperFast │  371.52   371.35   0.05 │  2893932815958   2893748370411   0.01 │ 2067184  2054368   0.62 │
│                 coq-category-theory │ 1201.00  1200.38   0.05 │  8650820335509   8652422861963  -0.02 │ 1235028  1234784   0.02 │
│               coq-engine-bench-lite │  112.36   112.20   0.14 │   869738510356    869802224801  -0.01 │ 1056428  1056512  -0.01 │
│                        coq-bedrock2 │  238.65   238.18   0.20 │  1834669270705   1835496664504  -0.05 │  944708   940960   0.40 │
│        coq-fiat-crypto-with-bedrock │ 6486.58  6472.76   0.21 │ 53770093147317  53775722811298  -0.01 │ 5214176  5214500  -0.01 │
│                           coq-color │  215.12   214.40   0.34 │  1375904451389   1377898160420  -0.14 │ 1280320  1287224  -0.54 │
│                        coq-compcert │  277.05   275.91   0.41 │  1795187806422   1796700069338  -0.08 │ 1378992  1380568  -0.11 │
│                         coq-coqutil │   42.42    42.21   0.50 │   269022027168    269278331204  -0.10 │  526920   527076  -0.03 │
│                           coq-flocq │   77.84    77.40   0.57 │   450152019758    450276147557  -0.03 │  946224   948960  -0.29 │
│ coq-neural-net-interp-computed-lite │  253.84   251.60   0.89 │  2521559800638   2521611620714  -0.00 │  952484   953708  -0.13 │
│                rocq-metarocq-common │  123.69   122.31   1.13 │   786960857018    782295438851   0.60 │ 2296940  2285812   0.49 │
│                 rocq-metarocq-pcuic │  591.71   584.95   1.16 │  3710863035083   3681519355805   0.80 │ 2910892  2897092   0.48 │
│                           rocq-core │   11.19    10.94   2.29 │    75376268476     75379067387  -0.00 │  454032   454456  -0.09 │
│                         coq-ext-lib │   11.73    11.40   2.89 │    79467448266     79530694510  -0.08 │  430084   433608  -0.81 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

INFO: failed to install
rocq-elpi (in NEW)
rocq-metarocq-template (in NEW)

rocq-mathcomp-boot (dependency rocq-elpi failed)
rocq-mathcomp-order (dependency rocq-elpi failed)
rocq-mathcomp-ssreflect (dependency rocq-elpi failed)
rocq-mathcomp-finite-group (dependency rocq-elpi failed)
rocq-mathcomp-algebra (dependency rocq-elpi failed)
rocq-mathcomp-solvable (dependency rocq-elpi failed)
rocq-mathcomp-field (dependency rocq-elpi failed)
rocq-mathcomp-group-representation (dependency rocq-elpi failed)
coq-mathcomp-odd-order (dependency rocq-elpi failed)
rocq-mathcomp-bigenough (dependency rocq-elpi failed)
rocq-mathcomp-finmap (dependency rocq-elpi failed)
rocq-mathcomp-classical (dependency rocq-elpi failed)
rocq-mathcomp-reals (dependency rocq-elpi failed)
rocq-mathcomp-analysis (dependency rocq-elpi failed)
coq-corn (dependency rocq-elpi failed)
rocq-metarocq-template-pcuic (dependency rocq-metarocq-template failed)
rocq-metarocq-safechecker (dependency rocq-metarocq-template failed)
rocq-metarocq-erasure (dependency rocq-metarocq-template failed)
rocq-metarocq-translations (dependency rocq-metarocq-template failed)
coq-coquelicot (dependency rocq-elpi failed)
rocq-iris (dependency rocq-elpi failed)
rocq-iris-heap-lang (dependency rocq-elpi failed)
rocq-iris-examples (dependency rocq-elpi failed)
coq-fourcolor-reals (dependency rocq-elpi failed)
coq-fourcolor (dependency rocq-elpi failed)

🐢 Top 25 slow downs
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                             TOP 25 SLOW DOWNS                                                              │
│                                                                                                                                            │
│  OLD     NEW     DIFF   %DIFF   Ln                      FILE                                                                               │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│    220     223  2.4307  1.10%     8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html         │
│   63.7    65.7  2.0261  3.18%   279  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                         │
│   65.4    66.2  0.8090  1.24%   302  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/Addchain.v.html                                    │
│   31.7    32.5  0.8073  2.54%   575  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/MMIO.v.html                      │
│   44.8    45.4  0.6544  1.46%     4  coq-fiat-crypto-with-bedrock/src/ExtractionOCaml/bedrock2_fiat_crypto.v.html                          │
│   70.1    70.7  0.6095  0.87%    22  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ArithWithCasts.v.html                                │
│   31.1    31.6  0.5051  1.63%   197  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                         │
│   25.6    26.1  0.4572  1.79%   334  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html                                            │
│   52.8    53.2  0.3897  0.74%   259  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                         │
│   23.7    24.1  0.3829  1.61%    91  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/modinv/u320_shr.v.html                                  │
│   25.5    25.9  0.3700  1.45%   258  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html                                            │
│   25.5    25.9  0.3617  1.42%   310  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/Addchain.v.html                                    │
│   45.3    45.6  0.2904  0.64%     4  coq-fiat-crypto-with-bedrock/src/ExtractionOCaml/WithBedrock/fiat_crypto.v.html                       │
│   17.4    17.7  0.2831  1.62%     6  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeEncodeI.v.html   │
│   16.8    17.1  0.2759  1.64%   245  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                          │
│   17.7    18.0  0.2753  1.55%    32  coq-performance-tests-lite/src/pattern.v.html                                                         │
│   72.8    73.1  0.2650  0.36%   663  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                                 │
│   13.3    13.6  0.2560  1.93%     6  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/DecodeEncodeCSR.v.html │
│   26.9    27.1  0.2520  0.94%   247  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                          │
│   43.1    43.3  0.2492  0.58%     3  coq-fiat-crypto-with-bedrock/src/ExtractionOCaml/fiat_crypto.v.html                                   │
│   24.3    24.5  0.2431  1.00%   374  coq-unimath/UniMath/ModelCategories/Generated/LNWFSMonoidalStructure.v.html                           │
│ 14.286  14.529  0.2430  1.70%  1223  coq-vst/floyd/Component.v.html                                                                        │
│   6.07    6.31  0.2392  3.94%     8  coq-fiat-crypto-with-bedrock/src/PerfTesting/PerfTestSearch.v.html                                    │
│   2.73    2.96  0.2317  8.50%    33  coq-fiat-crypto-with-bedrock/src/Fancy/Barrett256.v.html                                              │
│    242     242  0.2310  0.10%   141  coq-fiat-crypto-with-bedrock/src/UnsaturatedSolinasHeuristics/Tests.v.html                            │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                           TOP 25 SPEED UPS                                                            │
│                                                                                                                                       │
│ OLD   NEW    DIFF    %DIFF    Ln                     FILE                                                                             │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 78.6  77.1  -1.4265  -1.82%    48  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                            │
│ 13.2  12.1  -1.0581  -8.04%   512  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Universal.v.html             │
│ 43.4  42.7  -0.7686  -1.77%   371  coq-fiat-crypto-with-bedrock/src/Stringification/Zig.v.html                                        │
│ 11.0  10.4  -0.6200  -5.64%  2325  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/compiler/src/compiler/FlatToRiscvFunctions.v.html   │
│ 7.54  6.95  -0.5851  -7.76%   820  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/NNORecursiveMap.v.html             │
│ 13.3  12.7  -0.5619  -4.23%   391  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html           │
│ 7.96  7.48  -0.4813  -6.05%   675  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                              │
│ 24.1  23.6  -0.4755  -1.98%    68  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/riscv-coq/src/riscv/Proofs/VerifyDecode.v.html │
│ 7.08  6.63  -0.4539  -6.41%  1018  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html              │
│ 13.2  12.8  -0.4147  -3.13%   832  coq-unimath/UniMath/CategoryTheory/ComprehensionCats/CwfFromCompCatWithUniv.v.html                 │
│ 4.09  3.77  -0.3209  -7.84%   122  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html              │
│ 45.4  45.1  -0.3107  -0.68%     4  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/bedrock2_fiat_crypto.v.html                   │
│ 7.71  7.42  -0.2971  -3.85%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_7_SuperFast.v.html           │
│ 12.9  12.7  -0.2746  -2.12%   197  coq-fiat-crypto-with-bedrock/src/Demo.v.html                                                       │
│ 3.51  3.25  -0.2563  -7.31%   451  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERNaturals.v.html                 │
│ 7.16  6.92  -0.2491  -3.48%  1016  coq-unimath/UniMath/CategoryTheory/ComprehensionCats/CwfFromCompCatWithUniv.v.html                 │
│ 3.24  3.01  -0.2287  -7.05%   189  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PEREqualizers.v.html               │
│ 4.86  4.64  -0.2245  -4.62%   785  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html              │
│ 28.4  28.2  -0.2169  -0.76%   348  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html                                         │
│ 2.97  2.75  -0.2148  -7.24%   498  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialPER.v.html              │
│ 9.18  8.97  -0.2103  -2.29%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_6_SuperFast.v.html           │
│ 8.23  8.03  -0.2072  -2.52%   326  coq-fiat-crypto-with-bedrock/src/Fancy/Barrett256.v.html                                           │
│ 4.26  4.07  -0.1917  -4.50%   437  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Universal.v.html             │
│ 20.3  20.1  -0.1866  -0.92%    98  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/coqutil/src/coqutil/Map/Memory.v.html          │
│ 8.52  8.34  -0.1778  -2.09%  2852  coq-fiat-crypto-with-bedrock/src/Assembly/EquivalenceProofs.v.html                                 │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@SkySkimmer SkySkimmer added request: full CI Use this label when you want your next push to trigger a full CI. and removed needs: progress Work in progress: awaiting action from the author. needs: fixing The proposed code change is broken. labels Dec 2, 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 Dec 2, 2026
@SkySkimmer SkySkimmer added kind: redesign The same functionality is being re-implemented in a different way. request: full CI Use this label when you want your next push to trigger a full CI. labels Dec 2, 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 Dec 2, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@coqbot bench

@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@coqbot ci minimize ci-color

@SkySkimmer
SkySkimmer requested review from a team as code owners December 2, 2026 12:50
We need to delay a call in declaremods to avoid calling it on an
invalid argument (ie avoid resurrecting rocq-prover#11845)
When introducing an aliasing, the object which gets a new aliasing is
not already aliased so there is no need to delta resolve.

NB: test suite passed when I kept the delta resolver use and added
"assert canon = user" in the aliasing = None branches.
I think if the kerpair is incorrect then the inductive from the
argument/discriminee type would not compare equal to the
projection/case info inductive
(assuming the argument is well typed), but it's probably better to be
explicit (until we get rid of kerpairs someday).

Also for cases the user name may have been unchecked with unknown
consequences (for projection it's checked by lookup_projection).
@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 2, 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 Dec 2, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@coqbot bench

@coqbot-app

coqbot-app Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor
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/color/Term/Lambda/LCompSimple.v in 5h 15m 5s (from ci-color) (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 48KiB file on GitHub Actions Artifacts under bug.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-w" "-deprecated-native-compiler-option" "-native-compiler" "no" "-coqlib" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq//" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/color" "CoLoR" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq///user-contrib/Bignums" "Bignums" "-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" "-top" "CoLoR.Term.Lambda.LCompSimple") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 523 lines to 10 lines, then from 24 lines to 1004 lines, then from 1011 lines to 83 lines, then from 97 lines to 1054 lines, then from 1061 lines to 94 lines, then from 108 lines to 692 lines, then from 699 lines to 106 lines, then from 120 lines to 2062 lines, then from 2069 lines to 118 lines, then from 132 lines to 2668 lines, then from 2675 lines to 130 lines, then from 144 lines to 1450 lines, then from 1457 lines to 169 lines, then from 183 lines to 642 lines, then from 648 lines to 196 lines, then from 210 lines to 1291 lines, then from 1298 lines to 215 lines, then from 229 lines to 981 lines, then from 988 lines to 227 lines, then from 241 lines to 508 lines, then from 515 lines to 248 lines, then from 262 lines to 835 lines, then from 839 lines to 694 lines, then from 706 lines to 1384 lines, then from 1390 lines to 707 lines, then from 719 lines to 1412 lines, then from 1415 lines to 737 lines, then from 749 lines to 1923 lines, then from 1914 lines to 989 lines, then from 1001 lines to 2307 lines, then from 2306 lines to 1291 lines, then from 1303 lines to 1872 lines, then from 1876 lines to 1362 lines, then from 1373 lines to 3400 lines, then from 3403 lines to 1638 lines, then from 1650 lines to 2047 lines, then from 2049 lines to 1947 lines *)
(* coqc version 9.4+alpha compiled with OCaml 5.4.1
   coqtop version 9.4+alpha
   Expected coqc runtime on this file: 1.019 sec
   Expected coqc peak memory usage on this file: 708256.0 kb *)









Require Corelib.Init.Datatypes.
Require Corelib.Lists.ListDef.
Require Corelib.Program.Basics.
Require Corelib.BinNums.PosDef.
Require Corelib.Classes.Morphisms_Prop.
Require Corelib.Init.Ltac.
Require Corelib.BinNums.NatDef.
Require Corelib.BinNums.IntDef.
Require Corelib.Relations.Relation_Definitions.
Require Corelib.Numbers.BinNums.
Require Corelib.Classes.Morphisms.
Require Corelib.Setoids.Setoid.
Require Corelib.Classes.RelationClasses.
Require Stdlib.Classes.DecidableClass.
Require Stdlib.Logic.Decidable.
Require Stdlib.Logic.EqdepFacts.
Require Stdlib.Logic.HLevelsBase.
Require Stdlib.Sets.Ensembles.
Require Stdlib.BinNums.IntDef.
Require Stdlib.BinNums.NatDef.
Require Stdlib.BinNums.PosDef.
Require Stdlib.Classes.Morphisms.
Require Stdlib.Classes.Morphisms_Prop.
Require Stdlib.Classes.RelationClasses.
Require Stdlib.Init.Datatypes.
Require Stdlib.Lists.ListDef.
Require Stdlib.Logic.Eqdep_dec.
Require Stdlib.Numbers.BinNums.
Require Stdlib.Program.Basics.
Require Stdlib.Relations.Relation_Definitions.
Require Stdlib.Setoids.Setoid.
Require Stdlib.Sets.Relations_1.
Require Stdlib.Bool.Bool.
Require Stdlib.Relations.Relation_Operators.
Require Stdlib.Relations.Operators_Properties.
Require Stdlib.PArith.BinPosDef.
Require Stdlib.Relations.Relations.
Require Stdlib.Numbers.NumPrelude.
Require Stdlib.Classes.RelationPairs.
Require Stdlib.Structures.Equalities.
Require Stdlib.Structures.Orders.
Require Stdlib.Structures.OrdersTac.
Require Stdlib.Structures.OrdersFacts.
Require Stdlib.Structures.GenericMinMax.
Require Stdlib.Numbers.NatInt.NZAxioms.
Require Stdlib.Numbers.NatInt.NZBase.
Require Stdlib.Numbers.NatInt.NZAdd.
Require Stdlib.Numbers.NatInt.NZMul.
Require Stdlib.Numbers.NatInt.NZOrder.
Require Stdlib.Numbers.NatInt.NZAddOrder.
Require Stdlib.Numbers.NatInt.NZMulOrder.
Require Stdlib.Numbers.NatInt.NZDiv.
Require Stdlib.Numbers.NatInt.NZGcd.
Require Stdlib.Numbers.NatInt.NZParity.
Require Stdlib.Numbers.NatInt.NZPow.
Require Stdlib.Numbers.NatInt.NZSqrt.
Require Stdlib.Numbers.NatInt.NZLog.
Require Stdlib.Numbers.NatInt.NZBits.
Require Stdlib.Numbers.Integer.Abstract.ZAxioms.
Require Stdlib.Numbers.Natural.Abstract.NAxioms.
Require Stdlib.Numbers.Integer.Abstract.ZBase.
Require Stdlib.Numbers.Natural.Abstract.NBase.
Require Stdlib.Numbers.Integer.Abstract.ZAdd.
Require Stdlib.Numbers.Natural.Abstract.NAdd.
Require Stdlib.Numbers.Integer.Abstract.ZMul.
Require Stdlib.Numbers.Natural.Abstract.NOrder.
Require Stdlib.Numbers.Integer.Abstract.ZLt.
Require Stdlib.Numbers.Natural.Abstract.NAddOrder.
Require Stdlib.Numbers.Integer.Abstract.ZAddOrder.
Require Stdlib.Numbers.Natural.Abstract.NMulOrder.
Require Stdlib.Numbers.Integer.Abstract.ZMulOrder.
Require Stdlib.Numbers.Natural.Abstract.NSub.
Require Stdlib.Numbers.Integer.Abstract.ZMaxMin.
Require Stdlib.Numbers.Integer.Abstract.ZParity.
Require Stdlib.Numbers.Integer.Abstract.ZSgnAbs.
Require Stdlib.Numbers.Natural.Abstract.NDiv.
Require Stdlib.Numbers.Natural.Abstract.NGcd.
Require Stdlib.Numbers.Natural.Abstract.NMaxMin.
Require Stdlib.Numbers.Natural.Abstract.NParity.
Require Stdlib.Numbers.Natural.Abstract.NSqrt.
Require Stdlib.Numbers.Integer.Abstract.ZDivFloor.
Require Stdlib.Numbers.Integer.Abstract.ZDivTrunc.
Require Stdlib.Numbers.Integer.Abstract.ZGcd.
Require Stdlib.Numbers.Natural.Abstract.NDiv0.
Require Stdlib.Numbers.Natural.Abstract.NPow.
Require Stdlib.Numbers.Integer.Abstract.ZPow.
Require Stdlib.Numbers.Natural.Abstract.NLcm.
Require Stdlib.Numbers.Natural.Abstract.NLog.
Require Stdlib.Numbers.Integer.Abstract.ZBits.
Require Stdlib.Numbers.Integer.Abstract.ZLcm.
Require Stdlib.Numbers.Natural.Abstract.NBits.
Require Stdlib.Numbers.Natural.Abstract.NLcm0.
Require Stdlib.Numbers.Integer.Abstract.ZProperties.
Require Stdlib.Numbers.Natural.Abstract.NProperties.
Require Stdlib.Arith.PeanoNat.
Require Stdlib.Arith.Peano_dec.
Require Stdlib.Lists.List.
Require Stdlib.PArith.BinPos.
Require Stdlib.Sorting.Sorted.
Require Stdlib.Sorting.SetoidList.
Require Stdlib.Structures.DecidableType.
Require Stdlib.Structures.OrderedType.
Require Stdlib.MSets.MSetInterface.
Require Stdlib.NArith.BinNatDef.
Require Stdlib.Structures.OrdersAlt.
Require Stdlib.FSets.FSetInterface.
Require Stdlib.FSets.FMapInterface.
Require Stdlib.NArith.BinNat.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Tactic Notation "admit" := abstract case proof_admitted.
Module Export BinIntDef.
Import Stdlib.PArith.BinPos.
Import Stdlib.NArith.BinNat.

#[local] Open Scope Z_scope.

#[local] Notation "0" := Z0.
#[local] Notation "1" := (Zpos 1).
#[local] Notation "2" := (Zpos 2).







Module Z.

Include BinNums.IntDef.Z.

Definition t := Z.



#[global] Abbreviation pos := Zpos.
#[global] Abbreviation neg := Zneg.



Definition zero := 0.
Definition one := 1.
Definition two := 2.



Definition succ x := x + 1.



Definition pred x := x + neg 1.



Definition square x :=
  match x with
    | 0 => 0
    | pos p => pos (Pos.square p)
    | neg p => pos (Pos.square p)
  end.



Definition sgn z :=
  match z with
    | 0 => 0
    | pos p => 1
    | neg p => neg 1
  end.

Infix "=?" := eqb (at level 70, no associativity) : Z_scope.
Infix "<=?" := leb (at level 70, no associativity) : Z_scope.
Infix "<?" := ltb (at level 70, no associativity) : Z_scope.



Definition abs z :=
  match z with
    | 0 => 0
    | pos p => pos p
    | neg p => pos p
  end.



Definition of_uint (d:Decimal.uint) := of_N (Pos.of_uint d).

Definition of_hex_uint (d:Hexadecimal.uint) := of_N (Pos.of_hex_uint d).

Definition of_int (d:Decimal.int) :=
  match d with
  | Decimal.Pos d => of_uint d
  | Decimal.Neg d => opp (of_uint d)
  end.

Definition of_hex_int (d:Hexadecimal.int) :=
  match d with
  | Hexadecimal.Pos d => of_hex_uint d
  | Hexadecimal.Neg d => opp (of_hex_uint d)
  end.

Definition of_num_int (d:Number.int) :=
  match d with
  | Number.IntDecimal d => of_int d
  | Number.IntHexadecimal d => of_hex_int d
  end.

Definition to_int n :=
  match n with
  | 0 => Decimal.Pos Decimal.zero
  | pos p => Decimal.Pos (Pos.to_uint p)
  | neg p => Decimal.Neg (Pos.to_uint p)
  end.

Definition to_num_int n := Number.IntDecimal (to_int n).

Infix "/" := div : Z_scope.
Infix "mod" := modulo (at level 40, no associativity) : Z_scope.



Definition odd z :=
  match z with
    | 0 => false
    | pos (xO _) => false
    | neg (xO _) => false
    | _ => true
  end.





Definition log2 z :=
  match z with
    | pos (p~1) => pos (Pos.size p)
    | pos (p~0) => pos (Pos.size p)
    | _ => 0
  end.



Definition sqrt n :=
 match n with
  | pos p => pos (Pos.sqrt p)
  | _ => 0
 end.



Definition gcd a b :=
  match a,b with
    | 0, _ => abs b
    | _, 0 => abs a
    | pos a, pos b => pos (Pos.gcd a b)
    | pos a, neg b => pos (Pos.gcd a b)
    | neg a, pos b => pos (Pos.gcd a b)
    | neg a, neg b => pos (Pos.gcd a b)
  end.







Definition testbit a n :=
 match n with
   | 0 => odd a
   | pos p =>
     match a with
       | 0 => false
       | pos a => Pos.testbit a (N.pos p)
       | neg a => negb (N.testbit (Pos.pred_N a) (N.pos p))
     end
   | neg _ => false
 end.



Definition ldiff a b :=
 match a, b with
   | 0, _ => 0
   | _, 0 => a
   | pos a, pos b => of_N (Pos.ldiff a b)
   | neg a, pos b => neg (N.succ_pos (N.lor (Pos.pred_N a) (N.pos b)))
   | pos a, neg b => of_N (N.land (N.pos a) (Pos.pred_N b))
   | neg a, neg b => of_N (N.ldiff (Pos.pred_N b) (Pos.pred_N a))
 end.
Number Notation Z of_num_int to_num_int : Z_scope.

End Z.

End BinIntDef.
Module Export Stdlib_DOT_ZArith_DOT_BinIntDef.
Module Export Stdlib.
Module Export ZArith.
Module Export BinIntDef.
End BinIntDef.

End ZArith.

End Stdlib.

End Stdlib_DOT_ZArith_DOT_BinIntDef.
Export Stdlib.PArith.BinPos.
Import Stdlib.Bool.Bool.
Import Stdlib.Structures.OrdersFacts.
Import Stdlib.Numbers.Integer.Abstract.ZProperties.

#[local] Open Scope Z_scope.

Module Z
 <: ZAxiomsSig
 <: UsualOrderedTypeFull
 <: UsualDecidableTypeFull
 <: TotalOrder.

Include BinIntDef.Z.

Definition eq := @Logic.eq Z.
Definition eq_equiv := @eq_equivalence Z.
Notation "x <= y < z" := (x <= y /\ y < z) : Z_scope.
Notation "x < y <= z" := (x < y /\ y <= z) : Z_scope.

Definition divide x y := exists z, y = z*x.
Notation "( x | y )" := (divide x y) (at level 0).

Definition Even a := exists b, a = 2*b.
Definition Odd a := exists b, a = 2*b+1.

Definition eq_dec (x y : Z) : {x = y} + {x <> y}.
Admitted.
Program Definition succ_wd : Proper (eq==>eq) succ.
Admitted.
Program Definition pred_wd : Proper (eq==>eq) pred.
Admitted.
Program Definition opp_wd : Proper (eq==>eq) opp.
Admitted.
Program Definition add_wd : Proper (eq==>eq==>eq) add.
Admitted.
Program Definition sub_wd : Proper (eq==>eq==>eq) sub.
Admitted.
Program Definition mul_wd : Proper (eq==>eq==>eq) mul.
Admitted.
Program Definition lt_wd : Proper (eq==>eq==>iff) lt.
Admitted.
Program Definition div_wd : Proper (eq==>eq==>eq) div.
Admitted.
Program Definition mod_wd : Proper (eq==>eq==>eq) modulo.
Admitted.
Program Definition quot_wd : Proper (eq==>eq==>eq) quot.
Admitted.
Program Definition rem_wd : Proper (eq==>eq==>eq) rem.
Admitted.
Program Definition pow_wd : Proper (eq==>eq==>eq) pow.
Admitted.
Program Definition testbit_wd : Proper (eq==>eq==>Logic.eq) testbit.
Admitted.

Lemma one_succ : 1 = succ 0.
Admitted.

Lemma two_succ : 2 = succ 1.
Admitted.

Lemma add_0_l n : 0 + n = n.
Admitted.

Lemma add_succ_l n m : succ n + m = succ (n + m).
Admitted.

Lemma opp_0 : -0 = 0.
Admitted.

Lemma opp_succ n : -(succ n) = pred (-n).
Admitted.

Lemma succ_pred n : succ (pred n) = n.
Admitted.

Lemma pred_succ n : pred (succ n) = n.
Admitted.

Lemma sub_0_r n : n - 0 = n.
Admitted.

Lemma sub_succ_r n m : n - succ m = pred (n - m).
Admitted.

Lemma mul_0_l n : 0 * n = 0.
Admitted.

Lemma mul_succ_l n m : succ n * m = n * m + m.
Admitted.

Lemma eqb_eq n m : (n =? m) = true <-> n = m.
Admitted.

Lemma ltb_lt n m : (n <? m) = true <-> n < m.
Admitted.

Lemma leb_le n m : (n <=? m) = true <-> n <= m.
Admitted.

Lemma compare_eq_iff n m : (n ?= m) = Eq <-> n = m.
Admitted.

Lemma compare_antisym n m : (m ?= n) = CompOpp (n ?= m).
Admitted.

Lemma compare_lt_iff n m : (n ?= m) = Lt <-> n < m.
Admitted.

Lemma compare_le_iff n m : (n ?= m) <> Gt <-> n <= m.
Admitted.

Include BoolOrderFacts.

Lemma lt_succ_r n m : n < succ m <-> n<=m.
Admitted.

Lemma max_l n m : m<=n -> max n m = n.
Admitted.

Lemma max_r n m :  n<=m -> max n m = m.
Admitted.

Lemma min_l n m : n<=m -> min n m = n.
Admitted.

Lemma min_r n m : m<=n -> min n m = m.
Admitted.

Lemma bi_induction (P : Z -> Prop) :
  Proper (eq ==> iff) P ->
  P 0 ->
  (forall x, P x <-> P (succ x)) ->
  forall z, P z.
Admitted.

Include ZBasicProp <+ UsualMinMaxLogicalProperties <+ UsualMinMaxDecProperties.

Lemma abs_eq n : 0 <= n -> abs n = n.
Admitted.

Lemma abs_neq n : n <= 0 -> abs n = - n.
Admitted.

Lemma sgn_null n : n = 0 -> sgn n = 0.
Admitted.

Lemma sgn_pos n : 0 < n -> sgn n = 1.
Admitted.

Lemma sgn_neg n : n < 0 -> sgn n = -1.
Admitted.

Lemma pow_0_r n : n^0 = 1.
Admitted.

Lemma pow_succ_r n m : 0<=m -> n^(succ m) = n * n^m.
Admitted.

Lemma pow_neg_r n m : m<0 -> n^m = 0.
Admitted.

Lemma square_spec n : square n = n * n.
Admitted.

Lemma sqrt_spec n : 0<=n ->
 let s := sqrt n in s*s <= n < (succ s)*(succ s).
Admitted.

Lemma sqrt_neg n : n<0 -> sqrt n = 0.
Admitted.

Lemma log2_spec n : 0 < n -> 2^(log2 n) <= n < 2^(succ (log2 n)).
Admitted.

Lemma log2_nonpos n : n<=0 -> log2 n = 0.
Admitted.

Lemma even_spec n : even n = true <-> Even n.
Admitted.

Lemma odd_spec n : odd n = true <-> Odd n.
Admitted.

Lemma div_mod a b : b<>0 -> a = b*(a/b) + (a mod b).
Admitted.

Lemma mod_pos_bound a b : 0 < b -> 0 <= a mod b < b.
Admitted.

Definition mod_bound_pos a b (_:0<=a) := mod_pos_bound a b.

Lemma mod_neg_bound a b : b < 0 -> b < a mod b <= 0.
Admitted.

Lemma quot_rem a b : b<>0 -> a = b*(a÷b) + rem a b.
Admitted.

Lemma rem_bound_pos a b : 0<=a -> 0<b -> 0 <= rem a b < b.
Admitted.

Lemma rem_opp_l a b : b<>0 -> rem (-a) b = - (rem a b).
Admitted.

Lemma rem_opp_r a b : b<>0 -> rem a (-b) = rem a b.
Admitted.

Lemma gcd_divide_l a b : (gcd a b | a).
Admitted.

Lemma gcd_divide_r a b : (gcd a b | b).
Admitted.

Lemma gcd_greatest a b c : (c|a) -> (c|b) -> (c | gcd a b).
Admitted.

Lemma gcd_nonneg a b : 0 <= gcd a b.
Admitted.

Lemma div2_spec a : div2 a = shiftr a 1.
Admitted.

Lemma testbit_neg_r a n : n<0 -> testbit a n = false.
Admitted.

Lemma testbit_odd_0 a : testbit (2*a+1) 0 = true.
Admitted.

Lemma testbit_even_0 a : testbit (2*a) 0 = false.
Admitted.

Lemma testbit_odd_succ a n : 0<=n ->
 testbit (2*a+1) (succ n) = testbit a n.
Admitted.

Lemma testbit_even_succ a n : 0<=n ->
 testbit (2*a) (succ n) = testbit a n.
Admitted.

Lemma shiftl_spec_low a n m : m<n ->
                              testbit (shiftl a n) m = false.
Admitted.

Lemma shiftl_spec_high a n m : 0<=m -> n<=m ->
                               testbit (shiftl a n) m = testbit a (m-n).
Admitted.

Lemma shiftr_spec a n m : 0<=m ->
 testbit (shiftr a n) m = testbit a (m+n).
Admitted.

Lemma lor_spec a b n :
 testbit (lor a b) n = testbit a n || testbit b n.
Admitted.

Lemma land_spec a b n :
 testbit (land a b) n = testbit a n && testbit b n.
Admitted.

Lemma ldiff_spec a b n :
 testbit (ldiff a b) n = testbit a n && negb (testbit b n).
Admitted.

Lemma lxor_spec a b n :
 testbit (lxor a b) n = xorb (testbit a n) (testbit b n).
Admitted.

End Z.

Number Notation Z Z.of_num_int Z.to_num_int : Z_scope.

Infix "+" := Z.add : Z_scope.
Notation "- x" := (Z.opp x) : Z_scope.
Infix "-" := Z.sub : Z_scope.
Infix "*" := Z.mul : Z_scope.
Module Export BinInt.
End BinInt.
Declare Scope Int_scope.
#[local] Open Scope Int_scope.

Module Type Int.

  Parameter t : Set.
  Parameter _1 : t.
  Parameter _2 : t.
  Parameter add : t -> t -> t.
  Parameter max : t -> t -> t.
  Notation "1" := _1 : Int_scope.
  Notation "2" := _2 : Int_scope.
  Infix "+" := add : Int_scope.
  Axiom ltb : t -> t -> bool.
  Axiom leb : t -> t -> bool.
  Infix "<?" := ltb.
  Infix "<=?" := leb.

End Int.

Module MoreInt (Import I:Int).

End MoreInt.

Module Z_as_Int <: Int.
  #[local] Open Scope Z_scope.
  Definition t := Z.
  Definition _0 := 0.
  Definition _1 := 1.
  Definition _2 := 2.
  Definition _3 := 3.
  Definition add := Z.add.
  Definition max := Z.max.
  Definition eqb := Z.eqb.
  Definition ltb := Z.ltb.
  Definition leb := Z.leb.
Definition i2z : t -> Z.
Admitted.
  Lemma i2z_eq n p : i2z n = i2z p -> n = p.
Admitted.
  Lemma i2z_0 : i2z _0 = 0.
Admitted.
  Lemma i2z_1 : i2z _1 = 1.
Admitted.
  Lemma i2z_2 : i2z _2 = 2.
Admitted.
  Lemma i2z_3 : i2z _3 = 3.
Admitted.
  Lemma i2z_add n p : i2z (n + p) = i2z n + i2z p.
Admitted.
  Lemma i2z_opp n : i2z (- n) = - i2z n.
Admitted.
  Lemma i2z_sub n p : i2z (n - p) = i2z n - i2z p.
Admitted.
  Lemma i2z_mul n p : i2z (n * p) = i2z n * i2z p.
Admitted.
  Lemma i2z_max n p : i2z (max n p) = Z.max (i2z n) (i2z p).
Admitted.
  Lemma i2z_eqb n p : eqb n p = Z.eqb (i2z n) (i2z p).
Admitted.
  Lemma i2z_leb n p : leb n p = Z.leb (i2z n) (i2z p).
Admitted.
  Lemma i2z_ltb n p : ltb n p = Z.ltb (i2z n) (i2z p).
Admitted.
End Z_as_Int.
Module Export Stdlib.
Module Export ZArith.
Module Export Int.
End Int.
Module Export MSetGenTree.
Import Stdlib.MSets.MSetInterface.
#[local] Open Scope lazy_bool_scope.

Module Type InfoTyp.
 Parameter t : Set.
End InfoTyp.

Module Ops (X:OrderedType)(Info:InfoTyp).

Definition elt := X.t.

Inductive tree  : Type :=
| Leaf : tree
| Node : Info.t -> tree -> X.t -> tree -> tree.

Definition empty := Leaf.

Definition is_empty t :=
 match t with
 | Leaf => true
 | _ => false
 end.

Fixpoint mem x t :=
 match t with
 | Leaf => false
 | Node _ l k r =>
   match X.compare x k with
     | Lt => mem x l
     | Eq => true
     | Gt => mem x r
   end
 end.
Fixpoint min_elt (t : tree) : option elt.
Admitted.
Fixpoint max_elt (t : tree) : option elt.
Admitted.

Definition choose := min_elt.

Fixpoint fold {A: Type} (f: elt -> A -> A) (t: tree) (base: A) : A :=
  match t with
  | Leaf => base
  | Node _ l x r => fold f r (f x (fold f l base))
 end.

Fixpoint elements_aux acc s :=
  match s with
   | Leaf => acc
   | Node _ l x r => elements_aux (x :: elements_aux acc r) l
  end.

Definition elements := elements_aux nil.
Fixpoint cardinal (s : tree) : nat.
Admitted.

Fixpoint for_all (f:elt->bool) s := match s with
  | Leaf => true
  | Node _ l x r => f x &&& for_all f l &&& for_all f r
end.

Fixpoint exists_ (f:elt->bool) s := match s with
  | Leaf => false
  | Node _ l x r => f x ||| exists_ f l ||| exists_ f r
end.

Inductive enumeration :=
 | End : enumeration
 | More : elt -> tree -> enumeration -> enumeration.

Fixpoint cons s e : enumeration :=
 match s with
  | Leaf => e
  | Node _ l x r => cons l (More x r e)
 end.

Definition compare_more x1 (cont:enumeration->comparison) e2 :=
 match e2 with
 | End => Gt
 | More x2 r2 e2 =>
     match X.compare x1 x2 with
      | Eq => cont (cons r2 e2)
      | Lt => Lt
      | Gt => Gt
     end
 end.

Fixpoint compare_cont s1 (cont:enumeration->comparison) e2 :=
 match s1 with
  | Leaf => cont e2
  | Node _ l1 x1 r1 =>
     compare_cont l1 (compare_more x1 (compare_cont r1 cont)) e2
  end.

Definition compare_end e2 :=
 match e2 with End => Eq | _ => Lt end.

Definition compare s1 s2 := compare_cont s1 compare_end (cons s2 End).

Definition equal s1 s2 :=
 match compare s1 s2 with Eq => true | _ => false end.

Fixpoint subsetl (subset_l1 : tree -> bool) x1 s2 : bool :=
 match s2 with
  | Leaf => false
  | Node _ l2 x2 r2 =>
     match X.compare x1 x2 with
      | Eq => subset_l1 l2
      | Lt => subsetl subset_l1 x1 l2
      | Gt => mem x1 r2 &&& subset_l1 s2
     end
 end.

Fixpoint subsetr (subset_r1 : tree -> bool) x1 s2 : bool :=
 match s2 with
  | Leaf => false
  | Node _ l2 x2 r2 =>
     match X.compare x1 x2 with
      | Eq => subset_r1 r2
      | Lt => mem x1 l2 &&& subset_r1 s2
      | Gt => subsetr subset_r1 x1 r2
     end
 end.

Fixpoint subset s1 s2 : bool := match s1, s2 with
  | Leaf, _ => true
  | Node _ _ _ _, Leaf => false
  | Node _ l1 x1 r1, Node _ l2 x2 r2 =>
     match X.compare x1 x2 with
      | Eq => subset l1 l2 &&& subset r1 r2
      | Lt => subsetl (subset l1) x1 l2 &&& subset r1 s2
      | Gt => subsetr (subset r1) x1 r2 &&& subset l1 s2
     end
 end.

End Ops.

Module Type OpsT (X:OrderedType)(Info:InfoTyp).
Include Ops X Info.
End OpsT.

Module Props (X:OrderedType)(Info:InfoTyp)(Import M:OpsT X Info).

Inductive InT (x : elt) : tree -> Prop :=
  | IsRoot : forall c l r y, X.eq x y -> InT x (Node c l y r)
  | InLeft : forall c l r y, InT x l -> InT x (Node c l y r)
  | InRight : forall c l r y, InT x r -> InT x (Node c l y r).

Definition In := InT.

Definition Equal s s' := forall a : elt, InT a s <-> InT a s'.
Definition Subset s s' := forall a : elt, InT a s -> InT a s'.
Definition Empty s := forall a : elt, ~ InT a s.
Definition For_all (P : elt -> Prop) s := forall x, InT x s -> P x.
Definition Exists (P : elt -> Prop) s := exists x, InT x s /\ P x.

Definition lt_tree x s := forall y, InT y s -> X.lt y x.
Definition gt_tree x s := forall y, InT y s -> X.lt x y.

Inductive bst : tree -> Prop :=
  | BSLeaf : bst Leaf
  | BSNode : forall c x l r, bst l -> bst r ->
     lt_tree x l -> gt_tree x r -> bst (Node c l x r).

Definition IsOk := bst.

Class Ok (s:tree) : Prop := ok : bst s.

Fixpoint ltb_tree x s :=
 match s with
  | Leaf => true
  | Node _ l y r =>
     match X.compare x y with
      | Gt => ltb_tree x l && ltb_tree x r
      | _ => false
     end
 end.

Fixpoint gtb_tree x s :=
 match s with
  | Leaf => true
  | Node _ l y r =>
     match X.compare x y with
      | Lt => gtb_tree x l && gtb_tree x r
      | _ => false
     end
 end.

Fixpoint isok s :=
 match s with
  | Leaf => true
  | Node _  l x r => isok l && isok r && ltb_tree x l && gtb_tree x r
 end.

#[global]
Instance isok_Ok s : isok s = true -> Ok s | 10.
Admitted.

#[global]
Instance In_compat : Proper (X.eq==>eq==>iff) InT.
Admitted.

Lemma empty_spec : Empty empty.
Admitted.

#[global]
Instance empty_ok : Ok empty.
Admitted.

Lemma is_empty_spec : forall s, is_empty s = true <-> Empty s.
Admitted.

Lemma mem_spec : forall s x `{Ok s}, mem x s = true <-> InT x s.
Admitted.

Lemma min_elt_spec1 s x : min_elt s = Some x -> InT x s.
Admitted.

Lemma min_elt_spec2 s x y `{Ok s} :
 min_elt s = Some x -> InT y s -> ~ X.lt y x.
Admitted.

Lemma min_elt_spec3 s : min_elt s = None -> Empty s.
Admitted.

Lemma max_elt_spec1 s x : max_elt s = Some x -> InT x s.
Admitted.

Lemma max_elt_spec2 s x y `{Ok s} :
 max_elt s = Some x -> InT y s -> ~ X.lt x y.
Admitted.

Lemma max_elt_spec3 s : max_elt s = None -> Empty s.
Admitted.

Lemma choose_spec1 : forall s x, choose s = Some x -> InT x s.
Admitted.

Lemma choose_spec2 : forall s, choose s = None -> Empty s.
Admitted.

Lemma choose_spec3 : forall s s' x x' `{Ok s, Ok s'},
  choose s = Some x -> choose s' = Some x' ->
  Equal s s' -> X.eq x x'.
Admitted.

Lemma elements_spec1 : forall s x, InA X.eq x (elements s) <-> InT x s.
Admitted.

Lemma elements_spec2 : forall s `(Ok s), sort X.lt (elements s).
Admitted.

Lemma elements_spec2w : forall s `(Ok s), NoDupA X.eq (elements s).
Admitted.

Lemma elements_cardinal : forall s : tree, cardinal s = length (elements s).
Admitted.

Definition cardinal_spec (s:tree)(Hs:Ok s) := elements_cardinal s.

Lemma for_all_spec s f : Proper (X.eq==>eq) f ->
 (for_all f s = true <-> For_all (fun x => f x = true) s).
Admitted.

Lemma exists_spec s f : Proper (X.eq==>eq) f ->
 (exists_ f s = true <-> Exists (fun x => f x = true) s).
Admitted.

Lemma fold_spec (s:tree) {A} (i : A) (f : elt -> A -> A) :
 fold f s i = fold_left (flip f) (elements s) i.
Admitted.

Lemma subset_spec : forall s1 s2 `{Ok s1, Ok s2},
 (subset s1 s2 = true <-> Subset s1 s2).
Admitted.

Definition eq := Equal.
#[global]
Instance eq_equiv : Equivalence eq.
Admitted.
Definition lt (s1 s2 : tree) : Prop.
Admitted.

#[global]
Instance lt_strorder : StrictOrder lt.
Admitted.

#[global]
Instance lt_compat : Proper (eq==>eq==>iff) lt.
Admitted.

Lemma compare_spec : forall s1 s2 `{Ok s1, Ok s2},
 CompSpec eq lt s1 s2 (compare s1 s2).
Admitted.

Lemma equal_spec : forall s1 s2 `{Ok s1, Ok s2},
 equal s1 s2 = true <-> eq s1 s2.
Admitted.

End Props.
Module Export MSetAVL.
Import Stdlib.MSets.MSetInterface.
Import Stdlib.ZArith.Int.

Module Ops (Import I:Int)(X:OrderedType) <: MSetInterface.Ops X.
#[local] Abbreviation int := I.t.

Include MSetGenTree.Ops X I.

Definition t := tree.
Definition height (s : t) : int.
Admitted.

Definition singleton x := Node 1 Leaf x Leaf.

Definition create l x r :=
   Node (max (height l) (height r) + 1) l x r.

Definition assert_false := create.

Definition bal l x r :=
  let hl := height l in
  let hr := height r in
  if (hr+2) <? hl then
    match l with
     | Leaf => assert_false l x r
     | Node _ ll lx lr =>
       if (height lr) <=? (height ll) then
         create ll lx (create lr x r)
       else
         match lr with
          | Leaf => assert_false l x r
          | Node _ lrl lrx lrr =>
              create (create ll lx lrl) lrx (create lrr x r)
         end
    end
  else
    if (hl+2) <? hr then
      match r with
       | Leaf => assert_false l x r
       | Node _ rl rx rr =>
         if (height rl) <=? (height rr) then
            create (create l x rl) rx rr
         else
           match rl with
            | Leaf => assert_false l x r
            | Node _ rll rlx rlr =>
                create (create l x rll) rlx (create rlr rx rr)
           end
      end
    else
      create l x r.

Fixpoint add x s := match s with
   | Leaf => Node 1 Leaf x Leaf
   | Node h l y r =>
      match X.compare x y with
         | Lt => bal (add x l) y r
         | Eq => Node h l y r
         | Gt => bal l y (add x r)
      end
  end.

Fixpoint join l : elt -> t -> t :=
  match l with
    | Leaf => add
    | Node lh ll lx lr => fun x =>
       fix join_aux (r:t) : t := match r with
          | Leaf => add x l
          | Node rh rl rx rr =>
               if (rh+2) <? lh then bal ll lx (join lr x r)
               else if (lh+2) <? rh then bal (join_aux rl) rx rr
               else create l x r
          end
  end.

Fixpoint remove_min l x r : t*elt :=
  match l with
    | Leaf => (r,x)
    | Node lh ll lx lr =>
       let (l',m) := remove_min ll lx lr in (bal l' x r, m)
  end.

Definition merge s1 s2 :=  match s1,s2 with
  | Leaf, _ => s2
  | _, Leaf => s1
  | _, Node _ l2 x2 r2 =>
        let (s2',m) := remove_min l2 x2 r2 in bal s1 m s2'
end.

Fixpoint remove x s := match s with
  | Leaf => Leaf
  | Node _ l y r =>
      match X.compare x y with
         | Lt => bal (remove x l) y r
         | Eq => merge l r
         | Gt => bal l y (remove x r)
      end
   end.

Definition concat s1 s2 :=
   match s1, s2 with
      | Leaf, _ => s2
      | _, Leaf => s1
      | _, Node _ l2 x2 r2 =>
            let (s2',m) := remove_min l2 x2 r2 in
            join s1 m s2'
   end.

Record triple := mktriple { t_left:t; t_in:bool; t_right:t }.
Notation "<< l , b , r >>" := (mktriple l b r) (at level 0).

Fixpoint split x s : triple := match s with
  | Leaf => << Leaf, false, Leaf >>
  | Node _ l y r =>
     match X.compare x y with
      | Lt => let (ll,b,rl) := split x l in << ll, b, join rl y r >>
      | Eq => << l, true, r >>
      | Gt => let (rl,b,rr) := split x r in << join l y rl, b, rr >>
     end
 end.

Fixpoint inter s1 s2 := match s1, s2 with
    | Leaf, _ => Leaf
    | _, Leaf => Leaf
    | Node _ l1 x1 r1, _ =>
            let (l2',pres,r2') := split x1 s2 in
            if pres then join (inter l1 l2') x1 (inter r1 r2')
            else concat (inter l1 l2') (inter r1 r2')
    end.

Fixpoint diff s1 s2 := match s1, s2 with
 | Leaf, _ => Leaf
 | _, Leaf => s1
 | Node _ l1 x1 r1, _ =>
    let (l2',pres,r2') := split x1 s2 in
    if pres then concat (diff l1 l2') (diff r1 r2')
    else join (diff l1 l2') x1 (diff r1 r2')
end.

Fixpoint union s1 s2 :=
 match s1, s2 with
  | Leaf, _ => s2
  | _, Leaf => s1
  | Node _ l1 x1 r1, _ =>
     let (l2',_,r2') := split x1 s2 in
     join (union l1 l2') x1 (union r1 r2')
 end.

Fixpoint filter (f:elt->bool) s := match s with
  | Leaf => Leaf
  | Node _ l x r =>
    let l' := filter f l in
    let r' := filter f r in
    if f x then join l' x r' else concat l' r'
 end.
Fixpoint partition (f:elt->bool)(s : t) : t*t.
Admitted.

End Ops.

Module MakeRaw (Import I:Int)(X:OrderedType) <: RawSets X.
Include Ops I X.

Include MSetGenTree.Props X I.

Notation "s #1" := (fst s) (at level 1, format "s '#1'") : pair_scope.
Notation "s #2" := (snd s) (at level 1, format "s '#2'") : pair_scope.

#[local] Open Scope pair_scope.

Lemma singleton_spec : forall x y, InT y (singleton x) <-> X.eq y x.
Admitted.

#[global]
Instance singleton_ok x : Ok (singleton x).
Admitted.

Lemma add_spec : forall s x y `{Ok s},
 InT y (add x s) <-> X.eq y x \/ InT y s.
Admitted.

#[global]
Instance add_ok s x `(Ok s) : Ok (add x s).
Admitted.

Lemma remove_spec : forall s x y `{Ok s},
 (InT y (remove x s) <-> InT y s /\ ~ X.eq y x).
Admitted.

#[global]
Instance remove_ok s x `(Ok s) : Ok (remove x s).
Admitted.

Lemma inter_spec : forall s1 s2 y `{Ok s1, Ok s2},
 (InT y (inter s1 s2) <-> InT y s1 /\ InT y s2).
Admitted.

#[global]
Instance inter_ok s1 s2 `(Ok s1, Ok s2) : Ok (inter s1 s2).
Admitted.

Lemma diff_spec : forall s1 s2 y `{Ok s1, Ok s2},
 (InT y (diff s1 s2) <-> InT y s1 /\ ~InT y s2).
Admitted.

#[global]
Instance diff_ok s1 s2 `(Ok s1, Ok s2) : Ok (diff s1 s2).
Admitted.

Lemma union_spec : forall s1 s2 y `{Ok s1, Ok s2},
 (InT y (union s1 s2) <-> InT y s1 \/ InT y s2).
Admitted.

#[global]
Instance union_ok s1 s2 : forall `(Ok s1, Ok s2), Ok (union s1 s2).
Admitted.

Lemma filter_spec : forall s x f,
 Proper (X.eq==>Logic.eq) f ->
 (InT x (filter f s) <-> InT x s /\ f x = true).
Admitted.

#[global]
Instance filter_ok s f `(H : Ok s) : Ok (filter f s).
Admitted.

Lemma partition_spec1 s f :
 Proper (X.eq==>Logic.eq) f ->
 Equal (partition f s)#1 (filter f s).
Admitted.

Lemma partition_spec2 s f :
 Proper (X.eq==>Logic.eq) f ->
 Equal (partition f s)#2 (filter (fun x => negb (f x)) s).
Admitted.

#[global]
Instance partition_ok1 s f `(Ok s) : Ok (partition f s)#1.
Admitted.

#[global]
Instance partition_ok2 s f `(Ok s) : Ok (partition f s)#2.
Admitted.

End MakeRaw.

Module IntMake (I:Int)(X: OrderedType) <: S with Module E := X.
 Module Raw := MakeRaw I X.
 Include Raw2Sets X Raw.
End IntMake.
Module Export OrderedTypeEx.

Import Stdlib.Structures.OrderedType.
Import Stdlib.Arith.Peano_dec.

Module Type UsualOrderedType.
End UsualOrderedType.

Module Nat_as_OT <: UsualOrderedType.

  Definition t := nat.

  Definition eq := @eq nat.
  Definition eq_refl := @eq_refl t.
  Definition eq_sym := @eq_sym t.
  Definition eq_trans := @eq_trans t.

  Definition lt := lt.

  Lemma lt_trans : forall x y z : t, lt x y -> lt y z -> lt x z.
Admitted.

  Lemma lt_not_eq : forall x y : t, lt x y -> ~ eq x y.
Admitted.

  Definition compare x y : Compare lt eq x y.
Admitted.

  Definition eq_dec := eq_nat_dec.

End Nat_as_OT.
Export Stdlib.FSets.FSetInterface.

Module WFacts_fun (Import E : DecidableType)(Import M : WSfun E).

Section IffSpec.

End IffSpec.

Section BoolSpec.

End BoolSpec.

End WFacts_fun.
Module Export FSetCompat.
Set Implicit Arguments.

Module Backport_WSets
 (E:DecidableType.DecidableType)
 (M:MSetInterface.WSets with Definition E.t := E.t
                        with Definition E.eq := E.eq)
 <: FSetInterface.WSfun E.

 Definition elt := E.t.
 Definition t := M.t.
Definition In : elt -> t -> Prop.
exact (M.In).
Defined.
 Definition Equal s s' := forall a : elt, In a s <-> In a s'.
 Definition Subset s s' := forall a : elt, In a s -> In a s'.
 Definition Empty s := forall a : elt, ~ In a s.
 Definition For_all (P : elt -> Prop) s := forall x, In x s -> P x.
 Definition Exists (P : elt -> Prop) s := exists x, In x s /\ P x.
Definition empty : t.
Admitted.
Definition is_empty : t -> bool.
Admitted.
Definition mem : elt -> t -> bool.
Admitted.
Definition add : elt -> t -> t.
Admitted.
Definition singleton : elt -> t.
Admitted.
Definition remove : elt -> t -> t.
Admitted.
Definition union : t -> t -> t.
Admitted.
Definition inter : t -> t -> t.
Admitted.
Definition diff : t -> t -> t.
Admitted.
Definition eq : t -> t -> Prop.
exact (M.eq).
Defined.
Definition eq_dec : forall s s', {eq s s'}+{~eq s s'}.
Admi

[...]

x "+" := Z.add : Z_scope.
Notation "- x" := (Z.opp x) : Z_scope.
Infix "-" := Z.sub : Z_scope.
Infix "*" := Z.mul : Z_scope.
Module Export BinInt.
End BinInt.
Declare Scope Int_scope.
#[local] Open Scope Int_scope.

Module Type Int.

  Parameter t : Set.
  Parameter _1 : t.
  Parameter _2 : t.
  Parameter add : t -> t -> t.
  Parameter max : t -> t -> t.
  Notation "1" := _1 : Int_scope.
  Notation "2" := _2 : Int_scope.
  Infix "+" := add : Int_scope.
  Axiom ltb : t -> t -> bool.
  Axiom leb : t -> t -> bool.
  Infix "<?" := ltb.
  Infix "<=?" := leb.

End Int.

Module MoreInt (Import I:Int).

End MoreInt.

Module Z_as_Int <: Int.
  #[local] Open Scope Z_scope.
  Definition t := Z.
  Definition _0 := 0.
  Definition _1 := 1.
  Definition _2 := 2.
  Definition _3 := 3.
  Definition add := Z.add.
  Definition max := Z.max.
  Definition eqb := Z.eqb.
  Definition ltb := Z.ltb.
  Definition leb := Z.leb.
Definition i2z : t -> Z.
Admitted.
  Lemma i2z_eq n p : i2z n = i2z p -> n = p.
Admitted.
  Lemma i2z_0 : i2z _0 = 0.
Admitted.
  Lemma i2z_1 : i2z _1 = 1.
Admitted.
  Lemma i2z_2 : i2z _2 = 2.
Admitted.
  Lemma i2z_3 : i2z _3 = 3.
Admitted.
  Lemma i2z_add n p : i2z (n + p) = i2z n + i2z p.
Admitted.
  Lemma i2z_opp n : i2z (- n) = - i2z n.
Admitted.
  Lemma i2z_sub n p : i2z (n - p) = i2z n - i2z p.
Admitted.
  Lemma i2z_mul n p : i2z (n * p) = i2z n * i2z p.
Admitted.
  Lemma i2z_max n p : i2z (max n p) = Z.max (i2z n) (i2z p).
Admitted.
  Lemma i2z_eqb n p : eqb n p = Z.eqb (i2z n) (i2z p).
Admitted.
  Lemma i2z_leb n p : leb n p = Z.leb (i2z n) (i2z p).
Admitted.
  Lemma i2z_ltb n p : ltb n p = Z.ltb (i2z n) (i2z p).
Admitted.
End Z_as_Int.
Module Export Stdlib.
Module Export ZArith.
Module Export Int.
End Int.
Module Export MSetGenTree.
Import Stdlib.MSets.MSetInterface.
#[local] Open Scope lazy_bool_scope.

Module Type InfoTyp.
 Parameter t : Set.
End InfoTyp.

Module Ops (X:OrderedType)(Info:InfoTyp).

Definition elt := X.t.

Inductive tree  : Type :=
| Leaf : tree
| Node : Info.t -> tree -> X.t -> tree -> tree.

Definition empty := Leaf.

Definition is_empty t :=
 match t with
 | Leaf => true
 | _ => false
 end.

Fixpoint mem x t :=
 match t with
 | Leaf => false
 | Node _ l k r =>
   match X.compare x k with
     | Lt => mem x l
     | Eq => true
     | Gt => mem x r
   end
 end.
Fixpoint min_elt (t : tree) : option elt.
Admitted.
Fixpoint max_elt (t : tree) : option elt.
Admitted.

Definition choose := min_elt.

Fixpoint fold {A: Type} (f: elt -> A -> A) (t: tree) (base: A) : A :=
  match t with
  | Leaf => base
  | Node _ l x r => fold f r (f x (fold f l base))
 end.

Fixpoint elements_aux acc s :=
  match s with
   | Leaf => acc
   | Node _ l x r => elements_aux (x :: elements_aux acc r) l
  end.

Definition elements := elements_aux nil.
Fixpoint cardinal (s : tree) : nat.
Admitted.

Fixpoint for_all (f:elt->bool) s := match s with
  | Leaf => true
  | Node _ l x r => f x &&& for_all f l &&& for_all f r
end.

Fixpoint exists_ (f:elt->bool) s := match s with
  | Leaf => false
  | Node _ l x r => f x ||| exists_ f l ||| exists_ f r
end.

Inductive enumeration :=
 | End : enumeration
 | More : elt -> tree -> enumeration -> enumeration.

Fixpoint cons s e : enumeration :=
 match s with
  | Leaf => e
  | Node _ l x r => cons l (More x r e)
 end.

Definition compare_more x1 (cont:enumeration->comparison) e2 :=
 match e2 with
 | End => Gt
 | More x2 r2 e2 =>
     match X.compare x1 x2 with
      | Eq => cont (cons r2 e2)
      | Lt => Lt
      | Gt => Gt
     end
 end.

Fixpoint compare_cont s1 (cont:enumeration->comparison) e2 :=
 match s1 with
  | Leaf => cont e2
  | Node _ l1 x1 r1 =>
     compare_cont l1 (compare_more x1 (compare_cont r1 cont)) e2
  end.

Definition compare_end e2 :=
 match e2 with End => Eq | _ => Lt end.

Definition compare s1 s2 := compare_cont s1 compare_end (cons s2 End).

Definition equal s1 s2 :=
 match compare s1 s2 with Eq => true | _ => false end.

Fixpoint subsetl (subset_l1 : tree -> bool) x1 s2 : bool :=
 match s2 with
  | Leaf => false
  | Node _ l2 x2 r2 =>
     match X.compare x1 x2 with
      | Eq => subset_l1 l2
      | Lt => subsetl subset_l1 x1 l2
      | Gt => mem x1 r2 &&& subset_l1 s2
     end
 end.

Fixpoint subsetr (subset_r1 : tree -> bool) x1 s2 : bool :=
 match s2 with
  | Leaf => false
  | Node _ l2 x2 r2 =>
     match X.compare x1 x2 with
      | Eq => subset_r1 r2
      | Lt => mem x1 l2 &&& subset_r1 s2
      | Gt => subsetr subset_r1 x1 r2
     end
 end.

Fixpoint subset s1 s2 : bool := match s1, s2 with
  | Leaf, _ => true
  | Node _ _ _ _, Leaf => false
  | Node _ l1 x1 r1, Node _ l2 x2 r2 =>
     match X.compare x1 x2 with
      | Eq => subset l1 l2 &&& subset r1 r2
      | Lt => subsetl (subset l1) x1 l2 &&& subset r1 s2
      | Gt => subsetr (subset r1) x1 r2 &&& subset l1 s2
     end
 end.

End Ops.

Module Type OpsT (X:OrderedType)(Info:InfoTyp).
Include Ops X Info.
End OpsT.

Module Props (X:OrderedType)(Info:InfoTyp)(Import M:OpsT X Info).

Inductive InT (x : elt) : tree -> Prop :=
  | IsRoot : forall c l r y, X.eq x y -> InT x (Node c l y r)
  | InLeft : forall c l r y, InT x l -> InT x (Node c l y r)
  | InRight : forall c l r y, InT x r -> InT x (Node c l y r).

Definition In := InT.

Definition Equal s s' := forall a : elt, InT a s <-> InT a s'.
Definition Subset s s' := forall a : elt, InT a s -> InT a s'.
Definition Empty s := forall a : elt, ~ InT a s.
Definition For_all (P : elt -> Prop) s := forall x, InT x s -> P x.
Definition Exists (P : elt -> Prop) s := exists x, InT x s /\ P x.

Definition lt_tree x s := forall y, InT y s -> X.lt y x.
Definition gt_tree x s := forall y, InT y s -> X.lt x y.

Inductive bst : tree -> Prop :=
  | BSLeaf : bst Leaf
  | BSNode : forall c x l r, bst l -> bst r ->
     lt_tree x l -> gt_tree x r -> bst (Node c l x r).

Definition IsOk := bst.

Class Ok (s:tree) : Prop := ok : bst s.

Fixpoint ltb_tree x s :=
 match s with
  | Leaf => true
  | Node _ l y r =>
     match X.compare x y with
      | Gt => ltb_tree x l && ltb_tree x r
      | _ => false
     end
 end.

Fixpoint gtb_tree x s :=
 match s with
  | Leaf => true
  | Node _ l y r =>
     match X.compare x y with
      | Lt => gtb_tree x l && gtb_tree x r
      | _ => false
     end
 end.

Fixpoint isok s :=
 match s with
  | Leaf => true
  | Node _  l x r => isok l && isok r && ltb_tree x l && gtb_tree x r
 end.

#[global]
Instance isok_Ok s : isok s = true -> Ok s | 10.
Admitted.

#[global]
Instance In_compat : Proper (X.eq==>eq==>iff) InT.
Admitted.

Lemma empty_spec : Empty empty.
Admitted.

#[global]
Instance empty_ok : Ok empty.
Admitted.

Lemma is_empty_spec : forall s, is_empty s = true <-> Empty s.
Admitted.

Lemma mem_spec : forall s x `{Ok s}, mem x s = true <-> InT x s.
Admitted.

Lemma min_elt_spec1 s x : min_elt s = Some x -> InT x s.
Admitted.

Lemma min_elt_spec2 s x y `{Ok s} :
 min_elt s = Some x -> InT y s -> ~ X.lt y x.
Admitted.

Lemma min_elt_spec3 s : min_elt s = None -> Empty s.
Admitted.

Lemma max_elt_spec1 s x : max_elt s = Some x -> InT x s.
Admitted.

Lemma max_elt_spec2 s x y `{Ok s} :
 max_elt s = Some x -> InT y s -> ~ X.lt x y.
Admitted.

Lemma max_elt_spec3 s : max_elt s = None -> Empty s.
Admitted.

Lemma choose_spec1 : forall s x, choose s = Some x -> InT x s.
Admitted.

Lemma choose_spec2 : forall s, choose s = None -> Empty s.
Admitted.

Lemma choose_spec3 : forall s s' x x' `{Ok s, Ok s'},
  choose s = Some x -> choose s' = Some x' ->
  Equal s s' -> X.eq x x'.
Admitted.

Lemma elements_spec1 : forall s x, InA X.eq x (elements s) <-> InT x s.
Admitted.

Lemma elements_spec2 : forall s `(Ok s), sort X.lt (elements s).
Admitted.

Lemma elements_spec2w : forall s `(Ok s), NoDupA X.eq (elements s).
Admitted.

Lemma elements_cardinal : forall s : tree, cardinal s = length (elements s).
Admitted.

Definition cardinal_spec (s:tree)(Hs:Ok s) := elements_cardinal s.

Lemma for_all_spec s f : Proper (X.eq==>eq) f ->
 (for_all f s = true <-> For_all (fun x => f x = true) s).
Admitted.

Lemma exists_spec s f : Proper (X.eq==>eq) f ->
 (exists_ f s = true <-> Exists (fun x => f x = true) s).
Admitted.

Lemma fold_spec (s:tree) {A} (i : A) (f : elt -> A -> A) :
 fold f s i = fold_left (flip f) (elements s) i.
Admitted.

Lemma subset_spec : forall s1 s2 `{Ok s1, Ok s2},
 (subset s1 s2 = true <-> Subset s1 s2).
Admitted.

Definition eq := Equal.
#[global]
Instance eq_equiv : Equivalence eq.
Admitted.
Definition lt (s1 s2 : tree) : Prop.
Admitted.

#[global]
Instance lt_strorder : StrictOrder lt.
Admitted.

#[global]
Instance lt_compat : Proper (eq==>eq==>iff) lt.
Admitted.

Lemma compare_spec : forall s1 s2 `{Ok s1, Ok s2},
 CompSpec eq lt s1 s2 (compare s1 s2).
Admitted.

Lemma equal_spec : forall s1 s2 `{Ok s1, Ok s2},
 equal s1 s2 = true <-> eq s1 s2.
Admitted.

End Props.
Module Export MSetAVL.
Import Stdlib.MSets.MSetInterface.
Import Stdlib.ZArith.Int.

Module Ops (Import I:Int)(X:OrderedType) <: MSetInterface.Ops X.
#[local] Abbreviation int := I.t.

Include MSetGenTree.Ops X I.

Definition t := tree.
Definition height (s : t) : int.
Admitted.

Definition singleton x := Node 1 Leaf x Leaf.

Definition create l x r :=
   Node (max (height l) (height r) + 1) l x r.

Definition assert_false := create.

Definition bal l x r :=
  let hl := height l in
  let hr := height r in
  if (hr+2) <? hl then
    match l with
     | Leaf => assert_false l x r
     | Node _ ll lx lr =>
       if (height lr) <=? (height ll) then
         create ll lx (create lr x r)
       else
         match lr with
          | Leaf => assert_false l x r
          | Node _ lrl lrx lrr =>
              create (create ll lx lrl) lrx (create lrr x r)
         end
    end
  else
    if (hl+2) <? hr then
      match r with
       | Leaf => assert_false l x r
       | Node _ rl rx rr =>
         if (height rl) <=? (height rr) then
            create (create l x rl) rx rr
         else
           match rl with
            | Leaf => assert_false l x r
            | Node _ rll rlx rlr =>
                create (create l x rll) rlx (create rlr rx rr)
           end
      end
    else
      create l x r.

Fixpoint add x s := match s with
   | Leaf => Node 1 Leaf x Leaf
   | Node h l y r =>
      match X.compare x y with
         | Lt => bal (add x l) y r
         | Eq => Node h l y r
         | Gt => bal l y (add x r)
      end
  end.

Fixpoint join l : elt -> t -> t :=
  match l with
    | Leaf => add
    | Node lh ll lx lr => fun x =>
       fix join_aux (r:t) : t := match r with
          | Leaf => add x l
          | Node rh rl rx rr =>
               if (rh+2) <? lh then bal ll lx (join lr x r)
               else if (lh+2) <? rh then bal (join_aux rl) rx rr
               else create l x r
          end
  end.

Fixpoint remove_min l x r : t*elt :=
  match l with
    | Leaf => (r,x)
    | Node lh ll lx lr =>
       let (l',m) := remove_min ll lx lr in (bal l' x r, m)
  end.

Definition merge s1 s2 :=  match s1,s2 with
  | Leaf, _ => s2
  | _, Leaf => s1
  | _, Node _ l2 x2 r2 =>
        let (s2',m) := remove_min l2 x2 r2 in bal s1 m s2'
end.

Fixpoint remove x s := match s with
  | Leaf => Leaf
  | Node _ l y r =>
      match X.compare x y with
         | Lt => bal (remove x l) y r
         | Eq => merge l r
         | Gt => bal l y (remove x r)
      end
   end.

Definition concat s1 s2 :=
   match s1, s2 with
      | Leaf, _ => s2
      | _, Leaf => s1
      | _, Node _ l2 x2 r2 =>
            let (s2',m) := remove_min l2 x2 r2 in
            join s1 m s2'
   end.

Record triple := mktriple { t_left:t; t_in:bool; t_right:t }.
Notation "<< l , b , r >>" := (mktriple l b r) (at level 0).

Fixpoint split x s : triple := match s with
  | Leaf => << Leaf, false, Leaf >>
  | Node _ l y r =>
     match X.compare x y with
      | Lt => let (ll,b,rl) := split x l in << ll, b, join rl y r >>
      | Eq => << l, true, r >>
      | Gt => let (rl,b,rr) := split x r in << join l y rl, b, rr >>
     end
 end.

Fixpoint inter s1 s2 := match s1, s2 with
    | Leaf, _ => Leaf
    | _, Leaf => Leaf
    | Node _ l1 x1 r1, _ =>
            let (l2',pres,r2') := split x1 s2 in
            if pres then join (inter l1 l2') x1 (inter r1 r2')
            else concat (inter l1 l2') (inter r1 r2')
    end.

Fixpoint diff s1 s2 := match s1, s2 with
 | Leaf, _ => Leaf
 | _, Leaf => s1
 | Node _ l1 x1 r1, _ =>
    let (l2',pres,r2') := split x1 s2 in
    if pres then concat (diff l1 l2') (diff r1 r2')
    else join (diff l1 l2') x1 (diff r1 r2')
end.

Fixpoint union s1 s2 :=
 match s1, s2 with
  | Leaf, _ => s2
  | _, Leaf => s1
  | Node _ l1 x1 r1, _ =>
     let (l2',_,r2') := split x1 s2 in
     join (union l1 l2') x1 (union r1 r2')
 end.

Fixpoint filter (f:elt->bool) s := match s with
  | Leaf => Leaf
  | Node _ l x r =>
    let l' := filter f l in
    let r' := filter f r in
    if f x then join l' x r' else concat l' r'
 end.
Fixpoint partition (f:elt->bool)(s : t) : t*t.
Admitted.

End Ops.

Module MakeRaw (Import I:Int)(X:OrderedType) <: RawSets X.
Include Ops I X.

Include MSetGenTree.Props X I.

Notation "s #1" := (fst s) (at level 1, format "s '#1'") : pair_scope.
Notation "s #2" := (snd s) (at level 1, format "s '#2'") : pair_scope.

#[local] Open Scope pair_scope.

Lemma singleton_spec : forall x y, InT y (singleton x) <-> X.eq y x.
Admitted.

#[global]
Instance singleton_ok x : Ok (singleton x).
Admitted.

Lemma add_spec : forall s x y `{Ok s},
 InT y (add x s) <-> X.eq y x \/ InT y s.
Admitted.

#[global]
Instance add_ok s x `(Ok s) : Ok (add x s).
Admitted.

Lemma remove_spec : forall s x y `{Ok s},
 (InT y (remove x s) <-> InT y s /\ ~ X.eq y x).
Admitted.

#[global]
Instance remove_ok s x `(Ok s) : Ok (remove x s).
Admitted.

Lemma inter_spec : forall s1 s2 y `{Ok s1, Ok s2},
 (InT y (inter s1 s2) <-> InT y s1 /\ InT y s2).
Admitted.

#[global]
Instance inter_ok s1 s2 `(Ok s1, Ok s2) : Ok (inter s1 s2).
Admitted.

Lemma diff_spec : forall s1 s2 y `{Ok s1, Ok s2},
 (InT y (diff s1 s2) <-> InT y s1 /\ ~InT y s2).
Admitted.

#[global]
Instance diff_ok s1 s2 `(Ok s1, Ok s2) : Ok (diff s1 s2).
Admitted.

Lemma union_spec : forall s1 s2 y `{Ok s1, Ok s2},
 (InT y (union s1 s2) <-> InT y s1 \/ InT y s2).
Admitted.

#[global]
Instance union_ok s1 s2 : forall `(Ok s1, Ok s2), Ok (union s1 s2).
Admitted.

Lemma filter_spec : forall s x f,
 Proper (X.eq==>Logic.eq) f ->
 (InT x (filter f s) <-> InT x s /\ f x = true).
Admitted.

#[global]
Instance filter_ok s f `(H : Ok s) : Ok (filter f s).
Admitted.

Lemma partition_spec1 s f :
 Proper (X.eq==>Logic.eq) f ->
 Equal (partition f s)#1 (filter f s).
Admitted.

Lemma partition_spec2 s f :
 Proper (X.eq==>Logic.eq) f ->
 Equal (partition f s)#2 (filter (fun x => negb (f x)) s).
Admitted.

#[global]
Instance partition_ok1 s f `(Ok s) : Ok (partition f s)#1.
Admitted.

#[global]
Instance partition_ok2 s f `(Ok s) : Ok (partition f s)#2.
Admitted.

End MakeRaw.

Module IntMake (I:Int)(X: OrderedType) <: S with Module E := X.
 Module Raw := MakeRaw I X.
 Include Raw2Sets X Raw.
End IntMake.
Module Export OrderedTypeEx.

Import Stdlib.Structures.OrderedType.
Import Stdlib.Arith.Peano_dec.

Module Type UsualOrderedType.
End UsualOrderedType.

Module Nat_as_OT <: UsualOrderedType.

  Definition t := nat.

  Definition eq := @eq nat.
  Definition eq_refl := @eq_refl t.
  Definition eq_sym := @eq_sym t.
  Definition eq_trans := @eq_trans t.

  Definition lt := lt.

  Lemma lt_trans : forall x y z : t, lt x y -> lt y z -> lt x z.
Admitted.

  Lemma lt_not_eq : forall x y : t, lt x y -> ~ eq x y.
Admitted.

  Definition compare x y : Compare lt eq x y.
Admitted.

  Definition eq_dec := eq_nat_dec.

End Nat_as_OT.
Export Stdlib.FSets.FSetInterface.

Module WFacts_fun (Import E : DecidableType)(Import M : WSfun E).

Section IffSpec.

End IffSpec.

Section BoolSpec.

End BoolSpec.

End WFacts_fun.
Module Export FSetCompat.
Set Implicit Arguments.

Module Backport_WSets
 (E:DecidableType.DecidableType)
 (M:MSetInterface.WSets with Definition E.t := E.t
                        with Definition E.eq := E.eq)
 <: FSetInterface.WSfun E.

 Definition elt := E.t.
 Definition t := M.t.
Definition In : elt -> t -> Prop.
exact (M.In).
Defined.
 Definition Equal s s' := forall a : elt, In a s <-> In a s'.
 Definition Subset s s' := forall a : elt, In a s -> In a s'.
 Definition Empty s := forall a : elt, ~ In a s.
 Definition For_all (P : elt -> Prop) s := forall x, In x s -> P x.
 Definition Exists (P : elt -> Prop) s := exists x, In x s /\ P x.
Definition empty : t.
Admitted.
Definition is_empty : t -> bool.
Admitted.
Definition mem : elt -> t -> bool.
Admitted.
Definition add : elt -> t -> t.
Admitted.
Definition singleton : elt -> t.
Admitted.
Definition remove : elt -> t -> t.
Admitted.
Definition union : t -> t -> t.
Admitted.
Definition inter : t -> t -> t.
Admitted.
Definition diff : t -> t -> t.
Admitted.
Definition eq : t -> t -> Prop.
exact (M.eq).
Defined.
Definition eq_dec : forall s s', {eq s s'}+{~eq s s'}.
Admitted.
Definition equal : t -> t -> bool.
Admitted.
Definition subset : t -> t -> bool.
Admitted.
Definition fold : forall A : Type, (elt -> A -> A) -> t -> A -> A.
Admitted.
Definition for_all : (elt -> bool) -> t -> bool.
Admitted.
Definition exists_ : (elt -> bool) -> t -> bool.
Admitted.
Definition filter : (elt -> bool) -> t -> t.
Admitted.
Definition partition : (elt -> bool) -> t -> t * t.
Admitted.
Definition cardinal : t -> nat.
Admitted.
Definition elements : t -> list elt.
Admitted.
Definition choose : t -> option elt.
Admitted.
Definition In_1 : forall s x y, E.eq x y -> In x s -> In y s.
Admitted.
Definition eq_refl : forall s, eq s s.
Admitted.
Definition eq_sym : forall s s', eq s s' -> eq s' s.
Admitted.
Definition eq_trans : forall s s' s'', eq s s' -> eq s' s'' -> eq s s''.
Admitted.
Definition mem_1 : forall s x, In x s -> mem x s = true.
Admitted.
Definition mem_2 : forall s x, mem x s = true -> In x s.
Admitted.
Definition equal_1 : forall s s', Equal s s' -> equal s s' = true.
Admitted.
Definition equal_2 : forall s s', equal s s' = true -> Equal s s'.
Admitted.
Definition subset_1 : forall s s', Subset s s' -> subset s s' = true.
Admitted.
Definition subset_2 : forall s s', subset s s' = true -> Subset s s'.
Admitted.
Definition empty_1 : Empty empty.
Admitted.
Definition is_empty_1 : forall s, Empty s -> is_empty s = true.
Admitted.
Definition is_empty_2 : forall s, is_empty s = true -> Empty s.
Admitted.
Definition add_1 : forall s x y, E.eq x y -> In y (add x s).
Admitted.
Definition add_2 : forall s x y, In y s -> In y (add x s).
Admitted.
Definition add_3 : forall s x y, ~ E.eq x y -> In y (add x s) -> In y s.
Admitted.
Definition remove_1 : forall s x y, E.eq x y -> ~ In y (remove x s).
Admitted.
Definition remove_2 : forall s x y, ~ E.eq x y -> In y s -> In y (remove x s).
Admitted.
Definition remove_3 : forall s x y, In y (remove x s) -> In y s.
Admitted.
Definition union_1 : forall s s' x, In x (union s s') -> In x s \/ In x s'.
Admitted.
Definition union_2 : forall s s' x, In x s -> In x (union s s').
Admitted.
Definition union_3 : forall s s' x, In x s' -> In x (union s s').
Admitted.
Definition inter_1 : forall s s' x, In x (inter s s') -> In x s.
Admitted.
Definition inter_2 : forall s s' x, In x (inter s s') -> In x s'.
Admitted.
Definition inter_3 : forall s s' x, In x s -> In x s' -> In x (inter s s').
Admitted.
Definition diff_1 : forall s s' x, In x (diff s s') -> In x s.
Admitted.
Definition diff_2 : forall s s' x, In x (diff s s') -> ~ In x s'.
Admitted.
Definition diff_3 : forall s s' x, In x s -> ~ In x s' -> In x (diff s s').
Admitted.
Definition singleton_1 : forall x y, In y (singleton x) -> E.eq x y.
Admitted.
Definition singleton_2 : forall x y, E.eq x y -> In y (singleton x).
Admitted.
Definition fold_1 : forall s (A : Type) (i : A) (f : elt -> A -> A),
   fold f s i = fold_left (fun a e => f e a) (elements s) i.
Admitted.
Definition cardinal_1 : forall s, cardinal s = length (elements s).
Admitted.
Definition filter_1 : forall s x f, compat_bool E.eq f ->
  In x (filter f s) -> In x s.
Admitted.
Definition filter_2 : forall s x f, compat_bool E.eq f ->
  In x (filter f s) -> f x = true.
Admitted.
Definition filter_3 : forall s x f, compat_bool E.eq f ->
  In x s -> f x = true -> In x (filter f s).
Admitted.
Definition for_all_1 : forall s f, compat_bool E.eq f ->
  For_all (fun x => f x = true) s -> for_all f s = true.
Admitted.
Definition for_all_2 : forall s f, compat_bool E.eq f ->
  for_all f s = true -> For_all (fun x => f x = true) s.
Admitted.
Definition exists_1 : forall s f, compat_bool E.eq f ->
  Exists (fun x => f x = true) s -> exists_ f s = true.
Admitted.
Definition exists_2 : forall s f, compat_bool E.eq f ->
  exists_ f s = true -> Exists (fun x => f x = true) s.
Admitted.
Definition partition_1 : forall s f, compat_bool E.eq f ->
  Equal (fst (partition f s)) (filter f s).
Admitted.
Definition partition_2 : forall s f, compat_bool E.eq f ->
  Equal (snd (partition f s)) (filter (fun x => negb (f x)) s).
Admitted.
Definition choose_1 : forall s x, choose s = Some x -> In x s.
Admitted.
Definition choose_2 : forall s, choose s = None -> Empty s.
Admitted.
Definition elements_1 : forall s x, In x s -> InA E.eq x (elements s).
Admitted.
Definition elements_2 : forall s x, InA E.eq x (elements s) -> In x s.
Admitted.
Definition elements_3w : forall s, NoDupA E.eq (elements s).
Admitted.

End Backport_WSets.

Module Backport_Sets
 (O:OrderedType.OrderedType)
 (M:MSetInterface.Sets with Definition E.t := O.t
                       with Definition E.eq := O.eq
                       with Definition E.lt := O.lt)
 <: FSetInterface.S with Module E:=O.

  Include Backport_WSets O M.
Definition lt : t -> t -> Prop.
Admitted.
Definition min_elt : t -> option elt.
Admitted.
Definition max_elt : t -> option elt.
Admitted.
Definition min_elt_1 : forall s x, min_elt s = Some x -> In x s.
Admitted.
Definition min_elt_2 : forall s x y,
   min_elt s = Some x -> In y s -> ~ O.lt y x.
Admitted.
Definition min_elt_3 : forall s, min_elt s = None -> Empty s.
Admitted.
Definition max_elt_1 : forall s x, max_elt s = Some x -> In x s.
Admitted.
Definition max_elt_2 : forall s x y,
   max_elt s = Some x -> In y s -> ~ O.lt x y.
Admitted.
Definition max_elt_3 : forall s, max_elt s = None -> Empty s.
Admitted.
Definition elements_3 : forall s, sort O.lt (elements s).
Admitted.
Definition choose_3 : forall s s' x y,
   choose s = Some x -> choose s' = Some y -> Equal s s' -> O.eq x y.
Admitted.
Definition lt_trans : forall s s' s'', lt s s' -> lt s' s'' -> lt s s''.
Admitted.
  Lemma lt_not_eq : forall s s',  lt s s' -> ~ eq s s'.
Admitted.
  Definition compare : forall s s', Compare lt eq s s'.
Admitted.

  Module E := O.

End Backport_Sets.

Module Update_WSets
 (E:Equalities.DecidableType)
 (M:FSetInterface.WS with Definition E.t := E.t
                     with Definition E.eq := E.eq)
 <: MSetInterface.WSetsOn E.

 Definition elt := E.t.
 Definition t := M.t.
Definition In : elt -> t -> Prop.
exact (M.In).
Defined.
 Definition Equal s s' := forall a : elt, In a s <-> In a s'.
 Definition Subset s s' := forall a : elt, In a s -> In a s'.
 Definition Empty s := forall a : elt, ~ In a s.
 Definition For_all (P : elt -> Prop) s := forall x, In x s -> P x.
 Definition Exists (P : elt -> Prop) s := exists x, In x s /\ P x.
Definition empty : t.
admit.
Defined.
Definition is_empty : t -> bool.
Admitted.
Definition mem : elt -> t -> bool.
Admitted.
Definition add : elt -> t -> t.
Admitted.
Definition singleton : elt -> t.
Admitted.
Definition remove : elt -> t -> t.
Admitted.
Definition union : t -> t -> t.
admit.
Defined.
Definition inter : t -> t -> t.
admit.
Defined.
Definition diff : t -> t -> t.
admit.
Defined.
Definition eq : t -> t -> Prop.
exact (M.eq).
Defined.
Definition eq_dec : forall s s', {eq s s'}+{~eq s s'}.
Admitted.
Definition equal : t -> t -> bool.
Admitted.
Definition subset : t -> t -> bool.
Admitted.
Definition fold : forall A : Type, (elt -> A -> A) -> t -> A -> A.
admit.
Defined.
Definition for_all : (elt -> bool) -> t -> bool.
Admitted.
Definition exists_ : (elt -> bool) -> t -> bool.
Admitted.
Definition filter : (elt -> bool) -> t -> t.
admit.
Defined.
Definition partition : (elt -> bool) -> t -> t * t.
admit.
Defined.
Definition cardinal : t -> nat.
admit.
Defined.
Definition elements : t -> list elt.
admit.
Defined.
Definition choose : t -> option elt.
admit.
Defined.

#[global]
 Instance In_compat : Proper (E.eq==>Logic.eq==>iff) In.
Admitted.
#[global]
 Instance eq_equiv : Equivalence eq.
Admitted.

 Section Spec.
  Variable s s': t.
  Variable x y : elt.

  Lemma mem_spec : mem x s = true <-> In x s.
Proof using .
admit.
Defined.

  Lemma equal_spec : equal s s' = true <-> Equal s s'.
Proof using .
admit.
Defined.

  Lemma subset_spec : subset s s' = true <-> Subset s s'.
Proof using .
admit.
Defined.
Definition empty_spec : Empty empty.
admit.
Defined.

  Lemma is_empty_spec : is_empty s = true <-> Empty s.
Proof using .
admit.
Defined.

  Lemma add_spec : In y (add x s) <-> E.eq y x \/ In y s.
Proof using .
admit.
Defined.

  Lemma remove_spec : In y (remove x s) <-> In y s /\ ~E.eq y x.
Proof using .
admit.
Defined.

  Lemma singleton_spec : In y (singleton x) <-> E.eq y x.
Proof using .
admit.
Defined.
Definition union_spec : In x (union s s') <-> In x s \/ In x s'.
admit.
Defined.
Definition inter_spec : In x (inter s s') <-> In x s /\ In x s'.
admit.
Defined.
Definition diff_spec : In x (diff s s') <-> In x s /\ ~In x s'.
admit.
Defined.
Definition fold_spec : forall (A : Type) (i : A) (f : elt -> A -> A),
   fold f s i = fold_left (flip f) (elements s) i.
admit.
Defined.
Definition cardinal_spec : cardinal s = length (elements s).
admit.
Defined.

  Lemma elements_spec1 : InA E.eq x (elements s) <-> In x s.
Proof using .
admit.
Defined.
Definition elements_spec2w : NoDupA E.eq (elements s).
admit.
Defined.
Definition choose_spec1 : choose s = Some x -> In x s.
admit.
Defined.
Definition choose_spec2 : choose s = None -> Empty s.
admit.
Defined.
Definition filter_spec : forall f, Proper (E.eq==>Logic.eq) f ->
   (In x (filter f s) <-> In x s /\ f x = true).
admit.
Defined.
Definition partition_spec1 : forall f, Proper (E.eq==>Logic.eq) f ->
   Equal (fst (partition f s)) (filter f s).
admit.
Defined.
Definition partition_spec2 : forall f, Proper (E.eq==>Logic.eq) f ->
   Equal (snd (partition f s)) (filter (fun x => negb (f x)) s).
admit.
Defined.

  Lemma for_all_spec : forall f, Proper (E.eq==>Logic.eq) f ->
    (for_all f s = true <-> For_all (fun x => f x = true) s).
Proof using .
admit.
Defined.

  Lemma exists_spec : forall f, Proper (E.eq==>Logic.eq) f ->
    (exists_ f s = true <-> Exists (fun x => f x = true) s).
Proof using .
admit.
Defined.

  End Spec.

End Update_WSets.

Module Update_Sets
 (O:Orders.OrderedType)
 (M:FSetInterface.S with Definition E.t := O.t
                    with Definition E.eq := O.eq
                    with Definition E.lt := O.lt)
 <: MSetInterface.Sets with Module E:=O.

  Include Update_WSets O M.
Definition lt : t -> t -> Prop.
Admitted.
Definition min_elt : t -> option elt.
Admitted.
Definition max_elt : t -> option elt.
Admitted.
Definition min_elt_spec1 : forall s x, min_elt s = Some x -> In x s.
Admitted.
Definition min_elt_spec2 : forall s x y,
   min_elt s = Some x -> In y s -> ~ O.lt y x.
Admitted.
Definition min_elt_spec3 : forall s, min_elt s = None -> Empty s.
Admitted.
Definition max_elt_spec1 : forall s x, max_elt s = Some x -> In x s.
Admitted.
Definition max_elt_spec2 : forall s x y,
   max_elt s = Some x -> In y s -> ~ O.lt x y.
Admitted.
Definition max_elt_spec3 : forall s, max_elt s = None -> Empty s.
Admitted.
Definition elements_spec2 : forall s, sort O.lt (elements s).
Admitted.
Definition choose_spec3 : forall s s' x y,
   choose s = Some x -> choose s' = Some y -> Equal s s' -> O.eq x y.
Admitted.

#[global]
  Instance lt_strorder : StrictOrder lt.
Admitted.

#[global]
  Instance lt_compat : Proper (eq==>eq==>iff) lt.
Admitted.

  Definition compare s s' :=
   match M.compare s s' with
    | EQ _ => Eq
    | LT _ => Lt
    | GT _ => Gt
   end.

  Lemma compare_spec : forall s s', CompSpec eq lt s s' (compare s s').
Admitted.

  Module E := O.

End Update_Sets.
Module Export FSetAVL.
Import Stdlib.FSets.FSetInterface.
Import Stdlib.ZArith.Int.

Module IntMake (I:Int)(X: OrderedType) <: S with Module E := X.
 Module X' := OrdersAlt.Update_OT X.
 Module MSet := MSetAVL.IntMake I X'.
 Include FSetCompat.Backport_Sets X MSet.
End IntMake.

Module Make (X: OrderedType) <: S with Module E := X
 :=IntMake(Z_as_Int)(X).

End FSetAVL.
Module Export Stdlib_DOT_FSets_DOT_FSetAVL.
Module Export FSetAVL.
End FSetAVL.

End Stdlib_DOT_FSets_DOT_FSetAVL.
Module Export FSetUtil.

Module Make (Export XSet : FSetInterface.S).

End Make.

End FSetUtil.
Module Export CoLoR_DOT_Util_DOT_FSet_DOT_FSetUtil.
Module Export FSetUtil.
End FSetUtil.

End CoLoR_DOT_Util_DOT_FSet_DOT_FSetUtil.
Module Export FMapUtil.

Module Make (Export XMap : FMapInterface.S).

  Module Domain (XSet : FSetInterface.S with Module E := XMap.E).

    Module Export XSetUtil := FSetUtil.Make XSet.

  End Domain.

End Make.

End FMapUtil.
Module Export CoLoR_DOT_Util_DOT_FMap_DOT_FMapUtil.
Module Export FMapUtil.
End FMapUtil.

End CoLoR_DOT_Util_DOT_FMap_DOT_FMapUtil.
Export Stdlib.Structures.OrderedType.

Module Type Cmp.

  Parameter t : Type.

  Parameter cmp : t -> t -> comparison.

End Cmp.

Module Type CmpTransLeibniz.

  Include Cmp.

End CmpTransLeibniz.
Module Export CoLoR_DOT_Util_DOT_Relation_DOT_OrdUtil.
Module Export CoLoR.
Module Export Util.
Module Export Relation.
Module Export OrdUtil.
End OrdUtil.

End Relation.

End Util.

End CoLoR.

End CoLoR_DOT_Util_DOT_Relation_DOT_OrdUtil.
Module Export LTerm.

Module Type Var.

  Parameter X : Type.

  Declare Module Export XOrd : OrderedType
  with Definition t := X
  with Definition eq := @Logic.eq X.

  Declare Module Export XSet : FSetInterface.S with Module E := XOrd.

End Var.

Module NatVar <: Var.

  Definition X := nat.

  Module XOrd := OrderedTypeEx.Nat_as_OT.

  Module Export XSet := FSetAVL.Make XOrd.

End NatVar.

Module Type L_Struct.

  Declare Module Export V : Var.

End L_Struct.

Module Make (Export L : L_Struct).

End Make.

End LTerm.
Module Export CoLoR_DOT_Term_DOT_Lambda_DOT_LTerm.
Module Export LTerm.
End LTerm.

End CoLoR_DOT_Term_DOT_Lambda_DOT_LTerm.
Module Export LSubs.

Module Make (Export L : L_Struct).

End Make.

End LSubs.
Module Export CoLoR_DOT_Term_DOT_Lambda_DOT_LSubs.
Module Export LSubs.
End LSubs.

End CoLoR_DOT_Term_DOT_Lambda_DOT_LSubs.
Module Export LAlpha.

Module Make (Export L : L_Struct).

End Make.

End LAlpha.
Module Export CoLoR_DOT_Term_DOT_Lambda_DOT_LAlpha.
Module Export LAlpha.
End LAlpha.

End CoLoR_DOT_Term_DOT_Lambda_DOT_LAlpha.
Module Export LBeta.

Module Make (Export L : L_Struct).

End Make.

End LBeta.
Module Export CoLoR_DOT_Term_DOT_Lambda_DOT_LBeta.
Module Export LBeta.
End LBeta.

End CoLoR_DOT_Term_DOT_Lambda_DOT_LBeta.

Module Type CP_Struct.

  Declare Module Export L : L_Struct.

End CP_Struct.

Module Make (Export CP : CP_Struct).

End Make.
Module Export CoLoR.
Module Export Term.
Module Export Lambda.
Module Export LComp.
End LComp.
Module Export LSimple.

Set Implicit Arguments.
Import CoLoR.Util.Relation.OrdUtil.

Section simple.

  Variable So : Type.

  Inductive Ty : Type :=
  | Base : So -> Ty
  | Arr : Ty -> Ty -> Ty.

  End simple.

Module ST_Cmp (Export BCmp : Cmp) <: Cmp.

  Definition t := Ty BCmp.t.

  Fixpoint cmp A B :=
    match A, B with
      | Base a, Base b => BCmp.cmp a b
      | Base _, Arr _ _ => Lt
      | Arr _ _, Base _ => Gt
      | Arr A1 A2, Arr B1 B2 =>
          match cmp A1 B1 with
            | Eq => cmp A2 B2
            | c => c
          end
    end.

  Lemma cmp_opp : forall x y, cmp x y = CompOpp (cmp y x).
Admitted.

End ST_Cmp.

Module ST_CmpTransLeibniz (Export BCmpTransLeibniz : CmpTransLeibniz)
  <: CmpTransLeibniz.

  Module C := ST_Cmp BCmpTransLeibniz.

  Include C.

  Lemma cmp_eq : forall x y, cmp x y = Eq -> x = y.
Admitted.

  Lemma cmp_lt_trans :
    forall x y z, cmp x y = Lt -> cmp y z = Lt -> cmp x z = Lt.
Admitted.

End ST_CmpTransLeibniz.

Module Type ST_Struct.

  Declare Module Export L : L_Struct.

  Declare Module Export XMap : FMapInterface.S with Module E := XOrd.

End ST_Struct.

Module Make (Export ST : ST_Struct).

  Module XMapUtil := FMapUtil.Make XMap.
  Module Export Domain := XMapUtil.Domain XSet.

End Make.

End LSimple.
Export CoLoR.Term.Lambda.LComp.

Module Make (Export ST : ST_Struct)
  (Export CP : CP_Struct with Module L := ST.L).
  Module Export T := LSimple.Make ST.
🛠️ 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.9MiB file on GitHub Actions Artifacts under build.log)
PO/HorpoExNonTrans.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.3yxMqqzfi0
MINIMIZER_DEBUG: files:  HORPO/HorpoExNonTrans.v /github/workspace/builds/coq/coq-failing/_build_ci/color/HORPO/HorpoExNonTrans.v
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, 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 "./HORPO/HorpoExNonTrans.v", line 45, characters 2-10:
Warning: "Proof term." is deprecated. Use "Proof. exact term. Qed." instead.
[deprecated-exact-proof,deprecated-since-9.2,deprecated,default]
File "./HORPO/HorpoExNonTrans.v", line 115, characters 0-30:
Warning: Rewrite hint database terms already exists.
[already-declared-rewrite-hint-db,automation,default]
HORPO/HorpoExNonTrans.vo (real: 1.46, user: 1.12, sys: 0.33, mem: 615892 ko)
ROCQ compile HORPO/HorpoExMap.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 -deprecated-native-compiler-option -native-compiler no -R /github/workspace/builds/coq/coq-failing/_build_ci/color CoLoR HORPO/HorpoExMap.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/color
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w -deprecated-native-compiler-option -native-compiler no -R /github/workspace/builds/coq/coq-failing/_build_ci/color CoLoR HORPO/HorpoExMap.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.KIgjNMy3Eu
MINIMIZER_DEBUG: files:  HORPO/HorpoExMap.v /github/workspace/builds/coq/coq-failing/_build_ci/color/HORPO/HorpoExMap.v
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, 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 "./HORPO/HorpoExMap.v", line 115, characters 0-30:
Warning: Rewrite hint database terms already exists.
[already-declared-rewrite-hint-db,automation,default]
HORPO/HorpoExMap.vo (real: 1.51, user: 1.15, sys: 0.36, mem: 616484 ko)
ROCQ compile Term/Lambda/LCompSimple.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 -deprecated-native-compiler-option -native-compiler no -R /github/workspace/builds/coq/coq-failing/_build_ci/color CoLoR Term/Lambda/LCompSimple.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/color
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/rocq.orig compile -q -w -deprecated-native-compiler-option -native-compiler no -R /github/workspace/builds/coq/coq-failing/_build_ci/color CoLoR Term/Lambda/LCompSimple.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.Kfb3PF11Yt
MINIMIZER_DEBUG: files:  Term/Lambda/LCompSimple.v /github/workspace/builds/coq/coq-failing/_build_ci/color/Term/Lambda/LCompSimple.v
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, 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 "./Term/Lambda/LCompSimple.v", line 68, characters 0-84:
Warning: Notation "_ [=] _" was already used.
[notation-overridden,parsing,default]
File "./Term/Lambda/LCompSimple.v", line 68, characters 0-84:
Warning: Notation "_ [<=] _" was already used.
[notation-overridden,parsing,default]
File "./Term/Lambda/LCompSimple.v", line 71, characters 2-35:
Warning: Notations "_ * _" defined at level 40 with arguments constr
at level 40 and "_ *" defined at level 1 with arguments constr at next level
have incompatible prefixes. One of them will likely not work.
[notation-incompatible-prefix,parsing,default]
File "./Term/Lambda/LCompSimple.v", line 71, characters 2-35:
Warning: Rewrite hint database mem already exists.
[already-declared-rewrite-hint-db,automation,default]
File "./Term/Lambda/LCompSimple.v", line 71, characters 2-35:
Warning: Rewrite hint database mem already exists.
[already-declared-rewrite-hint-db,automation,default]
File "./Term/Lambda/LCompSimple.v", line 72, characters 2-37:
Warning: Rewrite hint database mem already exists.
[already-declared-rewrite-hint-db,automation,default]
File "./Term/Lambda/LCompSimple.v", line 72, characters 2-37:
Error:
Anomaly
"File "kernel/mod_subst.ml", line 80, characters 13-19: Assertion failed."
Please report at http://rocq-prover.org/bugs/.

Command exited with non-zero status 129
Term/Lambda/LCompSimple.vo (real: 1.31, user: 0.97, sys: 0.34, mem: 593324 ko)
make[2]: *** [rocq.mk:875: Term/Lambda/LCompSimple.vo] Error 129
make[2]: *** [Term/Lambda/LCompSimple.vo] Deleting file 'Term/Lambda/LCompSimple.glob'
make[1]: *** [rocq.mk:429: all] Error 2
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/color'
make: *** [Makefile:17: default] Error 2
+ code=2
+ printf '\n%s exit code: %s\n' color 2
+ '[' color '!=' stdlib_test ']'
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ '[' -e _build_ci/dune-trace.json ']'
+ tools/make-one-time-file.py --real _build_ci/color.log
    Time |  Peak Mem | File Name                       
-------------------------------------------------------
0m16.00s | 616484 ko | Total Time / Peak Mem           
-------------------------------------------------------
0m02.89s | 608464 ko | HORPO/Horpo.vo                  
0m01.55s | 575748 ko | HORPO/Computability.vo          
0m01.51s | 616484 ko | HORPO/HorpoExMap.vo             
0m01.46s | 615892 ko | HORPO/HorpoExNonTrans.vo        
0m01.33s | 578080 ko | DP/ASCCUnion.vo                 
0m01.31s | 593324 ko | Term/Lambda/LCompSimple.vo      
0m01.28s | 600676 ko | HORPO/HorpoWf.vo                
0m01.07s | 537016 ko | Util/Relation/SCCTopoOrdering.vo
0m01.02s | 560736 ko | HORPO/HorpoComp.vo              
0m00.88s | 534280 ko | Term/SimpleType/Terms.vo        
0m00.86s | 548388 ko | DP/ADPUnif.vo                   
0m00.84s | 532380 ko | DP/AHDE.vo                      
+ '[' '' ']'
+ exit 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 8.8MiB file on GitHub Actions Artifacts under bug.log)
g: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1467, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1469, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1471, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1473, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1475, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1477, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1479, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1481, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1483, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1485, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1487, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1489, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1491, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1493, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1495, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1497, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1499, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1501, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1503, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1506, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1508, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1511, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1514, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1517, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1520, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1523, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1526, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1529, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1532, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1535, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1537, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1539, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1541, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1543, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1545, characters 0-9:
Warning: This interactive proof is not started by the "Proof" command.
[missing-proof-command,fragile,default]
File "/tmp/tmpteml2tvy/CoLoR/Term/Lambda/LCompSimple.v", line 1547, characters 0-19:
Error: Signature components for field eq do not match:
the body of definitions differs: expected
"CoLoR.Term.Lambda.LCompSimple.Stdlib.ZArith.MSetGenTree.MSetAVL.OrderedTypeEx.FSetCompat.Backport_WSets.Equal"
but found
"CoLoR.Term.Lambda.LCompSimple.Stdlib.ZArith.MSetGenTree.MSetAVL.OrderedTypeEx.FSetCompat.Backport_WSets.eq_subproof".


�[93mIntermediate code not saved.�[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

coqbot-app Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🏁 Bench results:

┌─────────────────────────────────────┬─────────────────────────┬───────────────────────────────────────┬─────────────────────────┐
│                                     │      user time [s]      │           CPU instructions            │  max resident mem [KB]  │
│                                     │                         │                                       │                         │
│            package_name             │   NEW      OLD    PDIFF │      NEW             OLD        PDIFF │   NEW      OLD    PDIFF │
├─────────────────────────────────────┼─────────────────────────┼───────────────────────────────────────┼─────────────────────────┤
│         coq-rewriter-perf-SuperFast │  378.16   383.54  -1.40 │  2857223848216   2856829123964   0.01 │ 2066376  2073280  -0.33 │
│                 coq-fourcolor-reals │    6.83     6.92  -1.30 │    38959711517     38993705947  -0.09 │ 1074820  1075528  -0.07 │
│               coq-engine-bench-lite │  113.71   114.89  -1.03 │   876224360068    879256487013  -0.34 │ 1046620  1047808  -0.11 │
│          coq-performance-tests-lite │  741.36   748.22  -0.92 │  5900836018966   5899830280739   0.02 │ 1822232  1821440   0.04 │
│             rocq-mathcomp-ssreflect │    1.19     1.20  -0.83 │     7453415542      7461157257  -0.10 │  662844   663492  -0.10 │
│                       coq-fiat-core │   63.72    64.12  -0.62 │   401217557429    401790012534  -0.14 │  535168   535648  -0.09 │
│                           coq-color │  222.97   224.28  -0.58 │  1361122976591   1363044192723  -0.14 │ 1271152  1280528  -0.73 │
│                         coq-unimath │ 1606.49  1615.23  -0.54 │ 13377394107516  13377951022445  -0.00 │ 1920856  1921004  -0.01 │
│                      coq-coquelicot │   38.35    38.55  -0.52 │   219971089820    220083077866  -0.05 │  694428   694580  -0.02 │
│                  rocq-iris-examples │  326.65   327.98  -0.41 │  2000253673534   2000368357248  -0.01 │ 1179224  1160364   1.63 │
│                 rocq-iris-heap-lang │   73.54    73.83  -0.39 │   437664748107    437838006559  -0.04 │  836956   837840  -0.11 │
│                rocq-mathcomp-finmap │    9.72     9.75  -0.31 │    58392471211     58394043354  -0.00 │  581744   582196  -0.08 │
│           rocq-metarocq-safechecker │  272.61   273.25  -0.23 │  2004786595764   2000102407050   0.23 │ 2033596  2032300   0.06 │
│                        rocq-bignums │   21.98    22.03  -0.23 │   136254524425    136299688082  -0.03 │  508852   510448  -0.31 │
│                        coq-coqprime │   58.47    58.60  -0.22 │   384489723357    384563686583  -0.02 │  913776   913872  -0.01 │
│                       coq-fourcolor │ 1333.96  1336.85  -0.22 │ 12066787116252  12067155971765  -0.00 │ 1081720  1082844  -0.10 │
│              rocq-mathcomp-solvable │   67.82    67.95  -0.19 │   420286448378    420450926783  -0.04 │ 1005552  1006476  -0.09 │
│                  rocq-mathcomp-boot │   38.56    38.63  -0.18 │   212401028227    212402130058  -0.00 │  689472   689640  -0.02 │
│                         coq-ext-lib │   12.45    12.47  -0.16 │    80391865806     80464569042  -0.09 │  427024   427516  -0.12 │
│                            coq-corn │  552.58   553.23  -0.12 │  3576415527119   3577203506738  -0.02 │  747976   747712   0.04 │
│                         rocq-stdlib │  241.82   242.08  -0.11 │  1461581580330   1462676125718  -0.07 │  809260   809944  -0.08 │
│          rocq-mathcomp-finite-group │   21.00    21.02  -0.10 │   125485236670    125506025199  -0.02 │  640504   640480   0.00 │
│                         coq-coqutil │   44.61    44.63  -0.04 │   268506874505    268772667109  -0.10 │  521896   521800   0.02 │
│              coq-mathcomp-odd-order │  392.86   393.03  -0.04 │  2718083056533   2718477965926  -0.01 │ 3695120  3695044   0.00 │
│                        rocq-runtime │  273.31   273.32  -0.00 │  2004252435606   2005381913674  -0.06 │  592964   593532  -0.10 │
│                           rocq-iris │  281.68   281.69  -0.00 │  1624302293267   1623897060116   0.02 │  773328   773440  -0.01 │
│                      rocq-equations │   14.36    14.36   0.00 │   101283188827    101293881646  -0.01 │  417620   417752  -0.03 │
│                             coq-vst │  709.54   709.12   0.06 │  5163153516117   5164803188975  -0.03 │ 2225940  2227208  -0.06 │
│                           coq-flocq │   79.30    79.23   0.09 │   445588284962    445826542935  -0.05 │  942624   942740  -0.01 │
│                        coq-compcert │  282.72   282.33   0.14 │  1766608145024   1767375673701  -0.04 │ 1373996  1376304  -0.17 │
│               rocq-metarocq-erasure │  728.50   727.46   0.14 │  4568629964562   4548457363151   0.44 │ 2415504  2418252  -0.11 │
│                            coq-core │    5.93     5.92   0.17 │    42628764525     42687945339  -0.14 │  110268   109960   0.28 │
│                    coq-fiat-parsers │  270.55   270.09   0.17 │  2029504752388   2030386255963  -0.04 │ 2293016  2290580   0.11 │
│        coq-fiat-crypto-with-bedrock │ 6559.89  6544.42   0.24 │ 52655769997852  52659388777590  -0.01 │ 5209016  5209328  -0.01 │
│                 rocq-metarocq-pcuic │  598.93   597.51   0.24 │  3665454614955   3636585542712   0.79 │ 2905080  2892400   0.44 │
│          rocq-metarocq-translations │   20.73    20.68   0.24 │   142412695318    139753125969   1.90 │ 1243928  1244176  -0.02 │
│                        coq-bedrock2 │  246.20   245.59   0.25 │  1819579305867   1820508448315  -0.05 │  936124   936236  -0.01 │
│                rocq-metarocq-common │  124.87   124.48   0.31 │   778829408093    774142334209   0.61 │ 2291916  2282036   0.43 │
│                 coq-category-theory │ 1244.70  1239.98   0.38 │  8623399928720   8624333300697  -0.01 │ 1225280  1225404  -0.01 │
│                            coq-hott │  163.54   162.86   0.42 │  1022421308852   1022375730853   0.00 │  487748   487668   0.02 │
│                    coq-math-classes │   77.22    76.88   0.44 │   439510041595    439687713638  -0.04 │  546412   546736  -0.06 │
│  rocq-mathcomp-group-representation │   73.81    73.44   0.50 │   471830604195    471963066204  -0.03 │ 1547596  1546452   0.07 │
│        rocq-metarocq-template-pcuic │   38.94    38.74   0.52 │   240908397089    237574233950   1.40 │ 1298784  1295204   0.28 │
│                        coq-rewriter │  289.56   287.91   0.57 │  2086706192425   2087424863736  -0.03 │ 1528532  1529776  -0.08 │
│                 rocq-mathcomp-field │  160.85   159.86   0.62 │  1065384872116   1065783157934  -0.04 │ 2644012  2649680  -0.21 │
│                          rocq-stdpp │   65.30    64.86   0.68 │   368677877637    368944281254  -0.07 │  773772   773676   0.01 │
│             rocq-mathcomp-classical │   89.53    88.91   0.70 │   557310628869    557503307872  -0.03 │ 1774908  1784204  -0.52 │
│                 rocq-mathcomp-reals │   43.58    43.25   0.76 │   265793136761    265832122651  -0.01 │ 2063212  2066108  -0.14 │
│              rocq-metarocq-template │   93.57    92.83   0.80 │   631300002958    624261201226   1.13 │ 1688636  1700016  -0.67 │
│                           rocq-elpi │   27.18    26.96   0.82 │   184255331374    184266732429  -0.01 │  495276   495600  -0.07 │
│                           rocq-core │   11.49    11.39   0.88 │    74011222475     74012497748  -0.00 │  451380   451224   0.03 │
│               rocq-mathcomp-algebra │  316.56   313.44   1.00 │  2076712952038   2077368568474  -0.03 │ 1420464  1425952  -0.38 │
│ coq-neural-net-interp-computed-lite │  248.19   245.63   1.04 │  2324712134574   2324268580431   0.02 │  946568   945976   0.06 │
│              rocq-mathcomp-analysis │ 1147.84  1135.99   1.04 │  7785353253052   7788458144527  -0.04 │ 2422904  2421716   0.05 │
│                 rocq-metarocq-utils │   19.56    19.34   1.14 │   123120262511    123237599047  -0.10 │  621368   621540  -0.03 │
│                 rocq-mathcomp-order │   94.02    92.90   1.21 │   603269483020    603301361761  -0.01 │  972400   973040  -0.07 │
└─────────────────────────────────────┴─────────────────────────┴───────────────────────────────────────┴─────────────────────────┘

🐢 Top 25 slow downs
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                       TOP 25 SLOW DOWNS                                                        │
│                                                                                                                                │
│ OLD   NEW    DIFF   %DIFF   Ln                    FILE                                                                         │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 43.4  46.0  2.6178   6.03%  371  coq-fiat-crypto-with-bedrock/src/Stringification/Zig.v.html                                   │
│  214   216  2.4882   1.16%    8  coq-neural-net-interp-computed-lite/theories/MaxOfTwoNumbersSimpler/Computed/AllLogits.v.html │
│ 25.8  26.5  0.6873   2.66%  258  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html                                    │
│ 20.7  21.4  0.6873   3.32%  254  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/modinv/beeu_shrtz.v.html                        │
│ 38.8  39.4  0.6687   1.72%  139  coq-fiat-parsers/src/Parsers/Refinement/SharpenedJSON.v.html                                  │
│ 26.1  26.7  0.6647   2.55%  334  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord.v.html                                    │
│ 53.1  53.8  0.6293   1.18%  259  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                 │
│ 78.0  78.6  0.6090   0.78%   48  coq-fiat-crypto-with-bedrock/src/Curves/Weierstrass/AffineProofs.v.html                       │
│ 30.2  30.8  0.5891   1.95%  222  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 38.6  39.1  0.5529   1.43%  116  coq-bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html                                    │
│ 34.9  35.4  0.5263   1.51%  221  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 25.7  26.2  0.5222   2.03%  223  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 21.5  22.0  0.5208   2.43%  224  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 18.0  18.5  0.4994   2.77%  272  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                 │
│ 17.2  17.6  0.4886   2.85%  245  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 38.6  39.1  0.4753   1.23%  116  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/bedrock2/src/bedrock2Examples/full_mul.v.html  │
│ 43.4  43.8  0.4198   0.97%    3  coq-fiat-crypto-with-bedrock/src/ExtractionOCaml/fiat_crypto.v.html                           │
│ 45.8  46.2  0.4130   0.90%    4  coq-fiat-crypto-with-bedrock/src/ExtractionOCaml/bedrock2_fiat_crypto.v.html                  │
│ 4.01  4.41  0.4044  10.09%  497  rocq-mathcomp-algebra/algebra/field_tactic.v.html                                             │
│ 17.1  17.5  0.3651   2.13%  225  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 21.8  22.1  0.3586   1.65%  229  coq-unimath/UniMath/CategoryTheory/Presheaves/Sheafification.v.html                           │
│ 13.7  14.0  0.3528   2.58%  391  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/Logic/Existential.v.html      │
│ 8.66  9.01  0.3482   4.02%  245  rocq-mathcomp-analysis/theories/gauss_integral.v.html                                         │
│ 16.1  16.5  0.3473   2.16%  233  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Coord32.v.html                                  │
│ 65.4  65.7  0.3453   0.53%  279  coq-fiat-crypto-with-bedrock/src/Bedrock/P256/Jacobian.v.html                                 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
🐇 Top 25 speed ups
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                              TOP 25 SPEED UPS                                                              │
│                                                                                                                                            │
│ OLD   NEW    DIFF    %DIFF    Ln                      FILE                                                                                 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│  297   292  -5.2059  -1.75%     3  coq-rewriter-perf-SuperFast/src/Rewriter/Rewriter/Examples/PerfTesting/LiftLetsMap/_10_SuperFast.v.html │
│ 60.0  57.1  -2.8873  -4.81%     3  coq-performance-tests-lite/PerformanceExperiments/typeclass_reification_let_in_HOAS/_0_SuperFast.v.html │
│ 50.8  49.4  -1.4080  -2.77%   999  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                         │
│ 50.6  49.4  -1.2185  -2.41%   968  coq-performance-tests-lite/src/fiat_crypto_via_setoid_rewrite_standalone.v.html                         │
│ 19.8  18.9  -0.8140  -4.12%    13  coq-fourcolor/theories/proof/job207to214.v.html                                                         │
│ 74.9  74.2  -0.6633  -0.89%   663  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                                   │
│ 55.9  55.4  -0.4537  -0.81%    20  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/NBE.v.html                                             │
│ 45.9  45.5  -0.4433  -0.97%     4  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/WithBedrock/fiat_crypto.v.html                     │
│ 27.5  27.2  -0.3654  -1.33%   145  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html                            │
│ 26.7  26.3  -0.3551  -1.33%    33  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/MontgomeryLadderRISCV.v.html                    │
│ 44.2  43.9  -0.3487  -0.79%     3  coq-fiat-crypto-with-bedrock/src/ExtractionJsOfOCaml/fiat_crypto.v.html                                 │
│ 20.9  20.5  -0.3473  -1.66%    98  coq-fiat-crypto-with-bedrock/rupicola/bedrock2/deps/coqutil/src/coqutil/Map/Memory.v.html               │
│ 27.6  27.2  -0.3309  -1.20%   148  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/GarageDoorTop.v.html                            │
│ 26.7  26.4  -0.3241  -1.21%    30  coq-fiat-crypto-with-bedrock/src/Bedrock/End2End/X25519/MontgomeryLadderRISCV.v.html                    │
│ 18.6  18.3  -0.3181  -1.71%    31  coq-engine-bench-lite/coq/PerformanceDemos/pattern.v.html                                               │
│ 38.1  37.8  -0.2916  -0.77%   600  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/JacobianCoZ.v.html                                   │
│ 13.4  13.1  -0.2564  -1.92%  2857  rocq-metarocq-safechecker/_build/default/theories/SafeChecker/PCUICTypeChecker.v.html                   │
│ 7.92  7.66  -0.2557  -3.23%     3  coq-performance-tests-lite/PerformanceExperiments/Reify/LtacVariants/_7_SuperFast.v.html                │
│ 8.61  8.35  -0.2533  -2.94%  1332  coq-mathcomp-odd-order/theories/PFsection9.v.html                                                       │
│ 35.7  35.5  -0.2532  -0.71%    27  coq-fiat-crypto-with-bedrock/src/Rewriter/Passes/ToFancyWithCasts.v.html                                │
│ 26.0  25.8  -0.2498  -0.96%    13  coq-fourcolor/theories/proof/job499to502.v.html                                                         │
│ 19.2  18.9  -0.2342  -1.22%   213  coq-fiat-crypto-with-bedrock/src/Curves/EdwardsMontgomery.v.html                                        │
│ 6.59  6.36  -0.2338  -3.55%   324  coq-fiat-crypto-with-bedrock/src/Bedrock/Secp256k1/Addchain.v.html                                      │
│ 3.13  2.90  -0.2300  -7.35%  1461  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERNaturals.v.html                      │
│ 7.27  7.05  -0.2295  -3.15%  1018  coq-unimath/UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/ExponentialEqs.v.html                   │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@ppedrot

ppedrot commented Dec 4, 2026

Copy link
Copy Markdown
Member

Regression: library objects inside a functor are wrongly named after going through a module alias

Module Type E. End E.
Module E0. End E0.
Module M.
  Module F (Y : E).
    Axiom a : nat.
    Axiom b : a = 0.
    #[export] Hint Resolve b : db.
  End F.
End M.
Module M' := M.
Module A := M'.F E0.
Import A.
Goal A.a = 0. auto with db. Qed.
Error: Ill-formed constant b: expected canonical name A.b but found M.F.b

On master this compiles and passes coqchk. If b has type P for some Axiom P : Prop instead, auto doesn't find the hint at all, because the hint's pattern names P with the wrong canonical name. The same failure shows up with alias chains (Q3 := Q2 := Q1 := M), a submodule reached through an alias, Include of a module containing an alias, with Module, and an alias of a functor application.

For Module M' := M, infer_struct_delta_gen M' (Some M) adds the root alias M' ↦ M, and a functor submodule contributes nothing because infer_delta returns None for it. So kn_of_delta now sends names under M'.F to M.F. The old strengthen_and_subst_struct added lift_mp_delta_resolver mp_to' for functor fields:

before:  M'.F => <lift>, M' => M, M'.MT => <lift>
now:                     M' => M, M'.MT => <lift>

Kernel signatures don't notice, since copying and subtyping add a more specific …F ↦ …F mapping. Library objects do. declare_module substitutes them with subst_reso_of_module, which turns the hint's (M.F.b, M.F.b) into (M'.F.b, M.F.b). Applying M'.F then combines this with M'.F ↦ A through join, which leaves the canonical half alone, giving (A.b, M.F.b).

Restoring the lift in the alias case only gives exactly the old resolvers:

--- a/kernel/mod_declarations.ml
+++ b/kernel/mod_declarations.ml
@@ -152,7 +152,7 @@ let rec infer_struct_delta_gen mp mp' struc =
     | SFBmodule mb ->
       let mp = MPdot (mp, l) in
       begin match infer_delta mp mb with
-        | None -> delta
+        | None -> if Option.is_empty mp' then delta else lift_mp_delta_resolver mp delta
         | Some delta' -> add_delta_resolver delta' delta
       end
     | SFBrules _ -> delta

Lifting unconditionally is wrong: bugs/bug_22954_1.v then hits the assert in Deltamap.add_mp_hint.

@ppedrot

ppedrot commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Regression: anomaly when a functor argument lacks an Inline parameter

Module Type T. Parameter Inline v : Prop. End T.
Module F (A:T). Definition w := A.v. End F.
Module N0. End N0.
Module B0 := F N0.
Error: Anomaly "Constant N0.v does not appear in the environment."

On master: Error: The field v is missing in N0. The same happens when N0.v is an inductive or a module, and when the Inline parameter sits in a submodule of the parameter type.

declare_module computes the module's library objects (get_functor_sobjs → compute_subst, and inlined_bodies) before the kernel has type-checked the module expression. Both call Modops.inline_delta_resolver, which builds N0.v from the parameter type's Inline fields. On master, inline_delta_resolver happened to check that the label exists, and that was where the user-facing error came from. The PR removed that check (#11845 coming back through another route), and 422c3fd delays the call only for Include.

declare_modtype already type-checks the expression first ((* We check immediately that mte is well-formed *)). Doing the same in declare_module means moving the existing translate_module call before the library objects are computed, in the environment that still has the parameters pushed: (@SkySkimmer edited to include the context code in the middle instead of @@ -1293,13 +1303,7 @@ let declare_module id args res mexpr_o =)

--- a/vernac/declaremods.ml
+++ b/vernac/declaremods.ml
@@ -1276,6 +1276,16 @@ let declare_module id args res mexpr_o =
     | None, Some (typ, inl) -> MType (params, typ), inl
     | Some body, otyp -> MExpr (params, body, Option.map fst otyp), Option.cata snd (default_inline_level ()) otyp
   in
+  let inl = match inl_expr with
+  | None -> None
+  | _ -> inl_res
+  in
+  let state = ((Environ.universes env, Univ.UnivConstraints.empty), Reductionops.inferred_universes) in
+  let entry_body = match entry with
+  | MType (_, typ) -> MType ([], typ)
+  | MExpr (_, body, typ) -> MExpr ([], body, typ)
+  in
+  let _, (_, cst), _ = Mod_typing.translate_module state vm_state env mp inl entry_body in
   let sobjs, mp0 = match entry with
     | MType (_,mte) | MExpr (_,_,Some mte) ->
       get_functor_sobjs false env inl_res (params,mte), get_module_path mte
     | MExpr (_,me,None) ->
       get_functor_sobjs true env inl_expr (params,me), get_module_path me
   in
   (* Computed here, while the parameters of the module are still part of the
      environment. *)
   let inlined = match entry with
     | MType (_,mte) | MExpr (_,_,Some mte) ->
       inlined_bodies env inl_res ~is_mod:false mte
     | MExpr (_,me,None) ->
       inlined_bodies env inl_expr ~is_mod:true me
   in
   (* Undo the simulated interactive building of the module
      and declare the module as a whole *)
   Summary.Interp.unfreeze_summaries fs;
-  let inl = match inl_expr with
-  | None -> None
-  | _ -> inl_res
-  in
   let () = Global.push_context_set ctx in
-  let state = ((Global.universes (), Univ.UnivConstraints.empty), Reductionops.inferred_universes) in
-  let _, (_, cst), _ = Mod_typing.translate_module state vm_state (Global.env ()) mp inl entry in
   let () = Global.add_univ_constraints cst in
   let mp_env = Global.add_module id entry inl in

Since the kernel check now runs first, some cases report the kernel's subtyping error instead of master's "field missing" one. For example, when v is an inductive you get Signature components for field v do not match: a definition is expected., which is what Module Type _ := F N1 and Declare Module _ : F N1 already reported on master.

@ppedrot

ppedrot commented Dec 4, 2026

Copy link
Copy Markdown
Member

Regression: the inductive alias check in Subtyping.check_inductive is wrong in both directions

False rejection (accepted on master):

Module Type TT. Inductive T := a | b. End TT.
Module Type S. Declare Module T : TT. End S.
Module Imp. Module T. Inductive T := a | b. End T. End Imp.
Module Type SI := S with Module T := Imp.T.
Module F (X : SI). End F.
Module FI := F Imp.
Error: Signature components for field T.T do not match:
aliases to inductive types do not match: expected Imp.T.T but found Imp.T.T.

False acceptance (rejected on master; coqchk accepts it too):

Unset Elimination Schemes.
Module Type S. Module T. Inductive T : Prop := . End T. Module T' := T. End S.
Module Imp. Module T. Inductive T : Prop := . End T. Module T'. Inductive T : Prop := . End T'. End Imp.
Module C1 : S := Imp.

With constructors or elimination schemes, the later constructor-type or T_rect comparison rejects it instead. When sealing, that later error mentions names that aren't declared yet, and printing it raises Anomaly "Uncaught exception Not_found." in Constrextern:

Module Type Empty. End Empty.
Module E0. End E0.
Module Type TypE (E : Empty). Inductive T := c : bool -> T. End TypE.
Module natE (E : Empty). Inductive T := c : bool -> T. End natE.
Module Type TypC (F : TypE). Module T := F E0. Module T' := T. End TypC.
Module Imp. Module T. Inductive T := c : bool -> T. End T. Module T'. Inductive T := c : bool -> T. End T'. End Imp.
Module C1 : TypC natE := Imp.

There are two problems:

  • Double substitution. mib2 has already been through Declareops.subst_mind_body subst2, so mib2.mind_aliasing is already the substituted target. Applying subst_mind subst2 to (kn2, kn2') again leaves the canonical half outside the domain, so subst_dual_mp takes the user = true branch and recomputes it from kn2. That makes the comparison true whenever the impl's inductive has an aliasing, whatever the spec says.
  • Missing aliasing treated as a mismatch. Modops.strengthen doesn't strengthen inductives, so an impl inductive can have no aliasing and still be its own canonical name. The None, Some _ branch rejects it unconditionally; master compared kn_of_delta reso1 kn1, which is kn1 in that case.

I couldn't turn the bypass into an inconsistency, because constructor types name the inductive under its canonical name and catch the mismatch. But that check is then effectively dead code.

--- a/kernel/subtyping.ml
+++ b/kernel/subtyping.ml
@@ -280,18 +280,12 @@ let check_inductive (cst, ustate) trace env mp1 l info1 mp2 mib2 subst1 subst2 =
       error (InductiveUniformParams { got = mib1.mind_nparams_rec; expected = mib2.mind_nparams_rec })
   in
 
-  let () = match mib1.mind_aliasing, mib2.mind_aliasing with
-    | _, None -> ()
-    | None, Some kn2' ->
-      let mind1 = MutInd.make1 kn1 in
-      let mind2 = subst_mind subst2 (MutInd.make kn1 kn2') in
-      error (NotEqualInductiveAliases (mind1, mind2))
-    | Some kn1', Some kn2' ->
-      let mind1 = MutInd.make kn1 kn1' in
-      let mind2 = subst_mind subst2 (MutInd.make kn2 kn2') in
-      if KerName.equal kn1' (MutInd.canonical mind2)
-      then ()
-      else error (NotEqualInductiveAliases (mind1, mind2))
+  let () = match mib2.mind_aliasing with
+    | None -> ()
+    | Some kn2' ->
+      let kn1' = Option.default kn1 mib1.mind_aliasing in
+      if not (KerName.equal kn1' kn2') then
+        error (NotEqualInductiveAliases (MutInd.make kn1 kn1', MutInd.make (subst_kn subst2 kn2) kn2'))
   in
   (* we first check simple things *)
   let cst =

subst_kn subst2 kn2 keeps master's error message, so output/ModuleErrorsComprehensive.out is unchanged.

@ppedrot ppedrot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In terms of design this looks fine to me. There are a few regressions, but some may be not so serious and their fix might be postponed to the next cleanup round?

Delta resolvers are now only used in substitutions. When we need a
delta resolver to build a substitution, we infer it from the module structure.

This simplifies data at rest, reducing the attack surface of crafted
.vo files.
@SkySkimmer SkySkimmer added the request: full CI Use this label when you want your next push to trigger a full CI. label Dec 5, 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 Dec 5, 2026
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

Regression: anomaly when a functor argument lacks an Inline parameter

didn't fix this one, the proposed patch fails on the assert at

let () = assert (not @@ ModPath.Map.mem mp env.env_modules) in
in test output/TranspModType

@SkySkimmer SkySkimmer added the needs: fixing The proposed code change is broken. label Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: redesign The same functionality is being re-implemented in a different way. needs: fixing The proposed code change is broken.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants