relation 与injective/surjective/bijective function 等相关的知识在
5. Tactics
里,为了避免每次都要grep
我在这里写一下。
Relations
Recalling Relation
from FCT/TAPL/Wiki…
a possible connection between the components of a k-tuple.
I have been long confused with Unary Relations vs. Binary Relation on the Same Set (homogeneous relation)
I thought they were same…but turns out they are totally different!
Unary/1-place relation is Predicate or Property!
Either defined via set X ⊆ P
or x ∈ P
,
or defined via function P : X -> Bool
or P : X -> {⊥, ⊤}
.
(usually used in Math. Logic)
Property = Indicator Fn = characteristic Fn = Boolean Predicate Fn = Predicate
- https://en.wikipedia.org/wiki/Property_(mathematics)
- https://en.wikipedia.org/wiki/Indicator_function
Binary Relation/2-place relation
Defined via two sets : R ⊆ X × Y
or x, y ∈ R
or xRy
. (where x ∈ X, y ∈ Y
.)
or via function R: X × Y -> Bool
.
Homogeneous Relation 同类(的)关系
Specifically! when X = Y
, is called a homogeneous relation:
Noticed that we are still concerning relations of 2 elements!!, but they are from the same Set!
(while 1-place relation concerning only 1 element.)
R ⊆ X × X
xRy where x ∈ X, y ∈ X
it’s written/spoken Binary relation on/over Set X
.
Properties e.g. reflexive, symmetric, transitive, are all properties of “Homogeneous Relation”!
Back to Coq
“relation” is a general idea. but in Coq standard lib it means “binary relation on a set X”
Coq
identifier
relation will always refer to a binary relation between some set and itself.
it’s defined as a family of Prop parameterized by two elements of X
:
1 | Definition relation (X: Type) := X → X → Prop. |
Basic Properties
ways to classifying relations.
so theorems can be proved generically about certain sorts of relations
It’s pretty fun to see all mathematical things defined in Coq!
(much more constructive)
Partial Function
function is defined as a special kind of binary relation.
1 | Definition partial_function {X: Type} (R: relation X) := |
meaning that foreach input x ∈ X
, there is a unique y ∈ Y
corresponded.
But this only establish a partial function.
because it doesn’t say anything about totality,
to define total function, we require f
map every x ∈ X
.
∀x ∀y (x ∈ X ∧ y ∈ X) ⇒ (xRy ∨ yRx).
totally different with total function but ask the binary relation holds between every pair.
Reflexive
1 | Definition transitive {X: Type} (R: relation X) := |
Transitive
1 | Definition transitive {X: Type} (R: relation X) := |
Symmetric & Antisymmetric
1 | Definition symmetric {X: Type} (R: relation X) := |
Antisymmetric vs Asymmetric vs Non-symmetric (反对称 vs. 非对称 vs. 不-对称)
A relation is asymmetric if and only if it is both antisymmetric and irreflexive
e.g. <=
is neither symmetric nor asymmetric, but it’s antisymmetric…
反对称: 可以自反 (只能 reflexive 时对称) <=
非对称: 不能自反 <
不对称: 不是对称
Equivalence
1 | Definition equivalence {X:Type} (R: relation X) := |
Partial Orders
A partial order under which every pair of elements is comparable is called a total order or linear order
In the Coq standard library it’s called just order
for short:
1 | Definition order {X:Type} (R: relation X) := |
Preorders
a.k.a quasiorder
The subtyping relations are usually preorders.
(TAPL p185) because of the record permutation rule…there are many pairs of distinct types where each is a subtype of the other.
1 | Definition preorder {X:Type} (R: relation X) := |
Reflexive, Transitive Closure
Closure
Closure can be considered as Operations on bin-rel
As properties such as reflexive, transitive,
the blah blah Closure are only talking about “homogeneous relations” i.e., Relation on a SINGLE set.
Reflexive Closure
Def. smallest reflexive relation on X
containing R
.
Operationally, as a =
operator on a binary relation R
:
R⁼ = R ∪ { (x, x) | x ∈ X }
and this obviously satisfy R⁼ ⊇ R
.
Transitive Closure
Def. smallest transitive relation on X
containing R
.
Operationally, as a +
operator on a binary relation R
:
R+ = R ∪ { (x1,xn) | n > 1 ∧ (x1,x2), ..., (xn-1,xn) ∈ R }
We can also constructively and inductively definition using R^i
where i = i-transitivity away
.
Reflexive, Transitive Closure
R* = R⁼ ∪ R+
Why is it useful?
The idea is that a relation is extended s.t.
the derived relation has the (reflexsive and) transitive property. – Prof. Arthur
e.g.
the “descendant” relation is the transitive closure of the “child” relation,
the “derives-star (⇒⋆)” relation is the reflexive-transitive closure of the “derives (⇒)” relation.
the “ε-closure” relation is the reflexive-transitive closure of the “ε-transition” relation.
the “Kleene-star (Σ⋆)” relation is the reflexive-transitive closure of the “concatentation” relation.
Another way is to think them as “set closed under some operation”.
Back to Coq
1 | Inductive clos_refl_trans {A: Type} (R: relation A) : relation A := |
The above version will generate 2 IHs in rt_trans
case. (since the proof tree has 2 branches).
Here is a better “linked-list”-ish one. (we will exclusively use this style)
1 | Inductive clos_refl_trans_1n {A : Type} (R : relation A) (x : A) : A → Prop := |
In later chapter, we will define a decorator multi
that can take any binary relation on a set and return its closure relation:
1 | Inductive multi (X : Type) (R : relation X) : relation X := |
We name it step
, standing for doing one step of this relation, and then we still have the rest (sub-structure) satisfied the closure relation.
- 本文标题:「SF-LC」11 Rel
- 创建时间:2021-03-28 00:00:00
- 本文链接:posts/6574.html
- 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!