src/ZF/Induct/Rmap.thy
author wenzelm
Thu, 23 Jul 2015 14:25:05 +0200
changeset 60770 240563fbf41d
parent 58871 c399ae4b836f
child 61798 27f3c10b0b50
permissions -rw-r--r--
isabelle update_cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
     1
(*  Title:      ZF/Induct/Rmap.thy
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     3
    Copyright   1994  University of Cambridge
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
     4
*)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     5
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
     6
section \<open>An operator to ``map'' a relation over a list\<close>
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 12610
diff changeset
     8
theory Rmap imports Main begin
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     9
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    10
consts
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    11
  rmap :: "i=>i"
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    12
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    13
inductive
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    14
  domains "rmap(r)" \<subseteq> "list(domain(r)) \<times> list(range(r))"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    15
  intros
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    16
    NilI:  "<Nil,Nil> \<in> rmap(r)"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    17
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    18
    ConsI: "[| <x,y>: r;  <xs,ys> \<in> rmap(r) |]
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    19
            ==> <Cons(x,xs), Cons(y,ys)> \<in> rmap(r)"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    20
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    21
  type_intros domainI rangeI list.intros
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    22
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    23
lemma rmap_mono: "r \<subseteq> s ==> rmap(r) \<subseteq> rmap(s)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    24
  apply (unfold rmap.defs)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    25
  apply (rule lfp_mono)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    26
    apply (rule rmap.bnd_mono)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    27
  apply (assumption | rule Sigma_mono list_mono domain_mono range_mono basic_monos)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    28
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    29
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    30
inductive_cases
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    31
      Nil_rmap_case [elim!]: "<Nil,zs> \<in> rmap(r)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    32
  and Cons_rmap_case [elim!]: "<Cons(x,xs),zs> \<in> rmap(r)"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    33
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    34
declare rmap.intros [intro]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    35
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    36
lemma rmap_rel_type: "r \<subseteq> A \<times> B ==> rmap(r) \<subseteq> list(A) \<times> list(B)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    37
  apply (rule rmap.dom_subset [THEN subset_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    38
  apply (assumption |
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    39
    rule domain_rel_subset range_rel_subset Sigma_mono list_mono)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    40
  done
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    41
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    42
lemma rmap_total: "A \<subseteq> domain(r) ==> list(A) \<subseteq> domain(rmap(r))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    43
  apply (rule subsetI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    44
  apply (erule list.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    45
   apply blast+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    46
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    47
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    48
lemma rmap_functional: "function(r) ==> function(rmap(r))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    49
  apply (unfold function_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    50
  apply (rule impI [THEN allI, THEN allI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    51
  apply (erule rmap.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    52
   apply blast+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    53
  done
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    54
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    55
text \<open>
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    56
  \medskip If @{text f} is a function then @{text "rmap(f)"} behaves
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    57
  as expected.
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    58
\<close>
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    59
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    60
lemma rmap_fun_type: "f \<in> A->B ==> rmap(f): list(A)->list(B)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    61
  by (simp add: Pi_iff rmap_rel_type rmap_functional rmap_total)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    62
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    63
lemma rmap_Nil: "rmap(f)`Nil = Nil"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    64
  by (unfold apply_def) blast
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    65
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    66
lemma rmap_Cons: "[| f \<in> A->B;  x \<in> A;  xs: list(A) |]
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    67
      ==> rmap(f) ` Cons(x,xs) = Cons(f`x, rmap(f)`xs)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    68
  by (blast intro: apply_equality apply_Pair rmap_fun_type rmap.intros)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    69
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    70
end