WellFounded

Trait WellFounded 

Source
pub trait WellFounded: Sized {
    // Required methods
    fn well_founded_relation(self, other: Self) -> bool;
    fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int;
}
Expand description

Instances of this trait are types which are allowed as variants of recursive definitions.

Required Methods§

Source

fn well_founded_relation(self, other: Self) -> bool

Relation used to specify well-foundedness.

Source

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

Being well-founded means that there is no infinitely decreasing sequence.

If you can map your type to another that already implements WellFounded (and the mapping preserves well_founded_relation), this lemma is quite easy to prove:

struct MyInt(Int);
impl WellFounded for MyInt {
    #[logic(open, inline)]
    fn well_founded_relation(self, other: Self) -> bool {
        Int::well_founded_relation(self.0, other.0)
    }

    #[logic]
    #[ensures(!Self::well_founded_relation(s[result], s[result + 1]))]
    fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int {
        Int::no_infinite_decreasing_sequence(|i| s[i].0)
    }
}

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl WellFounded for i8

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for i16

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for i32

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for i64

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for i128

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for isize

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for u8

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for u16

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for u32

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for u64

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for u128

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for ()

Source§

fn well_founded_relation(self, _: Self) -> bool

(open, inline)

false

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl WellFounded for usize

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

self > other

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0> WellFounded for (T0,)
where T0: WellFounded,

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1> WellFounded for (T0, T1)
where T0: WellFounded, T1: WellFounded,

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1, T2> WellFounded for (T0, T1, T2)
where T0: WellFounded, T1: WellFounded, T2: WellFounded,

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1, T2, T3> WellFounded for (T0, T1, T2, T3)

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1, T2, T3, T4> WellFounded for (T0, T1, T2, T3, T4)

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1, T2, T3, T4, T5> WellFounded for (T0, T1, T2, T3, T4, T5)

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1, T2, T3, T4, T5, T6> WellFounded for (T0, T1, T2, T3, T4, T5, T6)

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7> WellFounded for (T0, T1, T2, T3, T4, T5, T6, T7)

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

$res

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T: WellFounded> WellFounded for &T

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

T::well_founded_relation(*self, *other)

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Source§

impl<T: WellFounded> WellFounded for Box<T>

Source§

fn well_founded_relation(self, other: Self) -> bool

(open, inline)

T::well_founded_relation(*self, *other)

Source§

fn no_infinite_decreasing_sequence(s: Mapping<Int, Self>) -> Int

ensures

result >= 0

ensures

!Self::well_founded_relation(s[result], s[result + 1])

Implementors§