1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use crate::{logic::Mapping, prelude::*};
use core::marker::PhantomData;
/// A (possibly infinite) set type.
#[opaque]
#[builtin("set.Set.set")]
pub struct Set<T: ?Sized>(PhantomData<T>);
impl<T: ?Sized> Set<T> {
/// The empty set.
#[logic]
#[builtin("set.Set.empty", ascription)]
pub fn empty() -> Self {
dead
}
/// Build a set from a predicate, given as a `Mapping`.
#[logic]
#[builtin("identity")]
pub fn from_predicate(_: Mapping<T, bool>) -> Self {
dead
}
/// Returns `true` if `e` is in the set.
#[logic(open, inline)]
pub fn contains(self, e: T) -> bool {
Self::mem(e, self)
}
/// [`Self::contains`], but with the order of arguments flipped.
///
/// This is how the function is defined in why3.
#[doc(hidden)]
#[logic]
#[builtin("set.Set.mem")]
pub fn mem(_: T, _: Self) -> bool {
dead
}
/// Returns a new set, where `e` has been added if it was not present.
#[logic(open, inline)]
pub fn insert(self, e: T) -> Self {
Self::add(e, self)
}
/// [`Self::insert`], but with the order of arguments flipped.
///
/// This is how the function is defined in why3.
#[doc(hidden)]
#[logic]
#[builtin("set.Set.add")]
pub fn add(_: T, _: Self) -> Self {
dead
}
/// Returns `true` if the set contains no elements.
#[logic]
#[builtin("set.Set.is_empty")]
pub fn is_empty(self) -> bool {
dead
}
/// Returns a new set, where `e` is no longer present.
#[logic(open, inline)]
pub fn remove(self, a: T) -> Self {
Self::rem(a, self)
}
/// [`Self::remove`], but with the order of arguments flipped.
///
/// This is how the function is defined in why3.
#[doc(hidden)]
#[logic]
#[builtin("set.Set.remove")]
pub fn rem(_: T, _: Self) -> Self {
dead
}
/// Returns a new set, which is the union of `self` and `other`.
///
/// An element is in the result if it is in `self` _or_ if it is in `other`.
#[logic]
#[builtin("set.Set.union")]
pub fn union(self, _: Self) -> Self {
dead
}
}