Skip to content

Commit 3cd501d

Browse files
refactor: Make Frame extend HeytingAlgebra (#10560)
It is mathematically true that a frame is a Heyting algebra. However we want nice defeqs, so we can't just provide an instance defining `himp` as some supremum. Instead, we need `Frame` to directly extend `HeytingAlgebra`. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent 670c001 commit 3cd501d

File tree

15 files changed

+461
-106
lines changed

15 files changed

+461
-106
lines changed

Archive/Imo/Imo1998Q2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ theorem A_fibre_over_contestant_card (c : C) :
116116
apply Finset.card_image_of_injOn
117117
unfold Set.InjOn
118118
rintro ⟨a, p⟩ h ⟨a', p'⟩ h' rfl
119-
aesop
119+
aesop (add simp AgreedTriple.contestant)
120120

121121
theorem A_fibre_over_judgePair {p : JudgePair J} (h : p.Distinct) :
122122
agreedContestants r p = ((A r).filter fun a : AgreedTriple C J => a.judgePair = p).image

Mathlib/Combinatorics/SimpleGraph/Finsubgraph.lean

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ instance : Sup G.Finsubgraph :=
6161
instance : Inf G.Finsubgraph :=
6262
fun G₁ G₂ => ⟨G₁ ⊓ G₂, G₁.2.subset inter_subset_left⟩⟩
6363

64+
instance instSDiff : SDiff G.Finsubgraph where
65+
sdiff G₁ G₂ := ⟨G₁ \ G₂, G₁.2.subset (Subgraph.verts_mono sdiff_le)⟩
66+
6467
@[simp, norm_cast] lemma coe_bot : (⊥ : G.Finsubgraph) = (⊥ : G.Subgraph) := rfl
6568

6669
@[simp, norm_cast]
@@ -69,17 +72,28 @@ lemma coe_sup (G₁ G₂ : G.Finsubgraph) : ↑(G₁ ⊔ G₂) = (G₁ ⊔ G₂
6972
@[simp, norm_cast]
7073
lemma coe_inf (G₁ G₂ : G.Finsubgraph) : ↑(G₁ ⊓ G₂) = (G₁ ⊓ G₂ : G.Subgraph) := rfl
7174

72-
instance : DistribLattice G.Finsubgraph :=
73-
Subtype.coe_injective.distribLattice _ (fun _ _ => rfl) fun _ _ => rfl
75+
@[simp, norm_cast]
76+
lemma coe_sdiff (G₁ G₂ : G.Finsubgraph) : ↑(G₁ \ G₂) = (G₁ \ G₂ : G.Subgraph) := rfl
77+
78+
instance instGeneralizedCoheytingAlgebra : GeneralizedCoheytingAlgebra G.Finsubgraph :=
79+
Subtype.coe_injective.generalizedCoheytingAlgebra _ coe_sup coe_inf coe_bot coe_sdiff
7480

7581
section Finite
7682
variable [Finite V]
7783

7884
instance instTop : Top G.Finsubgraph where top := ⟨⊤, finite_univ⟩
85+
instance instHasCompl : HasCompl G.Finsubgraph where compl G' := ⟨G'ᶜ, Set.toFinite _⟩
86+
instance instHNot : HNot G.Finsubgraph where hnot G' := ⟨¬G', Set.toFinite _⟩
87+
instance instHImp : HImp G.Finsubgraph where himp G₁ G₂ := ⟨G₁ ⇨ G₂, Set.toFinite _⟩
7988
instance instSupSet : SupSet G.Finsubgraph where sSup s := ⟨⨆ G ∈ s, ↑G, Set.toFinite _⟩
8089
instance instInfSet : InfSet G.Finsubgraph where sInf s := ⟨⨅ G ∈ s, ↑G, Set.toFinite _⟩
8190

82-
@[simp, norm_cast] lemma coe_top : ↑(⊤ : G.Finsubgraph) = (⊤ : G.Subgraph) := rfl
91+
@[simp, norm_cast] lemma coe_top : (⊤ : G.Finsubgraph) = (⊤ : G.Subgraph) := rfl
92+
@[simp, norm_cast] lemma coe_compl (G' : G.Finsubgraph) : ↑(G'ᶜ) = (G'ᶜ : G.Subgraph) := rfl
93+
@[simp, norm_cast] lemma coe_hnot (G' : G.Finsubgraph) : ↑(¬G') = (¬G' : G.Subgraph) := rfl
94+
95+
@[simp, norm_cast]
96+
lemma coe_himp (G₁ G₂ : G.Finsubgraph) : ↑(G₁ ⇨ G₂) = (G₁ ⇨ G₂ : G.Subgraph) := rfl
8397

8498
@[simp, norm_cast]
8599
lemma coe_sSup (s : Set G.Finsubgraph) : sSup s = (⨆ G ∈ s, G : G.Subgraph) := rfl
@@ -97,6 +111,7 @@ lemma coe_iInf {ι : Sort*} (f : ι → G.Finsubgraph) : ⨅ i, f i = (⨅ i, f
97111

98112
instance instCompletelyDistribLattice : CompletelyDistribLattice G.Finsubgraph :=
99113
Subtype.coe_injective.completelyDistribLattice _ coe_sup coe_inf coe_sSup coe_sInf coe_top coe_bot
114+
coe_compl coe_himp coe_hnot coe_sdiff
100115

101116
end Finite
102117
end Finsubgraph

Mathlib/Combinatorics/SimpleGraph/Subgraph.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ instance : BoundedOrder (Subgraph G) where
397397
le_top x := ⟨Set.subset_univ _, fun _ _ => x.adj_sub⟩
398398
bot_le _ := ⟨Set.empty_subset _, fun _ _ => False.elim⟩
399399

400-
-- Note that subgraphs do not form a Boolean algebra, because of `verts`.
401-
instance : CompletelyDistribLattice G.Subgraph :=
400+
/-- Note that subgraphs do not form a Boolean algebra, because of `verts`. -/
401+
def completelyDistribLatticeMinimalAxioms : CompletelyDistribLattice.MinimalAxioms G.Subgraph :=
402402
{ Subgraph.distribLattice with
403403
le := (· ≤ ·)
404404
sup := (· ⊔ ·)
@@ -422,6 +422,9 @@ instance : CompletelyDistribLattice G.Subgraph :=
422422
iInf_iSup_eq := fun f => Subgraph.ext _ _ (by simpa using iInf_iSup_eq)
423423
(by ext; simp [Classical.skolem]) }
424424

425+
instance : CompletelyDistribLattice G.Subgraph :=
426+
.ofMinimalAxioms completelyDistribLatticeMinimalAxioms
427+
425428
@[gcongr] lemma verts_mono {H H' : G.Subgraph} (h : H ≤ H') : H.verts ⊆ H'.verts := h.1
426429
lemma verts_monotone : Monotone (verts : G.Subgraph → Set V) := fun _ _ h ↦ h.1
427430

Mathlib/Data/Fintype/Order.lean

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ noncomputable abbrev toCompleteLattice [Lattice α] [BoundedOrder α] : Complete
9191
sInf_le := fun _ _ ha => Finset.inf_le (Set.mem_toFinset.mpr ha)
9292
le_sInf := fun s _ ha => Finset.le_inf fun b hb => ha _ <| Set.mem_toFinset.mp hb
9393

94-
-- Porting note: `convert` doesn't work as well as it used to.
9594
-- See note [reducible non-instances]
9695
/-- A finite bounded distributive lattice is completely distributive. -/
97-
noncomputable abbrev toCompleteDistribLattice [DistribLattice α] [BoundedOrder α] :
98-
CompleteDistribLattice α where
96+
noncomputable abbrev toCompleteDistribLatticeMinimalAxioms [DistribLattice α] [BoundedOrder α] :
97+
CompleteDistribLattice.MinimalAxioms α where
9998
__ := toCompleteLattice α
10099
iInf_sup_le_sup_sInf := fun a s => by
101100
convert (Finset.inf_sup_distrib_left s.toFinset id a).ge using 1
@@ -108,6 +107,11 @@ noncomputable abbrev toCompleteDistribLattice [DistribLattice α] [BoundedOrder
108107
simp_rw [Set.mem_toFinset]
109108
rfl
110109

110+
-- See note [reducible non-instances]
111+
/-- A finite bounded distributive lattice is completely distributive. -/
112+
noncomputable abbrev toCompleteDistribLattice [DistribLattice α] [BoundedOrder α] :
113+
CompleteDistribLattice α := .ofMinimalAxioms (toCompleteDistribLatticeMinimalAxioms _)
114+
111115
-- See note [reducible non-instances]
112116
/-- A finite bounded linear order is complete. -/
113117
noncomputable abbrev toCompleteLinearOrder

Mathlib/MeasureTheory/MeasurableSpace/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ theorem coe_top : ↑(⊤ : Subtype (MeasurableSet : Set α → Prop)) = (⊤ :
12871287
noncomputable instance Subtype.instBooleanAlgebra :
12881288
BooleanAlgebra (Subtype (MeasurableSet : Set α → Prop)) :=
12891289
Subtype.coe_injective.booleanAlgebra _ coe_union coe_inter coe_top coe_bot coe_compl coe_sdiff
1290+
coe_himp
12901291

12911292
@[measurability]
12921293
theorem measurableSet_blimsup {s : ℕ → Set α} {p : ℕ → Prop} (h : ∀ n, p n → MeasurableSet (s n)) :

Mathlib/ModelTheory/Definability.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ theorem coe_sdiff (s t : L.DefinableSet A α) :
377377
@[simp, norm_cast]
378378
lemma coe_himp (s t : L.DefinableSet A α) : ↑(s ⇨ t) = (s ⇨ t : Set (α → M)) := rfl
379379

380-
instance instBooleanAlgebra : BooleanAlgebra (L.DefinableSet A α) :=
380+
noncomputable instance instBooleanAlgebra : BooleanAlgebra (L.DefinableSet A α) :=
381381
Function.Injective.booleanAlgebra (α := L.DefinableSet A α) _ Subtype.coe_injective
382-
coe_sup coe_inf coe_top coe_bot coe_compl coe_sdiff
382+
coe_sup coe_inf coe_top coe_bot coe_compl coe_sdiff coe_himp
383383

384384
end DefinableSet
385385

Mathlib/Order/BooleanAlgebra.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,14 @@ protected abbrev Function.Injective.generalizedBooleanAlgebra [Sup α] [Inf α]
751751
-- See note [reducible non-instances]
752752
/-- Pullback a `BooleanAlgebra` along an injection. -/
753753
protected abbrev Function.Injective.booleanAlgebra [Sup α] [Inf α] [Top α] [Bot α] [HasCompl α]
754-
[SDiff α] [BooleanAlgebra β] (f : α → β) (hf : Injective f)
754+
[SDiff α] [HImp α] [BooleanAlgebra β] (f : α → β) (hf : Injective f)
755755
(map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b) (map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b)
756756
(map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥) (map_compl : ∀ a, f aᶜ = (f a)ᶜ)
757-
(map_sdiff : ∀ a b, f (a \ b) = f a \ f b) : BooleanAlgebra α where
757+
(map_sdiff : ∀ a b, f (a \ b) = f a \ f b) (map_himp : ∀ a b, f (a ⇨ b) = f a ⇨ f b) :
758+
BooleanAlgebra α where
758759
__ := hf.generalizedBooleanAlgebra f map_sup map_inf map_bot map_sdiff
759760
compl := compl
761+
himp := himp
760762
top := ⊤
761763
le_top a := (@le_top β _ _ _).trans map_top.ge
762764
bot_le a := map_bot.le.trans bot_le
@@ -765,6 +767,7 @@ protected abbrev Function.Injective.booleanAlgebra [Sup α] [Inf α] [Top α] [B
765767
sdiff_eq a b := by
766768
refine hf ((map_sdiff _ _).trans (sdiff_eq.trans ?_))
767769
rw [map_inf, map_compl]
770+
himp_eq a b := hf $ (map_himp _ _).trans $ himp_eq.trans $ by rw [map_sup, map_compl]
768771

769772
end lift
770773

0 commit comments

Comments
 (0)