src/HOL/UNITY/Follows.ML
author paulson
Fri, 12 May 2000 15:05:02 +0200
changeset 8862 78643f8449c6
parent 8314 463f63a9a7f2
child 9019 9c1118619d6c
permissions -rw-r--r--
NatSimprocs is now a theory, not a file
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Follows
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     2
    ID:         $Id$
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     5
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     6
The Follows relation of Charpentier and Sivilotte
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     7
*)
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     8
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
     9
(*Does this hold for "invariant"?*)
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    10
Goal "mono h ==> Always {s. f s <= g s} <= Always {s. h (f s) <= h (g s)}";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    11
by (asm_simp_tac (simpset() addsimps [Always_eq_includes_reachable]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    12
by (blast_tac (claset() addIs [monoD]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    13
qed "mono_Always_o";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    14
7363
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    15
Goal "mono (h::'a::order => 'b::order) \
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    16
\     ==> (INT j. {s. j <= g s} LeadsTo {s. j <= f s}) <= \
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    17
\         (INT k. {s. k <= h (g s)} LeadsTo {s. k <= h (f s)})";
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    18
by Auto_tac;
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    19
by (rtac single_LeadsTo_I 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    20
by (dres_inst_tac [("x", "g s")] spec 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    21
by (etac LeadsTo_weaken 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    22
by (ALLGOALS (blast_tac (claset() addIs [monoD, order_trans])));
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    23
qed "mono_LeadsTo_o";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    24
6809
5b8912f7bb69 shortened Follows to Fols
paulson
parents: 6706
diff changeset
    25
Goalw [Follows_def] "mono h ==> f Fols g <= (h o f) Fols (h o g)";
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    26
by (Clarify_tac 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    27
by (asm_full_simp_tac
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    28
    (simpset() addsimps [impOfSubs mono_Increasing_o,
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    29
			 impOfSubs mono_Always_o,
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    30
			 impOfSubs mono_LeadsTo_o RS INT_D]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    31
qed "mono_Follows_o";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    32
7542
b6599e292011 new theorem mono_Follows_apply
paulson
parents: 7363
diff changeset
    33
Goal "mono h ==> f Fols g <= (%x. h (f x)) Fols (%x. h (g x))";
b6599e292011 new theorem mono_Follows_apply
paulson
parents: 7363
diff changeset
    34
by (dtac mono_Follows_o 1);
b6599e292011 new theorem mono_Follows_apply
paulson
parents: 7363
diff changeset
    35
by (force_tac (claset(), simpset() addsimps [o_def]) 1);
b6599e292011 new theorem mono_Follows_apply
paulson
parents: 7363
diff changeset
    36
qed "mono_Follows_apply";
b6599e292011 new theorem mono_Follows_apply
paulson
parents: 7363
diff changeset
    37
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    38
Goalw [Follows_def]
6809
5b8912f7bb69 shortened Follows to Fols
paulson
parents: 6706
diff changeset
    39
     "[| F : f Fols g;  F: g Fols h |] ==> F : f Fols h";
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    40
by (asm_full_simp_tac (simpset() addsimps [Always_eq_includes_reachable]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    41
by (blast_tac (claset() addIs [order_trans, LeadsTo_Trans]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    42
qed "Follows_trans";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    43
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    44
7363
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    45
(** Destructiom rules **)
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    46
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    47
Goalw [Follows_def]
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    48
     "F : f Fols g ==> F : Increasing f";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    49
by (Blast_tac 1);
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    50
qed "Follows_Increasing1";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    51
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    52
Goalw [Follows_def]
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    53
     "F : f Fols g ==> F : Increasing g";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    54
by (Blast_tac 1);
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    55
qed "Follows_Increasing2";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    56
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    57
Goalw [Follows_def]
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    58
     "F : f Fols g ==> F : Always {s. f s <= g s}";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    59
by (Blast_tac 1);
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    60
qed "Follows_Bounded";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    61
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    62
Goalw [Follows_def]
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    63
     "F : f Fols g ==> F : {s. k <= g s} LeadsTo {s. k <= f s}";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    64
by (Blast_tac 1);
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    65
qed "Follows_LeadsTo";
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    66
8128
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    67
Goal "F : f Fols g ==> F : {s. k pfixLe g s} LeadsTo {s. k pfixLe f s}";
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    68
by (rtac single_LeadsTo_I 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    69
by (Clarify_tac 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    70
by (dtac Follows_LeadsTo 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    71
by (etac LeadsTo_weaken 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    72
by (blast_tac set_cs 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    73
by (blast_tac (claset() addIs [pfixLe_trans, prefix_imp_pfixLe]) 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    74
qed "Follows_LeadsTo_pfixLe";
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    75
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    76
Goal "F : f Fols g ==> F : {s. k pfixGe g s} LeadsTo {s. k pfixGe f s}";
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    77
by (rtac single_LeadsTo_I 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    78
by (Clarify_tac 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    79
by (dtac Follows_LeadsTo 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    80
by (etac LeadsTo_weaken 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    81
by (blast_tac set_cs 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    82
by (blast_tac (claset() addIs [pfixGe_trans, prefix_imp_pfixGe]) 1);
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    83
qed "Follows_LeadsTo_pfixGe";
3a5864b465e2 still working; a bit of polishing
paulson
parents: 8113
diff changeset
    84
7363
eddb3d77a363 new destruction rules
paulson
parents: 6809
diff changeset
    85
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    86
(*Can replace "Un" by any sup.  But existing max only works for linorders.*)
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    87
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    88
Goalw [increasing_def, stable_def, constrains_def]
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    89
    "[| F : increasing f;  F: increasing g |] \
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    90
\    ==> F : increasing (%s. (f s) Un (g s))";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    91
by Auto_tac;
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    92
by (dres_inst_tac [("x","f xa")] spec 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    93
by (dres_inst_tac [("x","g xa")] spec 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    94
by (blast_tac (claset() addSDs [bspec]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    95
qed "increasing_Un";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    96
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    97
Goalw [Increasing_def, Stable_def, Constrains_def, stable_def, constrains_def]
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    98
    "[| F : Increasing f;  F: Increasing g |] \
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
    99
\    ==> F : Increasing (%s. (f s) Un (g s))";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   100
by Auto_tac;
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   101
by (dres_inst_tac [("x","f xa")] spec 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   102
by (dres_inst_tac [("x","g xa")] spec 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   103
by (blast_tac (claset() addSDs [bspec]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   104
qed "Increasing_Un";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   105
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   106
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   107
Goal "[| F : Always {s. f' s <= f s}; F : Always {s. g' s <= g s} |] \
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   108
\     ==> F : Always {s. f' s Un g' s <= f s Un g s}";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   109
by (asm_full_simp_tac (simpset() addsimps [Always_eq_includes_reachable]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   110
by (Blast_tac 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   111
qed "Always_Un";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   112
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   113
(*Lemma to re-use the argument that one variable increases (progress)
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   114
  while the other variable doesn't decrease (safety)*)
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   115
Goal "[| F : Increasing f; F : Increasing g; \
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   116
\        F : Increasing g'; F : Always {s. f' s <= f s};\
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   117
\        ALL k. F : {s. k <= f s} LeadsTo {s. k <= f' s} |]\
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   118
\     ==> F : {s. k <= f s Un g s} LeadsTo {s. k <= f' s Un g s}";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   119
by (rtac single_LeadsTo_I 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   120
by (dres_inst_tac [("x", "f s")] IncreasingD 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   121
by (dres_inst_tac [("x", "g s")] IncreasingD 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   122
by (rtac LeadsTo_weaken 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   123
by (rtac PSP_Stable 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   124
by (eres_inst_tac [("x", "f s")] spec 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   125
by (etac Stable_Int 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   126
by (assume_tac 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   127
by (Blast_tac 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   128
by (Blast_tac 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   129
qed "Follows_Un_lemma";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   130
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   131
Goalw [Follows_def]
6809
5b8912f7bb69 shortened Follows to Fols
paulson
parents: 6706
diff changeset
   132
    "[| F : f' Fols f;  F: g' Fols g |] \
5b8912f7bb69 shortened Follows to Fols
paulson
parents: 6706
diff changeset
   133
\    ==> F : (%s. (f' s) Un (g' s)) Fols (%s. (f s) Un (g s))";
6706
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   134
by (asm_full_simp_tac (simpset() addsimps [Increasing_Un, Always_Un]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   135
by Auto_tac;
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   136
by (rtac LeadsTo_Trans 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   137
by (blast_tac (claset() addIs [Follows_Un_lemma]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   138
(*Weakening is used to exchange Un's arguments*)
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   139
by (blast_tac (claset() addIs [Follows_Un_lemma RS LeadsTo_weaken]) 1);
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   140
qed "Follows_Un";
d8067e272d4f Theory of the "Follows" relation
paulson
parents:
diff changeset
   141
8314
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   142
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   143
(*Currently UNUSED, but possibly of interest*)
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   144
Goal "F : Increasing func ==> F : Stable {s. h pfixGe (func s)}";
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   145
by (asm_full_simp_tac
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   146
    (simpset() addsimps [Increasing_def, Stable_def, Constrains_def, 
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   147
			 constrains_def]) 1); 
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   148
by (blast_tac (claset() addIs [trans_Ge RS trans_genPrefix RS transD,
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   149
			       prefix_imp_pfixGe]) 1);
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   150
qed "Increasing_imp_Stable_pfixGe";
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   151
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   152
(*Currently UNUSED, but possibly of interest*)
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   153
Goal "ALL z. F : {s. z <= f s} LeadsTo {s. z <= g s} \
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   154
\     ==> F : {s. z pfixGe f s} LeadsTo {s. z pfixGe g s}";
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   155
by (rtac single_LeadsTo_I 1);
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   156
by (dres_inst_tac [("x", "f s")] spec 1);
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   157
by (etac LeadsTo_weaken 1);
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   158
by (blast_tac (claset() addIs [trans_Ge RS trans_genPrefix RS transD,
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   159
			       prefix_imp_pfixGe]) 2);
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   160
by (Blast_tac 1);
463f63a9a7f2 even Alloc works again, using "rename"
paulson
parents: 8216
diff changeset
   161
qed "LeadsTo_le_imp_pfixGe";