|
| 1 | +use std::marker::PhantomData; |
| 2 | + |
| 3 | +use crate::{ghost, open, trusted, DeepModel, OrdLogic}; |
| 4 | +use num_rational::BigRational; |
| 5 | +use std::cmp::Ordering; |
| 6 | + |
| 7 | +#[cfg_attr(creusot, creusot::builtins = "prelude.Real.real")] |
| 8 | +#[trusted] |
| 9 | +pub struct Real(PhantomData<*mut ()>); |
| 10 | + |
| 11 | +#[cfg(creusot)] |
| 12 | +impl DeepModel for BigRational { |
| 13 | + type DeepModelTy = Real; |
| 14 | + |
| 15 | + #[ghost] |
| 16 | + #[open(self)] |
| 17 | + #[trusted] |
| 18 | + fn deep_model(self) -> Self::DeepModelTy { |
| 19 | + absurd |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +impl OrdLogic for Real { |
| 24 | + #[ghost] |
| 25 | + #[open] |
| 26 | + fn cmp_log(self, o: Self) -> Ordering { |
| 27 | + if self < o { |
| 28 | + Ordering::Less |
| 29 | + } else if self == o { |
| 30 | + Ordering::Equal |
| 31 | + } else { |
| 32 | + Ordering::Greater |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + #[trusted] |
| 37 | + #[open] |
| 38 | + #[ghost] |
| 39 | + #[creusot::builtins = "prelude.Real.(<=)"] |
| 40 | + fn le_log(self, _: Self) -> bool { |
| 41 | + true |
| 42 | + } |
| 43 | + |
| 44 | + #[trusted] |
| 45 | + #[open] |
| 46 | + #[ghost] |
| 47 | + #[creusot::builtins = "prelude.Real.(<)"] |
| 48 | + fn lt_log(self, _: Self) -> bool { |
| 49 | + true |
| 50 | + } |
| 51 | + |
| 52 | + #[trusted] |
| 53 | + #[open] |
| 54 | + #[ghost] |
| 55 | + #[creusot::builtins = "prelude.Real.(>=)"] |
| 56 | + fn ge_log(self, _: Self) -> bool { |
| 57 | + true |
| 58 | + } |
| 59 | + |
| 60 | + #[trusted] |
| 61 | + #[open] |
| 62 | + #[ghost] |
| 63 | + #[creusot::builtins = "prelude.Real.(>)"] |
| 64 | + fn gt_log(self, _: Self) -> bool { |
| 65 | + true |
| 66 | + } |
| 67 | + |
| 68 | + #[ghost] |
| 69 | + #[open(self)] |
| 70 | + fn cmp_le_log(_: Self, _: Self) { |
| 71 | + () |
| 72 | + } |
| 73 | + |
| 74 | + #[ghost] |
| 75 | + #[open(self)] |
| 76 | + fn cmp_lt_log(_: Self, _: Self) { |
| 77 | + () |
| 78 | + } |
| 79 | + |
| 80 | + #[ghost] |
| 81 | + #[open(self)] |
| 82 | + fn cmp_ge_log(_: Self, _: Self) { |
| 83 | + () |
| 84 | + } |
| 85 | + |
| 86 | + #[ghost] |
| 87 | + #[open(self)] |
| 88 | + fn cmp_gt_log(_: Self, _: Self) { |
| 89 | + () |
| 90 | + } |
| 91 | + |
| 92 | + #[ghost] |
| 93 | + #[open(self)] |
| 94 | + fn refl(_: Self) { |
| 95 | + () |
| 96 | + } |
| 97 | + |
| 98 | + #[ghost] |
| 99 | + #[open(self)] |
| 100 | + fn trans(_: Self, _: Self, _: Self, _: Ordering) { |
| 101 | + () |
| 102 | + } |
| 103 | + |
| 104 | + #[ghost] |
| 105 | + #[open(self)] |
| 106 | + fn antisym1(_: Self, _: Self) { |
| 107 | + () |
| 108 | + } |
| 109 | + |
| 110 | + #[ghost] |
| 111 | + #[open(self)] |
| 112 | + fn antisym2(_: Self, _: Self) { |
| 113 | + () |
| 114 | + } |
| 115 | + |
| 116 | + #[ghost] |
| 117 | + #[open(self)] |
| 118 | + fn eq_cmp(_: Self, _: Self) { |
| 119 | + () |
| 120 | + } |
| 121 | +} |
0 commit comments