Draft: use SProp for well-formedness condition in Pmap and gmap
Proof of concept for #85. I'm not sure the reduction behavior is actually what we want, but I was able to get a lookup on a concrete map to reduce using only simpl
(ordinarily you can get this to work with vm_compute
, which breaks the opacity of proofs).
Merge request reports
Activity
Another fun one, insert the sequence 0..n into an empty map, insert the sequence n..0 into an empty map, and then try to prove an equality between the two resulting maps using reflexivity. That should be
O(n log n)
for the insertions, andO(n)
for the equality checking.Edited by Robbert Krebbers@tchajed @robbertkrebbers it has been a while since we saw any activity in this MR. Do either of you have plans to further work on this? Looks to me like it is currently waiting for a more in-depth review, so marking as such.
added S-waiting-for-review label
mentioned in merge request !266 (merged)
I finally had time to take a proper look at this. I have done a couple of things, which can be found at https://gitlab.mpi-sws.org/iris/stdpp/-/tree/tchajed/stdpp-sprop-gmap
- I noticed that the complexity of the map operations was no longer
O(log-n)
. The problem is that each time you call an operation likepartial_alter
it would reestablish thatPmap_wf
holds, giving rise toO(n)
, complexity due to the check. Why this happened was very subtle. You use functions likeis_true_bind
to construct thewf
proof. These functions have the Boolean as an implicit argument, and hencevm_compute
evaluates it eagerly. Instead, in my branch, I state lemmas likePpartial_alter_wf
using an explicitSIs_true
, making sure that the proof is properly opaque. - Since the above problem, I removed the
bind
andfmap
combinators. - I ported
coPset
andQp
to useSProp
. The change forQp
is rather invasive, but it does not change the API.
Edited by Robbert Krebbers- I noticed that the complexity of the map operations was no longer
Let's see what @tchajed thinks.
I've had a quick look at https://gitlab.mpi-sws.org/iris/stdpp/-/tree/tchajed/stdpp-sprop-gmap and found the following problems when using Coq 8.10.2:
- I need to add
Global Set Allow StrictProp.
in sprop.v - The new tests fail as
simpl
does not seem to do anything. I.e. the firstShow.
prints{[3 := false; 2 := true]} = {[2 := true; 3 := false]}
and the secondShow.
prints{[3 := false; 2 := true]} !! 2 = Some true
.
- I need to add
I need to add
Global Set Allow StrictProp.
in sprop.vAh, they seem to have changed that default? In 8.13 it seems to be enabled by default. I guess we can add that so as to make 8.10 happy too.
The new tests fail as
simpl
does not seem to do anything.I am afraid that there's nothing to do about that. There's two problems:
- There's no way of telling
simpl
that it should only reduce a gmap whenever its entirely concrete. You surely don't wantsimpl
to reduce anything involving variables. For example,{[ 1 := 1; 2 := 2 ]} ∪ m
is not going to anything meaningful. - The
simpl
tactic will not turncomplex_sprop_proof : SUnit
into juststt : SUnit
. So even if we were to enablesimpl
for the gmap operations, you end up with large proofs in the end (unless you project out). The alternative is to make the proofs transparent, but that destroys the log-n complexity of the map operations.
- There's no way of telling
What about https://gitlab.mpi-sws.org/iris/stdpp/-/blob/tchajed/stdpp-sprop-gmap/tests/gmap.v#L56 and https://gitlab.mpi-sws.org/iris/stdpp/-/blob/tchajed/stdpp-sprop-gmap/tests/gmap.v#L56? Or am I looking at the wrong branch?
It seems like this branch breaks Iris: https://gitlab.mpi-sws.org/iris/refinedc/-/jobs/137510
[ERROR] The compilation of coq-iris failed at "/builds/iris/refinedc/_opam/ocaml-base-compiler.4.07.1/.opam-switch/build/coq-iris.dev.2021-07-26.8.eb05e835/./make-package iris -j2". #=== ERROR while compiling coq-iris.dev.2021-07-26.8.eb05e835 =================# # context 2.0.8 | linux/x86_64 | ocaml-base-compiler.4.07.1 | git+https://gitlab.mpi-sws.org/iris/opam.git # path /builds/iris/refinedc/_opam/ocaml-base-compiler.4.07.1/.opam-switch/build/coq-iris.dev.2021-07-26.8.eb05e835 # command /builds/iris/refinedc/_opam/ocaml-base-compiler.4.07.1/.opam-switch/build/coq-iris.dev.2021-07-26.8.eb05e835/./make-package iris -j2 # exit-code 2 # env-file /builds/iris/refinedc/_opam/log/coq-iris-405-736596.env # output-file /builds/iris/refinedc/_opam/log/coq-iris-405-736596.out ### output ### # [...] # invGS0 : invGS Σ # na_invG0 : na_invG Σ # p : na_inv_pool_name # E : coPset # The term "E" has type "coPset" while it is expected to have type # "coPset_raw".
Edited by Michael SammlerWhich file is that failure in?
EDIT: Ah,
na_invariants.v
.Edited by Ralf JungThe
algebra
version has precedence up untilFrom iris.base_logic.lib Require Export invariants.
.That
invariants
file doesFrom stdpp Require Export namespaces.
which means when importing it, the std++
CoPset
takes precedence.This is exactly why using
Export
is bad. (But I know the alternatives are bad, too, in different ways.)I added an
_
.@msammler Iris compiles against this branch now.
This doc sounds to me like that axiom is unsound? Or how else should I interpret "The special reduction rule of UIP combined with an impredicative sort breaks termination of reduction"?
mentioned in commit refinedc@82c8290f
mentioned in commit refinedc@1f49292f
@robbertkrebbers I'd be happy if you took this over! I had fun figuring out the initial implementation but I think this feature is a bit too subtle for me at the moment. Once I've seen a productive SProp use case then I'll be more sold but for now I don't really get it.
It ensures that more equalities hold definitionally, and can thus be proved by
reflexivity
or even by conversion as part of unification.For example
1/4 + 3/4 = 1
, or{[ 1 := 1; 2 := 2 ]} = {[ 2 := 2; 1 := 1 ]}
, or{[ 1 ]} ∖ {[ 1 ]} = ∅
can be proved using a merereflexivity
with this MR. Also, if you have a goal that involves, say1/4 + 3/4
, then you can just apply a lemma involving1
because both are convertible.Edited by Robbert Krebbers
mentioned in merge request !309 (merged)
Closing in favor of !309 (merged)