离散结构:基础:逻辑和证明(Discrete Structures :The Foundations: Logic and Proofs)(1)

第一章:第一部分:命题逻辑(Chapter 1, Part I: Propositional Logic


章节摘要(Chapter Summary

  • 命题逻辑(Propositional Logic)

    • 命题语言(The Language of Propositions)

    • 应用(Applications)

    • 逻辑等价(Logical Equivalences)

  • 谓词逻辑(Predicate Logic)

    • 量词语言(The Language of Quantifiers)

    • 逻辑等价(Logical Equivalences)

    • 嵌套量词(Nested Quantifiers)

  • 证明(Proofs)

    • 推理规则(Rules of Inference)

    • 证明方法(Proof Methods)

    • 证明策略(Proof Strategy)


命题逻辑摘要(Propositional Logic Summary

  • 命题语言(The Language of Propositions)

    • 连接词(Connectives)

    • 真值(Truth Values)

    • 真值表(Truth Tables)

  • 应用(Applications)

    • 翻译英语句子(Translating English Sentences)

    • 布朗搜索(Boolean Searches)

    • 逻辑循环(Logic Circuits)

  • 逻辑等价(Logical Equivalences)

    • 重要等价(Important Equivalences)

    • 显示对等(Showing Equivalence)

    • 满足性(Satisfiability)


命题逻辑 1.1小节(Propositional Logic Section 1.1

  • 小节摘要(Section Summary)

    • 命题(Propositions)

    • 连接词(Connectives)

      • 否定(Negation)

      • 且(Conjunction)

      • 析取(Disjunction)

      • 可推出;对换,取逆,取反(Implication; contrapositive, inverse, converse)

      • 双条件(Biconditional)

    • 真值表(Truth Tables)


  • 命题(Propositions)

    • 命题是一个明晰的可以确定正误的句子。

    • 命题的例子:

      • a)华盛顿特区是美国首都

      • b)多伦多是加拿大首都

      • c)1 + 0 = 1

      • d)0 + 0 = 2

    • 不是命题的例子

      • A)坐下!

      • b)现在几点?

      • c)x + 1 = 2

      • d)x + y = z

  • A proposition is a declarative sentence that is either true or false.
  • Examples of propositions:
    • Washington, D.C., is the capital of the United States of America.
    • Toronto is the capital of Canada.
    • 1 + 0 = 1
    • 0 + 0 = 2
  • Examples that are not propositions.
    • Sit down!
    • What time is it?
    • x + 1 = 2
    • x + y = z

  • 命题逻辑(Propositional Logic)

    • 构建命题(Constructing Propositions)

      • 命题变量:p,q,r,s,……

      • 永远为真的命题被记为T,永远为假的命题被记为F

      • 复合命题;由逻辑连接词和其他命题构成

        • 否定(Negation) ¬

        • 且(Conjunction) ∧

        • 析取(Disjunction) ∨

        • 可推出(Implication) →

        • 双条件(Biconditional )↔

  • Constructing Propositions
    • Propositional Variables: p, q, r, s, …
    • The proposition that is always true is denoted by T and the proposition that is always false is denoted by F.
    • Compound Propositions; constructed from logical connectives and other propositions
      • Negation ¬
      • Conjunction ∧
      • Disjunction ∨
      • Implication →
      • Biconditional ↔

  • 复合命题:否定(Compound Propositions: Negation)

    • 命题p的否定由¬p表示并具有此真值表:

p

¬p 

T

F

F

T

  • 例子:如果p表示“地球是圆的”,那么¬p就是“这不是地球是圆的的情况。”,或者换句话说“地球不是圆的。”

  • Compound Propositions: Negation

    • The negation of a proposition  p  is  denoted by  ¬p  and has this truth table:
    • Example: If p   denotes “The earth is round.”, then ¬p     denotes “It is not the case that the earth is round,” or more simply “The earth is not round.”

  • 且(Conjunction)

    • p和q命题的且用p ∧q表示,并有如下的真值表:

p

q

p

T

T

T

T

F

F

F

T

F

F

F

F

  • 例子:如果p表示“我在家。”q表示“在下雨。”那么p ∧q表示“我在家而且在下雨。”

  • The conjunction of propositions  p  and  q  is denoted by p ∧ q  and has this truth table:
  • Example:  If p  denotes “I am at home.” and q  denotes “It is raining.” then p ∧q   denotes “I am at home and it is raining.”

  • 或(Disjunction)

    • 命题p和q的析取表示为p ∨ q,并有如下的真值表:

p

q 

pq

T

T

T

T

F

T

F

T

T

F

F

F

  • 例子:如果p表示“我在家”q表示“在下雨”,那么p ∨ q就表示“要不我在家,要不在下雨”

  • The disjunction of propositions  p  and q   is denoted by  p ∨q and has this truth table:
  • Example:  If p  denotes “I am at home.” and q  denotes “It is raining.” then p ∨q denotes “I am at home or it is raining.”
  • 英语中的连接或(The Connective Or in English)

    • 在英语中“或”有两种不同的意义

      • “排除或”在如下句子“汤或沙拉会配着主餐上”中,我们不指望同时吃到汤和沙拉,因为这里的意思是“排除或”。在 p⊕q中,p和q之一必须为真,但不同时为真。并有如下的真值表:

      • “包括或”在如下句子“学习过CS202或者Math120的学生才能选报这门课”,我们假设学生需要满足以上一条条件,但也可能都满足。这就是析取的意思。对于p∨ q要为真,其中任意一个或两个条件都要为真。

q

pq

T

T

F

T

F

T

F

T

T

F

F

F

    • “Inclusive Or”  - In the sentence “Students who have taken CS202 or Math120 may take this class,” we assume that students need to have taken one of the prerequisites, but may have taken both. This is the meaning of disjunction. For p ∨q  to be true, either one or both of p and q must be true.
    • “Exclusive Or”  - When reading the sentence “Soup or salad comes with this entrée,” we do not expect to be able to get both soup and salad. This is the meaning of Exclusive Or (Xor). In p ⊕ q, one of p and q must be true, but not both.  The truth table for ⊕ is:

  • 可推出(Implication)

    • 如果p和q是命题,那么p →q是一个条件陈述或者意义,读作如果p, 那么 q,并有如下的真值表:

p 

q

pq

T

T

T

T

F

F

F

T

T

F

F

T

  • 例子:如果p表示“我在家”,q表示“在下雨”那么p →q表示“如果我在家,那么就在下雨”

  • 在p→q中,p是假设(先行条件或前提)q是结论(或后果)。

  • If p  and q  are propositions, then p →q is a conditional statement or implication which is read as “if p, then q ” and has this truth table:
  • Example: If p  denotes “I am at home.” and q  denotes “It is raining.” then   p →q  denotes “If I am at home then it is raining.”
  • In p →q , p  is the hypothesis (antecedent or premise) and q  is the conclusion (or consequence).

  • 理解可推出(Understanding Implication)

    • 在p→q里,不需要前情和后果不需要有任何的联系。p →q的意义仅依赖于p和q的真值

    • 这些Implication都没有问题,但不会被用在日常的英语中。

      • “如果月亮是绿色的起司,那我就比比尔盖茨还有钱”

      • “如果月亮是绿色的起司,那我就有福利了”

      • “如果1 + 1 = 3,那么你的奶奶穿战靴”

    • 了解逻辑条件的一个方法是考虑一个义务和合同。

      • “如果我被选上,那么我会降低税率。”

      • “如果你在期末考试中拿到100%,那么你会得到A。”

    • 如果这个政客被选上了却不降低税收,那么选民就可以说他或她已经打破了竞选承诺,对教授来说也有一些相似的事。这种情况对应p为真二q为假的情况。

  • In p →q there does not need to be any connection between the antecedent or the consequent. The “meaning” of p →q depends only on the truth values of p and q.
  • These implications are perfectly fine, but would not be used in ordinary English.
    • “If the moon is made of green cheese, then I have more money than Bill Gates. ”
    • “If the moon is made of green cheese then I’m on welfare.”
    • “If 1 + 1 = 3, then your grandma wears combat boots.”
  • One way to view the logical conditional is to think of an obligation or contract.
    • “If I am elected, then I will lower taxes.”
    • “If you get 100% on the final, then you will get an A.”
  • If the politician is elected and does not lower taxes, then the voters can say that he or she has broken the campaign pledge. Something similar holds for the professor. This corresponds to the case where p is true and q is false.

  • 表示p→q的不同方法(Different Ways of Expressing p →q)

    • ifp, thenq

    • pimpliesq

    • if pq

    • ponly if q

    • qunless ¬p

    • qwhenp

    • qif

    • qwheneverp

    • pis sufficient for q

    • qfollows from p

    • qis necessary for p

    • a necessary condition for pisq

    • a sufficient condition for qisp


  • 逆命题,逆否命题否命题(Converse, Contrapositive, and Inverse

    • 从p →q我们可以得出新的条件陈述

      • q → p是p →q的逆命题

      • ¬q →¬p是p→q的逆否命题

      • ¬p ¬q是p→q的否命题

    • 例子:找到“下雨是我不去镇上的充分条件。”中的逆命题,否命题,质位变换命题,这等同于“如果在下雨,那么我就不会去镇上”

    • 解决方案:

      • 逆命题:如果我不去镇上,那么就在下雨。

      • 否命题:如果没在下雨,那么我会去镇上。

      • 质位变换命题:如果我去镇上,那么就没在下雨。

  • From p →q  we can form new conditional statements.
    • q →p            is the converse of p →q
    • ¬q → ¬ p    is the contrapositive of p →q
    • ¬ p → ¬ q     is the inverse of p →q

   Example: Find the converse, inverse, and contrapositive of “It’s raining is a sufficient condition for my not going to town.” This is equivalent to “If It’s raining, then I am not going to town.”

    Solution:

converse: If I do not go to town, then it is raining.

inverse:  If it is not raining, then I will go to town.

contrapositive: If I go to town, then it is not raining.


  • 双条件(Biconditional

    • 如果p和q是命题,那么我们可以形成双条件命题p↔q,读作“当且仅当q”双条件p↔q表示的真值表如下:

    • If p  and q  are propositions, then  we can form the biconditional proposition p ↔q , read as “p  if and only if q .” The  biconditional          p ↔q  denotes the proposition with this truth table:

p

q

pq 

T

T

T

T

F

F

F

T

F

F

F

T

  • 双条件声明p↔q当p和q有相同的真值时为真,在相反的情况下为假。Biconditional也叫bi-implications。

  • 如果p表示“我在家”,q表示“在下雨”那么p↔q表示“当且仅当下雨时我在家”

  • The biconditional statement p ↔ q is true when p and q have the same truth values, and is false otherwise. Biconditional statements are also called bi-implications.
  • If p  denotes “I am at home.” and q   denotes “It is raining.” then       p ↔q   denotes “I am at home if and only if it is raining.”

  • 表达双条件(Expressing the Biconditional

    • 一些“当且仅当q成立q才成立”的替代说法表达成英语为:

      • is necessary and sufficient for q

      • if then qand conversely

      • iff q

  • Some alternative ways “p if and only if q” is expressed in English:
    • p is necessary and sufficient for q
    •   if p then q, and conversely

  p iff q


  • 复合命题的真值表(Truth Tables For Compound Propositions

    • 真值表的结构

      • 子命题每个可能的组合都需要一行

      • 复合命题需要一列(通常在最右边)

      • 需要一列来表示复合命题中出现的每个表达式的真值。

        • 这包含了子命题

  • Construction of a truth table:
  • Rows
    • Need a row for every possible combination of values  for the  atomic propositions.
  • Columns
    • Need a column for the compound proposition (usually at far right)
    • Need a column for the truth value of each expression that occurs in the compound proposition as it is built up.
      • This includes the atomic propositions

  • 示例真值表(Example Truth Table)

    • 以p ∨ q→¬r构建真值表(Construct a truth table for p ∨ q→¬r)

p

q

r

¬r

pq

pq¬r

T

T

T

F

T

F

T

T

F

T

T

T

F

T

F

T

F

T

F

F

T

T

T

F

T

T

F

T

F

F

T

F

T

T

T

F

F

T

F

F

T

F

F

F

T

F

T


  • 当量命题(Equivalent Propositions)

    • 当两个命题总是有相同的真值,我们说这两个命题是等价的。

    • 例子:用真值表表示条件和兑换句是等价的。

    • 解决方案:

    • Two propositions are equivalent if they always have the same truth value.
    • Example: Show using a truth table that the conditional is equivalent to the contrapositive.
    •    Solution:

p

q

¬ p

¬ q

pq 

¬q¬ p 

T

T

F

F

T

T

T

F

F

T

F

F

F

T

T

F

T

T

F

F

T

T

T

T


  • 用真值表表示不等价(Using a Truth Table to Show  Non-Equivalence)

    • 例子:用真值表表示命题(implication)的反转和倒数都不等同于命题(implication)

    • 解决方案

    • Example: Show using truth tables that neither  the converse nor inverse of an implication is not equivalent to the implication.

         Solution:

p

q

¬ p

¬ q

pq 

¬ p¬ q

qp 

T

T

F

F

T

T

T

T

F

F

T

F

T

T

F

T

T

F

T

F

F

F

F

T

T

T

T

T


  • 问题(Problem)

    • 对于一个有n个命题变量的真值表,应该用多少行来表示。

      • 解决方案:2^n,我们会在第6章学习如何这样做。

    • 注意这意味着我们可以从n个命题变量中构建2^n个不同的命题

    • How many rows are there in a truth table with n propositional variables?
    •  
    • Note that this means that with n propositional variables, we can construct 2n     distinct (i.e., not equivalent) propositions.
    •     Solution:  2n We will see how to do this in Chapter 6.


  • 逻辑运算符的优先级(Precedence of Logical Operators)

Operator

Precedence

¬

1

2

3

4

5

  • p  ¬r和 (p  ∨ q)→ ¬r是等价的,如果这里是想表示p  (q → ¬r ),那就必须使用括号。

  • p  ∨q →  ¨r   is equivalent to (p  ∨q) →  ¨r

    If the intended meaning is p  ∨(q →  ¨r )

    then parentheses must be used.


  • 逻辑和位操作(Logic and Bit Operations)

    • 计算机使用位表示信息。

    • 位是具有两个可能值的符号,即0(零)和1(一)。

    • 可以使用一个位来表示真值,因为有两个真值,即真和假。

    • 按照惯例,我们将使用1位表示true,使用0位表示false。 即,1表示T(真),0表示F(假)。

    • 如果变量的值为true或false,则该变量称为布尔变量。 因此,可以使用位来表示布尔变量。

    • 计算机位操作对应于逻辑连接词。通过在运算符∧,∨和⊕的真值表中将true替换为1,将false替换为0。

    • 位串是零或更多位的序列。 该字符串的长度是字符串中的位数。

    • 例子:找到位串01 1011 0110和11 0001 1101的位按OR,按位AND和按位XOR。

  • Computers represent information using bits.
  • A bit is a symbol with two possible values, namely, 0 (zero) and 1 (one).
  • A bit can be used to represent a truth value, because there are two truth values, namely, true and false.
  • As is customarily done, we will use a 1 bit to represent true and a 0 bit to represent false. That is, 1 represents T (true), 0 represents F (false).
  • A variable is called a Boolean variable if its value is either true or false. Consequently, a Boolean variable can be represented using a bit.
  • Computer bit operations correspond to the logical connectives. By replacing true by a one and false by a zero in the truth tables for the operators ∧, ∨, and ⊕.
  • A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string.
  • Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings 01 1011 0110 and
  •    11 0001 1101.


命题逻辑的应用(Applications of Propositional Logic

  • 命题逻辑的应用汇总

    • 将英语翻译为命题逻辑

    • 布尔搜索

    • 逻辑电路

  • 翻译英语陈述(Translating English Sentences)

    • 将英语句子转换为命题逻辑中的语句的步骤

      • 识别子命题并使用命题变量表示。

      • 确定适当的逻辑连接词

    • “如果我去亨利家或去乡下,我不会去购物”

      • P:“我去亨利家”

      • Q:“我去乡下”

      • R:“我会去购物”

      • 如果p或者q那就非r

      • (p  ∨ q)→ ¬r

  • 例子

    • 问题:将以下句子翻译成命题逻辑:

      • 当且仅当你主修计算机科学或者不是新生时你才可以通过电脑连接网络。

      • 一个解决方案:设a,c和f分别代表“你能通过电脑连接到网络”,“你是主修计算机科学”,“你是新生”

      • a→(c¬f

  • 布尔搜索

    • 逻辑连接词广泛用于搜索大量信息,例如网页索引。 在布尔搜索中

Connective  

AND 

match records that contain both of two search terms

OR  

match one or both of two search terms

NOT

exclude a particular search term.

(sometimes written as AND NOT )

  • 网页搜索大多数网络搜索引擎都支持布尔搜索技术,这些技术通常可以帮助查找有关特定主题的网页。

  • 例子

    • 查找有关新墨西哥州大学的网页

    • 新 AND 墨西哥 AND 大学

  • 逻辑电路

    • 电子电路; 每个输入/输出信号可以被视为0或1。

      • 0代表假

      • 1代表真

    • 复杂电路由称为门的三个基本电路构成。

  • 反相器(非门)接收输入位并产生该位的否定。

  • 或门取两个输入位,产生的值等于两位的分离。

  • AND门占用两个输入位,并产生相当于两位结合的值。

  • 通过组合这些基本电路以通过为每个输出表达式构建电路然后组合它们来给出输入信号以产生所需输出,可以构造更复杂的数字电路。 例如:

命题等价

  • 章节汇总

    • Tautologies, Contradictions, and Contingencies. 

    • 逻辑等价

      • 重要的逻辑等价

      • 表示逻辑等价

    • 命题满足性

  • Tautologies, Contradictions, and Contingencies

    • Tautologies是指永远为真的命题

      • 例子:p¬p

    • Contradictions是指永远为假的命题

      • 例子:p∧¬p

    • Contingencies是指既不为Tautologies又不为Contradictions的命题,就像p

P

¬p

p¬p 

p¬p 

T

F

T

F

F

T

T

F

  • 逻辑等价

    • 如果p↔q是重言式,则两个复合命题p和q在逻辑上是等价的。

    • 我们将其写为p⇔q或p≡q,其中p和q是复合命题。

    • 当且仅当真值表中的列给出它们的真值时,两个复合命题p和q是等价的。

    • 该真值表显示¬p∨q等于p→q。

p

q 

¬p

¬pq

pq

T

T

F

T

T

T

F

F

F

F

F

T

T

T

T

F

F

T

T

T

  • 德摩根定律

这个真值表显示了德摩根的第二定律。

p

q

¬p

¬q

(pq)

¬(pq)

¬p¬q

T

T

F

F

T

F

F

T

F

F

T

T

F

F

F

T

T

F

T

F

F

F

F

T

T

F

T

T


  • 关键逻辑等价

  • Identity Laws:

  • Domination Laws:

  • Idempotent laws:

  • Double Negation Law:

  • Negation Laws:

  • Commutative Laws:

  • Associative Laws:

  • Distributive Laws:

  • Absorption Laws:


  • 更多逻辑等价(More Logical Equivalences)


  • 构造新的逻辑等价

    • 我们可以通过开发一系列逻辑上等价的语句来证明两个表达式在逻辑上是等价的。

    • 为了证明我们产生了一系列以A开头并以B结尾的等价。

    • ……

    • 请记住,只要命题(由命题变量表示)出现在前面列出的等价中,它就可以被任意复杂的复合命题所取代。

    • We can show that two expressions are logically equivalent by developing a series of logically equivalent statements.
    • To prove that                 we produce a series of equivalences beginning with A and ending with B.
    •  
    •  
    •  
    • Keep in mind that whenever a proposition (represented by a propositional variable) occurs in the equivalences listed earlier, it may be replaced by an arbitrarily complex compound proposition.

  • 等价的证明

    • 例子:证明和等价

    • 解决方案:

  • 例子:证明是tautology

  • 解决方案


  • 命题可满足性

    • 如果将真值赋值给它的变量使其成立,则复合命题是可以满足的。 当不存在这样的任务时,复合命题是不可满足的。

    • 当且仅当其否定是重言式时,复合命题是不可满足的。

    • 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.
    • A compound proposition is unsatisfiable if and only if its negation is a tautology.

  • 命题可满足性的问题

    • 例子:确定以下复合命题的可满足性:

    • 解决方案:满足的。 将T分配给p,q和r。

    • 解决方案:将T分配给p,将F分配给q。

    • 解决方案:不满足。 检查每个可能的真值分配到命题变量,没有一个会使命题成立。

    • Example: Determine the satisfiability of the following compound propositions:

    •  
    •    Solution: Satisfiable. Assign T to p, q, and r.

    •  
    •    Solution: Satisfiable. Assign T to p and F  to q.

    •  
    •    Solution:  Not satisfiable. Check each possible assignment of truth values to the propositional variables and none will make the proposition true.


  • 解决可满足性问题

    • 真值表总是可以用来确定复合命题的可满足性。 但即使对于大型问题的现代计算机来说,这也太复杂了。

    • 在开发解决可满足性问题的有效方法方面已经做了很多工作,因为许多实际问题可以转化为可满足性问题。

    • A truth table can always be used to determine the satisfiability of a compound proposition. But this is too complex even for modern computers for large problems.
    • There has been much work on developing efficient methods for solving satisfiability problems as many practical problems can be translated into satisfiability problems.

猜你喜欢

转载自blog.csdn.net/qq_27467365/article/details/82592356