Skip to content

Fix restrict_universe_context#7495

Merged
mattam82 merged 2 commits into
rocq-prover:masterfrom
SkySkimmer:fix-restrict
Jun 5, 2018
Merged

Fix restrict_universe_context#7495
mattam82 merged 2 commits into
rocq-prover:masterfrom
SkySkimmer:fix-restrict

Conversation

@SkySkimmer

Copy link
Copy Markdown
Contributor

This should fix #7472 although I didn't test it.

Instead of messing with a buggy custom graph algorithm we go through the ugraph algorithm in a slightly brute-force manner.
It seems this impacts some tricky heuristic causing HoTT and formal-topology (and a HoTT-based test suite file) to fail. Still investigating.

Bench: https://ci.inria.fr/coq/view/benchmarking/job/benchmark-part-of-the-branch/426/console
Despite the unsophisticated algorithm there is little impact, I think we rarely have many new universes / constraints per object.

┌──────────────────────────┬─────────────────────────┬───────────────────────────────────────┬───────────────────────────────────────┬─────────────────────────┬─────────────────┐
│                          │      user time [s]      │              CPU cycles               │           CPU instructions            │  max resident mem [KB]  │   mem faults    │
│                          │                         │                                       │                                       │                         │                 │
│             package_name │     NEW     OLD PDIFF   │            NEW            OLD PDIFF   │            NEW            OLD PDIFF   │     NEW     OLD PDIFF   │ NEW OLD PDIFF   │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│               coq-sf-vfa │   26.19   26.48 -1.10 % │    72078267639    72152115741 -0.10 % │    93867490685    94035628199 -0.18 % │  541376  541380 -0.00 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                coq-sf-lf │   20.78   20.88 -0.48 % │    56161474465    56271106701 -0.19 % │    73618512048    73872348912 -0.34 % │  429260  429140 +0.03 % │   7   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│              coq-bignums │   79.78   80.08 -0.37 % │   220549849581   220674642906 -0.06 % │   285941360780   286264820515 -0.11 % │  528684  528732 -0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│          coq-fiat-crypto │ 4108.89 4113.51 -0.11 % │ 11397157329157 11410919665169 -0.12 % │ 18427840323976 18442342141631 -0.08 % │ 3185336 3147660 +1.20 % │   8  33 -75.76 % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│         coq-math-classes │  228.35  228.58 -0.10 % │   628530108909   629035769844 -0.08 % │   788150193061   786417458071 +0.22 % │  532584  533152 -0.11 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                 coq-corn │ 1563.74 1564.48 -0.05 % │  4341727574523  4325870881332 +0.37 % │  6452506241544  6450126963962 +0.04 % │  875020  874056 +0.11 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│    coq-mathcomp-fingroup │   64.94   64.97 -0.05 % │   178952540988   179084420300 -0.07 % │   239204768022   239794506122 -0.25 % │  588384  589000 -0.10 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│           coq-coquelicot │   83.52   83.54 -0.02 % │   230493921022   230181842101 +0.14 % │   275444082307   275437213366 +0.00 % │  721580  720136 +0.20 % │  29   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                coq-flocq │  263.23  263.24 -0.00 % │   730312386310   730385581913 -0.01 % │   903594177302   903317960182 +0.03 % │ 1245704 1245604 +0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│       coq-mathcomp-field │  460.97  460.98 -0.00 % │  1282709326728  1282401193211 +0.02 % │  2066762859212  2064538964300 +0.11 % │  814584  814392 +0.02 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│         coq-fiat-parsers │  703.45  703.24 +0.03 % │  1946437216614  1946269578221 +0.01 % │  2975529193808  2979563842492 -0.14 % │ 3376576 3376520 +0.00 % │   0   9 -100.00 % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│    coq-mathcomp-solvable │  201.21  201.12 +0.04 % │   558641643648   558190473032 +0.08 % │   770409292656   770917220716 -0.07 % │  839588  866264 -3.08 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│ coq-mathcomp-real-closed │  171.78  171.54 +0.14 % │   477975725875   477399075006 +0.12 % │   699118837987   698698054275 +0.06 % │  839508  837272 +0.27 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                coq-color │  723.37  722.23 +0.16 % │  1999700567406  1995187718879 +0.23 % │  2385012886632  2384593340636 +0.02 % │ 1450604 1446404 +0.29 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│             coq-compcert │  875.59  873.48 +0.24 % │  2425409110563  2419988860901 +0.22 % │  3483911297171  3481702485365 +0.06 % │ 1335604 1333456 +0.16 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                  coq-vst │ 3849.68 3840.16 +0.25 % │ 10701114539363 10672001365828 +0.27 % │ 14014496246065 14003087057603 +0.08 % │ 2232116 2234312 -0.10 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│              coq-unimath │ 1291.28 1287.94 +0.26 % │  3576386632018  3566802329864 +0.27 % │  6047356902985  6047511516079 -0.00 % │ 1071100 1071192 -0.01 % │   1   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│   coq-mathcomp-ssreflect │   45.31   45.19 +0.27 % │   123795015548   123548759317 +0.20 % │   145512283840   145469700027 +0.03 % │  537116  537276 -0.03 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│     coq-mathcomp-algebra │  185.64  185.10 +0.29 % │   514971975928   513827131380 +0.22 % │   693801057199   693315221524 +0.07 % │  650772  645120 +0.88 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│               coq-geocoq │ 3104.64 3092.45 +0.39 % │  8610245606594  8578404414075 +0.37 % │ 13830358266032 13818865418258 +0.08 % │ 1239700 1210724 +2.39 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│               coq-sf-plf │   53.94   53.63 +0.58 % │   148135110655   147999661663 +0.09 % │   187565992538   187696689307 -0.07 % │  514416  514684 -0.05 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│            coq-fiat-core │  111.95  111.25 +0.63 % │   310466951147   309300228426 +0.38 % │   380270573253   379700140505 +0.15 % │  502092  500004 +0.42 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│   coq-mathcomp-odd-order │ 1420.54 1411.10 +0.67 % │  3957117294869  3931405783138 +0.65 % │  6664863723229  6666033452918 -0.02 % │ 1416680 1393308 +1.68 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│   coq-mathcomp-character │  276.06  274.16 +0.69 % │   767362696214   762136638822 +0.69 % │  1091194393647  1087543890712 +0.34 % │ 1130488 1120628 +0.88 % │   0   0  +nan % │
└──────────────────────────┴─────────────────────────┴───────────────────────────────────────┴───────────────────────────────────────┴─────────────────────────┴─────────────────┘

@SkySkimmer SkySkimmer added needs: fixing The proposed code change is broken. kind: fix This fixes a bug or incorrect documentation. part: universes The universe system. labels May 12, 2018
@SkySkimmer SkySkimmer added this to the 8.9+beta1 milestone May 12, 2018
@SkySkimmer SkySkimmer requested a review from mattam82 May 12, 2018 20:13
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@gares could you check that it works for your bug?

Since it's hard to trigger we will have to wait for unit tests to put a regression test in.

@gares

gares commented May 12, 2018

Copy link
Copy Markdown
Member

Once merged I can enable restriction in elpi, and this triggers the bug... I'll prepare an overlay for you with minimisation on

@SkySkimmer

SkySkimmer commented May 12, 2018 via email

Copy link
Copy Markdown
Contributor Author

@SkySkimmer

Copy link
Copy Markdown
Contributor Author

Incidentally fixes the example in #5200.

gares added a commit to SkySkimmer/rocq that referenced this pull request May 13, 2018
@gares

gares commented May 13, 2018

Copy link
Copy Markdown
Member

elpi passes! I see 3 tests failing:

  • test suite fails bugs/closed/4544
  • Formal topolgy fails with Error: Universe instance should have length 4, maybe now restriction leaves more/less universes around and hence one has to pass more/less universe instances.
  • Hott fails with Error: Universe {HoTT.Modalities.Modality.895} is unbound., I've no clue

@gares

gares commented May 13, 2018

Copy link
Copy Markdown
Member

I think @mattam82 is the most reasonable assignee here, given that @SkySkimmer authors the PR. Maybe also @ppedrot understand this code and can be shepherd. In case he can just override my assignment of this PR to Matthieu.

gares added a commit to SkySkimmer/rocq that referenced this pull request May 14, 2018
@gares

gares commented May 14, 2018

Copy link
Copy Markdown
Member

the rebase dropped my commit, I hope it was not intended since I put it back

@SkySkimmer

Copy link
Copy Markdown
Contributor Author

There was no rebase, I did push -f --all to pick up any branches lying on my disk.

@gares

gares commented May 14, 2018

Copy link
Copy Markdown
Member

Well same result.

For the formal-topology overlay, I'm not sure I did the right thing.
I made a PR with the right set of changes, see bmsherman/topology#17 but
I made the PR on master, while the current branch being tested by ci includes extra commits from other overlays I guess

@gares

gares commented May 14, 2018

Copy link
Copy Markdown
Member

I did push -f --all to pick up any branches lying on my disk.

well, given you did not pull this branch, you dropped my commit. No problem, but next time beware -f

@SkySkimmer

SkySkimmer commented May 14, 2018 via email

Copy link
Copy Markdown
Contributor Author

@gares

gares commented May 14, 2018

Copy link
Copy Markdown
Member

I can't fix the test suite alone. The first error is about a missing instance, I passed l there, but then you get the error we also have on hott (indeed the test is taken from hott) that is "unknown...". I'll stop here.

@mattam82 mattam82 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.

I'm trying to understand the difference it introduces. It can certainly select a different subset of the constraints. There are cases where it now selects a different subset of the kept universes, eliminating more spurious ones as well? I think overall the code is better that way, reusing the existing uGraph implementation.

Comment thread engine/univops.ml Outdated
LSet.fold (fun v (csts,g as cstsg) ->
(** Fold through all pairs of kept universes. We avoid
recomputing for swapped order pairs. *)
if Level.compare u v >= 0 then cstsg

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.

Why > here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why > here?

What do you mean?

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.

Why not Level.compare u v == 0

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.

Right, I don't understand the comment either... That's meant to avoid treating u = l, v = l twice?

Comment thread engine/univops.ml
allkept cstsg)
allkept (Constraint.empty,g)
in
(LSet.inter univs keep, csts)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The universes we keep are exactly the same, as indicated by this line not changing. The constraints are not the same.

@SkySkimmer

SkySkimmer commented May 14, 2018 via email

Copy link
Copy Markdown
Contributor Author

@SkySkimmer

SkySkimmer commented May 14, 2018 via email

Copy link
Copy Markdown
Contributor Author

@mattam82

Copy link
Copy Markdown
Member

Good, I see now.

@gares

gares commented May 16, 2018

Copy link
Copy Markdown
Member

I think this bug/PR should have high priority for two reasons:

  • it breaks scripts (more/less univ variables) hence it should be merged soon in order give users the time to handle this. Note that there is no way to have the same .v file work before/after this PR AFAICT (if the file is affected by the bug, of course).
  • the bug popped up in my code when I ported it to the recommendations written here that we are about to give to others in a few weeks at the CoqIW.

@gares gares added the priority: high The priority for inclusion in the next release is high. label May 16, 2018
@SkySkimmer

SkySkimmer commented May 18, 2018

Copy link
Copy Markdown
Contributor Author

New commit is a better version

Smarter fix for restrict_universe_context using the UGraph

This time the shortcut (if is_empty removed ...) is unecessary. See
pipeline https://gitlab.com/SkySkimmer/coq/pipelines/22278594 which
has the shortcut disabled (and a slight bug because instead of using
enforce_eq_level I added the constraint sometimes getting u = u).

I'll leave it with separate commits for a bit so people can have a look.

@SkySkimmer SkySkimmer added the needs: squashing Some commits should be squashed together. label May 21, 2018
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

For the new version (vs master):
https://ci.inria.fr/coq/view/benchmarking/job/benchmark-part-of-the-branch/434/console


┌──────────────────────────┬─────────────────────────┬───────────────────────────────────────┬───────────────────────────────────────┬─────────────────────────┬─────────────────┐
│                          │      user time [s]      │              CPU cycles               │           CPU instructions            │  max resident mem [KB]  │   mem faults    │
│                          │                         │                                       │                                       │                         │                 │
│             package_name │     NEW     OLD PDIFF   │            NEW            OLD PDIFF   │            NEW            OLD PDIFF   │     NEW     OLD PDIFF   │ NEW OLD PDIFF   │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                coq-sf-lf │   20.72   20.94 -1.05 % │    56586894766    56654246973 -0.12 % │    73891870225    74069232425 -0.24 % │  429656  429608 +0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│   coq-mathcomp-ssreflect │   45.30   45.37 -0.15 % │   123806720642   123799292129 +0.01 % │   145548136255   145771497523 -0.15 % │  536796  536716 +0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                coq-flocq │  263.12  263.14 -0.01 % │   731219442568   731902717211 -0.09 % │   904156796927   905285612183 -0.12 % │ 1245728 1245560 +0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│               coq-sf-plf │   53.98   53.98 +0.00 % │   148727380769   148430869002 +0.20 % │   187815126446   187950661875 -0.07 % │  514592  514412 +0.03 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│              coq-bignums │   80.01   79.92 +0.11 % │   220489851144   220318437126 +0.08 % │   285975572343   286193859558 -0.08 % │  519628  519620 +0.00 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│     coq-mathcomp-algebra │  185.96  185.71 +0.13 % │   513703263527   512680842050 +0.20 % │   692541240217   691814201723 +0.11 % │  652800  644336 +1.31 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│               coq-geocoq │ 3102.08 3096.87 +0.17 % │  8607052732530  8591803586226 +0.18 % │ 13801076120917 13796676884727 +0.03 % │ 1239940 1240020 -0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                coq-color │  722.42  720.76 +0.23 % │  1997153880301  1993083136609 +0.20 % │  2380268365514  2379847535519 +0.02 % │ 1445680 1445768 -0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│    coq-mathcomp-solvable │  203.03  202.55 +0.24 % │   561273093929   559138979266 +0.38 % │   771762732374   771080124299 +0.09 % │  839696  842096 -0.29 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│             coq-compcert │  870.01  867.28 +0.31 % │  2409939537904  2403686186618 +0.26 % │  3481007314018  3481556723029 -0.02 % │ 1387860 1387936 -0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│ coq-mathcomp-real-closed │  171.90  171.33 +0.33 % │   476570138411   475428734025 +0.24 % │   695992758165   696231970223 -0.03 % │  838800  838260 +0.06 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│       coq-mathcomp-field │  460.27  458.73 +0.34 % │  1277819418902  1272754858352 +0.40 % │  2055922942355  2056146495448 -0.01 % │  809880  808924 +0.12 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                 coq-hott │  336.38  335.20 +0.35 % │   935005249418   927958727299 +0.76 % │  1432342299484  1432631241535 -0.02 % │  588980  588912 +0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│              coq-unimath │ 1296.82 1292.27 +0.35 % │  3592638477235  3578213482818 +0.40 % │  6048026234513  6047947608826 +0.00 % │ 1079620 1079608 +0.00 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│          coq-fiat-crypto │ 4116.47 4099.58 +0.41 % │ 11423720793012 11376309732568 +0.42 % │ 18432090209390 18433184974321 -0.01 % │ 3188188 3195900 -0.24 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│            coq-fiat-core │  112.06  111.59 +0.42 % │   310915867493   310488028499 +0.14 % │   379974873653   380017034773 -0.01 % │  498240  497644 +0.12 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                 coq-corn │ 1569.84 1562.97 +0.44 % │  4341219649599  4322259729286 +0.44 % │  6439793133435  6439697642863 +0.00 % │  933372  933504 -0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│           coq-coquelicot │   83.74   83.36 +0.46 % │   231267932037   230913631171 +0.15 % │   275685961424   275903096266 -0.08 % │  721424  720880 +0.08 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│   coq-mathcomp-character │  276.42  275.13 +0.47 % │   766367056434   762832465191 +0.46 % │  1086733439366  1086875019240 -0.01 % │ 1143688 1142244 +0.13 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│         coq-fiat-parsers │  704.06  700.61 +0.49 % │  1950895020109  1938700556753 +0.63 % │  2974055646686  2973910848249 +0.00 % │ 3378628 3376620 +0.06 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│         coq-math-classes │  228.62  227.47 +0.51 % │   626481108311   624990542994 +0.24 % │   780713787090   780832986925 -0.02 % │  533480  532120 +0.26 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│                  coq-vst │ 3853.29 3833.01 +0.53 % │ 10717454939540 10657425284106 +0.56 % │ 14007728670257 14007469696424 +0.00 % │ 2228092 2227588 +0.02 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│               coq-sf-vfa │   26.56   26.42 +0.53 % │    72573328792    72412050020 +0.22 % │    94212802699    94368738572 -0.17 % │  537092  537168 -0.01 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│    coq-mathcomp-fingroup │   65.62   65.08 +0.83 % │   179771023970   178827292739 +0.53 % │   239795638550   239263004142 +0.22 % │  588928  588412 +0.09 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│   coq-mathcomp-odd-order │ 1443.08 1429.46 +0.95 % │  4010343917347  3971055820611 +0.99 % │  6663998632137  6661443108835 +0.04 % │ 1374596 1368920 +0.41 % │   0   0  +nan % │
├──────────────────────────┼─────────────────────────┼───────────────────────────────────────┼───────────────────────────────────────┼─────────────────────────┼─────────────────┤
│      coq-formal-topology │   37.98   37.57 +1.09 % │   101550100197   101540779000 +0.01 % │   126597350115   126737890258 -0.11 % │  482496  482284 +0.04 % │   0   0  +nan % │
└──────────────────────────┴─────────────────────────┴───────────────────────────────────────┴───────────────────────────────────────┴─────────────────────────┴─────────────────┘


Comment thread kernel/uGraph.ml
let rmap, csts = LSet.fold (fun u (rmap,csts) ->
let arcu = repr g u in
if LSet.mem arcu.univ kept then
LMap.add arcu.univ arcu.univ rmap, enforce_eq_level u arcu.univ csts

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.

Ok, we add u = u so that the LMap.find on kept canonical universes works.

Comment thread kernel/uGraph.ml
else
match LMap.find arcu.univ rmap with
| v -> rmap, enforce_eq_level u v csts
| exception Not_found -> LMap.add arcu.univ u rmap, csts)

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.

Here I'm a bit worried: rmap is in the process of being built, so we depend on the fold order somehow?

Otherwise, it looks to me that indeed, constraints_for will for sure not return constraints mentioning anything else than the kept universes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here I'm a bit worried: rmap is in the process of being built, so we depend on the fold order somehow?

The fold order impacts which kept universe is canonical when the ugraph considers a removed universe to be canonical.

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.

@SkySkimmer could you confirm or infirm my worry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What is the worry exactly? ie what can go wrong?

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.

Good, thanks for the explanation.

SkySkimmer pushed a commit to SkySkimmer/rocq that referenced this pull request May 23, 2018
@SkySkimmer SkySkimmer removed the needs: squashing Some commits should be squashed together. label May 23, 2018
@SkySkimmer

Copy link
Copy Markdown
Contributor Author

Squashed.

@gares

gares commented May 23, 2018

Copy link
Copy Markdown
Member

Maybe this is not the right place but I'd like to know the answer to the point raised by @JasonGross, that is also where I wanted to go with my example: understand if this minimization can be specified at the semantic level of the graph, and not at its syntactic level.

That is "having 1 syntactic predecessor" makes no sense, since the two graphs in my example are semantically equivalent but only in one case the node v is purged.
Intuitively v has to be purged (made = to x) if:

  • v has no successors (strict or weak, eg v is a node on the border of the graph)
  • x is the max of all the predecessors of v.
    If there is a node x with such property then v=x (v is collapsed to x).

Does this make sense?

@mattam82

mattam82 commented May 23, 2018 via email

Copy link
Copy Markdown
Member

@herbelin

Copy link
Copy Markdown
Member

@mattam82, @SkySkimmer:

I have a somewhat related minimization question. Minimization is currently done by joining universes different from Prop and Set. Would it be easy to instrument it so that it knows how to minimize using Prop for the universes which are not constrained below and using Set for the universes which are constrained only by Set below. This is in relation with #7369: in practice, there are two kinds of existential variables for universes, either Type where I did not mention the level, or ?[X] when it eventually happens that it has to be instantiated by some sort. In the latter case, Prop and Set should remain potential solutions and that would be useful for #7369 that minimization handles this case.

I tried to hack Universe.compute_lbound in this direction but that's working "too often" and it seems that what I fail to see is the meaning of uctx_univ_variables and uctx_univ_algebraic.

When a variable occurs in uctx_univ_variables or uctx_univ_algebraic, is there an implicit assumption that it should be higher than Set? According to UState.new_univ_variable it is only greater or equal to Set, so Set should in theory be a possible instance, but then, in minimization, Set seems to be forbidden as a possible solution for such a variable.

Conversely, if I'd like in the cases above that some given universe variable is allowed to be minimized to Set (or even to Prop using the variant of UState.new_univ_variable in #7369), should a specific information be added somewhere in the UState.t or is this information retrievable from the data already present?

Typical examples where this would be useful are the following:

Check fun b : bool => if b then bool else True.  (* works *)
Check fun b : bool => if b then True else bool.  (* fails *)

or

Check bool = True. (* works *)
Check True = bool. (* fails *)

Both failing examples would work and return the same sort as in the succeeding examples if we were able in #7369 to minimize the graph Set <= u for u allowed to be Set.

@gares

gares commented May 24, 2018

Copy link
Copy Markdown
Member

I don’t see how to do this properly without basically doing a transitive closure computation.

AFAICT (from the comments) this PR does the TC of the graph. Am I wrong? (otherwise my example is bogus).

@SkySkimmer

Copy link
Copy Markdown
Contributor Author

AFAICT (from the comments) this PR does the TC of the graph.

It stops at the first kept universe in any transitive chain.

@gares

gares commented May 25, 2018

Copy link
Copy Markdown
Member

OK. Anyway, is it true that if we perform/reason-on the TC closure of the graph then restriction/minimization is a semantic property and not a syntactic one?

I agree it is still an heuristic in the sense that one could be smarter and collapse more/less, but if we fix the criteria as in #7495 (comment) then: is the algorithm working at the semantic level?

@mattam82

Copy link
Copy Markdown
Member

Yes, it can be made a semantic property of the TC of the graph. Actually, it might be feasible, I did not experiment.

@mattam82

mattam82 commented Jun 4, 2018

Copy link
Copy Markdown
Member

@gares what do you think, shall we merge this cleanup? @SkySkimmer it seems the HoTT failure happens no more, as there's no overlay and it works on gitlab, right?
@herbelin could you open a separate issue about the treatment of Prop/Set please?

@SkySkimmer

Copy link
Copy Markdown
Contributor Author

@SkySkimmer it seems the HoTT failure happens no more, as there's no overlay and it works on gitlab, right?

Yes.

@herbelin

herbelin commented Jun 4, 2018

Copy link
Copy Markdown
Member

@herbelin could you open a separate issue about the treatment of Prop/Set please?

I shall maybe do at some time (I'm in workshop this week and my time is pretty limited). #7369 covers part of the state of my reflection otherwise.

@gares

gares commented Jun 4, 2018

Copy link
Copy Markdown
Member

The cleanup should be merged IMO.
I'm not competent enough to try out the TC thingy, so I hope someone else does.

@mattam82

mattam82 commented Jun 5, 2018

Copy link
Copy Markdown
Member

Thanks for the answers everyone, I'll merge.

@mattam82 mattam82 merged commit 3490e3c into rocq-prover:master Jun 5, 2018
mattam82 added a commit that referenced this pull request Jun 5, 2018
@mattam82

mattam82 commented Jun 5, 2018

Copy link
Copy Markdown
Member

@gares I'm not sure what you need to do about the overlay, just reminding you there was one for elpi

@SkySkimmer SkySkimmer deleted the fix-restrict branch June 5, 2018 10:47
@gares

gares commented Jun 6, 2018

Copy link
Copy Markdown
Member

It's fine, I'll eventually uncomment restriction in elpi, I should be able to update the branch we track in CI next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: fix This fixes a bug or incorrect documentation. part: universes The universe system. priority: high The priority for inclusion in the next release is high.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

universe restriction drops equations

5 participants