BooleanFunction[k,n]
表示第 k
个 n 元布尔函数.
BooleanFunction[values]
表示对应指定真值向量的布尔函数.
BooleanFunction[{{i11,i12,…}o1,…}]
表示由输入到输出的指定映射所定义的布尔函数.
BooleanFunction[spec,{a1,a2,…}]
给出 ai 元布尔表达式,对应于 spec 指定的布尔函数.
BooleanFunction[spec,{a1,a2,…},form]
给出 form 指定形式的布尔表达式.
BooleanFunction
BooleanFunction[k,n]
表示第 k
个 n 元布尔函数.
BooleanFunction[values]
表示对应指定真值向量的布尔函数.
BooleanFunction[{{i11,i12,…}o1,…}]
表示由输入到输出的指定映射所定义的布尔函数.
BooleanFunction[spec,{a1,a2,…}]
给出 ai 元布尔表达式,对应于 spec 指定的布尔函数.
BooleanFunction[spec,{a1,a2,…},form]
给出 form 指定形式的布尔表达式.
更多信息
- BooleanFunction[spec] 给出一个布尔函数对象,其作用与 Function 类似.
- BooleanFunction[fun] 将布尔纯函数 fun 转换为布尔函数对象.
- BooleanFunction[spec][a1,a2,…] 给出等价于明确的布尔表达式 BooleanFunction[spec,{a1,a2,…}] 的一个隐式表示.
- BooleanConvert 将 BooleanFunction[spec][vars] 转换为一个明确的布尔表达式.
- 在 BooleanFunction[values] 等函数中,变量值可以用 True、 False 或 1、0 来指定.
- BooleanFunction 表示的函数恒返回 True 或 False.
- 在 BooleanFunction[values] 中,变量值按二进制顺序指定,从 111, … 开始.
- BooleanFunction[k,n] 等价于 BooleanFunction[IntegerDigits[k,2,2^n]].
- 在 BooleanFunction[values] 中,每个值可以是列表,表示向量值的布尔函数.
- 在 BooleanFunction[{{i11,i12,…}->o1,…}] 中, oi 可以是列表,表示向量值的布尔函数.
- 输入和输出的元素可以用 True、 False 或 1、0 来指定.
- 输入和输出的元素也可以包含任意数量的 _,表示“不介意”.
- 它们也可以包含一个 __,表示一系列“不介意”.
- 在 BooleanFunction[spec,{a1,a2,…},form] 中,为 BooleanConvert 给出可能的形式.
- BooleanFunction[spec,{a1,a2,…}] 缺省下按析取范式给出一个表达式.
- BooleanFunction[k] 给出第 k
个 n 元布尔函数,其中 n 是满足
的最小值. - 在 BooleanFunction[k,…] 中,布尔函数的编号与CellularAutomaton 一致.
- BooleanFunction[CellularAutomaton[n]] 等价于 BooleanFunction[n,3].
- BooleanFunction[CellularAutomaton[{n,2,r}]] 等价于 BooleanFunction[n,2r+1].
- 类似 BooleanMinimize, BooleanTable 等操作可以直接作用在 BooleanFunction 对象上.
- BooleanFunction 对象可以像其它布尔函数 And、Or 等一样作用于变量上.
- 在 StandardForm 和相关格式中,BooleanFunction 对象以编辑形式输出,仅显示变量数量.
- BooleanVariables 给出一个 BooleanFunction 对象的变量数量.
范例
打开所有单元 关闭所有单元基本范例 (4)
f = BooleanFunction[30, 3]f[True, False, True]BooleanConvert[f[x, y, z], "DNF"]BooleanFunction[30, {x, y, z}]BooleanFunction[{{False, False} -> True, {False, True} -> False, {True, False} -> True, {True, True} -> True}, {x, y}]BooleanFunction[{{True, True, False} -> True, {False, __} -> False}, {x, y, z}]将一个布尔表达式转换为一个 BooleanFunction:
f = BooleanConvert[Xor[x, y, z], "BooleanFunction"]BooleanTable[{f, Xor[x, y, z]}, {x, y, z}]将布尔纯函数转换为 BooleanFunction 对象:
BooleanFunction[#1 && #2 || #3&]BooleanFunction[BooleanCountingFunction[3, 5]]范围 (15)
基本用法 (3)
创建一个二元 BooleanFunction,并指针索引:
f = BooleanFunction[11, 2]f[False, True]f[x, y]BooleanFunction 可以和其它任何布尔运算符一样使用:
FindInstance[f[x, y], {x, y}, Booleans]RegionPlot[f[x ^ 2 + y < 1, x - y ^ 2 > 0], {x, -2, 2}, {y, -2, 2}]Integrate[Boole[f[x ^ 2 + y < 1, x - y ^ 2 > 0]], {x, 0, 2}, {y, 0, 2}]Reduce[f[x + y < 1, x + y ^ 2 > 0], {x, y}]Sum[Boole[f[x ^ 2 + y < 1, x - y ^ 2 > 0]], {x, 0, 10}, {y, 0, 10}]任何布尔表达式可以转换为一个 BooleanFunction 表达式:
BooleanConvert[x && (y || z), "BFF"]包含 BooleanFunction 表达式的组合:
BooleanConvert[f[%, w], "BFF"]等价于 True 或 False 的一个 BooleanFunction 表达式自动化简:
{g, h} = {BooleanFunction[0, 10], BooleanFunction[2 ^ 2 ^ 10 - 1, 10]}g@@Array[x, 10]h@@Array[x, 10]BooleanFunction 是一个标准表示,其相等性可以用 SameQ 测试:
g = BooleanConvert[a && b, "BFF"]h = BooleanConvert[x && y, "BFF"]Head[g] === Head[h]真值表 (7)
f1 = x && (y || z);t1 = BooleanTable[f1, {x, y, z}]创建一个等价的 BooleanFunction 表达式:
f2 = BooleanFunction[t1][x, y, z]TautologyQ[Equivalent[f1, f2]]t2 = BooleanTable[f2, {x, y, z}]t1 === t2f1 = x && (y || z);t1 = BooleanTable[{x, y, z} -> f1, {x, y, z}]创建相应的 BooleanFunction 表达式:
f2 = BooleanFunction[t1][x, y, z]f3 = BooleanFunction[Reverse[t1]][x, y, z]TautologyQ[Equivalent[f1, f2, f3]]t1 = {False, _, _, True};创建一个 BooleanFunction:
f1 = BooleanFunction[t1][x, y]t2 = BooleanTable[f1, {x, y}]MatchQ[t2, t1]r1 = {{True, True, _} -> True, {__} -> False};创建一个 BooleanFunction:
f1 = BooleanFunction[r1][x, y, z]r2 = BooleanTable[{x, y, z} -> f1, {x, y, z}]Replace[Tuples[{True, False}, 3], r1, {1}]Replace[Tuples[{True, False}, 3], r2, {1}]t1 = {{True, False}, {__}, {_, False}, {False, True}};创建一个 BooleanFunction:
f1 = BooleanFunction[t1][x, y]t2 = BooleanTable[f1, {x, y}]MatchQ[t2, t1]r1 = {{True, True, False} -> {False, True}, {False, __} -> {True, False}};创建一个 BooleanFunction:
f1 = BooleanFunction[r1][x, y, z]r2 = BooleanTable[{x, y, z} -> f1, {x, y, z}]t1 = Replace[Tuples[{True, False}, 3], Append[r1, _ -> _], {1}]t2 = Replace[Tuples[{True, False}, 3], r2, {1}]MatchQ[t2, t1]真值表也可以用 0 替代 False,用 1 替代 True:
t1 = RandomInteger[{0, 1}, 8]f = BooleanFunction[t1][x, y, z]t2 = Boole@BooleanTable[f, {x, y, z}]t1 === t2其它表示 (5)
将任意布尔表达式转换为一个 BooleanFunction 表达式:
f1 = Nand[Nor[x, y], Xor[y, z]];f2 = BooleanConvert[f1, "BFF"]TautologyQ[Equivalent[f1, f2]]以指定的标准形式构建 BooleanFunction 表达式:
f = BooleanFunction[123, {x, y, z}, "DNF"]f = BooleanFunction[123, {x, y, z}, "CNF"]f = BooleanFunction[123, {x, y, z}, "ANF"]f = BooleanFunction[123, {x, y, z}, "NAND"]f = BooleanFunction[123, {x, y, z}, "NOR"]f = BooleanFunction[123, {x, y, z}, "Implies"]f1 = BooleanMinterms[{1, 4, 7}, 3][x, BooleanFunction[110, 3][x, y, z], BooleanCountingFunction[{3, 5}, 5][x, y, x, y, z]]f2 = BooleanConvert[f1, "BFF"]TautologyQ[Equivalent[f1, f2]]将一个 BooleanFunction 表达式转换为其它标准形式:
f = BooleanFunction[123, 3][x, y, z]BooleanConvert[f, "DNF"]BooleanConvert[f, "CNF"]BooleanConvert[f, "ANF"]BooleanConvert[f, "NAND"]BooleanConvert[f, "NOR"]BooleanConvert[f, "Implies"]BooleanTable[f, {x, y, z}]BooleanTable[{x, y, z} -> f, {x, y, z}]使用 CellularAutomaton 指定 BooleanFunction:
BooleanFunction[CellularAutomaton[77]]% === BooleanFunction[77, 3]BooleanFunction[CellularAutomaton[{123, 2, 7 / 2}]]% === BooleanFunction[123, 2 7 / 2 + 1]应用 (4)
列举布尔函数 (2)
Table[ArrayPlot[BooleanTable[BooleanFunction[i, 2][x, y], {x}, {y}], ColorRules -> {False -> White, True -> Black}, ImageSize -> 15, PlotLabel -> Style[i, Small]], {i, 0, 15}]Table[ArrayPlot[BooleanTable[BooleanFunction[i, 3][x, y, z], {x}, {y, z}], ColorRules -> {False -> White, True -> Black}, ImageSize -> 25, PlotLabel -> Style[i, Small]], {i, 0, 255}]Table[ArrayPlot[BooleanTable[BooleanFunction[i, 4][x, y, z, w], {x, y}, {z, w}], ColorRules -> {False -> White, True -> Black}, ImageSize -> 30, PlotLabel -> Style[i, Small]], {i, RandomInteger[{0, 2 ^ 2 ^ 4 - 1}, 50]}]size[h_] := If[Head[h] === Or, Length[h], 1]Tally@Table[size@BooleanFunction[i, {x, y, z}], {i, 0, 2 ^ 2 ^ 3 - 1}]Tally@Table[size@BooleanMinimize[BooleanFunction[i, {x, y, z}]], {i, 0, 2 ^ 2 ^ 3 - 1}]ListLinePlot[{%%, %}]Tally@Table[size@BooleanFunction[i, {x, y, z, w}], {i, 0, 1000}]Tally@Table[size@BooleanMinimize[BooleanFunction[i, {x, y, z, w}]], {i, 0, 1000}]ListLinePlot[{%%, %}]创建新指令 (1)
BooleanLessEqual = BooleanFunction[{{0, 0} -> 1, {0, 1} -> 1, {1, 0} -> 0, {1, 1} -> 1}];BooleanGreaterEqual = BooleanFunction[{{0, 0} -> 1, {0, 1} -> 0, {1, 0} -> 1, {1, 1} -> 1}];BooleanLess = BooleanFunction[{{0, 0} -> 0, {0, 1} -> 1, {1, 0} -> 0, {1, 1} -> 0}];BooleanGreater = BooleanFunction[{{0, 0} -> 0, {0, 1} -> 0, {1, 0} -> 1, {1, 1} -> 0}];TautologyQ[Equivalent[Not[BooleanLessEqual[x, y]], BooleanGreater[x, y]]]TautologyQ[Equivalent[Not[BooleanGreaterEqual[x, y]], BooleanLess[x, y]]]Implies 等价于 x<=y:
TautologyQ[Equivalent[BooleanLessEqual[x, y], Implies[x, y]]]定义布尔函数 f≼g 在当且仅当
f[u]≤g[u] 时的联系:
Conjunction[BooleanLessEqual[x, x∨y], {x, y}]BooleanTable[{x, x∨y}, {x, y}]BooleanLessEqual@@@%Boole@BooleanTable[{x, x∨y}, {x, y}]LessEqual@@@%Conjunction[BooleanLessEqual[f∧g, f], {f, g}]Conjunction[BooleanLessEqual[f, f∨g], {f, g}]TautologyQ[Equivalent[BooleanLessEqual[f, g], Equivalent[f∧g, f]]]TautologyQ[Equivalent[BooleanLessEqual[f, g], Equivalent[f∨g, g]]]TautologyQ[Implies[BooleanLessEqual[f, g]∧BooleanLessEqual[g, h], BooleanLessEqual[f, h]]]元胞自动机 (1)
属性和关系 (7)
以可编辑形式显示 BooleanFunction,它指示参数的数量:
f = BooleanFunction[30, 3]{AtomQ[f], Length[f]}InputForm 给出一个编码,可以用于重构对象:
InputForm[f]用编码构建一个 BooleanFunction:
g = BooleanFunction["BDD" -> {-3, 0, 2, -2, 1, 1, 3, 2, 1, -1}]f === gBooleanFunction 值的次数和 BooleanTable 相同:
t1 = BooleanTable[Xor[x, y], {x, y}]对应的 BooleanFunction 有一个相等的真值表:
f = BooleanFunction[t1]BooleanTable[f[x, y], {x, y}]次序是与 Tuples 一致:
f@@@Tuples[{True, False}, 2]BooleanFunction 的指针与 IntegerDigits 一致:
With[{m = 1234, k = 5}, BooleanFunction[m, k] === BooleanFunction[IntegerDigits[m, 2, 2 ^ k]]]从一个 BooleanFunction 到它的指针的转换:
f = BooleanFunction[1234, 5]FromDigits[Boole@BooleanTable[f], 2]FromDigits[Boole@BooleanTable[Xor[x, y, x || z], {x, y, z}], 2]显示它等价于有指针的 BooleanFunction 表达式:
TautologyQ[Equivalent[BooleanFunction[%, 3][x, y, z], Xor[x, y, x || z]]]CellularAutomaton[30, #][[2]]& /@ Tuples[{1, 0}, 3]Boole@BooleanTable[BooleanFunction[30, 3]]更一般地,对于带有整数
和
的 CellularAutomaton[{k,2,r}],关系如下:
With[{k = 123, r = 5 / 2}, CellularAutomaton[{k, 2, r}, #][[Ceiling[r] + 1]]& /@ Tuples[{1, 0}, 2r + 1] === Boole@BooleanTable[BooleanFunction[k, 2r + 1]]]CellularAutomaton 满足之前的属性,可以指定 BooleanFunction:
BooleanFunction[CellularAutomaton[30]] === BooleanFunction[30, 3]BooleanFunction[CellularAutomaton[{123, 2, 5 / 2}]] === BooleanFunction[123, 6]BooleanMinterms 也可以表示任何 BooleanFunction:
f1 = BooleanMinterms[{1, 5, 7}, 3]f2 = BooleanFunction[FromDigits[{1, 0, 1, 0, 0, 0, 1, 0}, 2], 3]f1 === f2mindex[l_, k_] := FromDigits[Table[If[MemberQ[l, i], 1, 0], {i, 2 ^ k - 1, 0, -1}], 2]mindex[{1, 5, 7}, 3]indmin[m_, k_] := Flatten@Position[Reverse[IntegerDigits[m, 2, 2 ^ k]], 1] - 1indmin[162, 3]With[{m = 123, k = 4}, BooleanMinterms[Select[Range[0, 2^k - 1], BitAnd[2^#, m] ≠ 0&], k] === BooleanFunction[m, k]]用 BooleanConvert 转换 BooleanFunction 到其它形式:
f1 = Xor[x, y && z];f2 = BooleanConvert[f1, "BFF"]也可以用 BooleanConvert 从 BooleanFunction 转换到其它形式:
f3 = BooleanConvert[f2, "NAND"]TautologyQ[Equivalent[f1, f2, f3]]用 BooleanTable 将 BooleanFunction 转换到真值表:
f = BooleanFunction[23, 3]BooleanTable[f]BooleanTable[{x, y, z} -> f[x, y, z], {x, y, z}]文本
Wolfram Research (2008),BooleanFunction,Wolfram 语言函数,https://reference.wolfram.com/language/ref/BooleanFunction.html.
CMS
Wolfram 语言. 2008. "BooleanFunction." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/BooleanFunction.html.
APA
Wolfram 语言. (2008). BooleanFunction. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/BooleanFunction.html 年
BibTeX
@misc{reference.wolfram_2026_booleanfunction, author="Wolfram Research", title="{BooleanFunction}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/BooleanFunction.html}", note=[Accessed: 11-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_booleanfunction, organization={Wolfram Research}, title={BooleanFunction}, year={2008}, url={https://reference.wolfram.com/language/ref/BooleanFunction.html}, note=[Accessed: 11-August-2026]}