混乱的命题逻辑算法命题、算法、逻辑、混乱

2023-09-11 06:14:35 作者:从小缺根筋

我不能够理解有关命题逻辑蕴涵下面的算法,从书中人工智能现代的方法。采取

一个真值表枚举算法来决定命题蕴涵。 TT代表真值表。 PL-正确的?如果一个句子一个模型中包含返回true。重新$ P $变量模型psents部分建模分配仅一些变量。函数调用扩展(磷,真实,模型)返回一个新的局部模型中P值为true。

 功能TT-限嗣继承? (KB,α)返回true或false
  输入:KB,知识基础,在​​命题逻辑的句子
           α,查询,在命题逻辑的句子

符号< ---在KB和α命题符号列表
返回TT-CHECK-ALL(KB,α,符号,[])
 

 功能TT-CHECK-ALL(KB,α,符号,模型)返回true或false
   如果是空的?(符号),然后
       如果PL-正确的?(KB,型号),然后返回PL-正确的?(α,型号)
       否则返回真

   做别的
       P&所述; --- FIRST(符号);休息< --- REST(符号)
       返回TT-CHECK-ALL(KB,α,休息,延长(P,真实,模型)和
              TT-CHECK-ALL(KB,α,休息,延长(P,假的,型号)
 
分类算法 逻辑回归

解决方案

当然,唯一 TT-限嗣继承确实是调用 TT -check-ALL 使用合适的参数,所以没有太多的告诉这里。有趣的位开始 TT-CHECK-ALL 这递归构建一个的巨大所有在知识库中的符号和查询(在模型)。

可能的分配相结合

例如, TT-CHECK-ALL(KB,一,[P,Q],[])将计算为(TT- CHECK-ALL(KB,一,[],[P = TRUE,Q =真])和TT-CHECK-ALL(KB,一,[],[P = TRUE,Q = FALSE))和(TT- CHECK-ALL(KB,一,[],[P =假,Q =真])和TT-CHECK-ALL(KB,一,[],[P =假,Q = FALSE))

TT-CHECK-ALL ,这是执行时所有的符号被赋予了模型,检查是否给定的模型,比如一个值的第一部分[P = TRUE,Q =假],与知识基础是一致的( PL-正确的?(KB,型号))。这些模型对应于真值表线,其中有一个的KB列。针对这一情况,该算法然后检查查询是否为真( PL-正确的?(查询模型))。其他所有型号,这与在首位的KB不一致的,不认为是,通过返回,这是共轭的中性元素。

在换句话说,这是一样的 PL-TRUE(KB,模型) - GT?; PL-正确的?(查询模型)

因此​​,在短期,TT-CHECK-所有的检查,对每个的模型,该模型与KB一致,查询(真或假的不同符号的每个可能的分配)计算结果为true:

的foreach型号:PL-TRUE(KB,模型) - > PL-正确的?(查询模型)

这是逻辑上等同于

不存在的模式:??PL-TRUE(KB,型号),而不是PL-TRUE(查询模型)

即,不存在模型,使得KB和的否定的查询的既可以是真实的,即KB和的否定的的查询是逻辑不一致的的。

这是完全相同的定义 KB限嗣继承查询

编辑: 关于符号。这些都是的原子的命题在词汇符号。在书中的例子的将是各种 P_i,J B_i,J ,表示无论是房间(我,J)有一个坑和/或微风。需要注意的是 R1 R5 并非符号部分,因为这些都只是速记为方便起见,重新presenting更复杂的条款。因此,通过了 KB 到算法,我们不会通过 R1和R2和R5 ... ,但(不P_1,1)和(B_1,1< =>(P_1,2或P_2,1))。然后...然后(B_2,1)

I'm not able to understand the following algorithm concerning propositional logic and entailment, taken from the book Artificial Intelligence A modern approach.

A truth-table enumeration algorithm for deciding propositional entailment. TT stands for truth table. PL-TRUE? returns true if a sentence holds within a model. The variable model represents a partial model- assignment to only some of the variables. The function call EXTEND(P, true, model) returns a new partial model in which P has the value true.

function  TT-ENTAILS? (KB,α) returns  true  or  false
  inputs: KB, the knowledge base, a sentence in propositional logic
           α, the query, a sentence in propositional logic

symbols <--- a list of the propositional symbols in KB and α
return TT-CHECK-ALL(KB,α,symbols,[])

function TT-CHECK-ALL(KB,α,symbols,model ) returns true or false
   if EMPTY?(symbols) then
       if PL-TRUE?(KB, model) then return PL-TRUE?(α,model)
       else return true

   else do
       P <---FIRST(symbols); rest <--- REST(symbols)
       return TT-CHECK-ALL(KB,α,rest,EXTEND(P,true,model) and
              TT-CHECK-ALL(KB, α, rest, EXTEND(P,false,model)

解决方案

Of course, the only thing TT-ENTAILS does is to call TT-CHECK-ALL with the proper parameters, so there is not much to tell here. The interesting bits start in the else part ofTT-CHECK-ALL which recursively constructs a huge conjunction for all the possible assignments for the symbols occurring in the knowledge base and the query (the 'models').

For example, TT-CHECK-ALL(KB, a, [P, Q], []) will evaluate to (TT-CHECK-ALL(KB, a, [], [P=true, Q=true]) and TT-CHECK-ALL(KB, a, [], [P=true, Q=false])) and (TT-CHECK-ALL(KB, a, [], [P=false, Q=true]) and TT-CHECK-ALL(KB, a, [], [P=false, Q=false]))

The first part of TT-CHECK-ALL, which is executed when all the symbols have been given a value in the model, checks whether the given model, e.g. [P=true, Q=false], is consistent with the knowledge base (PL-TRUE?(KB, model)). These models correspond to the lines in the truth table, which have a true in the KB column. For those, the algorithm then checks whether the query evaluates to true (PL-TRUE?(query, model)). All other models, that are inconsistent with the KB in the first place, are not considered, by returning true, which is the neutral element of conjugation.

In other words, this is the same as PL-TRUE?(KB, model) -> PL-TRUE?(query, model).

So in short, TT-CHECK-ALL checks that for each model (each possible assignment of 'true' or 'false' to the different symbols) that is consistent with the KB, the query evaluates to true:

foreach model: PL-TRUE?(KB, model) -> PL-TRUE?(query, model)

Which is logically equivalent to

not exist model: PL-TRUE?(KB, model) and not PL-TRUE?(query, model)

That is, there is no model, such that KB and the negation of the query can both be true, i.e. the KB and the negation of the query are logically inconsistent.

And this is exactly the definition of KB entails query.

Edit: About the symbols. Those are the atomic propositional symbols in the vocabulary. In the example in the book those would be the various P_i,j and B_i,j, denoting whether room (i,j) has a pit and/or a breeze. Note that R1 through R5 are not part of symbols, as those are just shorthands for convenience, representing more complex terms. Consequently, when passing the KB into the algorithm we would not pass R1 and R2 and ... R5, but (not P_1,1) and (B_1,1 <=> (P_1,2 or P_2,1)) and ... and (B_2,1).