src/Tools/isac/calcelems.sml
changeset 55339 cccd24e959ba
parent 55335 880cce03f16e
child 55344 2a421c3a8b47
equal deleted inserted replaced
55338:6d95baca55dd 55339:cccd24e959ba
   798 
   798 
   799 val e_Ptyp = Ptyp ("e_pblID",[e_pbt],[])
   799 val e_Ptyp = Ptyp ("e_pblID",[e_pbt],[])
   800 type ptyps = (pbt ptyp) list
   800 type ptyps = (pbt ptyp) list
   801 val ptyps = Unsynchronized.ref ([e_Ptyp] : ptyps);
   801 val ptyps = Unsynchronized.ref ([e_Ptyp] : ptyps);
   802 
   802 
       
   803 
       
   804 fun insrt _ pbt [k] [] = [Ptyp (k, [pbt],[])]
       
   805   | insrt d pbt [k] ((Ptyp (k', [p], ps))::pys) =
       
   806 ((*tracing("### insert 1: ks = "^(strs2str [k])^"    k'= "^k');*)
       
   807      if k=k'
       
   808      then ((Ptyp (k', [pbt], ps))::pys)
       
   809      else (*ev.newly added pbt is free _only_ with 'last_elem pblID'*)
       
   810 	 ((Ptyp (k', [p], ps))::(insrt d pbt [k] pys))
       
   811 )			 
       
   812   | insrt d pbt (k::ks) ((Ptyp (k', [p], ps))::pys) =
       
   813 ((*tracing("### insert 2: ks = "^(strs2str (k::ks))^"    k'= "^k');*)
       
   814      if k=k'
       
   815      then ((Ptyp (k', [p], insrt d pbt ks ps))::pys)
       
   816      else 
       
   817 	 if length pys = 0
       
   818 	 then error ("insert: not found "^(strs2str (d:pblID)))
       
   819 	 else ((Ptyp (k', [p], ps))::(insrt d pbt (k::ks) pys))
       
   820 );
       
   821 
       
   822 (* this function only works wrt. the way Isabelle evaluates Theories and is not a general merge
       
   823   function for trees / ptyps *)
       
   824 fun merge_ptyps ([], pt) = pt
       
   825   | merge_ptyps (pt, []) = pt
       
   826   | merge_ptyps ((Ptyp (k, x, ps)::xs), (ys' as Ptyp (k', y, ps')::ys)) =
       
   827       if k = k' then
       
   828         (Ptyp (k, y, merge_ptyps (ps, ps')) :: merge_ptyps (xs, ys)) else
       
   829         (Ptyp (k, x, ps) :: merge_ptyps (xs, ys'));
       
   830 
   803 (* types for methods *)
   831 (* types for methods *)
   804 
   832 
   805 
   833 
   806 (*
   834 (*
   807 end (*struct*)
   835 end (*struct*)