src/CCL/Gfp.thy
author wenzelm
Fri, 17 Nov 2006 02:20:03 +0100
changeset 21404 eb85850d3eb7
parent 20140 98acc6d0fab6
child 32153 a0e57fb1b930
permissions -rw-r--r--
more robust syntax for definition/abbreviation/notation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
     1
(*  Title:      CCL/Gfp.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1474
3f7d67927fe2 expanded tabs
clasohm
parents: 0
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
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
     7
header {* Greatest fixed points *}
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
     8
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
     9
theory Gfp
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
    10
imports Lfp
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
    11
begin
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
    12
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    13
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20140
diff changeset
    14
  gfp :: "['a set=>'a set] => 'a set" where -- "greatest fixed point"
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
    15
  "gfp(f) == Union({u. u <= f(u)})"
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
    16
20140
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    17
(* gfp(f) is the least upper bound of {u. u <= f(u)} *)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    18
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    19
lemma gfp_upperbound: "[| A <= f(A) |] ==> A <= gfp(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    20
  unfolding gfp_def by blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    21
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    22
lemma gfp_least: "[| !!u. u <= f(u) ==> u<=A |] ==> gfp(f) <= A"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    23
  unfolding gfp_def by blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    24
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    25
lemma gfp_lemma2: "mono(f) ==> gfp(f) <= f(gfp(f))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    26
  by (rule gfp_least, rule subset_trans, assumption, erule monoD,
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    27
    rule gfp_upperbound, assumption)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    28
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    29
lemma gfp_lemma3: "mono(f) ==> f(gfp(f)) <= gfp(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    30
  by (rule gfp_upperbound, frule monoD, rule gfp_lemma2, assumption+)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    31
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    32
lemma gfp_Tarski: "mono(f) ==> gfp(f) = f(gfp(f))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    33
  by (rule equalityI gfp_lemma2 gfp_lemma3 | assumption)+
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    34
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    35
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    36
(*** Coinduction rules for greatest fixed points ***)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    37
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    38
(*weak version*)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    39
lemma coinduct: "[| a: A;  A <= f(A) |] ==> a : gfp(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    40
  by (blast dest: gfp_upperbound)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    41
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    42
lemma coinduct2_lemma:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    43
  "[| A <= f(A) Un gfp(f);  mono(f) |] ==>   
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    44
    A Un gfp(f) <= f(A Un gfp(f))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    45
  apply (rule subset_trans)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    46
   prefer 2
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    47
   apply (erule mono_Un)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    48
  apply (rule subst, erule gfp_Tarski)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    49
  apply (erule Un_least)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    50
  apply (rule Un_upper2)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    51
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    52
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    53
(*strong version, thanks to Martin Coen*)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    54
lemma coinduct2:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    55
  "[| a: A;  A <= f(A) Un gfp(f);  mono(f) |] ==> a : gfp(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    56
  apply (rule coinduct)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    57
   prefer 2
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    58
   apply (erule coinduct2_lemma, assumption)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    59
  apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    60
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    61
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    62
(***  Even Stronger version of coinduct  [by Martin Coen]
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    63
         - instead of the condition  A <= f(A)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    64
                           consider  A <= (f(A) Un f(f(A)) ...) Un gfp(A) ***)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    65
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    66
lemma coinduct3_mono_lemma: "mono(f) ==> mono(%x. f(x) Un A Un B)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    67
  by (rule monoI) (blast dest: monoD)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    68
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    69
lemma coinduct3_lemma:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    70
  assumes prem: "A <= f(lfp(%x. f(x) Un A Un gfp(f)))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    71
    and mono: "mono(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    72
  shows "lfp(%x. f(x) Un A Un gfp(f)) <= f(lfp(%x. f(x) Un A Un gfp(f)))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    73
  apply (rule subset_trans)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    74
   apply (rule mono [THEN coinduct3_mono_lemma, THEN lfp_lemma3])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    75
  apply (rule Un_least [THEN Un_least])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    76
    apply (rule subset_refl)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    77
   apply (rule prem)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    78
  apply (rule mono [THEN gfp_Tarski, THEN equalityD1, THEN subset_trans])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    79
  apply (rule mono [THEN monoD])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    80
  apply (subst mono [THEN coinduct3_mono_lemma, THEN lfp_Tarski])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    81
  apply (rule Un_upper2)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    82
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    83
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    84
lemma coinduct3:
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    85
  assumes 1: "a:A"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    86
    and 2: "A <= f(lfp(%x. f(x) Un A Un gfp(f)))"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    87
    and 3: "mono(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    88
  shows "a : gfp(f)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    89
  apply (rule coinduct)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    90
   prefer 2
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    91
   apply (rule coinduct3_lemma [OF 2 3])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    92
  apply (subst lfp_Tarski [OF coinduct3_mono_lemma, OF 3])
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    93
  using 1 apply blast
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    94
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    95
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    96
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    97
subsection {* Definition forms of @{text "gfp_Tarski"}, to control unfolding *}
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    98
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
    99
lemma def_gfp_Tarski: "[| h==gfp(f);  mono(f) |] ==> h = f(h)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   100
  apply unfold
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   101
  apply (erule gfp_Tarski)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   102
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   103
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   104
lemma def_coinduct: "[| h==gfp(f);  a:A;  A <= f(A) |] ==> a: h"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   105
  apply unfold
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   106
  apply (erule coinduct)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   107
  apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   108
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   109
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   110
lemma def_coinduct2: "[| h==gfp(f);  a:A;  A <= f(A) Un h; mono(f) |] ==> a: h"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   111
  apply unfold
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   112
  apply (erule coinduct2)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   113
   apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   114
  apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   115
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   116
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   117
lemma def_coinduct3: "[| h==gfp(f);  a:A;  A <= f(lfp(%x. f(x) Un A Un h)); mono(f) |] ==> a: h"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   118
  apply unfold
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   119
  apply (erule coinduct3)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   120
   apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   121
  apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   122
  done
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   123
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   124
(*Monotonicity of gfp!*)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   125
lemma gfp_mono: "[| mono(f);  !!Z. f(Z)<=g(Z) |] ==> gfp(f) <= gfp(g)"
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   126
  apply (rule gfp_upperbound)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   127
  apply (rule subset_trans)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   128
   apply (rule gfp_lemma2)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   129
   apply assumption
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   130
  apply (erule meta_spec)
98acc6d0fab6 removed obsolete ML files;
wenzelm
parents: 17456
diff changeset
   131
  done
17456
bcf7544875b2 converted to Isar theory format;
wenzelm
parents: 1474
diff changeset
   132
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
end