Types and Programming Languages

Size: px
Start display at page:

Download "263-2200 Types and Programming Languages"

Transcription

1 Types and Programming Languages 1 / 49

2 Outline Types Evaluation Rules Typing Rules Properties of the Typing Relation The Inversion Lemma Prolog Implementation Reasoning Involving Types Progress Preservation 2 / 49

3 Outline Types Evaluation Rules Typing Rules Properties of the Typing Relation The Inversion Lemma Prolog Implementation Reasoning Involving Types Progress Preservation 3 / 49

4 Plan We will now revisit the simple language of arithmetic and boolean expressions NB and show how to equip it with a (very simple) type system The key property of this type system will be soundness: Well-typed programs do not get stuck After that we will develop a simple type system for the λ-calculus We will spend a good part of the rest of the semester adding features to this type system 4 / 49

5 Outline 1. begin with a set of terms, a set of values, and an evaluation relation 2. define a set of types classifying values according to their shapes 3. define a typing relation t : T that classifies terms according to the shape of the values that result from evaluating them 4. check that the typing relation is sound in the sense that, 4.1 if t : T and t v, then v : T 4.2 if t : T then the evaluation of t will not get stuck 5 / 49

6 The Language NB t ::= terms true constant true false constant false if t then t else t conditional 0 constant zero succ t successor prec t predecessor iszero t zero test v ::= values true true value false false value nv numeric value nv ::= numeric values 0 zero value succ nv successor value 6 / 49

7 Evaluation Rules if true then t 2 else t 3 t 2 if false then t 2 else t 3 t 3 (E-IfTrue) (E-IfFalse) t 1 t 1 if t 1 then t 2 else t3 if t 1 then t 2 else t 3 (E-If) 7 / 49

8 t 1 t 1 succ t 1 succ t 1 pred 0 0 pred (succ nv 1 ) nv 1 (E-Succ) (E-PredZero) (E-PredSucc) t 1 t 1 pred t 1 pred t 1 iszero 0 true iszero (succ nv 1 ) false (E-Pred) (E-IsZeroZero) (E-IsZeroSucc) t 1 t 1 iszero t 1 iszero t 1 (E-IsZero) 8 / 49

9 Types In this language, values have two possible shapes : they are either booleans or numbers. T ::= types Bool type of booleans Nat type of numbers 9 / 49

10 Typing Rules true : Bool false : Bool t 1 : Bool t 2 : T t 3 : T if t 1 then t 2 else t 3 : T (T-True) (T-False) (T-If) 0 : Nat (T-Zero) t 1 : Nat succ t 1 : Nat t 1 : Nat pred t 1 : Nat t 1 : Nat iszero t 1 : Bool (T-Succ) (T-Pred) (T-IsZero) 10 / 49

11 Typing Derivations Every pair (t, T ) in the typing relation can be justified by a derivation tree built from instances of the inference rules. T-Zero 0 : Nat T-IsZero iszero 0 : Bool T-Zero 0 : Nat if iszero 0 then 0 else pred 0 : Nat T-Zero 0 : Nat T-Pred pred 0 : Nat T-If Proofs of properties about the typing relation often proceed by induction on typing derivations. 11 / 49

12 Imprecision of Typing Like other static program analyses, type systems are generally imprecise: they do not predict exactly what kind of value will be returned by every program, but just a conservative (safe) approximation. t 1 : Bool t 2 : T t 3 : T if t 1 then t 2 else t 3 : T (T-If) Using this rule, we cannot assign a type to if true then 0 else false even though this term will certainly evaluate to a number. 12 / 49

13 Outline Types Evaluation Rules Typing Rules Properties of the Typing Relation The Inversion Lemma Prolog Implementation Reasoning Involving Types Progress Preservation 13 / 49

14 Type Safety The safety (or soundness) of this type system can be expressed by two properties: 1. Progress: A well-typed term is not stuck If t : T, then either t is a value or else t t for some t. 2. Preservation: Types are preserved by one-step evaluation If t : T and t t, then t : T. 14 / 49

15 Inversion Lemma: 1. If true : R, then R = Bool. 2. If false : R, then R = Bool. 3. If if t 1 then t 2 else t 3 : R, then t 1 : Bool, t 2 : R, and t 3 : R. 4. If 0 : R, then R = Nat 5. if succ t 1 : R, then R = Nat and t 1 : Nat. 6. if pred t 1 : R, then R = Nat and t 1 : Nat. 7. if iszero t 1 : R, then R = Bool and t 1 : Nat. 15 / 49

16 Inversion Lemma: 1. If true : R, then R = Bool. 2. If false : R, then R = Bool. 3. If if t 1 then t 2 else t 3 : R, then t 1 : Bool, t 2 : R, and t 3 : R. 4. If 0 : R, then R = Nat 5. if succ t 1 : R, then R = Nat and t 1 : Nat. 6. if pred t 1 : R, then R = Nat and t 1 : Nat. 7. if iszero t 1 : R, then R = Bool and t 1 : Nat. Proof: / 49

17 Inversion Lemma: 1. If true : R, then R = Bool. 2. If false : R, then R = Bool. 3. If if t 1 then t 2 else t 3 : R, then t 1 : Bool, t 2 : R, and t 3 : R. 4. If 0 : R, then R = Nat 5. if succ t 1 : R, then R = Nat and t 1 : Nat. 6. if pred t 1 : R, then R = Nat and t 1 : Nat. 7. if iszero t 1 : R, then R = Bool and t 1 : Nat. Proof:... This leads directly to a recursive algorithm for calculating the type of a term / 49

18 Step 1: Design a Mapping to a Term Algebra Abstract Syntax true false if t 1 then t 2 else t 3 0 succ t pred t iszero t map Term true map false map cond(t 1, t 2, t 3 ) map 0 map succ(t) map pred(t) iszero(t) map Bool Nat map map bool nat 18 / 49

19 Step 2: Implement the Typing Relation typeof(true, bool). typeof(false, bool). typeof(0,nat). typeof(succ(t1), nat) :- typeof(t1, nat). typeof(cond(t1,t2,t3), T) :- typeof(t1,bool), typeof(t2,t), typeof(t3,t). typeof(pred(t1), nat) :- typeof(t1,nat). typeof(iszero(t1), bool) :- typeof(t1,nat). 19 / 49

20 Step 3: Develop Testing Framework generictest(t) :- typeof( T, Type ), write( Result = ), write(t), write( : ), write(type), fail. test 01 :- generictest( succ(succ(0)) ). test 02 :- generictest( succ(pred(succ(pred(0)))) ). batchtest :- write( test 01:\n ), not(test 01), nl, nl, write( test 02:\n ), not(test 02), nl, nl. 20 / 49

21 Outline Types Evaluation Rules Typing Rules Properties of the Typing Relation The Inversion Lemma Prolog Implementation Reasoning Involving Types Progress Preservation 21 / 49

22 Canonical Forms Lemma: 1. If v is a value of type Bool, then v is either true or false. 2. If v is a value of type Nat, then v is a numeric value. Proof: 22 / 49

23 Part 1 Recall the syntax of values: v ::= values true true value false false value nv numeric value nv ::= numeric values 0 zero value succ nv successor value For part 1, 23 / 49

24 Part 1 Recall the syntax of values: v ::= values true true value false false value nv numeric value nv ::= numeric values 0 zero value succ nv successor value For part 1, if v is true or false, the result is immediate. 24 / 49

25 Part 1 Recall the syntax of values: v ::= values true true value false false value nv numeric value nv ::= numeric values 0 zero value succ nv successor value For part 1, if v is true or false, the result is immediate. Also note that in this case v cannot be 0 or succ nv, since the inversion lemma tells us that v would then have type Nat, not Bool. 25 / 49

26 Part 1 Recall the syntax of values: v ::= values true true value false false value nv numeric value nv ::= numeric values 0 zero value succ nv successor value For part 1, if v is true or false, the result is immediate. Also note that in this case v cannot be 0 or succ nv, since the inversion lemma tells us that v would then have type Nat, not Bool. Part 2 is similar. 26 / 49

27 Progress Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. 27 / 49

28 Progress Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Proof: 28 / 49

29 Progress Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Proof: By induction on a derivation of t : T. 29 / 49

30 Aside Recall that our typing relation consists of the following typing rules: T rule = { } T-True, T-False, T-If, T-Zero, T-Succ, T-Pred, T-IsZero Also recall that we have the following evaluation rules: E rule = E bool E nat E bool = { E-IfTrue, E-IfFalse, E-If } E nat = { E-Succ, E-PredZero, E-PredSucc, E-Pred, E-IsZeroZero, E-IsZeroSucc, E-IsZero } 30 / 49

31 Aside For each typing rule r T rule, we will consider the implications of a typing derivation ending with r. (r i T rule ) t : T (r j T rule ) (r) In particular, we will need to consider which evaluation rules (if any) can be applied to t. Essentially, our analysis covers: T rule E rule 31 / 49

32 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-True. This implies that t = true (and no evaluation rules apply). Since t is value, the theorem holds in this case. 32 / 49

33 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-False. This implies that t = false (and no evaluation rules apply). Since t is value, the theorem holds in this case. 33 / 49

34 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-Zero. This implies that t = 0 (and no evaluation rules apply). Since t is value, the theorem holds in this case. 34 / 49

35 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-If. This implies (by the inversion lemma) that following must hold for t: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T 35 / 49

36 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-If. This implies (by the inversion lemma) that following must hold for t: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T There are three evaluation rules that need to be considered: E-IfTrue, E-IfFalse, and E-If. We assume (by the induction hypothesis) that the theorem holds for t 1. This allows us to conclude that (1) t 1 is a value or (2) there exists a t 1 such that t 1 t / 49

37 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-If. This implies (by the inversion lemma) that following must hold for t: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T Subcase t 1 is a value. We also know that t 1 : Bool and hence t 1 must either be true or false (by the canonical forms lemma). In this case, the reduction t t is accomplished via the evaluation rule E-IfTrue or E-IfFalse. 37 / 49

38 Progress Proof Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-If. This implies (by the inversion lemma) that following must hold for t: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T Subcase There exists a t 1 such that t 1 t 1. In this case, the reduction t t is accomplished via the evaluation rule E-If. Thus, for the case T-If, our analysis accounts for all evaluation rules. 38 / 49

39 Remaining Cases Theorem: Suppose t is a well-typed term (that is, t : T for some type T ). Then either t is a value or else there is some t with t t. Case r = T-Zero. Here t = 0 so no evaluation rules apply. Case r = T-Succ. Here t = succ t 1 so only the evaluation rule E-Succ must be considered (in the case where t 1 is not a value). Case r = T-Pred. Here t = pred t 1 and the evaluation rules E-PredZero, E-PredSucc and E-Pred must be considered. Case r = T-IsZero. Here t = iszero t 1 and the evaluation rules E-IsZeroZero, E-IsZeroSucc and E-IsZero must be considered. 39 / 49

40 Preservation Theorem: If t : T and t t, then t : T. 40 / 49

41 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. 41 / 49

42 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-True. In this case, t = true. Therefore, t t is not possible, and the theorem is vacuously true. 42 / 49

43 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-False. In this case, t = false. Therefore, t t is not possible, and the theorem is vacuously true. 43 / 49

44 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-If. In this case, it follows that: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T 44 / 49

45 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-If. In this case, it follows that: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T In this context, there are three evaluation rule by which t t can be derived: E-IfTrue, E-IfFalse, E-If. 45 / 49

46 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-If. In this case, it follows that: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T Subcase Evaluation rule = E-IfTrue. In this case, t 1 = true and t = t 2. We also know that t 2 : T, and hence t : T as required. 46 / 49

47 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-If. In this case, it follows that: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T Subcase Evaluation rule = E-IfFalse. In this case, t 1 = false and t = t 3. We also know that t 3 : T, and hence t : T as required. 47 / 49

48 Preservation Theorem: If t : T and t t, then t : T. Proof: By induction on a typing derivation of t : T. Case r = T-If. In this case, it follows that: t = if t 1 then t 2 else t 3 t 1 : Bool t 2 : T t 3 : T Subcase Evaluation rule = E-If. In this case, t 1 t 1 and t = if t 1 then t 2 else t 3 Combining the inductive assumption with t 1 : Bool lets us conclude t 1 : Bool. We also know t 2 : T and t 3 : T. Therefore we can conclude that t : T. 48 / 49

49 Remaining Cases Theorem: If t : T and t t, then t : T. Case r = T-Zero. Here t = 0 so no evaluation rules apply. Case r = T-Succ. Here t = succ t 1 so only the evaluation rule E-Succ must be considered (and only in the case where t 1 is not a value). Case r = T-Pred. Here t = pred t 1 and the evaluation rules E-PredZero, E-PredSucc and E-Pred must be considered. Case r = T-IsZero. Here t = iszero t 1 and the evaluation rules E-IsZeroZero, E-IsZeroSucc and E-IsZero must be considered. 49 / 49

Types, Polymorphism, and Type Reconstruction

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

More information

Assignment 1 (100 Points)

Assignment 1 (100 Points) CIS 705 Programming Languages Spring 2010 Assignment 1 (100 Points) Due by 2:30 p.m. on Thursday, February 11 The context for this assignment is Chapters 2-3 of TAPL. Terms The set of terms is inductively

More information

CIS 500 Software Foundations Midterm I, Review Questions

CIS 500 Software Foundations Midterm I, Review Questions CIS 500 Software Foundations Midterm I, Review Questions Untyped lambda calculus 1. (2 points) We have seen that a linear expression likeλx.λy.xyx is shorthand for an abstract syntax tree that can be drawn

More information

NOTES ON TYPES AND PROGRAMMING LANGUAGES

NOTES ON TYPES AND PROGRAMMING LANGUAGES NOTES ON TYPES AND PROGRAMMING LANGUAGES NEAL PARIKH Abstract. This document aims to serve as a brief outline and concise reference for Types and Programming Languages by B. Pierce. The sections roughly

More information

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors. The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

More information

Full and Complete Binary Trees

Full and Complete Binary Trees Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

More information

Fun with Phantom Types

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

More information

DEGREES OF ORDERS ON TORSION-FREE ABELIAN GROUPS

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

More information

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful

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/

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

Deterministic Discrete Modeling

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

More information

Turing Degrees and Definability of the Jump. Theodore A. Slaman. University of California, Berkeley. CJuly, 2005

Turing Degrees and Definability of the Jump. Theodore A. Slaman. University of California, Berkeley. CJuly, 2005 Turing Degrees and Definability of the Jump Theodore A. Slaman University of California, Berkeley CJuly, 2005 Outline Lecture 1 Forcing in arithmetic Coding and decoding theorems Automorphisms of countable

More information

Termination Checking: Comparing Structural Recursion and Sized Types by Examples

Termination Checking: Comparing Structural Recursion and Sized Types by Examples Termination Checking: Comparing Structural Recursion and Sized Types by Examples David Thibodeau Decemer 3, 2011 Abstract Termination is an important property for programs and is necessary for formal proofs

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

Generating Elementary Combinatorial Objects

Generating Elementary Combinatorial Objects Fall 2009 Combinatorial Generation Combinatorial Generation: an old subject Excerpt from: D. Knuth, History of Combinatorial Generation, in pre-fascicle 4B, The Art of Computer Programming Vol 4. Combinatorial

More information

MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

More information

11 Ideals. 11.1 Revisiting Z

11 Ideals. 11.1 Revisiting Z 11 Ideals The presentation here is somewhat different than the text. In particular, the sections do not match up. We have seen issues with the failure of unique factorization already, e.g., Z[ 5] = O Q(

More information

Notes from February 11

Notes from February 11 Notes from February 11 Math 130 Course web site: www.courses.fas.harvard.edu/5811 Two lemmas Before proving the theorem which was stated at the end of class on February 8, we begin with two lemmas. The

More information

Lecture 14: Section 3.3

Lecture 14: Section 3.3 Lecture 14: Section 3.3 Shuanglin Shao October 23, 2013 Definition. Two nonzero vectors u and v in R n are said to be orthogonal (or perpendicular) if u v = 0. We will also agree that the zero vector in

More information

Basic Proof Techniques

Basic Proof Techniques Basic Proof Techniques David Ferry dsf43@truman.edu September 13, 010 1 Four Fundamental Proof Techniques When one wishes to prove the statement P Q there are four fundamental approaches. This document

More information

POLYNOMIAL RINGS AND UNIQUE FACTORIZATION DOMAINS

POLYNOMIAL RINGS AND UNIQUE FACTORIZATION DOMAINS POLYNOMIAL RINGS AND UNIQUE FACTORIZATION DOMAINS RUSS WOODROOFE 1. Unique Factorization Domains Throughout the following, we think of R as sitting inside R[x] as the constant polynomials (of degree 0).

More information

The Factor Theorem and a corollary of the Fundamental Theorem of Algebra

The Factor Theorem and a corollary of the Fundamental Theorem of Algebra Math 421 Fall 2010 The Factor Theorem and a corollary of the Fundamental Theorem of Algebra 27 August 2010 Copyright 2006 2010 by Murray Eisenberg. All rights reserved. Prerequisites Mathematica Aside

More information

6.2 Permutations continued

6.2 Permutations continued 6.2 Permutations continued Theorem A permutation on a finite set A is either a cycle or can be expressed as a product (composition of disjoint cycles. Proof is by (strong induction on the number, r, of

More information

Mathematical Induction. Lecture 10-11

Mathematical Induction. Lecture 10-11 Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

More information

Programming Languages Featherweight Java David Walker

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

More information

Mathematical Induction

Mathematical Induction Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

More information

Factorization in Polynomial Rings

Factorization in Polynomial Rings Factorization in Polynomial Rings These notes are a summary of some of the important points on divisibility in polynomial rings from 17 and 18 of Gallian s Contemporary Abstract Algebra. Most of the important

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

A Tutorial on [Co-]Inductive Types in Coq

A Tutorial on [Co-]Inductive Types in Coq A Tutorial on [Co-]Inductive Types in Coq Eduardo Giménez, Pierre Castéran May 1998 August 17, 2007 Abstract This document 1 is an introduction to the definition and use of inductive and co-inductive types

More information

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm MTHSC 412 Section 2.4 Prime Factors and Greatest Common Divisor Greatest Common Divisor Definition Suppose that a, b Z. Then we say that d Z is a greatest common divisor (gcd) of a and b if the following

More information

Cycles in a Graph Whose Lengths Differ by One or Two

Cycles in a Graph Whose Lengths Differ by One or Two Cycles in a Graph Whose Lengths Differ by One or Two J. A. Bondy 1 and A. Vince 2 1 LABORATOIRE DE MATHÉMATIQUES DISCRÉTES UNIVERSITÉ CLAUDE-BERNARD LYON 1 69622 VILLEURBANNE, FRANCE 2 DEPARTMENT OF MATHEMATICS

More information

The Classes P and NP

The Classes P and NP The Classes P and NP We now shift gears slightly and restrict our attention to the examination of two families of problems which are very important to computer scientists. These families constitute the

More information

arxiv:1112.0829v1 [math.pr] 5 Dec 2011

arxiv:1112.0829v1 [math.pr] 5 Dec 2011 How Not to Win a Million Dollars: A Counterexample to a Conjecture of L. Breiman Thomas P. Hayes arxiv:1112.0829v1 [math.pr] 5 Dec 2011 Abstract Consider a gambling game in which we are allowed to repeatedly

More information

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl)

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl) Subsets of Euclidean domains possessing a unique division algorithm Andrew D. Lewis 2009/03/16 Abstract Subsets of a Euclidean domain are characterised with the following objectives: (1) ensuring uniqueness

More information

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 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)

More information

How To Write A Type System

How To Write A Type System Type Systems 1 Introduction Luca Cardelli Digital Equipment Corporation Systems Research Center The fundamental purpose of a type system is to prevent the occurrence of execution errors during the running

More information

TAKE-AWAY GAMES. ALLEN J. SCHWENK California Institute of Technology, Pasadena, California INTRODUCTION

TAKE-AWAY GAMES. ALLEN J. SCHWENK California Institute of Technology, Pasadena, California INTRODUCTION TAKE-AWAY GAMES ALLEN J. SCHWENK California Institute of Technology, Pasadena, California L INTRODUCTION Several games of Tf take-away?f have become popular. The purpose of this paper is to determine the

More information

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z DANIEL BIRMAJER, JUAN B GIL, AND MICHAEL WEINER Abstract We consider polynomials with integer coefficients and discuss their factorization

More information

If n is odd, then 3n + 7 is even.

If n is odd, then 3n + 7 is even. Proof: Proof: We suppose... that 3n + 7 is even. that 3n + 7 is even. Since n is odd, there exists an integer k so that n = 2k + 1. that 3n + 7 is even. Since n is odd, there exists an integer k so that

More information

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions Marcel B. Finan Arkansas Tech University c All Rights Reserved First Draft February 8, 2006 1 Contents 25

More information

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic

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

More information

SOLVING POLYNOMIAL EQUATIONS

SOLVING POLYNOMIAL EQUATIONS C SOLVING POLYNOMIAL EQUATIONS We will assume in this appendix that you know how to divide polynomials using long division and synthetic division. If you need to review those techniques, refer to an algebra

More information

Breaking The Code. Ryan Lowe. Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and

Breaking The Code. Ryan Lowe. Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and Breaking The Code Ryan Lowe Ryan Lowe is currently a Ball State senior with a double major in Computer Science and Mathematics and a minor in Applied Physics. As a sophomore, he took an independent study

More information

Type Systems. Luca Cardelli. Microsoft Research

Type Systems. Luca Cardelli. Microsoft Research Type Systems Luca Cardelli Microsoft Research 1 Introduction The fundamental purpose of a type system is to prevent the occurrence of execution errors during the running of a program. This informal statement

More information

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

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

More information

Chapter II. Controlling Cars on a Bridge

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

More information

Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test

Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test 1 Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test Definition: Prime numbers are numbers with only two factors, one and itself. For example: 2, 3, and 5. Definition: Composite numbers

More information

SECTION 10-2 Mathematical Induction

SECTION 10-2 Mathematical Induction 73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

More information

Properties of Real Numbers

Properties of Real Numbers 16 Chapter P Prerequisites P.2 Properties of Real Numbers What you should learn: Identify and use the basic properties of real numbers Develop and use additional properties of real numbers Why you should

More information

Indiana State Core Curriculum Standards updated 2009 Algebra I

Indiana State Core Curriculum Standards updated 2009 Algebra I Indiana State Core Curriculum Standards updated 2009 Algebra I Strand Description Boardworks High School Algebra presentations Operations With Real Numbers Linear Equations and A1.1 Students simplify and

More information

Correspondence analysis for strong three-valued logic

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 ).

More information

Finite dimensional topological vector spaces

Finite dimensional topological vector spaces Chapter 3 Finite dimensional topological vector spaces 3.1 Finite dimensional Hausdorff t.v.s. Let X be a vector space over the field K of real or complex numbers. We know from linear algebra that the

More information

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom.

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom. Some Polynomial Theorems by John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom.com This paper contains a collection of 31 theorems, lemmas,

More information

IV.2 (b) Higher level programming concepts for URMs Anton Setzer

IV.2 (b) Higher level programming concepts for URMs Anton Setzer CS 275 Automata and Formal Language Theory Course Notes Additional Material Part IV: Limits of Computation Chapt. IV.2: The URM IV.2 (a) Definition of the URM IV.2 (b) Higher level programming concepts

More information

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm. Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm. We begin by defining the ring of polynomials with coefficients in a ring R. After some preliminary results, we specialize

More information

MATH 22. THE FUNDAMENTAL THEOREM of ARITHMETIC. Lecture R: 10/30/2003

MATH 22. THE FUNDAMENTAL THEOREM of ARITHMETIC. Lecture R: 10/30/2003 MATH 22 Lecture R: 10/30/2003 THE FUNDAMENTAL THEOREM of ARITHMETIC You must remember this, A kiss is still a kiss, A sigh is just a sigh; The fundamental things apply, As time goes by. Herman Hupfeld

More information

The Basics of Graphical Models

The Basics of Graphical Models The Basics of Graphical Models David M. Blei Columbia University October 3, 2015 Introduction These notes follow Chapter 2 of An Introduction to Probabilistic Graphical Models by Michael Jordan. Many figures

More information

FUNCTIONAL ANALYSIS LECTURE NOTES: QUOTIENT SPACES

FUNCTIONAL ANALYSIS LECTURE NOTES: QUOTIENT SPACES FUNCTIONAL ANALYSIS LECTURE NOTES: QUOTIENT SPACES CHRISTOPHER HEIL 1. Cosets and the Quotient Space Any vector space is an abelian group under the operation of vector addition. So, if you are have studied

More information

Online Appendix to. Stability and Competitive Equilibrium in Trading Networks

Online Appendix to. Stability and Competitive Equilibrium in Trading Networks Online Appendix to Stability and Competitive Equilibrium in Trading Networks John William Hatfield Scott Duke Kominers Alexandru Nichifor Michael Ostrovsky Alexander Westkamp Abstract In this appendix,

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

each college c i C has a capacity q i - the maximum number of students it will admit

each college c i C has a capacity q i - the maximum number of students it will admit n colleges in a set C, m applicants in a set A, where m is much larger than n. each college c i C has a capacity q i - the maximum number of students it will admit each college c i has a strict order i

More information

The countdown problem

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

More information

Applied Algorithm Design Lecture 5

Applied Algorithm Design Lecture 5 Applied Algorithm Design Lecture 5 Pietro Michiardi Eurecom Pietro Michiardi (Eurecom) Applied Algorithm Design Lecture 5 1 / 86 Approximation Algorithms Pietro Michiardi (Eurecom) Applied Algorithm Design

More information

DEGREES OF CATEGORICITY AND THE HYPERARITHMETIC HIERARCHY

DEGREES OF CATEGORICITY AND THE HYPERARITHMETIC HIERARCHY DEGREES OF CATEGORICITY AND THE HYPERARITHMETIC HIERARCHY BARBARA F. CSIMA, JOHANNA N. Y. FRANKLIN, AND RICHARD A. SHORE Abstract. We study arithmetic and hyperarithmetic degrees of categoricity. We extend

More information

A Practical Scheme for Wireless Network Operation

A Practical Scheme for Wireless Network Operation A Practical Scheme for Wireless Network Operation Radhika Gowaikar, Amir F. Dana, Babak Hassibi, Michelle Effros June 21, 2004 Abstract In many problems in wireline networks, it is known that achieving

More information

Factoring Algorithms

Factoring Algorithms Factoring Algorithms The p 1 Method and Quadratic Sieve November 17, 2008 () Factoring Algorithms November 17, 2008 1 / 12 Fermat s factoring method Fermat made the observation that if n has two factors

More information

GREATEST COMMON DIVISOR

GREATEST COMMON DIVISOR DEFINITION: GREATEST COMMON DIVISOR The greatest common divisor (gcd) of a and b, denoted by (a, b), is the largest common divisor of integers a and b. THEOREM: If a and b are nonzero integers, then their

More information

Section 4.2: The Division Algorithm and Greatest Common Divisors

Section 4.2: The Division Algorithm and Greatest Common Divisors Section 4.2: The Division Algorithm and Greatest Common Divisors The Division Algorithm The Division Algorithm is merely long division restated as an equation. For example, the division 29 r. 20 32 948

More information

CS510 Software Engineering

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

More information

How To Understand The Theory Of Computer Science

How To Understand The Theory Of Computer Science 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

More information

Stochastic Inventory Control

Stochastic Inventory Control Chapter 3 Stochastic Inventory Control 1 In this chapter, we consider in much greater details certain dynamic inventory control problems of the type already encountered in section 1.3. In addition to the

More information

FALSE ALARMS IN FAULT-TOLERANT DOMINATING SETS IN GRAPHS. Mateusz Nikodem

FALSE ALARMS IN FAULT-TOLERANT DOMINATING SETS IN GRAPHS. Mateusz Nikodem Opuscula Mathematica Vol. 32 No. 4 2012 http://dx.doi.org/10.7494/opmath.2012.32.4.751 FALSE ALARMS IN FAULT-TOLERANT DOMINATING SETS IN GRAPHS Mateusz Nikodem Abstract. We develop the problem of fault-tolerant

More information

THE DIMENSION OF A VECTOR SPACE

THE DIMENSION OF A VECTOR SPACE THE DIMENSION OF A VECTOR SPACE KEITH CONRAD This handout is a supplementary discussion leading up to the definition of dimension and some of its basic properties. Let V be a vector space over a field

More information

Find-The-Number. 1 Find-The-Number With Comps

Find-The-Number. 1 Find-The-Number With Comps Find-The-Number 1 Find-The-Number With Comps Consider the following two-person game, which we call Find-The-Number with Comps. Player A (for answerer) has a number x between 1 and 1000. Player Q (for questioner)

More information

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce

More information

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

More information

Jieh Hsiang Department of Computer Science State University of New York Stony brook, NY 11794

Jieh Hsiang Department of Computer Science State University of New York Stony brook, NY 11794 ASSOCIATIVE-COMMUTATIVE REWRITING* Nachum Dershowitz University of Illinois Urbana, IL 61801 N. Alan Josephson University of Illinois Urbana, IL 01801 Jieh Hsiang State University of New York Stony brook,

More information

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics An Introductory Single Variable Real Analysis: A Learning Approach through Problem Solving Marcel B. Finan c All Rights

More information

THE FUNDAMENTAL THEOREM OF ARBITRAGE PRICING

THE FUNDAMENTAL THEOREM OF ARBITRAGE PRICING THE FUNDAMENTAL THEOREM OF ARBITRAGE PRICING 1. Introduction The Black-Scholes theory, which is the main subject of this course and its sequel, is based on the Efficient Market Hypothesis, that arbitrages

More information

Lectures notes on orthogonal matrices (with exercises) 92.222 - Linear Algebra II - Spring 2004 by D. Klain

Lectures notes on orthogonal matrices (with exercises) 92.222 - Linear Algebra II - Spring 2004 by D. Klain Lectures notes on orthogonal matrices (with exercises) 92.222 - Linear Algebra II - Spring 2004 by D. Klain 1. Orthogonal matrices and orthonormal sets An n n real-valued matrix A is said to be an orthogonal

More information

Degrees of Truth: the formal logic of classical and quantum probabilities as well as fuzzy sets.

Degrees of Truth: the formal logic of classical and quantum probabilities as well as fuzzy sets. Degrees of Truth: the formal logic of classical and quantum probabilities as well as fuzzy sets. Logic is the study of reasoning. A language of propositions is fundamental to this study as well as true

More information

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B KITCHENS The equation 1 Lines in two-dimensional space (1) 2x y = 3 describes a line in two-dimensional space The coefficients of x and y in the equation

More information

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs CSE599s: Extremal Combinatorics November 21, 2011 Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs Lecturer: Anup Rao 1 An Arithmetic Circuit Lower Bound An arithmetic circuit is just like

More information

Mathematical Induction

Mathematical Induction Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

More information

1 if 1 x 0 1 if 0 x 1

1 if 1 x 0 1 if 0 x 1 Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

More information

NOTES ON LINEAR TRANSFORMATIONS

NOTES ON LINEAR TRANSFORMATIONS NOTES ON LINEAR TRANSFORMATIONS Definition 1. Let V and W be vector spaces. A function T : V W is a linear transformation from V to W if the following two properties hold. i T v + v = T v + T v for all

More information

NIM with Cash. Abstract. loses. This game has been well studied. For example, it is known that for NIM(1, 2, 3; n)

NIM with Cash. Abstract. loses. This game has been well studied. For example, it is known that for NIM(1, 2, 3; n) NIM with Cash William Gasarch Univ. of MD at College Park John Purtilo Univ. of MD at College Park Abstract NIM(a 1,..., a k ; n) is a -player game where initially there are n stones on the board and the

More information

Two-Sided Matching Theory

Two-Sided Matching Theory Two-Sided Matching Theory M. Utku Ünver Boston College Introduction to the Theory of Two-Sided Matching To see which results are robust, we will look at some increasingly general models. Even before we

More information

Quotient Rings and Field Extensions

Quotient Rings and Field Extensions Chapter 5 Quotient Rings and Field Extensions In this chapter we describe a method for producing field extension of a given field. If F is a field, then a field extension is a field K that contains F.

More information

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)! Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

More information

INCIDENCE-BETWEENNESS GEOMETRY

INCIDENCE-BETWEENNESS GEOMETRY INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

More information

Verifying Specifications with Proof Scores in CafeOBJ

Verifying Specifications with Proof Scores in CafeOBJ Verifying Specifications with Proof Scores in CafeOBJ FUTATSUGI, Kokichi 二 木 厚 吉 Chair of Language Design Graduate School of Information Science Japan Advanced Institute of Science and Technology (JAIST)

More information

EMBEDDING COUNTABLE PARTIAL ORDERINGS IN THE DEGREES

EMBEDDING COUNTABLE PARTIAL ORDERINGS IN THE DEGREES EMBEDDING COUNTABLE PARTIAL ORDERINGS IN THE ENUMERATION DEGREES AND THE ω-enumeration DEGREES MARIYA I. SOSKOVA AND IVAN N. SOSKOV 1. Introduction One of the most basic measures of the complexity of a

More information

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009. Notes on Algebra

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009. Notes on Algebra U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, 2009 Notes on Algebra These notes contain as little theory as possible, and most results are stated without proof. Any introductory

More information

To define function and introduce operations on the set of functions. To investigate which of the field properties hold in the set of functions

To define function and introduce operations on the set of functions. To investigate which of the field properties hold in the set of functions Chapter 7 Functions This unit defines and investigates functions as algebraic objects. First, we define functions and discuss various means of representing them. Then we introduce operations on functions

More information

Notes on Determinant

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

More information

Notes from Week 1: Algorithms for sequential prediction

Notes from Week 1: Algorithms for sequential prediction CS 683 Learning, Games, and Electronic Markets Spring 2007 Notes from Week 1: Algorithms for sequential prediction Instructor: Robert Kleinberg 22-26 Jan 2007 1 Introduction In this course we will be looking

More information

Orthogonal Projections

Orthogonal Projections Orthogonal Projections and Reflections (with exercises) by D. Klain Version.. Corrections and comments are welcome! Orthogonal Projections Let X,..., X k be a family of linearly independent (column) vectors

More information

Continued Fractions and the Euclidean Algorithm

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

More information

Scheduling Single Machine Scheduling. Tim Nieberg

Scheduling Single Machine Scheduling. Tim Nieberg Scheduling Single Machine Scheduling Tim Nieberg Single machine models Observation: for non-preemptive problems and regular objectives, a sequence in which the jobs are processed is sufficient to describe

More information