Information technology — Programming languages — Prolog — Part 1: General core

Designed to promote the applicability and portability of Prolog text and data among a variety of data processing systems. Specifies: the representation of Prolog text; the syntax and constraints of the Prolog language; the semantic rules for interpreting Prolog text; the representation of input data to be processed by Prolog; the representation of output produced by Prolog and the restrictions and limits imposed on a conforming Prolog processor.

Technologies de l'information — Langages de programmation — Prolog — Partie 1: Noyau général

General Information

Status
Published
Publication Date
31-May-1995
Current Stage
9093 - International Standard confirmed
Start Date
24-Sep-2024
Completion Date
19-Apr-2025
Ref Project
Standard
ISO/IEC 13211-1:1995 - Information technology -- Programming languages -- Prolog
English language
199 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (Sample)


INTERNATIONAL
ISO/IEC
STANDARD
13211-1
First edition
1995-06-01
Information technology - Programming
languages - Prolog -
Part 1:
General core
Technologies de I’informa tion
- Langages de programmation -
Prolog -
Partie 1: Noyau g&Gral
ISO/IEC 13211-1 : 1995(E)
Page
Contents
. . .
~111
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1 Scope .
..........................................
1.1 Notes
2 Normative references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.............................. 10
4 Symbols and abbreviations
........................................ 10
4.1 Notation
....................... 10
4.1.1 Basic mathematical types
................... 10
4.1.2 Mathematical and set Operators
.............................. 10
4.1.3 Other functions
............................ 11
Abstract data type: Stack
4.2
.......................... 11
4.3 Abstract data type: mapping
......................................... 11
5 Compliance
.................................. 11
5.1 Prolog processor
...................................... 12
5.2 Prolog text
...................................... 12
Prolog goal
5.3
...................................
5.4 Documentation.
....................................... 12
5.5 Extensions
.................................... 12
5.5.1 Syntax
.......................... 12
5.5.2 Predefined Operators
.................... 12
5.5.3 Character-conversion mapping
.................................... 12
5.5.4 Types.
.................................. 13
5.5.5 Directives
................................ 13
5.5.6 Side effects
............................ 13
5.5.7 Control constructs
..................................... 13
5.5.8 Flags
............................ 13
5.5.9 Built-in predicates
@ ISO/IEC 1995
Unless otherwise specified, no part of this publication may be
All rights reserved.
reproduced or utilized in any form or by any means, electronie or mechanical, including
photocopying and microfilm, without Permission in writing from the publisher.
ISO/IEC Copyright Office l Case Postale 56 l CH-l 211 Geneve 20 l Switzerland
Printed in Switzerland
ii
ISO/IEC 132114 : 1995(E)
@ ISO/IEC 1995
5.510 Evaluable functors . 13
55.11 Reserved atoms. . 13
6 Syntax .
........................................ 13
6.1 Notation
........................... 13
6.1.1 Backus Naur Form
.......................... 14
6.1.2 Abstract term Syntax
............................... 15
6.2 Prolog text and data.
................................. 15
6.2.1 Prolog text
................................ 15
6.2.2 Prolog data.
.......................................... 15
6.3 Terms
............................... 16
6.3.1 Atomic terms
..................................
6.3.2 Variables 16
6.3.3 Compound terms - functional notation . 16
6.3.4 Compound terms - Operator notation .
6.3.5 Compound terms - list notation . 19
............ 20
6.3.6 Compound terms - curly bracketed term
............... 20
6.3.7 Terms - double quoted list notation
......................................... 20
6.4 Tokens
................................ 21
6.4.1 Layout text.
.................................... 21
6.4.2 Names
.................................. 23
6.4.3 Variables
............................. 23
6.4.4 Integer numbers
6.4.5 Floating Point numbers . 23
........................... 24
6.4.6 Double quoted lists
........................... 24
6.4.7 Back quoted strings
................................ 24
6.4.8 Other tokens
.............................. 24
6.5 Processor Character set
............................ 25
6.5.1 Graphit characters
6.5.2 Alphanumeric characters . 25
6.5.3 Solo characters . 25
6.5.4 Layout characters . 25
6.5.5 Meta characters . 26
6.6 Collating sequence . 26
......................... 26
7 Language concepts and semantics
.......................................... 27
7.1 Types
................................... 27
7.1.1 Variable
.................................... 27
7.1.2 Integer
............................... 28
7.1.3 Floating Point
7.1.4 Atom . 29
7.1.5 Compound term . 29
7.1.6 Related terms . 29
...................................... 30
7.2 Term Order
7.2.1 Variable . 31
...............................
7.2.2 Floating Point 31
.................................... 31
7.2.3 Integer
..................................... 31
7.2.4 Atom
7.2.5 Compound . 31
......................................
7.3 Unification 31
..................... 31
7.3.1 The mathematical definition
...........................
7.3.2 Herbrand algorithm 31
7.3.3 Subject to occurs-check (STO) and not subject to occurs-
check (NSTO) .
.................... 33
7.3.4 Normal unification in Prolog
...................................... 33
7.4 Prolog text
7.4.1 Undefined features . 34
. . .
@ ISO/IEC 1995
ISO/IEC 13211-1 : 1995(E)
..................................
7.4.2 Directives
................................... 35
7.4.3 Clauses
........................................ 36
7.5 Database
.............. 36
7.5.1 Preparing a Prolog text for execution
...................
7.5.2 Static and dynamic procedures
....................
Private and public procedures
7.5.3
......................
A logical database update
7.5.4
........ 37
7.6 Converting a term to a clause, and a clause to a term
........... 37
7.6.1 Converting a term to the head of a clause
.......... 37
7.6.2 Converting a term to the body of a clause.
........... 37
7.6.3 Converting the head of a clause to a term
.......... 38
7.6.4 Converting the body of a clause to a term.
............................. 38
7.7 Executing a Prolog goal
.................................. 38
7.7.1 Execution
............... 38
7.7.2 Data types for the execution model-
................................ 39
7.7.3 Initialization
............................. 39
7.7.4 A goal succeeds
................................ 39
7.7.5 A goal fails
........................... 39
7.7.6 Re-executing a goal
.................. 40
7.7.7 Selecting a clause for execution
................................ 40
7.7.8 Backtracking
................................ 40
7.7.9 Side effects
................ 40
7.7.10 Executing a user-defined procedure
7.7.11 Executing a user-defined procedure with no more clauses
.................... 42
7.7.12 Executing a built-in predicate
................................. 43
7.8 Control constructs
.................................... 43
7.8.1 truel0.
..................................... 43
7.8.2 fail/O
.....................................
7.8.3 callll
7.8.4 !/O - tut .
..........................
7.8.5 (‘,‘)/2 - conjunction
............................ 47
(;)/2 - disjunction
7.8.6
.............................. 49
(->)/2 - if-then
7.8.7
............................ 50
7.8.8 (;)/2 - if-then-else
.................................... 51
7.8.9 catch/3
................................... 53
7.8.10 throwfl
.............................
7.9 Evaluating an expression
................................. 54
7.9.1 Description
.................................... 54
7.9.2 Errors
...................................... 54
7.10 Input/output
............................ 54
7.10.1 Sources and sinks
................................... 55
7.10.2 Streams
............................. 58
7.10.3 Read-Options list
............................ 58
7.10.4 Write-Options list
.............................. 59
7.10.5 Writing a term
.......................................... 60
7.11 Flags
.................... 60
7.11.1 Flags defining integer type 1
................................. 61
7.11.2 Other flags
.......................................... 61
7.12 Errors
......................... 62
7.12.1 The effect of an error
........................... 62
7.12.2 Error classification
.................................... 63
8 Built-in predicates
................
8.1 The format of built-in predicate definitions
................................. 63
8.1.1 Description
.......................... 64
S.l.2 Template and modes
.................................... 64
8.1.3 Errors
iv
@ ISO/IEC 1995 ISO/IEC 132114 : 1995(E)
.................................. 65
8.1.4 Examples
8.1.5 Bootstrapped built-in predicates . , , , , , . , , , . , , , , , , ,
................................... 65
8.2 Term unification
.......................... 65
8.2.1 (=)/2 - Prolog unify
8.2.2 unify_with_occurs_check/2 - unify . . , , , , , , , , , , , , , . .
8.2.3 (\=)/2 - . 67
not Prolog unifiable
..................................... 67
8.3 Type testing
..................................... 67
8.3.1 var/l
.................................... 68
8.3.2 atom/l
................................... 68
8.3.3 integer/1
.................................... 68
8.3.4 floatll
................................... 68
8.3.5 atomic/l
................................ 69
8.3.6 compound/l
................................... 69
8.3.7 nonvar/l
.................................. 69
8.3.8 number/l
.................................. 70
8.4 Term comparison
8.4.1 (@=<)/2 - term less than or equal, (==)/2 - term identical,
(\==)/2 - term not identical, (@<)/2 - term less than,
(@>)/2 - term greater than, (@>=)/2 - term greater than
or equal . 70
....................... 71
8.5 Term creation and decomposition
.................................. 71
8.5.1 functor/3
8.5.2 arg/3 . 72
8.5.3 (=.)/ 2 - univ . 72
8.5.4 copy-term/2 . 73
............................... 74
8.6 Arithmetic evaluation
8.6.1 (is)/2 - evaluate expression . 74
8.7 Arithmetic comparison . 74
8.7.1 (=:=)/2 - arithmetic equal, (=\=)/2 - arithmetic not equal,
(<)/2 - arithmetic less than, (=<)/2 - arithmetic less
than or equal, (>)/2 - arithmetic greater than, (>=)/2 -
arithmetic greater than or equal . 76
8.8 Clause retrieval and information . 77
................................... 77
8.8.1 clause/2
............................ 78
8.8.2 current-predicate/l
........................ 78
8.9 Clause creation and destruction
................................... 78
8.9.1 asserta/l
................................... 79
8.9.2 assertz/l
................................... 80
8.9.3 retract/l
.................................. 81
8.9.4 abolishll
..................................... 82
8.10 All solutions
................................... 82
8.10.1 findall/
................................... 83
8.10.2 bagof/3
.................................... 84
8.10.3 setof/3
.......................... 86
8.11 Stream selection and control
8.11.1 currenL.input/l . 86
8.11.2 current-output/1 . 86
................................. 87
8.11.3 set-input/l
................................ 87
8.11.4 set-output/1
8.11.5 open/4, open/3 . 87
8.11.6 close/2, close/l . 88
.................... 89
8.11.7 flush-output/l, flush-output/0
8.11.8 stream_property/2, at-end-ofstream/O, at-end-of-strearn/l . 89
.......................... 90
8.11.9 set_stream_position/2
.............................. 9 1
8.12 Character input/output
8.12.1 get_char/2, getcharll , get-Code/1 , get-Code/2 . 9 1
8.12.2 peek_char/2, peek-charll , peek-codell , peekcodel2 . 92
V
@ ISO/IEC 1995
ISO/IEC 13211-1 : 1995(E)
8.12.3 put-charl2, put-charll, put-codell, putcodel2, nl/O, nlll ,
.................................. 95
8.13 Byte inputloutput
.......................... 95
8.13.1 get-bytel2, get-bytell
....................... 96
8.13.2 peek-bytel2, peek-bytell
......................... 97
8.13.3 put-bytel2, put-bytell
.................................. 98
8.14 Term inputloutput
............. 98
8.14.1 read_term/3, read_term/2, readll, readl2
8.14.2 write_term/3, write_term/2, writell, writel2, writeqll,
......... 99
writeql2, writecanonicalll, write-canonicall2
...................................... 101
8.14.3 op/3
................................ 102
8.14.4 current-op/3
............................ 103
8.14.5 char-conversionl2
....................... 103
8.14.6 currentcharconversionl2
................................. 104
8.15 Logic and control
......................... 104
8.15.1 (\+)/l - not provable
.................................... 105
8.15.2 oncell
................................... 105
8.15.3 repeat/O
............................. 105
8.16 Atomic term processing
............................... 106
8.16.1 atomJengthl2
............................... 106
8.16.2 atomconcatl3
................................. 107
8.16.3 sub-atom/5
................................
8.16.4 atomcharsl2
............................... 109
8.16.5 atomcodes
................................. 109
8.16.6 char-codel2
.............................. 110
8.16.7 numbercharsl2
.............................. 111
8.16.8 numbercodesl2
......................... 112
8.17 Implementation defined hooks
............................. 112
8.17.1 set-prologflagl2
.......................... 112
8.17.2 current-prologflagl2
..................................... 113
8.17.3 halt/0
..................................... 113
8.17.4 halt/1
.................................... 114
9 Evaluable functors
........................ 114
9.1 The simple arithmetic functors
....
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.