src/HOL/Recdef.thy
author huffman
Thu, 14 Dec 2006 22:19:39 +0100
changeset 21857 f9d085c2625c
parent 19770 be5c23ebe1eb
child 22264 6a65e9b2ae05
permissions -rw-r--r--
remove Hyperreal/fuf.ML
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7701
2c8c3b7003e5 load / setup recdef package (TFL);
wenzelm
parents: 7357
diff changeset
     1
(*  Title:      HOL/Recdef.thy
2c8c3b7003e5 load / setup recdef package (TFL);
wenzelm
parents: 7357
diff changeset
     2
    ID:         $Id$
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
     3
    Author:     Konrad Slind and Markus Wenzel, TU Muenchen
12023
wenzelm
parents: 11533
diff changeset
     4
*)
5123
97c1d5c7b701 stepping stones;
wenzelm
parents:
diff changeset
     5
12023
wenzelm
parents: 11533
diff changeset
     6
header {* TFL: recursive function definitions *}
7701
2c8c3b7003e5 load / setup recdef package (TFL);
wenzelm
parents: 7357
diff changeset
     7
15131
c69542757a4d New theory header syntax.
nipkow
parents: 12437
diff changeset
     8
theory Recdef
19770
be5c23ebe1eb HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents: 19564
diff changeset
     9
imports Wellfounded_Relations
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15481
diff changeset
    10
uses
15150
c7af682b9ee5 fix to eliminate excessive case-splits in the recursion equations, by Luca Dixon
paulson
parents: 15140
diff changeset
    11
  ("../TFL/casesplit.ML")
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    12
  ("../TFL/utils.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    13
  ("../TFL/usyntax.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    14
  ("../TFL/dcterm.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    15
  ("../TFL/thms.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    16
  ("../TFL/rules.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    17
  ("../TFL/thry.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    18
  ("../TFL/tfl.ML")
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    19
  ("../TFL/post.ML")
15131
c69542757a4d New theory header syntax.
nipkow
parents: 12437
diff changeset
    20
  ("Tools/recdef_package.ML")
c69542757a4d New theory header syntax.
nipkow
parents: 12437
diff changeset
    21
begin
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    22
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    23
lemma tfl_eq_True: "(x = True) --> x"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    24
  by blast
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    25
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    26
lemma tfl_rev_eq_mp: "(x = y) --> y --> x";
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    27
  by blast
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    28
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    29
lemma tfl_simp_thm: "(x --> y) --> (x = x') --> (x' --> y)"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    30
  by blast
6438
e55a1869ed38 'HOL/recdef' theory data;
wenzelm
parents: 5123
diff changeset
    31
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    32
lemma tfl_P_imp_P_iff_True: "P ==> P = True"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    33
  by blast
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    34
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    35
lemma tfl_imp_trans: "(A --> B) ==> (B --> C) ==> (A --> C)"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    36
  by blast
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    37
12023
wenzelm
parents: 11533
diff changeset
    38
lemma tfl_disj_assoc: "(a \<or> b) \<or> c == a \<or> (b \<or> c)"
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    39
  by simp
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    40
12023
wenzelm
parents: 11533
diff changeset
    41
lemma tfl_disjE: "P \<or> Q ==> P --> R ==> Q --> R ==> R"
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    42
  by blast
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    43
12023
wenzelm
parents: 11533
diff changeset
    44
lemma tfl_exE: "\<exists>x. P x ==> \<forall>x. P x --> Q ==> Q"
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    45
  by blast
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    46
15150
c7af682b9ee5 fix to eliminate excessive case-splits in the recursion equations, by Luca Dixon
paulson
parents: 15140
diff changeset
    47
use "../TFL/casesplit.ML"
10773
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    48
use "../TFL/utils.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    49
use "../TFL/usyntax.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    50
use "../TFL/dcterm.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    51
use "../TFL/thms.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    52
use "../TFL/rules.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    53
use "../TFL/thry.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    54
use "../TFL/tfl.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    55
use "../TFL/post.ML"
0deff0197496 renamed .sml files to .ML;
wenzelm
parents: 10653
diff changeset
    56
use "Tools/recdef_package.ML"
6438
e55a1869ed38 'HOL/recdef' theory data;
wenzelm
parents: 5123
diff changeset
    57
setup RecdefPackage.setup
e55a1869ed38 'HOL/recdef' theory data;
wenzelm
parents: 5123
diff changeset
    58
9855
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    59
lemmas [recdef_simp] =
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    60
  inv_image_def
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    61
  measure_def
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    62
  lex_prod_def
11284
981ea92a86dd made same_fst recdef_simp
nipkow
parents: 11165
diff changeset
    63
  same_fst_def
9855
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    64
  less_Suc_eq [THEN iffD2]
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    65
18336
1a2e30b37ed3 Added recdef congruence rules for bounded quantifiers and commonly used
krauss
parents: 17040
diff changeset
    66
lemmas [recdef_cong] = 
1a2e30b37ed3 Added recdef congruence rules for bounded quantifiers and commonly used
krauss
parents: 17040
diff changeset
    67
  if_cong image_cong INT_cong UN_cong bex_cong ball_cong imp_cong
9855
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    68
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    69
lemma let_cong [recdef_cong]:
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    70
    "M = N ==> (!!x. x = N ==> f x = g x) ==> Let M f = Let N g"
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    71
  by (unfold Let_def) blast
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    72
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    73
lemmas [recdef_wf] =
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    74
  wf_trancl
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    75
  wf_less_than
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    76
  wf_lex_prod
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    77
  wf_inv_image
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    78
  wf_measure
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    79
  wf_pred_nat
10653
55f33da63366 small mods.
nipkow
parents: 10212
diff changeset
    80
  wf_same_fst
9855
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    81
  wf_empty
709a295731e2 improved recdef setup;
wenzelm
parents: 8303
diff changeset
    82
17040
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    83
(* The following should really go into Datatype or Finite_Set, but
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    84
each one lacks the other theory as a parent . . . *)
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    85
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    86
lemma insert_None_conv_UNIV: "insert None (range Some) = UNIV"
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    87
by (rule set_ext, case_tac x, auto)
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    88
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    89
instance option :: (finite) finite
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    90
proof
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    91
  have "finite (UNIV :: 'a set)" by (rule finite)
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    92
  hence "finite (insert None (Some ` (UNIV :: 'a set)))" by simp
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    93
  also have "insert None (Some ` (UNIV :: 'a set)) = UNIV"
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    94
    by (rule insert_None_conv_UNIV)
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    95
  finally show "finite (UNIV :: 'a option set)" .
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    96
qed
6682c93b7d9f added finite(option) to Recdef.thy
nipkow
parents: 16417
diff changeset
    97
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents: 18336
diff changeset
    98
6438
e55a1869ed38 'HOL/recdef' theory data;
wenzelm
parents: 5123
diff changeset
    99
end