逻辑推理构成了计算机科学和数学领域的基础。它们有助于建立有效或无效的数学论证。
1.命题逻辑:
命题基本上是具有真实价值的陈述性句子。真值可以是true或false,但是需要为其分配两个值中的任何一个,并且不要含糊不清。使用命题逻辑的目的是单独或组合分析陈述。
例如 :
以下语句:
- 如果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。
谓词变量可以采用的一组值称为“ Universe”或“ Domain of Discourse”或“ Predicate Domain”。
命题逻辑与谓词逻辑的区别:
|
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. |