12088
|
1 |
(* Title: ZF/ex/Rmap
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1994 University of Cambridge
|
|
5 |
|
|
6 |
Inductive definition of an operator to "map" a relation over a list
|
|
7 |
*)
|
|
8 |
|
|
9 |
Goalw rmap.defs "r \\<subseteq> s ==> rmap(r) \\<subseteq> rmap(s)";
|
|
10 |
by (rtac lfp_mono 1);
|
|
11 |
by (REPEAT (rtac rmap.bnd_mono 1));
|
|
12 |
by (REPEAT (ares_tac ([Sigma_mono, list_mono, domain_mono, range_mono] @
|
|
13 |
basic_monos) 1));
|
|
14 |
qed "rmap_mono";
|
|
15 |
|
|
16 |
val Nil_rmap_case = rmap.mk_cases "<Nil,zs> \\<in> rmap(r)"
|
|
17 |
and Cons_rmap_case = rmap.mk_cases "<Cons(x,xs),zs> \\<in> rmap(r)";
|
|
18 |
|
|
19 |
AddIs rmap.intrs;
|
|
20 |
AddSEs [Nil_rmap_case, Cons_rmap_case];
|
|
21 |
|
|
22 |
Goal "r \\<subseteq> A*B ==> rmap(r) \\<subseteq> list(A)*list(B)";
|
|
23 |
by (rtac (rmap.dom_subset RS subset_trans) 1);
|
|
24 |
by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset,
|
|
25 |
Sigma_mono, list_mono] 1));
|
|
26 |
qed "rmap_rel_type";
|
|
27 |
|
|
28 |
Goal "A \\<subseteq> domain(r) ==> list(A) \\<subseteq> domain(rmap(r))";
|
|
29 |
by (rtac subsetI 1);
|
|
30 |
by (etac list.induct 1);
|
|
31 |
by (ALLGOALS Fast_tac);
|
|
32 |
qed "rmap_total";
|
|
33 |
|
|
34 |
Goalw [function_def] "function(r) ==> function(rmap(r))";
|
|
35 |
by (rtac (impI RS allI RS allI) 1);
|
|
36 |
by (etac rmap.induct 1);
|
|
37 |
by (ALLGOALS Fast_tac);
|
|
38 |
qed "rmap_functional";
|
|
39 |
|
|
40 |
|
|
41 |
(** If f is a function then rmap(f) behaves as expected. **)
|
|
42 |
|
|
43 |
Goal "f \\<in> A->B ==> rmap(f): list(A)->list(B)";
|
|
44 |
by (asm_full_simp_tac (simpset() addsimps [Pi_iff, rmap_rel_type,
|
|
45 |
rmap_functional, rmap_total]) 1);
|
|
46 |
qed "rmap_fun_type";
|
|
47 |
|
|
48 |
Goalw [apply_def] "rmap(f)`Nil = Nil";
|
|
49 |
by (Blast_tac 1);
|
|
50 |
qed "rmap_Nil";
|
|
51 |
|
|
52 |
Goal "[| f \\<in> A->B; x \\<in> A; xs: list(A) |] \
|
|
53 |
\ ==> rmap(f) ` Cons(x,xs) = Cons(f`x, rmap(f)`xs)";
|
|
54 |
by (rtac apply_equality 1);
|
|
55 |
by (REPEAT (ares_tac ([apply_Pair, rmap_fun_type] @ rmap.intrs) 1));
|
|
56 |
qed "rmap_Cons";
|