Logtalk 2.17.1 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1071 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura 2004-06-06 22:46:45 +00:00
parent 0101c09236
commit b25690af56
158 changed files with 4565 additions and 476 deletions

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
@ -46,11 +46,11 @@ variable named $LOGTALKHOME pointing to the Logtalk installation for use with
your Prolog compilers. If you use a csh shell, add the following line to your
~/.cshrc file:
setenv LOGTALKHOME "/your/installation/directory/lgt2170"
setenv LOGTALKHOME "/your/installation/directory/lgt2171"
If you use a bash shell, add the following lines to your ~/.profile file:
LOGTALKHOME="/your/installation/directory/lgt2170"
LOGTALKHOME="/your/installation/directory/lgt2171"
export LOGTALKHOME
When using the provided shell script for installing Logtalk, a symbolic link

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
@ -10,6 +10,47 @@ RELEASE NOTES
=============
2.17.1 - June 7, 2004
Added custom handling of specification of predicate exceptions in info/2
documenting directives when writing XML documenting files (declared as
"exceptions is [Cond1-Term1, Cond2-Term2, ...]"; each pair (Condi, Termi)
represents an error condition and its respective exception).
Changed debugger command "e" to print exception terms instead of exiting
Logtalk session.
Corrected a compilation error with B-Prolog due to operator priorities.
Corrected a possible problem with the redefinition of loaded entities that
define (possibly at runtime) dynamic predicates. All clauses for an entity
dynamic predicates are retracted before loading the new entity definition.
Corrected a potential bug when pretty printing terms with variables in the
debugger and in the created XML documenting files.
Added four more DCGs examples ("walker movements", "iterative shell command
parsing", "bill of materials", and "command language").
New "puzzles" and "metainterpreters" examples.
Added a mode bundle for the SubEthaEdit 2.x (MacOS X) text editor providing
syntax coloring for editing Logtalk source files. Optimized some of the
regular expressions in the syntax coloring files for the Kate/Kwrite and Vim
text editors.
Removed predicate nth/3 from library entities listp, list, and difflist.
Replaced by the predicates nth0/3 and nth1/3. Added new predicates nth1/4
and nth0/4.
Updated the config file for Quintus Prolog to make use of the "files"
library.
Added experimental implementations for some Prolog compilers of the library
portable protocol for operating system access (systemp.lgt). See the file
library/experimental/NOTES for details.
2.17.0 - April 26, 2004
Added built-in debugging support implemented through the definition of a

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
@ -79,3 +79,6 @@ the compiler.
Logtalk version 2.16.2 changed the possible option values of the read-only
compiler option "startup_message" to "none", "banner", and "flags". Default
value is "flags" (print both banner and default flag values).
Logtalk version 2.17.1 removes predicate nth/3 from library entities listp,
list, and difflist (replaced by the predicates nth0/3 and nth1/3).

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
@ -66,6 +66,9 @@ lpa
metapredicates
example of using metapredicates in Logtalk objects
metainterpreters
some examples of simple metainterpreters
mi
multi-inheritance examples
@ -94,6 +97,9 @@ polygons
profiling
examples of using of events and monitors to implement profilers
puzzles
several examples of logical puzzles
reflection
example of a simple class-based reflective system

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -22,7 +22,7 @@
set_cv(Value) :-
retractall(cv_(_)), % retract old cv value from this class
retractall(cv_(_)), % retract old cv value from this class
asserta(cv_(Value)). % assert the new value in this class

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
@ -9,5 +9,33 @@ Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
To load all entities in this example consult the dcgs.loader
utility file (note that this is a Prolog file).
This folder contains examples of using DCGs inside objects and
categories.
This folder contains the following examples of using DCGs inside
objects and categories:
calculator
canonical DCG example of parsing arithmetic expressions
bom
bill of materials DCG example (see below for original source)
sentence
simple parsing of natural language sentences
parsetree
same as above but building and returning the parse tree
xml
conversion between XML and Prolog terms
url
parsing of URLs, decomposing them in components
shell
parsing of coomand-line shell commands
faa
command language DCG example (see below for original source)
walker
parsing of walker movements and calculation of distance
travelled
This folder contains two examples of DCGs (bom and faa) adopted with
permission from the Amzi! Prolog documentation. The documentation is
available on-line in HTML format at the URL:
http://www.amzi.com/
Please refer to the book for more information on the original examples.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
@ -14,7 +14,7 @@ Result = -9
yes
% recognizing gramatically correct sentences
% recognizing gramatically correct sentences:
| ?- sentence::parse([the, girl, likes, the, boy], Result).
@ -27,7 +27,7 @@ Result = false
yes
% generating parse trees for sentences
% generating parse trees for sentences:
| ?- parsetree::parse([the, girl, likes, the, boy], Tree).
@ -35,7 +35,38 @@ Tree = Tree = s(np(d(the), n(girl)), vp(v(likes), np(d(the), n(boy))))
yes
% conversion between compound terms and XML
% bill of materials example:
| ?- bom::parts(bike, L).
L = [frame, crank, pedal, pedal, chain, spokes, rim, hub, spokes, rim, hub]
yes
| ?- bom::parts(wheel, L).
L = [spokes, rim, hub]
yes
% parsing command-line shell input:
| ?- shell::parse("pwd; cd ..; ls -a", L).
L = [pwd,'cd ..','ls -a'] ?
yes
% walker movements:
| ?- walker::walk([n(5), e(4), s(2), nw(8), s(5), se(1), n(4)], Ending).
Ending = -0.94974746830583223,6.9497474683058318 ?
yes
% conversion between compound terms and XML:
| ?- xml::convert(word(child, children), word(singular, plural), XML).
@ -49,7 +80,7 @@ Interpretation = word(singular, plural)
yes
% parsing URLs
% parsing URLs:
| ?- url::parse("http://www.logtalk.org", Components).
@ -75,3 +106,20 @@ yes
Components = [protocol(http), address([193, 136, 64, 5]), path([files, update]), file('')]
yes
% command language example:
?- faa::main.
Fly Amzi! Air
enter command> list flights
aa101
aa102
aa103
enter command> book elana aa102
enter command> book tom aa102
enter command> list passengers aa102
elana
tom
enter command> exit
yes

View File

@ -0,0 +1,33 @@
:- object(bom).
:- info([
version is 1.0,
date is 2004/5/11,
author is 'Paulo Moura',
comment is 'Adaptation of the bill of materials DCG example from the Amzi! Prolog manual.']).
:- public(parts/2).
:- mode(parts(+atom, -list), one).
:- info(parts/2, [
comment is 'Returns the list of parts for building an object.',
argnames is ['Object', 'Parts']]).
parts(Object, Parts) :-
phrase(Object, Parts).
bike --> frame, drivechain, wheel, wheel.
wheel --> spokes, rim, hub.
drivechain --> crank, pedal, pedal, chain.
spokes --> [spokes].
crank --> [crank].
pedal --> [pedal].
chain --> [chain].
rim --> [rim].
hub --> [hub].
frame --> [frame].
:- end_object.

View File

@ -9,4 +9,8 @@
verbs,
sentence,
url,
xml])).
xml,
shell,
walker,
bom,
faa])).

View File

@ -0,0 +1,94 @@
:- object(faa).
:- info([
version is 1.0,
date is 2004/5/10,
author is 'Paulo Moura',
comment is 'Adaptation of the command language DCG example from the Amzi! Prolog manual.']).
:- public(main/0).
:- mode(main, one).
:- info(main/0, [
comment is 'Starts iteractive command language interpreter.']).
:- private(booked/2).
:- dynamic(booked/2).
:- mode(booked(?atom, ?atom), zero_or_more).
:- info(booked/2, [
comment is 'Booked places in flight.',
argnames is ['Passenger', 'Flight']]).
main :-
write('Fly Amzi! Air'), nl,
repeat,
do_command(Command),
Command == exit.
do_command(Command) :-
write('enter command> '),
read_tokens(Tokens),
phrase(command(List), Tokens),
Command =.. List,
call(Command),
!.
read_tokens(Tokens) :-
read_codes(Codes),
codes_to_tokens(Codes, Tokens).
read_codes(Codes) :-
get_code(Code),
read_codes(Code, Codes).
read_codes(10, [[]]) :-
!.
read_codes(13, [[]]) :-
!.
read_codes(32, [[]| Rest]) :-
!, read_codes(Rest).
read_codes(Code, [[Code| Codes]| Rest]) :-
read_codes([Codes| Rest]).
codes_to_tokens([], []).
codes_to_tokens([List| Lists], [Token| Tokens]) :-
atom_codes(Token, List),
codes_to_tokens(Lists, Tokens).
command([Op| Args]) --> operation(Op), arguments(Args).
arguments([Arg| Args]) --> argument(Arg), arguments(Args).
arguments([]) --> [].
operation(report) --> [list].
operation(book) --> [book].
operation(exit) --> ([exit]; [quit]; [bye]).
argument(passengers) --> [passengers].
argument(flights) --> [flights].
argument(Flight) --> [Flight], {flight(Flight)}.
argument(Passenger) --> [Passenger].
flight(aa101).
flight(aa102).
flight(aa103).
report(flights) :-
flight(Flight),
write(Flight), nl,
fail.
report(_).
report(passengers, Flight) :-
booked(Passenger, Flight),
write(Passenger), nl,
fail.
report(_, _).
book(Passenger, Flight) :-
assertz(booked(Passenger, Flight)).
exit.
:- end_object.

View File

@ -0,0 +1,54 @@
:- object(shell).
:- info([
version is 1.0,
date is 2004/4/29,
author is 'Paulo Moura',
comment is 'Simple example of command-line shell parsing.']).
:- public(parse/2).
:- mode(parse(@list, -list), zero_or_one).
:- info(parse/2, [
comment is 'Parses a sequence of commands.',
argnames is ['Sequence', 'Commands']]).
parse(Sequence, Commands) :-
phrase(commands(Commands), Sequence).
commands([C| Cs]) -->
command(C), separator, commands(Cs).
commands([C]) -->
command(C).
separator --> ";".
whitespace --> " ", whitespace.
whitespace --> [].
command(Cd) -->
whitespace, "cd", whitespace, cdargs(Args), whitespace,
{atom_concat(cd, Args, Cd)}.
command(Ls) -->
whitespace, "ls", whitespace, lsargs(Args), whitespace,
{atom_concat(ls, Args, Ls)}.
command(pwd) -->
whitespace, "pwd", whitespace.
cdargs(' ~') --> "~".
cdargs(' ..') --> "..".
cdargs(' .') --> ".".
cdargs('') --> [].
lsargs(' -l') --> "-l".
lsargs(' -a') --> "-a".
lsargs('') --> [].
:- end_object.

View File

@ -0,0 +1,43 @@
:- object(walker).
:- info([
version is 1.0,
date is 2004/4/29,
author is 'Paulo Moura',
comment is 'Walker movements.']).
:- public(walk/2).
:- mode(walk(@list, -position), one).
:- info(walk/2, [
comment is 'Parses a sequence of walker moves, returning ending position.',
argnames is ['Moves', 'Ending']]).
walk(Moves, Ending) :-
phrase(walk(Ending), Moves).
walk(Ending) -->
moves((0, 0), Ending).
moves(Start, Ending) -->
move(Start, Temp), moves(Temp, Ending).
moves(Ending, Ending) -->
[].
move((X0, Y0), (X, Y)) --> [ n(S)], {X is X0, Y is Y0 + S}.
move((X0, Y0), (X, Y)) --> [ne(S)], {X is X0 + S / sqrt(2), Y is Y0 + S / sqrt(2)}.
move((X0, Y0), (X, Y)) --> [ e(S)], {X is X0 + S, Y = Y0}.
move((X0, Y0), (X, Y)) --> [se(S)], {X is X0 + S / sqrt(2), Y is Y0 - S / sqrt(2)}.
move((X0, Y0), (X, Y)) --> [ s(S)], {X is X0, Y is Y0 - S}.
move((X0, Y0), (X, Y)) --> [sw(S)], {X is X0 - S / sqrt(2), Y is Y0 - S / sqrt(2)}.
move((X0, Y0), (X, Y)) --> [ w(S)], {X is X0 - S, Y = Y0}.
move((X0, Y0), (X, Y)) --> [nw(S)], {X is X0 - S / sqrt(2), Y is Y0 + S / sqrt(2)}.
:- end_object.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -0,0 +1,12 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
To load all objects in this library consult the metainterpreters.loader utility
file.
This example contains simple meta-interpreters for pure Prolog encapsulated in
Logtalk objects.

View File

@ -0,0 +1,107 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
% solver - a simple meta-interpreter for pure Prolog:
| ?- solver::assertz(member_of(H, [H| _])).
H = _G178
yes
| ?- solver::assertz((member_of(H, [_| T]) :- member_of(H, T))).
H = _G181
T = _G179
yes
| ?- solver::solve(member_of(2, [1,2,3])).
yes
| ?- solver::solve(member_of(X, [1,2,3])).
X = 1 ;
X = 2 ;
X = 3
yes
% proof_tree - a simple meta-interpreter for pure Prolog that
% construct a proof tree:
| ?- proof_tree::assertz(member_of(H, [H| _])).
H = _G178
yes
| ?- proof_tree::assertz((member_of(H, [_| T]) :- member_of(H, T))).
H = _G181
T = _G179
yes
| ?- proof_tree::solve(member_of(2, [1,2,3]), Tree).
Tree = member_of(2, [1, 2, 3]):- (member_of(2, [2, 3]):-true)
yes
% tracer - a simple meta-interpreter for tracing goal proofs
% using pure Prolog:
| ?- tracer::assertz(member_of(H, [H| _])).
H = _G178
yes
| ?- tracer::assertz((member_of(H, [_| T]) :- member_of(H, T))).
H = _G181
T = _G179
yes
| ?- tracer::trace(member_of(3, [1,2,3])).
1 call: member_of(3, [1, 2, 3])
2 call: member_of(3, [2, 3])
3 call: member_of(3, [3])
3 exit: member_of(3, [3])
2 exit: member_of(3, [2, 3])
1 exit: member_of(3, [1, 2, 3])
yes
| ?- tracer::trace(member_of(X, [1,2,3])).
1 call: member_of(_G187, [1, 2, 3])
1 exit: member_of(1, [1, 2, 3])
X = 1 ;
1 redo: member_of(1, [1, 2, 3])
2 call: member_of(_G187, [2, 3])
2 exit: member_of(2, [2, 3])
1 exit: member_of(2, [1, 2, 3])
X = 2 ;
1 redo: member_of(2, [1, 2, 3])
2 redo: member_of(2, [2, 3])
3 call: member_of(_G187, [3])
3 exit: member_of(3, [3])
2 exit: member_of(3, [2, 3])
1 exit: member_of(3, [1, 2, 3])
X = 3 ;
1 redo: member_of(3, [1, 2, 3])
2 redo: member_of(3, [2, 3])
3 redo: member_of(3, [3])
4 call: member_of(_G187, [])
4 fail: member_of(_G187, [])
3 fail: member_of(_G187, [3])
2 fail: member_of(_G187, [2, 3])
1 fail: member_of(_G187, [1, 2, 3])
no

View File

@ -0,0 +1,6 @@
:- initialization(
logtalk_load([
solver,
proof_tree,
tracer])).

View File

@ -0,0 +1,22 @@
:- object(proof_tree).
:- info([
version is 1.0,
date is 2004/5/2,
author is 'Paulo Moura',
comment is 'Meta-interpreter for pure Prolog.']).
:- public(solve/2).
:- mode(solve(+goal, -tree), zero_or_more).
:- info(solve/2, [
comment is 'Constructs a proof tree for a goal.',
argnames is ['Goal', 'Tree']]).
solve(true, true).
solve((A, B), (PA, PB)) :-
!, solve(A, PA), solve(B, PB).
solve(A, (A :- PB)) :-
clause(A, B), solve(B, PB).
:- end_object.

View File

@ -0,0 +1,23 @@
:- object(solver).
:- info([
version is 1.0,
date is 2004/5/2,
author is 'Paulo Moura',
comment is 'Simple meta-interpreter for pure Prolog.']).
:- public(solve/1).
:- mode(solve(+goal), zero_or_more).
:- info(solve/1, [
comment is 'Proofs goal.',
argnames is ['Goal']]).
solve(true) :-
!.
solve((A, B)) :-
!, solve(A), solve(B).
solve(A) :-
clause(A, B), solve(B).
:- end_object.

View File

@ -0,0 +1,39 @@
:- object(tracer).
:- info([
version is 1.0,
date is 2004/5/5,
author is 'Paulo Moura',
comment is 'A simple tracer meta-interpreter for pure Prolog.']).
:- public(trace/1).
:- mode(trace(+goal), zero_or_more).
:- info(trace/1, [
comment is 'Traces goal proof.',
argnames is ['Goal']]).
trace(Goal) :-
trace(Goal, 1).
trace(true, _) :-
!.
trace((A, B), Depth) :-
!, trace(A, Depth), trace(B, Depth).
trace(A, Depth) :-
write_trace(call, A, Depth),
clause(A, B),
Depth2 is Depth + 1,
trace(B, Depth2),
( write_trace(exit, A, Depth)
;
write_trace(redo, A, Depth),
fail).
trace(A, Depth) :-
write_trace(fail, A, Depth),
fail.
write_trace(Port, Goal, Depth) :-
write(Depth), write(' '), write(Port), write(': '), writeq(Goal), nl.
:- end_object.

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -0,0 +1,13 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
To load all entities in this example consult the puzzles.loader
utility file (note that this is a Prolog file).
This folder contains examples of Logtalk implementations for popular
logical puzzles.

View File

@ -0,0 +1,90 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
% Harry Potter's room of potions logical puzzle:
| ?- potions::potions(P1, P2, P3, P4, P5, P6, P7).
P1 = poison
P2 = wine
P3 = forward
P4 = poison
P5 = poison
P6 = wine
P7 = backwards
yes
% Horse show logical puzzle:
| ?- horses::(horses(S), print(S)).
1 place: april riding doc, the chestnut gelding
2 place: sue riding danny, the bay gelding
3 place: doc riding gopher, the gray gelding
4 place: danny riding april, the white mare
5 place: gopher riding sue, the black mare
S = [h(doc,gelding,chestnut,april,1),h(danny,gelding,bay,sue,2),h(gopher,gelding,gray,doc,3),h(april,mare,white,danny,4),h(sue,mare,black,gopher,5)] ?
yes
% Who Stole the Jam?
| ?- jam_thief::thief(Thief).
Thief = hare
yes
| ?- jam_thief::thief(Thief, Why).
Thief = hare
Why = [trusty(dormouse),liar(hare),trusty(hatter)] ?
yes
% Houses logical puzzle:
| ?- houses::(houses(S), print(S)).
h(norwegian,fox,kool,water,yellow)
h(ukrainian,horse,chesterfield,tea,blue)
h(english,snake,winston,milk,red)
h(japonese,zebra,kent,coffee,green)
h(spanish,dog,lucky,juice,white)
S = [h(norwegian,fox,kool,water,yellow),h(ukrainian,horse,chesterfield,tea,blue),h(english,snake,winston,milk,red),h(japonese,zebra,kent,coffee,green),h(spanish,dog,lucky,juice,white)] ? ;
yes
% Passing a note logical puzzle
| ?- note::(students(S), print(S)).
s(mary,english,red,1)
s(paul,math,yellow,2)
s(josephine,science,green,3)
s(derrick,french,blue,4)
s(alexis,reading,black,5)
S = [s(mary,english,red,1),s(paul,math,yellow,2),s(josephine,science,green,3),s(derrick,french,blue,4),s(alexis,reading,black,5)] ?
yes
| ?- camp_swampy::(beds(S), print(S)).
tim thomas, from maine, sleeps on bed number 1
sam franklin, from north_carolina, sleeps on bed number 2
mac miller, from virginia, sleeps on bed number 3
fred james, from florida, sleeps on bed number 4
john smith, from arkansas, sleeps on bed number 5
S = [b(tim,thomas,maine,1),b(sam,franklin,north_carolina,2),b(mac,miller,virginia,3),b(fred,james,florida,4),b(john,smith,arkansas,5)] ?
yes

View File

@ -0,0 +1,93 @@
/* Mort's Letter from Camp Swampy logical puzzle by Sally Quinn
Dear Mom and Dad,
I am having a great time at camp. There are five guys other in my cabin with me and our beds are all lined up in a row. My bed is up against a wall with a window, and when I sleep on my left side I can look out at the moonlight. The boy whose bed is next to mine is from Maine and Sam is next to him. They have become my best friends. We like to go swimming when we have some free time, which isn't often. They keep us pretty busy around here.
The kids in my cabin come from all over the USA. Mac and the Franklin boy are from neighboring states. John Smith is the only boy from west of the Mississippi River. Fred is from the most southern state and the Thomas kid is from the most northern state. Tim and Sam took a plane to camp, but Mac got to ride in a train.
When Mr. Miller came to visit his son, he took Sam, Fred, Tim, and me out to dinner with them. When Sam's mom writes to him from North Carolina, she always sends him cookies. He shares them with Mac and Tim whose beds are next to his. Are you going to send me some cookies? I really miss the M & M cookies that you bake every weekend.
After lights out, I can whisper to the guys whose beds are close. I don't get to talk to the Smith boy much because his bed is the farthest away from mine. We both take horseback riding, and I get to see him then. The girls cabin is next to ours, and sometimes we can hear the girls talking and laughing. Their cabin counselor must not be as strict as ours.
I am learning how to swim, ride horses, paddle a canoe, and shoot a bow and arrow. Maybe when I get home, I can show you all that I have learned here at camp.
Well, it's bed time now, so I have to go. I love you and send cookies.
Love, Mort
Can you determine who sleeps where in the cabin and where each boy is from?
Who sleeps where? Include first name, last name, and home state.
Published on the web:
http://www.norfacad.pvt.k12.va.us/puzzles/camp.htm
*/
:- object(camp_swampy).
:- info([
version is 1.0,
date is 2004/5/1,
author is 'Paulo Moura',
comment is 'Camp Swampy logical puzzle']).
:- public(beds/1).
:- mode(beds(-list), one).
:- info(beds/1, [
comment is 'Solution to the puzzle.',
argnames is ['Solution']]).
:- public(print/1).
:- mode(print(+list), one).
:- info(print/1, [
comment is 'Pretty print solution to the puzzle.',
argnames is ['Solution']]).
beds(Solution) :-
template(Solution),
member(b(_, _, maine, 1), Solution),
member(b(sam, _, _, 2), Solution),
member(b(_, smith, _, 5), Solution),
next(b(tim, _, _, _), b(sam, _, _, _), Solution),
next(b(sam, _, _, _), b(mac, _, _, _), Solution),
member(b(sam, _, north_carolina, _), Solution),
member(b(john, smith, arkansas, _), Solution),
member(b(fred, _, florida, _), Solution),
member(b(_, thomas, maine, _), Solution),
member(b(mac, _, State1, _), Solution),
member(b(_, franklin, State2, _), Solution),
neighbors(State1, State2),
member(b(_, james, _, _), Solution),
member(b(Name, miller, _, _), Solution),
Name \= sam, Name \= fred, Name \= tim.
neighbors(north_carolina, virginia).
neighbors(virginia, north_carolina).
print([]).
print([Place| Places]) :-
print_boy(Place),
print(Places).
print_boy(b(First, Last, State, Bed)) :-
write(First), write(' '), write(Last), write(', from '), write(State),
write(', sleeps on bed number '), write(Bed), nl.
% b(First, Last, State, Bed)
template([b(_, _, _, 1), b(_, _, _, 2), b(_, _, _, 3), b(_, _, _, 4), b(_, _, _, 5)]).
member(A, [A, _, _, _, _]).
member(B, [_, B, _, _, _]).
member(C, [_, _, C, _, _]).
member(D, [_, _, _, D, _]).
member(E, [_, _, _, _, E]).
next(A, B, [A, B, _, _, _]).
next(B, C, [_, B, C, _, _]).
next(C, D, [_, _, C, D, _]).
next(D, E, [_, _, _, D, E]).
:- end_object.

View File

@ -0,0 +1,89 @@
/* Horse show logical puzzle by Sally Quinn
"YouÕll be late for your own funeral." Her motherÕs words kept repeating in AlexÕs head as she approached the fair grounds-late again! It was a curse, no matter how hard she tried, she was always late. This time she had missed the first class of the local horse show. Not really a major crisis, but she had to report the results to the local paper. She couldnÕt let her boss know that she had arrived late. His last words were, "If you are late one more time, youÕre fired!". She needed to figure out another way to write her article accurately for the paper. As Alex entered the show grounds, she overheard bits of conversation which she jotted down.
"No horse and rider had the same name" ...
.."Danny rode his white mare..."...
..." the horse named April finished behind the rider named Sue and ahead of the black mare"..
..." April rode the Chestnut gelding and finished one place ahead of the bay horse"....
.." The Gray horse named Gopher was not first or last place"....
..."The horse named Doc was first, and the rider named Doc was third"
By looking at a program, Alex discovered that the horses and riders names were Doc, April, Sue, Danny, and Gopher. She knew that April and Sue were the only mares. Does Alex have enough information to fool her boss and write the article accurately?
Published on the web:
http://www.norfacad.pvt.k12.va.us/puzzles/horse.htm
*/
:- object(horses).
:- info([
version is 1.0,
date is 2004/5/1,
author is 'Paulo Moura',
comment is 'Horse show logical puzzle']).
:- public(horses/1).
:- mode(horses(-list), one).
:- info(horses/1, [
comment is 'Solution to the puzzle.',
argnames is ['Solution']]).
:- public(print/1).
:- mode(print(+list), one).
:- info(print/1, [
comment is 'Pretty print solution to the puzzle.',
argnames is ['Solution']]).
horses(Solution) :-
template(Solution),
member(h(doc, _, _, _, 1), Solution),
member(h(_, _, _, doc, 3), Solution),
member(h(april, mare, _, _, _), Solution),
member(h(sue, mare, _, _, _), Solution),
member(h(gopher, gelding, _, _, _), Solution),
member(h(doc, gelding, _, _, _), Solution),
member(h(danny, gelding, _, _, _), Solution),
member(h(gopher, _, gray, _, P), Solution), P \= 1, P \= 5,
member(h(_, mare, white, danny, _), Solution),
member(h(_, _, _, sue, Pi), Solution), member(h(april, _, _, _, Pj), Solution), Pi < Pj,
member(h(april, _, _, _, Pj), Solution), member(h(_, mare, black, _, Pk), Solution), Pj < Pk,
next(h(_, gelding, chestnut, april, _), h(_, _, bay, _, _), Solution),
member(h(_, _, _, gopher, _), Solution),
\+ member(h(N, _, _, N, _), Solution).
print([]).
print([Place| Places]) :-
print_place(Place),
print(Places).
print_place(h(H, S, C, R, P)) :-
write(P), write(' place: '),
write(R), write(' riding '), write(H),
write(', the '), write(C), write(' '), write(S), nl.
% h(Name, Sex, Color, Rider, Place)
template([h(_, _, _, _, 1), h(_, _, _, _, 2), h(_, _, _, _, 3), h(_, _, _, _, 4), h(_, _, _, _, 5)]).
member(A, [A, _, _, _, _]).
member(B, [_, B, _, _, _]).
member(C, [_, _, C, _, _]).
member(D, [_, _, _, D, _]).
member(E, [_, _, _, _, E]).
next(A, B, [A, B, _, _, _]).
next(B, C, [_, B, C, _, _]).
next(C, D, [_, _, C, D, _]).
next(D, E, [_, _, _, D, E]).
:- end_object.

View File

@ -0,0 +1,81 @@
/* Houses logical puzzle: who owns the zebra and who drinks water?
1) Five colored houses in a row, each with an owner, a pet, cigarettes, and a drink.
2) The English lives in the red house.
3) The Spanish has a dog.
4) They drink coffee in the green house.
5) The Ukrainian drinks tea.
6) The green house is next to the white house.
7) The Winston smoker has a serpent.
8) In the yellow house they smoke Kool.
9) In the middle house they drink milk.
10) The Norwegian lives in the first house from the left.
11) The Chesterfield smoker lives near the man with the fox.
12) In the house near the house with the horse they smoke Kool.
13) The Lucky Strike smoker drinks juice.
14) The Japanese smokes Kent.
15) The Norwegian lives near the blue house.
Who owns the zebra and who drinks water?
*/
:- object(houses).
:- info([
version is 1.0,
date is 2004/5/1,
author is 'Paulo Moura',
comment is 'Houses logical puzzle']).
:- public(houses/1).
:- mode(houses(-list), one).
:- info(houses/1, [
comment is 'Solution to the puzzle.',
argnames is ['Solution']]).
:- public(print/1).
:- mode(print(+list), one).
:- info(print/1, [
comment is 'Pretty print solution to the puzzle.',
argnames is ['Solution']]).
houses(Solution) :-
template(Solution), % 1
member(h(english, _, _, _, red), Solution), % 2
member(h(spanish, dog, _, _, _), Solution), % 3
member(h(_, _, _, coffee, green), Solution), % 4
member(h(ukrainian, _, _, tea, _), Solution), % 5
next(h(_, _, _, _, green), h(_, _, _, _, white), Solution), % 6
member(h(_, snake, winston, _, _), Solution), % 7
member(h(_, _, kool, _, yellow), Solution), % 8
Solution = [_, _, h(_, _, _, milk, _), _, _], % 9
Solution = [h(norwegian, _, _, _, _)| _], % 10
next(h(_, fox, _, _, _), h(_, _, chesterfield, _, _), Solution), % 11
next(h(_, _, kool, _, _), h(_, horse, _, _, _), Solution), % 12
member(h(_, _, lucky, juice, _), Solution), % 13
member(h(japonese, _, kent, _, _), Solution), % 14
next(h(norwegian, _, _, _, _), h(_, _, _, _, blue), Solution), % 15
member(h(_, _, _, water, _), Solution), % one of them drinks water
member(h(_, zebra, _, _, _), Solution). % one of them owns a zebra
print([]).
print([House| Houses]) :-
write(House), nl,
print(Houses).
% h(Nationality, Pet, Cigarette, Drink, Color)
template([h(_, _, _, _, _), h(_, _, _, _, _), h(_, _, _, _, _), h(_, _, _, _, _), h(_, _, _, _, _)]).
member(A, [A, _, _, _, _]).
member(B, [_, B, _, _, _]).
member(C, [_, _, C, _, _]).
member(D, [_, _, _, D, _]).
member(E, [_, _, _, _, E]).
next(A, B, [A, B, _, _, _]).
next(B, C, [_, B, C, _, _]).
next(C, D, [_, _, C, D, _]).
next(D, E, [_, _, _, D, E]).
:- end_object.

View File

@ -0,0 +1,69 @@
/* Logical puzzle: Who Stole the Jam?
Someone has stolen the jam! The March Hare said he didn't do it (naturally!) The Mad Hatter proclaimed one of them (the Hare, the Hatter or the Dormouse) stole the jam, but of course it wasn't the Hatter himself. When asked whether the Mad Hatter and March Hare spoke the truth, the Dormouse said that one of the three (including herself) must have stolen the jam.
By employing the very expensive servieces of Dr. Himmelheber, the famous psychiatrist, we eventually learned that not both the Dormous and the March Hare spoke the truth.
Assuming, as we do, that fairy-tale characters either always lie or always tell the truth, it remains to discover who really stole the jam.
(posted on comp.lang.prolog Usenet News group)
*/
:- object(jam_thief).
:- info([
version is 1.0,
date is 2004/4/29,
author is 'Paulo Moura',
comment is 'Who Stole the Jam logical puzzle']).
:- public(thief/1).
:- mode(thief(?atom), zero_or_one).
:- info(thief/1, [
comment is 'Thief that stole the jam.',
argnames is ['Thief']]).
:- public(thief/2).
:- mode(thief(?atom, -list), zero_or_one).
:- info(thief/2, [
comment is 'Thief that stole the jam.',
argnames is ['Thief', 'Justification']]).
thief(Thief) :-
(claim(dormouse, Thief); \+ claim(dormouse, Thief)),
(claim(hare, Thief); \+ claim(hare, Thief)),
(claim(hatter, Thief); \+ claim(hatter, Thief)),
(\+ claim(hare, Thief); \+ claim(dormouse, Thief)).
thief(Thief, [Reason1, Reason2, Reason3]) :-
( claim(dormouse, Thief) -> Reason1 = trusty(dormouse)
; \+ claim(dormouse, Thief) -> Reason1 = liar(dormouse)),
( claim(hare, Thief) -> Reason2 = trusty(hare)
; \+ claim(hare, Thief) -> Reason2 = liar(hare)),
( claim(hatter, Thief) -> Reason3 = trusty(hatter)
; \+ claim(hatter, Thief) -> Reason3 = liar(hatter)),
( \+ claim(hare, Thief)
; \+ claim(dormouse, Thief)).
claim(hare, Thief) :-
Thief \= hare.
claim(hatter, Thief) :-
member(Thief, [hare, hatter, dormouse]),
Thief \= hatter.
claim(dormouse, Thief) :-
member(Thief, [hare, hatter, dormouse]).
member(A, [A, _, _]).
member(B, [_, B, _]).
member(C, [_, _, C]).
:- end_object.

View File

@ -0,0 +1,86 @@
/* Passing A Note logical puzzle by Sally Quinn
Jack has a major crush on Jill. During study hall, he finally gathers all of his courage and writes her a note asking her out on Saturday night. The note passes to five students (who all read it) before it gets to Jill. Just as Jill gets the note, Mrs. Wilson the teacher confiscates it. After reading the note, she wants to know all who were involved in the note passing incident. She questions her students, and receives the following responses.
The girl studying English passed it to Paul who passed it to the girl in green.
Josephine passed it to the boy in blue who gave it to Alexis who was reading.
The girl in black gave it to Jill.
Jack first gave it to Mary who was studying English.
The girl in black who was reading got the note from Derrick.
Mrs. Wilson remembers the following facts from study hall.
Paul was wearing yellow.
Derrick was studying French.
The girl in green was studying science.
From the information given by the students, can you determine what color each culprit was wearing, the subject they were studying and the order that they received the note? Use the chart below to help you.
Published on the web:
http://www.norfacad.pvt.k12.va.us/puzzles/note.htm
*/
:- object(note).
:- info([
version is 1.0,
date is 2004/5/1,
author is 'Paulo Moura',
comment is 'Passing a note logical puzzle']).
:- public(students/1).
:- mode(students(-list), one).
:- info(students/1, [
comment is 'Solution to the puzzle.',
argnames is ['Solution']]).
:- public(print/1).
:- mode(print(+list), one).
:- info(print/1, [
comment is 'Pretty print solution to the puzzle.',
argnames is ['Solution']]).
students(Solution) :-
template(Solution),
next(s(Girl1, english, _, _), s(paul, _, _, _), Solution), girl(Girl1),
next(s(paul, _, _, _), s(Girl2, _, green, _), Solution), girl(Girl2),
next(s(josephine, _, _, _), s(Boy1, _, blue, _), Solution), boy(Boy1),
next(s(Boy1, _, blue, _), s(alexis, reading, _, _), Solution),
member(s(Girl3, _, black, 5), Solution), girl(Girl3),
member(s(mary, english, _, 1), Solution),
next(s(derrick, _, _, _), s(Girl4, reading, black, _), Solution), girl(Girl4),
member(s(paul, _, yellow, _), Solution),
member(s(derrick, french, _, _), Solution),
member(s(Girl5, science, green, _), Solution), girl(Girl5),
member(s(_, math, _, _), Solution),
member(s(_, _, red, _), Solution).
girl(alexis).
girl(josephine).
girl(mary).
boy(derrick).
boy(paul).
print([]).
print([Student| Students]) :-
write(Student), nl,
print(Students).
% h(Name, Subject, Color, Place)
template([s(_, _, _, 1), s(_, _, _, 2), s(_, _, _, 3), s(_, _, _, 4), s(_, _, _, 5)]).
member(A, [A, _, _, _, _]).
member(B, [_, B, _, _, _]).
member(C, [_, _, C, _, _]).
member(D, [_, _, _, D, _]).
member(E, [_, _, _, _, E]).
next(A, B, [A, B, _, _, _]).
next(B, C, [_, B, C, _, _]).
next(C, D, [_, _, C, D, _]).
next(D, E, [_, _, _, D, E]).
:- end_object.

View File

@ -0,0 +1,49 @@
:- object(potions).
:- info([
version is 1.0,
date is 2004/4/29,
author is 'Paulo Moura',
comment is 'Harry Potter potions logical puzzle.']).
:- uses(list).
:- public(potions/7).
:- mode(potions(?atom, ?atom, ?atom, ?atom, ?atom, ?atom, ?atom), zero_or_one).
:- info(potions/7, [
comment is 'Contents of the seven potions.',
argnames is ['P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7']]).
contents([wine, wine, poison, poison, poison, forward, backwards]).
potions(P1, P2, P3, P4, P5, P6, P7) :-
contents(H1),
list::select(P1, H1, H2),
list::select(P7, H2, H3),
P1 \= P7, P1 \= forward, P7 \= forward, % second clue
list::select(P2, H3, H4),
P2 \= poison,
list::select(P3, H4, H5),
P3 \= poison, % third clue
P2 = P6,
list::select(P6, H5, H6), % fourth clue
list::select(P4, H6, H7),
list::select(P5, H7, []),
two_pairs_poison_wine([P1, P2, P3, P4, P5, P6, P7]). % first clue
two_pairs_poison_wine(S) :-
poison_wine_pair(S, R),
poison_wine_pair(R, _).
poison_wine_pair([poison, wine| R], R) :-
!.
poison_wine_pair([_| L], R) :-
poison_wine_pair(L, R).
:- end_object.

View File

@ -0,0 +1,9 @@
:- initialization(
logtalk_load([
potions,
jam_thief,
horses,
houses,
note,
camp_swampy])).

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -6,8 +6,8 @@
:- info([
version is 1.0,
date is 2000/7/24,
version is 1.1,
date is 2004/5/9,
author is 'Esteban Zimanyi, Paulo Moura',
comment is 'Enables the representation of relations between independent objects.']).
@ -49,8 +49,8 @@
add_tuple(Tuple) :-
::descriptor(Descriptor),
list::nth(Position, Tuple, Object),
list::nth(Position, Descriptor, Role),
list::nth1(Position, Tuple, Object),
list::nth1(Position, Descriptor, Role),
::cardinality(Role, _, Maximum),
::plays_role_n_times(Object, Role, Number),
Maximum = Number,
@ -60,8 +60,8 @@
add_tuple(Tuple) :-
::descriptor(Descriptor),
list::nth(Position, Tuple, Object),
list::nth(Position, Descriptor, Role),
list::nth1(Position, Tuple, Object),
list::nth1(Position, Descriptor, Role),
::domain(Role, Domain),
(Domain::strict_instance ->
\+ Domain::valid(Object)
@ -94,8 +94,8 @@
remove_tuple(Tuple) :-
::descriptor(Descriptor),
list::nth(Position, Tuple, Object),
list::nth(Position, Descriptor, Role),
list::nth1(Position, Tuple, Object),
list::nth1(Position, Descriptor, Role),
::cardinality(Role, Minimum, _),
::plays_role_n_times(Object, Role, Number),
Minimum = Number,
@ -123,24 +123,24 @@
setof(Role,
Tuple^Position^ (::tuple(Tuple),
list::member(Object, Tuple),
list::nth(Position, Tuple, Object),
once(list::nth(Position, Descriptor, Role))),
list::nth1(Position, Tuple, Object),
once(list::nth1(Position, Descriptor, Role))),
Roles).
plays_role_in_tuple(Object, Role, Tuple) :-
::descriptor(Descriptor),
::tuple(Tuple),
list::nth(Position, Tuple, Object),
list::nth(Position, Descriptor, Role).
list::nth1(Position, Tuple, Object),
list::nth1(Position, Descriptor, Role).
plays_role_n_times(Object, Role, Number) :-
::descriptor(Descriptor),
list::nth(Position, Descriptor, Role),
list::nth1(Position, Descriptor, Role),
setof(Tuple,
(::tuple(Tuple),
list::nth(Position, Tuple, Object)),
list::nth1(Position, Tuple, Object)),
Tuples),
list::length(Tuples, Number).

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -9,22 +9,24 @@
before_event_registry, after_event_registry,
monitorp, monitor,
event_dbgp, % debugging
event_dbgp, % debugging
event_dbg,
subject, % dependents
subject, % dependents
observer,
hierarchyp, % hierarchies
hierarchyp, % hierarchies
proto_hierarchyp, proto_hierarchy,
class_hierarchyp, class_hierarchy,
metap, meta, % metapredicates
loopp, loop,
randomp, % random
random,
systemp, % os interface protocol
termp, term, % types
atomic,
atom, callable,

View File

@ -1,7 +1,7 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -5,9 +5,9 @@
:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2000/7/24,
date is 2004/5/9,
comment is 'Difference list predicates.']).
@ -178,19 +178,31 @@
once(member(Element, List)).
nth(Position, List, Element) :-
nth(Element, List, 1, Position).
nth0(Position, List, Element) :-
nth(Element, List, 0, Position, _).
nth(Element, List-Back, Position, Position) :-
nth0(Nth, List, Element, Tail) :-
nth(Element, List, 0, Nth, Tail).
nth1(Position, List, Element) :-
nth(Element, List, 1, Position, _).
nth1(Nth, List, Element, Tail) :-
nth(Element, List, 1, Nth, Tail).
nth(Element, List-Back, Position, Position, Tail-Back) :-
List \== Back,
List = [Element| _].
List = [Element| Tail].
nth(Element, List-Back, Count, Position) :-
nth(Element, List-Back, Count, Position, Tail-Back) :-
List \== Back,
List = [_| Tail],
List = [_| List2],
Count2 is Count + 1,
nth(Element, Tail-Back, Count2, Position).
nth(Element, List2-Back, Count2, Position, Tail-Back).
min(List-Back, Min) :-

View File

@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.0
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================

View File

@ -0,0 +1,12 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.17.1
Copyright (c) 1998-2004 Paulo Moura. All Rights Reserved.
=================================================================
This folder contains objects, categories, and protocols whose
implementation is Prolog-compiler dependent. Each sub-folder
contains files specific for a Prolog compiler. All code in this
folder is under development, incomplete, and should be considered
highly experimental.

View File

@ -0,0 +1,120 @@
:- object(system,
implements(systemp)).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2004/6/5,
comment is 'Operating system interface for ALS Prolog.']).
make_directory(Directory) :-
{fail}.
delete_directory(Directory) :-
{fail}.
change_directory(Directory) :-
{change_cwd(Directory)}.
working_directory(Directory) :-
{get_cwd(Directory)}.
directory_exists(Directory) :-
{fail}.
directory_files(Directory, Files) :-
{files(Directory, '*', Files)}.
absolute_file_name(File) :-
{is_absolute_path(File)}.
absolute_file_name(File, Full) :-
{fail}.
file_base_name(File, Base) :-
{path_directory_tail(File, _, Name),
file_extension(Name, Base, _)}.
file_name_extension(File, Extension) :-
{path_directory_tail(File, _, Name),
file_extension(Name, _, Extension)}.
file_name_directory(File, Directory) :-
{path_directory_tail(File, Directory, _)}.
file_exists(File) :-
{exists_file(File)}.
file_modification_time(File, Time) :-
{file_status(File, Status),
dmember(mod_time=Time, Status)}.
file_size(File, Size) :-
{file_status(File, Status),
dmember(size=Size, Status)}.
file_type(File, Type) :-
{file_status(File, Status),
dmember(type=Type, Status)}.
file_permission(File, Permission) :-
{file_status(File, Status),
dmember(permissions=Permissions, Status),
member(Permission, Permissions)}.
delete_file(File) :-
{remove_file(File)}.
rename_file(Old, New) :-
{fail}.
symbolic_link(File, Target) :-
{fail}.
environment_variable(Variable, Value) :-
{getenv(Variable, Value)}.
set_environment_variable(Variable, Value) :-
{fail}.
date_time(Year, Month, Day, Hours, Mins, Secs, 0) :-
{datetime(Year/Month/Day, Hours:Mins:Secs)}.
convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :-
{fail}.
cpu_time(Time) :-
{Time is cputime}.
host_name(Name) :-
{fail}.
:- end_object.

View File

@ -0,0 +1,100 @@
:- use_module(library(system)).
:- object(system,
implements(systemp)).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2004/6/5,
comment is 'Operating system interface for Amzi! Prolog.']).
make_directory(Directory) :-
{mkdir(Directory)}.
delete_directory(Directory) :-
{rmdir(Directory, 0)}.
change_directory(Directory) :-
{chdir(Directory)}.
working_directory(Directory) :-
{curdir(Directory, Directory)}.
directory_exists(Directory) :-
{fail}.
directory_files(Directory, Files) :-
{directory_files(Directory, Files)}.
absolute_file_name(File) :-
{fail}.
absolute_file_name(File, Full) :-
{fail}.
file_exists(File) :-
{file_exists(File)}.
file_modification_time(File, Time) :-
{stat(File, _, _, Time, _, _, _, _, _)}.
file_size(File, Size) :-
{stat(File, _, _, _, Size, _, _, _, _)}.
file_permission(File, Permission) :-
{stat(File, _, _, _, _, Permission, _, _, _)}.
delete_file(File) :-
{delfile(File, 0)}.
rename_file(Old, New) :-
{rename(Old, New)}.
symbolic_link(File, Target) :-
{fail}.
environment_variable(Variable, Value) :-
{get_env_var(Variable, Value)}.
set_environment_variable(Variable, Value) :-
{fail}.
date_time(Year, Month, Day, Hours, Mins, Secs, 0) :-
{date(Year, Month, Day), time(Hours, Mins, Secs)}.
convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :-
{fail}.
cpu_time(Time) :-
{Time is cputime}.
host_name(Name) :-
{current_host(Name)}.
:- end_object.

View File

@ -0,0 +1,101 @@
:- object(system,
implements(systemp)).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2004/6/5,
comment is 'Operating system interface for B-Prolog.']).
make_directory(Directory) :-
{atom_concat('mkdir ', Directory, Command), system(Command)}.
delete_directory(Directory) :-
{atom_concat('rmdir ', Directory, Command), system(Command)}.
change_directory(Directory) :-
{chdir(Directory)}.
working_directory(Directory) :-
{fail}.
directory_exists(Directory) :-
{fail}.
directory_files(Directory, Files) :-
{fail}.
absolute_file_name(File) :-
{fail}.
absolute_file_name(File, Full) :-
{fail}.
file_exists(File) :-
{exists(File)}.
file_modification_time(File, Time) :-
{fail}.
file_size(File, Size) :-
{fail}.
file_type(File, Type) :-
{fail}.
file_permission(File, Permission) :-
{fail}.
delete_file(File) :-
{atom_concat('rm ', File, Command), system(Command)}.
rename_file(Old, New) :-
{atom_concat('mv ', Old, Temp), atom_concat(' ', New, Command), system(Command)}.
symbolic_link(File, Target) :-
{fail}.
environment_variable(Variable, Value) :-
{environ(Variable, Value)}.
set_environment_variable(Variable, Value) :-
{fail}.
date_time(Year, Month, Day, Hours, Mins, Secs, 0) :-
{date(Year, Month, Day), time(Hours, Mins, Secs)}.
convert_time(Time, Year, Month, Day, Hours, Mins, Secs, Milisecs) :-
{fail}.
cpu_time(Time) :-
{cputime(Miliseconds), Time is Miliseconds/1000}.
host_name(Name) :-
{fail}.
:- end_object.

Some files were not shown because too many files have changed in this diff Show More