src/Tools/isac/Knowledge/Rational.thy
branchisac-update-Isa09-2
changeset 38034 928cebc9c4aa
parent 38031 460c24a6a6ba
child 38036 02a9b2540eb7
equal deleted inserted replaced
38033:491b133d154a 38034:928cebc9c4aa
  1320 
  1320 
  1321 (*. help function for is_polynomial  
  1321 (*. help function for is_polynomial  
  1322     checks the order of the operators .*)
  1322     checks the order of the operators .*)
  1323 fun test_polynomial (Const ("uminus",_) $ Free (str,_)) _ = true (*WN.13.3.03*)
  1323 fun test_polynomial (Const ("uminus",_) $ Free (str,_)) _ = true (*WN.13.3.03*)
  1324   | test_polynomial (t as Free(str,_)) v = true
  1324   | test_polynomial (t as Free(str,_)) v = true
  1325   | test_polynomial (t as Const ("op *",_) $ t1 $ t2) v = if v="^" then false
  1325   | test_polynomial (t as Const ("Groups.times_class.times",_) $ t1 $ t2) v = if v="^" then false
  1326 						     else (test_polynomial t1 "*") andalso (test_polynomial t2 "*")
  1326 						     else (test_polynomial t1 "*") andalso (test_polynomial t2 "*")
  1327   | test_polynomial (t as Const ("Groups.plus_class.plus",_) $ t1 $ t2) v = if v="*" orelse v="^" then false 
  1327   | test_polynomial (t as Const ("Groups.plus_class.plus",_) $ t1 $ t2) v = if v="*" orelse v="^" then false 
  1328 							  else (test_polynomial t1 " ") andalso (test_polynomial t2 " ")
  1328 							  else (test_polynomial t1 " ") andalso (test_polynomial t2 " ")
  1329   | test_polynomial (t as Const ("Atools.pow",_) $ t1 $ t2) v = (test_polynomial t1 "^") andalso (test_polynomial t2 "^")
  1329   | test_polynomial (t as Const ("Atools.pow",_) $ t1 $ t2) v = (test_polynomial t1 "^") andalso (test_polynomial t2 "^")
  1330   | test_polynomial _ v = false;  
  1330   | test_polynomial _ v = false;  
  1333 fun is_polynomial t = test_polynomial t " ";
  1333 fun is_polynomial t = test_polynomial t " ";
  1334 
  1334 
  1335 (*. help function for is_expanded 
  1335 (*. help function for is_expanded 
  1336     checks the order of the operators .*)
  1336     checks the order of the operators .*)
  1337 fun test_exp (t as Free(str,_)) v = true 
  1337 fun test_exp (t as Free(str,_)) v = true 
  1338   | test_exp (t as Const ("op *",_) $ t1 $ t2) v = if v="^" then false
  1338   | test_exp (t as Const ("Groups.times_class.times",_) $ t1 $ t2) v = if v="^" then false
  1339 						     else (test_exp t1 "*") andalso (test_exp t2 "*")
  1339 						     else (test_exp t1 "*") andalso (test_exp t2 "*")
  1340   | test_exp (t as Const ("Groups.plus_class.plus",_) $ t1 $ t2) v = if v="*" orelse v="^" then false 
  1340   | test_exp (t as Const ("Groups.plus_class.plus",_) $ t1 $ t2) v = if v="*" orelse v="^" then false 
  1341 							  else (test_exp t1 " ") andalso (test_exp t2 " ") 
  1341 							  else (test_exp t1 " ") andalso (test_exp t2 " ") 
  1342   | test_exp (t as Const ("Groups.minus_class.minus",_) $ t1 $ t2) v = if v="*" orelse v="^" then false 
  1342   | test_exp (t as Const ("Groups.minus_class.minus",_) $ t1 $ t2) v = if v="*" orelse v="^" then false 
  1343 							  else (test_exp t1 " ") andalso (test_exp t2 " ")
  1343 							  else (test_exp t1 " ") andalso (test_exp t2 " ")
  1377 		      i:=(!i)+1    
  1377 		      i:=(!i)+1    
  1378 		      );		
  1378 		      );		
  1379 		 SOME [(1,rev(!vl))] handle _ => NONE
  1379 		 SOME [(1,rev(!vl))] handle _ => NONE
  1380 	    )
  1380 	    )
  1381     end
  1381     end
  1382   | term2coef' (Const ("op *",_) $ t1 $ t2) v :mv_poly option= 
  1382   | term2coef' (Const ("Groups.times_class.times",_) $ t1 $ t2) v :mv_poly option= 
  1383     let
  1383     let
  1384 	val t1pp= Unsynchronized.ref  [];
  1384 	val t1pp= Unsynchronized.ref  [];
  1385 	val t2pp= Unsynchronized.ref  [];
  1385 	val t2pp= Unsynchronized.ref  [];
  1386 	val t1c= Unsynchronized.ref  0;
  1386 	val t1c= Unsynchronized.ref  0;
  1387 	val t2c= Unsynchronized.ref  0;
  1387 	val t2c= Unsynchronized.ref  0;
  1490 		      i:=(!i)+1    
  1490 		      i:=(!i)+1    
  1491 		      );		
  1491 		      );		
  1492 		 SOME [(1,rev(!vl))] handle _ => NONE
  1492 		 SOME [(1,rev(!vl))] handle _ => NONE
  1493 	    )
  1493 	    )
  1494     end
  1494     end
  1495   | term2poly' (Const ("op *",_) $ t1 $ t2) v :mv_poly option= 
  1495   | term2poly' (Const ("Groups.times_class.times",_) $ t1 $ t2) v :mv_poly option= 
  1496     let
  1496     let
  1497 	val t1pp= Unsynchronized.ref  [];
  1497 	val t1pp= Unsynchronized.ref  [];
  1498 	val t2pp= Unsynchronized.ref  [];
  1498 	val t2pp= Unsynchronized.ref  [];
  1499 	val t1c= Unsynchronized.ref  0;
  1499 	val t1c= Unsynchronized.ref  0;
  1500 	val t2c= Unsynchronized.ref  0;
  1500 	val t2c= Unsynchronized.ref  0;
  1601 	      )
  1601 	      )
  1602 	 else
  1602 	 else
  1603 	     (
  1603 	     (
  1604 	      if hd(!xss)=1 then 
  1604 	      if hd(!xss)=1 then 
  1605 		  ( 
  1605 		  ( 
  1606 		   Const("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1606 		   Const("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1607 		   Free(hd(!vv), HOLogic.realT) $
  1607 		   Free(hd(!vv), HOLogic.realT) $
  1608 		   powerproduct2term(tl(!xss),tl(!vv))
  1608 		   powerproduct2term(tl(!xss),tl(!vv))
  1609 		   )
  1609 		   )
  1610 	      else
  1610 	      else
  1611 		  (
  1611 		  (
  1612 		   Const("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1612 		   Const("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1613 		   (
  1613 		   (
  1614 		    Const("Atools.pow",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1614 		    Const("Atools.pow",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1615 		    Free(hd(!vv), HOLogic.realT) $  Free(str_of_int (hd(!xss)),HOLogic.realT)
  1615 		    Free(hd(!vv), HOLogic.realT) $  Free(str_of_int (hd(!xss)),HOLogic.realT)
  1616 		    ) $
  1616 		    ) $
  1617 		    powerproduct2term(tl(!xss),tl(!vv))
  1617 		    powerproduct2term(tl(!xss),tl(!vv))
  1635 		  (
  1635 		  (
  1636 		   powerproduct2term(e,v)
  1636 		   powerproduct2term(e,v)
  1637 		   )
  1637 		   )
  1638 	      else
  1638 	      else
  1639 		  (
  1639 		  (
  1640 		   Const("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $
  1640 		   Const("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $
  1641 		   Free(str_of_int c,HOLogic.realT)  $
  1641 		   Free(str_of_int c,HOLogic.realT)  $
  1642 		   powerproduct2term(e,v)
  1642 		   powerproduct2term(e,v)
  1643 		   )
  1643 		   )
  1644 		  )
  1644 		  )
  1645 	     );*)
  1645 	     );*)
  1652 	then Free (str_of_int i, HOLogic.realT)
  1652 	then Free (str_of_int i, HOLogic.realT)
  1653 	else Const ("uminus", HOLogic.realT --> HOLogic.realT) $
  1653 	else Const ("uminus", HOLogic.realT --> HOLogic.realT) $
  1654 		   Free ((str_of_int o abs) i, HOLogic.realT)
  1654 		   Free ((str_of_int o abs) i, HOLogic.realT)
  1655     else
  1655     else
  1656 	if i > 0 
  1656 	if i > 0 
  1657 	then Const ("op *", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
  1657 	then Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
  1658 		   (Free (str_of_int i, HOLogic.realT)) $
  1658 		   (Free (str_of_int i, HOLogic.realT)) $
  1659 		   powerproduct2term(is, v)
  1659 		   powerproduct2term(is, v)
  1660 	else Const ("op *", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
  1660 	else Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
  1661 		   (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
  1661 		   (Const ("uminus", HOLogic.realT --> HOLogic.realT) $
  1662 		   Free ((str_of_int o abs) i, HOLogic.realT)) $
  1662 		   Free ((str_of_int o abs) i, HOLogic.realT)) $
  1663 		   powerproduct2term(is, vs);---------------------------*)
  1663 		   powerproduct2term(is, vs);---------------------------*)
  1664 fun monom2term ((i, is) : mv_monom, vs) = 
  1664 fun monom2term ((i, is) : mv_monom, vs) = 
  1665     if list_is_null is 
  1665     if list_is_null is 
  1666     then Free (str_of_int i, HOLogic.realT)
  1666     then Free (str_of_int i, HOLogic.realT)
  1667     else if i = 1
  1667     else if i = 1
  1668     then powerproduct2term (is, vs)
  1668     then powerproduct2term (is, vs)
  1669     else Const ("op *", [HOLogic.realT, HOLogic.realT] ---> HOLogic.realT) $
  1669     else Const ("Groups.times_class.times", [HOLogic.realT, HOLogic.realT] ---> HOLogic.realT) $
  1670 	       (Free (str_of_int i, HOLogic.realT)) $
  1670 	       (Free (str_of_int i, HOLogic.realT)) $
  1671 	       powerproduct2term (is, vs);
  1671 	       powerproduct2term (is, vs);
  1672     
  1672     
  1673 (*. converts the internal polynomial representation into an Isabelle term.*)
  1673 (*. converts the internal polynomial representation into an Isabelle term.*)
  1674 fun poly2term' ([] : mv_poly, vs) = Free(str_of_int 0, HOLogic.realT)  
  1674 fun poly2term' ([] : mv_poly, vs) = Free(str_of_int 0, HOLogic.realT)  
  1695 		  (
  1695 		  (
  1696 		   powerproduct2term(e,v)
  1696 		   powerproduct2term(e,v)
  1697 		   )
  1697 		   )
  1698 	      else
  1698 	      else
  1699 		  (
  1699 		  (
  1700 		   Const("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $
  1700 		   Const("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $
  1701 		   Free(str_of_int (abs(c)),HOLogic.realT)  $
  1701 		   Free(str_of_int (abs(c)),HOLogic.realT)  $
  1702 		   powerproduct2term(e,v)
  1702 		   powerproduct2term(e,v)
  1703 		   )
  1703 		   )
  1704 		  )
  1704 		  )
  1705 	     );
  1705 	     );
  1767 	      if #1(hd(sort (mv_geq LEX_) (!p2'))) (*mv_lc2(!p2',LEX_)*)>0 then
  1767 	      if #1(hd(sort (mv_geq LEX_) (!p2'))) (*mv_lc2(!p2',LEX_)*)>0 then
  1768 	      (
  1768 	      (
  1769 	       Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1769 	       Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1770 	       $ 
  1770 	       $ 
  1771 	       (
  1771 	       (
  1772 		Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1772 		Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1773 		poly2term(!p1',vars) $ 
  1773 		poly2term(!p1',vars) $ 
  1774 		poly2term(!p3,vars) 
  1774 		poly2term(!p3,vars) 
  1775 		) 
  1775 		) 
  1776 	       $ 
  1776 	       $ 
  1777 	       (
  1777 	       (
  1778 		Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1778 		Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1779 		poly2term(!p2',vars) $ 
  1779 		poly2term(!p2',vars) $ 
  1780 		poly2term(!p3,vars)
  1780 		poly2term(!p3,vars)
  1781 		) 	
  1781 		) 	
  1782 	       )	
  1782 	       )	
  1783 	      else
  1783 	      else
  1787 	       p3:=mv_skalar_mul(!p3,~1);
  1787 	       p3:=mv_skalar_mul(!p3,~1);
  1788 	       (
  1788 	       (
  1789 		Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1789 		Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1790 		$ 
  1790 		$ 
  1791 		(
  1791 		(
  1792 		 Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1792 		 Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1793 		 poly2term(!p1',vars) $ 
  1793 		 poly2term(!p1',vars) $ 
  1794 		 poly2term(!p3,vars) 
  1794 		 poly2term(!p3,vars) 
  1795 		 ) 
  1795 		 ) 
  1796 		$ 
  1796 		$ 
  1797 		(
  1797 		(
  1798 		 Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1798 		 Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1799 		 poly2term(!p2',vars) $ 
  1799 		 poly2term(!p2',vars) $ 
  1800 		 poly2term(!p3,vars)
  1800 		 poly2term(!p3,vars)
  1801 		 ) 	
  1801 		 ) 	
  1802 		)	
  1802 		)	
  1803 	       )	  
  1803 	       )	  
  1832 	      if #1(hd(sort (mv_geq LEX_) (!p2')))(* mv_lc2(!p2',LEX_)*)>0 then
  1832 	      if #1(hd(sort (mv_geq LEX_) (!p2')))(* mv_lc2(!p2',LEX_)*)>0 then
  1833 	      (
  1833 	      (
  1834 	       Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1834 	       Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1835 	       $ 
  1835 	       $ 
  1836 	       (
  1836 	       (
  1837 		Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1837 		Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1838 		poly2expanded(!p1',vars) $ 
  1838 		poly2expanded(!p1',vars) $ 
  1839 		poly2expanded(!p3,vars) 
  1839 		poly2expanded(!p3,vars) 
  1840 		) 
  1840 		) 
  1841 	       $ 
  1841 	       $ 
  1842 	       (
  1842 	       (
  1843 		Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1843 		Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1844 		poly2expanded(!p2',vars) $ 
  1844 		poly2expanded(!p2',vars) $ 
  1845 		poly2expanded(!p3,vars)
  1845 		poly2expanded(!p3,vars)
  1846 		) 	
  1846 		) 	
  1847 	       )	
  1847 	       )	
  1848 	      else
  1848 	      else
  1852 	       p3:=mv_skalar_mul(!p3,~1);
  1852 	       p3:=mv_skalar_mul(!p3,~1);
  1853 	       (
  1853 	       (
  1854 		Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1854 		Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  1855 		$ 
  1855 		$ 
  1856 		(
  1856 		(
  1857 		 Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1857 		 Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1858 		 poly2expanded(!p1',vars) $ 
  1858 		 poly2expanded(!p1',vars) $ 
  1859 		 poly2expanded(!p3,vars) 
  1859 		 poly2expanded(!p3,vars) 
  1860 		 ) 
  1860 		 ) 
  1861 		$ 
  1861 		$ 
  1862 		(
  1862 		(
  1863 		 Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1863 		 Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  1864 		 poly2expanded(!p2',vars) $ 
  1864 		 poly2expanded(!p2',vars) $ 
  1865 		 poly2expanded(!p3,vars)
  1865 		 poly2expanded(!p3,vars)
  1866 		 ) 	
  1866 		 ) 	
  1867 		)	
  1867 		)	
  1868 	       )	  
  1868 	       )	  
  2281 		 $ 
  2281 		 $ 
  2282 		 (
  2282 		 (
  2283 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2283 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2284 		  $ 
  2284 		  $ 
  2285 		  (
  2285 		  (
  2286 		   Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2286 		   Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2287 		   poly2term(the (term2poly p1' p1var),p1var) $ 
  2287 		   poly2term(the (term2poly p1' p1var),p1var) $ 
  2288 		   poly2term(p3,var)
  2288 		   poly2term(p3,var)
  2289 		   ) 
  2289 		   ) 
  2290 		  $ 
  2290 		  $ 
  2291 		  (
  2291 		  (
  2313 	     else
  2313 	     else
  2314 		 (
  2314 		 (
  2315 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2315 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2316 		  $ 
  2316 		  $ 
  2317 		  (
  2317 		  (
  2318 		   Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2318 		   Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2319 		   poly2term(the (term2poly p1' p1var),p1var) $ 
  2319 		   poly2term(the (term2poly p1' p1var),p1var) $ 
  2320 		   poly2term(p3,var)
  2320 		   poly2term(p3,var)
  2321 		   ) 
  2321 		   ) 
  2322 		  $ 
  2322 		  $ 
  2323 		  den 	
  2323 		  den 	
  2357 		 $ 
  2357 		 $ 
  2358 		 (
  2358 		 (
  2359 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2359 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2360 		  $ 
  2360 		  $ 
  2361 		  (
  2361 		  (
  2362 		   Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2362 		   Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2363 		   poly2expanded(the(expanded2poly p1' p1var),p1var) $ 
  2363 		   poly2expanded(the(expanded2poly p1' p1var),p1var) $ 
  2364 		   poly2expanded(p3,var)
  2364 		   poly2expanded(p3,var)
  2365 		   ) 
  2365 		   ) 
  2366 		  $ 
  2366 		  $ 
  2367 		  (
  2367 		  (
  2389 	     else
  2389 	     else
  2390 		 (
  2390 		 (
  2391 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2391 		  Const ("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) 
  2392 		  $ 
  2392 		  $ 
  2393 		  (
  2393 		  (
  2394 		   Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2394 		   Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2395 		   poly2expanded(the(expanded2poly p1' p1var),p1var) $ 
  2395 		   poly2expanded(the(expanded2poly p1' p1var),p1var) $ 
  2396 		   poly2expanded(p3,var)
  2396 		   poly2expanded(p3,var)
  2397 		   ) 
  2397 		   ) 
  2398 		  $ 
  2398 		  $ 
  2399 		  den 	
  2399 		  den 	
  2557 (*. makes a term out of the elements of the list (polynomial representation) .*)
  2557 (*. makes a term out of the elements of the list (polynomial representation) .*)
  2558 fun make_term ([],vars) = Free(str_of_int 0,HOLogic.realT) 
  2558 fun make_term ([],vars) = Free(str_of_int 0,HOLogic.realT) 
  2559   | make_term ((x::xs),vars) = if length(xs)=0 then poly2term(sort (mv_geq LEX_) (x),vars)
  2559   | make_term ((x::xs),vars) = if length(xs)=0 then poly2term(sort (mv_geq LEX_) (x),vars)
  2560 			       else
  2560 			       else
  2561 				   (
  2561 				   (
  2562 				    Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2562 				    Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2563 				    poly2term(sort (mv_geq LEX_) (x),vars) $ 
  2563 				    poly2term(sort (mv_geq LEX_) (x),vars) $ 
  2564 				    make_term(xs,vars)
  2564 				    make_term(xs,vars)
  2565 				    );
  2565 				    );
  2566 
  2566 
  2567 (*. factorizes the denominator (polynomial representation) .*)				
  2567 (*. factorizes the denominator (polynomial representation) .*)				
  2582 (*. makes a term out of the elements of the list (expanded polynomial representation) .*)
  2582 (*. makes a term out of the elements of the list (expanded polynomial representation) .*)
  2583 fun make_exp ([],vars) = Free(str_of_int 0,HOLogic.realT) 
  2583 fun make_exp ([],vars) = Free(str_of_int 0,HOLogic.realT) 
  2584   | make_exp ((x::xs),vars) = if length(xs)=0 then poly2expanded(sort (mv_geq LEX_) (x),vars)
  2584   | make_exp ((x::xs),vars) = if length(xs)=0 then poly2expanded(sort (mv_geq LEX_) (x),vars)
  2585 			       else
  2585 			       else
  2586 				   (
  2586 				   (
  2587 				    Const ("op *",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2587 				    Const ("Groups.times_class.times",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2588 				    poly2expanded(sort (mv_geq LEX_) (x),vars) $ 
  2588 				    poly2expanded(sort (mv_geq LEX_) (x),vars) $ 
  2589 				    make_exp(xs,vars)
  2589 				    make_exp(xs,vars)
  2590 				    );
  2590 				    );
  2591 
  2591 
  2592 (*. factorizes the denominator (expanded polynomial representation) .*)	
  2592 (*. factorizes the denominator (expanded polynomial representation) .*)	
  2680      ]
  2680      ]
  2681   | term2list (t as (Free(_,_))) = 
  2681   | term2list (t as (Free(_,_))) = 
  2682     [Const("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2682     [Const("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2683 	  t $  Free("1",HOLogic.realT)
  2683 	  t $  Free("1",HOLogic.realT)
  2684      ]
  2684      ]
  2685   | term2list (t as (Const("op *",_) $ _ $ _)) = 
  2685   | term2list (t as (Const("Groups.times_class.times",_) $ _ $ _)) = 
  2686     [Const("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2686     [Const("Rings.inverse_class.divide",[HOLogic.realT,HOLogic.realT]--->HOLogic.realT) $ 
  2687 	  t $ Free("1",HOLogic.realT)
  2687 	  t $ Free("1",HOLogic.realT)
  2688      ]
  2688      ]
  2689   | term2list (Const("Groups.plus_class.plus",_) $ t1 $ t2) = term2list(t1) @ term2list(t2)
  2689   | term2list (Const("Groups.plus_class.plus",_) $ t1 $ t2) = term2list(t1) @ term2list(t2)
  2690   | term2list (Const("Groups.minus_class.minus",_) $ t1 $ t2) = 
  2690   | term2list (Const("Groups.minus_class.minus",_) $ t1 $ t2) = 
  3000     Rrls {id = "cancel_p", prepat=[],
  3000     Rrls {id = "cancel_p", prepat=[],
  3001 	  rew_ord=("ord_make_polynomial",
  3001 	  rew_ord=("ord_make_polynomial",
  3002 		   ord_make_polynomial false thy),
  3002 		   ord_make_polynomial false thy),
  3003 	  erls = rational_erls,
  3003 	  erls = rational_erls,
  3004 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3004 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3005 		  ("TIMES"   ,("op *"        ,eval_binop "#mult_")),
  3005 		  ("TIMES"   ,("Groups.times_class.times"        ,eval_binop "#mult_")),
  3006 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3006 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3007 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3007 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3008 	  (*asm_thm=[("real_mult_div_cancel2","")],*)
  3008 	  (*asm_thm=[("real_mult_div_cancel2","")],*)
  3009 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3009 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3010 		     normal_form = cancel_p_ thy,
  3010 		     normal_form = cancel_p_ thy,
  3082     Rrls {id = "cancel", prepat=prepat,
  3082     Rrls {id = "cancel", prepat=prepat,
  3083 	  rew_ord=("ord_make_polynomial",
  3083 	  rew_ord=("ord_make_polynomial",
  3084 		   ord_make_polynomial false thy),
  3084 		   ord_make_polynomial false thy),
  3085 	  erls = rational_erls, 
  3085 	  erls = rational_erls, 
  3086 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3086 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3087 		  ("TIMES"   ,("op *"        ,eval_binop "#mult_")),
  3087 		  ("TIMES"   ,("Groups.times_class.times"        ,eval_binop "#mult_")),
  3088 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3088 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3089 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3089 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3090 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3090 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3091 		     normal_form = cancel_ thy, 
  3091 		     normal_form = cancel_ thy, 
  3092 		     locate_rule = locate_rule thy Atools_erls ro,
  3092 		     locate_rule = locate_rule thy Atools_erls ro,
  3234     Rrls {id = "common_nominator_p", prepat=prepat,
  3234     Rrls {id = "common_nominator_p", prepat=prepat,
  3235 	  rew_ord=("ord_make_polynomial",
  3235 	  rew_ord=("ord_make_polynomial",
  3236 		   ord_make_polynomial false thy),
  3236 		   ord_make_polynomial false thy),
  3237 	  erls = rational_erls,
  3237 	  erls = rational_erls,
  3238 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3238 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3239 		  ("TIMES"   ,("op *"        ,eval_binop "#mult_")),
  3239 		  ("TIMES"   ,("Groups.times_class.times"        ,eval_binop "#mult_")),
  3240 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3240 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3241 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3241 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3242 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3242 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3243 		     normal_form = add_fraction_p_ thy,(*FIXME.WN0211*)
  3243 		     normal_form = add_fraction_p_ thy,(*FIXME.WN0211*)
  3244 		     locate_rule = locate_rule thy Atools_erls ro,
  3244 		     locate_rule = locate_rule thy Atools_erls ro,
  3382     Rrls {id = "common_nominator", prepat=prepat,
  3382     Rrls {id = "common_nominator", prepat=prepat,
  3383 	  rew_ord=("ord_make_polynomial",
  3383 	  rew_ord=("ord_make_polynomial",
  3384 		   ord_make_polynomial false thy),
  3384 		   ord_make_polynomial false thy),
  3385 	  erls = rational_erls,
  3385 	  erls = rational_erls,
  3386 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3386 	  calc = [("PLUS"    ,("Groups.plus_class.plus"        ,eval_binop "#add_")),
  3387 		  ("TIMES"   ,("op *"        ,eval_binop "#mult_")),
  3387 		  ("TIMES"   ,("Groups.times_class.times"        ,eval_binop "#mult_")),
  3388 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3388 		  ("DIVIDE" ,("Rings.inverse_class.divide"  ,eval_cancel "#divide_e")),
  3389 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3389 		  ("POWER"  ,("Atools.pow"  ,eval_binop "#power_"))],
  3390 	  (*asm_thm=[("real_mult_div_cancel2","")],*)
  3390 	  (*asm_thm=[("real_mult_div_cancel2","")],*)
  3391 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3391 	  scr=Rfuns {init_state  = init_state thy Atools_erls ro,
  3392 		     normal_form = add_fraction_ (*NOT common_nominator_*) thy,
  3392 		     normal_form = add_fraction_ (*NOT common_nominator_*) thy,
  3402 
  3402 
  3403 (*.the expression contains + - * ^ / only ?.*)
  3403 (*.the expression contains + - * ^ / only ?.*)
  3404 fun is_ratpolyexp (Free _) = true
  3404 fun is_ratpolyexp (Free _) = true
  3405   | is_ratpolyexp (Const ("Groups.plus_class.plus",_) $ Free _ $ Free _) = true
  3405   | is_ratpolyexp (Const ("Groups.plus_class.plus",_) $ Free _ $ Free _) = true
  3406   | is_ratpolyexp (Const ("Groups.minus_class.minus",_) $ Free _ $ Free _) = true
  3406   | is_ratpolyexp (Const ("Groups.minus_class.minus",_) $ Free _ $ Free _) = true
  3407   | is_ratpolyexp (Const ("op *",_) $ Free _ $ Free _) = true
  3407   | is_ratpolyexp (Const ("Groups.times_class.times",_) $ Free _ $ Free _) = true
  3408   | is_ratpolyexp (Const ("Atools.pow",_) $ Free _ $ Free _) = true
  3408   | is_ratpolyexp (Const ("Atools.pow",_) $ Free _ $ Free _) = true
  3409   | is_ratpolyexp (Const ("Rings.inverse_class.divide",_) $ Free _ $ Free _) = true
  3409   | is_ratpolyexp (Const ("Rings.inverse_class.divide",_) $ Free _ $ Free _) = true
  3410   | is_ratpolyexp (Const ("Groups.plus_class.plus",_) $ t1 $ t2) = 
  3410   | is_ratpolyexp (Const ("Groups.plus_class.plus",_) $ t1 $ t2) = 
  3411                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3411                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3412   | is_ratpolyexp (Const ("Groups.minus_class.minus",_) $ t1 $ t2) = 
  3412   | is_ratpolyexp (Const ("Groups.minus_class.minus",_) $ t1 $ t2) = 
  3413                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3413                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3414   | is_ratpolyexp (Const ("op *",_) $ t1 $ t2) = 
  3414   | is_ratpolyexp (Const ("Groups.times_class.times",_) $ t1 $ t2) = 
  3415                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3415                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3416   | is_ratpolyexp (Const ("Atools.pow",_) $ t1 $ t2) = 
  3416   | is_ratpolyexp (Const ("Atools.pow",_) $ t1 $ t2) = 
  3417                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3417                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3418   | is_ratpolyexp (Const ("Rings.inverse_class.divide",_) $ t1 $ t2) = 
  3418   | is_ratpolyexp (Const ("Rings.inverse_class.divide",_) $ t1 $ t2) = 
  3419                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))
  3419                ((is_ratpolyexp t1) andalso (is_ratpolyexp t2))