@@ -9,6 +9,7 @@ public import Mathlib.Logic.Relator
99public import Mathlib.Tactic.Use
1010public import Mathlib.Tactic.MkIffOfInductiveProp
1111public import Mathlib.Tactic.SimpRw
12+ public import Mathlib.Order.Defs.Prop
1213public import Mathlib.Order.Defs.Unbundled
1314public import Batteries.Logic
1415public import Batteries.Tactic.Trans
@@ -53,7 +54,7 @@ the bundled version, see `Rel`.
5354
5455open Function
5556
56- variable {α β γ δ ε ζ : Sort *}
57+ variable {α β γ δ ε ζ : Type *}
5758
5859section NeImp
5960
@@ -76,19 +77,21 @@ theorem Std.Refl.ne_imp_iff [Std.Refl r] {x y : α} : x ≠ y → r x y ↔ r x
7677 ⟨Std.Refl.rel_of_ne_imp, fun hr _ ↦ hr⟩
7778
7879@ [deprecated (since := "2026-03-27" )] alias Reflexive.ne_imp_iff := Std.Refl.ne_imp_iff
79-
8080@ [deprecated (since := "2026-03-27" )] alias reflexive_ne_imp_iff := Std.Refl.ne_imp_iff
8181
82- theorem refl_iff_subrelation_eq : Std.Refl r ↔ Subrelation Eq r := by
83- grind [Std.Refl, Subrelation]
82+ theorem refl_iff_eq_le : Std.Refl r ↔ Eq ≤ r := by
83+ unfold Pi.hasLe Prop .le
84+ grind [Std.Refl]
8485
85- @ [deprecated (since := "2026-03-27" )] alias reflexive_iff_subrelation_eq := refl_iff_subrelation_eq
86+ @ [deprecated (since := "2026-06-30" )] alias refl_iff_subrelation_eq := refl_iff_eq_le
87+ @ [deprecated (since := "2026-03-27" )] alias reflexive_iff_subrelation_eq := refl_iff_eq_le
8688
87- theorem irrefl_iff_subrelation_ne : Std.Irrefl r ↔ Subrelation r Ne := by
88- grind [Std.Irrefl, Subrelation]
89+ theorem irrefl_iff_le_ne : Std.Irrefl r ↔ r ≤ Ne := by
90+ unfold Pi.hasLe Prop .le
91+ grind [Std.Irrefl]
8992
90- @ [deprecated (since := "2026-02-12 " )]
91- alias irreflexive_iff_subrelation_ne := irrefl_iff_subrelation_ne
93+ @ [deprecated (since := "2026-06-30 " )] alias irrefl_iff_subrelation_ne := irrefl_iff_le_ne
94+ @ [ deprecated (since := "2026-02-12" )] alias irreflexive_iff_subrelation_ne := irrefl_iff_le_ne
9295
9396protected theorem Std.Symm.iff [Std.Symm r] (x y : α) : r x y ↔ r y x :=
9497 ⟨symm_of r, symm_of r⟩
@@ -280,22 +283,21 @@ lemma map_equivalence {r : α → α → Prop} (hr : Equivalence r) (f : α →
280283 symm := @(hr.stdSymm.map f |>.symm)
281284 trans := @(hr.isTrans.map hf_ker |>.trans)
282285
283- -- TODO: state this using `≤`, after adjusting imports.
284- lemma map_mono {r s : α → β → Prop } {f : α → γ} {g : β → δ} (h : ∀ x y, r x y → s x y) :
285- ∀ x y, Relation.Map r f g x y → Relation.Map s f g x y :=
286+ lemma map_mono {r s : α → β → Prop } {f : α → γ} {g : β → δ} (h : r ≤ s) :
287+ Relation.Map r f g ≤ Relation.Map s f g :=
286288 fun _ _ ⟨x, y, hxy, hx, hy⟩ => ⟨x, y, h _ _ hxy, hx, hy⟩
287289
288- lemma le_onFun_map {r : α → α → Prop } (f : α → β) : Subrelation r (Relation.Map r f f on f) := by
289- intro
290+ lemma le_onFun_map {r : α → α → Prop } (f : α → β) : r ≤ (Relation.Map r f f on f) := by
291+ unfold Pi.hasLe Prop .le
290292 grind [Relation.Map]
291293
292294lemma onFun_map_eq_of_injective {r : α → α → Prop } {f : α → β} (hinj : f.Injective) :
293295 (Relation.Map r f f on f) = r := by
294296 ext x y
295297 exact ⟨fun ⟨x', y', hr, hx, hy⟩ ↦ hinj hx ▸ hinj hy ▸ hr, fun h ↦ ⟨x, y, h, rfl, rfl⟩⟩
296298
297- lemma map_onFun_le {r : β → β → Prop } (f : α → β) : Subrelation ( Relation.Map (r on f) f f) r := by
298- intro
299+ lemma map_onFun_le {r : β → β → Prop } (f : α → β) : Relation.Map (r on f) f f ≤ r := by
300+ unfold Pi.hasLe Prop .le
299301 grind [Relation.Map]
300302
301303lemma map_onFun_eq_of_surjective {r : β → β → Prop } {f : α → β} (hsurj : f.Surjective) :
@@ -355,13 +357,16 @@ inductive EqvGen : α → α → Prop
355357attribute [mk_iff] TransGen
356358attribute [grind] TransGen
357359
360+ theorem reflGen_le_reflTransGen : ReflGen r ≤ ReflTransGen r
361+ | a, _, .refl => by rfl
362+ | _, _, .single h => ReflTransGen.tail ReflTransGen.refl h
363+
358364namespace ReflGen
359365
360- theorem to_reflTransGen : ∀ {a b}, ReflGen r a b → ReflTransGen r a b
361- | a, _, refl => by rfl
362- | _, _, single h => ReflTransGen.tail ReflTransGen.refl h
366+ theorem to_reflTransGen {a b} : ReflGen r a b → ReflTransGen r a b :=
367+ reflGen_le_reflTransGen a b
363368
364- theorem mono {p : α → α → Prop } (hp : ∀ a b, r a b → p a b ) : ∀ {a b}, ReflGen r a b → ReflGen p a b
369+ theorem mono {p : α → α → Prop } (hp : r ≤ p ) : ReflGen r ≤ ReflGen p
365370 | a, _, ReflGen.refl => by rfl
366371 | a, b, single h => single (hp a b h)
367372
@@ -436,6 +441,9 @@ theorem trans (hab : ReflTransGen r a b) (hbc : ReflTransGen r b c) : ReflTransG
436441theorem single (hab : r a b) : ReflTransGen r a b :=
437442 refl.tail hab
438443
444+ theorem le_reflTransGen : r ≤ ReflTransGen r :=
445+ fun _ _ ↦ single
446+
439447theorem head (hab : r a b) (hbc : ReflTransGen r b c) : ReflTransGen r a c := by
440448 induction hbc with
441449 | refl => exact refl.tail hab
@@ -497,13 +505,17 @@ theorem total_of_right_unique (U : Relator.RightUnique r) (ab : ReflTransGen r a
497505
498506end ReflTransGen
499507
500- namespace TransGen
501-
502- theorem to_reflTransGen {a b} (h : TransGen r a b) : ReflTransGen r a b := by
508+ theorem transGen_le_reflTransGen : TransGen r ≤ ReflTransGen r := by
509+ intro a _ h
503510 induction h with
504511 | single h => exact ReflTransGen.single h
505512 | tail _ bc ab => exact ReflTransGen.tail ab bc
506513
514+ namespace TransGen
515+
516+ theorem to_reflTransGen {a b} : TransGen r a b → ReflTransGen r a b :=
517+ transGen_le_reflTransGen a b
518+
507519theorem trans_left (hab : TransGen r a b) (hbc : ReflTransGen r b c) : TransGen r a c := by
508520 induction hbc with
509521 | refl => assumption
@@ -586,9 +598,8 @@ lemma reflGen_eq_self [Std.Refl r] : ReflGen r = r := by
586598@ [deprecated inferInstance (since := "2026-03-27" )]
587599lemma reflexive_reflGen : Std.Refl (ReflGen r) := inferInstance
588600
589- lemma reflGen_minimal {r' : α → α → Prop } [Std.Refl r'] (h : ∀ x y, r x y → r' x y) {x y : α}
590- (hxy : ReflGen r x y) : r' x y := by
591- simpa [reflGen_eq_self] using ReflGen.mono h hxy
601+ lemma reflGen_minimal {r' : α → α → Prop } [Std.Refl r'] (h : r ≤ r') : ReflGen r ≤ r' := by
602+ simpa [reflGen_eq_self] using ReflGen.mono h
592603
593604end reflGen
594605
@@ -641,40 +652,39 @@ theorem transitive_transGen : IsTrans α (TransGen r) := inferInstance
641652theorem transGen_idem : TransGen (TransGen r) = TransGen r :=
642653 transGen_eq_self
643654
644- theorem TransGen.lift {p : β → β → Prop } {a b : α} (f : α → β) (h : ∀ a b, r a b → p (f a) (f b))
645- (hab : TransGen r a b) : TransGen p (f a) (f b) := by
655+ theorem TransGen.lift {p : β → β → Prop } (f : α → β) (h : r ≤ (p on f)) :
656+ TransGen r ≤ (TransGen p on f) := by
657+ intro a _ hab
646658 induction hab with
647659 | single hac => exact TransGen.single (h a _ hac)
648660 | tail _ hcd hac => exact TransGen.tail hac (h _ _ hcd)
649661
650- theorem TransGen.lift' {p : β → β → Prop } {a b : α} (f : α → β)
651- (h : ∀ a b, r a b → TransGen p (f a) (f b)) (hab : TransGen r a b) :
652- TransGen p (f a) (f b) := by
662+ theorem TransGen.lift' {p : β → β → Prop } (f : α → β) (h : r ≤ (TransGen p on f)) :
663+ TransGen r ≤ ( TransGen p on f) := by
664+ intro _ _ hab
653665 simpa [transGen_eq_self] using hab.lift f h
654666
655- theorem TransGen.closed {p : α → α → Prop } :
656- (∀ a b, r a b → TransGen p a b) → TransGen r a b → TransGen p a b :=
667+ theorem TransGen.closed {p : α → α → Prop } : r ≤ TransGen p → TransGen r ≤ TransGen p :=
657668 TransGen.lift' id
658669
659670lemma TransGen.closed' {P : α → Prop } (dc : ∀ {a b}, r a b → P b → P a)
660671 {a b : α} (h : TransGen r a b) : P b → P a :=
661672 h.head_induction_on dc fun hr _ hi ↦ dc hr ∘ hi
662673
663- theorem TransGen.mono {p : α → α → Prop } :
664- (∀ a b, r a b → p a b) → TransGen r a b → TransGen p a b :=
674+ theorem TransGen.mono {p : α → α → Prop } : r ≤ p → TransGen r ≤ TransGen p :=
665675 TransGen.lift id
666676
667- lemma transGen_minimal {r' : α → α → Prop } [IsTrans α r'] (h : ∀ x y, r x y → r' x y) {x y : α}
668- (hxy : TransGen r x y) : r' x y := by
669- simpa [transGen_eq_self] using TransGen.mono h hxy
677+ lemma transGen_minimal {r' : α → α → Prop } [IsTrans α r'] (h : r ≤ r') : TransGen r ≤ r' := by
678+ simpa [transGen_eq_self] using TransGen.mono h
670679
671- theorem TransGen.swap (h : TransGen r b a) : TransGen (swap r) a b := by
680+ theorem TransGen.swap : swap (TransGen r) ≤ TransGen (swap r) := by
681+ intro _ _ h
672682 induction h with
673683 | single h => exact TransGen.single h
674684 | tail _ hbc ih => exact ih.head hbc
675685
676686theorem transGen_swap : TransGen (swap r) a b ↔ TransGen r b a :=
677- ⟨TransGen.swap, TransGen.swap⟩
687+ ⟨TransGen.swap b a , TransGen.swap a b ⟩
678688
679689end TransGen
680690
@@ -696,12 +706,11 @@ theorem reflTransGen_iff_eq_or_transGen : ReflTransGen r a b ↔ b = a ∨ Trans
696706 · rfl
697707 · exact h.to_reflTransGen
698708
699- theorem ReflTransGen.lift {p : β → β → Prop } {a b : α} (f : α → β)
700- (h : ∀ a b, r a b → p (f a) (f b)) (hab : ReflTransGen r a b) : ReflTransGen p (f a) (f b ) :=
701- ReflTransGen. trans_induction_on hab (fun _ ↦ refl) (ReflTransGen. single ∘ h _ _) fun _ _ ↦ trans
709+ theorem ReflTransGen.lift {p : β → β → Prop } (f : α → β) (h : r ≤ (p on f)) :
710+ ReflTransGen r ≤ ( ReflTransGen p on f ) :=
711+ fun _ _ hab ↦ trans_induction_on hab (fun _ ↦ refl) (single ∘ h _ _) fun _ _ ↦ trans
702712
703- theorem ReflTransGen.mono {p : α → α → Prop } : (∀ a b, r a b → p a b) →
704- ReflTransGen r a b → ReflTransGen p a b :=
713+ theorem ReflTransGen.mono {p : α → α → Prop } : r ≤ p → ReflTransGen r ≤ ReflTransGen p :=
705714 ReflTransGen.lift id
706715
707716@ [grind =]
@@ -734,22 +743,23 @@ theorem transitive_reflTransGen : IsTrans α (ReflTransGen r) := inferInstance
734743theorem reflTransGen_idem : ReflTransGen (ReflTransGen r) = ReflTransGen r :=
735744 reflTransGen_eq_self
736745
737- theorem ReflTransGen.lift' {p : β → β → Prop } {a b : α} (f : α → β)
738- (h : ∀ a b, r a b → ReflTransGen p (f a) (f b))
739- (hab : ReflTransGen r a b) : ReflTransGen p (f a) (f b) := by
746+ theorem ReflTransGen.lift' {p : β → β → Prop } (f : α → β) (h : r ≤ (ReflTransGen p on f)) :
747+ ReflTransGen r ≤ ( ReflTransGen p on f) := by
748+ intro _ _ hab
740749 simpa [reflTransGen_eq_self] using hab.lift f h
741750
742751theorem reflTransGen_closed {p : α → α → Prop } :
743- (∀ a b, r a b → ReflTransGen p a b) → ReflTransGen r a b → ReflTransGen p a b :=
752+ r ≤ ReflTransGen p → ReflTransGen r ≤ ReflTransGen p :=
744753 ReflTransGen.lift' id
745754
746- theorem ReflTransGen.swap (h : ReflTransGen r b a) : ReflTransGen (swap r) a b := by
755+ theorem ReflTransGen.swap : swap (ReflTransGen r) ≤ ReflTransGen (swap r) := by
756+ intro _ _ h
747757 induction h with
748758 | refl => rfl
749759 | tail _ hbc ih => exact ih.head hbc
750760
751761theorem reflTransGen_swap : ReflTransGen (swap r) a b ↔ ReflTransGen r b a :=
752- ⟨ReflTransGen.swap, ReflTransGen.swap⟩
762+ ⟨ReflTransGen.swap b a , ReflTransGen.swap a b ⟩
753763
754764@ [simp, grind =] lemma reflGen_transGen : ReflGen (TransGen r) = ReflTransGen r := by
755765 ext x y
@@ -758,10 +768,10 @@ theorem reflTransGen_swap : ReflTransGen (swap r) a b ↔ ReflTransGen r b a :=
758768@ [simp, grind =] lemma transGen_reflGen : TransGen (ReflGen r) = ReflTransGen r := by
759769 ext x y
760770 refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
761- · simpa [reflTransGen_eq_self] using ( h.mono fun _ _ ↦ ReflGen.to_reflTransGen) .to_reflTransGen
771+ · simpa [reflTransGen_eq_self] using h.mono reflGen_le_reflTransGen x y |> .to_reflTransGen
762772 · obtain (rfl | h) := reflTransGen_iff_eq_or_transGen.mp h
763773 · exact .single .refl
764- · exact TransGen .mono (fun _ _ ↦ .single) h
774+ · exact h .mono (fun _ _ ↦ .single) x y
765775
766776@ [simp, grind =] lemma reflTransGen_reflGen : ReflTransGen (ReflGen r) = ReflTransGen r := by
767777 simp only [← transGen_reflGen, reflGen_eq_self]
@@ -794,8 +804,8 @@ see for example `Quot.eqvGen_exact` and `Quot.eqvGen_sound`. -/
794804def setoid : Setoid α :=
795805 Setoid.mk _ (EqvGen.is_equivalence r)
796806
797- theorem mono {r p : α → α → Prop } (hrp : ∀ a b, r a b → p a b) (h : EqvGen r a b) :
798- EqvGen p a b := by
807+ theorem mono {r p : α → α → Prop } (hrp : r ≤ p) : EqvGen r ≤ EqvGen p := by
808+ intro _ _ h
799809 induction h with
800810 | rel a b h => exact EqvGen.rel _ _ (hrp _ _ h)
801811 | refl => exact EqvGen.refl _
@@ -840,9 +850,10 @@ theorem church_rosser (h : ∀ a b c, r a b → r a c → ∃ d, ReflGen r b d
840850 | refl => exact ⟨b, hea, hcb⟩
841851 | single hba => exact ⟨a, hea, hcb.tail hba⟩
842852
853+ theorem le_join_of_refl [Std.Refl r] : r ≤ Join r :=
854+ fun _ b hab ↦ ⟨b, hab, refl b⟩
843855
844- theorem join_of_single [Std.Refl r] (hab : r a b) : Join r a b :=
845- ⟨b, hab, refl b⟩
856+ @ [deprecated (since := "2026-06-30" )] alias join_of_single := le_join_of_refl
846857
847858protected instance Join.symm : Std.Symm (Join r) where
848859 symm _ _ := fun ⟨c, hac, hcb⟩ ↦ ⟨c, hcb, hac⟩
@@ -871,23 +882,30 @@ theorem equivalence_join_reflTransGen
871882 Equivalence (Join (ReflTransGen r)) :=
872883 equivalence_join fun _ _ _ ↦ church_rosser h
873884
874- theorem join_of_equivalence {r' : α → α → Prop } (hr : Equivalence r) (h : ∀ a b, r' a b → r a b ) :
875- Join r' a b → r a b
876- | ⟨_ , hac, hbc⟩ => hr.trans (h _ _ hac) (hr.symm <| h _ _ hbc)
885+ theorem join_le_of_equivalence_of_le {r' : α → α → Prop } (hr : Equivalence r) (h : r' ≤ r ) :
886+ Join r' ≤ r :=
887+ fun a b ⟨c , hac, hbc⟩ ↦ hr.trans (h a c hac) (hr.symm <| h b c hbc)
877888
878- theorem reflTransGen_of_isTrans_reflexive {r' : α → α → Prop } [Std.Refl r] [IsTrans α r]
879- (h : ∀ a b, r' a b → r a b) (h' : ReflTransGen r' a b) : r a b := by
880- simpa [reflTransGen_eq_self] using ReflTransGen.mono h h'
889+ @ [deprecated (since := "2026-06-30" )] alias join_of_equivalence := join_le_of_equivalence_of_le
890+
891+ theorem reflTransGen_le_of_le {r' : α → α → Prop } [Std.Refl r] [IsTrans α r]
892+ (h : r' ≤ r) : ReflTransGen r' ≤ r := by
893+ simpa [reflTransGen_eq_self] using ReflTransGen.mono h
894+
895+ @ [deprecated (since := "2026-06-30" )]
896+ alias reflTransGen_of_isTrans_reflexive := reflTransGen_le_of_le
881897
882898@ [deprecated (since := "2026-02-21" )]
883- alias reflTransGen_of_transitive_reflexive := reflTransGen_of_isTrans_reflexive
899+ alias reflTransGen_of_transitive_reflexive := reflTransGen_le_of_le
900+
901+ @ [deprecated (since := "2025-12-17" )] alias reflTransGen_minimal := reflTransGen_le_of_le
884902
885- @ [deprecated (since := "2025-12-17" )] alias reflTransGen_minimal :=
886- reflTransGen_of_transitive_reflexive
903+ theorem reflTransGen_le_of_equivalence_of_le {r' : α → α → Prop } (hr : Equivalence r) :
904+ r' ≤ r → ReflTransGen r' ≤ r :=
905+ @reflTransGen_le_of_le _ _ _ hr.stdRefl hr.isTrans
887906
888- theorem reflTransGen_of_equivalence {r' : α → α → Prop } (hr : Equivalence r) :
889- (∀ a b, r' a b → r a b) → ReflTransGen r' a b → r a b :=
890- @reflTransGen_of_isTrans_reflexive _ _ _ _ _ hr.stdRefl hr.isTrans
907+ @ [deprecated (since := "2026-06-30" )]
908+ alias reflTransGen_of_equivalence := reflTransGen_le_of_equivalence_of_le
891909
892910end Join
893911
0 commit comments