l3lab/ntp-mathlib huggingface dataset:
private theorem exists_term_realize_eq_freeCommRing (p : FreeCommRing α) :
    ∃ t : Language.ring.Term α,
      (t.realize FreeCommRing.of : FreeCommRing α) = p :=
  FreeCommRing.induction_on p
    ⟨-1, by 

Proof state:
α : Type u_1
p : FreeCommRing α
⊢ Term.realize FreeCommRing.of (-1) = -1

Next tactic:
simp [Term.realize]
private theorem exists_term_realize_eq_freeCommRing (p : FreeCommRing α) :
    ∃ t : Language.ring.Term α,
      (t.realize FreeCommRing.of : FreeCommRing α) = p :=
  FreeCommRing.induction_on p
    ⟨-1, by simp [Term.realize]⟩
    (fun a => ⟨Term.var a, by 

Proof state:
α : Type u_1
p : FreeCommRing α
a : α
⊢ Term.realize FreeCommRing.of (var a) = FreeCommRing.of a

Next tactic:
simp [Term.realize]
private theorem exists_term_realize_eq_freeCommRing (p : FreeCommRing α) :
    ∃ t : Language.ring.Term α,
      (t.realize FreeCommRing.of : FreeCommRing α) = p :=
  FreeCommRing.induction_on p
    ⟨-1, by simp [Term.realize]⟩
    (fun a => ⟨Term.var a, by simp [Term.realize]⟩)
    (fun x y ⟨t₁, ht₁⟩ ⟨t₂, ht₂⟩ =>
      ⟨t₁ + t₂, by 

Proof state:
α : Type u_1
p x y : FreeCommRing α
x✝¹ : ∃ t, Term.realize FreeCommRing.of t = x
x✝ : ∃ t, Term.realize FreeCommRing.of t = y
t₁ : Term ring α
ht₁ : Term.realize FreeCommRing.of t₁ = x
t₂ : Term ring α
ht₂ : Term.realize FreeCommRing.of t₂ = y
⊢ Term.realize FreeCommRing.of (t₁ + t₂) = x + y

Next tactic:
simp_all [Term.realize]
private theorem exists_term_realize_eq_freeCommRing (p : FreeCommRing α) :
    ∃ t : Language.ring.Term α,
      (t.realize FreeCommRing.of : FreeCommRing α) = p :=
  FreeCommRing.induction_on p
    ⟨-1, by simp [Term.realize]⟩
    (fun a => ⟨Term.var a, by simp [Term.realize]⟩)
    (fun x y ⟨t₁, ht₁⟩ ⟨t₂, ht₂⟩ =>
      ⟨t₁ + t₂, by simp_all [Term.realize]⟩)
    (fun x y ⟨t₁, ht₁⟩ ⟨t₂, ht₂⟩ =>
      ⟨t₁ * t₂, by 

Proof state:
α : Type u_1
p x y : FreeCommRing α
x✝¹ : ∃ t, Term.realize FreeCommRing.of t = x
x✝ : ∃ t, Term.realize FreeCommRing.of t = y
t₁ : Term ring α
ht₁ : Term.realize FreeCommRing.of t₁ = x
t₂ : Term ring α
ht₂ : Term.realize FreeCommRing.of t₂ = y
⊢ Term.realize FreeCommRing.of (t₁ * t₂) = x * y

Next tactic:
simp_all [Term.realize]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
⊢ Term.realize v (termOfFreeCommRing p) = (FreeCommRing.lift v) p

Next tactic:
let _ := compatibleRingOfRing (FreeCommRing α)
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
⊢ Term.realize v (termOfFreeCommRing p) = (FreeCommRing.lift v) p

Next tactic:
rw [termOfFreeCommRing]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
⊢ Term.realize v (Classical.choose (_ : ∃ t, Term.realize FreeCommRing.of t = p)) = (FreeCommRing.lift v) p

Next tactic:
conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => 

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
| (FreeCommRing.lift v) p

Next tactic:
rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
⊢ Term.realize v (Classical.choose (_ : ∃ t, Term.realize FreeCommRing.of t = p)) =
    (FreeCommRing.lift v)
      (Term.realize FreeCommRing.of (Classical.choose (_ : ∃ t, Term.realize FreeCommRing.of t = p)))

Next tactic:
induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝¹ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
x✝ : Term ring α
⊢ Term.realize v x✝ = (FreeCommRing.lift v) (Term.realize FreeCommRing.of x✝)

Next tactic:
induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  

Proof state:
case var
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
_a✝ : α
⊢ Term.realize v (var _a✝) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (var _a✝))

Next tactic:
| var _ => simp
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => 

Proof state:
case var
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
_a✝ : α
⊢ Term.realize v (var _a✝) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (var _a✝))

Next tactic:
simp
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  

Proof state:
case func
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
l✝ : ℕ
f : Functions ring l✝
a : Fin l✝ → Term ring α
ih : ∀ (a_1 : Fin l✝), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func f a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func f a))

Next tactic:
| func f a ih =>
    cases f <;>
    simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    

Proof state:
case func
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
l✝ : ℕ
f : Functions ring l✝
a : Fin l✝ → Term ring α
ih : ∀ (a_1 : Fin l✝), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func f a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func f a))

Next tactic:
cases f
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    

Proof state:
case func.add
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
a : Fin 2 → Term ring α
ih : ∀ (a_1 : Fin 2), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func ringFunc.add a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func ringFunc.add a))

Next tactic:
simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    

Proof state:
case func.mul
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
a : Fin 2 → Term ring α
ih : ∀ (a_1 : Fin 2), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func ringFunc.mul a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func ringFunc.mul a))

Next tactic:
simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    

Proof state:
case func.neg
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
a : Fin 1 → Term ring α
ih : ∀ (a_1 : Fin 1), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func ringFunc.neg a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func ringFunc.neg a))

Next tactic:
simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    

Proof state:
case func.zero
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
a : Fin 0 → Term ring α
ih : ∀ (a_1 : Fin 0), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func ringFunc.zero a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func ringFunc.zero a))

Next tactic:
simp [ih]
@[simp]
theorem realize_termOfFreeCommRing (p : FreeCommRing α) (v : α → R) :
    (termOfFreeCommRing p).realize v = FreeCommRing.lift v p := by
  let _ := compatibleRingOfRing (FreeCommRing α)
  rw [termOfFreeCommRing]
  conv_rhs => rw [← Classical.choose_spec (exists_term_realize_eq_freeCommRing p)]
  induction Classical.choose (exists_term_realize_eq_freeCommRing p) with
  | var _ => simp
  | func f a ih =>
    cases f <;>
    

Proof state:
case func.one
α : Type u_1
R : Type u_2
inst✝¹ : CommRing R
inst✝ : CompatibleRing R
p : FreeCommRing α
v : α → R
x✝ : CompatibleRing (FreeCommRing α) := compatibleRingOfRing (FreeCommRing α)
a : Fin 0 → Term ring α
ih : ∀ (a_1 : Fin 0), Term.realize v (a a_1) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (a a_1))
⊢ Term.realize v (func ringFunc.one a) = (FreeCommRing.lift v) (Term.realize FreeCommRing.of (func ringFunc.one a))

Next tactic:
simp [ih]
theorem pairwise_on_bool (hr : Symmetric r) {a b : α} :
    Pairwise (r on fun c => cond c a b) ↔ r a b := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a✝ b✝ : α
hr : Symmetric r
a b : α
⊢ Pairwise (r on fun c => bif c then a else b) ↔ r a b

Next tactic:
simpa [Pairwise, Function.onFun] using @hr a b
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
hs : Set.Nonempty s
⊢ Set.Pairwise s (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z

Next tactic:
constructor
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
hs : Set.Nonempty s
⊢ Set.Pairwise s (r on f) → ∃ z, ∀ x ∈ s, r (f x) z

Next tactic:
rcases hs with ⟨y, hy⟩
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · rcases hs with ⟨y, hy⟩
    

Proof state:
case mp.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
y : ι
hy : y ∈ s
⊢ Set.Pairwise s (r on f) → ∃ z, ∀ x ∈ s, r (f x) z

Next tactic:
refine' fun H => ⟨f y, fun x hx => _⟩
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · rcases hs with ⟨y, hy⟩
    refine' fun H => ⟨f y, fun x hx => _⟩
    

Proof state:
case mp.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
y : ι
hy : y ∈ s
H : Set.Pairwise s (r on f)
x : ι
hx : x ∈ s
⊢ r (f x) (f y)

Next tactic:
rcases eq_or_ne x y with (rfl | hne)
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · rcases hs with ⟨y, hy⟩
    refine' fun H => ⟨f y, fun x hx => _⟩
    rcases eq_or_ne x y with (rfl | hne)
    · 

Proof state:
case mp.intro.inl
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
H : Set.Pairwise s (r on f)
x : ι
hx hy : x ∈ s
⊢ r (f x) (f x)

Next tactic:
apply IsRefl.refl
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · rcases hs with ⟨y, hy⟩
    refine' fun H => ⟨f y, fun x hx => _⟩
    rcases eq_or_ne x y with (rfl | hne)
    · apply IsRefl.refl
    · 

Proof state:
case mp.intro.inr
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
y : ι
hy : y ∈ s
H : Set.Pairwise s (r on f)
x : ι
hx : x ∈ s
hne : x ≠ y
⊢ r (f x) (f y)

Next tactic:
exact H hx hy hne
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · rcases hs with ⟨y, hy⟩
    refine' fun H => ⟨f y, fun x hx => _⟩
    rcases eq_or_ne x y with (rfl | hne)
    · apply IsRefl.refl
    · exact H hx hy hne
  · 

Proof state:
case mpr
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
hs : Set.Nonempty s
⊢ (∃ z, ∀ x ∈ s, r (f x) z) → Set.Pairwise s (r on f)

Next tactic:
rintro ⟨z, hz⟩ x hx y hy _
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :
    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  constructor
  · rcases hs with ⟨y, hy⟩
    refine' fun H => ⟨f y, fun x hx => _⟩
    rcases eq_or_ne x y with (rfl | hne)
    · apply IsRefl.refl
    · exact H hx hy hne
  · rintro ⟨z, hz⟩ x hx y hy _
    

Proof state:
case mpr.intro
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s✝ t u : Set α
a b : α
inst✝ : IsEquiv α r
s : Set ι
hs : Set.Nonempty s
z : α
hz : ∀ x ∈ s, r (f x) z
x : ι
hx : x ∈ s
y : ι
hy : y ∈ s
a✝ : x ≠ y
⊢ (r on f) x y

Next tactic:
exact @IsTrans.trans α r _ (f x) z (f y) (hz _ hx) (IsSymm.symm _ _ <| hz _ hy)
theorem pairwise_iff_exists_forall [Nonempty ι] (s : Set α) (f : α → ι) {r : ι → ι → Prop}
    [IsEquiv ι r] : s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r✝ p q : α → α → Prop
f✝ g : ι → α
s✝ t u : Set α
a b : α
inst✝¹ : Nonempty ι
s : Set α
f : α → ι
r : ι → ι → Prop
inst✝ : IsEquiv ι r
⊢ Set.Pairwise s (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z

Next tactic:
rcases s.eq_empty_or_nonempty with (rfl | hne)
theorem pairwise_iff_exists_forall [Nonempty ι] (s : Set α) (f : α → ι) {r : ι → ι → Prop}
    [IsEquiv ι r] : s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  rcases s.eq_empty_or_nonempty with (rfl | hne)
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r✝ p q : α → α → Prop
f✝ g : ι → α
s t u : Set α
a b : α
inst✝¹ : Nonempty ι
f : α → ι
r : ι → ι → Prop
inst✝ : IsEquiv ι r
⊢ Set.Pairwise ∅ (r on f) ↔ ∃ z, ∀ x ∈ ∅, r (f x) z

Next tactic:
simp
theorem pairwise_iff_exists_forall [Nonempty ι] (s : Set α) (f : α → ι) {r : ι → ι → Prop}
    [IsEquiv ι r] : s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by
  rcases s.eq_empty_or_nonempty with (rfl | hne)
  · simp
  · 

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r✝ p q : α → α → Prop
f✝ g : ι → α
s✝ t u : Set α
a b : α
inst✝¹ : Nonempty ι
s : Set α
f : α → ι
r : ι → ι → Prop
inst✝ : IsEquiv ι r
hne : Set.Nonempty s
⊢ Set.Pairwise s (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z

Next tactic:
exact hne.pairwise_iff_exists_forall
theorem pairwise_union :
    (s ∪ t).Pairwise r ↔
    s.Pairwise r ∧ t.Pairwise r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b ∧ r b a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
⊢ Set.Pairwise (s ∪ t) r ↔ Set.Pairwise s r ∧ Set.Pairwise t r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b ∧ r b a

Next tactic:
simp only [Set.Pairwise, mem_union, or_imp, forall_and]
theorem pairwise_union :
    (s ∪ t).Pairwise r ↔
    s.Pairwise r ∧ t.Pairwise r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b ∧ r b a := by
  simp only [Set.Pairwise, mem_union, or_imp, forall_and]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
⊢ (((∀ x ∈ s, ∀ x_1 ∈ s, x ≠ x_1 → r x x_1) ∧ ∀ x ∈ t, ∀ x_1 ∈ s, x ≠ x_1 → r x x_1) ∧
      (∀ x ∈ s, ∀ x_1 ∈ t, x ≠ x_1 → r x x_1) ∧ ∀ x ∈ t, ∀ x_1 ∈ t, x ≠ x_1 → r x x_1) ↔
    (∀ x ∈ s, ∀ x_1 ∈ s, x ≠ x_1 → r x x_1) ∧
      (∀ x ∈ t, ∀ x_1 ∈ t, x ≠ x_1 → r x x_1) ∧
        (∀ x ∈ s, ∀ x_1 ∈ t, x ≠ x_1 → r x x_1) ∧ ∀ x ∈ s, ∀ x_2 ∈ t, x ≠ x_2 → r x_2 x

Next tactic:
exact
    ⟨fun H => ⟨H.1.1, H.2.2, H.2.1, fun x hx y hy hne => H.1.2 y hy x hx hne.symm⟩, fun H =>
      ⟨⟨H.1, fun x hx y hy hne => H.2.2.2 y hy x hx hne.symm⟩, H.2.2.1, H.2.1⟩⟩
theorem pairwise_union_of_symmetric (hr : Symmetric r) :
    (s ∪ t).Pairwise r ↔ s.Pairwise r ∧ t.Pairwise r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b :=
  pairwise_union.trans <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
hr : Symmetric r
⊢ (Set.Pairwise s r ∧ Set.Pairwise t r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b ∧ r b a) ↔
    Set.Pairwise s r ∧ Set.Pairwise t r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b

Next tactic:
simp only [hr.iff, and_self_iff]
theorem pairwise_insert :
    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, a ≠ b → r a b ∧ r b a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
⊢ Set.Pairwise (insert a s) r ↔ Set.Pairwise s r ∧ ∀ b ∈ s, a ≠ b → r a b ∧ r b a

Next tactic:
simp only [insert_eq, pairwise_union, pairwise_singleton, true_and_iff, mem_singleton_iff,
    forall_eq]
theorem pairwise_insert_of_not_mem (ha : a ∉ s) :
    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, r a b ∧ r b a :=
  pairwise_insert.trans <|
    and_congr_right' <| forall₂_congr fun b hb => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b✝ : α
ha : a ∉ s
b : α
hb : b ∈ s
⊢ a ≠ b → r a b ∧ r b a ↔ r a b ∧ r b a

Next tactic:
simp [(ne_of_mem_of_not_mem hb ha).symm]
theorem pairwise_insert_of_symmetric (hr : Symmetric r) :
    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, a ≠ b → r a b := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
hr : Symmetric r
⊢ Set.Pairwise (insert a s) r ↔ Set.Pairwise s r ∧ ∀ b ∈ s, a ≠ b → r a b

Next tactic:
simp only [pairwise_insert, hr.iff a, and_self_iff]
theorem pairwise_insert_of_symmetric_of_not_mem (hr : Symmetric r) (ha : a ∉ s) :
    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, r a b := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
hr : Symmetric r
ha : a ∉ s
⊢ Set.Pairwise (insert a s) r ↔ Set.Pairwise s r ∧ ∀ b ∈ s, r a b

Next tactic:
simp only [pairwise_insert_of_not_mem ha, hr.iff a, and_self_iff]
theorem pairwise_pair : Set.Pairwise {a, b} r ↔ a ≠ b → r a b ∧ r b a := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
⊢ Set.Pairwise {a, b} r ↔ a ≠ b → r a b ∧ r b a

Next tactic:
simp [pairwise_insert]
theorem pairwise_pair_of_symmetric (hr : Symmetric r) : Set.Pairwise {a, b} r ↔ a ≠ b → r a b := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
ι : Type u_4
ι' : Type u_5
r p q : α → α → Prop
f g : ι → α
s t u : Set α
a b : α
hr : Symmetric r
⊢ Set.Pairwise {a, b} r ↔ a ≠ b → r a b

Next tactic:
simp [pairwise_insert_of_symmetric hr]