# A CAL"CULUS OF FUNCTIONS FOR PROGRAM DERIVATION

Save this PDF as:

Size: px
Start display at page: ## Transcription

1 A CAL"CULUS OF FUNCTIONS FOR PROGRAM DERIVATION by Richard Bird Oxforo university Compullng Laboratory Programming Research Group-Library 8-11 Keble Road Oxford OX1 3QD Oxford (O~R Technical Monograph PRG-64 December 1987 Oxford University Computing Laboratory Programming Research Group 8-11 Keble Road Oxford OXI 3QD England

2 Rkhard Bird Oxford Uciversity Computing Laboratory Programming Research Group 8-11 Keble Road Oxford OX13QD England

3 A Calculus of Functions for Program Derivation R.S. Bird Programming Research Group, Oxford University.! 1. Introduction. This paper is about how to calculate programs. We introduce a n~ tation for describing functions, outline a calculus for manipulating functiondescriptions, and prove two general theorems for implementing certain functions efficiently. Like useful calculi in other branches of mathematicb, tbe calculus offunctions consists of a body of knowledge expre88ed as basic algebraic identities, technical lemmas and more general theorems. We illustrate the calculational approach to program construction by posing and Bolving a simple problem about coding sequences. In presenting this work we wish to argue: (i) that Borne, perhapb many, algorithma <:an be derived by procebb of systematic calculation from their specifications; (ii) that an appropriate framework for this activity can be baaed on notation for describing functions, notation that is wide enough to express both specifications and implementationsj (iii) that an effective calculus of program derivation must be built upon useful general theorems relating certain forolfl of expression to common patterns of computation, theorems that-in the main-we still lack. By way of motivation, we start in Section 2 by posing the problem we want to solve. The notational framework is introduced in Section 3. In that section we also state (mostly without proof) a number of simple algebraic laws about functions. In Section 4 we apply these laws to our example problem until we arrive at a point where a more substantial theorem is required. This theorem is stated, together with a second theorem, in Section 5. We believe that these two theorema are of the kind that will eventually prove important in establishing a useful calculus for program derivation. 2. Run-length encoding. The problem we will use to illustrate our approach is that of run-length encoding. The idea behind run-jength encoding is to represent a sequence of values (usually characters) in a compact form by coding each "run" of equal values by a pair consisting of the common value and the length of the 1 Addreu: 11 Keble Roa.d, Oxford, OXl 3QD, U.K. 1

4 run. For example, code "AABCCAAA" = [('A', 2), ('B', 1), ('C', 2), ('A', 3)1 The algorithm for computing code contains no surprises or subtleties. Our objective, however, is to derive the algorithm from its specification, using essentially the same kind of reasoning that a mathematician might employ in solving a problem in, say, formal integration. To specify code, consider the inverse function, decode. A sequence of pairs can be decoded by "expanding" each pair to a sequence of values, and concatenating the results. Given decode, we can specify (code z) as the shortest sequence of pairs that decodes to z. To make this idea precise, suppose we define the generalised inverse I-I of a function f by the equation r'z={wlfw=z} Using notation from [IJ (discussed further in the next section) we can now specify cod, as follows: code.. ... [(0, N+)J code =!II /. decode-' decode = */. ezpo ezp(a,n) = K. 0[1.. n] The first line of the specification gives the type of code as a function from lists of o:-values to lists of pairs, each pair consisting of an o:-value and a positive integer. The second line says that code is the functional composition of a function (!II /) that select. the shortest in a set of sequences, and the generalised inverse of decode. The third line defines decode as the composition ofa function (*/) that concatenates a list of lists together, and a function (<<po) that applies ezp to every element of a list. Finally, ezp (a, n) is obtained for a positive integer n by applying the constant-value function K. to each element of the list [1.. n], thereby giving a list of n copies of a. We shall return to this specification in Section 4. First we need to discuss notation in more detail, as well as introduce some of basic algebraic identities employed in the derivation. 3. Notation. Our notation i. basically that of [IJ (see also ,  and 16]) with some additions and modifications. In particular, functions are curried, so function 2

5 application associates to the left, and simple function arguments are written without brackets. Lists and sets. We shall use square brackets "[" and "I" to denote lists, and braces "{" and "}" for sets. The symbol * denotes list concatenation and U denotes set union. The functions [.] and {o} return singleton lists and sets, respectively. Thus [,1 a = [a] {.}a = {a} To avoid clumsy subscripts, we shall use ao rather than Kg to describe the function that always returns the value a. In particular, []O denotes the function defined by the equation [J"a = [J A similar function for sets is used below. We use #z to denote the length of the list z (or the size of the set z). Selection. Suppose f is a numeric-valued function. The binary operator 1, selects its left or right argument, depending on which has the smaller I-value: z 1, II = z, If I z < I II = II, if I II < I z Unless f is an injective function on the domain of values of interest, the operator 1, is under-specified: if z # II but I z = I II, then the value of z 1, II is not specified (beyond the fact that it is one of z or II). example, the value "bye" 1* "all" is under-specified since both arguments have the same length. In order to reason about 1/ for arbitrary f, it is abbumed only that l, is associative, idempotent, commutative, selective, and minimising in the sense that l(zl,ii)=/ z 1l11 Here, 1 is used as an abbreviation for lid, where id is the identity function, and so selects the smaller of its two numeric arguments. The under-definedn... of 1, can be very useful in specifying problems in computation. If necebbary, Uties" can be resolved by imposing extra condi~ tions on I. By definition, a refinement of I is a function 9 that r.spects the For 3

6 ordering on values given by /, in the sense that Ix</y=?gx<gy but 9 may introduce further distinctions. (Here, =? denotes logical implication), Such refinements can always be introduced into a specification in order to ease the task of calculation, the only requirement being that the refinement must be recorded and must be consistent with all previous refinements, if any. (In both [lj and [6J, re5nements were recorded by uaing a special Bymbol, either... or ~. In the present paper, use of such signs is avoided; instead we stay strictly in the framework of equational reasoning, and make refinements explicit.) Conditionals. We shall use the McCarthy conditional form (p -+ I, g) to describe the function (p-+i,g)x = Ix, Ifpx = 9 x, otherwise For total predicates p we have the following well-known identity: h'(p-+i,g) = (p-+h'l,h'g) (1) Equation (1) is referred to 88 the "dot-condo law. Map. The operator 0 (pronounced "map") takes a function on its left and a list (or set) on its right. Informally, we have 1 0 [a" a2,..., an] = [I alol a2,".'/ an] with an analogous equation holding Cor sets. We can specify * over lists by the three equations 1 0 [J = [] 10 [a] =!f a] lo(x*y) Uox)*Uoy) These equations can also be expressed as identities between functions: 1 0 [)" = [J" (2) 10.[.J = [']'1 (3) 1 0 '*/ = */'Uo)o (4) 4

7 We will refer to (2) as the "map-empty law, to (3) as the "map-single" law, and to (4) as the "map-concat" law. Equstion (4) makes use of the reduetion operator I discussed helow. Similar equations hold for the definition of over sets. In particular, the analogue of (4) (in which -tt is replaced by u) is called the "map-union" law. [Note 0" sy"ta". In [IJ laws like the above were written with more brackets. For example, the map-concat law---called "'map promotion" in [I)-was written (t.). (-ttl) = (*I)' ((t.).) In the present paper we avoid these additional brackets hy assuming functional composition (.) has lowest precedence.i Another useful identity is provided by the fact that. distributes over functional composition-the "dot.map" law: (t.g). = f g (5) Reduce. The reduction operator I takes a binary operator (Il on its left, and a list (or set) on its right. Informally, we have (Il/[a., ""...,...1= a. (Il a. (Il... (Il an More formally, we can specify (ilion non-empty lists by the equations (Il/la] = a (Il/(z * y) = ((Il/z) (Il ((Illy) For the second equation to be unambiguous we require that EEl be an associative operator (because * is). These equations can also be expressed as functional identities (the "reduce-single" and "reduce--concat" Jaws): (Ill [,1 = id (6) (Il/ *I = (Il/'(Il/' (7) Similarly, we can define EB/ over non-empty sets by the equations (Il/{a} = a (Il/(z U y) = ((Il/z)(Il ((Illy) 5

8 In particular, the function level equivalent of the second equation is the "reduce-union" law: ffj/ ul = ffj/ ffji (8) In order for the application of e/ to a set to be unambiguous, we require EB to be an associative, commutative and idempotent operator (because u is). For example, ffj/z =ffj/(z u z) =(ffj/z) ffj (ffj/z) and so e must be idempotent. Since!! has these three properties, we can reduce with it over both sets and lists. In particular, we have the "shortestmap" law: L* I.(J.). = f L* I (9) Identity elements. If EB has an identity element e, then we can also define ffj/[j= ffj/{} = e Equivalently, the "reduce-empty" laws says ffj/ [I' = e' (10) It is often useful to invent "fictitious" identity elements for operators that do not possess them. For example, we introduce w as the fictitious identity element of L*: thus L*IO = w Provided certain care is taken, fictitious identity elements can always be adjoined to a domain (oee [IJ for a more complete discussion). HOInomorphlsms. Functions of the form ffji.f. describe homomorphisms over lists (or sets), and are discu..ed in [11 (s.. also ). There are three particular homomorphisms that will be needed below: generalised conjunction, filter, and cartesian prcxluct. (i) Generalised conjunction. For a boolean-va.iued function p we define all p by the equation all p = /\1. p' 6

9 where 1\ denotes logical conjunction. Thus (all p x) returns true if every element of the list (or set) z satisfies p, and false otherwise. One simple law ("all-and") is all (p 1\ q) = all p 1\ all q (11) (ii) Filter. The operator ~ (pronounced "filter") is defined for sets by the equation p~=u/.(p~ {-},{}O)' Thus, (p <l) is a homomorphism on sets. A similar equation holds for lists. In effect, (p ~ z) returns the subset of elements of z that satisfy p. This subset is obtained by replacing each element a of z by {a} if p a holds, or { } if p a does not hold, and taking the union of the resulting set of sets. The "filter-union" law says that p ~.u/ = u;'(p~). (12) The following proof of this result shows the way we shall layout the steps of a calculation: as required. D p ~.u/ =: definition of <l u/. (p ~ {-},{}O). u/ map-union (4) u/.u/. ((p ~ {.), { }O).). reduce-union (8) u/.u/.((p ~ {-}, { }O).). dot-map (5) u/. (u/. ((p ~ {-}, { }O).). definition of <l u/ (p~). For total predicates p and q, we have the "and-filter" law: (pl\q)~ = P~'q~ (13) Another identity ("reduce-cond") involving <l is as follows. Suppose ED has identity elemen t e, then (fj/ (p~f,eo). = (fj/'f"p~ (14) 1

10 Here is the proof: fij/'/"p<j definition of <J fiji /. * I. (p --+ ['), []O). = map-concat (4) fiji *1 (I.). (p --+ [.J, [JO). = reduce-concat (7) fiji fiji'.(1.). (p --+ [.J, [)O). dot-map (5) fiji (fiji (I.). (p --+ [.), [JO)). dot-cond (1) fiji (p --+ fiji /. [.J, fiji /.[)0)* Now we argue that and also that fij/ /, [.) = map-single (3) fiji [.)./ = reduce-single (6) / fiji /. [Jo map-empty (2) fiji. []O reduce-empty (10) eo completing the calculation. 0 (iii) Cart,";an product. The third homomorphism is a function cp (short for ucartesian product") with type cp:: [{a}) --+ {[an Thus, the cartesian product of a list of sets is a set of lists. Informally we have cp [S" S"...,S.I = {[ai, a"...,..) I aj f Sj} Formally we can define cp as the homomorphism cp = * 1 ([.J.). 8

11 S*OT= {z*y I z es; yet} Note that *0 is an a.ssociative operator. For example, we can calculate cp [{a,6},{e},{d,e}] *o/[{[a], }, {Ie]}, {[d], [e]}] = {[a],lb]} *O{[e]} *0 {[dj, [e]} = {[a, e, d], [a, e, e], [6, e, d], [6, e, d]} Two identities involving cp are the "cp-single" and "cp-cond" laws: ep Oo = {.} (15) ep' (p --+ /, no)o = (all p --+ ep '/0, no) (16) In effect, the first law says that the cartesian product of a list of singleton sets is a singleton set, while the second law says-in part-that if any set in the argument list is empty, then so is the cartesian product. Generalised inverse. by The generalised inverse of a function I is defined ria = {61/6 = a} The "dot-inverse" and.<imap-inverse" laws are We give a proof of (17): as required. 0 (/. g)-i u/ go -I /-1 (17) (/0)-1 ep./-1 0 (18) (/. g)-i a definition of inverse {6 I/(g 6) = a} == set theory u/{{6 I 9 6 = e} 1/ c = a} definition of inverse U/{g-I e 1/ e = a} == definition of * u/g-io{e 1/ e= a} definition of inverse U/g-I o/-ia 9

12 Partitions. Finally, we introduce a special case of generalised inverse. By definition, a partition of a list % is a decomposition of z into contiguous segments. A proper partition is a decomposition into non-empty segments. The (infinite) set of partitions of % is just (*/)-1%. The function parta, where paris = all (# []). (*/)-1 returns the (finite) set of proper partitions of a sequence. Two theorems about parts are given in Section Calculation of code. Using the identities given in the previous section, we can now begin to calculate an algorithm for lode. The derivation is almost entirely mechanical: at each step--with one or two minor exceptions-there is only one law that can be applied. where lode = definition of code!"1. decode- 1 = definition of decode!"i' (*1' e%p.)-1 = dot-inverse (17)!"I _ul _(e%p.)-i. _(*/)-1 = reduce-union (8)!,,;.!"I' _(e%p.)-i. _(*/)-1 = dot-map (5)!"I U"I' (e%p.)-i) "(*/)-1 introduction of /!"1-I. _(*/)-1 / =!"I. (e%p.)-1 The purpose of this last step is just to name the subexpression that will he the focus of future manipulation. Before calculating I, we first consider the function e%p-1 that will arise during the calculation. This function has values given by e%p-l%={(a,n)le%p(a,n)=%) For the set on the right to be non~emptyi we require that z is a non-empty list of duplicated values (Recall that n must he a positive integer). Suppose 10

13 we define (x 'I []) 1\ dup x nedup z dup x = all(=headx)x rep z (head x, #x) where head x returns the first element of the non-empty list x. It then follows that exp-1x = (nedup x --+ {repx},{}) or l expressed at the function level, that This equation is needed below. Now we return to calculating f: exp-l = (nedup --+ {-}. rep, {}O) f definition of f L# /. (exp_)-l map-inverse (18) L# /. cp exp-l_ definition of exp-l L# /. cp (nedup --+ {.}. rep, { }O)_ cp-cond (16) L# /. (all nedup --+ cp (0. rep)_, { }O) dot-cond (1) (all nedup --+L*/' cp (0 rep)_,)*/' {}O) = dot-map (5), and introducing w as the identity of)* (all nedup --+L*/ cp' {.} _.rep.,wo) = cp-single (15) (all nedup --+h/' {.}. rep_,wo) reduce-single (6) (all nedup --+ rep_, WO) 11

14 HavinR calculated I, we continue with the calculation of code: code = calculation so far L* /-/< _(*/)-1 = calculation of / L* /- (all n.dup ---> rep<,w") < _(*/)-1 = reduce-cond (14) L* /- (rep<) < -all n.dup <1_(*/)-1 shortest-map (9) rep < - L* / -all n.dup <I _( */)-1 definition of n.dup; all-and (ll); and-filter (13) rep < - L* /- all dup <1'011 (# []) <1.(*/)-1 = definition of parts rep < L* /. all dup. parts We ha.ve shown that cod. % = rep < L* / all dup <I parts % In worda l code % can be obtained by taking the shortest partition of % into non-empty segments of duplicated values, and representing each segment by its common value and its length. Expressed this way, the derived equation seems entirely reasonable, and might even have served as the specification of the problem. Unlike the original specification, the new definition of cod. is executable. The set parts % contains a finite number of elements (in fact, 2 n - 1 elements, if n > 0 is the length of %), and these can be enumerated, filtered, and the shortest taken. What we now need is a faster method for computing expressions of the above form, and for this we need to consider various algorithms for computing partititons. 5. Algorithms for partititons. Expressions of the form Ltlall p <I parts % arise in a number of applications. For example, in Borting by naturalmerging, the input is first divided into runs of non-decreasing values. The fudction runs which does this division can be expressed in the form runs % =L* / all nond«<l parts % 12

15 This reads: the shortest partititon of z, all of whose components are nondecreasing sequences. Similarly, the problem of filling a paragraph (see ) can b. expressed as a problem about partitions: fill m ws =L w jail (fits m) ~ parts ws This reads: the least wasteful (according to the waste function W) partition of a sequence of words ws, all of whose component segments (or Cllines") will fit on a line of given width m. There are numerous other examples (including, of course, code). This leads to the question: can we find ways of computing solutions to problems of the form LI fall p ~ parts z efficiently? The Greedy algorithm. partititon: Here is a "greedy algorithm for computing a greedy p z [), If z = [] [y] * greedy p (z ~ y), otherwise where y =i#jp~inits+z In this algorithm, the expression inits+ z denotes the list of non-empty initial segments of z, in increasing order of length, and (z ---,. y) is the sequence that remains when the initial segment y of z is deleted from z. The operator ----r is specified by the equation (u*.)~u=. for all sequences u and v. It is easy to see that, at each step, the greedy algorithm chooses the longest non-empty initial segment y of the remaining input z that satisfies the predicate p. In order for greedy to make progress, it is necessary to suppoee that p holds for [] and every singleton sequence at least. In this way a non-empty portion of the input is "consumed" at each step. There is a useful condition on p which enables the next segment y to be computed efficiently. Say p is prefix-closed if p(z*y) => pz 13

16 In words, if p holds for a sequence, then it holds for every initial segment of the sequence (including [D. Ifp is prefix-closed, then there exists a derivative function 6 such that For example, with p = dup we have and with p = non dec we have P (% * [all = p %/18 a % 8 a %= (% = [IlV(a = head%) 8 0%= (% = [Il V (labt %<:; a) where last x returns the last element of a non-empty sequence x. If p is prefix-closed, we can formulate the following version of the greedy algorithm: greedy p % = Bhunt [] % Bhunt y [] Bhunt y ([a] * %) = [] Bhunt (y * [an %, [y] * shunt [al %, if <5 a y otherwise This version is linear in the number of S-calculations. A related condition on p is that of being sutjix-closed, Le. p(%*y)*py If p is both prefix- and suffix-closed, then p is said to be segment-closed. For example, both dup and nondup are segment-closed. The suffix-closed condition arises in one of the theorems discussed below. Here is another algorithm for computing parti The Leory algorltjun. tions: leery f p % = I], if % = [] = if j{[yl * leery f p (% ~ y) I y f P ~ initb+%} otherwise This algorithm is a little more "careful" than the greedy algorithm (whence the name «leery"). At each stage, some initial segment y of x is chosen so that (i) y satisfies p; and (ii) f ([y] * yb) is as small as possihle, where yb is the result of adopting the same strategy on the rest of the input. Unlike the 14

17 greedy algorithm, the leery algorithm will not necessarily chao.. the longest initial segment of z satisfying p at each stage. The direct recursive implementation of leery is inefficient, since values of leery on tail segments of % will be recomputed many times. Instead, leery is better implemented by a dynamic-programming scheme that computes and stores the results of applying leery to all tsil segments of the input. In making a decision about the next component of the partition, these subsidiary results are then available without recomputation. We shall not, however, formulate the efficient version of leery here. We now state two theorems about the greedy and leery algorithms. For the first, we need the following definition. Definition 1 A function f, from sequences to numbers, is said to be prefixstable if f z ~ f V {} f ([a] * z) ~ f ([oj * V) for all a, z, and y. Equivalentlv, f is prefix-stable if for all a. 1/ /. ([01*)' = ([aj*) l/ / Theore= 1 (The Leery Theore=) Iff is prefix-stable, then 1/ / all p <1 parts z = leery f p z, provided p holds for [I and all singleton sequences. Proof. We shall need the following recursive definition of parts: parts [] = {[I} parts % u/subpart inits+ z if x 'I [I where subparts V = ([V]*). parts (z - V) We omit the proof that this definition of parts satisfies the specification Let 9 be defined by parts = all ('I [ll. (*/)-1 9z =1t1 all p <1 parts % The theorem is proved by showing that (J satisfies the recursive definition of leery. There are two cases to consider: 15

18 Case % = []. The derivation of 8[] = [J is straightforward and is omitted. Case % i [I. In the csse % f. [], we argue where Lr I all p " p.rts % definition of p.rts Lr I all p" U/subparts inits+ % = filter-union (12); reduce-union (8) Lr I Lr I' (.11 p") subparts. inits+ % dot-map (5) Lr!Ur!.1I p".subp.rts). inits+% = introduction of h Lr Ih. inits+% h y = Lr!.11 p" subp.rts y We continue by calculating h (note that h depends on %): Lr 1.11 p" subp.rts y = definition of subp.rts Lr I all p" ([y]*). p.rts (% - y) = property of all Lr I(p y ---> ([yl*) 11 p "p.rts (% ~ y), { }} = dot-cond (1) (p y --olr l([y]*) 11 p "p.rts (% ~ y), Lf I{}) prefix-stability (p y ---> [yj* Lr!.11 p" p.rts (% ~ y), LII{ }) = definition of 8 (py---> [y)*8(z-y),lr!{}) Finally, if we substitute the derived definition of h into the derived equation for 8 and apply the reduce-cond law, we obtain 8% = Lr!4>.p"inits+% where 4>y = [yj * 8(% ~ y) In other words, 8 satisfies the recursive definition of leery, completing the proof of the theorem. 0 16

19 Perhaps the simplest useful example of a prefix-stable function is the length function #. Another example is the function +/ that sums a list of numbers. However, prefix-stability is too strong a condition to be satsfied by commonly useful optimisation functions. Fortunately there is a weaker condition that can be artificially strengthened to give prefix-stability. Definition 2 A function f I prefix-stable if from sequences to numbers, 's said to be weakly for all x, yond a. f x ~ f y '* f ([a] * x) ~ f ([oj * y) For example, the function (t /) (where i selects the greater of its two numeric arguments) is weakly prefix-stable, but not prefix-stable. The proof of the following lemma, due to A.W. Roscoe, is given in an Appendix. Lemma 1 Suppa.. f :: [a] --+ Q is weakly prefix stable, where a contains a countable number 0/ elements} and Q denotes the rationals. Then there exists a prefix-stable function g :: [a) --+ Q that refines f. By using Lemma 1t we can therefore apply the Leery theorem in the case of a weakly prefix-stable function f. For the second theorem we need the following definition. Definition 3 A function f, from sequences (of seqences) to numbers, is greedy if both the following conditions hold for all z, y. z and s: f ([x * yj * s) < f ([z] * [y] * s) f Uz*yJ*[zJ*s) <f([zj*[y*zj*s) The first greedy condition says that shorter partitions have a smaller f value than longer ones; the second condition says that, for partitions of equal length, the longer the first component, tbe smaller is its f-value. Theore:rn 2 (The Greedy Theore:rn) If f is prefix-stable and greedy, and p is sutfiz-closed, then!// all p ~ parts z = greedy p x provided p holds for all singleton sequences. 17

20 ProDI. We show leery 1 p = greedy p. Abbreviating leery 1 p by 8, it suffices to prove that 1 (I:r * yl * 8z):s 1 ([:r] * 8(y * z)) for all:r, y and z, with equality only in the esse y = I]. In words, the longer the next component of the partition, the smaller is its I-va)ue. The proof is by induction on the length of y. The base case, #y = 0, is immediate. For the induction step, consider the value of 8(y * z). There are two possibilities: either 8(y*z) = [y*zd*8(z,) (case A) for some ZI I' [] and z" such that z = ZI * Z, and p (y * zil holds; or 8(y * z) = [y,] * 8(1h * z) (case B) for some Yl I' [] and Y2, such that y = Yl * 1h and p Yl holds; (This case includes the possibility that 1h = [].) In case A, we reason that p ZI holds, since P is suflix-closed, and so by definition of 8, 1 (8z) :s 1 ([ZI] * 8z,) Hence as required. In case B, we reason 1([:r*y)*8z) :s prefix-stability 1 ([z * yj * [zd * 6z,) < second greedy condition 1 ([:r] * Iy * ZI] * 6z,) case A 1 ([:r] * 8(y * z)) 1 ([:r * yj * 8z) case B: 1([:r*y'*1hJ*8z) :s induction hypothesis, as #1h < #!I 1 ([:r * y,] * 6(1h * z)) < first greedy condition 1 ([:r] * [VI] * 8(1h * z)) case B 1 ([:r] * 8(y * z)) 18

21 The length function # satisfies the first greedy condition, but not tbe second. AB with prefix-stability, there is a weaker version of the greedy condition that is sufficient to enable the Greedy theorem to be used. Definition <& Say / i8 weakly greedy i/ the greedy eondition8 hall when < is replaced by ~. Le=a 2 A weakly greedy /unctionhu a greedy refinement: Proof. Let / be weakly greedy. Define g by the rule g %8 < g Y8 if (J %8 < / Y8) V (J %8 = / Y811 #head %8> #head Y8) It is clear that g respects the ordering of / and is greedy Application. We give one application of the Greedy theorem. Since dup is suffix-closed (in fact, segment-closed), and # is weakly greedy, we bave that code = rep * greedy dup is a solution to the problem of run-length encoding. Acknowledgement8 Much of the calculus presented above was developed in collaboration with Lambert Meertens of the CWI, Amsterdam! to whom I am grateful for both support and friendship. I would like to thank Bill Roscoe, of the PRG, Oxford, who supplied the proof of Lemma 1 at a moment's notice. I am also grateful to Carroll Morgan and Tony Hoare for many enjoyable discussions on the proper role of refinement in a purely functional calculus. Reference. 1. Bird, R.S. An introduction to the theory oflists. Logic 0/ Programming and Calculi 0/ Di8crete Design, (edited by M. Broy), Springer-Verlag, (1981) Bird, R.S. Transformational programming and the paragraph problem. Science 0/ Computer Programming 6 (1986) lss

22 3. Bird, RS. and Hughes, RJ.M. The alpha-beta algorithm: an exercise in program transformation. Inf. Proc. Letter. 24 (1987) Bird, RS. and Meertens L.G.L.T Two exercises found in a book on algorithmics. Program SpeciMation and Transformation (edited by L.G.L.T Meertens), Nortb-Holland, (1987), Bird, RS. and WadIer, P. An Introduction to Functional Programming Prentice-Hall (to be published Spring-1988). 6. Meertens, L.G.L.T Algorithmics - towards programming... a mathematical activity. Prot. OWl Symp. on Mathematics and Computer Science, CWI Monographs, North-Holland, 1 (1986) Appendix: Proof of Lemma 1 The proofof Lemma 1 is by constructing an injective weakly prefix-stable function g. Such a function must also be prefix-stable. We argue this by contradiction. Suppose the implication fails to hold. In such a case 9 ([al* 0) ~ g([al*y) => gx ~ gy 9 ([al * 0) \$ 9 ([a] * y) 1\ go> 9 Y for Borne a, z and y. By assumption, 9 is weakly prefix-stable, 80 the above assertion implies g([al*x) ~ g([al*y)l\g([a)*y) ~ g([a}*x) However, since 9 is injective, it rohows that % = Y which contradicts the hypothesis. To construct 9, we suppose the finite sequences of [a] are enumerated in such a way that z precedes [a1* % for all a and z. Let this enumeration be denoted by {:to, x"...}. Furthermore, to avoid a subsequent appea to the Axiom of Choice, let {I'o, q"...} be some fixed enumeration of the (positive and negative) rationals Q. For the base case in the inductive construction of g) arbitrarily define 9 :to "" O. Note that :to "" []. Assume, by way of induction, that 9 %0,9 %1,,9 2;"-1

23 have so far been defined and that these distinct values satisfy all that is required of g. To determine 9 Z;, we partition {:r; I i < i} into three sets, any of which may be empty: A = {:r;jj<i/\!:r;<!z;} B = {zjli<i/\!:r;=!z;} C = {:r;li<i/\!zj>!z;} Because 9 preserves the ordering of!, the rational values assigned to 9 for arguments in A must precede those assigned to 9 for arguments in B, which must in turn precede those for arguments in C. Suppose Xi =  * %Jr:. By the given enumeration of sequences, we have k < i. Define the following two subsets of B: B, = {I a] * z/ I g:q < 9 Z.} B. = {I al * Z/ I 9 Z/ > 9 Z.} For Z f HI and Yl B: we have 9 z < 9 y, since--by induetion-g is injective and weakly prefix-stable on the values already defined. We now cboose 9 Z; to be the rational q, of least index in the given enumeration of QI such that q is greater than every element of g. (A U B,) and less than every element of 9 (C U B,). By construction we have, for i < i, that!zj<!z;~gzj<9z;!zj>!z;~gzj>gz; so the extended definition of 9 respects the ordering of!. We must also show that the extension of 9 maintains weak prefix-stablility. Supposing Z; = lal * z. and Zj = [a] *:q, where i < i, we need to show g:q<gz. ~ gzj>gz. ~ g:r;<9z; gzj>9z; Since! is weakly prefix-stable, and 9 respects!, we have Thus,! Z; <! Zj ~! z. <! z/ ~ 9 z. < 9 Z/ gz/<gz. ~ gz/<gz.ii!z;?'!zj => g%j < gx" by definition of 9 z;. The proof of the second part is similar. This completes the induction, and the proof of the lemma. 0 21

### Program Calculus Calculational Programming Program Calculus Calculational Programming National Institute of Informatics June 21 / June 28 / July 5, 2010 Program Calculus Calculational Programming What we will learn? Discussing the mathematical

### [Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics 400 lecture note #4 [Ch 6] Set Theory 1. Basic Concepts and Definitions 1) Basics Element: ; A is a set consisting of elements x which is in a/another set S such that P(x) is true. Empty set: notated {

### Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np Chapter 1: Introduction Introduction Purpose of the Theory of Computation: Develop formal mathematical models of computation that reflect real-world computers. Nowadays, the Theory of Computation can be

### Lecture 1. 1 Notation Lecture 1 (The material on mathematical logic is covered in the textbook starting with Chapter 5; however, for the first few lectures, I will be providing some required background topics and will not be

### Module 7. Independent sets, coverings. and matchings. Contents Module 7 Independent sets, coverings Contents and matchings 7.1 Introduction.......................... 152 7.2 Independent sets and coverings: basic equations..... 152 7.3 Matchings in bipartite graphs................

### CSC Discrete Math I, Spring Sets CSC 125 - Discrete Math I, Spring 2017 Sets Sets A set is well-defined, unordered collection of objects The objects in a set are called the elements, or members, of the set A set is said to contain its

### Discrete 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

### Natural Numbers. We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general. Natural Numbers We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general. For the moment we will ignore that fact that each type in Haskell includes possible

### Review of Sets. Review. Philippe B. Laval. Current Semester. Kennesaw State University. Philippe B. Laval (KSU) Sets Current Semester 1 / 16 Review of Sets Review Philippe B. Laval Kennesaw State University Current Semester Philippe B. Laval (KSU) Sets Current Semester 1 / 16 Outline 1 Introduction 2 Definitions, Notations and Examples 3 Special

### MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) Last modified: September 16, 2004 Reference: Apostol, Calculus, Vol. 2, section 13.19 (attached). The aim

### PACKING 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

### Foundations of AI. 8. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution. Wolfram Burgard and Luc De Raedt 08/1 Foundations of AI 8. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard and Luc De Raedt 08/1 Contents Motivation Syntax and Semantics Normal Forms Reduction

### LOGIC AND DISCRETE MATHEMATICS LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University

### (a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1 CS 70 Discrete Mathematics for CS Fall 2000 Wagner MT1 Sol Solutions to Midterm 1 1. (16 pts.) Theorems and proofs (a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are Oxford University Press 2013 Slides for Faculty Assistance Preliminaries Author: Vivek Kulkarni vivek_kulkarni@yahoo.com Outline Following topics are covered in the slides: Basic concepts, namely, symbols,

### 3 No-Wait Job Shops with Variable Processing Times 3 No-Wait Job Shops with Variable Processing Times In this chapter we assume that, on top of the classical no-wait job shop setting, we are given a set of processing times for each operation. We may select

### Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller 09/1 Contents Motivation 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

### FUNCTIONAL PEARLS The countdown problem To appear in the Journal of Functional Programming 1 FUNCTIONAL PEARLS The countdown problem GRAHAM HUTTON School of Computer Science and IT University of Nottingham, Nottingham, UK www.cs.nott.ac.uk/

### Figure 1.1: This is an illustration of a generic set and its elements. Chapter 1 Mathematical Review et theory is now generally accepted as the foundation of modern mathematics, and it plays an instrumental role in the treatment of probability. Unfortunately, a simple description

### On 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

### SAT-CNF Is N P-complete SAT-CNF Is N P-complete Rod Howell Kansas State University November 9, 2000 The purpose of this paper is to give a detailed presentation of an N P- completeness proof using the definition of N P given

### Relational Database: The Relational Data Model; Operations on Database Relations Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview

### Chapter 3. Set Theory. 3.1 What is a Set? Chapter 3 Set Theory 3.1 What is a Set? A set is a well-defined collection of objects called elements or members of the set. Here, well-defined means accurately and unambiguously stated or described. Any

### The Encoding Complexity of Network Coding The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

### STABILITY AND PARADOX IN ALGORITHMIC LOGIC STABILITY AND PARADOX IN ALGORITHMIC LOGIC WAYNE AITKEN, JEFFREY A. BARRETT Abstract. Algorithmic logic is the logic of basic statements concerning algorithms and the algorithmic rules of deduction between

### COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS JOSHUA LENERS Abstract. An algorithm is function from ω to ω defined by a finite set of instructions to transform a given input x to the desired output

### Algebraic Properties of CSP Model Operators? Y.C. Law and J.H.M. Lee. The Chinese University of Hong Kong. Algebraic Properties of CSP Model Operators? Y.C. Law and J.H.M. Lee Department of Computer Science and Engineering The Chinese University of Hong Kong Shatin, N.T., Hong Kong SAR, China fyclaw,jleeg@cse.cuhk.edu.hk

### THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions. THREE LECTURES ON BASIC TOPOLOGY PHILIP FOTH 1. Basic notions. Let X be a set. To make a topological space out of X, one must specify a collection T of subsets of X, which are said to be open subsets of

### 9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS What is discrete? Sets (Rosen, Chapter 2) TOPICS Discrete math Set Definition Set Operations Tuples Consisting of distinct or unconnected elements, not continuous (calculus) Helps us in Computer Science

### Cantor s Diagonal Argument for Different Levels of Infinity JANUARY 2015 1 Cantor s Diagonal Argument for Different Levels of Infinity Michael J. Neely University of Southern California http://www-bcf.usc.edu/ mjneely Abstract These notes develop the classic Cantor

### BOOLEAN ALGEBRA AND CIRCUITS UNIT 3 Structure BOOLEAN ALGEBRA AND CIRCUITS Boolean Algebra and 3. Introduction 3. Objectives 3.2 Boolean Algebras 3.3 Logic 3.4 Boolean Functions 3.5 Summary 3.6 Solutions/ Answers 3. INTRODUCTION This

### AXIOMS FOR THE INTEGERS AXIOMS FOR THE INTEGERS BRIAN OSSERMAN We describe the set of axioms for the integers which we will use in the class. The axioms are almost the same as what is presented in Appendix A of the textbook,

### Lecture 6, Lecture 6, 4.16.2009 Today: Review: Basic Set Operation: Recall the basic set operator,!. From this operator come other set quantifiers and operations:!,!,!,! \ Set difference (sometimes denoted, a minus

### Introductory logic and sets for Computer scientists Introductory logic and sets for Computer scientists Nimal Nissanke University of Reading ADDISON WESLEY LONGMAN Harlow, England II Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario

### Chapter 18 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal. Chapter 8 out of 7 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal 8 Matrices Definitions and Basic Operations Matrix algebra is also known

### Progress Towards the Total Domination Game 3 4 -Conjecture Progress Towards the Total Domination Game 3 4 -Conjecture 1 Michael A. Henning and 2 Douglas F. Rall 1 Department of Pure and Applied Mathematics University of Johannesburg Auckland Park, 2006 South Africa

### Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

### Treewidth and graph minors Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under

### Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

### EDAA40 At home exercises 1 EDAA40 At home exercises 1 1. Given, with as always the natural numbers starting at 1, let us define the following sets (with iff ): Give the number of elements in these sets as follows: 1. 23 2. 6 3.

### Module 11. Directed Graphs. Contents Module 11 Directed Graphs Contents 11.1 Basic concepts......................... 256 Underlying graph of a digraph................ 257 Out-degrees and in-degrees.................. 258 Isomorphism..........................

### 2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006 2386 IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 52, NO. 6, JUNE 2006 The Encoding Complexity of Network Coding Michael Langberg, Member, IEEE, Alexander Sprintson, Member, IEEE, and Jehoshua Bruck,

### Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus

### A.1 Numbers, Sets and Arithmetic 522 APPENDIX A. MATHEMATICS FOUNDATIONS A.1 Numbers, Sets and Arithmetic Numbers started as a conceptual way to quantify count objects. Later, numbers were used to measure quantities that were extensive,

### SEQUENCES, 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

### Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee Sets Mukulika Ghosh Fall 2018 Based on slides by Dr. Hyunyoung Lee Sets Sets A set is an unordered collection of objects, called elements, without duplication. We write a A to denote that a is an element

### CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T CS 1200 Discrete Math A.R. Hurson 323 CS Building, Missouri S&T hurson@mst.edu 1 Course Objective: Mathematical way of thinking in order to solve problems 2 Variable: holder. A variable is simply a place

### Mathematically Rigorous Software Design Review of mathematical prerequisites Mathematically Rigorous Software Design 2002 September 27 Part 1: Boolean algebra 1. Define the Boolean functions and, or, not, implication ( ), equivalence ( ) and equals (=) by truth tables. 2. In an

### CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p. CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections 10.1-10.3 p. 1/106 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

### Complete Variable-Length "Fix-Free" Codes Designs, Codes and Cryptography, 5, 109-114 (1995) 9 1995 Kluwer Academic Publishers, Boston. Manufactured in The Netherlands. Complete Variable-Length "Fix-Free" Codes DAVID GILLMAN* gillman @ es.toronto.edu

### 2.1 Sets 2.2 Set Operations CSC2510 Theoretical Foundations of Computer Science 2.1 Sets 2.2 Set Operations Introduction to Set Theory A set is a structure, representing an unordered collection (group, plurality) of zero or more

### To illustrate what is intended the following are three write ups by students. Diagonalization General guidelines: You may work with other people, as long as you write up your solution in your own words and understand everything you turn in. Make sure to justify your answers they should be clear

### Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from Discrete Mathematics and It's Applications Kenneth H.

### Applied Algorithm Design Lecture 3 Applied Algorithm Design Lecture 3 Pietro Michiardi Eurecom Pietro Michiardi (Eurecom) Applied Algorithm Design Lecture 3 1 / 75 PART I : GREEDY ALGORITHMS Pietro Michiardi (Eurecom) Applied Algorithm

### Characterization of Boolean Topological Logics Characterization of Boolean Topological Logics Short Form: Boolean Topological Logics Anthony R. Fressola Denison University Granville, OH 43023 University of Illinois Urbana-Champaign, IL USA 61801-61802

### CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F 1 Logical Operations 1.1 And The and operator is a binary operator, denoted as, &,, or sometimes by just concatenating symbols, is true only if both parameters are true. A B A B F T F F F F The expression

### Introduction to Programming, Aug-Dec 2006 Introduction to Programming, Aug-Dec 2006 Lecture 3, Friday 11 Aug 2006 Lists... We can implicitly decompose a list into its head and tail by providing a pattern with two variables to denote the two components

### Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

### Binary Decision Diagrams Logic and roof Hilary 2016 James Worrell Binary Decision Diagrams A propositional formula is determined up to logical equivalence by its truth table. If the formula has n variables then its truth table

### Checks and Balances - Constraint Solving without Surprises in Object-Constraint Programming Languages: Full Formal Development Checks and Balances - Constraint Solving without Surprises in Object-Constraint Programming Languages: Full Formal Development Tim Felgentreff, Todd Millstein, Alan Borning and Robert Hirschfeld Viewpoints

### CSE 20 DISCRETE MATH. Fall CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam

### Lecture 5. Logic I. Statement Logic Ling 726: Mathematical Linguistics, Logic. Statement Logic V. Borschev and B. Partee, September 27, 2 p. Lecture 5. Logic I. Statement Logic. Statement Logic...... Goals..... Syntax of Statement Logic....2.

### 9.5 Equivalence Relations 9.5 Equivalence Relations You know from your early study of fractions that each fraction has many equivalent forms. For example, 2, 2 4, 3 6, 2, 3 6, 5 30,... are all different ways to represent the same 1 of 7 7/15/2009 3:40 PM Virtual Laboratories > 1. Foundations > 1 2 3 4 5 6 7 8 9 1. Sets Poincaré's quote, on the title page of this chapter could not be more wrong (what was he thinking?). Set theory

### Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................

### Solutions to Homework 10 CS/Math 240: Intro to Discrete Math 5/3/20 Instructor: Dieter van Melkebeek Solutions to Homework 0 Problem There were five different languages in Problem 4 of Homework 9. The Language D 0 Recall that

### Geodesic Convexity and Cartesian Products in Graphs Geodesic Convexity and Cartesian Products in Graphs Tao Jiang Ignacio Pelayo Dan Pritikin September 23, 2004 Abstract In this work we investigate the behavior of various geodesic convexity parameters with

### 2 Review of Set Theory 2 Review of Set Theory Example 2.1. Let Ω = {1, 2, 3, 4, 5, 6} 2.2. Venn diagram is very useful in set theory. It is often used to portray relationships between sets. Many identities can be read out simply

### Chapter Seven: Regular Expressions. Formal Language, chapter 7, slide 1 Chapter Seven: Regular Expressions Formal Language, chapter 7, slide The first time a young student sees the mathematical constant π, it looks like just one more school artifact: one more arbitrary symbol

### Lecture : Topological Space Example of Lecture : Dr. Department of Mathematics Lovely Professional University Punjab, India October 18, 2014 Outline Example of 1 2 3 Example of 4 5 6 Example of I Topological spaces and continuous

### LATIN SQUARES AND TRANSVERSAL DESIGNS LATIN SQUARES AND TRANSVERSAL DESIGNS *Shirin Babaei Department of Mathematics, University of Zanjan, Zanjan, Iran *Author for Correspondence ABSTRACT We employ a new construction to show that if and if

### Basic Properties The Definition of Catalan Numbers 1 Basic Properties 1.1. The Definition of Catalan Numbers There are many equivalent ways to define Catalan numbers. In fact, the main focus of this monograph is the myriad combinatorial interpretations

### Fundamental Properties of Graphs Chapter three In many real-life situations we need to know how robust a graph that represents a certain network is, how edges or vertices can be removed without completely destroying the overall connectivity,

### Symmetric Product Graphs Rochester Institute of Technology RIT Scholar Works Theses Thesis/Dissertation Collections 5-20-2015 Symmetric Product Graphs Evan Witz Follow this and additional works at: http://scholarworks.rit.edu/theses

### 1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

### Abstract. A graph G is perfect if for every induced subgraph H of G, the chromatic number of H is equal to the size of the largest clique of H. Abstract We discuss a class of graphs called perfect graphs. After defining them and getting intuition with a few simple examples (and one less simple example), we present a proof of the Weak Perfect Graph

### CSE 215: Foundations of Computer Science Recitation Exercises Set #9 Stony Brook University. Name: ID#: Section #: Score: / 4 CSE 215: Foundations of Computer Science Recitation Exercises Set #9 Stony Brook University Name: ID#: Section #: Score: / 4 Unit 14: Set Theory: Definitions and Properties 1. Let C = {n Z n = 6r 5 for

### Categorical models of type theory 1 / 59 Categorical models of type theory Michael Shulman February 28, 2012 2 / 59 Outline 1 Type theory and category theory 2 Categorical type constructors 3 Dependent types and display maps 4 Fibrations

### Integers 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

### On the Relationships between Zero Forcing Numbers and Certain Graph Coverings On the Relationships between Zero Forcing Numbers and Certain Graph Coverings Fatemeh Alinaghipour Taklimi, Shaun Fallat 1,, Karen Meagher 2 Department of Mathematics and Statistics, University of Regina,

### 1 Sets, Fields, and Events CHAPTER 1 Sets, Fields, and Events B 1.1 SET DEFINITIONS The concept of sets play an important role in probability. We will define a set in the following paragraph. Definition of Set A set is a collection

### IS 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

### Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Lecture - 11 Coding Strategies and Introduction to Huffman Coding The Fundamental

### Summary 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

### A GRAPH FROM THE VIEWPOINT OF ALGEBRAIC TOPOLOGY A GRAPH FROM THE VIEWPOINT OF ALGEBRAIC TOPOLOGY KARL L. STRATOS Abstract. The conventional method of describing a graph as a pair (V, E), where V and E repectively denote the sets of vertices and edges,

### Math 170- Graph Theory Notes 1 Math 170- Graph Theory Notes Michael Levet December 3, 2018 Notation: Let n be a positive integer. Denote [n] to be the set {1, 2,..., n}. So for example,  = {1, 2, 3}. To quote Bud Brown, Graph theory

### Infinite locally random graphs Infinite locally random graphs Pierre Charbit and Alex D. Scott Abstract Motivated by copying models of the web graph, Bonato and Janssen  introduced the following simple construction: given a graph

### How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the

### Consistency and Set Intersection Consistency and Set Intersection Yuanlin Zhang and Roland H.C. Yap National University of Singapore 3 Science Drive 2, Singapore {zhangyl,ryap}@comp.nus.edu.sg Abstract We propose a new framework to study

### To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions): CS 70 Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 7 This lecture returns to the topic of propositional logic. Whereas in Lecture Notes 1 we studied this topic as a way of understanding

### THEORY OF COMPUTATION THEORY OF COMPUTATION UNIT-1 INTRODUCTION Overview This chapter begins with an overview of those areas in the theory of computation that are basic foundation of learning TOC. This unit covers the introduction

### THE ISOMORPHISM PROBLEM FOR SOME CLASSES OF MULTIPLICATIVE SYSTEMS THE ISOMORPHISM PROBLEM FOR SOME CLASSES OF MULTIPLICATIVE SYSTEMS BY TREVOR EVANS 1. Introduction. We give here a solution of the isomorphism problem for finitely presented algebras in various classes

### Introduction II. Sets. Terminology III. Definition. Definition. Definition. Example Sets Slides by Christopher M. ourke Instructor: erthe Y. Choueiry Spring 2006 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 1.6 1.7 of Rosen cse235@cse.unl.edu Introduction

### Data Compression - Seminar 4 Data Compression - Seminar 4 October 29, 2013 Problem 1 (Uniquely decodable and instantaneous codes) Let L = p i l 100 i be the expected value of the 100th power of the word lengths associated with an

### Comparing sizes of sets Comparing sizes of sets Sets A and B are the same size if there is a bijection from A to B. (That was a definition!) For finite sets A, B, it is not difficult to verify that there is a bijection from A Sets MAT231 Transition to Higher Mathematics Fall 2014 MAT231 (Transition to Higher Math) Sets Fall 2014 1 / 31 Outline 1 Sets Introduction Cartesian Products Subsets Power Sets Union, Intersection, Difference 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be