diff -r 4dc65845eab3 -r d8d7d1b785af src/HOL/MicroJava/Comp/TranslCompTp.thy --- a/src/HOL/MicroJava/Comp/TranslCompTp.thy Wed Feb 24 11:55:52 2010 +0100 +++ b/src/HOL/MicroJava/Comp/TranslCompTp.thy Mon Mar 01 13:40:23 2010 +0100 @@ -6,17 +6,14 @@ imports Index "../BV/JVMType" begin - - (**********************************************************************) - -constdefs - comb :: "['a \ 'b list \ 'c, 'c \ 'b list \ 'd, 'a] \ 'b list \ 'd" +definition comb :: "['a \ 'b list \ 'c, 'c \ 'b list \ 'd, 'a] \ 'b list \ 'd" where "comb == (\ f1 f2 x0. let (xs1, x1) = f1 x0; (xs2, x2) = f2 x1 in (xs1 @ xs2, x2))" - comb_nil :: "'a \ 'b list \ 'a" + +definition comb_nil :: "'a \ 'b list \ 'a" where "comb_nil a == ([], a)" syntax (xsymbols) @@ -59,23 +56,26 @@ compTpStmt :: "java_mb \ java_mb prog \ stmt \ state_type \ method_type \ state_type" - -constdefs - nochangeST :: "state_type \ method_type \ state_type" +definition nochangeST :: "state_type \ method_type \ state_type" where "nochangeST sttp == ([Some sttp], sttp)" - pushST :: "[ty list, state_type] \ method_type \ state_type" + +definition pushST :: "[ty list, state_type] \ method_type \ state_type" where "pushST tps == (\ (ST, LT). ([Some (ST, LT)], (tps @ ST, LT)))" - dupST :: "state_type \ method_type \ state_type" + +definition dupST :: "state_type \ method_type \ state_type" where "dupST == (\ (ST, LT). ([Some (ST, LT)], (hd ST # ST, LT)))" - dup_x1ST :: "state_type \ method_type \ state_type" + +definition dup_x1ST :: "state_type \ method_type \ state_type" where "dup_x1ST == (\ (ST, LT). ([Some (ST, LT)], (hd ST # hd (tl ST) # hd ST # (tl (tl ST)), LT)))" - popST :: "[nat, state_type] \ method_type \ state_type" + +definition popST :: "[nat, state_type] \ method_type \ state_type" where "popST n == (\ (ST, LT). ([Some (ST, LT)], (drop n ST, LT)))" - replST :: "[nat, ty, state_type] \ method_type \ state_type" + +definition replST :: "[nat, ty, state_type] \ method_type \ state_type" where "replST n tp == (\ (ST, LT). ([Some (ST, LT)], (tp # (drop n ST), LT)))" - storeST :: "[nat, ty, state_type] \ method_type \ state_type" +definition storeST :: "[nat, ty, state_type] \ method_type \ state_type" where "storeST i tp == (\ (ST, LT). ([Some (ST, LT)], (tl ST, LT [i:= OK tp])))" @@ -138,9 +138,8 @@ (pushST [PrimT Boolean]) \ (compTpExpr jmb G e) \ popST 2 \ (compTpStmt jmb G c) \ nochangeST" -constdefs - compTpInit :: "java_mb \ (vname * ty) - \ state_type \ method_type \ state_type" +definition compTpInit :: "java_mb \ (vname * ty) + \ state_type \ method_type \ state_type" where "compTpInit jmb == (\ (vn,ty). (pushST [ty]) \ (storeST (index jmb vn) ty))" consts @@ -151,14 +150,13 @@ "compTpInitLvars jmb [] = comb_nil" "compTpInitLvars jmb (lv#lvars) = (compTpInit jmb lv) \ (compTpInitLvars jmb lvars)" -constdefs - start_ST :: "opstack_type" +definition start_ST :: "opstack_type" where "start_ST == []" - start_LT :: "cname \ ty list \ nat \ locvars_type" +definition start_LT :: "cname \ ty list \ nat \ locvars_type" where "start_LT C pTs n == (OK (Class C))#((map OK pTs))@(replicate n Err)" - compTpMethod :: "[java_mb prog, cname, java_mb mdecl] \ method_type" +definition compTpMethod :: "[java_mb prog, cname, java_mb mdecl] \ method_type" where "compTpMethod G C == \ ((mn,pTs),rT, jmb). let (pns,lvars,blk,res) = jmb in (mt_of @@ -168,7 +166,7 @@ nochangeST) (start_ST, start_LT C pTs (length lvars))))" - compTp :: "java_mb prog => prog_type" +definition compTp :: "java_mb prog => prog_type" where "compTp G C sig == let (D, rT, jmb) = (the (method (G, C) sig)) in compTpMethod G C (sig, rT, jmb)" @@ -177,15 +175,13 @@ (**********************************************************************) (* Computing the maximum stack size from the method_type *) -constdefs - ssize_sto :: "(state_type option) \ nat" +definition ssize_sto :: "(state_type option) \ nat" where "ssize_sto sto == case sto of None \ 0 | (Some (ST, LT)) \ length ST" - max_of_list :: "nat list \ nat" +definition max_of_list :: "nat list \ nat" where "max_of_list xs == foldr max xs 0" - max_ssize :: "method_type \ nat" +definition max_ssize :: "method_type \ nat" where "max_ssize mt == max_of_list (map ssize_sto mt)" - end