File: example

package info (click to toggle)
gap-openmath 11.4.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 624 kB
  • sloc: xml: 460; makefile: 10
file content (110 lines) | stat: -rw-r--r-- 2,769 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
LoadPackage("openmath");


########################################################
## Bruhat order on permutations
########################################################

# return {(i,j) | i < j and p(i) > p(j)}
inv := function(p)
	local n, i, j, res;

	res := [];
	n := Length(ListPerm(p));

	for j in [1 .. n] do
		for i in [1 .. j-1] do
			if i^p > j^p then
				Append(res, [[i,j]]);
			fi;
		od;
	od;
	return res;
end;

le := function(p,t)
	return IsSubset(inv(t), inv(p));
end;

s := SymmetricGroup(4);
l := AsList(s);
h := CreateHasseDiagram(l,le);
DrawHasse(h);



########################################################
## Divisor lattice of a natural number
########################################################

leq := function(x,y) return y mod x = 0; end;
N := 102;
h := CreateHasseDiagram(Filtered([1..N],i->N mod i = 0), leq);
DrawHasse(h);

#try these numbers N := 102, 2618, 282387;
# the number lattice is basically boring, just a concatenation of cubes...



#########################################################################
## Some semigroups examples #############################################
#########################################################################
s1 := Transformation([1,1,3,4]);
s2 := Transformation([1,2,2,4]);
s3 := Transformation([1,2,3,3]);
t1 := Transformation([2,2,3,4]);
t2 := Transformation([1,3,3,4]);
t3 := Transformation([1,2,4,4]);
o4 := Semigroup([s1,s2,s3,t1,t2,t3]);
rcl := GreensRClasses( o4 );                                
h := CreateHasseDiagram(rcl, IsGreensLessThanOrEqual);
DrawHasse(h);



lcl := GreensRClasses( o4 );                                
h := CreateHasseDiagram(lcl, IsGreensLessThanOrEqual);
DrawHasse(h);

###################################################################
## Some basic Hasse Diagrams - for when everything else is broken
###################################################################
d := Domain(["0","a","b","c","1"]);
Elements(d);
Size(d);

r := BinaryRelationByElements(d,
[ DirectProductElement(["0","a"]),
DirectProductElement(["0","b"]),
DirectProductElement(["0","c"]),
DirectProductElement(["a","1"]),
DirectProductElement(["b","1"]),
DirectProductElement(["c","1"])]);

SetIsHasseDiagram(r, true);
DrawHasse(r);



########################################################
## Partitions of a Natural Number
##
## problematic? - writing matrices?
########################################################

# this identifies the holes where the spacers go
sumrep := function(p)
	return List([1 .. Length(p)], i->Sum([1 .. i], j->p[j]));
end;

# a refines b iff sumrep(b) is a subset of sumrep(a)
refines := function(a,b)
	return IsSubset(sumrep(a), sumrep(b));
end;

p := Partitions(5);
h := CreateHasseDiagram(p, refines);
DrawHasse(h);