src/HOLCF/ex/Hoare.ML
author regensbu
Thu, 29 Jun 1995 16:28:40 +0200
changeset 1168 74be52691d62
parent 1043 ffa68eb2730b
child 1267 bca91b4e1710
permissions -rw-r--r--
The curried version of HOLCF is now just called HOLCF. The old uncurried version is no longer supported
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     1
(*  Title:	HOLCF/ex/hoare.ML
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     2
    ID:         $Id$
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     3
    Author: 	Franz Regensburger
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     4
    Copyright	1993 Technische Universitaet Muenchen
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     5
*)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     6
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     7
open Hoare;
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     8
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     9
(* --------- pure HOLCF logic, some little lemmas ------ *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    10
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    11
val hoare_lemma2 = prove_goal HOLCF.thy "b~=TT ==> b=FF | b=UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    12
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    13
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    14
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    15
	(rtac (Exh_tr RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    16
	(fast_tac HOL_cs 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    17
	(etac disjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    18
	(contr_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    19
	(fast_tac HOL_cs 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    20
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    21
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    22
val hoare_lemma3 = prove_goal HOLCF.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    23
" (!k.b1`(iterate k g x) = TT) | (? k. b1`(iterate k g x)~=TT)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    24
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    25
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    26
	(fast_tac HOL_cs 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    27
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    28
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    29
val hoare_lemma4 = prove_goal HOLCF.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    30
"(? k. b1`(iterate k g x) ~= TT) ==> \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    31
\ ? k. b1`(iterate k g x) = FF | b1`(iterate k g x) = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    32
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    33
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    34
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    35
	(etac exE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    36
	(rtac exI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    37
	(rtac hoare_lemma2 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    38
	(atac 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    39
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    40
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    41
val hoare_lemma5 = prove_goal HOLCF.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    42
"[|(? k. b1`(iterate k g x) ~= TT);\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    43
\   k=theleast(%n. b1`(iterate n g x) ~= TT)|] ==> \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    44
\ b1`(iterate k g x)=FF | b1`(iterate k g x)=UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    45
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    46
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    47
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    48
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    49
	(rtac hoare_lemma2 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    50
	(etac exE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    51
	(etac theleast1 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    52
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    53
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    54
val hoare_lemma6 = prove_goal HOLCF.thy "b=UU ==> b~=TT"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    55
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    56
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    57
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    58
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    59
	(resolve_tac dist_eq_tr 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    60
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    61
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    62
val hoare_lemma7 = prove_goal HOLCF.thy "b=FF ==> b~=TT"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    63
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    64
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    65
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    66
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    67
	(resolve_tac dist_eq_tr 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    68
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    69
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    70
val hoare_lemma8 = prove_goal HOLCF.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    71
"[|(? k. b1`(iterate k g x) ~= TT);\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    72
\   k=theleast(%n. b1`(iterate n g x) ~= TT)|] ==> \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    73
\ !m. m < k --> b1`(iterate m g x)=TT"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    74
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    75
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    76
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    77
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    78
	(etac exE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    79
	(strip_tac 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    80
	(res_inst_tac [("p","b1`(iterate m g x)")] trE 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    81
	(atac 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    82
	(rtac (le_less_trans RS less_anti_refl) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    83
	(atac 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    84
	(rtac theleast2 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    85
	(etac hoare_lemma6 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    86
	(rtac (le_less_trans RS less_anti_refl) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    87
	(atac 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    88
	(rtac theleast2 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    89
	(etac hoare_lemma7 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    90
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    91
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    92
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    93
val hoare_lemma28 = prove_goal HOLCF.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    94
"b1`(y::'a)=(UU::tr) ==> b1`UU = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    95
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    96
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    97
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    98
	(etac (flat_tr RS flat_codom RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    99
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   100
	(etac spec 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   101
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   102
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   103
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   104
(* ----- access to definitions ----- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   105
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   106
val p_def2 = prove_goalw Hoare.thy [p_def]
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   107
"p = fix`(LAM f x. If b1`x then f`(g`x) else x fi)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   108
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   109
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   110
	(rtac refl 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   111
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   112
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   113
val q_def2 = prove_goalw Hoare.thy [q_def]
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   114
"q = fix`(LAM f x. If b1`x orelse b2`x then \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   115
\     f`(g`x) else x fi)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   116
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   117
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   118
	(rtac refl 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   119
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   120
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   121
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   122
val p_def3 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   123
"p`x = If b1`x then p`(g`x) else x fi"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   124
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   125
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   126
	(fix_tac3 p_def 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   127
	(simp_tac HOLCF_ss 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   128
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   129
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   130
val q_def3 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   131
"q`x = If b1`x orelse b2`x then q`(g`x) else x fi"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   132
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   133
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   134
	(fix_tac3 q_def 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   135
	(simp_tac HOLCF_ss 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   136
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   137
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   138
(** --------- proves about iterations of p and q ---------- **)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   139
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   140
val hoare_lemma9 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   141
"(! m. m< Suc k --> b1`(iterate m g x)=TT) -->\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   142
\  p`(iterate k g x)=p`x"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   143
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   144
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   145
	(nat_ind_tac "k" 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   146
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   147
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   148
	(strip_tac 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   149
	(res_inst_tac [("s","p`(iterate k1 g x)")] trans 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   150
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   151
	(rtac (p_def3 RS sym) 2),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   152
	(res_inst_tac [("s","TT"),("t","b1`(iterate k1 g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   153
	(rtac mp 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   154
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   155
	(simp_tac nat_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   156
	(simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   157
	(etac mp 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   158
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   159
	(rtac mp 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   160
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   161
	(etac less_trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   162
	(simp_tac nat_ss 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   163
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   164
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   165
val hoare_lemma24 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   166
"(! m. m< Suc k --> b1`(iterate m g x)=TT) --> \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   167
\ q`(iterate k g x)=q`x"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   168
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   169
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   170
	(nat_ind_tac "k" 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   171
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   172
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   173
	(strip_tac 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   174
	(res_inst_tac [("s","q`(iterate k1 g x)")] trans 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   175
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   176
	(rtac (q_def3 RS sym) 2),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   177
	(res_inst_tac [("s","TT"),("t","b1`(iterate k1 g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   178
	(rtac mp 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   179
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   180
	(simp_tac nat_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   181
	(simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   182
	(etac mp 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   183
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   184
	(rtac mp 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   185
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   186
	(etac less_trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   187
	(simp_tac nat_ss 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   188
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   189
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   190
(* -------- results about p for case (? k. b1`(iterate k g x)~=TT) ------- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   191
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   192
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   193
val hoare_lemma10 = (hoare_lemma8 RS (hoare_lemma9 RS mp));
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   194
(* 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   195
val hoare_lemma10 = "[| ? k. b1`(iterate k g ?x1) ~= TT;
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   196
    Suc ?k3 = theleast (%n. b1`(iterate n g ?x1) ~= TT) |] ==>
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   197
 p`(iterate ?k3 g ?x1) = p`?x1" : thm
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   198
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   199
*)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   200
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   201
val hoare_lemma11 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   202
"(? n.b1`(iterate n g x) ~= TT) ==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   203
\ k=theleast(%n.b1`(iterate n g x) ~= TT) & b1`(iterate k g x)=FF \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   204
\ --> p`x = iterate k g x"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   205
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   206
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   207
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   208
	(res_inst_tac [("n","k")] natE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   209
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   210
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   211
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   212
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   213
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   214
	(rtac p_def3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   215
	(asm_simp_tac HOLCF_ss  1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   216
	(eres_inst_tac [("s","0"),("t","theleast(%n. b1`(iterate n g x) ~= TT)")]
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   217
	subst 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   218
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   219
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   220
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   221
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   222
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   223
	(etac (hoare_lemma10 RS sym) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   224
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   225
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   226
	(rtac p_def3 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   227
	(res_inst_tac [("s","TT"),("t","b1`(iterate xa g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   228
	(rtac (hoare_lemma8 RS spec RS mp) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   229
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   230
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   231
	(simp_tac nat_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   232
	(simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   233
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   234
	(rtac p_def3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   235
	(simp_tac (HOLCF_ss addsimps [iterate_Suc RS sym]) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   236
	(eres_inst_tac [("s","FF")]	ssubst 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   237
	(simp_tac HOLCF_ss 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   238
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   239
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   240
val hoare_lemma12 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   241
"(? n. b1`(iterate n g x) ~= TT) ==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   242
\ k=theleast(%n. b1`(iterate n g x)~=TT) & b1`(iterate k g x)=UU \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   243
\ --> p`x = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   244
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   245
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   246
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   247
	(res_inst_tac [("n","k")] natE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   248
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   249
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   250
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   251
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   252
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   253
	(rtac p_def3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   254
	(asm_simp_tac HOLCF_ss  1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   255
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   256
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   257
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   258
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   259
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   260
	(rtac (hoare_lemma10 RS sym) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   261
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   262
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   263
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   264
	(rtac p_def3 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   265
	(res_inst_tac [("s","TT"),("t","b1`(iterate xa g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   266
	(rtac (hoare_lemma8 RS spec RS mp) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   267
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   268
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   269
	(simp_tac nat_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   270
	(asm_simp_tac HOLCF_ss  1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   271
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   272
	(rtac p_def3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   273
	(asm_simp_tac HOLCF_ss  1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   274
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   275
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   276
(* -------- results about p for case  (! k. b1`(iterate k g x)=TT) ------- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   277
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   278
val fernpass_lemma = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   279
"(! k. b1`(iterate k g x)=TT) ==> !k.p`(iterate k g x) = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   280
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   281
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   282
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   283
	(rtac (p_def2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   284
	(rtac fix_ind 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   285
	(rtac adm_all 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   286
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   287
	(rtac adm_eq 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   288
	(cont_tacR 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   289
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   290
	(rtac (strict_fapp1 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   291
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   292
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   293
	(rtac allI 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   294
	(res_inst_tac [("s","TT"),("t","b1`(iterate k g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   295
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   296
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   297
	(rtac (iterate_Suc RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   298
	(etac spec 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   299
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   300
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   301
val hoare_lemma16 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   302
"(! k. b1`(iterate k g x)=TT) ==> p`x = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   303
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   304
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   305
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   306
	(res_inst_tac [("F1","g"),("t","x")] (iterate_0 RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   307
	(etac (fernpass_lemma RS spec) 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   308
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   309
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   310
(* -------- results about q for case  (! k. b1`(iterate k g x)=TT) ------- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   311
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   312
val hoare_lemma17 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   313
"(! k. b1`(iterate k g x)=TT) ==> !k.q`(iterate k g x) = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   314
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   315
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   316
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   317
	(rtac (q_def2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   318
	(rtac fix_ind 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   319
	(rtac adm_all 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   320
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   321
	(rtac adm_eq 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   322
	(cont_tacR 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   323
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   324
	(rtac (strict_fapp1 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   325
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   326
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   327
	(simp_tac iterate_ss 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   328
	(res_inst_tac [("s","TT"),("t","b1`(iterate k g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   329
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   330
	(asm_simp_tac HOLCF_ss  1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   331
	(rtac (iterate_Suc RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   332
	(etac spec 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   333
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   334
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   335
val hoare_lemma18 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   336
"(! k. b1`(iterate k g x)=TT) ==> q`x = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   337
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   338
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   339
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   340
	(res_inst_tac [("F1","g"),("t","x")] (iterate_0 RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   341
	(etac (hoare_lemma17 RS spec) 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   342
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   343
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   344
val hoare_lemma19 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   345
"(!k. (b1::'a->tr)`(iterate k g x)=TT) ==> b1`(UU::'a) = UU | (!y.b1`(y::'a)=TT)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   346
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   347
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   348
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   349
	(rtac (flat_tr RS flat_codom) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   350
	(res_inst_tac [("t","x1")] (iterate_0 RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   351
	(etac spec 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   352
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   353
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   354
val hoare_lemma20 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   355
"(! y. b1`(y::'a)=TT) ==> !k.q`(iterate k g (x::'a)) = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   356
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   357
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   358
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   359
	(rtac (q_def2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   360
	(rtac fix_ind 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   361
	(rtac adm_all 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   362
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   363
	(rtac adm_eq 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   364
	(cont_tacR 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   365
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   366
	(rtac (strict_fapp1 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   367
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   368
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   369
	(simp_tac iterate_ss 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   370
	(res_inst_tac [("s","TT"),("t","b1`(iterate k g (x::'a))")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   371
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   372
	(asm_simp_tac HOLCF_ss  1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   373
	(rtac (iterate_Suc RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   374
	(etac spec 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   375
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   376
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   377
val hoare_lemma21 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   378
"(! y. b1`(y::'a)=TT) ==> q`(x::'a) = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   379
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   380
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   381
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   382
	(res_inst_tac [("F1","g"),("t","x")] (iterate_0 RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   383
	(etac (hoare_lemma20 RS spec) 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   384
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   385
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   386
val hoare_lemma22 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   387
"b1`(UU::'a)=UU ==> q`(UU::'a) = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   388
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   389
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   390
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   391
	(rtac (q_def3 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   392
	(asm_simp_tac HOLCF_ss  1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   393
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   394
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   395
(* -------- results about q for case (? k. b1`(iterate k g x) ~= TT) ------- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   396
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   397
val hoare_lemma25 = (hoare_lemma8 RS (hoare_lemma24 RS mp) );
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   398
(* 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   399
val hoare_lemma25 = "[| ? k. b1`(iterate k g ?x1) ~= TT;
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   400
    Suc ?k3 = theleast (%n. b1`(iterate n g ?x1) ~= TT) |] ==>
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   401
 q`(iterate ?k3 g ?x1) = q`?x1" : thm
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   402
*)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   403
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   404
val hoare_lemma26 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   405
"(? n. b1`(iterate n g x)~=TT) ==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   406
\ k=theleast(%n. b1`(iterate n g x) ~= TT) & b1`(iterate k g x) =FF \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   407
\ --> q`x = q`(iterate k g x)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   408
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   409
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   410
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   411
	(res_inst_tac [("n","k")] natE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   412
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   413
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   414
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   415
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   416
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   417
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   418
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   419
	(rtac (hoare_lemma25 RS sym) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   420
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   421
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   422
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   423
	(rtac q_def3 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   424
	(res_inst_tac [("s","TT"),("t","b1`(iterate xa g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   425
	(rtac (hoare_lemma8 RS spec RS mp) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   426
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   427
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   428
	(simp_tac nat_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   429
	(simp_tac (HOLCF_ss addsimps [iterate_Suc]) 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   430
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   431
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   432
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   433
val hoare_lemma27 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   434
"(? n. b1`(iterate n g x) ~= TT) ==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   435
\ k=theleast(%n. b1`(iterate n g x)~=TT) & b1`(iterate k g x)=UU \
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   436
\ --> q`x = UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   437
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   438
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   439
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   440
	(res_inst_tac [("n","k")] natE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   441
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   442
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   443
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   444
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   445
	(rtac (q_def3 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   446
	(asm_simp_tac HOLCF_ss  1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   447
	(hyp_subst_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   448
	(simp_tac iterate_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   449
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   450
	(etac conjE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   451
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   452
	(rtac (hoare_lemma25 RS sym) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   453
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   454
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   455
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   456
	(rtac q_def3 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   457
	(res_inst_tac [("s","TT"),("t","b1`(iterate xa g x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   458
	(rtac (hoare_lemma8 RS spec RS mp) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   459
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   460
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   461
	(simp_tac nat_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   462
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   463
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   464
	(rtac q_def3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   465
	(asm_simp_tac HOLCF_ss  1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   466
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   467
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   468
(* ------- (! k. b1`(iterate k g x)=TT) ==> q o p = q   ----- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   469
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   470
val hoare_lemma23 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   471
"(! k. b1`(iterate k g x)=TT) ==> q`(p`x) = q`x"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   472
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   473
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   474
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   475
	(rtac (hoare_lemma16 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   476
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   477
	(rtac (hoare_lemma19 RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   478
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   479
	(rtac (hoare_lemma18 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   480
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   481
	(rtac (hoare_lemma22 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   482
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   483
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   484
	(rtac (hoare_lemma21 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   485
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   486
	(rtac (hoare_lemma21 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   487
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   488
	(rtac refl 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   489
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   490
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   491
(* ------------  ? k. b1~(iterate k g x) ~= TT ==> q o p = q   ----- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   492
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   493
val hoare_lemma29 = prove_goal Hoare.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   494
"? k. b1`(iterate k g x) ~= TT ==> q`(p`x) = q`x"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   495
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   496
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   497
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   498
	(rtac (hoare_lemma5 RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   499
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   500
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   501
	(rtac (hoare_lemma11 RS mp RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   502
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   503
	(rtac conjI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   504
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   505
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   506
	(rtac (hoare_lemma26 RS mp RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   507
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   508
	(rtac conjI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   509
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   510
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   511
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   512
	(rtac (hoare_lemma12 RS mp RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   513
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   514
	(rtac conjI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   515
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   516
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   517
	(rtac (hoare_lemma22 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   518
	(rtac (hoare_lemma28 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   519
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   520
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   521
	(rtac sym 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   522
	(rtac (hoare_lemma27 RS mp RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   523
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   524
	(rtac conjI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   525
	(rtac refl 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   526
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   527
	(rtac refl 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   528
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   529
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   530
(* ------ the main prove q o p = q ------ *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   531
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   532
val hoare_main = prove_goal Hoare.thy "q oo p = q"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   533
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   534
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   535
	(rtac ext_cfun 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   536
	(rtac (cfcomp2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   537
	(rtac (hoare_lemma3 RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   538
	(etac hoare_lemma23 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   539
	(etac hoare_lemma29 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   540
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   541
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   542