l3lab/ntp-mathlib huggingface dataset:
theorem sublistsLenAux_append {α β γ : Type*} :
    ∀ (n : ℕ) (l : List α) (f : List α → β) (g : β → γ) (r : List β) (s : List γ),
      sublistsLenAux n l (g ∘ f) (r.map g ++ s) = (sublistsLenAux n l f r).map g ++ s
  | 0, l, f, g, r, s => by unfold sublistsLenAux; simp
  | n + 1, [], f, g, r, s => rfl
  | n + 1, a :: l, f, g, r, s => by
    unfold sublistsLenAux
    

Proof state:
α✝ : Type u
β✝ : Type v
γ✝ : Type w
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
a : α
l : List α
f : List α → β
g : β → γ
r : List β
s : List γ
⊢ sublistsLenAux (Nat.add n 0 + 1) l (g ∘ f) (sublistsLenAux (Nat.add n 0) l ((g ∘ f) ∘ cons a) (map g r ++ s)) =
    map g (sublistsLenAux (Nat.add n 0 + 1) l f (sublistsLenAux (Nat.add n 0) l (f ∘ cons a) r)) ++ s

Next tactic:
simp only [show (g ∘ f) ∘ List.cons a = g ∘ f ∘ List.cons a by rfl, sublistsLenAux_append,
      sublistsLenAux_append]
theorem sublistsLenAux_append {α β γ : Type*} :
    ∀ (n : ℕ) (l : List α) (f : List α → β) (g : β → γ) (r : List β) (s : List γ),
      sublistsLenAux n l (g ∘ f) (r.map g ++ s) = (sublistsLenAux n l f r).map g ++ s
  | 0, l, f, g, r, s => by unfold sublistsLenAux; simp
  | n + 1, [], f, g, r, s => rfl
  | n + 1, a :: l, f, g, r, s => by
    unfold sublistsLenAux
    simp only [show (g ∘ f) ∘ List.cons a = g ∘ f ∘ List.cons a by 

Proof state:
α✝ : Type u
β✝ : Type v
γ✝ : Type w
α : Type u_1
β : Type u_2
γ : Type u_3
n : ℕ
a : α
l : List α
f : List α → β
g : β → γ
r : List β
s : List γ
⊢ (g ∘ f) ∘ cons a = g ∘ f ∘ cons a

Next tactic:
rfl
theorem sublistsLenAux_eq {α β : Type*} (l : List α) (n) (f : List α → β) (r) :
    sublistsLenAux n l f r = (sublistsLen n l).map f ++ r := by
  

Proof state:
α✝ : Type u
β✝ : Type v
γ : Type w
α : Type u_1
β : Type u_2
l : List α
n : ℕ
f : List α → β
r : List β
⊢ sublistsLenAux n l f r = map f (sublistsLen n l) ++ r

Next tactic:
rw [sublistsLen, ← sublistsLenAux_append]
theorem sublistsLenAux_eq {α β : Type*} (l : List α) (n) (f : List α → β) (r) :
    sublistsLenAux n l f r = (sublistsLen n l).map f ++ r := by
  rw [sublistsLen, ← sublistsLenAux_append]; 

Proof state:
α✝ : Type u
β✝ : Type v
γ : Type w
α : Type u_1
β : Type u_2
l : List α
n : ℕ
f : List α → β
r : List β
⊢ sublistsLenAux n l f r = sublistsLenAux n l (f ∘ id) (map f [] ++ r)

Next tactic:
rfl
theorem sublistsLenAux_zero {α : Type*} (l : List α) (f : List α → β) (r) :
    sublistsLenAux 0 l f r = f [] :: r := by 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l : List α
f : List α → β
r : List β
⊢ sublistsLenAux 0 l f r = f [] :: r

Next tactic:
cases l
theorem sublistsLenAux_zero {α : Type*} (l : List α) (f : List α → β) (r) :
    sublistsLenAux 0 l f r = f [] :: r := by cases l <;> 

Proof state:
case nil
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
f : List α → β
r : List β
⊢ sublistsLenAux 0 [] f r = f [] :: r

Next tactic:
rfl
theorem sublistsLenAux_zero {α : Type*} (l : List α) (f : List α → β) (r) :
    sublistsLenAux 0 l f r = f [] :: r := by cases l <;> 

Proof state:
case cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
f : List α → β
r : List β
head✝ : α
tail✝ : List α
⊢ sublistsLenAux 0 (head✝ :: tail✝) f r = f [] :: r

Next tactic:
rfl
@[simp]
theorem sublistsLen_succ_cons {α : Type*} (n) (a : α) (l) :
    sublistsLen (n + 1) (a :: l) = sublistsLen (n + 1) l ++ (sublistsLen n l).map (cons a) := by
  

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l : List α
⊢ sublistsLen (n + 1) (a :: l) = sublistsLen (n + 1) l ++ map (cons a) (sublistsLen n l)

Next tactic:
rw [sublistsLen, sublistsLenAux, sublistsLenAux_eq, sublistsLenAux_eq, map_id,
      append_nil]
@[simp]
theorem sublistsLen_succ_cons {α : Type*} (n) (a : α) (l) :
    sublistsLen (n + 1) (a :: l) = sublistsLen (n + 1) l ++ (sublistsLen n l).map (cons a) := by
  rw [sublistsLen, sublistsLenAux, sublistsLenAux_eq, sublistsLenAux_eq, map_id,
      append_nil]; 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l : List α
⊢ sublistsLen (n + 1) l ++ map (id ∘ cons a) (sublistsLen n l) = sublistsLen (n + 1) l ++ map (cons a) (sublistsLen n l)

Next tactic:
rfl
theorem sublistsLen_one {α : Type*} (l : List α) : sublistsLen 1 l = l.reverse.map ([·]) :=
  l.rec (by 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l : List α
⊢ sublistsLen 1 [] = map (fun x => [x]) (reverse [])

Next tactic:
rw [sublistsLen_succ_nil, reverse_nil, map_nil]
theorem sublistsLen_one {α : Type*} (l : List α) : sublistsLen 1 l = l.reverse.map ([·]) :=
  l.rec (by rw [sublistsLen_succ_nil, reverse_nil, map_nil]) fun a s ih ↦ by
    

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l : List α
a : α
s : List α
ih : sublistsLen 1 s = map (fun x => [x]) (reverse s)
⊢ sublistsLen 1 (a :: s) = map (fun x => [x]) (reverse (a :: s))

Next tactic:
rw [sublistsLen_succ_cons, ih, reverse_cons, map_append, sublistsLen_zero]
theorem sublistsLen_one {α : Type*} (l : List α) : sublistsLen 1 l = l.reverse.map ([·]) :=
  l.rec (by rw [sublistsLen_succ_nil, reverse_nil, map_nil]) fun a s ih ↦ by
    rw [sublistsLen_succ_cons, ih, reverse_cons, map_append, sublistsLen_zero]; 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l : List α
a : α
s : List α
ih : sublistsLen 1 s = map (fun x => [x]) (reverse s)
⊢ map (fun x => [x]) (reverse s) ++ map (cons a) [[]] = map (fun x => [x]) (reverse s) ++ map (fun x => [x]) [a]

Next tactic:
rfl
@[simp]
theorem length_sublistsLen {α : Type*} :
    ∀ (n) (l : List α), length (sublistsLen n l) = Nat.choose (length l) n
  | 0, l => by 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l : List α
⊢ length (sublistsLen 0 l) = Nat.choose (length l) 0

Next tactic:
simp
@[simp]
theorem length_sublistsLen {α : Type*} :
    ∀ (n) (l : List α), length (sublistsLen n l) = Nat.choose (length l) n
  | 0, l => by simp
  | _ + 1, [] => by 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n✝ : ℕ
⊢ length (sublistsLen (n✝ + 1) []) = Nat.choose (length []) (n✝ + 1)

Next tactic:
simp
@[simp]
theorem length_sublistsLen {α : Type*} :
    ∀ (n) (l : List α), length (sublistsLen n l) = Nat.choose (length l) n
  | 0, l => by simp
  | _ + 1, [] => by simp
  | n + 1, a :: l => by
    

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l : List α
⊢ length (sublistsLen (n + 1) (a :: l)) = Nat.choose (length (a :: l)) (n + 1)

Next tactic:
rw [sublistsLen_succ_cons, length_append, length_sublistsLen (n+1) l,
      length_map, length_sublistsLen n l, length_cons, Nat.choose_succ_succ, add_comm]
theorem sublistsLen_sublist_sublists' {α : Type*} :
    ∀ (n) (l : List α), sublistsLen n l <+ sublists' l
  | 0, l => by 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l : List α
⊢ sublistsLen 0 l <+ sublists' l

Next tactic:
simp
theorem sublistsLen_sublist_sublists' {α : Type*} :
    ∀ (n) (l : List α), sublistsLen n l <+ sublists' l
  | 0, l => by simp
  | _ + 1, [] => nil_sublist _
  | n + 1, a :: l => by
    

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l : List α
⊢ sublistsLen (n + 1) (a :: l) <+ sublists' (a :: l)

Next tactic:
rw [sublistsLen_succ_cons, sublists'_cons]
theorem sublistsLen_sublist_sublists' {α : Type*} :
    ∀ (n) (l : List α), sublistsLen n l <+ sublists' l
  | 0, l => by simp
  | _ + 1, [] => nil_sublist _
  | n + 1, a :: l => by
    rw [sublistsLen_succ_cons, sublists'_cons]
    

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l : List α
⊢ sublistsLen (n + 1) l ++ map (cons a) (sublistsLen n l) <+ sublists' l ++ map (cons a) (sublists' l)

Next tactic:
exact (sublistsLen_sublist_sublists' _ _).append ((sublistsLen_sublist_sublists' _ _).map _)
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
l₁ l₂ : List α
h : l₁ <+ l₂
⊢ sublistsLen n l₁ <+ sublistsLen n l₂

Next tactic:
induction' n with n IHn generalizing l₁ l₂
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · 

Proof state:
case zero
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l₁ l₂ : List α
h : l₁ <+ l₂
⊢ sublistsLen zero l₁ <+ sublistsLen zero l₂

Next tactic:
simp
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  

Proof state:
case succ
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁ l₂ : List α
h : l₁ <+ l₂
⊢ sublistsLen (succ n) l₁ <+ sublistsLen (succ n) l₂

Next tactic:
induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH; · 

Proof state:
case succ.slnil
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁ l₂ : List α
⊢ sublistsLen (succ n) [] <+ sublistsLen (succ n) []

Next tactic:
rfl
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH; · rfl
  · 

Proof state:
case succ.cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁✝ l₂✝ l₁ l₂ : List α
a : α
a✝ : l₁ <+ l₂
IH : sublistsLen (succ n) l₁ <+ sublistsLen (succ n) l₂
⊢ sublistsLen (succ n) l₁ <+ sublistsLen (succ n) (a :: l₂)

Next tactic:
refine' IH.trans _
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH; · rfl
  · refine' IH.trans _
    

Proof state:
case succ.cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁✝ l₂✝ l₁ l₂ : List α
a : α
a✝ : l₁ <+ l₂
IH : sublistsLen (succ n) l₁ <+ sublistsLen (succ n) l₂
⊢ sublistsLen (succ n) l₂ <+ sublistsLen (succ n) (a :: l₂)

Next tactic:
rw [sublistsLen_succ_cons]
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH; · rfl
  · refine' IH.trans _
    rw [sublistsLen_succ_cons]
    

Proof state:
case succ.cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁✝ l₂✝ l₁ l₂ : List α
a : α
a✝ : l₁ <+ l₂
IH : sublistsLen (succ n) l₁ <+ sublistsLen (succ n) l₂
⊢ sublistsLen (succ n) l₂ <+ sublistsLen (n + 1) l₂ ++ map (cons a) (sublistsLen n l₂)

Next tactic:
apply sublist_append_left
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH; · rfl
  · refine' IH.trans _
    rw [sublistsLen_succ_cons]
    apply sublist_append_left
  · 

Proof state:
case succ.cons₂
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁✝ l₂✝ l₁ l₂ : List α
a : α
s : l₁ <+ l₂
IH : sublistsLen (succ n) l₁ <+ sublistsLen (succ n) l₂
⊢ sublistsLen (succ n) (a :: l₁) <+ sublistsLen (succ n) (a :: l₂)

Next tactic:
simp [sublistsLen_succ_cons]
theorem sublistsLen_sublist_of_sublist {α : Type*} (n) {l₁ l₂ : List α} (h : l₁ <+ l₂) :
    sublistsLen n l₁ <+ sublistsLen n l₂ := by
  induction' n with n IHn generalizing l₁ l₂; · simp
  induction' h with l₁ l₂ a _ IH l₁ l₂ a s IH; · rfl
  · refine' IH.trans _
    rw [sublistsLen_succ_cons]
    apply sublist_append_left
  · simp [sublistsLen_succ_cons]
    

Proof state:
case succ.cons₂
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
IHn : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → sublistsLen n l₁ <+ sublistsLen n l₂
l₁✝ l₂✝ l₁ l₂ : List α
a : α
s : l₁ <+ l₂
IH : sublistsLen (succ n) l₁ <+ sublistsLen (succ n) l₂
⊢ sublistsLen (n + 1) l₁ ++ map (cons a) (sublistsLen n l₁) <+ sublistsLen (n + 1) l₂ ++ map (cons a) (sublistsLen n l₂)

Next tactic:
exact IH.append ((IHn s).map _)
theorem length_of_sublistsLen {α : Type*} :
    ∀ {n} {l l' : List α}, l' ∈ sublistsLen n l → length l' = n
  | 0, l, l', h => by 

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' : List α
h : l' ∈ sublistsLen 0 l
⊢ length l' = 0

Next tactic:
simp_all
theorem length_of_sublistsLen {α : Type*} :
    ∀ {n} {l l' : List α}, l' ∈ sublistsLen n l → length l' = n
  | 0, l, l', h => by simp_all
  | n + 1, a :: l, l', h => by
    

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l l' : List α
h : l' ∈ sublistsLen (n + 1) (a :: l)
⊢ length l' = n + 1

Next tactic:
rw [sublistsLen_succ_cons, mem_append, mem_map] at h
theorem length_of_sublistsLen {α : Type*} :
    ∀ {n} {l l' : List α}, l' ∈ sublistsLen n l → length l' = n
  | 0, l, l', h => by simp_all
  | n + 1, a :: l, l', h => by
    rw [sublistsLen_succ_cons, mem_append, mem_map] at h
    

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l l' : List α
h : l' ∈ sublistsLen (n + 1) l ∨ ∃ a_1 ∈ sublistsLen n l, a :: a_1 = l'
⊢ length l' = n + 1

Next tactic:
rcases h with (h | ⟨l', h, rfl⟩)
theorem length_of_sublistsLen {α : Type*} :
    ∀ {n} {l l' : List α}, l' ∈ sublistsLen n l → length l' = n
  | 0, l, l', h => by simp_all
  | n + 1, a :: l, l', h => by
    rw [sublistsLen_succ_cons, mem_append, mem_map] at h
    rcases h with (h | ⟨l', h, rfl⟩)
    · 

Proof state:
case inl
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l l' : List α
h : l' ∈ sublistsLen (n + 1) l
⊢ length l' = n + 1

Next tactic:
exact length_of_sublistsLen h
theorem length_of_sublistsLen {α : Type*} :
    ∀ {n} {l l' : List α}, l' ∈ sublistsLen n l → length l' = n
  | 0, l, l', h => by simp_all
  | n + 1, a :: l, l', h => by
    rw [sublistsLen_succ_cons, mem_append, mem_map] at h
    rcases h with (h | ⟨l', h, rfl⟩)
    · exact length_of_sublistsLen h
    · 

Proof state:
case inr.intro.intro
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
n : ℕ
a : α
l l' : List α
h : l' ∈ sublistsLen n l
⊢ length (a :: l') = n + 1

Next tactic:
exact congr_arg (· + 1) (length_of_sublistsLen h)
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  

Proof state:
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' : List α
h : l' <+ l
⊢ l' ∈ sublistsLen (length l') l

Next tactic:
induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · 

Proof state:
case slnil
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' : List α
⊢ [] ∈ sublistsLen (length []) []

Next tactic:
simp
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · simp
  · 

Proof state:
case cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' l₁ l₂ : List α
a : α
s : l₁ <+ l₂
IH : l₁ ∈ sublistsLen (length l₁) l₂
⊢ l₁ ∈ sublistsLen (length l₁) (a :: l₂)

Next tactic:
cases' l₁ with b l₁
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · simp
  · cases' l₁ with b l₁
    · 

Proof state:
case cons.nil
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' l₂ : List α
a : α
s : [] <+ l₂
IH : [] ∈ sublistsLen (length []) l₂
⊢ [] ∈ sublistsLen (length []) (a :: l₂)

Next tactic:
simp
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · simp
  · cases' l₁ with b l₁
    · simp
    · 

Proof state:
case cons.cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' l₂ : List α
a b : α
l₁ : List α
s : b :: l₁ <+ l₂
IH : b :: l₁ ∈ sublistsLen (length (b :: l₁)) l₂
⊢ b :: l₁ ∈ sublistsLen (length (b :: l₁)) (a :: l₂)

Next tactic:
rw [length, sublistsLen_succ_cons]
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · simp
  · cases' l₁ with b l₁
    · simp
    · rw [length, sublistsLen_succ_cons]
      

Proof state:
case cons.cons
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' l₂ : List α
a b : α
l₁ : List α
s : b :: l₁ <+ l₂
IH : b :: l₁ ∈ sublistsLen (length (b :: l₁)) l₂
⊢ b :: l₁ ∈ sublistsLen (length l₁ + 1) l₂ ++ map (cons a) (sublistsLen (length l₁) l₂)

Next tactic:
exact mem_append_left _ IH
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · simp
  · cases' l₁ with b l₁
    · simp
    · rw [length, sublistsLen_succ_cons]
      exact mem_append_left _ IH
  · 

Proof state:
case cons₂
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' l₁ l₂ : List α
a : α
s : l₁ <+ l₂
IH : l₁ ∈ sublistsLen (length l₁) l₂
⊢ a :: l₁ ∈ sublistsLen (length (a :: l₁)) (a :: l₂)

Next tactic:
rw [length, sublistsLen_succ_cons]
theorem mem_sublistsLen_self {α : Type*} {l l' : List α} (h : l' <+ l) :
    l' ∈ sublistsLen (length l') l := by
  induction' h with l₁ l₂ a s IH l₁ l₂ a s IH
  · simp
  · cases' l₁ with b l₁
    · simp
    · rw [length, sublistsLen_succ_cons]
      exact mem_append_left _ IH
  · rw [length, sublistsLen_succ_cons]
    

Proof state:
case cons₂
α✝ : Type u
β : Type v
γ : Type w
α : Type u_1
l l' l₁ l₂ : List α
a : α
s : l₁ <+ l₂
IH : l₁ ∈ sublistsLen (length l₁) l₂
⊢ a :: l₁ ∈ sublistsLen (length l₁ + 1) l₂ ++ map (cons a) (sublistsLen (length l₁) l₂)

Next tactic:
exact mem_append_right _ (mem_map.2 ⟨_, IH, rfl⟩)
@[simp]
theorem sublistsLen_length : ∀ l : List α, sublistsLen l.length l = [l]
  | [] => rfl
  | a :: l => by
    

Proof state:
α : Type u
β : Type v
γ : Type w
a : α
l : List α
⊢ sublistsLen (length (a :: l)) (a :: l) = [a :: l]

Next tactic:
simp only [length, sublistsLen_succ_cons, sublistsLen_length, map,
      sublistsLen_of_length_lt (lt_succ_self _), nil_append]
theorem Pairwise.sublists' {R} :
    ∀ {l : List α}, Pairwise R l → Pairwise (Lex (swap R)) (sublists' l)
  | _, Pairwise.nil => pairwise_singleton _ _
  | _, @Pairwise.cons _ _ a l H₁ H₂ => by
    

Proof state:
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
a : α
l : List α
H₁ : ∀ a' ∈ l, R a a'
H₂ : Pairwise R l
⊢ Pairwise (Lex (swap R)) (List.sublists' (a :: l))

Next tactic:
simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp,
      and_imp]
theorem Pairwise.sublists' {R} :
    ∀ {l : List α}, Pairwise R l → Pairwise (Lex (swap R)) (sublists' l)
  | _, Pairwise.nil => pairwise_singleton _ _
  | _, @Pairwise.cons _ _ a l H₁ H₂ => by
    simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp,
      and_imp]
    

Proof state:
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
a : α
l : List α
H₁ : ∀ a' ∈ l, R a a'
H₂ : Pairwise R l
⊢ Pairwise (Lex (swap R)) (List.sublists' l) ∧
    Pairwise (fun a_1 b => Lex (swap R) (a :: a_1) (a :: b)) (List.sublists' l) ∧
      ∀ (a_1 : List α), a_1 <+ l → ∀ (b x : List α), x <+ l → a :: x = b → Lex (swap R) a_1 b

Next tactic:
refine' ⟨H₂.sublists', H₂.sublists'.imp fun l₁ => Lex.cons l₁, _⟩
theorem Pairwise.sublists' {R} :
    ∀ {l : List α}, Pairwise R l → Pairwise (Lex (swap R)) (sublists' l)
  | _, Pairwise.nil => pairwise_singleton _ _
  | _, @Pairwise.cons _ _ a l H₁ H₂ => by
    simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp,
      and_imp]
    refine' ⟨H₂.sublists', H₂.sublists'.imp fun l₁ => Lex.cons l₁, _⟩
    

Proof state:
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
a : α
l : List α
H₁ : ∀ a' ∈ l, R a a'
H₂ : Pairwise R l
⊢ ∀ (a_1 : List α), a_1 <+ l → ∀ (b x : List α), x <+ l → a :: x = b → Lex (swap R) a_1 b

Next tactic:
rintro l₁ sl₁ x l₂ _ rfl
theorem Pairwise.sublists' {R} :
    ∀ {l : List α}, Pairwise R l → Pairwise (Lex (swap R)) (sublists' l)
  | _, Pairwise.nil => pairwise_singleton _ _
  | _, @Pairwise.cons _ _ a l H₁ H₂ => by
    simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp,
      and_imp]
    refine' ⟨H₂.sublists', H₂.sublists'.imp fun l₁ => Lex.cons l₁, _⟩
    rintro l₁ sl₁ x l₂ _ rfl
    

Proof state:
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
a : α
l : List α
H₁ : ∀ a' ∈ l, R a a'
H₂ : Pairwise R l
l₁ : List α
sl₁ : l₁ <+ l
l₂ : List α
a✝ : l₂ <+ l
⊢ Lex (swap R) l₁ (a :: l₂)

Next tactic:
cases' l₁ with b l₁
theorem Pairwise.sublists' {R} :
    ∀ {l : List α}, Pairwise R l → Pairwise (Lex (swap R)) (sublists' l)
  | _, Pairwise.nil => pairwise_singleton _ _
  | _, @Pairwise.cons _ _ a l H₁ H₂ => by
    simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp,
      and_imp]
    refine' ⟨H₂.sublists', H₂.sublists'.imp fun l₁ => Lex.cons l₁, _⟩
    rintro l₁ sl₁ x l₂ _ rfl
    cases' l₁ with b l₁; · 

Proof state:
case nil
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
a : α
l : List α
H₁ : ∀ a' ∈ l, R a a'
H₂ : Pairwise R l
l₂ : List α
a✝ : l₂ <+ l
sl₁ : [] <+ l
⊢ Lex (swap R) [] (a :: l₂)

Next tactic:
constructor
theorem Pairwise.sublists' {R} :
    ∀ {l : List α}, Pairwise R l → Pairwise (Lex (swap R)) (sublists' l)
  | _, Pairwise.nil => pairwise_singleton _ _
  | _, @Pairwise.cons _ _ a l H₁ H₂ => by
    simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp,
      and_imp]
    refine' ⟨H₂.sublists', H₂.sublists'.imp fun l₁ => Lex.cons l₁, _⟩
    rintro l₁ sl₁ x l₂ _ rfl
    cases' l₁ with b l₁; · constructor
    

Proof state:
case cons
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
a : α
l : List α
H₁ : ∀ a' ∈ l, R a a'
H₂ : Pairwise R l
l₂ : List α
a✝ : l₂ <+ l
b : α
l₁ : List α
sl₁ : b :: l₁ <+ l
⊢ Lex (swap R) (b :: l₁) (a :: l₂)

Next tactic:
exact Lex.rel (H₁ _ <| sl₁.subset <| mem_cons_self _ _)
theorem pairwise_sublists {R} {l : List α} (H : Pairwise R l) :
    Pairwise (fun l₁ l₂ => Lex R (reverse l₁) (reverse l₂)) (sublists l) := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
l : List α
H : Pairwise R l
⊢ Pairwise (fun l₁ l₂ => Lex R (reverse l₁) (reverse l₂)) (sublists l)

Next tactic:
have := (pairwise_reverse.2 H).sublists'
theorem pairwise_sublists {R} {l : List α} (H : Pairwise R l) :
    Pairwise (fun l₁ l₂ => Lex R (reverse l₁) (reverse l₂)) (sublists l) := by
  have := (pairwise_reverse.2 H).sublists'
  

Proof state:
α : Type u
β : Type v
γ : Type w
R : α → α → Prop
l : List α
H : Pairwise R l
this : Pairwise (Lex (swap fun b a => R a b)) (sublists' (reverse l))
⊢ Pairwise (fun l₁ l₂ => Lex R (reverse l₁) (reverse l₂)) (sublists l)

Next tactic:
rwa [sublists'_reverse, pairwise_map] at this
@[simp]
theorem nodup_sublists {l : List α} : Nodup (sublists l) ↔ Nodup l :=
  ⟨fun h => (h.sublist (map_ret_sublist_sublists _)).of_map _, fun h =>
    (pairwise_sublists h).imp @fun l₁ l₂ h => by 

Proof state:
α : Type u
β : Type v
γ : Type w
l : List α
h✝ : Nodup l
l₁ l₂ : List α
h : Lex (fun x x_1 => x ≠ x_1) (reverse l₁) (reverse l₂)
⊢ l₁ ≠ l₂

Next tactic:
simpa using h.to_ne
@[simp]
theorem nodup_sublists' {l : List α} : Nodup (sublists' l) ↔ Nodup l := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
l : List α
⊢ Nodup (sublists' l) ↔ Nodup l

Next tactic:
rw [sublists'_eq_sublists, nodup_map_iff reverse_injective, nodup_sublists, nodup_reverse]