src/HOL/Hoare/SepLogHeap.thy
changeset 38353 d98baa2cf589
parent 35416 d8d7d1b785af
child 41959 b460124855b8
equal deleted inserted replaced
38352:4c8bcb826e83 38353:d98baa2cf589
     1 (*  Title:      HOL/Hoare/Heap.thy
     1 (*  Title:      HOL/Hoare/Heap.thy
     2     ID:         $Id$
       
     3     Author:     Tobias Nipkow
     2     Author:     Tobias Nipkow
     4     Copyright   2002 TUM
     3     Copyright   2002 TUM
     5 
     4 
     6 Heap abstractions (at the moment only Path and List)
     5 Heap abstractions (at the moment only Path and List)
     7 for Separation Logic.
     6 for Separation Logic.
    16 text{* @{text "Some"} means allocated, @{text "None"} means
    15 text{* @{text "Some"} means allocated, @{text "None"} means
    17 free. Address @{text "0"} serves as the null reference. *}
    16 free. Address @{text "0"} serves as the null reference. *}
    18 
    17 
    19 subsection "Paths in the heap"
    18 subsection "Paths in the heap"
    20 
    19 
    21 consts
    20 primrec Path :: "heap \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> nat \<Rightarrow> bool"
    22  Path :: "heap \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> nat \<Rightarrow> bool"
    21 where
    23 primrec
    22   "Path h x [] y = (x = y)"
    24 "Path h x [] y = (x = y)"
    23 | "Path h x (a#as) y = (x\<noteq>0 \<and> a=x \<and> (\<exists>b. h x = Some b \<and> Path h b as y))"
    25 "Path h x (a#as) y = (x\<noteq>0 \<and> a=x \<and> (\<exists>b. h x = Some b \<and> Path h b as y))"
       
    26 
    24 
    27 lemma [iff]: "Path h 0 xs y = (xs = [] \<and> y = 0)"
    25 lemma [iff]: "Path h 0 xs y = (xs = [] \<and> y = 0)"
    28 by (cases xs) simp_all
    26 by (cases xs) simp_all
    29 
    27 
    30 lemma [simp]: "x\<noteq>0 \<Longrightarrow> Path h x as z =
    28 lemma [simp]: "x\<noteq>0 \<Longrightarrow> Path h x as z =
    39 by (induct as) simp_all
    37 by (induct as) simp_all
    40 
    38 
    41 
    39 
    42 subsection "Lists on the heap"
    40 subsection "Lists on the heap"
    43 
    41 
    44 definition List :: "heap \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> bool" where
    42 definition List :: "heap \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> bool"
    45 "List h x as == Path h x as 0"
    43   where "List h x as = Path h x as 0"
    46 
    44 
    47 lemma [simp]: "List h x [] = (x = 0)"
    45 lemma [simp]: "List h x [] = (x = 0)"
    48 by (simp add: List_def)
    46 by (simp add: List_def)
    49 
    47 
    50 lemma [simp]:
    48 lemma [simp]: