逻辑推理构成了一个巨大的计算机科学和数学领域的基础。它们有助于建立有效或无效的数学论证。
1.命题逻辑:
命题基本上是一个具有真值的陈述句。真值可以为真,也可以为假,但需要指定两个值中的任何一个,并且不能有歧义。使用命题逻辑的目的是单独或综合分析一个陈述。
例如 :
以下陈述:
- 如果 x 是实数,则 x 2 > 0
- 你叫什么名字?
- (a+b) 2 = 100
- 这个说法是错误的。
- 这个说法是正确的。
不是命题,因为它们没有真值。他们是模棱两可的。
但以下陈述:
- (a+b) 2 = a 2 + 2ab + b 2
- 如果 x 是实数,则 x 2 >= 0
- 如果 x 是实数,则 x 2 < 0
- 太阳从东边升起。
- 太阳从西边出来。
都是命题,因为它们具有特定的真值,真或假。
处理命题的逻辑分支是命题逻辑。
2.谓词逻辑:
谓词是属性,是更好地表达句子主语的附加信息。量化谓词是一个命题,也就是说,当你给一个带有变量的谓词赋值时,它可以成为一个命题。
例如 :
在 P(x) : x>5 中,x 是主语或变量,’>5′ 是谓语。
P(7) : 7>5 是我们给变量x赋值的命题,它有一个真值,即True。
谓词的变量可以假定的一组值称为宇宙或话语域或谓词域。
命题逻辑和谓词逻辑的区别:
|
Propositional Logic |
Predicate Logic |
1 |
Propositional logic is the logic that deals with a collection of declarative statements which have a truth value, true or false. | Predicate logic is an expression consisting of variables with a specified domain. It consists of objects, relations and functions between the objects. |
2 |
It is the basic and most widely used logic. Also known as Boolean logic. | It is an extension of propositional logic covering predicates and quantification. |
3 |
A proposition has a specific truth value, either true or false. | A predicate’s truth value depends on the variables’ value. |
4 |
Scope analysis is not done in propositional logic. | Predicate logic helps analyze the scope of the subject over the predicate. There are three quantifiers : Universal Quantifier (∀) depicts for all, Existential Quantifier (∃) depicting there exists some and Uniqueness Quantifier (∃!) depicting exactly one. |
5 |
Propositions are combined with Logical Operators or Logical Connectives like Negation(¬), Disjunction(∧), Conjunction(∨), Exclusive OR(⊕), Implication(⇒), Bi-Conditional or Double Implication(⇔). | Predicate Logic adds by introducing quantifiers to the existing proposition. |
6 |
It is a more generalized representation. | It is a more specialized representation. |
7 |
It cannot deal with sets of entities. | It can deal with set of entities with the help of quantifiers. |