src/ZF/Inductive.thy
author paulson
Fri, 12 Oct 2007 10:24:49 +0200
changeset 24998 a339b33adfaf
parent 24893 b8ef7afe3a6b
permissions -rw-r--r--
metis calls
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12175
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
     1
(*  Title:      ZF/Inductive.thy
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
     2
    ID:         $Id$
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
     4
    Copyright   1993  University of Cambridge
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
     5
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
     6
Inductive definitions use least fixedpoints with standard products and sums
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
     7
Coinductive definitions use greatest fixedpoints with Quine products and sums
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
     8
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
     9
Sums are used only for mutual recursion;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    10
Products are used only to derive "streamlined" induction rules for relations
12175
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    11
*)
578
efc648d29dd0 ZF/Inductive.thy,.ML: renamed from "inductive" to allow re-building without
lcp
parents:
diff changeset
    12
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13259
diff changeset
    13
header{*Inductive and Coinductive Definitions*}
c9cfe1638bf2 improved presentation markup
paulson
parents: 13259
diff changeset
    14
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13357
diff changeset
    15
theory Inductive imports Fixedpt QPair
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13357
diff changeset
    16
  uses
12183
c10cea75dd56 adapted primrec/datatype to Isar;
wenzelm
parents: 12175
diff changeset
    17
    "ind_syntax.ML"
12175
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    18
    "Tools/cartprod.ML"
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    19
    "Tools/ind_cases.ML"
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    20
    "Tools/inductive_package.ML"
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    21
    "Tools/induct_tacs.ML"
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13357
diff changeset
    22
    "Tools/primrec_package.ML" begin
12175
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    23
5cf58a1799a7 rearranged inductive package for Isar;
wenzelm
parents: 9491
diff changeset
    24
setup IndCases.setup
12208
5efe7b6874fd setup DatatypeTactics.setup;
wenzelm
parents: 12183
diff changeset
    25
setup DatatypeTactics.setup
2870
6d6fd10a9fdc Now a non-trivial theory so that require_thy can find it
paulson
parents: 805
diff changeset
    26
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    27
ML_setup {*
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    28
val iT = Ind_Syntax.iT
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    29
and oT = FOLogic.oT;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    30
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    31
structure Lfp =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    32
  struct
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    33
  val oper      = Const("Fixedpt.lfp", [iT,iT-->iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    34
  val bnd_mono  = Const("Fixedpt.bnd_mono", [iT,iT-->iT]--->oT)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    35
  val bnd_monoI = @{thm bnd_monoI}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    36
  val subs      = @{thm def_lfp_subset}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    37
  val Tarski    = @{thm def_lfp_unfold}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    38
  val induct    = @{thm def_induct}
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    39
  end;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    40
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    41
structure Standard_Prod =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    42
  struct
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    43
  val sigma     = Const("Sigma", [iT, iT-->iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    44
  val pair      = Const("Pair", [iT,iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    45
  val split_name = "split"
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    46
  val pair_iff  = @{thm Pair_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    47
  val split_eq  = @{thm split}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    48
  val fsplitI   = @{thm splitI}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    49
  val fsplitD   = @{thm splitD}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    50
  val fsplitE   = @{thm splitE}
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    51
  end;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    52
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    53
structure Standard_CP = CartProd_Fun (Standard_Prod);
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    54
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    55
structure Standard_Sum =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    56
  struct
24826
78e6a3cea367 avoid unnamed infixes;
wenzelm
parents: 22814
diff changeset
    57
  val sum       = Const(@{const_name sum}, [iT,iT]--->iT)
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    58
  val inl       = Const("Inl", iT-->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    59
  val inr       = Const("Inr", iT-->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    60
  val elim      = Const("case", [iT-->iT, iT-->iT, iT]--->iT)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    61
  val case_inl  = @{thm case_Inl}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    62
  val case_inr  = @{thm case_Inr}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    63
  val inl_iff   = @{thm Inl_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    64
  val inr_iff   = @{thm Inr_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    65
  val distinct  = @{thm Inl_Inr_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    66
  val distinct' = @{thm Inr_Inl_iff}
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    67
  val free_SEs  = Ind_Syntax.mk_free_SEs
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    68
            [distinct, distinct', inl_iff, inr_iff, Standard_Prod.pair_iff]
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    69
  end;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    70
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    71
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    72
structure Ind_Package =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    73
    Add_inductive_def_Fun
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    74
      (structure Fp=Lfp and Pr=Standard_Prod and CP=Standard_CP
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    75
       and Su=Standard_Sum val coind = false);
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    76
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    77
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    78
structure Gfp =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    79
  struct
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    80
  val oper      = Const("Fixedpt.gfp", [iT,iT-->iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    81
  val bnd_mono  = Const("Fixedpt.bnd_mono", [iT,iT-->iT]--->oT)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    82
  val bnd_monoI = @{thm bnd_monoI}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    83
  val subs      = @{thm def_gfp_subset}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    84
  val Tarski    = @{thm def_gfp_unfold}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    85
  val induct    = @{thm def_Collect_coinduct}
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    86
  end;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    87
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    88
structure Quine_Prod =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    89
  struct
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    90
  val sigma     = Const("QPair.QSigma", [iT, iT-->iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    91
  val pair      = Const("QPair.QPair", [iT,iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    92
  val split_name = "QPair.qsplit"
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    93
  val pair_iff  = @{thm QPair_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    94
  val split_eq  = @{thm qsplit}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    95
  val fsplitI   = @{thm qsplitI}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    96
  val fsplitD   = @{thm qsplitD}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
    97
  val fsplitE   = @{thm qsplitE}
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    98
  end;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
    99
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   100
structure Quine_CP = CartProd_Fun (Quine_Prod);
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   101
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   102
structure Quine_Sum =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   103
  struct
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   104
  val sum       = Const("QPair.op <+>", [iT,iT]--->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   105
  val inl       = Const("QPair.QInl", iT-->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   106
  val inr       = Const("QPair.QInr", iT-->iT)
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   107
  val elim      = Const("QPair.qcase", [iT-->iT, iT-->iT, iT]--->iT)
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
   108
  val case_inl  = @{thm qcase_QInl}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
   109
  val case_inr  = @{thm qcase_QInr}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
   110
  val inl_iff   = @{thm QInl_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
   111
  val inr_iff   = @{thm QInr_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
   112
  val distinct  = @{thm QInl_QInr_iff}
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24826
diff changeset
   113
  val distinct' = @{thm QInr_QInl_iff}
22814
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   114
  val free_SEs  = Ind_Syntax.mk_free_SEs
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   115
            [distinct, distinct', inl_iff, inr_iff, Quine_Prod.pair_iff]
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   116
  end;
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   117
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   118
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   119
structure CoInd_Package =
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   120
  Add_inductive_def_Fun(structure Fp=Gfp and Pr=Quine_Prod and CP=Quine_CP
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   121
    and Su=Quine_Sum val coind = true);
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   122
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   123
*}
4cd25f1706bb removed lagacy ML files;
wenzelm
parents: 16417
diff changeset
   124
2870
6d6fd10a9fdc Now a non-trivial theory so that require_thy can find it
paulson
parents: 805
diff changeset
   125
end