1.1 Propositional Logic 命题逻辑
【Definition】A proposition is a declarative sentence that is either true or false, but not both.
Examples(use F and T to present whether it is a proposition)
Where am I? F 带问号,不是命题
Cheer up! F 感叹号,不是命题
X+1=2 F 有可能正确有可能错误,不是命题
1+1=2 T 属于命题且命题正确
Hangzhou is the capital of China. T 属于命题但命题错误
The teacher exclaimed, “Don’t come into class late again!” T 陈述性语句,老师说了一句话xxx 讲的是一个事实 即说没说,所以也是一个命题
Propositional Logic (Calculus): the area of logic that deals with propositions
Propositional variables: small letters such as p, q, r, s …
Truth value: T (true proposition), F (false proposition)
Logical operators (Connectives): be used to form compound propositions from existing propositions
Negation operator ¬ (NOT)
Conjunction operator ∧ (AND)
Disjunction operator ∨ (OR)
Exclusive or operator ⊕ (XOR)
Conditional operator -> (IF--THEN)
Biconditional operator <-> (IF AND ONLY IF)
1. Negation (NOT)
【Definition】Let p be a proposition. The negation of p, ¬p, is the proposition “It is not the case that p.”
Example:
p: Today is Monday.
¬p: It is not the case that today is Monday. (Today is not Monday.)
The truth value of ¬p is the opposite of the truth value of p
2. Conjunction (AND)
【Definition】Let p and q be propositions. The conjunction of p and q, p q, is the proposition “p and q.”
Example:
p: Today is Monday.
q: It is raining.
p ∧ q: Today is Monday and it is raining.
3. Disjunction (OR)
【Definition】Let p and q be propositions. The disjunction of p and q, p q, is the proposition “p or q.”
Example:
p: Today is Monday .
q: It is raining.
p ∨ q: Today is Monday or it is raining.
4.Exclusive OR(XOR)
【Definition】Let p and q be propositions. The exclusive or of p and q, p q, is the proposition “p or q, but not both.”
Example:
p: Today is Monday.
q: It is raining.
p ⊕ q: Either Today is Monday or it is raining, but not both.
p q p⊕q
1 1 0
0 0 0
1 0 1
0 1 1
5.Conditional Operator (If--then)
【Definition】Let p and q be propositions. The conditional statement (implication) p q, is the proposition “if p,then q. ”
Example:
p: Today is Tuesday.
q: It is raining.
p -> q: If today is Tuesday, then it is raining.
p q p->q
1 1 1
1 0 0
0 1 1
0 0 1
上面两个很好理解,下面两个意义何在呢?
不要把→理解成退出,要用如果,那么代替 毕竟我们叫 -> 条件操作符是把?
意思是除非你证明p为真,再去证明结论的真伪 否则这个关系就是真命题
用王小波的话说,从一个错误前提出发什么都能推导出来
如果你是人,那么你不是人,这是一个假命题
如果你不是人,那么你是人,这是一个真命题
*补充一个例子吧:*
给出一个假设:只要你赢了,我就给你100块钱。此命题在什么时候为假,只有
在你赢了,我没给钱的时候为假。而,当你赢了,我又给你钱的时候为真,或者
当你输了的时候,无论给不给你钱都为真。因为给的假设前提只规定了你赢的情
况,而没有规定输的情况,所以如果你输的话,我给不给你钱,假设都为真。
不建议过分深究呐
6.Converse of Conditional Statement 逆命题
Conditional Statement: p -> q
Converse: q -> p
7.Inverse of Conditional Statement 否命题
Conditional statement: p -> q
Inverse: ¬p -> ¬q
8.Contrapositive of Conditional Statement 逆否命题
Conditional statement: p -> q
Contrapositive: ¬q -> ¬p
6,7,8不多讲
9.Biconditional Operator
【Definition】Let p and q be propositions. The biconditional statement p q, is the proposition “p if and only if (iff) q.”
Equivalent expressions:
1. p is necessary and sufficient for q
2. if p then q and conversely
p q p<->q
1 1 1
1 0 0
0 1 0
0 0 1
Both p and q must have the same truth value for p <-> q to be true.
10.Precedence of Logical Operators 优先级
¬ ∧ ∨ -> <->
非且与单双
high->low
Consistent System Specifications
【Definition】 A list of propositions is consistent if it is possible to assign truth values to the proposition variables so that each proposition is true.
Let p: “The diagnostic message is stored in the buffer”
q: “The diagnostic message is retransmitted”
p ∨ q, p→ q, ¬p
When p is false and q is true all three statements are true. So the specification is consistent.
Classification of Compound Propositions
Tautology : compound proposition that is always true 恒真
Contradiction : compound proposition that is always false. 矛盾的
Contingency: compound proposition that is neither a tautology nor a contradiction. 偶然的(不确定的
Examples:
p ∧ ¬p
p ∨¬p
p ∨¬q
predicate 断言
【Definition】A predicate (propositional function) is a statement that contains variables. Once the values of the variables are specified, the function has a truth value.
Examples
P(x)=“x>3”
Q(x,y)=“x is the best player of team y”
R(x,y,z)=“x+y=z”
Examples
Let P(x) denote the statement “x > 0.” What are the truth values of P(-3), P(0) and P(3)?
P(-3)=“-3>0” F
P0)=“0>0” F
P(3)=“3>0” T
Let Q(x, y) denote the statement “x < y.” What are the truth values of Q(4, 3) and Q(2, 7) ?
Q(4, 3) =“4 < 3” F
Q(2, 7) = “2 < 7” T
Quantifiers
1.Quantifications
—Every computer connected to the university network is functioning properly.
—Students in this class are smart.
*Universal quantification
【Definition】A universal quantification of P(x), denoted by ∀x P(x), is the statement “P(x) for all values of x in the domain. ”
*Existential quantification
【Definition】An existential quantification of P(x), denoted by x P(x), is the statement “There exists an element x in the domain such that P(x). ”
∃ : existential quantifier
Other expressions:
For some x P(x)
There is an x such that P(x)
There is at least one x such that P(x)
*Predicate logic (calculus): the area of logic that deals with predicate and quantifiers.