Skip to content
Snippets Groups Projects
Commit 2bd38bc3 authored by Ali Sinan Köksal's avatar Ali Sinan Köksal
Browse files

abstract memory example from Alloy

parent ee21fa1e
No related branches found
No related tags found
No related merge requests found
import funcheck.Utils._
import funcheck.Annotations._
import cp.Definitions._
@spec object AbstractMemory {
// - our maps are already ``canonicalized''
def init(): Map[Int,Int] = {
Map.empty[Int,Int]
}
def write(memory: Map[Int,Int], address: Int, data: Int): Map[Int,Int] = {
memory.updated(address, data)
}
def read(memory: Map[Int,Int], address: Int): Int = {
require(memory.isDefinedAt(address))
memory(address)
}
def writeRead(m: Map[Int,Int], a: Int, d: Int): Boolean = {
(m.updated(a, d))(a) == d
} holds
def writeIdempotent(m: Map[Int,Int], a: Int, d: Int): Boolean = {
val m2 = m.updated(a, d)
val m3 = m2.updated(a, d)
m2 == m3
} holds
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment