src/ZF/ex/TF.ML
author oheimb
Sat, 15 Feb 1997 17:52:31 +0100
changeset 2637 e9b203f854ae
parent 2496 40efb87985b5
child 3840 e0baea4d485a
permissions -rw-r--r--
reflecting my recent changes of the simplifier and classical reasoner
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
     1
(*  Title:      ZF/ex/tf.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Trees & forests, a mutually recursive type definition.
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
     7
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
     8
Still needs
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
     9
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    10
"TF_reflect == (%z. TF_rec(z, %x ts r. Tcons(x,r), 0, 
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    11
               %t ts r1 r2. TF_of_list(list_of_TF(r2) @ <r1,0>)))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    14
open TF;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    16
val [TconsI, FnilI, FconsI] = tree_forest.intrs;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
(** tree_forest(A) as the union of tree(A) and forest(A) **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    20
val [_, tree_def, forest_def] = tree_forest.defs;
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    21
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    22
goalw TF.thy [tree_def] "tree(A) <= tree_forest(A)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
by (rtac Part_subset 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    24
qed "tree_subset_TF";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    26
goalw TF.thy [forest_def] "forest(A) <= tree_forest(A)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
by (rtac Part_subset 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    28
qed "forest_subset_TF";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    30
goal TF.thy "tree(A) Un forest(A) = tree_forest(A)";
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    31
by (safe_tac (subset_cs addSIs [equalityI, tree_subset_TF, forest_subset_TF]));
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    32
by (fast_tac (!claset addSIs tree_forest.intrs addEs [tree_forest.elim]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    33
qed "TF_equals_Un";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
(** NOT useful, but interesting... **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    37
goalw TF.thy [tree_def, forest_def] 
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    38
    "tree_forest(A) = (A*forest(A)) + ({0} + tree(A)*forest(A))";
529
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    39
let open tree_forest;  
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    40
    val rew = rewrite_rule (con_defs @ tl defs) in  
2496
40efb87985b5 Removal of needless "addIs [equality]", etc.
paulson
parents: 2493
diff changeset
    41
by (fast_tac (!claset addSIs (map rew intrs RL [PartD1]) addEs [rew elim]) 1)
529
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    42
end;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 739
diff changeset
    43
qed "tree_forest_unfold";
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    44
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    45
val tree_forest_unfold' = rewrite_rule [tree_def, forest_def] 
529
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    46
                          tree_forest_unfold;
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    47
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    48
goalw TF.thy [tree_def, forest_def]
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    49
    "tree(A) = {Inl(x). x: A*forest(A)}";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 434
diff changeset
    50
by (rtac (Part_Inl RS subst) 1);
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 434
diff changeset
    51
by (rtac (tree_forest_unfold' RS subst_context) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    52
qed "tree_unfold";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
739
786f32e0b64e modified for new treatment of mutual recursion
lcp
parents: 529
diff changeset
    54
goalw TF.thy [tree_def, forest_def]
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    55
    "forest(A) = {Inr(x). x: {0} + tree(A)*forest(A)}";
438
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 434
diff changeset
    56
by (rtac (Part_Inr RS subst) 1);
52e8393ccd77 minor tidying up (ordered rewriting in Integ.ML)
lcp
parents: 434
diff changeset
    57
by (rtac (tree_forest_unfold' RS subst_context) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    58
qed "forest_unfold";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    60
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    61
(*** TF_rec -- by Vset recursion ***)
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    62
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    63
(** conversion rules **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    64
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    65
goal TF.thy "TF_rec(Tcons(a,f), b, c, d) = b(a, f, TF_rec(f,b,c,d))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    66
by (rtac (TF_rec_def RS def_Vrec RS trans) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    67
by (rewrite_goals_tac tree_forest.con_defs);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    68
by (simp_tac rank_ss 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 739
diff changeset
    69
qed "TF_rec_Tcons";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    70
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    71
goal TF.thy "TF_rec(Fnil, b, c, d) = c";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    72
by (rtac (TF_rec_def RS def_Vrec RS trans) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    73
by (rewrite_goals_tac tree_forest.con_defs);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    74
by (Simp_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 739
diff changeset
    75
qed "TF_rec_Fnil";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    76
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    77
goal TF.thy "TF_rec(Fcons(t,f), b, c, d) = \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    78
\      d(t, f, TF_rec(t, b, c, d), TF_rec(f, b, c, d))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    79
by (rtac (TF_rec_def RS def_Vrec RS trans) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    80
by (rewrite_goals_tac tree_forest.con_defs);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    81
by (simp_tac rank_ss 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 739
diff changeset
    82
qed "TF_rec_Fcons";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    83
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    84
Addsimps [TF_rec_Tcons, TF_rec_Fnil, TF_rec_Fcons, TconsI, FnilI, FconsI];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    85
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    86
(** Type checking **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    87
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    88
val major::prems = goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    89
    "[| z: tree_forest(A);  \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
    90
\       !!x f r. [| x: A;  f: forest(A);  r: C(f)               \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
    91
\                 |] ==> b(x,f,r): C(Tcons(x,f));       \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
    92
\       c : C(Fnil);                                            \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    93
\       !!t f r1 r2. [| t: tree(A);  f: forest(A);  r1: C(t); r2: C(f) \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
    94
\                     |] ==> d(t,f,r1,r2): C(Fcons(t,f))        \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    95
\    |] ==> TF_rec(z,b,c,d) : C(z)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    96
by (rtac (major RS tree_forest.induct) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    97
by (ALLGOALS (asm_simp_tac (!simpset addsimps prems)));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 739
diff changeset
    98
qed "TF_rec_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    99
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   100
(*Mutually recursive version*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   101
val prems = goal TF.thy
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   102
    "[| !!x f r. [| x: A;  f: forest(A);  r: D(f)               \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   103
\                 |] ==> b(x,f,r): C(Tcons(x,f));               \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   104
\       c : D(Fnil);                                            \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   105
\       !!t f r1 r2. [| t: tree(A);  f: forest(A);  r1: C(t); r2: D(f) \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   106
\                     |] ==> d(t,f,r1,r2): D(Fcons(t,f))        \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   107
\    |] ==> (ALL t:tree(A).    TF_rec(t,b,c,d)  : C(t)) &       \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   108
\           (ALL f: forest(A). TF_rec(f,b,c,d) : D(f))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   109
by (rewtac Ball_def);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   110
by (rtac tree_forest.mutual_induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   111
by (ALLGOALS (asm_simp_tac (!simpset addsimps prems)));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   112
qed "tree_forest_rec_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   113
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   114
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   115
(** Versions for use with definitions **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   116
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   117
val [rew] = goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   118
    "[| !!z. j(z)==TF_rec(z,b,c,d) |] ==> j(Tcons(a,f)) = b(a,f,j(f))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   119
by (rewtac rew);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   120
by (rtac TF_rec_Tcons 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   121
qed "def_TF_rec_Tcons";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   122
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   123
val [rew] = goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   124
    "[| !!z. j(z)==TF_rec(z,b,c,d) |] ==> j(Fnil) = c";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   125
by (rewtac rew);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   126
by (rtac TF_rec_Fnil 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   127
qed "def_TF_rec_Fnil";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   128
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   129
val [rew] = goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   130
    "[| !!z. j(z)==TF_rec(z,b,c,d) |] ==> j(Fcons(t,f)) = d(t,f,j(t),j(f))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   131
by (rewtac rew);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   132
by (rtac TF_rec_Fcons 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   133
qed "def_TF_rec_Fcons";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   134
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   135
fun TF_recs def = map standard 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   136
        ([def] RL [def_TF_rec_Tcons, def_TF_rec_Fnil, def_TF_rec_Fcons]);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   137
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   138
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   139
(** list_of_TF and TF_of_list **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   140
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   141
val [list_of_TF_Tcons, list_of_TF_Fnil, list_of_TF_Fcons] =
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   142
        TF_recs list_of_TF_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   143
Addsimps [list_of_TF_Tcons, list_of_TF_Fnil, list_of_TF_Fcons];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   144
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   145
goalw TF.thy [list_of_TF_def]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   146
    "!!z A. z: tree_forest(A) ==> list_of_TF(z) : list(tree(A))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   147
by (REPEAT (ares_tac ([TF_rec_type,TconsI] @ list_typechecks) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   148
qed "list_of_TF_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   149
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   150
val [TF_of_list_Nil,TF_of_list_Cons] = list_recs TF_of_list_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   151
Addsimps [TF_of_list_Nil,TF_of_list_Cons];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   152
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   153
goalw TF.thy [TF_of_list_def] 
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   154
    "!!l A. l: list(tree(A)) ==> TF_of_list(l) : forest(A)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   155
by (REPEAT (ares_tac [list_rec_type, FnilI, FconsI] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   156
qed "TF_of_list_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   157
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   158
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   159
(** TF_map **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   160
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   161
val [TF_map_Tcons, TF_map_Fnil, TF_map_Fcons] = TF_recs TF_map_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   162
Addsimps [TF_map_Tcons, TF_map_Fnil, TF_map_Fcons];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   163
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   164
val prems = goalw TF.thy [TF_map_def]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   165
    "[| !!x. x: A ==> h(x): B |] ==> \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   166
\      (ALL t:tree(A). TF_map(h,t) : tree(B)) &  \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   167
\      (ALL f: forest(A). TF_map(h,f) : forest(B))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   168
by (REPEAT
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   169
    (ares_tac ([tree_forest_rec_type, TconsI, FnilI, FconsI] @ prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   170
qed "TF_map_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   171
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   172
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   173
(** TF_size **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   174
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   175
val [TF_size_Tcons, TF_size_Fnil, TF_size_Fcons] = TF_recs TF_size_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   176
Addsimps [TF_size_Tcons, TF_size_Fnil, TF_size_Fcons];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   177
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   178
goalw TF.thy [TF_size_def]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   179
    "!!z A. z: tree_forest(A) ==> TF_size(z) : nat";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   180
by (REPEAT (ares_tac [TF_rec_type, add_type, nat_0I, nat_succI] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   181
qed "TF_size_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   182
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   183
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   184
(** TF_preorder **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   185
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   186
val [TF_preorder_Tcons, TF_preorder_Fnil, TF_preorder_Fcons] =
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   187
        TF_recs TF_preorder_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   188
Addsimps [TF_preorder_Tcons, TF_preorder_Fnil, TF_preorder_Fcons];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   189
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   190
goalw TF.thy [TF_preorder_def]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   191
    "!!z A. z: tree_forest(A) ==> TF_preorder(z) : list(A)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   192
by (REPEAT (ares_tac ([TF_rec_type, app_type] @ list.intrs) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   193
qed "TF_preorder_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   194
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   195
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   196
(** Term simplification **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   197
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   198
val treeI = tree_subset_TF RS subsetD
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   199
and forestI = forest_subset_TF RS subsetD;
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   200
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   201
val TF_typechecks =
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   202
    [TconsI, FnilI, FconsI, treeI, forestI,
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   203
     list_of_TF_type, TF_map_type, TF_size_type, TF_preorder_type];
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   204
2637
e9b203f854ae reflecting my recent changes of the simplifier and classical reasoner
oheimb
parents: 2496
diff changeset
   205
simpset := !simpset setSolver type_auto_tac (list_typechecks@TF_typechecks);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   206
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   207
(** theorems about list_of_TF and TF_of_list **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   208
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   209
(*essentially the same as list induction*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   210
val major::prems = goal TF.thy 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   211
    "[| f: forest(A);   \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   212
\       R(Fnil);        \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   213
\       !!t f. [| t: tree(A);  f: forest(A);  R(f) |] ==> R(Fcons(t,f))  \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   214
\    |] ==> R(f)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   215
by (rtac (major RS (tree_forest.mutual_induct RS conjunct2 RS spec RSN (2,rev_mp))) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   216
by (REPEAT (ares_tac (TrueI::prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   217
qed "forest_induct";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   218
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   219
goal TF.thy "!!f A. f: forest(A) ==> TF_of_list(list_of_TF(f)) = f";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   220
by (etac forest_induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   221
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   222
qed "forest_iso";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   223
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   224
goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   225
    "!!ts. ts: list(tree(A)) ==> list_of_TF(TF_of_list(ts)) = ts";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   226
by (etac list.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   227
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   228
qed "tree_list_iso";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   229
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   230
(** theorems about TF_map **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   231
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   232
goal TF.thy "!!z A. z: tree_forest(A) ==> TF_map(%u.u, z) = z";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   233
by (etac tree_forest.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   234
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   235
qed "TF_map_ident";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   236
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   237
goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   238
 "!!z A. z: tree_forest(A) ==> TF_map(h, TF_map(j,z)) = TF_map(%u.h(j(u)), z)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   239
by (etac tree_forest.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   240
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   241
qed "TF_map_compose";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   242
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   243
(** theorems about TF_size **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   244
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   245
goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   246
    "!!z A. z: tree_forest(A) ==> TF_size(TF_map(h,z)) = TF_size(z)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   247
by (etac tree_forest.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   248
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   249
qed "TF_size_TF_map";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   250
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   251
goal TF.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   252
    "!!z A. z: tree_forest(A) ==> TF_size(z) = length(TF_preorder(z))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   253
by (etac tree_forest.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   254
by (ALLGOALS (asm_simp_tac (!simpset addsimps [length_app])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   255
qed "TF_size_length";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   256
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   257
(** theorems about TF_preorder **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   258
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   259
goal TF.thy "!!z A. z: tree_forest(A) ==> \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   260
\                      TF_preorder(TF_map(h,z)) = map(h, TF_preorder(z))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   261
by (etac tree_forest.induct 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   262
by (ALLGOALS (asm_simp_tac (!simpset addsimps [map_app_distrib])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   263
qed "TF_preorder_TF_map";