# Bounded Cost Algorithms for Multivalued Consensus Using Binary Consensus Instances

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Bounded Cost Algorithms for Multivalued Consensus Using Binary Consensus Instances Jialin Zhang Tsinghua University Wei Chen Microsoft Research Asia Abstract In this paper, we present two bounded cost algorithms that solve multivalued consensus using binary consensus instances. Our first algorithm uses log 2 n number of binary consensus instances where n is the number of processes, while our second algorithm uses at most 2 k binary consensus instances, where k is the maximum length of the binary representation of all proposed values in the run. Both algorithms are significant improvements over the previous algorithm in [6], where the number of binary consensus instances needed to solve one multivalued consensus is unbounded. Keywords: distributed computing, fault tolerance, binary consensus, multivalued consensus. 1 Introduction Consensus is a fundamental problem to solve when building fault-tolerant distributed systems. Informally, consensus abstracts the basic agreement problem one often sees in distributed systems as follows: Each process in a system proposes some value, and through communication they eventually need to decide on one value proposed, and the decision is irrevocable. Many important distributed tasks, such as atomic broadcast, data replication, mutual exclusion, atomic commit, etc., can use consensus as one of the core components in their implementations. Therefore, consensus has been extensively studied from various angles in the distributed computing community. One basic form of consensus is binary consensus, in which processes may only propose 0 or 1 and the decision is one of the two values. Binary consensus is a form used in studying both impossibility and lower bound results (e.g., [2, 4]) and consensus algorithms (e.g., [1, 3]). However, solving the general multivalued consensus using binary consensus is not trivial. In [7], Turpin and Coan provide an algorithm reducing multivalued consensus to binary consensus in synchronous systems with Byzantine failures. In [6], Mostefaoui et al. provide a reduction algorithm in asynchronous systems with crash failures. Our work is a direct improvement of the work in [6]. In the algorithm of [6], every process runs a series of binary consensus instances sequentially to solve multivalued consensus. However, the number of the binary consensus instances needed to solve one multivalued consensus instance is unbounded, and it depends on the message delay among the processes. As long as each proposed value is delayed in reaching at least one process, it is possible that all processes may keep This work was supported in part by the National Natural Science Foundation of China Grant , and the National Basic Research Program of China Grant 2007CB807900,2007CB

2 running an arbitrarily many number of binary consensus instances without solving the multivalued consensus. Since the actual implementation of binary consensus is usually costly, it is certainly undesirable to invoke an unbounded number of binary consensus instances to solve one instance of multivalued consensus. In this paper, we provide bounded cost algorithms that solve multivalued consensus using a bounded number of binary consensus instances. In our first algorithm, every process invokes exactly log 2 n number of binary consensus instances to solve one multivalued consensus instance, where n is the number of processes in the system. The idea is to use binary consensus to agree on a log 2 n bit long process identifier bit by bit, such that the decision value is the proposal value of this process. In our second algorithm, every process invokes at most 2 k binary consensus instances, where k is the maximum length of the binary representation of all proposed values in the run. The idea is to use binary consensus to agree on the decision value directly bit by bit, but we need to address the issue of when to terminate the binary consensus instances since processes do not know in advance the number of bits they need to agree on. The second algorithm is adaptive to the actual length of proposed values in a run, and it is more efficient than the first algorithm if we know in advance that the length of proposed values are at most log 2 n /2. Our paper focuses on bounding the cost for asynchronous systems. In synchronous systems, the algorithm in [6] is better since it only needs one binary consensus instance while our algorithms still needs log 2 n or 2 k binary consensus instances. 2 The model and the problem We consider a distributed system consisting of n processes {p 1, p 2,..., p n }. Processes may fail by crashing, i.e., stop taking any actions. We say that a process is faulty in a run if it crashes in the run and a process is correct if it is not faulty. The problem to solve is multivalued consensus, in which every process proposes a value from an arbitrary range of values, and makes an irrevocable decision on one value. It needs to satisfy the following three properties: Validity: If a process decides v, then v has been proposed by some process. Uniform Agreement: No two processes (correct or not) decide differently. Termination: If all correct processes propose, eventually all correct processes decide. 1 In this paper, we show how to solve multivalued consensus using binary consensus, which is a special form of multivalued consensus in which processes may only propose 0 or 1. Note that in this paper we are interested in the uniform version of consensus, i.e., it satisfies the Uniform Agreement property. In our algorithms, we use B-Consensus(v) to represent a binary consensus instance, where v is the proposal value. When there are multiple binary consensus instances used in the algorithm, we use array notation like B-Consensus[k]() to differentiate different consensus instances. The communication primitive we use in this paper is uniform reliable broadcast [5], which is also used in [6]. In uniform reliable broadcast, a process broadcasts a value v, which is associated with an attribute sender(v) to denote the initiator of the broadcast of v, and eventually correct processes should deliver v. More precisely, it should satisfy the following properties: 1 An alternative specification may not require that all correct processes propose, and only require that all correct processes that propose eventually decide. It is easy to check that our algorithm satisfies this alternative requirement if the underlying binary consensus satisfies the same requirement. 2

3 Uniform Integrity: For any value v, any process (correct or faulty) delivers v at most once, and only if v was previously broadcast by sender(v). Validity: If a correct process broadcasts v, then it eventually delivers v. Uniform Agreement: If a process (correct or faulty) delivers a value v, then all correct processes eventually deliver value v. In our algorithms, we use UR-Broadcast(v) to denote the uniform reliable broadcast of value v, and UR-Deliver(v) to denote the uniform reliable delivery of v. We do not use any other communication primitives. Therefore, we do not need to further clarify if our model is based on the message-passing model or the shared-memory model. In fact, the uniform reliable broadcast abstraction can be implemented in both models. In the message-passing model with reliable links, it can be implemented using the algorithms in [5]. In the shared-memory model, it can be simply implemented as follows: When a process wants to broadcast v, it writes v into a shared single-writer multireader atomic register dedicated to this process, since once v is written, all other processes can read it and it will not be lost. Subsequent broadcasts by the same process can be implemented by piggybacking all values that have been broadcasted by the process together and write into one shared register. 3 Algorithms from binary consensus to multivalued consensus In this section, we present two algorithms that solve multivalued consensus using binary consensus instances and uniform reliable broadcast. The number of binary consensus instances used in the first algorithm is linear to the length of process identifiers, while the number of binary consensus instances used in the second algorithm is linear to the lengths of proposed values in the run. Therefore, the algorithms can be used for different situations to achieve the best efficiency. For many variables in our algorithms, we need to operate on both their integer representations and bit string representations. To keep the simplicity and the clarity of the presentation, we use the following conventions in both algorithms. All simple variables in the algorithms, such as i, j, l, and d, are treated as non-negative integers by default. For an integer variable j, we suppose the binary representation of the value of j is j m j m 1... j 1 j 0, such that j k {0, 1}, k = 0, 1,..., m, and j m = 1 if j > 0 (j m is the most significant bit and thus is always 1 except when j = 0). For any non-negative integer k, we use j[k] to represent the k-th bit of j: When reading j[k], the return value is j k if 0 k m and 0 if k > m; when writing a bit b to j[k], the result is changing the integer value of j such that the k-th bit j[k] becomes b and all other bits remain unchanged. We also use j[k..0] to represent the bit string j[k] j[k 1] j[1] j[0]. By convention, if k < 0, j[k..0] is the empty string. For example, if j = 101 (i.e., integer 5), then j[1] = 0, j[2] = 1, j[5] = 0, j[1..0] = 01, j[2..0] = 101, j[5..0] = , and setting j[3] to 1 changes j to 1101 (integer 13). 3.1 Algorithm linear to the length of process identifiers We first give an algorithm (Figure 1) that uses log 2 n sequential calls to binary consensus instances to solve multivalued consensus. The idea is for the processes to agree on the identifier of a process, and the proposed value of that process would be used as the decision value. To do so, processes use binary consensus instances to agree on the binary representation of the process identifier bit by bit, starting from 3

4 Local variables on process p i : 1 v i, input proposal value of process p i 2 prop[0..n 1], array storing the proposed values of processes, initially for all entries 3 l, non-negative integer storing the process identifier to be decided, initally 0 Code for process p i : 4 UR-Broadcast(v i ) 5 wait until [prop[i] ] 6 j i 7 for k = 0 to log 2 n 1 8 l[k] B-Consensus[k](j[k]) 9 repeat j (j + 1) mod n 10 until [prop[j] and l[k..0] = j[k..0]] 11 endfor 12 return prop[l] /* decide on prop[l] */ 13 Upon UR-Deliver(v) with sender(v) = p j : 14 prop[j] v Figure 1: Algorithm linear to the length of process identifiers the least significant bit. The key mechanism in the algorithm is to guarantee that after deciding on a process identifier l, every process also know the proposed value of process p l. In the algorithm, v i is the proposal of process p i. Each process p i first uniformly broadcasts its own proposed value (line 4). Whenever p i uniformly delivers a proposed value from p j, it stores it into prop[j] (lines 13 14). Process p i waits until it delivers its own proposed value (line 5), then sets variable j to i (line 6). Variable j is the process identifier such that at the beginning of the k-th iteration of the for-loop (lines 7 11), prop[j] and j[k 1..0] = l[k 1..0], where variable l stores the process identifier on which all processes should eventually agree. In the for-loop (lines 7 11), processes fill in l as a bit string bit by bit starting from the least significant bit. In the k-th round (i.e., the k-th iterations of the for-loop with k = 0, 1,..., log 2 n 1), process p i first proposes to the k-th binary consensus instance B-Consensus[k]() with the k-th bit of j (line 8). The decision of this instance is used to fill the k-th bit of l. Then p i waits for a proposed value from a process p j such that the current identifier l (with bits up to the k-th bit filled) is the same as j, that is, l[k..0] = j[k..0] (line 9 10). The loop ends when it has gone through all bits of process identifiers. At this point l is the final identifier, and p i then decide on p l s proposed value (line 12). Theorem 1 The algorithm in Figure 1 solves multivalued consensus problem based on the binary consensus. Proof. We show that the algorithm satisfies the Validity, Uniform Agreement, and Termination properties of consensus. Validity: Suppose process p decides on prop[l]. First, in the last round of process p, p has already checked in line 10 that prop[j] and l[ log n 1..0] = j[ log n 1..0], which means l = j and prop[l]. Thus p decides on prop[l] = v. The value of prop[l] becomes v only after p uniformly delivers value v with sender(v) = p l. By the Uniform Integrity of the uniform reliable broadcast, p l broadcasts v. According to the algorithm, v = v l is the proposal value of p l. Uniform Agreement: Suppose process p and q (either correct or not) both return some decision value in line 12. Thus, both of them complete all log 2 n rounds without crashing in between. In each round k = 0, 1,..., log 2 n 1, they run the same binary consensus instance B-Consensus[k]() to determine the k-th bit of l. By the Uniform Agreement of the binary consensus instances, we know that they have the same 4

5 value l after they complete all rounds. Moreover, on both p and q, prop[l] can only contain the proposed value v l from process p l. Therefore, p and q can only decide on the same value v l. Termination: First, for every correct process p i, by the Validity of the uniform reliable broadcast, after p i broadcasts v i in line 4, p i eventually delivers v i and sets prop[i] to v i (line 14). Thus, p i will not be blocked at line 5 forever. Suppose, for a contradiction, that some correct process p does not decide. Then p is blocked forever in some round k. Let k {0, 1,..., log 2 n 1} be the earliest round number in which some correct process is blocked forever. We first show that no correct process can be blocked at the binary consensus instance B-Consensus[k]() in line 8. Since no correct process is blocked in the previous round by the definition of k, all correct processes eventually propose to B-Consensus[k](). By the Termination property of binary consensus, all correct processes eventually decide in B-Consensus[k](). We then show that no correct process can be blocked forever in the repeat-until loop in lines 9 10 in round k. For every correct process p i, p i has already run the binary consensus instance B-Consensus[k]() to determine bit l[k]. By the Validity of binary consensus, some process q must have proposed l[k]. If k > 0, we consider the (k 1)- th round on process q. According to line 10, on process q there exists j q such that prop[j q ] and l[k 1..0] = j q [k 1..0] and then q proposes j q [k] to binary consensus instance B-Consensus[k](). So l[k] = j q [k] means l[k..0] = j q [k..0]. If k = 0, suppose the identifier of q is j q. Then according to lines 5 6, process q proposes j q [0] = l[0], and prop[j q ] on process q. So, in both cases, we can find j q such that prop[j q ] on some process q and l[k..0] = j q [k..0]. By the Uniform Agreement of uniform reliable broadcast, eventually on p i prop[j q ] is also non-. After this time point, the repeat-until loop in lines 9 10 of round k on process p i will end since p i can at least find j = j q that matches the condition in line 10. So, p i will not be blocked in this repeat-until loop. Therefore, no correct process is blocked forever in any round k, which means eventually all correct processes must decide. It is clear that in the algorithm, every process runs exactly log 2 n binary consensus instances sequentially to decide for the multivalued consensus. It is an improvement comparing to the algorithm in [6], in which the number of sequential binary consensus instances needed is unbounded and is affected by the synchrony and the speed of the uniform reliable broadcast algorithm. 3.2 Algorithm linear to the length of the proposed values The algorithm in Figure 1 uses binary consensus instances to determine the process identifier bit by bit. Using the similar structure, we can also determine the decision value directly bit by bit. The advantage is that when the bit representations of the proposed values are much shorter than log 2 n (the length of the bit representations of process identifiers), multivalued consensus terminates with less number of invocations to binary consensus instances. The difficulty, however, is that we do not know in advance what are the values to be proposed, and thus it is difficult to set an upper bound on the number of binary consensus instances needed to determine all bits. If we use a large fixed bound based on the number of all possible proposed values, it could be very large or even infinite. To deal with this problem, we use another binary consensus instance to determine if the algorithm should terminate after choosing each bit of the decision value. The resulting algorithm is adaptive in the sense that the number of binary consensus instances needed is linear to the maximum length of proposed values in the run, and it is not related to the total number of possible proposed values in all runs. Figure 2 shows the algorithm that determines the decision value bit by bit, starting from the least significant bit. In the algorithm, the proposal value v i of process p i is a non-negative integer value. Any finite-length string can be encoded by a non-negative integer, so using non-negative integers does not lose 5

6 Local variables on process p i : 1 v i, non-negative integer storing the input proposal value of process p i 2 prop[0..n 1], array storing the proposed values of processes, initially for all entries 3 d, non-negative integer storing the decision value, initially 0 Code for process p i : 4 UR-Broadcast(v i ) 5 wait until prop[i] 6 k 0; j i 7 repeat 8 d[k] B-Consensus[0][k](prop[j][k]) 9 repeat j (j + 1) mod n 10 until [d[k..0] = prop[j][k..0]] 11 if d = prop[j] then finish = 1 else finish = 0 12 r B-Consensus[1][k](finish) 13 k k until r = 1 15 return d /* decide on d */ 16 Upon UR-Deliver(v) with sender(v) = p j : 17 prop[j] v Figure 2: Algorithm linear to the length of the proposed values the generality of the solution. Similar to the first algorithm, each process first uniformly broadcasts its own proposed value and stores all received proposed values in array prop[ ]. Variable d is an integer variable used to store the final decision value. Processes decide the decision value d bit by bit from d[0], d[1], and so on. In round k, i.e., the k-th iteration of the repeat-until loop in lines 7 14 with k 0, processes decide on d[k], the k-th bit of d. Process p i first uses the k-th bit of prop[j] to be the proposal of the binary consensus B-Consensus[0][k]() (line 8) where j is chosen in the previous round (initially, j is set to p i s own identifier i). Then process p i finds a non-empty proposal prop[j] such that d[k..0] = prop[j][k..0] (lines 9 10), This is to ensure that the final decision value is from one of the proposed values, i.e., to ensure the Validity property of consensus. Finally, process p i uses another binary consensus instance B-Consensus[1][k]() to decide whether or not the procedure should terminate (line 12). The input to this binary consensus instance is 1 if p i finds that the integer d is the same as prop[j], or 0 otherwise (line 11). If the decision of this instance is 1, then the multivalued consensus terminates with the decision d. Theorem 2 The algorithm in Figure 2 solves multivalued consensus problem based on the binary consensus. Proof. We show that the algorithm satisfies the Validity, Uniform Agreement, and Termination properties of consensus. Validity: Suppose d is the decision value returned by process p. By line 14, p breaks from the repeatuntil loop with r = 1 in some round k. This means at least one process q proposes finish = 1 in the binary consensus instance B-Consensus[1][k]() in line 12. So d = prop[j] for some j when process q runs line 11. By the Uniform Integrity of the uniform reliable broadcast, some p j broadcasts prop[j], and thus p j proposes d for its multivalued consensus instance. The Validity property holds. Uniform Agreement: Suppose process p and q (either correct or not) both return some decision value in line 15. Thus, neither of them crashes or is blocked before making a decision. We first prove that for any k 0, if process p runs the binary consensus instance B-Consensus[0][k](), process q also runs the binary consensus instance B-Consensus[0][k](). If not, there must exist k < k, process q breaks from repeat-until 6

7 loop in line 14 after running the binary consensus instance B-Consensus[1][k ](). Thus, B-Consensus[1][k ]() returns 1 in line 12. But process p also runs the binary consensus instance B-Consensus[1][k ](). By the Uniform Agreement property of the binary consensus, process p should get the return value 1 from instance B-Consensus[1][k ](), which means it should break from the repeat-until loop in line 14 in round k < k, which contradicts to the fact that p runs the binary consensus instance B-Consensus[0][k](). So processes p and q run the same set of binary consensus instances B-Consensus[0][k](). The k-th bit of the decision value d returned by p and q are decided by the binary consensus instance B-Consensus[0][k](), which means that the k-th bit decided by p and q are the same. So decision value returned by process p is the same as the decision value returned by process q. This proves the Uniform agreement property. Termination: First, by the same argument as in Theorem 1, no correct process p is blocked in line 5. We then prove that no correct process is blocked inside the repeat-until loop (line 7 14). If not, let k be the earliest round number in which some correct process is blocked forever. We first show that no correct process p i is blocked at the binary consensus instance B-Consensus[0][k]() in line 8. If k = 0, then j = i for process p i. So prop[j] by line 5. If k > 0, since process p i is not blocked in the previous round, prop[j] by line 10. Therefore, all correct processes eventually propose to B-Consensus[0][k](). By the Termination property of binary consensus, all correct processes eventually decide in B-Consensus[0][k](). We then show that no correct process p i is blocked forever in the repeat-until loop in lines 9 10 in round k. By the Validity of binary consensus, the decision value d[k] in round k is proposed by some process q. So d[k] = prop[j q ][k] for some j q on q. If k > 0, in the (k 1)-th round of process q, according to line 10, we have d[k 1..0] = prop[j q ][k 1..0]. So d[k..0] = prop[j q ][k..0] and prop[j q ] on process q. If k = 0, suppose the identifier of q is j q. Then we have prop[j q ] and d[0..0] = prop[j q ][0..0] on process q. In both cases, we have prop[j q ] on process q and d[k..0] = prop[j q ][k..0]. By the Uniform Agreement of uniform reliable broadcast, eventually on p i, prop[j q ] is also non-. After this time point, the repeat-until loop in lines 9 10 of round k on process p i will end since p i can at least find j = j q that matches the condition in line 10. So, p i will not be blocked in this repeat-until loop. Therefore, all correct processes eventually propose to B-Consensus[1][k](). By the Termination property of binary consensus, all correct processes eventually decide in B-Consensus[1][k](). Therefore, no correct process is blocked forever in any round k. Finally, let v i = 1 if v i = 0, and v i = max{j v i [j] = 1} + 1, i.e. v i is the length of the binary representation of v i. Let k = max{ v i i = 1, 2,..., n}, i.e., k is the maximum length of the binary representations of all proposed values. We prove that for any process p that finishes round k 1, p must decide at the end of this round and terminate the multivalued consensus. When p executes line 11 in round k 1, we have d[ k 1..0] = prop[j][ k 1..0] for some j according to line 10. By the definition of k, prop[j] has no bit higher than the ( k 1)-th bit that is 1, so d = prop[j]. Therefore, process p can only propose finish = 1 to the binary consensus instance B-Consensus[1][ k 1]() according to line 11. Since no process can propose 0 to B-Consensus[1][ k 1](), by the Validity of binary consensus the decision of this instance can only be 1. Therefore p will decide at the end of round k 1 and terminates. Since we know that all correct processes will reach the end of round k 1 if they have not decided earlier, we know that all correct processes eventually decide by the end of round k 1. From the proof of Termination, it is clear that the algorithm in Figures 2 solves multivalued consensus with at most 2 k sequential calls to binary consensus instances, where k is the maximum length of the binary representation of all proposed values in the run. Therefore, when k < log 2 n /2, this algorithm is preferred over the algorithm in the previous section. 7

8 4 Conclusion In this paper we present two bounded cost algorithms that solve multivalued consensus problem using binary consensus instances and uniform reliable broadcast primitives. In the first algorithm every processes invokes log 2 n number of binary consensus instances where n is the number of processes, while in the second algorithm every processes invokes 2 k binary consensus instances, where k is the maximum length of the binary representation of all proposed values in the run. Both algorithms significantly improve the worst-case cost of the previous algorithm in [6] in which processes may invoke an unbounded number of binary consensus instances. Finally, we remark that, even though our definition of consensus is for deterministic algorithms, our results can be certainly extended to include randomized algorithms. Therefore, we can directly use the randomized binary consensus algorithms in [1, 3] to solve randomized multivalued consensus. References [1] M. K. Aguilera and S. Toueg. Failure detection and randomization: A hybrid approach to solve consensus. SIAM Journal on Computing, 28(3): , [2] M. K. Aguilera and S. Toueg. A simple bivalency proof that t-resilient consensus requires t + 1 rounds. Information Processing Letters, 71(3-4): , [3] M. Ben-Or. Another advantage of free choice: Completely asynchronous agreement protocols. In Proceedings of the 2nd ACM Symposium on Principles of Distributed Computing, pages 27 30, Aug [4] M. J. Fischer, N. A. Lynch, and M. S. Paterson. Impossibility of distributed consensus with one faulty process. Journal of the ACM, 32(2): , Apr [5] V. Hadzilacos and S. Toueg. A modular approach to fault-tolerant broadcasts and related problems. Technical Report , Department of Computer Science, Cornell University, Ithaca, New York, May [6] A. Mostefaoui, M. Raynal, and F. Tronel. From binary consensus to multivalued consensus in asynchronous message-passing systems. Information Processing Letters, 73(5-6): , [7] R. Turpin and B. A. Coan. Extending binary byzantine agreement to multivalued byzantine agreement. Information Processing Letters, 18(2):73 76,

### Signature-Free Asynchronous Binary Byzantine Consensus with t < n/3, O(n 2 ) Messages, and O(1) Expected Time

Signature-Free Asynchronous Binary Byzantine Consensus with t < n/3, O(n 2 ) Messages, and O(1) Expected Time Achour Mostéfaoui Hamouma Moumen Michel Raynal, LINA, Université de Nantes, 44322 Nantes Cedex,

### Impossibility of Distributed Consensus with One Faulty Process

Impossibility of Distributed Consensus with One Faulty Process MICHAEL J. FISCHER Yale University, New Haven, Connecticut NANCY A. LYNCH Massachusetts Institute of Technology, Cambridge, Massachusetts

### Arithmetic Coding: Introduction

Data Compression Arithmetic coding Arithmetic Coding: Introduction Allows using fractional parts of bits!! Used in PPM, JPEG/MPEG (as option), Bzip More time costly than Huffman, but integer implementation

### Analysis of Binary Search algorithm and Selection Sort algorithm

Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to

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

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

### Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

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

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

### MODULAR ARITHMETIC. a smallest member. It is equivalent to the Principle of Mathematical Induction.

MODULAR ARITHMETIC 1 Working With Integers The usual arithmetic operations of addition, subtraction and multiplication can be performed on integers, and the result is always another integer Division, on

### Transactional Support for SDN Control Planes "

Transactional Support for SDN Control Planes Petr Kuznetsov Telecom ParisTech WTTM, 2015 Software Defined Networking An emerging paradigm in computer network management Separate forwarding hardware (data

### GROUPS SUBGROUPS. Definition 1: An operation on a set G is a function : G G G.

Definition 1: GROUPS An operation on a set G is a function : G G G. Definition 2: A group is a set G which is equipped with an operation and a special element e G, called the identity, such that (i) the

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

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

### Brewer s Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services

Brewer s Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services Seth Gilbert Nancy Lynch Abstract When designing distributed web services, there are three properties that

### Approximation Algorithms

Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms

### Classification - Examples

Lecture 2 Scheduling 1 Classification - Examples 1 r j C max given: n jobs with processing times p 1,...,p n and release dates r 1,...,r n jobs have to be scheduled without preemption on one machine taking

### Software-Based Replication for Fault Tolerance

Theme Feature Software-Based Replication for Fault Tolerance Replication handled by software on off-the-shelf hardware costs less than using specialized hardware. Although an intuitive concept, replication

### An Overview of Clock Synchronization

An Overview of Clock Synchronization Barbara Simons, IBM Almaden Research Center Jennifer Lundelius Welch, GTE Laboratories Incorporated Nancy Lynch, MIT 1 Introduction A distributed system consists of

### 8.1 Makespan Scheduling

600.469 / 600.669 Approximation Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programing: Min-Makespan and Bin Packing Date: 2/19/15 Scribe: Gabriel Kaptchuk 8.1 Makespan Scheduling Consider an instance

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

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

### 1. (First passage/hitting times/gambler s ruin problem:) Suppose that X has a discrete state space and let i be a fixed state. Let

Copyright c 2009 by Karl Sigman 1 Stopping Times 1.1 Stopping Times: Definition Given a stochastic process X = {X n : n 0}, a random time τ is a discrete random variable on the same probability space as

### Fairness in Routing and Load Balancing

Fairness in Routing and Load Balancing Jon Kleinberg Yuval Rabani Éva Tardos Abstract We consider the issue of network routing subject to explicit fairness conditions. The optimization of fairness criteria

### An improved on-line algorithm for scheduling on two unrestrictive parallel batch processing machines

This is the Pre-Published Version. An improved on-line algorithm for scheduling on two unrestrictive parallel batch processing machines Q.Q. Nong, T.C.E. Cheng, C.T. Ng Department of Mathematics, Ocean

### Notes from Week 1: Algorithms for sequential prediction

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

### Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

### 6.852: Distributed Algorithms Fall, 2009. Class 2

.8: Distributed Algorithms Fall, 009 Class Today s plan Leader election in a synchronous ring: Lower bound for comparison-based algorithms. Basic computation in general synchronous networks: Leader election

### Protocols for Secure Cloud Computing (Parts 3 and 4)

School on Applied Cryptographic Protocols 2010 Christian Cachin, IBM Research - Zurich CASED & ECRYPT II www.zurich.ibm.com/ cca/ Protocols for Secure Cloud Computing (Parts 3 and 4) 3 Proofs of storage

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

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

### Zabin Visram Room CS115 CS126 Searching. Binary Search

Zabin Visram Room CS115 CS126 Searching Binary Search Binary Search Sequential search is not efficient for large lists as it searches half the list, on average Another search algorithm Binary search Very

### Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

CSE341T 08/31/2015 Lecture 3 Cost Model: Work, Span and Parallelism In this lecture, we will look at how one analyze a parallel program written using Cilk Plus. When we analyze the cost of an algorithm

### What Can Be Implemented Anonymously?

What Can Be Implemented Anonymously? Rachid Guerraoui 1 and Eric Ruppert 2 1 EPFL, Lausanne, Switzerland 2 York University, Toronto, Canada Abstract. The vast majority of papers on distributed computing

### 8 Primes and Modular Arithmetic

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

### Modular Communication Infrastructure Design with Quality of Service

Modular Communication Infrastructure Design with Quality of Service Pawel Wojciechowski and Péter Urbán Distributed Systems Laboratory School of Computer and Communication Sciences Swiss Federal Institute

### Using Generalized Forecasts for Online Currency Conversion

Using Generalized Forecasts for Online Currency Conversion Kazuo Iwama and Kouki Yonezawa School of Informatics Kyoto University Kyoto 606-8501, Japan {iwama,yonezawa}@kuis.kyoto-u.ac.jp Abstract. El-Yaniv

### Competitive Analysis of On line Randomized Call Control in Cellular Networks

Competitive Analysis of On line Randomized Call Control in Cellular Networks Ioannis Caragiannis Christos Kaklamanis Evi Papaioannou Abstract In this paper we address an important communication issue arising

### Local periods and binary partial words: An algorithm

Local periods and binary partial words: An algorithm F. Blanchet-Sadri and Ajay Chriscoe Department of Mathematical Sciences University of North Carolina P.O. Box 26170 Greensboro, NC 27402 6170, USA E-mail:

### Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

Algorithms Efficiency of algorithms Computational resources: time and space Best, worst and average case performance How to compare algorithms: machine-independent measure of efficiency Growth rate Complexity

### Introduction to computer science

Introduction to computer science Michael A. Nielsen University of Queensland Goals: 1. Introduce the notion of the computational complexity of a problem, and define the major computational complexity classes.

### I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

I GROUPS: BASIC DEFINITIONS AND EXAMPLES Definition 1: An operation on a set G is a function : G G G Definition 2: A group is a set G which is equipped with an operation and a special element e G, called

### Single-Link Failure Detection in All-Optical Networks Using Monitoring Cycles and Paths

Single-Link Failure Detection in All-Optical Networks Using Monitoring Cycles and Paths Satyajeet S. Ahuja, Srinivasan Ramasubramanian, and Marwan Krunz Department of ECE, University of Arizona, Tucson,

### 2.1 Complexity Classes

15-859(M): Randomized Algorithms Lecturer: Shuchi Chawla Topic: Complexity classes, Identity checking Date: September 15, 2004 Scribe: Andrew Gilpin 2.1 Complexity Classes In this lecture we will look

### 1 Definition of a Turing machine

Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,

### Full and Complete Binary Trees

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

### Classification - Examples -1- 1 r j C max given: n jobs with processing times p 1,..., p n and release dates

Lecture 2 Scheduling 1 Classification - Examples -1-1 r j C max given: n jobs with processing times p 1,..., p n and release dates r 1,..., r n jobs have to be scheduled without preemption on one machine

### The Trip Scheduling Problem

The Trip Scheduling Problem Claudia Archetti Department of Quantitative Methods, University of Brescia Contrada Santa Chiara 50, 25122 Brescia, Italy Martin Savelsbergh School of Industrial and Systems

### CMSC 858T: Randomized Algorithms Spring 2003 Handout 8: The Local Lemma

CMSC 858T: Randomized Algorithms Spring 2003 Handout 8: The Local Lemma Please Note: The references at the end are given for extra reading if you are interested in exploring these ideas further. You are

### The sum of digits of polynomial values in arithmetic progressions

The sum of digits of polynomial values in arithmetic progressions Thomas Stoll Institut de Mathématiques de Luminy, Université de la Méditerranée, 13288 Marseille Cedex 9, France E-mail: stoll@iml.univ-mrs.fr

### 1. LINEAR EQUATIONS. A linear equation in n unknowns x 1, x 2,, x n is an equation of the form

1. LINEAR EQUATIONS A linear equation in n unknowns x 1, x 2,, x n is an equation of the form a 1 x 1 + a 2 x 2 + + a n x n = b, where a 1, a 2,..., a n, b are given real numbers. For example, with x and

CS787: Advanced Algorithms Lecture 14: Online algorithms We now shift focus to a different kind of algorithmic problem where we need to perform some optimization without knowing the input in advance. Algorithms

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

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

### Homework 5 Solutions

Homework 5 Solutions 4.2: 2: a. 321 = 256 + 64 + 1 = (01000001) 2 b. 1023 = 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = (1111111111) 2. Note that this is 1 less than the next power of 2, 1024, which

### Multi-layer Structure of Data Center Based on Steiner Triple System

Journal of Computational Information Systems 9: 11 (2013) 4371 4378 Available at http://www.jofcis.com Multi-layer Structure of Data Center Based on Steiner Triple System Jianfei ZHANG 1, Zhiyi FANG 1,

### Duplicating and its Applications in Batch Scheduling

Duplicating and its Applications in Batch Scheduling Yuzhong Zhang 1 Chunsong Bai 1 Shouyang Wang 2 1 College of Operations Research and Management Sciences Qufu Normal University, Shandong 276826, China

### a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.

Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given

### Product irregularity strength of certain graphs

Also available at http://amc.imfm.si ISSN 1855-3966 (printed edn.), ISSN 1855-3974 (electronic edn.) ARS MATHEMATICA CONTEMPORANEA 7 (014) 3 9 Product irregularity strength of certain graphs Marcin Anholcer

### CHAPTER II THE LIMIT OF A SEQUENCE OF NUMBERS DEFINITION OF THE NUMBER e.

CHAPTER II THE LIMIT OF A SEQUENCE OF NUMBERS DEFINITION OF THE NUMBER e. This chapter contains the beginnings of the most important, and probably the most subtle, notion in mathematical analysis, i.e.,

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

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

### Modern Optimization Methods for Big Data Problems MATH11146 The University of Edinburgh

Modern Optimization Methods for Big Data Problems MATH11146 The University of Edinburgh Peter Richtárik Week 3 Randomized Coordinate Descent With Arbitrary Sampling January 27, 2016 1 / 30 The Problem

### Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

### 1 Formulating The Low Degree Testing Problem

6.895 PCP and Hardness of Approximation MIT, Fall 2010 Lecture 5: Linearity Testing Lecturer: Dana Moshkovitz Scribe: Gregory Minton and Dana Moshkovitz In the last lecture, we proved a weak PCP Theorem,

### How to Build a Highly Available System Using Consensus

How to Build a Highly Available System Using Consensus Butler W. Lampson 1 Microsoft 180 Lake View Av., Cambridge, MA 02138 Abstract. Lamport showed that a replicated deterministic state machine is a general

### Every Positive Integer is the Sum of Four Squares! (and other exciting problems)

Every Positive Integer is the Sum of Four Squares! (and other exciting problems) Sophex University of Texas at Austin October 18th, 00 Matilde N. Lalín 1. Lagrange s Theorem Theorem 1 Every positive integer

### Applied Algorithm Design Lecture 5

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

### Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80)

Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80) CS 30, Winter 2016 by Prasad Jayanti 1. (10 points) Here is the famous Monty Hall Puzzle. Suppose you are on a game show, and you

### Quicksort is a divide-and-conquer sorting algorithm in which division is dynamically carried out (as opposed to static division in Mergesort).

Chapter 7: Quicksort Quicksort is a divide-and-conquer sorting algorithm in which division is dynamically carried out (as opposed to static division in Mergesort). The three steps of Quicksort are as follows:

### Lecture 10: CPA Encryption, MACs, Hash Functions. 2 Recap of last lecture - PRGs for one time pads

CS 7880 Graduate Cryptography October 15, 2015 Lecture 10: CPA Encryption, MACs, Hash Functions Lecturer: Daniel Wichs Scribe: Matthew Dippel 1 Topic Covered Chosen plaintext attack model of security MACs

### Virtual Time and Timeout in Client-Server Networks

Virtual Time and Timeout in Client-Server Networks Jayadev Misra July 13, 2011 Contents 1 Introduction 2 1.1 Background.............................. 2 1.1.1 Causal Model of Virtual Time...............

### Online Bipartite Perfect Matching With Augmentations

Online Bipartite Perfect Matching With Augmentations Kamalika Chaudhuri, Constantinos Daskalakis, Robert D. Kleinberg, and Henry Lin Information Theory and Applications Center, U.C. San Diego Email: kamalika@soe.ucsd.edu

### How to build a probability-free casino

How to build a probability-free casino Adam Chalcraft CCR La Jolla dachalc@ccrwest.org Chris Freiling Cal State San Bernardino cfreilin@csusb.edu Randall Dougherty CCR La Jolla rdough@ccrwest.org Jason

### Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

### CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

### Continued Fractions and the Euclidean Algorithm

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

### Computing Cubic Fields in Quasi-Linear Time

Computing Cubic Fields in Quasi-Linear Time K. Belabas Département de mathématiques (A2X) Université Bordeaux I 351, cours de la Libération, 33405 Talence (France) belabas@math.u-bordeaux.fr Cubic fields

### CONTRIBUTIONS TO ZERO SUM PROBLEMS

CONTRIBUTIONS TO ZERO SUM PROBLEMS S. D. ADHIKARI, Y. G. CHEN, J. B. FRIEDLANDER, S. V. KONYAGIN AND F. PAPPALARDI Abstract. A prototype of zero sum theorems, the well known theorem of Erdős, Ginzburg

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

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

### Best Monotone Degree Bounds for Various Graph Parameters

Best Monotone Degree Bounds for Various Graph Parameters D. Bauer Department of Mathematical Sciences Stevens Institute of Technology Hoboken, NJ 07030 S. L. Hakimi Department of Electrical and Computer

### Two Algorithms for the Student-Project Allocation Problem

Two Algorithms for the Student-Project Allocation Problem David J. Abraham 1, Robert W. Irving 2, and David F. Manlove 2 1 Computer Science Department, Carnegie-Mellon University, 5000 Forbes Ave, Pittsburgh

### An example of a computable

An example of a computable absolutely normal number Verónica Becher Santiago Figueira Abstract The first example of an absolutely normal number was given by Sierpinski in 96, twenty years before the concept

### Linear Time Byzantine Self-Stabilizing Clock Synchronization

Linear Time Byzantine Self-Stabilizing Clock Synchronization Ariel Daliot 1, Danny Dolev 1, and Hanna Parnas 2 1 School of Engineering and Computer Science, The Hebrew University of Jerusalem, Israel.

### Lecture 5 - CPA security, Pseudorandom functions

Lecture 5 - CPA security, Pseudorandom functions Boaz Barak October 2, 2007 Reading Pages 82 93 and 221 225 of KL (sections 3.5, 3.6.1, 3.6.2 and 6.5). See also Goldreich (Vol I) for proof of PRF construction.

Adaptive Online Gradient Descent Peter L Bartlett Division of Computer Science Department of Statistics UC Berkeley Berkeley, CA 94709 bartlett@csberkeleyedu Elad Hazan IBM Almaden Research Center 650

### Topic: Greedy Approximations: Set Cover and Min Makespan Date: 1/30/06

CS880: Approximations Algorithms Scribe: Matt Elder Lecturer: Shuchi Chawla Topic: Greedy Approximations: Set Cover and Min Makespan Date: 1/30/06 3.1 Set Cover The Set Cover problem is: Given a set of

### Why? A central concept in Computer Science. Algorithms are ubiquitous.

Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

### Concepts of Concurrent Computation

Chair of Software Engineering Concepts of Concurrent Computation Bertrand Meyer Sebastian Nanz Lecture 3: Synchronization Algorithms Today's lecture In this lecture you will learn about: the mutual exclusion

### CUNSHENG DING HKUST, Hong Kong. Computer Security. Computer Security. Cunsheng DING, HKUST COMP4631

Cunsheng DING, HKUST Lecture 08: Key Management for One-key Ciphers Topics of this Lecture 1. The generation and distribution of secret keys. 2. A key distribution protocol with a key distribution center.

### A Formal Model of Program Dependences and Its Implications for Software Testing, Debugging, and Maintenance

A Formal Model of Program Dependences and Its Implications for Software Testing, Debugging, and Maintenance Andy Podgurski Lori A. Clarke Computer Engineering & Science Department Case Western Reserve

### CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

### 1 Construction of CCA-secure encryption

CSCI 5440: Cryptography Lecture 5 The Chinese University of Hong Kong 10 October 2012 1 Construction of -secure encryption We now show how the MAC can be applied to obtain a -secure encryption scheme.

### Optimized Asynchronous Passive Multi-Channel Discovery of Beacon-Enabled Networks

t t Technische Universität Berlin Telecommunication Networks Group arxiv:1506.05255v1 [cs.ni] 17 Jun 2015 Optimized Asynchronous Passive Multi-Channel Discovery of Beacon-Enabled Networks Niels Karowski,

### 24. The Branch and Bound Method

24. The Branch and Bound Method It has serious practical consequences if it is known that a combinatorial problem is NP-complete. Then one can conclude according to the present state of science that no

### Scheduling Real-time Tasks: Algorithms and Complexity

Scheduling Real-time Tasks: Algorithms and Complexity Sanjoy Baruah The University of North Carolina at Chapel Hill Email: baruah@cs.unc.edu Joël Goossens Université Libre de Bruxelles Email: joel.goossens@ulb.ac.be

Approximation Algorithms Chapter Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should I do? A. Theory says you're unlikely to find a poly-time algorithm. Must sacrifice one

### A single minimal complement for the c.e. degrees

A single minimal complement for the c.e. degrees Andrew Lewis Leeds University, April 2002 Abstract We show that there exists a single minimal (Turing) degree b < 0 s.t. for all c.e. degrees 0 < a < 0,

### Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search

Chapter Objectives Chapter 9 Search Algorithms Data Structures Using C++ 1 Learn the various search algorithms Explore how to implement the sequential and binary search algorithms Discover how the sequential

### Markov random fields and Gibbs measures

Chapter Markov random fields and Gibbs measures 1. Conditional independence Suppose X i is a random element of (X i, B i ), for i = 1, 2, 3, with all X i defined on the same probability space (.F, P).

### 3 Does the Simplex Algorithm Work?

Does the Simplex Algorithm Work? In this section we carefully examine the simplex algorithm introduced in the previous chapter. Our goal is to either prove that it works, or to determine those circumstances

### Factoring & Primality

Factoring & Primality Lecturer: Dimitris Papadopoulos In this lecture we will discuss the problem of integer factorization and primality testing, two problems that have been the focus of a great amount

### ! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Approximation Algorithms Chapter Approximation Algorithms Q Suppose I need to solve an NP-hard problem What should I do? A Theory says you're unlikely to find a poly-time algorithm Must sacrifice one of

### Mathematical Induction

Mathematical Induction Victor Adamchik Fall of 2005 Lecture 2 (out of three) Plan 1. Strong Induction 2. Faulty Inductions 3. Induction and the Least Element Principal Strong Induction Fibonacci Numbers

### Math 319 Problem Set #3 Solution 21 February 2002

Math 319 Problem Set #3 Solution 21 February 2002 1. ( 2.1, problem 15) Find integers a 1, a 2, a 3, a 4, a 5 such that every integer x satisfies at least one of the congruences x a 1 (mod 2), x a 2 (mod