src/HOL/HOLCF/Fixrec.thy
author haftmann
Thu, 19 Jun 2025 17:15:40 +0200
changeset 82734 89347c0cc6a3
parent 81583 b6df83045178
permissions -rw-r--r--
treat map_filter similar to list_all, list_ex, list_ex1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41429
diff changeset
     1
(*  Title:      HOL/HOLCF/Fixrec.thy
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
     2
    Author:     Franz Regensburger
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
     3
    Author:     Amber Telfer and Brian Huffman
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
     4
*)
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
     5
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
     6
theory Fixrec
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
     7
imports Cprod Sprod Ssum Up One Tr Cfun
69913
ca515cf61651 more specific keyword kinds;
wenzelm
parents: 69605
diff changeset
     8
keywords "fixrec" :: thy_defn
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
     9
begin
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
    10
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    11
section \<open>Fixed point operator and admissibility\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    12
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    13
subsection \<open>Iteration\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    14
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
    15
primrec iterate :: "nat \<Rightarrow> ('a \<rightarrow> 'a) \<rightarrow> ('a \<rightarrow> 'a)"
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    16
  where
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    17
    "iterate 0 = (\<Lambda> F x. x)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    18
  | "iterate (Suc n) = (\<Lambda> F x. F\<cdot>(iterate n\<cdot>F\<cdot>x))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    19
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    20
text \<open>Derive inductive properties of iterate from primitive recursion\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    21
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    22
lemma iterate_0 [simp]: "iterate 0\<cdot>F\<cdot>x = x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    23
  by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    24
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    25
lemma iterate_Suc [simp]: "iterate (Suc n)\<cdot>F\<cdot>x = F\<cdot>(iterate n\<cdot>F\<cdot>x)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    26
  by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    27
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    28
declare iterate.simps [simp del]
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    29
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    30
lemma iterate_Suc2: "iterate (Suc n)\<cdot>F\<cdot>x = iterate n\<cdot>F\<cdot>(F\<cdot>x)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    31
  by (induct n) simp_all
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    32
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    33
lemma iterate_iterate: "iterate m\<cdot>F\<cdot>(iterate n\<cdot>F\<cdot>x) = iterate (m + n)\<cdot>F\<cdot>x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    34
  by (induct m) simp_all
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    35
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    36
text \<open>The sequence of function iterations is a chain.\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    37
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    38
lemma chain_iterate [simp]: "chain (\<lambda>i. iterate i\<cdot>F\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    39
  by (rule chainI, unfold iterate_Suc2, rule monofun_cfun_arg, rule minimal)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    40
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    41
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    42
subsection \<open>Least fixed point operator\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    43
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
    44
definition "fix" :: "('a::pcpo \<rightarrow> 'a) \<rightarrow> 'a"
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    45
  where "fix = (\<Lambda> F. \<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    46
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    47
text \<open>Binder syntax for \<^term>\<open>fix\<close>\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    48
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
    49
abbreviation fix_syn :: "('a::pcpo \<Rightarrow> 'a) \<Rightarrow> 'a"  (binder \<open>\<mu> \<close> 10)
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    50
  where "fix_syn (\<lambda>x. f x) \<equiv> fix\<cdot>(\<Lambda> x. f x)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    51
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    52
notation (ASCII)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    53
  fix_syn  (binder \<open>FIX \<close> 10)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    54
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    55
text \<open>Properties of \<^term>\<open>fix\<close>\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    56
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    57
text \<open>direct connection between \<^term>\<open>fix\<close> and iteration\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    58
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    59
lemma fix_def2: "fix\<cdot>F = (\<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    60
  by (simp add: fix_def)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    61
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    62
lemma iterate_below_fix: "iterate n\<cdot>f\<cdot>\<bottom> \<sqsubseteq> fix\<cdot>f"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    63
  unfolding fix_def2
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    64
  using chain_iterate by (rule is_ub_thelub)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    65
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    66
text \<open>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    67
  Kleene's fixed point theorems for continuous functions in pointed
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    68
  omega cpo's
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    69
\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    70
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    71
lemma fix_eq: "fix\<cdot>F = F\<cdot>(fix\<cdot>F)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    72
  apply (simp add: fix_def2)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    73
  apply (subst lub_range_shift [of _ 1, symmetric])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    74
   apply (rule chain_iterate)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    75
  apply (subst contlub_cfun_arg)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    76
   apply (rule chain_iterate)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    77
  apply simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    78
  done
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    79
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    80
lemma fix_least_below: "F\<cdot>x \<sqsubseteq> x \<Longrightarrow> fix\<cdot>F \<sqsubseteq> x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    81
  apply (simp add: fix_def2)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    82
  apply (rule lub_below)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    83
   apply (rule chain_iterate)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    84
  apply (induct_tac i)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    85
   apply simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    86
  apply simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    87
  apply (erule rev_below_trans)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    88
  apply (erule monofun_cfun_arg)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    89
  done
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    90
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    91
lemma fix_least: "F\<cdot>x = x \<Longrightarrow> fix\<cdot>F \<sqsubseteq> x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    92
  by (rule fix_least_below) simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    93
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    94
lemma fix_eqI:
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    95
  assumes fixed: "F\<cdot>x = x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    96
    and least: "\<And>z. F\<cdot>z = z \<Longrightarrow> x \<sqsubseteq> z"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    97
  shows "fix\<cdot>F = x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    98
  apply (rule below_antisym)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
    99
   apply (rule fix_least [OF fixed])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   100
  apply (rule least [OF fix_eq [symmetric]])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   101
  done
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   102
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   103
lemma fix_eq2: "f \<equiv> fix\<cdot>F \<Longrightarrow> f = F\<cdot>f"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   104
  by (simp add: fix_eq [symmetric])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   105
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   106
lemma fix_eq3: "f \<equiv> fix\<cdot>F \<Longrightarrow> f\<cdot>x = F\<cdot>f\<cdot>x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   107
  by (erule fix_eq2 [THEN cfun_fun_cong])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   108
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   109
lemma fix_eq4: "f = fix\<cdot>F \<Longrightarrow> f = F\<cdot>f"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   110
  by (erule ssubst) (rule fix_eq)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   111
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   112
lemma fix_eq5: "f = fix\<cdot>F \<Longrightarrow> f\<cdot>x = F\<cdot>f\<cdot>x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   113
  by (erule fix_eq4 [THEN cfun_fun_cong])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   114
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   115
text \<open>strictness of \<^term>\<open>fix\<close>\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   116
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   117
lemma fix_bottom_iff: "fix\<cdot>F = \<bottom> \<longleftrightarrow> F\<cdot>\<bottom> = \<bottom>"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   118
  apply (rule iffI)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   119
   apply (erule subst)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   120
   apply (rule fix_eq [symmetric])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   121
  apply (erule fix_least [THEN bottomI])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   122
  done
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   123
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   124
lemma fix_strict: "F\<cdot>\<bottom> = \<bottom> \<Longrightarrow> fix\<cdot>F = \<bottom>"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   125
  by (simp add: fix_bottom_iff)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   126
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   127
lemma fix_defined: "F\<cdot>\<bottom> \<noteq> \<bottom> \<Longrightarrow> fix\<cdot>F \<noteq> \<bottom>"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   128
  by (simp add: fix_bottom_iff)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   129
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   130
text \<open>\<^term>\<open>fix\<close> applied to identity and constant functions\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   131
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   132
lemma fix_id: "(\<mu> x. x) = \<bottom>"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   133
  by (simp add: fix_strict)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   134
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   135
lemma fix_const: "(\<mu> x. c) = c"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   136
  by (subst fix_eq) simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   137
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   138
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   139
subsection \<open>Fixed point induction\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   140
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   141
lemma fix_ind: "adm P \<Longrightarrow> P \<bottom> \<Longrightarrow> (\<And>x. P x \<Longrightarrow> P (F\<cdot>x)) \<Longrightarrow> P (fix\<cdot>F)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   142
  unfolding fix_def2
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   143
  apply (erule admD)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   144
   apply (rule chain_iterate)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   145
  apply (rule nat_induct, simp_all)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   146
  done
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   147
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   148
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))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   149
  by (simp add: fix_ind)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   150
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   151
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"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   152
  by (simp add: fix_ind)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   153
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   154
lemma fix_ind2:
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   155
  assumes adm: "adm P"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   156
  assumes 0: "P \<bottom>" and 1: "P (F\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   157
  assumes step: "\<And>x. \<lbrakk>P x; P (F\<cdot>x)\<rbrakk> \<Longrightarrow> P (F\<cdot>(F\<cdot>x))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   158
  shows "P (fix\<cdot>F)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   159
  unfolding fix_def2
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   160
  apply (rule admD [OF adm chain_iterate])
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   161
  apply (rule nat_less_induct)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   162
  apply (case_tac n)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   163
   apply (simp add: 0)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   164
  apply (case_tac nat)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   165
   apply (simp add: 1)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   166
  apply (frule_tac x=nat in spec)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   167
  apply (simp add: step)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   168
  done
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   169
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   170
lemma parallel_fix_ind:
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   171
  assumes adm: "adm (\<lambda>x. P (fst x) (snd x))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   172
  assumes base: "P \<bottom> \<bottom>"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   173
  assumes step: "\<And>x y. P x y \<Longrightarrow> P (F\<cdot>x) (G\<cdot>y)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   174
  shows "P (fix\<cdot>F) (fix\<cdot>G)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   175
proof -
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   176
  from adm have adm': "adm (case_prod P)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   177
    unfolding split_def .
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   178
  have "P (iterate i\<cdot>F\<cdot>\<bottom>) (iterate i\<cdot>G\<cdot>\<bottom>)" for i
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   179
    by (induct i) (simp add: base, simp add: step)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   180
  then have "\<And>i. case_prod P (iterate i\<cdot>F\<cdot>\<bottom>, iterate i\<cdot>G\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   181
    by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   182
  then have "case_prod P (\<Squnion>i. (iterate i\<cdot>F\<cdot>\<bottom>, iterate i\<cdot>G\<cdot>\<bottom>))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   183
    by - (rule admD [OF adm'], simp, assumption)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   184
  then have "case_prod P (\<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>, \<Squnion>i. iterate i\<cdot>G\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   185
    by (simp add: lub_Pair)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   186
  then have "P (\<Squnion>i. iterate i\<cdot>F\<cdot>\<bottom>) (\<Squnion>i. iterate i\<cdot>G\<cdot>\<bottom>)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   187
    by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   188
  then show "P (fix\<cdot>F) (fix\<cdot>G)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   189
    by (simp add: fix_def2)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   190
qed
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   191
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   192
lemma cont_parallel_fix_ind:
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   193
  assumes "cont F" and "cont G"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   194
  assumes "adm (\<lambda>x. P (fst x) (snd x))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   195
  assumes "P \<bottom> \<bottom>"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   196
  assumes "\<And>x y. P x y \<Longrightarrow> P (F x) (G y)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   197
  shows "P (fix\<cdot>(Abs_cfun F)) (fix\<cdot>(Abs_cfun G))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   198
  by (rule parallel_fix_ind) (simp_all add: assms)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   199
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   200
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   201
subsection \<open>Fixed-points on product types\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   202
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   203
text \<open>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   204
  Bekic's Theorem: Simultaneous fixed points over pairs
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   205
  can be written in terms of separate fixed points.
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   206
\<close>
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   207
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   208
lemma fix_cprod:
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   209
  fixes F :: "'a::pcpo \<times> 'b::pcpo \<rightarrow> 'a \<times> 'b"
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   210
  shows
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   211
    "fix\<cdot>F =
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   212
     (\<mu> x. fst (F\<cdot>(x, \<mu> y. snd (F\<cdot>(x, y)))),
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   213
      \<mu> y. snd (F\<cdot>(\<mu> x. fst (F\<cdot>(x, \<mu> y. snd (F\<cdot>(x, y)))), y)))"
81574
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   214
  (is "fix\<cdot>F = (?x, ?y)")
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   215
proof (rule fix_eqI)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   216
  have *: "fst (F\<cdot>(?x, ?y)) = ?x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   217
    by (rule trans [symmetric, OF fix_eq], simp)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   218
  have "snd (F\<cdot>(?x, ?y)) = ?y"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   219
    by (rule trans [symmetric, OF fix_eq], simp)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   220
  with * show "F\<cdot>(?x, ?y) = (?x, ?y)"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   221
    by (simp add: prod_eq_iff)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   222
next
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   223
  fix z
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   224
  assume F_z: "F\<cdot>z = z"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   225
  obtain x y where z: "z = (x, y)" by (rule prod.exhaust)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   226
  from F_z z have F_x: "fst (F\<cdot>(x, y)) = x" by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   227
  from F_z z have F_y: "snd (F\<cdot>(x, y)) = y" by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   228
  let ?y1 = "\<mu> y. snd (F\<cdot>(x, y))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   229
  have "?y1 \<sqsubseteq> y"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   230
    by (rule fix_least) (simp add: F_y)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   231
  then have "fst (F\<cdot>(x, ?y1)) \<sqsubseteq> fst (F\<cdot>(x, y))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   232
    by (simp add: fst_monofun monofun_cfun)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   233
  with F_x have "fst (F\<cdot>(x, ?y1)) \<sqsubseteq> x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   234
    by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   235
  then have *: "?x \<sqsubseteq> x"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   236
    by (simp add: fix_least_below)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   237
  then have "snd (F\<cdot>(?x, y)) \<sqsubseteq> snd (F\<cdot>(x, y))"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   238
    by (simp add: snd_monofun monofun_cfun)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   239
  with F_y have "snd (F\<cdot>(?x, y)) \<sqsubseteq> y"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   240
    by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   241
  then have "?y \<sqsubseteq> y"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   242
    by (simp add: fix_least_below)
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   243
  with z * show "(?x, ?y) \<sqsubseteq> z"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   244
    by simp
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   245
qed
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   246
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   247
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   248
section "Package for defining recursive functions in HOLCF"
c4abe6582ee5 fewer theories;
wenzelm
parents: 80914
diff changeset
   249
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   250
subsection \<open>Pattern-match monad\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   251
49759
ecf1d5d87e5e removed support for set constant definitions in HOLCF {cpo,pcpo,domain}def commands;
huffman
parents: 48891
diff changeset
   252
pcpodef 'a match = "UNIV::(one ++ 'a u) set"
29063
7619f0561cd7 pcpodef package: state two goals, instead of encoded conjunction;
wenzelm
parents: 28891
diff changeset
   253
by simp_all
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   254
29141
d5582ab1311f constdefs -> definition
huffman
parents: 29138
diff changeset
   255
definition
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   256
  fail :: "'a match" where
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   257
  "fail = Abs_match (sinl\<cdot>ONE)"
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   258
29141
d5582ab1311f constdefs -> definition
huffman
parents: 29138
diff changeset
   259
definition
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   260
  succeed :: "'a \<rightarrow> 'a match" where
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   261
  "succeed = (\<Lambda> x. Abs_match (sinr\<cdot>(up\<cdot>x)))"
19092
e32cf29f01fc make maybe into a real type constructor; remove monad syntax
huffman
parents: 18293
diff changeset
   262
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   263
lemma matchE [case_names bottom fail succeed, cases type: match]:
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   264
  "\<lbrakk>p = \<bottom> \<Longrightarrow> Q; p = fail \<Longrightarrow> Q; \<And>x. p = succeed\<cdot>x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   265
unfolding fail_def succeed_def
19092
e32cf29f01fc make maybe into a real type constructor; remove monad syntax
huffman
parents: 18293
diff changeset
   266
apply (cases p, rename_tac r)
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   267
apply (rule_tac p=r in ssumE, simp add: Abs_match_strict)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   268
apply (rule_tac p=x in oneE, simp, simp)
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   269
apply (rule_tac p=y in upE, simp, simp add: cont_Abs_match)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   270
done
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   271
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   272
lemma succeed_defined [simp]: "succeed\<cdot>x \<noteq> \<bottom>"
41029
f7d8cfa6e7fc pcpodef no longer generates _defined lemmas, use _bottom_iff lemmas instead
huffman
parents: 40834
diff changeset
   273
by (simp add: succeed_def cont_Abs_match Abs_match_bottom_iff)
18293
4eaa654c92f2 reimplement Case expression pattern matching to support lazy patterns
huffman
parents: 18112
diff changeset
   274
4eaa654c92f2 reimplement Case expression pattern matching to support lazy patterns
huffman
parents: 18112
diff changeset
   275
lemma fail_defined [simp]: "fail \<noteq> \<bottom>"
41029
f7d8cfa6e7fc pcpodef no longer generates _defined lemmas, use _bottom_iff lemmas instead
huffman
parents: 40834
diff changeset
   276
by (simp add: fail_def Abs_match_bottom_iff)
18293
4eaa654c92f2 reimplement Case expression pattern matching to support lazy patterns
huffman
parents: 18112
diff changeset
   277
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   278
lemma succeed_eq [simp]: "(succeed\<cdot>x = succeed\<cdot>y) = (x = y)"
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   279
by (simp add: succeed_def cont_Abs_match Abs_match_inject)
18293
4eaa654c92f2 reimplement Case expression pattern matching to support lazy patterns
huffman
parents: 18112
diff changeset
   280
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   281
lemma succeed_neq_fail [simp]:
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   282
  "succeed\<cdot>x \<noteq> fail" "fail \<noteq> succeed\<cdot>x"
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   283
by (simp_all add: succeed_def fail_def cont_Abs_match Abs_match_inject)
19092
e32cf29f01fc make maybe into a real type constructor; remove monad syntax
huffman
parents: 18293
diff changeset
   284
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81574
diff changeset
   285
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   286
subsubsection \<open>Run operator\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   287
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   288
definition
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   289
  run :: "'a match \<rightarrow> 'a::pcpo" where
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   290
  "run = (\<Lambda> m. sscase\<cdot>\<bottom>\<cdot>(fup\<cdot>ID)\<cdot>(Rep_match m))"
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   291
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   292
text \<open>rewrite rules for run\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   293
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   294
lemma run_strict [simp]: "run\<cdot>\<bottom> = \<bottom>"
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   295
unfolding run_def
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   296
by (simp add: cont_Rep_match Rep_match_strict)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   297
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   298
lemma run_fail [simp]: "run\<cdot>fail = \<bottom>"
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   299
unfolding run_def fail_def
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   300
by (simp add: cont_Rep_match Abs_match_inverse)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   301
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   302
lemma run_succeed [simp]: "run\<cdot>(succeed\<cdot>x) = x"
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   303
unfolding run_def succeed_def
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   304
by (simp add: cont_Rep_match cont_Abs_match Abs_match_inverse)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   305
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81574
diff changeset
   306
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   307
subsubsection \<open>Monad plus operator\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   308
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   309
definition
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   310
  mplus :: "'a match \<rightarrow> 'a match \<rightarrow> 'a match" where
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   311
  "mplus = (\<Lambda> m1 m2. sscase\<cdot>(\<Lambda> _. m2)\<cdot>(\<Lambda> _. m1)\<cdot>(Rep_match m1))"
18097
d196d84c306f add case syntax stuff
huffman
parents: 18096
diff changeset
   312
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   313
abbreviation
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 69913
diff changeset
   314
  mplus_syn :: "['a match, 'a match] \<Rightarrow> 'a match"  (infixr \<open>+++\<close> 65)  where
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   315
  "m1 +++ m2 == mplus\<cdot>m1\<cdot>m2"
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   316
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   317
text \<open>rewrite rules for mplus\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   318
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   319
lemma mplus_strict [simp]: "\<bottom> +++ m = \<bottom>"
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   320
unfolding mplus_def
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40795
diff changeset
   321
by (simp add: cont_Rep_match Rep_match_strict)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   322
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   323
lemma mplus_fail [simp]: "fail +++ m = m"
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   324
unfolding mplus_def fail_def
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40795
diff changeset
   325
by (simp add: cont_Rep_match Abs_match_inverse)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   326
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   327
lemma mplus_succeed [simp]: "succeed\<cdot>x +++ m = succeed\<cdot>x"
40735
6f65843e78f3 remove case combinator for fixrec match type
huffman
parents: 40502
diff changeset
   328
unfolding mplus_def succeed_def
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40795
diff changeset
   329
by (simp add: cont_Rep_match cont_Abs_match Abs_match_inverse)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   330
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   331
lemma mplus_fail2 [simp]: "m +++ fail = m"
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   332
by (cases m, simp_all)
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   333
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   334
lemma mplus_assoc: "(x +++ y) +++ z = x +++ (y +++ z)"
37108
00f13d3ad474 rename type 'a maybe to 'a match; rename Fixrec.return to Fixrec.succeed
huffman
parents: 37080
diff changeset
   335
by (cases x, simp_all)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   336
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81574
diff changeset
   337
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   338
subsection \<open>Match functions for built-in types\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   339
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   340
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   341
  match_bottom :: "'a::pcpo \<rightarrow> 'c match \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   342
where
40768
50a80cf4b7ef rename function 'match_UU' to 'match_bottom'
huffman
parents: 40767
diff changeset
   343
  "match_bottom = (\<Lambda> x k. seq\<cdot>x\<cdot>fail)"
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   344
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   345
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   346
  match_Pair :: "'a \<times> 'b \<rightarrow> ('a \<rightarrow> 'b \<rightarrow> 'c match) \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   347
where
39807
19ddbededdd3 fixrec: rename match_cpair to match_Pair
huffman
parents: 37109
diff changeset
   348
  "match_Pair = (\<Lambda> x k. csplit\<cdot>k\<cdot>x)"
16776
a3899ac14a1c generalized types of monadic operators to class cpo; added match function for UU
huffman
parents: 16758
diff changeset
   349
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   350
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   351
  match_spair :: "'a::pcpo \<otimes> 'b::pcpo \<rightarrow> ('a \<rightarrow> 'b \<rightarrow> 'c match) \<rightarrow> 'c::pcpo match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   352
where
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   353
  "match_spair = (\<Lambda> x k. ssplit\<cdot>k\<cdot>x)"
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   354
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   355
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   356
  match_sinl :: "'a::pcpo \<oplus> 'b::pcpo \<rightarrow> ('a \<rightarrow> 'c::pcpo match) \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   357
where
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   358
  "match_sinl = (\<Lambda> x k. sscase\<cdot>k\<cdot>(\<Lambda> b. fail)\<cdot>x)"
16551
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   359
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   360
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   361
  match_sinr :: "'a::pcpo \<oplus> 'b::pcpo \<rightarrow> ('b \<rightarrow> 'c::pcpo match) \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   362
where
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   363
  "match_sinr = (\<Lambda> x k. sscase\<cdot>(\<Lambda> a. fail)\<cdot>k\<cdot>x)"
16551
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   364
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   365
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   366
  match_up :: "'a u \<rightarrow> ('a \<rightarrow> 'c::pcpo match) \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   367
where
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   368
  "match_up = (\<Lambda> x k. fup\<cdot>k\<cdot>x)"
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   369
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   370
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   371
  match_ONE :: "one \<rightarrow> 'c::pcpo match \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   372
where
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   373
  "match_ONE = (\<Lambda> ONE k. k)"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   374
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   375
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   376
  match_TT :: "tr \<rightarrow> 'c::pcpo match \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   377
where
40322
707eb30e8a53 make syntax of continuous if-then-else consistent with HOL if-then-else
huffman
parents: 40046
diff changeset
   378
  "match_TT = (\<Lambda> x k. If x then k else fail)"
65380
ae93953746fc eliminated Plain_HOLCF.thy (see also 8e92772bc0e8): it was modeled after HOL/Plain.thy which was discontinued later;
wenzelm
parents: 62175
diff changeset
   379
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 23152
diff changeset
   380
definition
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   381
  match_FF :: "tr \<rightarrow> 'c::pcpo match \<rightarrow> 'c match"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   382
where
40322
707eb30e8a53 make syntax of continuous if-then-else consistent with HOL if-then-else
huffman
parents: 40046
diff changeset
   383
  "match_FF = (\<Lambda> x k. If x then fail else k)"
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   384
40768
50a80cf4b7ef rename function 'match_UU' to 'match_bottom'
huffman
parents: 40767
diff changeset
   385
lemma match_bottom_simps [simp]:
40795
c52cd8bc426d change match_bottom_simps to produce if-then-else, making more uses of bottom-patterns work with fixrec
huffman
parents: 40774
diff changeset
   386
  "match_bottom\<cdot>x\<cdot>k = (if x = \<bottom> then \<bottom> else fail)"
c52cd8bc426d change match_bottom_simps to produce if-then-else, making more uses of bottom-patterns work with fixrec
huffman
parents: 40774
diff changeset
   387
by (simp add: match_bottom_def)
16776
a3899ac14a1c generalized types of monadic operators to class cpo; added match function for UU
huffman
parents: 16758
diff changeset
   388
39807
19ddbededdd3 fixrec: rename match_cpair to match_Pair
huffman
parents: 37109
diff changeset
   389
lemma match_Pair_simps [simp]:
19ddbededdd3 fixrec: rename match_cpair to match_Pair
huffman
parents: 37109
diff changeset
   390
  "match_Pair\<cdot>(x, y)\<cdot>k = k\<cdot>x\<cdot>y"
19ddbededdd3 fixrec: rename match_cpair to match_Pair
huffman
parents: 37109
diff changeset
   391
by (simp_all add: match_Pair_def)
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   392
16551
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   393
lemma match_spair_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   394
  "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> match_spair\<cdot>(:x, y:)\<cdot>k = k\<cdot>x\<cdot>y"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   395
  "match_spair\<cdot>\<bottom>\<cdot>k = \<bottom>"
16551
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   396
by (simp_all add: match_spair_def)
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   397
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   398
lemma match_sinl_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   399
  "x \<noteq> \<bottom> \<Longrightarrow> match_sinl\<cdot>(sinl\<cdot>x)\<cdot>k = k\<cdot>x"
30914
ceeb5f2eac75 fix too-specific types in lemmas match_{sinl,sinr}_simps
huffman
parents: 30912
diff changeset
   400
  "y \<noteq> \<bottom> \<Longrightarrow> match_sinl\<cdot>(sinr\<cdot>y)\<cdot>k = fail"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   401
  "match_sinl\<cdot>\<bottom>\<cdot>k = \<bottom>"
16551
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   402
by (simp_all add: match_sinl_def)
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   403
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   404
lemma match_sinr_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   405
  "x \<noteq> \<bottom> \<Longrightarrow> match_sinr\<cdot>(sinl\<cdot>x)\<cdot>k = fail"
30914
ceeb5f2eac75 fix too-specific types in lemmas match_{sinl,sinr}_simps
huffman
parents: 30912
diff changeset
   406
  "y \<noteq> \<bottom> \<Longrightarrow> match_sinr\<cdot>(sinr\<cdot>y)\<cdot>k = k\<cdot>y"
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   407
  "match_sinr\<cdot>\<bottom>\<cdot>k = \<bottom>"
16551
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   408
by (simp_all add: match_sinr_def)
7abf8a713613 added match functions for spair, sinl, sinr
huffman
parents: 16463
diff changeset
   409
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   410
lemma match_up_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   411
  "match_up\<cdot>(up\<cdot>x)\<cdot>k = k\<cdot>x"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   412
  "match_up\<cdot>\<bottom>\<cdot>k = \<bottom>"
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   413
by (simp_all add: match_up_def)
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   414
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   415
lemma match_ONE_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   416
  "match_ONE\<cdot>ONE\<cdot>k = k"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   417
  "match_ONE\<cdot>\<bottom>\<cdot>k = \<bottom>"
18094
404f298220af simplify definitions
huffman
parents: 16779
diff changeset
   418
by (simp_all add: match_ONE_def)
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   419
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   420
lemma match_TT_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   421
  "match_TT\<cdot>TT\<cdot>k = k"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   422
  "match_TT\<cdot>FF\<cdot>k = fail"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   423
  "match_TT\<cdot>\<bottom>\<cdot>k = \<bottom>"
18094
404f298220af simplify definitions
huffman
parents: 16779
diff changeset
   424
by (simp_all add: match_TT_def)
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   425
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   426
lemma match_FF_simps [simp]:
30912
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   427
  "match_FF\<cdot>FF\<cdot>k = k"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   428
  "match_FF\<cdot>TT\<cdot>k = fail"
4022298c1a86 change definition of match combinators for fixrec package
huffman
parents: 30131
diff changeset
   429
  "match_FF\<cdot>\<bottom>\<cdot>k = \<bottom>"
18094
404f298220af simplify definitions
huffman
parents: 16779
diff changeset
   430
by (simp_all add: match_FF_def)
16460
72a08d509d62 added match functions for ONE, TT, and FF; added theorem mplus_fail2
huffman
parents: 16417
diff changeset
   431
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81574
diff changeset
   432
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   433
subsection \<open>Mutual recursion\<close>
16401
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   434
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   435
text \<open>
16401
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   436
  The following rules are used to prove unfolding theorems from
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   437
  fixed-point definitions of mutually recursive functions.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   438
\<close>
16401
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   439
31095
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   440
lemma Pair_equalI: "\<lbrakk>x \<equiv> fst p; y \<equiv> snd p\<rbrakk> \<Longrightarrow> (x, y) \<equiv> p"
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   441
by simp
16401
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   442
31095
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   443
lemma Pair_eqD1: "(x, y) = (x', y') \<Longrightarrow> x = x'"
16401
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   444
by simp
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   445
31095
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   446
lemma Pair_eqD2: "(x, y) = (x', y') \<Longrightarrow> y = y'"
16401
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   447
by simp
57c35ede00b9 fixrec package now handles mutually-recursive definitions
huffman
parents: 16229
diff changeset
   448
31095
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   449
lemma def_cont_fix_eq:
40327
1dfdbd66093a renamed {Rep,Abs}_CFun to {Rep,Abs}_cfun
huffman
parents: 40322
diff changeset
   450
  "\<lbrakk>f \<equiv> fix\<cdot>(Abs_cfun F); cont F\<rbrakk> \<Longrightarrow> f = F f"
31095
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   451
by (simp, subst fix_eq, simp)
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   452
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   453
lemma def_cont_fix_ind:
40327
1dfdbd66093a renamed {Rep,Abs}_CFun to {Rep,Abs}_cfun
huffman
parents: 40322
diff changeset
   454
  "\<lbrakk>f \<equiv> fix\<cdot>(Abs_cfun F); cont F; adm P; P \<bottom>; \<And>x. P x \<Longrightarrow> P (F x)\<rbrakk> \<Longrightarrow> P f"
31095
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   455
by (simp add: fix_ind)
b79d140f6d0b simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman
parents: 31008
diff changeset
   456
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   457
text \<open>lemma for proving rewrite rules\<close>
16463
342d74ca8815 fixrec shows unsolved subgoals when proofs of rewrites fail
huffman
parents: 16460
diff changeset
   458
342d74ca8815 fixrec shows unsolved subgoals when proofs of rewrites fail
huffman
parents: 16460
diff changeset
   459
lemma ssubst_lhs: "\<lbrakk>t = s; P s = Q\<rbrakk> \<Longrightarrow> P t = Q"
342d74ca8815 fixrec shows unsolved subgoals when proofs of rewrites fail
huffman
parents: 16460
diff changeset
   460
by simp
342d74ca8815 fixrec shows unsolved subgoals when proofs of rewrites fail
huffman
parents: 16460
diff changeset
   461
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   462
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   463
subsection \<open>Initializing the fixrec package\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   464
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   465
ML_file \<open>Tools/holcf_library.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   466
ML_file \<open>Tools/fixrec.ML\<close>
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   467
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   468
method_setup fixrec_simp = \<open>
47432
e1576d13e933 more standard method setup;
wenzelm
parents: 46950
diff changeset
   469
  Scan.succeed (SIMPLE_METHOD' o Fixrec.fixrec_simp_tac)
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   470
\<close> "pattern prover for fixrec constants"
30131
6be1be402ef0 use TheoryData to keep track of pattern match combinators
huffman
parents: 29530
diff changeset
   471
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   472
setup \<open>
31738
7b9b9ba532ca discontinued ancient tradition to suffix certain ML module names with "_package"
haftmann
parents: 31095
diff changeset
   473
  Fixrec.add_matchers
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   474
    [ (\<^const_name>\<open>up\<close>, \<^const_name>\<open>match_up\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   475
      (\<^const_name>\<open>sinl\<close>, \<^const_name>\<open>match_sinl\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   476
      (\<^const_name>\<open>sinr\<close>, \<^const_name>\<open>match_sinr\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   477
      (\<^const_name>\<open>spair\<close>, \<^const_name>\<open>match_spair\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   478
      (\<^const_name>\<open>Pair\<close>, \<^const_name>\<open>match_Pair\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   479
      (\<^const_name>\<open>ONE\<close>, \<^const_name>\<open>match_ONE\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   480
      (\<^const_name>\<open>TT\<close>, \<^const_name>\<open>match_TT\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   481
      (\<^const_name>\<open>FF\<close>, \<^const_name>\<open>match_FF\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 65380
diff changeset
   482
      (\<^const_name>\<open>bottom\<close>, \<^const_name>\<open>match_bottom\<close>) ]
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   483
\<close>
30131
6be1be402ef0 use TheoryData to keep track of pattern match combinators
huffman
parents: 29530
diff changeset
   484
37109
e67760c1b851 move unused pattern match syntax stuff into HOLCF/ex
huffman
parents: 37108
diff changeset
   485
hide_const (open) succeed fail run
19104
7d69b6d7b8f1 use qualified name for return
huffman
parents: 19092
diff changeset
   486
16221
879400e029bf New theory with lemmas for the fixrec package
huffman
parents:
diff changeset
   487
end