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

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

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

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

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

实现基于谓词逻辑的归结原理

河南城建学院

《人工智能》实验报告

实验名称:

实现基于谓词逻辑的归结原理

成绩:

____

专业班级:

 

学号:

姓名:

实 验 日 期:

2014年05月13日

实验器材:

一台装PC机。

1、实验目的

熟练掌握使用归结原理进行定理证明的过程,掌握基于谓词逻辑的归结过程中,子句变换过程、替换与合一算法、归结过程及简单归结策略等重要环节,进一步了解机器自动定理证明的实现过程。

2、实验要求

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

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

(2)替换与合一算法;

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

3、实验步骤

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

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

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

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

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

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

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

4、代码

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

#include

#include

#include

#include

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<<"------------------求子句集九步法演示-----------------------"<

system("color0A");

//orign="Q(x,y)%~(P(y)";

//orign="(@x)(P(y)>P)";

//orign="~(#x)y(x)";

//orign="~((@x)x!

b(x))";

//orign="~(x!

y)";

//orign="~(~a(b))";

stringorign,temp;

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

command6,command7,command8,command9,command10;

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

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

cin>>command;

if(command=='y'||command=='Y')

initString(orign);

else

exit(0);

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

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

cin>>command0;

if(command0=='y'||command0=='Y')

{

//del_blank(orign);//undone

cout<<"消除空格后是"<

<

}

else

exit(0);

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

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

cin>>command1;

if(command1=='y'||command1=='Y')

{

orign=del_inlclue(orign);

cout<<"消去蕴涵项后是"<

<

}

else

exit(0);

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

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

cin>>command2;

if(command2=='y'||command2=='Y')

{

do

{

temp=orign;

orign=dec_neg_rand(orign);

}while(temp!

=orign);

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

<

}

else

exit(0);

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

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

cin>>command3;

if(command3=='y'||command3=='Y')

{

orign=standard_var(orign);

cout<<"对变量进行标准化后是"<

<

}

else

exit(0);

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

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

cin>>command4;

if(command4=='y'||command4=='Y')

{

orign=del_exists(orign);

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

<

}

else

exit(0);

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

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

cin>>command5;

if(command5=='y'||command5=='Y')

{

orign=convert_to_front(orign);

cout<<"化为前束形后是"<

<

}

else

exit(0);

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

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

cin>>command6;

if(command6=='y'||command6=='Y')

{

orign=convert_to_and(orign);

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

<

}

else

exit(0);

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

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

cin>>command7;

if(command7=='y'||command7=='Y')

{

orign=del_all(orign);

cout<<"消去全称量词后是"<

<

}

else

exit(0);

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

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

cin>>command8;

if(command8=='y'||command8=='Y')

{

orign=del_and(orign);

cout<<"消去连接符号后是"<

<

}

else

exit(0);

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

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

cin>>command9;

if(command9=='y'||command9=='Y')

{

orign=change_name(orign);

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

<

}

else

exit(0);

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

cout<<"-------------------------完毕-----------------------------------"<

cout<<"(请输入Y/y)结束"<

do

{

}while('y'==getchar()||'Y'==getchar());

exit(0);

}

voidinitString(stri

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

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

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

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