相关疑难解决方法(0)

如何在Java或C#等语言中实现统一算法?

我正在通过我的AI教科书工作,我已经完成了我的部分的最后一个作业问题:

"以您选择的任何语言实施第69页概述的统一算法."

在页69,您有统一算法的以下伪代码:

function unify(E1, E2);
    begin
        case
            both E1 and E2 are constants or the empty list:
                if E1 = E2 then return {}
                else return FAIL;
            E1 is a variable:
                if E1 occurs in E2 then return FAIL
                 else return {E2/E1}
            E2 is a variable
                if E2 occurs in E1 then FAIL
                    else return {E1/E2}
            either E1 or E2 are empty then return FAIL
            otherwise:
                begin
                    HE1 := first element of E1;
                    HE2 := first element of E2; …
Run Code Online (Sandbox Code Playgroud)

artificial-intelligence predicate unification

16
推荐指数
2
解决办法
1万
查看次数

python 逻辑编程

我正在做一个主要基于逻辑编程的项目。我已经预先定义了程序用来计算概率的相关规则和事实,然后将这些概率附加到数据中并输入到进一步的机器学习模型中。计算概率的程序可以在序言中轻松定义,例如:

has_lot_work(daniel, 8). %number of lets say urgent tasks
has_lot_work(david, 3).
stress(X, P) :- has_lot_work(X, P2), P is P2 / 100.
to_smoke(X, Prob) :- stress(X, P1), friends(Y, X), influences(Y, X, P2), smokes(Y), Prob is P1 + P2.
to_have_asthma(X, 0.3) :- smokes(X). %30 percent of current smokers get asthma
to_have_asthma(X, Prob) :- to_smoke(X, P2), Prob is P2 * 0.25. %25 percent of smokers-to-be will get asthma
friends(X, Y) :- friend(X, Y).
friends(X, Y) :- friend(Y, X).
influences(X, Y, 0.4) :- friends(X, …
Run Code Online (Sandbox Code Playgroud)

python prolog logic-programming

3
推荐指数
2
解决办法
1万
查看次数