Relation closures #
This file defines the reflexive, transitive, reflexive transitive and equivalence closures of relations and proves some basic results on them.
Note that this is about unbundled relations, that is terms of types of the form α → β → Prop
. For
the bundled version, see Rel
.
Definitions #
Relation.ReflGen
: Reflexive closure.ReflGen r
relates everythingr
related, plus for alla
it relatesa
with itself. SoReflGen r a b ↔ r a b ∨ a = b
.Relation.TransGen
: Transitive closure.TransGen r
relates everythingr
related transitively. SoTransGen r a b ↔ ∃ x₀ ... xₙ, r a x₀ ∧ r x₀ x₁ ∧ ... ∧ r xₙ b
.Relation.ReflTransGen
: Reflexive transitive closure.ReflTransGen r
relates everythingr
related transitively, plus for alla
it relatesa
with itself. SoReflTransGen r a b ↔ (∃ x₀ ... xₙ, r a x₀ ∧ r x₀ x₁ ∧ ... ∧ r xₙ b) ∨ a = b
. It is the same as the reflexive closure of the transitive closure, or the transitive closure of the reflexive closure. In terms of rewriting systems, this means thata
can be rewritten tob
in a number of rewrites.Relation.EqvGen
: Equivalence closure.EqvGen r
relates everythingReflTransGen r
relates, plus for all related pairs it relates them in the opposite order.Relation.Comp
: Relation composition. We provide notation∘r
. Forr : α → β → Prop
ands : β → γ → Prop
,r ∘r s
relatesa : α
andc : γ
iff there existsb : β
that's related to both.Relation.Map
: Image of a relation under a pair of maps. Forr : α → β → Prop
,f : α → γ
,g : β → δ
,Map r f g
is the relationγ → δ → Prop
relatingf a
andg b
for alla
,b
related byr
.Relation.Join
: Join of a relation. Forr : α → α → Prop
,Join r a b ↔ ∃ c, r a c ∧ r b c
. In terms of rewriting systems, this means thata
andb
can be rewritten to the same term.
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]
.
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
- Relation.Comp r p a c = ∃ (b : β), r a b ∧ p b c
Instances For
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
- Relation.Fibration rα rβ f = ∀ ⦃a : α⦄ ⦃b : β⦄, rβ b (f a) → ∃ (a' : α), rα a' a ∧ f a' = b
Instances For
If f : α → β
is a fibration between relations rα
and rβ
, and a : α
is
accessible under rα
, then f a
is accessible under rβ
.
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
.
Instances For
Equations
- Relation.instDecidableMapOfExistsAndEq = inst
ReflTransGen r
: reflexive transitive closure of r
- refl: ∀ {α : Type u_1} {r : α → α → Prop} {a : α}, Relation.ReflTransGen r a a
- tail: ∀ {α : Type u_1} {r : α → α → Prop} {a b c : α}, Relation.ReflTransGen r a b → r b c → Relation.ReflTransGen r a c
Instances For
ReflGen r
: reflexive closure of r
- refl: ∀ {α : Type u_1} {r : α → α → Prop} {a : α}, Relation.ReflGen r a a
- single: ∀ {α : Type u_1} {r : α → α → Prop} {a b : α}, r a b → Relation.ReflGen r a b
Instances For
EqvGen r
: equivalence closure of r
.
- rel: ∀ {α : Type u_1} {r : α → α → Prop} (x y : α), r x y → Relation.EqvGen r x y
- refl: ∀ {α : Type u_1} {r : α → α → Prop} (x : α), Relation.EqvGen r x x
- symm: ∀ {α : Type u_1} {r : α → α → Prop} (x y : α), Relation.EqvGen r x y → Relation.EqvGen r y x
- trans: ∀ {α : Type u_1} {r : α → α → Prop} (x y z : α), Relation.EqvGen r x y → Relation.EqvGen r y z → Relation.EqvGen r x z
Instances For
Equations
- ⋯ = ⋯
Equations
- Relation.TransGen.instTransReflTransGen = { trans := ⋯ }
Equations
- Relation.TransGen.instTrans_mathlib = { trans := ⋯ }
Equations
- Relation.TransGen.instTransReflTransGen_1 = { trans := ⋯ }
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
EqvGen.setoid r
is the setoid generated by a relation r
.
The motivation for this definition is that Quot r
behaves like Quotient (EqvGen.setoid r)
,
see for example Quot.eqvGen_exact
and Quot.eqvGen_sound
.
Equations
- Relation.EqvGen.setoid r = { r := Relation.EqvGen r, iseqv := ⋯ }
Instances For
Alias of Relation.EqvGen.is_equivalence
.
Alias of Relation.EqvGen.setoid
.
EqvGen.setoid r
is the setoid generated by a relation r
.
The motivation for this definition is that Quot r
behaves like Quotient (EqvGen.setoid r)
,
see for example Quot.eqvGen_exact
and Quot.eqvGen_sound
.
Equations
Instances For
Alias of Relation.EqvGen.mono
.
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
- Relation.Join r a b = ∃ (c : α), r a c ∧ r b c
Instances For
A sufficient condition for the Church-Rosser property.
Alias of Quot.eqvGen_exact
.
Alias of Quot.eqvGen_sound
.