src/ZF/ex/BT.ML
author paulson
Wed, 06 Jan 1999 13:24:33 +0100
changeset 6065 3b4a29166f26
parent 6046 2c8a8be36c94
child 6112 5e4871c5136b
permissions -rw-r--r--
induct_tac and exhaust_tac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1170
diff changeset
     1
(*  Title:      ZF/ex/BT.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1170
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
     4
    Copyright   1994  University of Cambridge
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Datatype definition of binary trees
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
     9
Addsimps bt.intrs;
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    10
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
(**  Lemmas to justify using "bt" in other recursive type definitions **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    13
Goalw bt.defs "A<=B ==> bt(A) <= bt(B)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
by (rtac lfp_mono 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    15
by (REPEAT (rtac bt.bnd_mono 1));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
by (REPEAT (ares_tac (univ_mono::basic_monos) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    17
qed "bt_mono";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    19
Goalw (bt.defs@bt.con_defs) "bt(univ(A)) <= univ(A)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
by (rtac lfp_lowerbound 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
by (rtac (A_subset_univ RS univ_mono) 2);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    22
by (fast_tac (claset() addSIs [zero_in_univ, Inl_in_univ, Inr_in_univ,
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1170
diff changeset
    23
                            Pair_in_univ]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    24
qed "bt_univ";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    26
bind_thm ("bt_subset_univ", [bt_mono, bt_univ] MRS subset_trans);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    27
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    28
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    29
(*Type checking -- proved by induction, as usual*)
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    30
val major::prems = goal BT.thy
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    31
    "[| t: bt(A);    \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    32
\       c: C(Lf);       \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    33
\       !!x y z r s. [| x:A;  y:bt(A);  z:bt(A);  r:C(y);  s:C(z) |] ==> \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1170
diff changeset
    34
\                    h(x,y,z,r,s): C(Br(x,y,z))  \
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    35
\    |] ==> bt_rec(c,h,t) : C(t)";
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    36
    (*instead of induct_tac "t", since t: bt(A) isn't an assumption*)
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    37
by (rtac (major RS bt.induct) 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    38
by (ALLGOALS (asm_simp_tac (simpset() addsimps prems)));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    39
qed "bt_rec_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    40
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    41
(** n_nodes **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    42
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    43
Goal "t: bt(A) ==> n_nodes(t) : nat";
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    44
by (induct_tac "t" 1);
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    45
by Auto_tac;
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    46
qed "n_nodes_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    47
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    48
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    49
(** n_leaves **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    50
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    51
Goal "t: bt(A) ==> n_leaves(t) : nat";
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    52
by (induct_tac "t" 1);
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    53
by Auto_tac;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    54
qed "n_leaves_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    55
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    56
(** bt_reflect **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    57
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    58
Goal "t: bt(A) ==> bt_reflect(t) : bt(A)";
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    59
by (induct_tac "t" 1);
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    60
by Auto_tac;
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    61
by (REPEAT (ares_tac (bt.intrs @ [bt_rec_type]) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    62
qed "bt_reflect_type";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    63
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    64
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    65
(** BT simplification **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    66
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    67
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5530
diff changeset
    68
Addsimps [bt_rec_type, n_nodes_type, n_leaves_type, bt_reflect_type];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    69
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    70
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    71
(*** theorems about n_leaves ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    72
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    73
Goal "t: bt(A) ==> n_leaves(bt_reflect(t)) = n_leaves(t)";
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    74
by (induct_tac "t" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    75
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_commute, n_leaves_type])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    76
qed "n_leaves_reflect";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    77
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    78
Goal "t: bt(A) ==> n_leaves(t) = succ(n_nodes(t))";
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    79
by (induct_tac "t" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2469
diff changeset
    80
by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_succ_right])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    81
qed "n_leaves_nodes";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    82
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    83
(*** theorems about bt_reflect ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    84
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    85
Goal "t: bt(A) ==> bt_reflect(bt_reflect(t))=t";
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6046
diff changeset
    86
by (induct_tac "t" 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    87
by (ALLGOALS Asm_simp_tac);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    88
qed "bt_reflect_bt_reflect_ident";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    89
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 477
diff changeset
    90