Add model for vstd Set and prove its axioms #1426
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR proves the set axioms and adds a fold function for finite sets (which is used to define cardinality) with associated lemmas.
The way things are bootstrapped is as follows:
fold
on finite sets by porting Isabelle/HOL's definitions and lemmas for itself.fold(|a, b: nat| b + 1, 0)
I'm not sure about where the
fold
module should go. The current place (inline inset.rs
) probably isn't it. But it needs to be a submodule ofset
to see the bodies ofclosed
functions and the non-public items. We could moveset.rs
toset/mod.rs
and then haveset/fold.rs
, which wouldn't break any imports ofvstd::set
. But arguablyset_lib.rs
should then also live in theset
directory, which would be a breaking change. How should I best handle this?Some miscellaneous notes:
fold
for sets, which I replaced with the new oneself.choose()
which makes reasoning about it very hardtokens.rs
can now be proved (I didn't try)if s == set![] { z } else { f(s.choose(), fold(s.remove(s.choose())), f, z) }
) is hard to reason about because the induction hypothesis is useless. The elements ofs.remove(s.choose())
might be folded in a completely different order than those ofs
.@tjhance I added you as a reviewer since
tokens.rs
seems to be the only current user offold
(within Verus/vstd)By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.