Com S 641 meeting -*- Outline -*- * operational properties of semantics (1.8) ** what is it? ------------------------------------------ OPERATIONAL SEMANTICS Shows computation steps taken by a program Good for: - modeling compiled code - studying efficiency issues - studying concurrent languages Not so good for: - studying program equivalence ------------------------------------------ ** subtree replacement systems *** example ------------------------------------------ USING DENOTATIONAL SEMANTICS AS AN OPERATIONAL SEMANTICS [[loc_3 := @loc_3 + 1: comm]]([5,4,0]) ==> update([[loc_3:intloc]], [[@loc_3+1:intexp]]([5,4,0]), [5,4,0]) ==> ------------------------------------------ continue this... reducing leftmost redex at each stage keep going until get a value *** formalizing this idea ------------------------------------------ SUBTREE REPLACEMENT SYSTEMS Work on texts (phrases). Identify set of Values (answers): Bool values = {true, false} Int values = { ..., -1, 0, 1, ...} Not values: not(false), plus(1,2) Orient equations from left to right: [[skip: comm]](s) ==> s [[n: int]] ==> n def: a subphrase f(e1,...,en) is a *redex* if computation step: replace redex by rhs in the phrase, written p0 ==> p1 computation: a sequence p0 ==> p1 ==> ... ==> pn i.e., p0 ==>* pn ------------------------------------------ ... the ei are all values and f(x1,...,xn) is the lhs of a rule. (we make an exception when f is 'if') Q: When would you say a computation *terminates*? when pn is a value. Q: Could a compuatation ever get "stuck"? Q: What does that have to do with type checking? *** properties ------------------------------------------ PROPERTIES OF SUBTREE REPLACEMENT SYSTEMS Subject reduction: Strong typing: Soundness: Computational adequacy: ------------------------------------------ ... if p:t and p ==>* p', then p':t ... if p:t and p ==>* p', then p' has no operator-operand incompatibilities (i.e., p' is not Wrong) ... if [[p:t]] = m, and p ==>* p', then [[p':t]] = m ... [[p:t]] = m and m is proper iff there is a Value, v, such that p ==>* v and [[v:t]] = m Q: do these hold? why? when? Q: How would you formulate type soundness? Q: What if we had subtyping, how would these change? Q: What's the contrapostitive of computional adequacy.