thys/FMap.thy
author ibm-PC\ibm <xingyuanzhang@126.com>
Fri, 12 Sep 2014 00:47:15 +0800
changeset 24 77daf1b85cf0
parent 20 e04123f4bacc
permissions -rw-r--r--
new change
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
theory FMap
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
  imports Main "~~/src/HOL/Quotient_Examples/FSet" "~~/src/HOL/Library/DAList"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
begin
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
subsubsection {* The type of finite maps *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
typedef ('a, 'b) fmap  (infixr "f\<rightharpoonup>" 1) = "{x :: 'a \<rightharpoonup> 'b. finite (dom x) }"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
  proof show "empty \<in> {x. finite (dom x)}" by simp qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
setup_lifting type_definition_fmap
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
lift_definition fdom :: "'key f\<rightharpoonup> 'value \<Rightarrow> 'key set" is "dom" ..
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
lift_definition fran :: "'key f\<rightharpoonup> 'value \<Rightarrow> 'value set" is "ran" ..
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
lift_definition lookup :: "'key f\<rightharpoonup> 'value \<Rightarrow> 'key \<Rightarrow> 'value option" is "(\<lambda> x. x)" ..
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
    18
notation lookup (infixl "$" 999)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
    19
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
abbreviation the_lookup (infix "f!" 55)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
  where "m f! x \<equiv> the (lookup m x)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
lift_definition fempty :: "'key f\<rightharpoonup> 'value" ("f\<emptyset>") is Map.empty by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
lemma fempty_fdom[simp]: "fdom f\<emptyset> = {}"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
    28
lemma fdomIff: "a \<in> fdom m \<longleftrightarrow> lookup m a \<noteq> None"
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
 by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
lemma lookup_not_fdom: "x \<notin> fdom m \<Longrightarrow> lookup m x = None"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
  by (auto iff:fdomIff)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
lemma finite_range:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
  assumes "finite (dom m)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
  shows "finite (ran m)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
  apply (rule finite_subset[OF _ finite_imageI[OF assms, of "\<lambda> x . the (m x)"]])
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
  by (auto simp add: ran_def dom_def image_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
lemma finite_fdom[simp]: "finite (fdom m)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
  by transfer
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
lemma finite_fran[simp]: "finite (fran m)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
  by (transfer, rule finite_range)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
lemma fmap_eqI[intro]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
  assumes "fdom a = fdom b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
  and "\<And> x. x \<in> fdom a \<Longrightarrow> a f! x = b f! x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
  shows "a = b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
using assms
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
proof(transfer)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
  fix a b :: "'a \<rightharpoonup> 'b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
  assume d: "dom a = dom b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
  assume eq: "\<And> x. x \<in> dom a \<Longrightarrow> the (a x) = the (b x)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
  show "a = b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
  proof
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
    fix x
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
    show "a x = b x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
    proof(cases "a x")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
    case None
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
      hence "x \<notin> dom a" by (simp add: dom_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
      hence "x \<notin> dom b" using d by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
      hence " b x = None"  by (simp add: dom_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
      thus ?thesis using None by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
    next
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
    case (Some y)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
      hence d': "x \<in> dom ( a)" by (simp add: dom_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
      hence "the ( a x) = the ( b x)" using eq by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
      moreover
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
      have "x \<in> dom ( b)" using Some d' d by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
      then obtain y' where " b x = Some y'" by (auto simp add: dom_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
      ultimately
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
      show " a x =  b x" using Some by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
    qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
  qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
subsubsection {* Updates *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
lift_definition
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
  fmap_upd :: "'key f\<rightharpoonup> 'value \<Rightarrow> 'key \<Rightarrow> 'value \<Rightarrow> 'key f\<rightharpoonup> 'value" ("_'(_ f\<mapsto> _')" [900,900]900)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
  is "\<lambda> m x v. m( x \<mapsto> v)"  by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
lemma fmap_upd_fdom[simp]: "fdom (h (x f\<mapsto> v)) = insert x (fdom h)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
lemma the_lookup_fmap_upd[simp]: "lookup (h (x f\<mapsto> v)) x = Some v"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
lemma the_lookup_fmap_upd_other[simp]: "x' \<noteq> x \<Longrightarrow> lookup (h (x f\<mapsto> v)) x' = lookup h x'"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
lemma fmap_upd_overwrite[simp]: "f (x f\<mapsto> y) (x f\<mapsto> z) = f (x f\<mapsto> z)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
  by (transfer, auto) 
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
lemma fmap_upd_twist: "a \<noteq> c \<Longrightarrow> (m(a f\<mapsto> b))(c f\<mapsto> d) = (m(c f\<mapsto> d))(a f\<mapsto> b)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
  apply (rule fmap_eqI)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
  apply auto[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
  apply (case_tac "x = a", auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
  apply (case_tac "x = c", auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
  done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
subsubsection {* Restriction *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
lift_definition fmap_restr :: "'a set \<Rightarrow> 'a f\<rightharpoonup> 'b \<Rightarrow> 'a f\<rightharpoonup> 'b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
  is "\<lambda> S m. (if finite S then (restrict_map m S) else empty)" by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
lemma lookup_fmap_restr[simp]: "finite S \<Longrightarrow> x \<in> S \<Longrightarrow> lookup (fmap_restr S m) x = lookup m x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
lemma fdom_fmap_restr[simp]: "finite S \<Longrightarrow> fdom (fmap_restr S m) = fdom m \<inter> S"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
  by (transfer, simp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
lemma fmap_restr_fmap_restr[simp]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
 "finite d1 \<Longrightarrow> finite d2 \<Longrightarrow> fmap_restr d1 (fmap_restr d2 x) = fmap_restr (d1 \<inter> d2) x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
 by (transfer, auto simp add: restrict_map_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
lemma fmap_restr_fmap_restr_subset:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
 "finite d2 \<Longrightarrow> d1 \<subseteq> d2 \<Longrightarrow> fmap_restr d1 (fmap_restr d2 x) = fmap_restr d1 x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
 by (metis Int_absorb2 finite_subset fmap_restr_fmap_restr)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
lemma fmap_restr_useless: "finite S \<Longrightarrow> fdom m \<subseteq> S \<Longrightarrow> fmap_restr S m = m"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
  by (rule fmap_eqI, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
lemma fmap_restr_not_finite:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
  "\<not> finite S \<Longrightarrow> fmap_restr S \<rho> = f\<emptyset>"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
  by (transfer, simp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
lemma fmap_restr_fmap_upd: "x \<in> S \<Longrightarrow> finite S \<Longrightarrow> fmap_restr S (m1(x f\<mapsto> v)) = (fmap_restr S m1)(x f\<mapsto> v)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
  apply (rule fmap_eqI)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
  apply auto[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
  apply (case_tac "xa = x")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
  apply auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
  done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
subsubsection {* Deleting *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
lift_definition fmap_delete :: "'a \<Rightarrow> 'a f\<rightharpoonup> 'b \<Rightarrow> 'a f\<rightharpoonup> 'b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
  is "\<lambda> x m. m(x := None)" by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
lemma fdom_fmap_delete[simp]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
  "fdom (fmap_delete x m) = fdom m - {x}"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
lemma fmap_delete_fmap_upd[simp]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
  "fmap_delete x (m(x f\<mapsto> v)) = fmap_delete x m"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
  by (transfer, simp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
lemma fmap_delete_noop:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
  "x \<notin> fdom m \<Longrightarrow> fmap_delete x m = m"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
lemma fmap_upd_fmap_delete[simp]: "x \<in> fdom \<Gamma> \<Longrightarrow> (fmap_delete x \<Gamma>)(x f\<mapsto> \<Gamma> f! x) = \<Gamma>"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
lemma fran_fmap_upd[simp]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
  "fran (m(x f\<mapsto> v)) = insert v (fran (fmap_delete x m))"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
by (transfer, auto simp add: ran_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
 
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
subsubsection {* Addition (merging) of finite maps *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
lift_definition fmap_add :: "'a f\<rightharpoonup> 'b \<Rightarrow> 'a f\<rightharpoonup> 'b \<Rightarrow> 'a f\<rightharpoonup> 'b" (infixl "f++" 100) 
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
  is "map_add" by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
lemma fdom_fmap_add[simp]: "fdom (m1 f++ m2) = fdom m1 \<union> fdom m2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
lemma lookup_fmap_add1[simp]: "x \<in> fdom m2 \<Longrightarrow> lookup (m1 f++ m2) x = lookup m2 x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
lemma lookup_fmap_add2[simp]:  "x \<notin> fdom m2 \<Longrightarrow> lookup (m1 f++ m2) x = lookup m1 x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
  apply transfer
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
  by (metis map_add_dom_app_simps(3))
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
lemma [simp]: "\<rho> f++ f\<emptyset> = \<rho>"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
lemma fmap_add_overwrite: "fdom m1 \<subseteq> fdom m2 \<Longrightarrow> m1 f++ m2 = m2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
  apply transfer
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
  apply rule
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
  apply (case_tac "x \<in> dom m2")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
  apply (auto simp add: map_add_dom_app_simps(1))
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
  done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
lemma fmap_add_upd_swap: 
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
  "x \<notin> fdom \<rho>' \<Longrightarrow> \<rho>(x f\<mapsto> z) f++ \<rho>' = (\<rho> f++ \<rho>')(x f\<mapsto> z)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
  apply transfer
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
  by (metis map_add_upd_left)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
lemma fmap_add_upd: 
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
  "\<rho> f++ (\<rho>'(x f\<mapsto> z)) = (\<rho> f++ \<rho>')(x f\<mapsto> z)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
  apply transfer
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
  by (metis map_add_upd)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
lemma fmap_restr_add: "fmap_restr S (m1 f++ m2) = fmap_restr S m1 f++ fmap_restr S m2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
  apply (cases "finite S")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
  apply (rule fmap_eqI)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
  apply auto[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
  apply (case_tac "x \<in> fdom m2")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
  apply auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
  apply (simp add: fmap_restr_not_finite)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
  done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
subsubsection {* Conversion from associative lists *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
lift_definition fmap_of :: "('a \<times> 'b) list \<Rightarrow> 'a f\<rightharpoonup> 'b"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
  is map_of by (rule finite_dom_map_of)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
lemma fmap_of_Nil[simp]: "fmap_of [] = f\<emptyset>"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
 by (transfer, simp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
lemma fmap_of_Cons[simp]: "fmap_of (p # l) = (fmap_of l)(fst p f\<mapsto> snd p)" 
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
  by (transfer, simp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
lemma fmap_of_append[simp]: "fmap_of (l1 @ l2) = fmap_of l2 f++ fmap_of l1"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
  by (transfer, simp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
lemma lookup_fmap_of[simp]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
  "lookup (fmap_of m) x = map_of m x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
lemma fmap_delete_fmap_of[simp]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
  "fmap_delete x (fmap_of m) = fmap_of (AList.delete x m)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
  by (transfer, metis delete_conv')
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
subsubsection {* Less-than-relation for extending finite maps *}
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
instantiation fmap :: (type,type) order
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
begin
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
  definition "\<rho> \<le> \<rho>' = ((fdom \<rho> \<subseteq> fdom \<rho>') \<and> (\<forall>x \<in> fdom \<rho>. lookup \<rho> x = lookup \<rho>' x))"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
  definition "(\<rho>::'a f\<rightharpoonup> 'b) < \<rho>' = (\<rho> \<noteq> \<rho>' \<and> \<rho> \<le> \<rho>')"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
  lemma fmap_less_eqI[intro]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
    assumes assm1: "fdom \<rho> \<subseteq> fdom \<rho>'"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
      and assm2:  "\<And> x. \<lbrakk> x \<in> fdom \<rho> ; x \<in> fdom \<rho>'  \<rbrakk> \<Longrightarrow> \<rho> f! x = \<rho>' f! x "
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   236
     shows "\<rho> \<le> \<rho>'"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
   unfolding less_eq_fmap_def
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
   apply rule
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
   apply fact
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
   apply rule+
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
   apply (frule subsetD[OF `_ \<subseteq> _`])
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
   apply (frule  assm2)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   243
   apply (auto iff: fdomIff)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   244
   done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
  
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
  lemma fmap_less_eqD:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   247
    assumes "\<rho> \<le> \<rho>'"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
    assumes "x \<in> fdom \<rho>"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
    shows "lookup \<rho> x = lookup \<rho>' x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
    using assms
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
    unfolding less_eq_fmap_def by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
  
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
  lemma fmap_antisym: assumes  "(x:: 'a f\<rightharpoonup> 'b) \<le> y" and "y \<le> x" shows "x = y "
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
  proof(rule fmap_eqI[rule_format])
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
      show "fdom x = fdom y" using `x \<le> y` and `y \<le> x` unfolding less_eq_fmap_def by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
      
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
      fix v
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
      assume "v \<in> fdom x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
      hence "v \<in> fdom y" using `fdom _ = _` by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
  
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261
      thus "x f! v = y f! v"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
        using `x \<le> y` `v \<in> fdom x` unfolding less_eq_fmap_def by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   263
    qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
  
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
  lemma fmap_trans: assumes  "(x:: 'a f\<rightharpoonup> 'b) \<le> y" and "y \<le> z" shows "x \<le> z"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
  proof
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
    show "fdom x \<subseteq> fdom z" using `x \<le> y` and `y \<le> z` unfolding less_eq_fmap_def
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
      by -(rule order_trans [of _ "fdom y"], auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
    
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
    fix v
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   271
    assume "v \<in> fdom x" and "v \<in> fdom z"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
    hence "v \<in> fdom y" using `x \<le> y`  unfolding less_eq_fmap_def by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
    hence "lookup y v = lookup x v"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
      using `x \<le> y` `v \<in> fdom x` unfolding less_eq_fmap_def by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
    moreover
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
    have "lookup y v = lookup z v"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
      by (rule fmap_less_eqD[OF `y \<le> z`  `v \<in> fdom y`])
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
    ultimately
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
    show "x f! v = z f! v" by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
  qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
  
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
  instance
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
    apply default
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
    using fmap_antisym apply (auto simp add: less_fmap_def)[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
    apply (auto simp add: less_eq_fmap_def)[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
    using fmap_trans apply assumption
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
    using fmap_antisym apply assumption
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
    done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
end
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
lemma fmap_less_fdom:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
  "\<rho>1 \<le> \<rho>2 \<Longrightarrow> fdom \<rho>1 \<subseteq> fdom \<rho>2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
  by (metis less_eq_fmap_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
lemma fmap_less_restrict:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
  "\<rho>1 \<le> \<rho>2 \<longleftrightarrow> \<rho>1 = fmap_restr (fdom \<rho>1) \<rho>2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
  unfolding less_eq_fmap_def
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
  apply transfer
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
  apply (auto simp add:restrict_map_def split:option.split_asm)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
  by (metis option.simps(3))+
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
lemma fmap_restr_less:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
  "fmap_restr S \<rho> \<le> \<rho>"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
  unfolding less_eq_fmap_def
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
  by (transfer, auto)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
lemma fmap_upd_less[simp, intro]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
  "\<rho>1 \<le> \<rho>2 \<Longrightarrow> v1 = v2 \<Longrightarrow> \<rho>1(x f\<mapsto> v1) \<le> \<rho>2(x f\<mapsto> v2)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
  apply (rule fmap_less_eqI)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
  apply (auto dest: fmap_less_fdom)[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
  apply (case_tac "xa = x")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   312
  apply (auto dest: fmap_less_eqD)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
  done
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   314
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   315
lemma fmap_update_less[simp, intro]:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
  "\<rho>1 \<le> \<rho>1' \<Longrightarrow> \<rho>2 \<le> \<rho>2' \<Longrightarrow>  (fdom \<rho>2' - fdom \<rho>2) \<inter> fdom \<rho>1 = {} \<Longrightarrow> \<rho>1 f++ \<rho>2 \<le> \<rho>1' f++ \<rho>2'"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
  apply (rule fmap_less_eqI)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
  apply (auto dest: fmap_less_fdom)[1]
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   319
  apply (case_tac "x \<in> fdom \<rho>2")
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   320
  apply (auto dest: fmap_less_eqD fmap_less_fdom)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   321
  apply (metis fmap_less_eqD fmap_less_fdom lookup_fmap_add1 set_mp)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   322
  by (metis Diff_iff Diff_triv fmap_less_eqD lookup_fmap_add2)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
lemma fmap_restr_le:
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
  assumes "\<rho>1 \<le> \<rho>2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   326
  assumes "S1 \<subseteq> S2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
  assumes [simp]:"finite S2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   328
  shows "fmap_restr S1 \<rho>1 \<le> fmap_restr S2 \<rho>2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   329
proof-
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   330
  have [simp]: "finite S1"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
    by (rule finite_subset[OF `S1 \<subseteq> S2` `finite S2`])
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   332
  show ?thesis
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   333
  proof (rule fmap_less_eqI)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   334
    have "fdom \<rho>1 \<subseteq> fdom \<rho>2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
      by (metis assms(1) less_eq_fmap_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
    thus "fdom (fmap_restr S1 \<rho>1) \<subseteq> fdom (fmap_restr S2 \<rho>2)"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
      using `S1 \<subseteq> S2`
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
      by auto
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
  next
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
    fix x
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   341
    assume "x \<in> fdom (fmap_restr S1 \<rho>1) "
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   342
    hence [simp]:"x \<in> fdom \<rho>1" and [simp]:"x \<in> S1" and [simp]: "x \<in> S2"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
      by (auto intro: set_mp[OF `S1 \<subseteq> S2`])
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   344
    have "\<rho>1 f! x = \<rho>2 f! x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
      by (metis `x \<in> fdom \<rho>1` assms(1) less_eq_fmap_def)
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
    thus "(fmap_restr S1 \<rho>1) f! x = (fmap_restr S2 \<rho>2) f! x"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
      by simp
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   348
  qed
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   349
qed
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   350
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   351
fun alookup
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   352
where
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   353
  "alookup k [] = None"
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   354
| "alookup k ((x, y) # xs) = (if (k = x) then Some y else alookup k xs)"
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   355
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   356
  
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   357
definition fdom_to_list :: "('a :: linorder) f\<rightharpoonup> 'b \<Rightarrow> 'a list"
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   358
where
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   359
  "fdom_to_list f = (THE xs. set xs = fdom f \<and> sorted xs \<and> distinct xs)"
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   360
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   361
lemma
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   362
  "fdom f = set (fdom_to_list f)"
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   363
unfolding fdom_to_list_def
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   364
apply(subgoal_tac "finite (fdom f)")
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   365
apply(drule finite_sorted_distinct_unique)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   366
apply(drule theI')
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   367
apply(simp_all)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   368
done
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   369
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   370
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   371
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
definition fmap_to_alist :: "('a :: linorder) f\<rightharpoonup> 'b \<Rightarrow> ('a \<times> 'b) list"
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   373
where
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   374
  "fmap_to_alist f = [(x, f f! x). x \<leftarrow> fdom_to_list f]"
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   375
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   376
lemma
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   377
  shows "(f $ k) = alookup k (fmap_to_alist f)" 
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   378
thm finite_dom_map_of
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   379
20
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   380
apply(transfer)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   381
apply(simp add: fmap_to_alist_def)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   382
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   383
thm lookup_def
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   384
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   385
apply(rule theI2)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   386
apply(induct k xs\<equiv>"fmap_to_alist f" rule: alookup.induct)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   387
apply(simp add: fmap_to_alist_def fmapdom_to_list_def)
e04123f4bacc soem more work
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 19
diff changeset
   388
thm theD1
19
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   389
087d82632852 added FMap theory and adapted tm-theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   390
end