@@ -271,6 +271,23 @@ impl<T, A: Allocator> super::core::IndexSetTrustedSpec<usize> for Vec<T, A> {
271271 }
272272}
273273
274+ pub assume_specification<T : PartialEq <U >, U , A1 : Allocator , A2 : Allocator >[ <Vec <T , A1 > as PartialEq <Vec <U , A2 >>>:: eq ] (
275+ x: & Vec <T , A1 >,
276+ y: & Vec <U , A2 >,
277+ ) -> bool
278+ ;
279+
280+ impl <T : super :: cmp:: PartialEqSpec <U >, U , A1 : Allocator , A2 : Allocator > super :: cmp:: PartialEqSpecImpl <Vec <U , A2 >> for Vec <T , A1 > {
281+ open spec fn obeys_eq_spec( ) -> bool {
282+ T :: obeys_eq_spec( )
283+ }
284+
285+ open spec fn eq_spec( & self , other: & Vec <U , A2 >) -> bool {
286+ &&& self . len( ) == other. len( )
287+ &&& forall|i: int| #![ auto] 0 <= i < self . len( ) ==> self [ i] . eq_spec( & other[ i] )
288+ }
289+ }
290+
274291// The `into_iter` method of a `Vec` returns an iterator of type `IntoIter`,
275292// so we specify that type here.
276293#[ verifier:: external_type_specification]
@@ -400,6 +417,49 @@ pub assume_specification<T, A: Allocator>[ Vec::<T, A>::into_iter ](vec: Vec<T,
400417 iter@ == ( 0 int, vec@) ,
401418;
402419
420+ pub broadcast proof fn lemma_vec_obeys_eq_spec<T : PartialEq >( )
421+ requires
422+ super :: super :: laws_eq:: obeys_eq_spec:: <T >( ) ,
423+ ensures
424+ #[ trigger] super :: super :: laws_eq:: obeys_eq_spec:: <Vec <T >>( ) ,
425+ {
426+ broadcast use { axiom_spec_len, super :: super :: seq:: group_seq_axioms} ;
427+ reveal( super :: super :: laws_eq:: obeys_eq_spec_properties) ;
428+ }
429+
430+ pub broadcast proof fn lemma_vec_obeys_view_eq<T : PartialEq + View >( )
431+ requires
432+ super :: super :: laws_eq:: obeys_concrete_eq:: <T >( ) ,
433+ ensures
434+ #[ trigger] super :: super :: laws_eq:: obeys_view_eq:: <Vec <T >>( ) ,
435+ {
436+ use super :: cmp:: PartialEqSpec ;
437+ broadcast use { axiom_spec_len, super :: super :: seq:: group_seq_axioms} ;
438+ reveal( super :: super :: laws_eq:: obeys_eq_spec_properties) ;
439+ reveal( super :: super :: laws_eq:: obeys_concrete_eq) ;
440+ reveal( super :: super :: laws_eq:: obeys_view_eq) ;
441+ assert( forall|x: Vec <T >, y: Vec <T >| x. eq_spec( & y) ==> x@ == y@) ;
442+ }
443+
444+ pub broadcast proof fn lemma_vec_obeys_deep_eq<T : PartialEq + DeepView >( )
445+ requires
446+ super :: super :: laws_eq:: obeys_deep_eq:: <T >( ) ,
447+ ensures
448+ #[ trigger] super :: super :: laws_eq:: obeys_deep_eq:: <Vec <T >>( ) ,
449+ {
450+ use super :: cmp:: PartialEqSpec ;
451+ broadcast use { axiom_spec_len, super :: super :: seq:: group_seq_axioms} ;
452+ reveal( super :: super :: laws_eq:: obeys_eq_spec_properties) ;
453+ reveal( super :: super :: laws_eq:: obeys_deep_eq) ;
454+ assert( forall|x: Vec <T >, y: Vec <T >| x. eq_spec( & y) ==> x. deep_view( ) == y. deep_view( ) ) ;
455+ assert forall|x: Vec <T >, y: Vec <T >| x. deep_view( ) == y. deep_view( ) implies x. eq_spec( & y) by {
456+ assert( x. deep_view( ) . len( ) == y. deep_view( ) . len( ) ) ;
457+ assert forall|i: int| #![ auto] 0 <= i < x. len( ) implies x[ i] . eq_spec( & y[ i] ) by {
458+ assert( x. deep_view( ) [ i] == y. deep_view( ) [ i] ) ;
459+ }
460+ }
461+ }
462+
403463pub broadcast group group_vec_axioms {
404464 axiom_spec_len,
405465 axiom_vec_index_decreases,
0 commit comments