实现基于谓词逻辑的归结原理Word下载.docx

上传人:b****4 文档编号:13603216 上传时间:2022-10-12 格式:DOCX 页数:26 大小:76.02KB
下载 相关 举报
实现基于谓词逻辑的归结原理Word下载.docx_第1页
第1页 / 共26页
实现基于谓词逻辑的归结原理Word下载.docx_第2页
第2页 / 共26页
实现基于谓词逻辑的归结原理Word下载.docx_第3页
第3页 / 共26页
实现基于谓词逻辑的归结原理Word下载.docx_第4页
第4页 / 共26页
实现基于谓词逻辑的归结原理Word下载.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

实现基于谓词逻辑的归结原理Word下载.docx

《实现基于谓词逻辑的归结原理Word下载.docx》由会员分享,可在线阅读,更多相关《实现基于谓词逻辑的归结原理Word下载.docx(26页珍藏版)》请在冰豆网上搜索。

实现基于谓词逻辑的归结原理Word下载.docx

2、实验要求

对于任意给定的一阶谓词逻辑所描述的定理,要求实现如下过程:

(1)谓词公式到子句集变换;

(2)替换与合一算法;

(3)在某简单归结策略下的归结。

3、实验步骤

步1设计谓词公式及自居的存储结构,即内部表示。

注意对全称量词∀x和存在量词∃x可采用其他符号代替;

步2实现谓词公式到子句集变换过程;

步3实现替换与合一算法;

步4实现某简单归结策略;

步5设计输出,动态演示归结过程,可以以归结树的形式给出;

步6实现谓词逻辑中的归结过程,其中要调用替换与合一算法和归结策略。

4、代码

谓词公式到子句集变换的源代码:

#include<

iostream>

sstream>

stack>

queue>

usingnamespacestd;

//一些函数的定义

voidinitString(string&

ini);

//初始化

stringdel_inlclue(stringtemp);

//消去蕴涵符号

stringdec_neg_rand(stringtemp);

//减少否定符号的辖域

stringstandard_var(stringtemp);

//对变量标准化

stringdel_exists(stringtemp);

//消去存在量词

stringconvert_to_front(stringtemp);

//化为前束形

stringconvert_to_and(stringtemp);

//把母式化为合取范式

stringdel_all(stringtemp);

//消去全称量词

stringdel_and(stringtemp);

//消去连接符号合取%

stringchange_name(stringtemp);

//更换变量名称

//辅助函数定义

boolisAlbum(chartemp);

//是字母

stringdel_null_bracket(stringtemp);

//删除多余的括号

stringdel_blank(stringtemp);

//删除多余的空格

voidcheckLegal(stringtemp);

//检查合法性

charnumAfectChar(inttemp);

//数字显示为字符

//主函数

voidmain()

{

cout<

<

"

------------------求子句集九步法演示-----------------------"

endl;

system("

color0A"

);

//orign="

Q(x,y)%~(P(y)"

;

(@x)(P(y)>

P)"

~(#x)y(x)"

~((@x)x!

b(x))"

~(x!

y)"

~(~a(b))"

stringorign,temp;

charcommand,command0,command1,command2,command3,command4,command5,

command6,command7,command8,command9,command10;

//=============================================================================

请输入(Y/y)初始化谓词演算公式"

cin>

>

command;

if(command=='

y'

||command=='

Y'

initString(orign);

else

exit(0);

请输入(Y/y)消除空格"

command0;

if(command0=='

||command0=='

{

//del_blank(orign);

//undone

cout<

消除空格后是"

endl

<

orign<

}

//=============================================================================

请输入(Y/y)消去蕴涵项"

command1;

if(command1=='

||command1=='

orign=del_inlclue(orign);

消去蕴涵项后是"

请输入(Y/y)减少否定符号的辖域"

command2;

if(command2=='

||command2=='

do

{

temp=orign;

orign=dec_neg_rand(orign);

}while(temp!

=orign);

减少否定符号的辖域后是"

<

请输入(Y/y)对变量进行标准化"

command3;

if(command3=='

||command3=='

orign=standard_var(orign);

对变量进行标准化后是"

请输入(Y/y)消去存在量词"

command4;

if(command4=='

||command4=='

orign=del_exists(orign);

消去存在量词后是(w=g(x)是一个Skolem函数)"

请输入(Y/y)化为前束形"

command5;

if(command5=='

||command5=='

orign=convert_to_front(orign);

化为前束形后是"

请输入(Y/y)把母式化为合取方式"

command6;

if(command6=='

||command6=='

orign=convert_to_and(orign);

把母式化为合取方式后是"

请输入(Y/y)消去全称量词"

command7;

if(command7=='

||command7=='

orign=del_all(orign);

消去全称量词后是"

请输入(Y/y)消去连接符号"

command8;

if(command8=='

||command8=='

orign=del_and(orign);

消去连接符号后是"

请输入(Y/y)变量分离标准化"

command9;

if(command9=='

||command9=='

orign=change_name(orign);

变量分离标准化后是(x1,x2,x3代替变量x)"

//============================================================================

-------------------------完毕-----------------------------------"

(请输入Y/y)结束"

do

}while('

==getchar()||'

==getchar());

exit(0);

}

voidinitString(stri

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1