src/HOL/Lex/Prefix.ML
author wenzelm
Mon, 22 Jun 1998 17:26:46 +0200
changeset 5069 3ea049f7979d
parent 4936 e67949e15255
child 5118 6b995dad8a9d
permissions -rw-r--r--
isatool fixgoal;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1344
diff changeset
     1
(*  Title:      HOL/Lex/Prefix.thy
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1344
diff changeset
     3
    Author:     Richard Mayr & Tobias Nipkow
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
     4
    Copyright   1995 TUM
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
     5
*)
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
     6
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
     7
(* Junk: *)
3842
b55686a7b22c fixed dots;
wenzelm
parents: 2130
diff changeset
     8
val [maj,min] = goal Prefix.thy "[| Q([]); !! y ys. Q(y#ys) |] ==> ! l. Q(l)";
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1344
diff changeset
     9
by (rtac allI 1);
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    10
by (list.induct_tac "l" 1);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1344
diff changeset
    11
by (rtac maj 1);
5d7a7e439cec expanded tabs
clasohm
parents: 1344
diff changeset
    12
by (rtac min 1);
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    13
val list_cases = result();
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    14
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    15
(** <= is a partial order: **)
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    16
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    17
Goalw [prefix_def] "xs <= (xs::'a list)";
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    18
by(Simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    19
qed "prefix_refl";
4647
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    20
AddIffs[prefix_refl];
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    21
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    22
Goalw [prefix_def] "!!xs::'a list. [| xs <= ys; ys <= zs |] ==> xs <= zs";
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    23
by(Clarify_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    24
by(Simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    25
qed "prefix_trans";
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    26
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    27
Goalw [prefix_def] "!!xs::'a list. [| xs <= ys; ys <= xs |] ==> xs = ys";
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    28
by(Clarify_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    29
by(Asm_full_simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    30
qed "prefix_antisym";
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    31
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    32
(** recursion equations **)
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    33
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    34
Goalw [prefix_def] "[] <= xs";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 3842
diff changeset
    35
by (simp_tac (simpset() addsimps [eq_sym_conv]) 1);
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    36
qed "Nil_prefix";
4647
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    37
AddIffs[Nil_prefix];
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    38
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    39
Goalw [prefix_def] "(xs <= []) = (xs = [])";
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    40
by (list.induct_tac "xs" 1);
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    41
by (Simp_tac 1);
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    42
by (Simp_tac 1);
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    43
qed "prefix_Nil";
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    44
Addsimps [prefix_Nil];
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    45
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    46
Goalw [prefix_def] "(xs <= ys@[y]) = (xs = ys@[y] | xs <= ys)";
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    47
br iffI 1;
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    48
 be exE 1;
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    49
 by(rename_tac "zs" 1);
4936
e67949e15255 snoc_induct/exhaust -> rev_induct_exhaust.
nipkow
parents: 4647
diff changeset
    50
 by(res_inst_tac [("xs","zs")] rev_exhaust 1);
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    51
  by(Asm_full_simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    52
 by(hyp_subst_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    53
 by(asm_full_simp_tac (simpset() delsimps [append_assoc]
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    54
                                 addsimps [append_assoc RS sym])1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    55
be disjE 1;
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    56
 by(Asm_simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    57
by(Clarify_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    58
by (Simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    59
qed "prefix_snoc";
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    60
Addsimps [prefix_snoc];
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    61
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    62
Goalw [prefix_def] "(x#xs <= y#ys) = (x=y & xs<=ys)";
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    63
by (Simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    64
by (Fast_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    65
qed"Cons_prefix_Cons";
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    66
Addsimps [Cons_prefix_Cons];
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    67
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    68
Goal "(xs@ys <= xs@zs) = (ys <= zs)";
4647
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    69
by (induct_tac "xs" 1);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    70
by(ALLGOALS Asm_simp_tac);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    71
qed "same_prefix_prefix";
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    72
Addsimps [same_prefix_prefix];
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    73
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    74
AddIffs
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    75
 [simplify (simpset()) (read_instantiate [("zs","[]")] same_prefix_prefix)];
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    76
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    77
Goalw [prefix_def] "!!xs. xs <= ys ==> xs <= ys@zs";
4643
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    78
by(Clarify_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    79
by (Simp_tac 1);
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    80
qed "prefix_prefix";
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    81
Addsimps [prefix_prefix];
1b40fcac5a09 New induction schemas for lists (length and snoc).
nipkow
parents: 4423
diff changeset
    82
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    83
(* nicht sehr elegant bewiesen - Induktion eigentlich ueberfluessig *)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    84
Goalw [prefix_def]
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    85
   "(xs <= y#ys) = (xs=[] | (? zs. xs=y#zs & zs <= ys))";
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    86
by (list.induct_tac "xs" 1);
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    87
by (Simp_tac 1);
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    88
by (Simp_tac 1);
1894
c2c8279d40f0 Classical tactics now use default claset.
berghofe
parents: 1465
diff changeset
    89
by (Fast_tac 1);
1344
f172a7f14e49 Half a lexical analyzer generator.
nipkow
parents:
diff changeset
    90
qed "prefix_Cons";
4647
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    91
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4936
diff changeset
    92
Goal "(xs <= ys@zs) = (xs <= ys | (? us. xs = ys@us & us <= zs))";
4936
e67949e15255 snoc_induct/exhaust -> rev_induct_exhaust.
nipkow
parents: 4647
diff changeset
    93
by(res_inst_tac [("xs","zs")] rev_induct 1);
4647
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    94
 by(Simp_tac 1);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    95
 by(Blast_tac 1);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    96
by(asm_full_simp_tac (simpset() delsimps [append_assoc]
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    97
                                addsimps [append_assoc RS sym])1);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    98
by(Simp_tac 1);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
    99
by(Blast_tac 1);
42af8ae6e2c1 Added some lemmas.
nipkow
parents: 4643
diff changeset
   100
qed "prefix_append";