School of Computing and Mathematics, University of Huddersfield CAS2545: WEEK 11 LECTURE: n The meaning of Algebraic Specifications TUTORIAL/PRACTICAL:

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 4 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 5 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE : INTERPRETATION IN HASKELL.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Copyright © Cengage Learning. All rights reserved.
ISBN Chapter 3 Describing Syntax and Semantics.
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 LECTURE: ABSTRACT SYNTAX SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
School of Computing and Mathematics, University of Huddersfield CIA2326: WEEK ?? LECTURE: Introduction to Algebras SUPPORTING NOTES: See chapters 8,9,10.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
Katz Formal Specifications Larch 1 Algebraic Specification and Larch Formal Specifications of Complex Systems Shmuel Katz The Technion.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
School of Computing and Mathematics, University of Huddersfield CIA2326 Week 14 LECTURE: How to reason with Algebraic Specifications TUTORIAL/PRACTICAL:
From Chapter 4 Formal Specification using Z David Lightfoot
Describing Syntax and Semantics
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
Copyright © Cengage Learning. All rights reserved.
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
MATH 224 – Discrete Mathematics
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
LANGUAGE TRANSLATORS: WEEK 3 LECTURE: Grammar Theory Introduction to Parsing Parser - Generators TUTORIAL: Questions on grammar theory WEEKLY WORK: Read.
Computing Fundamentals 1 Equations and Reduction in CafeOBJ
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
Chapter 8 Relational Calculus. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.8-2 Topics in this Chapter Tuple Calculus Calculus vs. Algebra.
Slide Copyright © 2012 Pearson Education, Inc.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
2.3Logical Implication: Rules of Inference From the notion of a valid argument, we begin a formal study of what we shall mean by an argument and when such.
School of Computing and Mathematics, University of Huddersfield CIA2326: Week 11 LECTURE: Formal Specification TUTORIAL/PRACTICAL: Finish off last weeks.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
School of Computing and Engineering, University of Huddersfield CIA2326 Week 14 LECTURE: Formal Specifications. How to reason with Algebraic Specifications.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Semantics In Text: Chapter 3.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra.
INM175 Topic 8 1 Module INM175 Discrete Mathematics Topic 8 Algebraic Theories.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 – SEMANTICS EXAMPLE LECTURE: SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
CMSC 330: Organization of Programming Languages Operational Semantics.
Faithful mapping of model classes to mathematical structures Ádám Darvas ETH Zürich Switzerland Peter Müller Microsoft Research Redmond, WA, USA SAVCBS.
Logic Simplification-Using Boolean Laws Logic Design Laboratory EE 2121 Lectures By Manesh T EE2121-In Charge
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra.
June 21, Reasoning about explicit strictness in a lazy language using mixed lazy/strict semantics Marko van Eekelen Maarten de Mol Nijmegen University,
Chapter 3 Boolean Algebra and Digital Logic T103: Computer architecture, logic and information processing.
IS 2620: Developing Secure Systems Formal Verification/Methods Lecture 9 March 15, 2012.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Dr. ClincyLecture Slide 1 CS6020- Chapter 3 (3A and ) Dr. Clincy Professor of CS First Exam - Tuesday, September 6th Coverage: All subjects up to.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Chapter 8 Relational Calculus.
CS Chapter 3 (3A and ) Part 1 of 8
MTH108 Business Math I Lecture 2.
CS Chapter 3 (3A and ) Part 1 of 8
4-1 LOGIC OPERATIONS In Chapter 3 we discussed the fact that data inside a computer is stored as patterns of bits. Logic operations refer to those operations.
Dr. Clincy Professor of CS
Propositional Calculus: Boolean Algebra and Simplification
Dr. Clincy Professor of CS
Logics for Data and Knowledge Representation
IS 2935: Developing Secure Systems
Dr. Clincy Professor of CS
CS Chapter 3 (3A and ) Part 3 of 8
Applied Discrete Mathematics Week 4: Functions
CS Chapter 3 (3A and ) – Part 2 of 5
ECB2212-Digital Electronics Boolean algebra
Algebraic Specification Software Specification Lecture 34
Mathematical Language
Presentation transcript:

School of Computing and Mathematics, University of Huddersfield CAS2545: WEEK 11 LECTURE: n The meaning of Algebraic Specifications TUTORIAL/PRACTICAL: Do the exercises given in last week’s handout Look at the revision questions on the web and attempt them without looking at the answers

School of Computing and Mathematics, University of Huddersfield Algebras and Algebraic Specifications Last week we saw: - what an algebra was (values + closed, total operations) - a way to specify algebras by writing Signatures of operation - we can give a semantics to data types via algebras But how can we show that an algebra ‘is specified’ by an algebraic specification? And what is the set of algebras specified by the specification?

School of Computing and Mathematics, University of Huddersfield MODELS of the “Metre” in Paris The “Metre” in Paris The “Metre” in BerlinThe “Metre” in London The “Metre” in Madrid The “Metre” in Rome

School of Computing and Mathematics, University of Huddersfield MODELS of the “Algebraic Specification” of some Data Type The Algebraic Specification Of the Data Type Algebras (data types)

School of Computing and Mathematics, University of Huddersfield Models of An Algebra Roughly: A model of an algebraic spec. AS is an algebra A which conforms to the spec. THE ALGEBRAIC SPEC is LIKE THE METRE IN PARIS! To show an algebra A conforms to a specification AS we have to be able to do the following: 1. Map every operation in AS to a unique operation in algebra A. 2. Using this mapping (interpretation), show that the equations in AS are made true.

School of Computing and Mathematics, University of Huddersfield Models of An Algebra 1. e.g. Truth table logic, 3 valued logic are models of Boolean specification. 2. e.g. decimal positive numbers, decimal positive numbers modulo 5, are models of the ‘Natural’ specification given out in the notes. 3. e.g. the C implementation of boolean type, with true = 1, false = 0, and = &&, not = !, can be said to be a model of the Boolean specification. 4. e.g. all ‘good’ implementations of a STACK data structure are models of the ‘Stack’ specification given out in the notes.

School of Computing and Mathematics, University of Huddersfield Good and Bad Models of An Algebraic Spec Models can be good or bad! For example, 3-valued logic is not a good model of Boolean. The set of models of an alg. spec. as defined is not restricted enough. To find the ‘good’ models we must look closely at an algebraic specification….

School of Computing and Mathematics, University of Huddersfield The Term Algebra of an Algebraic Specification The Term Algebra of an Alg. Spec. AS is a SPECIAL model (its similar idea to the Herbrand Universe of a set of well formed formulae in first order logic) The Term Algebra is defined by: n set of values = the set of all terms that can be generated using the signature as a generative grammar n set of operations = operations as in the signature of the spec.

School of Computing and Mathematics, University of Huddersfield Focus on the Type Of Interest If we have a heterogeneous algebra with N carrier sets, then the values in its term algebra will split into those N sets. E.g. in stack, (push init 3) is in stack, (is_empty init) is in bool, (top (push init 3)) is in nat. We focus in on the values of the TYPE OF INTEREST (TOI) e.g. stack in the ‘Stack’ spec

School of Computing and Mathematics, University of Huddersfield Equivalence Classes in a Term Algebra The values of the term algebra of the TOI fall into distinct equivalence classes If X, Y are in the TOI, then X = Y if and only if X can be transformed to Y using the equations. E.g. (push init 3) and (push init (top (push init 3))) are in the same equivalence class

School of Computing and Mathematics, University of Huddersfield Equational reasoning (READ section 8.8 in the online book) n Assume we have an equation X = Y in an Algebraic Specification and a member of its term algebra T. n X and Y may contain (universally quantified) variables, T contains only operators / values (no variables). n Then we can use the equation to REWRITE T to another (equal) term T1. n The process is as follows: n 1. Find a substring of T called T' that MATCHES with X under substitution sequence S. n 2. Apply S to Y to get Y' n 3. Replace T' in T with Y' to form new term T1.

School of Computing and Mathematics, University of Huddersfield Equational reasoning example n Let T = or(and(true,not(false)),false) n Using the axiom: n (3) and(true,b) = b n Substring of T “and(true,not(false))” matches with the LHS of this equation under the substitution S = [not(false) / b ] n Thus we can re-write term T = or(and(true,not(false)),false) to new term: n or(b,false) [not(false) / b ] = or(not(false),false)

School of Computing and Mathematics, University of Huddersfield Initial Models of An Algebraic Spec A model is INITIAL if two conditions hold: 1. All distinct values in the model are represented by an equivalence class in the spec’s term algebra This means NO JUNK - there are no DISTINCT values in the model (algebra) which aren’t represented by some DISTINCT equivalence class.

School of Computing and Mathematics, University of Huddersfield Initial Models of An Algebraic Spec 2. Each equivalence class in the spec’s term algebra represents a unique value in the model This means NO CONFUSION - we cannot have 2 equivalence classes in the model that map to the same value in the model.

School of Computing and Mathematics, University of Huddersfield INITIAL MODEL of an “Algebraic Specification” The Algebraic Specification Of the Data Type Algebras (data types) values A B C D Equivalence classes

School of Computing and Mathematics, University of Huddersfield JUNK! The Algebraic Specification Of the Data Type Algebras (data types) values A B C D E F Equivalence classes

School of Computing and Mathematics, University of Huddersfield CONFUSION! The Algebraic Specification Of the Data Type Algebras (data types) values A B C Equivalence classes

School of Computing and Mathematics, University of Huddersfield The Semantics of An Algebraic Spec Given an algebraic specification, its meaning is the set of all its INITIAL MODELS

School of Computing and Mathematics, University of Huddersfield Algebraic Specs as ‘Objects’ n An algebraic spec provides an INTERFACE SPECIFICATION informing a client what services are on offer (class and operations). n This spec. is a good one because it provides the formal syntax AND semantics. n The TOI is a defined CLASS.

School of Computing and Mathematics, University of Huddersfield Algebraic Specs as ‘Objects’ n A specification of an object’s states are the equiv classes of the spec’s term algebra. n However, algebraic specs give no notion of identity and persistence! n Alg. Specs are easily implemented in HASKELL.

School of Computing and Mathematics, University of Huddersfield Operational semantics of algebraic specifications Alg. Specs are easily operationalised (and implemented in HASKELL) The equations are treat as Left to Right re-write rules (or function definitions). But the equations must be in a certain form to make this work..

School of Computing and Mathematics, University of Huddersfield Conclusions n Algebraic Specs are using to abstractly define algebras n An algebra conforms to a spec if it is an initial model of that spec. n Equational Algebraic Specs can be prototyped (operationalised) by using the equations are L-R re-write rules