Presentation is loading. Please wait.

Presentation is loading. Please wait.

C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 C LAUS B RABRAND © 2005–2006, University of Aarhus [ ] [

Similar presentations


Presentation on theme: "C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 C LAUS B RABRAND © 2005–2006, University of Aarhus [ ] ["— Presentation transcript:

1 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 C LAUS B RABRAND © 2005–2006, University of Aarhus [ brabrand@daimi.au.dk ] [ http://www.daimi.au.dk/~brabrand/ ] S EMANTICS (Q1,’06) W EEK 1

2 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 2 ] A UG 31, 2006 Week 1 - Outline Introduction Welcome Short-film about teaching (20')... Course Presentation [ homepage ]homepage Prerequisitional (discrete) Mathematics Relations Inference Systems Transition Systems The Language “L”

3 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 3 ] A UG 31, 2006 Short-film about teaching...

4 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 4 ] A UG 31, 2006 Course Introduction [ homepage ]

5 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 5 ] A UG 31, 2006 Learning vs. Breaks #Breaks, |Breaks|,...? Conclusion: more (shorter) breaks

6 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 I NFERENCE S YSTEMS Keywords: relations, axioms, rules, (co-)inductive interpretation, fixed-points

7 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 7 ] A UG 31, 2006 Relations 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’ 

8 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 8 ] A UG 31, 2006 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

9 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 9 ] A UG 31, 2006 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)

10 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 10 ] A UG 31, 2006 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

11 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 11 ] A UG 31, 2006 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

12 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 12 ] A UG 31, 2006 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 ]

13 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 13 ] A UG 31, 2006 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" When you are done, take a break (see you 13:15)

14 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 14 ] A UG 31, 2006 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

15 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 15 ] A UG 31, 2006 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 ’)

16 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 16 ] A UG 31, 2006 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” 

17 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 17 ] A UG 31, 2006 Co-inductive Interpretation (  ) A relation:  …induces a function: Definition: ‘gfp’ (greatest fixed point) ~ greatest solution: | _ even 0 | _ even n | _ even n+2 [rule 1 ] [axiom 1 ] F: P(Z)  P(Z) | _ even  Z F(R) = {0}  { n+2 | n  R } F(Z) = Z | _ even := gfp(F) =  F n (Z) n | _ even  P(Z) From rel. to rel. F 2 (Z) = F(Z) = Z  F 3 (Z) = F 2 (Z) = F(Z) = Z  … Z  = F n (Z) ~ “Anything that cannot be disproved in ‘n’ steps”

18 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 T RANSITION S YSTEMS Keywords: Configuration, Final Configuration, Transition, Action / label

19 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 19 ] A UG 31, 2006 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 use the following notation:  ,     ’  ’( ,  ’)     ’  ’  |_ ’ |_ ’   ’  ’ …

20 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 20 ] A UG 31, 2006 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"

21 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 21 ] A UG 31, 2006 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  

22 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 22 ] A UG 31, 2006 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} }

23 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 23 ] A UG 31, 2006 E.g.: NFA Transition System (1) Define (FA) Trans. Sys. 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

24 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 24 ] A UG 31, 2006 E.g.: NFA Trans. Sys. (Cont’d) Define behavior of M:  M  T M L (M) := { w   * |  T :  *  }

25 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 25 ] A UG 31, 2006 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,  ’)  ‘  ’

26 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 26 ] A UG 31, 2006 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

27 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 27 ] A UG 31, 2006 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 q  M q’ := q’  (q,a) A M :=  a M =  Q, , q 0, F,  

28 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 28 ] A UG 31, 2006 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  T M 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’’

29 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 29 ] A UG 31, 2006 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

30 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 30 ] A UG 31, 2006 More Examples… More Examples in [Plotkin, p. 6 – 13]: 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…

31 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 T HE L ANGUAGE “L” Keywords: Expressions, Boolean Expressions, Commands, Abstract Syntax, Concrete Syntax

32 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 32 ] A UG 31, 2006 The Language ”L” Basic Syntactic Sets: Truthvalues: Set ranged over by: t, t’, t 0, … Numbers: Set ranged over by: m, n, … Variables: Set ranged over by: v, v’, … T = { tt, ff } N = { 0, 1, 2, …} VAR = { a, b, c, …, z } Meta-variables

33 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 33 ] A UG 31, 2006 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

34 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 34 ] A UG 31, 2006 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”

35 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 N EXT W EEK… Semantics of…: “ Simple Commands and Expressions”

36 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 36 ] A UG 31, 2006 Next week Use everything…: Inference Systems, Transition Systems, Syntax, … …to: describe explain analyse compare …semantics of Expressions:

37 C LAUS B RABRAND S EMANTICS (Q1,’06) [ 37 ] A UG 31, 2006 "Three minutes paper" Please spend three minutes writing down the most important things that you have learned today (now). Efter en dag Efter en uge Efter 3 uger Efter 2 uger Med det samme

38 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 Exercises... [ homepage ]

39 C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 See you next week… Questions?


Download ppt "C LAUS B RABRAND © S EMANTICS (Q1,’06) A UG 31, 2006 C LAUS B RABRAND © 2005–2006, University of Aarhus [ ] ["

Similar presentations


Ads by Google