L34ADT - Specification and Implementation of Abstract Data...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 1 Specification and Implementation of Abstract Data Types
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 2 Data Abstraction Clients Interested in WHAT services a module provides, not HOW they are carried out. So, ignore details irrelevant to the overall behavior, for clarity. Implementors Reserve the right to change the code, to improve performance. So, ensure that clients do not make unwarranted assumptions.
Background image of page 2
cs784(Prasad) L34ADT 3 Specification of Data Types Type : Values + Operations Specify Syntax Semantics Signature of Ops Meaning of Ops Model-based Axiomatic ( Algebraic ) Description in terms of Give axioms satisfied standard “primitive” data types by the operations
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 4 Syntax of LISP S-expr operations : nil , cons , car , cdr , null signatures : nil : S-expr cons : S-expr S-expr - S-expr car : S-expr - S-expr cdr : S-expr - S-expr null : S-expr - boolean for every atom a : a : S-expr
Background image of page 4
cs784(Prasad) L34ADT 5 Signature tells us how to form complex terms from primitive operations. Legal nil null(cons(nil,nil)) cons(car(nil),nil) Illegal nil(cons) null(null) cons(nil)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 6 Semantics of +: What to expect? + : N x N - N 1 + 2 = 3 zero + succ(succ(zero)) = succ(succ(zero)) x + 0 = x 2 * (3 + 4) = 2 * 7 = 14 = 6 + 8
Background image of page 6
cs784(Prasad) L34ADT 7 Semantics of S-Expr : What to expect? null(nil) = true car(cons(nil,nil)) = nil null(cdr(cons(nil,cons(nil,nil)))) = false for all E,F in S-Expr car(cons( E , F )) = E null(cons( E , F )) = false
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 8 Formal Spec. of ADTs Characteristics of an “Adequate” Specification Completeness ( No “undefinedness” ) Consistency/Soundness ( No conflicting definitions ) Minimality Minimality GOAL: Learn to write sound and complete algebraic(axiomatic) specifications of ADTs
Background image of page 8
cs784(Prasad) L34ADT 9 Classification of Operations Observers generate a value outside the type E.g., null in ADT S-expr Constructors required for representing values in the type E.g., nil, cons, atoms a in ADT S-expr Non-constructors remaining operations E.g., car, cdr in ADT S-expr
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 10 S-Expr in LISP a : S-Expr nil : S-Expr cons : S-Expr x S-Expr - S-Expr car : S-Expr - S-Expr cdr : S-Expr - S-Expr null : S-Expr - boolean Observers : null Constructors : a, nil, cons Non-constructors : car , cdr
Background image of page 10
cs784(Prasad) L34ADT 11 Algebraic Spec Write axioms ( equations ) that characterize the meaning of all the operations. Describe the meaning of the observers and the non-constructors on all possible constructor patterns. Note the use of typed variables to abbreviate the definition. (“Finite Spec.”)
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cs784(Prasad) L34ADT 12 for all S, T in S-expr cdr(nil) = ? error? cdr(a) = ? error? cdr(cons(
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 48

L34ADT - Specification and Implementation of Abstract Data...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online