简化这些布尔表达式?

时间:2015-10-03 03:52:25

标签: c++ boolean-logic

我不确定我是否正确简化了这些布尔表达式:

1. (A && B) || B
2. (A || B) && A
3. !(A || B) && A
4. !(A && B) || !B

简化表达式:

1. A && B
2. A || B
3. !B && A
4. !A || !B

1 个答案:

答案 0 :(得分:3)

使用一些真值表非常容易理清

1. (A && B) || B

A B | E
0 0 | 0
0 1 | 1
1 0 | 0
1 1 | 1

Simplified: B
################
2. (A || B) && A

A B | E
0 0 | 0
0 1 | 0
1 0 | 1
1 1 | 1

Simplified: A

Algebraically:
Using our identity that we've derived from part 1:
(A || B) && A --> (A && A) || (A && B) --> A || (A && B) --> A
#################
3. !(A || B) && A

A B | E
0 0 | 0
0 1 | 0
1 0 | 0
1 1 | 0

Simplified: 0

Algebraically (via demorgans)
!(A||B)&&A --> (!A && !B)  && A --> !A && !B && A
--> (A && !A) && !B --> 0 && !B --> 0

##################
4. !(A && B) || !B
A B | E
0 0 | 1
0 1 | 1
1 0 | 1
1 1 | 0

Simplified: !A || !B

其中大多数也可以用代数方式完成,但真值表真的会让你的生活变得轻松。