# HG changeset patch # User wenzelm # Date 1280158886 -7200 # Node ID ee939247b2fb180c9c0f4693cf925b6f7ebf94b1 # Parent f87d1105e181580667995416b3aa5f35c46ab21d modernized/unified some specifications; diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/AxCompl.thy --- a/src/HOL/Bali/AxCompl.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/AxCompl.thy Mon Jul 26 17:41:26 2010 +0200 @@ -20,8 +20,9 @@ section "set of not yet initialzed classes" -definition nyinitcls :: "prog \ state \ qtname set" where - "nyinitcls G s \ {C. is_class G C \ \ initd C s}" +definition + nyinitcls :: "prog \ state \ qtname set" + where "nyinitcls G s = {C. is_class G C \ \ initd C s}" lemma nyinitcls_subset_class: "nyinitcls G s \ {C. is_class G C}" apply (unfold nyinitcls_def) @@ -113,8 +114,9 @@ section "init-le" -definition init_le :: "prog \ nat \ state \ bool" ("_\init\_" [51,51] 50) where - "G\init\n \ \s. card (nyinitcls G s) \ n" +definition + init_le :: "prog \ nat \ state \ bool" ("_\init\_" [51,51] 50) + where "G\init\n = (\s. card (nyinitcls G s) \ n)" lemma init_le_def2 [simp]: "(G\init\n) s = (card (nyinitcls G s)\n)" apply (unfold init_le_def) @@ -132,27 +134,22 @@ section "Most General Triples and Formulas" -definition remember_init_state :: "state assn" ("\") where - "\ \ \Y s Z. s = Z" +definition + remember_init_state :: "state assn" ("\") + where "\ \ \Y s Z. s = Z" lemma remember_init_state_def2 [simp]: "\ Y = op =" apply (unfold remember_init_state_def) apply (simp (no_asm)) done -consts - +definition MGF ::"[state assn, term, prog] \ state triple" ("{_} _\ {_\}"[3,65,3]62) - MGFn::"[nat , term, prog] \ state triple" ("{=:_} _\ {_\}"[3,65,3]62) + where "{P} t\ {G\} = {P} t\ {\Y s' s. G\s \t\\ (Y,s')}" -defs - - - MGF_def: - "{P} t\ {G\} \ {P} t\ {\Y s' s. G\s \t\\ (Y,s')}" - - MGFn_def: - "{=:n} t\ {G\} \ {\ \. G\init\n} t\ {G\}" +definition + MGFn :: "[nat, term, prog] \ state triple" ("{=:_} _\ {_\}"[3,65,3]62) + where "{=:n} t\ {G\} = {\ \. G\init\n} t\ {G\}" (* unused *) lemma MGF_valid: "wf_prog G \ G,{}\{\} t\ {G\}" @@ -574,9 +571,9 @@ unroll the loop in iterated evaluations of the expression and evaluations of the loop body. *} -definition unroll :: "prog \ label \ expr \ stmt \ (state \ state) set" where - - "unroll G l e c \ {(s,t). \ v s1 s2. +definition + unroll :: "prog \ label \ expr \ stmt \ (state \ state) set" where + "unroll G l e c = {(s,t). \ v s1 s2. G\s \e-\v\ s1 \ the_Bool v \ normal s1 \ G\s1 \c\ s2 \ t=(abupd (absorb (Cont l)) s2)}" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/AxExample.thy --- a/src/HOL/Bali/AxExample.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/AxExample.thy Mon Jul 26 17:41:26 2010 +0200 @@ -8,10 +8,11 @@ imports AxSem Example begin -definition arr_inv :: "st \ bool" where - "arr_inv \ \s. \obj a T el. globs s (Stat Base) = Some obj \ +definition + arr_inv :: "st \ bool" where + "arr_inv = (\s. \obj a T el. globs s (Stat Base) = Some obj \ values obj (Inl (arr, Base)) = Some (Addr a) \ - heap s a = Some \tag=Arr T 2,values=el\" + heap s a = Some \tag=Arr T 2,values=el\)" lemma arr_inv_new_obj: "\a. \arr_inv s; new_Addr (heap s)=Some a\ \ arr_inv (gupd(Inl a\x) s)" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/AxSem.thy --- a/src/HOL/Bali/AxSem.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/AxSem.thy Mon Jul 26 17:41:26 2010 +0200 @@ -62,8 +62,9 @@ translations (type) "'a assn" <= (type) "vals \ state \ 'a \ bool" -definition assn_imp :: "'a assn \ 'a assn \ bool" (infixr "\" 25) where - "P \ Q \ \Y s Z. P Y s Z \ Q Y s Z" +definition + assn_imp :: "'a assn \ 'a assn \ bool" (infixr "\" 25) + where "(P \ Q) = (\Y s Z. P Y s Z \ Q Y s Z)" lemma assn_imp_def2 [iff]: "(P \ Q) = (\Y s Z. P Y s Z \ Q Y s Z)" apply (unfold assn_imp_def) @@ -75,8 +76,9 @@ subsection "peek-and" -definition peek_and :: "'a assn \ (state \ bool) \ 'a assn" (infixl "\." 13) where - "P \. p \ \Y s Z. P Y s Z \ p s" +definition + peek_and :: "'a assn \ (state \ bool) \ 'a assn" (infixl "\." 13) + where "(P \. p) = (\Y s Z. P Y s Z \ p s)" lemma peek_and_def2 [simp]: "peek_and P p Y s = (\Z. (P Y s Z \ p s))" apply (unfold peek_and_def) @@ -114,8 +116,9 @@ subsection "assn-supd" -definition assn_supd :: "'a assn \ (state \ state) \ 'a assn" (infixl ";." 13) where - "P ;. f \ \Y s' Z. \s. P Y s Z \ s' = f s" +definition + assn_supd :: "'a assn \ (state \ state) \ 'a assn" (infixl ";." 13) + where "(P ;. f) = (\Y s' Z. \s. P Y s Z \ s' = f s)" lemma assn_supd_def2 [simp]: "assn_supd P f Y s' Z = (\s. P Y s Z \ s' = f s)" apply (unfold assn_supd_def) @@ -124,8 +127,9 @@ subsection "supd-assn" -definition supd_assn :: "(state \ state) \ 'a assn \ 'a assn" (infixr ".;" 13) where - "f .; P \ \Y s. P Y (f s)" +definition + supd_assn :: "(state \ state) \ 'a assn \ 'a assn" (infixr ".;" 13) + where "(f .; P) = (\Y s. P Y (f s))" lemma supd_assn_def2 [simp]: "(f .; P) Y s = P Y (f s)" @@ -143,8 +147,9 @@ subsection "subst-res" -definition subst_res :: "'a assn \ res \ 'a assn" ("_\_" [60,61] 60) where - "P\w \ \Y. P w" +definition + subst_res :: "'a assn \ res \ 'a assn" ("_\_" [60,61] 60) + where "P\w = (\Y. P w)" lemma subst_res_def2 [simp]: "(P\w) Y = P w" apply (unfold subst_res_def) @@ -178,8 +183,9 @@ subsection "subst-Bool" -definition subst_Bool :: "'a assn \ bool \ 'a assn" ("_\=_" [60,61] 60) where - "P\=b \ \Y s Z. \v. P (Val v) s Z \ (normal s \ the_Bool v=b)" +definition + subst_Bool :: "'a assn \ bool \ 'a assn" ("_\=_" [60,61] 60) + where "P\=b = (\Y s Z. \v. P (Val v) s Z \ (normal s \ the_Bool v=b))" lemma subst_Bool_def2 [simp]: "(P\=b) Y s Z = (\v. P (Val v) s Z \ (normal s \ the_Bool v=b))" @@ -193,8 +199,9 @@ subsection "peek-res" -definition peek_res :: "(res \ 'a assn) \ 'a assn" where - "peek_res Pf \ \Y. Pf Y Y" +definition + peek_res :: "(res \ 'a assn) \ 'a assn" + where "peek_res Pf = (\Y. Pf Y Y)" syntax "_peek_res" :: "pttrn \ 'a assn \ 'a assn" ("\_:. _" [0,3] 3) @@ -221,8 +228,9 @@ subsection "ign-res" -definition ign_res :: " 'a assn \ 'a assn" ("_\" [1000] 1000) where - "P\ \ \Y s Z. \Y. P Y s Z" +definition + ign_res :: "'a assn \ 'a assn" ("_\" [1000] 1000) + where "P\ = (\Y s Z. \Y. P Y s Z)" lemma ign_res_def2 [simp]: "P\ Y s Z = (\Y. P Y s Z)" apply (unfold ign_res_def) @@ -252,8 +260,9 @@ subsection "peek-st" -definition peek_st :: "(st \ 'a assn) \ 'a assn" where - "peek_st P \ \Y s. P (store s) Y s" +definition + peek_st :: "(st \ 'a assn) \ 'a assn" + where "peek_st P = (\Y s. P (store s) Y s)" syntax "_peek_st" :: "pttrn \ 'a assn \ 'a assn" ("\_.. _" [0,3] 3) @@ -296,8 +305,9 @@ subsection "ign-res-eq" -definition ign_res_eq :: "'a assn \ res \ 'a assn" ("_\=_" [60,61] 60) where - "P\=w \ \Y:. P\ \. (\s. Y=w)" +definition + ign_res_eq :: "'a assn \ res \ 'a assn" ("_\=_" [60,61] 60) + where "P\=w \ (\Y:. P\ \. (\s. Y=w))" lemma ign_res_eq_def2 [simp]: "(P\=w) Y s Z = ((\Y. P Y s Z) \ Y=w)" apply (unfold ign_res_eq_def) @@ -326,8 +336,9 @@ subsection "RefVar" -definition RefVar :: "(state \ vvar \ state) \ 'a assn \ 'a assn" (infixr "..;" 13) where - "vf ..; P \ \Y s. let (v,s') = vf s in P (Var v) s'" +definition + RefVar :: "(state \ vvar \ state) \ 'a assn \ 'a assn" (infixr "..;" 13) + where "(vf ..; P) = (\Y s. let (v,s') = vf s in P (Var v) s')" lemma RefVar_def2 [simp]: "(vf ..; P) Y s = P (Var (fst (vf s))) (snd (vf s))" @@ -337,12 +348,13 @@ subsection "allocation" -definition Alloc :: "prog \ obj_tag \ 'a assn \ 'a assn" where - "Alloc G otag P \ \Y s Z. - \s' a. G\s \halloc otag\a\ s'\ P (Val (Addr a)) s' Z" +definition + Alloc :: "prog \ obj_tag \ 'a assn \ 'a assn" + where "Alloc G otag P = (\Y s Z. \s' a. G\s \halloc otag\a\ s'\ P (Val (Addr a)) s' Z)" -definition SXAlloc :: "prog \ 'a assn \ 'a assn" where - "SXAlloc G P \ \Y s Z. \s'. G\s \sxalloc\ s' \ P Y s' Z" +definition + SXAlloc :: "prog \ 'a assn \ 'a assn" + where "SXAlloc G P = (\Y s Z. \s'. G\s \sxalloc\ s' \ P Y s' Z)" lemma Alloc_def2 [simp]: "Alloc G otag P Y s Z = @@ -359,11 +371,12 @@ section "validity" -definition type_ok :: "prog \ term \ state \ bool" where - "type_ok G t s \ - \L T C A. (normal s \ \prg=G,cls=C,lcl=L\\t\T \ - \prg=G,cls=C,lcl=L\\dom (locals (store s))\t\A ) - \ s\\(G,L)" +definition + type_ok :: "prog \ term \ state \ bool" where + "type_ok G t s = + (\L T C A. (normal s \ \prg=G,cls=C,lcl=L\\t\T \ + \prg=G,cls=C,lcl=L\\dom (locals (store s))\t\A ) + \ s\\(G,L))" datatype 'a triple = triple "('a assn)" "term" "('a assn)" (** should be something like triple = \'a. triple ('a assn) term ('a assn) **) @@ -407,34 +420,35 @@ definition mtriples :: "('c \ 'sig \ 'a assn) \ ('c \ 'sig \ expr) \ ('c \ 'sig \ 'a assn) \ ('c \ 'sig) set \ 'a triples" ("{{(1_)}/ _-\/ {(1_)} | _}"[3,65,3,65]75) where - "{{P} tf-\ {Q} | ms} \ (\(C,sig). {Normal(P C sig)} tf C sig-\ {Q C sig})`ms" + "{{P} tf-\ {Q} | ms} = (\(C,sig). {Normal(P C sig)} tf C sig-\ {Q C sig})`ms" -consts - - triple_valid :: "prog \ nat \ 'a triple \ bool" - ( "_\_:_" [61,0, 58] 57) - ax_valids :: "prog \ 'b triples \ 'a triples \ bool" - ("_,_|\_" [61,58,58] 57) +definition + triple_valid :: "prog \ nat \ 'a triple \ bool" ("_\_:_" [61,0, 58] 57) + where + "G\n:t = + (case t of {P} t\ {Q} \ + \Y s Z. P Y s Z \ type_ok G t s \ + (\Y' s'. G\s \t\\n\ (Y',s') \ Q Y' s' Z))" abbreviation - triples_valid:: "prog \ nat \ 'a triples \ bool" - ( "_||=_:_" [61,0, 58] 57) - where "G||=n:ts == Ball ts (triple_valid G n)" + triples_valid:: "prog \ nat \ 'a triples \ bool" ( "_||=_:_" [61,0, 58] 57) + where "G||=n:ts == Ball ts (triple_valid G n)" + +notation (xsymbols) + triples_valid ("_|\_:_" [61,0, 58] 57) + + +definition + ax_valids :: "prog \ 'b triples \ 'a triples \ bool" ("_,_|\_" [61,58,58] 57) + where "(G,A|\ts) = (\n. G|\n:A \ G|\n:ts)" abbreviation - ax_valid :: "prog \ 'b triples \ 'a triple \ bool" - ( "_,_|=_" [61,58,58] 57) - where "G,A |=t == G,A|\{t}" + ax_valid :: "prog \ 'b triples \ 'a triple \ bool" ( "_,_|=_" [61,58,58] 57) + where "G,A |=t == G,A|\{t}" notation (xsymbols) - triples_valid ("_|\_:_" [61,0, 58] 57) and ax_valid ("_,_\_" [61,58,58] 57) -defs triple_valid_def: "G\n:t \ case t of {P} t\ {Q} \ - \Y s Z. P Y s Z \ type_ok G t s \ - (\Y' s'. G\s \t\\n\ (Y',s') \ Q Y' s' Z)" - -defs ax_valids_def:"G,A|\ts \ \n. G|\n:A \ G|\n:ts" lemma triple_valid_def2: "G\n:{P} t\ {Q} = (\Y s Z. P Y s Z @@ -625,8 +639,9 @@ axioms *) -definition adapt_pre :: "'a assn \ 'a assn \ 'a assn \ 'a assn" where -"adapt_pre P Q Q'\\Y s Z. \Y' s'. \Z'. P Y s Z' \ (Q Y' s' Z' \ Q' Y' s' Z)" +definition + adapt_pre :: "'a assn \ 'a assn \ 'a assn \ 'a assn" + where "adapt_pre P Q Q' = (\Y s Z. \Y' s'. \Z'. P Y s Z' \ (Q Y' s' Z' \ Q' Y' s' Z))" section "rules derived by induction" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/AxSound.thy --- a/src/HOL/Bali/AxSound.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/AxSound.thy Mon Jul 26 17:41:26 2010 +0200 @@ -9,18 +9,15 @@ section "validity" -consts - - triple_valid2:: "prog \ nat \ 'a triple \ bool" - ( "_\_\_"[61,0, 58] 57) - ax_valids2:: "prog \ 'a triples \ 'a triples \ bool" - ("_,_|\\_" [61,58,58] 57) - -defs triple_valid2_def: "G\n\t \ case t of {P} t\ {Q} \ - \Y s Z. P Y s Z \ (\L. s\\(G,L) - \ (\T C A. (normal s \ (\prg=G,cls=C,lcl=L\\t\T \ - \prg=G,cls=C,lcl=L\\dom (locals (store s))\t\A)) \ - (\Y' s'. G\s \t\\n\ (Y',s') \ Q Y' s' Z \ s'\\(G,L))))" +definition + triple_valid2 :: "prog \ nat \ 'a triple \ bool" ("_\_\_"[61,0, 58] 57) + where + "G\n\t = + (case t of {P} t\ {Q} \ + \Y s Z. P Y s Z \ (\L. s\\(G,L) + \ (\T C A. (normal s \ (\prg=G,cls=C,lcl=L\\t\T \ + \prg=G,cls=C,lcl=L\\dom (locals (store s))\t\A)) \ + (\Y' s'. G\s \t\\n\ (Y',s') \ Q Y' s' Z \ s'\\(G,L)))))" text {* This definition differs from the ordinary @{text triple_valid_def} manly in the conclusion: We also ensures conformance of the result state. So @@ -29,8 +26,10 @@ proof of the axiomatic semantics, in the end we will conclude to the ordinary definition. *} - -defs ax_valids2_def: "G,A|\\ts \ \n. (\t\A. G\n\t) \ (\t\ts. G\n\t)" + +definition + ax_valids2 :: "prog \ 'a triples \ 'a triples \ bool" ("_,_|\\_" [61,58,58] 57) + where "G,A|\\ts = (\n. (\t\A. G\n\t) \ (\t\ts. G\n\t))" lemma triple_valid2_def2: "G\n\{P} t\ {Q} = (\Y s Z. P Y s Z \ (\Y' s'. G\s \t\\n\ (Y',s')\ diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Basis.thy --- a/src/HOL/Bali/Basis.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Basis.thy Mon Jul 26 17:41:26 2010 +0200 @@ -180,31 +180,34 @@ notation sum_case (infixr "'(+')"80) -consts the_Inl :: "'a + 'b \ 'a" - the_Inr :: "'a + 'b \ 'b" -primrec "the_Inl (Inl a) = a" -primrec "the_Inr (Inr b) = b" +primrec the_Inl :: "'a + 'b \ 'a" + where "the_Inl (Inl a) = a" + +primrec the_Inr :: "'a + 'b \ 'b" + where "the_Inr (Inr b) = b" datatype ('a, 'b, 'c) sum3 = In1 'a | In2 'b | In3 'c -consts the_In1 :: "('a, 'b, 'c) sum3 \ 'a" - the_In2 :: "('a, 'b, 'c) sum3 \ 'b" - the_In3 :: "('a, 'b, 'c) sum3 \ 'c" -primrec "the_In1 (In1 a) = a" -primrec "the_In2 (In2 b) = b" -primrec "the_In3 (In3 c) = c" +primrec the_In1 :: "('a, 'b, 'c) sum3 \ 'a" + where "the_In1 (In1 a) = a" + +primrec the_In2 :: "('a, 'b, 'c) sum3 \ 'b" + where "the_In2 (In2 b) = b" + +primrec the_In3 :: "('a, 'b, 'c) sum3 \ 'c" + where "the_In3 (In3 c) = c" abbreviation In1l :: "'al \ ('al + 'ar, 'b, 'c) sum3" - where "In1l e == In1 (Inl e)" + where "In1l e == In1 (Inl e)" abbreviation In1r :: "'ar \ ('al + 'ar, 'b, 'c) sum3" - where "In1r c == In1 (Inr c)" + where "In1r c == In1 (Inr c)" abbreviation the_In1l :: "('al + 'ar, 'b, 'c) sum3 \ 'al" - where "the_In1l == the_Inl \ the_In1" + where "the_In1l == the_Inl \ the_In1" abbreviation the_In1r :: "('al + 'ar, 'b, 'c) sum3 \ 'ar" - where "the_In1r == the_Inr \ the_In1" + where "the_In1r == the_Inr \ the_In1" ML {* fun sum3_instantiate ctxt thm = map (fn s => @@ -232,8 +235,9 @@ text{* Deemed too special for theory Map. *} -definition chg_map :: "('b => 'b) => 'a => ('a ~=> 'b) => ('a ~=> 'b)" where - "chg_map f a m == case m a of None => m | Some b => m(a|->f b)" +definition + chg_map :: "('b => 'b) => 'a => ('a ~=> 'b) => ('a ~=> 'b)" + where "chg_map f a m = (case m a of None => m | Some b => m(a|->f b))" lemma chg_map_new[simp]: "m a = None ==> chg_map f a m = m" by (unfold chg_map_def, auto) @@ -247,8 +251,9 @@ section "unique association lists" -definition unique :: "('a \ 'b) list \ bool" where - "unique \ distinct \ map fst" +definition + unique :: "('a \ 'b) list \ bool" + where "unique = distinct \ map fst" lemma uniqueD [rule_format (no_asm)]: "unique l--> (!x y. (x,y):set l --> (!x' y'. (x',y'):set l --> x=x'--> y=y'))" @@ -296,11 +301,11 @@ section "list patterns" -consts - lsplit :: "[['a, 'a list] => 'b, 'a list] => 'b" -defs - lsplit_def: "lsplit == %f l. f (hd l) (tl l)" -(* list patterns -- extends pre-defined type "pttrn" used in abstractions *) +definition + lsplit :: "[['a, 'a list] => 'b, 'a list] => 'b" where + "lsplit = (\f l. f (hd l) (tl l))" + +text {* list patterns -- extends pre-defined type "pttrn" used in abstractions *} syntax "_lpttrn" :: "[pttrn,pttrn] => pttrn" ("_#/_" [901,900] 900) translations diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Conform.thy --- a/src/HOL/Bali/Conform.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Conform.thy Mon Jul 26 17:41:26 2010 +0200 @@ -96,8 +96,8 @@ section "value conformance" -definition conf :: "prog \ st \ val \ ty \ bool" ("_,_\_\\_" [71,71,71,71] 70) where - "G,s\v\\T \ \T'\typeof (\a. Option.map obj_ty (heap s a)) v:G\T'\T" +definition conf :: "prog \ st \ val \ ty \ bool" ("_,_\_\\_" [71,71,71,71] 70) + where "G,s\v\\T = (\T'\typeof (\a. Option.map obj_ty (heap s a)) v:G\T'\T)" lemma conf_cong [simp]: "G,set_locals l s\v\\T = G,s\v\\T" by (auto simp: conf_def) @@ -177,8 +177,9 @@ section "value list conformance" -definition lconf :: "prog \ st \ ('a, val) table \ ('a, ty) table \ bool" ("_,_\_[\\]_" [71,71,71,71] 70) where - "G,s\vs[\\]Ts \ \n. \T\Ts n: \v\vs n: G,s\v\\T" +definition + lconf :: "prog \ st \ ('a, val) table \ ('a, ty) table \ bool" ("_,_\_[\\]_" [71,71,71,71] 70) + where "G,s\vs[\\]Ts = (\n. \T\Ts n: \v\vs n: G,s\v\\T)" lemma lconfD: "\G,s\vs[\\]Ts; Ts n = Some T\ \ G,s\(the (vs n))\\T" by (force simp: lconf_def) @@ -260,8 +261,9 @@ *} -definition wlconf :: "prog \ st \ ('a, val) table \ ('a, ty) table \ bool" ("_,_\_[\\\]_" [71,71,71,71] 70) where - "G,s\vs[\\\]Ts \ \n. \T\Ts n: \ v\vs n: G,s\v\\T" +definition + wlconf :: "prog \ st \ ('a, val) table \ ('a, ty) table \ bool" ("_,_\_[\\\]_" [71,71,71,71] 70) + where "G,s\vs[\\\]Ts = (\n. \T\Ts n: \ v\vs n: G,s\v\\T)" lemma wlconfD: "\G,s\vs[\\\]Ts; Ts n = Some T; vs n = Some v\ \ G,s\v\\T" by (auto simp: wlconf_def) @@ -338,11 +340,12 @@ section "object conformance" -definition oconf :: "prog \ st \ obj \ oref \ bool" ("_,_\_\\\_" [71,71,71,71] 70) where - "G,s\obj\\\r \ G,s\values obj[\\]var_tys G (tag obj) r \ +definition + oconf :: "prog \ st \ obj \ oref \ bool" ("_,_\_\\\_" [71,71,71,71] 70) where + "(G,s\obj\\\r) = (G,s\values obj[\\]var_tys G (tag obj) r \ (case r of Heap a \ is_type G (obj_ty obj) - | Stat C \ True)" + | Stat C \ True))" lemma oconf_is_type: "G,s\obj\\\Heap a \ is_type G (obj_ty obj)" @@ -373,12 +376,14 @@ section "state conformance" -definition conforms :: "state \ env' \ bool" ("_\\_" [71,71] 70) where - "xs\\E \ let (G, L) = E; s = snd xs; l = locals s in - (\r. \obj\globs s r: G,s\obj \\\r) \ - \ G,s\l [\\\]L\ \ - (\a. fst xs=Some(Xcpt (Loc a)) \ G,s\Addr a\\ Class (SXcpt Throwable)) \ - (fst xs=Some(Jump Ret) \ l Result \ None)" +definition + conforms :: "state \ env' \ bool" ("_\\_" [71,71] 70) where + "xs\\E = + (let (G, L) = E; s = snd xs; l = locals s in + (\r. \obj\globs s r: G,s\obj \\\r) \ + \ G,s\l [\\\]L\ \ + (\a. fst xs=Some(Xcpt (Loc a)) \ G,s\Addr a\\ Class (SXcpt Throwable)) \ + (fst xs=Some(Jump Ret) \ l Result \ None))" section "conforms" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Decl.thy --- a/src/HOL/Bali/Decl.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Decl.thy Mon Jul 26 17:41:26 2010 +0200 @@ -206,8 +206,9 @@ (type) "mdecl" <= (type) "sig \ methd" -definition mhead :: "methd \ mhead" where - "mhead m \ \access=access m, static=static m, pars=pars m, resT=resT m\" +definition + mhead :: "methd \ mhead" + where "mhead m = \access=access m, static=static m, pars=pars m, resT=resT m\" lemma access_mhead [simp]:"access (mhead m) = access m" by (simp add: mhead_def) @@ -237,7 +238,7 @@ definition memberdecl_memberid_def: - "memberid m \ (case m of + "memberid m = (case m of fdecl (vn,f) \ fid vn | mdecl (sig,m) \ mid sig)" @@ -262,7 +263,7 @@ definition pair_memberid_def: - "memberid p \ memberid (snd p)" + "memberid p = memberid (snd p)" instance .. @@ -274,8 +275,9 @@ lemma memberid_pair_simp1: "memberid p = memberid (snd p)" by (simp add: pair_memberid_def) -definition is_field :: "qtname \ memberdecl \ bool" where -"is_field m \ \ declC f. m=(declC,fdecl f)" +definition + is_field :: "qtname \ memberdecl \ bool" + where "is_field m = (\ declC f. m=(declC,fdecl f))" lemma is_fieldD: "is_field m \ \ declC f. m=(declC,fdecl f)" by (simp add: is_field_def) @@ -283,8 +285,9 @@ lemma is_fieldI: "is_field (C,fdecl f)" by (simp add: is_field_def) -definition is_method :: "qtname \ memberdecl \ bool" where -"is_method membr \ \ declC m. membr=(declC,mdecl m)" +definition + is_method :: "qtname \ memberdecl \ bool" + where "is_method membr = (\declC m. membr=(declC,mdecl m))" lemma is_methodD: "is_method membr \ \ declC m. membr=(declC,mdecl m)" by (simp add: is_method_def) @@ -314,8 +317,9 @@ isuperIfs::qtname list,\::'a\" (type) "idecl" <= (type) "qtname \ iface" -definition ibody :: "iface \ ibody" where - "ibody i \ \access=access i,imethods=imethods i\" +definition + ibody :: "iface \ ibody" + where "ibody i = \access=access i,imethods=imethods i\" lemma access_ibody [simp]: "(access (ibody i)) = access i" by (simp add: ibody_def) @@ -349,8 +353,9 @@ super::qtname,superIfs::qtname list,\::'a\" (type) "cdecl" <= (type) "qtname \ class" -definition cbody :: "class \ cbody" where - "cbody c \ \access=access c, cfields=cfields c,methods=methods c,init=init c\" +definition + cbody :: "class \ cbody" + where "cbody c = \access=access c, cfields=cfields c,methods=methods c,init=init c\" lemma access_cbody [simp]:"access (cbody c) = access c" by (simp add: cbody_def) @@ -368,18 +373,17 @@ section "standard classes" consts - Object_mdecls :: "mdecl list" --{* methods of Object *} SXcpt_mdecls :: "mdecl list" --{* methods of SXcpts *} - ObjectC :: "cdecl" --{* declaration of root class *} - SXcptC ::"xname \ cdecl" --{* declarations of throwable classes *} - -defs +definition + ObjectC :: "cdecl" --{* declaration of root class *} where + "ObjectC = (Object,\access=Public,cfields=[],methods=Object_mdecls, + init=Skip,super=undefined,superIfs=[]\)" -ObjectC_def:"ObjectC \ (Object,\access=Public,cfields=[],methods=Object_mdecls, - init=Skip,super=undefined,superIfs=[]\)" -SXcptC_def:"SXcptC xn\ (SXcpt xn,\access=Public,cfields=[],methods=SXcpt_mdecls, +definition + SXcptC ::"xname \ cdecl" --{* declarations of throwable classes *} where + "SXcptC xn = (SXcpt xn,\access=Public,cfields=[],methods=SXcpt_mdecls, init=Skip, super=if xn = Throwable then Object else SXcpt Throwable, @@ -391,8 +395,9 @@ lemma SXcptC_inject [simp]: "(SXcptC xn = SXcptC xm) = (xn = xm)" by (simp add: SXcptC_def) -definition standard_classes :: "cdecl list" where - "standard_classes \ [ObjectC, SXcptC Throwable, +definition + standard_classes :: "cdecl list" where + "standard_classes = [ObjectC, SXcptC Throwable, SXcptC NullPointer, SXcptC OutOfMemory, SXcptC ClassCast, SXcptC NegArrSize , SXcptC IndOutBound, SXcptC ArrStore]" @@ -426,16 +431,15 @@ section "is type" -consts - is_type :: "prog \ ty \ bool" - isrtype :: "prog \ ref_ty \ bool" - -primrec "is_type G (PrimT pt) = True" - "is_type G (RefT rt) = isrtype G rt" - "isrtype G (NullT ) = True" - "isrtype G (IfaceT tn) = is_iface G tn" - "isrtype G (ClassT tn) = is_class G tn" - "isrtype G (ArrayT T ) = is_type G T" +primrec is_type :: "prog \ ty \ bool" + and isrtype :: "prog \ ref_ty \ bool" +where + "is_type G (PrimT pt) = True" +| "is_type G (RefT rt) = isrtype G rt" +| "isrtype G (NullT) = True" +| "isrtype G (IfaceT tn) = is_iface G tn" +| "isrtype G (ClassT tn) = is_class G tn" +| "isrtype G (ArrayT T ) = is_type G T" lemma type_is_iface: "is_type G (Iface I) \ is_iface G I" by auto @@ -446,13 +450,13 @@ section "subinterface and subclass relation, in anticipation of TypeRel.thy" -consts +definition subint1 :: "prog \ (qtname \ qtname) set" --{* direct subinterface *} - subcls1 :: "prog \ (qtname \ qtname) set" --{* direct subclass *} + where "subint1 G = {(I,J). \i\iface G I: J\set (isuperIfs i)}" -defs - subint1_def: "subint1 G \ {(I,J). \i\iface G I: J\set (isuperIfs i)}" - subcls1_def: "subcls1 G \ {(C,D). C\Object \ (\c\class G C: super c = D)}" +definition + subcls1 :: "prog \ (qtname \ qtname) set" --{* direct subclass *} + where "subcls1 G = {(C,D). C\Object \ (\c\class G C: super c = D)}" abbreviation subcls1_syntax :: "prog => [qtname, qtname] => bool" ("_|-_<:C1_" [71,71,71] 70) @@ -517,15 +521,18 @@ section "well-structured programs" -definition ws_idecl :: "prog \ qtname \ qtname list \ bool" where - "ws_idecl G I si \ \J\set si. is_iface G J \ (J,I)\(subint1 G)^+" +definition + ws_idecl :: "prog \ qtname \ qtname list \ bool" + where "ws_idecl G I si = (\J\set si. is_iface G J \ (J,I)\(subint1 G)^+)" -definition ws_cdecl :: "prog \ qtname \ qtname \ bool" where - "ws_cdecl G C sc \ C\Object \ is_class G sc \ (sc,C)\(subcls1 G)^+" +definition + ws_cdecl :: "prog \ qtname \ qtname \ bool" + where "ws_cdecl G C sc = (C\Object \ is_class G sc \ (sc,C)\(subcls1 G)^+)" -definition ws_prog :: "prog \ bool" where - "ws_prog G \ (\(I,i)\set (ifaces G). ws_idecl G I (isuperIfs i)) \ - (\(C,c)\set (classes G). ws_cdecl G C (super c))" +definition + ws_prog :: "prog \ bool" where + "ws_prog G = ((\(I,i)\set (ifaces G). ws_idecl G I (isuperIfs i)) \ + (\(C,c)\set (classes G). ws_cdecl G C (super c)))" lemma ws_progI: @@ -810,10 +817,10 @@ apply simp done -definition imethds :: "prog \ qtname \ (sig,qtname \ mhead) tables" where +definition + imethds :: "prog \ qtname \ (sig,qtname \ mhead) tables" where --{* methods of an interface, with overriding and inheritance, cf. 9.2 *} -"imethds G I - \ iface_rec G I + "imethds G I = iface_rec G I (\I i ts. (Un_tables ts) \\ (Option.set \ table_of (map (\(s,m). (s,I,m)) (imethods i))))" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/DeclConcepts.thy --- a/src/HOL/Bali/DeclConcepts.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/DeclConcepts.thy Mon Jul 26 17:41:26 2010 +0200 @@ -9,7 +9,7 @@ section "access control (cf. 6.6), overriding and hiding (cf. 8.4.6.1)" definition is_public :: "prog \ qtname \ bool" where -"is_public G qn \ (case class G qn of +"is_public G qn = (case class G qn of None \ (case iface G qn of None \ False | Some i \ access i = Public) @@ -21,33 +21,35 @@ in their package or if they are defined public, an array type is accessible if its element type is accessible *} -consts accessible_in :: "prog \ ty \ pname \ bool" - ("_ \ _ accessible'_in _" [61,61,61] 60) - rt_accessible_in:: "prog \ ref_ty \ pname \ bool" - ("_ \ _ accessible'_in' _" [61,61,61] 60) primrec -"G\(PrimT p) accessible_in pack = True" -accessible_in_RefT_simp: -"G\(RefT r) accessible_in pack = G\r accessible_in' pack" - -"G\(NullT) accessible_in' pack = True" -"G\(IfaceT I) accessible_in' pack = ((pid I = pack) \ is_public G I)" -"G\(ClassT C) accessible_in' pack = ((pid C = pack) \ is_public G C)" -"G\(ArrayT ty) accessible_in' pack = G\ty accessible_in pack" + accessible_in :: "prog \ ty \ pname \ bool" ("_ \ _ accessible'_in _" [61,61,61] 60) and + rt_accessible_in :: "prog \ ref_ty \ pname \ bool" ("_ \ _ accessible'_in' _" [61,61,61] 60) +where + "G\(PrimT p) accessible_in pack = True" +| accessible_in_RefT_simp: + "G\(RefT r) accessible_in pack = G\r accessible_in' pack" +| "G\(NullT) accessible_in' pack = True" +| "G\(IfaceT I) accessible_in' pack = ((pid I = pack) \ is_public G I)" +| "G\(ClassT C) accessible_in' pack = ((pid C = pack) \ is_public G C)" +| "G\(ArrayT ty) accessible_in' pack = G\ty accessible_in pack" declare accessible_in_RefT_simp [simp del] -definition is_acc_class :: "prog \ pname \ qtname \ bool" where - "is_acc_class G P C \ is_class G C \ G\(Class C) accessible_in P" +definition + is_acc_class :: "prog \ pname \ qtname \ bool" + where "is_acc_class G P C = (is_class G C \ G\(Class C) accessible_in P)" -definition is_acc_iface :: "prog \ pname \ qtname \ bool" where - "is_acc_iface G P I \ is_iface G I \ G\(Iface I) accessible_in P" +definition + is_acc_iface :: "prog \ pname \ qtname \ bool" + where "is_acc_iface G P I = (is_iface G I \ G\(Iface I) accessible_in P)" -definition is_acc_type :: "prog \ pname \ ty \ bool" where - "is_acc_type G P T \ is_type G T \ G\T accessible_in P" +definition + is_acc_type :: "prog \ pname \ ty \ bool" + where "is_acc_type G P T = (is_type G T \ G\T accessible_in P)" -definition is_acc_reftype :: "prog \ pname \ ref_ty \ bool" where - "is_acc_reftype G P T \ isrtype G T \ G\T accessible_in' P" +definition + is_acc_reftype :: "prog \ pname \ ref_ty \ bool" + where "is_acc_reftype G P T = (isrtype G T \ G\T accessible_in' P)" lemma is_acc_classD: "is_acc_class G P C \ is_class G C \ G\(Class C) accessible_in P" @@ -87,7 +89,7 @@ begin definition - acc_modi_accmodi_def: "accmodi (a::acc_modi) \ a" + acc_modi_accmodi_def: "accmodi (a::acc_modi) = a" instance .. @@ -100,7 +102,7 @@ begin definition - decl_acc_modi_def: "accmodi (d::('a:: type) decl_scheme) \ access d" + decl_acc_modi_def: "accmodi (d::('a:: type) decl_scheme) = access d" instance .. @@ -113,7 +115,7 @@ begin definition - pair_acc_modi_def: "accmodi p \ (accmodi (snd p))" + pair_acc_modi_def: "accmodi p = accmodi (snd p)" instance .. @@ -126,7 +128,7 @@ begin definition - memberdecl_acc_modi_def: "accmodi m \ (case m of + memberdecl_acc_modi_def: "accmodi m = (case m of fdecl f \ accmodi f | mdecl m \ accmodi m)" @@ -152,7 +154,7 @@ begin definition - "declclass q \ \ pid = pid q, tid = tid q \" + "declclass q = \ pid = pid q, tid = tid q \" instance .. @@ -169,7 +171,7 @@ begin definition - pair_declclass_def: "declclass p \ declclass (fst p)" + pair_declclass_def: "declclass p = declclass (fst p)" instance .. @@ -208,7 +210,7 @@ begin definition - pair_is_static_def: "is_static p \ is_static (snd p)" + pair_is_static_def: "is_static p = is_static (snd p)" instance .. @@ -225,7 +227,7 @@ definition memberdecl_is_static_def: - "is_static m \ (case m of + "is_static m = (case m of fdecl f \ is_static f | mdecl m \ is_static m)" @@ -246,28 +248,34 @@ -- {* some mnemotic selectors for various pairs *} -definition decliface :: "qtname \ 'a decl_scheme \ qtname" where +definition + decliface :: "qtname \ 'a decl_scheme \ qtname" where "decliface = fst" --{* get the interface component *} -definition mbr :: "qtname \ memberdecl \ memberdecl" where +definition + mbr :: "qtname \ memberdecl \ memberdecl" where "mbr = snd" --{* get the memberdecl component *} -definition mthd :: "'b \ 'a \ 'a" where +definition + mthd :: "'b \ 'a \ 'a" where "mthd = snd" --{* get the method component *} --{* also used for mdecl, mhead *} -definition fld :: "'b \ 'a decl_scheme \ 'a decl_scheme" where +definition + fld :: "'b \ 'a decl_scheme \ 'a decl_scheme" where "fld = snd" --{* get the field component *} --{* also used for @{text "((vname \ qtname)\ field)"} *} -- {* some mnemotic selectors for @{text "(vname \ qtname)"} *} -definition fname:: "vname \ 'a \ vname" where - "fname = fst" +definition + fname:: "vname \ 'a \ vname" + where "fname = fst" --{* also used for fdecl *} -definition declclassf:: "(vname \ qtname) \ qtname" where - "declclassf = snd" +definition + declclassf:: "(vname \ qtname) \ qtname" + where "declclassf = snd" lemma decliface_simp[simp]: "decliface (I,m) = I" @@ -320,11 +328,13 @@ --{* some mnemotic selectors for @{text "(vname \ qtname)"} *} -definition fldname :: "vname \ qtname \ vname" where - "fldname = fst" +definition + fldname :: "vname \ qtname \ vname" + where "fldname = fst" -definition fldclass :: "vname \ qtname \ qtname" where - "fldclass = snd" +definition + fldclass :: "vname \ qtname \ qtname" + where "fldclass = snd" lemma fldname_simp[simp]: "fldname (n,c) = n" by (simp add: fldname_def) @@ -338,8 +348,9 @@ text {* Convert a qualified method declaration (qualified with its declaring class) to a qualified member declaration: @{text methdMembr} *} -definition methdMembr :: "qtname \ mdecl \ qtname \ memberdecl" where - "methdMembr m = (fst m, mdecl (snd m))" +definition + methdMembr :: "qtname \ mdecl \ qtname \ memberdecl" + where "methdMembr m = (fst m, mdecl (snd m))" lemma methdMembr_simp[simp]: "methdMembr (c,m) = (c,mdecl m)" by (simp add: methdMembr_def) @@ -356,8 +367,9 @@ text {* Convert a qualified method (qualified with its declaring class) to a qualified member declaration: @{text method} *} -definition method :: "sig \ (qtname \ methd) \ (qtname \ memberdecl)" where -"method sig m \ (declclass m, mdecl (sig, mthd m))" +definition + method :: "sig \ (qtname \ methd) \ (qtname \ memberdecl)" + where "method sig m = (declclass m, mdecl (sig, mthd m))" lemma method_simp[simp]: "method sig (C,m) = (C,mdecl (sig,m))" by (simp add: method_def) @@ -377,8 +389,9 @@ lemma memberid_method_simp[simp]: "memberid (method sig m) = mid sig" by (simp add: method_def) -definition fieldm :: "vname \ (qtname \ field) \ (qtname \ memberdecl)" where -"fieldm n f \ (declclass f, fdecl (n, fld f))" +definition + fieldm :: "vname \ (qtname \ field) \ (qtname \ memberdecl)" + where "fieldm n f = (declclass f, fdecl (n, fld f))" lemma fieldm_simp[simp]: "fieldm n (C,f) = (C,fdecl (n,f))" by (simp add: fieldm_def) @@ -401,8 +414,9 @@ text {* Select the signature out of a qualified method declaration: @{text msig} *} -definition msig :: "(qtname \ mdecl) \ sig" where -"msig m \ fst (snd m)" +definition + msig :: "(qtname \ mdecl) \ sig" + where "msig m = fst (snd m)" lemma msig_simp[simp]: "msig (c,(s,m)) = s" by (simp add: msig_def) @@ -410,8 +424,9 @@ text {* Convert a qualified method (qualified with its declaring class) to a qualified method declaration: @{text qmdecl} *} -definition qmdecl :: "sig \ (qtname \ methd) \ (qtname \ mdecl)" where -"qmdecl sig m \ (declclass m, (sig,mthd m))" +definition + qmdecl :: "sig \ (qtname \ methd) \ (qtname \ mdecl)" + where "qmdecl sig m = (declclass m, (sig,mthd m))" lemma qmdecl_simp[simp]: "qmdecl sig (C,m) = (C,(sig,m))" by (simp add: qmdecl_def) @@ -476,7 +491,7 @@ begin definition - pair_resTy_def: "resTy p \ resTy (snd p)" + pair_resTy_def: "resTy p = resTy (snd p)" instance .. @@ -503,14 +518,15 @@ it is not accessible for inheritance at all. \end{itemize} *} -definition inheritable_in :: "prog \ (qtname \ memberdecl) \ pname \ bool" ("_ \ _ inheritable'_in _" [61,61,61] 60) where - -"G\membr inheritable_in pack - \ (case (accmodi membr) of - Private \ False - | Package \ (pid (declclass membr)) = pack - | Protected \ True - | Public \ True)" +definition + inheritable_in :: "prog \ (qtname \ memberdecl) \ pname \ bool" ("_ \ _ inheritable'_in _" [61,61,61] 60) +where +"G\membr inheritable_in pack = + (case (accmodi membr) of + Private \ False + | Package \ (pid (declclass membr)) = pack + | Protected \ True + | Public \ True)" abbreviation Method_inheritable_in_syntax:: @@ -526,24 +542,26 @@ subsubsection "declared-in/undeclared-in" -definition cdeclaredmethd :: "prog \ qtname \ (sig,methd) table" where -"cdeclaredmethd G C - \ (case class G C of +definition + cdeclaredmethd :: "prog \ qtname \ (sig,methd) table" where + "cdeclaredmethd G C = + (case class G C of None \ \ sig. None - | Some c \ table_of (methods c) - )" + | Some c \ table_of (methods c))" -definition cdeclaredfield :: "prog \ qtname \ (vname,field) table" where -"cdeclaredfield G C - \ (case class G C of - None \ \ sig. None - | Some c \ table_of (cfields c) - )" +definition + cdeclaredfield :: "prog \ qtname \ (vname,field) table" where + "cdeclaredfield G C = + (case class G C of + None \ \ sig. None + | Some c \ table_of (cfields c))" -definition declared_in :: "prog \ memberdecl \ qtname \ bool" ("_\ _ declared'_in _" [61,61,61] 60) where -"G\m declared_in C \ (case m of - fdecl (fn,f ) \ cdeclaredfield G C fn = Some f - | mdecl (sig,m) \ cdeclaredmethd G C sig = Some m)" +definition + declared_in :: "prog \ memberdecl \ qtname \ bool" ("_\ _ declared'_in _" [61,61,61] 60) +where + "G\m declared_in C = (case m of + fdecl (fn,f ) \ cdeclaredfield G C fn = Some f + | mdecl (sig,m) \ cdeclaredmethd G C sig = Some m)" abbreviation method_declared_in:: "prog \ (qtname \ mdecl) \ qtname \ bool" @@ -560,10 +578,12 @@ by (cases m) (auto simp add: declared_in_def cdeclaredmethd_def cdeclaredfield_def) -definition undeclared_in :: "prog \ memberid \ qtname \ bool" ("_\ _ undeclared'_in _" [61,61,61] 60) where -"G\m undeclared_in C \ (case m of - fid fn \ cdeclaredfield G C fn = None - | mid sig \ cdeclaredmethd G C sig = None)" +definition + undeclared_in :: "prog \ memberid \ qtname \ bool" ("_\ _ undeclared'_in _" [61,61,61] 60) +where + "G\m undeclared_in C = (case m of + fid fn \ cdeclaredfield G C fn = None + | mid sig \ cdeclaredmethd G C sig = None)" subsubsection "members" @@ -607,17 +627,20 @@ ("_ \Field _ _ member'_of _" [61,61,61] 60) where "G\Field n f member_of C == G\fieldm n f member_of C" -definition inherits :: "prog \ qtname \ (qtname \ memberdecl) \ bool" ("_ \ _ inherits _" [61,61,61] 60) where -"G\C inherits m - \ G\m inheritable_in (pid C) \ G\memberid m undeclared_in C \ - (\ S. G\C \\<^sub>C1 S \ G\(Class S) accessible_in (pid C) \ G\m member_of S)" +definition + inherits :: "prog \ qtname \ (qtname \ memberdecl) \ bool" ("_ \ _ inherits _" [61,61,61] 60) +where + "G\C inherits m = + (G\m inheritable_in (pid C) \ G\memberid m undeclared_in C \ + (\S. G\C \\<^sub>C1 S \ G\(Class S) accessible_in (pid C) \ G\m member_of S))" lemma inherits_member: "G\C inherits m \ G\m member_of C" by (auto simp add: inherits_def intro: members.Inherited) -definition member_in :: "prog \ (qtname \ memberdecl) \ qtname \ bool" ("_ \ _ member'_in _" [61,61,61] 60) where -"G\m member_in C \ \ provC. G\ C \\<^sub>C provC \ G \ m member_of provC" +definition + member_in :: "prog \ (qtname \ memberdecl) \ qtname \ bool" ("_ \ _ member'_in _" [61,61,61] 60) + where "G\m member_in C = (\ provC. G\ C \\<^sub>C provC \ G \ m member_of provC)" text {* A member is in a class if it is member of the class or a superclass. If a member is in a class we can select this member. This additional notion is necessary since not all members are inherited to subclasses. So such @@ -703,13 +726,15 @@ subsubsection "Hiding" -definition hides :: "prog \ (qtname \ mdecl) \ (qtname \ mdecl) \ bool" ("_\ _ hides _" [61,61,61] 60) where -"G\new hides old - \ is_static new \ msig new = msig old \ - G\(declclass new) \\<^sub>C (declclass old) \ - G\Method new declared_in (declclass new) \ - G\Method old declared_in (declclass old) \ - G\Method old inheritable_in pid (declclass new)" +definition + hides :: "prog \ (qtname \ mdecl) \ (qtname \ mdecl) \ bool" ("_\ _ hides _" [61,61,61] 60) +where + "G\new hides old = + (is_static new \ msig new = msig old \ + G\(declclass new) \\<^sub>C (declclass old) \ + G\Method new declared_in (declclass new) \ + G\Method old declared_in (declclass old) \ + G\Method old inheritable_in pid (declclass new))" abbreviation sig_hides:: "prog \ sig \ (qtname \ methd) \ (qtname \ methd) \ bool" @@ -762,16 +787,18 @@ by (auto simp add: hides_def) subsubsection "permits access" -definition permits_acc :: "prog \ (qtname \ memberdecl) \ qtname \ qtname \ bool" ("_ \ _ in _ permits'_acc'_from _" [61,61,61,61] 60) where -"G\membr in cls permits_acc_from accclass - \ (case (accmodi membr) of - Private \ (declclass membr = accclass) - | Package \ (pid (declclass membr) = pid accclass) - | Protected \ (pid (declclass membr) = pid accclass) +definition + permits_acc :: "prog \ (qtname \ memberdecl) \ qtname \ qtname \ bool" ("_ \ _ in _ permits'_acc'_from _" [61,61,61,61] 60) +where + "G\membr in cls permits_acc_from accclass = + (case (accmodi membr) of + Private \ (declclass membr = accclass) + | Package \ (pid (declclass membr) = pid accclass) + | Protected \ (pid (declclass membr) = pid accclass) \ (G\accclass \\<^sub>C declclass membr \ (G\cls \\<^sub>C accclass \ is_static membr)) - | Public \ True)" + | Public \ True)" text {* The subcondition of the @{term "Protected"} case: @{term "G\accclass \\<^sub>C declclass membr"} could also be relaxed to: @@ -1380,24 +1407,25 @@ translations (type) "fspec" <= (type) "vname \ qtname" -definition imethds :: "prog \ qtname \ (sig,qtname \ mhead) tables" where -"imethds G I - \ iface_rec G I - (\I i ts. (Un_tables ts) \\ +definition + imethds :: "prog \ qtname \ (sig,qtname \ mhead) tables" where + "imethds G I = + iface_rec G I (\I i ts. (Un_tables ts) \\ (Option.set \ table_of (map (\(s,m). (s,I,m)) (imethods i))))" text {* methods of an interface, with overriding and inheritance, cf. 9.2 *} -definition accimethds :: "prog \ pname \ qtname \ (sig,qtname \ mhead) tables" where -"accimethds G pack I - \ if G\Iface I accessible_in pack - then imethds G I - else (\ k. {})" +definition + accimethds :: "prog \ pname \ qtname \ (sig,qtname \ mhead) tables" where + "accimethds G pack I = + (if G\Iface I accessible_in pack + then imethds G I + else (\ k. {}))" text {* only returns imethds if the interface is accessible *} -definition methd :: "prog \ qtname \ (sig,qtname \ methd) table" where - -"methd G C - \ class_rec G C empty +definition + methd :: "prog \ qtname \ (sig,qtname \ methd) table" where + "methd G C = + class_rec G C empty (\C c subcls_mthds. filter_tab (\sig m. G\C inherits method sig m) subcls_mthds @@ -1409,10 +1437,10 @@ Every new method with the same signature coalesces the method of a superclass. *} -definition accmethd :: "prog \ qtname \ qtname \ (sig,qtname \ methd) table" where -"accmethd G S C - \ filter_tab (\sig m. G\method sig m of C accessible_from S) - (methd G C)" +definition + accmethd :: "prog \ qtname \ qtname \ (sig,qtname \ methd) table" where + "accmethd G S C = + filter_tab (\sig m. G\method sig m of C accessible_from S) (methd G C)" text {* @{term "accmethd G S C"}: only those methods of @{term "methd G C"}, accessible from S *} @@ -1423,23 +1451,24 @@ So we must test accessibility of method @{term m} of class @{term C} (not @{term "declclass m"}) *} -definition dynmethd :: "prog \ qtname \ qtname \ (sig,qtname \ methd) table" where -"dynmethd G statC dynC - \ \ sig. - (if G\dynC \\<^sub>C statC - then (case methd G statC sig of - None \ None - | Some statM - \ (class_rec G dynC empty - (\C c subcls_mthds. - subcls_mthds - ++ - (filter_tab - (\ _ dynM. G,sig\dynM overrides statM \ dynM=statM) - (methd G C) )) - ) sig - ) - else None)" +definition + dynmethd :: "prog \ qtname \ qtname \ (sig,qtname \ methd) table" where + "dynmethd G statC dynC = + (\sig. + (if G\dynC \\<^sub>C statC + then (case methd G statC sig of + None \ None + | Some statM + \ (class_rec G dynC empty + (\C c subcls_mthds. + subcls_mthds + ++ + (filter_tab + (\ _ dynM. G,sig\dynM overrides statM \ dynM=statM) + (methd G C) )) + ) sig + ) + else None))" text {* @{term "dynmethd G statC dynC"}: dynamic method lookup of a reference with dynamic class @{term dynC} and static class @{term statC} *} @@ -1449,11 +1478,12 @@ filters the new methods (to get only those methods which actually override the methods of the static class) *} -definition dynimethd :: "prog \ qtname \ qtname \ (sig,qtname \ methd) table" where -"dynimethd G I dynC - \ \ sig. if imethds G I sig \ {} - then methd G dynC sig - else dynmethd G Object dynC sig" +definition + dynimethd :: "prog \ qtname \ qtname \ (sig,qtname \ methd) table" where + "dynimethd G I dynC = + (\sig. if imethds G I sig \ {} + then methd G dynC sig + else dynmethd G Object dynC sig)" text {* @{term "dynimethd G I dynC"}: dynamic method lookup of a reference with dynamic class dynC and static interface type I *} text {* @@ -1468,31 +1498,34 @@ down to the actual dynamic class. *} -definition dynlookup :: "prog \ ref_ty \ qtname \ (sig,qtname \ methd) table" where -"dynlookup G statT dynC - \ (case statT of - NullT \ empty - | IfaceT I \ dynimethd G I dynC - | ClassT statC \ dynmethd G statC dynC - | ArrayT ty \ dynmethd G Object dynC)" +definition + dynlookup :: "prog \ ref_ty \ qtname \ (sig,qtname \ methd) table" where + "dynlookup G statT dynC = + (case statT of + NullT \ empty + | IfaceT I \ dynimethd G I dynC + | ClassT statC \ dynmethd G statC dynC + | ArrayT ty \ dynmethd G Object dynC)" text {* @{term "dynlookup G statT dynC"}: dynamic lookup of a method within the static reference type statT and the dynamic class dynC. In a wellformd context statT will not be NullT and in case statT is an array type, dynC=Object *} -definition fields :: "prog \ qtname \ ((vname \ qtname) \ field) list" where -"fields G C - \ class_rec G C [] (\C c ts. map (\(n,t). ((n,C),t)) (cfields c) @ ts)" +definition + fields :: "prog \ qtname \ ((vname \ qtname) \ field) list" where + "fields G C = + class_rec G C [] (\C c ts. map (\(n,t). ((n,C),t)) (cfields c) @ ts)" text {* @{term "fields G C"} list of fields of a class, including all the fields of the superclasses (private, inherited and hidden ones) not only the accessible ones (an instance of a object allocates all these fields *} -definition accfield :: "prog \ qtname \ qtname \ (vname, qtname \ field) table" where -"accfield G S C - \ let field_tab = table_of((map (\((n,d),f).(n,(d,f)))) (fields G C)) - in filter_tab (\n (declC,f). G\ (declC,fdecl (n,f)) of C accessible_from S) - field_tab" +definition + accfield :: "prog \ qtname \ qtname \ (vname, qtname \ field) table" where + "accfield G S C = + (let field_tab = table_of((map (\((n,d),f).(n,(d,f)))) (fields G C)) + in filter_tab (\n (declC,f). G\ (declC,fdecl (n,f)) of C accessible_from S) + field_tab)" text {* @{term "accfield G C S"}: fields of a class @{term C} which are accessible from scope of class @{term S} with inheritance and hiding, cf. 8.3 *} @@ -1503,11 +1536,13 @@ inheritance, too. So we must test accessibility of field @{term f} of class @{term C} (not @{term "declclass f"}) *} -definition is_methd :: "prog \ qtname \ sig \ bool" where - "is_methd G \ \C sig. is_class G C \ methd G C sig \ None" +definition + is_methd :: "prog \ qtname \ sig \ bool" + where "is_methd G = (\C sig. is_class G C \ methd G C sig \ None)" -definition efname :: "((vname \ qtname) \ field) \ (vname \ qtname)" where -"efname \ fst" +definition + efname :: "((vname \ qtname) \ field) \ (vname \ qtname)" + where "efname = fst" lemma efname_simp[simp]:"efname (n,f) = n" by (simp add: efname_def) @@ -2270,8 +2305,9 @@ section "calculation of the superclasses of a class" -definition superclasses :: "prog \ qtname \ qtname set" where - "superclasses G C \ class_rec G C {} +definition + superclasses :: "prog \ qtname \ qtname set" where + "superclasses G C = class_rec G C {} (\ C c superclss. (if C=Object then {} else insert (super c) superclss))" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/DefiniteAssignment.thy --- a/src/HOL/Bali/DefiniteAssignment.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/DefiniteAssignment.thy Mon Jul 26 17:41:26 2010 +0200 @@ -49,33 +49,33 @@ with a jump, since no breaks, continues or returns are allowed in an expression. *} -consts jumpNestingOkS :: "jump set \ stmt \ bool" -primrec -"jumpNestingOkS jmps (Skip) = True" -"jumpNestingOkS jmps (Expr e) = True" -"jumpNestingOkS jmps (j\ s) = jumpNestingOkS ({j} \ jmps) s" -"jumpNestingOkS jmps (c1;;c2) = (jumpNestingOkS jmps c1 \ - jumpNestingOkS jmps c2)" -"jumpNestingOkS jmps (If(e) c1 Else c2) = (jumpNestingOkS jmps c1 \ - jumpNestingOkS jmps c2)" -"jumpNestingOkS jmps (l\ While(e) c) = jumpNestingOkS ({Cont l} \ jmps) c" +primrec jumpNestingOkS :: "jump set \ stmt \ bool" +where + "jumpNestingOkS jmps (Skip) = True" +| "jumpNestingOkS jmps (Expr e) = True" +| "jumpNestingOkS jmps (j\ s) = jumpNestingOkS ({j} \ jmps) s" +| "jumpNestingOkS jmps (c1;;c2) = (jumpNestingOkS jmps c1 \ + jumpNestingOkS jmps c2)" +| "jumpNestingOkS jmps (If(e) c1 Else c2) = (jumpNestingOkS jmps c1 \ + jumpNestingOkS jmps c2)" +| "jumpNestingOkS jmps (l\ While(e) c) = jumpNestingOkS ({Cont l} \ jmps) c" --{* The label of the while loop only handles continue jumps. Breaks are only handled by @{term Lab} *} -"jumpNestingOkS jmps (Jmp j) = (j \ jmps)" -"jumpNestingOkS jmps (Throw e) = True" -"jumpNestingOkS jmps (Try c1 Catch(C vn) c2) = (jumpNestingOkS jmps c1 \ - jumpNestingOkS jmps c2)" -"jumpNestingOkS jmps (c1 Finally c2) = (jumpNestingOkS jmps c1 \ - jumpNestingOkS jmps c2)" -"jumpNestingOkS jmps (Init C) = True" +| "jumpNestingOkS jmps (Jmp j) = (j \ jmps)" +| "jumpNestingOkS jmps (Throw e) = True" +| "jumpNestingOkS jmps (Try c1 Catch(C vn) c2) = (jumpNestingOkS jmps c1 \ + jumpNestingOkS jmps c2)" +| "jumpNestingOkS jmps (c1 Finally c2) = (jumpNestingOkS jmps c1 \ + jumpNestingOkS jmps c2)" +| "jumpNestingOkS jmps (Init C) = True" --{* wellformedness of the program must enshure that for all initializers jumpNestingOkS {} holds *} --{* Dummy analysis for intermediate smallstep term @{term FinA} *} -"jumpNestingOkS jmps (FinA a c) = False" +| "jumpNestingOkS jmps (FinA a c) = False" definition jumpNestingOk :: "jump set \ term \ bool" where -"jumpNestingOk jmps t \ (case t of +"jumpNestingOk jmps t = (case t of In1 se \ (case se of Inl e \ True | Inr s \ jumpNestingOkS jmps s) @@ -116,48 +116,46 @@ subsection {* Very restricted calculation fallback calculation *} -consts the_LVar_name:: "var \ lname" -primrec -"the_LVar_name (LVar n) = n" +primrec the_LVar_name :: "var \ lname" + where "the_LVar_name (LVar n) = n" -consts assignsE :: "expr \ lname set" - assignsV :: "var \ lname set" - assignsEs:: "expr list \ lname set" -text {* *} -primrec -"assignsE (NewC c) = {}" -"assignsE (NewA t e) = assignsE e" -"assignsE (Cast t e) = assignsE e" -"assignsE (e InstOf r) = assignsE e" -"assignsE (Lit val) = {}" -"assignsE (UnOp unop e) = assignsE e" -"assignsE (BinOp binop e1 e2) = (if binop=CondAnd \ binop=CondOr - then (assignsE e1) - else (assignsE e1) \ (assignsE e2))" -"assignsE (Super) = {}" -"assignsE (Acc v) = assignsV v" -"assignsE (v:=e) = (assignsV v) \ (assignsE e) \ - (if \ n. v=(LVar n) then {the_LVar_name v} - else {})" -"assignsE (b? e1 : e2) = (assignsE b) \ ((assignsE e1) \ (assignsE e2))" -"assignsE ({accC,statT,mode}objRef\mn({pTs}args)) - = (assignsE objRef) \ (assignsEs args)" +primrec assignsE :: "expr \ lname set" + and assignsV :: "var \ lname set" + and assignsEs:: "expr list \ lname set" +where + "assignsE (NewC c) = {}" +| "assignsE (NewA t e) = assignsE e" +| "assignsE (Cast t e) = assignsE e" +| "assignsE (e InstOf r) = assignsE e" +| "assignsE (Lit val) = {}" +| "assignsE (UnOp unop e) = assignsE e" +| "assignsE (BinOp binop e1 e2) = (if binop=CondAnd \ binop=CondOr + then (assignsE e1) + else (assignsE e1) \ (assignsE e2))" +| "assignsE (Super) = {}" +| "assignsE (Acc v) = assignsV v" +| "assignsE (v:=e) = (assignsV v) \ (assignsE e) \ + (if \ n. v=(LVar n) then {the_LVar_name v} + else {})" +| "assignsE (b? e1 : e2) = (assignsE b) \ ((assignsE e1) \ (assignsE e2))" +| "assignsE ({accC,statT,mode}objRef\mn({pTs}args)) + = (assignsE objRef) \ (assignsEs args)" -- {* Only dummy analysis for intermediate expressions @{term Methd}, @{term Body}, @{term InsInitE} and @{term Callee} *} -"assignsE (Methd C sig) = {}" -"assignsE (Body C s) = {}" -"assignsE (InsInitE s e) = {}" -"assignsE (Callee l e) = {}" +| "assignsE (Methd C sig) = {}" +| "assignsE (Body C s) = {}" +| "assignsE (InsInitE s e) = {}" +| "assignsE (Callee l e) = {}" -"assignsV (LVar n) = {}" -"assignsV ({accC,statDeclC,stat}objRef..fn) = assignsE objRef" -"assignsV (e1.[e2]) = assignsE e1 \ assignsE e2" +| "assignsV (LVar n) = {}" +| "assignsV ({accC,statDeclC,stat}objRef..fn) = assignsE objRef" +| "assignsV (e1.[e2]) = assignsE e1 \ assignsE e2" -"assignsEs [] = {}" -"assignsEs (e#es) = assignsE e \ assignsEs es" +| "assignsEs [] = {}" +| "assignsEs (e#es) = assignsE e \ assignsEs es" definition assigns :: "term \ lname set" where -"assigns t \ (case t of +"assigns t = (case t of In1 se \ (case se of Inl e \ assignsE e | Inr s \ {}) @@ -190,42 +188,42 @@ subsection "Analysis of constant expressions" -consts constVal :: "expr \ val option" -primrec -"constVal (NewC c) = None" -"constVal (NewA t e) = None" -"constVal (Cast t e) = None" -"constVal (Inst e r) = None" -"constVal (Lit val) = Some val" -"constVal (UnOp unop e) = (case (constVal e) of - None \ None - | Some v \ Some (eval_unop unop v))" -"constVal (BinOp binop e1 e2) = (case (constVal e1) of - None \ None - | Some v1 \ (case (constVal e2) of - None \ None - | Some v2 \ Some (eval_binop - binop v1 v2)))" -"constVal (Super) = None" -"constVal (Acc v) = None" -"constVal (Ass v e) = None" -"constVal (Cond b e1 e2) = (case (constVal b) of +primrec constVal :: "expr \ val option" +where + "constVal (NewC c) = None" +| "constVal (NewA t e) = None" +| "constVal (Cast t e) = None" +| "constVal (Inst e r) = None" +| "constVal (Lit val) = Some val" +| "constVal (UnOp unop e) = (case (constVal e) of None \ None - | Some bv\ (case the_Bool bv of - True \ (case (constVal e2) of - None \ None - | Some v \ constVal e1) - | False\ (case (constVal e1) of - None \ None - | Some v \ constVal e2)))" + | Some v \ Some (eval_unop unop v))" +| "constVal (BinOp binop e1 e2) = (case (constVal e1) of + None \ None + | Some v1 \ (case (constVal e2) of + None \ None + | Some v2 \ Some (eval_binop + binop v1 v2)))" +| "constVal (Super) = None" +| "constVal (Acc v) = None" +| "constVal (Ass v e) = None" +| "constVal (Cond b e1 e2) = (case (constVal b) of + None \ None + | Some bv\ (case the_Bool bv of + True \ (case (constVal e2) of + None \ None + | Some v \ constVal e1) + | False\ (case (constVal e1) of + None \ None + | Some v \ constVal e2)))" --{* Note that @{text "constVal (Cond b e1 e2)"} is stricter as it could be. It requires that all tree expressions are constant even if we can decide which branch to choose, provided the constant value of @{term b} *} -"constVal (Call accC statT mode objRef mn pTs args) = None" -"constVal (Methd C sig) = None" -"constVal (Body C s) = None" -"constVal (InsInitE s e) = None" -"constVal (Callee l e) = None" +| "constVal (Call accC statT mode objRef mn pTs args) = None" +| "constVal (Methd C sig) = None" +| "constVal (Body C s) = None" +| "constVal (InsInitE s e) = None" +| "constVal (Callee l e) = None" lemma constVal_Some_induct [consumes 1, case_names Lit UnOp BinOp CondL CondR]: assumes const: "constVal e = Some v" and @@ -282,55 +280,55 @@ to a specific boolean value. If the expression cannot evaluate to a @{term Boolean} value UNIV is returned. If we expect true/false the opposite constant false/true will also lead to UNIV. *} -consts assigns_if:: "bool \ expr \ lname set" -primrec -"assigns_if b (NewC c) = UNIV" --{*can never evaluate to Boolean*} -"assigns_if b (NewA t e) = UNIV" --{*can never evaluate to Boolean*} -"assigns_if b (Cast t e) = assigns_if b e" -"assigns_if b (Inst e r) = assignsE e" --{*Inst has type Boolean but - e is a reference type*} -"assigns_if b (Lit val) = (if val=Bool b then {} else UNIV)" -"assigns_if b (UnOp unop e) = (case constVal (UnOp unop e) of - None \ (if unop = UNot - then assigns_if (\b) e - else UNIV) - | Some v \ (if v=Bool b - then {} - else UNIV))" -"assigns_if b (BinOp binop e1 e2) - = (case constVal (BinOp binop e1 e2) of - None \ (if binop=CondAnd then - (case b of - True \ assigns_if True e1 \ assigns_if True e2 - | False \ assigns_if False e1 \ - (assigns_if True e1 \ assigns_if False e2)) - else - (if binop=CondOr then - (case b of - True \ assigns_if True e1 \ - (assigns_if False e1 \ assigns_if True e2) - | False \ assigns_if False e1 \ assigns_if False e2) - else assignsE e1 \ assignsE e2)) - | Some v \ (if v=Bool b then {} else UNIV))" +primrec assigns_if :: "bool \ expr \ lname set" +where + "assigns_if b (NewC c) = UNIV" --{*can never evaluate to Boolean*} +| "assigns_if b (NewA t e) = UNIV" --{*can never evaluate to Boolean*} +| "assigns_if b (Cast t e) = assigns_if b e" +| "assigns_if b (Inst e r) = assignsE e" --{*Inst has type Boolean but + e is a reference type*} +| "assigns_if b (Lit val) = (if val=Bool b then {} else UNIV)" +| "assigns_if b (UnOp unop e) = (case constVal (UnOp unop e) of + None \ (if unop = UNot + then assigns_if (\b) e + else UNIV) + | Some v \ (if v=Bool b + then {} + else UNIV))" +| "assigns_if b (BinOp binop e1 e2) + = (case constVal (BinOp binop e1 e2) of + None \ (if binop=CondAnd then + (case b of + True \ assigns_if True e1 \ assigns_if True e2 + | False \ assigns_if False e1 \ + (assigns_if True e1 \ assigns_if False e2)) + else + (if binop=CondOr then + (case b of + True \ assigns_if True e1 \ + (assigns_if False e1 \ assigns_if True e2) + | False \ assigns_if False e1 \ assigns_if False e2) + else assignsE e1 \ assignsE e2)) + | Some v \ (if v=Bool b then {} else UNIV))" -"assigns_if b (Super) = UNIV" --{*can never evaluate to Boolean*} -"assigns_if b (Acc v) = (assignsV v)" -"assigns_if b (v := e) = (assignsE (Ass v e))" -"assigns_if b (c? e1 : e2) = (assignsE c) \ - (case (constVal c) of - None \ (assigns_if b e1) \ - (assigns_if b e2) - | Some bv \ (case the_Bool bv of - True \ assigns_if b e1 - | False \ assigns_if b e2))" -"assigns_if b ({accC,statT,mode}objRef\mn({pTs}args)) - = assignsE ({accC,statT,mode}objRef\mn({pTs}args)) " +| "assigns_if b (Super) = UNIV" --{*can never evaluate to Boolean*} +| "assigns_if b (Acc v) = (assignsV v)" +| "assigns_if b (v := e) = (assignsE (Ass v e))" +| "assigns_if b (c? e1 : e2) = (assignsE c) \ + (case (constVal c) of + None \ (assigns_if b e1) \ + (assigns_if b e2) + | Some bv \ (case the_Bool bv of + True \ assigns_if b e1 + | False \ assigns_if b e2))" +| "assigns_if b ({accC,statT,mode}objRef\mn({pTs}args)) + = assignsE ({accC,statT,mode}objRef\mn({pTs}args)) " -- {* Only dummy analysis for intermediate expressions @{term Methd}, @{term Body}, @{term InsInitE} and @{term Callee} *} -"assigns_if b (Methd C sig) = {}" -"assigns_if b (Body C s) = {}" -"assigns_if b (InsInitE s e) = {}" -"assigns_if b (Callee l e) = {}" +| "assigns_if b (Methd C sig) = {}" +| "assigns_if b (Body C s) = {}" +| "assigns_if b (InsInitE s e) = {}" +| "assigns_if b (Callee l e) = {}" lemma assigns_if_const_b_simp: assumes boolConst: "constVal e = Some (Bool b)" (is "?Const b e") @@ -429,14 +427,17 @@ subsection {* Lifting set operations to range of tables (map to a set) *} -definition union_ts :: "('a,'b) tables \ ('a,'b) tables \ ('a,'b) tables" ("_ \\ _" [67,67] 65) where - "A \\ B \ \ k. A k \ B k" +definition + union_ts :: "('a,'b) tables \ ('a,'b) tables \ ('a,'b) tables" ("_ \\ _" [67,67] 65) + where "A \\ B = (\ k. A k \ B k)" -definition intersect_ts :: "('a,'b) tables \ ('a,'b) tables \ ('a,'b) tables" ("_ \\ _" [72,72] 71) where - "A \\ B \ \ k. A k \ B k" +definition + intersect_ts :: "('a,'b) tables \ ('a,'b) tables \ ('a,'b) tables" ("_ \\ _" [72,72] 71) + where "A \\ B = (\k. A k \ B k)" -definition all_union_ts :: "('a,'b) tables \ 'b set \ ('a,'b) tables" (infixl "\\\<^sub>\" 40) where - "A \\\<^sub>\ B \ \ k. A k \ B" +definition + all_union_ts :: "('a,'b) tables \ 'b set \ ('a,'b) tables" (infixl "\\\<^sub>\" 40) + where "(A \\\<^sub>\ B) = (\ k. A k \ B)" subsubsection {* Binary union of tables *} @@ -507,16 +508,19 @@ brk :: "breakass" --{* Definetly assigned variables for abrupt completion with a break *} -definition rmlab :: "'a \ ('a,'b) tables \ ('a,'b) tables" where -"rmlab k A \ \ x. if x=k then UNIV else A x" +definition + rmlab :: "'a \ ('a,'b) tables \ ('a,'b) tables" + where "rmlab k A = (\x. if x=k then UNIV else A x)" (* -definition setbrk :: "breakass \ assigned \ breakass set" where -"setbrk b A \ {b} \ {a| a. a\ brk A \ lab a \ lab b}" +definition + setbrk :: "breakass \ assigned \ breakass set" where + "setbrk b A = {b} \ {a| a. a\ brk A \ lab a \ lab b}" *) -definition range_inter_ts :: "('a,'b) tables \ 'b set" ("\\_" 80) where - "\\A \ {x |x. \ k. x \ A k}" +definition + range_inter_ts :: "('a,'b) tables \ 'b set" ("\\_" 80) + where "\\A = {x |x. \ k. x \ A k}" text {* In @{text "E\ B \t\ A"}, diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Eval.thy --- a/src/HOL/Bali/Eval.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Eval.thy Mon Jul 26 17:41:26 2010 +0200 @@ -141,7 +141,7 @@ where "\es\\<^sub>l == In3 es" definition undefined3 :: "('al + 'ar, 'b, 'c) sum3 \ vals" where - "undefined3 \ sum3_case (In1 \ sum_case (\x. undefined) (\x. Unit)) + "undefined3 = sum3_case (In1 \ sum_case (\x. undefined) (\x. Unit)) (\x. In2 undefined) (\x. In3 undefined)" lemma [simp]: "undefined3 (In1l x) = In1 undefined" @@ -159,8 +159,9 @@ section "exception throwing and catching" -definition throw :: "val \ abopt \ abopt" where - "throw a' x \ abrupt_if True (Some (Xcpt (Loc (the_Addr a')))) (np a' x)" +definition + throw :: "val \ abopt \ abopt" where + "throw a' x = abrupt_if True (Some (Xcpt (Loc (the_Addr a')))) (np a' x)" lemma throw_def2: "throw a' x = abrupt_if True (Some (Xcpt (Loc (the_Addr a')))) (np a' x)" @@ -168,8 +169,9 @@ apply (simp (no_asm)) done -definition fits :: "prog \ st \ val \ ty \ bool" ("_,_\_ fits _"[61,61,61,61]60) where - "G,s\a' fits T \ (\rt. T=RefT rt) \ a'=Null \ G\obj_ty(lookup_obj s a')\T" +definition + fits :: "prog \ st \ val \ ty \ bool" ("_,_\_ fits _"[61,61,61,61]60) + where "G,s\a' fits T = ((\rt. T=RefT rt) \ a'=Null \ G\obj_ty(lookup_obj s a')\T)" lemma fits_Null [simp]: "G,s\Null fits T" by (simp add: fits_def) @@ -192,9 +194,10 @@ apply iprover done -definition catch :: "prog \ state \ qtname \ bool" ("_,_\catch _"[61,61,61]60) where - "G,s\catch C\\xc. abrupt s=Some (Xcpt xc) \ - G,store s\Addr (the_Loc xc) fits Class C" +definition + catch :: "prog \ state \ qtname \ bool" ("_,_\catch _"[61,61,61]60) where + "G,s\catch C = (\xc. abrupt s=Some (Xcpt xc) \ + G,store s\Addr (the_Loc xc) fits Class C)" lemma catch_Norm [simp]: "\G,Norm s\catch tn" apply (unfold catch_def) @@ -217,9 +220,9 @@ apply (simp (no_asm)) done -definition new_xcpt_var :: "vname \ state \ state" where - "new_xcpt_var vn \ - \(x,s). Norm (lupd(VName vn\Addr (the_Loc (the_Xcpt (the x)))) s)" +definition + new_xcpt_var :: "vname \ state \ state" where + "new_xcpt_var vn = (\(x,s). Norm (lupd(VName vn\Addr (the_Loc (the_Xcpt (the x)))) s))" lemma new_xcpt_var_def2 [simp]: "new_xcpt_var vn (x,s) = @@ -232,9 +235,10 @@ section "misc" -definition assign :: "('a \ state \ state) \ 'a \ state \ state" where - "assign f v \ \(x,s). let (x',s') = (if x = None then f v else id) (x,s) - in (x',if x' = None then s' else s)" +definition + assign :: "('a \ state \ state) \ 'a \ state \ state" where + "assign f v = (\(x,s). let (x',s') = (if x = None then f v else id) (x,s) + in (x',if x' = None then s' else s))" (* lemma assign_Norm_Norm [simp]: @@ -293,26 +297,29 @@ done *) -definition init_comp_ty :: "ty \ stmt" where - "init_comp_ty T \ if (\C. T = Class C) then Init (the_Class T) else Skip" +definition + init_comp_ty :: "ty \ stmt" + where "init_comp_ty T = (if (\C. T = Class C) then Init (the_Class T) else Skip)" lemma init_comp_ty_PrimT [simp]: "init_comp_ty (PrimT pt) = Skip" apply (unfold init_comp_ty_def) apply (simp (no_asm)) done -definition invocation_class :: "inv_mode \ st \ val \ ref_ty \ qtname" where - "invocation_class m s a' statT - \ (case m of - Static \ if (\ statC. statT = ClassT statC) - then the_Class (RefT statT) - else Object - | SuperM \ the_Class (RefT statT) - | IntVir \ obj_class (lookup_obj s a'))" +definition + invocation_class :: "inv_mode \ st \ val \ ref_ty \ qtname" where + "invocation_class m s a' statT = + (case m of + Static \ if (\ statC. statT = ClassT statC) + then the_Class (RefT statT) + else Object + | SuperM \ the_Class (RefT statT) + | IntVir \ obj_class (lookup_obj s a'))" -definition invocation_declclass::"prog \ inv_mode \ st \ val \ ref_ty \ sig \ qtname" where -"invocation_declclass G m s a' statT sig - \ declclass (the (dynlookup G statT +definition + invocation_declclass :: "prog \ inv_mode \ st \ val \ ref_ty \ sig \ qtname" where + "invocation_declclass G m s a' statT sig = + declclass (the (dynlookup G statT (invocation_class m s a' statT) sig))" @@ -330,10 +337,11 @@ else Object)" by (simp add: invocation_class_def) -definition init_lvars :: "prog \ qtname \ sig \ inv_mode \ val \ val list \ - state \ state" where - "init_lvars G C sig mode a' pvs - \ \ (x,s). +definition + init_lvars :: "prog \ qtname \ sig \ inv_mode \ val \ val list \ state \ state" +where + "init_lvars G C sig mode a' pvs = + (\(x,s). let m = mthd (the (methd G C sig)); l = \ k. (case k of @@ -343,7 +351,7 @@ | Res \ None) | This \ (if mode=Static then None else Some a')) - in set_lvars l (if mode = Static then x else np a' x,s)" + in set_lvars l (if mode = Static then x else np a' x,s))" @@ -364,9 +372,11 @@ apply (simp (no_asm) add: Let_def) done -definition body :: "prog \ qtname \ sig \ expr" where - "body G C sig \ let m = the (methd G C sig) - in Body (declclass m) (stmt (mbody (mthd m)))" +definition + body :: "prog \ qtname \ sig \ expr" where + "body G C sig = + (let m = the (methd G C sig) + in Body (declclass m) (stmt (mbody (mthd m))))" lemma body_def2: --{* better suited for simplification *} "body G C sig = Body (declclass (the (methd G C sig))) @@ -377,28 +387,30 @@ section "variables" -definition lvar :: "lname \ st \ vvar" where - "lvar vn s \ (the (locals s vn), \v. supd (lupd(vn\v)))" +definition + lvar :: "lname \ st \ vvar" + where "lvar vn s = (the (locals s vn), \v. supd (lupd(vn\v)))" -definition fvar :: "qtname \ bool \ vname \ val \ state \ vvar \ state" where - "fvar C stat fn a' s - \ let (oref,xf) = if stat then (Stat C,id) - else (Heap (the_Addr a'),np a'); +definition + fvar :: "qtname \ bool \ vname \ val \ state \ vvar \ state" where + "fvar C stat fn a' s = + (let (oref,xf) = if stat then (Stat C,id) + else (Heap (the_Addr a'),np a'); n = Inl (fn,C); f = (\v. supd (upd_gobj oref n v)) - in ((the (values (the (globs (store s) oref)) n),f),abupd xf s)" + in ((the (values (the (globs (store s) oref)) n),f),abupd xf s))" -definition avar :: "prog \ val \ val \ state \ vvar \ state" where - "avar G i' a' s - \ let oref = Heap (the_Addr a'); - i = the_Intg i'; - n = Inr i; - (T,k,cs) = the_Arr (globs (store s) oref); - f = (\v (x,s). (raise_if (\G,s\v fits T) +definition + avar :: "prog \ val \ val \ state \ vvar \ state" where + "avar G i' a' s = + (let oref = Heap (the_Addr a'); + i = the_Intg i'; + n = Inr i; + (T,k,cs) = the_Arr (globs (store s) oref); + f = (\v (x,s). (raise_if (\G,s\v fits T) ArrStore x ,upd_gobj oref n v s)) - in ((the (cs n),f) - ,abupd (raise_if (\i in_bounds k) IndOutBound \ np a') s)" + in ((the (cs n),f),abupd (raise_if (\i in_bounds k) IndOutBound \ np a') s))" lemma fvar_def2: --{* better suited for simplification *} "fvar C stat fn a' s = @@ -431,27 +443,29 @@ apply (simp (no_asm) add: Let_def split_beta) done -definition check_field_access :: "prog \ qtname \ qtname \ vname \ bool \ val \ state \ state" where -"check_field_access G accC statDeclC fn stat a' s - \ let oref = if stat then Stat statDeclC - else Heap (the_Addr a'); - dynC = case oref of +definition + check_field_access :: "prog \ qtname \ qtname \ vname \ bool \ val \ state \ state" where + "check_field_access G accC statDeclC fn stat a' s = + (let oref = if stat then Stat statDeclC + else Heap (the_Addr a'); + dynC = case oref of Heap a \ obj_class (the (globs (store s) oref)) | Stat C \ C; - f = (the (table_of (DeclConcepts.fields G dynC) (fn,statDeclC))) - in abupd + f = (the (table_of (DeclConcepts.fields G dynC) (fn,statDeclC))) + in abupd (error_if (\ G\Field fn (statDeclC,f) in dynC dyn_accessible_from accC) AccessViolation) - s" + s)" -definition check_method_access :: "prog \ qtname \ ref_ty \ inv_mode \ sig \ val \ state \ state" where -"check_method_access G accC statT mode sig a' s - \ let invC = invocation_class mode (store s) a' statT; +definition + check_method_access :: "prog \ qtname \ ref_ty \ inv_mode \ sig \ val \ state \ state" where + "check_method_access G accC statT mode sig a' s = + (let invC = invocation_class mode (store s) a' statT; dynM = the (dynlookup G statT invC sig) - in abupd + in abupd (error_if (\ G\Methd sig dynM in invC dyn_accessible_from accC) AccessViolation) - s" + s)" section "evaluation judgments" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Example.thy --- a/src/HOL/Bali/Example.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Example.thy Mon Jul 26 17:41:26 2010 +0200 @@ -70,22 +70,21 @@ datatype vnam' = arr' | vee' | z' | e' datatype label' = lab1' -consts - - tnam' :: "tnam' \ tnam" - vnam' :: "vnam' \ vname" +axiomatization + tnam' :: "tnam' \ tnam" and + vnam' :: "vnam' \ vname" and label':: "label' \ label" -axioms (** tnam', vnam' and label are intended to be isomorphic +where + (** tnam', vnam' and label are intended to be isomorphic to tnam, vname and label **) - inj_tnam' [simp]: "(tnam' x = tnam' y) = (x = y)" - inj_vnam' [simp]: "(vnam' x = vnam' y) = (x = y)" - inj_label' [simp]: "(label' x = label' y) = (x = y)" - - - surj_tnam': "\m. n = tnam' m" - surj_vnam': "\m. n = vnam' m" - surj_label':" \m. n = label' m" + inj_tnam' [simp]: "\x y. (tnam' x = tnam' y) = (x = y)" and + inj_vnam' [simp]: "\x y. (vnam' x = vnam' y) = (x = y)" and + inj_label' [simp]: "\x y. (label' x = label' y) = (x = y)" and + + surj_tnam': "\n. \m. n = tnam' m" and + surj_vnam': "\n. \m. n = vnam' m" and + surj_label':" \n. \m. n = label' m" abbreviation HasFoo :: qtname where @@ -149,22 +148,24 @@ Object_mdecls_def: "Object_mdecls \ []" SXcpt_mdecls_def: "SXcpt_mdecls \ []" -consts - +axiomatization foo :: mname -definition foo_sig :: sig - where "foo_sig \ \name=foo,parTs=[Class Base]\" +definition + foo_sig :: sig + where "foo_sig = \name=foo,parTs=[Class Base]\" -definition foo_mhead :: mhead - where "foo_mhead \ \access=Public,static=False,pars=[z],resT=Class Base\" +definition + foo_mhead :: mhead + where "foo_mhead = \access=Public,static=False,pars=[z],resT=Class Base\" -definition Base_foo :: mdecl - where "Base_foo \ (foo_sig, \access=Public,static=False,pars=[z],resT=Class Base, +definition + Base_foo :: mdecl + where "Base_foo = (foo_sig, \access=Public,static=False,pars=[z],resT=Class Base, mbody=\lcls=[],stmt=Return (!!z)\\)" definition Ext_foo :: mdecl - where "Ext_foo \ (foo_sig, + where "Ext_foo = (foo_sig, \access=Public,static=False,pars=[z],resT=Class Ext, mbody=\lcls=[] ,stmt=Expr({Ext,Ext,False}Cast (Class Ext) (!!z)..vee := @@ -172,11 +173,13 @@ Return (Lit Null)\ \)" -definition arr_viewed_from :: "qtname \ qtname \ var" where -"arr_viewed_from accC C \ {accC,Base,True}StatRef (ClassT C)..arr" +definition + arr_viewed_from :: "qtname \ qtname \ var" + where "arr_viewed_from accC C = {accC,Base,True}StatRef (ClassT C)..arr" -definition BaseCl :: "class" where -"BaseCl \ \access=Public, +definition + BaseCl :: "class" where + "BaseCl = \access=Public, cfields=[(arr, \access=Public,static=True ,type=PrimT Boolean.[]\), (vee, \access=Public,static=False,type=Iface HasFoo \)], methods=[Base_foo], @@ -185,16 +188,18 @@ super=Object, superIfs=[HasFoo]\" -definition ExtCl :: "class" where -"ExtCl \ \access=Public, +definition + ExtCl :: "class" where + "ExtCl = \access=Public, cfields=[(vee, \access=Public,static=False,type= PrimT Integer\)], methods=[Ext_foo], init=Skip, super=Base, superIfs=[]\" -definition MainCl :: "class" where -"MainCl \ \access=Public, +definition + MainCl :: "class" where + "MainCl = \access=Public, cfields=[], methods=[], init=Skip, @@ -202,14 +207,17 @@ superIfs=[]\" (* The "main" method is modeled seperately (see tprg) *) -definition HasFooInt :: iface - where "HasFooInt \ \access=Public,imethods=[(foo_sig, foo_mhead)],isuperIfs=[]\" +definition + HasFooInt :: iface + where "HasFooInt = \access=Public,imethods=[(foo_sig, foo_mhead)],isuperIfs=[]\" -definition Ifaces ::"idecl list" - where "Ifaces \ [(HasFoo,HasFooInt)]" +definition + Ifaces ::"idecl list" + where "Ifaces = [(HasFoo,HasFooInt)]" -definition "Classes" ::"cdecl list" - where "Classes \ [(Base,BaseCl),(Ext,ExtCl),(Main,MainCl)]@standard_classes" +definition + "Classes" ::"cdecl list" + where "Classes = [(Base,BaseCl),(Ext,ExtCl),(Main,MainCl)]@standard_classes" lemmas table_classes_defs = Classes_def standard_classes_def ObjectC_def SXcptC_def @@ -264,12 +272,13 @@ tprg :: prog where "tprg == \ifaces=Ifaces,classes=Classes\" -definition test :: "(ty)list \ stmt" where - "test pTs \ e:==NewC Ext;; +definition + test :: "(ty)list \ stmt" where + "test pTs = (e:==NewC Ext;; \ Try Expr({Main,ClassT Base,IntVir}!!e\foo({pTs}[Lit Null])) \ Catch((SXcpt NullPointer) z) (lab1\ While(Acc - (Acc (arr_viewed_from Main Ext).[Lit (Intg 2)])) Skip)" + (Acc (arr_viewed_from Main Ext).[Lit (Intg 2)])) Skip))" section "well-structuredness" @@ -1185,9 +1194,9 @@ rewrite_rule [@{thm assign_def}, @{thm Let_def}]) @{thms eval.intros}) *} lemmas eval_Is = eval_Init eval_StatRef AbruptIs eval_intros -consts - a :: loc - b :: loc +axiomatization + a :: loc and + b :: loc and c :: loc abbreviation "one == Suc 0" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Name.thy --- a/src/HOL/Bali/Name.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Name.thy Mon Jul 26 17:41:26 2010 +0200 @@ -68,14 +68,14 @@ begin definition - tname_tname_def: "tname (t::tname) \ t" + tname_tname_def: "tname (t::tname) = t" instance .. end definition - qtname_qtname_def: "qtname (q::'a qtname_ext_type) \ q" + qtname_qtname_def: "qtname (q::'a qtname_ext_type) = q" translations (type) "qtname" <= (type) "\pid::pname,tid::tname\" @@ -84,16 +84,17 @@ axiomatization java_lang::pname --{* package java.lang *} -consts +definition Object :: qtname - SXcpt :: "xname \ qtname" -defs - Object_def: "Object \ \pid = java_lang, tid = Object'\" - SXcpt_def: "SXcpt \ \x. \pid = java_lang, tid = SXcpt' x\" + where "Object = \pid = java_lang, tid = Object'\" + +definition SXcpt :: "xname \ qtname" + where "SXcpt = (\x. \pid = java_lang, tid = SXcpt' x\)" lemma Object_neq_SXcpt [simp]: "Object \ SXcpt xn" by (simp add: Object_def SXcpt_def) lemma SXcpt_inject [simp]: "(SXcpt xn = SXcpt xm) = (xn = xm)" by (simp add: SXcpt_def) + end diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/State.thy --- a/src/HOL/Bali/State.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/State.thy Mon Jul 26 17:41:26 2010 +0200 @@ -38,8 +38,9 @@ (type) "obj" <= (type) "\tag::obj_tag, values::vn \ val option\" (type) "obj" <= (type) "\tag::obj_tag, values::vn \ val option,\::'a\" -definition the_Arr :: "obj option \ ty \ int \ (vn, val) table" where - "the_Arr obj \ SOME (T,k,t). obj = Some \tag=Arr T k,values=t\" +definition + the_Arr :: "obj option \ ty \ int \ (vn, val) table" + where "the_Arr obj = (SOME (T,k,t). obj = Some \tag=Arr T k,values=t\)" lemma the_Arr_Arr [simp]: "the_Arr (Some \tag=Arr T k,values=cs\) = (T,k,cs)" apply (auto simp: the_Arr_def) @@ -50,18 +51,20 @@ apply (auto simp add: the_Arr_def) done -definition upd_obj :: "vn \ val \ obj \ obj" where - "upd_obj n v \ \ obj . obj \values:=(values obj)(n\v)\" +definition + upd_obj :: "vn \ val \ obj \ obj" + where "upd_obj n v = (\obj. obj \values:=(values obj)(n\v)\)" lemma upd_obj_def2 [simp]: "upd_obj n v obj = obj \values:=(values obj)(n\v)\" apply (auto simp: upd_obj_def) done -definition obj_ty :: "obj \ ty" where - "obj_ty obj \ case tag obj of - CInst C \ Class C - | Arr T k \ T.[]" +definition + obj_ty :: "obj \ ty" where + "obj_ty obj = (case tag obj of + CInst C \ Class C + | Arr T k \ T.[])" lemma obj_ty_eq [intro!]: "obj_ty \tag=oi,values=x\ = obj_ty \tag=oi,values=y\" by (simp add: obj_ty_def) @@ -97,10 +100,11 @@ apply (auto split add: obj_tag.split_asm) done -definition obj_class :: "obj \ qtname" where - "obj_class obj \ case tag obj of - CInst C \ C - | Arr T k \ Object" +definition + obj_class :: "obj \ qtname" where + "obj_class obj = (case tag obj of + CInst C \ C + | Arr T k \ Object)" lemma obj_class_CInst [simp]: "obj_class \tag=CInst C,values=vs\ = C" @@ -136,9 +140,10 @@ "Stat" => "CONST Inr" (type) "oref" <= (type) "loc + qtname" -definition fields_table :: "prog \ qtname \ (fspec \ field \ bool) \ (fspec, ty) table" where - "fields_table G C P - \ Option.map type \ table_of (filter (split P) (DeclConcepts.fields G C))" +definition + fields_table :: "prog \ qtname \ (fspec \ field \ bool) \ (fspec, ty) table" where + "fields_table G C P = + Option.map type \ table_of (filter (split P) (DeclConcepts.fields G C))" lemma fields_table_SomeI: "\table_of (DeclConcepts.fields G C) n = Some f; P n f\ @@ -173,20 +178,23 @@ apply simp done -definition in_bounds :: "int \ int \ bool" ("(_/ in'_bounds _)" [50, 51] 50) where - "i in_bounds k \ 0 \ i \ i < k" +definition + in_bounds :: "int \ int \ bool" ("(_/ in'_bounds _)" [50, 51] 50) + where "i in_bounds k = (0 \ i \ i < k)" -definition arr_comps :: "'a \ int \ int \ 'a option" where - "arr_comps T k \ \i. if i in_bounds k then Some T else None" +definition + arr_comps :: "'a \ int \ int \ 'a option" + where "arr_comps T k = (\i. if i in_bounds k then Some T else None)" -definition var_tys :: "prog \ obj_tag \ oref \ (vn, ty) table" where -"var_tys G oi r - \ case r of +definition + var_tys :: "prog \ obj_tag \ oref \ (vn, ty) table" where + "var_tys G oi r = + (case r of Heap a \ (case oi of CInst C \ fields_table G C (\n f. \static f) (+) empty | Arr T k \ empty (+) arr_comps T k) | Stat C \ fields_table G C (\fn f. declclassf fn = C \ static f) - (+) empty" + (+) empty)" lemma var_tys_Some_eq: "var_tys G oi r n = Some T @@ -222,14 +230,16 @@ subsection "access" -definition globs :: "st \ globs" where - "globs \ st_case (\g l. g)" +definition + globs :: "st \ globs" + where "globs = st_case (\g l. g)" -definition locals :: "st \ locals" where - "locals \ st_case (\g l. l)" +definition + locals :: "st \ locals" + where "locals = st_case (\g l. l)" -definition heap :: "st \ heap" where - "heap s \ globs s \ Heap" +definition heap :: "st \ heap" where + "heap s = globs s \ Heap" lemma globs_def2 [simp]: " globs (st g l) = g" @@ -250,8 +260,9 @@ subsection "memory allocation" -definition new_Addr :: "heap \ loc option" where - "new_Addr h \ if (\a. h a \ None) then None else Some (SOME a. h a = None)" +definition + new_Addr :: "heap \ loc option" where + "new_Addr h = (if (\a. h a \ None) then None else Some (SOME a. h a = None))" lemma new_AddrD: "new_Addr h = Some a \ h a = None" apply (auto simp add: new_Addr_def) @@ -290,20 +301,25 @@ subsection "update" -definition gupd :: "oref \ obj \ st \ st" ("gupd'(_\_')"[10,10]1000) where - "gupd r obj \ st_case (\g l. st (g(r\obj)) l)" +definition + gupd :: "oref \ obj \ st \ st" ("gupd'(_\_')" [10, 10] 1000) + where "gupd r obj = st_case (\g l. st (g(r\obj)) l)" -definition lupd :: "lname \ val \ st \ st" ("lupd'(_\_')"[10,10]1000) where - "lupd vn v \ st_case (\g l. st g (l(vn\v)))" +definition + lupd :: "lname \ val \ st \ st" ("lupd'(_\_')" [10, 10] 1000) + where "lupd vn v = st_case (\g l. st g (l(vn\v)))" -definition upd_gobj :: "oref \ vn \ val \ st \ st" where - "upd_gobj r n v \ st_case (\g l. st (chg_map (upd_obj n v) r g) l)" +definition + upd_gobj :: "oref \ vn \ val \ st \ st" + where "upd_gobj r n v = st_case (\g l. st (chg_map (upd_obj n v) r g) l)" -definition set_locals :: "locals \ st \ st" where - "set_locals l \ st_case (\g l'. st g l)" +definition + set_locals :: "locals \ st \ st" + where "set_locals l = st_case (\g l'. st g l)" -definition init_obj :: "prog \ obj_tag \ oref \ st \ st" where - "init_obj G oi r \ gupd(r\\tag=oi, values=init_vals (var_tys G oi r)\)" +definition + init_obj :: "prog \ obj_tag \ oref \ st \ st" + where "init_obj G oi r = gupd(r\\tag=oi, values=init_vals (var_tys G oi r)\)" abbreviation init_class_obj :: "prog \ qtname \ st \ st" @@ -447,23 +463,22 @@ -consts +primrec the_Xcpt :: "abrupt \ xcpt" + where "the_Xcpt (Xcpt x) = x" - the_Xcpt :: "abrupt \ xcpt" - the_Jump :: "abrupt => jump" - the_Loc :: "xcpt \ loc" - the_Std :: "xcpt \ xname" +primrec the_Jump :: "abrupt => jump" + where "the_Jump (Jump j) = j" -primrec "the_Xcpt (Xcpt x) = x" -primrec "the_Jump (Jump j) = j" -primrec "the_Loc (Loc a) = a" -primrec "the_Std (Std x) = x" +primrec the_Loc :: "xcpt \ loc" + where "the_Loc (Loc a) = a" - +primrec the_Std :: "xcpt \ xname" + where "the_Std (Std x) = x" -definition abrupt_if :: "bool \ abopt \ abopt \ abopt" where - "abrupt_if c x' x \ if c \ (x = None) then x' else x" +definition + abrupt_if :: "bool \ abopt \ abopt \ abopt" + where "abrupt_if c x' x = (if c \ (x = None) then x' else x)" lemma abrupt_if_True_None [simp]: "abrupt_if True x None = x" by (simp add: abrupt_if_def) @@ -542,8 +557,9 @@ apply auto done -definition absorb :: "jump \ abopt \ abopt" where - "absorb j a \ if a=Some (Jump j) then None else a" +definition + absorb :: "jump \ abopt \ abopt" + where "absorb j a = (if a=Some (Jump j) then None else a)" lemma absorb_SomeD [dest!]: "absorb j a = Some x \ a = Some x" by (auto simp add: absorb_def) @@ -593,16 +609,18 @@ apply clarsimp done -definition normal :: "state \ bool" where - "normal \ \s. abrupt s = None" +definition + normal :: "state \ bool" + where "normal = (\s. abrupt s = None)" lemma normal_def2 [simp]: "normal s = (abrupt s = None)" apply (unfold normal_def) apply (simp (no_asm)) done -definition heap_free :: "nat \ state \ bool" where - "heap_free n \ \s. atleast_free (heap (store s)) n" +definition + heap_free :: "nat \ state \ bool" + where "heap_free n = (\s. atleast_free (heap (store s)) n)" lemma heap_free_def2 [simp]: "heap_free n s = atleast_free (heap (store s)) n" apply (unfold heap_free_def) @@ -611,11 +629,13 @@ subsection "update" -definition abupd :: "(abopt \ abopt) \ state \ state" where - "abupd f \ prod_fun f id" +definition + abupd :: "(abopt \ abopt) \ state \ state" + where "abupd f = prod_fun f id" -definition supd :: "(st \ st) \ state \ state" where - "supd \ prod_fun id" +definition + supd :: "(st \ st) \ state \ state" + where "supd = prod_fun id" lemma abupd_def2 [simp]: "abupd f (x,s) = (f x,s)" by (simp add: abupd_def) @@ -669,11 +689,13 @@ section "initialisation test" -definition inited :: "qtname \ globs \ bool" where - "inited C g \ g (Stat C) \ None" +definition + inited :: "qtname \ globs \ bool" + where "inited C g = (g (Stat C) \ None)" -definition initd :: "qtname \ state \ bool" where - "initd C \ inited C \ globs \ store" +definition + initd :: "qtname \ state \ bool" + where "initd C = inited C \ globs \ store" lemma not_inited_empty [simp]: "\inited C empty" apply (unfold inited_def) @@ -706,8 +728,10 @@ done section {* @{text error_free} *} -definition error_free :: "state \ bool" where -"error_free s \ \ (\ err. abrupt s = Some (Error err))" + +definition + error_free :: "state \ bool" + where "error_free s = (\ (\ err. abrupt s = Some (Error err)))" lemma error_free_Norm [simp,intro]: "error_free (Norm s)" by (simp add: error_free_def) diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Table.thy --- a/src/HOL/Bali/Table.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Table.thy Mon Jul 26 17:41:26 2010 +0200 @@ -54,15 +54,15 @@ --{* when merging tables old and new, only override an entry of table old when the condition cond holds *} -"cond_override cond old new \ - \ k. +"cond_override cond old new = + (\k. (case new k of None \ old k | Some new_val \ (case old k of None \ Some new_val | Some old_val \ (if cond new_val old_val then Some new_val - else Some old_val)))" + else Some old_val))))" lemma cond_override_empty1[simp]: "cond_override c empty t = t" by (simp add: cond_override_def expand_fun_eq) @@ -95,10 +95,11 @@ section {* Filter on Tables *} -definition filter_tab :: "('a \ 'b \ bool) \ ('a, 'b) table \ ('a, 'b) table" where -"filter_tab c t \ \ k. (case t k of +definition + filter_tab :: "('a \ 'b \ bool) \ ('a, 'b) table \ ('a, 'b) table" where + "filter_tab c t = (\k. (case t k of None \ None - | Some x \ if c k x then Some x else None)" + | Some x \ if c k x then Some x else None))" lemma filter_tab_empty[simp]: "filter_tab c empty = empty" by (simp add: filter_tab_def empty_def) @@ -279,27 +280,31 @@ done -consts - Un_tables :: "('a, 'b) tables set \ ('a, 'b) tables" - overrides_t :: "('a, 'b) tables \ ('a, 'b) tables \ - ('a, 'b) tables" (infixl "\\" 100) - hidings_entails:: "('a, 'b) tables \ ('a, 'c) tables \ - ('b \ 'c \ bool) \ bool" ("_ hidings _ entails _" 20) +definition + Un_tables :: "('a, 'b) tables set \ ('a, 'b) tables" + where "Un_tables ts\\= (\k. \t\ts. t k)" + +definition + overrides_t :: "('a, 'b) tables \ ('a, 'b) tables \ ('a, 'b) tables" (infixl "\\" 100) + where "s \\ t = (\k. if t k = {} then s k else t k)" + +definition + hidings_entails :: "('a, 'b) tables \ ('a, 'c) tables \ ('b \ 'c \ bool) \ bool" + ("_ hidings _ entails _" 20) + where "(t hidings s entails R) = (\k. \x\t k. \y\s k. R x y)" + +definition --{* variant for unique table: *} - hiding_entails :: "('a, 'b) table \ ('a, 'c) table \ - ('b \ 'c \ bool) \ bool" ("_ hiding _ entails _" 20) + hiding_entails :: "('a, 'b) table \ ('a, 'c) table \ ('b \ 'c \ bool) \ bool" + ("_ hiding _ entails _" 20) + where "(t hiding s entails R) = (\k. \x\t k: \y\s k: R x y)" + +definition --{* variant for a unique table and conditional overriding: *} cond_hiding_entails :: "('a, 'b) table \ ('a, 'c) table \ ('b \ 'c \ bool) \ ('b \ 'c \ bool) \ bool" ("_ hiding _ under _ entails _" 20) - -defs - Un_tables_def: "Un_tables ts\\\ \k. \t\ts. t k" - overrides_t_def: "s \\ t \ \k. if t k = {} then s k else t k" - hidings_entails_def: "t hidings s entails R \ \k. \x\t k. \y\s k. R x y" - hiding_entails_def: "t hiding s entails R \ \k. \x\t k: \y\s k: R x y" - cond_hiding_entails_def: "t hiding s under C entails R - \ \k. \x\t k: \y\s k: C x y \ R x y" + where "(t hiding s under C entails R) = (\k. \x\t k: \y\s k: C x y \ R x y)" section "Untables" @@ -383,12 +388,10 @@ (*###TO Map?*) -consts - atleast_free :: "('a ~=> 'b) => nat => bool" -primrec - "atleast_free m 0 = True" - atleast_free_Suc: - "atleast_free m (Suc n) = (? a. m a = None & (!b. atleast_free (m(a|->b)) n))" +primrec atleast_free :: "('a ~=> 'b) => nat => bool" +where + "atleast_free m 0 = True" +| atleast_free_Suc: "atleast_free m (Suc n) = (\a. m a = None & (!b. atleast_free (m(a|->b)) n))" lemma atleast_free_weaken [rule_format (no_asm)]: "!m. atleast_free m (Suc n) \ atleast_free m n" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Term.thy --- a/src/HOL/Bali/Term.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Term.thy Mon Jul 26 17:41:26 2010 +0200 @@ -258,8 +258,9 @@ StatRef :: "ref_ty \ expr" where "StatRef rt == Cast (RefT rt) (Lit Null)" -definition is_stmt :: "term \ bool" where - "is_stmt t \ \c. t=In1r c" +definition + is_stmt :: "term \ bool" + where "is_stmt t = (\c. t=In1r c)" ML {* bind_thms ("is_stmt_rews", sum3_instantiate @{context} @{thm is_stmt_def}) *} @@ -307,7 +308,7 @@ begin definition - stmt_inj_term_def: "\c::stmt\ \ In1r c" + stmt_inj_term_def: "\c::stmt\ = In1r c" instance .. @@ -323,7 +324,7 @@ begin definition - expr_inj_term_def: "\e::expr\ \ In1l e" + expr_inj_term_def: "\e::expr\ = In1l e" instance .. @@ -339,7 +340,7 @@ begin definition - var_inj_term_def: "\v::var\ \ In2 v" + var_inj_term_def: "\v::var\ = In2 v" instance .. @@ -368,7 +369,7 @@ begin definition - "\es::'a list\ \ In3 (map expr_of es)" + "\es::'a list\ = In3 (map expr_of es)" instance .. @@ -425,46 +426,47 @@ done section {* Evaluation of unary operations *} -consts eval_unop :: "unop \ val \ val" -primrec -"eval_unop UPlus v = Intg (the_Intg v)" -"eval_unop UMinus v = Intg (- (the_Intg v))" -"eval_unop UBitNot v = Intg 42" -- "FIXME: Not yet implemented" -"eval_unop UNot v = Bool (\ the_Bool v)" +primrec eval_unop :: "unop \ val \ val" +where + "eval_unop UPlus v = Intg (the_Intg v)" +| "eval_unop UMinus v = Intg (- (the_Intg v))" +| "eval_unop UBitNot v = Intg 42" -- "FIXME: Not yet implemented" +| "eval_unop UNot v = Bool (\ the_Bool v)" section {* Evaluation of binary operations *} -consts eval_binop :: "binop \ val \ val \ val" -primrec -"eval_binop Mul v1 v2 = Intg ((the_Intg v1) * (the_Intg v2))" -"eval_binop Div v1 v2 = Intg ((the_Intg v1) div (the_Intg v2))" -"eval_binop Mod v1 v2 = Intg ((the_Intg v1) mod (the_Intg v2))" -"eval_binop Plus v1 v2 = Intg ((the_Intg v1) + (the_Intg v2))" -"eval_binop Minus v1 v2 = Intg ((the_Intg v1) - (the_Intg v2))" +primrec eval_binop :: "binop \ val \ val \ val" +where + "eval_binop Mul v1 v2 = Intg ((the_Intg v1) * (the_Intg v2))" +| "eval_binop Div v1 v2 = Intg ((the_Intg v1) div (the_Intg v2))" +| "eval_binop Mod v1 v2 = Intg ((the_Intg v1) mod (the_Intg v2))" +| "eval_binop Plus v1 v2 = Intg ((the_Intg v1) + (the_Intg v2))" +| "eval_binop Minus v1 v2 = Intg ((the_Intg v1) - (the_Intg v2))" -- "Be aware of the explicit coercion of the shift distance to nat" -"eval_binop LShift v1 v2 = Intg ((the_Intg v1) * (2^(nat (the_Intg v2))))" -"eval_binop RShift v1 v2 = Intg ((the_Intg v1) div (2^(nat (the_Intg v2))))" -"eval_binop RShiftU v1 v2 = Intg 42" --"FIXME: Not yet implemented" +| "eval_binop LShift v1 v2 = Intg ((the_Intg v1) * (2^(nat (the_Intg v2))))" +| "eval_binop RShift v1 v2 = Intg ((the_Intg v1) div (2^(nat (the_Intg v2))))" +| "eval_binop RShiftU v1 v2 = Intg 42" --"FIXME: Not yet implemented" -"eval_binop Less v1 v2 = Bool ((the_Intg v1) < (the_Intg v2))" -"eval_binop Le v1 v2 = Bool ((the_Intg v1) \ (the_Intg v2))" -"eval_binop Greater v1 v2 = Bool ((the_Intg v2) < (the_Intg v1))" -"eval_binop Ge v1 v2 = Bool ((the_Intg v2) \ (the_Intg v1))" +| "eval_binop Less v1 v2 = Bool ((the_Intg v1) < (the_Intg v2))" +| "eval_binop Le v1 v2 = Bool ((the_Intg v1) \ (the_Intg v2))" +| "eval_binop Greater v1 v2 = Bool ((the_Intg v2) < (the_Intg v1))" +| "eval_binop Ge v1 v2 = Bool ((the_Intg v2) \ (the_Intg v1))" -"eval_binop Eq v1 v2 = Bool (v1=v2)" -"eval_binop Neq v1 v2 = Bool (v1\v2)" -"eval_binop BitAnd v1 v2 = Intg 42" -- "FIXME: Not yet implemented" -"eval_binop And v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" -"eval_binop BitXor v1 v2 = Intg 42" -- "FIXME: Not yet implemented" -"eval_binop Xor v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" -"eval_binop BitOr v1 v2 = Intg 42" -- "FIXME: Not yet implemented" -"eval_binop Or v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" -"eval_binop CondAnd v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" -"eval_binop CondOr v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" +| "eval_binop Eq v1 v2 = Bool (v1=v2)" +| "eval_binop Neq v1 v2 = Bool (v1\v2)" +| "eval_binop BitAnd v1 v2 = Intg 42" -- "FIXME: Not yet implemented" +| "eval_binop And v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" +| "eval_binop BitXor v1 v2 = Intg 42" -- "FIXME: Not yet implemented" +| "eval_binop Xor v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" +| "eval_binop BitOr v1 v2 = Intg 42" -- "FIXME: Not yet implemented" +| "eval_binop Or v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" +| "eval_binop CondAnd v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" +| "eval_binop CondOr v1 v2 = Bool ((the_Bool v1) \ (the_Bool v2))" -definition need_second_arg :: "binop \ val \ bool" where -"need_second_arg binop v1 \ \ ((binop=CondAnd \ \ the_Bool v1) \ - (binop=CondOr \ the_Bool v1))" +definition + need_second_arg :: "binop \ val \ bool" where + "need_second_arg binop v1 = (\ ((binop=CondAnd \ \ the_Bool v1) \ + (binop=CondOr \ the_Bool v1)))" text {* @{term CondAnd} and @{term CondOr} only evalulate the second argument if the value isn't already determined by the first argument*} diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Trans.thy --- a/src/HOL/Bali/Trans.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Trans.thy Mon Jul 26 17:41:26 2010 +0200 @@ -9,12 +9,13 @@ theory Trans imports Evaln begin -definition groundVar :: "var \ bool" where -"groundVar v \ (case v of - LVar ln \ True - | {accC,statDeclC,stat}e..fn \ \ a. e=Lit a - | e1.[e2] \ \ a i. e1= Lit a \ e2 = Lit i - | InsInitV c v \ False)" +definition + groundVar :: "var \ bool" where + "groundVar v \ (case v of + LVar ln \ True + | {accC,statDeclC,stat}e..fn \ \ a. e=Lit a + | e1.[e2] \ \ a i. e1= Lit a \ e2 = Lit i + | InsInitV c v \ False)" lemma groundVar_cases [consumes 1, case_names LVar FVar AVar]: assumes ground: "groundVar v" and @@ -34,14 +35,15 @@ done qed -definition groundExprs :: "expr list \ bool" where - "groundExprs es \ (\e \ set es. \v. e = Lit v)" +definition + groundExprs :: "expr list \ bool" + where "groundExprs es \ (\e \ set es. \v. e = Lit v)" -primrec the_val:: "expr \ val" where - "the_val (Lit v) = v" +primrec the_val:: "expr \ val" + where "the_val (Lit v) = v" primrec the_var:: "prog \ state \ var \ (vvar \ state)" where - "the_var G s (LVar ln) =(lvar ln (store s),s)" + "the_var G s (LVar ln) = (lvar ln (store s),s)" | the_var_FVar_def: "the_var G s ({accC,statDeclC,stat}a..fn) =fvar statDeclC stat fn (the_val a) s" | the_var_AVar_def: "the_var G s(a.[i]) =avar G (the_val i) (the_val a) s" diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Type.thy --- a/src/HOL/Bali/Type.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Type.thy Mon Jul 26 17:41:26 2010 +0200 @@ -36,8 +36,9 @@ abbreviation Array :: "ty \ ty" ("_.[]" [90] 90) where "T.[] == RefT (ArrayT T)" -definition the_Class :: "ty \ qtname" where - "the_Class T \ SOME C. T = Class C" (** primrec not possible here **) +definition + the_Class :: "ty \ qtname" + where "the_Class T = (SOME C. T = Class C)" (** primrec not possible here **) lemma the_Class_eq [simp]: "the_Class (Class C)= C" by (auto simp add: the_Class_def) diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/TypeRel.thy --- a/src/HOL/Bali/TypeRel.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/TypeRel.thy Mon Jul 26 17:41:26 2010 +0200 @@ -25,14 +25,17 @@ \end{itemize} *} -consts - (*subint1, in Decl.thy*) (* direct subinterface *) (*subint , by translation*) (* subinterface (+ identity) *) (*subcls1, in Decl.thy*) (* direct subclass *) (*subcls , by translation*) (* subclass *) (*subclseq, by translation*) (* subclass + identity *) - implmt1 :: "prog \ (qtname \ qtname) set" --{* direct implementation *} + +definition + implmt1 :: "prog \ (qtname \ qtname) set" --{* direct implementation *} + --{* direct implementation, cf. 8.1.3 *} + where "implmt1 G = {(C,I). C\Object \ (\c\class G C: I\set (superIfs c))}" + abbreviation subint1_syntax :: "prog => [qtname, qtname] => bool" ("_|-_<:I1_" [71,71,71] 70) @@ -325,16 +328,11 @@ section "implementation relation" -defs - --{* direct implementation, cf. 8.1.3 *} -implmt1_def:"implmt1 G\{(C,I). C\Object \ (\c\class G C: I\set (superIfs c))}" - lemma implmt1D: "G\C\1I \ C\Object \ (\c\class G C: I\set (superIfs c))" apply (unfold implmt1_def) apply auto done - inductive --{* implementation, cf. 8.1.4 *} implmt :: "prog \ qtname \ qtname \ bool" ("_\_\_" [71,71,71] 70) for G :: prog @@ -568,8 +566,9 @@ apply (fast dest: widen_Class_Class widen_Class_Iface) done -definition widens :: "prog \ [ty list, ty list] \ bool" ("_\_[\]_" [71,71,71] 70) where - "G\Ts[\]Ts' \ list_all2 (\T T'. G\T\T') Ts Ts'" +definition + widens :: "prog \ [ty list, ty list] \ bool" ("_\_[\]_" [71,71,71] 70) + where "G\Ts[\]Ts' = list_all2 (\T T'. G\T\T') Ts Ts'" lemma widens_Nil [simp]: "G\[][\][]" apply (unfold widens_def) diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/TypeSafe.thy --- a/src/HOL/Bali/TypeSafe.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/TypeSafe.thy Mon Jul 26 17:41:26 2010 +0200 @@ -93,23 +93,27 @@ section "result conformance" -definition assign_conforms :: "st \ (val \ state \ state) \ ty \ env' \ bool" ("_\|_\_\\_" [71,71,71,71] 70) where -"s\|f\T\\E \ - (\s' w. Norm s'\\E \ fst E,s'\w\\T \ s\|s' \ assign f w (Norm s')\\E) \ - (\s' w. error_free s' \ (error_free (assign f w s')))" +definition + assign_conforms :: "st \ (val \ state \ state) \ ty \ env' \ bool" ("_\|_\_\\_" [71,71,71,71] 70) +where + "s\|f\T\\E = + ((\s' w. Norm s'\\E \ fst E,s'\w\\T \ s\|s' \ assign f w (Norm s')\\E) \ + (\s' w. error_free s' \ (error_free (assign f w s'))))" -definition rconf :: "prog \ lenv \ st \ term \ vals \ tys \ bool" ("_,_,_\_\_\\_" [71,71,71,71,71,71] 70) where - "G,L,s\t\v\\T - \ case T of - Inl T \ if (\ var. t=In2 var) - then (\ n. (the_In2 t) = LVar n - \ (fst (the_In2 v) = the (locals s n)) \ - (locals s n \ None \ G,s\fst (the_In2 v)\\T)) \ - (\ (\ n. the_In2 t=LVar n) \ (G,s\fst (the_In2 v)\\T))\ - (s\|snd (the_In2 v)\T\\(G,L)) - else G,s\the_In1 v\\T - | Inr Ts \ list_all2 (conf G s) (the_In3 v) Ts" +definition + rconf :: "prog \ lenv \ st \ term \ vals \ tys \ bool" ("_,_,_\_\_\\_" [71,71,71,71,71,71] 70) +where + "G,L,s\t\v\\T = + (case T of + Inl T \ if (\ var. t=In2 var) + then (\ n. (the_In2 t) = LVar n + \ (fst (the_In2 v) = the (locals s n)) \ + (locals s n \ None \ G,s\fst (the_In2 v)\\T)) \ + (\ (\ n. the_In2 t=LVar n) \ (G,s\fst (the_In2 v)\\T))\ + (s\|snd (the_In2 v)\T\\(G,L)) + else G,s\the_In1 v\\T + | Inr Ts \ list_all2 (conf G s) (the_In3 v) Ts)" text {* With @{term rconf} we describe the conformance of the result value of a term. @@ -324,9 +328,11 @@ declare fun_upd_apply [simp del] -definition DynT_prop :: "[prog,inv_mode,qtname,ref_ty] \ bool" ("_\_\_\_"[71,71,71,71]70) where - "G\mode\D\t \ mode = IntVir \ is_class G D \ - (if (\T. t=ArrayT T) then D=Object else G\Class D\RefT t)" +definition + DynT_prop :: "[prog,inv_mode,qtname,ref_ty] \ bool" ("_\_\_\_"[71,71,71,71]70) +where + "G\mode\D\t = (mode = IntVir \ is_class G D \ + (if (\T. t=ArrayT T) then D=Object else G\Class D\RefT t))" lemma DynT_propI: "\(x,s)\\(G, L); G,s\a'\\RefT statT; wf_prog G; mode = IntVir \ a' \ Null\ diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/Value.thy --- a/src/HOL/Bali/Value.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/Value.thy Mon Jul 26 17:41:26 2010 +0200 @@ -17,29 +17,34 @@ | Addr loc --{* addresses, i.e. locations of objects *} -consts the_Bool :: "val \ bool" -primrec "the_Bool (Bool b) = b" -consts the_Intg :: "val \ int" -primrec "the_Intg (Intg i) = i" -consts the_Addr :: "val \ loc" -primrec "the_Addr (Addr a) = a" +primrec the_Bool :: "val \ bool" + where "the_Bool (Bool b) = b" + +primrec the_Intg :: "val \ int" + where "the_Intg (Intg i) = i" + +primrec the_Addr :: "val \ loc" + where "the_Addr (Addr a) = a" types dyn_ty = "loc \ ty option" -consts - typeof :: "dyn_ty \ val \ ty option" - defpval :: "prim_ty \ val" --{* default value for primitive types *} - default_val :: " ty \ val" --{* default value for all types *} + +primrec typeof :: "dyn_ty \ val \ ty option" +where + "typeof dt Unit = Some (PrimT Void)" +| "typeof dt (Bool b) = Some (PrimT Boolean)" +| "typeof dt (Intg i) = Some (PrimT Integer)" +| "typeof dt Null = Some NT" +| "typeof dt (Addr a) = dt a" -primrec "typeof dt Unit = Some (PrimT Void)" - "typeof dt (Bool b) = Some (PrimT Boolean)" - "typeof dt (Intg i) = Some (PrimT Integer)" - "typeof dt Null = Some NT" - "typeof dt (Addr a) = dt a" +primrec defpval :: "prim_ty \ val" --{* default value for primitive types *} +where + "defpval Void = Unit" +| "defpval Boolean = Bool False" +| "defpval Integer = Intg 0" -primrec "defpval Void = Unit" - "defpval Boolean = Bool False" - "defpval Integer = Intg 0" -primrec "default_val (PrimT pt) = defpval pt" - "default_val (RefT r ) = Null" +primrec default_val :: "ty \ val" --{* default value for all types *} +where + "default_val (PrimT pt) = defpval pt" +| "default_val (RefT r ) = Null" end diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/WellForm.thy --- a/src/HOL/Bali/WellForm.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/WellForm.thy Mon Jul 26 17:41:26 2010 +0200 @@ -31,8 +31,9 @@ text {* well-formed field declaration (common part for classes and interfaces), cf. 8.3 and (9.3) *} -definition wf_fdecl :: "prog \ pname \ fdecl \ bool" where - "wf_fdecl G P \ \(fn,f). is_acc_type G P (type f)" +definition + wf_fdecl :: "prog \ pname \ fdecl \ bool" + where "wf_fdecl G P = (\(fn,f). is_acc_type G P (type f))" lemma wf_fdecl_def2: "\fd. wf_fdecl G P fd = is_acc_type G P (type (snd fd))" apply (unfold wf_fdecl_def) @@ -54,11 +55,12 @@ \item the parameter names are unique \end{itemize} *} -definition wf_mhead :: "prog \ pname \ sig \ mhead \ bool" where - "wf_mhead G P \ \ sig mh. length (parTs sig) = length (pars mh) \ +definition + wf_mhead :: "prog \ pname \ sig \ mhead \ bool" where + "wf_mhead G P = (\ sig mh. length (parTs sig) = length (pars mh) \ \ ( \T\set (parTs sig). is_acc_type G P T) \ is_acc_type G P (resTy mh) \ - \ distinct (pars mh)" + \ distinct (pars mh))" text {* @@ -76,23 +78,25 @@ \end{itemize} *} -definition callee_lcl :: "qtname \ sig \ methd \ lenv" where -"callee_lcl C sig m - \ \ k. (case k of +definition + callee_lcl :: "qtname \ sig \ methd \ lenv" where + "callee_lcl C sig m = + (\k. (case k of EName e \ (case e of VNam v \(table_of (lcls (mbody m))((pars m)[\](parTs sig))) v | Res \ Some (resTy m)) - | This \ if is_static m then None else Some (Class C))" + | This \ if is_static m then None else Some (Class C)))" -definition parameters :: "methd \ lname set" where -"parameters m \ set (map (EName \ VNam) (pars m)) - \ (if (static m) then {} else {This})" +definition + parameters :: "methd \ lname set" where + "parameters m = set (map (EName \ VNam) (pars m)) \ (if (static m) then {} else {This})" -definition wf_mdecl :: "prog \ qtname \ mdecl \ bool" where - "wf_mdecl G C \ - \(sig,m). +definition + wf_mdecl :: "prog \ qtname \ mdecl \ bool" where + "wf_mdecl G C = + (\(sig,m). wf_mhead G (pid C) sig (mhead m) \ unique (lcls (mbody m)) \ (\(vn,T)\set (lcls (mbody m)). is_acc_type G (pid C) T) \ @@ -102,7 +106,7 @@ \prg=G,cls=C,lcl=callee_lcl C sig m\\(stmt (mbody m))\\ \ (\ A. \prg=G,cls=C,lcl=callee_lcl C sig m\ \ parameters m \\stmt (mbody m)\\ A - \ Result \ nrm A)" + \ Result \ nrm A))" lemma callee_lcl_VNam_simp [simp]: "callee_lcl C sig m (EName (VNam v)) @@ -216,9 +220,10 @@ superinterfaces widens to each of the corresponding result types \end{itemize} *} -definition wf_idecl :: "prog \ idecl \ bool" where - "wf_idecl G \ - \(I,i). +definition + wf_idecl :: "prog \ idecl \ bool" where + "wf_idecl G = + (\(I,i). ws_idecl G I (isuperIfs i) \ \is_class G I \ (\(sig,mh)\set (imethods i). wf_mhead G (pid I) sig mh \ @@ -233,7 +238,7 @@ is_static new = is_static old)) \ (Option.set \ table_of (imethods i) hidings Un_tables((\J.(imethds G J))`set (isuperIfs i)) - entails (\new old. G\resTy new\resTy old))" + entails (\new old. G\resTy new\resTy old)))" lemma wf_idecl_mhead: "\wf_idecl G (I,i); (sig,mh)\set (imethods i)\ \ wf_mhead G (pid I) sig mh \ \is_static mh \ accmodi mh = Public" @@ -317,8 +322,9 @@ \end{itemize} *} (* to Table *) -definition entails :: "('a,'b) table \ ('b \ bool) \ bool" ("_ entails _" 20) where -"t entails P \ \k. \ x \ t k: P x" +definition + entails :: "('a,'b) table \ ('b \ bool) \ bool" ("_ entails _" 20) + where "(t entails P) = (\k. \ x \ t k: P x)" lemma entailsD: "\t entails P; t k = Some x\ \ P x" @@ -327,9 +333,10 @@ lemma empty_entails[simp]: "empty entails P" by (simp add: entails_def) -definition wf_cdecl :: "prog \ cdecl \ bool" where -"wf_cdecl G \ - \(C,c). +definition + wf_cdecl :: "prog \ cdecl \ bool" where + "wf_cdecl G = + (\(C,c). \is_iface G C \ (\I\set (superIfs c). is_acc_iface G (pid C) I \ (\s. \ im \ imethds G I s. @@ -352,7 +359,7 @@ (G,sig\new hides old \ (accmodi old \ accmodi new \ is_static old)))) - ))" + )))" (* definition wf_cdecl :: "prog \ cdecl \ bool" where @@ -511,13 +518,14 @@ \item all defined classes are wellformed \end{itemize} *} -definition wf_prog :: "prog \ bool" where - "wf_prog G \ let is = ifaces G; cs = classes G in +definition + wf_prog :: "prog \ bool" where + "wf_prog G = (let is = ifaces G; cs = classes G in ObjectC \ set cs \ (\ m\set Object_mdecls. accmodi m \ Package) \ (\xn. SXcptC xn \ set cs) \ (\i\set is. wf_idecl G i) \ unique is \ - (\c\set cs. wf_cdecl G c) \ unique cs" + (\c\set cs. wf_cdecl G c) \ unique cs)" lemma wf_prog_idecl: "\iface G I = Some i; wf_prog G\ \ wf_idecl G (I,i)" apply (unfold wf_prog_def Let_def) @@ -2095,16 +2103,16 @@ Class dynC Array Object *} -consts valid_lookup_cls:: "prog \ ref_ty \ qtname \ bool \ bool" +primrec valid_lookup_cls:: "prog \ ref_ty \ qtname \ bool \ bool" ("_,_ \ _ valid'_lookup'_cls'_for _" [61,61,61,61] 60) -primrec -"G,NullT \ dynC valid_lookup_cls_for static_membr = False" -"G,IfaceT I \ dynC valid_lookup_cls_for static_membr - = (if static_membr - then dynC=Object - else G\Class dynC\ Iface I)" -"G,ClassT C \ dynC valid_lookup_cls_for static_membr = G\Class dynC\ Class C" -"G,ArrayT T \ dynC valid_lookup_cls_for static_membr = (dynC=Object)" +where + "G,NullT \ dynC valid_lookup_cls_for static_membr = False" +| "G,IfaceT I \ dynC valid_lookup_cls_for static_membr + = (if static_membr + then dynC=Object + else G\Class dynC\ Iface I)" +| "G,ClassT C \ dynC valid_lookup_cls_for static_membr = G\Class dynC\ Class C" +| "G,ArrayT T \ dynC valid_lookup_cls_for static_membr = (dynC=Object)" lemma valid_lookup_cls_is_class: assumes dynC: "G,statT \ dynC valid_lookup_cls_for static_membr" and diff -r f87d1105e181 -r ee939247b2fb src/HOL/Bali/WellType.thy --- a/src/HOL/Bali/WellType.thy Mon Jul 26 13:50:52 2010 +0200 +++ b/src/HOL/Bali/WellType.thy Mon Jul 26 17:41:26 2010 +0200 @@ -53,11 +53,13 @@ emhead = "ref_ty \ mhead" --{* Some mnemotic selectors for emhead *} -definition "declrefT" :: "emhead \ ref_ty" where - "declrefT \ fst" +definition + "declrefT" :: "emhead \ ref_ty" + where "declrefT = fst" -definition "mhd" :: "emhead \ mhead" where - "mhd \ snd" +definition + "mhd" :: "emhead \ mhead" + where "mhd \ snd" lemma declrefT_simp[simp]:"declrefT (r,m) = r" by (simp add: declrefT_def) @@ -77,50 +79,51 @@ lemma mhd_accmodi_simp [simp]: "accmodi (mhd m) = accmodi m" by (cases m) simp -consts - cmheads :: "prog \ qtname \ qtname \ sig \ emhead set" - Objectmheads :: "prog \ qtname \ sig \ emhead set" - accObjectmheads:: "prog \ qtname \ ref_ty \ sig \ emhead set" - mheads :: "prog \ qtname \ ref_ty \ sig \ emhead set" -defs - cmheads_def: -"cmheads G S C - \ \sig. (\(Cls,mthd). (ClassT Cls,(mhead mthd))) ` Option.set (accmethd G S C sig)" - Objectmheads_def: -"Objectmheads G S - \ \sig. (\(Cls,mthd). (ClassT Cls,(mhead mthd))) - ` Option.set (filter_tab (\sig m. accmodi m \ Private) (accmethd G S Object) sig)" - accObjectmheads_def: -"accObjectmheads G S T - \ if G\RefT T accessible_in (pid S) - then Objectmheads G S - else (\sig. {})" -primrec -"mheads G S NullT = (\sig. {})" -"mheads G S (IfaceT I) = (\sig. (\(I,h).(IfaceT I,h)) - ` accimethds G (pid S) I sig \ - accObjectmheads G S (IfaceT I) sig)" -"mheads G S (ClassT C) = cmheads G S C" -"mheads G S (ArrayT T) = accObjectmheads G S (ArrayT T)" +definition + cmheads :: "prog \ qtname \ qtname \ sig \ emhead set" + where "cmheads G S C = (\sig. (\(Cls,mthd). (ClassT Cls,(mhead mthd))) ` Option.set (accmethd G S C sig))" + +definition + Objectmheads :: "prog \ qtname \ sig \ emhead set" where + "Objectmheads G S = + (\sig. (\(Cls,mthd). (ClassT Cls,(mhead mthd))) + ` Option.set (filter_tab (\sig m. accmodi m \ Private) (accmethd G S Object) sig))" + +definition + accObjectmheads :: "prog \ qtname \ ref_ty \ sig \ emhead set" +where + "accObjectmheads G S T = + (if G\RefT T accessible_in (pid S) + then Objectmheads G S + else (\sig. {}))" + +primrec mheads :: "prog \ qtname \ ref_ty \ sig \ emhead set" +where + "mheads G S NullT = (\sig. {})" +| "mheads G S (IfaceT I) = (\sig. (\(I,h).(IfaceT I,h)) + ` accimethds G (pid S) I sig \ + accObjectmheads G S (IfaceT I) sig)" +| "mheads G S (ClassT C) = cmheads G S C" +| "mheads G S (ArrayT T) = accObjectmheads G S (ArrayT T)" definition --{* applicable methods, cf. 15.11.2.1 *} - appl_methds :: "prog \ qtname \ ref_ty \ sig \ (emhead \ ty list)\ set" where - "appl_methds G S rt = (\ sig. + appl_methds :: "prog \ qtname \ ref_ty \ sig \ (emhead \ ty list)\ set" where + "appl_methds G S rt = (\ sig. {(mh,pTs') |mh pTs'. mh \ mheads G S rt \name=name sig,parTs=pTs'\ \ G\(parTs sig)[\]pTs'})" definition --{* more specific methods, cf. 15.11.2.2 *} - more_spec :: "prog \ emhead \ ty list \ emhead \ ty list \ bool" where - "more_spec G = (\(mh,pTs). \(mh',pTs'). G\pTs[\]pTs')" + more_spec :: "prog \ emhead \ ty list \ emhead \ ty list \ bool" where + "more_spec G = (\(mh,pTs). \(mh',pTs'). G\pTs[\]pTs')" (*more_spec G \\((d,h),pTs). \((d',h'),pTs'). G\RefT d\RefT d'\G\pTs[\]pTs'*) definition --{* maximally specific methods, cf. 15.11.2.2 *} - max_spec :: "prog \ qtname \ ref_ty \ sig \ (emhead \ ty list)\ set" where - "max_spec G S rt sig = {m. m \appl_methds G S rt sig \ - (\m'\appl_methds G S rt sig. more_spec G m' m \ m'=m)}" + max_spec :: "prog \ qtname \ ref_ty \ sig \ (emhead \ ty list)\ set" where + "max_spec G S rt sig = {m. m \appl_methds G S rt sig \ + (\m'\appl_methds G S rt sig. more_spec G m' m \ m'=m)}" lemma max_spec2appl_meths: @@ -138,13 +141,15 @@ done -definition empty_dt :: "dyn_ty" where - "empty_dt \ \a. None" +definition + empty_dt :: "dyn_ty" + where "empty_dt = (\a. None)" -definition invmode :: "('a::type)member_scheme \ expr \ inv_mode" where -"invmode m e \ if is_static m +definition + invmode :: "('a::type)member_scheme \ expr \ inv_mode" where + "invmode m e = (if is_static m then Static - else if e=Super then SuperM else IntVir" + else if e=Super then SuperM else IntVir)" lemma invmode_nonstatic [simp]: "invmode \access=a,static=False,\=x\ (Acc (LVar e)) = IntVir" @@ -171,71 +176,71 @@ section "Typing for unary operations" -consts unop_type :: "unop \ prim_ty" -primrec -"unop_type UPlus = Integer" -"unop_type UMinus = Integer" -"unop_type UBitNot = Integer" -"unop_type UNot = Boolean" +primrec unop_type :: "unop \ prim_ty" +where + "unop_type UPlus = Integer" +| "unop_type UMinus = Integer" +| "unop_type UBitNot = Integer" +| "unop_type UNot = Boolean" -consts wt_unop :: "unop \ ty \ bool" -primrec -"wt_unop UPlus t = (t = PrimT Integer)" -"wt_unop UMinus t = (t = PrimT Integer)" -"wt_unop UBitNot t = (t = PrimT Integer)" -"wt_unop UNot t = (t = PrimT Boolean)" +primrec wt_unop :: "unop \ ty \ bool" +where + "wt_unop UPlus t = (t = PrimT Integer)" +| "wt_unop UMinus t = (t = PrimT Integer)" +| "wt_unop UBitNot t = (t = PrimT Integer)" +| "wt_unop UNot t = (t = PrimT Boolean)" section "Typing for binary operations" -consts binop_type :: "binop \ prim_ty" -primrec -"binop_type Mul = Integer" -"binop_type Div = Integer" -"binop_type Mod = Integer" -"binop_type Plus = Integer" -"binop_type Minus = Integer" -"binop_type LShift = Integer" -"binop_type RShift = Integer" -"binop_type RShiftU = Integer" -"binop_type Less = Boolean" -"binop_type Le = Boolean" -"binop_type Greater = Boolean" -"binop_type Ge = Boolean" -"binop_type Eq = Boolean" -"binop_type Neq = Boolean" -"binop_type BitAnd = Integer" -"binop_type And = Boolean" -"binop_type BitXor = Integer" -"binop_type Xor = Boolean" -"binop_type BitOr = Integer" -"binop_type Or = Boolean" -"binop_type CondAnd = Boolean" -"binop_type CondOr = Boolean" +primrec binop_type :: "binop \ prim_ty" +where + "binop_type Mul = Integer" +| "binop_type Div = Integer" +| "binop_type Mod = Integer" +| "binop_type Plus = Integer" +| "binop_type Minus = Integer" +| "binop_type LShift = Integer" +| "binop_type RShift = Integer" +| "binop_type RShiftU = Integer" +| "binop_type Less = Boolean" +| "binop_type Le = Boolean" +| "binop_type Greater = Boolean" +| "binop_type Ge = Boolean" +| "binop_type Eq = Boolean" +| "binop_type Neq = Boolean" +| "binop_type BitAnd = Integer" +| "binop_type And = Boolean" +| "binop_type BitXor = Integer" +| "binop_type Xor = Boolean" +| "binop_type BitOr = Integer" +| "binop_type Or = Boolean" +| "binop_type CondAnd = Boolean" +| "binop_type CondOr = Boolean" -consts wt_binop :: "prog \ binop \ ty \ ty \ bool" -primrec -"wt_binop G Mul t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Div t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Mod t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Plus t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Minus t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G LShift t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G RShift t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G RShiftU t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Less t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Le t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Greater t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Ge t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Eq t1 t2 = (G\t1\t2 \ G\t2\t1)" -"wt_binop G Neq t1 t2 = (G\t1\t2 \ G\t2\t1)" -"wt_binop G BitAnd t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G And t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" -"wt_binop G BitXor t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Xor t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" -"wt_binop G BitOr t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" -"wt_binop G Or t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" -"wt_binop G CondAnd t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" -"wt_binop G CondOr t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" +primrec wt_binop :: "prog \ binop \ ty \ ty \ bool" +where + "wt_binop G Mul t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Div t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Mod t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Plus t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Minus t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G LShift t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G RShift t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G RShiftU t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Less t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Le t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Greater t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Ge t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Eq t1 t2 = (G\t1\t2 \ G\t2\t1)" +| "wt_binop G Neq t1 t2 = (G\t1\t2 \ G\t2\t1)" +| "wt_binop G BitAnd t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G And t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" +| "wt_binop G BitXor t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Xor t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" +| "wt_binop G BitOr t1 t2 = ((t1 = PrimT Integer) \ (t2 = PrimT Integer))" +| "wt_binop G Or t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" +| "wt_binop G CondAnd t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" +| "wt_binop G CondOr t1 t2 = ((t1 = PrimT Boolean) \ (t2 = PrimT Boolean))" section "Typing for terms" @@ -244,9 +249,8 @@ (type) "tys" <= (type) "ty + ty list" -inductive - wt :: "env \ dyn_ty \ [term,tys] \ bool" ("_,_\_\_" [51,51,51,51] 50) - and wt_stmt :: "env \ dyn_ty \ stmt \ bool" ("_,_\_\\" [51,51,51 ] 50) +inductive wt :: "env \ dyn_ty \ [term,tys] \ bool" ("_,_\_\_" [51,51,51,51] 50) + and wt_stmt :: "env \ dyn_ty \ stmt \ bool" ("_,_\_\\" [51,51,51] 50) and ty_expr :: "env \ dyn_ty \ [expr ,ty ] \ bool" ("_,_\_\-_" [51,51,51,51] 50) and ty_var :: "env \ dyn_ty \ [var ,ty ] \ bool" ("_,_\_\=_" [51,51,51,51] 50) and ty_exprs :: "env \ dyn_ty \ [expr list, ty list] \ bool"