Com S 641 meeting -*- Outline -*- * soundness of the typing rules (1.7) ------------------------------------------ SOUNDNESS OF THE TYPING RULES (1.7) Soundness means: Formalizing this: ------------------------------------------ ... each well-typed phrase has a meaning, more precisely, the meaning it has is of the right type Wright and Felleisen (Information and Compuation, Vol 115, No, 1, Nov, 1994) distinguish two varieties of type soundness (both of which are found in the literature as "soundness") Weak soundness: for all stores s, if P:theta is provable, then [[P:theta]](s) ~= Wrong where [[.]] is extended to a function of type ATree Command -> DStore -> (DStore \union {Wrong}) _|_ _|_ (and similarly with [[.]] for expressions...) by assigning the meaning Wrong in all cases where the underlying primitives can't process the data. for example, if "plus" requires 2 integers, then [[E1+E2:int exp]](s) = Wrong when either [[E1:int exp]](s) is a Boolean or [[E2:int exp]](s) is a Boolean look at the semantics for all the other examples. Strong soundness: for all stores s, if P:theta is provable and [[P:theta]](s) = v, then v \in [[theta]](s) (This formulation assumes the meaning of the type takes a store, as it will for commands, but it should be adjusted for other domains, such as numbers.) The idea here is to pratition the space of values according to their types. We also assume that Wrong is not in [[theta]](s) for any type theta and store s. Q: Does strong soundness imply weak soundness? yes, if we assume Wrong is not in [[theta]](s). ... requires we formalize the intended set of meanings (theorem has to be all math) ------------------------------------------ MEANINGS FOR TYPES Attributes: tau ::= int | bool theta ::= int loc | tau exp | comm Meanings for type attributes: [[int]] = Int [[bool]] = Bool [[int loc]] = Location [[tau exp]] = Store -> [[tau]] [[comm]] = Store -> Store _|_ ------------------------------------------ Q: What are some examples of theta? Compare the attributes to the Haskell formulation. Recall what bottom is, lifed notation is the set with bottom ------------------------------------------ SOUNDNESS THEOREM FOR TYPE RULES Thm: For all well-typed phrases, P: theta, [[P:theta]] \in [[theta]] ------------------------------------------ Q: How does the proof go? by induction on the type rules do several cases, have them do the rest N: int exp E1 = E2: bool exp if E then C1 else C2 fi also change the type system, and add boolean literals (note, this makes it unsound in some variations!)