School of Computing and Mathematics, University of Huddersfield CIA2326 Week 14 LECTURE: How to reason with Algebraic Specifications TUTORIAL/PRACTICAL:

Slides:



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

Semantics Static semantics Dynamic semantics attribute grammars
Chapter 1 Section 3 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 LECTURE: ABSTRACT SYNTAX SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
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 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.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
Chapter 2 Section 2 Solving a System of Linear Equations II.
Cse536 Functional Programming 1 7/14/2015 Lecture #2, Sept 29, 2004 Reading Assignments –Begin Chapter 2 of the Text Home work #1 can be found on the webpage,
Chapter 3 Math Vocabulary
Systems of Equations and Inequalities
Properties of Logarithms Section 4.3 Properties of Logarithms
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,
Chapter 1 Equations, Inequalities, and Mathematical Models
Expressions Objective: EE.01 I can write and evaluate numerical expressions involving whole number exponents.
1-8 An Introduction to Equations
MATH 224 – Discrete Mathematics
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Chapter 11 Systems of Equations.
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
Algebra-2 Section 3-2A Solving Systems of Linear Equations Algebraically Using Substitution.
Variables Tutorial 3c variable A variable is any symbol that can be replaced with a number to solve a math problem. An open sentence has at least one.
Extending the Definition of Exponents © Math As A Second Language All Rights Reserved next #10 Taking the Fear out of Math 2 -8.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 7 Algebra: Graphs, Functions, and Linear Systems.
Algebra-2 Section 3-2B.
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.
School of Computing and Engineering, University of Huddersfield CIA2326 Week 14 LECTURE: Formal Specifications. How to reason with Algebraic Specifications.
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.
Martin-Gay, Beginning Algebra, 5ed 22 Location of NewportD1 Location of GatlinburgC2 Location of RobbinsvilleA5.
School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE TUTORIAL: Do exercises.
Expectations What Do YOU Expect To Learn What Do YOU Expect To Learn  How to Compute  How to Solve Equations  How to Solve (textbook) Problems  More.
Chapter 01 – Section 05 Open Sentences. © William James Calhoun To solve open sentences by performing arithmetic operations. open sentence - a mathematical.
Chapter 1 Section 3. Objectives 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Evaluate algebraic expressions, given values for the variables.
Solving an equation with one unknown From arithmetic to algebra Modifying equations in algebra.
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 – SEMANTICS EXAMPLE LECTURE: SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
Types and Programming Languages
Warm-Up Tickets for a concert cost $10 each if you order them online, but you must pay an $8 service charge per order. The tickets are $12 each if you.
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.
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,
Math 3121 Abstract Algebra I Lecture 6 Midterm back over+Section 7.
Homework.
MTH108 Business Math I Lecture 2.
1-5 Equations Goals: Solve equations with one variable
Expectations What Do YOU Expect To Learn How to Compute
The Real Number System Opening Routine
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.
Section 1-3 Equations.
March 1, Math 201 OBJECTIVE: Students will be able to use substitution to evaluate algebraic expressions, including exponents of one, two, or.
There are infinite solutions to the system.
Section 2.4 Variables and Equations
Chapter 10 Section 4.
Chapter 1 Section 3.
George Boole English Mathematician
Algebraic Specification Software Specification Lecture 34
OBJ first-order functional language based on equational logic
9.7 Solving Systems of Equations Algebraically
Algebra 1 Section 2.4.
Variables and Equations
To Start – 10 Points!! Simplify the following:
Variables.
Presentation transcript:

School of Computing and Mathematics, University of Huddersfield CIA2326 Week 14 LECTURE: 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 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 reason with values in an algebra?

School of Computing and Mathematics, 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 Mathematics, 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 Mathematics, 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 Mathematics, 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 Mathematics, 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 Mathematics, 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 Mathematics, 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 Mathematics, 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 Mathematics, 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