110 by (induct_tac "ys" 1); |
110 by (induct_tac "ys" 1); |
111 by (ALLGOALS Asm_simp_tac); |
111 by (ALLGOALS Asm_simp_tac); |
112 qed_spec_mp "append1_eq_conv"; |
112 qed_spec_mp "append1_eq_conv"; |
113 AddIffs [append1_eq_conv]; |
113 AddIffs [append1_eq_conv]; |
114 |
114 |
|
115 goal thy "!ys zs. (ys @ xs = zs @ xs) = (ys=zs)"; |
|
116 by (induct_tac "xs" 1); |
|
117 by (Simp_tac 1); |
|
118 by (strip_tac 1); |
|
119 by (subgoal_tac "((ys @ [a]) @ list = (zs @ [a]) @ list) = (ys=zs)" 1); |
|
120 by (Asm_full_simp_tac 1); |
|
121 by (Blast_tac 1); |
|
122 qed_spec_mp "append_same_eq"; |
|
123 AddIffs [append_same_eq]; |
|
124 |
115 goal thy "xs ~= [] --> hd xs # tl xs = xs"; |
125 goal thy "xs ~= [] --> hd xs # tl xs = xs"; |
116 by (induct_tac "xs" 1); |
126 by (induct_tac "xs" 1); |
117 by (ALLGOALS Asm_simp_tac); |
127 by (ALLGOALS Asm_simp_tac); |
118 qed_spec_mp "hd_Cons_tl"; |
128 qed_spec_mp "hd_Cons_tl"; |
119 Addsimps [hd_Cons_tl]; |
129 Addsimps [hd_Cons_tl]; |
120 |
130 |
121 goal thy "hd(xs@ys) = (if xs=[] then hd ys else hd xs)"; |
131 goal thy "hd(xs@ys) = (if xs=[] then hd ys else hd xs)"; |
122 by (induct_tac "xs" 1); |
132 by (induct_tac "xs" 1); |
123 by (ALLGOALS Asm_simp_tac); |
133 by (ALLGOALS Asm_simp_tac); |
124 qed "hd_append"; |
134 qed "hd_append"; |
|
135 |
|
136 goal thy "!!xs. xs ~= [] ==> hd(xs @ ys) = hd xs"; |
|
137 by (asm_simp_tac (!simpset addsimps [hd_append] |
|
138 setloop (split_tac [expand_list_case])) 1); |
|
139 qed "hd_append2"; |
|
140 Addsimps [hd_append2]; |
125 |
141 |
126 goal thy "tl(xs@ys) = (case xs of [] => tl(ys) | z#zs => zs@ys)"; |
142 goal thy "tl(xs@ys) = (case xs of [] => tl(ys) | z#zs => zs@ys)"; |
127 by (simp_tac (!simpset setloop(split_tac[expand_list_case])) 1); |
143 by (simp_tac (!simpset setloop(split_tac[expand_list_case])) 1); |
128 qed "tl_append"; |
144 qed "tl_append"; |
|
145 |
|
146 goal thy "!!xs. xs ~= [] ==> tl(xs @ ys) = (tl xs) @ ys"; |
|
147 by (asm_simp_tac (!simpset addsimps [tl_append] |
|
148 setloop (split_tac [expand_list_case])) 1); |
|
149 qed "tl_append2"; |
|
150 Addsimps [tl_append2]; |
129 |
151 |
130 (** map **) |
152 (** map **) |
131 |
153 |
132 section "map"; |
154 section "map"; |
133 |
155 |