HOME

TheInfoList



OR:

In
mathematics Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, the transitive closure of a homogeneous binary relation on a
set Set, The Set, SET or SETS may refer to: Science, technology, and mathematics Mathematics *Set (mathematics), a collection of elements *Category of sets, the category whose objects and morphisms are sets and total functions, respectively Electro ...
is the smallest
relation Relation or relations may refer to: General uses * International relations, the study of interconnection of politics, economics, and law on a global level * Interpersonal relationship, association or acquaintance between two or more people * ...
on that contains and is transitive. For finite sets, "smallest" can be taken in its usual sense, of having the fewest related pairs; for infinite sets is the unique minimal transitive
superset In mathematics, a set ''A'' is a subset of a set ''B'' if all elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they are unequal, then ''A'' is a proper subset ...
of . For example, if is a set of airports and means "there is a direct flight from airport to airport " (for and in ), then the transitive closure of on is the relation such that means "it is possible to fly from to in one or more flights". More formally, the transitive closure of a binary relation on a set is the smallest (w.r.t. ⊆) transitive relation on such that ⊆ ; see . We have = if, and only if, itself is transitive. Conversely,
transitive reduction In the mathematical field of graph theory, a transitive reduction of a directed graph is another directed graph with the same vertices and as few edges as possible, such that for all pairs of vertices , a (directed) path from to in exists ...
adduces a minimal relation from a given relation such that they have the same closure, that is, ; however, many different with this property may exist. Both transitive closure and transitive reduction are also used in the closely related area of
graph theory In mathematics and computer science, graph theory is the study of ''graph (discrete mathematics), graphs'', which are mathematical structures used to model pairwise relations between objects. A graph in this context is made up of ''Vertex (graph ...
.


Transitive relations and examples

A relation ''R'' on a set ''X'' is transitive if, for all ''x'', ''y'', ''z'' in ''X'', whenever and then . Examples of transitive relations include the equality relation on any set, the "less than or equal" relation on any linearly ordered set, and the relation "''x'' was born before ''y''" on the set of all people. Symbolically, this can be denoted as: if and then . One example of a non-transitive relation is "city ''x'' can be reached via a direct flight from city ''y''" on the set of all cities. Simply because there is a direct flight from one city to a second city, and a direct flight from the second city to the third, does not imply there is a direct flight from the first city to the third. The transitive closure of this relation is a different relation, namely "there is a sequence of direct flights that begins at city ''x'' and ends at city ''y''". Every relation can be extended in a similar way to a transitive relation. An example of a non-transitive relation with a less meaningful transitive closure is "''x'' is the
day of the week In a vast number of languages, the names given to the seven days of the week are derived from the names of the classical planets in Hellenistic astronomy, which were in turn named after contemporary deities, a system introduced by the Sume ...
after ''y''". The transitive closure of this relation is "some day ''x'' comes after a day ''y'' on the calendar", which is trivially true for all days of the week ''x'' and ''y'' (and thus equivalent to the
Cartesian square In mathematics, specifically set theory, the Cartesian product of two sets and , denoted , is the set of all ordered pairs where is an element of and is an element of . In terms of set-builder notation, that is A\times B = \. A table ca ...
, which is "''x'' and ''y'' are both days of the week").


Existence and description

For any relation ''R'', the transitive closure of ''R'' always exists. To see this, note that the
intersection In mathematics, the intersection of two or more objects is another object consisting of everything that is contained in all of the objects simultaneously. For example, in Euclidean geometry, when two lines in a plane are not parallel, their ...
of any
family Family (from ) is a Social group, group of people related either by consanguinity (by recognized birth) or Affinity (law), affinity (by marriage or other relationship). It forms the basis for social order. Ideally, families offer predictabili ...
of transitive relations is again transitive. Furthermore,
there exists There may refer to: * ''There'' (film), a 2009 Turkish film (Turkish title: ''Orada'') * ''There'' (virtual world) *''there'', a deictic adverb in English *''there'', an English pronoun used in phrases such as '' there is'' and ''there are'' { ...
at least one transitive relation containing ''R'', namely the trivial one: ''X'' × ''X''. The transitive closure of ''R'' is then given by the intersection of all transitive relations containing ''R''. For finite sets, we can construct the transitive closure step by step, starting from ''R'' and adding transitive edges. This gives the intuition for a general construction. For any set ''X'', we can prove that transitive closure is given by the following expression :R^=\bigcup_^ R^i. where R^i is the ''i''-th power of ''R'', defined inductively by :R^1 = R and, for i>0, :R^ = R \circ R^i where \circ denotes
composition of relations In the mathematics of binary relations, the composition of relations is the forming of a new binary relation from two given binary relations ''R'' and ''S''. In the calculus of relations, the composition of relations is called relative multiplica ...
. To show that the above definition of ''R''+ is the least transitive relation containing ''R'', we show that it contains ''R'', that it is transitive, and that it is the smallest set with both of those characteristics. * R \subseteq R^: R^+ contains all of the R^i, so in particular R^+ contains R. * R^ is transitive: If (s_1, s_2), (s_2, s_3)\in R^+, then (s_1, s_2)\in R^j and (s_2, s_3)\in R^k for some j,k by definition of R^+. Since composition is associative, R^ = R^j \circ R^k; hence (s_1, s_3)\in R^ \subseteq R^+ by definition of \circ and R^+. * R^ is minimal, that is, if T is any transitive relation containing R, then R^ \subseteq T: Given any such T, induction on i can be used to show R^i\subseteq T for all i as follows: ''Base:'' R^1 = R \subseteq T by assumption. ''Step:'' If R^i\subseteq T holds, and (s_1, s_3)\in R^ = R \circ R^i, then (s_1, s_2) \in R and (s_2, s_3)\in R^i for some s_2, by definition of \circ. Hence, (s_1, s_2), (s_2, s_3)\in T by assumption and by induction hypothesis. Hence (s_1, s_3)\in T by transitivity of T; this completes the induction. Finally, R^i\subseteq T for all i implies R^ \subseteq T by definition of R^.


Properties

The
intersection In mathematics, the intersection of two or more objects is another object consisting of everything that is contained in all of the objects simultaneously. For example, in Euclidean geometry, when two lines in a plane are not parallel, their ...
of two transitive relations is transitive. The union of two transitive relations need not be transitive. To preserve transitivity, one must take the transitive closure. This occurs, for example, when taking the union of two
equivalence relation In mathematics, an equivalence relation is a binary relation that is reflexive, symmetric, and transitive. The equipollence relation between line segments in geometry is a common example of an equivalence relation. A simpler example is equ ...
s or two
preorder In mathematics, especially in order theory, a preorder or quasiorder is a binary relation that is reflexive relation, reflexive and Transitive relation, transitive. The name is meant to suggest that preorders are ''almost'' partial orders, ...
s. To obtain a new equivalence relation or preorder one must take the transitive closure (reflexivity and symmetry—in the case of equivalence relations—are automatic).


In graph theory

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, the concept of transitive closure can be thought of as constructing a data structure that makes it possible to answer
reachability In graph theory, reachability refers to the ability to get from one vertex to another within a graph. A vertex s can reach a vertex t (and t is reachable from s) if there exists a sequence of adjacent vertices (i.e. a walk) which starts with s a ...
questions. That is, can one get from node ''a'' to node ''d'' in one or more hops? A binary relation tells you only that node a is connected to node ''b'', and that node ''b'' is connected to node ''c'', etc. After the transitive closure is constructed, as depicted in the following figure, in an O(1) operation one may determine that node ''d'' is reachable from node ''a''. The data structure is typically stored as a Boolean matrix, so if matrix 4] = true, then it is the case that node 1 can reach node 4 through one or more hops. The transitive closure of the adjacency relation of a
directed acyclic graph In mathematics, particularly graph theory, and computer science, a directed acyclic graph (DAG) is a directed graph with no directed cycles. That is, it consists of vertices and edges (also called ''arcs''), with each edge directed from one ...
(DAG) is the reachability relation of the DAG and a
strict partial order In mathematics, especially order theory, a partial order on a set is an arrangement such that, for certain pairs of elements, one precedes the other. The word ''partial'' is used to indicate that not every pair of elements needs to be comparable; ...
. The transitive closure of an
undirected graph In discrete mathematics, particularly in graph theory, a graph is a structure consisting of a set of objects where some pairs of the objects are in some sense "related". The objects are represented by abstractions called '' vertices'' (also call ...
produces a
cluster graph In graph theory, a branch of mathematics, a cluster graph is a graph formed from the disjoint union of complete graphs. Equivalently, a graph is a cluster graph if and only if it has no three-vertex induced path; for this reason, the cluster g ...
, a
disjoint union In mathematics, the disjoint union (or discriminated union) A \sqcup B of the sets and is the set formed from the elements of and labelled (indexed) with the name of the set from which they come. So, an element belonging to both and appe ...
of
cliques A clique ( AusE, CanE, or ; ), in the social sciences, is a small group of individuals who interact with one another and share similar interests rather than include others. Interacting with cliques is part of normative social development regardle ...
. Constructing the transitive closure is an equivalent formulation of the problem of finding the
components Component may refer to: In engineering, science, and technology Generic systems *System components, an entity with discrete structure, such as an assembly or software module, within a system considered at a particular level of analysis * Lumped e ...
of the graph.


In logic and computational complexity

The transitive closure of a binary relation cannot, in general, be expressed in
first-order logic First-order logic, also called predicate logic, predicate calculus, or quantificational logic, is a collection of formal systems used in mathematics, philosophy, linguistics, and computer science. First-order logic uses quantified variables over ...
(FO). This means that one cannot write a formula using predicate symbols ''R'' and ''T'' that will be satisfied in any model if and only if ''T'' is the transitive closure of ''R''. In
finite model theory Finite model theory is a subarea of model theory. Model theory is the branch of logic which deals with the relation between a formal language (syntax) and its interpretations (semantics). Finite model theory is a restriction of model theory to inte ...
, first-order logic (FO) extended with a transitive closure operator is usually called transitive closure logic, and abbreviated FO(TC) or just TC. TC is a sub-type of
fixpoint logic In mathematical logic, fixed-point logics are extensions of classical predicate logic that have been introduced to express recursion. Their development has been motivated by descriptive complexity theory and their relationship to database query l ...
s. The fact that FO(TC) is strictly more expressive than FO was discovered by
Ronald Fagin Ronald Fagin (born 1945) is an American mathematician and computer scientist, and IBM Fellow at the IBM Almaden Research Center. He is known for his work in database theory, finite model theory, and reasoning about knowledge. Biography Ron F ...
in 1974; the result was then rediscovered by
Alfred Aho Alfred Vaino Aho (born August 9, 1941) is a Canadian computer scientist best known for his work on programming languages, compilers, and related algorithms, and his textbooks on the art and science of computer programming. Aho was elected into ...
and
Jeffrey Ullman Jeffrey David Ullman (born November 22, 1942) is an American computer scientist and the Stanford W. Ascherman Professor of Engineering, Emeritus, at Stanford University. His textbooks on compilers (various editions are popularly known as the dr ...
in 1979, who proposed to use fixpoint logic as a database query language. With more recent concepts of finite model theory, proof that FO(TC) is strictly more expressive than FO follows immediately from the fact that FO(TC) is not Gaifman-local. In
computational complexity theory In theoretical computer science and mathematics, computational complexity theory focuses on classifying computational problems according to their resource usage, and explores the relationships between these classifications. A computational problem ...
, the
complexity class In computational complexity theory, a complexity class is a set (mathematics), set of computational problems "of related resource-based computational complexity, complexity". The two most commonly analyzed resources are time complexity, time and s ...
NL corresponds precisely to the set of logical sentences expressible in TC. This is because the transitive closure property has a close relationship with the NL-complete problem STCON for finding directed paths in a graph. Similarly, the class L is first-order logic with the commutative, transitive closure. When transitive closure is added to
second-order logic In logic and mathematics, second-order logic is an extension of first-order logic, which itself is an extension of propositional logic. Second-order logic is in turn extended by higher-order logic and type theory. First-order logic quantifies on ...
instead, we obtain
PSPACE In computational complexity theory, PSPACE is the set of all decision problems that can be solved by a Turing machine using a polynomial amount of space. Formal definition If we denote by SPACE(''f''(''n'')), the set of all problems that can ...
.


In database query languages

Since the 1980s
Oracle Database Oracle Database (commonly referred to as Oracle DBMS, Oracle Autonomous Database, or simply as Oracle) is a proprietary multi-model database management system produced and marketed by Oracle Corporation. It is a database commonly used for ru ...
has implemented a proprietary
SQL Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel") is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
extension CONNECT BY... START WITH that allows the computation of a transitive closure as part of a declarative query. The SQL 3 (1999) standard added a more general WITH RECURSIVE construct also allowing transitive closures to be computed inside the query processor; as of 2011 the latter is implemented in IBM Db2,
Microsoft SQL Server Microsoft SQL Server is a proprietary relational database management system developed by Microsoft using Structured Query Language (SQL, often pronounced "sequel"). As a database server, it is a software product with the primary function of ...
,
Oracle An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
,
PostgreSQL PostgreSQL ( ) also known as Postgres, is a free and open-source software, free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. PostgreSQL features transaction processing, transactions ...
, and
MySQL MySQL () is an Open-source software, open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A rel ...
(v8.0+).
SQLite SQLite ( "S-Q-L-ite", "sequel-ite") is a free and open-source relational database engine written in the C programming language. It is not a standalone app; rather, it is a library that software developers embed in their apps. As such, it ...
released support for this in 2014.
Datalog Datalog is a declarative logic programming language. While it is syntactically a subset of Prolog, Datalog generally uses a bottom-up rather than top-down evaluation model. This difference yields significantly different behavior and properties ...
also implements transitive closure computations.
MariaDB MariaDB is a community-developed, commercially supported Fork (software development), fork of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License. Developm ...
implements Recursive Common Table Expressions, which can be used to compute transitive closures. This feature was introduced in release 10.2.2 of April 2016.


Algorithms

Efficient algorithms for computing the transitive closure of the adjacency relation of a graph can be found in . Reducing the problem to multiplications of adjacency matrices achieves the time complexity of
matrix multiplication In mathematics, specifically in linear algebra, matrix multiplication is a binary operation that produces a matrix (mathematics), matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the n ...
, O(n^). However, this approach is not practical since both the constant factors and the memory consumption for sparse graphs are high . The problem can also be solved by the
Floyd–Warshall algorithm In computer science, the Floyd–Warshall algorithm (also known as Floyd's algorithm, the Roy–Warshall algorithm, the Roy–Floyd algorithm, or the WFI algorithm) is an algorithm for finding shortest paths in a directed weighted graph with po ...
in O(n^3), or by repeated
breadth-first search Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
or
depth-first search Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible al ...
starting from each node of the graph. For directed graphs, Purdom's algorithm solves the problem by first computing its condensation DAG and its transitive closure, then lifting it to the original graph. Its runtime is O(m+\mu n), where \mu is the number of edges between its
strongly connected component In the mathematics, mathematical theory of directed graphs, a graph is said to be strongly connected if every vertex is reachability, reachable from every other vertex. The strongly connected components of a directed graph form a partition of a s ...
s. More recent research has explored efficient ways of computing transitive closure on distributed systems based on the
MapReduce MapReduce is a programming model and an associated implementation for processing and generating big data sets with a parallel and distributed algorithm on a cluster. A MapReduce program is composed of a ''map'' procedure, which performs filte ...
paradigm.(Afrati et al. 2011)


See also

*
Ancestral relation In mathematical logic, the ancestral relation (often shortened to ancestral) of a binary relation ''R'' is its transitive closure, however defined in a different way, see below. Ancestral relations make their first appearance in Frege's ''Begriff ...
*
Deductive closure In mathematical logic, a set of Well-formed formula, logical formulae is deductively closed if it contains every formula that can be deductive reasoning, logically deduced from ; formally, if always implies . If is a set of formulae, the deduct ...
*
Reflexive closure In mathematics, the reflexive closure of a binary relation R on a set X is the smallest reflexive relation on X that contains R, i.e. the set R \cup \. For example, if X is a set of distinct numbers and x R y means "x is less than y", then the refl ...
*
Symmetric closure In mathematics, the symmetric closure of a binary relation R on a set X is the smallest symmetric relation A symmetric relation is a type of binary relation. Formally, a binary relation ''R'' over a set ''X'' is symmetric if: : \forall a, b \in ...
*
Transitive reduction In the mathematical field of graph theory, a transitive reduction of a directed graph is another directed graph with the same vertices and as few edges as possible, such that for all pairs of vertices , a (directed) path from to in exists ...
(a smallest relation having the transitive closure of ''R'' as its transitive closure)


References

* Foto N. Afrati, Vinayak Borkar, Michael Carey, Neoklis Polyzotis, Jeffrey D. Ullman
Map-Reduce Extensions and Recursive Queries
EDBT 2011, March 22–24, 2011, Uppsala, Sweden, * * * * * * Keller, U., 2004,
Some Remarks on the Definability of Transitive Closure in First-order Logic and Datalog
' (unpublished manuscript)* * * * *
Appendix C
(online only)


External links

*
Transitive closure and reduction
, The Stony Brook Algorithm Repository, Steven Skiena. {{Order theory Binary relations Closure operators Graph algorithms