src/ZF/Update.thy
author berghofe
Thu, 11 Jul 2002 16:57:14 +0200
changeset 13349 7d4441c8c46a
parent 13269 3ba9be497c33
permissions -rw-r--r--
Added "using" to the beginning of original newman proof again, because it was lost during last update; renamed second version of newman to newman' (this allows for a comparison of the primitive proof objects, for example).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     1
(*  Title:      ZF/Update.thy
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     2
    ID:         $Id$
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     5
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     6
Function updates: like theory Map, but for ordinary functions
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     7
*)
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
     8
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
     9
theory Update = func:
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    10
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    11
constdefs
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    12
  update  :: "[i,i,i] => i"
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    13
   "update(f,a,b) == lam x: cons(a, domain(f)). if(x=a, b, f`x)"
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    14
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    15
nonterminals
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    16
  updbinds  updbind
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    17
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    18
syntax
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    19
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    20
  (* Let expressions *)
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    21
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    22
  "_updbind"    :: "[i, i] => updbind"               ("(2_ :=/ _)")
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    23
  ""            :: "updbind => updbinds"             ("_")
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    24
  "_updbinds"   :: "[updbind, updbinds] => updbinds" ("_,/ _")
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    25
  "_Update"     :: "[i, updbinds] => i"              ("_/'((_)')" [900,0] 900)
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    26
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    27
translations
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    28
  "_Update (f, _updbinds(b,bs))"  == "_Update (_Update(f,b), bs)"
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    29
  "f(x:=y)"                       == "update(f,x,y)"
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    30
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    31
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    32
lemma update_apply [simp]: "f(x:=y) ` z = (if z=x then y else f`z)"
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    33
apply (simp add: update_def)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    34
apply (rule_tac P="z \<in> domain(f)" in case_split_thm)   
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    35
apply (simp_all add: apply_0)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    36
done
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    37
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    38
lemma update_idem: "[| f`x = y;  f: Pi(A,B);  x: A |] ==> f(x:=y) = f"
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    39
apply (unfold update_def)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    40
apply (simp add: domain_of_fun cons_absorb)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    41
apply (rule fun_extension)
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13177
diff changeset
    42
apply (best intro: apply_type if_type lam_type, assumption, simp)
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    43
done
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    44
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    45
13177
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    46
(* [| f: Pi(A, B); x:A |] ==> f(x := f`x) = f *)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    47
declare refl [THEN update_idem, simp]
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    48
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    49
lemma domain_update [simp]: "domain(f(x:=y)) = cons(x, domain(f))"
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    50
by (unfold update_def, simp)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    51
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    52
lemma update_type: "[| f: A -> B;  x : A;  y: B |] ==> f(x:=y) : A -> B"
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    53
apply (unfold update_def)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    54
apply (simp add: domain_of_fun cons_absorb apply_funtype lam_type)
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    55
done
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    56
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    57
ML
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    58
{*
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    59
val update_def = thm "update_def";
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    60
val update_apply = thm "update_apply";
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    61
val update_idem = thm "update_idem";
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    62
val domain_update = thm "domain_update";
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    63
val update_type = thm "update_type";
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    64
*}
ba734cc2887d converted Update to Isar
paulson
parents: 5157
diff changeset
    65
5157
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    66
6e03de8ec2b4 as in HOL
paulson
parents:
diff changeset
    67
end