ImageVerifierCode 换一换
格式:DOC , 页数:18 ,大小:314KB ,
资源ID:5672549      下载积分:8 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/5672549.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(人工智能(-化为子句集的九步法实验).doc)为本站上传会员【a199****6536】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

人工智能(-化为子句集的九步法实验).doc

1、 化为子句集的九步法实验报告 实验目的 1. 熟悉谓词公式化为子句集的九个步骤 2. 理解消解(谓词公式化为子句集)规则,能把任意谓词公式转换成子句集。 3. 学会谓词公式化为子句集 实验原理 任一谓词公式通过九步法可以化成一个子句集。九步法消解包括消去蕴含和等价符号、把否定符号移到紧靠谓词的位置上、变量标准化、消去存在量词、化为前束型、化为Skolem标准形、

2、略去全称量词、消去合取词,把母式用子句集表示、子句换变量标准化,依次变换即可得到子句集。 实验条件 1. Window NT/xp/7及以上的操作系统 2. 内存在512M以上 3. CPU在奔腾II以上 实验内容 熟悉谓词公式转换成子句集的步骤,子句集转换演示程序参考界面如下图1所示。 图1 子句集转换演示程序参考界面 实验分析 1. 对默认谓词公式进行转换。进入程序,点击“语法检查”,再依次点击消解过程的九个步骤按钮,得到转换结果。 2. 自定义转换目标。点击“清除”删除默认公式,利用界面键盘输入新的转换目标,用“大写字母”、“小写字母”按键进行输入中的字母变换。

3、 3. 语法检查。点击“语法检查”检查输入谓词公式的语法错误。如无错误,则依次点击步骤按钮进行转换。 4. 重复运行2、3步,熟悉消解原理和转换过程。 程序代码 //化为子句集的九步法演示 //作者:RanchoChan //时间:2010.12.15 //有bug #include #include #include #include using namespace std; //一些函数的定义 void initString(string &ini);//初始化 string del_inlc

4、lue(string temp);//消去蕴涵符号 string dec_neg_rand(string temp);//减少否定符号的辖域 string standard_var(string temp);//对变量标准化 string del_exists(string temp);//消去存在量词 string convert_to_front(string temp);//化为前束形 string convert_to_and(string temp);//把母式化为合取范式 string del_all(string temp);//消去全称量词 string del_

5、and(string temp);//消去连接符号合取% string change_name(string temp);//更换变量名称 //辅助函数定义 bool isAlbum(char temp);//是字母 string del_null_bracket(string temp);//删除多余的括号 string del_blank(string temp);//删除多余的空格 void checkLegal(string temp);//检查合法性 char numAfectChar(int temp);//数字显示为字符 //主函数 void main() {

6、 cout<<"------------------求子句集九步法演示-----------------------"<

7、d1,command2,command3,command4,command5, command6,command7,command8,command9,command10; //============================================================================= cout<<"请输入(Y/y)初始化谓词演算公式"<>command; if(command == 'y' || command == 'Y') initString(orign); else exit(0

8、); //============================================================================= cout<<"请输入(Y/y)消除空格"<>command0; if(command0 == 'y' || command0 == 'Y') { //del_blank(orign);//undone cout<<"消除空格后是"<

9、 cout<<"请输入(Y/y)消去蕴涵项"<>command1; if(command1 == 'y' || command1 == 'Y') { orign =del_inlclue(orign); cout<<"消去蕴涵项后是"<

10、 cout<<"请输入(Y/y)减少否定符号的辖域"<>command2; if(command2 == 'y' || command2 == 'Y') { do { temp = orign; orign = dec_neg_rand(orign); }while(temp != orign); cout<<"减少否定符号的辖域后是"<

11、 cout<<"请输入(Y/y)对变量进行标准化"<>command3; if(command3 == 'y' || command3 == 'Y') { orign = standard_var(orign); cout<<"对变量进行标准化后是"<

12、 cout<<"请输入(Y/y)消去存在量词"<>command4; if(command4 == 'y' || command4 == 'Y') { orign = del_exists(orign); cout<<"消去存在量词后是(w = g(x)是一个Skolem函数)"<

13、 cout<<"请输入(Y/y)化为前束形"<>command5; if(command5 == 'y' || command5== 'Y') { orign = convert_to_front(orign); cout<<"化为前束形后是"<

14、 cout<<"请输入(Y/y)把母式化为合取方式"<>command6; if(command6 == 'y' || command6 == 'Y') { orign = convert_to_and(orign); cout<<"把母式化为合取方式后是"<

15、 cout<<"请输入(Y/y)消去全称量词"<>command7; if(command7 == 'y' || command7 == 'Y') { orign= del_all(orign); cout<<"消去全称量词后是"<

16、<>command8; if(command8 == 'y' || command8 == 'Y') { orign = del_and(orign); cout<<"消去连接符号后是"<>command9; i

17、f(command9 == 'y' || command9 == 'Y') { orign = change_name(orign); cout<<"变量分离标准化后是(x1,x2,x3代替变量x)"<

18、"<>commanda; if(commanda == 'Y' || commanda == 'y')

19、 cout<<"本例程规定输入时蕴涵符号为>,全称量词为@,存在量词为#,"<>commandb; if(commandb =='Y'|| commandb=='y') cin>>ini; else ini = "(@x)(P(x)>((@y)(P(y)>P(f(x, y)))%~(@y)(Q(x,y)>P(y))))"; cout<<"原始命题是"<

20、 <蕴涵项 { //a>b变为~a!b char ctemp[100]={""}; string output; int length = temp.length(); int i = 0,right_bracket = 0,falg= 0; stack stack1,stack2,stack3; strcpy_s(ctemp,temp.c_str()); while(ctemp[i] != '\0' && i <= length-1) {

21、 stack1.push(ctemp[i]); if('>' == ctemp[i+1])//如果是a>b则用~a!b替代 { falg = 1; if(isAlbum(ctemp[i]))//如果是字母则把ctemp[i]弹出 { stack1.pop(); stack1.push('~'); stack1.push(ctemp[i]); stack1.push('!'); i = i + 1; } else if(')' == ctemp[i]) { right_br

22、acket++; do { if('(' == stack1.top()) right_bracket--; stack3.push(stack1.top()); stack1.pop(); }while((right_bracket != 0)); stack3.push(stack1.top()); stack1.pop(); stack1.push('~'); while(!stack3.empty()) { stack1.push(s

23、tack3.top()); stack3.pop(); } stack1.push('!'); i = i + 1; } } i++; } while(!stack1.empty()) { stack2.push(stack1.top()); stack1.pop(); } while(!stack2.empty()) { output += stack2.top(); stack2.pop(); } if(falg == 1) return output; else

24、 return temp; } string dec_neg_rand(string temp)//减少否定符号的辖域 { char ctemp[100],tempc; string output; int flag2 = 0; int i = 0,left_bracket = 0,length = temp.length(); stack stack1,stack2; queue queue1; strcpy_s(ctemp,temp.c_str());//复制到字符数组中 while(ctemp[i] != '\0'

25、 i <= length - 1) { stack1.push(ctemp[i]); if(ctemp[i] == '~')//如果是~否则什么都不做 { char fo = ctemp[i+2]; if(ctemp[i+1] == '(')//如果是(,否则什么都不做 { if(fo == '@' || fo =='#')//如果是全称量词 { flag2 = 1; i++; stack1.pop(); stack1.push(ctemp[i]); if(fo =

26、 '@') stack1.push('#'); else stack1.push('@'); stack1.push(ctemp[i+2]); stack1.push(ctemp[i+3]); stack1.push('('); stack1.push('~'); if(isAlbum(ctemp[i+4])) { stack1.push(ctemp[i+4]); i = i + 5; } else i = i +

27、4; do { queue1.push(temp[i]); if(temp[i] == '(') left_bracket ++; else if(temp[i] == ')') left_bracket --; i ++; }while(left_bracket != 0 && left_bracket >=0); queue1.push(')'); while(!queue1.empty()) { tempc = qu

28、eue1.front(); queue1.pop(); stack1.push(tempc); } } } } i ++; } while(!stack1.empty()) { stack2.push(stack1.top()); stack1.pop(); } while(!stack2.empty()) { output += stack2.top(); stack2.pop(); } if(flag2 == 1) temp = output; /****

29、/ char ctemp1[100]; string output1; stack stack11,stack22; int falg1 = 0; int times = 0; int length1 = temp.length(),inleftbackets = 1,j = 0; strcpy_s(ctemp1,temp.c_str()); while(ctemp1[j] != '\0' && j <= (length1 -1)) {

30、 stack11.push(ctemp1[j]); if(ctemp1[j] == '~') { if(ctemp1[j+1] == '(' /*&& ctemp1[j + 2] != '~'*/) { j = j + 2; stack11.push('(');//////////////// while(inleftbackets != 0 && inleftbackets >=0 && times <= (length1 - j) && times >= 0) { stack11.push(c

31、temp1[j]); if(ctemp1[j] == '(') inleftbackets ++; else if(ctemp1[j] == ')') inleftbackets --; if(inleftbackets == 1 && ctemp1[j+1] == '!' && ctemp1[j+2] != '@' && ctemp1[j+2] != '#') { falg1 =1; stack11.push(')');////////// stack11.push('%'

32、); stack11.push('~'); stack11.push('(');////////// j = j+1; } if(inleftbackets == 1 && ctemp1[j+1] == '%' && ctemp1[j+2] != '@' && ctemp1[j+2] != '#') { falg1 =1; stack11.push(')');////////// stack11.push('!'); stack11.push('~');

33、 stack11.push('(');////////// j = j+1; } j = j +1; } if(falg1 == 1) stack11.push(')'); stack11.pop(); stack11.push(')');//此处有bug stack11.push(')');//此处有bug } } j ++; } while(!stack11.empty()) { stack22.push(stack11.top()); s

34、tack11.pop(); } while(!stack22.empty()) { output1 += stack22.top(); stack22.pop(); } if(falg1 == 1) temp = output1; /************************************************************/ char ctemp3[100]; string output3; int k = 0,left_bracket3 = 1,length3 = temp.length(); stack

35、 stack13,stack23; int flag = 0,bflag = 0; strcpy_s(ctemp3,temp.c_str());//复制到字符数组中 while(ctemp3[k] != '\0' && k <= length3-1) { stack13.push(ctemp3[k]); if(ctemp3[k] == '~') { if(ctemp3[k+1] == '(') { if(ctemp3[k + 2] == '~') { flag = 1; stack13.

36、pop(); k =k + 2; while(left_bracket3 != 0 && left_bracket3 >=0) { stack13.push(ctemp3[k+1]); if(ctemp3[k+1] == '(') left_bracket3 ++; if(ctemp3[k+1] == ')') left_bracket3 --; if(ctemp3[k+1] == '!' | ctemp3[k+1] == '%') bflag = 1;

37、 k ++; } stack13.pop(); } } } k ++; } while(!stack13.empty()) { stack23.push(stack13.top()); stack13.pop(); } while(!stack23.empty()) { output3 += stack23.top(); stack23.pop(); } if(flag == 1 && bflag == 0) temp = output3; return tem

38、p; } string standard_var(string temp)//对变量标准化,简化,不考虑多层嵌套 { char ctemp[100],des[10]={" "}; strcpy_s(ctemp,temp.c_str()); stack stack1,stack2; int l_bracket = 1,falg = 0,bracket = 1; int i = 0,j = 0; string output; while(ctemp[i] != '\0' && i < temp.length()) { stack1.p

39、ush(ctemp[i]); if(ctemp[i] == '@' || ctemp[i] == '#') { stack1.push(ctemp[i+1]); des[j] = ctemp[i+1]; j++; stack1.push(ctemp[i+2]); i = i + 3; stack1.push(ctemp[i]); i++; if(ctemp[i-1] == '(') { while(ctemp[i] != '\0' && l_bracket != 0) { if(

40、ctemp[i] == '(') l_bracket ++; if(ctemp[i] == ')') l_bracket --; if(ctemp[i] == '(' && ctemp[i+1] == '@' ) { des[j] = ctemp[i+2]; j++; } if(ctemp[i+1] == '(' && ctemp[i+2] == '#' ) { falg = 1; int kk = 1; stack1.pus

41、h(ctemp[i]); stack1.push('('); stack1.push(ctemp[i+2]); i = i+3; if(ctemp[i] == 'y') ctemp[i] ='w'; stack1.push(ctemp[i]); stack1.push(')'); stack1.push('('); i = i+3; while(kk != 0) { if(ctemp[i]=='(')

42、 kk++; if(ctemp[i] ==')') kk--; if(ctemp[i] == 'y') ctemp[i] ='w'; stack1.push(ctemp[i]); i++; } } stack1.push(ctemp[i]); i ++; } } } i ++; } while(!stack1.empty()) { stack2.push(stack1.top());

43、 stack1.pop(); } while(!stack2.empty()) { output += stack2.top(); stack2.pop(); } if(falg == 1) return output; else return temp; } string del_exists(string temp)//消去存在量词 { char ctemp[100],unknow; strcpy_s(ctemp,temp.c_str()); int left_brackets = 0,i = 0,falg = 0;

44、queue queue1; string output; while(ctemp[i] != '\0' && i < temp.length()) { if(ctemp[i] =='(' && ctemp[i+1] =='#') { falg = 1; unknow = ctemp[i+2]; i = i+4; do { if(ctemp[i] == '(') left_brackets ++; if(ctemp[i] == ')') left_brackets --

45、 if(ctemp[i] == unknow) { queue1.push('g'); queue1.push('('); queue1.push('x'); queue1.push(')'); } if(ctemp[i] != unknow) queue1.push(ctemp[i]); i++; }while(left_brackets != 0); } queue1.push(ctemp[i]); i++; } while(!queue1.em

46、pty()) { output+= queue1.front(); queue1.pop(); } if(falg == 1) return output; else return temp; } string convert_to_front(string temp)//化为前束形 { char ctemp[100]; strcpy(ctemp,temp.c_str()); int i = 0; string out_var = "",output = ""; while(ctemp[i] != '\0' && i < tem

47、p.length()) { if(ctemp[i] == '(' && ctemp[i+1] == '@') { out_var = out_var + ctemp[i] ;//(@) out_var = out_var + ctemp[i+1] ; out_var = out_var +ctemp[i+2]; out_var = out_var +ctemp[i+3]; i = i + 4; } output = output + ctemp[i]; i++; } output = o

48、ut_var + output; return output; } string convert_to_and(string temp)//把母式化为合取范式 ,Q/A? { temp = "(@x)(@y)((~P(x)!(~P(y))!P(f(x,y)))%((~P(x)!Q(x,g(x)))%((~P(x))!(~P(g(x)))))"; return temp; } string del_all(string temp)//消去全称量词 { char ctemp[100]; strcpy(ctemp,temp.c_str()); int i = 0,

49、flag = 0; string output = ""; while(ctemp[i] != '\0' && i < temp.length()) { if(ctemp[i] == '(' && ctemp[i+1] == '@') { i = i + 4; flag = 1; } else { output = output + ctemp[i]; i ++; } } return output; } string del_and(string temp)//消去连接符号合取% { ch

50、ar ctemp[100]; strcpy(ctemp,temp.c_str()); int i = 0,flag = 0; string output = ""; while(ctemp[i] != '\0' && i < temp.length()) { if(ctemp[i] == '%' ) { ctemp[i] = '\n'; } output = output +ctemp[i]; i++; } return output; } string change_name(string temp)//更换变量名称

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服