Semantics Q1 2007 S EMANTICS (Q1,’07) Week 1 Jacob Andersen PhD student

Slides:



Advertisements
Similar presentations
CPSC Compiler Tutorial 4 Midterm Review. Deterministic Finite Automata (DFA) Q: finite set of states Σ: finite set of “letters” (input alphabet)
Advertisements

1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Lecture 02 – Structural Operational Semantics (SOS) Eran Yahav 1.
1 Introduction to Computability Theory Discussion1: Non-Deterministic Finite Automatons Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
CS5371 Theory of Computation
CS5371 Theory of Computation
C LAUS B RABRAND S EMANTICS (Q1,’05) S EP 8, 2005 C LAUS B RABRAND © 2005, University of Aarhus [ ] [
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
61 Nondeterminism and Nodeterministic Automata. 62 The computational machine models that we learned in the class are deterministic in the sense that the.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
C LAUS B RABRAND Inference Systems J AN 27, 2009 I NFERENCE S YSTEMS Claus Brabrand IT University of Copenhagen [
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
C LAUS B RABRAND S EMANTICS (Q1,’05) S EP 8, 2005 C LAUS B RABRAND © 2005, University of Aarhus [ ] [
TR1413: Discrete Mathematics For Computer Science Lecture 3: Formal approach to propositional logic.
Context-Free Grammars Lecture 7
1 Semantics Q S EMANTICS (Q1,’07) Week 2 Jacob Andersen PhD student
1 Semantics Q S EMANTICS (Q1,’07) Week 3 Jacob Andersen PhD student
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 C LAUS B RABRAND © 2005–2006, University of Aarhus [ ] [
1 Semantics Q S EMANTICS (Q1,’07) Week 4 Jacob Andersen PhD student
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
C LAUS B RABRAND & J ACOB A NDERSEN © S EMANTICS (Q1,’07) Aug 30, 2007 Adapted version for dSem 2007 Original story by: C LAUS B RABRAND © 2005–2006, University.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Describing Syntax and Semantics
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
C LAUS B RABRAND S EMANTICS (Q1,’06) S EP 7, 2006 C LAUS B RABRAND © , University of Aarhus [ ] [
Finite State Machines Data Structures and Algorithms for Information Processing 1.
C LAUS B RABRAND © S EMANTICS (Q1,’05) S EP 1, 2005 C LAUS B RABRAND © 2005, University of Aarhus [ ] [
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Context-Free Grammars and Parsing 1.
Syntax & Semantic Introduction Organization of Language Description Abstract Syntax Formal Syntax The Way of Writing Grammars Formal Semantic.
Chpater 3. Outline The definition of Syntax The Definition of Semantic Most Common Methods of Describing Syntax.
CPSC 388 – Compiler Design and Construction Parsers – Context Free Grammars.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 2: Operational Semantics I Roman Manevich Ben-Gurion University.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Pushdown Automata (PDAs)
CSCI 2670 Introduction to Theory of Computing September 15, 2005.
Grammars CPSC 5135.
PART I: overview material
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
Theory of Computing Lecture 21 MAS 714 Hartmut Klauck.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Chapter 3 Describing Syntax and Semantics
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Formal Semantics of Programming Languages 虞慧群 Topic 2: Operational Semantics.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Parsing & Context-Free Grammars
CIS Automata and Formal Languages – Pei Wang
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
Intro to Data Structures
Chapter Five: Nondeterministic Finite Automata
Presentation transcript:

Semantics Q S EMANTICS (Q1,’07) Week 1 Jacob Andersen PhD student

Semantics Q Week 1 - Outline Introduction Welcome and introduction Short-film about teaching (20')... Course Presentation [ homepage ]homepage Prerequisitional (discrete) Mathematics Relations Inference Systems Transition Systems The Language “L”

Semantics Q Introduction Semantics –Merriam-Webster: –Example: “I would like a cup of coffee.” “Colourless green ideas sleep furiously.” Question: Would you fly the space shuttle if you had written the guidance software??? In this course we shall explore formal ways of reasoning about the meaning / behaviour of computer programs. Main Entry: se·man·tics Pronunciation: si-'man-tiks Function: noun plural but singular or plural in construction 1 : the study of meanings

Semantics Q Short-film about teaching...

Semantics Q Course Introduction I SOLO 2, 3, 4 Verbs identifies skills / competences Actor

Semantics Q Course Introduction II No-one can force new skills into your head –You do not learn how to ride a bike by observing others (!!) Expected weekly time consumption: Lecture3 Reading1 Exercise class3 Hand-in2 Sum13 Fitting the pieces together Lecture3 Reading1 Reflecting / Solving exercises4 Exercise class3 Hand-in2 Sum13

Semantics Q Course Introduction III Course Retrospection dSem ’05:

Semantics Q Learning vs. Breaks #Breaks, |Breaks|,...? Conclusion: more (shorter) breaks

Semantics Q R ELATIONS AND I NFERENCE S YSTEMS

Semantics Q Relations I Example 1 : “even” relation: Written as: as a short-hand for: … and as: as a short-hand for: Example 2 : “equals” relation: Written as: as a short-hand for: … and as: as a short-hand for: Example 3 : “DFA transition” relation: Written as: as a short-hand for: … and as: as a short-hand for: | _ even  Z | _ even 4 | _ even 5 4  | _ even 5  | _ even 2  3(2,3)  ‘=’ ‘=’  Z  Z (2,2)  ‘=’ 2 = 2 ‘  ’  Q    Q q  q’  (q, , q’)  ‘  ’ (p, , p’)  ‘  ’p  p’ 

Semantics Q Relations II In general, a k-ary relation, L, over the sets S 1, S 2, …, S k is a subset L  S 1  S 2  …  S k k is called the “arity” of L, and “L  S 1  S 2  …  S k ” is the “signature”.

Semantics Q Inference System Inference System: Inductive (recursive) specification of relations Consists of axioms and rules Example: Axiom: “0 (zero) is even”! Rule: “If n is even, then m is even (where m = n+2)” | _ even 0 | _ even n | _ even m m = n+2 | _ even  Z

Semantics Q Terminology Meaning: Inductive: “If n is even, then m is even (provided m = n+2)”; or Deductive: “m is even, if n is even (provided m = n+2)” | _ even n | _ even m m = n+2 premise(s) conclusion side-condition(s) Question: Why have both premises and side-conditions?? Note: The “ “ is actually just another way of writing a “  ” !

Semantics Q Abbreviation Often, rules are abbreviated: Rule: “If n is even, then m is even (provided m = n+2)”; or “m is even, if n is even (provided m = n+2)” Abbreviated rule: “If n is even, then n+2 is even”; or “n+2 is even, if n is even” | _ even n | _ even n+2 | _ even n | _ even m m = n+2 Even so, this is what we mean Warning: Be careful !

Semantics Q Relation Membership (Even)? Axiom: “0 (zero) is even”! Rule: “If n is even, then n+2 is even” Is 6 even?!? The inference tree proves that: | _ even 0 | _ even 2 | _ even 4 | _ even 6 | _ even 0 | _ even n | _ even n+2 [rule 1 ] [axiom 1 ] inference tree | _ even 6

Semantics Q Example: “less-than-or-equal-to” Relation: Is ”1  2” ?!? Yes, because there exists an inference tree: »In fact, it has two inference trees: 0  0 n  m n  m+1 [rule 1 ] [axiom 1 ] ‘  ’  N  N n  m n+1  m+1 [rule 2 ] 0  0 0  1 1  2 [rule 2 ] [rule 1 ] [axiom 1 ] 0  0 1  1 1  2 [rule 1 ] [rule 2 ] [axiom 1 ]

Semantics Q Activation Exercise 1 Activation Exercise: 1. Specify the signature of the relation: ' << ' »x << y " y is-double-that-of x " 2. Specify the relation via an inference system »i.e. axioms and rules 3. Prove that indeed: »3 << 6 "6 is-double-that-of 3"

Semantics Q Activation Exercise 2 Activation Exercise: 1. Specify the signature of the relation: ' // ' »x // y " x is-half-that-of y " 2. Specify the relation via an inference system »i.e. axioms and rules 3. Prove that indeed: »3 // 6 "3 is-half-that-of 6" Syntactically different Semantically the same relation

Semantics Q Relation Definition (Interpretation) Actually, an inference system: …is a demand specification for a relation: The three relations: R = {0, 2, 4, 6, …}(aka., 2N) R’ = {0, 2, 4, 5, 6, 7, 8, …} R’’ = {…, -2, -1, 0, 1, 2, …}(aka., Z) …all satisfy the (above) specification! |_R 0|_R 0 | _ R n | _ R n+2 [rule 1 ] [axiom 1 ] | _ R  Z (0  ‘| _ R ’)  (  n  ‘| _ R ’  n+2  ‘| _ R ’)

Semantics Q Inductive Interpretation A inference system: …induces a function: Definition: ‘lfp’ (least fixed point) ~ least solution: | _ R 0 | _ R n | _ R n+2 [rule 1 ] [axiom 1 ] F R : P(Z)  P(Z) | _ R  Z F R (R) = {0}  { n+2 | n  R } F(Ø) = {0}F 2 (Ø) = F({0}) = {0,2}F 3 (Ø) = F 2 ({0}) = F({0,2}) = {0,2,4} … | _ even := lfp(F R ) =  F R n (Ø) n | _ R  P(Z) From rel. to rel. 2N   = F n (Ø) ~ “Anything that can be proved in ‘n’ steps” 

Semantics Q T RANSITION S YSTEMS

Semantics Q Definition: Transition System A Transition System is (just) a structure:  is a set of configurations      is a binary relation (called the transition relation) –We will write instead of Other times we might use the following notations:  ,     ’  ’( ,  ’)     ’  ’  |_ ’ |_ ’   ’  ’,, …

Semantics Q The transition may be illustrated as: In this course, we will be (mostly) using: For instance: A Transition   ’  ’ ’’  = system configuration = ...and have "  " describe "one step of computation"

Semantics Q Def: Terminal Transition System A Terminal Transition System is a structure:  is the set of configurations      is the transition relation T   is a set of final configurations –…satisfying: –i.e. “all configurations in ‘T’ really are terminal”.  , , T    t  T :     :  t  

Semantics Q E.g.: Finite Automaton A Non-det Finite Automaton (NFA) is a 5tuple: Q finite set of states  finite set of input symbols q 0  Qinitial state F  Qset of acceptance states  : Q    P(Q)state transition relation M =  Q, , q 0, F,   Q = { 0,1,2 }  = {  = { toss,heads,tails } (0,toss)  {1,2}, q 0 = 0 (1,heads)  {0}, F = { 0 } (2,tails)  {0} }

Semantics Q E.g.: NFA Transition System (1) Define Term. Trans. Syst. by: Configurations: Transition relation: –i.e., we have whenever Final Configurations:  M := Q   *   M,  M, T M  T M := { | q  F }  M := { (, ) | q,q’  Q, a , w  *, q’  (q,a) } “State component” “Data component” q’   (q,a)  M Recall:      M =  Q, , q 0, F,   Given

Semantics Q E.g.: NFA Trans. Sys. (Cont’d) Define behavior of M:  M  T M L (M) := { w   * |  T :  *  }

Semantics Q Def: Labelled Transition System A Labelled Transition System is a structure:  is the set of configurations A is the set of actions (= labels)     A   is the transition relation –Note: we will write instead of  , A,     ’  ’ a ( , a,  ’)  ‘  ’

Semantics Q The labelled transition may be illustrated as: –The labels(/actions) add the opportunity of describing transitions: –Internally (e.g., information about what went on internally) –Externally (e.g., information about communication /w env) –…or both. A Labelled Transition   ’  ’ ’’ a a

Semantics Q E.g.: NFA Transition System (2) Given Finite Automaton: Define Labelled Terminal Transition System: Configurations: Labels: Transition relation: Final configurations:  M := Q   M, A M,  M, T M  T M := F  M := {(q,a,q’)|q’  (q,a)} A M :=  M =  Q, , q 0, F,   X ??? “Relaxed” v

Semantics Q E.g.: NFA Trans. Sys. (Cont’d) Behavior: Define ”  *” as the reflexive transitive closure of ”  ” on sequences of labels: 0  M 1  M 0  M 2  M 0 L (M) := { w  A* |  q  T : q 0  * q w toss heads toss tails L (M) := { a a’ … a’’  A* |  q  T : q 0  q’  …  q a a’ a’’

Semantics Q NFA: Machine 1 vs. Machine 2 The two transition systems are very different: Machine 1: –”I transitioned from to ” Implicit: ”…by consuming part of (internal) data component” Machine 2: –”I transitioned from q to q’ …by inputing an ’a’ symbol from the (external) environment!”  M q  M q’ a

Semantics Q More Examples… More Examples in [Plotkin, p. 22 – 26]: –Three Counter Machine (***) –Context-Free Grammars (**) –Petri Nets (*) They illustrate expressive power of transition systems –no new points...except formalizing input / output behavior (also later here…) Read these yourself…

Semantics Q T HE L ANGUAGE “L”

Semantics Q The Language ”L” Basic Syntactic Sets: Truthvalues: –Setranged over by: t, t’, t 0, … Numbers: –Setranged over by: m, n, … Variables: –Setranged over by: v, v’, … T = { tt, ff } N = { 0, 1, 2, …} VAR = { a, b, c, …, z } Meta-variables

Semantics Q The Language ”L” Derived Syntactic Sets: Arithmetic Expressions ( e  Exp): Boolean Expressions ( b  BExp): Commands ( c  Com): e ::= n | v | e + e’ | e – e’ | e  e’ b ::= t | e = e’ | b or b’ | ~ b c ::= nil | v := e | c ; c’ | if b then c else c’ | while b do c

Semantics Q Consider program: It can be (ambiguously) understood: Note: Abstract- vs. Concrete Syntax while b do c ; c’  while b do c  ; c’while b do  c ; c’  …either as: …or as: “Concrete syntax” while b c ; c’ while b c ; c’ “Abstract syntax” Parsing: “Concrete syntax”  “Abstract syntax”

Semantics Q Next week Use everything…: Inference Systems, Transition Systems, Syntax, … …to: –describe –explain –analyse –compare …semantics of Expressions:

Semantics Q "Three minutes paper" Please spend three minutes writing down the most important things that you have learned today (now). After 1 day After 1 week After 3 weeks After 2 weeks Right away

Semantics Q Exercises... [ homepage ]

Semantics Q See you next week… Questions?

Semantics Q1 2007