# language agnostic - a &&(a || b)简化成什么?

## language-agnostic boolean-logic (6)

### 重言式表

`````` | a | b | !a | a || b |  !a && (a || b)  | !a && b | [ !a && (a || b) ] <=> [!a && b]    |
|---|---|----|--------|------------------|---------|-------------------------------------|
| 0 | 0 |  1 |   0    |      0           |    0    |                   1                 |
| 0 | 1 |  1 |   1    |      1           |    1    |                   1                 |
| 1 | 0 |  0 |   1    |      0           |    0    |                   1                 |
| 1 | 1 |  0 |   1    |      0           |    0    |                   1                 |
``````

### “证明”

1. 根据分配原则 `!a && (a || b)`等价于`(!a && a) || (!a && b)` `(!a && a) || (!a && b)`
2. 按照非矛盾律 `(!a && a)`相当于`false`
3. 把它放在一起：

`!a && (a || b) <=> (!a && a) || (!a && b) <=> false || (!a && b) <=> !a && b`

``````!a&&a or !a&&b
``````

``````!a || a&&b
``````

`!a && (a || b)`可以用一个二元真值表来考虑，

``````a       b       out
true    true    false
false   true    true
false   false   false
true    false   false
``````

`````` (!a && b)
``````

`````` !(a || !b)
``````

``````!a && b
``````

``````(!a && a) || (!a && b)
``````