This paper describes a purely functional library for computing level-$p$-complexity of Boolean functions, and applies it to two-level iterated majority. Boolean functions are simply functions from $n$ bits to one bit, and they can describe digital circuits, voting systems, etc. An example of a Boolean function is majority, which returns the value that has majority among the $n$ input bits for odd $n$. The complexity of a Boolean function $f$ measures the cost of evaluating it: how many bits of the input are needed to be certain about the result of $f$. There are many competing complexity measures but we focus on level-$p$-complexity -- a function of the probability $p$ that a bit is 1. The level-$p$-complexity $D_p(f)$ is the minimum expected cost when the input bits are independent and identically distributed with Bernoulli($p$) distribution. We specify the problem as choosing the minimum expected cost of all possible decision trees -- which directly translates to a clearly correct, but very inefficient implementation. The library uses thinning and memoization for efficiency and type classes for separation of concerns. The complexity is represented using (sets of) polynomials, and the order relation used for thinning is implemented using polynomial factorisation and root-counting. Finally we compute the complexity for two-level iterated majority and improve on an earlier result by J.~Jansson.
翻译:本文描述了一个纯函数式库,用于计算布尔函数的层次-p复杂度,并将其应用于两级迭代多数投票函数。布尔函数本质上是将n位输入映射为单比特输出的函数,可用于描述数字电路、投票系统等。多数投票函数是布尔函数的一个实例:当n为奇数时,它返回n个输入比特中占多数的值。布尔函数f的复杂度衡量其求值成本:为确定f的输出结果,需要考察多少位输入。尽管存在多种竞争性的复杂度度量方案,我们聚焦于层次-p复杂度——该指标是输入比特取值为1的概率p的函数。层次-p复杂度D_p(f)定义当输入比特独立同分布于伯努利(p)分布时,所需的最小期望成本。我们将该问题表述为在所有可能的决策树中选择最小期望成本——这直接对应一个逻辑正确但效率极低的实现方案。该库通过稀疏化和记忆化技术提升效率,并利用类型类实现关注点分离。复杂度采用多项式(集)表示,用于稀疏化的序关系则通过多项式因式分解和根计数实现。最后我们计算了两级迭代多数投票函数的复杂度,并改进了J. Jansson此前的研究结果。