src/HOL/FunDef.thy
author krauss
Wed Sep 13 12:05:50 2006 +0200 (2006-09-13)
changeset 20523 36a59e5d0039
parent 20324 71d63a30cc96
child 20536 f088edff8af8
permissions -rw-r--r--
Major update to function package, including new syntax and the (only theoretical)
ability to handle local contexts.
wenzelm@20324
     1
(*  Title:      HOL/FunDef.thy
wenzelm@20324
     2
    ID:         $Id$
wenzelm@20324
     3
    Author:     Alexander Krauss, TU Muenchen
wenzelm@20324
     4
wenzelm@20324
     5
A package for general recursive function definitions. 
wenzelm@20324
     6
*)
wenzelm@20324
     7
krauss@19564
     8
theory FunDef
krauss@19770
     9
imports Accessible_Part Datatype Recdef
krauss@19564
    10
uses 
krauss@19770
    11
("Tools/function_package/sum_tools.ML")
krauss@19564
    12
("Tools/function_package/fundef_common.ML")
krauss@19564
    13
("Tools/function_package/fundef_lib.ML")
krauss@20523
    14
("Tools/function_package/inductive_wrap.ML")
krauss@19564
    15
("Tools/function_package/context_tree.ML")
krauss@19564
    16
("Tools/function_package/fundef_prep.ML")
krauss@19564
    17
("Tools/function_package/fundef_proof.ML")
krauss@19564
    18
("Tools/function_package/termination.ML")
krauss@19770
    19
("Tools/function_package/mutual.ML")
krauss@20270
    20
("Tools/function_package/pattern_split.ML")
krauss@19564
    21
("Tools/function_package/fundef_package.ML")
krauss@19770
    22
("Tools/function_package/fundef_datatype.ML")
krauss@19770
    23
("Tools/function_package/auto_term.ML")
krauss@19564
    24
begin
krauss@19564
    25
krauss@19564
    26
lemma fundef_ex1_existence:
krauss@20523
    27
assumes f_def: "f \<equiv> \<lambda>x. THE y. (x,y)\<in>G"
krauss@19564
    28
assumes ex1: "\<exists>!y. (x,y)\<in>G"
krauss@19564
    29
shows "(x, f x)\<in>G"
krauss@19564
    30
  by (simp only:f_def, rule theI', rule ex1)
krauss@19564
    31
krauss@19564
    32
lemma fundef_ex1_uniqueness:
krauss@20523
    33
assumes f_def: "f \<equiv> \<lambda>x. THE y. (x,y)\<in>G"
krauss@19564
    34
assumes ex1: "\<exists>!y. (x,y)\<in>G"
krauss@19564
    35
assumes elm: "(x, h x)\<in>G"
krauss@19564
    36
shows "h x = f x"
krauss@19564
    37
  by (simp only:f_def, rule the1_equality[symmetric], rule ex1, rule elm)
krauss@19564
    38
krauss@19564
    39
lemma fundef_ex1_iff:
krauss@20523
    40
assumes f_def: "f \<equiv> \<lambda>x. THE y. (x,y)\<in>G"
krauss@19564
    41
assumes ex1: "\<exists>!y. (x,y)\<in>G"
krauss@19564
    42
shows "((x, y)\<in>G) = (f x = y)"
krauss@19564
    43
  apply (auto simp:ex1 f_def the1_equality)
krauss@19564
    44
  by (rule theI', rule ex1)
krauss@19564
    45
krauss@19564
    46
krauss@19770
    47
subsection {* Projections *}
krauss@19770
    48
consts
krauss@19770
    49
  lpg::"(('a + 'b) * 'a) set"
krauss@19770
    50
  rpg::"(('a + 'b) * 'b) set"
krauss@19770
    51
krauss@19770
    52
inductive lpg
krauss@19770
    53
intros
krauss@19770
    54
  "(Inl x, x) : lpg"
krauss@19770
    55
inductive rpg
krauss@19770
    56
intros
krauss@19770
    57
  "(Inr y, y) : rpg"
krauss@19770
    58
definition
krauss@19770
    59
  "lproj x = (THE y. (x,y) : lpg)"
krauss@19770
    60
  "rproj x = (THE y. (x,y) : rpg)"
krauss@19770
    61
krauss@19770
    62
lemma lproj_inl:
krauss@19770
    63
  "lproj (Inl x) = x"
krauss@19770
    64
  by (auto simp:lproj_def intro: the_equality lpg.intros elim: lpg.cases)
krauss@19770
    65
lemma rproj_inr:
krauss@19770
    66
  "rproj (Inr x) = x"
krauss@19770
    67
  by (auto simp:rproj_def intro: the_equality rpg.intros elim: rpg.cases)
krauss@19770
    68
krauss@19770
    69
krauss@19770
    70
krauss@19770
    71
krauss@19770
    72
use "Tools/function_package/sum_tools.ML"
krauss@19564
    73
use "Tools/function_package/fundef_common.ML"
krauss@19564
    74
use "Tools/function_package/fundef_lib.ML"
krauss@20523
    75
use "Tools/function_package/inductive_wrap.ML"
krauss@19564
    76
use "Tools/function_package/context_tree.ML"
krauss@19564
    77
use "Tools/function_package/fundef_prep.ML"
krauss@19564
    78
use "Tools/function_package/fundef_proof.ML"
krauss@19564
    79
use "Tools/function_package/termination.ML"
krauss@19770
    80
use "Tools/function_package/mutual.ML"
krauss@20270
    81
use "Tools/function_package/pattern_split.ML"
krauss@19564
    82
use "Tools/function_package/fundef_package.ML"
krauss@19564
    83
krauss@19564
    84
setup FundefPackage.setup
krauss@19564
    85
krauss@19770
    86
use "Tools/function_package/fundef_datatype.ML"
krauss@19770
    87
setup FundefDatatype.setup
krauss@19770
    88
krauss@19770
    89
use "Tools/function_package/auto_term.ML"
krauss@19770
    90
setup FundefAutoTerm.setup
krauss@19770
    91
krauss@19770
    92
krauss@19770
    93
lemmas [fundef_cong] = 
krauss@19770
    94
  let_cong if_cong image_cong INT_cong UN_cong bex_cong ball_cong imp_cong
krauss@19564
    95
krauss@19564
    96
krauss@19934
    97
lemma split_cong[fundef_cong]:
krauss@19934
    98
  "\<lbrakk> \<And>x y. (x, y) = q \<Longrightarrow> f x y = g x y; p = q \<rbrakk> 
krauss@19934
    99
  \<Longrightarrow> split f p = split g q"
krauss@19934
   100
  by (auto simp:split_def)
krauss@19934
   101
krauss@19934
   102
krauss@19564
   103
end