Index: Singular/grammar.cc
===================================================================
--- Singular/grammar.cc	(revision b1645e52df1f9ba737d354f5a3f4bebff0aac7cd)
+++ Singular/grammar.cc	(revision f4f4033f0b5880920c8e4bfa1a3ab7c2f9e749b8)
@@ -805,13 +805,13 @@
      727,   731,   735,   739,   743,   747,   751,   755,   759,   763,
      780,   787,   786,   804,   812,   820,   829,   833,   837,   841,
-     845,   849,   853,   857,   861,   865,   869,   873,   877,   884,
-     891,   892,   911,   912,   924,   929,   934,   938,   942,   982,
-    1008,  1029,  1037,  1041,  1042,  1056,  1064,  1073,  1118,  1119,
-    1128,  1129,  1135,  1142,  1144,  1146,  1156,  1155,  1163,  1168,
-    1175,  1183,  1195,  1211,  1230,  1234,  1238,  1243,  1247,  1251,
-    1255,  1259,  1264,  1270,  1276,  1282,  1288,  1294,  1300,  1312,
-    1319,  1323,  1360,  1370,  1376,  1376,  1379,  1451,  1455,  1484,
-    1497,  1514,  1523,  1528,  1536,  1548,  1567,  1577,  1596,  1619,
-    1625,  1637,  1643
+     845,   849,   853,   857,   861,   865,   869,   873,   877,   889,
+     896,   897,   916,   917,   929,   934,   939,   943,   947,   987,
+    1013,  1034,  1042,  1046,  1047,  1061,  1069,  1078,  1123,  1124,
+    1133,  1134,  1140,  1147,  1149,  1151,  1161,  1160,  1168,  1173,
+    1180,  1188,  1200,  1216,  1235,  1239,  1243,  1248,  1252,  1256,
+    1260,  1264,  1269,  1275,  1281,  1287,  1293,  1299,  1305,  1317,
+    1324,  1328,  1365,  1375,  1381,  1381,  1384,  1456,  1460,  1489,
+    1502,  1519,  1528,  1533,  1541,  1553,  1572,  1582,  1601,  1624,
+    1630,  1642,  1648
 };
 #endif
@@ -3289,8 +3289,13 @@
 #line 878 "grammar.y"
     {
-            memset(&(yyval.lv),0,sizeof((yyval.lv)));
-            int i; TESTSETINT((yyvsp[(2) - (2)].lv),i);
-            (yyval.lv).rtyp  = INT_CMD;
-            (yyval.lv).data = (void *)(long)(i == 0 ? 1 : 0);
+            if (siq>0)
+            { if (iiExprArith1(&(yyval.lv),&(yyvsp[(2) - (2)].lv),NOT)) YYERROR; }
+	    else
+	    {
+              memset(&(yyval.lv),0,sizeof((yyval.lv)));
+              int i; TESTSETINT((yyvsp[(2) - (2)].lv),i);
+              (yyval.lv).rtyp  = INT_CMD;
+              (yyval.lv).data = (void *)(long)(i == 0 ? 1 : 0);
+	    }
           ;}
     break;
@@ -3299,5 +3304,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 885 "grammar.y"
+#line 890 "grammar.y"
     {
             if(iiExprArith1(&(yyval.lv),&(yyvsp[(2) - (2)].lv),'-')) YYERROR;
@@ -3308,5 +3313,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 891 "grammar.y"
+#line 896 "grammar.y"
     { (yyval.lv) = (yyvsp[(1) - (2)].lv); ;}
     break;
@@ -3315,5 +3320,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 893 "grammar.y"
+#line 898 "grammar.y"
     {
             if ((yyvsp[(1) - (2)].lv).rtyp==0)
@@ -3335,5 +3340,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 913 "grammar.y"
+#line 918 "grammar.y"
     {
             if ((yyvsp[(2) - (3)].lv).Typ()!=STRING_CMD)
@@ -3349,5 +3354,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 925 "grammar.y"
+#line 930 "grammar.y"
     {
             if (iiDeclCommand(&(yyval.lv),&(yyvsp[(2) - (2)].lv),myynest,(yyvsp[(1) - (2)].i),&((yyvsp[(2) - (2)].lv).req_packhdl->idroot)))
@@ -3359,5 +3364,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 930 "grammar.y"
+#line 935 "grammar.y"
     {
             if (iiDeclCommand(&(yyval.lv),&(yyvsp[(2) - (2)].lv),myynest,(yyvsp[(1) - (2)].i),&((yyvsp[(2) - (2)].lv).req_packhdl->idroot)))
@@ -3369,5 +3374,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 935 "grammar.y"
+#line 940 "grammar.y"
     {
             if (iiDeclCommand(&(yyval.lv),&(yyvsp[(2) - (2)].lv),myynest,(yyvsp[(1) - (2)].i),&(currRing->idroot), TRUE)) YYERROR;
@@ -3378,5 +3383,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 939 "grammar.y"
+#line 944 "grammar.y"
     {
             if (iiDeclCommand(&(yyval.lv),&(yyvsp[(2) - (2)].lv),myynest,(yyvsp[(1) - (2)].i),&(currRing->idroot), TRUE)) YYERROR;
@@ -3387,5 +3392,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 943 "grammar.y"
+#line 948 "grammar.y"
     {
             int r; TESTSETINT((yyvsp[(4) - (8)].lv),r);
@@ -3432,5 +3437,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 983 "grammar.y"
+#line 988 "grammar.y"
     {
             if ((yyvsp[(1) - (2)].i) == MATRIX_CMD)
@@ -3463,5 +3468,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1009 "grammar.y"
+#line 1014 "grammar.y"
     {
             int t=(yyvsp[(1) - (3)].lv).Typ();
@@ -3489,5 +3494,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1030 "grammar.y"
+#line 1035 "grammar.y"
     {
             if (iiDeclCommand(&(yyval.lv),&(yyvsp[(2) - (2)].lv),myynest,(yyvsp[(1) - (2)].i),&((yyvsp[(2) - (2)].lv).req_packhdl->idroot)))
@@ -3499,5 +3504,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1043 "grammar.y"
+#line 1048 "grammar.y"
     {
             leftv v = &(yyvsp[(2) - (5)].lv);
@@ -3515,5 +3520,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1057 "grammar.y"
+#line 1062 "grammar.y"
     {
           // let rInit take care of any errors
@@ -3525,5 +3530,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1065 "grammar.y"
+#line 1070 "grammar.y"
     {
             memset(&(yyval.lv),0,sizeof((yyval.lv)));
@@ -3539,5 +3544,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1074 "grammar.y"
+#line 1079 "grammar.y"
     {
             memset(&(yyval.lv),0,sizeof((yyval.lv)));
@@ -3586,5 +3591,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1120 "grammar.y"
+#line 1125 "grammar.y"
     {
             (yyval.lv) = (yyvsp[(1) - (3)].lv);
@@ -3597,5 +3602,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1130 "grammar.y"
+#line 1135 "grammar.y"
     {
             (yyval.lv) = (yyvsp[(2) - (3)].lv);
@@ -3606,5 +3611,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1136 "grammar.y"
+#line 1141 "grammar.y"
     {
             expected_parms = TRUE;
@@ -3615,5 +3620,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1143 "grammar.y"
+#line 1148 "grammar.y"
     { (yyval.i) = (yyvsp[(1) - (1)].i); ;}
     break;
@@ -3622,5 +3627,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1145 "grammar.y"
+#line 1150 "grammar.y"
     { (yyval.i) = (yyvsp[(1) - (1)].i); ;}
     break;
@@ -3629,5 +3634,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1147 "grammar.y"
+#line 1152 "grammar.y"
     { (yyval.i) = (yyvsp[(1) - (1)].i); ;}
     break;
@@ -3636,5 +3641,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1156 "grammar.y"
+#line 1161 "grammar.y"
     { if ((yyvsp[(1) - (2)].i) != '<') YYERROR;
             if((feFilePending=feFopen((yyvsp[(2) - (2)].name),"r",NULL,TRUE))==NULL) YYERROR; ;}
@@ -3644,5 +3649,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1159 "grammar.y"
+#line 1164 "grammar.y"
     { newFile((yyvsp[(2) - (4)].name),feFilePending); ;}
     break;
@@ -3651,5 +3656,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1164 "grammar.y"
+#line 1169 "grammar.y"
     {
             feHelp((yyvsp[(2) - (3)].name));
@@ -3661,5 +3666,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1169 "grammar.y"
+#line 1174 "grammar.y"
     {
             feHelp(NULL);
@@ -3670,5 +3675,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1176 "grammar.y"
+#line 1181 "grammar.y"
     {
             singular_example((yyvsp[(2) - (3)].name));
@@ -3680,5 +3685,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1184 "grammar.y"
+#line 1189 "grammar.y"
     {
           if (basePack!=(yyvsp[(2) - (2)].lv).req_packhdl)
@@ -3694,5 +3699,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1196 "grammar.y"
+#line 1201 "grammar.y"
     {
           leftv v=&(yyvsp[(2) - (2)].lv);
@@ -3715,5 +3720,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1212 "grammar.y"
+#line 1217 "grammar.y"
     {
           leftv v=&(yyvsp[(3) - (3)].lv);
@@ -3736,5 +3741,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1231 "grammar.y"
+#line 1236 "grammar.y"
     {
             list_cmd((yyvsp[(3) - (4)].i),NULL,"// ",TRUE);
@@ -3745,5 +3750,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1235 "grammar.y"
+#line 1240 "grammar.y"
     {
             list_cmd((yyvsp[(3) - (4)].i),NULL,"// ",TRUE);
@@ -3754,5 +3759,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1239 "grammar.y"
+#line 1244 "grammar.y"
     {
             if ((yyvsp[(3) - (4)].i)==QRING_CMD) (yyvsp[(3) - (4)].i)=RING_CMD;
@@ -3764,5 +3769,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1244 "grammar.y"
+#line 1249 "grammar.y"
     {
             list_cmd((yyvsp[(3) - (4)].i),NULL,"// ",TRUE);
@@ -3773,5 +3778,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1248 "grammar.y"
+#line 1253 "grammar.y"
     {
             list_cmd(RING_CMD,NULL,"// ",TRUE);
@@ -3782,5 +3787,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1252 "grammar.y"
+#line 1257 "grammar.y"
     {
             list_cmd((yyvsp[(3) - (4)].i),NULL,"// ",TRUE);
@@ -3791,5 +3796,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1256 "grammar.y"
+#line 1261 "grammar.y"
     {
             list_cmd(PROC_CMD,NULL,"// ",TRUE);
@@ -3800,5 +3805,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1260 "grammar.y"
+#line 1265 "grammar.y"
     {
             list_cmd(0,(yyvsp[(3) - (4)].lv).Fullname(),"// ",TRUE);
@@ -3810,5 +3815,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1265 "grammar.y"
+#line 1270 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3821,5 +3826,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1271 "grammar.y"
+#line 1276 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3832,5 +3837,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1277 "grammar.y"
+#line 1282 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3843,5 +3848,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1283 "grammar.y"
+#line 1288 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3854,5 +3859,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1289 "grammar.y"
+#line 1294 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3865,5 +3870,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1295 "grammar.y"
+#line 1300 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3876,5 +3881,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1301 "grammar.y"
+#line 1306 "grammar.y"
     {
             if((yyvsp[(3) - (6)].lv).Typ() == PACKAGE_CMD)
@@ -3887,5 +3892,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1313 "grammar.y"
+#line 1318 "grammar.y"
     {
             list_cmd(-1,NULL,"// ",TRUE);
@@ -3896,5 +3901,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1319 "grammar.y"
+#line 1324 "grammar.y"
     { yyInRingConstruction = TRUE; ;}
     break;
@@ -3903,5 +3908,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1328 "grammar.y"
+#line 1333 "grammar.y"
     {
             const char *ring_name = (yyvsp[(2) - (8)].lv).name;
@@ -3941,5 +3946,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1361 "grammar.y"
+#line 1366 "grammar.y"
     {
             const char *ring_name = (yyvsp[(2) - (2)].lv).name;
@@ -3953,5 +3958,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1371 "grammar.y"
+#line 1376 "grammar.y"
     {
             if (((yyvsp[(1) - (2)].i)!=LIB_CMD)||(jjLOAD((yyvsp[(2) - (2)].name),TRUE))) YYERROR;
@@ -3962,5 +3967,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1380 "grammar.y"
+#line 1385 "grammar.y"
     {
             if (((yyvsp[(1) - (2)].i)==KEEPRING_CMD) && (myynest==0))
@@ -4036,5 +4041,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1452 "grammar.y"
+#line 1457 "grammar.y"
     {
             type_cmd(&((yyvsp[(2) - (2)].lv)));
@@ -4045,5 +4050,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1456 "grammar.y"
+#line 1461 "grammar.y"
     {
             //Print("typ is %d, rtyp:%d\n",$1.Typ(),$1.rtyp);
@@ -4073,5 +4078,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1485 "grammar.y"
+#line 1490 "grammar.y"
     {
             int i; TESTSETINT((yyvsp[(3) - (5)].lv),i);
@@ -4091,5 +4096,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1498 "grammar.y"
+#line 1503 "grammar.y"
     {
             if (currentVoice->ifsw==1)
@@ -4113,5 +4118,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1515 "grammar.y"
+#line 1520 "grammar.y"
     {
             int i; TESTSETINT((yyvsp[(3) - (5)].lv),i);
@@ -4127,5 +4132,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1524 "grammar.y"
+#line 1529 "grammar.y"
     {
             if (exitBuffer(BT_break)) YYERROR;
@@ -4137,5 +4142,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1529 "grammar.y"
+#line 1534 "grammar.y"
     {
             if (contBuffer(BT_break)) YYERROR;
@@ -4147,5 +4152,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1537 "grammar.y"
+#line 1542 "grammar.y"
     {
             /* -> if(!$2) break; $3; continue;*/
@@ -4161,5 +4166,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1549 "grammar.y"
+#line 1554 "grammar.y"
     {
             /* $2 */
@@ -4182,5 +4187,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1568 "grammar.y"
+#line 1573 "grammar.y"
     {
             idhdl h = enterid((yyvsp[(2) - (3)].name),myynest,PROC_CMD,&IDROOT,TRUE);
@@ -4197,5 +4202,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1578 "grammar.y"
+#line 1583 "grammar.y"
     {
             idhdl h = enterid((yyvsp[(1) - (3)].name),myynest,PROC_CMD,&IDROOT,TRUE);
@@ -4221,5 +4226,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1597 "grammar.y"
+#line 1602 "grammar.y"
     {
             omFree((ADDRESS)(yyvsp[(3) - (4)].name));
@@ -4246,5 +4251,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1620 "grammar.y"
+#line 1625 "grammar.y"
     {
             // decl. of type proc p(int i)
@@ -4257,5 +4262,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1626 "grammar.y"
+#line 1631 "grammar.y"
     {
             // decl. of type proc p(i)
@@ -4271,5 +4276,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1638 "grammar.y"
+#line 1643 "grammar.y"
     {
             iiRETURNEXPR.Copy(&(yyvsp[(3) - (4)].lv));
@@ -4282,5 +4287,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 1644 "grammar.y"
+#line 1649 "grammar.y"
     {
             if ((yyvsp[(1) - (3)].i)==RETURN)
@@ -4296,5 +4301,5 @@
 
 /* Line 1464 of yacc.c  */
-#line 4297 "grammar.cc"
+#line 4302 "grammar.cc"
       default: break;
     }
Index: Singular/grammar.y
===================================================================
--- Singular/grammar.y	(revision b1645e52df1f9ba737d354f5a3f4bebff0aac7cd)
+++ Singular/grammar.y	(revision f4f4033f0b5880920c8e4bfa1a3ab7c2f9e749b8)
@@ -877,8 +877,13 @@
         | NOT expr
           {
-            memset(&$$,0,sizeof($$));
-            int i; TESTSETINT($2,i);
-            $$.rtyp  = INT_CMD;
-            $$.data = (void *)(long)(i == 0 ? 1 : 0);
+            if (siq>0)
+            { if (iiExprArith1(&$$,&$2,NOT)) YYERROR; }
+	    else
+	    {
+              memset(&$$,0,sizeof($$));
+              int i; TESTSETINT($2,i);
+              $$.rtyp  = INT_CMD;
+              $$.data = (void *)(long)(i == 0 ? 1 : 0);
+	    }
           }
         | '-' expr %prec UMINUS
Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision b1645e52df1f9ba737d354f5a3f4bebff0aac7cd)
+++ Singular/iparith.cc	(revision f4f4033f0b5880920c8e4bfa1a3ab7c2f9e749b8)
@@ -4602,4 +4602,9 @@
 {
   res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
+  return FALSE;
+}
+static BOOLEAN jjNOT(leftv res, leftv v)
+{
+  res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
   return FALSE;
 }
Index: Singular/table.h
===================================================================
--- Singular/table.h	(revision b1645e52df1f9ba737d354f5a3f4bebff0aac7cd)
+++ Singular/table.h	(revision f4f4033f0b5880920c8e4bfa1a3ab7c2f9e749b8)
@@ -176,4 +176,5 @@
 ,{D(jjNAMES),      NAMES_CMD,       LIST_CMD,       RING_CMD      , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjNAMES),      NAMES_CMD,       LIST_CMD,       QRING_CMD     , ALLOW_PLURAL |ALLOW_RING}
+,{D(jjNOT),        NOT,             INT_CMD,        INT_CMD       , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjDUMMY),      NUMBER_CMD,      NUMBER_CMD,     NUMBER_CMD    , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjP2N),        NUMBER_CMD,      NUMBER_CMD,     POLY_CMD      , ALLOW_PLURAL |ALLOW_RING}
