# Translating Generalized Algebraic Data Types to System F

Save this PDF as:

Size: px
Start display at page:

## Transcription

4 (x : ā.c t ) Γ (Var) C [t/a]c (App) C, Γ x : [t/a]t C, Γ e 2 : t 2 C, Γ e 1 : t 2 t C, Γ e 1 e 2 : t (Abs) C, Γ.x : t 1 e : t 2 C, Γ λx.e : t 1 t 2 ( Intro) (Eq) C 1 C 2, Γ e : t ā fv(c 1, Γ) = C 1 ā.c 2, Γ e : ā.c 2 t (Pat) C, Γ e : t C t = t C, Γ e : t (Case) p : t 1 b.(c p Γ p) b fv(c, Γ, t2) = C C p, Γ Γ p e : t 2 C, Γ p e : t 1 t 2 (Let) C, Γ e 1 : σ C, Γ {g : σ} e 2 : t 2 C, Γ let g = e 1 in e 2 : t 2 C, Γ e : t 1 C, Γ p i e i : t 1 t 2 for i I C, Γ case e of [p i e i] i I : t 2 (P-Var) x : t (True {x : t}) K : ā, b.c t 1... t n F ā b ā = (P-K) p i : [t /a]t i b i.(c i Γ pi ) for i = 1,..., n K p 1...p n : F t b 1,..., b n, b.(c 1... C n [t /a]c Γ p1... Γ pn ) Fig.1. GADT Typing Rules We assume familiarity with the concepts of substitutions, unifiers etc [16]. We write ō as a short-hand for a sequence of objects o 1,..., o n (e.g. expressions, types etc). We write [o/a]o to denote applying substitution [o/a] on o, i.e. simultanously replacing all occurrences of variables a i by object o i in o for i = 1,..., n. We write o 1 = o 2 to specify equality among object o 1 and o 2 (a.k.a. unification problem). Sometimes, we write o 1 o 2 to denote syntactic equivalence between two objects o 1 and o 2 in order to avoid confusion with =. We write fv(o) to denote the free variables in some object o. 3 Background: Generalized Algebraic Data Types GADTs first appeared under the name guarded recursive data types [39] and first-class phantom types [6]. Although, the idea of GADTs appears in some even earlier work [40]. Here, we use the more popular becoming name generalized algebraic data types [14]. Our formulation of GADTs as an extension of Hindley/Milner is closest to [31]. Note that all existing variations of GADTs are largely equivalent. The language of expressions, types and constraints is as follows. Expressions e ::= K x λx.e e e let g = e in e case e of [p i e i ] i I Patterns p ::= x K p Types t ::= a t t F t Constraints C ::= t = t C C Type Schemes σ ::= t ᾱ.c t 4

5 For simplicity, we leave out type annotations and recursive function definitions but may make use of them in examples. Pattern matching syntax used in examples can be straightforwardly expressed in terms of case expressions. We assume that K refers to constructors of user-defined data types F ā. Basic types such as booleans, integers, tuples and lists are predefined and their constructors are recorded in some initial environment Γ init. As usual patterns are assumed to be linear, i.e., each variable occurs at most once. We use True as a short-hand for some always satisfiable constraint, e.g. Int = Int. We assume that GADT definitions are pre-processed and the types of their constructors recorded in some initial environment Γ init. E.g., the GADT from Example 1 implies constructors Zero : a.(a = Int) Exp a, Succ : a.(a = Int) Exp Int Exp a and Pair : a, b, c.(a = (b, c)) Exp b Exp c Exp a. This explains the need for constrained type schemes of the form ā.c t. The typing rules describing well-typing of expressions are in Figure 1. We introduce judgments C, Γ e : t to denote that expression e has type t under constraint C and environment Γ which holds a set of type bindings of the form x : σ. A judgment is valid if we find a derivation w.r.t. the typing rules. In rule (Var), we build a type instance of a type scheme by demanding that the instantiated constraint is entailed by the given constraint. This is formally expressed by C [t/a]c. Note that C t 1 = t 2 holds iff (1) C does not have a unifier, or (2) for any unifier φ of C we have that φ(t 1 ) = φ(t 2 ) holds. Rule ( Intro) is the familiar HM(X) [21, 33] quantifier introduction rule. Note that our constraint language does not support existential quantification explicitly. However, w.l.o.g. the constraint ā.c 2 is equivalent to some constraint C 3 consisting of type equations only. Rules (Abs), (App), (Case) and (Let) are standard. The only worth mentioning point is that we consider p e as a (special purpose) expression only appearing in intermediate steps. Next, we consider the GADT specific rules. In rule (Eq) we are able to change the type of an expression. 1 In rule (Pat) we make use of an auxiliary judgment p : t b.(c p Γ p ) which establishes a relation among pattern p of type t, the constraint C p arising out of p and the binding Γ p of variables in p. Variables b refer to all existential variables. Logically, these variables must be considered as universally quantified. Hence, we write b. The side condition b fv(c, Γ, t 2 ) = prevents existential variables from escaping. A common property for typing derivations involving constraints is that if the constraint in the final judgment is satisfiable all constraints arising in intermediate judgments are satisfiable too. This property is lost here as the following variation of Example 1 shows. eval :: Exp Bool -> (Int->Int) eval Zero = 0 Matching the pattern Zero against the type Exp Bool leads to the temporary type constraint Bool = Int. This constraint is equivalent to False. Thus, we can 1 Some formulations allow to change the type of (sub)patterns [31]. This may matter if patterns are nested. For brevity, we neglect such an extension. Note that in case patterns are evaluated in a certain order, say from left-to-right, we can simply translate a nested pattern into a sequence of shallow patterns. This is done in GHC. 5

6 give any type to 0 and therefore eval s rather strange looking type is correct. Note that False does not appear in the final judgment. Cheney and Hinze [6] observed that such programs are meaningless because there is no value of type Exp Bool. Hence, we can never apply eval (under its new type) to a concrete value. We can rule out such meaningless programs by demanding that all constraints in a typing derivation must be satisfiable, i.e. have a unifier. Assumption 1 W.l.o.g. we assume that for any GADT typing derivation we have that all constraints in typing judgments have a unifier. The important consequence is that the entailment test between constraints is now constructive. We exploit this fact in the following section where we represent type equation proofs via well-typed programs. 4 Translating Generalized Algebraic Data Types We proceed in three steps. First, we introduce the syntax and static semantics of System F s. Typing in System F s is staged whereas the dynamic semantics remains essentially unchanged compared to System F. Then, we define a proof system to represent GADT type equations by proof terms typable in System F. Finally, we give a type-directed translation scheme from GADTs to System F s where we insert proof terms to mimic GADT type conversions. Proof terms are staged and evaluate to the identity at run-time. Hence, we can safely remove them without affecting the semantic meaning of the original GADT program. Note that we could achieve our technical results using System F directly. However, we feel that System F s helps to understand the separation between proof terms representing type conversions and the real program text. 4.1 An Extension of System F with Staged Typing System F s inherits the syntax of expressions and types from System F. Target E ::= x E E λx : T.E E [T] Λā.E < E > let g : T = E in E case (T)E of [P i E i ] i I Patterns P ::= (x : T) K b P < P > Types T ::= a T T < T > ā.t The only extension is the staging operator <> which allows us to form staged expressions, patterns and types. We assume that type bindings (x : l T) and judgments E : T carry some stage information; a natural number l. The typing rules in Figure 2 guarantee that lower staged expressions/patterns cannot affect the type of higher staged expressions/patterns and vice versa. See rules (Var), (<> ) and (P-<>). The only exception is rule (<> ) where a staged expression has a unstaged type. As we will see, via this rule we will mimic the GADT (Eq) rule. Note that constructors are explicitly annotated with the set of existential variables. See rule (P-K). The remaining rules contain no surprises as they leave the stage l unchanged. Commonly, we write {x 1 : T 1,..., x n : T n } Fs E : T as a short-hand for {x 1 : 1 T 1,..., x n : 1 T n } 1 F s E : T. We write Γ F E : T to denote a System F 6

7 (Abs) Γ {x : l T 1} l F s E : T 2 λx : T 1.E : T 1 T 2 (App) Γ l F s E 1 : T 1 T 2 E 2 : T 1 E 1 E 2 : T 2 (T-Abs) Γ l F s E : T ā fv(γ) = Λā.E : ā.t (Var) (x :l ā.t) Γ x : ā.t (Let) E : T (Case) P i E i : T T for i I case (T )E of [P i E i] i I : T Γ l F (T-App) s E : ā.t E [T] : [T/a]T E : ā.t Γ {g : l ā.t } l F s E : T let g : ā.t = E in E : T (Pat) P : T 1 l F s b.γ P b fv(γ, T2) = Γ P E : T 2 P E : T 1 T 2 Γ l+1 F (<> ) s E : T < E >:< T > (<> ) Γ l+1 F s E : T 1 T 2 < E >: T 1 T 2 (P-Var) (x : T) : T l F s {x : l T } P : T l+1 F (P-<>) s b.γ < P >:< T > l F s b.γ K b : ā, b.t 1... T n F ā b ā = P i : [T /a]t i l F (P-K) s b i.γp i for i = 1,..., n c = b 1,..., b n, b Γ = Γ P1... Γ Pn K b b P1...P n : F [T /a] l F s c.γ Fig.2. System F s Typing Rules derivation where we do not make use of the staged rules (<> ), (<> ) and (P-<>). We explain the dynamic semantics of System F s in terms of a standard single-step rewriting semantics [38] written E E. This gives rise to a system of reductions where each expression E either reduces (or evaluates) to a value v, written E v, or we encounter failure (this includes the case that the reduction gets stuck). We assume that staged expressions and patterns follow the same evaluation rules. That is, we simply replace < E > by E and < P > by P before evaluation. The entire development is standard and can be found elsewhere [38,23]. Hence, we omit the details. 4.2 Proof Terms for Type Equations We define a proof system for representing (syntactic) equality among types where type equations carry proof terms. We write (f : g) : t 1 = t 2 to denote that (f, g) is the proof for t 1 = t 2. Depending on the context, we may silently drop proof terms if they do not matter. The proof rules are formulated in terms of judgments C = (f, g) : t 1 = t 2. They are directly derived from a constructive formulation of type equality. Details are in Figure 3. Rule (Var) looks up an equality constraint. For convenience, we interpret a constraint as a set of type equations. Rules (Ref) and (Sym) describe reflexivity and symmetry of equality. In rule (Trans), we write f g as a short-hand for 7

8 (Var) (f, g) : t 1 = t 2 C C = (f, g) : t1 = t2 (Ref) C = (λx.x,λx.x) : t = t (Sym) C = (f, g) : t 1 = t 2 C = (g, f) : t 2 = t 1 (Trans) C = (f1, g1) : t1 = t2 C = (f2, g2) : t2 = t3 C = (f 2 f 1, g 1 g 2) : t 1 = t 3 (F ) C = (f, g) : F t 1...t n = F t (F 1...t n i) C = (decompff i [ t t ] (f, g),decompfg i [ t t ] (f, g)) : t i = t i C = (f i, g i) : t i = t i for i = 1,..., n C = (compff [ t t ] (f 1, g 1)...(f n, g n),compfg [ t t ] (f 1, g 1)...(f n, g n)) : F t = F t Fig.3. Type Equation Proof System λx.f (g x) to define a proof term representing transitivity. Rules (F ) and (F i ) deal with user-defined types F ā (including the function type). Recall that t and t are short-hands for t 1,..., t n and t 1,..., t n. We have that F t 1...t n = F t 1...t n iff t i = t i for i = 1,..., n. Our task is to associate appropriate proof terms to each type equation. For this purpose, we assume the following set of composition and decomposition functions whose types are recorded in some initial proof environment Γ proof compff : a, b.(a 1 b 1, b 1 a 1 )... (a n b n, b n a n ) (F ā F b) compfg : a, b.(a 1 b 1, b 1 a 1 )... (a n b n, b n a n ) (F b F ā) decompff i : a, b.(f ā F b, F b F ā) (a i b i ) decompfg i : a, b.(f ā F b, F b F ā) (b i a i ) It is straightforward to verify that proof terms are typable in System F. Let C (f 1, g 1 ) : t 1 = t 1... (f n, g n ) : t n = t n. We write C Γ to denote the conversion of constraint C into a type environment Γ = {f 1 : t 1 t 1, g 1 : t 1 t 1,..., f n : t n t n, g n : t n t n }. Lemma 1 (Typability). Let C = (E 1, E 2 ) : t = t such that C Γ. Then, Γ Γ proof F E 1 : t t and Γ Γ proof F E 2 : t t. Next, we show that well-typed proof terms are sound. We follow [38] and give meaning to primitive functions such as decompff i,decompfg i,compff and compfg in terms of a function δ : (Primitive ClosedVal) ClosedVal that interprets the application of primitive functions to closed input values and yields closed output values. Thus, we define the rewrite rule primitive v 1...v n δ(c v 1...v n ) if δ(primitive v 1...v n ) is defined For each composition and decomposition primitive for type F a 1...a n we define δ(compff [t 1...t n t 1...t n ] (v 1, v 1 )...(v n, v n )) = λx.x δ(compff [t 1...t n t 1...t n ] (v 1, v 1 )...(v n, v n )) = λx.x δ(decompff i [t 1...t n t 1...t n ] (v 1, v 2 )) = λx.x δ(decompfg i [t 1...t n t 1...t n] (v 1, v 2 )) = λx.x 8

9 if t j t j (i.e. t j and t j are syntactically equal) for j = 1,..., n. Note that the δ function is undefined in case t j and t j are syntactically different. Hence, there is the danger that the reduction of well-typed proof terms gets stuck. The important observation is that = (E 1, E 2 ) : t 1 = t 2 implies that t 1 and t 2 must be syntactically equal. Hence, during the reduction of proof terms E 1 and E 2 we can guarantee that whenever one of the above primitives is applied to a sequence of closed values [t 1...t n t 1...t n] v 1...v n the condition t j t j for j = 1,..., n is always satisfied. This observation is formalized in the following result. For clarity, we enumerate the individual statements. Lemma 2 (Subject Reduction). Let C = (E 1, E 2 ) : t 1 = t 2 such that (1) for each (f, g) : t = t C we have that t t, (2) E 1 E 1, (3) E 2 E 2 and (4) C Γ for some E 1, E 2 and Γ. Then, (5) t 1 t 2, (6) Γ Γ proof F E 1 : t 1 t 2 and (7) Γ Γ proof F E 2 : t 2 t 1. In order to obtain type soundness, we yet need to verify that well-typed proof terms do not get stuck. We omit the straightforward details. We summarize the results of this section. Proof terms are well-typed and evaluate to the identity function. 2 Theorem 1. Let = (E 1, E 2 ) : t 1 = t 2. Then, (1) t 1 t 2, (2) Γ proof F E 1 : t 1 t 2, (3) Γ proof F E 2 : t 2 t 1, (4) E 1 λx.x and (5) E 2 λx.x. Note that proof term construction is decidable. That is, given C and t 1, t 2 where C has a unifier, there is a decidable algorithm which either finds E 1 and E 2 such that C = (E 1, E 2 ) : t 1 = t 2 or C t 1 = t 2 does not hold. Due to space limitations, we refer the interested reader to [34]. 4.3 Type-Directed Translation Scheme We are in the position to define the translation of GADTs to System F s. For translation purposes, we assume that type constraints t 1 = t 2 in GADT constructors are annotated with proof terms (f, g) where f and g are distinct variables. In a preprocessing step, we translate each GADT constructor K : ā, b.(f 1, g 1 ) : t 1 = t 1... (f n, g n ) : t n = t n ) t 1... t n F ā to a System F s constructor K b : ā, b. < (t 1 t 1, t 1 t 1,..., t n t n, t n t n) > t 1... t n F ā where type constraints are turned into additional (staged) arguments. The actual translation scheme is formulated in terms of judgments C, Γ e : t E. For simplicity, we only consider the most interesting rules. Details are in Figure 4. In rule (Var), we must provide proof terms to satisfy the instantiated constraint [t/a]c. For convenience, we assume that there is a fixed order among 2 Strictly speaking, when applied to a value proof terms behave like the identity function, see rule (Trans) in Figure 3. Though, we could introduce a transitivity primitive which always evaluates to the identity similar to the composition and decomposition primitives. 9

10 (Var) (Eq) (x : ā.c t ) Γ C (f 1, g 1) : t 1 = t 1... (f n, g n) : t n = t n for each t i = t i [t/a]c we have that C = (E i, E i) : t i = t i C, Γ x : [t/a]t x [t] < (E 1, E 1,..., E n, E n) > C, Γ e : t E C = (E, E ) : t = t C, Γ e : t < E > E ( Intro) C 1 C 2, Γ e : t E ā fv(c 1, Γ) = C 2 (f 1, g 1) : t 1 = t 1... (f n, g n) : t n = t n C 1 ā.c 2, Γ e : ā.c 2 t Λā.λ < (f 1, g 1,..., f n, g n) >:< (t 1 t 1, t 1 t 1,..., t n t n, t n t n) >.E (Pat) (P-Var) (P-K) p : t 1 b.(c p Γ p) P b fv(c, Γ, t2) = C C p, Γ Γ p e : t 2 E C, Γ p e : t 1 t 2 P E x : t (True {x : t}) x K : ā, b.c t 1... t n F ā C (f 1, g 1) : t 1 = t 1... (f n, g n) : t n = t n ) b ā = p i : [t /a]t i b i.(c i Γ pi ) P i for i = 1,..., n ( K p 1...p n : F t b 1,..., b n, b.c 1... C n [t /a]c Γ p1... Γ pn ) K b < (f 1, g 1,..., f n, g n) > P 1...P n Fig. 4. Type-Directed Translation (interesting cases) type equations t i = t i in [t/a]c. We are a bit sloppy here and simply drop the proof terms associated to t i = t i. Based on Assumption 1 we know that C = E i : t i = t i holds iff C t i = t i. The same observations applies in case of rule (Eq) where we apply proof term E to maintain well-typing of expressions. In rule ( Intro), we turn constraints in type schemes into additional proof term parameters. For convenience, we use pattern syntax in λ-abstraction. The main tasks of rules (Pat), (Pat-Var) and (Pat-K) are to translate patterns which now may contain proof terms. The left out rules are the familiar ones for translating Hindley/Milner to System F [10]. We can verify that resulting expressions are typable in System F s. E.g., consider rule (Eq). Let C Γ C. We write ΓC 2 and Γ proof 2 to denote that the type bindings are at stage 2. Then, ΓC 2 Γ proof 2 2 F s E : t t (follows from Lemma 1). Via the System F s rules (<> ) and (App), we can conclude that ΓC 2 Γ proof 2 Γ 1 F s < E > E : t. Similar reasoning steps apply to the other rules. We can also verify that the evaluation of resulting expressions cannot go wrong. System F s inherits the System F type soundness result. By construction, 10

11 the evaluation of proof terms is independent of the surrounding program text (this is explicitly enforced by the System F s typing rules). Hence, Theorem 1 (proof terms cannot go wrong) is applicable and therefore the translated program cannot go wrong. We summarize. Theorem 2 (Type Preservation and Soundness). Let True, e : t E. Then, Γ 2 proof 1 F s E : t and E v for some value v. 3 Theorem 1 (proof terms evaluate to the identity) also guarantees that proof terms do not affect the semantic meaning of the GADT program. Hence, we can safely erase them. Hence, the original GADT program is equivalent to the resulting System F s program after erasing proof terms and types. Corollary 1. Let e : t E. Then, E(E) = e. The erasure function E() is defined following the structure of possible target and pattern terms: E(E [T]) = E(E) E(Λā.E) = E(E) E(E 1 E 2 ) = E(E 1 ) E(E 2 ) E(λx : T.E) = λx.e(e) E(< E 1 > E 2 ) = E(E 2 ) E(x [T] < E >) = x E(let g : T = E in E ) = let g = E(E)in E(E ) E(x) = x E(case (T)E of [P i E i ] i I ) = case E(E)of [E(P i ) E(E i )] i I E(K < E > P 1...P n ) = K E(P 1 )...E(P n ) E(x : T) = x Another immediate consequence is the following result. Corollary 2. Well-typed GADT programs cannot go wrong. 5 Direct Translation of GADTs to Existential Types A number of authors [1, 4,5, 22,37] have shown by example that GADT style behavior can often be directly encoded in terms of existing languages such as Haskell [11]. The following (non-sensical) example shows that a source-level encoding is not always possible. Example 2. Consider data Erk a = (Int->Int=a->Int) => I a f :: Erk a->a f (I x) = 0 which is clearly type correct. Note that Int Int = a Int iff Int = a. Our translation method yields data Erk a = I <((Int->Int)->(a->Int),(a->Int)->(Int->Int))> a f = Λ y:erk a.case y of I <(f,g)> x -> <decomp [a Int Int Int] (f,g)> 0 3 In case we extend the source language with recursive functions we need the additional case that reduction of E may not terminate. 11

13 6 Extensions with User-Specifiable Type Equality We provide evidence that our translation method scales to extensions where type equality is user-specifiable. For concreteness, we use the associated types (AT) formalism [2] to represent type equality definitions. Our task is to represent AT type definitions by extending the proof system in Section 4.2. As a simple example, we define a extended GADT to represent a while language which satisfies a resource usage policy specified in terms of a DFA. The DFA transitions are specified via AT type functions. In the extended GADT, we make use of these type functions. Example 3. Here is an excerpt of a possible specification. -- states type S0; type S1 -- alphabet type Open; type Write; type Close -- transition function type Delta S0 Open = S1 -- (1) type Delta S1 Close = S0 -- (2) type Delta S1 Write = S1 -- (3) -- Resource GADT data Cmd p q = forall r. Seq (Cmd p r) (Cmd r q) ITE Exp (Cmd p q) (Cmd p q) (p=q) => While Exp (Cmd p q) -- while state is invariant (Delta p Open = q) => OpenF (Delta p Close = q) => CloseF (Delta p Write = q) => WriteF We introduce type function Delta and some type constants to specify the resource DFA in terms of (type) function definitions (1-3). We make use of these assumptions when defining the GADT Cmd p q where type parameters p and q represent the input and output state, before and after execution of the command. We can translate programs making use of such extended GADTs by appropriately extending our proof system in Section 4.2. For the above example, we define (D1) C = (f 1, g 1 ) : Delta S0 Open = S1 (D2) C = (f 2, g 2 ) : Delta S1 Close = S0 (D3) C = (f 3, g 3 ) : Delta S1 Write = S1 where f 1 : Delta S0 Open S1, g 1 : S1 Delta S0 Open etc are in Γ proof, and δ(f 1 v) = λx.x if typeof (v) = S1, δ(g 1 v) = λx.x if typeof (v) = Delta S0 Open etc. Function typeof () retrieves the type of a value. Let s consider another (contrived) example. We define type F [a] = [F a], i.e. for any a we have that F [a] and [F a] are equal. The corresponding proof rule is as follows. (F) C = (upf [t], downf [t]) : F [t] = [F t] 13

16 29. T. Sheard. Omega. sheard/omega/index.html. 30. T. Sheard. Languages of the future. SIGPLAN Not., 39(10): , V. Simonet and F. Pottier. Constraint-based type inference for guarded algebraic data types. Research Report 5462, INRIA, January P. J. Stuckey and M. Sulzmann. Type inference for guarded recursive data types. sulzmann, Draft. 33. M. Sulzmann. A General Framework for Hindley/Milner Type Systems with Constraints. PhD thesis, Yale University, Department of Computer Science, May M. Sulzmann and M. Wang. A systematic translation of guarded recursive data types to existential types. Technical Report TR22/04, The National University of Singapore, W. Taha. Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology, P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In Proc. of POPL 89, pages ACM Press, S. Weirich. Type-safe cast: (functional pearl). In Proc. of ICFP 00, pages ACM Press, A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Inf. Comput., 115(1):38 94, H. Xi, C. Chen, and G. Chen. Guarded recursive datatype constructors. In Proc. of POPL 03, pages ACM Press, C. Zenger. Indizierte Typen. PhD thesis, Universität Karlsruhe, A Translating Type Classes in the Presence of Type Improvement User-specifiable type equations also arise in the context of type classes [36, 15] with type improvement [12]. For concreteness, we consider the associated types (ATs) [3, 2] (improvement) formalism. Similar observations apply to other formalisms such as functional dependencies [13]. Example 4. Consider the following AT program class C a where type F a -- (1) class D a where d :: C a => F a->f a instance C Int where type F Int = Bool -- (2) instance D Int where d x = x && True -- (3) Type class C introduces a type function F (see (1)) whose concrete definitions are provided by the instance declarations (see (2)). Effectively, we state that the type F Int can be improved to Int and vice versa. Type class D introduces a method which is locally constrained by the type class C. Note that the second input and result type are constrained by the type F a. We verify type correctness of instance definition (3). Let us assume thatxhas type F Int. Based on (2) we can improve x s type to Bool. Hence, expression x && True has type Bool. which can be improved to F Int. Hence, the definition is correct. 16

17 Existing translation schemes [3, 2] use System F as their target language. For the above program, the only choice we have is to replace type F a by a universally quantified variable b and add b as a parameter to type class C. Then, the translation of definition (3) is as follows. data C a b =... d = Λ b λ d:c b. λ x:b. x && True However, the above translation is not type correct. Variable x has the universal type b but is conjoined with True. Thus, x must have type Bool which leads to a contradiction. The above program is contrived, but similar examples crop up all the time on the Haskell mailing list. The bottom line is this. Existing implementations [7] rely on System F as their target language. Hence, some sensible programs are rejected. On the other hand, in a translation scheme based on System F s we can represent the type equation F Int=Bool via primitives f1:f Int->Bool and g1:bool->f Int. Thus, definition (3) can be translated as follows while preserving well-typing. d = λ d:c Int. λ x:f Int. <g1>((<f1> x) && Bool) Here is another AT example. Example 5. Consider type F a data G a = forall b. (F a=b) => K (b->b) f (K h1) (K h2) = K (h1.h2) translates to data G a = forall b. (F a=b) => K (F a->b,b->f a) (b->b) f (K <(f1,g1)> h1) (K <(f2,g2>) h2) = K <(f2,g2)> (\x->(<f2> (<g1> (h1 (<f1> (<g2> (h2 x))))))) 17

### OutsideIn(X) Modular type inference with local assumptions

Under consideration for publication in J. Functional Programming 1 OutsideIn(X) Modular type inference with local assumptions 11 April 2011 Dimitrios Vytiniotis Microsoft Research Simon Peyton Jones Microsoft

### Aspect-Oriented Programming with Type Classes

Aspect-Oriented Programming with Type Classes Martin Sulzmann School of Computing, National University of Singapore S16 Level 5, 3 Science Drive 2, Singapore 117543 sulzmann@comp.nus.edu.sg Meng Wang School

### POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful RALF HINZE Institute of Information and Computing Sciences Utrecht University Email: ralf@cs.uu.nl Homepage: http://www.cs.uu.nl/~ralf/

### Type Classes with Functional Dependencies

Appears in Proceedings of the 9th European Symposium on Programming, ESOP 2000, Berlin, Germany, March 2000, Springer-Verlag LNCS 1782. Type Classes with Functional Dependencies Mark P. Jones Department

First Class Overloading via Insersection Type Parameters Elton Cardoso 2, Carlos Camarão 1, and Lucilia Figueiredo 2 1 Universidade Federal de Minas Gerais, camarao@dcc.ufmg.br 2 Universidade Federal de

### The countdown problem

JFP 12 (6): 609 616, November 2002. c 2002 Cambridge University Press DOI: 10.1017/S0956796801004300 Printed in the United Kingdom 609 F U N C T I O N A L P E A R L The countdown problem GRAHAM HUTTON

### Introduction to type systems

Introduction to type systems p. 1/5 Introductory Course on Logic and Automata Theory Introduction to type systems Polyvios.Pratikakis@imag.fr Based on slides by Jeff Foster, UMD Introduction to type systems

### Types, Polymorphism, and Type Reconstruction

Types, Polymorphism, and Type Reconstruction Sources This material is based on the following sources: Pierce, B.C., Types and Programming Languages. MIT Press, 2002. Kanellakis, P.C., Mairson, H.G. and

### Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic Lars Birkedal Rasmus Ejlers Møgelberg Rasmus Lerchedahl Petersen IT University Technical Report Series TR-00-7 ISSN 600 600 February 00

### Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML

Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML Xavier Leroy École Normale Supérieure Michel Mauny INRIA Rocquencourt Abstract Objects with dynamic types allow the integration

### Chapter 7: Functional Programming Languages

Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language

### Elementary Number Theory We begin with a bit of elementary number theory, which is concerned

CONSTRUCTION OF THE FINITE FIELDS Z p S. R. DOTY Elementary Number Theory We begin with a bit of elementary number theory, which is concerned solely with questions about the set of integers Z = {0, ±1,

### Applied Type System. (Extended Abstract) Hongwei Xi. Boston University. Abstract. The framework Pure Type System (PTS) offers a simple

Applied Type System (Extended Abstract) Hongwei Xi Boston University Abstract. The framework Pure Type System (PTS) offers a simple and general approach to designing and formalizing type systems. However,

### Lecture 2: Universality

CS 710: Complexity Theory 1/21/2010 Lecture 2: Universality Instructor: Dieter van Melkebeek Scribe: Tyson Williams In this lecture, we introduce the notion of a universal machine, develop efficient universal

### Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

### Programming Languages Featherweight Java David Walker

Programming Languages Featherweight Java David Walker Overview Featherweight Java (FJ), a minimal Javalike language. Models inheritance and subtyping. Immutable objects: no mutation of fields. Trivialized

### THREE DIMENSIONAL GEOMETRY

Chapter 8 THREE DIMENSIONAL GEOMETRY 8.1 Introduction In this chapter we present a vector algebra approach to three dimensional geometry. The aim is to present standard properties of lines and planes,

### Improving type-error messages in functional languages

Improving type-error messages in Bastiaan Heeren Universiteit Utrecht January 5, 200 Contents Introduction Constraints Type inference rules Solving constraints Solving inconsistencies Future work Conclusion

### CS510 Software Engineering

CS510 Software Engineering Propositional Logic Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-cs510-se

### From Program Verification to Certified Binaries

From Program Verification to Certified Binaries The Quest for the Holy Grail of Software Engineering Angelos Manousaridis, Michalis A. Papakyriakou, and Nikolaos S. Papaspyrou National Technical University

### Translating a Subset of OCaml into System F. Jonatha Protzenk under the dire ion of François Po ier

Translating a Subset of OCaml into System F Jonatha Protzenk under the dire ion of François Po ier June I Some background 1 Motivations Contents I Some background 2 1 Motivations 2 2 A high-level description

### Chapter II. Controlling Cars on a Bridge

Chapter II. Controlling Cars on a Bridge 1 Introduction The intent of this chapter is to introduce a complete example of a small system development. During this development, you will be made aware of the

### Unboxed Polymorphic Objects for Functional Numerical Programming

Unboxed Polymorphic Objects for Functional Numerical Programming Christopher Rodrigues cirodrig@illinois.edu Wen-Mei Hwu w-hwu@illinois.edu IMPACT Technical Report IMPACT-12-02 University of Illinois at

### CHAPTER 7 GENERAL PROOF SYSTEMS

CHAPTER 7 GENERAL PROOF SYSTEMS 1 Introduction Proof systems are built to prove statements. They can be thought as an inference machine with special statements, called provable statements, or sometimes

### 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

### Fun with Phantom Types

1 Fun with Phantom Types RALF HINZE Institut für Informatik III, Universität Bonn Römerstraße 164, 53117 Bonn, Germany Email: ralf@informatik.uni-bonn.de Homepage: http://www.informatik.uni-bonn.de/~ralf

### CHAPTER 3 Numbers and Numeral Systems

CHAPTER 3 Numbers and Numeral Systems Numbers play an important role in almost all areas of mathematics, not least in calculus. Virtually all calculus books contain a thorough description of the natural,

### Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Functional Programming Languages Chapter 14 Introduction Functional programming paradigm History Features and concepts Examples: Lisp ML 1 2 Functional Programming Functional Programming Languages The

### Harmless Advice. Daniel S Dantas Princeton University. with David Walker

Harmless Advice Daniel S Dantas Princeton University with David Walker Aspect Oriented Programming Aspect Oriented Programming IBM - 2004 IBM reports positive results in aspect-oriented programming experiments

### A Framework for the Semantics of Behavioral Contracts

A Framework for the Semantics of Behavioral Contracts Ashley McNeile Metamaxim Ltd, 48 Brunswick Gardens, London W8 4AN, UK ashley.mcneile@metamaxim.com Abstract. Contracts have proved a powerful concept

### System Description: Delphin A Functional Programming Language for Deductive Systems

System Description: Delphin A Functional Programming Language for Deductive Systems Adam Poswolsky 1 and Carsten Schürmann 2 1 Yale University poswolsky@cs.yale.edu 2 IT University of Copenhagen carsten@itu.dk

### OPERATIONAL TYPE THEORY by Adam Petcher Prepared under the direction of Professor Aaron Stump A thesis presented to the School of Engineering of

WASHINGTON NIVERSITY SCHOOL OF ENGINEERING AND APPLIED SCIENCE DEPARTMENT OF COMPTER SCIENCE AND ENGINEERING DECIDING JOINABILITY MODLO GROND EQATIONS IN OPERATIONAL TYPE THEORY by Adam Petcher Prepared

### [Refer Slide Time: 05:10]

Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture

### Computer Science at Kent

Computer Science at Kent Transformation in HaRe Chau Nguyen-Viet Technical Report No. 21-04 December 2004 Copyright 2004 University of Kent Published by the Computing Laboratory, University of Kent, Canterbury,

### Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

### The Goldberg Rao Algorithm for the Maximum Flow Problem

The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }

### Ralf Hinze Generic Programs and Proofs

Ralf Hinze Generic Programs and Proofs Bonn, 2000 Für Anja, Lisa und Florian Brief contents 1 Introduction 1 2 Background 15 3 Generic programs 53 4 Generic proofs 87 5 Examples 107 6 Generic Haskell 147

### Chapter 15 Functional Programming Languages

Chapter 15 Functional Programming Languages Introduction - The design of the imperative languages is based directly on the von Neumann architecture Efficiency (at least at first) is the primary concern,

### A Propositional Dynamic Logic for CCS Programs

A Propositional Dynamic Logic for CCS Programs Mario R. F. Benevides and L. Menasché Schechter {mario,luis}@cos.ufrj.br Abstract This work presents a Propositional Dynamic Logic in which the programs are

### Extraction of certified programs with effects from proofs with monadic types in Coq

Extraction of certified programs with effects from proofs with monadic types in Coq Marino Miculan 1 and Marco Paviotti 2 1 Dept. of Mathematics and Computer Science, University of Udine, Italy 2 IT University

### The Clean programming language. Group 25, Jingui Li, Daren Tuzi

The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was

### Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)

### Formal Engineering for Industrial Software Development

Shaoying Liu Formal Engineering for Industrial Software Development Using the SOFL Method With 90 Figures and 30 Tables Springer Contents Introduction 1 1.1 Software Life Cycle... 2 1.2 The Problem 4 1.3

### Predicate Logic Review

Predicate Logic Review UC Berkeley, Philosophy 142, Spring 2016 John MacFarlane 1 Grammar A term is an individual constant or a variable. An individual constant is a lowercase letter from the beginning

### Formal Verification Coverage: Computing the Coverage Gap between Temporal Specifications

Formal Verification Coverage: Computing the Coverage Gap between Temporal Specifications Sayantan Das Prasenjit Basu Ansuman Banerjee Pallab Dasgupta P.P. Chakrabarti Department of Computer Science & Engineering

### Object-Oriented Software Specification in Programming Language Design and Implementation

Object-Oriented Software Specification in Programming Language Design and Implementation Barrett R. Bryant and Viswanathan Vaidyanathan Department of Computer and Information Sciences University of Alabama

### Advanced Functional Programming (9) Domain Specific Embedded Languages

Advanced Functional Programming (9) Domain Specific Embedded Languages Advanced Functional Programming (9) Domain Specific Embedded Languages, Universiteit Utrecht http://www.cs.uu.nl/groups/st/ February

### InvGen: An Efficient Invariant Generator

InvGen: An Efficient Invariant Generator Ashutosh Gupta and Andrey Rybalchenko Max Planck Institute for Software Systems (MPI-SWS) Abstract. In this paper we present InvGen, an automatic linear arithmetic

### Practical Generic Programming with OCaml

Practical Generic Programming with OCaml Jeremy Yallop LFCS, University of Edinburgh ML Workshop 2007 Instead of this... type α tree = Node of α Branch of (α tree) (α tree) val show_tree : (α string) (α

### 263-2200 Types and Programming Languages

263-2200 Types and Programming Languages 1 / 49 Outline Types Evaluation Rules Typing Rules Properties of the Typing Relation The Inversion Lemma Prolog Implementation Reasoning Involving Types Progress

### A Note on Context Logic

A Note on Context Logic Philippa Gardner Imperial College London This note describes joint work with Cristiano Calcagno and Uri Zarfaty. It introduces the general theory of Context Logic, and has been

### Correspondence analysis for strong three-valued logic

Correspondence analysis for strong three-valued logic A. Tamminga abstract. I apply Kooi and Tamminga s (2012) idea of correspondence analysis for many-valued logics to strong three-valued logic (K 3 ).

### Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

### Simulation-Based Security with Inexhaustible Interactive Turing Machines

Simulation-Based Security with Inexhaustible Interactive Turing Machines Ralf Küsters Institut für Informatik Christian-Albrechts-Universität zu Kiel 24098 Kiel, Germany kuesters@ti.informatik.uni-kiel.de

### The Student-Project Allocation Problem

The Student-Project Allocation Problem David J. Abraham, Robert W. Irving, and David F. Manlove Department of Computing Science, University of Glasgow, Glasgow G12 8QQ, UK Email: {dabraham,rwi,davidm}@dcs.gla.ac.uk.

### Deterministic Discrete Modeling

Deterministic Discrete Modeling Formal Semantics of Firewalls in Isabelle/HOL Cornelius Diekmann, M.Sc. Dr. Heiko Niedermayer Prof. Dr.-Ing. Georg Carle Lehrstuhl für Netzarchitekturen und Netzdienste

### Compiler Design. Type Checking

Compiler Design Type Checking Static Checking Token Stream Parser Abstract Syntax Tree Static Checker Decorated Abstract Syntax Tree Intermediate Code Generator Intermediate Code Static (Semantic) Checks

### Verifying Semantic of System Composition for an Aspect-Oriented Approach

2012 International Conference on System Engineering and Modeling (ICSEM 2012) IPCSIT vol. 34 (2012) (2012) IACSIT Press, Singapore Verifying Semantic of System Composition for an Aspect-Oriented Approach

### Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

### Andrew Pitts chapter for D. Sangorgi and J. Rutten (eds), Advanced Topics in Bisimulation and Coinduction, Cambridge Tracts in Theoretical Computer

Andrew Pitts chapter for D. Sangorgi and J. Rutten (eds), Advanced Topics in Bisimulation and Coinduction, Cambridge Tracts in Theoretical Computer Science No. 52, chapter 5, pages 197 232 ( c 2011 CUP)

### Transformation Techniques for Constraint Logic Programs with Applications to Protocol Verification

UNIVERSITÀ DEGLI STUDI DI ROMA TOR VERGATA FACOLTÀ DI INGEGNERIA DOTTORATO DI RICERCA IN INFORMATICA ED INGEGNERIA DELL AUTOMAZIONE XX CICLO Transformation Techniques for Constraint Logic Programs with

### Indexed Types in Object-Oriented Programming

Indexed Types in Object-Oriented Programming Joana Campos and Vasco T. Vasconcelos University of Lisbon, Faculty of Sciences, LaSIGE Abstract. Dependent type systems allow semantic properties to be expressed

### A first step towards modeling semistructured data in hybrid multimodal logic

A first step towards modeling semistructured data in hybrid multimodal logic Nicole Bidoit * Serenella Cerrito ** Virginie Thion * * LRI UMR CNRS 8623, Université Paris 11, Centre d Orsay. ** LaMI UMR

### Computability Theory

CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

### The gradual typing approach to mixing static and dynamic typing

1/38 The gradual typing approach to mixing static and dynamic typing Jeremy G. Siek University of Colorado =) Indiana University TFP 2013 at Provo, Utah, May 2013 The Goals of Gradual Typing I Enjoy the

### Semantic Analysis: Types and Type Checking

Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

### THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER JASPER DEANTONIO Abstract. This paper is a study of the Turing Degrees, which are levels of incomputability naturally arising from sets of natural numbers.

### ML for the Working Programmer

ML for the Working Programmer 2nd edition Lawrence C. Paulson University of Cambridge CAMBRIDGE UNIVERSITY PRESS CONTENTS Preface to the Second Edition Preface xiii xv 1 Standard ML 1 Functional Programming

### A SOUND TYPE SYSTEM FOR SECURE FLOW ANALYSIS

Journal of Computer Security draft printout, (17 Sep 2009), 1 20 IOS Press 1 A SOUND TYPE SYSTEM FOR SECURE FLOW ANALYSIS Dennis Volpano Computer Science Department Naval Postgraduate School Monterey,

### There is no degree invariant half-jump

There is no degree invariant half-jump Rod Downey Mathematics Department Victoria University of Wellington P O Box 600 Wellington New Zealand Richard A. Shore Mathematics Department Cornell University

### Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation

Under consideration for publication in J. Functional Programming 1 Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation EDWIN BRADY School of Computer Science, University

### Software quality improvement via pattern matching

Software quality improvement via pattern matching Radu Kopetz and Pierre-Etienne Moreau INRIA & LORIA {Radu.Kopetz, Pierre-Etienne.Moreau@loria.fr Abstract. Nested if-then-else statements is the most common

### Type and Effect Systems

Type and Effect Systems Flemming Nielson & Hanne Riis Nielson Department of Computer Science, Aarhus University, Denmark. Abstract. The design and implementation of a correct system can benefit from employing

### Introduction to Automata Theory. Reading: Chapter 1

Introduction to Automata Theory Reading: Chapter 1 1 What is Automata Theory? Study of abstract computing devices, or machines Automaton = an abstract computing device Note: A device need not even be a

### ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS

PROCEEDINGS OF THE YEREVAN STATE UNIVERSITY Physical and Mathematical Sciences 2012 1 p. 43 48 ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS I nf or m at i cs L. A. HAYKAZYAN * Chair of Programming and Information

### 3515ICT Theory of Computation Turing Machines

Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation

### Computing divisors and common multiples of quasi-linear ordinary differential equations

Computing divisors and common multiples of quasi-linear ordinary differential equations Dima Grigoriev CNRS, Mathématiques, Université de Lille Villeneuve d Ascq, 59655, France Dmitry.Grigoryev@math.univ-lille1.fr

### DEGREES OF ORDERS ON TORSION-FREE ABELIAN GROUPS

DEGREES OF ORDERS ON TORSION-FREE ABELIAN GROUPS ASHER M. KACH, KAREN LANGE, AND REED SOLOMON Abstract. We construct two computable presentations of computable torsion-free abelian groups, one of isomorphism

### INF5140: Specification and Verification of Parallel Systems

INF5140: Specification and Verification of Parallel Systems Lecture 7 LTL into Automata and Introduction to Promela Gerardo Schneider Department of Informatics University of Oslo INF5140, Spring 2007 Gerardo

### Boolean Algebra Part 1

Boolean Algebra Part 1 Page 1 Boolean Algebra Objectives Understand Basic Boolean Algebra Relate Boolean Algebra to Logic Networks Prove Laws using Truth Tables Understand and Use First Basic Theorems

Checking Access to Protected Members in the Java Virtual Machine Alessandro Coglio Kestrel Institute 3260 Hillview Avenue, Palo Alto, CA 94304, USA Ph. +1-650-493-6871 Fax +1-650-424-1807 http://www.kestrel.edu/

### 1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

1 Introduction The purpose of this assignment is to write an interpreter for a small subset of the Lisp programming language. The interpreter should be able to perform simple arithmetic and comparisons

### An Exception Monitoring System for Java

An Exception Monitoring System for Java Heejung Ohe and Byeong-Mo Chang Department of Computer Science, Sookmyung Women s University, Seoul 140-742, Korea {lutino, chang@sookmyung.ac.kr Abstract. Exception

### Notes on Determinant

ENGG2012B Advanced Engineering Mathematics Notes on Determinant Lecturer: Kenneth Shum Lecture 9-18/02/2013 The determinant of a system of linear equations determines whether the solution is unique, without

### 4 Domain Relational Calculus

4 Domain Relational Calculus We now present two relational calculi that we will compare to RA. First, what is the difference between an algebra and a calculus? The usual story is that the algebra RA is

### Boolean Representations and Combinatorial Equivalence

Chapter 2 Boolean Representations and Combinatorial Equivalence This chapter introduces different representations of Boolean functions. It then discuss the applications of these representations for proving

### Basic Polymorphic Typechecking

Science of Computer Programming 8/2 (April 1987) Revised 6/21/88 Basic Polymorphic Typechecking Luca Cardelli AT&T Bell Laboratories, Murray Hill, NJ 07974 (current address: DEC SRC, 130 Lytton Ave, Palo

### The Foundations: Logic and Proofs. Chapter 1, Part III: Proofs

The Foundations: Logic and Proofs Chapter 1, Part III: Proofs Rules of Inference Section 1.6 Section Summary Valid Arguments Inference Rules for Propositional Logic Using Rules of Inference to Build Arguments

### Theory of Computation Lecture Notes

Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked

### Syntax Check of Embedded SQL in C++ with Proto

Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, 2010. Vol. 2. pp. 383 390. Syntax Check of Embedded SQL in C++ with Proto Zalán Szűgyi, Zoltán Porkoláb

### Integrating Formal Models into the Programming Languages Course

Integrating Formal Models into the Programming Languages Course Allen B. Tucker Robert E. Noonan Computer Science Department Computer Science Department Bowdoin College College of William and Mary Brunswick,

### The Needle Programming Language

The Needle Programming Language The Needle Programming Language 1 What is Needle? Needle is an object-oriented functional programming language with a multimethod-based OO system, and a static type system

### From Workflow Design Patterns to Logical Specifications

AUTOMATYKA/ AUTOMATICS 2013 Vol. 17 No. 1 http://dx.doi.org/10.7494/automat.2013.17.1.59 Rados³aw Klimek* From Workflow Design Patterns to Logical Specifications 1. Introduction Formal methods in software

### Design by Contract beyond class modelling

Design by Contract beyond class modelling Introduction Design by Contract (DbC) or Programming by Contract is an approach to designing software. It says that designers should define precise and verifiable

### AURA: A language with authorization and audit

AURA: A language with authorization and audit Steve Zdancewic University of Pennsylvania WG 2.8 2008 Security-oriented Languages Limin Jia, Karl Mazurak, Jeff Vaughan, Jianzhou Zhao Joey Schorr and Luke

### Well-typed programs can t be blamed

Well-typed programs can t be blamed Philip Wadler University of Edinburgh Robert Bruce Findler University of Chicago Abstract We introduce the blame calculus, which adds the notion of blame from Findler

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding