src/ZF/Fixedpt.ML
author wenzelm
Thu, 14 Oct 1999 15:04:36 +0200
changeset 7866 3ccaa11b6df9
parent 5321 f8848433d240
child 9907 473a6604da94
permissions -rw-r--r--
pdf: generate thumbnails if ISABELLE_THUMBPDF set;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
     1
(*  Title:      ZF/fixedpt.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
     6
Least and greatest fixed points; the Knaster-Tarski Theorem
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
Proved in the lattice of subsets of D, namely Pow(D), with Inter as glb
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
open Fixedpt;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
(*** Monotone operators ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    15
val prems = Goalw [bnd_mono_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
    "[| h(D)<=D;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
\       !!W X. [| W<=D;  X<=D;  W<=X |] ==> h(W) <= h(X)  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
\    |] ==> bnd_mono(D,h)";  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
by (REPEAT (ares_tac (prems@[conjI,allI,impI]) 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
     ORELSE etac subset_trans 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    21
qed "bnd_monoI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    23
Goalw [bnd_mono_def] "bnd_mono(D,h) ==> h(D) <= D";
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    24
by (etac conjunct1 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    25
qed "bnd_monoD1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    27
Goalw [bnd_mono_def] "[| bnd_mono(D,h);  W<=X;  X<=D |] ==> h(W) <= h(X)";
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    28
by (Blast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    29
qed "bnd_monoD2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
val [major,minor] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
    "[| bnd_mono(D,h);  X<=D |] ==> h(X) <= D";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
by (rtac (major RS bnd_monoD2 RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
by (rtac (major RS bnd_monoD1) 3);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
by (rtac minor 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
by (rtac subset_refl 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    37
qed "bnd_mono_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
    39
Goal "[| bnd_mono(D,h);  A <= D;  B <= D |] ==> \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
\                         h(A) Un h(B) <= h(A Un B)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
by (REPEAT (ares_tac [Un_upper1, Un_upper2, Un_least] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
     ORELSE etac bnd_monoD2 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    43
qed "bnd_mono_Un";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
(*Useful??*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
    46
Goal "[| bnd_mono(D,h);  A <= D;  B <= D |] ==> \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
\                        h(A Int B) <= h(A) Int h(B)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
by (REPEAT (ares_tac [Int_lower1, Int_lower2, Int_greatest] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
     ORELSE etac bnd_monoD2 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    50
qed "bnd_mono_Int";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
(**** Proof of Knaster-Tarski Theorem for the lfp ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
(*lfp is contained in each pre-fixedpoint*)
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 3016
diff changeset
    55
Goalw [lfp_def]
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
    56
    "[| h(A) <= A;  A<=D |] ==> lfp(D,h) <= A";
3016
15763781afb0 Conversion to use blast_tac
paulson
parents: 2469
diff changeset
    57
by (Blast_tac 1);
744
2054fa3c8d76 tidied proofs, using fast_tac etc. as much as possible
lcp
parents: 684
diff changeset
    58
(*or  by (rtac (PowI RS CollectI RS Inter_lower) 1); *)
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    59
qed "lfp_lowerbound";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
(*Unfolding the defn of Inter dispenses with the premise bnd_mono(D,h)!*)
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 3016
diff changeset
    62
Goalw [lfp_def,Inter_def] "lfp(D,h) <= D";
3016
15763781afb0 Conversion to use blast_tac
paulson
parents: 2469
diff changeset
    63
by (Blast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    64
qed "lfp_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
(*Used in datatype package*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
val [rew] = goal Fixedpt.thy "A==lfp(D,h) ==> A <= D";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
by (rtac lfp_subset 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    70
qed "def_lfp_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    72
val prems = Goalw [lfp_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
    "[| h(D) <= D;  !!X. [| h(X) <= X;  X<=D |] ==> A<=X |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
\    A <= lfp(D,h)";
14
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 0
diff changeset
    75
by (rtac (Pow_top RS CollectI RS Inter_greatest) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [CollectE,PowD] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    77
qed "lfp_greatest";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
val hmono::prems = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
    "[| bnd_mono(D,h);  h(A)<=A;  A<=D |] ==> h(lfp(D,h)) <= A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
by (rtac (hmono RS bnd_monoD2 RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
by (rtac lfp_lowerbound 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
by (REPEAT (resolve_tac prems 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    84
qed "lfp_lemma1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    86
Goal "bnd_mono(D,h) ==> h(lfp(D,h)) <= lfp(D,h)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
by (rtac (bnd_monoD1 RS lfp_greatest) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
by (rtac lfp_lemma1 2);
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
    89
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    90
qed "lfp_lemma2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
val [hmono] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
    "bnd_mono(D,h) ==> lfp(D,h) <= h(lfp(D,h))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
by (rtac lfp_lowerbound 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
by (rtac (hmono RS bnd_monoD2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
by (rtac (hmono RS lfp_lemma2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
by (rtac (hmono RS bnd_mono_subset) 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
by (REPEAT (rtac lfp_subset 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
    99
qed "lfp_lemma3";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   101
Goal "bnd_mono(D,h) ==> lfp(D,h) = h(lfp(D,h))";
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   102
by (REPEAT (ares_tac [equalityI,lfp_lemma2,lfp_lemma3] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   103
qed "lfp_Tarski";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
(*Definition form, to control unfolding*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
val [rew,mono] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
    "[| A==lfp(D,h);  bnd_mono(D,h) |] ==> A = h(A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
by (rtac (mono RS lfp_Tarski) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   110
qed "def_lfp_Tarski";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
(*** General induction rule for least fixedpoints ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   114
val [hmono,indstep] = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
    "[| bnd_mono(D,h);  !!x. x : h(Collect(lfp(D,h),P)) ==> P(x) \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
\    |] ==> h(Collect(lfp(D,h),P)) <= Collect(lfp(D,h),P)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
by (rtac subsetI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
by (rtac CollectI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
by (etac indstep 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
by (rtac (hmono RS lfp_lemma2 RS subsetD) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
by (rtac (hmono RS bnd_monoD2 RS subsetD) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
by (REPEAT (ares_tac [Collect_subset, lfp_subset] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   123
qed "Collect_is_pre_fixedpt";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
(*This rule yields an induction hypothesis in which the components of a
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
  data structure may be assumed to be elements of lfp(D,h)*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   127
val prems = Goal
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
   128
    "[| bnd_mono(D,h);  a : lfp(D,h);                   \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
   129
\       !!x. x : h(Collect(lfp(D,h),P)) ==> P(x)        \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
\    |] ==> P(a)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
by (rtac (Collect_is_pre_fixedpt RS lfp_lowerbound RS subsetD RS CollectD2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
by (rtac (lfp_subset RS (Collect_subset RS subset_trans)) 3);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
by (REPEAT (ares_tac prems 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   134
qed "induct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
(*Definition form, to control unfolding*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   137
val rew::prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
    "[| A == lfp(D,h);  bnd_mono(D,h);  a:A;   \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
\       !!x. x : h(Collect(A,P)) ==> P(x) \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
\    |] ==> P(a)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
by (rtac induct 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   143
qed "def_induct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
(*This version is useful when "A" is not a subset of D;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
  second premise could simply be h(D Int A) <= D or !!X. X<=D ==> h(X)<=D *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
val [hsub,hmono] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
    "[| h(D Int A) <= A;  bnd_mono(D,h) |] ==> lfp(D,h) <= A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
by (rtac (lfp_lowerbound RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
by (rtac (hmono RS bnd_mono_subset RS Int_greatest) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
by (REPEAT (resolve_tac [hsub,Int_lower1,Int_lower2] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   152
qed "lfp_Int_lowerbound";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
(*Monotonicity of lfp, where h precedes i under a domain-like partial order
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
  monotonicity of h is not strictly necessary; h must be bounded by D*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   156
val [hmono,imono,subhi] = Goal
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
   157
    "[| bnd_mono(D,h);  bnd_mono(E,i);          \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
\       !!X. X<=D ==> h(X) <= i(X)  |] ==> lfp(D,h) <= lfp(E,i)";
14
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 0
diff changeset
   159
by (rtac (bnd_monoD1 RS lfp_greatest) 1);
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 0
diff changeset
   160
by (rtac imono 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
by (rtac (hmono RSN (2, lfp_Int_lowerbound)) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
by (rtac (Int_lower1 RS subhi RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
by (rtac (imono RS bnd_monoD2 RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   164
by (REPEAT (ares_tac [Int_lower2] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   165
qed "lfp_mono";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
(*This (unused) version illustrates that monotonicity is not really needed,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
  but both lfp's must be over the SAME set D;  Inter is anti-monotonic!*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   169
val [isubD,subhi] = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
    "[| i(D) <= D;  !!X. X<=D ==> h(X) <= i(X)  |] ==> lfp(D,h) <= lfp(D,i)";
14
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 0
diff changeset
   171
by (rtac lfp_greatest 1);
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 0
diff changeset
   172
by (rtac isubD 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
by (rtac lfp_lowerbound 1);
14
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 0
diff changeset
   174
by (etac (subhi RS subset_trans) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   176
qed "lfp_mono2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
(**** Proof of Knaster-Tarski Theorem for the gfp ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
(*gfp contains each post-fixedpoint that is contained in D*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   182
Goalw [gfp_def] "[| A <= h(A);  A<=D |] ==> A <= gfp(D,h)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
by (rtac (PowI RS CollectI RS Union_upper) 1);
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   184
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   185
qed "gfp_upperbound";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 3016
diff changeset
   187
Goalw [gfp_def] "gfp(D,h) <= D";
3016
15763781afb0 Conversion to use blast_tac
paulson
parents: 2469
diff changeset
   188
by (Blast_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   189
qed "gfp_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
(*Used in datatype package*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
val [rew] = goal Fixedpt.thy "A==gfp(D,h) ==> A <= D";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   193
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
by (rtac gfp_subset 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   195
qed "def_gfp_subset";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   197
val hmono::prems = Goalw [gfp_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
    "[| bnd_mono(D,h);  !!X. [| X <= h(X);  X<=D |] ==> X<=A |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
\    gfp(D,h) <= A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
by (fast_tac (subset_cs addIs ((hmono RS bnd_monoD1)::prems)) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   201
qed "gfp_least";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
val hmono::prems = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
    "[| bnd_mono(D,h);  A<=h(A);  A<=D |] ==> A <= h(gfp(D,h))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
by (rtac (hmono RS bnd_monoD2 RSN (2,subset_trans)) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
by (rtac gfp_subset 3);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
by (rtac gfp_upperbound 2);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
by (REPEAT (resolve_tac prems 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   209
qed "gfp_lemma1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   211
Goal "bnd_mono(D,h) ==> gfp(D,h) <= h(gfp(D,h))";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
by (rtac gfp_least 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
by (rtac gfp_lemma1 2);
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   214
by (REPEAT (assume_tac 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   215
qed "gfp_lemma2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
val [hmono] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
    "bnd_mono(D,h) ==> h(gfp(D,h)) <= gfp(D,h)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
by (rtac gfp_upperbound 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
by (rtac (hmono RS bnd_monoD2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
by (rtac (hmono RS gfp_lemma2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
by (REPEAT (rtac ([hmono, gfp_subset] MRS bnd_mono_subset) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   223
qed "gfp_lemma3";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   225
Goal "bnd_mono(D,h) ==> gfp(D,h) = h(gfp(D,h))";
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   226
by (REPEAT (ares_tac [equalityI,gfp_lemma2,gfp_lemma3] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   227
qed "gfp_Tarski";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
(*Definition form, to control unfolding*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
val [rew,mono] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
    "[| A==gfp(D,h);  bnd_mono(D,h) |] ==> A = h(A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
by (rtac (mono RS gfp_Tarski) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   234
qed "def_gfp_Tarski";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
(*** Coinduction rules for greatest fixed points ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   238
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
(*weak version*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   240
Goal "[| a: X;  X <= h(X);  X <= D |] ==> a : gfp(D,h)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
by (REPEAT (ares_tac [gfp_upperbound RS subsetD] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   242
qed "weak_coinduct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
val [subs_h,subs_D,mono] = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
    "[| X <= h(X Un gfp(D,h));  X <= D;  bnd_mono(D,h) |] ==>  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
\    X Un gfp(D,h) <= h(X Un gfp(D,h))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
by (rtac (subs_h RS Un_least) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
by (rtac (mono RS gfp_lemma2 RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
by (rtac (Un_upper2 RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
by (rtac ([mono, subs_D, gfp_subset] MRS bnd_mono_Un) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   251
qed "coinduct_lemma";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
(*strong version*)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   254
Goal "[| bnd_mono(D,h);  a: X;  X <= h(X Un gfp(D,h));  X <= D |] ==> \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
\           a : gfp(D,h)";
647
fb7345cccddc ZF/Fixedpt/coinduct: modified proof to suppress deep unification
lcp
parents: 484
diff changeset
   256
by (rtac weak_coinduct 1);
fb7345cccddc ZF/Fixedpt/coinduct: modified proof to suppress deep unification
lcp
parents: 484
diff changeset
   257
by (etac coinduct_lemma 2);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
by (REPEAT (ares_tac [gfp_subset, UnI1, Un_least] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   259
qed "coinduct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
(*Definition form, to control unfolding*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
val rew::prems = goal Fixedpt.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
    "[| A == gfp(D,h);  bnd_mono(D,h);  a: X;  X <= h(X Un A);  X <= D |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
\    a : A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
by (rtac coinduct 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   268
qed "def_coinduct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
(*Lemma used immediately below!*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   271
val [subsA,XimpP] = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
    "[| X <= A;  !!z. z:X ==> P(z) |] ==> X <= Collect(A,P)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
by (rtac (subsA RS subsetD RS CollectI RS subsetI) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
by (assume_tac 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
by (etac XimpP 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   276
qed "subset_Collect";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
(*The version used in the induction/coinduction package*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   279
val prems = Goal
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
    "[| A == gfp(D, %w. Collect(D,P(w)));  bnd_mono(D, %w. Collect(D,P(w)));  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
\       a: X;  X <= D;  !!z. z: X ==> P(X Un A, z) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
\    a : A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
by (rtac def_coinduct 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   284
by (REPEAT (ares_tac (subset_Collect::prems) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   285
qed "def_Collect_coinduct";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
(*Monotonicity of gfp!*)
5321
f8848433d240 got rid of some goal thy commands
paulson
parents: 5147
diff changeset
   288
val [hmono,subde,subhi] = Goal
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
   289
    "[| bnd_mono(D,h);  D <= E;                 \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
\       !!X. X<=D ==> h(X) <= i(X)  |] ==> gfp(D,h) <= gfp(E,i)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
by (rtac gfp_upperbound 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
by (rtac (hmono RS gfp_lemma2 RS subset_trans) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
by (rtac (gfp_subset RS subhi) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
by (rtac ([gfp_subset, subde] MRS subset_trans) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 744
diff changeset
   295
qed "gfp_mono";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296