src/HOLCF/Porder.thy
author haftmann
Mon, 10 Nov 2008 09:03:28 +0100
changeset 28727 185110a4b97a
parent 27317 7f4ee574f29c
child 29138 661a8db7e647
permissions -rw-r--r--
clarified verbatim vs. typewriter
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15600
a59f07556a8d fixed filename in header
huffman
parents: 15587
diff changeset
     1
(*  Title:      HOLCF/Porder.thy
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     2
    ID:         $Id$
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
     3
    Author:     Franz Regensburger and Brian Huffman
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     4
*)
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
     5
15587
f363e6e080e7 added subsections and text for document generation
huffman
parents: 15577
diff changeset
     6
header {* Partial orders *}
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
     7
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     8
theory Porder
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
     9
imports Main
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    10
begin
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    11
15587
f363e6e080e7 added subsections and text for document generation
huffman
parents: 15577
diff changeset
    12
subsection {* Type class for partial orders *}
f363e6e080e7 added subsections and text for document generation
huffman
parents: 15577
diff changeset
    13
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    14
class sq_ord = type +
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    15
  fixes sq_le :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    16
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    17
notation
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    18
  sq_le (infixl "<<" 55)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    19
23284
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    20
notation (xsymbols)
07ae93e58fea use new-style class for sq_ord; rename op << to sq_le
huffman
parents: 21524
diff changeset
    21
  sq_le (infixl "\<sqsubseteq>" 55)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    22
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 26420
diff changeset
    23
class po = sq_ord +
25897
e9d45709bece use new-style class for po
huffman
parents: 25878
diff changeset
    24
  assumes refl_less [iff]: "x \<sqsubseteq> x"
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 25922
diff changeset
    25
  assumes trans_less: "\<lbrakk>x \<sqsubseteq> y; y \<sqsubseteq> z\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
25897
e9d45709bece use new-style class for po
huffman
parents: 25878
diff changeset
    26
  assumes antisym_less: "\<lbrakk>x \<sqsubseteq> y; y \<sqsubseteq> x\<rbrakk> \<Longrightarrow> x = y"
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    27
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    28
text {* minimal fixes least element *}
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    29
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    30
lemma minimal2UU[OF allI] : "\<forall>x::'a::po. uu \<sqsubseteq> x \<Longrightarrow> uu = (THE u. \<forall>y. u \<sqsubseteq> y)"
15930
145651bc64a8 Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents: 15600
diff changeset
    31
by (blast intro: theI2 antisym_less)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    32
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    33
text {* the reverse law of anti-symmetry of @{term "op <<"} *}
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    34
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    35
lemma antisym_less_inverse: "(x::'a::po) = y \<Longrightarrow> x \<sqsubseteq> y \<and> y \<sqsubseteq> x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    36
by simp
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    37
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    38
lemma box_less: "\<lbrakk>(a::'a::po) \<sqsubseteq> b; c \<sqsubseteq> a; b \<sqsubseteq> d\<rbrakk> \<Longrightarrow> c \<sqsubseteq> d"
18088
e5b23b85e932 cleaned up
huffman
parents: 18071
diff changeset
    39
by (rule trans_less [OF trans_less])
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    40
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    41
lemma po_eq_conv: "((x::'a::po) = y) = (x \<sqsubseteq> y \<and> y \<sqsubseteq> x)"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    42
by (fast elim!: antisym_less_inverse intro!: antisym_less)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    43
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    44
lemma rev_trans_less: "\<lbrakk>(y::'a::po) \<sqsubseteq> z; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> z"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
    45
by (rule trans_less)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
    46
18647
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    47
lemma sq_ord_less_eq_trans: "\<lbrakk>a \<sqsubseteq> b; b = c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> c"
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    48
by (rule subst)
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    49
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    50
lemma sq_ord_eq_less_trans: "\<lbrakk>a = b; b \<sqsubseteq> c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> c"
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    51
by (rule ssubst)
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    52
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    53
lemmas HOLCF_trans_rules [trans] =
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    54
  trans_less
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    55
  antisym_less
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    56
  sq_ord_less_eq_trans
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    57
  sq_ord_eq_less_trans
5f5d37e763c4 add transitivity rules
huffman
parents: 18088
diff changeset
    58
25777
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    59
subsection {* Upper bounds *}
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
    60
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    61
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    62
  is_ub :: "['a set, 'a::po] \<Rightarrow> bool"  (infixl "<|" 55)  where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    63
  "(S <| x) = (\<forall>y. y \<in> S \<longrightarrow> y \<sqsubseteq> x)"
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
    64
25777
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    65
lemma is_ubI: "(\<And>x. x \<in> S \<Longrightarrow> x \<sqsubseteq> u) \<Longrightarrow> S <| u"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    66
by (simp add: is_ub_def)
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    67
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    68
lemma is_ubD: "\<lbrakk>S <| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    69
by (simp add: is_ub_def)
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    70
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    71
lemma ub_imageI: "(\<And>x. x \<in> S \<Longrightarrow> f x \<sqsubseteq> u) \<Longrightarrow> (\<lambda>x. f x) ` S <| u"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    72
unfolding is_ub_def by fast
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    73
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    74
lemma ub_imageD: "\<lbrakk>f ` S <| u; x \<in> S\<rbrakk> \<Longrightarrow> f x \<sqsubseteq> u"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    75
unfolding is_ub_def by fast
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    76
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    77
lemma ub_rangeI: "(\<And>i. S i \<sqsubseteq> x) \<Longrightarrow> range S <| x"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    78
unfolding is_ub_def by fast
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    79
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    80
lemma ub_rangeD: "range S <| x \<Longrightarrow> S i \<sqsubseteq> x"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    81
unfolding is_ub_def by fast
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    82
25828
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    83
lemma is_ub_empty [simp]: "{} <| u"
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    84
unfolding is_ub_def by fast
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    85
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    86
lemma is_ub_insert [simp]: "(insert x A) <| y = (x \<sqsubseteq> y \<and> A <| y)"
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    87
unfolding is_ub_def by fast
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    88
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    89
lemma is_ub_upward: "\<lbrakk>S <| x; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> S <| y"
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    90
unfolding is_ub_def by (fast intro: trans_less)
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
    91
25777
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    92
subsection {* Least upper bounds *}
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
    93
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    94
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    95
  is_lub :: "['a set, 'a::po] \<Rightarrow> bool"  (infixl "<<|" 55)  where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    96
  "(S <<| x) = (S <| x \<and> (\<forall>u. S <| u \<longrightarrow> x \<sqsubseteq> u))"
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
    97
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    98
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
    99
  lub :: "'a set \<Rightarrow> 'a::po" where
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
   100
  "lub S = (THE x. S <<| x)"
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   101
25777
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   102
syntax
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   103
  "_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" ("(3LUB _:_./ _)" [0,0, 10] 10)
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   104
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   105
syntax (xsymbols)
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   106
  "_BLub" :: "[pttrn, 'a set, 'b] \<Rightarrow> 'b" ("(3\<Squnion>_\<in>_./ _)" [0,0, 10] 10)
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   107
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   108
translations
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   109
  "LUB x:A. t" == "CONST lub ((%x. t) ` A)"
74ee4914bb37 new is_ub lemmas; new lub syntax for set image
huffman
parents: 25773
diff changeset
   110
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
   111
abbreviation
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
   112
  Lub  (binder "LUB " 10) where
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
   113
  "LUB n. t n == lub (range t)"
2394
91d8abf108be adaptions for symbol font
oheimb
parents: 2291
diff changeset
   114
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
   115
notation (xsymbols)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 20770
diff changeset
   116
  Lub  (binder "\<Squnion> " 10)
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   117
25813
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   118
text {* access to some definition as inference rule *}
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   119
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   120
lemma is_lubD1: "S <<| x \<Longrightarrow> S <| x"
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   121
unfolding is_lub_def by fast
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   122
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   123
lemma is_lub_lub: "\<lbrakk>S <<| x; S <| u\<rbrakk> \<Longrightarrow> x \<sqsubseteq> u"
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   124
unfolding is_lub_def by fast
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   125
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   126
lemma is_lubI: "\<lbrakk>S <| x; \<And>u. S <| u \<Longrightarrow> x \<sqsubseteq> u\<rbrakk> \<Longrightarrow> S <<| x"
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   127
unfolding is_lub_def by fast
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   128
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   129
text {* lubs are unique *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   130
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   131
lemma unique_lub: "\<lbrakk>S <<| x; S <<| y\<rbrakk> \<Longrightarrow> x = y"
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   132
apply (unfold is_lub_def is_ub_def)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   133
apply (blast intro: antisym_less)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   134
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   135
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   136
text {* technical lemmas about @{term lub} and @{term is_lub} *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   137
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   138
lemma lubI: "M <<| x \<Longrightarrow> M <<| lub M"
15930
145651bc64a8 Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents: 15600
diff changeset
   139
apply (unfold lub_def)
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   140
apply (rule theI)
15930
145651bc64a8 Replaced all unnecessary uses of SOME with THE or LEAST
huffman
parents: 15600
diff changeset
   141
apply assumption
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   142
apply (erule (1) unique_lub)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   143
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   144
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   145
lemma thelubI: "M <<| l \<Longrightarrow> lub M = l"
18088
e5b23b85e932 cleaned up
huffman
parents: 18071
diff changeset
   146
by (rule unique_lub [OF lubI])
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   147
25780
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   148
lemma is_lub_singleton: "{x} <<| x"
25834
3acdbb5626dc cleaned up some proofs
huffman
parents: 25828
diff changeset
   149
by (simp add: is_lub_def)
25780
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   150
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   151
lemma lub_singleton [simp]: "lub {x} = x"
25780
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   152
by (rule thelubI [OF is_lub_singleton])
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   153
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   154
lemma is_lub_bin: "x \<sqsubseteq> y \<Longrightarrow> {x, y} <<| y"
25834
3acdbb5626dc cleaned up some proofs
huffman
parents: 25828
diff changeset
   155
by (simp add: is_lub_def)
25780
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   156
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   157
lemma lub_bin: "x \<sqsubseteq> y \<Longrightarrow> lub {x, y} = y"
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   158
by (rule is_lub_bin [THEN thelubI])
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   159
25813
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   160
lemma is_lub_maximal: "\<lbrakk>S <| x; x \<in> S\<rbrakk> \<Longrightarrow> S <<| x"
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   161
by (erule is_lubI, erule (1) is_ubD)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   162
25813
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   163
lemma lub_maximal: "\<lbrakk>S <| x; x \<in> S\<rbrakk> \<Longrightarrow> lub S = x"
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   164
by (rule is_lub_maximal [THEN thelubI])
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   165
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   166
subsection {* Countable chains *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   167
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   168
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   169
  -- {* Here we use countable chains and I prefer to code them as functions! *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   170
  chain :: "(nat \<Rightarrow> 'a::po) \<Rightarrow> bool" where
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   171
  "chain Y = (\<forall>i. Y i \<sqsubseteq> Y (Suc i))"
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   172
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   173
lemma chainI: "(\<And>i. Y i \<sqsubseteq> Y (Suc i)) \<Longrightarrow> chain Y"
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   174
unfolding chain_def by fast
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   175
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   176
lemma chainE: "chain Y \<Longrightarrow> Y i \<sqsubseteq> Y (Suc i)"
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   177
unfolding chain_def by fast
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   178
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   179
text {* chains are monotone functions *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   180
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   181
lemma chain_mono_less: "\<lbrakk>chain Y; i < j\<rbrakk> \<Longrightarrow> Y i \<sqsubseteq> Y j"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   182
by (erule less_Suc_induct, erule chainE, erule trans_less)
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   183
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   184
lemma chain_mono: "\<lbrakk>chain Y; i \<le> j\<rbrakk> \<Longrightarrow> Y i \<sqsubseteq> Y j"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   185
by (cases "i = j", simp, simp add: chain_mono_less)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   186
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   187
lemma chain_shift: "chain Y \<Longrightarrow> chain (\<lambda>i. Y (i + j))"
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   188
by (rule chainI, simp, erule chainE)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   189
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   190
text {* technical lemmas about (least) upper bounds of chains *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   191
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   192
lemma is_ub_lub: "range S <<| x \<Longrightarrow> S i \<sqsubseteq> x"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   193
by (rule is_lubD1 [THEN ub_rangeD])
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   194
16318
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   195
lemma is_ub_range_shift:
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   196
  "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <| x = range S <| x"
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   197
apply (rule iffI)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   198
apply (rule ub_rangeI)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   199
apply (rule_tac y="S (i + j)" in trans_less)
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   200
apply (erule chain_mono)
16318
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   201
apply (rule le_add1)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   202
apply (erule ub_rangeD)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   203
apply (rule ub_rangeI)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   204
apply (erule ub_rangeD)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   205
done
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   206
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   207
lemma is_lub_range_shift:
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   208
  "chain S \<Longrightarrow> range (\<lambda>i. S (i + j)) <<| x = range S <<| x"
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   209
by (simp add: is_lub_def is_ub_range_shift)
45b12a01382f added theorems is_ub_range_shift and is_lub_range_shift
huffman
parents: 16092
diff changeset
   210
25695
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   211
text {* the lub of a constant chain is the constant *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   212
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   213
lemma chain_const [simp]: "chain (\<lambda>i. c)"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   214
by (simp add: chainI)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   215
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   216
lemma lub_const: "range (\<lambda>x. c) <<| c"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   217
by (blast dest: ub_rangeD intro: is_lubI ub_rangeI)
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   218
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   219
lemma thelub_const [simp]: "(\<Squnion>i. c) = c"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   220
by (rule lub_const [THEN thelubI])
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   221
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   222
subsection {* Finite chains *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   223
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   224
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   225
  -- {* finite chains, needed for monotony of continuous functions *}
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   226
  max_in_chain :: "[nat, nat \<Rightarrow> 'a::po] \<Rightarrow> bool" where
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   227
  "max_in_chain i C = (\<forall>j. i \<le> j \<longrightarrow> C i = C j)"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   228
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   229
definition
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   230
  finite_chain :: "(nat \<Rightarrow> 'a::po) \<Rightarrow> bool" where
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   231
  "finite_chain C = (chain C \<and> (\<exists>i. max_in_chain i C))"
7025a263aa49 rearrange into subsections
huffman
parents: 25131
diff changeset
   232
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   233
text {* results about finite chains *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   234
25878
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   235
lemma max_in_chainI: "(\<And>j. i \<le> j \<Longrightarrow> Y i = Y j) \<Longrightarrow> max_in_chain i Y"
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   236
unfolding max_in_chain_def by fast
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   237
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   238
lemma max_in_chainD: "\<lbrakk>max_in_chain i Y; i \<le> j\<rbrakk> \<Longrightarrow> Y i = Y j"
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   239
unfolding max_in_chain_def by fast
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   240
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   241
lemma finite_chainI:
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   242
  "\<lbrakk>chain C; max_in_chain i C\<rbrakk> \<Longrightarrow> finite_chain C"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   243
unfolding finite_chain_def by fast
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   244
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   245
lemma finite_chainE:
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   246
  "\<lbrakk>finite_chain C; \<And>i. \<lbrakk>chain C; max_in_chain i C\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   247
unfolding finite_chain_def by fast
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   248
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   249
lemma lub_finch1: "\<lbrakk>chain C; max_in_chain i C\<rbrakk> \<Longrightarrow> range C <<| C i"
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   250
apply (rule is_lubI)
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   251
apply (rule ub_rangeI, rename_tac j)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   252
apply (rule_tac x=i and y=j in linorder_le_cases)
25878
bfd53f791c10 new lemmas max_in_chainI, max_in_chainD
huffman
parents: 25834
diff changeset
   253
apply (drule (1) max_in_chainD, simp)
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   254
apply (erule (1) chain_mono)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   255
apply (erule ub_rangeD)
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   256
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   257
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 24728
diff changeset
   258
lemma lub_finch2:
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   259
  "finite_chain C \<Longrightarrow> range C <<| C (LEAST i. max_in_chain i C)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   260
apply (erule finite_chainE)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   261
apply (erule LeastI2 [where Q="\<lambda>i. range C <<| C i"])
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   262
apply (erule (1) lub_finch1)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   263
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   264
19621
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   265
lemma finch_imp_finite_range: "finite_chain Y \<Longrightarrow> finite (range Y)"
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   266
 apply (erule finite_chainE)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   267
 apply (rule_tac B="Y ` {..i}" in finite_subset)
19621
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   268
  apply (rule subsetI)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   269
  apply (erule rangeE, rename_tac j)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   270
  apply (rule_tac x=i and y=j in linorder_le_cases)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   271
   apply (subgoal_tac "Y j = Y i", simp)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   272
   apply (simp add: max_in_chain_def)
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   273
  apply simp
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   274
 apply simp
19621
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   275
done
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   276
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   277
lemma finite_range_has_max:
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   278
  fixes f :: "nat \<Rightarrow> 'a" and r :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   279
  assumes mono: "\<And>i j. i \<le> j \<Longrightarrow> r (f i) (f j)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   280
  assumes finite_range: "finite (range f)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   281
  shows "\<exists>k. \<forall>i. r (f i) (f k)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   282
proof (intro exI allI)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   283
  fix i :: nat
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   284
  let ?j = "LEAST k. f k = f i"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   285
  let ?k = "Max ((\<lambda>x. LEAST k. f k = x) ` range f)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   286
  have "?j \<le> ?k"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   287
  proof (rule Max_ge)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   288
    show "finite ((\<lambda>x. LEAST k. f k = x) ` range f)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   289
      using finite_range by (rule finite_imageI)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   290
    show "?j \<in> (\<lambda>x. LEAST k. f k = x) ` range f"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   291
      by (intro imageI rangeI)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   292
  qed
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   293
  hence "r (f ?j) (f ?k)"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   294
    by (rule mono)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   295
  also have "f ?j = f i"
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   296
    by (rule LeastI, rule refl)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   297
  finally show "r (f i) (f ?k)" .
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   298
qed
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   299
19621
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   300
lemma finite_range_imp_finch:
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   301
  "\<lbrakk>chain Y; finite (range Y)\<rbrakk> \<Longrightarrow> finite_chain Y"
27317
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   302
 apply (subgoal_tac "\<exists>k. \<forall>i. Y i \<sqsubseteq> Y k")
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   303
  apply (erule exE)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   304
  apply (rule finite_chainI, assumption)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   305
  apply (rule max_in_chainI)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   306
  apply (rule antisym_less)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   307
   apply (erule (1) chain_mono)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   308
  apply (erule spec)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   309
 apply (rule finite_range_has_max)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   310
  apply (erule (1) chain_mono)
7f4ee574f29c cleaned up some proofs;
huffman
parents: 27292
diff changeset
   311
 apply assumption
19621
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   312
done
475140eb82f2 add new finite chain theorems
huffman
parents: 19105
diff changeset
   313
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   314
lemma bin_chain: "x \<sqsubseteq> y \<Longrightarrow> chain (\<lambda>i. if i=0 then x else y)"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   315
by (rule chainI, simp)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   316
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   317
lemma bin_chainmax:
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   318
  "x \<sqsubseteq> y \<Longrightarrow> max_in_chain (Suc 0) (\<lambda>i. if i=0 then x else y)"
27292
huffman
parents: 27268
diff changeset
   319
unfolding max_in_chain_def by simp
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   320
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   321
lemma lub_bin_chain:
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   322
  "x \<sqsubseteq> y \<Longrightarrow> range (\<lambda>i::nat. if i=0 then x else y) <<| y"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   323
apply (frule bin_chain)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   324
apply (drule bin_chainmax)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   325
apply (drule (1) lub_finch1)
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   326
apply simp
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   327
done
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   328
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15562
diff changeset
   329
text {* the maximal element in a chain is its lub *}
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   330
17810
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   331
lemma lub_chain_maxelem: "\<lbrakk>Y i = c; \<forall>i. Y i \<sqsubseteq> c\<rbrakk> \<Longrightarrow> lub (range Y) = c"
3bdf516d93d8 cleaned up; renamed "Porder.op <<" to "Porder.<<"
huffman
parents: 17372
diff changeset
   332
by (blast dest: ub_rangeD intro: thelubI is_lubI ub_rangeI)
15562
8455c9671494 converted to new-style theory
huffman
parents: 14981
diff changeset
   333
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   334
subsection {* Directed sets *}
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   335
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   336
definition
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   337
  directed :: "'a::po set \<Rightarrow> bool" where
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   338
  "directed S = ((\<exists>x. x \<in> S) \<and> (\<forall>x\<in>S. \<forall>y\<in>S. \<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z))"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   339
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   340
lemma directedI:
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   341
  assumes 1: "\<exists>z. z \<in> S"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   342
  assumes 2: "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   343
  shows "directed S"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   344
unfolding directed_def using prems by fast
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   345
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   346
lemma directedD1: "directed S \<Longrightarrow> \<exists>z. z \<in> S"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   347
unfolding directed_def by fast
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   348
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   349
lemma directedD2: "\<lbrakk>directed S; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   350
unfolding directed_def by fast
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   351
25780
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   352
lemma directedE1:
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   353
  assumes S: "directed S"
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   354
  obtains z where "z \<in> S"
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   355
by (insert directedD1 [OF S], fast)
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   356
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   357
lemma directedE2:
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   358
  assumes S: "directed S"
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   359
  assumes x: "x \<in> S" and y: "y \<in> S"
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   360
  obtains z where "z \<in> S" "x \<sqsubseteq> z" "y \<sqsubseteq> z"
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   361
by (insert directedD2 [OF S x y], fast)
0fd4c238273b added new lemmas
huffman
parents: 25777
diff changeset
   362
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   363
lemma directed_finiteI:
25828
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   364
  assumes U: "\<And>U. \<lbrakk>finite U; U \<subseteq> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. U <| z"
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   365
  shows "directed S"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   366
proof (rule directedI)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   367
  have "finite {}" and "{} \<subseteq> S" by simp_all
25828
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   368
  hence "\<exists>z\<in>S. {} <| z" by (rule U)
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   369
  thus "\<exists>z. z \<in> S" by simp
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   370
next
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   371
  fix x y
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   372
  assume "x \<in> S" and "y \<in> S"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   373
  hence "finite {x, y}" and "{x, y} \<subseteq> S" by simp_all
25828
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   374
  hence "\<exists>z\<in>S. {x, y} <| z" by (rule U)
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   375
  thus "\<exists>z\<in>S. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" by simp
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   376
qed
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   377
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   378
lemma directed_finiteD:
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   379
  assumes S: "directed S"
25828
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   380
  shows "\<lbrakk>finite U; U \<subseteq> S\<rbrakk> \<Longrightarrow> \<exists>z\<in>S. U <| z"
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   381
proof (induct U set: finite)
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   382
  case empty
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   383
  from S have "\<exists>z. z \<in> S" by (rule directedD1)
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   384
  thus "\<exists>z\<in>S. {} <| z" by simp
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   385
next
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   386
  case (insert x F)
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   387
  from `insert x F \<subseteq> S`
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   388
  have xS: "x \<in> S" and FS: "F \<subseteq> S" by simp_all
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   389
  from FS have "\<exists>y\<in>S. F <| y" by fact
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   390
  then obtain y where yS: "y \<in> S" and Fy: "F <| y" ..
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   391
  obtain z where zS: "z \<in> S" and xz: "x \<sqsubseteq> z" and yz: "y \<sqsubseteq> z"
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   392
    using S xS yS by (rule directedE2)
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   393
  from Fy yz have "F <| z" by (rule is_ub_upward)
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   394
  with xz have "insert x F <| z" by simp
228c53fdb3b4 add new is_ub lemmas; clean up directed_finite proofs
huffman
parents: 25813
diff changeset
   395
  with zS show "\<exists>z\<in>S. insert x F <| z" ..
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   396
qed
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   397
25813
641b4da8eb9d add lub_maximal lemmas;
huffman
parents: 25780
diff changeset
   398
lemma not_directed_empty [simp]: "\<not> directed {}"
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   399
by (rule notI, drule directedD1, simp)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   400
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   401
lemma directed_singleton: "directed {x}"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   402
by (rule directedI, auto)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   403
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   404
lemma directed_bin: "x \<sqsubseteq> y \<Longrightarrow> directed {x, y}"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   405
by (rule directedI, auto)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   406
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   407
lemma directed_chain: "chain S \<Longrightarrow> directed (range S)"
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   408
apply (rule directedI)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   409
apply (rule_tac x="S 0" in exI, simp)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   410
apply (clarify, rename_tac m n)
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   411
apply (rule_tac x="S (max m n)" in bexI)
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25897
diff changeset
   412
apply (simp add: chain_mono)
25773
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   413
apply simp
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   414
done
0d585d756745 new section for directed sets
huffman
parents: 25695
diff changeset
   415
18071
940c2c0ff33a cleaned up; chain_const and thelub_const are simp rules
huffman
parents: 17810
diff changeset
   416
end