stack.gas - An algebraic specification of a stack. | Lecture 13 - slide 4 : 32 Program 1 |
Type stack [int] declare constructors new () -> stack; push (int, stack) -> stack; destructors pop (stack) -> stack; selectors top (stack) -> int; isnew (stack) -> bool; for all i in int; s in stack; let pop (new()) = error; pop (push (i,s)) = s; top (new()) = error; top (push (i,s)) = i; isnew (new()) = true; isnew (push(i,s)) = false; end end stack.