Fixed crash on disconnected braid and possible loss of orientation

information when building braids.  knot parser supports disjoint union
(juxtaposition).  Minor documentation changes.
This commit is contained in:
Cotton Seed 2013-03-26 12:44:40 -04:00
parent dc11fd082c
commit 36e0303fca
8 changed files with 271 additions and 181 deletions

11
README
View File

@ -106,13 +106,17 @@ usage: kk <invariant> [options...] <link>
<invariant> can be one of:
kh: Khovanov homology
gss: Szabo's geometric spectral sequence
ls: Batson-Seed link splitting spectral sequence
lsss: Batson-Seed link splitting spectral sequence
component weights are 0, 1, ..., m
sq2: Lipshitz-Sarkar Steenrod square on Z/2 Kh
output suitable for Sage
leess: spectral sequence coming from Bar-Natan analogue of Lee's
deformation of Khovanov's complex (whew!)
s: Rasmussen's s-invariant coming from lee
output:
kh, gss, lsss, leess: .tex file
sq2: text in Sage format
s: text
options:
-r : compute reduced theory
-h : print this message
@ -128,7 +132,7 @@ options:
- a torus knot, e.g. T(2,3)
- a Rolfsen table knot, e.g. 10_124
- a Hoste-Thistlethwaite-Weeks knot, e.g. 11a12 or 12n214
- a Morwen Thistlethwaite link, e.g. L9a21 or L14n7631
- a Morwen Thistlethwaite link, e.g. L8n9 or L13n8862
- a planar diagram, e.g.
PD[X[1, 4, 2, 5], X[3, 6, 4, 1], X[5, 2, 6, 3]] or
PD[[1, 4, 2, 5], [3, 6, 4, 1], [5, 2, 6, 3]]
@ -137,6 +141,7 @@ options:
DT[dadbcda] or
DT[{6, -8}, {-10, 12, -14, 2, -4}]
- a braid, e.g. BR[2, {-1, -1, -1}]
- disjoint union (juxtaposition), e.g. T(2,3) U
4. UPCOMING CHANGES
@ -145,7 +150,7 @@ The following changes are currently planned:
* support for Z/p, p arbitrary prime and F(x) field of rational functions
* Roberts' totally twisted Khovanov homology
* the E^3 page of the twisted spectral sequence Kh(L) => \widehat{HF}(\Sigma_L)
* spectral sequences of PIDs: ls over F[x], gss over Z
* spectral sequences of PIDs: lsss over F[x], gss over Z
* maps induced by cobordisms
5. FOR DEVELOPERS

12
kk.cpp
View File

@ -11,13 +11,17 @@ usage ()
printf ("<invariant> can be one of:\n");
printf (" kh: Khovanov homology\n");
printf (" gss: Szabo's geometric spectral sequence\n");
printf (" ls: Batson-Seed link splitting spectral sequence\n");
printf (" lsss: Batson-Seed link splitting spectral sequence\n");
printf (" component weights are 0, 1, ..., m\n");
printf (" sq2: Lipshitz-Sarkar Steenrod square on Z/2 Kh\n");
printf (" output suitable for Sage\n");
printf (" leess: spectral sequence coming from Bar-Natan analogue of Lee's\n");
printf (" deformation of Khovanov's complex (whew!)\n");
printf (" s: Rasmussen's s-invariant coming from lee\n");
printf ("output:\n");
printf (" kh, gss, lsss, leess: .tex file\n");
printf (" sq2: text in Sage format\n");
printf (" s: text\n");
printf ("options:\n");
printf (" -r : compute reduced theory\n");
printf (" -h : print this message\n");
@ -33,7 +37,7 @@ usage ()
printf (" - a torus knot, e.g. T(2,3)\n");
printf (" - a Rolfsen table knot, e.g. 10_124\n");
printf (" - a Hoste-Thistlethwaite-Weeks knot, e.g. 11a12 or 12n214\n");
printf (" - a Morwen Thistlethwaite link, e.g. L9a21 or L14n7631\n");
printf (" - a Morwen Thistlethwaite link, e.g. L8n9 or L13n8862\n");
printf (" - a planar diagram, e.g.\n");
printf (" PD[X[1, 4, 2, 5], X[3, 6, 4, 1], X[5, 2, 6, 3]] or\n");
printf (" PD[[1, 4, 2, 5], [3, 6, 4, 1], [5, 2, 6, 3]]\n");
@ -42,6 +46,7 @@ usage ()
printf (" DT[dadbcda] or\n");
printf (" DT[{6, -8}, {-10, 12, -14, 2, -4}]\n");
printf (" - a braid, e.g. BR[2, {-1, -1, -1}]\n");
printf (" - disjoint union (juxtaposition), e.g. T(2,3) U\n");
}
FILE *outfp = stdout;
@ -317,10 +322,11 @@ compute_invariant ()
sseq ss (b, pages);
tex_header ();
fprintf (outfp, "$E_k = %s^{BS}_k(\\verb~%s~; \\verb~%s~)$:\\\\\n",
fprintf (outfp, "$E_k = %s^{BS}_k({}^{%d}\\verb~%s~; \\verb~%s~)$:\\\\\n",
(reduced
? "\\widetilde{E}"
: "E"),
m,
knot,
field);
ss.texshow (outfp, mapper);

View File

@ -1,4 +1,14 @@
// for building knot_diagram
inline unsigned edge_from_ept (unsigned e)
{
return e * 2 - 1;
}
inline unsigned edge_to_ept (unsigned e)
{
return e * 2;
}
static inline unsigned
add_base1_mod4 (unsigned x, unsigned y)
{

View File

@ -52,7 +52,7 @@
YY_DECL;
/* Line 285 of lalr1.cc */
#line 29 "knot_parser/knot_parser.yy"
#line 30 "knot_parser/knot_parser.yy"
#define yylex knot_yylex
@ -416,16 +416,35 @@ namespace yy {
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 10:
case 2:
/* Line 661 of lalr1.cc */
#line 67 "knot_parser/knot_parser.yy"
#line 60 "knot_parser/knot_parser.yy"
{
parsed_knot = *(yysemantic_stack_[(1) - (1)].kd);
delete (yysemantic_stack_[(1) - (1)].kd);
}
break;
case 4:
/* Line 661 of lalr1.cc */
#line 69 "knot_parser/knot_parser.yy"
{
(yyval.kd) = new knot_diagram (DISJOINT_UNION, *(yysemantic_stack_[(2) - (1)].kd), *(yysemantic_stack_[(2) - (2)].kd));
delete (yysemantic_stack_[(2) - (1)].kd);
delete (yysemantic_stack_[(2) - (2)].kd);
}
break;
case 13:
/* Line 661 of lalr1.cc */
#line 89 "knot_parser/knot_parser.yy"
{
unsigned n = (yysemantic_stack_[(3) - (1)].integer),
k = (yysemantic_stack_[(3) - (3)].integer);
if (n >= 1 && n <= 10
&& k >= 1 && k <= rolfsen_crossing_knots (n))
parsed_knot = knot_diagram (rolfsen_knot (n, k));
(yyval.kd) = new knot_diagram (rolfsen_knot (n, k));
else
{
fprintf (stderr, "knot_parser: no such Rolfsen knot `%d_%d'\n",
@ -435,9 +454,9 @@ namespace yy {
}
break;
case 11:
case 14:
/* Line 661 of lalr1.cc */
#line 85 "knot_parser/knot_parser.yy"
#line 107 "knot_parser/knot_parser.yy"
{
unsigned n = (yysemantic_stack_[(3) - (1)].integer),
k = (yysemantic_stack_[(3) - (3)].integer);
@ -445,7 +464,7 @@ namespace yy {
if (n >= 1 && n <= 16
&& k >= 1 && k <= htw_knots (n, alt))
parsed_knot = knot_diagram (htw_knot (n, alt, k));
(yyval.kd) = new knot_diagram (htw_knot (n, alt, k));
else
{
fprintf (stderr, "knot_parser: no such HTW knot `%d%c%d'\n",
@ -455,9 +474,9 @@ namespace yy {
}
break;
case 12:
case 15:
/* Line 661 of lalr1.cc */
#line 104 "knot_parser/knot_parser.yy"
#line 126 "knot_parser/knot_parser.yy"
{
unsigned n = (yysemantic_stack_[(4) - (2)].integer),
k = (yysemantic_stack_[(4) - (4)].integer);
@ -465,7 +484,7 @@ namespace yy {
if (n >= 1 && n <= 14
&& k >= 1 && k <= mt_links (n, alt))
parsed_knot = knot_diagram (mt_link (n, alt, k));
(yyval.kd) = new knot_diagram (mt_link (n, alt, k));
else
{
fprintf (stderr, "knot_parser: no such MT link `%d%c%d'\n",
@ -475,66 +494,66 @@ namespace yy {
}
break;
case 13:
/* Line 661 of lalr1.cc */
#line 123 "knot_parser/knot_parser.yy"
{ parsed_knot = knot_diagram (planar_diagram ("<parsed>", *(yysemantic_stack_[(4) - (3)].int_vec2))); }
break;
case 14:
/* Line 661 of lalr1.cc */
#line 125 "knot_parser/knot_parser.yy"
{ parsed_knot = knot_diagram (planar_diagram ("<parsed>", *(yysemantic_stack_[(4) - (3)].int_vec2))); }
break;
case 15:
/* Line 661 of lalr1.cc */
#line 130 "knot_parser/knot_parser.yy"
{
basedvector<basedvector<int, 1>, 1> even_labels (1);
even_labels[1] = *(yysemantic_stack_[(4) - (3)].int_vec);
parsed_knot = knot_diagram (dt_code ("<parsed>", even_labels));
}
break;
case 16:
/* Line 661 of lalr1.cc */
#line 136 "knot_parser/knot_parser.yy"
{ parsed_knot = knot_diagram (dt_code ("<parsed>", *(yysemantic_stack_[(4) - (3)].int_vec2))); }
#line 145 "knot_parser/knot_parser.yy"
{ (yyval.kd) = new knot_diagram (planar_diagram ("<parsed>", *(yysemantic_stack_[(4) - (3)].int_vec2))); }
break;
case 17:
/* Line 661 of lalr1.cc */
#line 138 "knot_parser/knot_parser.yy"
{ parsed_knot = knot_diagram (dt_code ("<parsed>", (yysemantic_stack_[(4) - (3)].string))); }
#line 147 "knot_parser/knot_parser.yy"
{ (yyval.kd) = new knot_diagram (planar_diagram ("<parsed>", *(yysemantic_stack_[(4) - (3)].int_vec2))); }
break;
case 18:
/* Line 661 of lalr1.cc */
#line 143 "knot_parser/knot_parser.yy"
{ parsed_knot = knot_diagram (torus_knot ((yysemantic_stack_[(6) - (3)].integer), (yysemantic_stack_[(6) - (5)].integer))); }
#line 152 "knot_parser/knot_parser.yy"
{
basedvector<basedvector<int, 1>, 1> even_labels (1);
even_labels[1] = *(yysemantic_stack_[(4) - (3)].int_vec);
(yyval.kd) = new knot_diagram (dt_code ("<parsed>", even_labels));
}
break;
case 19:
/* Line 661 of lalr1.cc */
#line 148 "knot_parser/knot_parser.yy"
{ parsed_knot = knot_diagram (braid ((yysemantic_stack_[(6) - (3)].integer), *(yysemantic_stack_[(6) - (5)].int_vec))); }
#line 158 "knot_parser/knot_parser.yy"
{ (yyval.kd) = new knot_diagram (dt_code ("<parsed>", *(yysemantic_stack_[(4) - (3)].int_vec2))); }
break;
case 20:
/* Line 661 of lalr1.cc */
#line 153 "knot_parser/knot_parser.yy"
{
unsigned unknot_ar[1][4] = {
{ 2, 1, 3, 4, },
};
parsed_knot = knot_diagram ("U", 1, unknot_ar);
}
#line 160 "knot_parser/knot_parser.yy"
{ (yyval.kd) = new knot_diagram (dt_code ("<parsed>", (yysemantic_stack_[(4) - (3)].string))); }
break;
case 21:
/* Line 661 of lalr1.cc */
#line 165 "knot_parser/knot_parser.yy"
{ (yyval.kd) = new knot_diagram (torus_knot ((yysemantic_stack_[(6) - (3)].integer), (yysemantic_stack_[(6) - (5)].integer))); }
break;
case 22:
/* Line 661 of lalr1.cc */
#line 170 "knot_parser/knot_parser.yy"
{ (yyval.kd) = new knot_diagram (braid ((yysemantic_stack_[(6) - (3)].integer), *(yysemantic_stack_[(6) - (5)].int_vec))); }
break;
case 23:
/* Line 661 of lalr1.cc */
#line 168 "knot_parser/knot_parser.yy"
#line 175 "knot_parser/knot_parser.yy"
{
unsigned unknot_ar[1][4] = {
{ 2, 1, 3, 4, },
};
(yyval.kd) = new knot_diagram ("U", 1, unknot_ar);
}
break;
case 26:
/* Line 661 of lalr1.cc */
#line 190 "knot_parser/knot_parser.yy"
{
basedvector<basedvector<int, 1>, 1> *v
= new basedvector<basedvector<int, 1>, 1> ();
@ -543,9 +562,9 @@ namespace yy {
}
break;
case 24:
case 27:
/* Line 661 of lalr1.cc */
#line 175 "knot_parser/knot_parser.yy"
#line 197 "knot_parser/knot_parser.yy"
{
basedvector<basedvector<int, 1>, 1> *v = (yysemantic_stack_[(3) - (1)].int_vec2);
v->append (*(yysemantic_stack_[(3) - (3)].int_vec));
@ -553,21 +572,21 @@ namespace yy {
}
break;
case 25:
case 28:
/* Line 661 of lalr1.cc */
#line 184 "knot_parser/knot_parser.yy"
#line 206 "knot_parser/knot_parser.yy"
{ (yyval.int_vec) = (yysemantic_stack_[(3) - (2)].int_vec); }
break;
case 26:
case 29:
/* Line 661 of lalr1.cc */
#line 186 "knot_parser/knot_parser.yy"
#line 208 "knot_parser/knot_parser.yy"
{ (yyval.int_vec) = (yysemantic_stack_[(3) - (2)].int_vec); }
break;
case 27:
case 30:
/* Line 661 of lalr1.cc */
#line 191 "knot_parser/knot_parser.yy"
#line 213 "knot_parser/knot_parser.yy"
{
basedvector<int, 1> *v =
new basedvector<int, 1> ();
@ -576,9 +595,9 @@ namespace yy {
}
break;
case 28:
case 31:
/* Line 661 of lalr1.cc */
#line 198 "knot_parser/knot_parser.yy"
#line 220 "knot_parser/knot_parser.yy"
{
basedvector<int, 1> *v = (yysemantic_stack_[(3) - (1)].int_vec);
v->append ((yysemantic_stack_[(3) - (3)].integer));
@ -586,9 +605,9 @@ namespace yy {
}
break;
case 29:
case 32:
/* Line 661 of lalr1.cc */
#line 207 "knot_parser/knot_parser.yy"
#line 229 "knot_parser/knot_parser.yy"
{
basedvector<basedvector<int, 1>, 1> *v
= new basedvector<basedvector<int, 1>, 1> ();
@ -597,9 +616,9 @@ namespace yy {
}
break;
case 30:
case 33:
/* Line 661 of lalr1.cc */
#line 214 "knot_parser/knot_parser.yy"
#line 236 "knot_parser/knot_parser.yy"
{
basedvector<basedvector<int, 1>, 1> *v = (yysemantic_stack_[(3) - (1)].int_vec2);
v->append (*(yysemantic_stack_[(3) - (3)].int_vec));
@ -607,9 +626,9 @@ namespace yy {
}
break;
case 31:
case 34:
/* Line 661 of lalr1.cc */
#line 223 "knot_parser/knot_parser.yy"
#line 245 "knot_parser/knot_parser.yy"
{
basedvector<int, 1> *v
= new basedvector<int, 1> ();
@ -623,7 +642,7 @@ namespace yy {
/* Line 661 of lalr1.cc */
#line 627 "knot_parser/knot_parser.cc"
#line 646 "knot_parser/knot_parser.cc"
default:
break;
}
@ -809,18 +828,18 @@ namespace yy {
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
const signed char knot_parser::yypact_ninf_ = -36;
const signed char knot_parser::yypact_ninf_ = -39;
const signed char
knot_parser::yypact_[] =
{
-1, 10, -9, 25, 26, 37, 9, -36, 43, -36,
-36, -36, -36, -36, -36, -36, -36, -36, -36, 41,
42, -7, -3, 44, 24, 45, -36, -36, -36, 30,
46, 46, 7, -36, 11, -36, -36, 33, 12, 15,
-4, 48, 34, 49, 16, -2, -36, 0, -36, 47,
-36, -36, -36, 51, 0, -36, 53, 38, -36, -36,
-36, -36, -36, 50, 39, 55, -36, -36, 52, 57,
54, 58, 59, -36
-1, 10, -9, 25, 26, 37, 9, -39, 43, -1,
-39, -39, -39, -39, -39, -39, -39, -39, -39, -39,
-39, 41, 42, -7, -3, 44, 24, 45, -39, -1,
-39, -39, 30, 46, 46, 7, -39, 11, -39, -39,
33, 12, 15, -4, 48, 34, 49, 16, -2, -39,
0, -39, 47, -39, -39, -39, 51, 0, -39, 53,
38, -39, -39, -39, -39, -39, 50, 39, 55, -39,
-39, 52, 57, 54, 58, 59, -39
};
/* YYDEFACT[S] -- default reduction number in state S. Performed when
@ -829,30 +848,30 @@ namespace yy {
const unsigned char
knot_parser::yydefact_[] =
{
0, 0, 0, 0, 0, 0, 0, 20, 0, 2,
3, 4, 5, 6, 7, 9, 8, 21, 22, 0,
0, 0, 0, 0, 0, 0, 1, 10, 11, 0,
0, 0, 0, 23, 0, 29, 27, 0, 0, 0,
0, 0, 0, 0, 0, 0, 13, 0, 14, 0,
17, 16, 15, 0, 0, 12, 0, 0, 26, 25,
24, 30, 28, 0, 0, 0, 19, 18, 0, 0,
0, 0, 0, 31
0, 0, 0, 0, 0, 0, 0, 23, 0, 2,
3, 5, 6, 7, 8, 9, 10, 12, 11, 24,
25, 0, 0, 0, 0, 0, 0, 0, 1, 4,
13, 14, 0, 0, 0, 0, 26, 0, 32, 30,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
0, 17, 0, 20, 19, 18, 0, 0, 15, 0,
0, 29, 28, 27, 33, 31, 0, 0, 0, 22,
21, 0, 0, 0, 0, 0, 34
};
/* YYPGOTO[NTERM-NUM]. */
const signed char
knot_parser::yypgoto_[] =
{
-36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
40, 56, -35, 8, -36, 13
-39, -39, 62, -39, -39, -39, -39, -39, -39, -39,
-39, -39, 40, 56, -38, 5, -39, 13
};
/* YYDEFGOTO[NTERM-NUM]. */
const signed char
knot_parser::yydefgoto_[] =
{
-1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
20, 32, 33, 39, 34, 35
-1, 8, 29, 10, 11, 12, 13, 14, 15, 16,
17, 18, 22, 35, 36, 42, 37, 38
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -862,14 +881,15 @@ namespace yy {
const unsigned char
knot_parser::yytable_[] =
{
36, 29, 1, 2, 3, 4, 5, 21, 6, 30,
7, 37, 60, 30, 31, 54, 30, 53, 31, 63,
59, 31, 17, 18, 46, 19, 47, 25, 48, 51,
49, 47, 52, 58, 53, 53, 17, 18, 44, 45,
24, 22, 23, 26, 27, 28, 43, 40, 42, 36,
50, 55, 57, 56, 62, 29, 64, 65, 68, 67,
70, 72, 61, 0, 41, 0, 0, 66, 0, 0,
0, 69, 0, 71, 0, 0, 73, 0, 38
39, 32, 1, 2, 3, 4, 5, 23, 6, 33,
7, 40, 63, 33, 34, 57, 33, 56, 34, 66,
62, 34, 19, 20, 49, 21, 50, 27, 51, 54,
52, 50, 55, 61, 56, 56, 19, 20, 47, 48,
26, 24, 25, 28, 30, 31, 46, 43, 45, 39,
53, 58, 60, 59, 65, 32, 67, 68, 71, 70,
73, 75, 9, 0, 0, 64, 44, 69, 0, 0,
0, 72, 0, 74, 0, 0, 76, 0, 0, 0,
41
};
/* YYCHECK. */
@ -877,13 +897,14 @@ namespace yy {
knot_parser::yycheck_[] =
{
3, 8, 3, 4, 5, 6, 7, 16, 9, 16,
11, 14, 47, 16, 21, 19, 16, 19, 21, 54,
11, 14, 50, 16, 21, 19, 16, 19, 21, 57,
22, 21, 12, 13, 17, 15, 19, 18, 17, 17,
19, 19, 17, 17, 19, 19, 12, 13, 30, 31,
19, 19, 17, 17, 19, 19, 12, 13, 33, 34,
3, 16, 16, 0, 3, 3, 16, 3, 3, 3,
17, 3, 3, 19, 3, 8, 3, 19, 3, 20,
3, 3, 49, -1, 24, -1, -1, 17, -1, -1,
-1, 19, -1, 19, -1, -1, 17, -1, 22
3, 3, 0, -1, -1, 52, 26, 17, -1, -1,
-1, 19, -1, 19, -1, -1, 17, -1, -1, -1,
24
};
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
@ -892,13 +913,13 @@ namespace yy {
knot_parser::yystos_[] =
{
0, 3, 4, 5, 6, 7, 9, 11, 24, 25,
26, 27, 28, 29, 30, 31, 32, 12, 13, 15,
33, 16, 16, 16, 3, 18, 0, 3, 3, 8,
16, 21, 34, 35, 37, 38, 3, 14, 34, 36,
3, 33, 3, 16, 36, 36, 17, 19, 17, 19,
17, 17, 17, 19, 19, 3, 19, 3, 17, 22,
35, 38, 3, 35, 3, 19, 17, 20, 3, 19,
3, 19, 3, 17
26, 27, 28, 29, 30, 31, 32, 33, 34, 12,
13, 15, 35, 16, 16, 16, 3, 18, 0, 25,
3, 3, 8, 16, 21, 36, 37, 39, 40, 3,
14, 36, 38, 3, 35, 3, 16, 38, 38, 17,
19, 17, 19, 17, 17, 17, 19, 19, 3, 19,
3, 17, 22, 37, 40, 3, 37, 3, 19, 17,
20, 3, 19, 3, 19, 3, 17
};
#if YYDEBUG
@ -917,20 +938,20 @@ namespace yy {
const unsigned char
knot_parser::yyr1_[] =
{
0, 23, 24, 24, 24, 24, 24, 24, 24, 24,
25, 26, 27, 28, 28, 29, 29, 29, 30, 31,
32, 33, 33, 34, 34, 35, 35, 36, 36, 37,
37, 38
0, 23, 24, 25, 25, 26, 26, 26, 26, 26,
26, 26, 26, 27, 28, 29, 30, 30, 31, 31,
31, 32, 33, 34, 35, 35, 36, 36, 37, 37,
38, 38, 39, 39, 40
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
const unsigned char
knot_parser::yyr2_[] =
{
0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
3, 3, 4, 4, 4, 4, 4, 4, 6, 6,
1, 1, 1, 1, 3, 3, 3, 1, 3, 1,
3, 10
0, 2, 1, 1, 2, 1, 1, 1, 1, 1,
1, 1, 1, 3, 3, 4, 4, 4, 4, 4,
4, 6, 6, 1, 1, 1, 1, 3, 3, 3,
1, 3, 1, 3, 10
};
#if YYDEBUG
@ -941,8 +962,8 @@ namespace yy {
{
"\"end of file\"", "error", "$undefined", "INT", "PD", "DT", "BR",
"LINK", "X", "T", "U", "UNKNOT", "ALT", "NONALT", "STRING", "'_'", "'['",
"']'", "'('", "','", "')'", "'{'", "'}'", "$accept", "knot",
"rolfsen_knot", "htw_knot", "mt_link", "planar_diagram", "dt",
"']'", "'('", "','", "')'", "'{'", "'}'", "$accept", "entry", "knot",
"knot_1", "rolfsen_knot", "htw_knot", "mt_link", "planar_diagram", "dt",
"torus_link", "braid", "unknot", "alt_spec", "int_vec2", "int_vec",
"int_vec_1", "crossing_vec", "crossing", YY_NULL
};
@ -952,18 +973,19 @@ namespace yy {
const knot_parser::rhs_number_type
knot_parser::yyrhs_[] =
{
24, 0, -1, 25, -1, 26, -1, 27, -1, 28,
-1, 29, -1, 30, -1, 32, -1, 31, -1, 3,
15, 3, -1, 3, 33, 3, -1, 7, 3, 33,
3, -1, 4, 16, 34, 17, -1, 4, 16, 37,
17, -1, 5, 16, 36, 17, -1, 5, 16, 34,
17, -1, 5, 16, 14, 17, -1, 9, 18, 3,
19, 3, 20, -1, 6, 16, 3, 19, 35, 17,
-1, 11, -1, 12, -1, 13, -1, 35, -1, 34,
19, 35, -1, 21, 36, 22, -1, 16, 36, 17,
-1, 3, -1, 36, 19, 3, -1, 38, -1, 37,
19, 38, -1, 8, 16, 3, 19, 3, 19, 3,
19, 3, 17, -1
24, 0, -1, 25, -1, 26, -1, 25, 25, -1,
27, -1, 28, -1, 29, -1, 30, -1, 31, -1,
32, -1, 34, -1, 33, -1, 3, 15, 3, -1,
3, 35, 3, -1, 7, 3, 35, 3, -1, 4,
16, 36, 17, -1, 4, 16, 39, 17, -1, 5,
16, 38, 17, -1, 5, 16, 36, 17, -1, 5,
16, 14, 17, -1, 9, 18, 3, 19, 3, 20,
-1, 6, 16, 3, 19, 37, 17, -1, 11, -1,
12, -1, 13, -1, 37, -1, 36, 19, 37, -1,
21, 38, 22, -1, 16, 38, 17, -1, 3, -1,
38, 19, 3, -1, 40, -1, 39, 19, 40, -1,
8, 16, 3, 19, 3, 19, 3, 19, 3, 17,
-1
};
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
@ -971,20 +993,20 @@ namespace yy {
const unsigned char
knot_parser::yyprhs_[] =
{
0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
19, 23, 27, 32, 37, 42, 47, 52, 57, 64,
71, 73, 75, 77, 79, 83, 87, 91, 93, 97,
99, 103
0, 0, 3, 5, 7, 10, 12, 14, 16, 18,
20, 22, 24, 26, 30, 34, 39, 44, 49, 54,
59, 64, 71, 78, 80, 82, 84, 86, 90, 94,
98, 100, 104, 106, 110
};
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
const unsigned char
knot_parser::yyrline_[] =
{
0, 55, 55, 56, 57, 58, 59, 60, 61, 62,
66, 84, 103, 122, 124, 129, 135, 137, 142, 147,
152, 162, 163, 167, 174, 183, 185, 190, 197, 206,
213, 222
0, 59, 59, 67, 68, 77, 78, 79, 80, 81,
82, 83, 84, 88, 106, 125, 144, 146, 151, 157,
159, 164, 169, 174, 184, 185, 189, 196, 205, 207,
212, 219, 228, 235, 244
};
// Print the state stack on the debug stream.
@ -1059,10 +1081,10 @@ namespace yy {
}
const int knot_parser::yyeof_ = 0;
const int knot_parser::yylast_ = 78;
const int knot_parser::yynnts_ = 16;
const int knot_parser::yylast_ = 80;
const int knot_parser::yynnts_ = 18;
const int knot_parser::yyempty_ = -2;
const int knot_parser::yyfinal_ = 26;
const int knot_parser::yyfinal_ = 28;
const int knot_parser::yyterror_ = 1;
const int knot_parser::yyerrcode_ = 256;
const int knot_parser::yyntokens_ = 23;
@ -1073,9 +1095,9 @@ namespace yy {
} // yy
/* Line 1106 of lalr1.cc */
#line 1077 "knot_parser/knot_parser.cc"
#line 1099 "knot_parser/knot_parser.cc"
/* Line 1107 of lalr1.cc */
#line 233 "knot_parser/knot_parser.yy"
#line 255 "knot_parser/knot_parser.yy"
void

View File

@ -82,10 +82,11 @@ namespace yy {
basedvector<int, 1> *int_vec;
basedvector<basedvector<int, 1>, 1> *int_vec2;
const char *string;
knot_diagram *kd;
/* Line 36 of lalr1.cc */
#line 89 "knot_parser/knot_parser.hh"
#line 90 "knot_parser/knot_parser.hh"
};
#else
typedef YYSTYPE semantic_type;
@ -283,7 +284,7 @@ namespace yy {
} // yy
/* Line 36 of lalr1.cc */
#line 287 "knot_parser/knot_parser.hh"
#line 288 "knot_parser/knot_parser.hh"

View File

@ -24,6 +24,7 @@ YY_DECL;
basedvector<int, 1> *int_vec;
basedvector<basedvector<int, 1>, 1> *int_vec2;
const char *string;
knot_diagram *kd;
}
%code {
@ -36,9 +37,12 @@ YY_DECL;
%token PD DT BR LINK X T
%token U UNKNOT
%token <alternating> ALT NONALT
%token <string> STRING
%type <kd> knot knot_1
%type <kd> rolfsen_knot htw_knot mt_link planar_diagram dt torus_link unknot braid
%type <alternating> alt_spec
%type <int_vec> int_vec int_vec_1
@ -49,9 +53,27 @@ YY_DECL;
%%
%start knot;
%start entry;
entry:
knot
{
parsed_knot = *$1;
delete $1;
}
;
knot:
knot_1
| knot knot
{
$$ = new knot_diagram (DISJOINT_UNION, *$1, *$2);
delete $1;
delete $2;
}
;
knot_1:
rolfsen_knot
| htw_knot
| mt_link
@ -70,7 +92,7 @@ rolfsen_knot:
if (n >= 1 && n <= 10
&& k >= 1 && k <= rolfsen_crossing_knots (n))
parsed_knot = knot_diagram (rolfsen_knot (n, k));
$$ = new knot_diagram (rolfsen_knot (n, k));
else
{
fprintf (stderr, "knot_parser: no such Rolfsen knot `%d_%d'\n",
@ -89,7 +111,7 @@ htw_knot:
if (n >= 1 && n <= 16
&& k >= 1 && k <= htw_knots (n, alt))
parsed_knot = knot_diagram (htw_knot (n, alt, k));
$$ = new knot_diagram (htw_knot (n, alt, k));
else
{
fprintf (stderr, "knot_parser: no such HTW knot `%d%c%d'\n",
@ -108,7 +130,7 @@ mt_link:
if (n >= 1 && n <= 14
&& k >= 1 && k <= mt_links (n, alt))
parsed_knot = knot_diagram (mt_link (n, alt, k));
$$ = new knot_diagram (mt_link (n, alt, k));
else
{
fprintf (stderr, "knot_parser: no such MT link `%d%c%d'\n",
@ -120,9 +142,9 @@ mt_link:
planar_diagram:
PD '[' int_vec2 ']'
{ parsed_knot = knot_diagram (planar_diagram ("<parsed>", *$3)); }
{ $$ = new knot_diagram (planar_diagram ("<parsed>", *$3)); }
| PD '[' crossing_vec ']'
{ parsed_knot = knot_diagram (planar_diagram ("<parsed>", *$3)); }
{ $$ = new knot_diagram (planar_diagram ("<parsed>", *$3)); }
;
dt:
@ -130,22 +152,22 @@ dt:
{
basedvector<basedvector<int, 1>, 1> even_labels (1);
even_labels[1] = *$3;
parsed_knot = knot_diagram (dt_code ("<parsed>", even_labels));
$$ = new knot_diagram (dt_code ("<parsed>", even_labels));
}
| DT '[' int_vec2 ']'
{ parsed_knot = knot_diagram (dt_code ("<parsed>", *$3)); }
{ $$ = new knot_diagram (dt_code ("<parsed>", *$3)); }
| DT '[' STRING ']'
{ parsed_knot = knot_diagram (dt_code ("<parsed>", $3)); }
{ $$ = new knot_diagram (dt_code ("<parsed>", $3)); }
;
torus_link:
T '(' INT ',' INT ')'
{ parsed_knot = knot_diagram (torus_knot ($3, $5)); }
{ $$ = new knot_diagram (torus_knot ($3, $5)); }
;
braid:
BR '[' INT ',' int_vec ']'
{ parsed_knot = knot_diagram (braid ($3, *$5)); }
{ $$ = new knot_diagram (braid ($3, *$5)); }
;
unknot:
@ -154,7 +176,7 @@ unknot:
unsigned unknot_ar[1][4] = {
{ 2, 1, 3, 4, },
};
parsed_knot = knot_diagram ("U", 1, unknot_ar);
$$ = new knot_diagram ("U", 1, unknot_ar);
}
;

View File

@ -612,7 +612,7 @@ torus_knot (unsigned n_strands, unsigned n_shifts)
return planar_diagram (std::string (buf), crossings);
}
planar_diagram
knot_diagram
braid (unsigned n_strands, unsigned n_twists, int twists_ar[])
{
basedvector<int, 1> twists (n_twists);
@ -621,10 +621,9 @@ braid (unsigned n_strands, unsigned n_twists, int twists_ar[])
return braid (n_strands, twists);
}
planar_diagram
knot_diagram
braid (unsigned n_strands, const basedvector<int, 1> &twists)
{
unsigned n_crossings = twists.size ();
unsigned e = 0;
basedvector<unsigned, 1> final_strands (n_strands);
@ -644,14 +643,36 @@ braid (unsigned n_strands, const basedvector<int, 1> &twists)
last_twist[t] = i;
last_twist[t + 1] = i;
}
#ifndef NDEBUG
for (unsigned i = 1; i <= n_strands; i ++)
assert (last_twist[i] != 0);
#endif
basedvector<basedvector<int, 1>, 1> crossings (n_crossings);
unsigned n_crossings = twists.size ();
for (unsigned i = 1; i <= n_strands; i ++)
{
if (last_twist[i] == 0)
n_crossings ++;
}
basedvector<basedvector<unsigned, 1>, 1> crossings (n_crossings);
for (unsigned i = 1; i <= n_crossings; i ++)
crossings[i] = basedvector<int, 1> (4);
crossings[i] = basedvector<unsigned, 1> (4);
unsigned c = twists.size ();
for (unsigned i = 1; i <= n_strands; i ++)
{
if (last_twist[i] == 0)
{
++ c;
unsigned e1 = strands[i];
unsigned e2 = ++ e;
strands[i] = final_strands[i] = 0;
crossings[c][1] = edge_from_ept (e1);
crossings[c][2] = edge_to_ept (e2);
crossings[c][3] = edge_from_ept (e2);
crossings[c][4] = edge_to_ept (e1);
}
}
assert (c == n_crossings);
for (unsigned i = 1; i <= twists.size (); i ++)
{
@ -686,27 +707,30 @@ braid (unsigned n_strands, const basedvector<int, 1> &twists)
if (twists[i] > 0)
{
crossings[i][1] = e1;
crossings[i][2] = e2;
crossings[i][3] = e3;
crossings[i][4] = e4;
crossings[i][1] = edge_to_ept (e1);
crossings[i][2] = edge_from_ept (e2);
crossings[i][3] = edge_from_ept (e3);
crossings[i][4] = edge_to_ept (e4);
}
else
{
crossings[i][1] = e2;
crossings[i][2] = e3;
crossings[i][3] = e4;
crossings[i][4] = e1;
crossings[i][1] = edge_from_ept (e2);
crossings[i][2] = edge_from_ept (e3);
crossings[i][3] = edge_to_ept (e4);
crossings[i][4] = edge_to_ept (e1);
}
}
assert (e == n_crossings * 2);
#ifndef NDEBUG
for (unsigned i = 1; i <= n_strands; i ++)
assert (final_strands[i] == 0);
{
assert (strands[i] == 0);
assert (final_strands[i] == 0);
}
#endif
return planar_diagram ("abraid", crossings);
return knot_diagram ("abraid", crossings);
}
basedvector<basedvector<unsigned, 1>, 1>

View File

@ -115,8 +115,8 @@ dt_code mt_link (unsigned n, unsigned k);
planar_diagram torus_knot (unsigned n_strands, unsigned n_shifts);
planar_diagram braid (unsigned n_strands, const basedvector<int, 1> &twists);
planar_diagram braid (unsigned n_strands, unsigned n_twists, int twists_ar[]);
knot_diagram braid (unsigned n_strands, const basedvector<int, 1> &twists);
knot_diagram braid (unsigned n_strands, unsigned n_twists, int twists_ar[]);
knot_diagram parse_knot (const char *s);
resolution_diagram parse_resolution_diagram (const char *s);