Stay Hungry,Stay Foolish!

Prolog 逻辑推导语言

Prolog

https://en.wikipedia.org/wiki/Prolog

Prolog is a general-purpose logic programming language associated with artificial intelligence and computational linguistics.[1][2][3]

Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is declarative: the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations.

Prolog是一种通用目的的 逻辑编程 语言, 与人工智能 和 计算语言学有关。

Prolog源于一阶逻辑,一种形式逻辑学,所以和其他很多编程语言不通。 其实 声明式的, 程序逻辑被以关系表达, 表述为 fact 和 rule。

使用查询,触发程序的计算,计算的目标在这些关系中搜索答案。

 

学习

http://www.learnprolognow.org/lpnpage.php?pageid=online

http://www.cnblogs.com/zhanjindong/p/3329647.html

http://www.learnprolognow.org/slides/official/LPNchapter1.pdf

 

demo

苏格拉底三段论:

是人就会死,苏格拉底是人

结论:苏格拉底会死

 

知识库:

die(X):-person(X).
person(socrates).

 

查询语句:

die(socrates).

 

线上运行环境:

https://swish.swi-prolog.org/

 

posted @ 2017-09-17 22:08  lightsong  阅读(609)  评论(0编辑  收藏  举报
Life Is Short, We Need Ship To Travel