src/HOLCF/ex/Loop.ML
author paulson
Thu, 18 Jan 1996 10:38:29 +0100
changeset 1444 23ceb1dc9755
parent 1274 ea0668a1c0ba
child 1461 6bcb44e4d6e5
permissions -rw-r--r--
trivial updates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1274
ea0668a1c0ba added 8bit pragmas
regensbu
parents: 1267
diff changeset
     1
(*  Title:	HOLCF/ex/Loop.ML
244
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
Lemmas for theory loop.thy
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     7
*)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     8
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
     9
open Loop;
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    10
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    11
(* --------------------------------------------------------------------------- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    12
(* access to definitions                                                       *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    13
(* --------------------------------------------------------------------------- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    14
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    15
val step_def2 = prove_goalw Loop.thy [step_def]
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    16
"step`b`g`x = If b`x then g`x else x fi"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    17
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    18
	[
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
    19
	(Simp_tac 1)
244
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 while_def2 = prove_goalw Loop.thy [while_def]
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    23
"while`b`g = fix`(LAM f x. If b`x then f`(g`x) else x fi)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    24
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    25
	[
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
    26
	(Simp_tac 1)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    27
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    28
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    29
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    30
(* ------------------------------------------------------------------------- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    31
(* rekursive properties of while                                             *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    32
(* ------------------------------------------------------------------------- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    33
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    34
val while_unfold = prove_goal Loop.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    35
"while`b`g`x = If b`x then while`b`g`(g`x) else x fi"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    36
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    37
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    38
	(fix_tac5  while_def2 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
    39
	(Simp_tac 1)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    40
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    41
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    42
val while_unfold2 = prove_goal Loop.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    43
	"!x.while`b`g`x = while`b`g`(iterate k (step`b`g) x)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    44
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    45
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    46
	(nat_ind_tac "k" 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
    47
	(simp_tac HOLCF_ss 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    48
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    49
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    50
	(rtac (while_unfold RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    51
	(rtac refl 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    52
	(rtac (iterate_Suc2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    53
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    54
	(etac spec 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    55
	(rtac (step_def2 RS ssubst) 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    56
	(res_inst_tac [("p","b`x")] trE 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    57
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    58
	(rtac (while_unfold RS ssubst) 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    59
	(res_inst_tac [("s","UU"),("t","b`UU")]ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    60
	(etac (flat_tr RS flat_codom RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    61
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    62
	(etac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    63
	(simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    64
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    65
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    66
	(rtac (while_unfold RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    67
	(asm_simp_tac HOLCF_ss 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 while_unfold3 = prove_goal Loop.thy 
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    71
	"while`b`g`x = while`b`g`(step`b`g`x)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    72
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    73
	[
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    74
	(res_inst_tac [("s",
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    75
		"while`b`g`(iterate (Suc 0) (step`b`g) x)")] trans 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    76
	(rtac (while_unfold2 RS spec) 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
    77
	(Simp_tac 1)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    78
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    79
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    80
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    81
(* --------------------------------------------------------------------------- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    82
(* properties of while and iterations                                          *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    83
(* --------------------------------------------------------------------------- *)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    84
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
    85
val loop_lemma1 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
    86
"[|? y.b`y=FF; iterate k (step`b`g) x = UU|]==>iterate(Suc k) (step`b`g) x=UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    87
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    88
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    89
	(cut_facts_tac prems 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
    90
	(Simp_tac 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    91
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    92
	(rtac step_def2 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    93
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    94
	(etac exE 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    95
	(etac (flat_tr RS flat_codom RS disjE) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    96
	(asm_simp_tac HOLCF_ss 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    97
	(asm_simp_tac HOLCF_ss 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    98
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
    99
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   100
val loop_lemma2 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   101
"[|? y.b`y=FF;iterate (Suc k) (step`b`g) x ~=UU |]==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   102
\iterate k (step`b`g) x ~=UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   103
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   104
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   105
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   106
	(rtac contrapos 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   107
	(etac  loop_lemma1 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   108
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   109
	(atac 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   110
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   111
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   112
val loop_lemma3 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   113
"[|!x. INV x & b`x=TT & g`x~=UU --> INV (g`x);\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   114
\? y.b`y=FF; INV x|] ==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   115
\iterate k (step`b`g) x ~=UU --> INV (iterate k (step`b`g) x)"
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
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   119
	(nat_ind_tac "k" 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   120
	(Asm_simp_tac 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   121
	(strip_tac 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   122
	(simp_tac (!simpset addsimps [step_def2]) 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   123
	(res_inst_tac [("p","b`(iterate k1 (step`b`g) x)")] trE 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   124
	(etac notE 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   125
	(asm_simp_tac (HOLCF_ss addsimps [step_def2] ) 1),
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   126
	(asm_simp_tac HOLCF_ss 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   127
	(rtac mp 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   128
	(etac spec 1),
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   129
	(asm_simp_tac (HOLCF_ss delsimps [iterate_Suc]
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   130
                                addsimps [loop_lemma2] ) 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   131
	(res_inst_tac [("s","iterate (Suc k1) (step`b`g) x"),
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   132
		("t","g`(iterate k1 (step`b`g) x)")] ssubst 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   133
	(atac 2),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   134
	(asm_simp_tac (HOLCF_ss addsimps [step_def2] ) 1),
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   135
	(asm_simp_tac (HOLCF_ss delsimps [iterate_Suc]
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   136
                                addsimps [loop_lemma2] ) 1)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   137
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   138
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   139
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   140
val loop_lemma4 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   141
"!x. b`(iterate k (step`b`g) x)=FF --> while`b`g`x= iterate k (step`b`g) x"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   142
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   143
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   144
	(nat_ind_tac "k" 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   145
	(Simp_tac 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   146
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   147
	(rtac (while_unfold RS ssubst) 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   148
	(asm_simp_tac HOLCF_ss 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   149
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   150
	(rtac (iterate_Suc2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   151
	(strip_tac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   152
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   153
	(rtac while_unfold3 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   154
	(asm_simp_tac HOLCF_ss 1)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   155
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   156
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   157
val loop_lemma5 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   158
"!k. b`(iterate k (step`b`g) x) ~= FF ==>\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   159
\ !m. while`b`g`(iterate m (step`b`g) x)=UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   160
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   161
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   162
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   163
	(rtac (while_def2 RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   164
	(rtac fix_ind 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   165
	(rtac (allI RS adm_all) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   166
	(rtac adm_eq 1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   167
	(cont_tacR 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   168
	(Simp_tac  1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   169
	(rtac allI 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   170
	(Simp_tac  1),
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   171
	(res_inst_tac [("p","b`(iterate m (step`b`g) x)")] trE 1),
1267
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   172
	(asm_simp_tac HOLCF_ss 1),
bca91b4e1710 added local simpsets
clasohm
parents: 1168
diff changeset
   173
	(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
   174
	(res_inst_tac [("s","xa`(iterate (Suc m) (step`b`g) x)")] trans 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   175
	(etac spec 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   176
	(rtac cfun_arg_cong 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   177
	(rtac trans 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   178
	(rtac (iterate_Suc RS sym) 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   179
	(asm_simp_tac (HOLCF_ss addsimps [step_def2]) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   180
	(dtac spec 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   181
	(contr_tac 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   182
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   183
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   184
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   185
val loop_lemma6 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   186
"!k. b`(iterate k (step`b`g) x) ~= FF ==> while`b`g`x=UU"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   187
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   188
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   189
	(res_inst_tac [("t","x")] (iterate_0 RS subst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   190
	(rtac (loop_lemma5 RS spec) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   191
	(resolve_tac prems 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   192
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   193
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   194
val loop_lemma7 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   195
"while`b`g`x ~= UU ==> ? k. b`(iterate k (step`b`g) x) = FF"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   196
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   197
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   198
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   199
	(etac swap 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   200
	(rtac loop_lemma6 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   201
	(fast_tac HOL_cs 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   202
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   203
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   204
val loop_lemma8 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   205
"while`b`g`x ~= UU ==> ? y. b`y=FF"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   206
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   207
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   208
	(cut_facts_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   209
	(dtac loop_lemma7 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   210
	(fast_tac HOL_cs 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   211
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   212
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   213
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   214
(* ------------------------------------------------------------------------- *)
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   215
(* an invariant rule for loops                                               *)
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   216
(* ------------------------------------------------------------------------- *)
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   217
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   218
val loop_inv2 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   219
"[| (!y. INV y & b`y=TT & g`y ~= UU --> INV (g`y));\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   220
\   (!y. INV y & b`y=FF --> Q y);\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   221
\   INV x; while`b`g`x~=UU |] ==> Q (while`b`g`x)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   222
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   223
	[
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   224
	(res_inst_tac [("P","%k. b`(iterate k (step`b`g) x)=FF")] exE 1),
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   225
	(rtac loop_lemma7 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   226
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   227
	(rtac ((loop_lemma4 RS spec RS mp) RS ssubst) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   228
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   229
	(rtac (nth_elem (1,prems) RS spec RS mp) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   230
	(rtac conjI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   231
	(atac 2),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   232
	(rtac (loop_lemma3 RS mp) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   233
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   234
	(rtac loop_lemma8 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   235
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   236
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   237
	(rtac classical3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   238
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   239
	(etac box_equals 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   240
	(rtac (loop_lemma4 RS spec RS mp RS sym) 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   241
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   242
	(rtac refl 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   243
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   244
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   245
val loop_inv3 = prove_goal Loop.thy
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   246
"[| !!y.[| INV y; b`y=TT; g`y~=UU|] ==> INV (g`y);\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   247
\   !!y.[| INV y; b`y=FF|]==> Q y;\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   248
\   INV x; while`b`g`x~=UU |] ==> Q (while`b`g`x)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   249
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   250
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   251
	(rtac loop_inv2 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   252
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   253
	(rtac impI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   254
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   255
	(fast_tac HOL_cs 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   256
	(fast_tac HOL_cs 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   257
	(fast_tac HOL_cs 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   258
	(rtac allI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   259
	(rtac impI 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   260
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   261
	(fast_tac HOL_cs 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   262
	(fast_tac HOL_cs 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   263
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   264
	(resolve_tac prems 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   265
	]);
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   266
1043
ffa68eb2730b adjusted HOLCF for new hyp_subst_tac
regensbu
parents: 892
diff changeset
   267
val loop_inv = prove_goal Loop.thy
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   268
"[| P(x);\
1168
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   269
\   !!y.P y ==> INV y;\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   270
\   !!y.[| INV y; b`y=TT; g`y~=UU|] ==> INV (g`y);\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   271
\   !!y.[| INV y; b`y=FF|]==> Q y;\
74be52691d62 The curried version of HOLCF is now just called HOLCF. The old
regensbu
parents: 1043
diff changeset
   272
\   while`b`g`x ~= UU |] ==> Q (while`b`g`x)"
244
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   273
 (fn prems =>
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   274
	[
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   275
	(rtac loop_inv3 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   276
	(eresolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   277
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   278
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   279
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   280
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   281
	(atac 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   282
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   283
	(resolve_tac prems 1),
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   284
	(resolve_tac prems 1)
929fc2c63bd0 HOLCF examples
nipkow
parents:
diff changeset
   285
	]);