Relation closures #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines the reflexive, transitive, and reflexive transitive closures of relations.
It also proves some basic results on definitions in core, such as eqv_gen
.
Note that this is about unbundled relations, that is terms of types of the form α → β → Prop
. For
the bundled version, see rel
.
Definitions #
relation.refl_gen
: Reflexive closure.refl_gen r
relates everythingr
related, plus for alla
it relatesa
with itself. Sorefl_gen r a b ↔ r a b ∨ a = b
.relation.trans_gen
: Transitive closure.trans_gen r
relates everythingr
related transitively. Sotrans_gen r a b ↔ ∃ x₀ ... xₙ, r a x₀ ∧ r x₀ x₁ ∧ ... ∧ r xₙ b
.relation.refl_trans_gen
: Reflexive transitive closure.refl_trans_gen r
relates everythingr
related transitively, plus for alla
it relatesa
with itself. Sorefl_trans_gen 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.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.
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
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α
.
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 relation.map
Equations
- relation.map.decidable = _inst_1
- refl : ∀ {α : Type u_1} {r : α → α → Prop} {a : α}, relation.refl_trans_gen r a a
- tail : ∀ {α : Type u_1} {r : α → α → Prop} {a b c : α}, relation.refl_trans_gen r a b → r b c → relation.refl_trans_gen r a c
refl_trans_gen r
: reflexive transitive closure of r
Instances for relation.refl_trans_gen
- single : ∀ {α : Type u_1} {r : α → α → Prop} {a b : α}, r a b → relation.trans_gen r a b
- tail : ∀ {α : Type u_1} {r : α → α → Prop} {a b c : α}, relation.trans_gen r a b → r b c → relation.trans_gen r a c
trans_gen r
: transitive closure of r
Instances for relation.trans_gen
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
A sufficient condition for the Church-Rosser property.