src/HOL/HOLCF/Fix.thy
author wenzelm
Sat, 05 Jan 2019 17:24:33 +0100
changeset 69597 ff784d5a5bfb
parent 67312 0d25e02759b7
permissions -rw-r--r--
isabelle update -u control_cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41430
diff changeset
     1
(*  Title:      HOL/HOLCF/Fix.thy
1479
21eb5e156d91 expanded tabs
clasohm
parents: 1410
diff changeset
     2
    Author:     Franz Regensburger
35794
8cd7134275cc use headers consistently
huffman
parents: 35055
diff changeset
     3
    Author:     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
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
     6
section \<open>Fixed point operator and admissibility\<close>
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     7
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     8
theory Fix
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
     9
  imports Cfun
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    10
begin
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    11
36452
d37c6eed8117 renamed command 'defaultsort' to 'default_sort';
wenzelm
parents: 36075
diff changeset
    12
default_sort pcpo
16082
ebb53ebfd4e2 added defaultsort declaration
huffman
parents: 16079
diff changeset
    13
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    14
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    15
subsection \<open>Iteration\<close>
16005
42f3f299ee68 cleaned up and shortened some proofs
huffman
parents: 15857
diff changeset
    16
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    17
primrec iterate :: "nat \<Rightarrow> ('a::cpo \<rightarrow> 'a) \<rightarrow> ('a \<rightarrow> 'a)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    18
  where
34941
156925dd67af dropped some old primrecs and some constdefs
haftmann
parents: 33590
diff changeset
    19
    "iterate 0 = (\<Lambda> F x. x)"
156925dd67af dropped some old primrecs and some constdefs
haftmann
parents: 33590
diff changeset
    20
  | "iterate (Suc n) = (\<Lambda> F x. F\<cdot>(iterate n\<cdot>F\<cdot>x))"
5192
704dd3a6d47d Adapted to new datatype package.
berghofe
parents: 4721
diff changeset
    21
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    22
text \<open>Derive inductive properties of iterate from primitive recursion\<close>
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    23
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    24
lemma iterate_0 [simp]: "iterate 0\<cdot>F\<cdot>x = x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    25
  by simp
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    26
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    27
lemma iterate_Suc [simp]: "iterate (Suc n)\<cdot>F\<cdot>x = F\<cdot>(iterate n\<cdot>F\<cdot>x)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    28
  by simp
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    29
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    30
declare iterate.simps [simp del]
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    31
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    32
lemma iterate_Suc2: "iterate (Suc n)\<cdot>F\<cdot>x = iterate n\<cdot>F\<cdot>(F\<cdot>x)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    33
  by (induct n) simp_all
27270
6a353260735e add lemma iterate_iterate
huffman
parents: 27185
diff changeset
    34
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    35
lemma iterate_iterate: "iterate m\<cdot>F\<cdot>(iterate n\<cdot>F\<cdot>x) = iterate (m + n)\<cdot>F\<cdot>x"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    36
  by (induct m) simp_all
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    37
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    38
text \<open>The sequence of function iterations is a chain.\<close>
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    39
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    40
lemma chain_iterate [simp]: "chain (\<lambda>i. iterate i\<cdot>F\<cdot>\<bottom>)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    41
  by (rule chainI, unfold iterate_Suc2, rule monofun_cfun_arg, rule minimal)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    42
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
    43
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    44
subsection \<open>Least fixed point operator\<close>
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
    45
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    46
definition "fix" :: "('a \<rightarrow> 'a) \<rightarrow> 'a"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    47
  where "fix = (\<Lambda> F. \<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>)"
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
    48
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67312
diff changeset
    49
text \<open>Binder syntax for \<^term>\<open>fix\<close>\<close>
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
    50
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    51
abbreviation fix_syn :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a"  (binder "\<mu> " 10)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    52
  where "fix_syn (\<lambda>x. f x) \<equiv> fix\<cdot>(\<Lambda> x. f x)"
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
    53
61998
b66d2ca1f907 clarified print modes;
wenzelm
parents: 61424
diff changeset
    54
notation (ASCII)
b66d2ca1f907 clarified print modes;
wenzelm
parents: 61424
diff changeset
    55
  fix_syn  (binder "FIX " 10)
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
    56
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67312
diff changeset
    57
text \<open>Properties of \<^term>\<open>fix\<close>\<close>
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    58
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67312
diff changeset
    59
text \<open>direct connection between \<^term>\<open>fix\<close> and iteration\<close>
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    60
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    61
lemma fix_def2: "fix\<cdot>F = (\<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    62
  by (simp add: fix_def)
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    63
35055
f0ecf952b864 add lemma iterate_below_fix
huffman
parents: 34941
diff changeset
    64
lemma iterate_below_fix: "iterate n\<cdot>f\<cdot>\<bottom> \<sqsubseteq> fix\<cdot>f"
f0ecf952b864 add lemma iterate_below_fix
huffman
parents: 34941
diff changeset
    65
  unfolding fix_def2
f0ecf952b864 add lemma iterate_below_fix
huffman
parents: 34941
diff changeset
    66
  using chain_iterate by (rule is_ub_thelub)
f0ecf952b864 add lemma iterate_below_fix
huffman
parents: 34941
diff changeset
    67
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    68
text \<open>
15637
d2a06007ebfa changed comments to text blocks, cleaned up a few proofs
huffman
parents: 15577
diff changeset
    69
  Kleene's fixed point theorems for continuous functions in pointed
d2a06007ebfa changed comments to text blocks, cleaned up a few proofs
huffman
parents: 15577
diff changeset
    70
  omega cpo's
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    71
\<close>
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    72
18074
a92b7c5133de reorganized; removed intermediate constant Ifix; changed iterate to a continuous type; added theorem fix_least_less
huffman
parents: 17816
diff changeset
    73
lemma fix_eq: "fix\<cdot>F = F\<cdot>(fix\<cdot>F)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    74
  apply (simp add: fix_def2)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    75
  apply (subst lub_range_shift [of _ 1, symmetric])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    76
   apply (rule chain_iterate)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    77
  apply (subst contlub_cfun_arg)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    78
   apply (rule chain_iterate)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    79
  apply simp
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    80
  done
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    81
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 29138
diff changeset
    82
lemma fix_least_below: "F\<cdot>x \<sqsubseteq> x \<Longrightarrow> fix\<cdot>F \<sqsubseteq> x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    83
  apply (simp add: fix_def2)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    84
  apply (rule lub_below)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    85
   apply (rule chain_iterate)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    86
  apply (induct_tac i)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    87
   apply simp
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    88
  apply simp
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    89
  apply (erule rev_below_trans)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    90
  apply (erule monofun_cfun_arg)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    91
  done
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    92
16214
e3816a7db016 cleaned up proof of cont_Ifix
huffman
parents: 16082
diff changeset
    93
lemma fix_least: "F\<cdot>x = x \<Longrightarrow> fix\<cdot>F \<sqsubseteq> x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    94
  by (rule fix_least_below) simp
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
    95
27185
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
    96
lemma fix_eqI:
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    97
  assumes fixed: "F\<cdot>x = x"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    98
    and least: "\<And>z. F\<cdot>z = z \<Longrightarrow> x \<sqsubseteq> z"
27185
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
    99
  shows "fix\<cdot>F = x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   100
  apply (rule below_antisym)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   101
   apply (rule fix_least [OF fixed])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   102
  apply (rule least [OF fix_eq [symmetric]])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   103
  done
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
   104
16214
e3816a7db016 cleaned up proof of cont_Ifix
huffman
parents: 16082
diff changeset
   105
lemma fix_eq2: "f \<equiv> fix\<cdot>F \<Longrightarrow> f = F\<cdot>f"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   106
  by (simp add: fix_eq [symmetric])
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
   107
16214
e3816a7db016 cleaned up proof of cont_Ifix
huffman
parents: 16082
diff changeset
   108
lemma fix_eq3: "f \<equiv> fix\<cdot>F \<Longrightarrow> f\<cdot>x = F\<cdot>f\<cdot>x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   109
  by (erule fix_eq2 [THEN cfun_fun_cong])
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
   110
16214
e3816a7db016 cleaned up proof of cont_Ifix
huffman
parents: 16082
diff changeset
   111
lemma fix_eq4: "f = fix\<cdot>F \<Longrightarrow> f = F\<cdot>f"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   112
  by (erule ssubst) (rule fix_eq)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
   113
16214
e3816a7db016 cleaned up proof of cont_Ifix
huffman
parents: 16082
diff changeset
   114
lemma fix_eq5: "f = fix\<cdot>F \<Longrightarrow> f\<cdot>x = F\<cdot>f\<cdot>x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   115
  by (erule fix_eq4 [THEN cfun_fun_cong])
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 14981
diff changeset
   116
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67312
diff changeset
   117
text \<open>strictness of \<^term>\<open>fix\<close>\<close>
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   118
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   119
lemma fix_bottom_iff: "fix\<cdot>F = \<bottom> \<longleftrightarrow> F\<cdot>\<bottom> = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   120
  apply (rule iffI)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   121
   apply (erule subst)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   122
   apply (rule fix_eq [symmetric])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   123
  apply (erule fix_least [THEN bottomI])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   124
  done
16917
1fe50b19daba add theorem fix_defined_iff; cleaned up
huffman
parents: 16556
diff changeset
   125
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   126
lemma fix_strict: "F\<cdot>\<bottom> = \<bottom> \<Longrightarrow> fix\<cdot>F = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   127
  by (simp add: fix_bottom_iff)
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   128
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   129
lemma fix_defined: "F\<cdot>\<bottom> \<noteq> \<bottom> \<Longrightarrow> fix\<cdot>F \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   130
  by (simp add: fix_bottom_iff)
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   131
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67312
diff changeset
   132
text \<open>\<^term>\<open>fix\<close> applied to identity and constant functions\<close>
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   133
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   134
lemma fix_id: "(\<mu> x. x) = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   135
  by (simp add: fix_strict)
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   136
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   137
lemma fix_const: "(\<mu> x. c) = c"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   138
  by (subst fix_eq) simp
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   139
16556
a0c8d0499b5f added theorems fix_strict, fix_defined, fix_id, fix_const
huffman
parents: 16388
diff changeset
   140
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   141
subsection \<open>Fixed point induction\<close>
18090
9d5cfd71f510 moved adm_chfindom from Fix.thy to Cfun.thy; moved admw-related stuff to its own section
huffman
parents: 18078
diff changeset
   142
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   143
lemma fix_ind: "adm P \<Longrightarrow> P \<bottom> \<Longrightarrow> (\<And>x. P x \<Longrightarrow> P (F\<cdot>x)) \<Longrightarrow> P (fix\<cdot>F)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   144
  unfolding fix_def2
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   145
  apply (erule admD)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   146
   apply (rule chain_iterate)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   147
  apply (rule nat_induct, simp_all)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   148
  done
18090
9d5cfd71f510 moved adm_chfindom from Fix.thy to Cfun.thy; moved admw-related stuff to its own section
huffman
parents: 18078
diff changeset
   149
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   150
lemma cont_fix_ind: "cont F \<Longrightarrow> adm P \<Longrightarrow> P \<bottom> \<Longrightarrow> (\<And>x. P x \<Longrightarrow> P (F x)) \<Longrightarrow> P (fix\<cdot>(Abs_cfun F))"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   151
  by (simp add: fix_ind)
41324
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   152
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   153
lemma def_fix_ind: "\<lbrakk>f \<equiv> fix\<cdot>F; adm P; P \<bottom>; \<And>x. P x \<Longrightarrow> P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P f"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   154
  by (simp add: fix_ind)
18090
9d5cfd71f510 moved adm_chfindom from Fix.thy to Cfun.thy; moved admw-related stuff to its own section
huffman
parents: 18078
diff changeset
   155
27185
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   156
lemma fix_ind2:
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   157
  assumes adm: "adm P"
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   158
  assumes 0: "P \<bottom>" and 1: "P (F\<cdot>\<bottom>)"
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   159
  assumes step: "\<And>x. \<lbrakk>P x; P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P (F\<cdot>(F\<cdot>x))"
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   160
  shows "P (fix\<cdot>F)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   161
  unfolding fix_def2
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   162
  apply (rule admD [OF adm chain_iterate])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   163
  apply (rule nat_less_induct)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   164
  apply (case_tac n)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   165
   apply (simp add: 0)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   166
  apply (case_tac nat)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   167
   apply (simp add: 1)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   168
  apply (frule_tac x=nat in spec)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   169
  apply (simp add: step)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   170
  done
27185
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   171
33590
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   172
lemma parallel_fix_ind:
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   173
  assumes adm: "adm (\<lambda>x. P (fst x) (snd x))"
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   174
  assumes base: "P \<bottom> \<bottom>"
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   175
  assumes step: "\<And>x y. P x y \<Longrightarrow> P (F\<cdot>x) (G\<cdot>y)"
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   176
  shows "P (fix\<cdot>F) (fix\<cdot>G)"
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   177
proof -
61424
c3658c18b7bc prod_case as canonical name for product type eliminator
haftmann
parents: 58880
diff changeset
   178
  from adm have adm': "adm (case_prod P)"
33590
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   179
    unfolding split_def .
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   180
  have "P (iterate i\<cdot>F\<cdot>\<bottom>) (iterate i\<cdot>G\<cdot>\<bottom>)" for i
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   181
    by (induct i) (simp add: base, simp add: step)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   182
  then have "\<And>i. case_prod P (iterate i\<cdot>F\<cdot>\<bottom>, iterate i\<cdot>G\<cdot>\<bottom>)"
33590
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   183
    by simp
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   184
  then have "case_prod P (\<Squnion>i. (iterate i\<cdot>F\<cdot>\<bottom>, iterate i\<cdot>G\<cdot>\<bottom>))"
33590
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   185
    by - (rule admD [OF adm'], simp, assumption)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   186
  then have "case_prod P (\<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>, \<Squnion>i. iterate i\<cdot>G\<cdot>\<bottom>)"
40771
1c6f7d4b110e renamed several HOLCF theorems (listed in NEWS)
huffman
parents: 40500
diff changeset
   187
    by (simp add: lub_Pair)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   188
  then have "P (\<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>) (\<Squnion>i. iterate i\<cdot>G\<cdot>\<bottom>)"
33590
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   189
    by simp
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   190
  then show "P (fix\<cdot>F) (fix\<cdot>G)"
33590
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   191
    by (simp add: fix_def2)
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   192
qed
1806f58a3651 add lemma parallel_fix_ind
huffman
parents: 31076
diff changeset
   193
41324
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   194
lemma cont_parallel_fix_ind:
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   195
  assumes "cont F" and "cont G"
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   196
  assumes "adm (\<lambda>x. P (fst x) (snd x))"
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   197
  assumes "P \<bottom> \<bottom>"
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   198
  assumes "\<And>x y. P x y \<Longrightarrow> P (F x) (G y)"
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   199
  shows "P (fix\<cdot>(Abs_cfun F)) (fix\<cdot>(Abs_cfun G))"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   200
  by (rule parallel_fix_ind) (simp_all add: assms)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   201
41324
1383653efec3 make internal proofs for deflation and isodefl theorems more robust, by avoiding calls to the simplifier for beta-reduction
huffman
parents: 40774
diff changeset
   202
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   203
subsection \<open>Fixed-points on product types\<close>
18093
587692219f69 put iterate and fix in separate sections; added Letrec
huffman
parents: 18092
diff changeset
   204
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   205
text \<open>
18095
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   206
  Bekic's Theorem: Simultaneous fixed points over pairs
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   207
  can be written in terms of separate fixed points.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   208
\<close>
18095
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   209
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   210
lemma fix_cprod:
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   211
  "fix\<cdot>(F::'a \<times> 'b \<rightarrow> 'a \<times> 'b) =
35921
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   212
   (\<mu> x. fst (F\<cdot>(x, \<mu> y. snd (F\<cdot>(x, y)))),
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   213
    \<mu> y. snd (F\<cdot>(\<mu> x. fst (F\<cdot>(x, \<mu> y. snd (F\<cdot>(x, y)))), y)))"
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   214
  (is "fix\<cdot>F = (?x, ?y)")
27185
0407630909ef change orientation of fix_eqI and convert to rule_format;
huffman
parents: 25927
diff changeset
   215
proof (rule fix_eqI)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   216
  have *: "fst (F\<cdot>(?x, ?y)) = ?x"
18095
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   217
    by (rule trans [symmetric, OF fix_eq], simp)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   218
  have "snd (F\<cdot>(?x, ?y)) = ?y"
18095
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   219
    by (rule trans [symmetric, OF fix_eq], simp)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   220
  with * show "F\<cdot>(?x, ?y) = (?x, ?y)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   221
    by (simp add: prod_eq_iff)
18095
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   222
next
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   223
  fix z
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   224
  assume F_z: "F\<cdot>z = z"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   225
  obtain x y where z: "z = (x, y)" by (rule prod.exhaust)
35921
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   226
  from F_z z have F_x: "fst (F\<cdot>(x, y)) = x" by simp
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   227
  from F_z z have F_y: "snd (F\<cdot>(x, y)) = y" by simp
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   228
  let ?y1 = "\<mu> y. snd (F\<cdot>(x, y))"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   229
  have "?y1 \<sqsubseteq> y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   230
    by (rule fix_least) (simp add: F_y)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   231
  then have "fst (F\<cdot>(x, ?y1)) \<sqsubseteq> fst (F\<cdot>(x, y))"
35921
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   232
    by (simp add: fst_monofun monofun_cfun)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   233
  with F_x have "fst (F\<cdot>(x, ?y1)) \<sqsubseteq> x"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   234
    by simp
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   235
  then have *: "?x \<sqsubseteq> x"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   236
    by (simp add: fix_least_below)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   237
  then have "snd (F\<cdot>(?x, y)) \<sqsubseteq> snd (F\<cdot>(x, y))"
35921
cd1b01664810 convert lemma fix_cprod to use Pair, fst, snd
huffman
parents: 35915
diff changeset
   238
    by (simp add: snd_monofun monofun_cfun)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   239
  with F_y have "snd (F\<cdot>(?x, y)) \<sqsubseteq> y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   240
    by simp
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   241
  then have "?y \<sqsubseteq> y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   242
    by (simp add: fix_least_below)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   243
  with z * show "(?x, ?y) \<sqsubseteq> z"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   244
    by simp
18095
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   245
qed
4328356ab7e6 add proof of Bekic's theorem: fix_cprod
huffman
parents: 18093
diff changeset
   246
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
   247
end