Theorem: List.range_bind_sublistsLen_perm
File: Mathlib/Data/List/Sublists.lean

tactic: induction' l with h tl l_ih
state_before: α : Type u
β : Type v
γ : Type w
l : List α
⊢ ((range (l.length + 1)).bind fun n => sublistsLen n l) ~ l.sublists'
state_after: case nil
α : Type u
β : Type v
γ : Type w
⊢ ((range ([].length + 1)).bind fun n => sublistsLen n []) ~ [].sublists'

case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ((range ((h :: tl).length + 1)).bind fun n => sublistsLen n (h :: tl)) ~ (h :: tl).sublists'

tactic: simp [range_succ]
state_before: case nil
α : Type u
β : Type v
γ : Type w
⊢ ((range ([].length + 1)).bind fun n => sublistsLen n []) ~ [].sublists'
state_after: no goals

tactic: simp_rw [range_succ_eq_map, length, bind_cons, bind_map, sublistsLen_succ_cons, sublists'_cons,
  List.sublistsLen_zero, List.singleton_append]
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ((range ((h :: tl).length + 1)).bind fun n => sublistsLen n (h :: tl)) ~ (h :: tl).sublists'
state_after: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ([] :: (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl ++ map (cons h) (sublistsLen a tl)) ~
    tl.sublists' ++ map (cons h) tl.sublists'

tactic: refine ((bind_append_perm (range (tl.length + 1)) _ _).symm.cons _).trans ?_
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ([] :: (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl ++ map (cons h) (sublistsLen a tl)) ~
    tl.sublists' ++ map (cons h) tl.sublists'
state_after: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ [] ::
      (((range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ++
        (range (tl.length + 1)).bind fun a => map (cons h) (sublistsLen a tl)) ~
    tl.sublists' ++ map (cons h) tl.sublists'

tactic: simp_rw [← List.map_bind, ← cons_append]
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ [] ::
      (((range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ++
        (range (tl.length + 1)).bind fun a => map (cons h) (sublistsLen a tl)) ~
    tl.sublists' ++ map (cons h) tl.sublists'
state_after: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ([] :: (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ++
      map (cons h) ((range (tl.length + 1)).bind fun a => sublistsLen a tl) ~
    tl.sublists' ++ map (cons h) tl.sublists'

tactic: rw [← List.singleton_append, ← List.sublistsLen_zero tl]
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ([] :: (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ++
      map (cons h) ((range (tl.length + 1)).bind fun a => sublistsLen a tl) ~
    tl.sublists' ++ map (cons h) tl.sublists'
state_after: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ (sublistsLen 0 tl ++ (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ++
      map (cons h) ((range (tl.length + 1)).bind fun a => sublistsLen a tl) ~
    tl.sublists' ++ map (cons h) tl.sublists'

tactic: refine Perm.append ?_ (l_ih.map _)
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ (sublistsLen 0 tl ++ (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ++
      map (cons h) ((range (tl.length + 1)).bind fun a => sublistsLen a tl) ~
    tl.sublists' ++ map (cons h) tl.sublists'
state_after: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ (sublistsLen 0 tl ++ (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ~ tl.sublists'

tactic: rw [List.range_succ, append_bind, bind_singleton,
  sublistsLen_of_length_lt (Nat.lt_succ_self _), append_nil,
  ← List.bind_map Nat.succ fun n => sublistsLen n tl,
  ← bind_cons 0 _ fun n => sublistsLen n tl, ← range_succ_eq_map]
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ (sublistsLen 0 tl ++ (range (tl.length + 1)).bind fun a => sublistsLen (a + 1) tl) ~ tl.sublists'
state_after: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'

tactic: exact l_ih
state_before: case cons
α : Type u
β : Type v
γ : Type w
h : α
tl : List α
l_ih : ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
⊢ ((range (tl.length + 1)).bind fun n => sublistsLen n tl) ~ tl.sublists'
state_after: no goals