src/HOL/IMP/Hoare.ML
changeset 2055 cc274e47f607
parent 2031 03a843f0f447
child 2810 c4e16b36bc57
equal deleted inserted replaced
2054:bf3891343aa5 2055:cc274e47f607
     9 
     9 
    10 open Hoare;
    10 open Hoare;
    11 
    11 
    12 goalw Hoare.thy [hoare_valid_def] "!!P c Q. |- {P}c{Q} ==> |= {P}c{Q}";
    12 goalw Hoare.thy [hoare_valid_def] "!!P c Q. |- {P}c{Q} ==> |= {P}c{Q}";
    13 by (etac hoare.induct 1);
    13 by (etac hoare.induct 1);
    14     by(ALLGOALS Asm_simp_tac);
    14     by (ALLGOALS Asm_simp_tac);
    15   by (Fast_tac 1);
    15   by (Fast_tac 1);
    16  by (Fast_tac 1);
    16  by (Fast_tac 1);
    17 by (rtac allI 1);
    17 by (rtac allI 1);
    18 by (rtac allI 1);
    18 by (rtac allI 1);
    19 by (rtac impI 1);
    19 by (rtac impI 1);
    20 by (etac induct2 1);
    20 by (etac induct2 1);
    21  br Gamma_mono 1;
    21  by (rtac Gamma_mono 1);
    22 by (rewtac Gamma_def);  
    22 by (rewtac Gamma_def);  
    23 by (Fast_tac 1);
    23 by (Fast_tac 1);
    24 qed "hoare_sound";
    24 qed "hoare_sound";
    25 
    25 
    26 goalw Hoare.thy [swp_def] "swp SKIP Q = Q";
    26 goalw Hoare.thy [swp_def] "swp SKIP Q = Q";
    27 by (Simp_tac 1);
    27 by (Simp_tac 1);
    28 by (rtac ext 1);
       
    29 by (Fast_tac 1);
       
    30 qed "swp_SKIP";
    28 qed "swp_SKIP";
    31 
    29 
    32 goalw Hoare.thy [swp_def] "swp (x:=a) Q = (%s.Q(s[a s/x]))";
    30 goalw Hoare.thy [swp_def] "swp (x:=a) Q = (%s.Q(s[a s/x]))";
    33 by (Simp_tac 1);
    31 by (Simp_tac 1);
    34 qed "swp_Ass";
    32 qed "swp_Ass";
    54 qed "swp_While_True";
    52 qed "swp_While_True";
    55 
    53 
    56 goalw Hoare.thy [swp_def] "!!s. ~b s ==> swp (WHILE b DO c) Q s = Q s";
    54 goalw Hoare.thy [swp_def] "!!s. ~b s ==> swp (WHILE b DO c) Q s = Q s";
    57 by (stac C_While_If 1);
    55 by (stac C_While_If 1);
    58 by (Asm_simp_tac 1);
    56 by (Asm_simp_tac 1);
    59 by (Fast_tac 1);
       
    60 qed "swp_While_False";
    57 qed "swp_While_False";
    61 
    58 
    62 Addsimps [swp_SKIP,swp_Ass,swp_Semi,swp_If,swp_While_True,swp_While_False];
    59 Addsimps [swp_SKIP,swp_Ass,swp_Semi,swp_If,swp_While_True,swp_While_False];
    63 
    60 
    64 (*Not suitable for rewriting: LOOPS!*)
    61 (*Not suitable for rewriting: LOOPS!*)
    77 by (ALLGOALS Simp_tac);
    74 by (ALLGOALS Simp_tac);
    78 by (REPEAT_FIRST Fast_tac);
    75 by (REPEAT_FIRST Fast_tac);
    79 by (deepen_tac (!claset addIs [hoare.conseq]) 0 1);
    76 by (deepen_tac (!claset addIs [hoare.conseq]) 0 1);
    80 by (Step_tac 1);
    77 by (Step_tac 1);
    81 by (rtac hoare.conseq 1);
    78 by (rtac hoare.conseq 1);
    82   be thin_rl 1;
    79   by (etac thin_rl 1);
    83   by (Fast_tac 1);
    80   by (Fast_tac 1);
    84  br hoare.While 1;
    81  by (rtac hoare.While 1);
    85  br hoare.conseq 1;
    82  by (rtac hoare.conseq 1);
    86    be thin_rl 3;
    83    by (etac thin_rl 3);
    87    br allI 3;
    84    by (rtac allI 3);
    88    br impI 3;
    85    by (rtac impI 3);
    89    ba 3;
    86    by (assume_tac 3);
    90   by (Fast_tac 2);
    87   by (Fast_tac 2);
    91  by(safe_tac HOL_cs);
    88  by (safe_tac HOL_cs);
    92  by(rotate_tac ~1 1);
    89  by (rotate_tac ~1 1);
    93  by(Asm_full_simp_tac 1);
    90  by (Asm_full_simp_tac 1);
    94 by (rotate_tac ~1 1);
    91 by (rotate_tac ~1 1);
    95 by (Asm_full_simp_tac 1);
    92 by (Asm_full_simp_tac 1);
    96 qed_spec_mp "swp_is_pre";
    93 qed_spec_mp "swp_is_pre";
    97 
    94 
    98 goal Hoare.thy "!!c. |= {P}c{Q} ==> |- {P}c{Q}";
    95 goal Hoare.thy "!!c. |= {P}c{Q} ==> |- {P}c{Q}";