# Maximum Segment Sum is Back

Save this PDF as:

Size: px
Start display at page:

## Transcription

2 of monotonicity. The key concepts of left-negative and right-screw segments proposed by Lin et al. [23] can both be seen as consequences of the attempts to meet the monotonicity conditions for the Thinning Theorem. After introducing some basic concepts in Section 2 and reviewing the derivation for MSS in Section 3, we deal with MSSU and MSDL respectively in Section 4 and Section Preliminaries In this section we give a minimal review the basic concepts we need. The reader is referred to Bird, Gibbons and Mu [6] for a short tutorial to relational program calculation for optimisation problems, and to Bird and de Moor [5] for a thorough introduction Sets, Functions, and Relations A relation R from set A to set B, written R :: A B, is a subset of the set {(a, b) a A b B}. When (a, b) R, we say R maps a to b and sometimes also write b R a. A function is a special case of relations such that (a, b) R and (a, b ) R implies b = b. In such case we can safely write b = R a. In this paper, free occurrences of identifiers f, g, and h refer to functions. A total function is a function such that every a A is mapped to some b. Given relations R :: B C and S :: A B, their composition R S is defined by: (a, c) R S b : (a, b) S (b, c) R. Composition is monotonic with respect to set inclusion. The identity function id a = a is the unit of composition. A partial function that is a subset of id is called a coreflexive, often used to filter inputs satisfying certain predicates. The power transpose operator Λ converts a relation to a setvalued total function: ΛR a = {b (a, b) R}. An equivalent definition is f = ΛR f = R, where is the relation mapping a set to one of its elements. Take f = ΛR, we get ΛR = R. The existential image functor E converts a relation R :: A B to a function mapping sets of A to sets of B: 2 ER x = {b a x : b R a}. An alternative definition is ER = Λ(R ). They satisfy the absorption law: ER ΛS = Λ(R S). (1) Take S = T, the absorption law implies ER ET = E(R T). We also have ER = E( ΛR) = E E(ΛR). The function E is usually called union because it joins a set of sets into a single set. Let fst (a, b) = a and snd (a, b) = b. The split operator and the product functor are defined respectively by: (b, c) R, S a b R a c S a, (R S) = R fst, S snd, They satisfy the absorption law: (R S) T, U = R T, S U. (2) Functional programmers may be more familiar with the special case when both arguments are functions: f, g a = (f a, g a), and (f g) (a, b) = (f a, g b). 1 The book presents program derivation from a category theoretical perspective. For the purpose of this paper, we restrict ourselves to sets and relations. Some properties may not necessarily be valid for all categories. 2 In this paper we may assume that the power functor P coincides with E. The relation distr maps (x, ys) to all (x, y) if y ys: distr = (id ). Therefore, we have Λdistr (x, ys) = {(x, y) y ys}. The following equality relates distr, the split, and Λ. Λ f, R = Λdistr f, ΛR (3) 2.2 Relational Fold on Lists Functional programmers are familiar with fold on lists, defined by: 3 foldr f e [ ] = e, foldr f e (a:x) = f (a, foldr f e x). In fact, a function satisfies the two equations above for foldr f e iff it equals foldr f e. One of the consequences of the uniqueness of fold is the fold-fusion rule: 4 h foldr f e = foldr g (h e) h f = g (id h). When the fusion premise does not hold for h, a common technique is to introduce another function k and try to show that the fusion premise holds for h, k. This technique is referred to as tupling and used a number of times in this paper. The sum and length of a list can both be computed by a fold: sum = foldr plus 0, where plus (a, b) = a + b, len = foldr ((1+) snd) 0. The familiar function map f, applying f to every element of the given list, is also a fold: map f = foldr (cons (f id)) [ ], where cons (a, x) = a:x. Let setify be the function collecting the elements in a list to a set, we have the following property: E f setify setify map f. (4) The function tails, returning all the suffixes of a list in decreasing lengths, can also be defined as a fold: tails = foldr f [[ ]], where f (a, x:xs) = (a:x):x:xs. The function scanr f e applies foldr f e to every suffix of a list: scanr f e = map (foldr f e) tails. (5) An important property we will make use of later is that scanr f e itself can be implemented as a fold: scanr f e = foldr step [e], where step (a, b:x) = f (a, b):b:x. The property can be verified using fold fusion. Relational folds is defined in terms of functional folds: foldr R e = foldr Λ(R distr) {e}. The fold fusion rule for relational folds generalise to inclusion: R foldr S e foldr T d R S T (id R) d R e. For example, the relation prefix, mapping the input list to one of its prefixes, can be defined as a fold: prefix = foldr (const [ ] cons) [ ], where const k x = k. Note that denotes the union of two relations (sets of pairs) const [ ] and cons, resulting in a relation mapping (a, x) to either [ ] or a: x. Dual to prefix, the relation suffix, defined as the reflexive, transitive closure of the partial function tail (a:x) = x, maps a list to one 3 Deviating from most functional languages, we use uncurried version of f. 4 Free variables are universally quantified.

3 of its suffixes. It cannot be defined as a fold. However, we do have the following property: setify tails = Λsuffix. (6) 2.3 Maximum A preorder is a relation of type A A for some A that is reflexive and transitive. We use the infix notation a b to denote (a, b). A preorder is called a connected preorder if for all a, b A, either a b or b a. The relation max picks a maximum element from the input set: a max xs a xs ( b xs : b a). The definition itself assumes nothing of. However, some theorems we will introduce later demands to be a preorder. Furthermore, if is not connected, max xs may be undefined for some xs. For the rest of the paper we assume that is a connected preorder if it is used in max. The following rule allows us to move max around by inventing new orderings: max Ef = f max f where a f b f a f b, (7) while the following rule allows us to distribute max into union: max union max Emax. (8) A naïve way to implement a set is to use a list. Let maxlist be the counterpart of max on lists. We only demand that maxlist satisfies the property: max setify maxlist. (9) One of the possible implementations for maxlist is foldr ( ) where a b yields the larger one between a and b. In this paper, we model segment problems in the form: max Λ(foldr R e). By the definition of relational fold, the expression is equivalent to max foldr Λ(R distr) {e}. The fold steps through the input list and maintains a set of all potential solutions, from which a best one is chosen by max. If certain properties hold, however, we may not need to keep all the potential solutions in each step. A relation R :: (A B) B is monotonic on a preorder if for all b and b in the range of R: c R (a, b) b b ( c : c R (a, b ) c c ). Consider two potential solutions b and b such that b b. That R is monotonic on means that for every c we can generate from R (a, b), there must be some c resulting from R (a, b ) that is no worse than c. Therefore, there is no point keeping the lessor solution c. Intuitively, if R is monotonic on, in each step of foldr R e we only need to keep the best solution with respect to. This is justified by the following theorem [4] provable by fold fusion: THEOREM 2.1 (Greedy Theorem (for Lists)). Let R be monotonic on preorder, then we have: max Λ(foldr R e) foldr (max ΛR) e. Sometimes, it is too strong a demand for to be a connected preorder. When the preorder is not connected, we instead appeal to a Thinning Theorem, to be introduced later. For now, let us look at an example using the Greedy Theorem. 3. Classical Maximum Segment Sum To familiarise the readers with relational program calculation, let us review how the classical MSS is solved in a relational setting. A segment of a list is a prefix of a suffix. The classical MSS problem is thus specified by: mss = max Λ(sum prefix suffix). The input has type [V] for some numerical type V, and is the less than or equal to order on V. From now on, when is the designated order, we omit the subscript. The standard derivation starts with some book-keeping manipulation distributing max into the set-construction: max Λ(sum prefix suffix) = { by (1) and ER = E EΛR } max union EΛ(sum prefix) Λsuffix = { by (8) } max E(max Λ(sum prefix)) Λsuffix. Let us concentrate on max Λ(sum prefix). The aim is to transform it into the form of max Λ(foldr R e) so that we can apply the Greedy Theorem. Since sum (const [ ] cons) = (const 0 plus) (id sum), by fold fusion we can fuse sum into prefix: sum prefix = foldr (const 0 plus) 0. Furthermore, one can see that const 0 plus is monotonic on ( ) the monotonicity condition expands to: b b (c = 0 c = a + b) ( c {0, a + b } : c c ). When const 0 is used to generate c, we can always choose c = 0; when plus is used, we can choose c = a+b. Both solutions are no worse than c. Thus the Greedy Theorem applies: we can promote max into the fold: max Λ(sum prefix) foldr (max Λ(const 0 plus)) 0. Let plz = max Λ(const 0 plus). After some calculation we have that plz (a, b) = 0 (a + b). We continue with the derivation: mss { derivation so far } max E(foldr plz 0) Λsuffix { by (6), (4), and (9) } maxlist map (foldr plz 0) tails = { by (5) } maxlist scanr plz 0. The penultimate step above implements sets by lists, while the introduction of scanr in the last step turns a quadratic-time algorithm to linear-time. Given an input of length n, the algorithm still uses O(n) space, which can be improved by: maxlist scanr plz 0 = { tupling } snd head, maxlist scanr plz 0 = { fold fusion, step defined below } snd foldr step (0, 0). We have therefore derived a linear-time, constant space algorithm for MSS: mss snd foldr step (0, 0), where step :: (V, (V, V)) (V, V) step (a, (b, m)) = (c, m c) where c = 0 (a + b). It is easy to check that the right-hand side defines a total function, since all its components are total functions.

8 Let us store the the SL-pairs of appendants in a deque in increasing lengths. Apart from (0, 0), they come in decreasing density. This is due to the constraint maintained by rm: given two surviving appendants x and x.y where the latter is longer, we must have x > d y, thus x > d x.y. Lin et al. [23] defined a right-screw segment to be a segment x such that take i x d drop i x for 0 i len x. The appendants we collect are exactly the decreasing right-screw segments. Since the appendants come in decreasing density, rm may start from the front of ys, and compare consecutive elements only: rm [y] = [y], rm (y:z:ys) = y:z:ys, if safe y z, = rm (z:ys), otherwise, where safe (s 1, l 1) (s 2, l 2) = s 1/l 1 > s 2/l 2. The empty case is not needed because the deque is never empty. Like in the previous section, we can also introduce diffs to save the cost of applying add b to every element in the deque. We will do so as the last step. Once it is done, all operations, apart from maxap, run in amortised linear time if cons and last (extracting from the tail) can be performed in O(1) time. How do we implement maxap efficiently? The following lemma is adapted from Lin et al. [23]: LEMMA 5.4. Let y 1... y n be a fully pruned set of SL-pairs, representing the appendants derived from the same prefix and sorted by increasing lengths. Let k be the greatest index that maximises div (x.y k ). Then for all i [0, n 1], i k if and only if div (x.y i) > div (x.y i+1). Therefore, maxap should find the smallest k such that div (x.y k ) > div (x.y k+1 ). Lin et al. used a binary search to find such k. They also proved that the segment having the maximum density cannot be longer than 2L 1: otherwise we can always cut it in half and pick the better half. Their algorithm is therefore O(n log L) (although their experiments showed that it was actually quicker to perform a naïve linear search on ys). In fact, it is possible to do better. Let us temporarily assume a naïve, linear-searching implementation of maxap, but start the search from the right-end of the deque. The following function cut drops elements from the right-end until it sees a y k 1 such that div (x.y k 1 ) > div (x.y k ) stops to hold: cut :: [V] Deque SL DequeSL, cut x [y 1] = [y 1], cut x (ys + [y k 1, y k ]) = ys + [y k 1, y k ], if dav (x, y k 1 ) dav (x, y k ), = cut x (ys + [y k 1 ]), otherwise. With cut, we can define maxap (x, ys) = dav (x, last (cut x ys)). The key observation leading us to a linear-time algorithm was made by Goldwasser et al. [18]. Assume that w yields the best density, m 1, among the prefixes of the list w + y + z. If the best density of a : w +y +z comes from a +w +y, it cannot be larger than m 1. The observation is made precise in this lemma: LEMMA 5.5. Let ys be a fully pruned set of appendants. Assume that m 1 = maxap (x, ys) results from an appendent with length l 1, and m 2 = maxap (rmshift (a, (x, ys))), results from an appendant with length l 2. If l 2 > l 1, then m 2 < m 1. Lemma 5.5 implies that, after extending ys with rmshift, we only need to consider those appendants that are not longer than the appendant chosen by maxap. In other words, we have: maxap (rmshift (a, (x, ys))) maxap (x, ys) = (14) maxap (rmshift (cut (a, (x, ys))))) maxap (x, ys). msdl snd foldr step (([ ], ((0, 0), [ ])), ) step :: (V, ((Queue V, (SL, Deque SL)), V)) ((Queue V, (SL, Deque SL)), V) step (a, ((x, ((c, n), ys)), m)) = ((a:x, ((c, n), ys)), avg (a:x)) if len x < L step (a, ((x + [b], ((c, n), ys)), m)) = ((a:x, (cn, ys )), m m) otherwise where cn = (b + c, 1 + n) sl = sumlen (a:x) ys = cut sl cn (rm ((c, n):ys)) m = if null ys then div sl else davd (sl.cn ) (last ys ) rm :: SL Deque SL Deque SL rm cn [y] = [y] rm cn (y:z:ys) = y:z:ys if avgd cn y > avgd cn z = rm cn (z:ys) otherwise davd (c, n) (s, l) = div (c s, n l) cut :: SL SL Deque SL Deque SL cut x cn [y] = if div x > davd (x.cn) y then [ ] else [y] cut x cn (ys + [z, y]) = if davd (x.cn) z davd (x.cn) y then ys + [z, y] else cut x cn (ys + [z]) Figure 3. Derived Program for MSDL. Continuing with the derivation, we transform fold to scan, and eliminate the list introduced by scanr using fold fusion, like in the previous sections: max E(maxap foldr rmshift ([ ], {(0, 0)})) Λsuffix { refining sets to deques, let e = ([ ], [(0, 0)]) } maxlist map (maxap foldr rmshift e) tails = { by (5) } maxlist map maxap scanr rmshift e = { tupling } snd cut head, maxlist map maxap scanr rmshift e = { fold fusion } snd foldr step (e, ). With the help of (14), the function step can be constructed as: step :: (V, (([V], Deque SL), V)) (([V], Deque SL), V), step (a, ((x, ys), m)) = ((a:x, ys), avg (a:x)), if len x < L, step (a, ((x + [b], ys), m)) = ((a:x, ys ), m m), otherwise, where ys = cut (a:x) ((0, 0):rm (map add b ys)) m = dav (a:x, last ys ). As the last step, we apply the transformation introducing diffs to lift map add b out. The final program for MSDL is given in Figure 3. 5 It is a short but complex program which, were it not derived, would be rather difficult to comprehend. It runs in linear time for the same reason as the previous section: consider the size of ys in step. Every recursive call to rm or cut decreases the size by Conclusion and Related Work Extending the classical derivation for MSS, we have derived two linear-time algorithms tackling MSSU and MSDL. The idea of thinning determines the structure of the algorithm. The concept of 5 Expository programs for the algorithms in this paper are available on the author s homepage.

9 the left-negative segments [23], introduced to solve MSSU, naturally emerges from our intuition choosing an ordering such that the monotonicity condition for the Thinning Theorem can be satisfied. For MSDL, we need an extended notion of monotonicity relating an element to a set. Right-screw segments are formed when we attempt to determine when a solution can be safely dropped. The story does not end there. Like most derivations with the Thinning Theorem, the key to efficiency is to analyse the set of solutions and design a fast data structure. We would like to know whether previous work on data structures for segment problems and dynamic programming [15, 24] could help to formalise our reasoning. We have dealt with merely the basic form of MSSU and MSDL. It should be possible to unify their variations [10] under a general framework and construct efficient solutions. While this paper follows the framework of Bird and de Moor [5], Maehara [25] recently reviewed the algorithm for MSSU by Lin and Fan from the viewpoint of a calculational formalisation of the windowing technique. That group is working on an alternative formalisation of optimisation algorithms more suitable for automatic derivation. Acknowledgements The author would like to thank Max Schäfer and Akiko Nakata for checking through the first draft of this paper, Sharon Curtis and Roland Backhouse for insightful discussions, and Zhenjiang Hu and Akimasa Morihata for pointing me to Takanori Maehara s thesis, as well as painstakingly reading through my early draft and promptly giving me plenty of valuable and thorough comments. References [1] R. C. Backhouse, P. de Bruin, G. Malcolm, E. Voermans, and J. van der Woude. Relational catamorphisms. In B. Möller, editor, Proceedings of the IFIP TC2/WG2.1 Working Conference on Constructing Programs, pages Elsevier Science Publishers, [2] J. Bentley. Programming Pearls. Addison-Wesley, [3] R. S. Bird. An introduction to the theory of lists. In M. Broy, editor, Logic of Programming and Calculi of Discrete Design, number 36 in NATO ASI Series F, pages Springer-Verlag, [4] R. S. Bird. A calculus of functions for program derivation. In D. A. Turner, editor, Research Topics in Functional Programming, University of Texas at Austin Year of Programming Series, pages Addison-Wesley, [5] R. S. Bird and O. de Moor. Algebra of Programming. International Series in Computer Science. Prentice Hall, [6] R. S. Bird, J. Gibbons, and S.-C. Mu. Algebraic methods for optimization problems. In R. C. Backhouse, R. Crole, and J. Gibbons, editors, Algebraic and Coalgebraic Methods in the Mathematics of Program Construction, Lecture Notes in Computer Science 2297, pages Springer-Verlag, January [7] Y. H. Chen, H.-I. Lu, and C. Y. Tang. Disjoint segments with maximum density. In Proceedings of the 2005 International Workshop on Bioinformatics Research and Applications (IWBRA 05), Lecture Notes in Computer Science 3515, pages , May [8] T.-R. Chuang and B. Goldberg. Real-time deques, multihead Turing machines, and purely functional programming. In Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark, June ACM Press. [9] K.-M. Chung and H.-I. Lu. An optimal algorithm for the maximumdensity segment problem. In Proceedings of the 11th Annual European Symposium on Algorithms (ESA 2003), Lecture Notes in Computer Science 2832, pages , September [10] K.-M. Chung and H.-I. Lu. An optimal algorithm for the maximumdensity segment problem. SIAM Journal on Computing, 34(2): , [11] S. Curtis. Dynamic Programming: a different perspective. In Proceedings of the IFIP TC2 Working Conference on Algorithmic Languages and Calculi, Le Bischenberg, France, February [12] S. Curtis. The classification of greedy algorithms. Science of Computer Programming, 49(1-3): , [13] E. W. Dijkstra and W. H. J. Feijen. Een methode van programmeren. Academic Service, s Gravenhage, the Netherlands, [14] T.-H. Fan, S. Lee, H.-I. Lu, T.-S. Tsou, T.-C. Wang, and A. Yao. An optimal algorithm for maximum-sum segment and its application in bioinformatics. In Proceedings of the 8th International Conference on Implementation and Application of Automata, Lecture Notes in Computer Science 2759, pages Springer-Verlag, July [15] Y. Futamura, C. Shirai, Y. Liu, N. Futamura, and K. Kakehi. Data structures for solving programming problems concerning segments in a sequence. In Workshop on Algorithm Engineering (WAE 97), pages 11 13, [16] J. Gibbons. An introduction to the Bird-Meertens formalism. New Zealand Formal Program Development Colloquium Seminar, Hamilton, November [17] J. Gibbons. Calculating functional programs. In Proceedings of ISRG/SERG Research Colloquium. Oxford Brookes University, November [18] M. H. Goldwasser, M.-Y. Kao, and H.-I. Lu. Fast algorithms for finding maximum-density segments of a sequence with applications to bioinformatics. In Proceedings of the 2nd Workshop on Algorithms in Bioinformatics (WABI 2002), pages , September [19] D. Gries. The maximum-segment-sum problem. In E. W. Dijkstra, editor, Formal Development Programs and Proofs, University of Texas at Austin Year of Programming Series, pages Addison- Wesley, [20] J. T. Jeuring. The derivation of on-line algorithms, with an application to finding palindromes. Algorithmica, 11: , [21] A. Kaldewaij. Programming: the Derivation of Algorithms. Prentice Hall, [22] H. C. Lau, T. H. Ngo, and B. N. Nguyen. Finding a length-constrained maximum-sum or maximum-density subtree and its application to logistics. Discrete Optimization, 3(4), [23] Y.-L. Lin, T. Jiang, and K.-M. Chao. Efficient algorithms for locating the length-constrained heaviest segments, with applications to biomolecular sequence analysis. In Proceedings of the 27th International Symposium on Mathematical Foundations of Computer Science, Lecture Notes in Computer Science 2420, pages Springer-Verlag, [24] Y. A. Liu and S. D. Stoller. Program optimization using indexed and recursive data structures. In Proceedings of ACM SIGPLAN 2002 Symposium on Partial Evaluation and Program Manipulation (PEPM), pages ACM Press, January [25] T. Maehara. プログラム運算によるWindowing 技法の定式化とその応用 (Formalization and Application of the Windowing Technique based on Program Calculation). Bachelor s Thesis (in Japanese), University of Tokyo, February [26] M. Rem. Small programming exercises 20. Science of Computer Programming, 10(1):99 105, [27] I. Sasano, Z. Hu, and M. Takeichi. Generation of efficient programs for solving maximum multi-marking problems. In ACM SIGPLAN Workshop on Semantics, Applications and Implementation of Program Generation ( SAIG 01), Lecture Notes in Computer Science 2196, pages Springer-Verlag, September [28] I. Sasano, Z. Hu, M. Takeichi, and M. Ogawa. Make it Practical: A Generic Linear-Time Algorithm for Solving Maximum-Weightsum Problems. In Proceedings of the 2000 ACM SIGPLAN International Conference on Functional Programming, pages ACM Press, September [29] J. P. H. W. van den Eijnde. Left-bottom and right-top segments. Science of Computer Programming, 15(1):79 94, [30] H. Zantema. Longest segment problems. Science of Computer Programming, 18(1):39 66, 1992.

### Axioms of Kleene Algebra

Introduction to Kleene Algebra Lecture 2 CS786 Spring 2004 January 28, 2004 Axioms of Kleene Algebra In this lecture we give the formal definition of a Kleene algebra and derive some basic consequences.

### Introduction to Metalogic

Philosophy 135 Spring 2008 Tony Martin Introduction to Metalogic 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: Remarks: (i) sentence letters p 0, p 1, p 2,... (ii)

### Step-Indexed Biorthogonality: a Tutorial Example

Step-Indexed Biorthogonality: a Tutorial Example Andrew Pitts University of Cambridge Computer Laboratory 1 Introduction The purpose of this note is to illustrate the use of step-indexing [2] combined

### CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers. 1 Complete partial orders (CPOs) 2 Least fixed points of functions

CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers We saw that the semantics of the while command are a fixed point. We also saw that intuitively, the semantics are the limit

### Clausal Presentation of Theories in Deduction Modulo

Gao JH. Clausal presentation of theories in deduction modulo. JOURNAL OF COMPUTER SCIENCE AND TECHNOL- OGY 28(6): 1085 1096 Nov. 2013. DOI 10.1007/s11390-013-1399-0 Clausal Presentation of Theories in

### Boolean Algebras. Chapter 2

Chapter 2 Boolean Algebras Let X be an arbitrary set and let P(X) be the class of all subsets of X (the power set of X). Three natural set-theoretic operations on P(X) are the binary operations of union

### A Behavioral Congruence for Concurrent Constraint Programming with Nondeterministic Choice

A Behavioral Congruence for Concurrent Constraint Programming with Nondeterministic Choice Luis Pino*, Filippo Bonchi** and Frank Valencia* (Presented by: Jorge A. Pe rez) *E quipe Come te, LIX, Laboratoire

### Step-indexed models of call-by-name: a tutorial example

Step-indexed models of call-by-name: a tutorial example Aleš Bizjak 1 and Lars Birkedal 1 1 Aarhus University {abizjak,birkedal}@cs.au.dk June 19, 2014 Abstract In this tutorial paper we show how to construct

### A Thread Algebra with Multi-level Strategic Interleaving

Theory of Computing Systems manuscript No. (will be inserted by the editor) A Thread Algebra with Multi-level Strategic Interleaving J.A. Bergstra 1,2, C.A. Middelburg 3,1 1 Programming Research Group,

### F U N C T I O N A L P E A R L S Inverting the Burrows-Wheeler Transform

Under consideration for publication in J. Functional Programming 1 F U N C T I O N A L P E A R L S Inverting the Burrows-Wheeler Transform RICHARD BIRD and SHIN-CHENG MU Programming Research Group, Oxford

### Introduction to Metalogic 1

Philosophy 135 Spring 2012 Tony Martin Introduction to Metalogic 1 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: (i) sentence letters p 0, p 1, p 2,... (ii) connectives,

### What You Must Remember When Processing Data Words

What You Must Remember When Processing Data Words Michael Benedikt, Clemens Ley, and Gabriele Puppis Oxford University Computing Laboratory, Park Rd, Oxford OX13QD UK Abstract. We provide a Myhill-Nerode-like

### The matrix approach for abstract argumentation frameworks

The matrix approach for abstract argumentation frameworks Claudette CAYROL, Yuming XU IRIT Report RR- -2015-01- -FR February 2015 Abstract The matrices and the operation of dual interchange are introduced

### Applied Logic for Computer Scientists. Answers to Some Exercises

Applied Logic for Computer Scientists Computational Deduction and Formal Proofs Springer, 2017 doi: http://link.springer.com/book/10.1007%2f978-3-319-51653-0 Answers to Some Exercises Mauricio Ayala-Rincón

### Total Ordering on Subgroups and Cosets

Total Ordering on Subgroups and Cosets Alexander Hulpke Department of Mathematics Colorado State University 1874 Campus Delivery Fort Collins, CO 80523-1874 hulpke@math.colostate.edu Steve Linton Centre

### ClC (X ) : X ω X } C. (11)

With each closed-set system we associate a closure operation. Definition 1.20. Let A, C be a closed-set system. Define Cl C : : P(A) P(A) as follows. For every X A, Cl C (X) = { C C : X C }. Cl C (X) is

### Topos Theory. Lectures 17-20: The interpretation of logic in categories. Olivia Caramello. Topos Theory. Olivia Caramello.

logic s Lectures 17-20: logic in 2 / 40 logic s Interpreting first-order logic in In Logic, first-order s are a wide class of formal s used for talking about structures of any kind (where the restriction

### First-Order Theorem Proving and Vampire

First-Order Theorem Proving and Vampire Laura Kovács 1,2 and Martin Suda 2 1 TU Wien 2 Chalmers Outline Introduction First-Order Logic and TPTP Inference Systems Saturation Algorithms Redundancy Elimination

### KRIPKE S THEORY OF TRUTH 1. INTRODUCTION

KRIPKE S THEORY OF TRUTH RICHARD G HECK, JR 1. INTRODUCTION The purpose of this note is to give a simple, easily accessible proof of the existence of the minimal fixed point, and of various maximal fixed

### An Algebraic View of the Relation between Largest Common Subtrees and Smallest Common Supertrees

An Algebraic View of the Relation between Largest Common Subtrees and Smallest Common Supertrees Francesc Rosselló 1, Gabriel Valiente 2 1 Department of Mathematics and Computer Science, Research Institute

### Nets and filters (are better than sequences)

Nets and filters (are better than sequences) Contents 1 Motivation 2 2 More implications we wish would reverse 2 3 Nets 4 4 Subnets 6 5 Filters 9 6 The connection between nets and filters 12 7 The payoff

### Strongly chordal and chordal bipartite graphs are sandwich monotone

Strongly chordal and chordal bipartite graphs are sandwich monotone Pinar Heggernes Federico Mancini Charis Papadopoulos R. Sritharan Abstract A graph class is sandwich monotone if, for every pair of its

### A generalization of modal definability

A generalization of modal definability Tin Perkov Polytechnic of Zagreb Abstract. Known results on global definability in basic modal logic are generalized in the following sense. A class of Kripke models

### Proofs Regarding Specification of Spark Aggregation

Proofs Regarding Specification of Spark Aggregation Yu-Fang Chen 1, Chih-Duo Hong 1, Ondřej Lengál 1,2, Shin-Cheng Mu 1, Nishant Sinha 3, and Bow-Yaw Wang 1 1 Academia Sinica, Taiwan 2 Brno University

### Enhancing Active Automata Learning by a User Log Based Metric

Master Thesis Computing Science Radboud University Enhancing Active Automata Learning by a User Log Based Metric Author Petra van den Bos First Supervisor prof. dr. Frits W. Vaandrager Second Supervisor

### Inverting the Burrows-Wheeler Transform

FUNCTIONAL PEARL Inverting the Burrows-Wheeler Transform Richard Bird and Shin-Cheng Mu 1 Programming Research Group, Oxford University Wolfson Building, Parks Road, Oxford, OX1 3QD, UK Abstract The objective

### Linking Duration Calculus and TLA

Linking Duration Calculus and TLA Yifeng Chen and Zhiming Liu Department of Computer Science, University of Leicester, Leicester LE1 7RH, UK Email: {Y.Chen, Z.Liu}@mcs.le.ac.uk Abstract. Different temporal

### SORTING SUFFIXES OF TWO-PATTERN STRINGS.

International Journal of Foundations of Computer Science c World Scientific Publishing Company SORTING SUFFIXES OF TWO-PATTERN STRINGS. FRANTISEK FRANEK and WILLIAM F. SMYTH Algorithms Research Group,

### Theory of Computation

Theory of Computation (Feodor F. Dragan) Department of Computer Science Kent State University Spring, 2018 Theory of Computation, Feodor F. Dragan, Kent State University 1 Before we go into details, what

### Notes for Comp 497 (454) Week 10

Notes for Comp 497 (454) Week 10 Today we look at the last two chapters in Part II. Cohen presents some results concerning the two categories of language we have seen so far: Regular languages (RL). Context-free

### 6 Coalgebraic modalities via predicate liftings

6 Coalgebraic modalities via predicate liftings In this chapter we take an approach to coalgebraic modal logic where the modalities are in 1-1 correspondence with so-called predicate liftings for the functor

### Lattices and Orders in Isabelle/HOL

Lattices and Orders in Isabelle/HOL Markus Wenzel TU München October 8, 2017 Abstract We consider abstract structures of orders and lattices. Many fundamental concepts of lattice theory are developed,

### Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 4 Ana Bove March 23rd 2018 Recap: Formal Proofs How formal should a proof be? Depends on its purpose...... but should be convincing......

### Learning via Finitely Many Queries

Learning via Finitely Many Queries Andrew C. Lee University of Louisiana at Lafayette 1 Abstract This work introduces a new query inference model that can access data and communicate with a teacher by

### Notes for Comp 497 (Comp 454) Week 10 4/5/05

Notes for Comp 497 (Comp 454) Week 10 4/5/05 Today look at the last two chapters in Part II. Cohen presents some results concerning context-free languages (CFL) and regular languages (RL) also some decidability

### Automata on linear orderings

Automata on linear orderings Véronique Bruyère Institut d Informatique Université de Mons-Hainaut Olivier Carton LIAFA Université Paris 7 September 25, 2006 Abstract We consider words indexed by linear

### Equational Theory of Kleene Algebra

Introduction to Kleene Algebra Lecture 7 CS786 Spring 2004 February 16, 2004 Equational Theory of Kleene Algebra We now turn to the equational theory of Kleene algebra. This and the next lecture will be

### Propositional Logic Review

Propositional Logic Review UC Berkeley, Philosophy 142, Spring 2016 John MacFarlane The task of describing a logical system comes in three parts: Grammar Describing what counts as a formula Semantics Defining

### CHAPTER THREE: RELATIONS AND FUNCTIONS

CHAPTER THREE: RELATIONS AND FUNCTIONS 1 Relations Intuitively, a relation is the sort of thing that either does or does not hold between certain things, e.g. the love relation holds between Kim and Sandy

### Explicit Logics of Knowledge and Conservativity

Explicit Logics of Knowledge and Conservativity Melvin Fitting Lehman College, CUNY, 250 Bedford Park Boulevard West, Bronx, NY 10468-1589 CUNY Graduate Center, 365 Fifth Avenue, New York, NY 10016 Dedicated

### DESIGN THEORY FOR RELATIONAL DATABASES. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

DESIGN THEORY FOR RELATIONAL DATABASES csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 1 Introduction There are always many different schemas for a given

### Stochastic Processes

qmc082.tex. Version of 30 September 2010. Lecture Notes on Quantum Mechanics No. 8 R. B. Griffiths References: Stochastic Processes CQT = R. B. Griffiths, Consistent Quantum Theory (Cambridge, 2002) DeGroot

### MA554 Assessment 1 Cosets and Lagrange s theorem

MA554 Assessment 1 Cosets and Lagrange s theorem These are notes on cosets and Lagrange s theorem; they go over some material from the lectures again, and they have some new material it is all examinable,

### FREE PRODUCTS AND BRITTON S LEMMA

FREE PRODUCTS AND BRITTON S LEMMA Dan Lidral-Porter 1. Free Products I determined that the best jumping off point was to start with free products. Free products are an extension of the notion of free groups.

### Some Examples of Lexicographic Order Algorithms and some Open Combinatorial Problems

Some Examples of Lexicographic Order Algorithms and some Open Combinatorial Problems Dimitar Vandev A general reasoning based on the lexicographic order is studied. It helps to create algorithms for generation

### What are Iteration Theories?

What are Iteration Theories? Jiří Adámek and Stefan Milius Institute of Theoretical Computer Science Technical University of Braunschweig Germany adamek,milius @iti.cs.tu-bs.de Jiří Velebil Department

### Homework 8. a b b a b a b. two-way, read/write

Homework 8 309 Homework 8 1. Describe a TM that accepts the set {a n n is a power of 2}. Your description should be at the level of the descriptions in Lecture 29 of the TM that accepts {ww w Σ } and the

### The Turing machine model of computation

The Turing machine model of computation For most of the remainder of the course we will study the Turing machine model of computation, named after Alan Turing (1912 1954) who proposed the model in 1936.

### Kolmogorov Complexity in Randomness Extraction

LIPIcs Leibniz International Proceedings in Informatics Kolmogorov Complexity in Randomness Extraction John M. Hitchcock, A. Pavan 2, N. V. Vinodchandran 3 Department of Computer Science, University of

### Between Functions and Relations in Calculating Programs

Between Functions and Relations in Calculating Programs Graham Muir Hutton A thesis submitted for the degree of Ph.D. at the Department of Computing Science, University of Glasgow 16th October 1992 Abstract

### IN THIS paper we investigate the diagnosability of stochastic

476 IEEE TRANSACTIONS ON AUTOMATIC CONTROL, VOL 50, NO 4, APRIL 2005 Diagnosability of Stochastic Discrete-Event Systems David Thorsley and Demosthenis Teneketzis, Fellow, IEEE Abstract We investigate

### Decision procedure for Default Logic

Decision procedure for Default Logic W. Marek 1 and A. Nerode 2 Abstract Using a proof-theoretic approach to non-monotone reasoning we introduce an algorithm to compute all extensions of any (propositional)

### cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 1 Course Web Page www3.cs.stonybrook.edu/ cse303 The webpage contains: lectures notes slides; very detailed solutions to

### Lecture 2: Syntax. January 24, 2018

Lecture 2: Syntax January 24, 2018 We now review the basic definitions of first-order logic in more detail. Recall that a language consists of a collection of symbols {P i }, each of which has some specified

### Propositional Logic Arguments (5A) Young W. Lim 11/8/16

Propositional Logic (5A) Young W. Lim Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version

### Basic Problems in Multi-View Modeling

Basic Problems in Multi-View Modeling Jan Reineke Stavros Tripakis Electrical Engineering and Computer Sciences University of California at Berkeley Technical Report No. UCB/EECS-2014-4 http://www.eecs.berkeley.edu/pubs/techrpts/2014/eecs-2014-4.html

### A framework based on implementation relations for implementing LOTOS specifications

Published in: Computer Networks and ISDN Systems, 25 (1992), 23-41 A framework based on implementation relations for implementing LOTOS specifications Guy Leduc Research Associate of the National Fund

### SLD-Resolution And Logic Programming (PROLOG)

Chapter 9 SLD-Resolution And Logic Programming (PROLOG) 9.1 Introduction We have seen in Chapter 8 that the resolution method is a complete procedure for showing unsatisfiability. However, finding refutations

### Pairing Transitive Closure and Reduction to Efficiently Reason about Partially Ordered Events

Pairing Transitive Closure and Reduction to Efficiently Reason about Partially Ordered Events Massimo Franceschet Angelo Montanari Dipartimento di Matematica e Informatica, Università di Udine Via delle

### CONWAY S COSMOLOGICAL THEOREM

CONWAY S COSMOLOGICAL THEOREM R.A. LITHERLAND. Introduction In [C], Conway introduced an operator on strings (finite sequences) of positive integers, the audioactive (or look and say ) operator. Usually,

### Some Basic Notations Of Set Theory

Some Basic Notations Of Set Theory References There are some good books about set theory; we write them down. We wish the reader can get more. 1. Set Theory and Related Topics by Seymour Lipschutz. 2.

### Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will

### Theoretical pearl - Church numerals, twice!

See discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/231890309 Theoretical pearl - Church numerals, twice! Article in Journal of Functional Programming

### Relational Algebra as non-distributive Lattice

Relational Algebra as non-distributive Lattice VADIM TROPASHKO Vadim.Tropashko@orcl.com We reduce the set of classic relational algebra operators to two binary operations: natural join and generalized

### 1. The Method of Coalgebra

1. The Method of Coalgebra Jan Rutten CWI Amsterdam & Radboud University Nijmegen IMS, Singapore - 15 September 2016 Overview of Lecture one 1. Category theory (where coalgebra comes from) 2. Algebras

### Chapter 1. Logic and Proof

Chapter 1. Logic and Proof 1.1 Remark: A little over 100 years ago, it was found that some mathematical proofs contained paradoxes, and these paradoxes could be used to prove statements that were known

### Stephen F Austin. Exponents and Logarithms. chapter 3

chapter 3 Starry Night was painted by Vincent Van Gogh in 1889. The brightness of a star as seen from Earth is measured using a logarithmic scale. Exponents and Logarithms This chapter focuses on understanding

### Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Lecture 4 Ana Bove March 24th 2017 Structural induction; Concepts of automata theory. Overview of today s lecture: Recap: Formal Proofs

### De Bruijn Sequences for the Binary Strings with Maximum Density

De Bruijn Sequences for the Binary Strings with Maximum Density Joe Sawada 1, Brett Stevens 2, and Aaron Williams 2 1 jsawada@uoguelph.ca School of Computer Science, University of Guelph, CANADA 2 brett@math.carleton.ca

### Algorithms for pattern involvement in permutations

Algorithms for pattern involvement in permutations M. H. Albert Department of Computer Science R. E. L. Aldred Department of Mathematics and Statistics M. D. Atkinson Department of Computer Science D.

### Introduction to Turing Machines. Reading: Chapters 8 & 9

Introduction to Turing Machines Reading: Chapters 8 & 9 1 Turing Machines (TM) Generalize the class of CFLs: Recursively Enumerable Languages Recursive Languages Context-Free Languages Regular Languages

### College Algebra Through Problem Solving (2018 Edition)

City University of New York (CUNY) CUNY Academic Works Open Educational Resources Queensborough Community College Winter 1-25-2018 College Algebra Through Problem Solving (2018 Edition) Danielle Cifone

### CONSTRUCTION OF THE REAL NUMBERS.

CONSTRUCTION OF THE REAL NUMBERS. IAN KIMING 1. Motivation. It will not come as a big surprise to anyone when I say that we need the real numbers in mathematics. More to the point, we need to be able to

### How to Pop a Deep PDA Matters

How to Pop a Deep PDA Matters Peter Leupold Department of Mathematics, Faculty of Science Kyoto Sangyo University Kyoto 603-8555, Japan email:leupold@cc.kyoto-su.ac.jp Abstract Deep PDA are push-down automata

### Kybernetika. Daniel Reidenbach; Markus L. Schmid Automata with modulo counters and nondeterministic counter bounds

Kybernetika Daniel Reidenbach; Markus L. Schmid Automata with modulo counters and nondeterministic counter bounds Kybernetika, Vol. 50 (2014), No. 1, 66 94 Persistent URL: http://dml.cz/dmlcz/143764 Terms

### Consistent Fixed Points and Negative Gain

2009 International Conference on Parallel and Distributed Computing, Applications and Technologies Consistent Fixed Points and Negative Gain H. B. Acharya The University of Texas at Austin acharya @ cs.utexas.edu

### Extensions to the Logic of All x are y: Verbs, Relative Clauses, and Only

1/53 Extensions to the Logic of All x are y: Verbs, Relative Clauses, and Only Larry Moss Indiana University Nordic Logic School August 7-11, 2017 2/53 An example that we ll see a few times Consider the

### Knuth-Morris-Pratt Algorithm

Knuth-Morris-Pratt Algorithm Jayadev Misra June 5, 2017 The Knuth-Morris-Pratt string matching algorithm (KMP) locates all occurrences of a pattern string in a text string in linear time (in the combined

### Zaslavsky s Theorem. As presented by Eric Samansky May 11, 2002

Zaslavsky s Theorem As presented by Eric Samansky May, 2002 Abstract This paper is a retelling of the proof of Zaslavsky s Theorem. For any arrangement of hyperplanes, there is a corresponding semi-lattice

### A Non-Topological View of Dcpos as Convergence Spaces

A Non-Topological View of Dcpos as Convergence Spaces Reinhold Heckmann AbsInt Angewandte Informatik GmbH, Stuhlsatzenhausweg 69, D-66123 Saarbrücken, Germany e-mail: heckmann@absint.com Abstract The category

### α-recursion Theory and Ordinal Computability

α-recursion Theory and Ordinal Computability by Peter Koepke University of Bonn 1 3. 2. 2007 Abstract Motivated by a talk of S. D. Friedman at BIWOC we show that the α-recursive and α-recursively enumerable

### Space-aware data flow analysis

Space-aware data flow analysis C. Bernardeschi, G. Lettieri, L. Martini, P. Masci Dip. di Ingegneria dell Informazione, Università di Pisa, Via Diotisalvi 2, 56126 Pisa, Italy {cinzia,g.lettieri,luca.martini,paolo.masci}@iet.unipi.it

This article was published in an Elsevier journal. The attached copy is furnished to the author for non-commercial research and education use, including for instruction at the author s institution, sharing

### 1 Some loose ends from last time

Cornell University, Fall 2010 CS 6820: Algorithms Lecture notes: Kruskal s and Borůvka s MST algorithms September 20, 2010 1 Some loose ends from last time 1.1 A lemma concerning greedy algorithms and

### THE FUNDAMENTAL GROUP AND CW COMPLEXES

THE FUNDAMENTAL GROUP AND CW COMPLEXES JAE HYUNG SIM Abstract. This paper is a quick introduction to some basic concepts in Algebraic Topology. We start by defining homotopy and delving into the Fundamental

### Words with the Smallest Number of Closed Factors

Words with the Smallest Number of Closed Factors Gabriele Fici Zsuzsanna Lipták Abstract A word is closed if it contains a factor that occurs both as a prefix and as a suffix but does not have internal

### Propositional Logic Language

Propositional Logic Language A logic consists of: an alphabet A, a language L, i.e., a set of formulas, and a binary relation = between a set of formulas and a formula. An alphabet A consists of a finite

### Turing Machines Part II

Turing Machines Part II Problem Set Set Five Five due due in in the the box box up up front front using using a late late day. day. Hello Hello Condensed Slide Slide Readers! Readers! This This lecture

### Lecture 9: The Recursion Theorem. Michael Beeson

Lecture 9: The Recursion Theorem Michael Beeson The problem of computing by recursion We still have not provided completely convincing evidence that every intuitively computable function is Turing computable,

### On the Cost of Worst-Case Coding Length Constraints

On the Cost of Worst-Case Coding Length Constraints Dror Baron and Andrew C. Singer Abstract We investigate the redundancy that arises from adding a worst-case length-constraint to uniquely decodable fixed

### Test Generation for Designs with Multiple Clocks

39.1 Test Generation for Designs with Multiple Clocks Xijiang Lin and Rob Thompson Mentor Graphics Corp. 8005 SW Boeckman Rd. Wilsonville, OR 97070 Abstract To improve the system performance, designs with

### A version of for which ZFC can not predict a single bit Robert M. Solovay May 16, Introduction In [2], Chaitin introd

CDMTCS Research Report Series A Version of for which ZFC can not Predict a Single Bit Robert M. Solovay University of California at Berkeley CDMTCS-104 May 1999 Centre for Discrete Mathematics and Theoretical

### 1 Two-Way Deterministic Finite Automata

1 Two-Way Deterministic Finite Automata 1.1 Introduction Hing Leung 1 In 1943, McCulloch and Pitts [4] published a pioneering work on a model for studying the behavior of the nervous systems. Following

### Semantics of intuitionistic propositional logic

Semantics of intuitionistic propositional logic Erik Palmgren Department of Mathematics, Uppsala University Lecture Notes for Applied Logic, Fall 2009 1 Introduction Intuitionistic logic is a weakening

### Linear Algebra and Eigenproblems

Appendix A A Linear Algebra and Eigenproblems A working knowledge of linear algebra is key to understanding many of the issues raised in this work. In particular, many of the discussions of the details

### Complete Partial Orders, PCF, and Control

Complete Partial Orders, PCF, and Control Andrew R. Plummer TIE Report Draft January 2010 Abstract We develop the theory of directed complete partial orders and complete partial orders. We review the syntax

### CMPSCI 601: Tarski s Truth Definition Lecture 15. where

@ CMPSCI 601: Tarski s Truth Definition Lecture 15! "\$#&%(') *+,-!".#/%0'!12 43 5 6 7 8:9 4; 9 9 < = 9 = or 5 6?>A@B!9 2 D for all C @B 9 CFE where ) CGE @B-HI LJKK MKK )HG if H ; C if H @ 1 > > > Fitch