Up
Next
Contents
1 Acknowledgements
2 GNU Prolog License Conditions
3 Introduction
4 Using GNU Prolog
4.1 Introduction
4.2 The GNU Prolog interactive interpreter
4.2.1 Starting/exiting the interactive interpreter
4.2.2 The interactive interpreter read-execute-write loop
4.2.3 Consulting a Prolog program
4.2.4 Scripting Prolog
4.2.5 Interrupting a query
4.2.6 The line editor
4.3 Adjusting the size of Prolog data
4.4 The GNU Prolog compiler
4.4.1 Different kinds of codes
4.4.2 Compilation scheme
4.4.3 Using the compiler
4.4.4 Running an executable
4.4.5 Generating a new interactive interpreter
4.4.6 The name mangling scheme
5 Debugging
5.1 Introduction
5.2 The procedure box model
5.3 Debugging predicates
5.3.1 Running and stopping the debugger
5.3.2 Leashing ports
5.3.3 Spy-points
5.4 Debugging messages
5.5 Debugger commands
5.6 The WAM debugger
6 Format of definitions
6.1 General format
6.2 Types and modes
6.3 Errors
6.3.1 General format and error context
6.3.2 Instantiation error
6.3.3 Uninstantiation error
6.3.4 Type error
6.3.5 Domain error
6.3.6 Existence error
6.3.7 Permission error
6.3.8 Representation error
6.3.9 Evaluation error
6.3.10 Resource error
6.3.11 Syntax error
6.3.12 System error
7 Prolog directives and control constructs
7.1 Prolog directives
7.1.1 Introduction
7.1.2
dynamic/1
7.1.3
public/1
7.1.4
multifile/1
7.1.5
discontiguous/1
7.1.6
ensure_linked/1
7.1.7
built_in/0
,
built_in/1
,
built_in_fd/0
,
built_in_fd/1
7.1.8
include/1
7.1.9
if/1
,
else/0
,
endif/0
,
elif/1
7.1.10
ensure_loaded/1
7.1.11
op/3
7.1.12
char_conversion/2
7.1.13
set_prolog_flag/2
7.1.14
initialization/1
7.1.15
foreign/2
,
foreign/1
7.2 Prolog control constructs
7.2.1
true/0
,
fail/0
,
!/0
7.2.2
(’,’)/2
- conjunction,
(;)/2
- disjunction,
(->)/2
- if-then,
(*->)/2
- soft-cut (soft if-then)
7.2.3
call/1
7.2.4
catch/3
,
throw/1
8 Prolog built-in predicates
8.1 Type testing
8.1.1
var/1
,
nonvar/1
,
atom/1
,
integer/1
,
float/1
,
number/1
,
atomic/1
,
compound/1
,
callable/1
,
ground/1
,
is_list/1
,
list/1
,
partial_list/1
,
list_or_partial_list/1
8.2 Term unification
8.2.1
(=)/2
- Prolog unification
8.2.2
unify_with_occurs_check/2
8.2.3
(\=)/2
- not Prolog unifiable
8.3 Term comparison
8.3.1 Standard total ordering of terms
8.3.2
(==)/2
- term identical,
(\==)/2
- term not identical,
(@<)/2
- term less than,
(@=<)/2
- term less than or equal to,
(@>)/2
- term greater than,
(@>=)/2
- term greater than or equal to
8.3.3
compare/3
8.4 Term processing
8.4.1
functor/3
8.4.2
arg/3
8.4.3
(=..)/2
- univ
8.4.4
copy_term/2
8.4.5
term_variables/2
,
term_variables/3
8.4.6
subsumes_term/2
8.4.7
acyclic_term/1
8.4.8
term_hash/4
,
term_hash/2
8.4.9
setarg/4
,
setarg/3
8.5 Variable naming/numbering
8.5.1
name_singleton_vars/1
8.5.2
name_query_vars/2
8.5.3
bind_variables/2
,
numbervars/3
,
numbervars/1
8.5.4
term_ref/2
8.6 Arithmetic
8.6.1 Evaluation of an arithmetic expression
8.6.2
(is)/2
- evaluate expression
8.6.3
(=:=)/2
- arithmetic equal,
(=\=)/2
- arithmetic not equal,
(<)/2
- arithmetic less than,
(=<)/2
- arithmetic less than or equal to,
(>)/2
- arithmetic greater than,
(>=)/2
- arithmetic greater than or equal to
8.6.4
succ/2
8.7 Dynamic clause management
8.7.1 Introduction
8.7.2
asserta/1
,
assertz/1
8.7.3
retract/1
8.7.4
retractall/1
8.7.5
clause/2
8.7.6
abolish/1
8.8 Predicate information
8.8.1
current_predicate/1
8.8.2
predicate_property/2
8.9 All solutions
8.9.1 Introduction
8.9.2
findall/4
,
findall/3
8.9.3
bagof/3
,
setof/3
8.10 Streams
8.10.1 Introduction
8.10.2
current_input/1
8.10.3
current_output/1
8.10.4
set_input/1
8.10.5
set_output/1
8.10.6
open/4
,
open/3
8.10.7
close/2
,
close/1
8.10.8
flush_output/1
,
flush_output/0
8.10.9
current_stream/1
8.10.10
stream_property/2
8.10.11
at_end_of_stream/1
,
at_end_of_stream/0
8.10.12
stream_position/2
8.10.13
set_stream_position/2
8.10.14
seek/4
8.10.15
character_count/2
8.10.16
line_count/2
8.10.17
line_position/2
8.10.18
stream_line_column/3
8.10.19
set_stream_line_column/3
8.10.20
add_stream_alias/2
8.10.21
current_alias/2
8.10.22
add_stream_mirror/2
8.10.23
remove_stream_mirror/2
8.10.24
current_mirror/2
8.10.25
set_stream_type/2
8.10.26
set_stream_eof_action/2
8.10.27
set_stream_buffering/2
8.11 Constant term streams
8.11.1 Introduction
8.11.2
open_input_atom_stream/2
,
open_input_chars_stream/2
,
open_input_codes_stream/2
8.11.3
close_input_atom_stream/1
,
close_input_chars_stream/1
,
close_input_codes_stream/1
8.11.4
open_output_atom_stream/1
,
open_output_chars_stream/1
,
open_output_codes_stream/1
8.11.5
close_output_atom_stream/2
,
close_output_chars_stream/2
,
close_output_codes_stream/2
8.12 Character input/output
8.12.1
get_char/2
,
get_char/1
,
get_code/1
,
get_code/2
8.12.2
get_key/2
,
get_key/1
get_key_no_echo/2
,
get_key_no_echo/1
8.12.3
peek_char/2
,
peek_char/1
,
peek_code/1
,
peek_code/2
8.12.4
unget_char/2
,
unget_char/1
,
unget_code/2
,
unget_code/1
8.12.5
put_char/2
,
put_char/1
,
put_code/1
,
put_code/2
,
nl/1
,
nl/0
8.13 Byte input/output
8.13.1
get_byte/2
,
get_byte/1
8.13.2
peek_byte/2
,
peek_byte/1
8.13.3
unget_byte/2
,
unget_byte/1
8.13.4
put_byte/2
,
put_byte/1
8.14 Term input/output
8.14.1
read_term/3
,
read_term/2
,
read/2
,
read/1
8.14.2
read_atom/2
,
read_atom/1
,
read_integer/2
,
read_integer/1
,
read_number/2
,
read_number/1
8.14.3
read_token/2
,
read_token/1
8.14.4
syntax_error_info/4
8.14.5
last_read_start_line_column/2
8.14.6
write_term/3
,
write_term/2
,
write/2
,
write/1
,
writeq/2
,
writeq/1
,
write_canonical/2
,
write_canonical/1
,
display/2
,
display/1
,
print/2
,
print/1
8.14.7
format/3
,
format/2
8.14.8
portray_clause/2
,
portray_clause/1
8.14.9
get_print_stream/1
8.14.10
op/3
8.14.11
current_op/3
8.14.12
char_conversion/2
8.14.13
current_char_conversion/2
8.15 Input/output from/to constant terms
8.15.1
read_term_from_atom/3
,
read_from_atom/2
,
read_token_from_atom/2
8.15.2
read_term_from_chars/3
,
read_from_chars/2
,
read_token_from_chars/2
8.15.3
read_term_from_codes/3
,
read_from_codes/2
,
read_token_from_codes/2
8.15.4
write_term_to_atom/3
,
write_to_atom/2
,
writeq_to_atom/2
,
write_canonical_to_atom/2
,
display_to_atom/2
,
print_to_atom/2
,
format_to_atom/3
8.15.5
write_term_to_chars/3
,
write_to_chars/2
,
writeq_to_chars/2
,
write_canonical_to_chars/2
,
display_to_chars/2
,
print_to_chars/2
,
format_to_chars/3
8.15.6
write_term_to_codes/3
,
write_to_codes/2
,
writeq_to_codes/2
,
write_canonical_to_codes/2
,
display_to_codes/2
,
print_to_codes/2
,
format_to_codes/3
8.16 DEC-10 compatibility input/output
8.16.1 Introduction
8.16.2
see/1
,
tell/1
,
append/1
8.16.3
seeing/1
,
telling/1
8.16.4
seen/0
,
told/0
8.16.5
get0/1
,
get/1
,
skip/1
8.16.6
put/1
,
tab/1
8.17 Term expansion
8.17.1 Definite clause grammars
8.17.2
expand_term/2
,
term_expansion/2
8.17.3
phrase/3
,
phrase/2
8.18 Logic, control and exceptions
8.18.1
abort/0
,
stop/0
,
top_level/0
,
break/0
,
halt/1
,
halt/0
8.18.2
false/0
,
once/1
,
(\+)/1
- not provable,
call/2-11
,
call_with_args/1-11
,
call_det/2
,
forall/2
8.18.3
repeat/0
8.18.4
between/3
,
for/3
8.19 Atomic term processing
8.19.1
atom_length/2
8.19.2
atom_concat/3
8.19.3
sub_atom/5
8.19.4
char_code/2
8.19.5
lower_upper/2
8.19.6
atom_chars/2
,
atom_codes/2
8.19.7
number_atom/2
,
number_chars/2
,
number_codes/2
8.19.8
name/2
8.19.9
new_atom/2
,
new_atom/1
8.19.10
current_atom/1
8.19.11
atom_property/2
8.20 List processing
8.20.1
append/3
8.20.2
member/2
,
memberchk/2
8.20.3
reverse/2
8.20.4
delete/3
,
select/3
8.20.5
subtract/3
8.20.6
permutation/2
8.20.7
prefix/2
,
suffix/2
8.20.8
sublist/2
8.20.9
last/2
8.20.10
flatten/2
8.20.11
length/2
8.20.12
nth/3
8.20.13
max_list/2
,
min_list/2
,
sum_list/2
8.20.14
maplist/2-8
8.20.15
sort/2
,
msort/2
,
keysort/2
sort/1
,
msort/1
,
keysort/1
8.21 Global variables
8.21.1 Introduction
8.21.2
g_assign/2
,
g_assignb/2
,
g_link/2
8.21.3
g_read/2
8.21.4
g_array_size/2
8.21.5
g_inc/3
,
g_inc/2
,
g_inco/2
,
g_inc/1
,
g_dec/3
,
g_dec/2
,
g_deco/2
,
g_dec/1
8.21.6
g_set_bit/2
,
g_reset_bit/2
,
g_test_set_bit/2
,
g_test_reset_bit/2
8.21.7 Examples
8.22 Prolog state
8.22.1
set_prolog_flag/2
8.22.2
current_prolog_flag/2
8.22.3
set_bip_name/2
8.22.4
current_bip_name/2
8.22.5
write_pl_state_file/1
,
read_pl_state_file/1
8.23 Program state
8.23.1
consult/1
,
’.’/2
- program consult
8.23.2
load/1
8.23.3
listing/1
,
listing/0
8.24 System statistics
8.24.1
statistics/0
,
statistics/2
8.24.2
user_time/1
,
system_time/1
,
cpu_time/1
,
real_time/1
8.25 Random number generator
8.25.1
set_seed/1
,
randomize/0
8.25.2
get_seed/1
8.25.3
random/1
8.25.4
random/3
8.26 File name processing
8.26.1
absolute_file_name/2
8.26.2
is_absolute_file_name/1
,
is_relative_file_name/1
8.26.3
decompose_file_name/4
8.26.4
prolog_file_name/2
8.27 Operating system interface
8.27.1
argument_counter/1
8.27.2
argument_value/2
8.27.3
argument_list/1
8.27.4
environ/2
8.27.5
make_directory/1
,
delete_directory/1
,
change_directory/1
8.27.6
working_directory/1
8.27.7
directory_files/2
8.27.8
rename_file/2
8.27.9
delete_file/1
,
unlink/1
8.27.10
file_permission/2
,
file_exists/1
8.27.11
file_property/2
8.27.12
temporary_name/2
8.27.13
temporary_file/3
8.27.14
date_time/1
8.27.15
host_name/1
8.27.16
os_version/1
8.27.17
architecture/1
8.27.18
shell/2
,
shell/1
,
shell/0
8.27.19
system/2
,
system/1
8.27.20
spawn/3
,
spawn/2
8.27.21
popen/3
8.27.22
exec/5
,
exec/4
8.27.23
fork_prolog/1
8.27.24
create_pipe/2
8.27.25
wait/2
8.27.26
prolog_pid/1
8.27.27
send_signal/2
8.27.28
sleep/1
8.27.29
select/5
8.28 Sockets input/output
8.28.1 Introduction
8.28.2
socket/2
8.28.3
socket_close/1
8.28.4
socket_bind/2
8.28.5
socket_connect/4
8.28.6
socket_listen/2
8.28.7
socket_accept/4
,
socket_accept/3
8.28.8
hostname_address/2
8.29 Linedit management
8.29.1
get_linedit_prompt/1
8.29.2
set_linedit_prompt/1
8.29.3
add_linedit_completion/1
8.29.4
find_linedit_completion/2
9 Finite domain solver and built-in predicates
9.1 Introduction
9.1.1 Finite Domain variables
9.2 FD variable parameters
9.2.1
fd_max_integer/1
9.2.2
fd_vector_max/1
9.2.3
fd_set_vector_max/1
9.3 Initial value constraints
9.3.1
fd_domain/3
,
fd_domain_bool/1
9.3.2
fd_domain/2
9.4 Type testing
9.4.1
fd_var/1
,
non_fd_var/1
,
generic_var/1
,
non_generic_var/1
9.5 FD variable information
9.5.1
fd_min/2
,
fd_max/2
,
fd_size/2
,
fd_dom/2
9.5.2
fd_has_extra_cstr/1
,
fd_has_vector/1
,
fd_use_vector/1
9.6 Arithmetic constraints
9.6.1 FD arithmetic expressions
9.6.2 Partial AC:
(#=)/2
- constraint equal,
(#\=)/2
- constraint not equal,
(#<)/2
- constraint less than,
(#=<)/2
- constraint less than or equal,
(#>)/2
- constraint greater than,
(#>=)/2
- constraint greater than or equal
9.6.3 Full AC:
(#=#)/2
- constraint equal,
(#\=#)/2
- constraint not equal,
(#<#)/2
- constraint less than,
(#=<#)/2
- constraint less than or equal,
(#>#)/2
- constraint greater than,
(#>=#)/2
- constraint greater than or equal
9.6.4
fd_prime/1
,
fd_not_prime/1
9.7 Boolean and reified constraints
9.7.1 Boolean FD expressions
9.7.2
fd_reified_in/4
9.7.3
(#\)/1
- constraint NOT,
(#<=>)/2
- constraint equivalent,
(#\<=>)/2
- constraint different,
(##)/2
- constraint XOR,
(#==>)/2
- constraint imply,
(#\==>)/2
- constraint not imply,
(#/\)/2
- constraint AND,
(#\/\)/2
- constraint NAND,
(#\/)/2
- constraint OR,
(#\\/)/2
- constraint NOR
9.7.4
fd_cardinality/2
,
fd_cardinality/3
,
fd_at_least_one/1
,
fd_at_most_one/1
,
fd_only_one/1
9.8 Symbolic constraints
9.8.1
fd_all_different/1
9.8.2
fd_element/3
9.8.3
fd_element_var/3
9.8.4
fd_atmost/3
,
fd_atleast/3
,
fd_exactly/3
9.8.5
fd_relation/2
,
fd_relationc/2
9.9 Labeling constraints
9.9.1
fd_labeling/2
,
fd_labeling/1
,
fd_labelingff/1
9.10 Optimization constraints
9.10.1
fd_minimize/2
,
fd_maximize/2
10 Interfacing Prolog and C
10.1 Introduction
10.2 Including and using
gprolog.h
10.3 Calling C from Prolog
10.3.1 Introduction
10.3.2
foreign/2
directive
10.3.3 The C function
10.3.4 Input arguments
10.3.5 Output arguments
10.3.6 Input/output arguments
10.3.7 Writing non-deterministic C code
10.3.8 Example: input and output arguments
10.3.9 Example: non-deterministic code
10.3.10 Example: input/output arguments
10.4 Manipulating Prolog terms
10.4.1 Introduction
10.4.2 Managing Prolog atoms
10.4.3 Reading Prolog terms
10.4.4 Unifying Prolog terms
10.4.5 Creating Prolog terms
10.4.6 Testing the type of Prolog terms
10.4.7 Comparing Prolog terms
10.4.8 Term processing
10.4.9 Comparing and evaluating arithmetic expressions
10.5 Raising Prolog errors
10.5.1 Managing the error context
10.5.2 Instantiation error
10.5.3 Uninstantiation error
10.5.4 Type error
10.5.5 Domain error
10.5.6 Existence error
10.5.7 Permission error
10.5.8 Representation error
10.5.9 Evaluation error
10.5.10 Resource error
10.5.11 Syntax error
10.5.12 System error
10.6 Calling Prolog from C
10.6.1 Introduction
10.6.2 Example:
my_call/1
- a
call/1
clone
10.6.3 Example: recovering the list of all operators
10.7 Defining a new C
main()
function
10.7.1 Example: asking for ancestors
References
Index
Copyright (C) 1999-2021 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
More about the copyright
Up
Next
AltStyle
によって変換されたページ
(->オリジナル)
/
アドレス:
モード:
デフォルト
音声ブラウザ
ルビ付き
配色反転
文字拡大
モバイル