19 and Cons_rmap_case = rmap.mk_cases list.con_defs "<Cons(x,xs),zs> : rmap(r)"; |
19 and Cons_rmap_case = rmap.mk_cases list.con_defs "<Cons(x,xs),zs> : rmap(r)"; |
20 |
20 |
21 AddIs rmap.intrs; |
21 AddIs rmap.intrs; |
22 AddSEs [Nil_rmap_case, Cons_rmap_case]; |
22 AddSEs [Nil_rmap_case, Cons_rmap_case]; |
23 |
23 |
24 goal Rmap.thy "!!r. r <= A*B ==> rmap(r) <= list(A)*list(B)"; |
24 Goal "!!r. r <= A*B ==> rmap(r) <= list(A)*list(B)"; |
25 by (rtac (rmap.dom_subset RS subset_trans) 1); |
25 by (rtac (rmap.dom_subset RS subset_trans) 1); |
26 by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset, |
26 by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset, |
27 Sigma_mono, list_mono] 1)); |
27 Sigma_mono, list_mono] 1)); |
28 qed "rmap_rel_type"; |
28 qed "rmap_rel_type"; |
29 |
29 |
30 goal Rmap.thy |
30 Goal |
31 "!!r. A <= domain(r) ==> list(A) <= domain(rmap(r))"; |
31 "!!r. A <= domain(r) ==> list(A) <= domain(rmap(r))"; |
32 by (rtac subsetI 1); |
32 by (rtac subsetI 1); |
33 by (etac list.induct 1); |
33 by (etac list.induct 1); |
34 by (ALLGOALS Fast_tac); |
34 by (ALLGOALS Fast_tac); |
35 qed "rmap_total"; |
35 qed "rmap_total"; |
36 |
36 |
37 goalw Rmap.thy [function_def] "!!r. function(r) ==> function(rmap(r))"; |
37 Goalw [function_def] "!!r. function(r) ==> function(rmap(r))"; |
38 by (rtac (impI RS allI RS allI) 1); |
38 by (rtac (impI RS allI RS allI) 1); |
39 by (etac rmap.induct 1); |
39 by (etac rmap.induct 1); |
40 by (ALLGOALS Fast_tac); |
40 by (ALLGOALS Fast_tac); |
41 qed "rmap_functional"; |
41 qed "rmap_functional"; |
42 |
42 |
43 |
43 |
44 (** If f is a function then rmap(f) behaves as expected. **) |
44 (** If f is a function then rmap(f) behaves as expected. **) |
45 |
45 |
46 goal Rmap.thy "!!f. f: A->B ==> rmap(f): list(A)->list(B)"; |
46 Goal "!!f. f: A->B ==> rmap(f): list(A)->list(B)"; |
47 by (asm_full_simp_tac |
47 by (asm_full_simp_tac |
48 (simpset() addsimps [Pi_iff, rmap_rel_type, rmap_functional, rmap_total]) 1); |
48 (simpset() addsimps [Pi_iff, rmap_rel_type, rmap_functional, rmap_total]) 1); |
49 qed "rmap_fun_type"; |
49 qed "rmap_fun_type"; |
50 |
50 |
51 goalw Rmap.thy [apply_def] "rmap(f)`Nil = Nil"; |
51 Goalw [apply_def] "rmap(f)`Nil = Nil"; |
52 by (fast_tac (claset() addIs [the_equality]) 1); |
52 by (fast_tac (claset() addIs [the_equality]) 1); |
53 qed "rmap_Nil"; |
53 qed "rmap_Nil"; |
54 |
54 |
55 goal Rmap.thy "!!f. [| f: A->B; x: A; xs: list(A) |] ==> \ |
55 Goal "!!f. [| f: A->B; x: A; xs: list(A) |] ==> \ |
56 \ rmap(f) ` Cons(x,xs) = Cons(f`x, rmap(f)`xs)"; |
56 \ rmap(f) ` Cons(x,xs) = Cons(f`x, rmap(f)`xs)"; |
57 by (rtac apply_equality 1); |
57 by (rtac apply_equality 1); |
58 by (REPEAT (ares_tac ([apply_Pair, rmap_fun_type] @ rmap.intrs) 1)); |
58 by (REPEAT (ares_tac ([apply_Pair, rmap_fun_type] @ rmap.intrs) 1)); |
59 qed "rmap_Cons"; |
59 qed "rmap_Cons"; |