Is this Prolog terminology correct?

2019-06-24 13:52发布

Getting the terminology correct is part of the success to communicating a concept and when the wrong terminology is used here at SO with the Prolog tag the respondents nicely point out the mistake.

In reading "Clause and Effect - Prolog Programming for the Working Programmer" by William F. Clocksin in 1997 (WorldCat) is the paragraph

A Prolog program consists of a collection of procedures. Each procedure defines a particular predicate, being a certain relationship between its arguments. A procedure consists of one or more assertions, or clauses. It is convenient to think of two kinds of clauses: facts and rules.

While I understand all of the words, is each bold word the currently correct terminology for use when communicating about Prolog?

In particular the use of rule seems to be frowned upon.

1条回答
不美不萌又怎样
2楼-- · 2019-06-24 14:21

From

ISO/IEC 13211-1 First edition 1995-06-01
Information technology - Programming languages - Prolog -
Part 1:
General Core

program - not defined

3.7 argument: A term which is associated with a predication or compound term.

3.9 arity: The number of arguments of a compound term. Syntactically, a non-negative integer associated with a functor or predicate.

3.10 assert, to: To assert a clause is to add it to the user-defined procedure in the database defined by the predicate of that clause.

3.19 body: A goal, distinguished by its context as part of a rule (see 3.154).

3.21 built-in predicate: A procedure whose execution is implemented by the processor (see 8).

3.32 clause: A fact or a rule. It has two parts: a head, and a body.

3.37 compound term: A functor of arity N, N positive, together with a sequence of N arguments.

3.45 control construct: A procedure whose definition is part of the Prolog processor (see 7.8).

3.59 dynamic (of a procedure): A dynamic procedure is one whose clauses can be inspected or altered during execution, for example by asserting or retracting * clauses (see 7.5.2).

3.72 fact: A clause whose body is the goal true.
NOTE - A fact can be represented in Prolog text by a term whose principal functor is neither (:-)/1 nor (:-)/2.

3.77 functor: An identifier together with an arity.

3.81 goal: A predication which is to be executed (see body, query, and 7.7.3).

3.84 head (of a rule): A predication, distinguished by its context.

3.88 identifier: A basic unstructured object used to denote an atom, functor name or predicate name.

3.129 predicate: An identifier together with an arity.

3.133 predication: A predicate with arity N and a sequence of N arguments.

3.136 procedure: A control construct, a built-in predicate, or a user-defined procedure. A procedure is either static or dynamic. A procedure is either private or public (see 7.5).

3.143 query: A goal given as interactive input to the top level.

3.154 rule: A clause whose body is not the goal true. During execution, if the body is true for some substitution, then the head is also true for that substitution. A rule is represented in Prolog text by a term whose principal functor is (:-)/2 where the first argument is converted to the head, and the second argument is converted to the body.

3.164 static (of a procedure): A static procedure is one whose clauses cannot be altered (see 7.5.2).

3.195 user-defined procedure: A procedure which is defined by a sequence of clauses where the head of each clause has the same predicate indicator, and each clause is expressed by Prolog text or has been asserted during execution (see 8.9).

EDIT: Anton Danilov

I will try to refine some of definitions above...

predicate : predicate indicator e.g. member/2

built-in predicate: a predicate that is the part of Prolog language. It may be implemented as a library predicate or by foreign language. A built-in predicate can optionally to be declared, unlike the regular library predicate.

predication : I never heard this term before. Probably it's just predicate or predicate compound (in contrary with function compound ).

rule: in my humble opinion the term "rule" is typically used in the context of Prolog and other logic based languages (production systems)

EDIT Anton Danilov:

More info:

program is used in the similar contexts as the rule

database a (part of) prolog program often called so when it mostly contains flat facts (which args are atomic).

relation rarely used as the synonym of predicate (or predicate-indicator).

查看更多
登录 后发表回答