@@ -223,13 +223,13 @@ lemma map_symmetric {r : α → α → Prop} (hr : Symmetric r) (f : α → β)
223223 rintro _ _ ⟨x, y, hxy, rfl, rfl⟩; exact ⟨_, _, hr hxy, rfl, rfl⟩
224224
225225lemma map_transitive {r : α → α → Prop } (hr : Transitive r) {f : α → β}
226- (hf : ∀ x y, f x = f y → r x y ) :
226+ (hf : Subrelation ((· = ·) on f) r ) :
227227 Transitive (Relation.Map r f f) := by
228228 rintro _ _ _ ⟨x, y, hxy, rfl, rfl⟩ ⟨y', z, hyz, hy, rfl⟩
229- exact ⟨x, z, hr hxy <| hr (hf _ _ hy.symm) hyz, rfl, rfl⟩
229+ exact ⟨x, z, hr hxy <| hr (hf hy.symm) hyz, rfl, rfl⟩
230230
231231lemma map_equivalence {r : α → α → Prop } (hr : Equivalence r) (f : α → β)
232- (hf : f.Surjective) (hf_ker : ∀ x y, f x = f y → r x y ) :
232+ (hf : f.Surjective) (hf_ker : Subrelation ((· = ·) on f) r ) :
233233 Equivalence (Relation.Map r f f) where
234234 refl := map_reflexive hr.reflexive hf
235235 symm := @(map_symmetric hr.symmetric _)
@@ -272,13 +272,13 @@ attribute [refl] ReflGen.refl
272272
273273namespace ReflGen
274274
275- theorem to_reflTransGen : ∀ {a b}, ReflGen r a b → ReflTransGen r a b
275+ theorem to_reflTransGen : Subrelation ( ReflGen r) ( ReflTransGen r)
276276 | a, _, refl => by rfl
277277 | _, _, single h => ReflTransGen.tail ReflTransGen.refl h
278278
279- theorem mono {p : α → α → Prop } (hp : ∀ a b, r a b → p a b ) : ∀ {a b}, ReflGen r a b → ReflGen p a b
279+ theorem mono {p : α → α → Prop } (hp : Subrelation r p ) : Subrelation ( ReflGen r) ( ReflGen p)
280280 | a, _, ReflGen.refl => by rfl
281- | a, b, single h => single ( hp a b h)
281+ | a, b, single h => single <| hp h
282282
283283instance : IsRefl α (ReflGen r) :=
284284 ⟨@refl α r⟩
@@ -293,8 +293,8 @@ theorem trans (hab : ReflTransGen r a b) (hbc : ReflTransGen r b c) : ReflTransG
293293 | refl => assumption
294294 | tail _ hcd hac => exact hac.tail hcd
295295
296- theorem single (hab : r a b) : ReflTransGen r a b :=
297- refl.tail hab
296+ theorem single : Subrelation r ( ReflTransGen r) :=
297+ refl.tail
298298
299299theorem head (hab : r a b) (hbc : ReflTransGen r b c) : ReflTransGen r a c := by
300300 induction hbc with
@@ -357,7 +357,7 @@ end ReflTransGen
357357
358358namespace TransGen
359359
360- theorem to_reflTransGen {a b} (h : TransGen r a b) : ReflTransGen r a b := by
360+ theorem to_reflTransGen : Subrelation ( TransGen r) ( ReflTransGen r) := fun h ↦ by
361361 induction h with
362362 | single h => exact ReflTransGen.single h
363363 | tail _ bc ab => exact ReflTransGen.tail ab bc
@@ -432,8 +432,8 @@ lemma reflGen_eq_self (hr : Reflexive r) : ReflGen r = r := by
432432
433433lemma reflexive_reflGen : Reflexive (ReflGen r) := fun _ ↦ .refl
434434
435- lemma reflGen_minimal {r' : α → α → Prop } (hr' : Reflexive r') (h : ∀ x y, r x y → r' x y) {x y : α}
436- (hxy : ReflGen r x y) : r' x y := by
435+ lemma reflGen_minimal {r' : α → α → Prop } (hr' : Reflexive r') (h : Subrelation r r') :
436+ Subrelation ( ReflGen r) r' := fun hxy ↦ by
437437 simpa [reflGen_eq_self hr'] using ReflGen.mono h hxy
438438
439439end reflGen
@@ -467,41 +467,44 @@ theorem transitive_transGen : Transitive (TransGen r) := fun _ _ _ ↦ TransGen.
467467theorem transGen_idem : TransGen (TransGen r) = TransGen r :=
468468 transGen_eq_self transitive_transGen
469469
470- theorem TransGen.lift {p : β → β → Prop } {a b : α} (f : α → β) (h : ∀ a b, r a b → p (f a) (f b))
471- (hab : TransGen r a b) : TransGen p (f a) (f b ) := by
470+ theorem TransGen.lift {p : β → β → Prop } (f : α → β) (h : Subrelation r (p on f)) :
471+ Subrelation ( TransGen r) ( TransGen p on f ) := fun hab ↦ by
472472 induction hab with
473- | single hac => exact TransGen.single (h a _ hac)
474- | tail _ hcd hac => exact TransGen.tail hac (h _ _ hcd)
473+ | single hac => exact TransGen.single <| h hac
474+ | tail _ hcd hac => exact TransGen.tail hac <| h hcd
475475
476- theorem TransGen.lift' {p : β → β → Prop } {a b : α} (f : α → β)
477- (h : ∀ a b, r a b → TransGen p (f a) (f b)) (hab : TransGen r a b) :
478- TransGen p (f a) (f b) := by
476+ theorem TransGen.lift' {p : β → β → Prop } (f : α → β) (h : Subrelation r (TransGen p on f)) :
477+ Subrelation (TransGen r) (TransGen p on f) := fun hab ↦ by
479478 simpa [transGen_idem] using hab.lift f h
480479
481480theorem TransGen.closed {p : α → α → Prop } :
482- (∀ a b, r a b → TransGen p a b) → TransGen r a b → TransGen p a b :=
481+ (Subrelation r ( TransGen p)) → Subrelation ( TransGen r) ( TransGen p) :=
483482 TransGen.lift' id
484483
485- lemma TransGen.closed' {P : α → Prop } (dc : ∀ {a b}, r a b → P b → P a)
486- {a b : α} (h : TransGen r a b) : P b → P a :=
487- h.head_induction_on dc fun hr _ hi ↦ dc hr ∘ hi
484+ lemma TransGen.closed' {P : α → Prop } (dc : Subrelation r (swap (· → ·) on P)) :
485+ Subrelation ( TransGen r) (swap (· → ·) on P) :=
486+ fun h ↦ h.head_induction_on dc fun hr _ hi ↦ dc hr ∘ hi
488487
489488theorem TransGen.mono {p : α → α → Prop } :
490- (∀ a b, r a b → p a b ) → TransGen r a b → TransGen p a b :=
489+ (Subrelation r p ) → Subrelation ( TransGen r) ( TransGen p) :=
491490 TransGen.lift id
492491
493- lemma transGen_minimal {r' : α → α → Prop } (hr' : Transitive r') (h : ∀ x y, r x y → r' x y)
494- {x y : α} (hxy : TransGen r x y) : r' x y := by
492+ lemma transGen_minimal {r' : α → α → Prop } (hr' : Transitive r') (h : Subrelation r r') :
493+ Subrelation ( TransGen r) r' := fun hxy ↦ by
495494 simpa [transGen_eq_self hr'] using TransGen.mono h hxy
496495
497- theorem TransGen.swap (h : TransGen r b a) : TransGen (swap r) a b := by
496+ theorem TransGen.swap : Subrelation (swap (TransGen r)) ( TransGen (swap r)) := fun h ↦ by
498497 induction h with
499498 | single h => exact TransGen.single h
500499 | tail _ hbc ih => exact ih.head hbc
501500
502- theorem transGen_swap : TransGen (swap r) a b ↔ TransGen r b a :=
501+ theorem transGen_swap : TransGen (swap r) a b ↔ swap ( TransGen r) a b :=
503502 ⟨TransGen.swap, TransGen.swap⟩
504503
504+ theorem transGen_swap_eq_swap_transGen : TransGen (swap r) = swap (TransGen r) := by
505+ ext a b
506+ exact transGen_swap
507+
505508end TransGen
506509
507510section ReflTransGen
@@ -520,12 +523,12 @@ theorem reflTransGen_iff_eq_or_transGen : ReflTransGen r a b ↔ b = a ∨ Trans
520523 · rfl
521524 · exact h.to_reflTransGen
522525
523- theorem ReflTransGen.lift {p : β → β → Prop } {a b : α} (f : α → β)
524- (h : ∀ a b, r a b → p (f a) (f b)) (hab : ReflTransGen r a b) : ReflTransGen p (f a) (f b ) :=
525- ReflTransGen.trans_induction_on hab (fun _ ↦ refl) (ReflTransGen.single ∘ h _ _ ) fun _ _ ↦ trans
526+ theorem ReflTransGen.lift {p : β → β → Prop } (f : α → β) (h : Subrelation r (p on f)) :
527+ Subrelation ( ReflTransGen r) ( ReflTransGen p on f ) := fun hab ↦
528+ ReflTransGen.trans_induction_on hab (fun _ ↦ refl) (ReflTransGen.single ∘ h) fun _ _ ↦ trans
526529
527- theorem ReflTransGen.mono {p : α → α → Prop } : (∀ a b, r a b → p a b ) →
528- ReflTransGen r a b → ReflTransGen p a b :=
530+ theorem ReflTransGen.mono {p : α → α → Prop } : (Subrelation r p ) →
531+ Subrelation ( ReflTransGen r) ( ReflTransGen p) :=
529532 ReflTransGen.lift id
530533
531534theorem reflTransGen_eq_self (refl : Reflexive r) (trans : Transitive r) : ReflTransGen r = r :=
@@ -536,7 +539,7 @@ theorem reflTransGen_eq_self (refl : Reflexive r) (trans : Transitive r) : ReflT
536539 | tail _ h₂ IH => exact trans IH h₂, single⟩
537540
538541lemma reflTransGen_minimal {r' : α → α → Prop } (hr₁ : Reflexive r') (hr₂ : Transitive r')
539- (h : ∀ x y, r x y → r' x y) {x y : α} (hxy : ReflTransGen r x y) : r' x y := by
542+ (h : Subrelation r r') : Subrelation ( ReflTransGen r) r' := fun hxy ↦ by
540543 simpa [reflTransGen_eq_self hr₁ hr₂] using ReflTransGen.mono h hxy
541544
542545theorem reflexive_reflTransGen : Reflexive (ReflTransGen r) := fun _ ↦ refl
@@ -558,23 +561,28 @@ instance : IsTrans α (ReflTransGen r) :=
558561theorem reflTransGen_idem : ReflTransGen (ReflTransGen r) = ReflTransGen r :=
559562 reflTransGen_eq_self reflexive_reflTransGen transitive_reflTransGen
560563
561- theorem ReflTransGen.lift' {p : β → β → Prop } {a b : α} (f : α → β)
562- (h : ∀ a b, r a b → ReflTransGen p (f a ) (f b) )
563- (hab : ReflTransGen r a b) : ReflTransGen p (f a) (f b) := by
564+ theorem ReflTransGen.lift' {p : β → β → Prop } (f : α → β)
565+ (h : Subrelation r (ReflTransGen p on f)) : Subrelation (ReflTransGen r ) (ReflTransGen p on f )
566+ := fun hab ↦ by
564567 simpa [reflTransGen_idem] using hab.lift f h
565568
566569theorem reflTransGen_closed {p : α → α → Prop } :
567- (∀ a b, r a b → ReflTransGen p a b) → ReflTransGen r a b → ReflTransGen p a b :=
570+ (Subrelation r ( ReflTransGen p)) → Subrelation ( ReflTransGen r) ( ReflTransGen p) :=
568571 ReflTransGen.lift' id
569572
570- theorem ReflTransGen.swap (h : ReflTransGen r b a) : ReflTransGen (swap r) a b := by
573+ theorem ReflTransGen.swap : Subrelation (swap <| ReflTransGen r) (ReflTransGen <| swap r) := by
574+ intro _ _ h
571575 induction h with
572576 | refl => rfl
573577 | tail _ hbc ih => exact ih.head hbc
574578
575579theorem reflTransGen_swap : ReflTransGen (swap r) a b ↔ ReflTransGen r b a :=
576580 ⟨ReflTransGen.swap, ReflTransGen.swap⟩
577581
582+ theorem reflTransGen_swap_eq_swap_reflTransGen : ReflTransGen (swap r) = swap (ReflTransGen r) := by
583+ ext a b
584+ exact reflTransGen_swap
585+
578586@[simp] lemma reflGen_transGen : ReflGen (TransGen r) = ReflTransGen r := by
579587 ext x y
580588 simp_rw [reflTransGen_iff_eq_or_transGen, reflGen_iff]
@@ -583,10 +591,10 @@ theorem reflTransGen_swap : ReflTransGen (swap r) a b ↔ ReflTransGen r b a :=
583591 ext x y
584592 refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
585593 · simpa [reflTransGen_idem]
586- using TransGen.to_reflTransGen <| TransGen.mono (fun _ _ ↦ ReflGen.to_reflTransGen) h
594+ using TransGen.to_reflTransGen <| TransGen.mono (ReflGen.to_reflTransGen) h
587595 · obtain (rfl | h) := reflTransGen_iff_eq_or_transGen.mp h
588596 · exact .single .refl
589- · exact TransGen.mono (fun _ _ ↦ .single) h
597+ · exact TransGen.mono (.single) h
590598
591599@[simp] lemma reflTransGen_reflGen : ReflTransGen (ReflGen r) = ReflTransGen r := by
592600 simp only [← transGen_reflGen, reflGen_eq_self reflexive_reflGen]
@@ -618,10 +626,10 @@ see for example `Quot.eqvGen_exact` and `Quot.eqvGen_sound`. -/
618626def setoid : Setoid α :=
619627 Setoid.mk _ (EqvGen.is_equivalence r)
620628
621- theorem mono {r p : α → α → Prop } (hrp : ∀ a b, r a b → p a b) (h : EqvGen r a b ) :
622- EqvGen p a b := by
629+ theorem mono {r p : α → α → Prop } (hrp : Subrelation r p) : Subrelation ( EqvGen r) (EqvGen p ) := by
630+ intro _ _ h
623631 induction h with
624- | rel a b h => exact EqvGen.rel _ _ ( hrp _ _ h)
632+ | rel a b h => exact EqvGen.rel _ _ <| hrp h
625633 | refl => exact EqvGen.refl _
626634 | symm a b _ ih => exact EqvGen.symm _ _ ih
627635 | trans a b c _ _ hab hbc => exact EqvGen.trans _ _ _ hab hbc
@@ -665,8 +673,8 @@ theorem church_rosser (h : ∀ a b c, r a b → r a c → ∃ d, ReflGen r b d
665673 | single hba => exact ⟨a, hea, hcb.tail hba⟩
666674
667675
668- theorem join_of_single (h : Reflexive r) (hab : r a b) : Join r a b :=
669- ⟨b , hab, h b ⟩
676+ theorem join_of_single (h : Reflexive r) : Subrelation r ( Join r) :=
677+ fun hab ↦ ⟨_ , hab, h _ ⟩
670678
671679theorem symmetric_join : Symmetric (Join r) := fun _ _ ⟨c, hac, hcb⟩ ↦ ⟨c, hcb, hac⟩
672680
@@ -687,18 +695,18 @@ theorem equivalence_join_reflTransGen
687695 Equivalence (Join (ReflTransGen r)) :=
688696 equivalence_join reflexive_reflTransGen transitive_reflTransGen fun _ _ _ ↦ church_rosser h
689697
690- theorem join_of_equivalence {r' : α → α → Prop } (hr : Equivalence r) (h : ∀ a b, r' a b → r a b ) :
691- Join r' a b → r a b
692- | ⟨_, hac, hbc⟩ => hr.trans (h _ _ hac) (hr.symm <| h _ _ hbc)
698+ theorem join_of_equivalence {r' : α → α → Prop } (hr : Equivalence r) (h : Subrelation r' r ) :
699+ Subrelation ( Join r') r :=
700+ fun ⟨_, hac, hbc⟩ ↦ hr.trans (h hac) (hr.symm <| h hbc)
693701
694702theorem reflTransGen_of_transitive_reflexive {r' : α → α → Prop } (hr : Reflexive r)
695- (ht : Transitive r) (h : ∀ a b, r' a b → r a b) (h' : ReflTransGen r' a b) : r a b := by
703+ (ht : Transitive r) (h : Subrelation r' r) : Subrelation ( ReflTransGen r') r := fun h' ↦ by
696704 induction h' with
697705 | refl => exact hr _
698- | tail _ hbc ih => exact ht ih (h _ _ hbc)
706+ | tail _ hbc ih => exact ht ih <| h hbc
699707
700708theorem reflTransGen_of_equivalence {r' : α → α → Prop } (hr : Equivalence r) :
701- (∀ a b, r' a b → r a b ) → ReflTransGen r' a b → r a b :=
709+ (Subrelation r' r ) → Subrelation ( ReflTransGen r') r :=
702710 reflTransGen_of_transitive_reflexive hr.1 (fun _ _ _ ↦ hr.trans)
703711
704712end Join
@@ -711,12 +719,12 @@ open Relation
711719
712720variable {r : α → α → Prop } {a b : α}
713721
714- theorem Quot.eqvGen_exact (H : Quot.mk r a = Quot.mk r b) : EqvGen r a b :=
715- @ Quotient.exact _ (EqvGen.setoid r) a b ( congrArg
716- (Quot.lift (Quotient.mk ( EqvGen.setoid r)) (fun x y h ↦ Quot.sound ( EqvGen.rel x y h))) H)
722+ theorem Quot.eqvGen_exact : Subrelation ((· = ·) on Quot.mk r) ( EqvGen r) :=
723+ fun H ↦ Quotient.exact <| congrArg
724+ (Quot.lift (Quotient.mk <| EqvGen.setoid r) (fun _ _ h ↦ Quot.sound <| EqvGen.rel _ _ h)) H
717725
718- theorem Quot.eqvGen_sound (H : EqvGen r a b) : Quot.mk r a = Quot.mk r b :=
719- EqvGen.rec
726+ theorem Quot.eqvGen_sound : Subrelation ( EqvGen r) ((· = ·) on Quot.mk r) :=
727+ fun H ↦ EqvGen.rec
720728 (fun _ _ h ↦ Quot.sound h)
721729 (fun _ ↦ rfl)
722730 (fun _ _ _ IH ↦ Eq.symm IH)
0 commit comments