《Types and Programming Languages》的原文摘录

  • Q: Why bother doing proofs about programming languages? They are almost always boring if the definitions are right. A: The definitions are almost always wrong. (查看原文)
    L142857 2赞 2020-01-04 11:12:29
    —— 引自第66页
  • n one end of the spec- trum are powerful frameworks such as Hoare logic, algebraic specification languages, modal logics, and denotational semantics. These can be used to express very general correctness properties but are often cumbersome to use and demand a good deal of sophistication on the part of programmers. (查看原文)
    L142857 1赞 2019-11-19 21:40:18
    —— 引自第23页
  • At the other end are techniques of much more modest power—modest enough that automatic checkers can be built into compilers, linkers, or program analyzers (查看原文)
    L142857 1赞 2019-11-19 21:40:18
    —— 引自第23页
  • The more abstract focuses on connections between various “pure typed lambda-calculi” and varieties of logic, via the Curry-Howard correspondence (查看原文)
    L142857 1赞 2019-11-19 21:40:18
    —— 引自第24页
  • they can categorically prove the absence of some bad program behaviors, but they cannot prove their presence, (查看原文)
    L142857 1赞 2019-11-19 21:40:18
    —— 引自第24页
  • type systems are also used to enforce higher-level modularity properties and to protect the in- tegrity of user-defined abstractions. (查看原文)
    L142857 1赞 2019-11-19 21:40:18
    —— 引自第25页
  • Chains can be either finite or infinite, but we are more interested in infinite ones, as in the next definition (查看原文)
    L142857 1赞 2019-12-01 13:38:45
    —— 引自第40页
  • The mathemati- cal foundations of inductive reasoning will be considered in more detail in Chapter 21, where we will see that all these specific induction principles are instances of a single deeper idea. (查看原文)
    L142857 1赞 2019-12-01 13:38:45
    —— 引自第41页
  • The first three rules here restate the first clause of Definition 3.2.1; the next four capture clauses (2) and (3). Each rule is read, “If we have established the statements in the premise(s) listed above the line, then we may derive the conclusion below the line.” The fact that T is the smallest set satisfying these rules is often (as here) not stated explicitly. Two points of terminology deserve mention. First, rules with no premises (like the first three above) are often called axioms. In this book, the term inference rule is used generically to include both axioms and “proper rules” with one or more premises. Axioms are usually written with no bar, since there is nothing to go above it. Second, to be completely pedantic, what we are calling “inference rules” are actually rule schemas, ... (查看原文)
    龙三 1赞 2019-06-18 11:01:24
    —— 引自第27页
  • 9.3.1 Lemma [Inversion of the typing relation]: 1. If Γ ⊢ x : R, then x:R ∈ Γ . 2. If Γ ⊢ λx:T1. t2 : R, then R = T1!R2 for some R2 with Γ , x:T1 ⊢ t2 : R2. 3. If Γ ⊢ t1 t2 : R, then there is some type T11 such that Γ ⊢ t1 : T11→R and Γ ⊢ t2 : T11. 4. If Γ ⊢ true : R, then R = Bool. 5. If Γ ⊢ false : R, then R = Bool. 6. If Γ ⊢ if t1 then t2 else t3 : R, then Γ ⊢ t1 : Bool and Γ ⊢ t2, t3 : R . 9.3.3 Theorem [Uniqueness of Types]: In a given typing context 􀀀 , a term t (with free variables all in the domain of 􀀀 ) has at most one type. That is, if a term is typable, then its type is unique. Moreover, there is just one derivation of this typing built from the inference rules that generate the typing relation. 9.3.4 Lemma [Canonical Forms]: 1. If v is a value of type Bool, then v is either ... (查看原文)
    龙三 1赞 2019-06-30 14:41:11
    —— 引自第104页
  • In languages in the ML family, for example, every datatype definition implicitly introduces a recursive type. Each use of one of the constructors to build a value of the datatype implicitly includes a fold, and each constructor appearing in a pattern match implicitly forces an unfold. Similarly, in Java each class definition implicitly introduces a recursive type, and invoking a method on an object involves an implicit unfold. This felicitous overlap of mechanisms makes the iso-recursive style quite palatable in practice. (查看原文)
    龙三 1赞 2019-08-10 13:27:44
    —— 引自第277页
  • lambda演算是Alonzo Church于20世纪20年代发明的一个形式系统,其中所有的计算规约为函数定义和应用的基本运算。 lambda演算广泛用于程序语言特征的说明、语言设计和实现,以及类型系统的研究。他的重要性在于,既可以作为描述计算的一个简单程序语言,同时也可以作为一个数学对象,其中严格语句能够得到证明。 (查看原文)
    Kimmy 2013-04-01 20:55:28
    —— 引自第32页
  • A reference cell need not contain just a number: the primitives above allow us to create references to values of any type, including functions. For example, we can use references to functions to give a (not very efficient) implementation of arrays of numbers, as follows. Write NatArray for the type Ref (Nat → Nat). (查看原文)
    龙三 2019-07-09 22:52:33
    —— 引自第158页
  • To build a new array, we allocate a reference cell and fill it with a function that, when given an index, always returns 0. (查看原文)
    龙三 2019-07-09 22:52:33
    —— 引自第158页
  • To look up an element of an array, we simply apply the function to the desired index. (查看原文)
    龙三 2019-07-09 22:52:33
    —— 引自第158页
  • The interesting part of the encoding is the update function. It takes an array, an index, and a new value to be stored at that index, and does its job by creating (and storing in the reference) a new function that, when it is asked for the value at this very index, returns the new value that was given to update, and on all other indices passes the lookup to the function that was previously stored in the reference. (查看原文)
    龙三 2019-07-09 22:52:33
    —— 引自第158页
  • The typing rules for ref, :=, and ! follow straightforwardly from the behaviors we have given them. (查看原文)
    龙三 2019-07-09 23:10:10
    —— 引自第159页
  • Using dummy lambda-abstractions to control evaluation order is a wellknown trick in the functional programming community. The idea is that an arbitrary expression t can be turned into a function ℷ_:Unit.t, called a thunk. This “thunked form” of t is a syntactic value; all the computation involved in evaluating t is postponed until the thunk is applied to unit. (查看原文)
    龙三 2019-08-03 02:12:03
    —— 引自第239页
  • 形式方法只有到了不理解它何的人们都能使用时才会产生重大影响。 (查看原文)
    animeng 2019-12-21 21:32:24
    —— 引自章节:第1章 引论