src/HOL/MicroJava/J/Example.ML
changeset 10613 78b1d6c3ee9c
parent 10138 412a3ced6efd
child 10763 08e1610c1dcb
equal deleted inserted replaced
10612:779af7c58743 10613:78b1d6c3ee9c
     1 
       
     2 AddIs [widen.null];
       
     3 
     1 
     4 Addsimps [inj_cnam_, inj_vnam_];
     2 Addsimps [inj_cnam_, inj_vnam_];
     5 Addsimps [Base_not_Object,Ext_not_Object];
     3 Addsimps [Base_not_Object,Ext_not_Object];
     6 Addsimps [Base_not_Object RS not_sym,Ext_not_Object RS not_sym];
     4 Addsimps [Base_not_Object RS not_sym,Ext_not_Object RS not_sym];
     7 
     5 
     8 val map_of_Cons = prove_goalw thy [get_def thy "map_of_list"] 
     6 bind_thm ("map_of_Cons", hd (tl (thms "map_of.simps")));
     9 "map_of (p#ps) = (map_of ps)(fst p |-> snd p)" (K [Simp_tac 1]);
     7 Goal "map_of ((aa,bb)#ps) aa = Some bb";
    10 val map_of_Cons1 = prove_goalw Map.thy [get_def thy "map_of_list"] 
     8 by (Simp_tac 1);
    11 "map_of ((x,y)#ps) x = Some y" (K [Simp_tac 1]);
     9 qed "map_of_Cons1";
    12 val map_of_Cons2 = prove_goalw Map.thy [get_def thy "map_of_list"] 
    10 Goal "aa\\<noteq>k ==> map_of ((k,bb)#ps) aa = map_of ps aa";
    13 "!!X. x\\<noteq>k ==> map_of ((k,y)#ps) x = map_of ps x" (K [Asm_simp_tac 1]);
    11 by (Asm_simp_tac 1);
       
    12 qed "map_of_Cons2";
    14 Delsimps[map_of_Cons]; (* sic! *)
    13 Delsimps[map_of_Cons]; (* sic! *)
    15 Addsimps[map_of_Cons1, map_of_Cons2];
    14 Addsimps[map_of_Cons1, map_of_Cons2];
    16 
    15 
    17 val class_tprg_Object = prove_goalw thy [class_def, ObjectC_def] 
    16 Goalw [ObjectC_def] "class tprg Object = Some (arbitrary, [], [])";
    18  	"class tprg Object = Some (None, [], [])" 
    17 by (Simp_tac 1);
    19 	(K [Simp_tac 1]);
    18 qed "class_tprg_Object";
    20 val class_tprg_Base = prove_goalw thy [class_def, ObjectC_def, BaseC_def, 
    19 
    21  ExtC_def] "class tprg Base = Some (Some Object, \
    20 Goalw [ObjectC_def, BaseC_def, ExtC_def] "class tprg Base = Some (Object, \
    22 	\ [(vee, PrimT Boolean)], \
    21 	\ [(vee, PrimT Boolean)], \
    23         \ [((foo, [Class Base]), Class Base, foo_Base)])" (K [
    22         \ [((foo, [Class Base]), Class Base, foo_Base)])";
    24 	Simp_tac 1]);
    23 by (Simp_tac 1);
    25 val class_tprg_Ext = prove_goalw thy [class_def, ObjectC_def, BaseC_def, 
    24 qed "class_tprg_Base";
    26  ExtC_def] "class tprg Ext = Some (Some Base, \
    25 
       
    26 Goalw [ObjectC_def, BaseC_def, ExtC_def] "class tprg Ext = Some (Base, \
    27 	\ [(vee, PrimT Integer)], \
    27 	\ [(vee, PrimT Integer)], \
    28         \ [((foo, [Class Base]), Class Ext, foo_Ext)])" (K [
    28         \ [((foo, [Class Base]), Class Ext, foo_Ext)])";
    29 	Simp_tac 1]);
    29 by (Simp_tac 1);
       
    30 qed "class_tprg_Ext";
       
    31 
    30 Addsimps [class_tprg_Object, class_tprg_Base, class_tprg_Ext];
    32 Addsimps [class_tprg_Object, class_tprg_Base, class_tprg_Ext];
    31 
    33 
    32 Goal "!!X. (Object,C) \\<in> (subcls1 tprg)^+ ==> R";
    34 Goal "(Object,C) \\<in> (subcls1 tprg)^+ ==> R";
    33 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    35 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    34 qed "not_Object_subcls";
    36 qed "not_Object_subcls";
    35 AddSEs [not_Object_subcls];
    37 AddSEs [not_Object_subcls];
    36 
    38 
    37 Goal "tprg\\<turnstile>Object\\<preceq>C C ==> C = Object";
    39 Goal "tprg\\<turnstile>Object\\<preceq>C C ==> C = Object";
    40 bd subcls1D 1;
    42 bd subcls1D 1;
    41 by Auto_tac;
    43 by Auto_tac;
    42 qed "subcls_ObjectD";
    44 qed "subcls_ObjectD";
    43 AddSDs[subcls_ObjectD];
    45 AddSDs[subcls_ObjectD];
    44 
    46 
    45 Goal "!!X. (Base, Ext) \\<in> (subcls1 tprg)^+ ==> R";
    47 Goal "(Base, Ext) \\<in> (subcls1 tprg)^+ ==> R";
    46 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    48 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    47 qed "not_Base_subcls_Ext";
    49 qed "not_Base_subcls_Ext";
    48 AddSEs [not_Base_subcls_Ext];
    50 AddSEs [not_Base_subcls_Ext];
    49 
    51 
    50 Goalw [class_def, ObjectC_def, BaseC_def, ExtC_def] "class tprg C = Some z ==> C=Object \\<or> C=Base \\<or> C=Ext";
    52 Goalw [ObjectC_def, BaseC_def, ExtC_def] "class tprg C = Some z ==> C=Object \\<or> C=Base \\<or> C=Ext";
    51 by (auto_tac (claset(),simpset()addsimps[]addsplits[split_if_asm]));
    53 by (auto_tac (claset(),simpset()addsplits[split_if_asm]addsimps[map_of_Cons]));
    52 qed "class_tprgD";
    54 qed "class_tprgD";
    53 
    55 
    54 Goal "(C,C) \\<in> (subcls1 tprg)^+ ==> R";
    56 Goal "(C,C) \\<in> (subcls1 tprg)^+ ==> R";
    55 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    57 by (auto_tac (claset() addSDs [tranclD,subcls1D],simpset()));
    56 by (ftac class_tprgD 1);
    58 by (ftac class_tprgD 1);
    64 by (Simp_tac 1);
    66 by (Simp_tac 1);
    65 qed "unique_classes";
    67 qed "unique_classes";
    66 
    68 
    67 bind_thm ("subcls_direct", subcls1I RS r_into_rtrancl);
    69 bind_thm ("subcls_direct", subcls1I RS r_into_rtrancl);
    68 
    70 
    69 Goalw [] "tprg\\<turnstile>Ext\\<preceq>C Base";
    71 Goal "tprg\\<turnstile>Ext\\<preceq>C Base";
    70 br subcls_direct 1;
    72 br subcls_direct 1;
    71 by (Simp_tac 1);
    73 by Auto_tac;
    72 qed "Ext_subcls_Base";
    74 qed "Ext_subcls_Base";
    73 Addsimps [Ext_subcls_Base];
    75 Addsimps [Ext_subcls_Base];
    74 
    76 
    75 Goalw [] "tprg\\<turnstile>Class Ext\\<preceq> Class Base";
    77 Goal "tprg\\<turnstile>Class Ext\\<preceq> Class Base";
    76 br widen.subcls 1;
    78 br widen.subcls 1;
    77 by (Simp_tac 1);
    79 by (Simp_tac 1);
    78 qed "Ext_widen_Base";
    80 qed "Ext_widen_Base";
    79 Addsimps [Ext_widen_Base];
    81 Addsimps [Ext_widen_Base];
    80 
    82 
    86 by Safe_tac ;
    88 by Safe_tac ;
    87 qed "acyclic_subcls1_";
    89 qed "acyclic_subcls1_";
    88 
    90 
    89 val wf_subcls1_=acyclic_subcls1_ RS(finite_subcls1 RS finite_acyclic_wf_converse);
    91 val wf_subcls1_=acyclic_subcls1_ RS(finite_subcls1 RS finite_acyclic_wf_converse);
    90 
    92 
    91 
       
    92 Addsimps[is_class_def];
       
    93 
    93 
    94 val fields_rec_ = wf_subcls1_ RSN (1, fields_rec_lemma);
    94 val fields_rec_ = wf_subcls1_ RSN (1, fields_rec_lemma);
    95 
    95 
    96 Goal "fields (tprg, Object) = []";
    96 Goal "fields (tprg, Object) = []";
    97 by (stac fields_rec_ 1);
    97 by (stac fields_rec_ 1);