-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmath.rs
More file actions
89 lines (77 loc) · 1.9 KB
/
Copy pathmath.rs
File metadata and controls
89 lines (77 loc) · 1.9 KB
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
88
89
// Shared atom-building macros for spec predicates.
//
// These macros expand into Verus spec code at the call site, but their
// definitions are plain Rust so they live outside any `verus!{}` block
// to keep rustc's macro-usage tracking working normally.
/// `and!(pred1, pred2, ...)` — pointwise conjunction over a state.
#[macro_export]
macro_rules! and {
($($tokens:tt)+) => {
closure_to_fn_spec(|s| {
$crate::and_internal!(s, $($tokens)+)
})
};
}
#[macro_export]
macro_rules! and_internal {
($s:expr, $head:expr) => {
$head($s)
};
($s:expr, $head:expr, $($tail:tt)+) => {
$crate::and_internal!($s, $head) && $crate::and_internal!($s, $($tail)+)
};
}
/// `or!(pred1, pred2, ...)` — pointwise disjunction over a state.
#[macro_export]
macro_rules! or {
($($tokens:tt)+) => {
closure_to_fn_spec(|s| {
$crate::or_internal!(s, $($tokens)+)
})
};
}
#[macro_export]
macro_rules! or_internal {
($s:expr, $head:expr) => {
$head($s)
};
($s:expr, $head:expr, $($tail:tt)+) => {
$crate::or_internal!($s, $head) || $crate::or_internal!($s, $($tail)+)
};
}
/// `not!(pred)` — pointwise negation over a state.
#[macro_export]
macro_rules! not {
( $pred:expr ) => {
closure_to_fn_spec(|s| {
! $pred(s)
})
};
}
// Hacky workaround for type conversion bug:
// error[E0605]: non-primitive cast: `{integer}` as `builtin::nat`
#[macro_export]
macro_rules! nat0 {
() => { spec_literal_nat("0") };
}
#[macro_export]
macro_rules! nat1 {
() => { spec_literal_nat("1") };
}
#[macro_export]
macro_rules! int0 {
() => { spec_literal_int("0") };
}
#[macro_export]
macro_rules! int1 {
() => { spec_literal_int("1") };
}
pub use and;
pub use and_internal;
pub use or;
pub use or_internal;
pub use not;
pub use nat0;
pub use nat1;
pub use int0;
pub use int1;