Theory of Relational Calculus and its Formalization
1. Theory of Relational Calculus and its formalization
Yoshihiro Mizoguchi
Institute of Mathematics for Industry
Kyushu University, JAPAN
Universal Structures in Mathematics and Computing (USMaC2016)
La Trobe University
June 29th, 2016
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 1 / 64
2. Abstract
There are many network structures (relations between certain objects)
considered in applications of mathematics for industry. We use many
calculations of numbers and equations of numbers in mathematical
analysis. But we seldom use calculations of network structures or
equations of relational structures. On the other hand, a sufficiently
developed theory of relations has been existing for a long while. In this
talk, we review those theory of relations from a view point of a
computation. we show an elementary theory of relations and its
formalization in Coq, a proof assistant system. Further, we introduce an
automatic proving procedures (tactics) for our formalization of the theory of
relational calculus.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 2 / 64
3. Table of Contents
1 Introduction
2 From Algebra to Category
3 Coq Proof Assitant System
4 Coq Library for Relational Calculus
5 Category Theory using Relational Calculus
6 Automata Theory using Relational Calculus
7 Relational Graph Rewriting
8 Conclusion
9 References
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 3 / 64
5. Introduction
There are many network structures (relations between certain
objects) considered in applications of mathematics in other sciences.
We use many calculations of numbers and equations of numbers in
mathematical analysis in application areas.
We seldom do calculations in mathematical analysis of network
structures or equations of structures.
A sufficiently developed theory of relations has been existing for a
long while.
Managing calculations of relations, we reexamine properties of
network structures.
It is also intended to construct a theory of relations with computer
verifiable proofs.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 5 / 64
6. Historical Background
The modern story of an algebra of logic is started by G. Boole (1847).
Complement, Converse (Inverse) and Composition of relations.
(De Morgen 1864)
To create an algebra out of logic. (C. S. Peirce 1870)
Axiomatization of a relation algebra and its Representability.
(Tarski 1941, R.Lyndon 1950, McKenzie 1966)
Relations in categories.
(S. MacLane 1961, D. Puppe 1962, Y. Kawahara 1973)
Algebra to Category (Homogeneous to heterogeneous)
Allegories(Freyd 1990), Dedekind category (Oliver 1980).
Axiomatization of Dedekind category with point axioms
(H. Furusawa 2015)
† R. D. Maddux, The origin of relation algebras in the development and
axiomaization of the calculus of relations, 1991.
† R. Hirsh, I. Hodkinson, Relation algebras by games, 2002.
† G. Schmidt, Relational Mathematics, 2010.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 6 / 64
7. Applications to Computer Science
Theory of program (Program verification)
The weakest prespecifiacion (Hoare 1987),
Categorical assertion semantics in toposes (Kawahara 1992),
Automated verification of relational while-programs (Berghammer 2014),
Semigroup with if–then–else and halting programs (Jackson 2009).
Automata, Graph rewritings (Model of computation)
Applications of relational calculus to computer mathematics
(Kawahara 1988),
Relational graph rewritings (Mizoguchi 1995).
Relational database, Formal concepts analysis (Model of data)
Relational aspects of relational database dependencies (Okuma 2000),
Formal concepts in Dedekind categories (Ishida 2008).
† 16th International Conference on Relational and Algebraic Methods in
Computer Science (RAMiCS),
http://www.ens-lyon.fr/LIP/PLUME/RAMiCS17/
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 7 / 64
8. Section 2: From Algebra to Category
From Algebra to Category
Boolean Algebra → Relation Algebra → Dedekind Category
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 8 / 64
9. Boolean algebra (1)
Let B = (B, ϕ, ∇, ⊔, −) be a quintuple of a set B, elements ϕ, ∇ ∈ B,
operations ⊔ : B × B → B and − : B → B. B is a Boolean algebra, if it
satisfies the following axioms for any elements a, b, c ∈ B.
(a ⊔ b) ⊔ c = a ⊔ (b ⊔ c)
a ⊔ b = b ⊔ a
a ⊔ a = a
−(−b) = b
b ⊔ (−b) = ∇
−∇ = ϕ
a ⊓ (b ⊔ c) = (a ⊓ b) ⊔ (a ⊓ c)
where x ⊓ y = −((−x) ⊔ (−y)).
ϕ ⊔ a = a
※ a ⊑ b is defined by a ⊔ b = b, and a − b is defined by a ⊔ (−b).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 9 / 64
10. Boolean algebra (2)
Let 2X be the set of all subsets of a set X. For any subsets A and B of X,
Let A ⊔ B be the union of sets A and B and −A the complement
(−A = X − A) of a set A. Then we have a Boolean algebra
P(X) = (2X, ϕ, X, ⊔, −).
Theorem (Stone’s representation theorem(1936))
Let B be a Boolean algebra. Then there exists a set X such that P(X) and
B are equivalent as a Boolean algebra.
Proposition
A finite Boolean algebra is equivalent to a Boolean algebra of some finite
set. So every finite Boolean algebra is corresponding to a natural number
n and its number of elements is 2n.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 10 / 64
11. Relation algebra (1)
Let R be a set, ϕ, ∇, id ∈ R, ⊔ : R × R → R, · : R × R → R, − : R → R
and ( )♯ : R → R. A octuple R = (R, ⊔, −, ϕ, ∇, id,♯ , ·) is called a relation
algebra, if for any elements a, b, c ∈ B it satisfies following axioms:
(R, ⊔, −, ϕ, ∇) is a Boolean algebra.
(R, ·, id,♯ ) is an involutive monoid with
the identity element id.
(a · b) · c = a · (b · c)
a · id = id · a = a
(a♯
)♯
= a
(a · b)♯
= b♯
· a♯
The following three conditions are
equivalent.
(a · b) ⊓ c = ϕ
(a♯
· c) ⊓ b = ϕ
a ⊓ (c · b♯
) = ϕ
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 11 / 64
12. Relation algebra (2)
Let X be a set and 2X×X a set of all subsets of X × X. For any subsets A,
B of X × X, we define
A · B = {(x, y) | ∃u, (x, u) ∈ A ∧ (u, y) ∈ B}
idX = {(x, x) | x ∈ X}, and
A♯
= {(y, x) | (x, y) ∈ A}.
Then P(X × X) = (2X×X, ⊔, −, ϕ, X × X, idX, ( )♯, ·) is a relational algebra.
Example
For a relation A ∈ 2X×X, the expression A · A ⊆ A is corresponding to the
transitive law,
(a, b) ∈ A ∧ (b, c) ∈ A ⇒ (a, c) ∈ A.
Our main idea is translating a logical formula in set theory to an expression
using relation algebra’s operations. Further, we prove those properties
using symbolic computations.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 12 / 64
13. Lyndon’s conditions
Let X be a set, P(X × X) a relation algebra defined by all subsets of
X × X. For any elements in 2X×X, the following conditions always hold:
(D1)
(a·b)⊓(c·d)⊓(e· f) ⊏ a·[(a♯
·c)⊓(b·d♯
)⊓{((a♯
·e)⊓(b· f♯
))·((e♯
·c)⊓(f ·d♯
))}]·d
(D2)
a⊓((b⊓(c·d))·(e⊓(f·g))) ⊏ c·[(((c♯
·a)⊓(d·e))·g♯
)⊓(d·f)⊓(c♯
·((a·g♯
)⊓(b·f)))]·g
(D3) If a ⊏ (b · c) ⊓ (d · e) and (b♯
· d) ⊓ (c · e♯
) ⊏ f · g then
a ⊏ ((b · f) ⊓ (d · g♯
)) · (( f♯
· b♯
) ⊓ (g · e)).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 13 / 64
14. McKenzie algebra
Let A = {id, x, y, y♯} and consider a freely generated relation algebra by
A ∪ {ϕ, ∇} (i.e. an element is a finite union(⊔) of elements of A ∪ {ϕ, ∇}
and ϕ(∇) is a minimum(maximum) elements).
x = x♯, id♯
= id
For any α ∈ A, ϕ ⊏ α ⊏ ∇ and α ⊓ α = α.
For any α, β ∈ A, if α β then α ⊓ β = ϕ.
concatenation (·) is defined by the following table:
· id x y y♯
id id x y y♯
x x id ⊔ y ⊔ y♯ x ⊔ y x ⊔ y♯
y y x ⊔ y y ∇
y♯ y♯ x ⊔ y♯ ∇ y♯
We call the relation algebra defined by above conditions as the McKenzie
algebra.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 14 / 64
15. undecidability of relation algebra
Conjecture
Any relation algebra R is equivalent to a sub-algebra of a relation algebra
P(X × X) for some set X.
Theorem (McKenzie 1970)
McKenzie algebra does not satisfy (D2). i.e. If a = c = d = f = g = x,
b = y, and e = y♯, then (D2) does not hold.
The proof of above theorem is proved by computing (D2) assigning
appropriate elements using axioms.
※ The first prove of existence of a relation algebra which is not
represented by a relation algebra of subsets of X × X is introduced by
Lyndon(1950).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 15 / 64
16. Dedekind category (Category of relations) (1)
Let D be a category, D(X, Y) a class of all morphisms from X to Y for
X, Y ∈ D. For any objects X, Y, and Z, we define the composition ·, the
inverse ( )♯, and the residue composition ▷ as follows:
· = D(X, Y) × D(Y, Z) → D(X, Z)
( )♯
= D(X, Y) → D(Y, X)
▷ = D(X, Y) × D(Y, Z) → D(X, Z)
We call D as a Dedekind category if it satisfies following conditions:
1 (D, ⊑, ⊓, ⊔, ⇒, ϕXY, ∇XY) is a complete Heyting algebra with the
minimum ϕXY and the maximum ∇XY.
2 Let α, α′ ∈ D(X, Y). Then
(α · β)♯
= β♯
· α♯
(α♯
)♯
= α
If α ⊑ α′
then α♯
⊑ α′♯
.
3 Let α ∈ D(X, Y), β ∈ D(Y, Z), γ ∈ D(X, Z). Then
(α · β) ⊓ γ ⊑ α · (β ⊓ (α♯
· γ))
4 Let α ∈ D(X, Y), β ∈ D(Y, Z), δ ∈ D(X, Z). Then
δ ⊑ α ▷ β ↔ α♯
· δ ⊑ β
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 16 / 64
17. Dedekind category (Category of relations) (2)
※ Summary of notations:
(1) A relation α from a set A into another set B is a subset of the
Cartesian product A × B and denoted by α : A ⇁ B.
(2) The inverse relation α♯ : B ⇁ A of α is a relation such that
(b, a) ∈ α♯ if and only if (a, b) ∈ α.
(3) The composite αβ : A ⇁ C of α : A ⇁ B followed by β : B ⇁ C is
a relation such that (a, c) ∈ αβ if and only if there exists b ∈ B with
(a, b) ∈ α and (b, c) ∈ β.
(4) As a relation of a set A into a set B is a subset of A × B, the inclusion
relation, union, intersection and difference of them are available as
usual and denoted by ⊑, ⊔, ⊓ and −, respectively.
(5) The identity relation idA : A ⇁ A is a relation with
idA = {(a, a) ∈ A × A |,a ∈ A}.
(6) The empty relation ϕ ⊆ A × B is denoted by 0AB. The entire set
A × B is called the universal relation and denoted by ∇AB.
(7) The one point set {∗} is denoted by I. We note that ∇II = idI.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 17 / 64
18. Section 3: A Coq Proof Assistant System
Coq Proof Assitant System
for Information Systems
and
for Mathematics
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 18 / 64
19. What is Coq?
Coq is a proof assistant system developed in INRIA (France). A proof
assistant system is used to show a correctness of a program. The
Common Criteria for Information Technology Security Evaluation is an
international standard (ISO/IEC 15408) for computer security certification.
In the EAL7 (The maximum Evaluation Assurance Level), a formal
verification is requested. In Japan, Sony(and FeliCa) took a certification of
EAL6+ for a FeliCa chip a payment IC card embedded in a mobile phone
called ’OSAIFU KEITAI’ (moblie wallet).
Personally, I think that formal verifications could be much important for
many areas including an automatic driving vehicle system. Recently, proof
assistant systems are used to create a computer verifiable proof for
complicated theorems in Mathematics.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 19 / 64
20. Formal Proofs in Mathematics
G. Gonthier, Formal Proof―The Four-Color Theorem. Notices of the American
Mathematical Society, 55(11), 13821393, 2008.
http://www.ams.org/notices/200811/tx081101382p.pdf
R. Affeldt and M. Hagiwara, Formalization of Shannon’s Therems in SSReflect-Coq,
Proc. 3rd Conference on Interactive Theorem Proving, LNCS 7406, 233249, 2012.
G. Gonthier, et al., A Machine-Checked Proof of the Odd Order Theorem, Proc. 4th
Conference on Interactive Theorem Proving, LNCS 7998, 163179, 2013.
https://hal.inria.fr/hal-00816699/file/main.pdf
F. Chyzak, A. Mahboubi et.al, A Computer-Algebra-Based Formal Proof of the
Irrationality of ζ(3), Proc. 5th International Conference on Interactive Theorem
Proving, LNCS 8558, 2014, https://hal.inria.fr/hal-00984057.
T. Hales, Dense Sphere Packings : A blueprint for formal proofs, Cambridge
University Press, 2012. (The Kepler Conjecture)
J.Avigad and J.Harrison, Formally Verified Mathematics, Communications of the
ACM, Vol.57(4), 2014. (Tutorial)
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 20 / 64
21. Four Color Theorem
Kyushu Island in Japan
Kyushu University is
in Fukuoka Prefecture
The four color theorem states that no
ore than four colors are required to
color the regions of the plane map so
that no two adjacent regions have the
same color.
First, it is proved by Appel and Haken
in 1976. They found 1405 unavoidable
sets and find solutions using a
computer (IBM-360).
In 1996, Robertson et. al. improved
and reduced the number of
unavoidable sets to 633. They use a
computer Sun Sparc20.
In 2004, Gonthier et. al. introduced a
complete verifiable proof for the four
color theorem using a proof assistant
system Coq and its extension
Ssreflect.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 21 / 64
22. Keplar Conjecture
Keplar Conjecture states that no arrangement of equality sized
spheres filling space has a greater average density than that of the
cubic close packing and hexagonal close packing arrangements.
In 1998, Thomas Hales proved it manually using a Java program
which compare densities of 5128 tame graphs corresponding to
specified arrangements. The reviewer gave up to review the paper.
In 2006, Nipkow et. al. reduced the number of tame graphs to 2771
and proved using a proof assistant Isabell/HOL.
In 2014, Hales et. al. announced the completion of a formal verifiable
proof. The member of Flyspec project finished to construct a formal
proof using HOL Light.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 22 / 64
23. Announcements and Links
SSreflect in the world,
http://coqfinitgroup.gforge.inria.fr/ssreflect_world.html
Coq Proof of the Four Color Theorem, 2006/04/26,
http://bit.ly/FourColorTheorem
Feit thompson proved in Coq, 2012/09/20,
http://bit.ly/FeitThompson
The announcement of the completion of the Flyspec project, 2014/8/10.
http://bit.ly/Flyspeck
(The Kepler Conjecture)
Univalent Foundations of Mathematics, 2012,2013.
http://bit.ly/UnivalentFoundations
(Homotopy Type Theory)
Computing close approximations of Pi,
http://www-sop.inria.fr/members/Yves.Bertot/proofs.html
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 23 / 64
24. Section 4
Coq Library for Relational Calculus
From Logical formula to Relational formula in Mathematics.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 24 / 64
25. Axioms and Lemmas in Dedekind category (1)
Library Basic_Notations
Definitions and notations of elementary operations.
Library Distributive_Laws
Distributive law, De-Morgan’s law, etc.
Library Empty_Universal_Inverse
Lemmas for empty, total, and inverse relations
Library Basic_Lemmas
Lemmas for inclusions, union, and intersection of relations.
Library Functions_Mappings
Definitions and lemmas for functions. 1
Library Dedekind
Lemmas for Dedekind categories.
1
※ including tactics.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 25 / 64
26. Axioms and Lemmas in Dedekind category (2)
Let A, B be eqType. We denote a type of a relation from A to B by
(Rel A B) and defied as A → B → Prop.
The followings is a list of notations.
Notation Coq Notation
Inverse α♯ (inverse_relation α) (α #)
Composite αβ (composite α β) (α · β)
Identity idA (identity_relation A) (Id A)
Empty ϕAB (empty_relation A B) (φ A B)
Total ∇AB (universal_relation A B) (∇ A B)
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 26 / 64
27. Relational representation of properties of maps (1)
Properties of a function (total function), injection, surjection are not defined
by logical formulas but relational expressions.
Definition
Let α : A ⇁ B be a relation.
(1) α is total, if idA ⊑ αα♯.
(2) α is univalent, if α♯α ⊑ idB.
(3) A univalent relation is also called as a partial function.
(4) α is (total) function, if α is total and univalent.
(3) A (total) function α : A ⇁ B is surjection, if α♯α = idB.
(4) A (total) function α : A ⇁ B is injection, if αα♯ = idA.
(5) A (total) function is bijection, if it is surjection and injection.
Note. We use letters f, g, h, · · · for (total) functions. For a function,
surjection and injection, we use an arrow symbol →, ↠ and ↣.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 27 / 64
28. Relational representation of properties of maps (2)
Definition total_id {A B : eqType} (alpha : Rel A B) :=
(Id A) ≡ (alpha ・ (alpha #)).
Definition univalent_id {A B : eqType} (alpha : Rel A B) :=
((alpha #) ・ alpha) ≡ (Id B).
Definition total_r {A B : eqType} (alpha : Rel A B) :=
(Id A) ⊆ (alpha ・ (alpha #)).
Definition univalent_r {A B : eqType} (alpha : Rel A B) :=
((alpha #) ・ alpha) ⊆ (Id B).
Definition function_r {A B : eqType} (alpha : Rel A B) :=
(total_r alpha) / (univalent_r alpha).
Definition surjection_r {A B : eqType} (alpha : Rel A B) :=
(function_r alpha) / (total_r (alpha #)).
Definition injection_r {A B : eqType} (alpha : Rel A B) :=
(function_r alpha) / (univalent_r (alpha #)).
Definition bijection_r {A B : eqType} (alpha : Rel A B) :=
(surjection_r alpha) / (injection_r alpha).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 28 / 64
29. composite of injections are injection
(logical formula)
Proposition
If f : X → Y and g : Y → Z are injections, then f · g : X → Z is an
injection.
(∀x, x′ ∈ X, ∀y ∈ Y, (x, y) ∈ f ∧ (x′, y) ∈ f ⇒ x = x′)
∧ (∀y, y′ ∈ Y, ∀z ∈ Z, (y, z) ∈ g ∧ (y′, z) ∈ g ⇒ y = y′)
⇒ (∀x, x′ ∈ X, ∀z ∈ Z, ((x, z) ∈ f · g) ∧ ((x′, z) ∈ f · g))
⇒ x = x′
where,
(x, z) ∈ f · g ⇔ ∃y ∈ Y, (x, y) ∈ f ∧ (y, z) ∈ g
(x′
, z) ∈ f · g ⇔ ∃y′
∈ Y, (x′
, y′
) ∈ f ∧ (y′
, z) ∈ g
※ Not easy to find a strategy to make proof automatically.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 29 / 64
30. composite of injections are injection
(logical formula)
Theorem injection_composite_set
{X Y Z : eqType} {f : Rel X Y} {g : Rel Y Z}:
(forall (x x’ : X)(y : Y), f x y / f x’ y - x = x’) /
(forall (y y’ : Y)(z : Z), g y z / g y’ z - y = y’) -
(forall (x x’ : X)(z : Z),
(exists y : Y, f x y / g y z) / (exists y’ : Y, f x’ y’ / g y’ z) - x = x’).
Proof.
intuition.
move:H2.
elim = y H4.
apply (H0 x x’ y).
split.
apply (proj1 H4).
move:H3.
elim =y’ H5.
have: y=y’.
apply (H1 y y’ z).
apply (conj (proj2 H4) (proj2 H5)).
move = H6.
rewrite -H6 in H5.
apply (proj1 H5).
Qed.
※ Of course, we can make a proof manually.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 30 / 64
31. composition of an injection and an injection is an injection
(relational formula)
Proposition
Let f : X → Y, g : Y → Z be injections. Then f · g : X → Z is an
injection.
( f · f♯
⊑ idX) ∧ (g · g♯
⊑ idY) ⇒ ((f · g) · ( f · g)♯
⊑ idX)
( f · g) · ( f · g)♯
= ( f · g) · (g♯ · f♯) (∵ (α · β)♯ = β♯ · α♯)
= f · (g · g♯) · f♯ (∵ associative law)
⊑ f · idY · f♯ (∵ g · g♯ ⊑ idY)
= f · f♯ (∵ idYis unit)
⊑ idX (∵ f · f♯ ⊑ idX)
Proof can be done using symbolic transformations.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 31 / 64
32. composition of an injection and an injection is an injection
(relational formula)
Theorem injection_composite_rel_tactic
{X Y Z : eqType} {f : Rel X Y} {g : Rel Y Z}:
(f ・ (f #)) ⊆ Id X / (g ・ (g #)) ⊆ Id Y -
((f ・ g) ・ ((f ・ g) #)) ⊆ Id X.
Proof.
Rel_simpl2.
Qed.
※ We can implement an automatic prover (Tactic).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 32 / 64
33. Elementary lemmas
Lemma composite_include_left
(a ⊆ a’) - ((a ・ b) ⊆ (a’ ・ b)).
Lemma composite_include_left_a_id
(a ⊆ Id A) - ((a ・ b) ⊆ b).
Lemma composite_include_right
(b ⊆ b’) - ((a ・ b) ⊆ (a ・ b’)).
Lemma composite_include_right_b_id
(b ⊆ Id B) - ((a ・ b) ⊆ a).
Lemma composite_include_right_id_b
(Id B ⊆ b) - (a ⊆ (a ・ b)).
Lemma composite_include_left_right
(b ⊆ b’) - ((a ・ (b ・ c)) ⊆ (a ・ (b’ ・ c))).
Lemma composite_include_left_right_b_id
(b ⊆ Id B) - ((a ・ (b ・ c)) ⊆ (a ・ c)).
Lemma composite_include_left_right_id_b
(Id B ⊆ b) - ((a ・ c) ⊆ (a ・ (b ・ c))).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 33 / 64
34. Automated proving (Tactic)
※ not only reductions.
Ltac Rel_simpl1 :=
Rel_simpl_intro;
repeat match goal with
| [_ : _ |- _ ⊆ _ ] = apply f_include
| [ H : _ |- _ ⊆ _ ] = apply H
| [_ : _ |- (_ ・ _) ⊆ (_ ・ _) ] = apply composite_include
| [_ : _ |- (_ ・ _) ⊆ _ ] = apply composite_include_left_a_id
| [_ : _ |- _ ⊆ (_ ・ _) ] = apply composite_include_left_id_a
| [_ : _ |- (_ ・ _) ⊆ _ ] = apply composite_include_right_b_id
| [_ : _ |- _ ⊆ (_ ・ _) ] = apply composite_include_right_id_b
| [ H : _ ⊆ _ , H0 : _ ⊆ _ |- _ ⊆ _ ] = apply (include_include H H0)
| [ H : (Id _) ⊆ _ ,H0 : _ ⊆ (Id _) |- _ ] = rewrite (include_equal H H0)
| [_ : _ |- (_ #) ⊆ (_ #) ] = apply include_inverse
| [_ : _ |- _ ] = rewrite composite_inverse
| [_ : _ |- _ ] = rewrite composite_composite4
end.
Ltac Rel_simpl2 :=
Rel_simpl_intro;
repeat match goal with
| [ H : (Id _) ⊆ _ |- (Id _) ⊆ _ ] = apply (include_include H)
| [ H : _ ⊆ (Id _) |- _ ⊆ (Id _) ] = apply (fun (H0 : _ ⊆ _) = (include_include H0 H))
end;Rel_simpl1.
※ A transformation is not always a reduction. We may add an identity
function(Rel_simpl2).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 34 / 64
35. composition of a surjection and a surjection is a surjection
(relational formulation)
Proposition
If f : X → Y and g : Y → Z are surjections, then f · g : X → Z is a
surjection.
(idX ⊑ f · f♯
) ∧ (idY ⊑ g · g♯
) ⇒ (idX ⊑ ( f · g) · (f · g)♯
)
idX
⊑ f · f♯ (∵ idX ⊑ f · f♯)
= f · (idY · f♯) (∵ idY is the unit)
⊑ f · ((g · g♯) · f♯) (∵ idY ⊑ g · g♯)
= ( f · g) · (g♯ · g♯) (∵ associative)
= ( f · g) · ( f · g)♯ (∵ inverse)
Proof can be done using symbolic transformations.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 35 / 64
36. composition of a surjection and a surjection is a surjection
(relational formulation) (2)
Lemma total_composite2
{A B C : eqType} {f : Rel A B} {g : Rel B C}:
((Id A) ⊆ (f ・ (f #))) - (Id B) ⊆ (g ・ (g #)) -
(Id A) ⊆ ((f ・ g) ・ ((f ・ g) #)).
Proof.
Rel_simpl2.
Qed.
※ We can implement an automatic prover (Tactic).
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 36 / 64
37. Section 5: Category Theory using Relational Calculus
Category Theory using Relational Calculus
Set Theory → Category Theory → Relational Calculus
(using ∈) → (logical formula) → (relational formula)
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 37 / 64
38. From a logical formula to a relational formula
(Equalizer)
Definition (Equalizer)
e = eq( f, g) ⇔
def
(∀d, ((d f = dg) ⇒ (∃!h, d = he)))
E
e E A
f E
g
E B
∀d
D
∃!h
T
A Definition using a relational formula.
e = eq( f, g) ⇔
def
((ee♯
= idE) ∧ (e♯
e = f g♯
⊓ idA))
We note h = de♯ for any d with d f = dg.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 38 / 64
39. From a logical formula to a relational formula
(Coequalizer)
Definition (Coequalizer)
c = coeq( f, g) ⇔
def
(∀d, ((f d = gd) ⇒ (∃!h, d = ch)))
A
f E
g
E B
c E Q
d
d
d
d
d
∀d
‚
D
∃!h
c
A Definition using a relational formula.
c = coeq( f, g) ⇔
de f
((c♯
c = idQ) ∧ (cc♯
= ⊔
n≥0
( f♯
g ⊓ g♯
f)n
))
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 39 / 64
40. From a logical formula to a relational formula
(Product)
Definition (Product)
A
p
← T
q
→ B is a product
⇔
def
(∀α, ∀β, ∃!γ, ((γp = α) ∧ (γq = β)))
A ' p
T
q E B
sd
d
d
d
d
∀α
∀β
X
∃!γ
T
A Definition using a relational formula.
⇔
def
((p♯
q = ∇AB) ∧ (pp♯
⊓ qq♯
= idT))
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 40 / 64
42. From a logical formula to a relational formula
(Pushout (1))
Definition (Pushout)
Assume f x = gy.
Pushout ⇔
def
(∀α, ∀β, ((αx = βy) ⇒ (∃!h, ((hf = α) ∧ (hg = β)))
Y
d
d
d
d
∃!
h
‚
rrrrrrrrrr
∀
α
j
e
e
e
e
e
e
e
e
e
e
∀
β
…
X
f E A
B
g
c
y
E D
x
c
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 42 / 64
43. From a logical formula to a relational formula
(Pushout (2))
Y
d
d
d
d
∃!
h
‚
rrrrrrrrrr
∀
α
j
e
e
e
e
e
e
e
e
e
e
∀
β
…
X
f E A
B
g
c
y
E D
x
c
A Definition using a relational formula.
Pushout ⇔
de f
(( f♯
g = xy♯
) ∧ ( f f♯
⊓ gg♯
= idX))
We assume the axiom of rationality:
∀α : X ⇁ Y, ∃f : R → X, ∃g : R → Y, ((α = f♯
g) ∧ ( f f♯
⊓ gg♯
) = idR)
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 43 / 64
44. Section 6
Automata Theory using Relational Calculus
Y.Kawahara, Applications of relational calculus to computer mathematics,
Bulletin of Informatics and Cybernetics, 23(1988), 67–78.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 44 / 64
45. Finite automaton
Let Σ = {a, b} be a finite set of symbols. We recall I = {∗}.
We illustrate M as: M : I
τ
⇁ Q
δs
⇁ Q
β
↽ I, (s ∈ Σ).
τ = {(∗, p0)}
δa = {(p0, p1), (p1, p2), (p2, p2)}
δb = {(p0, p2), (p1, p0), (p2, p2)}
β = {(∗, p1)}
T(M) = {w ∈ Σ∗
| τδwβ♯
= idI}
= {a, aba, ababa, . . .}
δaba = δaδbδa
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 45 / 64
46. Finite automaton (relational formula)
Let Σ be a finite set of symbols. We recall I = {∗} is the one point set.
Definition
A finite automaton M over Σ is a 3-tuple
M = (τ : I ⇁ Q, δa : Q ⇁ Q (a ∈ Σ), β : I ⇁ Q),
where Q is a finite.
We illustrate M as:
M : I
τ
⇁ Q
δa
⇁ Q
β
↽ I.
We define δw : Q ⇁ Q for w ∈ Σ∗, by
δε = idQ, and
δwa = δwδa (w ∈ Σ∗
, a ∈ Σ).
For an automaton M, we define the recognized language T(M) by
T(M) = {w ∈ Σ∗
| τδwβ♯
= idI}
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 46 / 64
47. Reverse automaton
Definition
Let M = (τ : I ⇁ Q, δa : Q ⇁ Q, β : I ⇁ Q) be a finite automaton. The
automaton
MR
= (τR
: I ⇁ Q, δR
a : Q ⇁ Q, βR
: I ⇁ Q)
is the reverse automaton of M, where rR = β, δR
a = δ
♯
a and β = τ.
Proposition
T(MR
) = T(M)R
where T(M)R = {anan−1 · · · a1 ∈ Σ∗ | a1a2 · · · an ∈ T(M)}.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 47 / 64
48. Coproduct of automata
Definition
Let M = (τ : I ⇁ Q, δa : Q ⇁ Q, β : I ⇁ Q) and
M′ = (τ′ : I ⇁ Q′, δ′
a : Q′ ⇁ Q′, β′ : I ⇁ Q′) be finite tutomata. The
automaton
M + M′
= (ˆτ : I ⇁ Q + Q′
, ˆδa : Q + Q′
⇁ Q + Q′
, ˆβ : I ⇁ Q + Q′
)
is the coproduct automaton of M and M′, where ˆτ = (τi) ⊔ (τ′ j),
ˆδ = (i♯δai) ⊔ ( j♯δ′
a j), ˆβ = (i♯β) ⊔ ( j♯β′) and Q
i
→ Q + Q′
j
← Q′ is a
coproduct of Q and Q′.
Proposition
T(M + M′
) = T(M) ∪ T(M′
)
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 48 / 64
49. Product of automata
Definition
Let M = (τ : I ⇁ Q, δa : Q ⇁ Q, β : I ⇁ Q) and
M′ = (τ′ : I ⇁ Q′, δ′
a : Q′ ⇁ Q′, β′ : I ⇁ Q′) be finite tutomata. The
automaton
M × M′
= (ˆτ : I ⇁ Q × Q′
, ˆδa : Q × Q′
⇁ Q × Q′
, ˆβ : I ⇁ Q × Q′
)
is the coproduct automaton of M and M′, where ˆτ = τp♯ ⊔ τ′q♯,
ˆδ = pδa p♯ ⊓ qδ′
aq♯, ˆβ = βp♯ ⊓ β′q♯ and Q
p
← Q × Q′
q
→ Q′ is a product of
Q and Q′.
Proposition
T(M × M′
) = T(M) ∩ T(M′
)
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 49 / 64
50. Concatenation of automata
Definition
Let M = (τ : I ⇁ Q, δa : Q ⇁ Q, β : I ⇁ Q) and
M′ = (τ′ : I ⇁ Q′, δ′
a : Q′ ⇁ Q′, β′ : I ⇁ Q′) be finite tutomata. The
automaton
M · M′
= (ˆτ : I ⇁ Q + Q′
, ˆδa : Q + Q′
⇁ Q + Q′
, ˆβ : I ⇁ Q + Q′
)
is the concatination automaton of M and M′, where ˆτ = τ(i ⊔ (β♯τ′ j)),
ˆδ = (i♯δai) ⊔ (i♯β♯τ′δ′
a j) ⊔ ( j♯δ′
a j), ˆβ = β′(τ′♯
βi ⊔ j) and
Q
i
→ Q + Q′
j
← Q′ is a coproduct of Q and Q′.
Proposition
T(M · M′
) = T(M) · T(M′
),
where T(M) · T(M′) = {ww′ ∈ Σ∗ | w ∈ T(M) ∧ w′ ∈ T(M′)}.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 50 / 64
51. Section 7
Relational Graph Rewriting
Y.Mizoguchi,Y.Kawahara, Relational graph rewritings, Theoretical
Computer Sicnece 141(1995), 311–328.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 51 / 64
52. Category of relational graphs (1)
Definition
A (simple) graph A, α is a pair of a set A and a relation α : A ⇁ A. A
partial morphism f of a graph A, α into a graph B, β , denoted by
f : A, α → B, β is a partial function f : A → B satisifying
d( f)α f ⊏ fβ, where d( f) = f f♯ ⊓ idA.
We can define a category Pfn(Graph) of graphs and partial morphisms
between them.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 52 / 64
53. Category of relational graphs (2)
Proposition
The category Pfn(Graph) of graphs and partial morphisms has pushouts.
That is for given partial morphisms
f : A, α → B, β and g : A, α → C, γ ,
there exist partial morphisms
h : B, β → D, δ and k : C, γ → D, δ
such that the following diagram is a pushout square:
A, α
fE B, β
C, γ
g
c
k
E D, δ
h
c
We note that f : A → B, g : A → C, h : B → D and k : C → D is a pushout
square in the category Pfn of sets and partial functions and δ = h♯
βh ⊔ k♯
γk.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 53 / 64
54. Graph Rewriting using relational calculus
Definition
A rewriting rule p : A, α → B, β ) is a partial morphism. A matching to p is
a morphism g : A, α → G, ξ of graphs. Consider a pushout in
Pfn(Graph).
A, α
f
(rewriting rule)
E B, β
G, ξ
g (matching)
c
k
E H, η
h
c
We say the graph G, ξ is said to be rewritten into a graph H, η by
applying a rewriting rule p along a matching g, and denote by
G, ξ ⇐p/g H, η .
In the rewriting, we note η = h♯
βh ⊔ k♯
(ξ − g♯
αg)k.
So we can investigate properties of graphs using relational calculus.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 54 / 64
55. Critical pairs
Definition (Critical Pairs)
Let fλ be a rewriting rules (λ = 0, 1). A critical pair formd from f0 and f1 is a pair
of morphism tλ : S, σ → Tλ, τλ (λ = 0, 1) of graphs such that all squares
in the following diagram are pushouts in Pfn(Graph) for some pair of injective
functiions iλ : A∩ → Aλ.
A∩, ϕA∩ A∩
i0E A0, α0
f0E B0, β0
A1, α1
i1
c s1E S, σ
s0
c
t0
E T0, τ0
u0
c
B1, β1
f1
c
u1
E T1, τ1
t1
c
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 55 / 64
56. Critical pairs (Illustration)
A + B
i0 E (−x) + x
f0 E 0
(x + y) + (−z)
i1
c s1E ((−s) + s) + (−t))
s0
c
t0
E 0 + (−t)
u0
c
x + (y + (−z))
f1
c
u1
E (−s) + (s + (−t))
t1
c
Note: If every critical pair is confluent, then a graph rewriting system is
confluent.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 56 / 64
57. Rewriting System
Definition (Rewriting System)
A rewriting system P is simply a family of rewriting rules (morphisms of
graphs). Let G, ξ ⇒fλ/gλ Hλ, ηλ with rewriting rules fλ ∈ P for
λ = 0, 1. The pair of graph rewritings G, ξ ⇒fλ/gλ Hλ, ηλ is called
confluent on P if there exist rewriting rules f′
λ
∈ P and graph rewritings
Hλ, ηλ ⇒f′
λ
/g′
λ
H, η for some graph H, η .
Theorem (Critical Pairs Lemma)
A graph rewriting system P is confluent if and only if every critical pair in P
is confluent.
This Theorem is proved using pushout properties in a general category.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 57 / 64
58. General Pushout properties (1)
A
f E B
(pushout)
C1
g1
c
k1
E D1
h1
c
(pushout)
C2
g2
c
k2
E D2
h2
c
Proposition
If f, g, h1 and k1 is a pushout square and k1, g2, h2 and k2 is a pushout square,
then f, (g1 g2), (h1h2) and k2 is a pushout square.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 58 / 64
59. General Pushout properties (2)
A
f1 E B1
f2 E B2
(pushout) (pushout)
C
g
c
k1
E D1
h1
c
k2
E D1
h2
c
Proposition
If f1, g, h1 and k1 is a pushout square and f2, h1, h2 and k2 is a pushout square,
then (f1 f2), g, h2 and (k1 k2) is a pushout square.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 59 / 64
60. Conclusion and future works
A proof assistant Coq is used not only for a verification of computer
system but for a formal proof of a theorem in Mathematics.
(4-color thm, Keplay conj., Feit-Tompson thm., etc.)
Relational structure is rich for applying and relational calculus is
suitable for using in a formal proof.
An introduction of a stream of a theory from Set theory, Category
theory to Relational calculus.
Small introductions about ’injection’ and ’surjection’.
Relational formulas for notions in the category theory.
Relational formulas for the theory of automata.
Relational formulas for a theory of graph rewritings.
Future work includes to clarify the mechanism of computations in
relational calculus for developing a theory and a system of a relational
calculus.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 60 / 64
61. References I
R. Berghammer, P. H¨ofner, and I. Stucke.
Automated verification of relational while-programs.
In P. H¨ofner, P. Jipsen, W. Kahl, and M. E. M¨uller, editors, Relational and Algebraic Methods in
Computer Science (RAMiCS’14), volume 8428 of Lecture Notes in Computer Sciences, pages
173–190, 2014.
Peter J. Freyd and Andre Scedrov.
Categories, allegories, volume 39 of North-Holland mathematical library.
North-Holland, Amsterdam, 1990.
Hitoshi Furusawa and Yasuo Kawahara.
Point axioms and related conditions in dedekind categories.
Journal of Logical and Algebraic Methods in Programming, 84:359–376, 2015.
Robin Hirsh and Ian Hodkinson.
Relation algebras by games, volume 147 of Studies in Logic and Foundations.
North-Holland, Amsterdam, 2002.
C. A. R. Hoare and HE Jifeng.
The weakest prespecification.
Information processing letter, 24:127–132., 1987.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 61 / 64
62. References II
T. Ishida, K. Honda, and Y. Kawahara.
Formal concepts in Dedekind categories.
In R. Berghammer, B. M¨oller, and G. Struth, editors, Relations and Kleene Algebras in Computer
Science, volume 4988 of Lecture Notes in Computer Science, pages 221–233, 2008.
Marcel Jackson and Tim Stokes.
Semigroup with if–then–else and halting programs.
International Journal of Algebra and Computation, 19(7):937–961, 2009.
Y. Kawahara.
Applications of relational calculus to computer mathematics.
Bull. Inform. Cybernet., 23:67–78, 1988.
Y. Kawahara and Y. Mizoguchi.
Categorical assertion semantics in toposes.
Advances in Software Science and Technology, 4:137–150, 1992.
Saunder Mac Lane.
Categories for the working mathematicians.
Springer-Verlag, 1971.
R. C. Lyndon.
The representation of relational algebras.
Annuals of Mathematics, 51:707–729, 1950.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 62 / 64
63. References III
Roger D. Maddux.
The origin of relation algebras in the development and axiomatization of the calculus of relations.
Studia Logica: An International Journal for Symbolic Logic, 50:421–455, 1991.
Ralph N. McKenzie, George F. McNulty, and Walter F. Tylor.
Algebras, lattices, varieties.
The Wadsworth Books/Cole mathematics series. Wadsworth Books, 1987.
Y. Mizoguchi and Y. Kawahara.
Relational graph rewritings.
Theoret. Comput. Sci., 141:311–328, 1995.
A. De Morgan.
On the syllogism: IV, and on the logic of relations.
Transactions of the Cambridge Philosophcal Society, pages 331–358, 1966.
H. Okuma and Y. Kawahara.
Relational aspects of relational database dependencies.
Bull. Inform. Cybernet., pages 91–104, 2000.
J. P. Oliver and D. Serrato.
Cat´egories de dedekind morphismes dans les cat´egories de Shr¨oder.
C. R. Acad. Sci. Paris, 290:939–941, 1980.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 63 / 64
64. References IV
C. S. Peirce.
Note B: the logic of relatives, volume iviii+vi+203, pages 187–203.
John Benjamins Publishing Co., Amsterdam and Philadelphia., 1983.
G. Schmidt.
Relational Mathematics.
Cambridge University Press, 2010.
Marshall H. Stone.
The theory of representations of Boolean algebras.
Transactions of American Mathematical Society, 40, 1936.
A. Tarski.
On the calculus of relations.
Journal of Symbolic Logic, 6:73–89, 1941.
Y.Mizoguchi Theory of Relational Calculus and its formalization 2016/06/29 64 / 64