l3lab/ntp-mathlib huggingface dataset:
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  

Proof state:
m k : ℕ+
⊢ div m k = if ↑m % ↑k = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
dsimp [div, modDiv]
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  

Proof state:
m k : ℕ+
⊢ (modDivAux k (↑m % ↑k) (↑m / ↑k)).2 = if ↑m % ↑k = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
cases (m : ℕ) % (k : ℕ) with
  | zero =>
    rw [if_pos rfl]
    rfl
  | succ n =>
    rw [if_neg n.succ_ne_zero]
    rfl
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  

Proof state:
m k : ℕ+
x✝ : ℕ
⊢ (modDivAux k x✝ (↑m / ↑k)).2 = if x✝ = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
cases (m : ℕ) % (k : ℕ) with
  | zero =>
    rw [if_pos rfl]
    rfl
  | succ n =>
    rw [if_neg n.succ_ne_zero]
    rfl
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  cases (m : ℕ) % (k : ℕ) with
  

Proof state:
case zero
m k : ℕ+
⊢ (modDivAux k zero (↑m / ↑k)).2 = if zero = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
| zero =>
    rw [if_pos rfl]
    rfl
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  cases (m : ℕ) % (k : ℕ) with
  | zero =>
    

Proof state:
case zero
m k : ℕ+
⊢ (modDivAux k zero (↑m / ↑k)).2 = if zero = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
rw [if_pos rfl]
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  cases (m : ℕ) % (k : ℕ) with
  | zero =>
    rw [if_pos rfl]
    

Proof state:
case zero
m k : ℕ+
⊢ (modDivAux k zero (↑m / ↑k)).2 = pred (↑m / ↑k)

Next tactic:
rfl
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  cases (m : ℕ) % (k : ℕ) with
  | zero =>
    rw [if_pos rfl]
    rfl
  

Proof state:
case succ
m k : ℕ+
n : ℕ
⊢ (modDivAux k (succ n) (↑m / ↑k)).2 = if succ n = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
| succ n =>
    rw [if_neg n.succ_ne_zero]
    rfl
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  cases (m : ℕ) % (k : ℕ) with
  | zero =>
    rw [if_pos rfl]
    rfl
  | succ n =>
    

Proof state:
case succ
m k : ℕ+
n : ℕ
⊢ (modDivAux k (succ n) (↑m / ↑k)).2 = if succ n = 0 then pred (↑m / ↑k) else ↑m / ↑k

Next tactic:
rw [if_neg n.succ_ne_zero]
theorem div_coe (m k : ℕ+) :
    (div m k : ℕ) = ite ((m : ℕ) % (k : ℕ) = 0) ((m : ℕ) / (k : ℕ)).pred ((m : ℕ) / (k : ℕ)) := by
  dsimp [div, modDiv]
  cases (m : ℕ) % (k : ℕ) with
  | zero =>
    rw [if_pos rfl]
    rfl
  | succ n =>
    rw [if_neg n.succ_ne_zero]
    

Proof state:
case succ
m k : ℕ+
n : ℕ
⊢ (modDivAux k (succ n) (↑m / ↑k)).2 = ↑m / ↑k

Next tactic:
rfl
instance Int.canLiftPNat : CanLift ℤ ℕ+ (↑) ((0 < ·)) :=
  ⟨fun n hn =>
    ⟨Nat.toPNat' (Int.natAbs n), by
      

Proof state:
n : ℤ
hn : 0 < n
⊢ ↑↑(Nat.toPNat' (natAbs n)) = n

Next tactic:
rw [Nat.toPNat'_coe, if_pos (Int.natAbs_pos.2 hn.ne'),
        Int.natAbs_of_nonneg hn.le]
theorem toLowerSet_injective : Injective (toLowerSet : Ideal P → LowerSet P) := fun s t _ ↦ by
  

Proof state:
P : Type u_1
inst✝ : LE P
I J s✝ t✝ : Ideal P
x y : P
s t : Ideal P
x✝ : s.toLowerSet = t.toLowerSet
⊢ s = t

Next tactic:
cases s
theorem toLowerSet_injective : Injective (toLowerSet : Ideal P → LowerSet P) := fun s t _ ↦ by
  cases s
  

Proof state:
case mk
P : Type u_1
inst✝ : LE P
I J s t✝ : Ideal P
x y : P
t : Ideal P
toLowerSet✝ : LowerSet P
nonempty'✝ : Set.Nonempty toLowerSet✝.carrier
directed'✝ : DirectedOn (fun x x_1 => x ≤ x_1) toLowerSet✝.carrier
x✝ : { toLowerSet := toLowerSet✝, nonempty' := nonempty'✝, directed' := directed'✝ }.toLowerSet = t.toLowerSet
⊢ { toLowerSet := toLowerSet✝, nonempty' := nonempty'✝, directed' := directed'✝ } = t

Next tactic:
cases t
theorem toLowerSet_injective : Injective (toLowerSet : Ideal P → LowerSet P) := fun s t _ ↦ by
  cases s
  cases t
  

Proof state:
case mk.mk
P : Type u_1
inst✝ : LE P
I J s t : Ideal P
x y : P
toLowerSet✝¹ : LowerSet P
nonempty'✝¹ : Set.Nonempty toLowerSet✝¹.carrier
directed'✝¹ : DirectedOn (fun x x_1 => x ≤ x_1) toLowerSet✝¹.carrier
toLowerSet✝ : LowerSet P
nonempty'✝ : Set.Nonempty toLowerSet✝.carrier
directed'✝ : DirectedOn (fun x x_1 => x ≤ x_1) toLowerSet✝.carrier
x✝ :
  { toLowerSet := toLowerSet✝¹, nonempty' := nonempty'✝¹, directed' := directed'✝¹ }.toLowerSet =
    { toLowerSet := toLowerSet✝, nonempty' := nonempty'✝, directed' := directed'✝ }.toLowerSet
⊢ { toLowerSet := toLowerSet✝¹, nonempty' := nonempty'✝¹, directed' := directed'✝¹ } =
    { toLowerSet := toLowerSet✝, nonempty' := nonempty'✝, directed' := directed'✝ }

Next tactic:
congr
theorem isProper_of_not_mem {I : Ideal P} {p : P} (nmem : p ∉ I) : IsProper I :=
  ⟨fun hp ↦ by
    

Proof state:
P : Type u_1
inst✝ : LE P
I✝ J s t : Ideal P
x y : P
I : Ideal P
p : P
nmem : p ∉ I
hp : ↑I = univ
⊢ False

Next tactic:
have := mem_univ p
theorem isProper_of_not_mem {I : Ideal P} {p : P} (nmem : p ∉ I) : IsProper I :=
  ⟨fun hp ↦ by
    have := mem_univ p
    

Proof state:
P : Type u_1
inst✝ : LE P
I✝ J s t : Ideal P
x y : P
I : Ideal P
p : P
nmem : p ∉ I
hp : ↑I = univ
this : p ∈ univ
⊢ False

Next tactic:
rw [← hp] at this
theorem isProper_of_not_mem {I : Ideal P} {p : P} (nmem : p ∉ I) : IsProper I :=
  ⟨fun hp ↦ by
    have := mem_univ p
    rw [← hp] at this
    

Proof state:
P : Type u_1
inst✝ : LE P
I✝ J s t : Ideal P
x y : P
I : Ideal P
p : P
nmem : p ∉ I
hp : ↑I = univ
this : p ∈ ↑I
⊢ False

Next tactic:
exact nmem this
theorem inter_nonempty [IsDirected P (· ≥ ·)] (I J : Ideal P) : (I ∩ J : Set P).Nonempty := by
  

Proof state:
P : Type u_1
inst✝¹ : LE P
I✝ J✝ s t : Ideal P
x y : P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
I J : Ideal P
⊢ Set.Nonempty (↑I ∩ ↑J)

Next tactic:
obtain ⟨a, ha⟩ := I.nonempty
theorem inter_nonempty [IsDirected P (· ≥ ·)] (I J : Ideal P) : (I ∩ J : Set P).Nonempty := by
  obtain ⟨a, ha⟩ := I.nonempty
  

Proof state:
case intro
P : Type u_1
inst✝¹ : LE P
I✝ J✝ s t : Ideal P
x y : P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
I J : Ideal P
a : P
ha : a ∈ ↑I
⊢ Set.Nonempty (↑I ∩ ↑J)

Next tactic:
obtain ⟨b, hb⟩ := J.nonempty
theorem inter_nonempty [IsDirected P (· ≥ ·)] (I J : Ideal P) : (I ∩ J : Set P).Nonempty := by
  obtain ⟨a, ha⟩ := I.nonempty
  obtain ⟨b, hb⟩ := J.nonempty
  

Proof state:
case intro.intro
P : Type u_1
inst✝¹ : LE P
I✝ J✝ s t : Ideal P
x y : P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
I J : Ideal P
a : P
ha : a ∈ ↑I
b : P
hb : b ∈ ↑J
⊢ Set.Nonempty (↑I ∩ ↑J)

Next tactic:
obtain ⟨c, hac, hbc⟩ := exists_le_le a b
theorem inter_nonempty [IsDirected P (· ≥ ·)] (I J : Ideal P) : (I ∩ J : Set P).Nonempty := by
  obtain ⟨a, ha⟩ := I.nonempty
  obtain ⟨b, hb⟩ := J.nonempty
  obtain ⟨c, hac, hbc⟩ := exists_le_le a b
  

Proof state:
case intro.intro.intro.intro
P : Type u_1
inst✝¹ : LE P
I✝ J✝ s t : Ideal P
x y : P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
I J : Ideal P
a : P
ha : a ∈ ↑I
b : P
hb : b ∈ ↑J
c : P
hac : c ≤ a
hbc : c ≤ b
⊢ Set.Nonempty (↑I ∩ ↑J)

Next tactic:
exact ⟨c, I.lower hac ha, J.lower hbc hb⟩
theorem _root_.IsCoatom.isMaximal (hI : IsCoatom I) : IsMaximal I :=
  { IsCoatom.isProper hI with maximal_proper := fun _ hJ ↦ by 

Proof state:
P : Type u_1
inst✝² : LE P
inst✝¹ : IsDirected P fun x x_1 => x ≤ x_1
inst✝ : Nonempty P
I : Ideal P
hI : IsCoatom I
src✝ : IsProper I := IsCoatom.isProper hI
x✝ : Ideal P
hJ : I < x✝
⊢ ↑x✝ = univ

Next tactic:
simp [hI.2 _ hJ]
theorem top_of_top_mem (h : ⊤ ∈ I) : I = ⊤ := by
  

Proof state:
P : Type u_1
inst✝¹ : LE P
inst✝ : OrderTop P
I : Ideal P
h : ⊤ ∈ I
⊢ I = ⊤

Next tactic:
ext
theorem top_of_top_mem (h : ⊤ ∈ I) : I = ⊤ := by
  ext
  

Proof state:
case a.h
P : Type u_1
inst✝¹ : LE P
inst✝ : OrderTop P
I : Ideal P
h : ⊤ ∈ I
x✝ : P
⊢ x✝ ∈ ↑I ↔ x✝ ∈ ↑⊤

Next tactic:
exact iff_of_true (I.lower le_top h) trivial
/-- There is a bottom ideal when `P` has a bottom element. -/
instance : OrderBot (Ideal P) where
  bot := principal ⊥
  bot_le := by 

Proof state:
P : Type u_1
inst✝¹ : Preorder P
inst✝ : OrderBot P
⊢ ∀ (a : Ideal P), ⊥ ≤ a

Next tactic:
simp
/-- The infimum of two ideals of a co-directed order is their intersection. -/
instance : Inf (Ideal P) :=
  ⟨fun I J ↦
    { toLowerSet := I.toLowerSet ⊓ J.toLowerSet
      nonempty' := inter_nonempty I J
      directed' := fun x hx y hy ↦ ⟨x ⊔ y, ⟨sup_mem hx.1 hy.1, sup_mem hx.2 hy.2⟩, by 

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
x✝ : P
I✝ J✝ K s t I J : Ideal P
x : P
hx : x ∈ (I.toLowerSet ⊓ J.toLowerSet).carrier
y : P
hy : y ∈ (I.toLowerSet ⊓ J.toLowerSet).carrier
⊢ (fun x x_1 => x ≤ x_1) x (x ⊔ y) ∧ (fun x x_1 => x ≤ x_1) y (x ⊔ y)

Next tactic:
simp
/-- The supremum of two ideals of a co-directed order is the union of the down sets of the pointwise
supremum of `I` and `J`. -/
instance : Sup (Ideal P) :=
  ⟨fun I J ↦
    { carrier := { x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j }
      nonempty' := by
        

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
x : P
I✝ J✝ K s t I J : Ideal P
⊢ Set.Nonempty
    { carrier := {x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j},
        lower' :=
          (_ :
            ∀ (x y : P),
              y ≤ x → x ∈ {x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j} → y ∈ {x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j}) }.carrier

Next tactic:
cases' inter_nonempty I J with w h
/-- The supremum of two ideals of a co-directed order is the union of the down sets of the pointwise
supremum of `I` and `J`. -/
instance : Sup (Ideal P) :=
  ⟨fun I J ↦
    { carrier := { x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j }
      nonempty' := by
        cases' inter_nonempty I J with w h
        

Proof state:
case intro
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
x : P
I✝ J✝ K s t I J : Ideal P
w : P
h : w ∈ ↑I ∩ ↑J
⊢ Set.Nonempty
    { carrier := {x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j},
        lower' :=
          (_ :
            ∀ (x y : P),
              y ≤ x → x ∈ {x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j} → y ∈ {x | ∃ i ∈ I, ∃ j ∈ J, x ≤ i ⊔ j}) }.carrier

Next tactic:
exact ⟨w, w, h.1, w, h.2, le_sup_left⟩
theorem lt_sup_principal_of_not_mem (hx : x ∉ I) : I < I ⊔ principal x :=
  le_sup_left.lt_of_ne fun h ↦ hx <| by 

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : IsDirected P fun x x_1 => x ≥ x_1
x : P
I J K s t : Ideal P
hx : x ∉ I
h : I = I ⊔ principal x
⊢ x ∈ I

Next tactic:
simpa only [left_eq_sup, principal_le_iff] using h
instance : InfSet (Ideal P) :=
  ⟨fun S ↦
    { toLowerSet := ⨅ s ∈ S, toLowerSet s
      nonempty' :=
        ⟨⊥, by
          

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S : Set (Ideal P)
⊢ ⊥ ∈ (⨅ s ∈ S, s.toLowerSet).carrier

Next tactic:
rw [LowerSet.carrier_eq_coe, LowerSet.coe_iInf₂, Set.mem_iInter₂]
instance : InfSet (Ideal P) :=
  ⟨fun S ↦
    { toLowerSet := ⨅ s ∈ S, toLowerSet s
      nonempty' :=
        ⟨⊥, by
          rw [LowerSet.carrier_eq_coe, LowerSet.coe_iInf₂, Set.mem_iInter₂]
          

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S : Set (Ideal P)
⊢ ∀ i ∈ S, ⊥ ∈ ↑i.toLowerSet

Next tactic:
exact fun s _ ↦ s.bot_mem
instance : InfSet (Ideal P) :=
  ⟨fun S ↦
    { toLowerSet := ⨅ s ∈ S, toLowerSet s
      nonempty' :=
        ⟨⊥, by
          rw [LowerSet.carrier_eq_coe, LowerSet.coe_iInf₂, Set.mem_iInter₂]
          exact fun s _ ↦ s.bot_mem⟩
      directed' := fun a ha b hb ↦
        ⟨a ⊔ b,
          ⟨by
            

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S : Set (Ideal P)
a : P
ha : a ∈ (⨅ s ∈ S, s.toLowerSet).carrier
b : P
hb : b ∈ (⨅ s ∈ S, s.toLowerSet).carrier
⊢ a ⊔ b ∈ (⨅ s ∈ S, s.toLowerSet).carrier

Next tactic:
rw [LowerSet.carrier_eq_coe, LowerSet.coe_iInf₂, Set.mem_iInter₂] at ha hb ⊢
instance : InfSet (Ideal P) :=
  ⟨fun S ↦
    { toLowerSet := ⨅ s ∈ S, toLowerSet s
      nonempty' :=
        ⟨⊥, by
          rw [LowerSet.carrier_eq_coe, LowerSet.coe_iInf₂, Set.mem_iInter₂]
          exact fun s _ ↦ s.bot_mem⟩
      directed' := fun a ha b hb ↦
        ⟨a ⊔ b,
          ⟨by
            rw [LowerSet.carrier_eq_coe, LowerSet.coe_iInf₂, Set.mem_iInter₂] at ha hb ⊢
            

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S : Set (Ideal P)
a : P
ha : ∀ i ∈ S, a ∈ ↑i.toLowerSet
b : P
hb : ∀ i ∈ S, b ∈ ↑i.toLowerSet
⊢ ∀ i ∈ S, a ⊔ b ∈ ↑i.toLowerSet

Next tactic:
exact fun s hs ↦ sup_mem (ha _ hs) (hb _ hs)
@[simp]
theorem mem_sInf : x ∈ sInf S ↔ ∀ s ∈ S, x ∈ s := by
  

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S : Set (Ideal P)
⊢ x ∈ sInf S ↔ ∀ s ∈ S, x ∈ s

Next tactic:
simp_rw [← SetLike.mem_coe, coe_sInf, mem_iInter₂]
instance : CompleteLattice (Ideal P) :=
  { (inferInstance : Lattice (Ideal P)),
    completeLatticeOfInf (Ideal P) fun S ↦ by
      

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S✝ : Set (Ideal P)
src✝ : Lattice (Ideal P) := inferInstance
S : Set (Ideal P)
⊢ IsGLB S (sInf S)

Next tactic:
refine' ⟨fun s hs ↦ _, fun s hs ↦ by rwa [← coe_subset_coe, coe_sInf, subset_iInter₂_iff]⟩
instance : CompleteLattice (Ideal P) :=
  { (inferInstance : Lattice (Ideal P)),
    completeLatticeOfInf (Ideal P) fun S ↦ by
      refine' ⟨fun s hs ↦ _, fun s hs ↦ by 

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S✝ : Set (Ideal P)
src✝ : Lattice (Ideal P) := inferInstance
S : Set (Ideal P)
s : Ideal P
hs : s ∈ lowerBounds S
⊢ s ≤ sInf S

Next tactic:
rwa [← coe_subset_coe, coe_sInf, subset_iInter₂_iff]
instance : CompleteLattice (Ideal P) :=
  { (inferInstance : Lattice (Ideal P)),
    completeLatticeOfInf (Ideal P) fun S ↦ by
      refine' ⟨fun s hs ↦ _, fun s hs ↦ by rwa [← coe_subset_coe, coe_sInf, subset_iInter₂_iff]⟩
      

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S✝ : Set (Ideal P)
src✝ : Lattice (Ideal P) := inferInstance
S : Set (Ideal P)
s : Ideal P
hs : s ∈ S
⊢ sInf S ≤ s

Next tactic:
rw [← coe_subset_coe, coe_sInf]
instance : CompleteLattice (Ideal P) :=
  { (inferInstance : Lattice (Ideal P)),
    completeLatticeOfInf (Ideal P) fun S ↦ by
      refine' ⟨fun s hs ↦ _, fun s hs ↦ by rwa [← coe_subset_coe, coe_sInf, subset_iInter₂_iff]⟩
      rw [← coe_subset_coe, coe_sInf]
      

Proof state:
P : Type u_1
inst✝¹ : SemilatticeSup P
inst✝ : OrderBot P
x : P
I J K : Ideal P
S✝ : Set (Ideal P)
src✝ : Lattice (Ideal P) := inferInstance
S : Set (Ideal P)
s : Ideal P
hs : s ∈ S
⊢ ⋂ s ∈ S, ↑s ⊆ ↑s

Next tactic:
exact biInter_subset_of_mem hs
theorem eq_sup_of_le_sup {x i j : P} (hi : i ∈ I) (hj : j ∈ J) (hx : x ≤ i ⊔ j) :
    ∃ i' ∈ I, ∃ j' ∈ J, x = i' ⊔ j' := by
  

Proof state:
P : Type u_1
inst✝ : DistribLattice P
I J : Ideal P
x i j : P
hi : i ∈ I
hj : j ∈ J
hx : x ≤ i ⊔ j
⊢ ∃ i' ∈ I, ∃ j' ∈ J, x = i' ⊔ j'

Next tactic:
refine' ⟨x ⊓ i, I.lower inf_le_right hi, x ⊓ j, J.lower inf_le_right hj, _⟩
theorem eq_sup_of_le_sup {x i j : P} (hi : i ∈ I) (hj : j ∈ J) (hx : x ≤ i ⊔ j) :
    ∃ i' ∈ I, ∃ j' ∈ J, x = i' ⊔ j' := by
  refine' ⟨x ⊓ i, I.lower inf_le_right hi, x ⊓ j, J.lower inf_le_right hj, _⟩
  

Proof state:
P : Type u_1
inst✝ : DistribLattice P
I J : Ideal P
x i j : P
hi : i ∈ I
hj : j ∈ J
hx : x ≤ i ⊔ j
⊢ x = x ⊓ i ⊔ x ⊓ j

Next tactic:
calc
    x = x ⊓ (i ⊔ j) := left_eq_inf.mpr hx
    _ = x ⊓ i ⊔ x ⊓ j := inf_sup_left
theorem IsProper.not_mem_of_compl_mem (hI : IsProper I) (hxc : xᶜ ∈ I) : x ∉ I := by
  

Proof state:
P : Type u_1
inst✝ : BooleanAlgebra P
x : P
I : Ideal P
hI : IsProper I
hxc : xᶜ ∈ I
⊢ x ∉ I

Next tactic:
intro hx
theorem IsProper.not_mem_of_compl_mem (hI : IsProper I) (hxc : xᶜ ∈ I) : x ∉ I := by
  intro hx
  

Proof state:
P : Type u_1
inst✝ : BooleanAlgebra P
x : P
I : Ideal P
hI : IsProper I
hxc : xᶜ ∈ I
hx : x ∈ I
⊢ False

Next tactic:
apply hI.top_not_mem
theorem IsProper.not_mem_of_compl_mem (hI : IsProper I) (hxc : xᶜ ∈ I) : x ∉ I := by
  intro hx
  apply hI.top_not_mem
  

Proof state:
P : Type u_1
inst✝ : BooleanAlgebra P
x : P
I : Ideal P
hI : IsProper I
hxc : xᶜ ∈ I
hx : x ∈ I
⊢ ⊤ ∈ I

Next tactic:
have ht : x ⊔ xᶜ ∈ I := sup_mem ‹_› ‹_›
theorem IsProper.not_mem_of_compl_mem (hI : IsProper I) (hxc : xᶜ ∈ I) : x ∉ I := by
  intro hx
  apply hI.top_not_mem
  have ht : x ⊔ xᶜ ∈ I := sup_mem ‹_› ‹_›
  

Proof state:
P : Type u_1
inst✝ : BooleanAlgebra P
x : P
I : Ideal P
hI : IsProper I
hxc : xᶜ ∈ I
hx : x ∈ I
ht : x ⊔ xᶜ ∈ I
⊢ ⊤ ∈ I

Next tactic:
rwa [sup_compl_eq_top] at ht
theorem IsProper.not_mem_or_compl_not_mem (hI : IsProper I) : x ∉ I ∨ xᶜ ∉ I := by
  

Proof state:
P : Type u_1
inst✝ : BooleanAlgebra P
x : P
I : Ideal P
hI : IsProper I
⊢ x ∉ I ∨ xᶜ ∉ I

Next tactic:
have h : xᶜ ∈ I → x ∉ I := hI.not_mem_of_compl_mem
theorem IsProper.not_mem_or_compl_not_mem (hI : IsProper I) : x ∉ I ∨ xᶜ ∉ I := by
  have h : xᶜ ∈ I → x ∉ I := hI.not_mem_of_compl_mem
  

Proof state:
P : Type u_1
inst✝ : BooleanAlgebra P
x : P
I : Ideal P
hI : IsProper I
h : xᶜ ∈ I → x ∉ I
⊢ x ∉ I ∨ xᶜ ∉ I

Next tactic:
tauto
theorem sequenceOfCofinals.monotone : Monotone (sequenceOfCofinals p 𝒟) := by
  

Proof state:
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
⊢ Monotone (sequenceOfCofinals p 𝒟)

Next tactic:
apply monotone_nat_of_le_succ
theorem sequenceOfCofinals.monotone : Monotone (sequenceOfCofinals p 𝒟) := by
  apply monotone_nat_of_le_succ
  

Proof state:
case hf
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
⊢ ∀ (n : ℕ), sequenceOfCofinals p 𝒟 n ≤ sequenceOfCofinals p 𝒟 (n + 1)

Next tactic:
intro n
theorem sequenceOfCofinals.monotone : Monotone (sequenceOfCofinals p 𝒟) := by
  apply monotone_nat_of_le_succ
  intro n
  

Proof state:
case hf
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
n : ℕ
⊢ sequenceOfCofinals p 𝒟 n ≤ sequenceOfCofinals p 𝒟 (n + 1)

Next tactic:
dsimp only [sequenceOfCofinals, Nat.add]
theorem sequenceOfCofinals.monotone : Monotone (sequenceOfCofinals p 𝒟) := by
  apply monotone_nat_of_le_succ
  intro n
  dsimp only [sequenceOfCofinals, Nat.add]
  

Proof state:
case hf
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
n : ℕ
⊢ sequenceOfCofinals p 𝒟 n ≤
    match Encodable.decode n with
    | none => sequenceOfCofinals p 𝒟 n
    | some i => Cofinal.above (𝒟 i) (sequenceOfCofinals p 𝒟 n)

Next tactic:
cases (Encodable.decode n : Option ι)
theorem sequenceOfCofinals.monotone : Monotone (sequenceOfCofinals p 𝒟) := by
  apply monotone_nat_of_le_succ
  intro n
  dsimp only [sequenceOfCofinals, Nat.add]
  cases (Encodable.decode n : Option ι)
  · 

Proof state:
case hf.none
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
n : ℕ
⊢ sequenceOfCofinals p 𝒟 n ≤
    match none with
    | none => sequenceOfCofinals p 𝒟 n
    | some i => Cofinal.above (𝒟 i) (sequenceOfCofinals p 𝒟 n)

Next tactic:
rfl
theorem sequenceOfCofinals.monotone : Monotone (sequenceOfCofinals p 𝒟) := by
  apply monotone_nat_of_le_succ
  intro n
  dsimp only [sequenceOfCofinals, Nat.add]
  cases (Encodable.decode n : Option ι)
  · rfl
  · 

Proof state:
case hf.some
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
n : ℕ
val✝ : ι
⊢ sequenceOfCofinals p 𝒟 n ≤
    match some val✝ with
    | none => sequenceOfCofinals p 𝒟 n
    | some i => Cofinal.above (𝒟 i) (sequenceOfCofinals p 𝒟 n)

Next tactic:
apply Cofinal.le_above
theorem sequenceOfCofinals.encode_mem (i : ι) :
    sequenceOfCofinals p 𝒟 (Encodable.encode i + 1) ∈ 𝒟 i := by
  

Proof state:
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
i : ι
⊢ sequenceOfCofinals p 𝒟 (Encodable.encode i + 1) ∈ 𝒟 i

Next tactic:
dsimp only [sequenceOfCofinals, Nat.add]
theorem sequenceOfCofinals.encode_mem (i : ι) :
    sequenceOfCofinals p 𝒟 (Encodable.encode i + 1) ∈ 𝒟 i := by
  dsimp only [sequenceOfCofinals, Nat.add]
  

Proof state:
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
i : ι
⊢ (match Encodable.decode (Encodable.encode i) with
    | none => sequenceOfCofinals p 𝒟 (Encodable.encode i)
    | some i_1 => Cofinal.above (𝒟 i_1) (sequenceOfCofinals p 𝒟 (Encodable.encode i))) ∈
    𝒟 i

Next tactic:
rw [Encodable.encodek]
theorem sequenceOfCofinals.encode_mem (i : ι) :
    sequenceOfCofinals p 𝒟 (Encodable.encode i + 1) ∈ 𝒟 i := by
  dsimp only [sequenceOfCofinals, Nat.add]
  rw [Encodable.encodek]
  

Proof state:
P : Type u_1
inst✝¹ : Preorder P
p : P
ι : Type u_2
inst✝ : Encodable ι
𝒟 : ι → Cofinal P
i : ι
⊢ (match some i with
    | none => sequenceOfCofinals p 𝒟 (Encodable.encode i)
    | some i_1 => Cofinal.above (𝒟 i_1) (sequenceOfCofinals p 𝒟 (Encodable.encode i))) ∈
    𝒟 i

Next tactic:
apply Cofinal.above_mem
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
  

Proof state:
⊢ univ = {0, 1}

Next tactic:
ext x
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
  ext x
  

Proof state:
case a
x : Fin 2
⊢ x ∈ univ ↔ x ∈ {0, 1}

Next tactic:
fin_cases x
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
  ext x
  fin_cases x <;> 

Proof state:
case a.head
⊢ { val := 0, isLt := (_ : 0 < 2) } ∈ univ ↔ { val := 0, isLt := (_ : 0 < 2) } ∈ {0, 1}

Next tactic:
simp
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
  ext x
  fin_cases x <;> 

Proof state:
case a.tail.head
⊢ { val := 1, isLt := (_ : (fun a => a < 2) 1) } ∈ univ ↔ { val := 1, isLt := (_ : (fun a => a < 2) 1) } ∈ {0, 1}

Next tactic:
simp
@[simp]
theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) :
    s.weightedVSubOfPoint p b w = ∑ i in s, w i • (p i -ᵥ b) := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p : ι → P
b : P
⊢ (weightedVSubOfPoint s p b) w = ∑ i in s, w i • (p i -ᵥ b)

Next tactic:
simp [weightedVSubOfPoint, LinearMap.sum_apply]
/-- The value of `weightedVSubOfPoint`, where the given points are equal. -/
@[simp (high)]
theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) :
    s.weightedVSubOfPoint (fun _ => p) b w = (∑ i in s, w i) • (p -ᵥ b) := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w : ι → k
p b : P
⊢ (weightedVSubOfPoint s (fun x => p) b) w = (∑ i in s, w i) • (p -ᵥ b)

Next tactic:
rw [weightedVSubOfPoint_apply, sum_smul]
/-- `weightedVSubOfPoint` gives equal results for two families of weights and two families of
points that are equal on `s`. -/
theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
    (hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) :
    s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by
  

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝² : Ring k
inst✝¹ : AddCommGroup V
inst✝ : Module k V
S : AffineSpace V P
ι : Type u_4
s : Finset ι
ι₂ : Type u_5
s₂ : Finset ι₂
w₁ w₂ : ι → k
hw : ∀ i ∈ s, w₁ i = w₂ i
p₁ p₂ : ι → P
hp : ∀ i ∈ s, p₁ i = p₂ i
b : P
⊢ (weightedVSubOfPoint s p₁ b) w₁ = (weightedVSubOfPoint s p₂ b) w₂

Next tactic:
simp_rw [weightedVSubOfPoint_apply]