src/HOL/UNITY/Update.ML
author oheimb
Mon, 27 Apr 1998 19:29:19 +0200
changeset 4836 fc5773ae2790
parent 4776 1f9362e769c1
permissions -rw-r--r--
added option_map_eq_Some via AddIffs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Update.thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     5
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     6
Function updates: like the standard theory Map, but for ordinary functions
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     7
*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     8
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     9
open Update;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    10
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    11
goalw thy [update_def] "(f[x|->y] = f) = (f x = y)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    12
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
by (etac subst 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
by (rtac ext 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
by Auto_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
qed "update_idem_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    17
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    18
(* f x = y ==> f[x|->y] = f *)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    19
bind_thm("update_idem", update_idem_iff RS iffD2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    20
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
AddIffs [refl RS update_idem];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    22
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    23
goal thy "(f[x|->y])z = (if x=z then y else f z)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    24
by (simp_tac (simpset() addsimps [update_def]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
qed "update_apply";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
Addsimps [update_apply];