File: Mathlib/Data/List/Join.lean

full_name: List.join_singleton
code: theorem join_singleton (l : List α) : [l].join = l 
goal: [l].join = l

full_name: List.join_eq_nil
code: @[simp]
theorem join_eq_nil : ∀ {L : List (List α)}, join L = [] ↔ ∀ l ∈ L, l = []
  
goal: L.join = [] ↔ ∀ (l : List α), l ∈ L → l = []

full_name: List.join_append
code: @[simp]
theorem join_append (L₁ L₂ : List (List α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ 
goal: (L₁ ++ L₂).join = L₁.join ++ L₂.join

full_name: List.join_concat
code: theorem join_concat (L : List (List α)) (l : List α) : join (L.concat l) = join L ++ l 
goal: (L.concat l).join = L.join ++ l

full_name: List.join_filter_not_isEmpty
code: @[simp]
theorem join_filter_not_isEmpty  :
    ∀ {L : List (List α)}, join (L.filter fun l => !l.isEmpty) = L.join
  
goal: (List.filter (fun l => !l.isEmpty) L).join = L.join

full_name: List.join_filter_ne_nil
code: @[simp]
theorem join_filter_ne_nil [DecidablePred fun l : List α => l ≠ []] {L : List (List α)} :
    join (L.filter fun l => l ≠ []) = L.join 
goal: (List.filter (fun l => decide (l ≠ [])) L).join = L.join

full_name: List.join_join
code: theorem join_join (l : List (List (List α))) : l.join.join = (l.map join).join 
goal: l.join.join = (List.map List.join l).join

full_name: List.length_join'
code: /-- See `List.length_join` for the corresponding statement using `List.sum`. -/
lemma length_join' (L : List (List α)) : length (join L) = Nat.sum (map length L) 
goal: L.join.length = Nat.sum (List.map List.length L)

full_name: List.countP_join'
code: /-- See `List.countP_join` for the corresponding statement using `List.sum`. -/
lemma countP_join' (p : α → Bool) :
    ∀ L : List (List α), countP p L.join = Nat.sum (L.map (countP p))
  
goal: List.countP p L.join = Nat.sum (List.map (List.countP p) L)

full_name: List.count_join'
code: /-- See `List.count_join` for the corresponding statement using `List.sum`. -/
lemma count_join' [BEq α] (L : List (List α)) (a : α) :
    L.join.count a = Nat.sum (L.map (count a)) 
goal: List.count a L.join = Nat.sum (List.map (List.count a) L)

full_name: List.length_bind'
code: /-- See `List.length_bind` for the corresponding statement using `List.sum`. -/
lemma length_bind' (l : List α) (f : α → List β) :
    length (l.bind f) = Nat.sum (map (length ∘ f) l) 
goal: (l.bind f).length = Nat.sum (List.map (List.length ∘ f) l)

full_name: List.countP_bind'
code: /-- See `List.countP_bind` for the corresponding statement using `List.sum`. -/
lemma countP_bind' (p : β → Bool) (l : List α) (f : α → List β) :
    countP p (l.bind f) = Nat.sum (map (countP p ∘ f) l) 
goal: List.countP p (l.bind f) = Nat.sum (List.map (List.countP p ∘ f) l)

full_name: List.count_bind'
code: /-- See `List.count_bind` for the corresponding statement using `List.sum`. -/
lemma count_bind' [BEq β] (l : List α) (f : α → List β) (x : β) :
    count x (l.bind f) = Nat.sum (map (count x ∘ f) l) 
goal: List.count x (l.bind f) = Nat.sum (List.map (List.count x ∘ f) l)

full_name: List.bind_eq_nil
code: @[simp]
theorem bind_eq_nil {l : List α} {f : α → List β} : List.bind l f = [] ↔ ∀ x ∈ l, f x = [] 
goal: l.bind f = [] ↔ ∀ (x : α), x ∈ l → f x = []

full_name: List.take_sum_join'
code: /-- In a join, taking the first elements up to an index which is the sum of the lengths of the
first `i` sublists, is the same as taking the join of the first `i` sublists.

See `List.take_sum_join` for the corresponding statement using `List.sum`. -/
theorem take_sum_join' (L : List (List α)) (i : ℕ) :
    L.join.take (Nat.sum ((L.map length).take i)) = (L.take i).join 
goal: List.take (Nat.sum (List.take i (List.map List.length L))) L.join = (List.take i L).join

full_name: List.drop_sum_join'
code: /-- In a join, dropping all the elements up to an index which is the sum of the lengths of the
first `i` sublists, is the same as taking the join after dropping the first `i` sublists.

See `List.drop_sum_join` for the corresponding statement using `List.sum`. -/
theorem drop_sum_join' (L : List (List α)) (i : ℕ) :
    L.join.drop (Nat.sum ((L.map length).take i)) = (L.drop i).join 
goal: List.drop (Nat.sum (List.take i (List.map List.length L))) L.join = (List.drop i L).join

full_name: List.drop_take_succ_eq_cons_getElem
code: /-- Taking only the first `i+1` elements in a list, and then dropping the first `i` ones, one is
left with a list of length `1` made of the `i`-th element of the original list. -/
theorem drop_take_succ_eq_cons_getElem (L : List α) (i : Nat) (h : i < L.length) :
    (L.take (i + 1)).drop i = [L[i]] 
goal: List.drop i (List.take (i + 1) L) = [L[i]]

full_name: List.drop_take_succ_eq_cons_get
code: @[deprecated drop_take_succ_eq_cons_getElem (since := "2024-06-11")]
theorem drop_take_succ_eq_cons_get (L : List α) (i : Fin L.length) :
    (L.take (i + 1)).drop i = [get L i] 
goal: List.drop (↑i) (List.take (↑i + 1) L) = [L.get i]

full_name: List.drop_take_succ_eq_cons_nthLe
code: /-- Taking only the first `i+1` elements in a list, and then dropping the first `i` ones, one is
left with a list of length `1` made of the `i`-th element of the original list. -/
@[deprecated drop_take_succ_eq_cons_get (since := "2023-01-10")]
theorem drop_take_succ_eq_cons_nthLe (L : List α) {i : ℕ} (hi : i < L.length) :
    (L.take (i + 1)).drop i = [nthLe L i hi] 
goal: List.drop i (List.take (i + 1) L) = [L.nthLe i hi]

full_name: List.drop_take_succ_join_eq_getElem'
code: /-- In a join of sublists, taking the slice between the indices `A` and `B - 1` gives back the
original sublist of index `i` if `A` is the sum of the lengths of sublists of index `< i`, and
`B` is the sum of the lengths of sublists of index `≤ i`.

See `List.drop_take_succ_join_eq_getElem` for the corresponding statement using `List.sum`. -/
theorem drop_take_succ_join_eq_getElem' (L : List (List α)) (i : Nat) (h : i <  L.length) :
    (L.join.take (Nat.sum ((L.map length).take (i + 1)))).drop (Nat.sum ((L.map length).take i)) =
      L[i] 
goal: List.drop (Nat.sum (List.take i (List.map List.length L)))
    (List.take (Nat.sum (List.take (i + 1) (List.map List.length L))) L.join) =
  L[i]

full_name: List.drop_take_succ_join_eq_get'
code: @[deprecated drop_take_succ_join_eq_getElem' (since := "2024-06-11")]
theorem drop_take_succ_join_eq_get' (L : List (List α)) (i : Fin L.length) :
    (L.join.take (Nat.sum ((L.map length).take (i + 1)))).drop (Nat.sum ((L.map length).take i)) =
      get L i 
goal: List.drop (Nat.sum (List.take (↑i) (List.map List.length L)))
    (List.take (Nat.sum (List.take (↑i + 1) (List.map List.length L))) L.join) =
  L.get i

full_name: List.eq_iff_join_eq
code: /-- Two lists of sublists are equal iff their joins coincide, as well as the lengths of the
sublists. -/
theorem eq_iff_join_eq (L L' : List (List α)) :
    L = L' ↔ L.join = L'.join ∧ map length L = map length L' 
goal: L = L' ↔ L.join = L'.join ∧ List.map List.length L = List.map List.length L'

full_name: List.join_drop_length_sub_one
code: theorem join_drop_length_sub_one {L : List (List α)} (h : L ≠ []) :
    (L.drop (L.length - 1)).join = L.getLast h 
goal: (List.drop (L.length - 1) L).join = L.getLast h

full_name: List.append_join_map_append
code: /-- We can rebracket `x ++ (l₁ ++ x) ++ (l₂ ++ x) ++ ... ++ (lₙ ++ x)` to
`(x ++ l₁) ++ (x ++ l₂) ++ ... ++ (x ++ lₙ) ++ x` where `L = [l₁, l₂, ..., lₙ]`. -/
theorem append_join_map_append (L : List (List α)) (x : List α) :
    x ++ (L.map (· ++ x)).join = (L.map (x ++ ·)).join ++ x 
goal: x ++ (List.map (fun x_1 => x_1 ++ x) L).join = (List.map (fun x_1 => x ++ x_1) L).join ++ x

full_name: List.reverse_join
code: /-- Reversing a join is the same as reversing the order of parts and reversing all parts. -/
theorem reverse_join (L : List (List α)) :
    L.join.reverse = (L.map reverse).reverse.join 
goal: L.join.reverse = (List.map List.reverse L).reverse.join

full_name: List.join_reverse
code: /-- Joining a reverse is the same as reversing all parts and reversing the joined result. -/
theorem join_reverse (L : List (List α)) :
    L.reverse.join = (L.map reverse).join.reverse 
goal: L.reverse.join = (List.map List.reverse L).join.reverse

full_name: List.sublist_join
code: /-- Any member of `L : List (List α))` is a sublist of `L.join` -/
lemma sublist_join (L : List (List α)) {s : List α} (hs : s ∈ L) :
    s.Sublist L.join 
goal: s.Sublist L.join