src/HOL/Hoare/HeapSyntax.thy
author wenzelm
Sun, 11 Jul 2004 20:33:22 +0200
changeset 15032 02aed07e01bf
parent 13875 12997e3ddd8d
child 16417 9bc16273c2d4
permissions -rw-r--r--
local_cla/simpset_of;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13875
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Hoare/HeapSyntax.thy
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   2002 TUM
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     5
*)
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     6
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     7
theory HeapSyntax = Hoare + Heap:
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     8
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     9
subsection "Field access and update"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    10
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    11
syntax
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    12
  "@refupdate" :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a ref \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> 'b)"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    13
   ("_/'((_ \<rightarrow> _)')" [1000,0] 900)
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    14
  "@fassign"  :: "'a ref => id => 'v => 's com"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    15
   ("(2_^._ :=/ _)" [70,1000,65] 61)
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    16
  "@faccess"  :: "'a ref => ('a ref \<Rightarrow> 'v) => 'v"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    17
   ("_^._" [65,1000] 65)
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    18
translations
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    19
  "f(r \<rightarrow> v)"  ==  "f(addr r := v)"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    20
  "p^.f := e"  =>  "f := f(p \<rightarrow> e)"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    21
  "p^.f"       =>  "f(addr p)"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    22
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    23
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    24
declare fun_upd_apply[simp del] fun_upd_same[simp] fun_upd_other[simp]
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    25
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    26
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    27
text "An example due to Suzuki:"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    28
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    29
lemma "VARS v n
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    30
  {w = Ref w0 & x = Ref x0 & y = Ref y0 & z = Ref z0 &
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    31
   distinct[w0,x0,y0,z0]}
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    32
  w^.v := (1::int); w^.n := x;
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    33
  x^.v := 2; x^.n := y;
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    34
  y^.v := 3; y^.n := z;
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    35
  z^.v := 4; x^.n := z
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    36
  {w^.n^.n^.v = 4}"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    37
by vcg_simp
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    38
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    39
end