src/HOL/Hoare/HeapSyntax.thy
author hoelzl
Thu Sep 02 10:14:32 2010 +0200 (2010-09-02)
changeset 39072 1030b1a166ef
parent 35316 870dfea4f9c0
permissions -rw-r--r--
Add lessThan_Suc_eq_insert_0
nipkow@13875
     1
(*  Title:      HOL/Hoare/HeapSyntax.thy
nipkow@13875
     2
    Author:     Tobias Nipkow
nipkow@13875
     3
    Copyright   2002 TUM
nipkow@13875
     4
*)
nipkow@13875
     5
haftmann@35316
     6
theory HeapSyntax imports Hoare_Logic Heap begin
nipkow@13875
     7
nipkow@13875
     8
subsection "Field access and update"
nipkow@13875
     9
nipkow@13875
    10
syntax
wenzelm@35101
    11
  "_refupdate" :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a ref \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> 'b)"
nipkow@13875
    12
   ("_/'((_ \<rightarrow> _)')" [1000,0] 900)
wenzelm@35101
    13
  "_fassign"  :: "'a ref => id => 'v => 's com"
nipkow@13875
    14
   ("(2_^._ :=/ _)" [70,1000,65] 61)
wenzelm@35101
    15
  "_faccess"  :: "'a ref => ('a ref \<Rightarrow> 'v) => 'v"
nipkow@13875
    16
   ("_^._" [65,1000] 65)
nipkow@13875
    17
translations
wenzelm@35113
    18
  "f(r \<rightarrow> v)" == "f(CONST addr r := v)"
wenzelm@35113
    19
  "p^.f := e" => "f := f(p \<rightarrow> e)"
wenzelm@35113
    20
  "p^.f" => "f(CONST addr p)"
nipkow@13875
    21
nipkow@13875
    22
nipkow@13875
    23
declare fun_upd_apply[simp del] fun_upd_same[simp] fun_upd_other[simp]
nipkow@13875
    24
nipkow@13875
    25
nipkow@13875
    26
text "An example due to Suzuki:"
nipkow@13875
    27
nipkow@13875
    28
lemma "VARS v n
nipkow@13875
    29
  {w = Ref w0 & x = Ref x0 & y = Ref y0 & z = Ref z0 &
nipkow@13875
    30
   distinct[w0,x0,y0,z0]}
nipkow@13875
    31
  w^.v := (1::int); w^.n := x;
nipkow@13875
    32
  x^.v := 2; x^.n := y;
nipkow@13875
    33
  y^.v := 3; y^.n := z;
nipkow@13875
    34
  z^.v := 4; x^.n := z
nipkow@13875
    35
  {w^.n^.n^.v = 4}"
nipkow@13875
    36
by vcg_simp
nipkow@13875
    37
nipkow@13875
    38
end