离散数学(Discrete Math)-命题逻辑
目录
逻辑命题Def:
Proposition 命题 :A proposition is a declaration that is either true or false but not both.
Truth Value 真值 :The truth value of a true (or false respectively) proposition is True (or false respectively) and denoted by T (or F respectively).
Ex:
- 太阳的英文是sun。是命题 为真命题
- 2+5=9 是命题 为假命题
- X+8=0 不是命题
- 今天天气不错哦。 不是命题
- 请递给我课本。 不是命题
Propositional Variables命题变量:Propositional Variables are variables that represent propositions,e.q: p,q,r…(小写)
propositions Caculus 命题运算 :The area of logic that deals with propositions is called propositions Caculus.
Compound Propositions 复合命题 : Compound Propositions are propositions that are formed from existing propositions using Logical Operators(逻辑算子).
Logical Operators 逻辑算子
Truth Table 真值表
logic puzzles 逻辑推理
算子运算符Def:
Negation Operator 否定运算符(横折 - )
例:
P | 非P |
0 | 1 |
1 | 0 |
Conjunction Operator 连接运算符(∧ AND)
例:
p | q | p∧q |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Disjunction Operator 或运算符 (∨ OR)
例:
p | q | p∨q |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Exclusive OR 异或 (圆里加号)
例:
p | q | P异或q |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Conditional Operator 条件运算符(→)
p→q,若p则q。
例:
p | q | P→q |
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 1 |
解释如下:若p则q,即(1,1)为真,(1,0)为假,但是若p=0,则对后面没影响,无论q为真或假,命题均为真命题。例:如果我买了一本书,那么晚饭我就会炒面。可是我没买书,那晚上炒不炒面就不依赖前面条件了,即无法通过p推出q,所以认为它是真命题。
p→q 等价于 非q→非q
Biconditional Operator 双条件运算符(<->)
p<->q 代表 (p→q)∧(q→p) 当且仅当
例:
p | Q | P→q | q→p | p<->q |
0 | 0 | 1 | 1 | 1 |
0 | 1 | 1 | 0 | 0 |
1 | 0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 | 1 |
运算优先级
not > and > or > → > <->
位运算
Bitwise OR
Bitwise AND
Bitwise XOR
事件Def:
A compound proposition is always true (or false resp) is called a tautology赘述 (or contradiction矛盾 ,resp),neither of them is contingency偶然事件.
Logical Eequivalence 逻辑等价 : The two compound proposition p and q are called logical equivalence , if p<->q is a tautology ,and is denoted as p≡q.
运算定律
结合律Associative laws | (p∧q)∧r ≡p∧(q∧r) |
交换律Commtative laws | P∧q ≡ q∧p p∨q ≡ q∨p |
分配律Distributive laws | 两者能相互分配 |
恒等率 Identity laws | p∧T ≡ p p∨F ≡ p |
支配律/零律 Domination laws | p∨T ≡ T p∧F ≡ F |
等幂律 Idempotent laws | p∧T ≡ p p∨p ≡ p |
对合律 Double negation | 非非p ≡ p |
德摩根律 De Morgan laws | 类似于分配率 非(p∧q) ≡ 非p∨非q 非(p∨q) ≡ 非p∧非q |
吸收律 Absorption laws | p∨(p∧q) ≡ p p∧(p∨q) ≡ p |
蕴含律 Conditional statement | p→q ≡ 非p∨q (即只有10时为0) |
逆反律Conditional statement | p→q ≡ 非q→非p |
输出律 | (p∧q) →r ≡ p→q →r |
归谬律 | (p→q) ∧(p→非q) ≡ 非p |
代数运算
方法一:真值表
方法二:推演法·定律运用