5157
|
1 |
(* Title: ZF/Update.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1998 University of Cambridge
|
|
5 |
|
|
6 |
Function updates: like theory Map, but for ordinary functions
|
|
7 |
*)
|
|
8 |
|
13177
|
9 |
theory Update = func:
|
5157
|
10 |
|
13177
|
11 |
constdefs
|
5157
|
12 |
update :: "[i,i,i] => i"
|
13177
|
13 |
"update(f,a,b) == lam x: cons(a, domain(f)). if(x=a, b, f`x)"
|
5157
|
14 |
|
|
15 |
nonterminals
|
|
16 |
updbinds updbind
|
|
17 |
|
|
18 |
syntax
|
|
19 |
|
|
20 |
(* Let expressions *)
|
|
21 |
|
13177
|
22 |
"_updbind" :: "[i, i] => updbind" ("(2_ :=/ _)")
|
|
23 |
"" :: "updbind => updbinds" ("_")
|
|
24 |
"_updbinds" :: "[updbind, updbinds] => updbinds" ("_,/ _")
|
|
25 |
"_Update" :: "[i, updbinds] => i" ("_/'((_)')" [900,0] 900)
|
5157
|
26 |
|
|
27 |
translations
|
|
28 |
"_Update (f, _updbinds(b,bs))" == "_Update (_Update(f,b), bs)"
|
13177
|
29 |
"f(x:=y)" == "update(f,x,y)"
|
|
30 |
|
|
31 |
|
|
32 |
lemma update_apply [simp]: "f(x:=y) ` z = (if z=x then y else f`z)"
|
|
33 |
apply (simp add: update_def)
|
|
34 |
apply (rule_tac P="z \<in> domain(f)" in case_split_thm)
|
|
35 |
apply (simp_all add: apply_0)
|
|
36 |
done
|
|
37 |
|
|
38 |
lemma update_idem: "[| f`x = y; f: Pi(A,B); x: A |] ==> f(x:=y) = f"
|
|
39 |
apply (unfold update_def)
|
|
40 |
apply (simp add: domain_of_fun cons_absorb)
|
|
41 |
apply (rule fun_extension)
|
|
42 |
apply (best intro: apply_type if_type lam_type, assumption)
|
|
43 |
apply simp
|
|
44 |
done
|
|
45 |
|
5157
|
46 |
|
13177
|
47 |
(* [| f: Pi(A, B); x:A |] ==> f(x := f`x) = f *)
|
|
48 |
declare refl [THEN update_idem, simp]
|
|
49 |
|
|
50 |
lemma domain_update [simp]: "domain(f(x:=y)) = cons(x, domain(f))"
|
|
51 |
by (unfold update_def, simp)
|
|
52 |
|
|
53 |
lemma update_type: "[| f: A -> B; x : A; y: B |] ==> f(x:=y) : A -> B"
|
|
54 |
apply (unfold update_def)
|
|
55 |
apply (simp add: domain_of_fun cons_absorb apply_funtype lam_type)
|
|
56 |
done
|
|
57 |
|
|
58 |
ML
|
|
59 |
{*
|
|
60 |
val update_def = thm "update_def";
|
|
61 |
val update_apply = thm "update_apply";
|
|
62 |
val update_idem = thm "update_idem";
|
|
63 |
val domain_update = thm "domain_update";
|
|
64 |
val update_type = thm "update_type";
|
|
65 |
*}
|
|
66 |
|
5157
|
67 |
|
|
68 |
end
|