<p>A <em>binary relation</em> <span class="SimpleMath">R</span> on a set <span class="SimpleMath">X</span> is a subset of <span class="SimpleMath">X × X</span>. A binary relation can also be thought of as a (general) mapping from <span class="SimpleMath">X</span> to itself or as a directed graph where each edge represents an element of <span class="SimpleMath">R</span>.</p>
<p>In <strong class="pkg">GAP</strong>, a relation is conceptually represented as a general mapping from <span class="SimpleMath">X</span> to itself. The category <code class="func">IsBinaryRelation</code> (<a href="chap33.html#X788D722F82165551"><span class="RefLink">33.1-1</span></a>) is a synonym for <code class="func">IsEndoGeneralMapping</code> (<a href="chap32.html#X81CFF5F87BBEA8AD"><span class="RefLink">32.13-3</span></a>). Attributes and properties of relations in <strong class="pkg">GAP</strong> are supported for relations, via considering relations as a subset of <span class="SimpleMath">X × X</span>, or as a directed graph; examples include finding the strongly connected components of a relation, via <code class="func">StronglyConnectedComponents</code> (<a href="chap33.html#X85C22B3D812957C0"><span class="RefLink">33.4-5</span></a>), or enumerating the tuples of the relation.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BinaryRelationByElements</code>( <var class="Arg">domain</var>, <var class="Arg">elms</var> )</td><tdclass="tdright">( function )</td></tr></table></div>
<p>is the binary relation on <var class="Arg">domain</var> and with underlying relation consisting of the tuples collection <var class="Arg">elms</var>. This construction is similar to <code class="func">GeneralMappingByElements</code> (<a href="chap32.html#X79D0D2F07A14D039"><span class="RefLink">32.2-1</span></a>) where the source and range are the same set.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IdentityBinaryRelation</code>( <var class="Arg">degree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IdentityBinaryRelation</code>( <var class="Arg">domain</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>is the binary relation which consists of diagonal pairs, i.e., pairs of the form <span class="SimpleMath">(x,x)</span>. In the first form if a positive integer <var class="Arg">degree</var> is given then the domain is the set of the integers <span class="SimpleMath">{ 1, ..., <var class="Arg">degree</var> }</span>. In the second form, the objects <span class="SimpleMath">x</span> are from the domain <var class="Arg">domain</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EmptyBinaryRelation</code>( <var class="Arg">degree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EmptyBinaryRelation</code>( <var class="Arg">domain</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>is the relation with <var class="Arg">R</var> empty. In the first form of the command with <var class="Arg">degree</var> an integer, the domain is the set of points <span class="SimpleMath">{ 1, ..., <var class="Arg">degree</var> }</span>. In the second form, the domain is that given by the argument <var class="Arg">domain</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsReflexiveBinaryRelation</code>( <var class="Arg">R</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the binary relation <var class="Arg">R</var> is reflexive, and <code class="keyw">false</code> otherwise.</p>
<p>A binary relation <span class="SimpleMath">R</span> (as a set of pairs) on a set <span class="SimpleMath">X</span> is <em>reflexive</em> if for all <span class="SimpleMath">x ∈ X</span>, <span class="SimpleMath">(x,x) ∈ R</span>. Alternatively, <span class="SimpleMath">R</span> as a mapping is reflexive if for all <span class="SimpleMath">x ∈ X</span>, <span class="SimpleMath">x</span> is an element of the image set <span class="SimpleMath">R(x)</span>.</p>
<p>A reflexive binary relation is necessarily a total endomorphic mapping (tested via <code class="func">IsTotal</code> (<a href="chap32.html#X83C7494E828CC9C8"><span class="RefLink">32.3-1</span></a>)).</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsSymmetricBinaryRelation</code>( <var class="Arg">R</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the binary relation <var class="Arg">R</var> is symmetric, and <code class="keyw">false</code> otherwise.</p>
<p>A binary relation <span class="SimpleMath">R</span> (as a set of pairs) on a set <span class="SimpleMath">X</span> is <em>symmetric</em> if <span class="SimpleMath">(x,y) ∈ R</span> then <span class="SimpleMath">(y,x) ∈ R</span>. Alternatively, <span class="SimpleMath">R</span> as a mapping is symmetric if for all <span class="SimpleMath">x ∈ X</span>, the preimage set of <span class="SimpleMath">x</span> under <span class="SimpleMath">R</span> equals the image set <span class="SimpleMath">R(x)</span>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsTransitiveBinaryRelation</code>( <var class="Arg">R</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the binary relation <var class="Arg">R</var> is transitive, and <code class="keyw">false</code> otherwise.</p>
<p>A binary relation <var class="Arg">R</var> (as a set of pairs) on a set <span class="SimpleMath">X</span> is <em>transitive</em> if <span class="SimpleMath">(x,y), (y,z) ∈ R</span> implies <span class="SimpleMath">(x,z) ∈ R</span>. Alternatively, <span class="SimpleMath">R</span> as a mapping is transitive if for all <span class="SimpleMath">x ∈ X</span>, the image set <span class="SimpleMath">R(R(x))</span> of the image set <span class="SimpleMath">R(x)</span> of <span class="SimpleMath">x</span> is a subset of <span class="SimpleMath">R(x)</span>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsAntisymmetricBinaryRelation</code>( <var class="Arg">rel</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the binary relation <var class="Arg">rel</var> is antisymmetric, and <code class="keyw">false</code> otherwise.</p>
<p>A binary relation <var class="Arg">R</var> (as a set of pairs) on a set <span class="SimpleMath">X</span> is <em>antisymmetric</em> if <span class="SimpleMath">(x,y), (y,x) ∈ R</span> implies <span class="SimpleMath">x = y</span>. Alternatively, <span class="SimpleMath">R</span> as a mapping is antisymmetric if for all <span class="SimpleMath">x ∈ X</span>, the intersection of the preimage set of <span class="SimpleMath">x</span> under <span class="SimpleMath">R</span> and the image set <span class="SimpleMath">R(x)</span> is <span class="SimpleMath">{ x }</span>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsHasseDiagram</code>( <var class="Arg">rel</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the binary relation <var class="Arg">rel</var> is a Hasse Diagram of a partial order, i.e., was computed via <code class="func">HasseDiagramBinaryRelation</code> (<a href="chap33.html#X79672B3A7BCB6991"><span class="RefLink">33.4-4</span></a>).</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Successors</code>( <var class="Arg">R</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns the list of images of a binary relation <var class="Arg">R</var>. If the underlying domain of the relation is not <span class="SimpleMath">{ 1, ..., n }</span>, for some positive integer <span class="SimpleMath">n</span>, then an error is signalled.</p>
<p>The returned value of <code class="func">Successors</code> is a list of lists where the lists are ordered as the elements according to the sorted order of the underlying set of <var class="Arg">R</var>. Each list consists of the images of the element whose index is the same as the list with the underlying set in sorted order.</p>
<p>The <code class="func">Successors</code> of a relation is the adjacency list representation of the relation.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DegreeOfBinaryRelation</code>( <var class="Arg">R</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns the size of the underlying domain of the binary relation <var class="Arg">R</var>. This is most natural when working with a binary relation on points.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PartialOrderOfHasseDiagram</code>( <var class="Arg">HD</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>is the partial order associated with the Hasse Diagram <var class="Arg">HD</var> i.e. the partial order generated by the reflexive and transitive closure of <var class="Arg">HD</var>.</p>
<h4>33.3 <span class="Heading">Binary Relations on Points</span></h4>
<p>We have special construction methods when the underlying <var class="Arg">X</var> of our relation is the set of integers <span class="SimpleMath">{ 1, ..., n }</span>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BinaryRelationOnPoints</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BinaryRelationOnPointsNC</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Given a list of <span class="SimpleMath">n</span> lists, each containing elements from the set <span class="SimpleMath">{ 1, ..., n }</span>, this function constructs a binary relation such that <span class="SimpleMath">1</span> is related to <var class="Arg">list</var><code class="code">[1]</code>, <span class="SimpleMath">2</span> to <var class="Arg">list</var><code class="code">[2]</code> and so on. The first version checks whether the list supplied is valid. The <code class="code">NC</code> version skips this check.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsBinaryRelationOnPoints</code>( <var class="Arg">trans</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsBinaryRelationOnPoints</code>( <var class="Arg">perm</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsBinaryRelationOnPoints</code>( <var class="Arg">rel</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>return the relation on points represented by general relation <var class="Arg">rel</var>, transformation <var class="Arg">trans</var> or permutation <var class="Arg">perm</var>. If <var class="Arg">rel</var> is already a binary relation on points then <var class="Arg">rel</var> is returned.</p>
<p>Transformations and permutations are special general endomorphic mappings and have a natural representation as a binary relation on points.</p>
<p>In the last form, an isomorphic relation on points is constructed where the points are indices of the elements of the underlying domain in sorted order.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ReflexiveClosureBinaryRelation</code>( <var class="Arg">R</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>is the smallest binary relation containing the binary relation <var class="Arg">R</var> which is reflexive. This closure inherits the properties symmetric and transitive from <var class="Arg">R</var>. E.g., if <var class="Arg">R</var> is symmetric then its reflexive closure is also.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SymmetricClosureBinaryRelation</code>( <var class="Arg">R</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>is the smallest binary relation containing the binary relation <var class="Arg">R</var> which is symmetric. This closure inherits the properties reflexive and transitive from <var class="Arg">R</var>. E.g., if <var class="Arg">R</var> is reflexive then its symmetric closure is also.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ TransitiveClosureBinaryRelation</code>( <var class="Arg">rel</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>is the smallest binary relation containing the binary relation <var class="Arg">R</var> which is transitive. This closure inherits the properties reflexive and symmetric from <var class="Arg">R</var>. E.g., if <var class="Arg">R</var> is symmetric then its transitive closure is also.</p>
<p><code class="func">TransitiveClosureBinaryRelation</code> is a modified version of the Floyd-Warshall method of solving the all-pairs shortest-paths problem on a directed graph. Its asymptotic runtime is <span class="SimpleMath">O(n^3)</span> where <span class="SimpleMath">n</span> is the size of the vertex set. It only assumes there is an arbitrary (but fixed) ordering of the vertex set.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HasseDiagramBinaryRelation</code>( <var class="Arg">partial-order</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>is the smallest relation contained in the partial order <var class="Arg">partial-order</var> whose reflexive and transitive closure is equal to <var class="Arg">partial-order</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PartialOrderByOrderingFunction</code>( <var class="Arg">dom</var>, <var class="Arg">orderfunc</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>constructs a partial order whose elements are from the domain <var class="Arg">dom</var> and are ordered using the ordering function <var class="Arg">orderfunc</var>. The ordering function must be a binary function returning a boolean value. If the ordering function does not describe a partial order then <code class="keyw">fail</code> is returned.</p>
<p>An <em>equivalence relation</em> <var class="Arg">E</var> over the set <var class="Arg">X</var> is a relation on <var class="Arg">X</var> which is reflexive, symmetric, and transitive. A <em>partition</em> <var class="Arg">P</var> is a set of subsets of <var class="Arg">X</var> such that for all <span class="SimpleMath">R, S ∈ P</span>, <span class="SimpleMath">R ∩ S</span> is the empty set and <span class="SimpleMath">∪ P = X</span>. An equivalence relation induces a partition such that if <span class="SimpleMath">(x,y) ∈ E</span> then <span class="SimpleMath">x, y</span> are in the same element of <var class="Arg">P</var>.</p>
<p>Like all binary relations in <strong class="pkg">GAP</strong> equivalence relations are regarded as general endomorphic mappings (and the operations, properties and attributes of general mappings are available). However, partitions provide an efficient way of representing equivalence relations. Moreover, only the non-singleton classes or blocks are listed allowing for small equivalence relations to be represented on infinite sets. Hence the main attribute of equivalence relations is <code class="func">EquivalenceRelationPartition</code> (<a href="chap33.html#X877389B683DD8F1A"><span class="RefLink">33.6-1</span></a>) which provides the partition induced by the given equivalence.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceRelationByPartition</code>( <var class="Arg">domain</var>, <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceRelationByPartitionNC</code>( <var class="Arg">domain</var>, <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>constructs the equivalence relation over the set <var class="Arg">domain</var> which induces the partition represented by <var class="Arg">list</var>. This representation includes only the non-trivial blocks (or equivalent classes). <var class="Arg">list</var> is a list of lists, each of these lists contain elements of <var class="Arg">domain</var> and are pairwise mutually exclusive.</p>
<p>The list of lists do not need to be in any order nor do the elements in the blocks (see <code class="func">EquivalenceRelationPartition</code> (<a href="chap33.html#X877389B683DD8F1A"><span class="RefLink">33.6-1</span></a>)). a list of elements of <var class="Arg">domain</var> The partition <var class="Arg">list</var> is a list of lists, each of these is a list of elements of <var class="Arg">domain</var> that makes up a block (or equivalent class). The <var class="Arg">domain</var> is the domain over which the relation is defined, and <var class="Arg">list</var> is a list of lists, each of these is a list of elements of <var class="Arg">domain</var> which are related to each other. <var class="Arg">list</var> need only contain the nontrivial blocks and singletons will be ignored. The <code class="code">NC</code> version will not check to see if the lists are pairwise mutually exclusive or that they contain only elements of the domain.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceRelationByPairs</code>( <var class="Arg">D</var>, <var class="Arg">elms</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceRelationByPairsNC</code>( <var class="Arg">D</var>, <var class="Arg">elms</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>return the smallest equivalence relation on the domain <var class="Arg">D</var> such that every pair in <var class="Arg">elms</var> is in the relation.</p>
<p>In the <code class="code">NC</code> form, it is not checked that <var class="Arg">elms</var> are in the domain <var class="Arg">D</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceRelationByProperty</code>( <var class="Arg">domain</var>, <var class="Arg">property</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>creates an equivalence relation on <var class="Arg">domain</var> whose only defining datum is that of having the property <var class="Arg">property</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceRelationPartition</code>( <var class="Arg">equiv</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns a list of lists of elements of the underlying set of the equivalence relation <var class="Arg">equiv</var>. The lists are precisely the nonsingleton equivalence classes of the equivalence. This allows us to describe <q>small</q> equivalences on infinite sets.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GeneratorsOfEquivalenceRelationPartition</code>( <var class="Arg">equiv</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>is a set of generating pairs for the equivalence relation <var class="Arg">equiv</var>. This set is not unique. The equivalence <var class="Arg">equiv</var> is the smallest equivalence relation over the underlying set which contains the generating pairs.</p>
<p><code class="func">MeetEquivalenceRelations</code> returns the intersection of the two equivalence relations <var class="Arg">equiv1</var> and <var class="Arg">equiv2</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsEquivalenceClass</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>returns <code class="keyw">true</code> if the object <var class="Arg">obj</var> is an equivalence class, and <code class="keyw">false</code> otherwise.</p>
<p>An <em>equivalence class</em> is a collection of elements which are mutually related to each other in the associated equivalence relation. Note, this is a special category of objects and not just a list of elements.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceClassRelation</code>( <var class="Arg">C</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns the equivalence relation of which <var class="Arg">C</var> is a class.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceClasses</code>( <var class="Arg">rel</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>returns a list of all equivalence classes of the equivalence relation <var class="Arg">rel</var>. Note that it is possible for different methods to yield the list in different orders, so that for two equivalence relations <span class="SimpleMath">c1</span> and <span class="SimpleMath">c2</span> we may have <span class="SimpleMath">c1 = c2</span> without having <code class="code">EquivalenceClasses</code><span class="SimpleMath">( c1 ) =</span><code class="code">EquivalenceClasses</code><span class="SimpleMath">( c2 )</span>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceClassOfElement</code>( <var class="Arg">rel</var>, <var class="Arg">elt</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EquivalenceClassOfElementNC</code>( <var class="Arg">rel</var>, <var class="Arg">elt</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>return the equivalence class of <var class="Arg">elt</var> in the binary relation <var class="Arg">rel</var>, where <var class="Arg">elt</var> is an element (i.e. a pair) of the domain of <var class="Arg">rel</var>. In the <code class="code">NC</code> form, it is not checked that <var class="Arg">elt</var> is in the domain over which <var class="Arg">rel</var> is defined.</p>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.