BIT predicate

From HandWiki
Short description: Test of a specified bit in a binary number

In mathematics and computer science, the BIT predicate, sometimes written [math]\displaystyle{ \text{BIT}(i,j) }[/math], is a predicate that tests whether the [math]\displaystyle{ j }[/math]th bit of the number [math]\displaystyle{ i }[/math] (starting from the least significant digit) is 1, when [math]\displaystyle{ i }[/math] is written as a binary number. Its mathematical applications include modeling the membership relation of hereditarily finite sets, and defining the adjacency relation of the Rado graph. In computer science, it is used for efficient representations of set data structures using bit vectors, in defining the private information retrieval problem from communication complexity, and in descriptive complexity theory to formulate logical descriptions of complexity classes.

History

The BIT predicate was first introduced in 1937 by Wilhelm Ackermann to define the Ackermann coding, which encodes hereditarily finite sets as natural numbers.[1][2] The BIT predicate can be used to perform membership tests for the encoded sets: [math]\displaystyle{ \text{BIT}(i,j) }[/math] is true if and only if the set encoded by [math]\displaystyle{ j }[/math] is a member of the set encoded by [math]\displaystyle{ i }[/math].[1]

Ackermann denoted the predicate [math]\displaystyle{ \text{BIT}(i,j) }[/math] as [math]\displaystyle{ \mathfrak{El}(j,i) }[/math], using a Fraktur font to distinguish it from the notation [math]\displaystyle{ \mathrm{El}(j,i) }[/math] that he used for set membership (short for "[math]\displaystyle{ j }[/math] is an element of [math]\displaystyle{ i }[/math]" in German).[1] The notation [math]\displaystyle{ \text{BIT}(i,j) }[/math], and the name "the BIT predicate", come from the work of Ronald Fagin and Neil Immerman, who applied this predicate in computational complexity theory as a way to encode and decode information in the late 1980s and early 1990s.[lower-alpha 1]

Description and implementation

The binary representation of a number [math]\displaystyle{ i }[/math] is an expression for [math]\displaystyle{ i }[/math] as a sum of distinct powers of two, [math]\displaystyle{ i = \cdots b_3 2^3 + b_2 2^2 + b_1 2^1 + b_0 2^0 }[/math] where each bit [math]\displaystyle{ b_j }[/math] in this expression is either 0 or 1. It is commonly written in binary notation as just the sequence of these bits, [math]\displaystyle{ \cdots b_3b_2b_1b_0 }[/math]. Given this expansion for [math]\displaystyle{ i }[/math], the BIT predicate [math]\displaystyle{ \text{BIT}(i,j) }[/math] is defined to equal [math]\displaystyle{ b_j }[/math]. It can be calculated from the formula [math]\displaystyle{ \text{BIT}(i,j) = \left\lfloor \frac{i}{2^j} \right\rfloor \bmod 2, }[/math] where [math]\displaystyle{ \lfloor \cdot \rfloor }[/math] is the floor function and mod is the modulo function.[6] The BIT predicate is a primitive recursive function.[2][7] As a binary relation (producing true and false values rather than 1 and 0 respectively), the BIT predicate is asymmetric: there do not exist two numbers [math]\displaystyle{ i }[/math] and [math]\displaystyle{ j }[/math] for which both [math]\displaystyle{ \text{BIT}(i,j) }[/math] and [math]\displaystyle{ \text{BIT}(j,i) }[/math] are true.[lower-alpha 2]

In programming languages such as C, C++, Java, or Python that provide a right shift operator >> and a bitwise Boolean and operator &, the BIT predicate [math]\displaystyle{ \text{BIT}(i,j) }[/math] can be implemented by the expression (i>>j)&1. The subexpression i>>j shifts the bits in the binary representation of [math]\displaystyle{ i }[/math] so that bit [math]\displaystyle{ b_j }[/math] is shifted to position 0, and the subexpression &1 masks off the remaining bits, leaving only the bit in position 0. As with the modular arithmetic formula above, the value of the expression is 1 or 0, respectively as the value of [math]\displaystyle{ \text{BIT}(i,j) }[/math] is true or false.[9]

Applications

Set data structures

For a set represented as a bit array, the BIT predicate can be used to test set membership. For instance, subsets of the non-negative integers [math]\displaystyle{ \{0, 1, \ldots\} }[/math] may be represented by a bit array with a one in position [math]\displaystyle{ i }[/math] when [math]\displaystyle{ i }[/math] is a member of the subset, and a zero in that position when it is not a member. When such a bit array is interpreted as a binary number, the set [math]\displaystyle{ \{i,j,k,\dots\} }[/math] for distinct [math]\displaystyle{ i,j,k,\dots }[/math] is represented as the binary number [math]\displaystyle{ 2^i+2^j+2^k+\cdots }[/math]. If [math]\displaystyle{ S }[/math] is a set, represented in this way, and [math]\displaystyle{ i }[/math] is a number that may or may not be an element of [math]\displaystyle{ S }[/math], then [math]\displaystyle{ \text{BIT}(S,i) }[/math] returns a nonzero value when [math]\displaystyle{ i }[/math] is a member and zero when it is not.[lower-alpha 3]

The same technique may be used to test membership in subsets of any sequence [math]\displaystyle{ x_0,x_1,\dots }[/math] of distinct values, encoded using powers of two whose exponents are the positions of the elements in this sequence, rather than their values. For instance, in the Java collections framework, java.util.EnumSet uses this technique to implement a set data structure for enumerated types.[11] Ackermann's encoding of the hereditarily finite sets is an example of this technique, for the recursively-generated sequence of hereditarily finite sets.[lower-alpha 4]

Private information retrieval

In the mathematical study of computer security, the private information retrieval problem can be modeled as one in which a client, communicating with a collection of servers that store a binary number [math]\displaystyle{ i }[/math], wishes to determine the result of a BIT predicate [math]\displaystyle{ \text{BIT}(i,j) }[/math] without divulging the value of [math]\displaystyle{ j }[/math] to the servers. (Chor Kushilevitz) describe a method for replicating [math]\displaystyle{ i }[/math] across two servers in such a way that the client can solve the private information retrieval problem using a substantially smaller amount of communication than would be necessary to recover the complete value of [math]\displaystyle{ i }[/math].[13]

Complexity and logic

The BIT predicate is often examined in the context of first-order logic, where systems of logic result from adding the BIT predicate to first-order logic. In descriptive complexity, the complexity class FO describes the class of formal languages that can be described by a formula in first-order logic with a comparison operation on totally ordered variables (interpreted as the indexes of characters in a string) and with predicates that test whether this string has a given character at a given numerical index. A formula in this logic defines a language consisting of its finite models.[lower-alpha 5] However, with these operations, only a very restricted class of languages, the star-free regular languages, can be described.[15] Adding the BIT predicate to the repertoire of operations used in these logical formulas results in a more robust complexity class, FO[BIT], meaning that it is less sensitive to minor variations in its definition.[lower-alpha 6]

The class FO[BIT] is the same as the class FO[+,×], of first-order logic with addition and multiplication predicates.[14] It is also the same as the circuit complexity class DLOGTIME-uniform AC0. Here, AC0 describes the problems that can be computed by circuits of AND gates and OR gates with polynomial size, bounded height, and unbounded fanout. "Uniform" means that the circuits of all problem sizes must be described by a single algorithm. More specifically, it must be possible to index the gates of each circuit by numbers in such a way that the type of each gate and the adjacency between any two gates can be computed by a deterministic algorithm whose time is logarithmic in the size of the circuit (DLOGTIME).[6][16]

Construction of the Rado graph

The Rado graph, constructed from the BIT predicate. For instance, an edge connects 0 to 3 because the 0th bit of 3 is nonzero.

In 1964, German–British mathematician Richard Rado used the BIT predicate to construct the infinite Rado graph. Rado's construction is just the symmetrization of Ackermann's 1937 construction of the hereditary finite sets from the BIT predicate: two vertices numbered [math]\displaystyle{ i }[/math] and [math]\displaystyle{ j }[/math] are adjacent in the Rado graph when either [math]\displaystyle{ \text{BIT}(i,j) }[/math] or [math]\displaystyle{ \text{BIT}(j,i) }[/math] is nonzero.[17]

The resulting graph has many important properties: it contains every finite undirected graph as an induced subgraph, and any isomorphism of its induced subgraphs can be extended to a symmetry of the whole graph.[8]

Notes

  1. An early use of the BIT predicate name is (Immerman 1989).[3] In a 1990 paper, David Mix Barrington attributes the [math]\displaystyle{ \text{BIT}(i,j) }[/math] notation, and its application in descriptive complexity, to Fagin; Barrington credits Fagin for inspiring Immerman to work in this area.[4] However, (Ajtai Fagin) refer to "Immerman's BIT relation".[5]
  2. For the asymmetry of the set membership relation that the BIT predicate encodes, see (Cameron 2001).[8]
  3. (Arndt 2011). Arndt implements the BIT predicate by S&(1<<i) rather than (S>>i)&1, but the result is zero or nonzero equally for both implementations.[10]
  4. (Tarau 2010). Tarau's implementation of the membership test (as inSet in the section "Deriving set operations") amounts to testing whether S&(1<<i) == 1<<i rather than (S>>i)&1, similar to that for (Arndt 2011).[12]
  5. In some sources this class is written FO[<], to indicate the comparison operation; however, when defining complexity classes from logic in this way, the comparison operation cannot be omitted,[14] so it is not necessary to indicate that it is present.
  6. (Immerman 1999), p. 13: "Adding BIT ... makes the set of first-order definable boolean queries a more robust complexity class."

References

  1. 1.0 1.1 1.2 Ackermann, Wilhelm (1937). "Die Widerspruchsfreiheit der allgemeinen Mengenlehre" (in de). Mathematische Annalen 114: 305–315. doi:10.1007/bf01594179. http://www.digizeitschriften.de/dms/img/?PPN=PPN235181684_0114&DMDID=dmdlog23. Retrieved 2012-01-09. 
  2. 2.0 2.1 Kirby, Laurence (2009). "Finitary Set Theory". Notre Dame Journal of Formal Logic 50 (3): 227–244. doi:10.1215/00294527-2009-009. 
  3. "Expressibility and parallel complexity". SIAM Journal on Computing 18 (3): 625–638. 1989. doi:10.1137/0218043. 
  4. Mix Barrington, David A. (1990). "Extensions of an idea of McNaughton". Mathematical Systems Theory 23 (3): 147–164. doi:10.1007/BF02090772. 
  5. "Reachability is harder for directed than for undirected finite graphs". The Journal of Symbolic Logic 55 (1): 113–150. 1990. doi:10.2307/2274958. 
  6. 6.0 6.1 Lindell, Steven (1992). "A purely logical characterization of circuit uniformity". IEEE Computer Society. pp. 185–192. doi:10.1109/SCT.1992.215393. https://web.archive.org/web/20170830004340id_/http://ww3.haverford.edu/cmsc/slindell/Uniformity.pdf. 
  7. Rautenberg, Wolfgang (2010). A Concise Introduction to Mathematical Logic (3rd ed.). New York City: Springer Science+Business Media. p. 261. doi:10.1007/978-1-4419-1221-3. ISBN 978-1-4419-1220-6. 
  8. 8.0 8.1 "The random graph revisited". 201. Basel: Birkhäuser. 2001. pp. 267–274. doi:10.1007/978-3-0348-8268-2_15. https://www.math.uni-bielefeld.de/~rehmann/ECM/cdrom/3ecm/pdfs/pant3/camer.pdf. 
  9. Venugopal, K. R. (1997). Mastering C++. Tata McGraw-Hill Publishing Company. p. 123. ISBN 9780074634547. https://books.google.com/books?id=2soaY85jGQIC&pg=PA123. .
  10. Arndt, Jörg (2011). "1.9.2: Testing whether an element is in a given set". Matters Computational: Ideas, Algorithms, Source Code. Springer. p. 24. http://jjj.de/fxt/fxtbook.pdf. 
  11. Bloch, Joshua (2008). "Item 32: Use enumSet instead of bit fields". Effective Java (2nd ed.). Addison-Wesley Professional. pp. 159–160. ISBN 9780132778046. https://books.google.com/books?id=ka2VUBqHiWkC&pg=PA159. 
  12. Tarau, Paul (2010). "A unified formal description of arithmetic and set theoretical data types". in Autexier, Serge; Calmet, Jacques; Delahaye, David et al.. 6167. Springer. pp. 247–261. doi:10.1007/978-3-642-14128-7_21. 
  13. "Private information retrieval". Journal of the ACM 45 (6): 965–981. 1998. doi:10.1145/293347.293350. .
  14. 14.0 14.1 Immerman, Neil (1999). Descriptive Complexity. New York: Springer-Verlag. pp. 13–16. ISBN 0-387-98600-6. 
  15. "First-order logic and star-free sets". Journal of Computer and System Sciences 32 (3): 393–406. 1986. doi:10.1016/0022-0000(86)90037-1. 
  16. Mix Barrington, David A. (1990). "On uniformity within NC1". Journal of Computer and System Sciences 41 (3): 274–306. doi:10.1016/0022-0000(90)90022-D. 
  17. Rado, Richard (1964). "Universal graphs and universal functions". Acta Arith. 9 (4): 331–340. doi:10.4064/aa-9-4-331-340. http://matwbn.icm.edu.pl/ksiazki/aa/aa9/aa9133.pdf. .