We Trusted What We Proved! Greatest Common Divisors: Theorem, Proof and Algorithm in PowerEpsilon
|
|
- Joel Harmon
- 6 years ago
- Views:
Transcription
1 We Trusted What We Proved! Greatest Common Divisors: Theorem, Proof and Algorithm in PowerEpsilon Ming-Yuan Zhu CoreTek Systems, Inc. 11 th Floor, 1109, CEC Building 6 South Zhongguancun Street Beijing People s Republic of China Abstract In this paper, we present a formal development of greatest common divisor algorithm with the mechanical proof development system PowerEpsilon. 1 Introduction In this paper, we present a proof development system called PowerEpsilon [11, 12], based on a constructive type theory which can be used as a formal system for actually proof development 1. PowerEpsilon, currently developed and maintained by author, is a strongly-typed polymorphic functional programming language based on Martin-Löf s type theory [8, 6, 7] and the calculus of constructions [4]. In PowerEpsilon, the concept of limit of type universe hierarchies (Kind) and a scheme for inductive define types are introduced. The system can be used as both a programming language with a very rich set of data structures and a metalanguage for formalizing constructive mathematics. The system has been implemented using the software development system AUTOSTAR constructed by author [10]. PowerEpsilon is a proof checker much similar to other mechanical proof checkers, such as COQ [1], HOL[5], Isabelle[9] and Nuprl [2], which are completely formal user-controlled systems. The aim of this paper is to derive a algorithm for computing the greatest common divisors of two given natural numbers using PowerEpsilon. 1.1 The Algorithm for Greatest Common Divisor - Euclid Euclid Algorithm The Euclid algorithm for calculating the greatest common divisor was established based on the following theorem. Theorem 1.1 GCD(a, b) = GCD(b, a mod b). The proof is outlined as follows: a can be represented as a = kb + rthen we have r = a mod b Suppose that d is a common divisor of a and b, then d a, d b, since r = a - kbhence d r, Therefore, d is the common divisor of (b, a mod b). Suppose that d is the common divisor of (b, a mod b), then d b, d r, but a = kb + r hence, d is also the common divisor of (a, b). Since the common divisors of (a, b) and (b, a mod b) are same, the greatest common divisor must also the same. 1 This work is supported in part by the TRUSTIE Project of Hi-Tech Research and Development Program of China (863 Program) under Grant No. 2007AA010304, by the Open Fund of the State Key Laboratory of Software Development Environment under Grant No. SKLSDE-2010KF-0X, Beijing University of Aeronautics and Astronautics, and by the National Basic Research Program of China (973 Program) under Grant No. 2005CB
2 2 Statement Theorem 2.1 a, b N. d GCD, a, b, d). dec GCDThm2 a, b, d); What we need actually is the following theorem: Theorem 2.2 f N N N. a, b GCD, a, a, b)). dec GCDThm3 :?(f : [Nat -> Nat -> a, a, b)); 3 Definitions 3.1 Divisibility dec Dividable : [Nat -> Nat -> Type(0)]; def Dividable = \(n1 : Nat, n2 : Nat)?(m : Nat) let n n2, m) Nat, n1, n); dec DivideReflLem a, a); dec DivideReflProp : let n a, II) Nat, a, n); def DivideReflLem = \(a : Nat) let m = II in a)>; dec OneDivideLem a, II); dec ZeroDivideLem OO, a); dec DivideLELem :!(a : Nat, m : Nat) [@(Dividable, a, m) m, a)]; 2
3 dec MultDivideLem :!(k : Nat, a : Nat, d : Nat) [@(Dividable, a, k, k, d))]; 3.2 Common Divisors def CDCond = \(n1 : Nat, n2 : Nat, cd n1, n2, cd)); 3.3 Greatest Common Divisors def GCDCond = \(n1 : Nat, n2 : Nat, gcd n1, n2, gcd),!(m : Nat) [@(CDCond, n1, n2, m) m, gcd)]); dec Is_GCD : [Nat -> Nat -> Nat -> Prop]; def Is_GCD = GCDCond; 4 Proof 4.1 Trivial Properties of GCDCond Reflexivity dec IsGCDRefLem a, a, a); dec IsGCDRefLem1 a, a, a); def IsGCDRefLem1 = \(a : Nat) let P a, a) in let p a) P, P, p, p); dec IsGCDRefLem2 :!(m : Nat) [@(CDCond, a, a, m) m, a)]; 3
4 def IsGCDRefLem = \(a : Nat) let A1 a, a, a), A2 =!(m : Nat) [@(CDCond, a, a, m) m, a)] in let a1 a), a2 a) A1, A2, a1, a2); 4.2 Symmetry dec IsGCDSymLem :!(a : Nat, b : Nat, d : Nat) [@(Is_GCD, a, b, d) b, a, d)]; dec IsGCDSymLem1 :!(a : Nat, b : Nat, d : Nat) [@(CDCond, a, b, d) b, a, d)]; dec IsGCDSymLem2 :!(a : Nat, b : Nat, d : Nat) [!(m : Nat) [@(CDCond, a, b, m) m, d)] ->!(m : Nat) [@(CDCond, b, a, m) m, d)]]; def IsGCDSymLem = \(a : Nat, b : Nat, d : Nat) \(p a, b, d)) let P1 a, b, d), P2 =!(m : Nat) [@(CDCond, a, b, m) m, d)] in let p1 P1, P2, p), p2 P1, P2, p) in let Q1 b, a, d), Q2 =!(m : Nat) [@(CDCond, b, a, m) m, d)] in let q1 a, b, d, p1), q2 a, b, d, p2) Q1, Q2, q1, q2); 4.3 Zero Property dec IsGCDZeroLem a, OO, a); dec IsGCDZeroLem1 a, OO, a); def IsGCDZeroLem1 = \(a : Nat) let P1 a, a), P2 OO, a) in let p1 a), 4
5 p2 a) P1, P2, p1, p2); dec IsGCDZeroLem2 :!(m : Nat) [@(CDCond, a, OO, m) m, a)]; def IsGCDZeroLem = \(a : Nat) let P1 a, OO, a), P2 =!(m : Nat) [@(CDCond, a, OO, m) m, a)] in let p1 a), p2 a) P1, P2, p1, p2); dec IsGCDZeroLemm OO, a, a); 4.4 Equality dec IsGCDEqLem a, a, a); 4.5 Theorem of CDCond dec CDLem2 :!(d : Nat) [@(Dividable, a, d) b, a, b), d)]; dec CDLem20 :!(d : Nat) [@(CDCond, a, b, d) a, b), d)]; def CDLem20 = \(d : Nat) \(p a, b, d)) let P1 a, d), P2 b, d) in let p1 P1, P2, p), p2 P1, P2, p) in let q a, b, d, p1, p2) in let a, b), d) P2, Q, p2, q); dec CDLem3 : 5
6 !(d : Nat) [@(Dividable, b, a, b), d) a, d)]; dec CDLem30 :!(d : Nat) [@(CDCond, a, b), d) a, b, d)]; def CDLem30 = \(d : Nat) \(p a, b), d)) let P1 b, d), a, b), d) in let p1 P1, P2, p), p2 P1, P2, p) in let q a, b, d, p1, p2) in let Q a, d) Q, P1, q, p1); 4.6 Theorem and Proof of GCDThmm dec GCDThmm :!(a : Nat, b : Nat, d : Nat) [@(GCDCond, a, b), d) a, b, d)]; def GCDThmm = \(a : Nat, b : Nat, d : Nat, q a, b), d)) let Q1 a, b), d), Q2 =!(m : Nat) [@(CDCond, a, b), m) m, d)] in let q1 Q1, Q2, q), q2 Q1, Q2, q) in let P1 a, b, d), P2 =!(m : Nat) [@(CDCond, a, b, m) m, d)] in let p1 a, b, d, q1), p2 = \(m : Nat, w a, b, m)) let u a, b, m, w) m, u) P1, P2, p1, p2); 4.7 Proof of GCDThm2 def MkGCDCond = \(a : Nat, b : Nat, d : Nat, p a, b, d)) <d, p>; dec GCDThm21 : 6
7 Nat, b, OO) a, b, d)]; def GCDThm21 = \(p Nat, b, OO)) let d = a, q a) in let r Nat, b, OO, p) in let P = \(x : a, x, d) a, b, P, q)); dec GCDThm22 : [@(Equal, Nat, a, OO) a, b, d)]; def GCDThm22 = \(p Nat, a, OO)) let d = b, q b) in let r Nat, a, OO, p) in let P = \(x : x, b, d) a, b, P, q)); dec GCDThm23 : [@(NGe, a, b) a, b), d) a, b, d)]; def GCDThm23 = \(a : Nat, b : Nat, w a, b)) \(p a, b), d)) let d p), q p) a, b, a, b, d, q)); dec GCDThm24 : [@(NLs, a, b) b, a, d) a, b, d)]; def GCDThm24 = \(a : Nat, b : Nat, w a, b)) \(p b, a, d)) let d p), q p) a, b, b, a, d, q)); dec GCDInduct : [[@(Equal, Nat, a, OO) a, b, d)] -> 7
8 Nat, b, OO) a, b, d)] -> a, b) b, a, d) a, b, d)] -> a, b) a, b), d) a, b, d)] a, b, d)]; 4.8 Proofs of GCDThm2 and GCDThm Proof of GCDThm2 def GCDThm2 a, a, a, a, a, b)); Lemma of Choice dec ChoiceLem2 :!(A : Prop, B : Prop, C : Prop)!(P : [A -> B -> C -> Type(0)]) [!(x : A, y : B)?(z : x, y, z) ->?(f : [A -> B -> C])!(x : A, y : x, x, y))]; def ChoiceLem2 = \(A : Prop, B : Prop, C : Prop) \(P : [A -> B -> C -> Type(0)]) \(l :!(x : A, y : B)?(z : x, y, z)) let f = \(x : A, y x, y)) in let p = \(x : A, y : B, a x, x, y))) a in let q = \(x : A, y : x, y))) in <f, q>; Proof of GCDThm3 def GCDThm3 Nat, Nat, Nat, GCDCond, GCDThm2); 4.9 Algorithm Derived dec GCD : [Nat -> Nat -> Nat]; def GCD = 8
9 a), b, b), a, a, b, a, b))))); The Euclid algorithm was derived from this theorem, the algorithm represented in C++ is described as follows: void swap(int &a, int &b) { int c = a; a = b; b = c; } int gcd(int a, int b) { if (0 == a) { return b; } if (0 == b) { return a; } if (a > b) { swap(a, b); } int c; for (c = a mon b; c > 0; c = a mod b) { a = b; b = c; } return b; } 5 Proof of Binary Algorithm 5.1 Binary GCD algorithm The binary GCD algorithm, also known as Stein s algorithm[3], is an algorithm that computes the greatest common divisor of two nonnegative integers. It gains a measure of efficiency over the ancient Euclidean algorithm by replacing divisions and multiplications with shifts, which are cheaper when operating on the binary representation used by modern computers. This is particularly critical on embedded platforms that have no direct processor support for division. Although the algorithm was first published by the Israeli physicist and programmer Josef Stein in 1967, it may have been known in first-century China. 9
10 5.2 Informal Description of Algorithm The algorithm reduces the problem of finding the GCD by repeatedly applying these identities: 1. GCD(0, v) = v, because everything divides zero, and v is the largest number that divides v. Similarly, GCD(u, 0) = u. GCD(0, 0) is not typically defined, but it is convenient to set GCD(0, 0) = If u and v are both even, then GCD(u, v) = 2 GCD(u/2, v/2), because 2 is a common divisor. 3. If u is even and v is odd, then GCD(u, v) = GCD(u/2, v), because 2 is not a common divisor. Similarly, if u is odd and v is even, then GCD(u, v) = GCD(u, v/2). 4. If u and v are both odd, and u v, then GCD(u, v) = GCD((u - v)/2, v). If both are odd and u < v, then GCD(u, v) = GCD((v - u)/2, u). These are combinations of one step of the simple Euclidean algorithm, which uses subtraction at each step, and an application of step 3 above. The division by 2 results in an integer because the difference of two odd numbers is even. 5. Repeat steps 3C4 until u = v, or (one more step) until u = 0. In either case, the GCD is 2kv, where k is the number of common factors of 2 found in step 2. Since this definition is tail-recursive, a loop can be used to replace the recursion. The algorithm requires O((log2 uv)2) worst-case time, or in other words time proportional to the square of the number of bits in u and v together. Although each step reduces at least one of the operands by at least a factor of 2, the subtract and shift operations do not take constant time for very large integers (although they re still quite fast in practice, requiring about one operation per word of the representation). 5.3 Definitions def IsEven = \(a : Nat)?(a2 : Nat, I2, a2)); def IsOdd = \(a : Nat)?(a2 : I2, a2))); 5.4 Theorem for Stein Algorithm Theorem SteinGCDThm0 Theorem 5.1 a a, a, a). dec SteinGCDThm0 a, a, a); def SteinGCDThm0 = \(a : a); Theorem 5.2 k, a, b, d a, b, k a, k b, k d). 10
11 5.4.2 Theorem SteinGCDThm1 dec SteinGCDThm1 :!(k : Nat, a : Nat, b : Nat, d : Nat) [@(GCDCond, a, b, k, k, k, d))]; Lemma SteinGCDLem11 Lemma 5.1 k, a, b, d a, b, k a, k b, k d). dec SteinGCDLem11 :!(k : Nat, a : Nat, b : Nat, d : Nat) [@(CDCond, a, b, k, k, k, d))]; def SteinGCDLem11 = \(k : Nat, a : Nat, b : Nat, d : Nat) \(p a, b, d)) let P1 a, d), P2 b, d) in let p1 P1, P2, p), p2 P1, P2, p) in let k, k, d)), k, k, d)) in let q1 k, a, d, p1), q2 k, b, d, p2) Q1, Q2, q1, q2); Lemma SteinGCDLem12 Lemma 5.2 k, a, b, d N. ( m a, b, m) m d) ( m k a, k b, m) m k d). dec SteinGCDLem12 :!(k : Nat, a : Nat, b : Nat, d : Nat) [!(m : Nat) [@(CDCond, a, b, m) m, d)] ->!(m : Nat) k, k, b), m) k, d))]]; dec MultiDivideLem :!(k : Nat, a : Nat, b : Nat, km : Nat) k, a), k, b), km) ->?(n : Nat, m Nat, k, a, b, m)))]; dec NatTimeLELem :!(a : Nat, b : Nat, c : Nat, d : Nat) [@(NLe, a, c) b, d) -> 11
12 a, c, d))]; dec NLeEqTranLem :!(a : Nat, b : Nat, c : Nat) [@(Equal, Nat, a, b) b, c) a, c)]; def NLeEqTranLem = \(a : Nat, b : Nat, c : Nat) \(p1 Nat, a, b), p2 b, c)) let P = \(x : x, c) in let q Nat, a, b, p1) P, p2); def SteinGCDLem12 = \(k : Nat, a : Nat, b : Nat, d : Nat) \(p :!(m : Nat) [@(CDCond, a, b, m) m, d)]) \(km : Nat) k, k, b), km)) let k, a), km), k, b), km) in let q1 Q1, Q2, q), q2 Q1, Q2, q) in let r k, a, b, km, q1, q2) in let kk r), r)), r)) in let R1 Nat, kk, mm)), R2 k, kk), R3 a, b, mm) in let r1 R2, R3), rr), r2 R2, R2, R3), rr)), r3 R2, R2, R3), rr)) in let u1 mm, r3), u2 k, kk, r2), u3 kk, mm, k, d, u2, u1) kk, k, d), r1, u3); Proof of SteinGCDThm1 def SteinGCDThm1 = \(k : Nat, a : Nat, b : Nat, d : Nat) \(p a, b, d)) let ka k, a), kb k, b), kd k, d) in let P1 a, b, d), P2 =!(m : Nat) [@(CDCond, a, b, m) m, d)] in let p1 P1, P2, p), p2 P1, P2, p) in let Q1 ka, kb, kd), Q2 =!(m : Nat) [@(CDCond, ka, kb, m) m, kd)] in let q1 k, a, b, d, p1), q2 k, a, b, d, p2) Q1, Q2, q1, q2); 12
13 5.5 Proofs Theorem 5.3 a, b N. b = 0 d a, b, d). dec GCDThm21 : [@(Equal, Nat, b, OO) a, b, d)]; def GCDThm21 = \(p Nat, b, OO)) let d = a, q a) in let r Nat, b, OO, p) in let P = \(x : a, x, d) a, b, P, q)); Theorem 5.4 a, b N. a = 0 d a, b, d). dec GCDThm22 : [@(Equal, Nat, a, OO) a, b, d)]; def GCDThm22 = \(p Nat, a, OO)) let d = b, q b) in let r Nat, a, OO, p) in let P = \(x : x, b, d) a, b, P, q)); Theorem 5.5 a, b N. a = b d a, b, d). dec GCDThm23 : [@(Equal, Nat, a, b) a, b, d)]; def GCDThm23 = \(p Nat, a, b)) let d = a, q a) in let P = \(x : a, x, d) a, b, P, q)); Theorem 5.6 a, b b) d a/2, b/2, d) d a, b, d). dec GCDThm24 : [@(IsEven, a) -> 13
14 @(IsEven, b) -> let a2 a, I2), b2 b, I2) a2, b2, d) a, b, d)]; dec GCDLem24 :!(a : Nat, b : Nat, d : Nat) [@(IsEven, a) b) -> let a2 a, I2), b2 b, I2) in [@(GCDCond, a2, b2, d) -> let dd I2, d) a, b, dd)]]; dec Time2Div2EqLem a, I2)), a); def GCDLem24 = \(a : Nat, b : Nat, d : Nat) \(p1 a), p2 b)) let a2 a, I2), b2 b, I2) in \(p3 a2, b2, d)) let P = \(x : I2, I2, d)), Q = \(x : a, I2, d)) in let q1 I2, a2, b2, d, p3), q2 a, P, q1) b, Q, q2); def GCDThm24 = \(p1 a), p2 b)) let a2 a, I2), b2 b, I2) in \(p3 a2, b2, d)) let d p3), q p3) in let dd I2, d), qq a, b, d, p1, p2, q) a, b, dd, qq); Theorem 5.7 a, b b) d a/2, b, d) d a, b, d). dec GCDThm25 : [@(IsEven, a) b) -> 14
15 let a2 a, I2) a2, b, d) a, b, d)]; dec GCDLem251 :!(a : Nat, b : Nat, d : Nat) [@(IsEven, a) b) -> let a2 a, I2) in [@(CDCond, a2, b, d) a, b, d)]]; dec GCDLem252 :!(a : Nat, b : Nat, d : Nat) [@(IsEven, a) b) -> let a2 a, I2) in [!(m : Nat) [@(CDCond, a2, b, m) m, d)] ->!(m : Nat) [@(CDCond, a, b, m) m, d)]]]; def GCDThm25 = \(p1 a), p2 b)) let a2 a, I2) in \(p3 a2, b, d)) let d p3), q p3) in let Q1 a2, b, d), Q2 =!(m : Nat) [@(CDCond, a2, b, m) m, d)] in let q1 Q1, Q2, q), q2 Q1, Q2, q) in let R1 a, b, d), R2 =!(m : Nat) [@(CDCond, a, b, m) m, d)] in let r1 a, b, d, p1, p2, q1), r2 a, b, d, p1, p2, q2) in let r R1, R2, r1, r2) a, b, d, r); Theorem 5.8 a, b b) d a, b/2, d) d a, b, d). dec GCDThm26 : [@(IsOdd, a) b) -> let b2 b, I2) a, b2, d) a, b, d)]; def GCDThm26 = \(p1 a), 15
16 p2 b)) let b2 b, I2) in \(p3 a, b2, d)) let d p3), q p3) in let q1 a, b2, d, q), q2 b2, a, d, q1), q3 b, a, p2, p1, q2) in let dd q3), qq q3) a, b, b, a, dd, qq)); Theorem 5.9 a, b b) a b d (a b)/2, b, d) d a, b, d). dec GCDThm27 : [@(IsOdd, a) b) a, b) -> let a, b), I2) amb, b, d) a, b, d)]; dec OddMinusEvenLem : [@(IsOdd, a) b) a, b) -> let amb a, b) amb)]; dec GCDMinusLem :!(a : Nat, b : Nat, d : Nat) [@(NGe, a, b) -> let amb a, b) in [@(GCDCond, amb, b, d) a, b, d)]]; def GCDThm27 = \(p1 a), p2 b), p3 a, b)) let a, b), I2) in \(p4 amb, b, d)) let q1 a, b, p1, p2, p3), a, b), b, q1, p2, p4) in let d q2), q q2) in let q3 a, b, d, p3, q) a, b, d, q3); 16
17 Theorem 5.10 a, b b) b a d a, (b a)/2, d) d a, b, d). dec GCDThm28 : [@(IsOdd, a) b) b, a) -> let b, a), I2) a, bma, d) a, b, d)]; def GCDThm28 = \(p1 a), p2 b), p3 b, a)) let b, a), I2) in \(p4 a, bma, d)) let d p4), q p4) in let q1 a, bma, d, q), q2 bma, a, d, q1), q3 b, a, p2, p1, p3, q2) in let dd q3), qq q3) a, b, b, a, dd, qq)); dec GCDInduct : [[@(Equal, Nat, a, OO) a, b, d)] -> [@(Equal, Nat, b, OO) a, b, d)] -> [@(Equal, Nat, a, b) a, b, d)] -> [@(IsEven, a) b) -> let a2 a, I2), b2 b, I2) a2, b2, d) a, b, d)] -> [@(IsEven, a) b) -> let a2 a, I2) a2, b, d) a, b, d)] -> [@(IsOdd, a) b) -> let b2 b, I2) a, b2, d) a, b, d)] -> 17
18 a) b) a, b) -> let a, b), I2) amb, b, d) a, b, d)] -> [@(IsOdd, a) b) b, a) -> let b, a), I2) a, bma, d) a, b, d)] a, b, d)]; def GCDThm2 a, a, a, a, a, a, a, a, a, b)); def GCDThm3 Nat, Nat, Nat, GCDCond, GCDThm2); 5.6 Algorithm Derived dec GCD : [Nat -> Nat -> Nat]; def GCD = a), b, b), a, a, b), a, Nat, 18
19 b)), let a2 a, I2), b2 b, I2) a2, b)), let a2 a, I2) a2, b)), let b2 b, I2) a, @(IS_ODD, a, b)), let a, b), I2) amb, @(IS_ODD, b, a)), let b, a), I2) a, bma), ERR_NAT)))))))); 5.7 Implementation in C Following is an implementation of the algorithm in C, taking two (non-negative) integer arguments u and v. It first removes all common factors of 2 using identity 2, then computes the GCD of the remaining numbers using identities 3 and 4, and combines these to form the final answer. typedef unsigned long long uint64; uint64 gcd(uint64 u, uint64 v) { int shift; /* GCD(0, x) := x */ if (u == 0 v == 0) return u v; /* Let shift := lg K, where K is the greatest power of 2 dividing both u and v. */ for (shift = 0; ((u v) & 1) == 0; ++shift) { u >>= 1; v >>= 1; } while ((u & 1) == 0) u >>= 1; /* From here on, u is always odd. */ do 19
20 { while ((v & 1) == 0) /* Loop X */ v >>= 1; /* Now u and v are both odd, so diff(u, v) is even. Let u = min(u, v), v = diff(u, v)/2. */ if (u < v) { v -= u; } else { uint64 diff = u - v; u = v; v = diff; } v >>= 1; } while (v!= 0); } return u << shift; References [1] Yves Bettot and Pierre Castéran. Interactive Theorem Proving and Program Development. Springer-Verlag, [2] R. L. Constable and et al. Implementing Mathematics with the Nuprl Proof Development System. Prentice-Hall Inc., Englewood Cliffs, New Jersey, [3] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. MIT Press and McGraw-Hill, second edition, [4] J.-Y. Girard. Proofs and Types. Cambridge University Press, Cambridge, UK, [5] Michael J. C. Gordon and Thomas F. Melham. Introduction to HOL: a theorem proving environment for higher order logic. Cambridge University Press, [6] P. Martin-Löf. An intuitionistic theory of types: Predicative part. In Proceedings of Logic Colloquium North- Holland, [7] P. Martin-Löf. Constructive mathematics and computer programming. In Proceedings of Six International Congress for Logic, Methodology, and Philosophy of Science, Amsterdam, North-Holland. [8] P. Martin-Löf. Intuitionistic Type Theory. Studies in Proof Theory, Vol. 1. Bibliopolis, Naples, [9] L. C. Paulson. A foundation of the simple theory of types for Isabelle. In P. Martin-Löf and G. Mints, editors, COLOG-88, LNCS 417. International Conference on Computer Logic, Springer-Verlag, [10] M.-Y. Zhu. AUTOSTAR - a software development system. ACM SIGPLAN Notices, 23(3), [11] M.-Y. Zhu and C.-W. Wang. A higher-order lambda calculus: PowerEpsilon. Technical report, Beijing Institute of Systems Engineering, Beijing, [12] M.-Y. Zhu and C.-W. Wang. Program derivation in PowerEpsilon. In Proceedings of COMPSAC 92, Chicago, September
1 Elementary number theory
Math 215 - Introduction to Advanced Mathematics Spring 2019 1 Elementary number theory We assume the existence of the natural numbers and the integers N = {1, 2, 3,...} Z = {..., 3, 2, 1, 0, 1, 2, 3,...},
More informationELEMENTARY NUMBER THEORY AND METHODS OF PROOF
CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF Copyright Cengage Learning. All rights reserved. SECTION 4.8 Application: Algorithms Copyright Cengage Learning. All rights reserved. Application:
More informationUCT Algorithm Circle: Number Theory
UCT Algorithm Circle: 7 April 2011 Outline Primes and Prime Factorisation 1 Primes and Prime Factorisation 2 3 4 Some revision (hopefully) What is a prime number? An integer greater than 1 whose only factors
More informationLecture 1. Introduction
Lecture 1 Introduction 1 Lecture Contents 1. What is an algorithm? 2. Fundamentals of Algorithmic Problem Solving 3. Important Problem Types 4. Fundamental Data Structures 2 1. What is an Algorithm? Algorithm
More informationIntegers and Mathematical Induction
IT Program, NTUT, Fall 07 Integers and Mathematical Induction Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology TAIWAN 1 Learning Objectives Learn about
More informationCS 310 Advanced Data Structures and Algorithms
CS 310 Advanced Data Structures and Algorithms Recursion June 27, 2017 Tong Wang UMass Boston CS 310 June 27, 2017 1 / 20 Recursion Recursion means defining something, such as a function, in terms of itself
More informationCOP 4516: Math for Programming Contest Notes
COP 4516: Math for Programming Contest Notes Euclid's Algorithm Euclid's Algorithm is the efficient way to determine the greatest common divisor between two integers. Given two positive integers a and
More informationSEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION
CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Copyright Cengage Learning. All rights reserved. SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All rights reserved.
More informationProvably Correct Software
Provably Correct Software Max Schäfer Institute of Information Science/Academia Sinica September 17, 2007 1 / 48 The Need for Provably Correct Software BUT bugs are annoying, embarrassing, and cost gazillions
More informationCS2 Algorithms and Data Structures Note 1
CS2 Algorithms and Data Structures Note 1 Analysing Algorithms This thread of the course is concerned with the design and analysis of good algorithms and data structures. Intuitively speaking, an algorithm
More informationMath Introduction to Advanced Mathematics
Math 215 - Introduction to Advanced Mathematics Number Theory Fall 2017 The following introductory guide to number theory is borrowed from Drew Shulman and is used in a couple of other Math 215 classes.
More informationMAT 243 Test 2 SOLUTIONS, FORM A
MAT 243 Test 2 SOLUTIONS, FORM A 1. [15 points] Calculate the following quantities: a. 17 mod 4 Solution: 17 17 4 = 17 4 4 = 1. 4 b. 17 div 4 17 Solution: = 4. 4 c. (( 1) mod 12) mod (27 div 5) Solution:
More informationCS3110 Spring 2017 Lecture 6 Building on Problem Set 1
CS3110 Spring 2017 Lecture 6 Building on Problem Set 1 Robert Constable 1 Lecture Plan 1. Repeating schedule of remaining five problem sets and prelim. 2. Expressing PS1 related concepts in type theory.
More informationCS/COE 1501 cs.pitt.edu/~bill/1501/ More Math
CS/COE 1501 cs.pitt.edu/~bill/1501/ More Math Exponentiation x y Can easily compute with a simple algorithm: Runtime? ans = 1 i = y while i > 0: ans = ans * x i-- 2 Just like with multiplication, let s
More informationCOMPSCI 230 Discrete Math Prime Numbers January 24, / 15
COMPSCI 230 Discrete Math January 24, 2017 COMPSCI 230 Discrete Math Prime Numbers January 24, 2017 1 / 15 Outline 1 Prime Numbers The Sieve of Eratosthenes Python Implementations GCD and Co-Primes COMPSCI
More informationHow Efficient Can Fully Verified Functional Programs Be - A Case Study of Graph Traversal Algorithms
How Efficient Can Fully Verified Functional Programs Be - A Case Study of Graph Traversal Algorithms Mirko Stojadinović Faculty of Mathematics, University of Belgrade Abstract. One approach in achieving
More informationABriefOverviewofAgda A Functional Language with Dependent Types
ABriefOverviewofAgda A Functional Language with Dependent Types Ana Bove, Peter Dybjer, and Ulf Norell e-mail: {bove,peterd,ulfn}@chalmers.se Chalmers University of Technology, Gothenburg, Sweden Abstract.
More informationTheorem Proving Principles, Techniques, Applications Recursion
NICTA Advanced Course Theorem Proving Principles, Techniques, Applications Recursion 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic,
More informationCreating a new data type
Appendix B Creating a new data type Object-oriented programming languages allow programmers to create new data types that behave much like built-in data types. We will explore this capability by building
More informationCS3110 Spring 2017 Lecture 9 Inductive proofs of specifications
CS3110 Spring 2017 Lecture 9 Inductive proofs of specifications Robert Constable 1 Lecture Plan 1. Repeating schedule of remaining five problem sets and prelim. 2. Comments on tautologies and the Coq logic.
More informationRecursion. Lars-Henrik Eriksson. Functional Programming 1. Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström
Lars-Henrik Eriksson Functional Programming 1 Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström Tjark Weber (UU) Recursion 1 / 41 Comparison: Imperative/Functional Programming Comparison:
More informationProgramming with dependent types: passing fad or useful tool?
Programming with dependent types: passing fad or useful tool? Xavier Leroy INRIA Paris-Rocquencourt IFIP WG 2.8, 2009-06 X. Leroy (INRIA) Dependently-typed programming 2009-06 1 / 22 Dependent types In
More informationIntroduction to Coq Proof Assistant
Introduction to Coq Proof Assistant Qian Hu, M.Sc McMaster University March 3, 2010 Presentation Outline Overview Computer Assistance in Proofs Proof Assistant Coq Introduction The Coq Proof Assistant
More informationEuclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm
MA/CSSE 473 Day 06 Euclid's Algorithm MA/CSSE 473 Day 06 Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm 1 Quick look at review topics in textbook REVIEW
More informationTheorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214
Theorem proving PVS theorem prover Abhik Roychoudhury National University of Singapore Both specification and implementation can be formalized in a suitable logic. Proof rules for proving statements in
More informationLemma (x, y, z) is a Pythagorean triple iff (y, x, z) is a Pythagorean triple.
Chapter Pythagorean Triples.1 Introduction. The Pythagorean triples have been known since the time of Euclid and can be found in the third century work Arithmetica by Diophantus [9]. An ancient Babylonian
More informationIntroduction to Sets and Logic (MATH 1190)
Introduction to Sets and Logic () Instructor: Email: shenlili@yorku.ca Department of Mathematics and Statistics York University Dec 4, 2014 Outline 1 2 3 4 Definition A relation R from a set A to a set
More informationAssertions & Verification & Example Loop Invariants Example Exam Questions
2014 November 27 1. Assertions & Verification & Example Loop Invariants Example Exam Questions 2. A B C Give a general template for refining an operation into a sequence and state what questions a designer
More informationSolutions to the Second Midterm Exam
CS/Math 240: Intro to Discrete Math 3/27/2011 Instructor: Dieter van Melkebeek Solutions to the Second Midterm Exam Problem 1 This question deals with the following implementation of binary search. Function
More informationCS3110 Spring 2017 Lecture 7 Specifications using types continued
CS3110 Spring 2017 Lecture 7 Specifications using types continued Robert Constable 1 Lecture Plan 1. Repeating schedule of remaining five problem sets and prelim. 2. Fixing OCaml specification and code
More informationProposal: k-d Tree Algorithm for k-point Matching
Proposal: k-d Tree Algorithm for k-point Matching John R Hott University of Virginia 1 Motivation Every drug seeking FDA approval must go through Phase II and III clinical trial periods (trials on human
More informationMathematical Induction
Mathematical Induction Victor Adamchik Fall of 2005 Lecture 3 (out of three) Plan 1. Recursive Definitions 2. Recursively Defined Sets 3. Program Correctness Recursive Definitions Sometimes it is easier
More informationLecture 10: Strongly Connected Components, Biconnected Graphs
15-750: Graduate Algorithms February 8, 2016 Lecture 10: Strongly Connected Components, Biconnected Graphs Lecturer: David Witmer Scribe: Zhong Zhou 1 DFS Continued We have introduced Depth-First Search
More informationMaximum flows & Maximum Matchings
Chapter 9 Maximum flows & Maximum Matchings This chapter analyzes flows and matchings. We will define flows and maximum flows and present an algorithm that solves the maximum flow problem. Then matchings
More informationAssertions & Verification Example Exam Questions
2009 November 23 Assertions & Verification Example Exam Questions 1. 2. A B C Give a general template for refining an operation into a sequence and state what questions a designer must answer to verify
More informationELEMENTARY NUMBER THEORY AND METHODS OF PROOF
CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF Copyright Cengage Learning. All rights reserved. SECTION 4.3 Direct Proof and Counterexample III: Divisibility Copyright Cengage Learning. All rights
More informationCS 157: Assignment 5
Problem : Printing Neatly CS 157: Assignment 5 Douglas R. Lanman 4 April 006 In a word processor or in L A TEX, one routinely encounters the pretty printing problem. That is, how does one transform text
More informationLecture slides & distribution files:
Type Theory Lecture slides & distribution files: http://www.cs.rhul.ac.uk/home/zhaohui/ttlectures.html Zhaohui Luo Department of Computer Science Royal Holloway, University of London April 2011 2 Type
More informationIntroduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD
Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD In this session, we will write another algorithm to solve a mathematical problem. If you
More informationoverview overview who practicalities introduction data structures and algorithms lecture 1 sorting insertion sort pseudo code merge sort
overview data structures and algorithms 2017 09 04 lecture 1 overview who lectures: Femke van Raamsdonk f.van.raamsdonk at vu.nl T446 exercise classes: Paul Ursulean Petar Vukmirovic when and where tests
More information15 212: Principles of Programming. Some Notes on Induction
5 22: Principles of Programming Some Notes on Induction Michael Erdmann Spring 20 These notes provide a brief introduction to induction for proving properties of ML programs. We assume that the reader
More informationELEMENTARY NUMBER THEORY AND METHODS OF PROOF
CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF Copyright Cengage Learning. All rights reserved. SECTION 4.3 Direct Proof and Counterexample III: Divisibility Copyright Cengage Learning. All rights
More informationCSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4
CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University Name: ID#: Section #: Score: / 4 Unit 7: Direct Proof Introduction 1. The statement below is true. Rewrite the
More informationAlgorithm Design: GCD
Algorithm Design: GCD Problem solution through refinement GCD Example of use of loops Arguing the complexity of an algorithm Greek mathematics achievement: Euclid s Algorithm 1 How to find the GCD of 2
More informationCS3110 Spring 2016 Lecture 5 Modules for Rational Numbers
CS3110 Spring 2016 Lecture 5 Modules for Rational Numbers Mark Bickford and R. Constable Abstract This lecture begins our discussion of modules in OCaml and module interfaces. These language constructs
More informationCSE-321 Programming Languages 2010 Midterm
Name: Hemos ID: CSE-321 Programming Languages 2010 Midterm Score Prob 1 Prob 2 Prob 3 Prob 4 Total Max 15 30 35 20 100 1 1 SML Programming [15 pts] Question 1. [5 pts] Give a tail recursive implementation
More informationIntroduction to the Calculus of Inductive Definitions
Introduction to the Calculus of Inductive Definitions Christine Paulin-Mohring 1 LRI, Univ Paris-Sud, CNRS and INRIA Saclay - Île-de-France, Toccata, Orsay F-91405 Christine.Paulin@lri.fr 1 Introduction
More informationFoundations of Computer Science Spring Mathematical Preliminaries
Foundations of Computer Science Spring 2017 Equivalence Relation, Recursive Definition, and Mathematical Induction Mathematical Preliminaries Mohammad Ashiqur Rahman Department of Computer Science College
More information1 Elementary number theory
1 Elementary number theory We assume the existence of the natural numbers and the integers N = {1, 2, 3,...} Z = {..., 3, 2, 1, 0, 1, 2, 3,...}, along with their most basic arithmetical and ordering properties.
More informationScan Scheduling Specification and Analysis
Scan Scheduling Specification and Analysis Bruno Dutertre System Design Laboratory SRI International Menlo Park, CA 94025 May 24, 2000 This work was partially funded by DARPA/AFRL under BAE System subcontract
More informationSCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems
SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics Numbers & Number Systems Introduction Numbers and Their Properties Multiples and Factors The Division Algorithm Prime and Composite Numbers Prime Factors
More informationUNIT-II NUMBER THEORY
UNIT-II NUMBER THEORY An integer n is even if, and only if, n equals twice some integer. i.e. if n is an integer, then n is even an integer k such that n =2k An integer n is odd if, and only if, n equals
More informationarxiv: v1 [cs.dm] 1 Jul 2016
1 A Note on Extended Euclid s Algorithm arxiv:1607.00106v1 [cs.dm] 1 Jul 2016 Hing Leung Department of Computer Science New Mexico State University Las Cruces, NM 88003, USA Abstract Starting with the
More informationLine Graphs and Circulants
Line Graphs and Circulants Jason Brown and Richard Hoshino Department of Mathematics and Statistics Dalhousie University Halifax, Nova Scotia, Canada B3H 3J5 Abstract The line graph of G, denoted L(G),
More informationAlgorithmic number theory Cryptographic hardness assumptions. Table of contents
Algorithmic number theory Cryptographic hardness assumptions Foundations of Cryptography Computer Science Department Wellesley College Fall 2016 Table of contents Introduction Primes and Divisibility Modular
More informationSummary of Course Coverage
CS-227, Discrete Structures I Spring 2006 Semester Summary of Course Coverage 1) Propositional Calculus a) Negation (logical NOT) b) Conjunction (logical AND) c) Disjunction (logical inclusive-or) d) Inequalities
More informationCS3110 Spring 2017 Lecture 18: Binary Search Trees
CS3110 Spring 2017 Lecture 18: Binary Search Trees Robert Constable Date for Due Date PS5 Out on April 10 April 24 PS6 Out on April 24 May 8 (day of last lecture) 1 Summarizing Computational Geometry In
More informationComputable Euclidean Domains
Computable Euclidean Domains Asher M. Kach (Joint Work with Rod Downey and with Paul Ellis and Reed Solomon) Southern Wisconsin Logic Colloquium 9 October 2012 Asher M. Kach Computable Euclidean Domains
More informationCS 3410 Ch 7 Recursion
CS 3410 Ch 7 Recursion Sections Pages 7.1-7.4, 7.7 93-319, 333-336 7.1 Introduction 1. A recursive method is a method that either directly or indirectly makes a call to itself. [Weiss]. It does this by
More informationCOE428 Lecture Notes Week 1 (Week of January 9, 2017)
COE428 Lecture Notes: Week 1 1 of 10 COE428 Lecture Notes Week 1 (Week of January 9, 2017) Table of Contents COE428 Lecture Notes Week 1 (Week of January 9, 2017)...1 Announcements...1 Topics...1 Informal
More informationIntroduction to the Theory of Computation, Sipser, PWS, ISBN X, 1996
CA320: COMPUTABILITY AND COMPLEXITY 1 1 Introduction CA320 Computability and Complexity Lecturer: Office: L2.55 Phone: 5017 Email: hamilton@computing.dcu.ie WWW: http://www.computing.dcu.ie/ hamilton Course
More informationMathematics. Jaehyun Park. CS 97SI Stanford University. June 29, 2015
Mathematics Jaehyun Park CS 97SI Stanford University June 29, 2015 Outline Algebra Number Theory Combinatorics Geometry Algebra 2 Sum of Powers n k=1 k 3 k 2 = 1 n(n + 1)(2n + 1) 6 = ( k ) 2 = ( 1 2 n(n
More informationOn Meaning Preservation of a Calculus of Records
On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract
More informationContent Development for Distance Education in Advanced University Mathematics Using Mizar
Content Development for Distance Education in Advanced University Mathematics Using Mizar Takaya IDO 1, Hiroyuki OKAZAKI 1, Hiroshi YAMAZAKI 1, Pauline Naomi KAWAMOTO 1, Katsumi WASAKI 1, and Yasunari
More informationMath 302 Introduction to Proofs via Number Theory. Robert Jewett (with small modifications by B. Ćurgus)
Math 30 Introduction to Proofs via Number Theory Robert Jewett (with small modifications by B. Ćurgus) March 30, 009 Contents 1 The Integers 3 1.1 Axioms of Z...................................... 3 1.
More informationCS3110 Spring 2017 Lecture 10 a Module for Rational Numbers
CS3110 Spring 2017 Lecture 10 a Module for Rational Numbers Robert Constable Abstract The notes and lecture start with a brief summary of the relationship between OCaml types, Coq types and logic that
More informationFrom Math to Machine A formal derivation of an executable Krivine Machine Wouter Swierstra Brouwer Seminar
From Math to Machine A formal derivation of an executable Krivine Machine Wouter Swierstra Brouwer Seminar β reduction (λx. t0) t1 t0 {t1/x} Substitution Realizing β-reduction through substitution is a
More informationA Deterministic Polynomial-time Algorithm for the Clique Problem and the Equality of P and NP Complexity Classes
Vol:, No:9, 008 A Deterministic Polynomial-time Algorithm for the Clique Problem and the Equality of P and NP Complexity Classes Zohreh O. Akbari Abstract In this paper a deterministic polynomial-time
More informationCSCI2100B Data Structures Introduction
https://www.cse.cuhk.edu.hk/irwin.king/teaching/csci2100b/2013 CSCI2100B Data Structures Introduction Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering
More informationCMSC 330: Organization of Programming Languages. Lambda Calculus Encodings
CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC330 Spring 2018 1 The Power of Lambdas Despite its simplicity, the lambda calculus is quite expressive: it is Turing complete!
More informationWeek - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program.
Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 03 Euclid's Algorithm
More informationSEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION
CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All
More informationDistributed minimum spanning tree problem
Distributed minimum spanning tree problem Juho-Kustaa Kangas 24th November 2012 Abstract Given a connected weighted undirected graph, the minimum spanning tree problem asks for a spanning subtree with
More informationCS3110 Spring 2017 Lecture 8 Specifications continued
CS3110 Spring 2017 Lecture 8 Specifications continued Robert Constable 1 Lecture Plan 1. Repeating schedule of remaining five problem sets and prelim. 2. Examples of logical specifications and the evolution
More informationConstrained Types and their Expressiveness
Constrained Types and their Expressiveness JENS PALSBERG Massachusetts Institute of Technology and SCOTT SMITH Johns Hopkins University A constrained type consists of both a standard type and a constraint
More informationThe Cheapest Way to Obtain Solution by Graph-Search Algorithms
Acta Polytechnica Hungarica Vol. 14, No. 6, 2017 The Cheapest Way to Obtain Solution by Graph-Search Algorithms Benedek Nagy Eastern Mediterranean University, Faculty of Arts and Sciences, Department Mathematics,
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC 330 Spring 2017 1 Review A lambda calculus expression is defined as e ::= x variable λx.e abstraction (fun def) e e application
More informationCHAPTER 8. Copyright Cengage Learning. All rights reserved.
CHAPTER 8 RELATIONS Copyright Cengage Learning. All rights reserved. SECTION 8.3 Equivalence Relations Copyright Cengage Learning. All rights reserved. The Relation Induced by a Partition 3 The Relation
More informationOn Jeśmanowicz Conjecture Concerning Pythagorean Triples
Journal of Mathematical Research with Applications Mar., 2015, Vol. 35, No. 2, pp. 143 148 DOI:10.3770/j.issn:2095-2651.2015.02.004 Http://jmre.dlut.edu.cn On Jeśmanowicz Conjecture Concerning Pythagorean
More informationTransforming Programs into Recursive Functions
SBMF 2008 Transforming Programs into Recursive Functions Magnus O. Myreen, Michael J. C. Gordon 1 Computer Laboratory, University of Cambridge 15 JJ Thomson Avenue, Cambridge, UK Abstract This paper presents
More informationModified Farey Sequences
Modified Farey Sequences Dhroova Aiylam MIT PRIMES May, Dhroova Aiylam (MIT PRIMES) Modified Farey Sequences May, / 8 The Farey Sequence a b, c d a + c b + d Dhroova Aiylam (MIT PRIMES) Modified Farey
More informationLECTURE 16. Functional Programming
LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative
More informationLecture Notes on Induction and Recursion
Lecture Notes on Induction and Recursion 15-317: Constructive Logic Frank Pfenning Lecture 7 September 19, 2017 1 Introduction At this point in the course we have developed a good formal understanding
More informationApplied Cryptography and Network Security
Applied Cryptography and Network Security William Garrison bill@cs.pitt.edu 6311 Sennott Square Lecture #8: RSA Didn t we learn about RSA last time? During the last lecture, we saw what RSA does and learned
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC 330 Summer 2017 1 The Power of Lambdas Despite its simplicity, the lambda calculus is quite expressive: it is Turing complete!
More information1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall
CSE 20 https://goo.gl/forms/1o 1KOd17RMoURxjn2 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Today's learning goals Explain the steps in a proof by mathematical and/or structural
More informationComputing Fundamentals 2 Introduction to CafeOBJ
Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal Faria, Prof. Heinrich Hußmann. See notes on slides
More informationDiscrete Mathematics Lecture 4. Harper Langston New York University
Discrete Mathematics Lecture 4 Harper Langston New York University Sequences Sequence is a set of (usually infinite number of) ordered elements: a 1, a 2,, a n, Each individual element a k is called a
More informationAutomata and Formal Languages - CM0081 Introduction to Agda
Automata and Formal Languages - CM0081 Introduction to Agda Andrés Sicard-Ramírez Universidad EAFIT Semester 2018-2 Introduction Curry-Howard correspondence Dependent types Constructivism Martin-Löf s
More informationIS BINARY ENCODING APPROPRIATE FOR THE PROBLEM-LANGUAGE RELATIONSHIP?
Theoretical Computer Science 19 (1982) 337-341 North-Holland Publishing Company NOTE IS BINARY ENCODING APPROPRIATE FOR THE PROBLEM-LANGUAGE RELATIONSHIP? Nimrod MEGIDDO Statistics Department, Tel Aviv
More informationExponentiation. Evaluation of Polynomial. A Little Smarter. Horner s Rule. Chapter 5 Recursive Algorithms 2/19/2016 A 2 M = (A M ) 2 A M+N = A M A N
Exponentiation Chapter 5 Recursive Algorithms A 2 M = (A M ) 2 A M+N = A M A N quickpower(a, N) { if (N == 1) return A; if (N is even) B = quickpower(a, N/2); retrun B*B; return A*quickPower(A, N-1); slowpower(a,
More informationSTRUCTURE EXITS, NOT LOOPS
STRUCTURE EXITS, NOT LOOPS Mordechai Ben-Ari Department of Science Teaching Weizmann Institute of Science Rehovot 76100 Israel ntbenari@wis.weizmann.ac.il Copyright c 1996 by the Association for Computing
More informationCh 3.4 The Integers and Division
Integers and Division 1 Ch 3.4 The Integers and Division This area of discrete mathematics belongs to the area of Number Theory. Some applications of the concepts in this section include generating pseudorandom
More informationCOMP6700/2140 Recursive Operations
COMP6700/2140 Recursive Operations Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU May 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Recursive Operations
More informationPACKING DIGRAPHS WITH DIRECTED CLOSED TRAILS
PACKING DIGRAPHS WITH DIRECTED CLOSED TRAILS PAUL BALISTER Abstract It has been shown [Balister, 2001] that if n is odd and m 1,, m t are integers with m i 3 and t i=1 m i = E(K n) then K n can be decomposed
More informationDESIGN OF A COMPOSITE ARITHMETIC UNIT FOR RATIONAL NUMBERS
DESIGN OF A COMPOSITE ARITHMETIC UNIT FOR RATIONAL NUMBERS Tomasz Pinkiewicz, Neville Holmes, and Tariq Jamil School of Computing University of Tasmania Launceston, Tasmania 7250 AUSTRALIA Abstract: As
More informationRecursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions
Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin
More informationAdvanced algorithms. topological ordering, minimum spanning tree, Union-Find problem. Jiří Vyskočil, Radek Mařík 2012
topological ordering, minimum spanning tree, Union-Find problem Jiří Vyskočil, Radek Mařík 2012 Subgraph subgraph A graph H is a subgraph of a graph G, if the following two inclusions are satisfied: 2
More informationUsing Templates to Introduce Time Efficiency Analysis in an Algorithms Course
Using Templates to Introduce Time Efficiency Analysis in an Algorithms Course Irena Pevac Department of Computer Science Central Connecticut State University, New Britain, CT, USA Abstract: We propose
More informationCoq projects for type theory 2018
Coq projects for type theory 2018 Herman Geuvers, James McKinna, Freek Wiedijk February 6, 2018 Here are five projects for the type theory course to choose from. Each student has to choose one of these
More information