prolog

Perfoming member check on a difference list, but how?

一曲冷凌霜 提交于 2020-05-30 23:28:15
问题 I tried to answer another question (wrongly though) and this led to a question on "difference lists" (or "list differences", which seems a more appropriate name, unless "Escherian Construction" isn't preferred) We have a fully ground list of elements obj(X,Y) (both X and Y ground). We want to retain only the first obj(X,_) where X hasn't been encountered yet when going through the list front to back. Those "first elements" must appear in order of appearance in the result. Let's specify the

Perfoming member check on a difference list, but how?

六眼飞鱼酱① 提交于 2020-05-30 23:27:49
问题 I tried to answer another question (wrongly though) and this led to a question on "difference lists" (or "list differences", which seems a more appropriate name, unless "Escherian Construction" isn't preferred) We have a fully ground list of elements obj(X,Y) (both X and Y ground). We want to retain only the first obj(X,_) where X hasn't been encountered yet when going through the list front to back. Those "first elements" must appear in order of appearance in the result. Let's specify the

Perfoming member check on a difference list, but how?

邮差的信 提交于 2020-05-30 23:26:26
问题 I tried to answer another question (wrongly though) and this led to a question on "difference lists" (or "list differences", which seems a more appropriate name, unless "Escherian Construction" isn't preferred) We have a fully ground list of elements obj(X,Y) (both X and Y ground). We want to retain only the first obj(X,_) where X hasn't been encountered yet when going through the list front to back. Those "first elements" must appear in order of appearance in the result. Let's specify the

Prolog membership predicate

混江龙づ霸主 提交于 2020-05-23 21:07:26
问题 I need to write a Prolog predicate that avoids redundant answers with items occurring multiple times in the list at hand, as shown in the following sample queries: ?- member(a, [a, b, a]). true ?- member(X, [a, b, a]). X = a ; X = b ; false. ?- member(X, [a, b, a, c, a, d, b]). X = a ; X = b ; X = c ; X = d ; false. I know that the following would output all of them regardless of the repeats: member(X, [X|_]). member(X, [_|T]) :- member(X, T). 回答1: Compare both clauses, are there cases, where

How to implement data structure in prolog

Deadly 提交于 2020-05-17 06:48:06
问题 I have the following predicate execute(actualState, instruction, nextState):- such that when executing with the instructions: move, swap , i have the following solutions: ?- executed(regs(1,4,*,+,2), swap(1,2), NS). solution: NS = regs(4,1,*,+,2)?; no ?- executed(regs(1,4,3,6,+), move(4), NS). solution: NS = regs(1,4,3,6,6)?; no How can I implement it? what I want it to do is that it has an initial state, an instruction and a final state "executed (actualState, instruction, nextState)" and

人工智能技术导论——基于产生式规则的机器推理

醉酒当歌 提交于 2020-05-09 10:43:16
在引出本章的内容之前先介绍一个概念 知识 知识的概念 知识(Knowledge)是人们在改造客观世界的实践中形成的对客观事物(包括自然的和人造的)及其规律的认识 ,包括对事物的现象、本质、状态、关系、联系和运动等的认识。 经过人的思维整理 过的信息、数据、形象、意象、价值标准以及社会的其他符号产物,不仅包括科学技术知识----知识中最重要的部分,还包括人文社会科学的知识、商业活动、日常生活和工作中的经验和知识,人们获取、运用和创造知识的知识,以及面临问题做出判断和提出解决方法的知识。 知识是把有关的信息关联在一起,形成的关于客观世界某种规律性认识的动态信息结构。 知识=事实+规则+概念 事实 就是指人类对客观世界、客观事物的状态、属性、特征的描述,以及对事物之间关系的描述。 规则 是指能表达在前提和结论之间的因果关系的一种形式; 概念 主要指事实的含义、规则、语义、说明等。 知识的分类 1、 按知识的作用范围分: (1)常识性知识:通用性知识,适用于所有领域; 如一年有四个季节。 (2)领域性知识:面向某个具体领域的知识,是专业性知识,如疾病诊断的知识。 2 、按知识的作用及表示划分: (1)事实性知识:用于描述领域内的有关概念、事实、事物的属性及状态; 如:太阳从东方升起 (2)过程性知识:与领域相关的、用于指出如何处理与问题相关的信息以及求得问题的解; 如:如果信道畅通

Recursive loop exit statement needed

那年仲夏 提交于 2020-05-07 09:21:28
问题 this is a simple prolog example of recursion. I cannot figure out where, and more or less how, to declare the exit statement. The test flight(sofia, dublin) should return true, but it keeps checking at the last steps if you can directFlight(dublin, dublin). Here is the code: directFlight(sofia, varna). directFlight(sofia, paris). directFlight(sofia, london). directFlight(london, edinburg). directFlight(paris, new_york). directFlight(new_york, seattle). directFlight(london, dublin). flight

User Input , How can we do it?

≡放荡痞女 提交于 2020-04-29 09:23:56
问题 How can we get something from user in prolog : for example : animal(dog). animal(cat). write('please type animal name:'),nl. /* How to read from user and store it to X and then check that user has typed animal name ?*/ ?-animal(X). 回答1: You can use read for that. For example you could write read(X), animal(X). into the prolog interpreter or write this into a script file: :- read(X), animal(X). If you then enter a valid animal name into the prompt, it will be bound to X. If you enter an

女生能学人工智能开发吗 哪门编程语言更适合

ε祈祈猫儿з 提交于 2020-04-20 17:48:56
  据了解,BAT三位大佬都看好人工智能的未来发展。人工智能开发适合女生吗?其实没有什么适不适合,男女都能学会,但是程序员这行需要加班,可能比较不习惯一些。到底哪门程序语言更适合人工智能开发呢?下面与千锋小编一同来看看吧。   Python   Python由于简单易用,是人工智能领域中使用极其广泛的编程语言之一,它可以无缝地与数据结构和其他常用的AI算法一起使用。   Python之所以时候AI项目,其实也是基于Python的很多有用的库都可以在AI中使用,如Numpy提供科学的计算能力,Scypy的高级计算和Pybrain的机器学习。   另外,Python有大量的在线资源,所以学习曲线也不会特别陡峭。   Java   Java也是AI项目的一个很好的选择。它是一种面向对象的编程语言,专注于提供AI项目上所需的所有高级功能,它是可移植的,并且提供了内置的垃圾回收。另外Java社区也是一个加分项,完善丰富的社区生态可以帮助开发人员随时随地查询和解决遇到的问题。   对于AI项目来说,算法几乎是灵魂,无论是搜索算法、自然语言处理算法还是神经网络,Java都可以提供一种简单的编码算法。另外,Java的扩展性也是AI项目必备的功能之一。   Lisp   Lisp因其出色的原型设计能力和对符号表达式的支持在AI领域崭露头角。LISP作为因应人工智能而设计的语言

Sum up data from facts

空扰寡人 提交于 2020-04-18 12:31:17
问题 (Given a list of movies, write a PROLOG rule to add and display the total takings.) This is my question I am basically trying to add an integer value give a list of movies from the list below. I am quite new in Prolog and I don't really understand how things work. takings(air_force_one,315000000). takings(american_beauty,336000000). takings(american_pie,201700000). takings(american_wedding,230700000). takings(armageddon,554600000). takings(as_good_as_it_gets,313300000). takings(austin_powers