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条回答

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?