src/HOL/Hoare/HeapSyntax.thy
author paulson <lp15@cam.ac.uk>
Thu, 26 Sep 2024 14:44:37 +0100
changeset 80948 572970d15ab0
parent 80914 d97fdabd9e2b
child 81189 47a0dfee26ea
permissions -rw-r--r--
To tiny but maybe useful lemmas (moved in from the AFP, Word_Lib)
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
    Author:     Tobias Nipkow
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     3
    Copyright   2002 TUM
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     4
*)
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
     5
72990
db8f94656024 tuned document, notably authors and sections;
wenzelm
parents: 35316
diff changeset
     6
section \<open>Heap syntax\<close>
db8f94656024 tuned document, notably authors and sections;
wenzelm
parents: 35316
diff changeset
     7
db8f94656024 tuned document, notably authors and sections;
wenzelm
parents: 35316
diff changeset
     8
theory HeapSyntax
db8f94656024 tuned document, notably authors and sections;
wenzelm
parents: 35316
diff changeset
     9
  imports Hoare_Logic Heap
db8f94656024 tuned document, notably authors and sections;
wenzelm
parents: 35316
diff changeset
    10
begin
13875
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    11
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    12
subsection "Field access and update"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    13
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    14
syntax
35101
6ce9177d6b38 modernized translations;
wenzelm
parents: 16417
diff changeset
    15
  "_refupdate" :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a ref \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> 'b)"
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 72990
diff changeset
    16
   (\<open>_/'((_ \<rightarrow> _)')\<close> [1000,0] 900)
35101
6ce9177d6b38 modernized translations;
wenzelm
parents: 16417
diff changeset
    17
  "_fassign"  :: "'a ref => id => 'v => 's com"
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 72990
diff changeset
    18
   (\<open>(2_^._ :=/ _)\<close> [70,1000,65] 61)
35101
6ce9177d6b38 modernized translations;
wenzelm
parents: 16417
diff changeset
    19
  "_faccess"  :: "'a ref => ('a ref \<Rightarrow> 'v) => 'v"
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 72990
diff changeset
    20
   (\<open>_^._\<close> [65,1000] 65)
13875
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    21
translations
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 35101
diff changeset
    22
  "f(r \<rightarrow> v)" == "f(CONST addr r := v)"
1a0c129bb2e0 modernized translations;
wenzelm
parents: 35101
diff changeset
    23
  "p^.f := e" => "f := f(p \<rightarrow> e)"
1a0c129bb2e0 modernized translations;
wenzelm
parents: 35101
diff changeset
    24
  "p^.f" => "f(CONST addr p)"
13875
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
declare fun_upd_apply[simp del] fun_upd_same[simp] fun_upd_other[simp]
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    28
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    29
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    30
text "An example due to Suzuki:"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    31
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    32
lemma "VARS v n
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    33
  {w = Ref w0 & x = Ref x0 & y = Ref y0 & z = Ref z0 &
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    34
   distinct[w0,x0,y0,z0]}
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    35
  w^.v := (1::int); w^.n := x;
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    36
  x^.v := 2; x^.n := y;
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    37
  y^.v := 3; y^.n := z;
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    38
  z^.v := 4; x^.n := z
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    39
  {w^.n^.n^.v = 4}"
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    40
by vcg_simp
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    41
12997e3ddd8d *** empty log message ***
nipkow
parents:
diff changeset
    42
end