Software as Math
E N D
Presentation Transcript
Software as Math (or why you should be paying attention in this class) Ryan Luna Javier Garcia
Overview • What the heck is discrete math? • Algebraic Specifications • Theories and Models • Specification Morphisms • Homomorphisms and Isomorphisms • Useful applications!!
Discrete Mathematics • What is discrete mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete objects where discrete refers to consisting of distinct or unconnected elements. • It could be said that these subjects define the mathematical basis for computing. • A key reason for the growth in importance of discrete mathematics is that information is stored and manipulated by computing machines in a discrete fashion.
Algebraic Specifications • An algebra consists of a set (sort) and a collection of operators defined over this set. • A good example: Natural Numbers: {0,1,2,3,…} Operators: + - x ÷ Each operator is defined over two elements in the sort. • An algebra is multi-sorted if it includes multiple sorts.
How does this relate to me? • A good example of a multi-sorted algebra is the Abstract Data Type programming style. • Remember: When defining an ADT we define: 1) Collection of types 2) Set of functions and procedures for those types
Binary Search Tree ADT • Sort: Any elementary or user defined data type. BSTree <int> myTree; BSTree <string> strTree; • Operators: The functions written for the tree. void BSTree <ADT> insert (ADT element) void BSTree <ADT> remove (ADT element) void BSTree <ADT> retrieve (ADT element)
Heap ADT • Sort: Any elementary or user defined data type. Heap <int> myTbl; Heap<string> strTbl; • Operators: Implementation of the Heap. void insert (ADT element); ADT removeMax (); void clear();
Theories and Models • Suppose a computer program could take an algebraic specification and from it generate all its implications; this set of true statements would be the theory associated with the algebraic specification. • A theory models a system if: 1) Every observable behavior of the system is a theorem in the theory. (Completeness) 2) Every theorem in the theory corresponds to a behavior in the system. (Consistency) • E=MC2
Specification Morphisms • Why do we care, really? • Software development is all about changing models. • Software Design Process • Specification morphism represents the transformation of one specification into another.
B B A C A Homomorphisms • A homomorphism exists between two specifications if every thing true in A is true in B. • A ≠ B, but A B. Homomorphism between A and B.A is more abstract than B.B is more general than A. Homomorphism between C, A and BB is more general than A or C.B represents both A and C.
Isomorphisms • An isomorphism exists between A and B when the two specifications represent the same theory. • Specifications are “structurally identical.” • Used less often in software engineering because they are “too strong.” • Physical examples: • Big Ben and a wristwatch • Two decks of cards, each a different color
List Stack A Good Example… • Consider two data structures: a stack and a list. • A homomorphism exists between the stack and the list. • Stack List
List Queue Stack Another Good Example… • Consider several data structures: A queue, a stack, and a list. • We can define a homomorphism between the queue and the list, as well as the stack and the list. • Stack List and Queue List No homomorphism exists between a stack and a queue!
Finally… • Algebraic specifications relate well to ADT programming • Knowing homomorphisms between two specifications can make life easier! • Set Theory and Functions can have real applications!