School of Computing and Engineering, University of Huddersfield CIA2326 Week 14 LECTURE: Formal Specifications. How to reason with Algebraic Specifications.

Slides:



Advertisements
Similar presentations
Cs7120 (Prasad)L22-MetaPgm1 Meta-Programming
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
CS 355 – Programming Languages
AI - Week 13 Knowledge Representation, Logic, Semantic Web Lee McCluskey, room 2/07
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 Engineering, University of Huddersfield CHA2545: WEEK 14 - SYNTAX LECTURE: ABSTRACT SYNTAX SIMPLE EXAMPLE OF SEMANTICS DEFINITION.
School of Computing and Mathematics, University of Huddersfield CAS2545: WEEK 11 LECTURE: n The meaning of Algebraic Specifications TUTORIAL/PRACTICAL:
School of Computing and Mathematics, University of Huddersfield CIA2326: WEEK ?? LECTURE: Introduction to Algebras SUPPORTING NOTES: See chapters 8,9,10.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
Axiomatic Semantics Dr. M Al-Mulhem ICS
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
School of Computing and Mathematics, University of Huddersfield CIA2326 Week 14 LECTURE: How to reason with Algebraic Specifications TUTORIAL/PRACTICAL:
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
Describing Syntax and Semantics
School of Computing and Engineering, University of Huddersfield Formal Aspects of Computer Science - CIA 2326 Lee McCluskey, room 2/07
Digital Logic Circuits – Chapter 1 Section 1-3, 1-2.
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
Overview of Formal Methods. Topics Introduction and terminology FM and Software Engineering Applications of FM Propositional and Predicate Logic Program.
Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo
Extending the Definition of Exponents © Math As A Second Language All Rights Reserved next #10 Taking the Fear out of Math 2 -8.
Algebra-2 Section 3-2B.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
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.
Type Safety Kangwon National University 임현승 Programming Languages.
Honors Geometry Intro. to Deductive Reasoning. Reasoning based on observing patterns, as we did in the first section of Unit I, is called inductive reasoning.
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
Algebra Equations Lesson 1-7 Pages Equations An Equation is a sentence that contains an equals = sign. The equals = sign tells you that the expression.
Logical Reasoning:Proof Prove the theorem using the basic axioms of algebra.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 – SEMANTICS EXAMPLE LECTURE: SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
Types and Programming Languages
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Advanced programming language theory. week 2. Attribute grammars and semantics.
Week 1 Real Numbers and Their Properties (Section 1.6, 1.7, 1.8)
1.7: Adding Like Terms TERM: A number, a variable, or the product of the two.Ex: a, 3x, 2x, 5, CONSTANT: a term with no variable (number) Ex: 4, -1, 6,
Dr. ClincyLecture Slide 1 CS6020- Chapter 3 (3A and ) Dr. Clincy Professor of CS First Exam - Tuesday, September 6th Coverage: All subjects up to.
CS Chapter 3 (3A and ) Part 1 of 8
MATH 245 Spring 2009 This is mathematics for computer science
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.
Chapter 5 Structures.
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
Dr. Clincy Professor of CS
CS Chapter 3 (3A and ) Part 3 of 8
CS Chapter 3 (3A and ) – Part 2 of 5
Sub-system interfaces
Algebraic Specification Software Specification Lecture 34
Copyright © Cengage Learning. All rights reserved.
OBJ first-order functional language based on equational logic
Variables.
Presentation transcript:

School of Computing and Engineering, University of Huddersfield CIA2326 Week 14 LECTURE: Formal Specifications. How to reason with Algebraic Specifications TUTORIAL/PRACTICAL: Do the exercises given in last week’s handout Read through chapters 8 and 9 of the online book

School of Computing and Engineering, 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 reason with values in an algebra?

School of Computing and Engineering, University of Huddersfield Formal Specifications - good for capturing requirements in safety related/critical applications - can eliminate bugs EARLY in SD process - can be used as a precise contract - can be reasoned with using logic - can be manipulated using computer tools - can be used as a basis to “prove” code correct BUT - not very understandable if they are in Maths - are only part of the story – they do not guarantee quality

School of Computing and Engineering, University of Huddersfield That Boolean Example again – an algebraic specification of the Boolean data type SPEC Boolean SORT bool OPS true : -> bool false : -> bool not : bool -> bool and : bool bool -> bool AXIOMS: FORALL b : bool (1) not(true) = false (2) not(false) = true (3) and(true,b) = b (4) and(b,true) = b (5) and(false,b) = false (6) and(b,false) = false ENDSPEC

School of Computing and Engineering, University of Huddersfield That Boolean Example again – notations NOTE Operator application can be in different notations – maths -like : not(true) and(true,not(false)) or(and(true,not(false)),false) Or more “functional” oriented - not true and true (not false) or (and true (not false)) false

School of Computing and Engineering, University of Huddersfield The Term Algebra of an Algebraic Specification The Term Algebra of an Algebraic Specification is defined by: set of values = the set of all terms that can be generated using the signature as a generative grammar set of operations = operations as in the signature of the spec.

School of Computing and Engineering, University of Huddersfield Values of the Boolean “Term Algebra” The Examples above - not(true) and(true,not(false)) or(and(true,not(false)),false) Are values of the term algebra of Boolean.

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

School of Computing and Engineering, University of Huddersfield Similar examples from other areas.. Basic numeric “algebra” Term: x**2 + 2 Axiom: x = 2 Term Rewrites to: 2**2+2 Grammars for Syntax definition Term: * Axiom: ::= ( + ) Term Rewrites to: ( + ) *

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

School of Computing and Engineering, University of Huddersfield Equational reasoning: LEFT to RIGHT rewrite rules To make re-writing more efficient, it is often assumed that it only happens using the axioms from left to right. Using them in this fashion leads them to be called “left to right rewrite rules”. They are similar (but more general than) BNF rules. (1) not(true) => false (2) not(false) => true (3) and(true,b) => b (4) and(b,true) => b (5) and(false,b) => false (6) and(b,false) => false or(not(false),false) =(2)=> or(true,false) =

School of Computing and Engineering, University of Huddersfield Conclusions Algebraic Specs are using to abstractly define algebras. Data types can be modelled as algebras. Equational Algebraic Specs can be prototyped (operationalised) by using the equations are L-R re-write rules