Documentation

Mathlib.Logic.Relation

Relation closures #

This file defines the reflexive, transitive, and reflexive transitive closures of relations. It also proves some basic results on definitions such as EqvGen.

Note that this is about unbundled relations, that is terms of types of the form α → β → Prop. For the bundled version, see Rel.

Definitions #

theorem IsRefl.reflexive {α : Type u_1} {r : α → α → Prop} [IsRefl α r] :
theorem Reflexive.rel_of_ne_imp {α : Type u_1} {r : α → α → Prop} (h : Reflexive r) {x : α} {y : α} (hr : x ≠ y → r x y) :
r x y

To show a reflexive relation r : α → α → Prop holds over x y : α, it suffices to show it holds when x ≠ y.

theorem Reflexive.ne_imp_iff {α : Type u_1} {r : α → α → Prop} (h : Reflexive r) {x : α} {y : α} :
x ≠ y → r x y ↔ r x y

If a reflexive relation r : α → α → Prop holds over x y : α, then it holds whether or not x ≠ y.

theorem reflexive_ne_imp_iff {α : Type u_1} {r : α → α → Prop} [IsRefl α r] {x : α} {y : α} :
x ≠ y → r x y ↔ r x y

If a reflexive relation r : α → α → Prop holds over x y : α, then it holds whether or not x ≠ y. Unlike Reflexive.ne_imp_iff, this uses [IsRefl α r].

theorem Symmetric.iff {α : Type u_1} {r : α → α → Prop} (H : Symmetric r) (x : α) (y : α) :
r x y ↔ r y x
theorem Symmetric.flip_eq {α : Type u_1} {r : α → α → Prop} (h : Symmetric r) :
flip r = r
theorem Symmetric.swap_eq {α : Type u_1} {r : α → α → Prop} :
theorem flip_eq_iff {α : Type u_1} {r : α → α → Prop} :
theorem swap_eq_iff {α : Type u_1} {r : α → α → Prop} :
theorem Reflexive.comap {α : Type u_1} {β : Type u_2} {r : β → β → Prop} (h : Reflexive r) (f : α → β) :
theorem Symmetric.comap {α : Type u_1} {β : Type u_2} {r : β → β → Prop} (h : Symmetric r) (f : α → β) :
theorem Transitive.comap {α : Type u_1} {β : Type u_2} {r : β → β → Prop} (h : Transitive r) (f : α → β) :
theorem Equivalence.comap {α : Type u_1} {β : Type u_2} {r : β → β → Prop} (h : Equivalence r) (f : α → β) :
def Relation.Comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} (r : α → β → Prop) (p : β → γ → Prop) (a : α) (c : γ) :

The composition of two relations, yielding a new relation. The result relates a term of α and a term of γ if there is an intermediate term of β related to both.

Equations
Instances For
    theorem Relation.comp_eq {α : Type u_1} {β : Type u_2} {r : α → β → Prop} :
    (Relation.Comp r fun (x x_1 : β) => x = x_1) = r
    theorem Relation.eq_comp {α : Type u_1} {β : Type u_2} {r : α → β → Prop} :
    Relation.Comp (fun (x x_1 : α) => x = x_1) r = r
    theorem Relation.iff_comp {α : Type u_1} {r : Prop → α → Prop} :
    Relation.Comp (fun (x x_1 : Prop) => x ↔ x_1) r = r
    theorem Relation.comp_iff {α : Type u_1} {r : α → Prop → Prop} :
    (Relation.Comp r fun (x x_1 : Prop) => x ↔ x_1) = r
    theorem Relation.comp_assoc {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {r : α → β → Prop} {p : β → γ → Prop} {q : γ → δ → Prop} :
    theorem Relation.flip_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → β → Prop} {p : β → γ → Prop} :
    def Relation.Fibration {α : Type u_1} {β : Type u_2} (rα : α → α → Prop) (rβ : β → β → Prop) (f : α → β) :

    A function f : α → β is a fibration between the relation rα and rβ if for all a : α and b : β, whenever b : β and f a are related by rβ, b is the image of some a' : α under f, and a' and a are related by rα.

    Equations
    Instances For
      theorem Acc.of_fibration {α : Type u_1} {β : Type u_2} {rα : α → α → Prop} {rβ : β → β → Prop} (f : α → β) (fib : Relation.Fibration rα rβ f) {a : α} (ha : Acc rα a) :
      Acc rβ (f a)

      If f : α → β is a fibration between relations rα and rβ, and a : α is accessible under rα, then f a is accessible under rβ.

      theorem Acc.of_downward_closed {α : Type u_1} {β : Type u_2} {rβ : β → β → Prop} (f : α → β) (dc : ∀ {a : α} {b : β}, rβ b (f a) → ∃ (c : α), f c = b) (a : α) (ha : Acc (InvImage rβ f) a) :
      Acc rβ (f a)
      def Relation.Map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (r : α → β → Prop) (f : α → γ) (g : β → δ) :
      γ → δ → Prop

      The map of a relation r through a pair of functions pushes the relation to the codomains of the functions. The resulting relation is defined by having pairs of terms related if they have preimages related by r.

      Equations
      Instances For
        theorem Relation.ReflTransGen.cases_tail_iff {α : Type u_1} (r : α → α → Prop) (a : α) :
        ∀ (a_1 : α), Relation.ReflTransGen r a a_1 ↔ a_1 = a ∨ ∃ (b : α), Relation.ReflTransGen r a b ∧ r b a_1
        inductive Relation.ReflTransGen {α : Type u_1} (r : α → α → Prop) (a : α) :
        α → Prop

        ReflTransGen r: reflexive transitive closure of r

        Instances For
          theorem Relation.reflGen_iff {α : Type u_1} (r : α → α → Prop) (a : α) :
          ∀ (a_1 : α), Relation.ReflGen r a a_1 ↔ a_1 = a ∨ r a a_1
          inductive Relation.ReflGen {α : Type u_1} (r : α → α → Prop) (a : α) :
          α → Prop

          ReflGen r: reflexive closure of r

          Instances For
            theorem Relation.transGen_iff {α : Type u_1} (r : α → α → Prop) (a : α) :
            ∀ (a_1 : α), Relation.TransGen r a a_1 ↔ r a a_1 ∨ ∃ (b : α), Relation.TransGen r a b ∧ r b a_1
            inductive Relation.TransGen {α : Type u_1} (r : α → α → Prop) (a : α) :
            α → Prop

            TransGen r: transitive closure of r

            Instances For
              theorem Relation.ReflGen.to_reflTransGen {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :
              theorem Relation.ReflGen.mono {α : Type u_1} {r : α → α → Prop} {p : α → α → Prop} (hp : ∀ (a b : α), r a b → p a b) {a : α} {b : α} :
              instance Relation.ReflGen.instIsReflReflGen {α : Type u_1} {r : α → α → Prop} :
              Equations
              theorem Relation.ReflTransGen.trans {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : Relation.ReflTransGen r a b) (hbc : Relation.ReflTransGen r b c) :
              theorem Relation.ReflTransGen.single {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (hab : r a b) :
              theorem Relation.ReflTransGen.head {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : r a b) (hbc : Relation.ReflTransGen r b c) :
              theorem Relation.ReflTransGen.symmetric {α : Type u_1} {r : α → α → Prop} (h : Symmetric r) :
              theorem Relation.ReflTransGen.cases_tail {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :
              Relation.ReflTransGen r a b → b = a ∨ ∃ (c : α), Relation.ReflTransGen r a c ∧ r c b
              theorem Relation.ReflTransGen.head_induction_on {α : Type u_1} {r : α → α → Prop} {b : α} {P : (a : α) → Relation.ReflTransGen r a b → Prop} {a : α} (h : Relation.ReflTransGen r a b) (refl : P b (_ : Relation.ReflTransGen r b b)) (head : ∀ {a c : α} (h' : r a c) (h : Relation.ReflTransGen r c b), P c h → P a (_ : Relation.ReflTransGen r a b)) :
              P a h
              theorem Relation.ReflTransGen.trans_induction_on {α : Type u_1} {r : α → α → Prop} {P : {a b : α} → Relation.ReflTransGen r a b → Prop} {a : α} {b : α} (h : Relation.ReflTransGen r a b) (ih₁ : ∀ (a : α), P (_ : Relation.ReflTransGen r a a)) (ih₂ : ∀ {a b : α} (h : r a b), P (_ : Relation.ReflTransGen r a b)) (ih₃ : ∀ {a b c : α} (h₁ : Relation.ReflTransGen r a b) (h₂ : Relation.ReflTransGen r b c), P h₁ → P h₂ → P (_ : Relation.ReflTransGen r a c)) :
              P h
              theorem Relation.ReflTransGen.cases_head {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : Relation.ReflTransGen r a b) :
              a = b ∨ ∃ (c : α), r a c ∧ Relation.ReflTransGen r c b
              theorem Relation.ReflTransGen.cases_head_iff {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :
              Relation.ReflTransGen r a b ↔ a = b ∨ ∃ (c : α), r a c ∧ Relation.ReflTransGen r c b
              theorem Relation.ReflTransGen.total_of_right_unique {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (U : Relator.RightUnique r) (ab : Relation.ReflTransGen r a b) (ac : Relation.ReflTransGen r a c) :
              theorem Relation.TransGen.to_reflTransGen {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : Relation.TransGen r a b) :
              theorem Relation.TransGen.trans_left {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : Relation.TransGen r a b) (hbc : Relation.ReflTransGen r b c) :
              Equations
              theorem Relation.TransGen.trans {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : Relation.TransGen r a b) (hbc : Relation.TransGen r b c) :
              Equations
              theorem Relation.TransGen.head' {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : r a b) (hbc : Relation.ReflTransGen r b c) :
              theorem Relation.TransGen.tail' {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : Relation.ReflTransGen r a b) (hbc : r b c) :
              theorem Relation.TransGen.head {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : r a b) (hbc : Relation.TransGen r b c) :
              theorem Relation.TransGen.head_induction_on {α : Type u_1} {r : α → α → Prop} {b : α} {P : (a : α) → Relation.TransGen r a b → Prop} {a : α} (h : Relation.TransGen r a b) (base : ∀ {a : α} (h : r a b), P a (_ : Relation.TransGen r a b)) (ih : ∀ {a c : α} (h' : r a c) (h : Relation.TransGen r c b), P c h → P a (_ : Relation.TransGen r a b)) :
              P a h
              theorem Relation.TransGen.trans_induction_on {α : Type u_1} {r : α → α → Prop} {P : {a b : α} → Relation.TransGen r a b → Prop} {a : α} {b : α} (h : Relation.TransGen r a b) (base : ∀ {a b : α} (h : r a b), P (_ : Relation.TransGen r a b)) (ih : ∀ {a b c : α} (h₁ : Relation.TransGen r a b) (h₂ : Relation.TransGen r b c), P h₁ → P h₂ → P (_ : Relation.TransGen r a c)) :
              P h
              theorem Relation.TransGen.trans_right {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : Relation.ReflTransGen r a b) (hbc : Relation.TransGen r b c) :
              Equations
              theorem Relation.TransGen.tail'_iff {α : Type u_1} {r : α → α → Prop} {a : α} {c : α} :
              Relation.TransGen r a c ↔ ∃ (b : α), Relation.ReflTransGen r a b ∧ r b c
              theorem Relation.TransGen.head'_iff {α : Type u_1} {r : α → α → Prop} {a : α} {c : α} :
              Relation.TransGen r a c ↔ ∃ (b : α), r a b ∧ Relation.ReflTransGen r b c
              theorem Acc.TransGen {α : Type u_1} {r : α → α → Prop} {a : α} (h : Acc r a) :
              theorem acc_transGen_iff {α : Type u_1} {r : α → α → Prop} {a : α} :
              theorem WellFounded.transGen {α : Type u_1} {r : α → α → Prop} (h : WellFounded r) :
              theorem Relation.reflGen_eq_self {α : Type u_1} {r : α → α → Prop} (hr : Reflexive r) :
              theorem Relation.reflexive_reflGen {α : Type u_1} {r : α → α → Prop} :
              theorem Relation.reflGen_minimal {α : Type u_1} {r : α → α → Prop} {r' : α → α → Prop} (hr' : Reflexive r') (h : ∀ (x y : α), r x y → r' x y) {x : α} {y : α} (hxy : Relation.ReflGen r x y) :
              r' x y
              theorem Relation.transGen_eq_self {α : Type u_1} {r : α → α → Prop} (trans : Transitive r) :
              theorem Relation.transitive_transGen {α : Type u_1} {r : α → α → Prop} :
              instance Relation.instIsTransTransGen {α : Type u_1} {r : α → α → Prop} :
              Equations
              theorem Relation.TransGen.lift {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop} {a : α} {b : α} (f : α → β) (h : ∀ (a b : α), r a b → p (f a) (f b)) (hab : Relation.TransGen r a b) :
              Relation.TransGen p (f a) (f b)
              theorem Relation.TransGen.lift' {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop} {a : α} {b : α} (f : α → β) (h : ∀ (a b : α), r a b → Relation.TransGen p (f a) (f b)) (hab : Relation.TransGen r a b) :
              Relation.TransGen p (f a) (f b)
              theorem Relation.TransGen.closed {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :
              (∀ (a b : α), r a b → Relation.TransGen p a b) → Relation.TransGen r a b → Relation.TransGen p a b
              theorem Relation.TransGen.mono {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :
              (∀ (a b : α), r a b → p a b) → Relation.TransGen r a b → Relation.TransGen p a b
              theorem Relation.transGen_minimal {α : Type u_1} {r : α → α → Prop} {r' : α → α → Prop} (hr' : Transitive r') (h : ∀ (x y : α), r x y → r' x y) {x : α} {y : α} (hxy : Relation.TransGen r x y) :
              r' x y
              theorem Relation.TransGen.swap {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : Relation.TransGen r b a) :
              theorem Relation.transGen_swap {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :
              theorem Relation.reflTransGen_iff_eq {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : ∀ (b : α), ¬r a b) :
              theorem Relation.reflTransGen_iff_eq_or_transGen {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :
              theorem Relation.ReflTransGen.lift {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop} {a : α} {b : α} (f : α → β) (h : ∀ (a b : α), r a b → p (f a) (f b)) (hab : Relation.ReflTransGen r a b) :
              Relation.ReflTransGen p (f a) (f b)
              theorem Relation.ReflTransGen.mono {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :
              (∀ (a b : α), r a b → p a b) → Relation.ReflTransGen r a b → Relation.ReflTransGen p a b
              theorem Relation.reflTransGen_eq_self {α : Type u_1} {r : α → α → Prop} (refl : Reflexive r) (trans : Transitive r) :
              theorem Relation.reflTransGen_minimal {α : Type u_1} {r : α → α → Prop} {r' : α → α → Prop} (hr₁ : Reflexive r') (hr₂ : Transitive r') (h : ∀ (x y : α), r x y → r' x y) {x : α} {y : α} (hxy : Relation.ReflTransGen r x y) :
              r' x y
              instance Relation.instIsReflReflTransGen {α : Type u_1} {r : α → α → Prop} :
              Equations
              instance Relation.instIsTransReflTransGen {α : Type u_1} {r : α → α → Prop} :
              Equations
              theorem Relation.ReflTransGen.lift' {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop} {a : α} {b : α} (f : α → β) (h : ∀ (a b : α), r a b → Relation.ReflTransGen p (f a) (f b)) (hab : Relation.ReflTransGen r a b) :
              Relation.ReflTransGen p (f a) (f b)
              theorem Relation.reflTransGen_closed {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :
              (∀ (a b : α), r a b → Relation.ReflTransGen p a b) → Relation.ReflTransGen r a b → Relation.ReflTransGen p a b
              theorem Relation.ReflTransGen.swap {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : Relation.ReflTransGen r b a) :
              theorem Relation.reflTransGen_swap {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :
              def Relation.Join {α : Type u_1} (r : α → α → Prop) :
              α → α → Prop

              The join of a relation on a single type is a new relation for which pairs of terms are related if there is a third term they are both related to. For example, if r is a relation representing rewrites in a term rewriting system, then confluence is the property that if a rewrites to both b and c, then join r relates b and c (see Relation.church_rosser).

              Equations
              Instances For
                theorem Relation.church_rosser {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (h : ∀ (a b c : α), r a b → r a c → ∃ (d : α), Relation.ReflGen r b d ∧ Relation.ReflTransGen r c d) (hab : Relation.ReflTransGen r a b) (hac : Relation.ReflTransGen r a c) :

                A sufficient condition for the Church-Rosser property.

                theorem Relation.join_of_single {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : Reflexive r) (hab : r a b) :
                theorem Relation.symmetric_join {α : Type u_1} {r : α → α → Prop} :
                theorem Relation.reflexive_join {α : Type u_1} {r : α → α → Prop} (h : Reflexive r) :
                theorem Relation.transitive_join {α : Type u_1} {r : α → α → Prop} (ht : Transitive r) (h : ∀ (a b c : α), r a b → r a c → Relation.Join r b c) :
                theorem Relation.equivalence_join {α : Type u_1} {r : α → α → Prop} (hr : Reflexive r) (ht : Transitive r) (h : ∀ (a b c : α), r a b → r a c → Relation.Join r b c) :
                theorem Relation.equivalence_join_reflTransGen {α : Type u_1} {r : α → α → Prop} (h : ∀ (a b c : α), r a b → r a c → ∃ (d : α), Relation.ReflGen r b d ∧ Relation.ReflTransGen r c d) :
                theorem Relation.join_of_equivalence {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {r' : α → α → Prop} (hr : Equivalence r) (h : ∀ (a b : α), r' a b → r a b) :
                Relation.Join r' a b → r a b
                theorem Relation.reflTransGen_of_transitive_reflexive {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {r' : α → α → Prop} (hr : Reflexive r) (ht : Transitive r) (h : ∀ (a b : α), r' a b → r a b) (h' : Relation.ReflTransGen r' a b) :
                r a b
                theorem Relation.reflTransGen_of_equivalence {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {r' : α → α → Prop} (hr : Equivalence r) :
                (∀ (a b : α), r' a b → r a b) → Relation.ReflTransGen r' a b → r a b
                theorem Equivalence.eqvGen_iff {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : Equivalence r) :
                EqvGen r a b ↔ r a b
                theorem Equivalence.eqvGen_eq {α : Type u_1} {r : α → α → Prop} (h : Equivalence r) :
                EqvGen r = r
                theorem EqvGen.mono {α : Type u_1} {a : α} {b : α} {r : α → α → Prop} {p : α → α → Prop} (hrp : ∀ (a b : α), r a b → p a b) (h : EqvGen r a b) :
                EqvGen p a b