qq_40947786 2019-01-23 05:41
浏览 702

如何用prolog语言实现自动推理?

希望能够实现自我推理。

The main predicate of your program is
to be prove/1 which is to take a list of sequents as argument and determine whether every sequent in the list can be proved.

举例: prove([[neg(p or q)] seq [neg p]]) 输出 ”Yes”.

大致思路应该是下图没错但是因为时间紧张之前又没有接触过prolog,特来求教


% THIS PROGRAM SUPPOSES A CORRECT INPUT OF THE FORM
% 'sequent = list1 seq list2', WHERE 'list1', 'list2' DO
% NOT CONTAIN 'seq' AS A SUBSTRING

% define logical operations 

:-op(800, xfx, seq). % syntactic entailment
:-op(700, xfy, iff). % biconditional
:-op(600, xfy, imp). % implication
:-op(400, yfx, and). % conjunction
:-op(400, yfx, or).  % disjunction
:-op(300, fy, neg).  % negation

% equivalence(+Formula1, +Formula2)
% equivalence between formulae

equivalence(neg (P and Q), (neg P) or (neg Q)).
equivalence(neg (P or Q), (neg P) and (neg Q)).
equivalence(P imp Q, (neg P) or Q).
equivalence(P iff Q, (neg P and neg Q) or (P and Q)).

% con_concat(+List, -Conjunction)
% transforms a list of formulae into a conjunction

???

% dis_concat(+List, -Disjunction)
% transforms a list of formulae into a disjunction

???

% preprocess(+Seq, -Prep_Seq)
% preprocesses the left and right lists of formulas in a sequent
% e.g. '[neg (p1 or p2), p3] seq [p4 and p5, p6, p7]' is the same as
% '(neg (p1 or p2)) and (p3) seq (p4 and p5) or (p6) or (p7))'

???

% rewrite_sequent(+Seq, -NewSeq, -Tree)
% rewrites a sequent applying the rules P2a-P6b 
% and returns the result together with its proof tree

???

% theorem(+Seq)
% check whether a sequent is a theore by applying rule P1

???

% prove_sequent(+Seq, -Tree)
% proves a sequent, prints its tree

???

% print_sequent(+Tree)
% printing the proof in a tree-like shape

???

% prove(+L). 
% proves a list of seqeunts

???

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python