1#![no_std]
2
3pub use prusti_contracts_proc_macros::requires;
5
6pub use prusti_contracts_proc_macros::ensures;
8
9pub use prusti_contracts_proc_macros::after_expiry;
11
12pub use prusti_contracts_proc_macros::assert_on_expiry;
14
15pub use prusti_contracts_proc_macros::pure;
17
18pub use prusti_contracts_proc_macros::trusted;
20
21pub use prusti_contracts_proc_macros::verified;
23
24pub use prusti_contracts_proc_macros::invariant;
26
27pub use prusti_contracts_proc_macros::body_invariant;
29
30pub use prusti_contracts_proc_macros::prusti_assert;
32
33pub use prusti_contracts_proc_macros::prusti_assume;
35
36pub use prusti_contracts_proc_macros::prusti_refute;
38
39pub use prusti_contracts_proc_macros::refine_trait_spec;
41
42pub use prusti_contracts_proc_macros::extern_spec;
44
45pub use prusti_contracts_proc_macros::predicate;
48
49pub use prusti_contracts_proc_macros::model;
51
52pub use prusti_contracts_proc_macros::refine_spec;
55
56pub use prusti_contracts_proc_macros::ghost;
59
60pub use prusti_contracts_proc_macros::print_counterexample;
62
63pub use prusti_contracts_proc_macros::terminates;
65
66pub use prusti_contracts_proc_macros::body_variant;
68
69#[cfg(not(feature = "prusti"))]
70mod private {
71 use core::marker::PhantomData;
72
73 #[macro_export]
79 macro_rules! closure {
80 ($condition:ident ($($args:tt)*), $($tail:tt)*) => {
81 $crate::closure!($($tail)*)
82 };
83 ($($tail:tt)*) => {
84 $($tail)*
85 };
86 }
87
88 #[macro_export]
89 macro_rules! prusti_assert_eq {
90 ($left:expr, $right:expr $(,)?) => {};
91 }
92
93 #[macro_export]
94 macro_rules! prusti_assert_ne {
95 ($left:expr, $right:expr $(,)?) => {};
96 }
97
98 #[non_exhaustive]
100 #[derive(PartialEq, Eq, Copy, Clone)]
101 pub struct Seq<T> {
102 _phantom: PhantomData<T>,
103 }
104
105 #[non_exhaustive]
107 #[derive(PartialEq, Eq, Copy, Clone)]
108 pub struct Map<K, V> {
109 _key_phantom: PhantomData<K>,
110 _val_phantom: PhantomData<V>,
111 }
112
113 pub struct Int(());
116
117 #[non_exhaustive]
118 #[derive(PartialEq, Eq, Copy, Clone)]
119 pub struct Ghost<T> {
120 _phantom: PhantomData<T>,
121 }
122}
123
124#[cfg(feature = "prusti")]
125pub mod core_spec;
126
127#[cfg(feature = "prusti")]
128mod private {
129 use core::{marker::PhantomData, ops::*};
130
131 pub use prusti_contracts_proc_macros::{closure, pure, trusted};
133
134 pub fn prusti_set_union_active_field<T>(_arg: T) {
135 unreachable!();
136 }
137
138 #[pure]
139 pub fn prusti_terminates_trusted() -> Int {
140 Int::new(1)
141 }
142
143 #[derive(Copy, Clone, PartialEq, Eq)]
146 pub struct Int(());
147
148 impl Int {
149 pub fn new(_: i64) -> Self {
150 panic!()
151 }
152
153 pub fn new_usize(_: usize) -> Self {
154 panic!()
155 }
156 }
157
158 macro_rules! __int_dummy_trait_impls__ {
159 ($($trait:ident $fun:ident),*) => {$(
160 impl core::ops::$trait for Int {
161 type Output = Self;
162 fn $fun(self, _other: Self) -> Self {
163 panic!()
164 }
165 }
166 )*}
167 }
168
169 __int_dummy_trait_impls__!(Add add, Sub sub, Mul mul, Div div, Rem rem);
170
171 #[macro_export]
172 macro_rules! prusti_assert_eq {
173 ($left:expr, $right:expr $(,)?) => {
174 $crate::prusti_assert!($crate::snapshot_equality($left, $right))
175 };
176 }
177
178 #[macro_export]
179 macro_rules! prusti_assert_ne {
180 ($left:expr, $right:expr $(,)?) => {
181 $crate::prusti_assert!(!$crate::snapshot_equality($left, $right))
182 };
183 }
184
185 impl Neg for Int {
186 type Output = Self;
187 fn neg(self) -> Self {
188 panic!()
189 }
190 }
191
192 impl PartialOrd for Int {
193 fn partial_cmp(&self, _other: &Self) -> Option<core::cmp::Ordering> {
194 panic!()
195 }
196 }
197 impl Ord for Int {
198 fn cmp(&self, _other: &Self) -> core::cmp::Ordering {
199 panic!()
200 }
201 }
202
203 #[non_exhaustive]
205 #[derive(PartialEq, Eq, Copy, Clone)]
206 pub struct Seq<T: Copy> {
207 _phantom: PhantomData<T>,
208 }
209
210 impl<T: Copy> Seq<T> {
211 pub fn empty() -> Self {
212 panic!()
213 }
214 pub fn single(_: T) -> Self {
215 panic!()
216 }
217 pub fn concat(self, _: Self) -> Self {
218 panic!()
219 }
220 pub fn lookup(self, _index: usize) -> T {
221 panic!()
222 }
223 pub fn len(self) -> Int {
224 panic!()
225 }
226 }
227
228 #[macro_export]
229 macro_rules! seq {
230 ($val:expr) => {
231 $crate::Seq::single($val)
232 };
233 ($($val:expr),*) => {
234 $crate::Seq::empty()
235 $(
236 .concat(seq![$val])
237 )*
238 };
239 }
240
241 impl<T: Copy> Index<usize> for Seq<T> {
242 type Output = T;
243 fn index(&self, _: usize) -> &T {
244 panic!()
245 }
246 }
247
248 impl<T: Copy> Index<Int> for Seq<T> {
249 type Output = T;
250 fn index(&self, _: Int) -> &T {
251 panic!()
252 }
253 }
254
255 #[non_exhaustive]
257 #[derive(PartialEq, Eq, Copy, Clone)]
258 pub struct Map<K, V> {
259 _key_phantom: PhantomData<K>,
260 _val_phantom: PhantomData<V>,
261 }
262
263 impl<K, V> Map<K, V> {
264 pub fn empty() -> Self {
265 panic!()
266 }
267 pub fn insert(self, _key: K, _val: V) -> Self {
268 panic!()
269 }
270 pub fn delete(self, _key: K) -> Self {
271 panic!()
272 }
273 pub fn len(self) -> Int {
274 panic!()
275 }
276 pub fn lookup(self, _key: K) -> V {
277 panic!()
278 }
279 pub fn contains(self, _key: K) -> bool {
280 panic!()
281 }
282 }
283
284 #[macro_export]
285 macro_rules! map {
286 ($($key:expr => $val:expr),*) => {
287 map!($crate::Map::empty(), $($key => $val),*)
288 };
289 ($existing_map:expr, $($key:expr => $val:expr),*) => {
290 $existing_map
291 $(
292 .insert($key, $val)
293 )*
294 };
295 }
296
297 impl<K, V> core::ops::Index<K> for Map<K, V> {
298 type Output = V;
299 fn index(&self, _key: K) -> &V {
300 panic!()
301 }
302 }
303
304 #[non_exhaustive]
305 #[derive(PartialEq, Eq, Copy, Clone)]
306 pub struct Ghost<T> {
307 _phantom: PhantomData<T>,
308 }
309
310 impl<T> Ghost<T> {
311 pub fn new(_: T) -> Self {
312 panic!()
313 }
314 }
315
316 impl<T> Deref for Ghost<T> {
317 type Target = T;
318 fn deref(&self) -> &T {
319 panic!()
320 }
321 }
322
323 impl<T> DerefMut for Ghost<T> {
324 fn deref_mut(&mut self) -> &mut T {
325 panic!()
326 }
327 }
328}
329
330pub fn before_expiry<T>(arg: T) -> T {
333 arg
334}
335
336pub fn old<T>(arg: T) -> T {
339 arg
340}
341
342pub fn forall<T, F>(_trigger_set: T, _closure: F) -> bool {
346 true
347}
348
349pub fn exists<T, F>(_trigger_set: T, _closure: F) -> bool {
353 true
354}
355
356pub fn snap<T>(_x: &T) -> T {
359 unimplemented!()
360}
361
362pub fn snapshot_equality<T>(_l: T, _r: T) -> bool {
368 true
369}
370
371pub use private::*;