From 77a99ff3fb386db34ce304ef3d5f1e21c869111b Mon Sep 17 00:00:00 2001 From: grouptheoryenthusiast Date: Wed, 28 Feb 2018 12:53:34 +0000 Subject: [PATCH] Adding examples to the relations chapter --- lib/relation.gd | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/lib/relation.gd b/lib/relation.gd index 0e4052e28e..c4cc9f8952 100644 --- a/lib/relation.gd +++ b/lib/relation.gd @@ -95,6 +95,10 @@ DeclareSynonym("IsBinaryRelation",IsEndoGeneralMapping); ## to list[1], 2 to list[2] and so on. ## The first version checks whether the list supplied is valid. ## The the NC version skips this check. +## R:=BinaryRelationOnPoints([[1,2],[2],[3]]); +## Binary Relation on 3 points +## ]]> ## ## ## <#/GAPDoc> @@ -137,6 +141,14 @@ DeclareGlobalFunction("RandomBinaryRelationOnPoints"); ## \{ 1, \ldots, degree \}. ## In the second form, the objects x are from the domain ## domain. +## IdentityBinaryRelation(5); +## > +## gap> s4:=SymmetricGroup(4); +## Sym( [ 1 .. 4 ] ) +## gap> IdentityBinaryRelation(s4); +## IdentityMapping( Sym( [ 1 .. 4 ] ) ) +## ]]> ## ## ## <#/GAPDoc> @@ -156,6 +168,10 @@ DeclareGlobalFunction("IdentityBinaryRelation"); ## consisting of the tuples collection elms. ## This construction is similar to ## where the source and range are the same set. +## r:=BinaryRelationByElements(Domain([1..3]),[Tuple([1,2]),Tuple([1,3])]); +## -> > +## ]]> ## ## ## <#/GAPDoc> @@ -178,6 +194,10 @@ DeclareGlobalFunction("BinaryRelationByElements"); ## the domain is the set of points \{ 1, \ldots, degree \}. ## In the second form, the domain is that given by the argument ## domain. +## EmptyBinaryRelation(3) = BinaryRelationOnPoints([ [], [], [] ]); +## true +## ]]> ## ## ## <#/GAPDoc> @@ -214,6 +234,15 @@ DeclareGlobalFunction("EmptyBinaryRelation"); ## 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. +## t:=Transformation([2,3,1]);; +## gap> r1:=AsBinaryRelationOnPoints(t); +## Binary Relation on 3 points +## gap> r2:=AsBinaryRelationOnPoints((1,2,3)); +## Binary Relation on 3 points +## gap> r1=r2; +## true +## ]]> ## ## ## <#/GAPDoc> @@ -241,6 +270,11 @@ DeclareGlobalFunction("AsBinaryRelationOnPoints"); ##

## The of a relation is the adjacency list ## representation of the relation. +## r1:=BinaryRelationOnPoints([[2],[3],[1]]);; +## gap> Successors(r1); +## [ [ 2 ], [ 3 ], [ 1 ] ] +## ]]> ## ## ## <#/GAPDoc> @@ -259,6 +293,10 @@ DeclareAttribute("Successors", IsBinaryRelation); ## returns the size of the underlying domain of the binary relation ## R. ## This is most natural when working with a binary relation on points. +## DegreeOfBinaryRelation(r1); +## 3 +## ]]> ## ## ## <#/GAPDoc> @@ -306,6 +344,12 @@ DeclareSynonym("UnderlyingDomainOfBinaryRelation",Source); ##

## A reflexive binary relation is necessarily a total endomorphic ## mapping (tested via ). +## IsReflexiveBinaryRelation(BinaryRelationOnPoints([[1,3],[2],[3]])); +## true +## gap> IsReflexiveBinaryRelation(BinaryRelationOnPoints([[2],[2]])); +## false +## ]]> ## ## ## <#/GAPDoc> @@ -330,6 +374,12 @@ DeclareProperty("IsReflexiveBinaryRelation", IsBinaryRelation); ## Alternatively, R as a mapping is symmetric ## if for all x \in X, the preimage set of x under R ## equals the image set R(x). +## IsSymmetricBinaryRelation(BinaryRelationOnPoints([[2],[1]])); +## true +## gap> IsSymmetricBinaryRelation(BinaryRelationOnPoints([[2],[2]])); +## false +## ]]> ## ## ## <#/GAPDoc> @@ -355,6 +405,12 @@ DeclareProperty("IsSymmetricBinaryRelation", IsBinaryRelation); ## Alternatively, R as a mapping is transitive if for all ## x \in X, the image set R(R(x)) of the image ## set R(x) of x is a subset of R(x). +## IsTransitiveBinaryRelation(BinaryRelationOnPoints([[1,2,3],[2,3],[]])); +## true +## gap> IsTransitiveBinaryRelation(BinaryRelationOnPoints([[1,2],[2,3],[]])); +## false +## ]]> ## ## ## <#/GAPDoc> @@ -735,6 +791,12 @@ DeclareAttribute("GeneratorsOfEquivalenceRelationPartition", ## and singletons will be ignored. The NC version will not check ## to see if the lists are pairwise mutually exclusive or that ## they contain only elements of the domain. +## er:=EquivalenceRelationByPartition(Domain([1..10]),[[1,3,5,7,9],[2,4,6,8,10]]); +## > +## gap> IsEquivalenceRelation(er); +## true +## ]]> ## ## ## <#/GAPDoc> @@ -867,6 +929,12 @@ DeclareAttribute("EquivalenceClassRelation", IsEquivalenceClass); ## c1 and c2 we may have c1 = c2 without having ## EquivalenceClasses( c1 ) = ## EquivalenceClasses( c2 ). +## er:=EquivalenceRelationByPartition(Domain([1..10]),[[1,3,5,7,9],[2,4,6,8,10]]); +## > +## gap> classes := EquivalenceClasses(er); +## [ {1}, {2} ] +## ]]> ## ## ## <#/GAPDoc> @@ -889,6 +957,10 @@ DeclareAttribute("EquivalenceClasses", IsEquivalenceRelation); ## where elt is an element (i.e. a pair) of the domain of rel. ## In the NC form, it is not checked that elt is in the domain ## over which rel is defined. +## EquivalenceClassOfElement(er,3); +## {3} +## ]]> ## ## ## <#/GAPDoc>