src/FOL/ex/List.ML
author wenzelm
Sun, 26 Nov 2006 23:43:53 +0100
changeset 21539 c5cf9243ad62
parent 17245 1c519a3cca59
permissions -rw-r--r--
converted legacy ML scripts;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1459
d12da312eff4 expanded tabs
clasohm
parents: 755
diff changeset
     1
(*  Title:      FOL/ex/list
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1459
d12da312eff4 expanded tabs
clasohm
parents: 755
diff changeset
     3
    Author:     Tobias Nipkow
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
17245
1c519a3cca59 converted to Isar theory format;
wenzelm
parents: 5050
diff changeset
     7
val prems = goal (the_context ()) "[| P([]);  !!x l. P(x . l) |] ==> All(P)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
by (rtac list_ind 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
by (REPEAT (resolve_tac (prems@[allI,impI]) 1));
725
d9c629fbacc6 replaced 'val ... = result();' by 'qed "...";'
clasohm
parents: 0
diff changeset
    10
qed "list_exh";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    12
Addsimps [list_distinct1, list_distinct2, app_nil, app_cons,
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    13
	  hd_eq, tl_eq, forall_nil, forall_cons, list_free,
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    14
	  len_nil, len_cons, at_0, at_succ];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    16
Goal "~l=[] --> hd(l).tl(l) = l";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    17
by (IND_TAC list_exh Simp_tac "l" 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    20
Goal "(l1++l2)++l3 = l1++(l2++l3)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    21
by (IND_TAC list_ind Simp_tac "l1" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    22
qed "append_assoc";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    24
Goal "l++[] = l";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    25
by (IND_TAC list_ind Simp_tac "l" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    26
qed "app_nil_right";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    28
Goal "l1++l2=[] <-> l1=[] & l2=[]";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    29
by (IND_TAC list_exh Simp_tac "l1" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    30
qed "app_eq_nil_iff";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    32
Goal "forall(l++l',P) <-> forall(l,P) & forall(l',P)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    33
by (IND_TAC list_ind Simp_tac "l" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    34
qed "forall_app";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    36
Goal "forall(l,%x. P(x)&Q(x)) <-> forall(l,P) & forall(l,Q)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    37
by (IND_TAC list_ind Simp_tac "l" 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    38
by (Fast_tac 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    39
qed "forall_conj";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    41
Goal "~l=[] --> forall(l,P) <-> P(hd(l)) & forall(tl(l),P)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    42
by (IND_TAC list_ind Simp_tac "l" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    43
qed "forall_ne";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
(*** Lists with natural numbers ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    47
Goal "len(l1++l2) = len(l1)+len(l2)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    48
by (IND_TAC list_ind Simp_tac "l1" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    49
qed "len_app";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    51
Goal "i<len(l1) --> at(l1++l2,i) = at(l1,i)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    52
by (IND_TAC list_ind Simp_tac "l1" 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
by (REPEAT (rtac allI 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
by (rtac impI 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    55
by (ALL_IND_TAC nat_exh Asm_simp_tac 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    56
qed "at_app1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
5050
e925308df78b isatool fixgoal;
wenzelm
parents: 3922
diff changeset
    58
Goal "at(l1++(x . l2), len(l1)) = x";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1459
diff changeset
    59
by (IND_TAC list_ind Simp_tac "l1" 1);
755
dfb3894d78e4 replaced "val ... = result()" by "qed ..."
clasohm
parents: 725
diff changeset
    60
qed "at_app_hd2";