src/HOLCF/Cont.thy
author wenzelm
Thu, 02 Jul 2009 17:34:14 +0200
changeset 31902 862ae16a799d
parent 31076 99fe356cbbc2
child 35794 8cd7134275cc
permissions -rw-r--r--
renamed NamedThmsFun to Named_Thms; simplified/unified names of instances of Named_Thms;
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
1479
21eb5e156d91 expanded tabs
clasohm
parents: 1274
diff changeset
     2
    Author:     Franz Regensburger
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     3
*)
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     4
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     5
header {* Continuity and monotonicity *}
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     6
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     7
theory Cont
25786
6b3c79acac1f move lemmas from Cont.thy to Ffun.thy;
huffman
parents: 25783
diff changeset
     8
imports Pcpo
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     9
begin
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    10
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    11
text {*
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    12
   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
    13
   of default class po
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    14
*}
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    15
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    16
defaultsort po
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    17
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    18
subsection {* Definitions *}
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    19
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    20
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    21
  monofun :: "('a \<Rightarrow> 'b) \<Rightarrow> bool"  -- "monotonicity"  where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    22
  "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
    23
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    24
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    25
  contlub :: "('a::cpo \<Rightarrow> 'b::cpo) \<Rightarrow> bool"  -- "first cont. def" where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    26
  "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
    27
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    28
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    29
  cont :: "('a::cpo \<Rightarrow> 'b::cpo) \<Rightarrow> bool"  -- "secnd cont. def" where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 18092
diff changeset
    30
  "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
    31
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    32
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
    33
  "\<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
    34
by (simp add: contlub_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    35
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    36
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
    37
  "\<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
    38
by (simp add: contlub_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    39
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
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
    41
  "\<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
    42
by (simp add: cont_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    43
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
    44
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
    45
  "\<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
    46
by (simp add: cont_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    47
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    48
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
    49
  "\<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
    50
by (simp add: monofun_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    51
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    52
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
    53
  "\<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
    54
by (simp add: monofun_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    55
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    56
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    57
subsection {* @{prop "monofun f \<and> contlub f \<equiv> cont f"} *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    58
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    59
text {* monotone functions map chains to chains *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    60
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
    61
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
    62
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
    63
apply (erule monofunE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    64
apply (erule chainE)
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    65
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    66
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    67
text {* monotone functions map upper bound to upper bounds *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    68
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    69
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
    70
  "\<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
    71
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
    72
apply (erule monofunE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    73
apply (erule ub_rangeD)
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    74
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    75
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
    76
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
    77
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
    78
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
    79
apply (rule contI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    80
apply (rule thelubE)
18088
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
    81
apply (erule (1) ch2ch_monofun)
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
    82
apply (erule (1) contlubE [symmetric])
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    83
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    84
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    85
text {* first a lemma about binary chains *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    86
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
    87
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
    88
  "\<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
    89
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
    90
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
    91
apply (erule contE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    92
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
    93
apply (rule_tac f=f in arg_cong)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    94
apply (erule lub_bin_chain [THEN thelubI])
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    95
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    96
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
    97
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
    98
text {* part1: @{prop "cont f \<Longrightarrow> monofun f"} *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
    99
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
   100
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
   101
apply (rule monofunI)
18088
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
   102
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
   103
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
   104
apply simp
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   105
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   106
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   107
lemmas cont2monofunE = cont2mono [THEN monofunE]
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   108
16737
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   109
lemmas ch2ch_cont = cont2mono [THEN ch2ch_monofun]
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
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
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
   112
text {* part2: @{prop "cont f \<Longrightarrow> contlub f"} *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   113
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   114
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
   115
apply (rule contlubI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   116
apply (rule thelubI [symmetric])
18088
e5b23b85e932 cleaned up
huffman
parents: 17831
diff changeset
   117
apply (erule (1) contE)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   118
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   119
16737
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   120
lemmas cont2contlubE = cont2contlub [THEN contlubE]
f0fd06dc93e3 add lemmas ch2ch_cont and cont2contlubE
huffman
parents: 16624
diff changeset
   121
25896
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   122
lemma contI2:
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   123
  assumes mono: "monofun f"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   124
  assumes below: "\<And>Y. \<lbrakk>chain Y; chain (\<lambda>i. f (Y i))\<rbrakk>
27413
3154f3765cc7 replace lub (range Y) with (LUB i. Y i)
huffman
parents: 26452
diff changeset
   125
     \<Longrightarrow> f (\<Squnion>i. Y i) \<sqsubseteq> (\<Squnion>i. f (Y i))"
25896
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   126
  shows "cont f"
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   127
apply (rule monocontlub2cont)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   128
apply (rule mono)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   129
apply (rule contlubI)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   130
apply (rule below_antisym)
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   131
apply (rule below, assumption)
25896
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   132
apply (erule ch2ch_monofun [OF mono])
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   133
apply (rule is_lub_thelub)
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   134
apply (erule ch2ch_monofun [OF mono])
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   135
apply (rule ub2ub_monofun [OF mono])
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   136
apply (rule is_lubD1)
26027
87cb69d27558 add lemma cpo_lubI
huffman
parents: 26024
diff changeset
   137
apply (erule cpo_lubI)
25896
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   138
done
b2d2f1ae5808 add lemma contI2
huffman
parents: 25825
diff changeset
   139
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   140
subsection {* Continuity simproc *}
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   141
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   142
ML {*
31902
862ae16a799d renamed NamedThmsFun to Named_Thms;
wenzelm
parents: 31076
diff changeset
   143
structure Cont2ContData = Named_Thms
862ae16a799d renamed NamedThmsFun to Named_Thms;
wenzelm
parents: 31076
diff changeset
   144
(
862ae16a799d renamed NamedThmsFun to Named_Thms;
wenzelm
parents: 31076
diff changeset
   145
  val name = "cont2cont"
862ae16a799d renamed NamedThmsFun to Named_Thms;
wenzelm
parents: 31076
diff changeset
   146
  val description = "continuity intro rule"
862ae16a799d renamed NamedThmsFun to Named_Thms;
wenzelm
parents: 31076
diff changeset
   147
)
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   148
*}
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   149
31030
5ee6368d622b use simproc_setup command for cont_proc
huffman
parents: 29541
diff changeset
   150
setup Cont2ContData.setup
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   151
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   152
text {*
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   153
  Given the term @{term "cont f"}, the procedure tries to construct the
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   154
  theorem @{term "cont f == True"}. If this theorem cannot be completely
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   155
  solved by the introduction rules, then the procedure returns a
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   156
  conditional rewrite rule with the unsolved subgoals as premises.
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   157
*}
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   158
31030
5ee6368d622b use simproc_setup command for cont_proc
huffman
parents: 29541
diff changeset
   159
simproc_setup cont_proc ("cont f") = {*
5ee6368d622b use simproc_setup command for cont_proc
huffman
parents: 29541
diff changeset
   160
  fn phi => fn ss => fn ct =>
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   161
    let
31030
5ee6368d622b use simproc_setup command for cont_proc
huffman
parents: 29541
diff changeset
   162
      val tr = instantiate' [] [SOME ct] @{thm Eq_TrueI};
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   163
      val rules = Cont2ContData.get (Simplifier.the_context ss);
29541
35c2654a95da use match_tac instead of resolve_tac for continuity simproc
huffman
parents: 29532
diff changeset
   164
      val tac = REPEAT_ALL_NEW (match_tac rules);
31030
5ee6368d622b use simproc_setup command for cont_proc
huffman
parents: 29541
diff changeset
   165
    in SINGLE (tac 1) tr end
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   166
*}
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   167
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   168
subsection {* Continuity of basic functions *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   169
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   170
text {* The identity function is continuous *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   171
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   172
lemma cont_id [cont2cont]: "cont (\<lambda>x. x)"
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   173
apply (rule contI)
26027
87cb69d27558 add lemma cpo_lubI
huffman
parents: 26024
diff changeset
   174
apply (erule cpo_lubI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   175
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   176
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   177
text {* constant functions are continuous *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   178
29530
9905b660612b change to simpler, more extensible continuity simproc
huffman
parents: 29138
diff changeset
   179
lemma cont_const [cont2cont]: "cont (\<lambda>x. c)"
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   180
apply (rule contI)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   181
apply (rule lub_const)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   182
done
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   183
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   184
text {* application of functions is continuous *}
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   185
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   186
lemma cont_apply:
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   187
  fixes f :: "'a::cpo \<Rightarrow> 'b::cpo \<Rightarrow> 'c::cpo" and t :: "'a \<Rightarrow> 'b"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   188
  assumes 1: "cont (\<lambda>x. t x)"
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   189
  assumes 2: "\<And>x. cont (\<lambda>y. f x y)"
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   190
  assumes 3: "\<And>y. cont (\<lambda>x. f x y)"
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   191
  shows "cont (\<lambda>x. (f x) (t x))"
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   192
proof (rule monocontlub2cont [OF monofunI contlubI])
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   193
  fix x y :: "'a" assume "x \<sqsubseteq> y"
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   194
  then show "f x (t x) \<sqsubseteq> f y (t y)"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   195
    by (auto intro: cont2monofunE [OF 1]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   196
                    cont2monofunE [OF 2]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   197
                    cont2monofunE [OF 3]
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   198
                    below_trans)
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   199
next
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   200
  fix Y :: "nat \<Rightarrow> 'a" assume "chain Y"
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   201
  then show "f (\<Squnion>i. Y i) (t (\<Squnion>i. Y i)) = (\<Squnion>i. f (Y i) (t (Y i)))"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   202
    by (simp only: cont2contlubE [OF 1] ch2ch_cont [OF 1]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   203
                   cont2contlubE [OF 2] ch2ch_cont [OF 2]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   204
                   cont2contlubE [OF 3] ch2ch_cont [OF 3]
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   205
                   diag_lub)
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   206
qed
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   207
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   208
lemma cont_compose:
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   209
  "\<lbrakk>cont c; cont (\<lambda>x. f x)\<rbrakk> \<Longrightarrow> cont (\<lambda>x. c (f x))"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 31030
diff changeset
   210
by (rule cont_apply [OF _ _ cont_const])
29532
59bee7985149 add lemmas cont2monofunE, cont2cont_apply
huffman
parents: 29530
diff changeset
   211
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   212
text {* if-then-else is continuous *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   213
26452
ed657432b8b9 declare cont_lemmas_ext as simp rules individually
huffman
parents: 26027
diff changeset
   214
lemma cont_if [simp]:
ed657432b8b9 declare cont_lemmas_ext as simp rules individually
huffman
parents: 26027
diff changeset
   215
  "\<lbrakk>cont f; cont g\<rbrakk> \<Longrightarrow> cont (\<lambda>x. if b then f x else g x)"
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   216
by (induct b) simp_all
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   217
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   218
subsection {* Finite chains and flat pcpos *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   219
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   220
text {* monotone functions map finite chains to finite chains *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   221
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   222
lemma monofun_finch2finch:
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   223
  "\<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
   224
apply (unfold finite_chain_def)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   225
apply (simp add: ch2ch_monofun)
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   226
apply (force simp add: max_in_chain_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   227
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   228
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   229
text {* The same holds for continuous functions *}
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   230
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   231
lemma cont_finch2finch:
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   232
  "\<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
   233
by (rule cont2mono [THEN monofun_finch2finch])
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   234
25825
94c075b912ff generalized chfindom_monofun2cont
huffman
parents: 25786
diff changeset
   235
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
   236
apply (rule monocontlub2cont)
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   237
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
   238
apply (rule contlubI)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   239
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
   240
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
   241
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
   242
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
   243
apply (force simp add: max_in_chain_def)
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   244
done
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   245
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   246
text {* some properties of flat *}
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   247
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   248
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
   249
apply (rule monofunI)
25920
8df5eabda5f6 change class axiom ax_flat to rule_format
huffman
parents: 25896
diff changeset
   250
apply (drule ax_flat)
16624
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   251
apply auto
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   252
done
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   253
645b9560f3fd cleaned up; reorganized and added section headings
huffman
parents: 16564
diff changeset
   254
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
   255
by (rule flatdom_strict2mono [THEN chfindom_monofun2cont])
15565
2454493bd77b converted to new-style theory
huffman
parents: 14981
diff changeset
   256
26024
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   257
text {* functions with discrete domain *}
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   258
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   259
lemma cont_discrete_cpo [simp]: "cont (f::'a::discrete_cpo \<Rightarrow> 'b::cpo)"
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   260
apply (rule contI)
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   261
apply (drule discrete_chain_const, clarify)
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   262
apply (simp add: lub_const)
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   263
done
d5129e687290 new lemma cont_discrete_cpo
huffman
parents: 25920
diff changeset
   264
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   265
end