src/CCL/Gfp.thy
author wenzelm
Tue Aug 12 21:29:50 2014 +0200 (2014-08-12)
changeset 57920 c1953856cfca
parent 32153 a0e57fb1b930
child 58889 5b7a9633cfa8
permissions -rw-r--r--
clarified focus and key handling -- more like SideKick;
avoid resetting input map with its potentially confusion propagation of key events to unrelated components, e.g. main text area or tree scrollbar;
wenzelm@17456
     1
(*  Title:      CCL/Gfp.thy
clasohm@1474
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     3
    Copyright   1992  University of Cambridge
clasohm@0
     4
*)
clasohm@0
     5
wenzelm@17456
     6
header {* Greatest fixed points *}
wenzelm@17456
     7
wenzelm@17456
     8
theory Gfp
wenzelm@17456
     9
imports Lfp
wenzelm@17456
    10
begin
wenzelm@17456
    11
wenzelm@20140
    12
definition
wenzelm@21404
    13
  gfp :: "['a set=>'a set] => 'a set" where -- "greatest fixed point"
wenzelm@17456
    14
  "gfp(f) == Union({u. u <= f(u)})"
wenzelm@17456
    15
wenzelm@20140
    16
(* gfp(f) is the least upper bound of {u. u <= f(u)} *)
wenzelm@20140
    17
wenzelm@20140
    18
lemma gfp_upperbound: "[| A <= f(A) |] ==> A <= gfp(f)"
wenzelm@20140
    19
  unfolding gfp_def by blast
wenzelm@20140
    20
wenzelm@20140
    21
lemma gfp_least: "[| !!u. u <= f(u) ==> u<=A |] ==> gfp(f) <= A"
wenzelm@20140
    22
  unfolding gfp_def by blast
wenzelm@20140
    23
wenzelm@20140
    24
lemma gfp_lemma2: "mono(f) ==> gfp(f) <= f(gfp(f))"
wenzelm@20140
    25
  by (rule gfp_least, rule subset_trans, assumption, erule monoD,
wenzelm@20140
    26
    rule gfp_upperbound, assumption)
wenzelm@20140
    27
wenzelm@20140
    28
lemma gfp_lemma3: "mono(f) ==> f(gfp(f)) <= gfp(f)"
wenzelm@20140
    29
  by (rule gfp_upperbound, frule monoD, rule gfp_lemma2, assumption+)
wenzelm@20140
    30
wenzelm@20140
    31
lemma gfp_Tarski: "mono(f) ==> gfp(f) = f(gfp(f))"
wenzelm@20140
    32
  by (rule equalityI gfp_lemma2 gfp_lemma3 | assumption)+
wenzelm@20140
    33
wenzelm@20140
    34
wenzelm@20140
    35
(*** Coinduction rules for greatest fixed points ***)
wenzelm@20140
    36
wenzelm@20140
    37
(*weak version*)
wenzelm@20140
    38
lemma coinduct: "[| a: A;  A <= f(A) |] ==> a : gfp(f)"
wenzelm@20140
    39
  by (blast dest: gfp_upperbound)
wenzelm@20140
    40
wenzelm@20140
    41
lemma coinduct2_lemma:
wenzelm@20140
    42
  "[| A <= f(A) Un gfp(f);  mono(f) |] ==>   
wenzelm@20140
    43
    A Un gfp(f) <= f(A Un gfp(f))"
wenzelm@20140
    44
  apply (rule subset_trans)
wenzelm@20140
    45
   prefer 2
wenzelm@20140
    46
   apply (erule mono_Un)
wenzelm@20140
    47
  apply (rule subst, erule gfp_Tarski)
wenzelm@20140
    48
  apply (erule Un_least)
wenzelm@20140
    49
  apply (rule Un_upper2)
wenzelm@20140
    50
  done
wenzelm@20140
    51
wenzelm@20140
    52
(*strong version, thanks to Martin Coen*)
wenzelm@20140
    53
lemma coinduct2:
wenzelm@20140
    54
  "[| a: A;  A <= f(A) Un gfp(f);  mono(f) |] ==> a : gfp(f)"
wenzelm@20140
    55
  apply (rule coinduct)
wenzelm@20140
    56
   prefer 2
wenzelm@20140
    57
   apply (erule coinduct2_lemma, assumption)
wenzelm@20140
    58
  apply blast
wenzelm@20140
    59
  done
wenzelm@20140
    60
wenzelm@20140
    61
(***  Even Stronger version of coinduct  [by Martin Coen]
wenzelm@20140
    62
         - instead of the condition  A <= f(A)
wenzelm@20140
    63
                           consider  A <= (f(A) Un f(f(A)) ...) Un gfp(A) ***)
wenzelm@20140
    64
wenzelm@20140
    65
lemma coinduct3_mono_lemma: "mono(f) ==> mono(%x. f(x) Un A Un B)"
wenzelm@20140
    66
  by (rule monoI) (blast dest: monoD)
wenzelm@20140
    67
wenzelm@20140
    68
lemma coinduct3_lemma:
wenzelm@20140
    69
  assumes prem: "A <= f(lfp(%x. f(x) Un A Un gfp(f)))"
wenzelm@20140
    70
    and mono: "mono(f)"
wenzelm@20140
    71
  shows "lfp(%x. f(x) Un A Un gfp(f)) <= f(lfp(%x. f(x) Un A Un gfp(f)))"
wenzelm@20140
    72
  apply (rule subset_trans)
wenzelm@20140
    73
   apply (rule mono [THEN coinduct3_mono_lemma, THEN lfp_lemma3])
wenzelm@20140
    74
  apply (rule Un_least [THEN Un_least])
wenzelm@20140
    75
    apply (rule subset_refl)
wenzelm@20140
    76
   apply (rule prem)
wenzelm@20140
    77
  apply (rule mono [THEN gfp_Tarski, THEN equalityD1, THEN subset_trans])
wenzelm@20140
    78
  apply (rule mono [THEN monoD])
wenzelm@20140
    79
  apply (subst mono [THEN coinduct3_mono_lemma, THEN lfp_Tarski])
wenzelm@20140
    80
  apply (rule Un_upper2)
wenzelm@20140
    81
  done
wenzelm@20140
    82
wenzelm@20140
    83
lemma coinduct3:
wenzelm@20140
    84
  assumes 1: "a:A"
wenzelm@20140
    85
    and 2: "A <= f(lfp(%x. f(x) Un A Un gfp(f)))"
wenzelm@20140
    86
    and 3: "mono(f)"
wenzelm@20140
    87
  shows "a : gfp(f)"
wenzelm@20140
    88
  apply (rule coinduct)
wenzelm@20140
    89
   prefer 2
wenzelm@20140
    90
   apply (rule coinduct3_lemma [OF 2 3])
wenzelm@20140
    91
  apply (subst lfp_Tarski [OF coinduct3_mono_lemma, OF 3])
wenzelm@20140
    92
  using 1 apply blast
wenzelm@20140
    93
  done
wenzelm@20140
    94
wenzelm@20140
    95
wenzelm@20140
    96
subsection {* Definition forms of @{text "gfp_Tarski"}, to control unfolding *}
wenzelm@20140
    97
wenzelm@20140
    98
lemma def_gfp_Tarski: "[| h==gfp(f);  mono(f) |] ==> h = f(h)"
wenzelm@20140
    99
  apply unfold
wenzelm@20140
   100
  apply (erule gfp_Tarski)
wenzelm@20140
   101
  done
wenzelm@20140
   102
wenzelm@20140
   103
lemma def_coinduct: "[| h==gfp(f);  a:A;  A <= f(A) |] ==> a: h"
wenzelm@20140
   104
  apply unfold
wenzelm@20140
   105
  apply (erule coinduct)
wenzelm@20140
   106
  apply assumption
wenzelm@20140
   107
  done
wenzelm@20140
   108
wenzelm@20140
   109
lemma def_coinduct2: "[| h==gfp(f);  a:A;  A <= f(A) Un h; mono(f) |] ==> a: h"
wenzelm@20140
   110
  apply unfold
wenzelm@20140
   111
  apply (erule coinduct2)
wenzelm@20140
   112
   apply assumption
wenzelm@20140
   113
  apply assumption
wenzelm@20140
   114
  done
wenzelm@20140
   115
wenzelm@20140
   116
lemma def_coinduct3: "[| h==gfp(f);  a:A;  A <= f(lfp(%x. f(x) Un A Un h)); mono(f) |] ==> a: h"
wenzelm@20140
   117
  apply unfold
wenzelm@20140
   118
  apply (erule coinduct3)
wenzelm@20140
   119
   apply assumption
wenzelm@20140
   120
  apply assumption
wenzelm@20140
   121
  done
wenzelm@20140
   122
wenzelm@20140
   123
(*Monotonicity of gfp!*)
wenzelm@20140
   124
lemma gfp_mono: "[| mono(f);  !!Z. f(Z)<=g(Z) |] ==> gfp(f) <= gfp(g)"
wenzelm@20140
   125
  apply (rule gfp_upperbound)
wenzelm@20140
   126
  apply (rule subset_trans)
wenzelm@20140
   127
   apply (rule gfp_lemma2)
wenzelm@20140
   128
   apply assumption
wenzelm@20140
   129
  apply (erule meta_spec)
wenzelm@20140
   130
  done
wenzelm@17456
   131
clasohm@0
   132
end