src/ZF/Inductive_ZF.thy
author wenzelm
Fri, 17 Aug 2012 11:23:57 +0200
changeset 48835 574042d14fd9
parent 46950 d0181abdbdac
child 48891 c0eafbd55de3
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
     1
(*  Title:      ZF/Inductive_ZF.thy
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     3
    Copyright   1993  University of Cambridge
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     4
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     5
Inductive definitions use least fixedpoints with standard products and sums
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     6
Coinductive definitions use greatest fixedpoints with Quine products and sums
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     7
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     8
Sums are used only for mutual recursion;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
     9
Products are used only to derive "streamlined" induction rules for relations
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    10
*)
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    11
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    12
header{*Inductive and Coinductive Definitions*}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    13
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    14
theory Inductive_ZF
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    15
imports Fixedpt QPair Nat_ZF
46947
b8c7eb0c2f89 declare minor keywords via theory header;
wenzelm
parents: 46821
diff changeset
    16
keywords
46950
d0181abdbdac declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents: 46947
diff changeset
    17
  "inductive" "coinductive" "rep_datatype" "primrec" :: thy_decl and
d0181abdbdac declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents: 46947
diff changeset
    18
  "inductive_cases" :: thy_script and
d0181abdbdac declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents: 46947
diff changeset
    19
  "domains" "intros" "monos" "con_defs" "type_intros" "type_elims"
46947
b8c7eb0c2f89 declare minor keywords via theory header;
wenzelm
parents: 46821
diff changeset
    20
  "elimination" "induction" "case_eqns" "recursor_eqns"
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    21
uses
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    22
  ("ind_syntax.ML")
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    23
  ("Tools/cartprod.ML")
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    24
  ("Tools/ind_cases.ML")
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    25
  ("Tools/inductive_package.ML")
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    26
  ("Tools/induct_tacs.ML")
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    27
  ("Tools/primrec_package.ML")
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    28
begin
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    29
46821
ff6b0c1087f2 Using mathematical notation for <-> and cardinal arithmetic
paulson
parents: 38514
diff changeset
    30
lemma def_swap_iff: "a == b ==> a = c \<longleftrightarrow> c = b"
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    31
  by blast
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    32
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    33
lemma def_trans: "f == g ==> g(a) = b ==> f(a) = b"
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    34
  by simp
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    35
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    36
lemma refl_thin: "!!P. a = a ==> P ==> P" .
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    37
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    38
use "ind_syntax.ML"
38514
bd9c4e8281ec deglobalization
haftmann
parents: 29580
diff changeset
    39
use "Tools/ind_cases.ML"
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    40
use "Tools/cartprod.ML"
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    41
use "Tools/inductive_package.ML"
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    42
use "Tools/induct_tacs.ML"
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    43
use "Tools/primrec_package.ML"
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    44
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    45
setup IndCases.setup
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    46
setup DatatypeTactics.setup
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    47
26480
544cef16045b replaced 'ML_setup' by 'ML';
wenzelm
parents: 26190
diff changeset
    48
ML {*
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    49
structure Lfp =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    50
  struct
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    51
  val oper      = @{const lfp}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    52
  val bnd_mono  = @{const bnd_mono}
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    53
  val bnd_monoI = @{thm bnd_monoI}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    54
  val subs      = @{thm def_lfp_subset}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    55
  val Tarski    = @{thm def_lfp_unfold}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    56
  val induct    = @{thm def_induct}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    57
  end;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    58
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    59
structure Standard_Prod =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    60
  struct
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    61
  val sigma     = @{const Sigma}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    62
  val pair      = @{const Pair}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    63
  val split_name = @{const_name split}
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    64
  val pair_iff  = @{thm Pair_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    65
  val split_eq  = @{thm split}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    66
  val fsplitI   = @{thm splitI}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    67
  val fsplitD   = @{thm splitD}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    68
  val fsplitE   = @{thm splitE}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    69
  end;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    70
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    71
structure Standard_CP = CartProd_Fun (Standard_Prod);
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    72
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    73
structure Standard_Sum =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    74
  struct
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    75
  val sum       = @{const sum}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    76
  val inl       = @{const Inl}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    77
  val inr       = @{const Inr}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    78
  val elim      = @{const case}
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    79
  val case_inl  = @{thm case_Inl}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    80
  val case_inr  = @{thm case_Inr}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    81
  val inl_iff   = @{thm Inl_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    82
  val inr_iff   = @{thm Inr_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    83
  val distinct  = @{thm Inl_Inr_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    84
  val distinct' = @{thm Inr_Inl_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    85
  val free_SEs  = Ind_Syntax.mk_free_SEs
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    86
            [distinct, distinct', inl_iff, inr_iff, Standard_Prod.pair_iff]
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    87
  end;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    88
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    89
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    90
structure Ind_Package =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    91
    Add_inductive_def_Fun
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    92
      (structure Fp=Lfp and Pr=Standard_Prod and CP=Standard_CP
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    93
       and Su=Standard_Sum val coind = false);
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    94
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    95
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    96
structure Gfp =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
    97
  struct
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    98
  val oper      = @{const gfp}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
    99
  val bnd_mono  = @{const bnd_mono}
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   100
  val bnd_monoI = @{thm bnd_monoI}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   101
  val subs      = @{thm def_gfp_subset}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   102
  val Tarski    = @{thm def_gfp_unfold}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   103
  val induct    = @{thm def_Collect_coinduct}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   104
  end;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   105
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   106
structure Quine_Prod =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   107
  struct
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   108
  val sigma     = @{const QSigma}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   109
  val pair      = @{const QPair}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   110
  val split_name = @{const_name qsplit}
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   111
  val pair_iff  = @{thm QPair_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   112
  val split_eq  = @{thm qsplit}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   113
  val fsplitI   = @{thm qsplitI}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   114
  val fsplitD   = @{thm qsplitD}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   115
  val fsplitE   = @{thm qsplitE}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   116
  end;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   117
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   118
structure Quine_CP = CartProd_Fun (Quine_Prod);
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   119
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   120
structure Quine_Sum =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   121
  struct
26189
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   122
  val sum       = @{const qsum}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   123
  val inl       = @{const QInl}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   124
  val inr       = @{const QInr}
9808cca5c54d misc cleanup of embedded ML code;
wenzelm
parents: 26056
diff changeset
   125
  val elim      = @{const qcase}
26056
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   126
  val case_inl  = @{thm qcase_QInl}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   127
  val case_inr  = @{thm qcase_QInr}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   128
  val inl_iff   = @{thm QInl_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   129
  val inr_iff   = @{thm QInr_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   130
  val distinct  = @{thm QInl_QInr_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   131
  val distinct' = @{thm QInr_QInl_iff}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   132
  val free_SEs  = Ind_Syntax.mk_free_SEs
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   133
            [distinct, distinct', inl_iff, inr_iff, Quine_Prod.pair_iff]
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   134
  end;
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   135
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   136
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   137
structure CoInd_Package =
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   138
  Add_inductive_def_Fun(structure Fp=Gfp and Pr=Quine_Prod and CP=Quine_CP
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   139
    and Su=Quine_Sum val coind = true);
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   140
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   141
*}
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   142
6a0801279f4c Made theory names in ZF disjoint from HOL theory names to allow loading both developments
krauss
parents:
diff changeset
   143
end