author | lcp |
Fri, 22 Oct 1993 11:42:02 +0100 | |
changeset 71 | 729fe026c5f3 |
parent 16 | 0b033d50ca1c |
child 445 | 7b6d8b8d4580 |
permissions | -rw-r--r-- |
16
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
1 |
(* Title: ZF/ex/rmap |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
2 |
ID: $Id$ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
4 |
Copyright 1993 University of Cambridge |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
5 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
6 |
Inductive definition of an operator to "map" a relation over a list |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
7 |
*) |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
8 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
9 |
structure Rmap = Inductive_Fun |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
10 |
(val thy = List.thy addconsts [(["rmap"],"i=>i")]; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
11 |
val rec_doms = [("rmap", "list(domain(r))*list(range(r))")]; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
12 |
val sintrs = |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
13 |
["<Nil,Nil> : rmap(r)", |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
14 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
15 |
"[| <x,y>: r; <xs,ys> : rmap(r) |] ==> \ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
16 |
\ <Cons(x,xs), Cons(y,ys)> : rmap(r)"]; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
17 |
val monos = []; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
18 |
val con_defs = []; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
19 |
val type_intrs = [domainI,rangeI] @ List.intrs @ [SigmaI] |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
20 |
val type_elims = [SigmaE2]); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
21 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
22 |
goalw Rmap.thy Rmap.defs "!!r s. r<=s ==> rmap(r) <= rmap(s)"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
23 |
by (rtac lfp_mono 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
24 |
by (REPEAT (rtac Rmap.bnd_mono 1)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
25 |
by (REPEAT (ares_tac ([Sigma_mono, list_mono, domain_mono, range_mono] @ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
26 |
basic_monos) 1)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
27 |
val rmap_mono = result(); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
28 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
29 |
val rmap_induct = standard |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
30 |
(Rmap.mutual_induct RS spec RS spec RSN (2,rev_mp)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
31 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
32 |
val Nil_rmap_case = Rmap.mk_cases List.con_defs "<Nil,zs> : rmap(r)" |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
33 |
and Cons_rmap_case = Rmap.mk_cases List.con_defs "<Cons(x,xs),zs> : rmap(r)"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
34 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
35 |
val rmap_cs = ZF_cs addIs Rmap.intrs |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
36 |
addSEs [Nil_rmap_case, Cons_rmap_case]; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
37 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
38 |
goal Rmap.thy "!!r. r <= A*B ==> rmap(r) <= list(A)*list(B)"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
39 |
by (rtac (Rmap.dom_subset RS subset_trans) 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
40 |
by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset, |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
41 |
Sigma_mono, list_mono] 1)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
42 |
val rmap_rel_type = result(); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
43 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
44 |
goal Rmap.thy |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
45 |
"!!r. [| ALL x:A. EX y. <x,y>: r; xs: list(A) |] ==> \ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
46 |
\ EX y. <xs, y> : rmap(r)"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
47 |
by (etac List.induct 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
48 |
by (ALLGOALS (fast_tac rmap_cs)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
49 |
val rmap_total = result(); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
50 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
51 |
goal Rmap.thy |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
52 |
"!!r. [| ALL x y z. <x,y>: r --> <x,z>: r --> y=z; \ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
53 |
\ <xs, ys> : rmap(r) |] ==> \ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
54 |
\ ALL zs. <xs, zs> : rmap(r) --> ys=zs"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
55 |
by (etac rmap_induct 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
56 |
by (ALLGOALS (fast_tac rmap_cs)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
57 |
val rmap_functional_lemma = result(); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
58 |
val rmap_functional = standard (rmap_functional_lemma RS spec RS mp); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
59 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
60 |
(** If f is a function then rmap(f) behaves as expected. **) |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
61 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
62 |
goal Rmap.thy "!!f. f: A->B ==> rmap(f): list(A)->list(B)"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
63 |
by (etac PiE 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
64 |
by (rtac PiI 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
65 |
by (etac rmap_rel_type 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
66 |
by (rtac (rmap_total RS ex_ex1I) 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
67 |
by (assume_tac 2); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
68 |
by (fast_tac (ZF_cs addSEs [bspec RS ex1E]) 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
69 |
by (rtac rmap_functional 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
70 |
by (REPEAT (assume_tac 2)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
71 |
by (fast_tac (ZF_cs addSEs [bspec RS ex1_equalsE]) 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
72 |
val rmap_fun_type = result(); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
73 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
74 |
goalw Rmap.thy [apply_def] "rmap(f)`Nil = Nil"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
75 |
by (fast_tac (rmap_cs addIs [the_equality]) 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
76 |
val rmap_Nil = result(); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
77 |
|
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
78 |
goal Rmap.thy "!!f. [| f: A->B; x: A; xs: list(A) |] ==> \ |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
79 |
\ rmap(f) ` Cons(x,xs) = Cons(f`x, rmap(f)`xs)"; |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
80 |
by (rtac apply_equality 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
81 |
by (REPEAT (ares_tac ([apply_Pair, rmap_fun_type] @ Rmap.intrs) 1)); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
diff
changeset
|
82 |
val rmap_Cons = result(); |