src/HOL/MicroJava/J/Example.ML
changeset 10042 7164dc0d24d8
parent 9348 f495dba0cb07
child 10138 412a3ced6efd
equal deleted inserted replaced
10041:30693ebd16ae 10042:7164dc0d24d8
     9 val map_of_Cons = prove_goalw thy [get_def thy "map_of_list"] 
     9 val map_of_Cons = prove_goalw thy [get_def thy "map_of_list"] 
    10 "map_of (p#ps) = (map_of ps)(fst p |-> snd p)" (K [Simp_tac 1]);
    10 "map_of (p#ps) = (map_of ps)(fst p |-> snd p)" (K [Simp_tac 1]);
    11 val map_of_Cons1 = prove_goalw Map.thy [get_def thy "map_of_list"] 
    11 val map_of_Cons1 = prove_goalw Map.thy [get_def thy "map_of_list"] 
    12 "map_of ((x,y)#ps) x = Some y" (K [Simp_tac 1]);
    12 "map_of ((x,y)#ps) x = Some y" (K [Simp_tac 1]);
    13 val map_of_Cons2 = prove_goalw Map.thy [get_def thy "map_of_list"] 
    13 val map_of_Cons2 = prove_goalw Map.thy [get_def thy "map_of_list"] 
    14 "\\<And>X. x\\<noteq>k \\<Longrightarrow> map_of ((k,y)#ps) x = map_of ps x" (K [Asm_simp_tac 1]);
    14 "!!X. x\\<noteq>k ==> map_of ((k,y)#ps) x = map_of ps x" (K [Asm_simp_tac 1]);
    15 Delsimps[map_of_Cons]; (* sic! *)
    15 Delsimps[map_of_Cons]; (* sic! *)
    16 Addsimps[map_of_Cons1, map_of_Cons2];
    16 Addsimps[map_of_Cons1, map_of_Cons2];
    17 
    17 
    18 val class_tprg_Object = prove_goalw thy [class_def, ObjectC_def] 
    18 val class_tprg_Object = prove_goalw thy [class_def, ObjectC_def] 
    19  	"class tprg Object = Some (None, [], [])" 
    19  	"class tprg Object = Some (None, [], [])" 
    28 	\ [(vee, PrimT Integer)], \
    28 	\ [(vee, PrimT Integer)], \
    29         \ [((foo, [Class Base]), Class Ext, foo_Ext)])" (K [
    29         \ [((foo, [Class Base]), Class Ext, foo_Ext)])" (K [
    30 	Simp_tac 1]);
    30 	Simp_tac 1]);
    31 Addsimps [class_tprg_Object, class_tprg_Base, class_tprg_Ext];
    31 Addsimps [class_tprg_Object, class_tprg_Base, class_tprg_Ext];
    32 
    32 
    33 Goal "\\<And>X. (Object,C) \\<in> (subcls1 tprg)^+ \\<Longrightarrow> R";
    33 Goal "!!X. (Object,C) \\<in> (subcls1 tprg)^+ ==> R";
    34 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    34 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    35 qed "not_Object_subcls";
    35 qed "not_Object_subcls";
    36 AddSEs [not_Object_subcls];
    36 AddSEs [not_Object_subcls];
    37 
    37 
    38 Goal "tprg\\<turnstile>Object\\<preceq>C C \\<Longrightarrow> C = Object";
    38 Goal "tprg\\<turnstile>Object\\<preceq>C C ==> C = Object";
    39 be rtrancl_induct 1;
    39 be rtrancl_induct 1;
    40 by  Auto_tac;
    40 by  Auto_tac;
    41 bd subcls1D 1;
    41 bd subcls1D 1;
    42 by Auto_tac;
    42 by Auto_tac;
    43 qed "subcls_ObjectD";
    43 qed "subcls_ObjectD";
    44 AddSDs[subcls_ObjectD];
    44 AddSDs[subcls_ObjectD];
    45 
    45 
    46 Goal "\\<And>X. (Base, Ext) \\<in> (subcls1 tprg)^+ \\<Longrightarrow> R";
    46 Goal "!!X. (Base, Ext) \\<in> (subcls1 tprg)^+ ==> R";
    47 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    47 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    48 qed "not_Base_subcls_Ext";
    48 qed "not_Base_subcls_Ext";
    49 AddSEs [not_Base_subcls_Ext];
    49 AddSEs [not_Base_subcls_Ext];
    50 
    50 
    51 Goalw [class_def, ObjectC_def, BaseC_def, ExtC_def] "class tprg C = Some z \\<Longrightarrow> C=Object \\<or> C=Base \\<or> C=Ext";
    51 Goalw [class_def, ObjectC_def, BaseC_def, ExtC_def] "class tprg C = Some z ==> C=Object \\<or> C=Base \\<or> C=Ext";
    52 by (auto_tac (claset(),simpset()addsimps[]addsplits[split_if_asm]));
    52 by (auto_tac (claset(),simpset()addsimps[]addsplits[split_if_asm]));
    53 qed "class_tprgD";
    53 qed "class_tprgD";
    54 
    54 
    55 Goal "(C,C) \\<in> (subcls1 tprg)^+ \\<Longrightarrow> R";
    55 Goal "(C,C) \\<in> (subcls1 tprg)^+ ==> R";
    56 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    56 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    57 by (ftac class_tprgD 1);
    57 by (ftac class_tprgD 1);
    58 by (auto_tac (claset() addSDs [],simpset()));
    58 by (auto_tac (claset() addSDs [],simpset()));
    59 bd rtranclD 1;
    59 bd rtranclD 1;
    60 by Auto_tac;
    60 by Auto_tac;
   194 by (auto_tac (claset(), simpset() addsimps [appl_methds_foo_Base]));
   194 by (auto_tac (claset(), simpset() addsimps [appl_methds_foo_Base]));
   195 qed "max_spec_foo_Base";
   195 qed "max_spec_foo_Base";
   196 
   196 
   197 fun t thm = resolve_tac ty_expr_ty_exprs_wt_stmt.intrs 1 thm;
   197 fun t thm = resolve_tac ty_expr_ty_exprs_wt_stmt.intrs 1 thm;
   198 Goalw [test_def] "(tprg, empty(e\\<mapsto>Class Base))\\<turnstile>\ 
   198 Goalw [test_def] "(tprg, empty(e\\<mapsto>Class Base))\\<turnstile>\ 
   199 \ Expr(e\\<Colon>=NewC Ext);; Expr(LAcc e..foo({?pTs'}[Lit Null]))\\<surd>";
   199 \ Expr(e::=NewC Ext);; Expr(LAcc e..foo({?pTs'}[Lit Null]))\\<surd>";
   200 (* ?pTs' = [Class Base] *)
   200 (* ?pTs' = [Class Base] *)
   201 by t;		(* ;; *)
   201 by t;		(* ;; *)
   202 by  t;		(* Expr *)
   202 by  t;		(* Expr *)
   203 by  t;		(* LAss *)
   203 by  t;		(* LAss *)
   204 by    t;	(* LAcc *)
   204 by    t;	(* LAcc *)
   223 fun e thm = resolve_tac (NewCI::eval_evals_exec.intrs) 1 thm;
   223 fun e thm = resolve_tac (NewCI::eval_evals_exec.intrs) 1 thm;
   224 
   224 
   225 Delsplits[split_if];
   225 Delsplits[split_if];
   226 Addsimps[init_vars_def,c_hupd_def,cast_ok_def];
   226 Addsimps[init_vars_def,c_hupd_def,cast_ok_def];
   227 Goalw [test_def] 
   227 Goalw [test_def] 
   228 " \\<lbrakk>new_Addr (heap (snd s0)) = (a, None)\\<rbrakk> \\<Longrightarrow> \
   228 " [|new_Addr (heap (snd s0)) = (a, None)|] ==> \
   229 \ tprg\\<turnstile>s0 -test\\<rightarrow> ?s";
   229 \ tprg\\<turnstile>s0 -test-> ?s";
   230 (* ?s = s3 *)
   230 (* ?s = s3 *)
   231 by e;		(* ;; *)
   231 by e;		(* ;; *)
   232 by  e;		(* Expr *)
   232 by  e;		(* Expr *)
   233 by  e;		(* LAss *)
   233 by  e;		(* LAss *)
   234 by   e;	(* NewC *)
   234 by   e;	(* NewC *)