Skip to main content

fold_prefix

Function fold_prefix 

Source
pub open spec fn fold_prefix<A, B, F: FnMut(B, A) -> B>(
    items: Seq<A>,
    produces: Seq<bool>,
    init: B,
    f: F,
    bs: Seq<B>,
) -> bool
Expand description
{
    &&& 1 <= bs.len() <= items.len() + 1
    &&& bs[0] == init
    &&& produces.take(bs.len() - 1).all(|p: bool| p)
    &&& forall |j: int| {
        0 <= j < bs.len() - 1
            ==> f.requires((bs[j], #[trigger] items[j]))
                && f.ensures((bs[j], items[j]), bs[j + 1])
    }

}