src/HOL/UNITY/UNITY.ML
changeset 10064 1a77667b21ef
parent 9025 e50c0764e522
child 10797 028d22926a41
equal deleted inserted replaced
10063:947ee8608b90 10064:1a77667b21ef
     6 The basic UNITY theory (revised version, based upon the "co" operator)
     6 The basic UNITY theory (revised version, based upon the "co" operator)
     7 
     7 
     8 From Misra, "A Logic for Concurrent Programming", 1994
     8 From Misra, "A Logic for Concurrent Programming", 1994
     9 *)
     9 *)
    10 
    10 
    11 set timing;
       
    12 
       
    13 (*Perhaps equalities.ML shouldn't add this in the first place!*)
    11 (*Perhaps equalities.ML shouldn't add this in the first place!*)
    14 Delsimps [image_Collect];
    12 Delsimps [image_Collect];
    15 
    13 
    16 
       
    17 (*** The abstract type of programs ***)
    14 (*** The abstract type of programs ***)
    18 
    15 
    19 val rep_ss = simpset() addsimps 
    16 val rep_ss = simpset() addsimps 
    20                 [Init_def, Acts_def, mk_program_def, Program_def, Rep_Program, 
    17                 [Init_def, Acts_def, AllowedActs_def, 
       
    18 		 mk_program_def, Program_def, Rep_Program, 
    21 		 Rep_Program_inverse, Abs_Program_inverse];
    19 		 Rep_Program_inverse, Abs_Program_inverse];
    22 
    20 
    23 
    21 
    24 Goal "Id : Acts F";
    22 Goal "Id : Acts F";
    25 by (cut_inst_tac [("x", "F")] Rep_Program 1);
    23 by (cut_inst_tac [("x", "F")] Rep_Program 1);
    30 Goal "insert Id (Acts F) = Acts F";
    28 Goal "insert Id (Acts F) = Acts F";
    31 by (simp_tac (simpset() addsimps [insert_absorb, Id_in_Acts]) 1);
    29 by (simp_tac (simpset() addsimps [insert_absorb, Id_in_Acts]) 1);
    32 qed "insert_Id_Acts";
    30 qed "insert_Id_Acts";
    33 AddIffs [insert_Id_Acts];
    31 AddIffs [insert_Id_Acts];
    34 
    32 
       
    33 Goal "Id : AllowedActs F";
       
    34 by (cut_inst_tac [("x", "F")] Rep_Program 1);
       
    35 by (auto_tac (claset(), rep_ss));
       
    36 qed "Id_in_AllowedActs";
       
    37 AddIffs [Id_in_AllowedActs];
       
    38 
       
    39 Goal "insert Id (AllowedActs F) = AllowedActs F";
       
    40 by (simp_tac (simpset() addsimps [insert_absorb, Id_in_AllowedActs]) 1);
       
    41 qed "insert_Id_AllowedActs";
       
    42 AddIffs [insert_Id_AllowedActs];
       
    43 
    35 (** Inspectors for type "program" **)
    44 (** Inspectors for type "program" **)
    36 
    45 
    37 Goal "Init (mk_program (init,acts)) = init";
    46 Goal "Init (mk_program (init,acts,allowed)) = init";
    38 by (auto_tac (claset(), rep_ss));
    47 by (auto_tac (claset(), rep_ss));
    39 qed "Init_eq";
    48 qed "Init_eq";
    40 
    49 
    41 Goal "Acts (mk_program (init,acts)) = insert Id acts";
    50 Goal "Acts (mk_program (init,acts,allowed)) = insert Id acts";
    42 by (auto_tac (claset(), rep_ss));
    51 by (auto_tac (claset(), rep_ss));
    43 qed "Acts_eq";
    52 qed "Acts_eq";
    44 
    53 
    45 Addsimps [Acts_eq, Init_eq];
    54 Goal "AllowedActs (mk_program (init,acts,allowed)) = insert Id allowed";
    46 
    55 by (auto_tac (claset(), rep_ss));
       
    56 qed "AllowedActs_eq";
       
    57 
       
    58 Addsimps [Init_eq, Acts_eq, AllowedActs_eq];
    47 
    59 
    48 (** Equality for UNITY programs **)
    60 (** Equality for UNITY programs **)
    49 
    61 
    50 Goal "mk_program (Init F, Acts F) = F";
    62 Goal "mk_program (Init F, Acts F, AllowedActs F) = F";
    51 by (cut_inst_tac [("x", "F")] Rep_Program 1);
    63 by (cut_inst_tac [("x", "F")] Rep_Program 1);
    52 by (auto_tac (claset(), rep_ss));
    64 by (auto_tac (claset(), rep_ss));
    53 by (REPEAT (dres_inst_tac [("f", "Abs_Program")] arg_cong 1));
    65 by (REPEAT (dres_inst_tac [("f", "Abs_Program")] arg_cong 1));
    54 by (asm_full_simp_tac (rep_ss addsimps [insert_absorb]) 1);
    66 by (asm_full_simp_tac (rep_ss addsimps [insert_absorb]) 1);
    55 qed "surjective_mk_program";
    67 qed "surjective_mk_program";
    56 
    68 
    57 Goal "[| Init F = Init G; Acts F = Acts G |] ==> F = G";
    69 Goal "[| Init F = Init G; Acts F = Acts G; AllowedActs F = AllowedActs G |] \
       
    70 \     ==> F = G";
    58 by (res_inst_tac [("t", "F")] (surjective_mk_program RS subst) 1);
    71 by (res_inst_tac [("t", "F")] (surjective_mk_program RS subst) 1);
    59 by (res_inst_tac [("t", "G")] (surjective_mk_program RS subst) 1);
    72 by (res_inst_tac [("t", "G")] (surjective_mk_program RS subst) 1);
    60 by (Asm_simp_tac 1);
    73 by (Asm_simp_tac 1);
    61 qed "program_equalityI";
    74 qed "program_equalityI";
    62 
    75 
    63 val [major,minor] =
    76 val [major,minor] =
    64 Goal "[| F = G; [| Init F = Init G; Acts F = Acts G |] ==> P |] ==> P";
    77 Goal "[| F = G; \
       
    78 \        [| Init F = Init G; Acts F = Acts G; AllowedActs F = AllowedActs G |]\
       
    79 \        ==> P |] ==> P";
    65 by (rtac minor 1);
    80 by (rtac minor 1);
    66 by (auto_tac (claset(), simpset() addsimps [major]));
    81 by (auto_tac (claset(), simpset() addsimps [major]));
    67 qed "program_equalityE";
    82 qed "program_equalityE";
    68 
    83 
    69 Goal "(F=G) = (Init F = Init G & Acts F = Acts G)";
    84 Goal "(F=G) =  \
       
    85 \     (Init F = Init G & Acts F = Acts G &AllowedActs F = AllowedActs G)";
    70 by (blast_tac (claset() addIs [program_equalityI, program_equalityE]) 1);
    86 by (blast_tac (claset() addIs [program_equalityI, program_equalityE]) 1);
    71 qed "program_equality_iff";
    87 qed "program_equality_iff";
    72 
    88 
    73 Addsimps [surjective_mk_program];
    89 Addsimps [surjective_mk_program];
    74 
    90 
    75 
    91 
    76 (*** These rules allow "lazy" definition expansion 
    92 (*** These rules allow "lazy" definition expansion 
    77      They avoid expanding the full program, which is a large expression
    93      They avoid expanding the full program, which is a large expression
    78 ***)
    94 ***)
    79 
    95 
    80 Goal "F == mk_program (init,acts) ==> Init F = init";
    96 Goal "F == mk_program (init,acts,allowed) ==> Init F = init";
    81 by Auto_tac;
    97 by Auto_tac;
    82 qed "def_prg_Init";
    98 qed "def_prg_Init";
       
    99 
       
   100 Goal "F == mk_program (init,acts,allowed) ==> Acts F = insert Id acts";
       
   101 by Auto_tac;
       
   102 qed "def_prg_Acts";
       
   103 
       
   104 Goal "F == mk_program (init,acts,allowed) \
       
   105 \     ==> AllowedActs F = insert Id allowed";
       
   106 by Auto_tac;
       
   107 qed "def_prg_AllowedActs";
    83 
   108 
    84 (*The program is not expanded, but its Init and Acts are*)
   109 (*The program is not expanded, but its Init and Acts are*)
    85 val [rew] = goal thy
   110 val [rew] = goal thy
    86     "[| F == mk_program (init,acts) |] \
   111     "[| F == mk_program (init,acts,allowed) |] \
    87 \    ==> Init F = init & Acts F = insert Id acts";
   112 \    ==> Init F = init & Acts F = insert Id acts";
    88 by (rewtac rew);
   113 by (rewtac rew);
    89 by Auto_tac;
   114 by Auto_tac;
    90 qed "def_prg_simps";
   115 qed "def_prg_simps";
    91 
   116