definition accessStorage :: "Types ==> Location ==> StorageT ==> Storagevalue" where "accessStorage t loc sto = (case sto $$ loc of Some v ==> v | None ==> ival t)"
declare accessStorage_def [solidity_symbex]
subsubsection‹Copy from storage to storage›
primrec copyRec :: "Location ==> Location ==> STypes ==> StorageT ==> StorageT option" where "copyRec ls ld (STArray x t) sto = iter' (λi s'. copyRec (hash ls (ShowLint i)) (hash ld (ShowLint i)) t s') sto x"
| "copyRec ls ld (STValue t) sto = (let e = accessStorage t ls sto in Some (fmupd ld e sto))"
| "copyRec _ _ (STMap _ _) _ = None"
definition copy :: "Location ==> Location ==> int ==> STypes ==> StorageT ==> StorageT option" where "copy ls ld x t sto = iter' (λi s'. copyRec (hash ls (ShowLint i)) (hash ld (ShowLint i)) t s') sto x"
primrec minitRec :: "Location ==> MTypes ==> MemoryT ==> MemoryT" where "minitRec loc (MTArray x t) = (λmem. let m = updateStore loc (MPointer loc) mem in iter (λi m' . minitRec (hash loc (ShowLint i)) t m') m x)"
| "minitRec loc (MTValue t) = updateStore loc (MValue (ival t))"
definition minit :: "int ==> MTypes ==> MemoryT ==> MemoryT" where "minit x t mem = (let l = ShowLnat (toploc mem); m = iter (λi m' . minitRec (hash l (ShowLint i)) t m') mem x in snd (allocate m))"
primrec cpm2mrec :: "Location ==> Location ==> MTypes ==> MemoryT ==> MemoryT ==> MemoryT option" where "cpm2mrec ls ld (MTArray x t) ms md = (case accessStore ls ms of Some (MPointer l) ==> (let m = updateStore ld (MPointer ld) md in iter' (λi m'. cpm2mrec (hash ls (ShowLint i)) (hash ld (ShowLint i)) t ms m') m x) | _ ==> None)"
| "cpm2mrec ls ld (MTValue t) ms md = (case accessStore ls ms of Some (MValue v) ==> Some (updateStore ld (MValue v) md) | _ ==> None)"
definition cpm2m :: "Location ==> Location ==> int ==> MTypes ==> MemoryT ==> MemoryT ==> MemoryT option" where "cpm2m ls ld x t ms md = iter' (λi m. cpm2mrec (hash ls (ShowLint i)) (hash ld (ShowLint i)) t ms m) md x"
declare cpm2m_def [solidity_symbex]
subsubsection‹Example›
lemma"cpm2m (STR ''0'') (STR ''0'') 2 (MTArray 2 (MTValue TBool)) mymemory (snd (allocate emptyStore)) = Some mymemory" by eval
primrec cps2mrec :: "Location ==> Location ==> STypes ==> StorageT ==> MemoryT ==>MemoryT option" where "cps2mrec locs locm (STArray x t) sto mem = (let m = updateStore locm (MPointer locm) mem in iter' (λi m'. cps2mrec (hash locs (ShowLint i)) (hash locm (ShowLint i)) t sto m') m x)"
| "cps2mrec locs locm (STValue t) sto mem = (let v = accessStorage t locs sto in Some (updateStore locm (MValue v) mem))"
| "cps2mrec _ _ (STMap _ _) _ _ = None"
definition cps2m :: "Location ==> Location ==> int ==> STypes ==> StorageT ==> MemoryT ==> MemoryT option" where "cps2m locs locm x t sto mem = iter' (λi m'. cps2mrec (hash locs (ShowLint i)) (hash locm (ShowLint i)) t sto m') mem x"
lemma"cps2m (STR ''1'') (STR ''0'') 2 (STArray 2 (STValue TBool)) mystorage3 (snd (allocate emptyStore)) = Some mymemory" by eval
subsection‹Copy from memory to storage›
subsubsection‹Definition›
primrec cpm2srec :: "Location ==> Location ==> MTypes ==> MemoryT ==> StorageT ==>StorageT option" where "cpm2srec locm locs (MTArray x t) mem sto = (case accessStore locm mem of Some (MPointer l) ==> iter' (λi s'. cpm2srec (hash locm (ShowLint i)) (hash locs (ShowLint i)) t mem s') sto x | _ ==> None)"
| "cpm2srec locm locs (MTValue t) mem sto = (case accessStore locm mem of Some (MValue v) ==> Some (fmupd locs v sto) | _ ==> None)"
definition cpm2s :: "Location ==> Location ==> int ==> MTypes ==> MemoryT ==> StorageT ==> StorageT option" where "cpm2s locm locs x t mem sto = iter' (λi s'. cpm2srec (hash locm (ShowLint i)) (hash locs (ShowLint i)) t mem s') sto x"
declare cpm2s_def [solidity_symbex]
subsubsection‹Example›
lemma"cpm2s (STR ''0'') (STR ''1'') 2 (MTArray 2 (MTValue TBool)) mymemory fmempty = Some mystorage3" by eval
declare copyRec.simps [simp del, solidity_symbex add] declare minitRec.simps [simp del, solidity_symbex add] declare cpm2mrec.simps [simp del, solidity_symbex add] declare cps2mrec.simps [simp del, solidity_symbex add] declare cpm2srec.simps [simp del, solidity_symbex add]
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.