15 |
15 |
16 Addsimps [list_distinct1, list_distinct2, app_nil, app_cons, |
16 Addsimps [list_distinct1, list_distinct2, app_nil, app_cons, |
17 hd_eq, tl_eq, forall_nil, forall_cons, list_free, |
17 hd_eq, tl_eq, forall_nil, forall_cons, list_free, |
18 len_nil, len_cons, at_0, at_succ]; |
18 len_nil, len_cons, at_0, at_succ]; |
19 |
19 |
20 goal List.thy "~l=[] --> hd(l).tl(l) = l"; |
20 Goal "~l=[] --> hd(l).tl(l) = l"; |
21 by (IND_TAC list_exh Simp_tac "l" 1); |
21 by (IND_TAC list_exh Simp_tac "l" 1); |
22 result(); |
22 result(); |
23 |
23 |
24 goal List.thy "(l1++l2)++l3 = l1++(l2++l3)"; |
24 Goal "(l1++l2)++l3 = l1++(l2++l3)"; |
25 by (IND_TAC list_ind Simp_tac "l1" 1); |
25 by (IND_TAC list_ind Simp_tac "l1" 1); |
26 qed "append_assoc"; |
26 qed "append_assoc"; |
27 |
27 |
28 goal List.thy "l++[] = l"; |
28 Goal "l++[] = l"; |
29 by (IND_TAC list_ind Simp_tac "l" 1); |
29 by (IND_TAC list_ind Simp_tac "l" 1); |
30 qed "app_nil_right"; |
30 qed "app_nil_right"; |
31 |
31 |
32 goal List.thy "l1++l2=[] <-> l1=[] & l2=[]"; |
32 Goal "l1++l2=[] <-> l1=[] & l2=[]"; |
33 by (IND_TAC list_exh Simp_tac "l1" 1); |
33 by (IND_TAC list_exh Simp_tac "l1" 1); |
34 qed "app_eq_nil_iff"; |
34 qed "app_eq_nil_iff"; |
35 |
35 |
36 goal List.thy "forall(l++l',P) <-> forall(l,P) & forall(l',P)"; |
36 Goal "forall(l++l',P) <-> forall(l,P) & forall(l',P)"; |
37 by (IND_TAC list_ind Simp_tac "l" 1); |
37 by (IND_TAC list_ind Simp_tac "l" 1); |
38 qed "forall_app"; |
38 qed "forall_app"; |
39 |
39 |
40 goal List.thy "forall(l,%x. P(x)&Q(x)) <-> forall(l,P) & forall(l,Q)"; |
40 Goal "forall(l,%x. P(x)&Q(x)) <-> forall(l,P) & forall(l,Q)"; |
41 by (IND_TAC list_ind Simp_tac "l" 1); |
41 by (IND_TAC list_ind Simp_tac "l" 1); |
42 by (Fast_tac 1); |
42 by (Fast_tac 1); |
43 qed "forall_conj"; |
43 qed "forall_conj"; |
44 |
44 |
45 goal List.thy "~l=[] --> forall(l,P) <-> P(hd(l)) & forall(tl(l),P)"; |
45 Goal "~l=[] --> forall(l,P) <-> P(hd(l)) & forall(tl(l),P)"; |
46 by (IND_TAC list_ind Simp_tac "l" 1); |
46 by (IND_TAC list_ind Simp_tac "l" 1); |
47 qed "forall_ne"; |
47 qed "forall_ne"; |
48 |
48 |
49 (*** Lists with natural numbers ***) |
49 (*** Lists with natural numbers ***) |
50 |
50 |
51 goal List.thy "len(l1++l2) = len(l1)+len(l2)"; |
51 Goal "len(l1++l2) = len(l1)+len(l2)"; |
52 by (IND_TAC list_ind Simp_tac "l1" 1); |
52 by (IND_TAC list_ind Simp_tac "l1" 1); |
53 qed "len_app"; |
53 qed "len_app"; |
54 |
54 |
55 goal List.thy "i<len(l1) --> at(l1++l2,i) = at(l1,i)"; |
55 Goal "i<len(l1) --> at(l1++l2,i) = at(l1,i)"; |
56 by (IND_TAC list_ind Simp_tac "l1" 1); |
56 by (IND_TAC list_ind Simp_tac "l1" 1); |
57 by (REPEAT (rtac allI 1)); |
57 by (REPEAT (rtac allI 1)); |
58 by (rtac impI 1); |
58 by (rtac impI 1); |
59 by (ALL_IND_TAC nat_exh Asm_simp_tac 1); |
59 by (ALL_IND_TAC nat_exh Asm_simp_tac 1); |
60 qed "at_app1"; |
60 qed "at_app1"; |
61 |
61 |
62 goal List.thy "at(l1++(x . l2), len(l1)) = x"; |
62 Goal "at(l1++(x . l2), len(l1)) = x"; |
63 by (IND_TAC list_ind Simp_tac "l1" 1); |
63 by (IND_TAC list_ind Simp_tac "l1" 1); |
64 qed "at_app_hd2"; |
64 qed "at_app_hd2"; |
65 |
65 |