1 (* Title: ZF/ex/rmap |
1 (* Title: ZF/ex/Rmap |
2 ID: $Id$ |
2 ID: $Id$ |
3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
4 Copyright 1993 University of Cambridge |
4 Copyright 1994 University of Cambridge |
5 |
5 |
6 Inductive definition of an operator to "map" a relation over a list |
6 Inductive definition of an operator to "map" a relation over a list |
7 *) |
7 *) |
8 |
8 |
9 structure Rmap = Inductive_Fun |
9 open Rmap; |
10 (val thy = List.thy |> add_consts [("rmap","i=>i",NoSyn)]; |
|
11 val thy_name = "Rmap"; |
|
12 val rec_doms = [("rmap", "list(domain(r))*list(range(r))")]; |
|
13 val sintrs = |
|
14 ["<Nil,Nil> : rmap(r)", |
|
15 |
10 |
16 "[| <x,y>: r; <xs,ys> : rmap(r) |] ==> \ |
11 goalw Rmap.thy rmap.defs "!!r s. r<=s ==> rmap(r) <= rmap(s)"; |
17 \ <Cons(x,xs), Cons(y,ys)> : rmap(r)"]; |
|
18 val monos = []; |
|
19 val con_defs = []; |
|
20 val type_intrs = [domainI,rangeI] @ List.intrs |
|
21 val type_elims = []); |
|
22 |
|
23 goalw Rmap.thy Rmap.defs "!!r s. r<=s ==> rmap(r) <= rmap(s)"; |
|
24 by (rtac lfp_mono 1); |
12 by (rtac lfp_mono 1); |
25 by (REPEAT (rtac Rmap.bnd_mono 1)); |
13 by (REPEAT (rtac rmap.bnd_mono 1)); |
26 by (REPEAT (ares_tac ([Sigma_mono, list_mono, domain_mono, range_mono] @ |
14 by (REPEAT (ares_tac ([Sigma_mono, list_mono, domain_mono, range_mono] @ |
27 basic_monos) 1)); |
15 basic_monos) 1)); |
28 val rmap_mono = result(); |
16 val rmap_mono = result(); |
29 |
17 |
30 val rmap_induct = standard |
18 val rmap_induct = standard |
31 (Rmap.mutual_induct RS spec RS spec RSN (2,rev_mp)); |
19 (rmap.mutual_induct RS spec RS spec RSN (2,rev_mp)); |
32 |
20 |
33 val Nil_rmap_case = Rmap.mk_cases List.con_defs "<Nil,zs> : rmap(r)" |
21 val Nil_rmap_case = rmap.mk_cases list.con_defs "<Nil,zs> : rmap(r)" |
34 and Cons_rmap_case = Rmap.mk_cases List.con_defs "<Cons(x,xs),zs> : rmap(r)"; |
22 and Cons_rmap_case = rmap.mk_cases list.con_defs "<Cons(x,xs),zs> : rmap(r)"; |
35 |
23 |
36 val rmap_cs = ZF_cs addIs Rmap.intrs |
24 val rmap_cs = ZF_cs addIs rmap.intrs |
37 addSEs [Nil_rmap_case, Cons_rmap_case]; |
25 addSEs [Nil_rmap_case, Cons_rmap_case]; |
38 |
26 |
39 goal Rmap.thy "!!r. r <= A*B ==> rmap(r) <= list(A)*list(B)"; |
27 goal Rmap.thy "!!r. r <= A*B ==> rmap(r) <= list(A)*list(B)"; |
40 by (rtac (Rmap.dom_subset RS subset_trans) 1); |
28 by (rtac (rmap.dom_subset RS subset_trans) 1); |
41 by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset, |
29 by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset, |
42 Sigma_mono, list_mono] 1)); |
30 Sigma_mono, list_mono] 1)); |
43 val rmap_rel_type = result(); |
31 val rmap_rel_type = result(); |
44 |
32 |
45 goal Rmap.thy |
33 goal Rmap.thy |
46 "!!r. [| ALL x:A. EX y. <x,y>: r; xs: list(A) |] ==> \ |
34 "!!r. [| ALL x:A. EX y. <x,y>: r; xs: list(A) |] ==> \ |
47 \ EX y. <xs, y> : rmap(r)"; |
35 \ EX y. <xs, y> : rmap(r)"; |
48 by (etac List.induct 1); |
36 by (etac list.induct 1); |
49 by (ALLGOALS (fast_tac rmap_cs)); |
37 by (ALLGOALS (fast_tac rmap_cs)); |
50 val rmap_total = result(); |
38 val rmap_total = result(); |
51 |
39 |
52 goal Rmap.thy |
40 goal Rmap.thy |
53 "!!r. [| ALL x y z. <x,y>: r --> <x,z>: r --> y=z; \ |
41 "!!r. [| ALL x y z. <x,y>: r --> <x,z>: r --> y=z; \ |