src/ZF/ex/Rmap.ML
author lcp
Tue Aug 16 18:58:42 1994 +0200 (1994-08-16)
changeset 532 851df239ac8b
parent 515 abcc438e7c27
child 694 c7d592f6312a
permissions -rw-r--r--
ZF/Makefile,ROOT.ML, ZF/ex/Integ.thy: updated for EquivClass
lcp@515
     1
(*  Title: 	ZF/ex/Rmap
lcp@16
     2
    ID:         $Id$
lcp@16
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
lcp@515
     4
    Copyright   1994  University of Cambridge
lcp@16
     5
lcp@16
     6
Inductive definition of an operator to "map" a relation over a list
lcp@16
     7
*)
lcp@16
     8
lcp@515
     9
open Rmap;
lcp@16
    10
lcp@515
    11
goalw Rmap.thy rmap.defs "!!r s. r<=s ==> rmap(r) <= rmap(s)";
lcp@16
    12
by (rtac lfp_mono 1);
lcp@515
    13
by (REPEAT (rtac rmap.bnd_mono 1));
lcp@16
    14
by (REPEAT (ares_tac ([Sigma_mono, list_mono, domain_mono, range_mono] @ 
lcp@16
    15
		      basic_monos) 1));
lcp@16
    16
val rmap_mono = result();
lcp@16
    17
lcp@16
    18
val rmap_induct = standard 
lcp@515
    19
    (rmap.mutual_induct RS spec RS spec RSN (2,rev_mp));
lcp@16
    20
lcp@515
    21
val Nil_rmap_case = rmap.mk_cases list.con_defs "<Nil,zs> : rmap(r)"
lcp@515
    22
and Cons_rmap_case = rmap.mk_cases list.con_defs "<Cons(x,xs),zs> : rmap(r)";
lcp@16
    23
lcp@515
    24
val rmap_cs = ZF_cs addIs  rmap.intrs
lcp@16
    25
		    addSEs [Nil_rmap_case, Cons_rmap_case];
lcp@16
    26
lcp@16
    27
goal Rmap.thy "!!r. r <= A*B ==> rmap(r) <= list(A)*list(B)";
lcp@515
    28
by (rtac (rmap.dom_subset RS subset_trans) 1);
lcp@16
    29
by (REPEAT (ares_tac [domain_rel_subset, range_rel_subset,
lcp@16
    30
		      Sigma_mono, list_mono] 1));
lcp@16
    31
val rmap_rel_type = result();
lcp@16
    32
lcp@16
    33
goal Rmap.thy
lcp@16
    34
    "!!r. [| ALL x:A. EX y. <x,y>: r;  xs: list(A) |] ==> \
lcp@16
    35
\         EX y. <xs, y> : rmap(r)";
lcp@515
    36
by (etac list.induct 1);
lcp@16
    37
by (ALLGOALS (fast_tac rmap_cs));
lcp@16
    38
val rmap_total = result();
lcp@16
    39
lcp@16
    40
goal Rmap.thy
lcp@16
    41
    "!!r. [| ALL x y z. <x,y>: r --> <x,z>: r --> y=z;    \
lcp@16
    42
\            <xs, ys> : rmap(r) |] ==>                    \
lcp@16
    43
\          ALL zs. <xs, zs> : rmap(r) --> ys=zs";
lcp@16
    44
by (etac rmap_induct 1);
lcp@16
    45
by (ALLGOALS (fast_tac rmap_cs));
lcp@16
    46
val rmap_functional_lemma = result();
lcp@16
    47
val rmap_functional = standard (rmap_functional_lemma RS spec RS mp);
lcp@16
    48
lcp@16
    49
(** If f is a function then rmap(f) behaves as expected. **)
lcp@16
    50
lcp@16
    51
goal Rmap.thy "!!f. f: A->B ==> rmap(f): list(A)->list(B)";
lcp@16
    52
by (etac PiE 1);
lcp@16
    53
by (rtac PiI 1);
lcp@16
    54
by (etac rmap_rel_type 1);
lcp@16
    55
by (rtac (rmap_total RS ex_ex1I) 1);
lcp@16
    56
by (assume_tac 2);
lcp@16
    57
by (fast_tac (ZF_cs addSEs [bspec RS ex1E]) 1);
lcp@16
    58
by (rtac rmap_functional 1);
lcp@16
    59
by (REPEAT (assume_tac 2));
lcp@16
    60
by (fast_tac (ZF_cs addSEs [bspec RS ex1_equalsE]) 1);
lcp@16
    61
val rmap_fun_type = result();
lcp@16
    62
lcp@16
    63
goalw Rmap.thy [apply_def] "rmap(f)`Nil = Nil";
lcp@16
    64
by (fast_tac (rmap_cs addIs [the_equality]) 1);
lcp@16
    65
val rmap_Nil = result();
lcp@16
    66
lcp@16
    67
goal Rmap.thy "!!f. [| f: A->B;  x: A;  xs: list(A) |] ==> \
lcp@16
    68
\                   rmap(f) ` Cons(x,xs) = Cons(f`x, rmap(f)`xs)";
lcp@16
    69
by (rtac apply_equality 1);
lcp@515
    70
by (REPEAT (ares_tac ([apply_Pair, rmap_fun_type] @ rmap.intrs) 1));
lcp@16
    71
val rmap_Cons = result();