COP 5021 Lecture -*- Outline -*- * Denotational Semantics (2.2) *** denotational example ------------------------------------------ DENOTATIONAL SEMANTICS OF EXPRESSIONS FOR WHILE LANGUAGE Syntax (1.2): x,y \in Var n \in NumericLiteral a \in AExp b \in BExp op_a \in Op_a op_b \in Op_b op_r \in Op_r a ::= x | n | a1 op_a a2 b ::= true | false | not b | b1 opb b2 | a1 op_r a2 Domains: Z = { ..., -1, 0, 1, ... } T = { true, false } s \in State = Var -> Z Meaning Functions: A : Aexp -> State -> Z A[[x]]s = s(x) A[[n]]s = N(n) A[[a1 op_a a2]]s = (O_a[[op_a]]) (A[[a1]]s) (A[[a2]]s) where N : NumericLiteral -> Z N[[n]] = the value of literal n O_a : Op_a -> (Z x Z -> Z) O_a[[+]] = \n1 n2 . n1 + n2 ... ------------------------------------------ E.g., in C or C++, N[[015]] = 13, since 015 is in octal. Q: Why is the state a parameter to the meaning of arithmetic expressions? it's needed to evaluate variable references Q: How would you define B : Bexp -> (State -> T)? Q: How would you define a tagged union type with operations left, right, and case?