Com S 641 Lecture -*- Outline -*- * first-order calculi (chapter 7) The goal now is to provide a sound type system for the sigma calculus of chapter 6, and to make it as complete as possible. But first we start with the simplest of type systems... First-order means without quantifiers (generic types) ** formal systems (section 7.1) The authors take a somewhat modular approach to designing type systems, composing them from "formal system fragments". The fragments are described in appendix A; each fragment relates to some feature. Q: what is a judgment? A typing environment? Q: what does a judgment that a typing environment is well-formed look like? Q: what does a derivation mean? Q: how does the proof format correspond to a proof tree? Q: what does it mean for a judgment to be valid? ** the object fragment (section 7.2) /\Ob is the formal system fragment for object types. [l_i:B_i i \in 1..n] gives the names and types of methods of an object. Q: why isn't the type of the self variable mentioned in object types? Q: why are object types attached to self variables in method declarations? Q: Could we do without these? Q: why not also declare the return type of a method? Q: do we need to declare these types at all? Q: is the syntax really implicit in the typing rules? Q: why do the rules contain judgments about types being well-formed? Q: can you explain the rules on page 81? Q: does the Type Object rule allow one to prove that [l1:[], l2:[]] = [l2:[], l1:[]] ? Q: in what sense is the Val Object rule circular? Q: why can't the type of a method change when it is updated? Q: can you give an example of an unsoundness that would happen otherwise? Q: does this type system permit subtyping? Q: what would the definition of the free variables of this language be? ** standard first-order fragments (section 7.3) To get a useful language add fragments for variables and constant types. *** variables and environments Q: why does it matter that environments are well formed? Q: can you give an example of an unsoundness that would happen otherwise? *** ground types Q: what is the type K like in lambda Prolog? *** functions and function types these are the rules from the simply-typed lambda calculus *** three typed calculi Q: what is the naming scheme of these calculi? Q: what conventions about equational theories are assumed? Q: what property is to be proved about an equational theory? ** examples (section 7.4) *** a divergent term Q: is possible to give the untyped term [l=s(x)x.l].l another annotation? *** the Booleans Q: how do true and false work? Q: how does if work? Q: why is there not a single type for the Booleans? Q: can you show the derivation tree for true? for if? *** others Q: if we translate \x(x)(x x) into the sigma-calculus, can we annotate it so that it has a type? ** properties of the type system (section 7.5) The goal is to demonstrate the techniques used in studying type systems *** unique types (section 7.5.1) Q: what does the equivalence sign mean in the statement of this theorem? Q: would this property still hold if we did type inference? Q: what would we have to do to recover it? *** subject reduction (section 7.5.2) Q: why do we need to redefine the big-step operational semantics? Q: what is subject reduction? Q: why do we need to assume that the term reduces to a result? Q: is this a soundness or completeness theorem? Q: what is the difference between subject reduction and theorem 7.5-4? Q: why is the absence of stuck states important? Q: how does one "routinely" derive the absence of stuck states from a subject reduction theorem? Q: can you prove a subject reduction theorem for a little-step semantics? We tried to prove lemma 7.5-2. We found that we needed several facts about environments. See the file "environment-lemmas.txt" We also looked at an environment-based semantics and a generalization of the subject reduction theorem. ** first-order equational theories (section 7.6) *** equational rules (section 7.6.1) Q: in what sense is the equational rule for variables limited? Q: how to the equational rules for objects differ from those of the untyped calculus? Q: how does the side condition for the eta rule enforce the usual side condition? *** equality and self (section 7.6.2) selection is not the only operation on objects, update matters Consider the example on page 91 Q: how can we fix this "problem"? Q: does have any practical effect in software engineering? ** functions and fixed points (section 7.7) Q: why do the authors say that the translation is defined on typing derivations? Q: can you explain the translation of the lambda calculus? Q: what does it mean for a typed object calculus to encode a typed lambda calculus? Q: to the type of fix make sense? Q: in what sense are the rules for the recursion operator "validated"?