AI基础 L18 Quantifying Uncertainty and Reasoning with Probabilities I

Propositional Logic
• Propositional logic is declarative: pieces of syntax correspond to facts
• Propositional logic allows partial/disjunctive/negated information
(unlike most data structures and databases)
• Propositional logic is compositional:
meaning of B1,1 ∧ P1,2 is derived from meaning of B1,1 and of P1,2
• Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)
• Propositional logic has very limited expressive power (unlike natural language)
E.g., cannot say “pits cause breezes in adjacent squares” except by writing one sentence for each square

  1. 声明性:命题逻辑是声明性的,它的语法单元对应于事实。在命题逻辑中,可以表达部分信息、析取信息和否定信息,这使得它与大多数数据结构和数据库不同。

  2. 组合性:命题逻辑是组合性的,表达式B1,1 ∧ P1,2(即B1,1和P1,2的合取)的意义可以从B1,1和P1,2的意义中推导出来。

  3. 意义独立于上下文:在命题逻辑中,表达式的意义是独立于上下文的,这与自然语言不同,因为在自然语言中,表达式的意义通常依赖于上下文。

  4. 表达能力有限:命题逻辑的表达能力非常有限,无法表达复杂的关系或量化信息。例如,它不能表达“pits cause breezes in adjacent squares”这样的命题,除非为每个相邻的方格写一句陈述。

First-order Logic A.k.a. FOL, or Predicate Logic
• Whereas propositional logic assumes world contains facts, first-order logic (like
natural language) assumes the world contains
— Objects: people, houses, numbers, theories, Felipe, colours, football games, wars,
centuries . . .
— Relations: red, round, bogus, prime, multistoried . . .,
brother of, bigger than, inside, part of, has colour, occurred after, owns, comes
between, . . .
— Functions: father of, best friend, second half of, one more than, end of . . .

• Many statements involve objects and variables:
— “One plus two equals three”
Objects: one, two, three, one plus two; Relation: equals; Function: plus
— “Squares neighbouring the wumpus are smelly”
Objects: wumpus, squares; Property: smelly; Relation: neighboring
— “Evil King John ruled England in 1200”
Objects: John, England, 1200; Relation: ruled; Properties: evil, king
— “x is greater than y”
Variables: x, y; Relation: greater than

一阶逻辑(First-order Logic,FOL)是一种形式逻辑系统,它允许我们表达关于对象、关系和函数的陈述。与命题逻辑相比,一阶逻辑更接近自然语言,因为它可以处理更复杂的概念和关系。以下是关于一阶逻辑的一些关键点:

  1. 对象(Objects):一阶逻辑假设世界包含各种对象,如人、房子、数字、理论、颜色、足球比赛、战争、世纪等。

  2. 关系(Relations):一阶逻辑可以表达对象之间的关系,如红色、圆形、伪造的、素数、多层建筑等属性关系,以及兄弟、大于、在内部、是部分、有颜色、发生在之后、拥有、位于之间等关系。

  3. 函数(Functions):一阶逻辑可以表达对象之间的函数关系,如父亲、最好的朋友、一半、比…多一个、…的末尾等。

例如,在一阶逻辑中,我们可以表达以下陈述:

  • 存在一个对象x,它是红色的。
  • 存在一个对象y,它是圆形的。
  • 存在一个对象z,它是素数。
  • x是y的父亲。
  • z大于y。

Syntax of FOL: Basic elements
1 First Order Logic
• Constants: KingJohn, 2, CMU, . . .
• Predicates: Brother, >, . . .
• Functions: Sqrt, LeftLegOf, . . .
• Variables: x, y, a, b, . . .
• Connectives: ∧, ∨, ¬, ⇒, ⇔
• Equality: =
• Quantifiers: ∀ ∃

想要理解一阶逻辑 要从谓语和量词入手

Predicates 谓语

• In predicate logic, we use predicate symbols P, Q, R . . . to represent predicates
• Thus, we can use P (x) to denote the statement that “the x is smelly”, and Q(x, y) to
denote that “x ruled y”
• In this example, and our understanding of the world, we know that
P (W umpus) is true and Q(F elipe, E ng land) is false

• When we assign specific values to its variables, a predicate has a truth-value, exactly
like a proposition in propositional logic
• We say that P (x) is the value of the propositional function P for x
• The number of arguments associated to a predicate symbol is its arity
• In formula R(t1, t2, . . . , tn) we say that R is an n-arity predicate

在谓词逻辑中,我们使用谓词符号 P, Q, R 等来代表谓词。谓词是一种表达属性或关系的表达式,它可以应用于对象或变量。例如,我们可以使用 P(x) 来表示“x 是臭的”这个陈述,使用 Q(x, y) 来表示“x 统治 y”这个陈述。

谓词逻辑中的谓词表达式可以看作是命题函数,当我们将具体的值分配给它的变量时,谓词表达式就有了一个真值,这与命题逻辑中的命题类似。例如,如果我们说 P(Felipe) 是真的,这意味着 Felipe 是臭的。

谓词符号后面的变量列表的数量被称为谓词的arity(基数),它表示谓词有多少个参数。例如,在公式 R(t1, t2, …, tn) 中,R 是一个 n-arity 谓词,因为它有 n 个参数。

Truth in first-order logic
• Sentences are true with respect to a model and an interpretation
• Model contains ≥ 1 objects (domain elements) and relations among them
• Interpretation specifies referents for
constant symbols → objects
predicate symbols → relations
function symbols → functional relations
• An atomic sentence predicate(term1, . . . , termn) is true
iff the objects referred to by term1, . . . , termn
are in the relation referred to by predicate

在第一阶逻辑(First-order Logic,FOL)中,真值与模型(model)和解释(interpretation)有关。模型包含至少一个对象(domain elements)和它们之间的关系,而解释则指定了常量符号、谓词符号和函数符号的指称。

  1. 模型(Model):模型是对现实世界的一个抽象或简化表示。它包含对象,这些对象可以是有形的(如人、物体)或无形的(如概念、理论),以及对象之间的关系。模型可以用来模拟和分析现实世界的各种情况。

  2. 解释(Interpretation):解释是对模型中的符号和表达式的具体指称。对于第一阶逻辑,解释通常包括:

    • 常量符号:指代模型中的特定对象。
    • 谓词符号:指代模型中的关系。
    • 函数符号:指代模型中的函数关系。
  3. 原子句子(Atomic Sentence):原子句子是谓词逻辑中最简单的句子,它由一个谓词和一个或多个术语组成。原子句子的真值取决于其术语所指的对象是否满足该谓词所表示的关系。

例如,如果模型中有一个对象 Felipe 和一个对象 England,并且 Felipe 确实统治过 England,那么原子句子 “Felipe ruled England” 在该模型和解释下是真的。

Models for FOL: Lots!
• Entailment in propositional logic can be computed by enumerating models
• We can enumerate the FOL models for a given KB vocabulary:
1. For each number of domain elements n from 1 to ∞
        2. For each k-ary predicate Pk in the vocabulary
                3. For each possible k-ary relation on n objects
                        4. For each constant symbol C in the vocabulary
                                5. For each choice of referent for C from n objects . . .
• Computing entailment by enumerating FOL models is not easy!

通过这个过程,我们可以构建出所有可能的模型,并检查给定的 KB 是否在这些模型中都是一致的。如果 KB 在所有可能的模型中都是一致的,那么我们可以说 KB 是无矛盾的。如果 KB 在某个模型中是一致的,而在另一个模型中不一致,那么我们可以说 KB 是矛盾的。

Unification
• Process by which we can substitute variables in two FOL sentences to make them syntactically identical

  1. 对于第一个例子,我们可以看到 “Knows(John, x)” 和 “Knows(John, Jane)” 中的变量 x 和 Jane 分别对应。因此,我们可以通过将 x 替换为 Jane 来统一这两个公式。
  2. 对于第二个例子,我们可以看到 “Knows(John, x)” 和 “Knows(y, Bill)” 中的变量 x 和 y 分别对应,同时 x 和 Bill 也分别对应。因此,我们可以通过将 x 替换为 Bill,y 替换为 John 来统一这两个公式。
  3. 对于第三个例子,我们可以看到 “Knows(John, x)” 和 “Knows(y, Mother(y))” 中的变量 x 和 y 分别对应,同时 x 和 Mother(John) 也分别对应。因此,我们可以通过将 y 替换为 John,x 替换为 Mother(John) 来统一这两个公式。
  4. 对于第四个例子,我们无法找到一个有效的替换方案来统一 “Knows(John, x)” 和 “Knows(x, Elizabeth)” 这两个公式,因为它们中的变量 x 在两个公式中的角色不同。因此,这个过程失败。

    在第一个公式 “Knows(John, x)” 中,变量 x 是一个参数,它被用作函数 Knows 的第一个参数,表示 John 知道的人。在这个公式中,x 被认为是 Knows 函数的第一个参数。

    在第二个公式 “Knows(x, Elizabeth)” 中,变量 x 同样是一个参数,但它被用作函数 Knows 的第二个参数,表示 Elizabeth 知道的人。在这个公式中,x 被认为是 Knows 函数的第二个参数。

    由于这两个公式中的变量 x 在不同的函数 Knows 中扮演不同的参数角色,因此它们的角色是不同的。在逻辑上,这被认为是一个不同的指称,因此无法通过简单的替换来统一这两个公式。换句话说,第一个公式中的 x 指的是 John 知道的人,而第二个公式中的 x 指的是 Elizabeth 知道的人,这两个概念在逻辑上是不等价的。

Generalized Modus Ponens (GMP)

• GMP used with KB of definite clauses (exactly one positive literal)
• All variables assumed universally quantified

如果前提是 P → Q(如果 P,则 Q)并且我们知道 P 是真的,那么我们可以得出结论 Q 是真的。

  1. 前提(Premises)

    • ∀x(King(x) ∧ Greedy(x) ⇒ Evil(x)):对于所有的 x,如果 x 是国王并且是贪婪的,那么 x 是邪恶的。
    • King(John):约翰是国王。
    • ∀y Greedy(y):对于所有的 y,y 是贪婪的。
  2. 目标(Goal)

    • q:John 是邪恶的。
  3. 推理过程

    • 首先,我们注意到 King(John) 是第一个前提中 King(x) 的实例,而 ∀y Greedy(y) 是第二个前提中 Greedy(x) 的实例。
    • 因此,我们可以使用 GMP 规则,将 King(John) 和 ∀y Greedy(y) 作为前提,得出结论 q:John 是邪恶的。

Example knowledge base
The law says that it is a crime for an American to sell weapons to hostile nations. The
country Nono, an enemy of America, has some missiles, and all of its missiles were sold to
it by Colonel West, who is American.
Can we prove that Col. West is a criminal?

Formalisation

• . . . it is a crime for an American to sell weapons to hostile nations:
American(x) ∧ W eapon(y) ∧ S ells(x, y , z) ∧ H ostile(z) ⇒ C riminal(x)
• Nono . . . has some missiles, i.e., ∃xOwns(Nono, x) ∧ Missile(x):
Owns(Nono, M1) and Missile(M1)

• . . . all of its missiles were sold to it by Colonel West
∀x(M issile(x) ∧ Owns(Nono, x) ⇒ Sells(West, x, Nono))

• Missiles are weapons:
Missile(x) ⇒ Weapon(x)

• An enemy of America counts as “hostile”:
Enemy(x, America) ⇒ Hostile(x)
• West, who is American . . .
American(West)

• The country Nono, an enemy of America . . .
Enemy(Nono, America)

Foward Chaining Proof

Properties of Forward Chaining
• Sound and complete for first-order definite clauses
(proof similar to propositional proof)
• Datalog = first-order definite clauses + no functions (e.g., crime KB)
FC terminates for Datalog in poly iterations: at most p · nk literals
• May not terminate in general if α is not entailed
This is unavoidable: entailment with definite clauses is semidecidable

  1. 对于一阶确定子句的可靠性和完备性

    • 可靠性(Soundness):如果一个结论可以从前向链推理中得出,那么这个结论在逻辑上是正确的。
    • 完备性(Completeness):如果一个结论在逻辑上是正确的,那么它可以通过前向链推理得出。

    对于一阶确定子句,前向链推理是可靠且完备的,其证明过程类似于命题逻辑的证明过程。

  2. Datalog 与一阶确定子句的关系

    • Datalog:是一种特定的逻辑编程语言,它包含了一阶确定子句,并且不允许使用函数(Function)。
    • 犯罪知识库示例:如果一个知识库只包含一阶确定子句和事实,那么这个知识库可以被看作是 Datalog。
  3. Datalog 的前向链推理的终止性

    • 终止性(Termination):对于 Datalog,前向链推理在多项式迭代内终止,最多 p · n^k 个文字。
    • 示例:其中 p 是规则的平均长度,n 是域中对象的数量,k 是规则的平均前件数量。
  4. 在一般情况下的非终止性

    • 非终止性(Non-termination):如果一个结论(α)没有被前向链推理所蕴含,那么前向链推理可能不会终止。
    • 不可避免性:对于一阶确定子句的蕴含性,它是半可判定的,这意味着在一般情况下,我们无法保证前向链推理一定会终止。

Backward Chaining Example



Properties of Backward Chaining
• Depth-first recursive proof search: space is linear in size of proof
Incomplete due to infinite loops ⇒ fix by checking current goal against every goal on stack
• Inefficient due to repeated subgoals (both success and failure)
⇒ fix using caching of previous results (extra space!)
• Widely used (without improvements!) for logic programming

  1. 深度优先递归证明搜索

    • 证明搜索:逆向链推理采用深度优先的递归搜索方法来寻找证明。
    • 空间复杂度:其空间复杂度与证明的大小成线性关系。
  2. 不完整性

    • 原因:逆向链推理可能会进入无限循环,因为如果当前目标不满足,它可能会重复处理相同的子目标。
    • 解决方法:为了避免无限循环,需要检查当前目标是否已经在堆栈上的某个目标中。
  3. 效率问题

    • 原因:逆向链推理可能会重复处理成功的子目标和失败的子目标,这导致效率低下。
    • 解决方法:通过缓存以前的结果来避免重复处理,但这需要额外的空间。
  4. 广泛应用

    • 应用领域:逆向链推理广泛应用于逻辑编程,尤其是在定理证明和问题求解中。





 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值