Theorem: Cycle.chain_of_pairwise
File: Mathlib/Data/List/Cycle.lean

tactic: induction' s using Cycle.induction_on with a l _
state_before: α : Type u_1
r : α → α → Prop
s : Cycle α
⊢ (∀ (a : α), a ∈ s → ∀ (b : α), b ∈ s → r a b) → Chain r s

tactic: exact fun _ => Cycle.Chain.nil r
state_before: case H0
α : Type u_1
r : α → α → Prop
s : Cycle α
⊢ (∀ (a : α), a ∈ nil → ∀ (b : α), b ∈ nil → r a b) → Chain r nil

case HI
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
⊢ (∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b) → Chain r ↑(a :: l)

tactic: intro hs
state_before: case HI
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
⊢ (∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b) → Chain r ↑(a :: l)

tactic: have Ha : a ∈ (a :: l : Cycle α) := by simp
state_before: case HI
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
⊢ Chain r ↑(a :: l)

tactic: have Hl : ∀ {b} (_hb : b ∈ l), b ∈ (a :: l : Cycle α) := @fun b hb => by simp [hb]
state_before: case HI
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
⊢ Chain r ↑(a :: l)

tactic: rw [Cycle.chain_coe_cons]
state_before: case HI
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
⊢ Chain r ↑(a :: l)

tactic: apply Pairwise.chain
state_before: case HI
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
⊢ List.Chain r a (l ++ [a])

tactic: rw [pairwise_cons]
state_before: case HI.p
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
⊢ List.Pairwise r (a :: (l ++ [a]))

tactic: refine'
  ⟨fun b hb => _,
    pairwise_append.2
      ⟨pairwise_of_forall_mem_list fun b hb c hc => hs b (Hl hb) c (Hl hc),
        pairwise_singleton r a, fun b hb c hc => _⟩⟩
state_before: case HI.p
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
⊢ (∀ (a' : α), a' ∈ l ++ [a] → r a a') ∧ List.Pairwise r (l ++ [a])

tactic: simp
state_before: α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
⊢ a ∈ ↑(a :: l)

tactic: simp [hb]
state_before: α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
b : α
hb : b ∈ l
⊢ b ∈ ↑(a :: l)

tactic: rw [mem_append] at hb
state_before: case HI.p.refine'_1
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ l ++ [a]
⊢ r a b

tactic: cases' hb with hb hb
state_before: case HI.p.refine'_1
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ l ∨ b ∈ [a]
⊢ r a b

tactic: exact hs a Ha b (Hl hb)
state_before: case HI.p.refine'_1.inl
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ l
⊢ r a b

tactic: rw [mem_singleton] at hb
state_before: case HI.p.refine'_1.inr
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ [a]
⊢ r a b

tactic: rw [hb]
state_before: case HI.p.refine'_1.inr
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b = a
⊢ r a b

tactic: exact hs a Ha a Ha
state_before: case HI.p.refine'_1.inr
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b = a
⊢ r a a

tactic: rw [mem_singleton] at hc
state_before: case HI.p.refine'_2
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ l
c : α
hc : c ∈ [a]
⊢ r b c

tactic: rw [hc]
state_before: case HI.p.refine'_2
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ l
c : α
hc : c = a
⊢ r b c

tactic: exact hs b (Hl hb) a Ha
state_before: case HI.p.refine'_2
α : Type u_1
r : α → α → Prop
s : Cycle α
a : α
l : List α
a✝ : (∀ (a : α), a ∈ ↑l → ∀ (b : α), b ∈ ↑l → r a b) → Chain r ↑l
hs : ∀ (a_1 : α), a_1 ∈ ↑(a :: l) → ∀ (b : α), b ∈ ↑(a :: l) → r a_1 b
Ha : a ∈ ↑(a :: l)
Hl : ∀ {b : α}, b ∈ l → b ∈ ↑(a :: l)
b : α
hb : b ∈ l
c : α
hc : c = a
⊢ r b a