l3lab/ntp-mathlib huggingface dataset:
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : a = x
h2 : ¬b = x
this :
  if f b = t then if f x = t then False else Adj G s (f x) else if f x = t then Adj G (f b) s else Adj G (f b) (f x)
⊢ Adj G s (f b) ↔ ¬a = b

Next tactic:
split_ifs at this
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; 

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : a = x
h2 : ¬b = x
h✝ : ¬f b = t
this : Adj G (f b) s
⊢ Adj G s (f b) ↔ ¬a = b

Next tactic:
subst h1
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; 

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
ms : s ∉ Set.range f
a b : Fin n
h✝ : ¬f b = t
this : Adj G (f b) s
hx : f a = t
h2 : ¬b = a
⊢ Adj G s (f b) ↔ ¬a = b

Next tactic:
tauto
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · 

Proof state:
case pos
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : b = x
⊢ Adj G (f a) s ↔ ¬a = b

Next tactic:
have := (@ha a x).mpr h1
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        

Proof state:
case pos
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : b = x
this :
  if f a = t then if f x = t then False else Adj G s (f x) else if f x = t then Adj G (f a) s else Adj G (f a) (f x)
⊢ Adj G (f a) s ↔ ¬a = b

Next tactic:
split_ifs at this
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; 

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : b = x
h✝ : ¬f a = t
this : Adj G (f a) s
⊢ Adj G (f a) s ↔ ¬a = b

Next tactic:
subst h2
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; 

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
ms : s ∉ Set.range f
a b : Fin n
h✝ : ¬f a = t
this : Adj G (f a) s
hx : f b = t
h1 : ¬a = b
⊢ Adj G (f a) s ↔ ¬a = b

Next tactic:
tauto
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; tauto
      · 

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : ¬b = x
⊢ Adj G (f a) (f b) ↔ ¬a = b

Next tactic:
rw [← @ha a b]
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; tauto
      · rw [← @ha a b]
        

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : ¬b = x
⊢ Adj G (f a) (f b) ↔
    if f a = t then if f b = t then False else Adj G s (f b) else if f b = t then Adj G (f a) s else Adj G (f a) (f b)

Next tactic:
have := (@hi a x).mt h1
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; tauto
      · rw [← @ha a b]
        have := (@hi a x).mt h1
        

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : ¬b = x
this : ¬f a = f x
⊢ Adj G (f a) (f b) ↔
    if f a = t then if f b = t then False else Adj G s (f b) else if f b = t then Adj G (f a) s else Adj G (f a) (f b)

Next tactic:
have := (@hi b x).mt h2
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; tauto
      · rw [← @ha a b]
        have := (@hi a x).mt h1
        have := (@hi b x).mt h2
        

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
x : Fin n
hx : f x = t
ms : s ∉ Set.range f
a b : Fin n
h1 : ¬a = x
h2 : ¬b = x
this✝ : ¬f a = f x
this : ¬f b = f x
⊢ Adj G (f a) (f b) ↔
    if f a = t then if f b = t then False else Adj G s (f b) else if f b = t then Adj G (f a) s else Adj G (f a) (f b)

Next tactic:
simp_all
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; tauto
      · rw [← @ha a b]
        have := (@hi a x).mt h1
        have := (@hi b x).mt h2
        simp_all
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
mt : t ∉ Set.range f
⊢ Nonempty (⊤ ↪g G)

Next tactic:
use ⟨f, hi⟩
/-- Clique-freeness is preserved by `replaceVertex`. -/
theorem cliqueFree_of_replaceVertex_cliqueFree [DecidableEq α] (s t : α) (h : G.CliqueFree n) :
    (G.replaceVertex s t).CliqueFree n := by
  contrapose h
  obtain ⟨⟨f, hi⟩, ha⟩ := topEmbeddingOfNotCliqueFree h
  simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq] at ha
  rw [not_cliqueFree_iff]
  by_cases mt : t ∈ Set.range f
  · obtain ⟨x, hx⟩ := mt
    by_cases ms : s ∈ Set.range f
    · obtain ⟨y, hy⟩ := ms
      by_cases hst : s = t
      · simp_all [not_cliqueFree_iff]
      · replace ha := @ha x y; simp_all
    · use ⟨fun v => if v = x then s else f v, ?_⟩
      swap
      · intro a b
        dsimp only
        split_ifs
        · simp_all
        · intro; simp_all
        · intro; simp_all
        · apply hi
      intro a b
      simp only [Function.Embedding.coeFn_mk, top_adj, ne_eq]
      split_ifs with h1 h2 h2
      · simp_all
      · have := (@ha b x).mpr h2
        split_ifs at this; subst h1; tauto
      · have := (@ha a x).mpr h1
        split_ifs at this; subst h2; tauto
      · rw [← @ha a b]
        have := (@hi a x).mt h1
        have := (@hi b x).mt h2
        simp_all
  · use ⟨f, hi⟩; 

Proof state:
case map_rel_iff'
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s✝ : Finset α
inst✝ : DecidableEq α
s t : α
h : ¬CliqueFree (replaceVertex G s t) n
f : Fin n → α
hi : Injective f
ha :
  ∀ {a b : Fin n},
    (if f a = t then if f b = t then False else Adj G s (f b)
      else if f b = t then Adj G (f a) s else Adj G (f a) (f b)) ↔
      ¬a = b
mt : t ∉ Set.range f
⊢ ∀ {a b : Fin n}, Adj G ({ toFun := f, inj' := hi } a) ({ toFun := f, inj' := hi } b) ↔ Adj ⊤ a b

Next tactic:
simp_all
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  

Proof state:
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s : Finset α
⊢ CliqueFree G 2 ↔ G = ⊥

Next tactic:
classical
  constructor
  · simp_rw [← edgeSet_eq_empty, Set.eq_empty_iff_forall_not_mem, Sym2.forall, mem_edgeSet]
    exact fun h a b hab => h _ ⟨by simpa [hab.ne], card_doubleton hab.ne⟩
  · rintro rfl
    exact cliqueFree_bot le_rfl
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  classical
  

Proof state:
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s : Finset α
⊢ CliqueFree G 2 ↔ G = ⊥

Next tactic:
constructor
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  classical
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s : Finset α
⊢ CliqueFree G 2 → G = ⊥

Next tactic:
simp_rw [← edgeSet_eq_empty, Set.eq_empty_iff_forall_not_mem, Sym2.forall, mem_edgeSet]
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  classical
  constructor
  · simp_rw [← edgeSet_eq_empty, Set.eq_empty_iff_forall_not_mem, Sym2.forall, mem_edgeSet]
    

Proof state:
case mp
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s : Finset α
⊢ CliqueFree G 2 → ∀ (x y : α), ¬Adj G x y

Next tactic:
exact fun h a b hab => h _ ⟨by simpa [hab.ne], card_doubleton hab.ne⟩
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  classical
  constructor
  · simp_rw [← edgeSet_eq_empty, Set.eq_empty_iff_forall_not_mem, Sym2.forall, mem_edgeSet]
    exact fun h a b hab => h _ ⟨by 

Proof state:
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s : Finset α
h : CliqueFree G 2
a b : α
hab : Adj G a b
⊢ IsClique G ↑{a, b}

Next tactic:
simpa [hab.ne]
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  classical
  constructor
  · simp_rw [← edgeSet_eq_empty, Set.eq_empty_iff_forall_not_mem, Sym2.forall, mem_edgeSet]
    exact fun h a b hab => h _ ⟨by simpa [hab.ne], card_doubleton hab.ne⟩
  · 

Proof state:
case mpr
α : Type u_1
β : Type u_2
G H : SimpleGraph α
m n : ℕ
s : Finset α
⊢ G = ⊥ → CliqueFree G 2

Next tactic:
rintro rfl
@[simp]
theorem cliqueFree_two : G.CliqueFree 2 ↔ G = ⊥ := by
  classical
  constructor
  · simp_rw [← edgeSet_eq_empty, Set.eq_empty_iff_forall_not_mem, Sym2.forall, mem_edgeSet]
    exact fun h a b hab => h _ ⟨by simpa [hab.ne], card_doubleton hab.ne⟩
  · rintro rfl
    

Proof state:
case mpr
α : Type u_1
β : Type u_2
H : SimpleGraph α
m n : ℕ
s : Finset α
⊢ CliqueFree ⊥ 2

Next tactic:
exact cliqueFree_bot le_rfl
theorem CliqueFreeOn.mono (hmn : m ≤ n) (hG : G.CliqueFreeOn s m) : G.CliqueFreeOn s n := by
  

Proof state:
α : Type u_1
β : Type u_2
G H : SimpleGraph α
s s₁ s₂ : Set α
t : Finset α
a b : α
m n : ℕ
hmn : m ≤ n
hG : CliqueFreeOn G s m
⊢ CliqueFreeOn G s n

Next tactic:
rintro t hts ht
theorem CliqueFreeOn.mono (hmn : m ≤ n) (hG : G.CliqueFreeOn s m) : G.CliqueFreeOn s n := by
  rintro t hts ht
  

Proof state:
α : Type u_1
β : Type u_2
G H : SimpleGraph α
s s₁ s₂ : Set α
t✝ : Finset α
a b : α
m n : ℕ
hmn : m ≤ n
hG : CliqueFreeOn G s m
t : Finset α
hts : ↑t ⊆ s
ht : IsNClique G n t
⊢ False

Next tactic:
obtain ⟨u, hut, hu⟩ := t.exists_smaller_set _ (hmn.trans ht.card_eq.ge)