The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.Vector.MapLemmas

36 declarations. Mathlib docs · Source

Normalization lemmas for map and mapAccumr on vectors

This file establishes a set of normalization lemmas for map/mapAccumr operations on vectors

Fold nested mapAccumrs into one

Bisimulations

We can prove two applications of mapAccumr equal by providing a bisimulation relation that relates the initial states.

That is, by providing a relation R : σ₁ → σ₁ → Prop such that R s₁ s₂ implies that R also relates any pair of states reachable by applying f₁ to s₁ and f₂ to s₂, with any possible input values.

Redundant state optimization

The following section are collection of rewrites to simplify, or even get rid, redundant accumulation state

Unused input optimizations

Commutativity

Argument Flipping

theorem List.Vector.mapAccumr_mapAccumr E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {s₁ : σ₁} {s₂ : σ₂}
  (xs : List.Vector α n) (f₁ : β → σ₁ → σ₁ × γ) (f₂ : α → σ₂ → σ₂ × β),
  List.Vector.mapAccumr f₁ (List.Vector.mapAccumr f₂ xs s₂).2 s₁ =
    have m :=
      List.Vector.mapAccumr
        (fun x s ↦
          have r₂ := f₂ x s.2;
          have r₁ := f₁ r₂.2 s.1;
          ((r₁.1, r₂.1), r₁.2))
        xs (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.mapAccumr_map E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {n : ℕ} (xs : List.Vector α n) (f₁ : β → σ₁ → σ₁ × γ)
  {s : σ₁} (f₂ : α → β),
  List.Vector.mapAccumr f₁ (List.Vector.map f₂ xs) s = List.Vector.mapAccumr (fun x s ↦ f₁ (f₂ x) s) xs s

theorem List.Vector.map_mapAccumr E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₂ : Type u_7} {n : ℕ} (xs : List.Vector α n) (f₂ : α → σ₂ → σ₂ × β)
  {s : σ₂} (f₁ : β → γ),
  List.Vector.map f₁ (List.Vector.mapAccumr f₂ xs s).2 =
    (List.Vector.mapAccumr
        (fun x s ↦
          have r := f₂ x s;
          (r.1, f₁ r.2))
        xs s).2

theorem List.Vector.map_map E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} (xs : List.Vector α n) (f₁ : β → γ) (f₂ : α → β),
  List.Vector.map f₁ (List.Vector.map f₂ xs) = List.Vector.map (fun x ↦ f₁ (f₂ x)) xs

theorem List.Vector.map_pmap E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} (xs : List.Vector α n) {p : α → Prop} (f₁ : β → γ)
  (f₂ : (a : α) → p a → β) (H : ∀ x ∈ xs.toList, p x),
  List.Vector.map f₁ (List.Vector.pmap f₂ xs H) = List.Vector.pmap (fun x hx ↦ f₁ (f₂ x hx)) xs H

theorem List.Vector.pmap_map E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} (xs : List.Vector α n) {p : β → Prop} (f₁ : (b : β) → p b → γ)
  (f₂ : α → β) (H : ∀ x ∈ (List.Vector.map f₂ xs).toList, p x),
  List.Vector.pmap f₁ (List.Vector.map f₂ xs) H = List.Vector.pmap (fun x hx ↦ f₁ (f₂ x) hx) xs ⋯

theorem List.Vector.mapAccumr₂_mapAccumr_left E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {ζ : Type u_4} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : γ → β → σ₁ → σ₁ × ζ) (f₂ : α → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr₂ f₁ (List.Vector.mapAccumr f₂ xs s₂).2 ys s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y s ↦
          have r₂ := f₂ x s.2;
          have r₁ := f₁ r₂.2 y s.1;
          ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.map₂_map_left E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {ζ : Type u_4} {n : ℕ} (xs : List.Vector α n) (ys : List.Vector β n)
  (f₁ : γ → β → ζ) (f₂ : α → γ),
  List.Vector.map₂ f₁ (List.Vector.map f₂ xs) ys = List.Vector.map₂ (fun x y ↦ f₁ (f₂ x) y) xs ys

theorem List.Vector.mapAccumr₂_mapAccumr_right E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {ζ : Type u_4} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : α → γ → σ₁ → σ₁ × ζ) (f₂ : β → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr₂ f₁ xs (List.Vector.mapAccumr f₂ ys s₂).2 s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y s ↦
          have r₂ := f₂ y s.2;
          have r₁ := f₁ x r₂.2 s.1;
          ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.map₂_map_right E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {ζ : Type u_4} {n : ℕ} (xs : List.Vector α n) (ys : List.Vector β n)
  (f₁ : α → γ → ζ) (f₂ : β → γ),
  List.Vector.map₂ f₁ xs (List.Vector.map f₂ ys) = List.Vector.map₂ (fun x y ↦ f₁ x (f₂ y)) xs ys

theorem List.Vector.mapAccumr_mapAccumr₂ E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {ζ : Type u_4} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : γ → σ₁ → σ₁ × ζ) (f₂ : α → β → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr f₁ (List.Vector.mapAccumr₂ f₂ xs ys s₂).2 s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y s ↦
          have r₂ := f₂ x y s.2;
          have r₁ := f₁ r₂.2 s.1;
          ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.map_map₂ E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {ζ : Type u_4} {n : ℕ} (xs : List.Vector α n) (ys : List.Vector β n)
  (f₁ : γ → ζ) (f₂ : α → β → γ),
  List.Vector.map f₁ (List.Vector.map₂ f₂ xs ys) = List.Vector.map₂ (fun x y ↦ f₁ (f₂ x y)) xs ys

theorem List.Vector.mapAccumr₂_mapAccumr₂_left_left E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {φ : Type u_8} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : γ → α → σ₁ → σ₁ × φ) (f₂ : α → β → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr₂ f₁ (List.Vector.mapAccumr₂ f₂ xs ys s₂).2 xs s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y x_1 ↦
          match x_1 with
          | (s₁, s₂) =>
            have r₂ := f₂ x y s₂;
            have r₁ := f₁ r₂.2 x s₁;
            ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.mapAccumr₂_mapAccumr₂_left_right E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {φ : Type u_8} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : γ → β → σ₁ → σ₁ × φ) (f₂ : α → β → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr₂ f₁ (List.Vector.mapAccumr₂ f₂ xs ys s₂).2 ys s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y x_1 ↦
          match x_1 with
          | (s₁, s₂) =>
            have r₂ := f₂ x y s₂;
            have r₁ := f₁ r₂.2 y s₁;
            ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.mapAccumr₂_mapAccumr₂_right_left E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {φ : Type u_8} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : α → γ → σ₁ → σ₁ × φ) (f₂ : α → β → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr₂ f₁ xs (List.Vector.mapAccumr₂ f₂ xs ys s₂).2 s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y x_1 ↦
          match x_1 with
          | (s₁, s₂) =>
            have r₂ := f₂ x y s₂;
            have r₁ := f₁ x r₂.2 s₁;
            ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.mapAccumr₂_mapAccumr₂_right_right E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {φ : Type u_8} {n : ℕ} {s₁ : σ₁}
  {s₂ : σ₂} (xs : List.Vector α n) (ys : List.Vector β n) (f₁ : β → γ → σ₁ → σ₁ × φ) (f₂ : α → β → σ₂ → σ₂ × γ),
  List.Vector.mapAccumr₂ f₁ ys (List.Vector.mapAccumr₂ f₂ xs ys s₂).2 s₁ =
    have m :=
      List.Vector.mapAccumr₂
        (fun x y x_1 ↦
          match x_1 with
          | (s₁, s₂) =>
            have r₂ := f₂ x y s₂;
            have r₁ := f₁ y r₂.2 s₁;
            ((r₁.1, r₂.1), r₁.2))
        xs ys (s₁, s₂);
    (m.1.1, m.2)

theorem List.Vector.mapAccumr_bisim E1 #

∀ {α : Type u_1} {β : Type u_2} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {xs : List.Vector α n} {f₁ : α → σ₁ → σ₁ × β}
  {f₂ : α → σ₂ → σ₂ × β} {s₁ : σ₁} {s₂ : σ₂} (R : σ₁ → σ₂ → Prop),
  R s₁ s₂ →
    (∀ {s : σ₁} {q : σ₂} (a : α), R s q → R (f₁ a s).1 (f₂ a q).1 ∧ (f₁ a s).2 = (f₂ a q).2) →
      R (List.Vector.mapAccumr f₁ xs s₁).1 (List.Vector.mapAccumr f₂ xs s₂).1 ∧
        (List.Vector.mapAccumr f₁ xs s₁).2 = (List.Vector.mapAccumr f₂ xs s₂).2

theorem List.Vector.mapAccumr_bisim_tail E1 #

∀ {α : Type u_1} {β : Type u_2} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {xs : List.Vector α n} {f₁ : α → σ₁ → σ₁ × β}
  {f₂ : α → σ₂ → σ₂ × β} {s₁ : σ₁} {s₂ : σ₂},
  (∃ R, R s₁ s₂ ∧ ∀ {s : σ₁} {q : σ₂} (a : α), R s q → R (f₁ a s).1 (f₂ a q).1 ∧ (f₁ a s).2 = (f₂ a q).2) →
    (List.Vector.mapAccumr f₁ xs s₁).2 = (List.Vector.mapAccumr f₂ xs s₂).2

theorem List.Vector.mapAccumr₂_bisim E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {xs : List.Vector α n}
  {ys : List.Vector β n} {f₁ : α → β → σ₁ → σ₁ × γ} {f₂ : α → β → σ₂ → σ₂ × γ} {s₁ : σ₁} {s₂ : σ₂} (R : σ₁ → σ₂ → Prop),
  R s₁ s₂ →
    (∀ {s : σ₁} {q : σ₂} (a : α) (b : β), R s q → R (f₁ a b s).1 (f₂ a b q).1 ∧ (f₁ a b s).2 = (f₂ a b q).2) →
      R (List.Vector.mapAccumr₂ f₁ xs ys s₁).1 (List.Vector.mapAccumr₂ f₂ xs ys s₂).1 ∧
        (List.Vector.mapAccumr₂ f₁ xs ys s₁).2 = (List.Vector.mapAccumr₂ f₂ xs ys s₂).2

theorem List.Vector.mapAccumr₂_bisim_tail E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ₁ : Type u_6} {σ₂ : Type u_7} {n : ℕ} {xs : List.Vector α n}
  {ys : List.Vector β n} {f₁ : α → β → σ₁ → σ₁ × γ} {f₂ : α → β → σ₂ → σ₂ × γ} {s₁ : σ₁} {s₂ : σ₂},
  (∃ R,
      R s₁ s₂ ∧
        ∀ {s : σ₁} {q : σ₂} (a : α) (b : β), R s q → R (f₁ a b s).1 (f₂ a b q).1 ∧ (f₁ a b s).2 = (f₂ a b q).2) →
    (List.Vector.mapAccumr₂ f₁ xs ys s₁).2 = (List.Vector.mapAccumr₂ f₂ xs ys s₂).2

theorem List.Vector.map_eq_mapAccumr E0 #

∀ {α : Type u_1} {β : Type u_2} {n : ℕ} {xs : List.Vector α n} {f : α → β},
  List.Vector.map f xs = (List.Vector.mapAccumr (fun x x_1 ↦ ((), f x)) xs ()).2

theorem List.Vector.mapAccumr_eq_map E1 #

∀ {α : Type u_1} {β : Type u_2} {σ : Type u_5} {n : ℕ} {xs : List.Vector α n} {f : α → σ → σ × β} {s₀ : σ} (S : Set σ),
  s₀ ∈ S →
    (∀ (a : α), ∀ s ∈ S, (f a s).1 ∈ S) →
      (∀ (a : α) (s s' : σ), s ∈ S → s' ∈ S → (f a s).2 = (f a s').2) →
        (List.Vector.mapAccumr f xs s₀).2 = List.Vector.map (fun x ↦ (f x s₀).2) xs

If there is a set of states that is closed under f, and such that f produces that same output for all states in this set, then the state is not actually needed. Hence, then we can rewrite mapAccumr into just map.

theorem List.Vector.map₂_eq_mapAccumr₂ E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} {xs : List.Vector α n} {ys : List.Vector β n} {f : α → β → γ},
  List.Vector.map₂ f xs ys = (List.Vector.mapAccumr₂ (fun x y x_1 ↦ ((), f x y)) xs ys ()).2

theorem List.Vector.mapAccumr₂_eq_map₂ E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {xs : List.Vector α n} {ys : List.Vector β n}
  {f : α → β → σ → σ × γ} {s₀ : σ} (S : Set σ),
  s₀ ∈ S →
    (∀ (a : α) (b : β), ∀ s ∈ S, (f a b s).1 ∈ S) →
      (∀ (a : α) (b : β) (s s' : σ), s ∈ S → s' ∈ S → (f a b s).2 = (f a b s').2) →
        (List.Vector.mapAccumr₂ f xs ys s₀).2 = List.Vector.map₂ (fun x1 x2 ↦ (f x1 x2 s₀).2) xs ys

If there is a set of states that is closed under f, and such that f produces that same output for all states in this set, then the state is not actually needed. Hence, then we can rewrite mapAccumr₂ into just map₂.

theorem List.Vector.mapAccumr_eq_map_of_constant_state E0 #

∀ {α : Type u_1} {β : Type u_2} {σ : Type u_5} {n : ℕ} {xs : List.Vector α n} (f : α → σ → σ × β) (s : σ),
  (∀ (a : α), (f a s).1 = s) → List.Vector.mapAccumr f xs s = (s, List.Vector.map (fun x ↦ (f x s).2) xs)

If an accumulation function f, given an initial state s, produces s as its output state for all possible input bits, then the state is redundant and can be optimized out.

theorem List.Vector.mapAccumr₂_eq_map₂_of_constant_state E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {xs : List.Vector α n} {ys : List.Vector β n}
  (f : α → β → σ → σ × γ) (s : σ),
  (∀ (a : α) (b : β), (f a b s).1 = s) →
    List.Vector.mapAccumr₂ f xs ys s = (s, List.Vector.map₂ (fun x y ↦ (f x y s).2) xs ys)

If an accumulation function f, given an initial state s, produces s as its output state for all possible input bits, then the state is redundant and can be optimized out.

theorem List.Vector.mapAccumr_eq_map_of_unused_state E0 #

∀ {α : Type u_1} {β : Type u_2} {σ : Type u_5} {n : ℕ} {xs : List.Vector α n} (f : α → σ → σ × β) (f' : α → β) (s : σ),
  (∀ (a : α) (s : σ), (f a s).2 = f' a) → (List.Vector.mapAccumr f xs s).2 = List.Vector.map f' xs

If an accumulation function f, produces the same output bits regardless of accumulation state, then the state is redundant and can be optimized out.

theorem List.Vector.mapAccumr₂_eq_map₂_of_unused_state E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {xs : List.Vector α n} {ys : List.Vector β n}
  (f : α → β → σ → σ × γ) (f' : α → β → γ) (s : σ),
  (∀ (a : α) (b : β) (s : σ), (f a b s).2 = f' a b) →
    (List.Vector.mapAccumr₂ f xs ys s).2 = List.Vector.map₂ (fun x y ↦ (f x y s).2) xs ys

If an accumulation function f, produces the same output bits regardless of accumulation state, then the state is redundant and can be optimized out.

theorem List.Vector.mapAccumr_redundant_pair E0 #

∀ {α : Type u_1} {β : Type u_2} {σ : Type u_5} {n : ℕ} {s : σ} {xs : List.Vector α n} (f : α → σ × σ → (σ × σ) × β),
  (∀ (x : α) (s : σ), (f x (s, s)).1.1 = (f x (s, s)).1.2) →
    (List.Vector.mapAccumr f xs (s, s)).2 =
      (List.Vector.mapAccumr (fun x s ↦ ((f x (s, s)).1.1, (f x (s, s)).2)) xs s).2

If f takes a pair of states, but always returns the same value for both elements of the pair, then we can simplify to just a single element of state.

theorem List.Vector.mapAccumr₂_redundant_pair E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {s : σ} {xs : List.Vector α n}
  {ys : List.Vector β n} (f : α → β → σ × σ → (σ × σ) × γ),
  (∀ (x : α) (y : β) (s : σ),
      have s' := (f x y (s, s)).1;
      s'.1 = s'.2) →
    (List.Vector.mapAccumr₂ f xs ys (s, s)).2 =
      (List.Vector.mapAccumr₂ (fun x y s ↦ ((f x y (s, s)).1.1, (f x y (s, s)).2)) xs ys s).2

If f takes a pair of states, but always returns the same value for both elements of the pair, then we can simplify to just a single element of state.

theorem List.Vector.mapAccumr₂_unused_input_left E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {s : σ} {xs : List.Vector α n}
  {ys : List.Vector β n} (f : α → β → σ → σ × γ) (f' : β → σ → σ × γ),
  (∀ (a : α) (b : β) (s : σ), f a b s = f' b s) → List.Vector.mapAccumr₂ f xs ys s = List.Vector.mapAccumr f' ys s

If f returns the same output and next state for every value of its first argument, then xs : Vector is ignored, and we can rewrite mapAccumr₂ into map.

theorem List.Vector.mapAccumr₂_unused_input_right E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {s : σ} {xs : List.Vector α n}
  {ys : List.Vector β n} (f : α → β → σ → σ × γ) (f' : α → σ → σ × γ),
  (∀ (a : α) (b : β) (s : σ), f a b s = f' a s) → List.Vector.mapAccumr₂ f xs ys s = List.Vector.mapAccumr f' xs s

If f returns the same output and next state for every value of its second argument, then ys : Vector is ignored, and we can rewrite mapAccumr₂ into map.

theorem List.Vector.map₂_comm E1 #

∀ {α : Type u_1} {β : Type u_2} {n : ℕ} (xs ys : List.Vector α n) (f : α → α → β),
  (∀ (a₁ a₂ : α), f a₁ a₂ = f a₂ a₁) → List.Vector.map₂ f xs ys = List.Vector.map₂ f ys xs

theorem List.Vector.mapAccumr₂_comm E1 #

∀ {α : Type u_1} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {s : σ} (xs ys : List.Vector α n) (f : α → α → σ → σ × γ),
  (∀ (a₁ a₂ : α) (s : σ), f a₁ a₂ s = f a₂ a₁ s) → List.Vector.mapAccumr₂ f xs ys s = List.Vector.mapAccumr₂ f ys xs s

theorem List.Vector.map₂_flip E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {n : ℕ} (xs : List.Vector α n) (ys : List.Vector β n) (f : α → β → γ),
  List.Vector.map₂ f xs ys = List.Vector.map₂ (flip f) ys xs

theorem List.Vector.mapAccumr₂_flip E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} {n : ℕ} {s : σ} (xs : List.Vector α n)
  (ys : List.Vector β n) (f : α → β → σ → σ × γ),
  List.Vector.mapAccumr₂ f xs ys s = List.Vector.mapAccumr₂ (flip f) ys xs s