Index: Singular/LIB/mathml.lib
===================================================================
--- Singular/LIB/mathml.lib	(revision ab10dbaf1bf66c6665fbaa245abc9604e631999b)
+++ Singular/LIB/mathml.lib	(revision ab10dbaf1bf66c6665fbaa245abc9604e631999b)
@@ -0,0 +1,813 @@
+///////////////////////////////////////////////////////////////////////////////
+version="version mathml.lib 4.0.2.0 Sep_2015"; // $Id$
+category="Miscellaneous";
+info="
+LIBRARY:  mathml.lib    printing mathml code
+
+AUTHORS:  J. Boehm, boehm @ mathematik.uni-kl.de
+          M. Mueller, mkmuelle @ mathematik.uni-kl.de
+          H. Rombach, HRombach @ gmx.de
+          M. Stein, maxstein77 @ web.de
+
+OVERVIEW:
+
+mathml conversion
+
+KEYWORDS:
+mathml
+
+
+
+PROCEDURES:
+mathml(def)                general procedure to generate a mathml code from a Singular object
+viewMathml(string)         view mathml code
+";
+
+LIB "matrix.lib";
+
+
+
+/*********************************************************
+**							**
+**			  TOOLs				**
+**							**
+*********************************************************/
+
+static proc mathmlStringReplace(string s,string dummy,string origin)"USAGE: texStringReplace(s); where s is a string
+ASSUME: s is a string
+RETURN:	s including origin instead of dummy
+THEORY: if s contains dummy, these parts will be replaced by origin
+"{
+	int k,L;
+	string S;
+	S = s;
+	while(find(S,dummy)>0){
+		k = find(S,dummy);
+		L = size(dummy);
+		if(k+L<=size(S)){		
+			S = S[1,k-1] + origin +  S[k+L..size(S)];
+		}
+		else{S = S[1,k-1] + origin;}
+	}
+
+return(S);
+}
+
+
+proc mathmlRingType(){
+	string S 	= charstr(basering);
+	int i		= find(S,",");
+        int n;
+	if(i>0){S = S[1,i-1];}
+	if(S=="real" || S =="complex"){return(0)}
+	else{ if (npars(basering)>0) {
+                  n=ringlist(basering)[1][1];
+                  if (n!=0 && prime(n)!=n) {return(2);}
+                  else {return(1);}}
+              else {return(1);}
+             }
+}
+
+
+/*********************************************************
+**							**
+**			  POLY				**
+**							**
+*********************************************************/
+
+
+proc mathmlLeadCoef(string s) {
+string t;
+int i=1;
+int u=0;
+if (s=="1"){return(t);}
+if (s=="-1"){return("<mo>-</mo>");}
+ while (i<size(s)) {
+   if (s[i]=="/")  {u=1;
+                    i=size(s);} 
+   i=i+1;
+  }
+i=1;
+if (u==1) {
+   if (s[1]=="-") {
+   t="<mo>-</mo>";
+   i=2;}
+   t=t+"<mfrac> <mn>";
+ while (i<=size(s)) {
+    if (s[i]=="/") {t=t+"</mn> <mn>";} 
+    else           {t=t+s[i];}
+    i=i+1;
+    }
+   t=t+"</mn> </mfrac>";
+  }
+if (u==0) {
+  if (s[1]=="-") {t=t+"<mo>-</mo>";s=s[2,size(s)-1];}
+  t=t+"<mn>"+s+"</mn>";}
+return(t);
+}  
+
+proc mathmlVariablesEncoding(string s)  {
+string S;
+int p;
+ if(s[size(s)]==")"){
+			p = find(s,"(");
+			S = S + "<msub><mi>"+s[1,p-1] + "</mi><mn>" + s[p+1,size(s)-p-1]+ "</mn></msub>";
+		}
+  else{   
+        if (size(s)>1)  { 
+                  S = S + "<msub><mi>"+s[1] + "</mi><mn>" + s[2,size(s)-1]+ "</mn></msub>";}
+        else         {S="<mi>"+s+"</mi>";}
+      }
+return(S);
+}
+
+proc mathmlMonomial(poly a) {
+string g;
+intvec d=leadexp(a);
+list e;
+for(int q=1;q<=size(variables(a));q++)  {
+e[q]=variables(a)[q];
+}
+int k=1;
+for(int i=1;i<=size(d);i++)  {
+  if (d[i]>0) {
+  g=g+"<msup><mrow>"+mathmlVariablesEncoding(string(e[k]))+"</mrow><mn>";
+  if (d[i]>1) {g=g+string(d[i]);}
+  g=g+"</mn></msup>";
+  k=k+1;}
+  }   
+return(g);
+}
+
+proc mathmlHilf1(poly a,def r) {
+poly d=a;
+list l1=ringlist(r);
+list l12=ringlist(r);
+  for(int i=1;i<=size(l12[1][2]);i++) {
+   l12[2][i]=l12[1][2][i]+"1";
+   l12[1][2][i]=l12[1][2][i]+"0";
+   }
+  def w=ring(l12);
+  setring(w);
+ poly f=fetch(r,d);
+ list l12=ringlist(basering);
+  for (i=1;i<=size(l12[1][2]);i++) {
+   f=subst(f,par(i),var(i));
+   }
+  while (size(l12[2])>size(l12[1][2])) {
+   l12[2]=delete(l12[2],size(l12[1][2])+1);
+   }
+  for (i=1;i<=size(l12[2]);i++) {
+   l12[2][i]=l12[2][i][1,size(l12[2][i])-1];
+   }
+ l12[1]=l12[1][1];
+ def w2=ring(l12);
+ setring(w2);
+ keepring(w2);
+ poly f=fetch(w,f);
+ return(f);
+}
+
+proc mathmlHilf(poly a,def r) {
+ string g;
+ def f=mathmlHilf1(a,r);
+ g=g+mathmlPoly(f,basering);
+ return(g);
+}
+
+proc SignumLeadcoef(poly a) {
+int n=0;
+def f=mathmlHilf1(a,basering);
+if (string(leadcoef(f))[1,1]=="-") {
+ n=1;
+ }
+return(n);
+}
+
+proc mathmlPolyGAL(poly p){
+	string S;
+	for(int i = 1;i<size(p);i++){
+		S = S + mathmlTermGAL(p[i]);
+           if (string(leadcoef(p[i+1]))!="-1") {S=S+"<mo>+</mo>";}
+	}
+	S = S+ mathmlTermGAL(p[i]);
+return(S);
+}
+
+proc mathmlTermGAL(poly p){
+	int b = 0;
+	int B = 0;	
+	string S,S1,C,Pname;
+	Pname = ringlist(basering)[1][2][1];
+	C = string(leadcoef(p));
+	
+	C = mathmlStringReplace(C,Pname,"");
+        C = mathmlStringReplace(C,"^","");
+        if (p==-1 || p==1 || p==0) {return("<mn>"+string(p)+"</mn>");}
+         else {
+           if (C=="-1") {S=S+"<mo>-</mo>";}
+           else { 
+             if (C!="1") {S =S+ "<msup><mi>"+Pname+"</mi><mn>"+C +"</mi></msup>";}
+              }
+          S=S+mathmlMonomial(leadmonom(p));
+       return(S);
+ }
+}
+
+
+
+
+proc mathmlPolyR(poly a) {
+      string S;
+  
+      def origin = basering;
+   
+      if(npars(origin) == 0){
+		list l 		= ringlist(basering);
+		l[1][3] 	= "parTMP";
+		def ringCOMPLEX	= ring(l);
+		setring ringCOMPLEX;
+		poly a = fetch(origin,a);
+	}
+    string S1;
+    string S2;
+    poly d;
+    string s;
+
+  for (int i=1;i<=size(a);i++) {
+     S2="";
+     d=a[i];
+     s=string(leadcoef(d));
+     if (s[1]=="-" || s[2]=="-") {S=S+"<mo>-</mo>";d=-1*d;}
+     else                        {S=S+"<mo>+</mo>";}
+     S1=mathmlMonomial(leadmonom(d));
+      if (leadcoef(d)==1) {
+       if (S1=="") {S=S+"<mn>1</mn>";} 
+   }
+    else {
+        s=string(leadcoef(d));
+        S2=mathmlStringReplace(s,"*1)",")");
+        S2=mathmlStringReplace(S2,"*","");
+        if (npars(basering)==1) {
+            if (find(S2,string(par(1)))>0) {
+              S2=mathmlStringReplace(S2,string(par(1)),"");
+              if (size(S2)>0) {S2=S2[1,size(S2)-1]+string(par(1))+")";}
+              else {S2=string(par(1));}
+            }
+        }
+     }
+   S=S+S2+S1;
+ }
+  if (S[1,10]=="<mo>+</mo>") {S=S[11..size(S)];}
+  return(S);
+}
+
+proc mathmlPolyN(poly a,def r){
+string g;
+number d=leadcoef(a);
+list l12=ringlist(r);
+int n=npars(basering);
+
+ if (n>0) { 
+    if (SignumLeadcoef(numerator(d))) {
+           g=g+"<mo>-</mo>";
+           d=-d;
+           }
+    if (d!=1) {
+              if (denominator(d)==1) {
+                def f=mathmlHilf1(d,r);
+                 if (leadexp(f)==0) {setring r;
+                                    g=g+mathmlHilf(d,r);}
+                 else               {setring r;
+                                    g=g+"<mi>(</mi>"+mathmlHilf(d,r)+"<mi>)</mi>";}
+                    }
+              else {g=g+"<mfrac><mrow>"+mathmlHilf(numerator(d),r)+"</mrow><mrow>"+mathmlHilf(denominator(d),r)+"</mrow></mfrac>";}
+            }
+          }
+else {
+ g=g+mathmlLeadCoef(string(leadcoef(a)));
+ }
+setring(r);
+if (a==1 || a==-1) {g=g+"<mn>1</mn>";}
+
+g=g+mathmlMonomial(leadmonom(a));
+a=a-lead(a);
+if (a!=0) {
+ if (n==0) {if (poly(leadcoef(a))>0) {g=g+"<mo>+</mo>";}}
+ else      {if (SignumLeadcoef(numerator(leadcoef(a)))==0) {g=g+"<mo>+</mo>";}}
+  g=g+mathmlPolyN(a,r);
+ } 
+return(g);
+}
+
+proc mathmlPoly(poly d)  {
+string g="<math xmlns=http://www.w3.org/1998/Math/MathML>";
+if (mathmlRingType()==0) {g=g+mathmlPolyR(d);}
+if (mathmlRingType()==2) {g=g+mathmlPolyGAL(d);}
+if (mathmlRingType()==1) {g=g+mathmlPolyN(d,basering);}
+g=g+"</math>";
+return(g);
+}
+
+
+
+
+
+example
+{ "EXAMPLE:"; echo=2;
+        string h;
+	ring r = (0,a),(x1,x2),dp;
+	h=h+mathmlPoly(x1+a2)+"<br>";
+	h=h+mathmlPoly(x1*x2^3)+"<br>";
+        ring r=(0,a,b),(x(1..2)),lp;
+        poly z=(3*a^2-12*b)*x(1)^2*x(2)+(3*a^3-1)*x(2)+x(1)^2-3/5*x(1)+1;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=(0,a),(x,y),lp;
+        poly z=(15*a^3+11*a-2)/(7*a^2+2)*x^2*y^3+13/7*x;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=(13,s(1..2)),(y(1..2)),lp;
+        poly z=(2*s(1)^4)*y(1)^3*y(2)-s(1)*s(2)*y(2)^4+(11*s(1)^3-2*s(2)^2+11*s(1)*s(2))*y(1)^2-s(2)*y(2)-3*y(2)+4;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=(11,y(1..2)),(x(1..3)),lp;
+        poly z=2*x(1)^3*x(3)-(2/(y(1)^2*y(2)^2+3))*x(2)^2;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=integer,(v,x,y),lp;
+        poly z=15*v^2*x^2*y^2-11*x*y;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=(3^4,a),x,lp;
+        poly z=a59*x2+a41;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=real,(x,y),lp;
+        poly z=3.334*x^2*y^3-4*y^2;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=(real,15,a),(x(1..4)),lp;
+        poly z=(5.2+11.11*a)*x(1)*x(4)^4-(2.333+1.344*a)*x(2);
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=complex,x,dp;
+        poly z=(3.4-3.5*i)*x^5+(11.4*i)*x^4-3.552*x^3+1;
+        h=h+mathmlPoly(z)+"<br>";
+        ring r=(complex,a),(ba,bb,bc),dp;
+        poly z=(3.4-11*a)*ba^2*bb^2+4.555*ba^3;
+        h=h+mathmlPoly(z);
+        viewMathml(h);
+
+}
+
+
+/*********************************************************
+**							**
+**			ring				**
+**							**
+*********************************************************/
+
+proc mathmlRing(def r)
+"USAGE:  texRing(r); where r is a ring
+ASSUME:  r is a ring
+RETURN:  lateX-code for the ring r
+THEORY:        
+KEYWORDS: ring, lateX, teX, tex, latex
+EXAMPLE:  example texRing; shows an example
+"
+{       setring r;
+	list l,l1,l2;
+	l 	= ringlist(r);
+        l2      = ringlist(r)[2];
+
+	string c,p,P,V,C,S,h;
+	
+	int i,b;
+	int bchar;
+        
+
+        list l3=l;
+        l3[4]=ideal(0);
+        def w=ring(l3);
+        setring w;
+        list l=fetch(r,l);
+        setring r;
+	
+      	
+	//characteristic
+	c  = charstr(r); 		
+	bchar = 0;
+	if(find(c,",") != 0){
+		c 	= c[1,find(c,",")-1];
+		b = 0;
+		if(typeof(l[1][2][1]) != "string" && b==0&& c =="integer"){bchar= 1;b = 1;}	
+		if(typeof(l[1][2][1]) != "string" && b==0){bchar  = 2;b=1;}
+		if(b==0){  if (mathmlRingType()==2) {bchar = 4;}
+                           else {bchar=3;} 
+                        }        
+	}	
+	
+	//minimalpolynom
+	p = string(minpoly);
+	
+
+
+
+	//parameters
+	if(bchar==3){
+		if(p != "0"){P=P+"[";}						
+		else{P=P+"(";}
+			for(i=1;i<size(l[1][2]);i++){
+				P = P + mathmlVariablesEncoding(string(l[1][2][i])) +",";
+			}
+			P=P+mathmlVariablesEncoding(string(l[1][2][size(l[1][2])]));
+		if(p != "0"){
+                        l3[1][4]=ideal(0);
+                        w=ring(l3);
+                        setring(w);
+                        list l=fetch(r,l);
+                        poly h1=l[1][4][1];
+                         if (SignumLeadcoef(h1)==1)  {h1=-h1;}
+                        h=mathmlPoly(h1);
+                        h=h[48..size(h)-7];
+                         if (h[1,10]=="<mi>(</mi>") {h=h[11..size(h)-10];}
+                        P=P + "]/{"+h+"}";
+                        setring(r);
+                       }
+		else{P=P+")";}
+	}
+
+
+	//variables
+	V = V + "[";
+	for(i = 1;i<size(l2);i++){
+		V = V + mathmlVariablesEncoding((string(l2[i]))) + ",";	
+	}
+	V = V + mathmlVariablesEncoding((string(l2[size(l2)])));
+	V = V + "]";
+
+	b = 0;
+	if(c == "integer" && b == 0){
+		if(bchar==1){							//Z/(p^k)
+			if(string(l[1][2][2])!="1"){
+			C=C+"<msub><mrow><mn>&integers;</mn></mrow><mrow><msup><mrow>"+string(l[1][2][1])+"</mrow><mrow>"+string(l[1][2][2])+"<mrow></msup></mrow></msub>";
+			}
+			else{C=C+"<msub><mn>&integers;</mn>"+"<mn>"+string(l[1][2][1])+"</mn></msub>";}
+			b = 1;
+		}
+		else{C = C + "<mn>&integers;</mn>";b=1;} 				//Z
+	}
+	if(c == "0" && b == 0){C = C + "<mn>&rationals;</mn>";b=1;}			//Q
+	if(c == "real" && b == 0){C = C + "<mn>&reals;</mn>";b=1;}			//R
+	if(c == "complex" && b == 0){
+		b=1;
+		if(typeof(l[1][3]) != "none"){
+			if(l[1][3]!="i"){C = C + "<mn>&reals;</mn>("+l[1][3]+")";}	//R(j)
+			else{C = C + "<mn>&complexes;</mn>";}
+		}
+		else{C = C + "<mn>&complexes;</mn";}					   //C
+	}
+	if(b == 0){ if (bchar==4) {C = C + "<msub><mn>F</mn>"+c+"</msub>";}                //F/p
+                    else          {C = C + "<msub><mn>&integers;</mn>"+c+"</msub>";b=1;}   //Z/p
+	
+	           }
+	//epic conclusion
+	if(size(P)!=0){S = S + C+P+V;}
+	else{S=S+C+V;}
+	
+       if (l[4]!=0) { 
+          setring w;
+           
+          S=S+"<mo>/</mo><mo>(</mo>";
+            for(int k=1;k<=size(l[4]);k++) {
+             h=mathmlPoly(l[4][k]);
+             h=h[48..size(h)-7];
+             S=S+h+"<mo>,</mo>";
+             }
+          S=S[1,size(S)-10]+"<mo>)</mo>";
+        }
+        
+	S = "<math xmlns=http://www.w3.org/1998/Math/MathML>" + S + "</math>";
+return(S);
+}
+
+
+example
+{ "EXAMPLE:"; echo=2;
+        string h;
+	ring r = 32003,(x,y,z),dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r = 32003,(x(1..10)),dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r = 0,(a,b,c,d),lp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =7,(x,y,z),ds;
+	h=h+mathmlRing(r)+"<br>";
+	ring r = 7,(x(1..6)),(lp(3),dp);
+	h=h+mathmlRing(r)+"<br>";
+	ring r =0,(x,y,z),(c,wp(2,1,3));
+	h=h+mathmlRing(r)+"<br>";
+	ring r =(7,a,b,c),(x,y,z),Dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =(7,a),(x,y,z),dp; minpoly = a^2+a+3;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =real,(x,y,z),dp;
+	h=h+mathmlRing(r)+"<br>";
+        ring r =(real,50),(x,y,z),dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =(real,10,50),(x,y,z),dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r = (complex,30,j),(x,y,z),dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =complex,(x,y,z),dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =7,(x,y,z), dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =integer,(x,y,z), dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =(integer, 6, 3),(x,y,z), dp;
+	h=h+mathmlRing(r)+"<br>";
+	ring r =(integer, 100),(x,y,z), dp;
+	h=h+mathmlRing(r)+"<br>";
+        ring r=(121,a),x,lp;
+        h=h+mathmlRing(r);
+        viewMathml(h);
+}
+
+
+
+/*********************************************************
+**							**
+**			map				**
+**							**
+*********************************************************/
+
+
+proc mathmlMap(map f, list #)"USAGE:  texMap(f, #); #[1] source XOR texMap(f),if source == target
+ASSUME:  f is a map, #[1] ring or empty
+RETURN:  lateX-code for the map f
+THEORY:        
+KEYWORDS: map, lateX, teX, tex, latex
+EXAMPLE:  example texMap; shows an example
+"
+{	
+	
+	// f: s--->r (rings) || f:s1--->s2 (string)
+	string s1,s2;
+        string h1,h2;
+	string T,S; //variables, output string 
+	s2 = mathmlRing(basering);
+	s2 = s2[48,size(s2)-54];
+	int B = 0;
+	int b = 0;
+	if(nameof(basering)==nameof(preimage(f))){b=1;}
+	
+	def r = basering;
+	if(size(#)!=0){
+		if(typeof(#[1]) != "ring"){return("ERROR - wrong input. check texMap documentation." );}
+		def 	s;
+			s = #[1];
+		setring s;
+		s1	= mathmlRing(s);
+		s1 	= s1[48,size(s1)-54];	
+		list l1;		
+		for(int k=1;k<=nvars(s);k++){
+			l1[k] = mathmlVariablesEncoding(string(var(k)));
+		}
+		
+		setring r;
+		for(int i = 1;i<=nvars(s);i++){
+                        h1=mathmlPoly(f[i]);
+                        h2=h1[48,size(h1)-54];
+			T =T+ "<mtr><mtd>"+l1[i]+"</mtd><mtd>"+"<mo>&mapsto;</mo>"+"</mtd><mtd>"+h2+"</mtd></mtr>";
+		}
+	}
+	else{
+		if(b==1){
+			mathmlMap(f,basering);
+			return();
+		}
+		else{
+			s1 = "'"+nameof(preimage(f))+"'";
+			print("For detailed information we need the source");
+			B = 1;
+		}
+
+	}
+	S = "<mtr><mtd>"+s1+"</mtd><mtd>" + "<mo>&rightarrow;</mo>" +"</mtd><mtd>"+ s2+"</mtd></mtr>"+T;
+	S = "<math xmlns=http://www.w3.org/1998/Math/MathML><mtable>" + S + "</mtable></math>";
+	
+	return(S);
+}
+example
+{ "EXAMPLE:"; echo=2;
+        string h;
+	ring U 	= 0,(x,y,z),lp;
+	ring M2 = real,(z(1..3)),lp;
+	setring M2;
+	map f	= U,z(1)*z(2)^3,z(1),-z(2);
+	h=h+mathmlMap(f)+"<br>";
+	//2nd
+	h=h+mathmlMap(f,U)+"<br>";
+	//3rd
+	ring R = real,(x,y,z),lp;
+	map f2 = R,x2,y2,z-x;
+	h=h+string(mathmlMap(f2));
+        viewMathml(h);}
+
+
+
+
+
+
+
+
+/*********************************************************
+**							**
+**			IDEAL				**
+**							**
+*********************************************************/
+proc mathmlIdeal(ideal I)"USAGE: texIdeal(I), where I is an ideal
+ASSUME:  I is an ideal
+RETURN:  lateX-code for the ideal I
+THEORY: 
+KEYWORDS: ideal, lateX, teX, tex, latex
+EXAMPLE:  example texIdeal; shows an example
+"{
+	string S = "";
+	for(int i = 1;i<size(I);i++){
+		S = S + mathmlPoly(I[i],"no$") + ",";
+	}
+	S = S + mathmlPoly(I[size(I)],"no$");
+	S = "<math xmlns=http://www.w3.org/1998/Math/MathML><mo>&lang;</mo>" + S + "<mo>&rang;</mo></math>";
+	return(S);
+}
+example
+{"EXAMPLE: "; echo=2;
+	ring r = 0,(x,y,z),dp;
+	ideal I = x2,y3,z;
+	viewMathml(mathmlIdeal(I));
+}
+
+
+
+/*********************************************************
+**							**
+**			LIST				**
+**							**
+*********************************************************/
+proc mathmlList(list l)"USAGE: texList(l), where l is a list
+ASSUME:  l is a list
+RETURN:  lateX-code for the list l
+THEORY: 
+KEYWORDS: list, lateX, teX, tex, latex
+EXAMPLE:  example texList; shows an example
+"{
+	string tmp;
+	string S = "";
+	for(int i=1;i<size(l);i++){
+		tmp = mathml(l[i]);	
+		tmp = tmp[48,size(tmp)-54];
+		//S = S + tex(l[i]) + ";";
+		S = S + tmp + ";";	
+	}
+	//tmp = tex(l[size(l)]);	
+	tmp = mathml(l[size(l)]);
+	tmp = tmp[48,size(tmp)-54];
+	//S = S + tex(l[size(l)]);
+	S = S + tmp;	
+	S = "<math xmlns=http://www.w3.org/1998/Math/MathML><mo>{</mo>" + S + "<mo>}</mo></math>";;
+	return(S);
+}
+example
+{"EXAMPLE:"; echo=2;
+        string h;
+	//int	
+	ring r = integer,(x,y,z),dp;
+	list l = 1,2,3;
+	h=h+mathmlList(l)+"<br>";
+	//ring	
+	ring r2 = real,(a,b,c),dp;
+	ring r3 = complex,(x(1..3)),dp;
+	list l2 = r,r2,r3;
+	h=h+mathmlList(l2)+"<br>";
+	//matrix
+	setring r;
+	matrix m1[2][2]=x2y,-xz3,0,17x3z2;
+	matrix m2[2][2]=1,2,3,4;
+	list l3 = m1,m2;
+	h=h+mathmlList(l3);
+	//poly
+	poly p  = x2-1;
+	poly p2 = x3-y+z;
+	poly p3 = y3-z7;
+	list l4 = p,p2,p3;
+	//mathmlList(l4);
+        viewMathml(h);
+}
+
+
+
+/*********************************************************
+**							**
+**			BIGINT,INT			**
+**							**
+*********************************************************/
+proc mathmlBigInt (bigint I){
+	return("<math xmlns=http://www.w3.org/1998/Math/MathML>"+string(I)+"</math>");
+}
+
+proc mathmlInt(int I){
+	return(mathmlBigInt(I));
+}
+
+
+/*********************************************************
+**							**
+**			STRING				**
+**							**
+*********************************************************/
+proc mathmlString(string m){
+ return(m);
+}
+
+
+/*********************************************************
+**							**
+**			NUMBER				**
+**							**
+**requires: mathmlPoly - since there might be a parameter 	**
+*********************************************************/
+
+proc mathmlNumber(number n){
+	string S;
+	S = mathmlPoly(n);	
+return(S);
+}
+
+/*********************************************************
+**							**
+**		VECTOR, INTVEC				**
+**		INTMAT, BIGINTMAT, MATRIX		**
+**							**
+*********************************************************/
+
+proc mathmlVector(vector v){
+	int L 		= size(v);
+	matrix m[L][1]	= v;
+	string S 	= mathmlMatrix(m);
+return(S);
+}
+
+proc mathmlIntvec(intvec v){
+	matrix m = v;
+	string S = mathmlMatrix(m);
+return(S);
+}
+proc mathmlIntmat(intmat M){
+	matrix m = M;
+	string S = mathmlMatrix(m);
+return(S);
+}
+proc mathmlBigintmat(bigintmat M){
+	matrix m = M;
+	string S = mathmlMatrix(m);
+return(S);
+}
+
+
+proc mathmlMatrix(matrix m){
+ string s,h;
+ int i=1;
+ int j=1;
+ s=s+"<math xmlns=http://www.w3.org/1998/Math/MathML><mrow><mo>(</mo><mtable>";
+  while (i<=nrows(m)) {
+   j=1;
+    s=s+"<mtr>";
+    while (j<=ncols(m)) {
+      h=mathmlPoly(m[i,j]);
+      s=s+"<mtd>"+h[48,size(h)-54]+"</mtd>";
+      j=j+1;
+     }
+     s=s+"</mtr>";
+    i=i+1;
+  }
+ s=s+"</mtable><mo>)</mo></mrow></math>";
+return(s);
+}
+
+
+/*********************************************************
+**							**
+**			View			**
+**							**
+*********************************************************/
+
+
+
+proc viewMathml(string s){
+	string p = "firefox";
+	string Sstart 	= "<!doctype html><html><head><meta charset=UTF-8><title>MathML Examples</title></head><body>";
+	string Send	= "</body></html> ";
+	string S = Sstart + s + Send;	
+	write(":w singular_mathml.html", S);
+	
+	system("sh",p+" singular_mathml.html");
+}
+
+
+
+
