src/HOL/Imperative_HOL/Ref.thy
changeset 37792 ba0bc31b90d7
parent 37787 30dc3abf4a58
child 37797 96551d6b1414
equal deleted inserted replaced
37791:0d6b64060543 37792:ba0bc31b90d7
    46 
    46 
    47 definition update :: "'a ref \<Rightarrow> 'a\<Colon>heap \<Rightarrow> unit Heap" ("_ := _" 62) where
    47 definition update :: "'a ref \<Rightarrow> 'a\<Colon>heap \<Rightarrow> unit Heap" ("_ := _" 62) where
    48   [code del]: "update r v = Heap_Monad.heap (\<lambda>h. ((), set r v h))"
    48   [code del]: "update r v = Heap_Monad.heap (\<lambda>h. ((), set r v h))"
    49 
    49 
    50 definition change :: "('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a ref \<Rightarrow> 'a Heap" where
    50 definition change :: "('a\<Colon>heap \<Rightarrow> 'a) \<Rightarrow> 'a ref \<Rightarrow> 'a Heap" where
    51   "change f r = (do
    51   "change f r = do {
    52      x \<leftarrow> ! r;
    52      x \<leftarrow> ! r;
    53      let y = f x;
    53      let y = f x;
    54      r := y;
    54      r := y;
    55      return y
    55      return y
    56    done)"
    56    }"
    57 
    57 
    58 
    58 
    59 subsection {* Properties *}
    59 subsection {* Properties *}
    60 
    60 
    61 text {* Primitives *}
    61 text {* Primitives *}