人智导(十九):知识表示与自动推理(Ⅱ)

人智导(十九):知识表示与自动推理(Ⅱ)

一阶谓词逻辑推理

逻辑推理

Δ \Delta Δ:一系列句子的集合(知识库)
ℜ \Re :一系列的推理规则
一个句子 α \alpha α是句子集合 Δ \Delta Δ的一个演绎(验证),当且仅当 α \alpha α能够通过 ℜ \Re Δ \Delta Δ推导出,即 Δ    ⟹    ℜ α \Delta\implies _{\Re}\alpha Δα
一个推理程序(推理引擎):发现一个合适的推理规则应用的步骤序列,视为构建一个证明的过程。

FOL推理示例

  • 自然语言(英文)描述:
    The law says that it is a crime for an American to sell instruments to hostile nations. The country China, an enemy of America, has some LHCs(对撞机), and all of its LHCs were sold to it by Prof. Trump (President D.Trump’s uncle), who is American.
  • 推导出结论:Trump is criminal.
  • 要求
    • 一阶谓词逻辑表示这段话的描述含义
    • 展示推理规则应用的步骤序列,作为一个验证(演绎)过程
  • 一阶谓词逻辑的表示
    • it is a crime for an American to… ∀ x , y , z   A m e r i c a n ( x ) ∧ I n s ( y ) ∧ N a t i o n ( z ) ∧ H o s t i l e ( z ) ∧ S e l l ( x , z , y ) → C r i m i n a l ( x )   ( 1 ) \forall x, y, z~American(x)\wedge Ins(y)\wedge Nation(z)\wedge Hostile(z)\wedge Sell(x, z, y)\to Criminal(x)~(1) x,y,z American(x)Ins(y)Nation(z)Hostile(z)Sell(x,z,y)Criminal(x) (1)
    • China…has some LHCs ∃ O w n s ( C h i n a , x ) ∧ L H C ( x )   ( 2 ) \exists Owns(China, x)\wedge LHC(x)~(2) Owns(China,x)LHC(x) (2)
    • All of its LHCs were sold to it by Prof. Trump ∀ x   O w n s ( C h i n a , x ) ∧ L H C ( x ) → S e l l ( T r u m p , C h i n a , x )   ( 3 ) \forall x~Owns(China, x)\wedge LHC(x)\to Sell(Trump, China, x)~(3) x Owns(China,x)LHC(x)Sell(Trump,China,x) (3)
    • We also need to know that LHCs are instruments ∀ x   L H C ( x ) → I n s ( x )   ( 4 ) \forall x~LHC(x)\to Ins(x)~(4) x LHC(x)Ins(x) (4)
    • and that an enemy of America counts as “hostile” ∀ x   E n e m y ( x , A m e r i c a ) → H o s t i l e ( x )   ( 5 ) \forall x~Enemy(x, America)\to Hostile(x)~(5) x Enemy(x,America)Hostile(x) (5)
    • Trump, who is American… A m e r i c a n ( T r u m p )   ( 6 ) American(Trump)~(6) American(Trump) (6)
    • The country China… N a t i o n ( C h i n a )   ( 7 ) Nation(China)~(7) Nation(China) (7)
    • China, an enemy of America E n e m y ( C h i n a , A m e r i c a )   ( 8 ) Enemy(China, America)~(8) Enemy(China,America) (8) N a t i o n ( A m e r i c a )   ( 9 ) Nation(America)~(9) Nation(America) (9)
  • 推理:推理规则应用的过程,一步步推导出结论
    • From (2) and Existential Elimination O w n s ( C h i n a , M 1 ) ∧ L H C ( M 1 )   ( 10 ) Owns(China, M_1)\wedge LHC(M_1)~(10) Owns(China,M1)LHC(M1) (10)
    • From (10) and And-Elimination O w n s ( C h i n a , M 1 )   ( 11 ) Owns(China, M_1)~(11) Owns(China,M1) (11) L H C ( M 1 )   ( 12 ) LHC(M_1)~(12) LHC(M1) (12)
    • From (4) and Universal Elimination L H C ( M 1 ) → I n s ( M 1 )   ( 13 ) LHC(M_1)\to Ins(M_1)~(13) LHC(M1)Ins(M1) (13)
    • From (12), (13) and Modus Ponens I n s ( M 1 )   ( 14 ) Ins(M_1)~(14) Ins(M1) (14)
    • From (3) and Universal Elimination O w n s ( C h i n a , M 1 ) ∧ L H C ( M 1 ) → S e l l ( T r u m p , C h i n a , M 1 )   ( 15 ) Owns(China, M_1)\wedge LHC(M_1)\to Sell(Trump, China, M_1)~(15) Owns(China,M1)LHC(M1)Sell(Trump,China,M1) (15)
    • From (15) and (10) and Modus Ponens S e l l s ( T r u m p , C h i n a , M 1 )   ( 16 ) Sells(Trump, China, M_1)~(16) Sells(Trump,China,M1) (16)
    • From (1) and Universal Elimination A m e r i c a n ( T r u m p ) ∧ I n s ( M 1 ) ∧ N a t i o n ( C h i n a ) ∧ H o s t i l e ( C h i n a ) ∧ S e l l ( T r u m p , C h i n a , M 1 ) → C r i m i n a l ( T r u m p )   ( 17 ) American(Trump)\wedge Ins(M_1)\wedge Nation(China)\wedge Hostile(China)\wedge Sell(Trump, China, M_1)\to Criminal(Trump)~(17) American(Trump)Ins(M1)Nation(China)Hostile(China)Sell(Trump,China,M1)Criminal(Trump) (17)
    • From (5) and Universal Elimination E n e m y ( C h i n a , A m e r i c a ) → H o s t i l e ( C h i n a )   ( 18 ) Enemy(China, America)\to Hostile(China)~(18) Enemy(China,America)Hostile(China) (18)
    • From (8), (18) and Modus Ponens H o s t i l e ( C h i n a ) Hostile(China) Hostile(China)
    • From (6), (7), (14), (16), (19) and And-Introduction A m e r i c a n ( T r u m p ) ∧ I n s ( M 1 ) ∧ N a t i o n ( C h i n a ) ∧ H o s t i l e ( C h i n a ) ∧ S e l l ( T r u m p , C h i n a , M 1 )   ( 20 ) American(Trump)\wedge Ins(M_1)\wedge Nation(China)\wedge Hostile(China)\wedge Sell(Trump, China, M_1)~(20) American(Trump)Ins(M1)Nation(China)Hostile(China)Sell(Trump,China,M1) (20)
    • From (17), (20) and Modus Ponens C r i m i n a l ( T r u m p )   ( 21 ) Criminal(Trump)~(21) Criminal(Trump) (21)

推理:发现一个推导的步骤

  • 推理过程:即发现一个推导的步骤以得出结论(proof)
  • 实际上,发现solution的搜索问题
  • 示例展现的推理过程作为一个搜索问题是一个smart程序,即没有任何错误路径(步骤)情况下发现了proof
    • 初始状态:知识库(KB)中的所有句子(1-9)
    • 动作:可使用的推理规则(inference rules)
    • 目标:推出新的事实(句子)

示例中观察到的推理特征

  • 发现的推导步骤(proof)有12步(在一个smart程序中完成)
  • 知识库中的句子增加,将导致搜索的分支增加
    应用推理规则时,需不断地把KB中的句子(公理)与存在的事实(facts)进行组合与匹配
  • 全称量词消除产生大量的分支
    变量可以通过任何一个取值范围内的常量置换
  • 花费大量的时间和代价
    • 通过合取方式组合原子句子
    • 例化全称量词以匹配公理句子的前件部分
    • 使用假言推理推导出例化后的公理句子的后件部分(结论部分)
  • 难点:潜在的搜索空间组合爆炸问题:潜在有较长的路径和大量的分支
  • 机会:推理规则的应用是具有模式的
    • 合取 atomic sentences
    • 例化 universal axioms
    • 使用 Modus Ponens

泛化的假言推理规则

泛化的假言推理规则

  • 目标:更有效地发现推导的步骤
    为减小搜索空间范围,考虑仅具有一个推理规则(动作),其同时完成三个步骤(合取原子句子, 例化全称量词, 使用假言推理)
  • 泛化的假言推理规则
    作为唯一的推理规则(动作),组合了And-Introduction, Universal Elimination和Modus Ponens
    示例:
    知识库(KB)包含:
    I n s ( L H C ) Ins(LHC) Ins(LHC)
    ∀ y   O w n s ( y , L H C ) \forall y~Owns(y, LHC) y Owns(y,LHC)
    ∀ x   O w n s ( C h i n a , x ) → S e l l ( T r u m p , C h i n a , x ) \forall x~Owns(China, x)\to Sell(Trump, China, x) x Owns(China,x)Sell(Trump,China,x)
    目的:一个步骤推导出新句子 S e l l ( T r u m p , C h i n a , L H C ) Sell(Trump, China, LHC) Sell(Trump,China,LHC)
    实现的关键:发现适合的变量置换,使得蕴含式中的前件与知识库在的原子句子(事实)相一致地匹配,例子中的置换 { x / L H C , y / C h i n a } \{x/LHC, y/China\} {x/LHC,y/China}
    泛化的假言推理规则:
    p i p_i pi, p i ′ p_i' pi q q q均为原子句子
    对于所有的i,存在一个变量置换 θ \theta θ使得 S U B S T ( θ , p i ) = S U B S T ( θ , p i ′ ) SUBST(\theta, p_i)=SUBST(\theta, p_i') SUBST(θ,pi)=SUBST(θ,pi):
    p 1 ′ , p 2 ′ , … , p n ′ , ( p 1 ∧ p 2 ∧ ⋯ ∧ p n → q ) S U B S T ( θ , q ) \frac{p_1',p_2',\dots ,p_n', (p_1\wedge p_2\wedge \dots\wedge p_n\to q)}{SUBST(\theta, q)} SUBST(θ,q)p1,p2,,pn,(p1p2pnq)
    n个原子句子 p i ′ p_i' pi,和一个蕴含式(公理)
    q q q是通过 θ \theta θ置换后的结果

更有效的推理

  • 组合几个FOL推理为一个
    问题转变成了发现一个变量的置换表(substitution),使得蕴含式前件与原子句子在变量置换(例化)后能匹配
  • 实现一个合一算法(unification)
    输入两个句子,算法输出一个置换表,使得变量置换后两个句子完全一致
  • 知识库(KB)中所有句子必须以规范形式(Horn范式)表示

范式形式

  • 目的:仅考虑用一条推理规则(泛化的假言推理规则)进行推理
  • 知识库(KB)中所有的句子
    • 要么是原子句子(事实)
    • 要么是蕴含式 p 1 ∧ p 2 ∧ ⋯ ∧ p n → q p_1\wedge p_2\wedge\dots\wedge p_n\to q p1p2pnq(公理)
    • 这种表示称为Horn范式
      如何将知识库中所有句子转换成Horn范式?通过Existential Elimination和And-Elimination实现
      示例:
      ∃ x   O w n s ( C h i n a , x ) ∧ I n s ( x ) \exists x~Owns(China, x)\wedge Ins(x) x Owns(China,x)Ins(x)转换为两个Horn句子:
      O w n s ( C h i n a , L H C ) Owns(China, LHC) Owns(China,LHC), I n s ( L H C ) Ins(LHC) Ins(LHC)
      当存在量词( ∃ \exists )被消除后,全称量词( ∀ \forall )标记即可取消
      ∀ y   O w n s ( y , L H C ) \forall y~Owns(y, LHC) y Owns(y,LHC)写为范式 O w n s ( y , L H C ) Owns(y, LHC) Owns(y,LHC)

合一(unification)算法

  • 合一程序:
    输入两个原子句子p和q,合一程序返回一个置换(sunstitution)表,使得p和q在变量置换后一致
    U N I F Y ( p , q ) = θ UNIFY(p, q)=\theta UNIFY(p,q)=θ 使得 S U B S T ( θ , p ) = S U B S T ( θ , q ) SUBST(\theta, p)=SUBST(\theta, q) SUBST(θ,p)=SUBST(θ,q)
    例如:
    U n i f y ( K n o w s ( J o h n , x ) , K n o w s ( J o h n , J a n e ) ) = { x / J a n e } Unify(Knows(John, x), Knows(John, Jane))=\{x/Jane\} Unify(Knows(John,x),Knows(John,Jane))={x/Jane}
    U n i f y ( K n o w s ( J o h n , x ) , K n o w s ( y , L e o n i d ) ) = { x / L e o n i d , y / J o h n } Unify(Knows(John, x), Knows(y, Leonid))=\{x/Leonid, y/John\} Unify(Knows(John,x),Knows(y,Leonid))={x/Leonid,y/John}
  • 合一过程中变量换名是合法的: U n i f y ( K n o w s ( J o h n , x ) , K n o w ( x , E l i z a b e t h ) ) = f a i l Unify(Knows(John, x), Know(x, Elizabeth))=fail Unify(Knows(John,x),Know(x,Elizabeth))=fail 变量换名体现区分 U n i f y ( K n o w s ( J o h n , x 1 ) , K n o w s ( x 2 , E l i z a b e t h ) ) = { x 1 / E l i z a b e t h , x 2 / J o h n } Unify(Knows(John, x_1), Knows(x_2, Elizabeth))=\{x_1/Elizabeth, x_2/John\} Unify(Knows(John,x1),Knows(x2,Elizabeth))={x1/Elizabeth,x2/John}
  • 最小置换(most general unifier) U n i f y ( K n o w s ( J o h n , x ) , K n o w s ( y , z ) ) = { y / J o h n , x / z } o r   { y / J o h n , x / z , w / F r e d a } o r   { y / J o h n , x / J o h n , z / J o h n }   o r … Unify(Knows(John, x), Knows(y, z))=\{y/John, x/z\}\\ or~\{y/John, x/z, w/Freda\}\\ or~\{y/John, x/John, z/John\}~or\dots Unify(Knows(John,x),Knows(y,z))={y/John,x/z}or {y/John,x/z,w/Freda}or {y/John,x/John,z/John} or
    最小置换 { y / J o h n , x / z } \{y/John, x/z\} {y/John,x/z}是算法实现策略
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值