src/HOL/Imperative_HOL/Heap_Monad.thy
changeset 43324 2b47822868e4
parent 43080 73a1d6a7ef1d
child 44174 d1d79f0e1ea6
equal deleted inserted replaced
43323:28e71a685c84 43324:2b47822868e4
   616 let
   616 let
   617 
   617 
   618 open Code_Thingol;
   618 open Code_Thingol;
   619 
   619 
   620 fun imp_program naming =
   620 fun imp_program naming =
   621 
       
   622   let
   621   let
   623     fun is_const c = case lookup_const naming c
   622     fun is_const c = case lookup_const naming c
   624      of SOME c' => (fn c'' => c' = c'')
   623      of SOME c' => (fn c'' => c' = c'')
   625       | NONE => K false;
   624       | NONE => K false;
   626     val is_bind = is_const @{const_name bind};
   625     val is_bind = is_const @{const_name bind};
   633       | NONE => error ("Must include " ^ @{const_name Unity} ^ " in generated constants.");
   632       | NONE => error ("Must include " ^ @{const_name Unity} ^ " in generated constants.");
   634     fun dest_abs ((v, ty) `|=> t, _) = ((v, ty), t)
   633     fun dest_abs ((v, ty) `|=> t, _) = ((v, ty), t)
   635       | dest_abs (t, ty) =
   634       | dest_abs (t, ty) =
   636           let
   635           let
   637             val vs = fold_varnames cons t [];
   636             val vs = fold_varnames cons t [];
   638             val v = Name.variant vs "x";
   637             val v = singleton (Name.variant_list vs) "x";
   639             val ty' = (hd o fst o unfold_fun) ty;
   638             val ty' = (hd o fst o unfold_fun) ty;
   640           in ((SOME v, ty'), t `$ IVar (SOME v)) end;
   639           in ((SOME v, ty'), t `$ IVar (SOME v)) end;
   641     fun force (t as IConst (c, _) `$ t') = if is_return c
   640     fun force (t as IConst (c, _) `$ t') = if is_return c
   642           then t' else t `$ unitt
   641           then t' else t `$ unitt
   643       | force t = t `$ unitt;
   642       | force t = t `$ unitt;