Skip to main content

FixWith

Struct FixWith 

Source
pub struct FixWith<const LIMIT: usize, Body, Param>(pub Body, pub Param);
Expand description

Bounded fixpoint combinator for parameterized recursive formats.

Param is the starting parameter for the recursive Body. Context-free recursive formats use Param = ().

Tuple Fields§

§0: Body§1: Param

Implementations§

Source§

impl<const LIMIT: usize, Body, Param> FixWith<LIMIT, Body, Param>
where Body: SpecRecBody, Param: DeepView<V = Body::Param>,

Source

pub open spec fn byte_len_gas( body: &Body, gas: nat, param: Body::Param, v: Body::T, ) -> nat

{ body.spec_body(param, Self::specs_callback(&body, gas)).byte_len(v) }
Source

pub open spec fn consistent_gas( body: &Body, gas: nat, param: Body::Param, v: Body::T, ) -> bool

{ body.spec_body(param, Self::specs_callback(&body, gas)).consistent(v) }
Source

pub open spec fn spec_parse_gas( body: &Body, gas: nat, param: Body::Param, input: Seq<u8>, ) -> Option<(int, Body::T)>

{ body.spec_body(param, Self::specs_callback(&body, gas)).spec_parse(input) }
Source

pub open spec fn spec_serialize_gas( body: &Body, gas: nat, param: Body::Param, v: Body::T, ) -> Seq<u8>

{ body.spec_body(param, Self::specs_callback(&body, gas)).spec_serialize(v) }
Source

pub open spec fn spec_serialize_dps_gas( body: &Body, gas: nat, param: Body::Param, v: Body::T, obuf: Seq<u8>, ) -> Seq<u8>

{ body.spec_body(param, Self::specs_callback(&body, gas)).spec_serialize_dps(v, obuf) }
Source

pub open spec fn spec_parse_callback( body: &Body, gas: nat, param: Body::Param, ) -> ParserFnSpec<Body::T>

{
    |ibuf: Seq<u8>| {
        if gas > 0 {
            Self::spec_parse_gas(body, (gas - 1) as nat, param, ibuf)
        } else {
            None
        }
    }
}
Source

pub open spec fn consistent_callback( body: &Body, gas: nat, param: Body::Param, ) -> PredFnSpec<Body::T>

{
    |vv: Body::T| {
        if gas > 0 {
            Self::consistent_gas(body, (gas - 1) as nat, param, vv)
        } else {
            false
        }
    }
}
Source

pub open spec fn byte_len_callback( body: &Body, gas: nat, param: Body::Param, ) -> ByteLenFnSpec<Body::T>

{
    |vv: Body::T| {
        if gas > 0 { Self::byte_len_gas(body, (gas - 1) as nat, param, vv) } else { 0 }
    }
}
Source

pub open spec fn spec_serialize_callback( body: &Body, gas: nat, param: Body::Param, ) -> SerializerFnSpec<Body::T>

{
    |vv: Body::T| {
        if gas > 0 {
            Self::spec_serialize_gas(body, (gas - 1) as nat, param, vv)
        } else {
            Seq::empty()
        }
    }
}
Source

pub open spec fn spec_serialize_dps_callback( body: &Body, gas: nat, param: Body::Param, ) -> SerializerDPSFnSpec<Body::T>

{
    |vv: Body::T, obuf: Seq<u8>| {
        if gas > 0 {
            Self::spec_serialize_dps_gas(body, (gas - 1) as nat, param, vv, obuf)
        } else {
            obuf
        }
    }
}
Source

pub open spec fn specs_callback( body: &Body, gas: nat, ) -> ParamRecSpecs<Body::Param, Body::T>

{
    |param: Body::Param| (
        Self::consistent_callback(&body, gas, param),
        Self::byte_len_callback(&body, gas, param),
        Self::spec_parse_callback(&body, gas, param),
        Self::spec_serialize_callback(&body, gas, param),
        Self::spec_serialize_dps_callback(&body, gas, param),
    )
}

Bundled callbacks used when unfolding one recursive level.

Source§

impl<const LIMIT: usize, Body, Param> FixWith<LIMIT, Body, Param>
where Body: SafeParserRecBody, Body::Body: SafeParser, Param: DeepView<V = Body::Param>,

Source

pub proof fn lemma_specs_callback_safe_inv(&self, gas: nat, param: Body::Param)

ensures
Self::specs_callback(&self.0, gas)(param).safe_inv(),
Source§

impl<const LIMIT: usize, Body, Param> FixWith<LIMIT, Body, Param>
where Body: SoundParserRecBody, Body::Body: SoundParser, Param: DeepView<V = Body::Param>,

Source

pub proof fn sound_parser_by_induction( &self, gas: nat, param: Body::Param, input: Seq<u8>, n: int, v: Body::T, )

ensures
Self::spec_parse_gas(&self.0, gas, param, input) == Some((n, v))
    ==> {
        &&& Self::consistent_gas(&self.0, gas, param, v)
        &&& Self::byte_len_gas(&self.0, gas, param, v) == n

    },

Inductive proof that spec_parse_gas satisfies sound_parser.

Source§

impl<const LIMIT: usize, Body, Param> FixWith<LIMIT, Body, Param>
where Body: ProductiveRecBody, Body::Body: Productive, Param: DeepView<V = Body::Param>,

Source

pub proof fn lemma_specs_callback_productive_inv(&self, gas: nat, param: Body::Param)

ensures
Self::specs_callback(&self.0, gas)(param).productive_inv(),

Establishes productivity for one bundled recursive callback.

Trait Implementations§

Source§

impl<const LIMIT: usize, Body: Clone, Param: Clone> Clone for FixWith<LIMIT, Body, Param>

Source§

exec fn clone(&self) -> cloned : Self

ensures
call_ensures(Body::clone, (&self.0,), cloned.0),
call_ensures(Param::clone, (&self.1,), cloned.1),
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const LIMIT: usize, Body, Param> Consistency for FixWith<LIMIT, Body, Param>
where Body: SpecRecBody, Param: DeepView<V = Body::Param>,

Source§

open spec fn consistent(&self, v: Self::Val) -> bool

{ Self::consistent_gas(&self.0, LIMIT as nat, self.1.deep_view(), v) }
Source§

type Val = <Body as SpecRecBody>::T

The type of values whose consistency is being checked.
Source§

impl<const LIMIT: usize, Body, Param> EquivSerializers for FixWith<LIMIT, Body, Param>
where Body: EquivSerializersGeneralRecBody, Body::Body: EquivSerializersGeneral, Param: DeepView<V = Body::Param>,

Source§

impl<const LIMIT: usize, Body, Param> EquivSerializersGeneral for FixWith<LIMIT, Body, Param>
where Body: EquivSerializersGeneralRecBody, Body::Body: EquivSerializersGeneral, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)

Source§

fn equiv_general_inv(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param> GoodSerializer for FixWith<LIMIT, Body, Param>
where Body: GoodSerializerRecBody, Body::Body: GoodSerializer, Param: DeepView<V = Body::Param>,

Source§

impl<const N: usize, Body, Param> LeafNonMalleable for FixWith<N, Body, Param>
where Param: DeepView<V = Body::Param>, Body: StrictRecBody, Body::Body: StrictCombinator,

Source§

proof fn nonmal_leaf_inv(&self)

Source§

impl<const LIMIT: usize, Body, Param> NoLookAhead for FixWith<LIMIT, Body, Param>
where Body: NoLookAheadRecBody, Body::Body: NoLookAhead, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)

Source§

fn no_lookahead_inv(&self) -> bool

Source§

fn corollary_non_extensible(&self, i1: Seq<u8>, i2: Seq<u8>)

Source§

impl<const LIMIT: usize, Body, Param> NonMalleable for FixWith<LIMIT, Body, Param>
where Body: NonMalleableRecBody, Body::Body: NonMalleable + SafeParser + SoundParser, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)

Source§

fn nonmal_inv(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param> NonTailFmt for FixWith<LIMIT, Body, Param>
where Body: NonTailFmtRecBody, Body::Body: NonTailFmt, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_serialize_dps_prepend(&self, v: Self::SValue, obuf: Seq<u8>)

Source§

proof fn lemma_serialize_dps_len(&self, v: Self::SValue, obuf: Seq<u8>)

Source§

fn serialize_dps_inv(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param, I> Parser<I> for FixWith<LIMIT, Body, Param>
where I: InputBuf, Param: DeepView<V = Body::Param>, Body: ParserRecBody<I, EP = Param> + ProductiveRecBody, Body::Body: Productive,

Source§

exec fn parse(&self, ibuf: &I) -> r : PResult<Self::PT>

Source§

type PT = <Body as ParserRecBody<I>>::O

Executable value returned by this parser.
Source§

fn exec_inv(&self) -> bool

Source§

impl<T, const LIMIT: usize, Body, Param> Prepare<T> for FixWith<LIMIT, Body, Param>
where T: DeepView<V = Body::T>, Param: DeepView<V = Body::Param>, Body: PrepareRecBody<T, EP = Param>,

Source§

open spec fn exec_inv(&self) -> bool

{ true }
Source§

exec fn prepare(&self, v: &T) -> checked : Result<usize, PreSerializeError>

Source§

impl<const LIMIT: usize, Body, Param> Productive for FixWith<LIMIT, Body, Param>
where Body: ProductiveRecBody, Body::Body: Productive, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_productive(&self, ibuf: Seq<u8>)

Source§

fn productive_inv(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param> SPRoundTripDps for FixWith<LIMIT, Body, Param>
where Body: SPRoundTripDpsRecBody + NonTailFmtRecBody, Body::Body: SPRoundTripDps + NonTailFmt, Param: DeepView<V = Body::Param>,

Source§

proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)

Source§

fn unambiguous(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param> SafeParser for FixWith<LIMIT, Body, Param>
where Body: SafeParserRecBody, Body::Body: SafeParser, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_parse_safe(&self, ibuf: Seq<u8>)

Source§

fn safe_inv(&self) -> bool

Source§

impl<Output: OutputBuf, T, const LIMIT: usize, Body, Param> Serializer<Output, T> for FixWith<LIMIT, Body, Param>
where T: DeepView<V = Body::T>, Param: DeepView<V = Body::Param>, Body: SerializerRecBody<Output, T, EP = Param>,

Source§

exec fn serialize_into(&self, v: &T, obuf: &mut Output)

Source§

fn exec_inv(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param> SoundParser for FixWith<LIMIT, Body, Param>
where Body: SoundParserRecBody, Body::Body: SoundParser, Param: DeepView<V = Body::Param>,

Source§

proof fn lemma_parse_sound_consumption(&self, ibuf: Seq<u8>)

Source§

proof fn lemma_parse_sound_value(&self, ibuf: Seq<u8>)

Source§

fn sound_inv(&self) -> bool

Source§

impl<const LIMIT: usize, Body, Param> SpecByteLen for FixWith<LIMIT, Body, Param>
where Body: SpecRecBody, Param: DeepView<V = Body::Param>,

Source§

open spec fn byte_len(&self, v: Self::T) -> nat

{ Self::byte_len_gas(&self.0, LIMIT as nat, self.1.deep_view(), v) }
Source§

type T = <Body as SpecRecBody>::T

The type of values whose byte length is being computed.
Source§

impl<const LIMIT: usize, Body, Param> SpecParser for FixWith<LIMIT, Body, Param>
where Body: SpecRecBody, Param: DeepView<V = Body::Param>,

Source§

open spec fn spec_parse(&self, input: Seq<u8>) -> Option<(int, Self::PVal)>

{ Self::spec_parse_gas(&self.0, LIMIT as nat, self.1.deep_view(), input) }
Source§

type PVal = <Body as SpecRecBody>::T

The type of parsed values.
Source§

impl<const LIMIT: usize, Body, Param> SpecSerializer for FixWith<LIMIT, Body, Param>
where Body: SpecRecBody, Param: DeepView<V = Body::Param>,

Source§

open spec fn spec_serialize(&self, v: Self::SVal) -> Seq<u8>

{ Self::spec_serialize_gas(&self.0, LIMIT as nat, self.1.deep_view(), v) }
Source§

type SVal = <Body as SpecRecBody>::T

The type of values to be serialized.
Source§

impl<const LIMIT: usize, Body, Param> SpecSerializerDps for FixWith<LIMIT, Body, Param>
where Body: SpecRecBody, Param: DeepView<V = Body::Param>,

Source§

open spec fn spec_serialize_dps(&self, v: Self::SValue, obuf: Seq<u8>) -> Seq<u8>

{ Self::spec_serialize_dps_gas(&self.0, LIMIT as nat, self.1.deep_view(), v, obuf) }
Source§

type SValue = <Body as SpecRecBody>::T

The type of values to be serialized.
Source§

impl<const LIMIT: usize, Body: Copy, Param: Copy> Copy for FixWith<LIMIT, Body, Param>

Auto Trait Implementations§

§

impl<const LIMIT: usize, Body, Param> Freeze for FixWith<LIMIT, Body, Param>
where Body: Freeze, Param: Freeze,

§

impl<const LIMIT: usize, Body, Param> RefUnwindSafe for FixWith<LIMIT, Body, Param>
where Body: RefUnwindSafe, Param: RefUnwindSafe,

§

impl<const LIMIT: usize, Body, Param> Send for FixWith<LIMIT, Body, Param>
where Body: Send, Param: Send,

§

impl<const LIMIT: usize, Body, Param> Sync for FixWith<LIMIT, Body, Param>
where Body: Sync, Param: Sync,

§

impl<const LIMIT: usize, Body, Param> Unpin for FixWith<LIMIT, Body, Param>
where Body: Unpin, Param: Unpin,

§

impl<const LIMIT: usize, Body, Param> UnsafeUnpin for FixWith<LIMIT, Body, Param>
where Body: UnsafeUnpin, Param: UnsafeUnpin,

§

impl<const LIMIT: usize, Body, Param> UnwindSafe for FixWith<LIMIT, Body, Param>
where Body: UnwindSafe, Param: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: From<T>,

§

fn obeys_from_spec() -> bool

§

fn from_spec(v: T) -> VERUS_SPEC__A

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: Into<T>,

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> T

§

impl<T, U> IntoSpecImpl<U> for T
where U: From<T>,

§

fn obeys_into_spec() -> bool

§

fn into_spec(self) -> U

Source§

impl<Fmt> Leaf for Fmt
where Fmt: LeafNonMalleable,

Source§

proof fn leaf_inv(&self)

Source§

impl<C> NonAmbiguous for C
where C: SPRoundTrip,

Source§

open spec fn nonamb_inv(&self) -> bool

{ self.sp_roundtrip_inv() }
Source§

proof fn lemma_serialize_injective( &self, v1: <C as Consistency>::Val, v2: <C as Consistency>::Val, )

Source§

fn corollary_serialize_injective_contrapositive( &self, v1: Self::Val, v2: Self::Val, )

Source§

impl<C> PSRoundTrip for C

Source§

open spec fn ps_roundtrip_inv(&self) -> bool

{ self.safe_inv() && self.sound_inv() && self.nonmal_inv() && self.sp_roundtrip_inv() }
Source§

proof fn theorem_parse_serialize_roundtrip(&self, ibuf: Seq<u8>)

Source§

fn corollary_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)

Source§

impl<C> SPRoundTrip for C

Source§

open spec fn sp_roundtrip_inv(&self) -> bool

{ self.serialize_inv() && self.equiv_inv() && self.unambiguous() }
Source§

proof fn theorem_serialize_parse_roundtrip(&self, v: <C as SpecByteLen>::T)

Source§

impl<T, S> SerializerExt<T> for S
where S: SpecByteLen<T = <T as DeepView>::V> + SpecSerializer<SVal = <T as DeepView>::V> + Consistency<Val = <T as DeepView>::V>, T: DeepView + ?Sized,

Source§

fn serialize<'a>(&self, v: &T, obuf: &'a mut [u8])
where Self: Serializer<OutputSlice<'a>, T>,

Source§

fn serialize_with_vec(&self, v: &T, obuf: &mut Vec<u8>)
where Self: Serializer<Vec<u8>, T>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryFrom<T>,

§

fn obeys_try_from_spec() -> bool

§

fn try_from_spec( v: T, ) -> Result<VERUS_SPEC__A, <VERUS_SPEC__A as TryFrom<T>>::Error>

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__A
where VERUS_SPEC__A: TryInto<T>,

§

fn obeys_try_into_spec() -> bool

§

fn try_into_spec(self) -> Result<T, <VERUS_SPEC__A as TryInto<T>>::Error>

§

impl<T, U> TryIntoSpecImpl<U> for T
where U: TryFrom<T>,

§

fn obeys_try_into_spec() -> bool

§

fn try_into_spec(self) -> Result<U, <U as TryFrom<T>>::Error>

Source§

impl<T> SpecCombinator for T
where T: SpecParser<PVal = <T as SpecByteLen>::T> + SpecByteLen + SpecSerializer<SVal = <T as SpecByteLen>::T> + Consistency<Val = <T as SpecByteLen>::T> + SpecSerializerDps<SValue = <T as SpecByteLen>::T>,

§

impl<A> SpecEq<&A> for A
where A: ?Sized,

§

impl<A> SpecEq<&mut A> for A
where A: ?Sized,

§

impl<A> SpecEq<A> for A
where A: ?Sized,

§

impl<A> SpecEq<Ghost<A>> for A

§

impl<A> SpecEq<Tracked<A>> for A

Source§

impl<Body> StrictCombinator for Body