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.List.Map2

35 declarations. Mathlib docs · Source

Map₂ Lemmas

This file contains additional lemmas about a number of list functions related to combining zipping Lists together. In particular, we include lemmas about:

  • map₂Left'
  • map₂Right'
  • zipWith
  • zipLeft'
  • zipRight'

map₂Left'

map₂Right'

zipWith

zipLeft'

zipRight'

map₂Left

map₂Right

zipLeft

zipRight

theorem List.map₂Left'_nil_right E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → Option β → γ) (as : List α),
  List.map₂Left' f as [] = (List.map (fun a ↦ f a none) as, [])

theorem List.map₂Right'_nil_left E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (bs : List β),
  List.map₂Right' f [] bs = (List.map (f none) bs, [])

theorem List.map₂Right'_nil_right E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (as : List α), List.map₂Right' f as [] = ([], as)

theorem List.map₂Right'_nil_cons E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (b : β) (bs : List β),
  List.map₂Right' f [] (b :: bs) = (f none b :: List.map (f none) bs, [])

theorem List.map₂Right'_cons_cons E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (a : α) (as : List α) (b : β) (bs : List β),
  List.map₂Right' f (a :: as) (b :: bs) =
    have r := List.map₂Right' f as bs;
    (f (some a) b :: r.1, r.2)

theorem List.nil_zipWith E1 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → β → γ) (l : List β), List.zipWith f [] l = []

theorem List.zipWith_nil E1 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → β → γ) (l : List α), List.zipWith f l [] = []

theorem List.zipWith_flip E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → β → γ) (as : List α) (bs : List β),
  List.zipWith (flip f) bs as = List.zipWith f as bs

theorem List.zipLeft'_nil_right E0 #

∀ {α : Type u} {β : Type v} (as : List α), as.zipLeft' [] = (List.map (fun a ↦ (a, none)) as, [])

theorem List.zipLeft'_nil_left E0 #

∀ {α : Type u} {β : Type v} (bs : List β), [].zipLeft' bs = ([], bs)

theorem List.zipLeft'_cons_nil E0 #

∀ {α : Type u} {β : Type v} (a : α) (as : List α),
  (a :: as).zipLeft' [] = ((a, none) :: List.map (fun a ↦ (a, none)) as, [])

theorem List.zipLeft'_cons_cons E0 #

∀ {α : Type u} {β : Type v} (a : α) (as : List α) (b : β) (bs : List β),
  (a :: as).zipLeft' (b :: bs) =
    have r := as.zipLeft' bs;
    ((a, some b) :: r.1, r.2)

theorem List.zipRight'_nil_left E0 #

∀ {α : Type u} {β : Type v} (bs : List β), [].zipRight' bs = (List.map (fun b ↦ (none, b)) bs, [])

theorem List.zipRight'_nil_right E0 #

∀ {α : Type u} {β : Type v} (as : List α), as.zipRight' [] = ([], as)

theorem List.zipRight'_nil_cons E0 #

∀ {α : Type u} {β : Type v} (b : β) (bs : List β),
  [].zipRight' (b :: bs) = ((none, b) :: List.map (fun b ↦ (none, b)) bs, [])

theorem List.zipRight'_cons_cons E0 #

∀ {α : Type u} {β : Type v} (a : α) (as : List α) (b : β) (bs : List β),
  (a :: as).zipRight' (b :: bs) =
    have r := as.zipRight' bs;
    ((some a, b) :: r.1, r.2)

theorem List.map₂Left_nil_right E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → Option β → γ) (as : List α),
  List.map₂Left f as [] = List.map (fun a ↦ f a none) as

theorem List.map₂Left_eq_map₂Left' E1 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → Option β → γ) (as : List α) (bs : List β),
  List.map₂Left f as bs = (List.map₂Left' f as bs).1

theorem List.map₂Left_eq_zipWith E1 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : α → Option β → γ) (as : List α) (bs : List β),
  as.length ≤ bs.length → List.map₂Left f as bs = List.zipWith (fun a b ↦ f a (some b)) as bs

theorem List.map₂Right_nil_left E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (bs : List β),
  List.map₂Right f [] bs = List.map (f none) bs

theorem List.map₂Right_nil_right E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (as : List α), List.map₂Right f as [] = []

theorem List.map₂Right_nil_cons E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (b : β) (bs : List β),
  List.map₂Right f [] (b :: bs) = f none b :: List.map (f none) bs

theorem List.map₂Right_cons_cons E0 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (a : α) (as : List α) (b : β) (bs : List β),
  List.map₂Right f (a :: as) (b :: bs) = f (some a) b :: List.map₂Right f as bs

theorem List.map₂Right_eq_map₂Right' E1 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (as : List α) (bs : List β),
  List.map₂Right f as bs = (List.map₂Right' f as bs).1

theorem List.map₂Right_eq_zipWith E1 #

∀ {α : Type u} {β : Type v} {γ : Type w} (f : Option α → β → γ) (as : List α) (bs : List β),
  bs.length ≤ as.length → List.map₂Right f as bs = List.zipWith (fun a b ↦ f (some a) b) as bs

theorem List.zipLeft_nil_right E0 #

∀ {α : Type u} {β : Type v} (as : List α), as.zipLeft [] = List.map (fun a ↦ (a, none)) as

theorem List.zipLeft_nil_left E0 #

∀ {α : Type u} {β : Type v} (bs : List β), [].zipLeft bs = []

theorem List.zipLeft_cons_nil E0 #

∀ {α : Type u} {β : Type v} (a : α) (as : List α), (a :: as).zipLeft [] = (a, none) :: List.map (fun a ↦ (a, none)) as

theorem List.zipLeft_cons_cons E0 #

∀ {α : Type u} {β : Type v} (a : α) (as : List α) (b : β) (bs : List β),
  (a :: as).zipLeft (b :: bs) = (a, some b) :: as.zipLeft bs

theorem List.zipLeft_eq_zipLeft' E1 #

∀ {α : Type u} {β : Type v} (as : List α) (bs : List β), as.zipLeft bs = (as.zipLeft' bs).1

theorem List.zipRight_nil_left E0 #

∀ {α : Type u} {β : Type v} (bs : List β), [].zipRight bs = List.map (fun b ↦ (none, b)) bs

theorem List.zipRight_nil_right E0 #

∀ {α : Type u} {β : Type v} (as : List α), as.zipRight [] = []

theorem List.zipRight_nil_cons E0 #

∀ {α : Type u} {β : Type v} (b : β) (bs : List β), [].zipRight (b :: bs) = (none, b) :: List.map (fun b ↦ (none, b)) bs

theorem List.zipRight_cons_cons E0 #

∀ {α : Type u} {β : Type v} (a : α) (as : List α) (b : β) (bs : List β),
  (a :: as).zipRight (b :: bs) = (some a, b) :: as.zipRight bs

theorem List.zipRight_eq_zipRight' E1 #

∀ {α : Type u} {β : Type v} (as : List α) (bs : List β), as.zipRight bs = (as.zipRight' bs).1