Chapter 1 - Logic and Proofs
离散数学的笔记对翁老师分享的前辈的笔记有所参考,所以放在前面,文章中讲的不详细的地方,大家可以去阅读学长的笔记
定义
注意
补充、解释
其他
术语对照
参考这就来了(
- conjunction 合取
- disconjunction 析取
- exclusive or 异或
- precedence 优先级
1 Propositional Logic
1.1 Proposition
A proposition is a declarative sentence that is either true or false,but not both.
- Beijing is the captial of China.
- He shouted, “Stop!”(光看这句话我们不知道真假,但是在那一刻地点那一时刻,他要么说了,要么没说,一定可以确定真假)
- x+1=2(这不是命题,因为我们无法判断真假,注意与上一个区别,上一个是我们不知道真假,但可以确定真假,譬如问一下在场的人,而这一个无法确定,因为我们不知道x的取值)
- Open the door.(祈使句,不是陈述句)
Anyway,it doesn’t matter.
Propositional Logic is the area of logic that deals with propositions.
- Propositional variables:
each represents a proposition like “Today is Friday.” - Truth value:T(if a proposition is true),F
- Logical operators(Connectives) :be used to form compound propositions from existing propositions
1.2 Logical Operators
- Negation
- Conjunction
(p和q都真才为真) - Disjunction
(p和q至少有一个为真即为真) - Exclusive OR
(p和q真值不同时为真)
1.2.1 Conditional Operator
Let
The conditional statement is false only when
Equivalent Forms
- If p,then q
- p implies q
- q if p
- q when p
- q whenever(every time that,每当,只要) p
- p is sufficient condition for q
- p only if q
(只有q为真时,p才能是真的,也就是说p can’t be true when q isn’t true,q为假时p为假(事实上,这个命题就只规定了这一件事),所以p为真q为假时这个命题为假;如果p是假的,那么q是真是假这个命题都是对的,因为这个命题只要求p是真的时,q必须是真的) - 让我们举个例子,我去上课only if我醒了,即只有我醒了,我才会去上课,但这并不说明我一定去上课了,其实就是在说我醒了是我去上课的必要条件,一定要我醒了,我才能去上课,而不是如果我醒了我就去上课(如果你因此更晕了,那就记住它或者忘掉我所说的orz)
unless (q是真的,除非p是假的,也就是p为真时q一定为真,p为假时这个命题一定正确,因为没说p是假的时对q有什么要求,而p是假的但q是真的时这个命题就是假的,因此它与implication等价)
Converse of Conditional Statement
二者不一定等价
Inverse of Conditional Statement
二者不一定等价
Contrapositive of Conditional Statement
二者等价
When two compound propositions always have the same truth value in all possible cases we call them equivalent
1.2.2 Biconditional Operator
即
p和q同时为真或同时为假时,
如果
注意一定要求是永真式,如果说:如果
例如,p:今年是2026年,q:我今天喝了水
那么在2026年,有一天我喝了水,那么那一天
如果你还是很晕,那么记住下面这点:
我们说复合命题p和复合命题q等价,只是在陈述“p和q的真值一定一样”或“
另一方面,
1.2.3 Precedence of Logical Operators
| Operator | Precedence |
|---|---|
| 1 | |
| 2 | |
| 3 |
1.3 Translation
You can access the Internet from campus only if you are a computer science major or you are not a freshman.
Let
a:”you can access the Internet from campus”
c:”you are a cs major”
f:”you are a freshman”
1.4 Consistent System Specifications
A list of propositions is consistent if it is possible to assign truth values to the proposition variables so that each proposition is true.
2 Propositional Equivalences
2.1 Classification of Compound Propositions
- Tautology:compound proposition that is always true
- Contradiction:compound proposition that is always false
- Contingency neither a tautology nor a contradiction
For example,is a tautology
2.2 Logical Equivalences
The compound propositions
Notation:
| Name | Equivalence |
|---|---|
| Identity laws | |
| Domination laws | |
| Idempotent laws(幂等律) | |
| Commutative laws | |
| Associative laws | |
| Distributive laws | |
| De Morgan’s laws | |
| Absorption laws | |
| Implication law | |
| Equivalence law |
2.3 Propositional Satisfiability
A compound proposition is satisfiable if there is an assignment of truth values to its variables that make it true.When no such assignments exist,the compound proposition is unsatisfiable.
3 Predicates and Quantifiers
3.1 Predicate
A predicate (propositional function) is a statement that contains variables.Once the values of the variables are specified,the function has a truth value.
” ”,and is false ” is the ’s best friend”
3.2 Quantifiers
Predicate Logic:the area of logic that deals with predicate and quantifiers.
3.2.1 Universal Quantification
A universal quantification of
Domain:range of the possible values of the variable x
An element for which P(x) is false is called a counterexample(反例) of
The truth value of
is false if the domain consists of all real numbers. Express the following statement as a universal quantification:
“All lions are fierce.”
Let Q(x) denote the statement “x is fierce.”
(1) Assuming that the domain is the set of all lions.
(2) Assuming that the domain is the set of all creatures.
P(x): “x is a lion.”
3.2.2 Existential Quantification
An existential quantification of P(x),denoted by
Express the following statement as an existential quantification.
“Some real numbers are rational numbers.”
Let Q(y): y is a rational number
(1) Assuming that the domain is the set of all real numbers.
(2) Assuming that the domain is the set of all complex numbers.Let R(y): y is a real number
存在唯一:
3.2.3 Quantifiers with Restricted Domains
Domain: the real numbers
It’s logically equivalent to
3.2.4 Precedence of Quantifiers
The quantifiers have higher precedence than all logical operators from propositional calculus.
3.2.5 Binding Variables
When a quantifier is used on the variable x,we say that this occurence of the variable is bound(受约束的).
A variable neither quantified nor specified with a value is said to be free.
All the variables in a propositional function must be quantified or set equal to a particular value to turn it into a proposition.
例如
(一般默认x和y的取值范围是一样的,但是约束x和y的domain其实可以不一样)
Scope of a quantifier:the part of a logical expression to which the quantifier is applied.
3.3 Logical Equivalences Involving Quantifiers
Statements involving predicates and quantifiers are logically equivalent iff they have the same truth value for every predicate substituted into these statements and for every domain of discourse used for the variables iin the expressions.
x is not occurring in A
| Equivalence | Proof |
|---|---|
| 分A为T或F两种情况证明 | |
| 上式任意或存在选一个,与变成或或者或变成与,四种情况都成立 | |
| 上式任意变成存在仍成立 | |
| 先去掉箭头,再利用第三行 | |
| 上式任意、存在互换仍成立 |
3.4 Translation
All lions are fierce.
Some lions do not drink coffee.
P(x):x is a lion
Q(x):x is fierce
R(x):x drinks coffee
Assume the domain consists of all creatures.
(1)
(2)
注意不能是
同理(1)中不能用与,那样就变成所有的生物都是狮子而且很凶狠
3.5 Nested Quantifiers
Two quantifiers are nested if one is within the scope of the other.
这里
也可以理解成
Everyone has exactly one best friend.
Domain:All people
B(x,y): “y is the best friend of x.”
注意x后的括号要一直括到最后,否则B(x,z)里的x就没被量词作用,也没赋值,就不是命题
同理y,z右侧的括号也要括到最后
也可以写成嵌套量词
过程是先遍历论域中的x,对每一个x要找到一个y满足:遍历论域中的z,
3.5.1 The Order of Quantifiers
The order of nested quantifiers matters if quantifiers are of different types.
论域:实数
存在一个x,使得对所有y,x+y=1,这是假命题
对任意y,都存在一个x使得x+y=1,这是真命题
3.5.2 Negating Nested Quantifiers
Successively apply the rules for negating statements involving a single quantifier.
这时这样理解的好处就凸显了
例如
等价于
等价于
等价于
4 Functionally Complete
A set of logical operators is called functionally complete if every compound proposition is logically equivalent to a compound proposition involving only this set of logical operators.
比如与、或、非构成的逻辑操作符集合就是functionally complete的
与非也可以(跟数逻联动了)
5 Propositional Normal Forms
Literal(字面量):
Disjunctions (conjunctions) with one or more literals as disjuncts (conjuncts) are called disjunctive (conjunctive) clauses.
例如
5.1 Normal Forms(CNF&DNF)
A conjunction with one or more disjunctive clauses is said to be in conjunctive normal form.
A disjunction with one or more conjunctive clauses is said to be in disjunctive normal form.
例如
5.2 How to Obtain Normal Forms
- 利用
和 和 去掉箭头 - 德摩根律去掉非
- 利用分配律统一符号
例 求full DNF
自己做,full DNF要化成最小项之和
如果不会了,可以尝试用数逻的那种表达做hh
5.3 Prenex Normal Form
所有量词提前,那么这个statement is in prenex normal form
没有量词的命题也是prenex normal form
方法:
- 外面的箭头去掉
- 量词德摩根律把非放到量词里面
- 重新命名变量
例如这两个变量是独立的,它们的domain可能不一样,不能写成 而应写成 

第二问利用step4最后两条,z、u、v可以随意交换,但不能把v放到x、y前面,因为
为什么step4最后两条是合理的?
例如
我们把看作
那么原式等价于
现在对于括号内的式子,我们再把看作 (因为P中没有y)
那么
所以原式等价于
即
这跟我们上面所说的如何理解嵌套量词是相符的
6 Rules of Inference
argument: 一系列proposition(称作premises),有一个conclusion
proof: 证明某个argument是valid的
valid: 如果preceding statements(propositions)都为真,那么结论是真的,我们称这样的argument是valid的
例
前提:如果今天是晴天,那么今天是周五;今天是晴天(p)
结论:今天是周五(q)
如果
事实上,这个argument确实是valid的,尽管它看上去并不对(因为它的前提事实上是假的,但我们判断时会假设前提都是真的)
argument form: 形式上的argument,也就是它的前提和结论可能并不是具体的命题,而是命题变量
如果不论命题变量取值是啥,即是什么命题,对应的具体的argument都是valid的,那么称这个argument form是valid的
也就是说argument form更偏向一种模板、规范
比如有这么一个argument form
前提是
结论是
如果
接下来我们介绍一些有用的模板(valid argument forms),不论命题变量取什么值,只要是这个形式的argument都是valid的,这些模板构成了Rules of Inference
| Rule of Inference | Name |
|---|---|
—— |
Modus ponens |
—— |
Modus tollens |
—— |
Hypothetical syllogism |
—— |
Disjunctive syllogism |
—— |
Addition |
—— |
Simplification |
—— |
Conjunction |
—— |
Resolution |
6.1 Using Rules of Inference to Build Arguments
如何证明一个argument是valid的?
假设前提是真的
利用逻辑等价和推理规则,推出结论是真的
Premises:
It is not sunny this afternoon
We will go swimming only if it is sunny
If we do not go swimming, then we will take a canoe trip
If we take a canoe trip, then we will be home by sunset
Conclusion:
We will be home by sunset
p: “It’s sunny this afternoon.”
r: “We will go swimming.”
s: “We will take a canoe trip.”
t: “We will be home by sunset.”
那么假设就是
(Premise) (Premise) (Modus tollens 1,2)
这里我们已经用了一次推理规则,我们假设前提是真的,根据推理规则,上述三步是一个有效论证,那么我们就得到是真的,这又可以作为我们证明的条件 (Premise) (Modus ponens 3,4) (Premise) (Modus ponens 5,6)
如果结论是
因为
(读者可以自己证明)
6.2 Rules of Inference for Quantified Statements
| Rule of Inference | Name |
|---|---|
—— |
Universal instantiation |
—— |
Universal generalization |
—— |
Existential instantiation |
—— |
Existential generalization |
—— |
Universal modus ponens |
错在哪?
c只对应那一个a,并不是随便取一个a都对应的c
比如G(x,y): x+y=0
我随便取一个a,确实
于是有一个c,我们知道c=-a,G(a,-a),要注意a是一个具体的值(我们所谓的任取一个a,这个a都是一个具体的值,只是我们强调它可以是任何值)也就是说这个c只对这一个a成立
但是对任意的x,G(x,-a)都对吗?取x=a+1就错了
7 Proofs
| 术语 | 译文 |
|---|---|
| axiom | 公理 |
| lemma | 引理 |
| corollary | 推论 |
| conjecture | 猜想 |
定理是怎么描述的
- Implied universal quantifiers
e.g. For all positive real numbersand , if , then - Implicit implications
e.g. “The square of an odd integer is odd.”
“For all integer, if is odd, then is odd.”
7.1 Methods of Proving Theorems
7.1.1 Direct Proofs
对于
假设前提P(c)是真的,然后证明Q(c)是真的
我的理解依然是,证明就是证明一个论证是有效论证
7.1.2 Proof by Contraposition
例 “完美数”是它所有除自己外的因数之和等于自身的数,如6=1+2+3,证明“完美数”不是素数
也就是说,对任意正整数s,如果s是完美数,那么s不是素数
这等价于证明对任意正整数s,如果s是素数,那么s不是完美数
如果s是素数,那么除去它自己的因数之和为1,而s不等于1,所以s不是完美数
我们证明了
由逻辑等价,
Q.E.D
7.1.3 Vacuous Proof
前提
这看上去和我的理解“证明就是展示一个论证是有效的的过程”有些矛盾
例 证明“对任意实数x,如果x的平方小于0,那么x大于1”
证明:
只需证明任意c,
for an arbitrary c,
爆炸原理(ex contradictione quodlibet) 矛盾推出任何命题的形式都是有效论证,即
上面好像有点复杂,其实可以不把p推q的p作为假设
任意的c,
由implication的定义,
由UG
7.1.4 Trivial Proof
如果q是真的,那么
何意味
7.1.5 Proof by Contradiction
证明
时,可以假设 ,如果得到了矛盾
即得到
也就是说我们先证明, 作为premise
证明完这个,这个又可以成为我们的premise(我们已经证明的东西可以作为premise)
这等价于
由implication的定义,证明
,其实上面证明 时也是有前提的,如数学公理等,所以也可以理解成 的形式
依旧先证明推出矛盾,通常这个矛盾就是 (与题意矛盾)
我们已经证明的东西可以作为premise,和上面一样就能得到是真的
我讲的可能有些啰嗦,因为我试图把“证明就是证明一个论证是有效的”这个理解贯彻到底,所以在解释各种证明方法到底是在干嘛。如果你已经理解了,可以不用看我写的东西。我想大多数人应该都不用看。
证明没有最大的素数
假设有最大的素数s
对于r=2×3×5×…×s
r+1要么是素数要么是合数,如果是素数,那么s不是最大的素数
如果r+1是合数,由算术基本定理,它可以分解为若干个素数的乘积,而这些素数不能是2到s的素数(nk+1不是k的倍数),所以r+1的因数应该有一个比s大的素数
我们假设
所以
7.1.6 Proofs of Equivalence
怎么证明
即证明
7.1.7 Proof by Cases
把
例 证明:如果整数n不被2整除也不被3整除,那么
- Title: Chapter 1 - Logic and Proofs
- Author: Hare Fuyukawa
- Created at : 2026-03-13 17:45:21
- Updated at : 2026-05-07 20:38:32
- Link: https://redefine.ohevan.com/Discrete-Mathematics/DM/DM-1/
- License: This work is licensed under CC BY-NC-SA 4.0.
