src/HOL/Lex/MaxChop.ML
author wenzelm
Tue, 21 Jul 1998 12:12:52 +0200
changeset 5168 adafef6eb295
parent 5161 e7457679e26d
child 5184 9b8547a9496a
permissions -rw-r--r--
isatool expandshort;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Lex/MaxChop.ML
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     4
    Copyright   1998 TUM
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     5
*)
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     6
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     7
(* Termination of chop *)
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
     8
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4910
diff changeset
     9
Goalw [reducing_def] "reducing(%qs. maxsplit P ([],qs) [] qs)";
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    10
by (asm_full_simp_tac (simpset() addsimps [maxsplit_eq]) 1);
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    11
qed "reducing_maxsplit";
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    12
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    13
val [tc] = chopr.tcs;
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    14
goalw_cterm [reducing_def] (cterm_of (sign_of thy) (HOLogic.mk_Trueprop tc));
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    15
by (blast_tac (claset() addDs [sym]) 1);
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    16
val lemma = result();
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    17
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    18
val chopr_rule = let val [chopr_rule] = chopr.rules in lemma RS chopr_rule end;
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    19
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    20
Goalw [chop_def] "reducing splitf ==> \
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    21
\ chop splitf xs = (let (pre,post) = splitf xs \
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    22
\                   in if pre=[] then ([],xs) \
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    23
\                      else let (xss,zs) = chop splitf post \
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    24
\                             in (pre#xss,zs))";
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    25
by (asm_simp_tac (simpset() addsimps [chopr_rule] addcongs [if_weak_cong]) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    26
by (simp_tac (simpset() addsimps [Let_def] addsplits [split_split]) 1);
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    27
qed "chop_rule";
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    28
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4910
diff changeset
    29
Goalw [is_maxsplitter_def,reducing_def]
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    30
 "is_maxsplitter P splitf ==> reducing splitf";
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    31
by (Asm_full_simp_tac 1);
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    32
qed "is_maxsplitter_reducing";
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    33
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    34
Goal "is_maxsplitter P splitf ==> \
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    35
\ !yss zs. chop splitf xs = (yss,zs) --> xs = concat yss @ zs";
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    36
by (res_inst_tac [("xs","xs")] length_induct 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    37
by (asm_simp_tac (simpset() delsplits [split_if]
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    38
                           addsimps [chop_rule,is_maxsplitter_reducing]
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    39
                           addcongs [if_weak_cong]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    40
by (asm_full_simp_tac (simpset() addsimps [Let_def,is_maxsplitter_def]
4832
bc11b5b06f87 Added conversion of reg.expr. to automata.
nipkow
parents: 4714
diff changeset
    41
                                addsplits [split_split]) 1);
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    42
qed_spec_mp "chop_concat";
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    43
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    44
Goal "is_maxsplitter P splitf ==> \
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    45
\ !yss zs. chop splitf xs = (yss,zs) --> (!ys : set yss. ys ~= [])";
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    46
by (res_inst_tac [("xs","xs")] length_induct 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    47
by (asm_simp_tac (simpset() addsimps [chop_rule,is_maxsplitter_reducing]
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    48
                           addcongs [if_weak_cong]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    49
by (asm_full_simp_tac (simpset() addsimps [Let_def,is_maxsplitter_def]
4832
bc11b5b06f87 Added conversion of reg.expr. to automata.
nipkow
parents: 4714
diff changeset
    50
                                addsplits [split_split]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    51
by (simp_tac (simpset() addsimps [Let_def,maxsplit_eq]
4832
bc11b5b06f87 Added conversion of reg.expr. to automata.
nipkow
parents: 4714
diff changeset
    52
                       addsplits [split_split]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    53
by (etac thin_rl 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    54
by (strip_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    55
by (rtac ballI 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    56
by (etac exE 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    57
by (etac allE 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    58
by Auto_tac;
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    59
qed_spec_mp "chop_nonempty";
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    60
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    61
val [prem] = goalw thy [is_maxchopper_def]
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
    62
 "is_maxsplitter P splitf ==> is_maxchopper P (chop splitf)";
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    63
by (Clarify_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    64
by (rtac iffI 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    65
 by (rtac conjI 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    66
  by (etac (prem RS chop_concat) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    67
 by (rtac conjI 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    68
  by (etac (prem RS chop_nonempty) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    69
 by (etac rev_mp 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    70
 by (stac (prem RS is_maxsplitter_reducing RS chop_rule) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    71
 by (simp_tac (simpset() addsimps [Let_def,rewrite_rule[is_maxsplitter_def]prem]
4832
bc11b5b06f87 Added conversion of reg.expr. to automata.
nipkow
parents: 4714
diff changeset
    72
                        addsplits [split_split]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    73
 by (Clarify_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    74
 by (rtac conjI 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    75
  by (Clarify_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    76
  by (Asm_full_simp_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    77
 by (Clarify_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    78
 by (Asm_full_simp_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    79
 by (forward_tac [prem RS chop_concat] 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    80
 by (Clarify_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    81
 by (assume_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    82
by (stac (prem RS is_maxsplitter_reducing RS chop_rule) 1);
5161
e7457679e26d Simplified last proof.
nipkow
parents: 5132
diff changeset
    83
by (simp_tac (simpset() addsimps [Let_def,rewrite_rule[is_maxsplitter_def]prem]
4832
bc11b5b06f87 Added conversion of reg.expr. to automata.
nipkow
parents: 4714
diff changeset
    84
                        addsplits [split_split]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    85
by (Clarify_tac 1);
5168
adafef6eb295 isatool expandshort;
wenzelm
parents: 5161
diff changeset
    86
by (rename_tac "xs1 ys1 xss1 ys" 1);
adafef6eb295 isatool expandshort;
wenzelm
parents: 5161
diff changeset
    87
by (split_asm_tac [split_list_case_asm] 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    88
 by (Asm_full_simp_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    89
 by (full_simp_tac (simpset() addsimps [is_maxpref_def]) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    90
 by (blast_tac (claset() addIs [prefix_append RS iffD2]) 1);
5161
e7457679e26d Simplified last proof.
nipkow
parents: 5132
diff changeset
    91
by (rtac conjI 1);
e7457679e26d Simplified last proof.
nipkow
parents: 5132
diff changeset
    92
 by (Clarify_tac 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    93
 by (full_simp_tac (simpset() addsimps [is_maxpref_def]) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    94
 by (blast_tac (claset() addIs [prefix_append RS iffD2]) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    95
by (Clarify_tac 1);
5168
adafef6eb295 isatool expandshort;
wenzelm
parents: 5161
diff changeset
    96
by (rename_tac "us uss" 1);
5161
e7457679e26d Simplified last proof.
nipkow
parents: 5132
diff changeset
    97
by (subgoal_tac "xs1=us" 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    98
 by (Asm_full_simp_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
    99
by (Asm_full_simp_tac 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
   100
by (full_simp_tac (simpset() addsimps [is_maxpref_def]) 1);
24f992a25adc isatool expandshort;
wenzelm
parents: 5118
diff changeset
   101
by (blast_tac (claset() addIs [prefix_append RS iffD2,prefix_antisym]) 1);
4714
bcdf68c78e18 New scanner in abstract form.
nipkow
parents:
diff changeset
   102
qed "is_maxchopper_chop";