@@ -536,7 +536,56 @@ lemma let_eq {α : Sort v} {β : Sort u} {a₁ a₂ : α} {b₁ b₂ : α → β
536
536
a₁ = a₂ → (∀ x, b₁ x = b₂ x) → (let x : α := a₁; b₁ x) = (let x : α := a₂; b₂ x) :=
537
537
λ h₁ h₂ => Eq.recOn (motive := λ a _ => (let x := a₁; b₁ x) = (let x := a; b₂ x)) h₁ (h₂ a₁)
538
538
539
- -- TODO: `section relation`
539
+ section relation
540
+
541
+ variable {α : Sort u} {β : Sort v} (r : β → β → Prop )
542
+
543
+ /-- Local notation for an arbitrary binary relation `r`. -/
544
+ local infix :50 " ≺ " => r
545
+
546
+ /-- A reflexive relation relates every element to itself. -/
547
+ def reflexive := ∀ x, x ≺ x
548
+
549
+ /-- A relation is symmetric if `x ≺ y` implies `y ≺ x`. -/
550
+ def symmetric := ∀ ⦃x y⦄, x ≺ y → y ≺ x
551
+
552
+ /-- A relation is transitive if `x ≺ y` and `y ≺ z` together imply `x ≺ z`. -/
553
+ def transitive := ∀ ⦃x y z⦄, x ≺ y → y ≺ z → x ≺ z
554
+
555
+ /-- An equivalance is a reflexive, symmetric, and transitive relation. -/
556
+ def equivalence := reflexive r ∧ symmetric r ∧ transitive r
557
+
558
+ /-- A relation is total if for all `x` and `y`, either `x ≺ y` or `y ≺ x`. -/
559
+ def total := ∀ x y, x ≺ y ∨ y ≺ x
560
+
561
+ lemma mk_equivalence (rfl : reflexive r) (symm : symmetric r) (trans : transitive r) :
562
+ equivalence r :=
563
+ ⟨rfl, symm, trans⟩
564
+
565
+ /-- Irreflexive means "not reflexive". -/
566
+ def irreflexive := ∀ x, ¬ x ≺ x
567
+
568
+ /-- A relation is antisymmetric if `x ≺ y` and `y ≺ x` together imply that `x = y`. -/
569
+ def anti_symmetric := ∀ ⦃x y⦄, x ≺ y → y ≺ x → x = y
570
+
571
+ /-- An empty relation does not relate any elements. -/
572
+ @[nolint unusedArguments]
573
+ def empty_relation := λ _ _ : α => False
574
+
575
+ /-- `q` is a subrelation of `r` if for all `x` and `y`, `q x y` implies `r x y` -/
576
+ def subrelation (q r : β → β → Prop ) := ∀ ⦃x y⦄, q x y → r x y
577
+
578
+ /-- Given `f : α → β`, a relation on `β` induces a relation on `α`.-/
579
+ def inv_image (f : α → β) : α → α → Prop :=
580
+ λ a₁ a₂ => f a₁ ≺ f a₂
581
+
582
+ lemma inv_image.trans (f : α → β) (h : transitive r) : transitive (inv_image r f) :=
583
+ λ (a₁ a₂ a₃ : α) (h₁ : inv_image r f a₁ a₂) (h₂ : inv_image r f a₂ a₃) => h h₁ h₂
584
+
585
+ lemma inv_image.irreflexive (f : α → β) (h : irreflexive r) : irreflexive (inv_image r f) :=
586
+ λ (a : α) (h₁ : inv_image r f a a) => h (f a) h₁
587
+
588
+ end relation
540
589
541
590
section binary
542
591
variable {α : Type u} {β : Type v}
0 commit comments