Propositional Logic
Truth tables for connectives
P | Q | P | PQ | PQ | PQ | PQ |
---|---|---|---|---|---|---|
F | F | T | F | F | T | T |
F | T | T | F | T | T | F |
T | F | F | F | T | F | F |
T | T | F | T | T | T | T |
Inference Rule
推理: 两个model为true的时候一定能推出下面的为true:
e.g. 请推导出
- to prove , consider use contradiction by shown is unsatisfiable
- expand and to CNF
- use Inference rule:
Horn Logic
首先将所有的Knowledge Base转写成的格式()
Forward chain
所需要的前提()的个数作为需要证实的数量.
如果的证明有两条路线, 那么这两条路线需要的证据是分开计算的.
只要有一条路线的证据数量被满足(为True), 那么认为也为True
initial:
step 1:
step 2:
step 3:
step 4:
step 5:
Then, we can obtain the final by knowledge base
Backward chain
找到需要证明的内容, 然后找如果要证明这个命题需要证明哪些
不断回溯, 知道找到已证明(true)的内容
First-Order Logic
Pros of Propositional Logic:
- 比较简单
- 支持命题操作比较多
- 可以将简单的逻辑组合, 推导出新的知识
- 上下文无关 context-independent Cons of Propositional Logic:
- 很难表述一个单独的单词
- 很难表述数字
- 很难表示关系
- Generalizations, patterns, regularities can’t easily be represented (e.g., “all triangles have 3 sides”)
一阶谓词逻辑
假设world包含:
- Object: 人, 房子, 颜色, …
- Relations: red, round, prime, bigger than, …
- Functions: father of, best friend of, …
假设了world中存在一些事实
Basic Element
Logic Symbols:
- Connectives
- Quantifiers
- Variables
- Equality
Non-Logic Symbols:
- Constants
KingJohn, 2 (numbers), ShanghaiTech, ...
- Predications
Brother, >, ...
- Functions
Sqrt, LeftLegOf, ...
Atomic Sentences: Predicate(term1, term2, ...)
or term1 = term2
Term: Constants
or Variables
or Function(term1, term2, ...)
一个原子语句Function(term1, term2, ...)
是正确的当且仅当object term1, term2, ...
是在Predicate
所描述的relation
中
Model的数量是infinity的
Inference
-
Universal Instantiation
e.g. 可以推出
-
Exists Instantiation
e.g. 可以推出
被称为Skolemization, 其中称为Skolem symbol
一般使用和配合, 一般使用和配合
Unify
第四行的表示的原因是两个sentence, 表示的变量名重复但是表示的含义不同. 因此需要标准化: 不同变量需要有不同变量名
为了Unify
和, 需要给变量赋值. 其中两种为:
- or
有一个最泛化的Unify的方式:
Horn Logic
Generalized Modus Pones(GMP
):
e.g.
, ,
- is , is
- is , is
- Therefore,
- is , is
Forward Chaining
e.g.
The US 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. Prove that Col. West is a criminal.
前向推理的性质:
- 对于一阶Horn Logic而言, FC是complete的
- 如果一阶谓词逻辑(FOL)没有function(Datalog), 那么FC在有限步数内终止
- 一般而言, 如果没有entail, 那么FC可能不会终止.
- 这是不可避免的
Backward Chaining
后向推理的性质:
- 使用DFS进行搜索. 搜索的空间占用和证明所需要的大小呈线性关系
- 通过检查当前目标和堆栈中的每个目标, 避免无限循环
- 通过缓存当前的结果, 避免重复子目标
Resolution(Inference Rule)
example
Conversion to CNF
- Eliminate biconditionals and implications
- Move inwards:
- Standardize variables: 对于每一个语句, 都需要使用不同的变量
- Skolemize: 将变量替换成一个特定的值
- Drop universal quantifierfs:
- Distribute over