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