《BS-ISO-IEC-13211-2-2000.pdf》由会员分享,可在线阅读,更多相关《BS-ISO-IEC-13211-2-2000.pdf(32页珍藏版)》请在三一文库上搜索。
1、| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BRITISH STANDARD BS ISO/IEC 13211-2:2000 I
2、CS 35.060 NO COPYING WITHOUT BSI PERMISSION EXCEPT AS PERMITTED BY COPYRIGHT LAW Information technology Programming languages Prolog Part 2: Modules Licensed Copy: sheffieldun sheffieldun, na, Thu Nov 23 01:59:13 GMT+00:00 2006, Uncontrolled Copy, (c) BSI This British Standard, having been prepared
3、under the direction of the DISC Board, was published under the authority of the Standards Committee and comes into effect on 15 November 2000 BSI 11-2000 ISBN 0 580 36677 4 BS ISO/IEC 13211-2:2000 Amendments issued since publication Amd. No.DateComments National foreword This British Standard reprod
4、uces verbatim ISO/IEC 13211-2:2000 and implements it as the UK national standard. The UK participation in its preparation was entrusted to Technical Committee IST/5, Programming languages, Their Environments and System Software, which has the responsibility to: aid enquirers to understand the text;
5、present to the responsible international/European committee any enquiries on the interpretation, or proposals for change, and keep the UK interests informed; monitor related international and European developments and promulgate them in the UK. A list of organizations represented on this committee c
6、an be obtained on request to its secretary. Cross-references The British Standards which implement international or European publications referred to in this document may be found in the BSI Standards Catalogue under the section entitled International Standards Correspondence Index, or by using the
7、Find facility of the BSI Standards Electronic Catalogue. A British Standard does not purport to include all the necessary provisions of a contract. Users of British Standards are responsible for their correct application. Compliance with a British Standard does not of itself confer immunity from leg
8、al obligations. Summary of pages This document comprises a front cover, an inside front cover, the ISO/IEC title page, pages ii to vi, pages 1 to 23 and a back cover. The BSI copyright notice displayed in this document indicates when the document was last issued. Licensed Copy: sheffieldun sheffield
9、un, na, Thu Nov 23 01:59:13 GMT+00:00 2006, Uncontrolled Copy, (c) BSI Reference number ISO/IEC 13211-2:2000(E) INTERNATIONAL STANDARD ISO/IEC 13211-2 First edition 2000-06-01 Information technology Programming languages Prolog Part 2: Modules Technologies de linformation Langages de programmation P
10、rolog Partie 2: Modules Licensed Copy: sheffieldun sheffieldun, na, Thu Nov 23 01:59:13 GMT+00:00 2006, Uncontrolled Copy, (c) BSI ISO/IEC 13211-2:2000(E) ii Licensed Copy: sheffieldun sheffieldun, na, Thu Nov 23 01:59:13 GMT+00:00 2006, Uncontrolled Copy, (c) BSI ISO/IEC 13211-2:2000(E) ContentsPag
11、e Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .v Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12、 . . . . . . . . . . . . . . . .vi 1Scope?1 1.1Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 2Normative reference?1 3 Terms and defi nitions?1 4Compliance?3 4.1Prolog processor . . . . . .
13、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 4.2Module text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 4.3Prolog goal . . .
14、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 4.4Prolog modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 4.4.1Prolog
15、text without modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 4.4.2The module user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 4.5Documentation . . . . . . .
16、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 4.5.1Dynamic Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 4.5.2Inaccessible Procedures . . .
17、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 5Syntax?4 5.1Module text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 5.2Terms . . . . . . . . .
18、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 5.2.1Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 6Language concepts a
19、nd semantics?4 6.1Related terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 6.1.1 Qualifi ed and unqualifi ed terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20、 . . . . .5 6.2Module text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 6.2.1Module user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21、 . . . . . .5 6.2.2Procedure Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 6.2.3Module interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22、 .5 6.2.4Module directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 6.2.5Module body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 6.2.6Cla
23、uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 6.3Complete database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 6.3.1V
24、isible database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 6.3.2Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 6.4Context sen
25、sitive predicates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 6.4.1Metapredicate built-ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 6.4.2Context sensiti
26、ve built-ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 6.4.3Module name expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 6.4.4Examples: Metapredicates . . . . .
27、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 6.5Converting a term to a clause, and a clause to a term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.5.1Converting a term to the head of a clause . . . . . . . . .
28、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.5.2 Converting a module qualifi ed term to a body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.5.3Converting the body of a clause to a term. . . . . . . . . . . . . . . . . . . . . . . . . .
29、. . . . . . . . . . . . . . . . 11 6.6Executing a Prolog goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 iiiSIO/EIC 0002 All hgirst rresevde iii Licensed Copy: sheffieldun sheffieldun, na, Thu Nov 23 01:59:13 GMT+00:00
30、 2006, Uncontrolled Copy, (c) BSI ISO/IEC 13211-2:2000(E) 6.6.1Data types for the execution model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 6.6.2Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31、 . . . . . . . . . . . . . . . . . . . . . 12 6.6.3Searching the complete database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.6.4Selecting a clause for execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32、 . . . . . . . . . . 13 6.6.5Backtracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6.6.6 Executing a user-defi ned procedure: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33、. . . . . 14 6.6.7Executing a built-in predicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6.7Executing a control construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
34、 14 6.7.1call/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6.7.2catch/3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
35、. . . 15 6.7.3throw/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 6.8Predicate properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36、. . . . . . . 16 6.9Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.9.1Flag: colon sets calling context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37、 . . . . . . . . 16 6.10 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.10.1 Error classifi cation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38、 . . . . . . . . . . . . . . . 16 7Built-in predicates?16 7.1 The format of built-in predicate defi nitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.1.1Type of an argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
39、. . . . . . . . . . . . . . . . . . . . . . . 16 7.2Module predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.2.1current module/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
40、 . . . . . . . . . . . . . . . . . . . . . . . 17 7.2.2predicate property/2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 7.3Clause retrieval and information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
41、 . . . . . . . . . . . . . . . . . . . . . 18 7.3.1clause/2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 7.3.2current predicate/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42、. . . . . . . . . . . . . . . . . . . . . 19 7.4 Database access and modifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 7.4.1asserta/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
43、 . . . . . . . . . . . . . . . . . . . . . 20 7.4.2assertz/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 7.4.3retract/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44、 . . . . . . . . . . . . . . . . . . . . . . . 21 7.4.4abolish/1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 ivSIO/EIC 0002 All hgirst rresevde iv Licensed Copy: sheffieldun sheffieldun, na, Thu Nov 23 01:59
45、:13 GMT+00:00 2006, Uncontrolled Copy, (c) BSI ISO/IEC 13211-2:2000(E) vSIO/EIC 0002 All hgirst rresevde Foreword ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodie
46、s that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other in
47、ternational organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 3. In the field of information technology, ISO and IEC have established a join
48、t technical committee, ISO/IEC JTC 1. Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an International Standard requires approval by at least 75 % of the national bodies casting a vote. Attention is drawn to the possibility that some of the elements of this part of ISO/IEC 13211 may be the subject of patent rights. ISO an