Docsity

Proof of Correctness for Stack ADT in COP 5021 Lecture Notes, Study notes of Computer Science

Toggle sidebar
bg1
Dr. Ferucio Laurent¸iu T¸ IPLEA
Visiting Professor
School of Computer Science
University of Central Florida
CSB #205
Orlando, FL 32816-2362
Tel: (407) 823-1593
COP 5021 (Program Analysis)
This is the correctness proof for the specification Stack in Lecture Notes #4.
Correctness. We will prove that Ais a member of ADT (Stack), that is, Ais
isomorphic to TΣ/=E.
The first step is to show that Ais a model of the set Eof equations in the
specification:
¯γstack(pop(estack)) = popA(estackA)
=P op(λ)
=λ
=estackA
= ¯γstack(estack)
and ¯γstack(pop(push(x, y))) = popA(pushA(γstack (x), γalph(y)))
=P op(P ush(γstack(x), γalph (y)))
=P op(γstack(x)γalph (y))
=γstack(x)
= ¯γstack(x).
Therefore, Ais a model of the set Eof equations of the specification.
Define now the function f:TΣ/=E→Asuch that the diagram in Figure 1 is
commutative, that is,
fs([t]=E,s ) = evalA,s (t),
for any sort sand term tof sort s(f=Eis the natural epimorphism induced by =E).
TΣ/=E
TΣA
-
AAAU
f=Ef
evalA
Figure 1: Graphic illustration of the isomorphism from TΣ/=Eto A
We show that fis an isomorphism:
1
pf3

Partial preview of the text

Download Proof of Correctness for Stack ADT in COP 5021 Lecture Notes and more Study notes Computer Science in PDF only on Docsity!

Dr. Ferucio Laurent¸iu T¸ IPLEA Visiting Professor School of Computer Science University of Central Florida CSB # Orlando, FL 32816- Tel: (407) 823- E-mail: [email protected]

COP 5021 (Program Analysis)

This is the correctness proof for the specification Stack in Lecture Notes #4.

Correctness. We will prove that A is a member of ADT (Stack), that is, A is isomorphic to TΣ/=E. The first step is to show that A is a model of the set E of equations in the specification: ¯γstack(pop(estack)) = popA(estackA) = P op(λ) = λ = estackA = ¯γstack(estack)

and ¯γstack(pop(push(x, y))) = popA(pushA(γstack(x), γalph(y))) = P op(P ush(γstack(x), γalph(y))) = P op(γstack(x)γalph(y)) = γstack(x) = ¯γstack(x).

Therefore, A is a model of the set E of equations of the specification.

Define now the function f : TΣ/=E →A such that the diagram in Figure 1 is commutative, that is, fs([t]=E,s ) = evalA,s(t),

for any sort s and term t of sort s (f=E is the natural epimorphism induced by =E ).

TΣ/=E

TΣ - A

A

A

AU 

f=E f

evalA

Figure 1: Graphic illustration of the isomorphism from TΣ/=E to A

We show that f is an isomorphism:

  • f is well-defined. If t and t′^ are terms of sort s and t =E,s t′, then

t =E,s t′^ ⇔ E ⊢ t = t′ ⇔ E |= t = t′ ⇔ M od(E) |= t = t′ ⇒ A |= t = t′ ⇒ evalA,s(t) = evalA,s(t′), which shows that fs([t]=E,s ) = fs([t′]=E,s );

  • f is homomorphism:
    • let 1 ≤ i ≤ n. Then:

falph(eT i Σ/=E) = falph([eT i Σ]=E,alph ) = falph([ei]=E,alph ) = evalA,alph(ei) = eAi ;

  • for the term estack we have: fstack(estackTΣ/=E^ ) = fstack([estackTΣ^ ]=E,stack ) = fstack([estack]=E,stack ) = evalA,stack(estack) = estackA;
  • if t 1 is a term of sort stack and t 2 is a term of sort alph, then: fstack(pushTΣ/=E^ ([t 1 ]=E,stack , [t 2 ]=E,alph )) =

= fstack([pushTΣ^ (t 1 , t 2 )]=E,stack ) = fstack([push(t 1 , t 2 )]=E,stack ) = evalA,stack(push(t 1 , t 2 )) = pushA(evalA,stack(t 1 ), evalA,alph(t 2 )) = pushA(fstack([t 1 ]=E,stack ), falpha([t 2 ]=E,alph ));

  • if t is a term of sort stack, then: fstack(popTΣ/=E^ ([t]=E,stack )) =

= fstack([popTΣ^ (t)]=E,stack ) = fstack([pop(t)]=E,stack ) = evalA,stack(pop(t)) = popA(evalA,stack(t)) = popA(fstack([t]=E,stack ));

  • f is injective. Define first the sets

Calph = {e 1 ,... , en} and Cstack = {push(· · · push(estack, α 1 ),... , αm)|(∀i)(αi ∈ Calph)} ∪ {estack}. These sets satisfy: