# 真值表（Truth table，truth_table）

条件的真值表：每一种取值组合占一行。

## 怎么写

### truth_table(p)

**p**

一个条件。接受一个条件，真或假。

## 示例

- $\displaystyle \operatorname{truth\_table}(p \land q) = \begin{pmatrix} \operatorname{false} & \operatorname{false} & \operatorname{false} \\ \operatorname{true} & \operatorname{false} & \operatorname{false} \\ \operatorname{false} & \operatorname{true} & \operatorname{false} \\ \operatorname{true} & \operatorname{true} & \operatorname{true} \end{pmatrix}$

  `truth_table(p and q)`

  在求解器中，`truth_table(p and q)` 的结果是 `[[false, false, false], [true, false, false], [false, true, false], [true, true, true]]`。

  [在求解器中打开](https://zh.hilberon.com/?q=truth_table%28p%20and%20q%29)

## 相关函数

- [unequal](https://zh.hilberon.com/library/unequal)

  两个值不同时为真：!= 的函数形式。
- [satisfiability_instances](https://zh.hilberon.com/library/satisfiability_instances)

  使条件为真的变量取值。
- [xor](https://zh.hilberon.com/library/xor)

  为真的条件个数为奇数时为真。
- [satisfiability_count](https://zh.hilberon.com/library/satisfiability_count)

  使条件为真的变量取值有多少种。
- [boolean_minimize](https://zh.hilberon.com/library/boolean_minimize)

  条件的最短等价形式。
- [nor](https://zh.hilberon.com/library/nor)

  当所有条件都为假时为真。

---
Source: https://zh.hilberon.com/library/truth_table
