src/HOLCF/Cont.thy
author huffman
Thu, 31 Jan 2008 21:22:03 +0100
changeset 26024 d5129e687290
parent 25920 8df5eabda5f6
child 26027 87cb69d27558
permissions -rw-r--r--
new lemma cont_discrete_cpo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15600
a59f07556a8d fixed filename in header
huffman
parents: 15588
diff changeset
     1
(*  Title:      HOLCF/Cont.thy
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     2
    ID:         $Id$
1479
21eb5e156d91 expanded tabs
clasohm
parents: 1274
diff changeset
     3
    Author:     Franz Regensburger
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     4
16070
4a83dd540b88 removed LICENCE note -- everything is subject to Isabelle licence as
wenzelm
parents: 16053
diff changeset
     5
Results about continuity and monotonicity.
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     6
*)
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     7
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     8
header {* Continuity and monotonicity *}
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     9
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    10
theory Cont
25786
6b3c79acac1f move lemmas from Cont.thy to Ffun.thy;
huffman
parents: 25783
diff changeset
    11
imports Pcpo
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    12
begin
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    13
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    14
text {*
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    15
   Now we change the default class! Form now on all untyped type variables are
3323
194ae2e0c193 eliminated the constant less by the introduction of the axclass sq_ord
slotosch
parents: 2838
diff changeset
    16
   of default class po
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    17
*}
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    18
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    19
defaultsort po
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    20
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    21
subsection {* Definitions *}
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    22
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    23
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    24
  monofun :: "('a \<Rightarrow> 'b) \<Rightarrow> bool"  -- "monotonicity"  where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    25
  "monofun f = (\<forall>x y. x \<sqsubseteq> y \<longrightarrow> f x \<sqsubseteq> f y)"
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    26
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    27
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    28
  contlub :: "('a::cpo \<Rightarrow> 'b::cpo) \<Rightarrow> bool"  -- "first cont. def" where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    29
  "contlub f = (\<forall>Y. chain Y \<longrightarrow> f (\<Squnion>i. Y i) = (\<Squnion>i. f (Y i)))"
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    30
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    31
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    32
  cont :: "('a::cpo \<Rightarrow> 'b::cpo) \<Rightarrow> bool"  -- "secnd cont. def" where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    33
  "cont f = (\<forall>Y. chain Y \<longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i))"
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    34
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    35
lemma contlubI:
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    36
  "\<lbrakk>\<And>Y. chain Y \<Longrightarrow> f (\<Squnion>i. Y i) = (\<Squnion>i. f (Y i))\<rbrakk> \<Longrightarrow> contlub f"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    37
by (simp add: contlub_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    38
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    39
lemma contlubE: 
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    40
  "\<lbrakk>contlub f; chain Y\<rbrakk> \<Longrightarrow> f (\<Squnion>i. Y i) = (\<Squnion>i. f (Y i))" 
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    41
by (simp add: contlub_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    42
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    43
lemma contI:
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    44
  "\<lbrakk>\<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> cont f"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    45
by (simp add: cont_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    46
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    47
lemma contE:
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    48
  "\<lbrakk>cont f; chain Y\<rbrakk> \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    49
by (simp add: cont_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    50
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    51
lemma monofunI: 
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    52
  "\<lbrakk>\<And>x y. x \<sqsubseteq> y \<Longrightarrow> f x \<sqsubseteq> f y\<rbrakk> \<Longrightarrow> monofun f"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    53
by (simp add: monofun_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    54
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    55
lemma monofunE: 
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    56
  "\<lbrakk>monofun f; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> f x \<sqsubseteq> f y"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    57
by (simp add: monofun_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    58
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    59
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    60
subsection {* @{prop "monofun f \<and> contlub f \<equiv> cont f"} *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    61
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    62
text {* monotone functions map chains to chains *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    63
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    64
lemma ch2ch_monofun: "\<lbrakk>monofun f; chain Y\<rbrakk> \<Longrightarrow> chain (\<lambda>i. f (Y i))"
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    65
apply (rule chainI)
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    66
apply (erule monofunE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    67
apply (erule chainE)
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    68
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    69
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    70
text {* monotone functions map upper bound to upper bounds *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    71
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    72
lemma ub2ub_monofun: 
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    73
  "\<lbrakk>monofun f; range Y <| u\<rbrakk> \<Longrightarrow> range (\<lambda>i. f (Y i)) <| f u"
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    74
apply (rule ub_rangeI)
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
    75
apply (erule monofunE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    76
apply (erule ub_rangeD)
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    77
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    78
25783
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    79
lemma ub2ub_monofun':
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    80
  "\<lbrakk>monofun f; S <| u\<rbrakk> \<Longrightarrow> f ` S <| f u"
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    81
apply (rule ub_imageI)
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    82
apply (erule monofunE)
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    83
apply (erule (1) is_ubD)
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    84
done
b2874ee9081a add lemma ub2ub_monofun'
huffman
parents: 25779
diff changeset
    85
25779
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    86
text {* monotone functions map directed sets to directed sets *}
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    87
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    88
lemma dir2dir_monofun:
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    89
  assumes f: "monofun f"
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    90
  assumes S: "directed S"
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    91
  shows "directed (f ` S)"
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    92
proof (rule directedI)
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    93
  from directedD1 [OF S]
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    94
  obtain x where "x \<in> S" ..
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    95
  hence "f x \<in> f ` S" by simp
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    96
  thus "\<exists>x. x \<in> f ` S" ..
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    97
next
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    98
  fix x assume "x \<in> f ` S"
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
    99
  then obtain a where x: "x = f a" and a: "a \<in> S" ..
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   100
  fix y assume "y \<in> f ` S"
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   101
  then obtain b where y: "y = f b" and b: "b \<in> S" ..
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   102
  from directedD2 [OF S a b]
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   103
  obtain c where "c \<in> S" and "a \<sqsubseteq> c \<and> b \<sqsubseteq> c" ..
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   104
  hence "f c \<in> f ` S" and "x \<sqsubseteq> f c \<and> y \<sqsubseteq> f c"
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   105
    using monofunE [OF f] x y by simp_all
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   106
  thus "\<exists>z\<in>f ` S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" ..
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   107
qed
ae71b21de8fb add lemma dir2dir_monofun
huffman
parents: 25131
diff changeset
   108
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   109
text {* left to right: @{prop "monofun f \<and> contlub f \<Longrightarrow> cont f"} *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   110
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   111
lemma monocontlub2cont: "\<lbrakk>monofun f; contlub f\<rbrakk> \<Longrightarrow> cont f"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   112
apply (rule contI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   113
apply (rule thelubE)
18088
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
   114
apply (erule (1) ch2ch_monofun)
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
   115
apply (erule (1) contlubE [symmetric])
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   116
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   117
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   118
text {* first a lemma about binary chains *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   119
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   120
lemma binchain_cont:
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   121
  "\<lbrakk>cont f; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> range (\<lambda>i::nat. f (if i = 0 then x else y)) <<| f y"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   122
apply (subgoal_tac "f (\<Squnion>i::nat. if i = 0 then x else y) = f y")
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   123
apply (erule subst)
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   124
apply (erule contE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   125
apply (erule bin_chain)
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   126
apply (rule_tac f=f in arg_cong)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   127
apply (erule lub_bin_chain [THEN thelubI])
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   128
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   129
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   130
text {* right to left: @{prop "cont f \<Longrightarrow> monofun f \<and> contlub f"} *}
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   131
text {* part1: @{prop "cont f \<Longrightarrow> monofun f"} *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   132
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   133
lemma cont2mono: "cont f \<Longrightarrow> monofun f"
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   134
apply (rule monofunI)
18088
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
   135
apply (drule (1) binchain_cont)
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   136
apply (drule_tac i=0 in is_ub_lub)
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   137
apply simp
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   138
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   139
16737
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   140
lemmas ch2ch_cont = cont2mono [THEN ch2ch_monofun]
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   141
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   142
text {* right to left: @{prop "cont f \<Longrightarrow> monofun f \<and> contlub f"} *}
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   143
text {* part2: @{prop "cont f \<Longrightarrow> contlub f"} *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   144
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   145
lemma cont2contlub: "cont f \<Longrightarrow> contlub f"
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   146
apply (rule contlubI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   147
apply (rule thelubI [symmetric])
18088
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
   148
apply (erule (1) contE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   149
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   150
16737
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   151
lemmas cont2contlubE = cont2contlub [THEN contlubE]
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   152
25896
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   153
lemma contI2:
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   154
  assumes mono: "monofun f"
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   155
  assumes less: "\<And>Y. \<lbrakk>chain Y; chain (\<lambda>i. f (Y i))\<rbrakk>
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   156
     \<Longrightarrow> f (lub (range Y)) \<sqsubseteq> (\<Squnion>i. f (Y i))"
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   157
  shows "cont f"
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   158
apply (rule monocontlub2cont)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   159
apply (rule mono)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   160
apply (rule contlubI)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   161
apply (rule antisym_less)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   162
apply (rule less, assumption)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   163
apply (erule ch2ch_monofun [OF mono])
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   164
apply (rule is_lub_thelub)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   165
apply (erule ch2ch_monofun [OF mono])
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   166
apply (rule ub2ub_monofun [OF mono])
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   167
apply (rule is_lubD1)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   168
apply (erule thelubE, rule refl)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   169
done
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   170
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   171
subsection {* Continuity of basic functions *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   172
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   173
text {* The identity function is continuous *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   174
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   175
lemma cont_id: "cont (\<lambda>x. x)"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   176
apply (rule contI)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   177
apply (erule thelubE)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   178
apply (rule refl)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   179
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   180
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   181
text {* constant functions are continuous *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   182
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   183
lemma cont_const: "cont (\<lambda>x. c)"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   184
apply (rule contI)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   185
apply (rule lub_const)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   186
done
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   187
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   188
text {* if-then-else is continuous *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   189
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   190
lemma cont_if: "\<lbrakk>cont f; cont g\<rbrakk> \<Longrightarrow> cont (\<lambda>x. if b then f x else g x)"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   191
by (induct b) simp_all
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   192
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   193
subsection {* Finite chains and flat pcpos *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   194
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   195
text {* monotone functions map finite chains to finite chains *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   196
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   197
lemma monofun_finch2finch:
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   198
  "\<lbrakk>monofun f; finite_chain Y\<rbrakk> \<Longrightarrow> finite_chain (\<lambda>n. f (Y n))"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   199
apply (unfold finite_chain_def)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   200
apply (simp add: ch2ch_monofun)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   201
apply (force simp add: max_in_chain_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   202
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   203
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   204
text {* The same holds for continuous functions *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   205
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   206
lemma cont_finch2finch:
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   207
  "\<lbrakk>cont f; finite_chain Y\<rbrakk> \<Longrightarrow> finite_chain (\<lambda>n. f (Y n))"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   208
by (rule cont2mono [THEN monofun_finch2finch])
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   209
25825
94c075b912ff generalized chfindom_monofun2cont
huffman
parents: 25786
diff changeset
   210
lemma chfindom_monofun2cont: "monofun f \<Longrightarrow> cont (f::'a::chfin \<Rightarrow> 'b::cpo)"
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   211
apply (rule monocontlub2cont)
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   212
apply assumption
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   213
apply (rule contlubI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   214
apply (frule chfin2finch)
16204
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   215
apply (clarsimp simp add: finite_chain_def)
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   216
apply (subgoal_tac "max_in_chain i (\<lambda>i. f (Y i))")
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   217
apply (simp add: maxinch_is_thelub ch2ch_monofun)
5dd79d3f0105 renamed theorems monofun, contlub, cont to monofun_def, etc.; changed intro/elim rules for these predicates into more useful rule_format; removed all MF2 lemmas (Pcpo.thy has more general versions now); cleaned up many proofs.
huffman
parents: 16096
diff changeset
   218
apply (force simp add: max_in_chain_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   219
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   220
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   221
text {* some properties of flat *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   222
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   223
lemma flatdom_strict2mono: "f \<bottom> = \<bottom> \<Longrightarrow> monofun (f::'a::flat \<Rightarrow> 'b::pcpo)"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   224
apply (rule monofunI)
25920
8df5eabda5f6 change class axiom ax_flat to rule_format
huffman
parents: 25896
diff changeset
   225
apply (drule ax_flat)
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   226
apply auto
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   227
done
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   228
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   229
lemma flatdom_strict2cont: "f \<bottom> = \<bottom> \<Longrightarrow> cont (f::'a::flat \<Rightarrow> 'b::pcpo)"
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   230
by (rule flatdom_strict2mono [THEN chfindom_monofun2cont])
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   231
26024
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   232
text {* functions with discrete domain *}
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   233
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   234
lemma cont_discrete_cpo [simp]: "cont (f::'a::discrete_cpo \<Rightarrow> 'b::cpo)"
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   235
apply (rule contI)
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   236
apply (drule discrete_chain_const, clarify)
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   237
apply (simp add: lub_const)
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   238
done
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   239
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   240
end