pila_(stack)
//--------------------------------------------//
// Especificacion Algebraica TAD Pila //
// Autor: Pablo Sanchez (p.sanchez@unican.es) //
// http://personales.unican.es/sanchezbp //
//--------------------------------------------//
espec Pila
usa Boolean, Natural
generos Stack(Element)como Stack
parametro
 generos Element como E
fparametro
operaciones
 emptyStack : -> Stack
 push : Stack E -> Stack
 parcial peek : Stack -> E
 parcial pop : Stack -> Stack
 isEmpty : Stack -> Boolean
 size : Stack -> Natural
vars
 s : Stack; x : Element;
precondiciones
 [isEmpty(s) != TRUE] pop(s), peek(s)
ecuaciones
 // Las generadoras son emptyStack y push(s,x) y son libres
 // Los patrones del tipo son:
 // - emptyStack
 // - push(s,x)
 size(emptyStack) = 0
 size(push(s,x)) = 1 + size(s)
 pop(push(s,x)) = s
 peek(push(s,x)) = x
 isEmpty(emptyStack) = TRUE
 isEmpty(push(s,x)) = FALSE
fespec