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