swi-prolog / issues Goto Github PK
View Code? Open in Web Editor NEWDummy repository for issue tracking
Dummy repository for issue tracking
On registering the admin for the first time a pengine's server is installed you get an error report:
Username (default: "admin")? admin
Password (will be ECHOED)? admin
ERROR: c:/users/szymon/google drive/myapplications/clio+pengines/pengines-master/run.pl:8:
Type error: atomic' expected, found
[97,100,109,105,110]' (a list)
The problem lies in the following clause in the change_passwd.pl library :
check_passwd(File) :-
print_message(warning, pengine(no_admin_passwd)),
nl(user_output),
ask('Username (default: "admin")? ', User, admin),
ask('Password (will be ECHOED)? ', Passwd, _),
change_passwd(File, User, Passwd).
The following revision fixes it:
check_passwd(File) :-
print_message(warning, pengine(no_admin_passwd)),
nl(user_output),
ask('Username (default: "admin")? ', User, admin),
ask('Password (will be ECHOED)? ', Passwd, _),
atom_codes(UserAtom, User),
change_passwd(File, UserAtom, Passwd).
Cheers,
Szymon
I'm updating the OpenBSD package to version 7.x. This report is against 7.2.3 on OpenBSD-current/amd64.
One test is failing:
$ egdb ./swipl
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd6.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./swipl...done.
(gdb) run
Starting program: /usr/ports/pobj/swi-prolog-7.2.3/swipl-7.2.3/src/swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.2.3)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- [test].
SWI-Prolog test suite. To run all tests run ?- test.
true.
?- gmp(shift-3).
Program received signal SIGBUS, Bus error.
0x000003beb539b15c in bt_create_backtrace (buffer=<optimized out>, depth=100,
flags=1) at backtrace.c:72
72 backtrace.c: No such file or directory.
(gdb) bt
#0 0x000003beb539b15c in bt_create_backtrace (buffer=<optimized out>,
depth=100, flags=1) at backtrace.c:72
#1 0x000003be296838bd in save_backtrace (why=0x3be2978f5e4 "out-of-stack")
at os/pl-cstack.c:307
#2 0x000003be295cc942 in outOfStack (stack=0x3be29ad42b8 <PL_local_data+152>,
how=STACK_OVERFLOW_RAISE) at pl-alloc.c:226
#3 0x000003be295ea225 in valueExpression (expr=246, result=0x7f7ffffea890,
__PL_ld=0x3be29ad4220 <PL_local_data>) at pl-arith.c:875
#4 0x000003be295ea886 in pl_is2_va (PL__t0=245, PL__ac=<optimized out>,
PL__ctx=<optimized out>) at pl-arith.c:3464
#5 0x000003be295e102c in PL_next_solution (qid=<optimized out>)
at pl-vmi.c:3555
#6 0x000003be29619d64 in query_loop (goal=25605, loop=1) at pl-pro.c:100
#7 0x000003be29619eca in prologToplevel (goal=25605) at pl-pro.c:403
#8 0x000003be295ca4c5 in PL_toplevel () at pl-fli.c:3964
#9 0x000003bc03500c1d in main (argc=1, argv=0x7f7ffffeada8) at pl-main.c:120
(gdb) frame 1
#1 0x000003be296838bd in save_backtrace (why=0x3be2978f5e4 "out-of-stack")
at os/pl-cstack.c:307
307 frames = backtrace(array, sizeof(array)/sizeof(void *));
(gdb) p array
$1 = {0x3be296838bd <save_backtrace+93>, 0x3bef4b5cf80, 0x3bef4b5cf80,
0xa0dda4894c, 0x274611e092401932, 0x3be29ad4220 <PL_local_data>, 0x0, 0x0,
0x0, 0xb4, 0x1, 0x3be81e33300, 0xe, 0x3be29ad2720 <PL_global_data>,
0x3bea53612a8 <__isthreaded>, 0x16, 0x3be29acea00 <text_atom>,
0x3bea4f2f7ab <malloc+171>, 0x3be29acf6a0 <_PL_mutexes+96>,
0x3bedfc0b9bd <_spinlock+29>, 0x3bee0011520 <_initial_thread>,
0x3be29ad2720 <PL_global_data>, 0x3bee9310480,
0x3bedfc0caf9 <*_libpthread_pthread_mutex_unlock+217>, 0x3bef4b5c7ad,
0x3be29ad2720 <PL_global_data>, 0x3be4dad2c00, 0xe, 0x1000,
0x3bedfc0eb80 <_rthread_findstorage+48>, 0x7f7ffffea1ac, 0x7f7ffffea160,
0x7f7ffffea170, 0x7f7ffffea360, 0xc6, 0xc7, 0x2,
0x3be29ad4220 <PL_local_data>, 0x0, 0x3be295c5aba <PL_unregister_atom+202>,
0x83b85, 0x3bea4ee0a8a <*_libc_mmap+42>, 0x0, 0x7da89eb35cb86338,
0x3be29ad4220 <PL_local_data>, 0x3bea4ec4848 <*_libc_arc4random_buf+328>,
0x3be4f1a4a60, 0x7da89eb35cb86338, 0x3be81e33300, 0x3be6163a0f0,
0x3be81e33300, 0x6, 0x30, 0x3bea4f2cab9 <rbytes_init+25>, 0x3be81e33300,
0xbd3dfab744444ce5, 0xb3f7, 0xbd3dfab744444ce5, 0x3be955ece70,
0x3bed0c85800, 0x3be81e33300, 0x3bea4f2df18 <ofree+264>, 0x1, 0x20, 0x20,
0x20, 0x3bea5e83ec0, 0x30, 0x3be81e33300, 0x3bea4f2f241 <realloc+385>,
0x7f7ffffea310, 0x16295a8c50, 0x7f7ffffea318, 0x3be295aca86, 0x8,
0x3bedfc0eb80 <_rthread_findstorage+48>, 0x20, 0x7f7ffffea4b8,
0x3bea53612a8 <__isthreaded>, 0x18, 0x3be29ad4220 <PL_local_data>,
0x3bed76515e0, 0x1, 0x7f7ffffea7f8, 0x3, 0x3be29655ab0 <mp_realloc+128>,
0x20, 0x7f7ffffea4b0, 0x7f7ffffea7f8, 0x3, 0x7f7ffffea4b8,
0x3be75fcadca <__gmpz_realloc+58>, 0x7f7ffffea39c, 0x7f7ffffea7f8,
0x3be29ad4220 <PL_local_data>, 0x47, 0x1,
0x3bedfc0eb80 <_rthread_findstorage+48>, 0x3be955ecd90, 0x3bec2414560}
(gdb) p sizeof(array)
$2 = 800
(gdb) p sizeof(void *)
$3 = 8
See anything out of place?
I guess backtrace.c is from libexecinfo. So I guess the next thing to do is to add debug symbols there.
Thanks
during the build, swipl -g check_installation,halt -t 'halt(1)'
detects:
Warning: library(bdb) .......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/bdb.html
But the last uri gives a 404...
Compiled latest SWI 7.2.3 from sources and installed.
SWI runs fine
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.2.3)
...
Test machine:
Processor 2.93 GHz Intel Core i7
Memory 4 GB 1333 MHz DDR3
Graphics ATI Radeon HD 5750 1024 MB
Software OS X 10.9.5 (13F1712)
We checked that simple JPL tests run fine.
Then we change the Zahed.java example to contain the following
import java.util.Map;
import org.jpl7.Atom;
import org.jpl7.Compound;
import org.jpl7.Query;
import org.jpl7.Term;
import org.jpl7.Variable;
import org.jpl7.JPL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Zahed {
private static final int NTHREADS = 88;
private static final String SwiPath ="/usr/lib/swipl-6.2.3/";
public static void main(java.lang.String argv[]) throws InterruptedException {
JPL.setDefaultInitArgs(new String[] { "--quiet", "--nosignals" });
JPL.setDTMMode(false);
new Zahed().multiThreadTest();
}
public void multiThreadTest() throws InterruptedException {
System.out.println("Multi-thread test");
List<Thread> threads = new ArrayList<Thread>();
for (int n = 0; n < NTHREADS; n++) {
threads.add(runThread(n));
}
while (!threads.isEmpty()) {
Thread thread = threads.get(0);
// System.out.println("Waiting for " + thread);
thread.join();
threads.remove(thread);
}
}
private Thread runThread(final int n) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
testSimpleQueries(n);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
thread.start();
return thread;
}
private void testSimpleQueries(int n) throws InterruptedException {
new Query("set_prolog_flag(debug_on_error,false)").hasSolution();
String module = "robot_" + n;
String formula = "test :- member(3,[1,2,3,4,5])";
insert(module, formula);
Map<String, Term> res = query(module, "test");
insert(module, "fibo(0,0)");
insert(module, "fibo(1,0)");
insert(module,
"fibo(X,Y):-X>1, X1 is X-1, X2 is X-2, fibo(X1,Y1), fibo(X2,Y2), Y is Y1 + Y2");
query(module, "listing");
res = query(module, "fibo(22,Y)");
}
private void insert(String module, String formula) {
String f = "assert(" + module + ":(" + formula + "))";
// System.out.println(f);
new Query(f).hasSolution();
}
@SuppressWarnings("unchecked")
private Map<String, Term> query(String module, String formula) {
String q = module + ":" + formula;
// System.out.println(q);
return new Query(q).allSolutions()[0];
}
}
we run it . We get many exceptions like this
ERROR: Unhandled exception: load_files/2: No permission to load source `'/usr/lib/swipl-7.2.3/library/lists.pl'' (Non-module file already loaded into module robot_36; trying to load into robot_61)
(Note: It is important to execute all three queries. Without the previous queries, the error does not show)
swipl -f none
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.9-37-gcf7ca1d)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- functor(F,f,10000000000000000000000).
ERROR: functor/3: Cannot represent due to `int64_t'
?-
| catch(functor(F,f,10000000000000000000000),error(E,_),true).
E = representation_error(int64_t).
?- catch(functor(F,f,1000000000000000000),error(E,_),true).
[Thread 1 (main) at Fri Nov 13 18:28:21 2015] pl-prims.c:828: term_size: Assertion failed: ((char *)(p) >= (char *)(__PL_ld->stacks.global.base) && (char *)(p) < (char *)(__PL_ld->stacks.local.base))
C-stack trace labeled "assert_fail":
[0] save_backtrace() at tai_unpack.c:0 [0x7f7d9cbf8dfb]
[1] __assert_fail() at ??:0 [0x7f7d9cbbbd60]
[2] term_size() at pl-prims.c:0 [0x7f7d9cb87e20]
[3] pl_term_size3_va() at pl-prims.c:0 [0x7f7d9cb87eb1]
[4] PL_next_solution() at ??:0 [0x7f7d9cb5081d]
[5] query_loop() at tai_unpack.c:0 [0x7f7d9cb8e6df]
[6] prologToplevel() at tai_unpack.c:0 [0x7f7d9cb8ef3f]
[7] PL_toplevel() at ??:0 [0x7f7d9cb4a265]
[8] /opt/gupu/swipl-devel/bin/swipl(main+0x35) [0x4007e5]
[9] ??() at ??:0 [0x7f7d9c56176d]
[10] /opt/gupu/swipl-devel/bin/swipl(+0x82d) [0x40082d]```
Some of the methods in the C++ interface are not declared as const
though they don't modify *this
. This prevents me from calling e.g. const PlTerm::name()
. I'm aware that the constness of a PlTerm
might be a slightly tricky concept, but since all of the thinking is left to the programmer in the C++ interface anyways, I see no reason to deliberately prevent const PlTerm
usage (and others).
On Debian stretch, kernel 4.0.9-040009.
I installed version 7.2.0-2 and calling edit/0 or edit/1 threw:
ERROR: toplevel: Undefined procedure: edit/0 (DWIM could not correct goal)
Trying the same with version 6.6.6-5 works fine.
4.0.9-040009
I looked (briefly) in the latest swi-prolog guide and could not find a reason for the different behavior.
When Java 8 is installed, there are some difficulties in the build (I'm working with version 6.6.5) dealing with the JPL docs:
"jar" cf ../../jpl.jar jpl/Atom.class jpl/Compound.class
jpl/Float.class jpl/Integer.class jpl/JRef.class
jpl/JPLException.class jpl/JPL.class jpl/PrologException.class
jpl/Query.class jpl/Term.class jpl/Util.class jpl/Variable.class
jpl/Version.class jpl/fli/atom_t.class jpl/fli/BooleanHolder.class
jpl/fli/DoubleHolder.class jpl/fli/engine_t.class jpl/fli/fid_t.class
jpl/fli/functor_t.class jpl/fli/IntHolder.class
jpl/fli/Int64Holder.class jpl/fli/LongHolder.class
jpl/fli/module_t.class jpl/fli/ObjectHolder.class
jpl/fli/PointerHolder.class jpl/fli/predicate_t.class
jpl/fli/Prolog.class jpl/fli/qid_t.class jpl/fli/StringHolder.class
jpl/fli/term_t.class
jpl/fli/atom_t.java:38: error: block element not allowed within inline
element <i>: p
* Copyright (C) 1998 Fred Dushin<p>
^
jpl/fli/atom_t.java:43: error: tag not allowed here: <p>
* of the License, or (at your option) any later version.<p>
^
jpl/fli/atom_t.java:48: error: tag not allowed here: <p>
* GNU Library Public License for more details.<p>
^
jpl/fli/atom_t.java:50: error: malformed HTML
* @author Fred Dushin <[email protected]>
^
jpl/fli/atom_t.java:50: error: bad use of '>'
* @author Fred Dushin <[email protected]>
^
Generating ../../docs/java_api/javadoc/jpl/fli/BooleanHolder.html...
jpl/fli/BooleanHolder.java:37: error: block element not allowed within
inline element <i>: p
* Copyright (C) 1998 Fred Dushin<p>
^
jpl/fli/BooleanHolder.java:42: error: tag not allowed here: <p>
* of the License, or (at your option) any later version.<p>
^
jpl/fli/BooleanHolder.java:47: error: tag not allowed here: <p>
* GNU Library Public License for more details.<p>
^
jpl/fli/BooleanHolder.java:49: error: malformed HTML
* @author Fred Dushin <[email protected]>
^
jpl/fli/BooleanHolder.java:49: error: bad use of '>'
* @author Fred Dushin <[email protected]>
^
Generating ../../docs/java_api/javadoc/jpl/fli/DoubleHolder.html...
jpl/fli/DoubleHolder.java:37: error: block element not allowed within
inline element <i>: p
* Copyright (C) 1998 Fred Dushin<p>
^
jpl/fli/DoubleHolder.java:42: error: tag not allowed here: <p>
* of the License, or (at your option) any later version.<p>
^
jpl/fli/DoubleHolder.java:47: error: tag not allowed here: <p>
* GNU Library Public License for more details.<p>
^
jpl/fli/DoubleHolder.java:49: error: malformed HTML
* @author Fred Dushin <[email protected]>
^
jpl/fli/DoubleHolder.java:49: error: bad use of '>'
* @author Fred Dushin <[email protected]>
^
Generating ../../docs/java_api/javadoc/jpl/fli/engine_t.html...
jpl/fli/engine_t.java:35: error: block element not allowed within
inline element <i>: p
* Copyright (C) 1998 Fred Dushin<p>
(and many more errors similar to these). The difficulty seems to be that Java 8 strictly enforces Javadoc comment styles, unlike Java 7.
JPL does not name nested (static) classes the way that Java does.
As expected,
?- jpl_new('java.awt.geom.GeneralPath', [], P).
P = @'J#00000000000034949976'.
but
?- jpl_new('java.awt.geom.Path2D.Float', [], P).
ERROR: Java exception: java.lang.NoClassDefFoundError: java/awt/geom/Path2D/Float
(Path2D is an abstract class which has two inner classes (Float and Double), and GeneralPath extends Path2D.Float but is defined in its own .java/.class file.)
It is possible to create an instance of a nested (static) class by calling
?- jpl_new('java.awt.geom.Path2D$Float', [], P).
P = @'J#00000140300878088832'.
presumably because that's the name of the class file (java/awt/geom/Path2D$Float.class). It would certainly be nicer to be able to use the Java class-naming convention rather than rely on how javac stores class definitions in the filesystem. In any case, it's not well documented and non-obvious.
Version of SWI-Prolog:
AMD64, Multi-threaded, version 6.6.6
Operating System:
64 Bit Windows 7
How to reproduce the issue:
A full program is not needed, just use a query with sleep
e.g. ?- sleep(10).
While sleep is in action, try to abort (strg c -> a).
The action will not be aborted, but lead to the following message:
Foreign predicate system:sleep/1 did not clear exception: $aborted
Especially problematic when working with infinite lists, as testing is only possible if SWI-Prolog is shut down completely after a run, as the program does not terminate and cannot be aborted either.
The following will segfault:
user:portray(t(X)) :- print(X).
tests(t(M),M,1).
tests(t(Rest),M,N) :- N>1, succ(N1,N), tests(Rest,M,N1).
main :-
tests(A,'world',10000),
format('Hello: ~p~n',[A]).
Bug occurs with SWI-Prolog 6.6.6 and 7.2.3 on Ubuntu 14.04 and Debian Jessie.
As I already reported to http://www.swi-prolog.org/bugzilla/show_bug.cgi?id=145, following three files can be used only for non-commercial purposes which hinders their redistribution by commercial-oriented parties:
bench/unify.pl
bench/simple_analyzer.pl
man/txt/dvi2tty/dvi2tty.c
The questionable license is:
All rights reserved. This program may be freely used and modified for
non-commercial purposes provided this copyright notice is kept unchanged.
This is still issue in the latest 7.2.0 version.
I needed a Cancel button on this "Create user profile" page.
I had to delete all of the cookies I had fro the swi-prolog site to workaround this issue.
The issue came about through the following steps:
I was reading the manual at http://www.swi-prolog.org/pldoc/refman/
I wanted to add a comnment.
Therefore I needed to add a login.
I chose google from the authorization method.
It turns out my (active) google account was the wrong one.
In another tab I log out of the active google account, login to the one I want to use.
However this has no effect on the swi-prolog server , I keep getting redirected to the "Create user profile" page and it has only the old google id information in it's fields, url is: http://www.swi-prolog.org/user/create_profile?return=/pldoc/doc_for?object%3Dmanual
I need a Cancel button on this "Create user profile" page.
This wouldn't be such a problem but I (now) always get redirected to the "Create user profile" page even if I try to read the manual using this url: http://www.swi-prolog.org/pldoc/refman/
The documentation for the format_time/3 predicate states that the %I conversion prints "the hour as a decimal number using a 12-hour clock (range 01 to 12).", so you can use it to print out "American" style time, with AM/PM.
It doesn't, however, it prints out values in the range 00-11, which is incorrect. For instance:
?- D = date(2014,11,6,12,30,0,0,'UTC',false), format_time(current_output, "%I:%M %p", D).
00:30 pm
D = date(2014, 11, 6, 12, 30, 0, 0, 'UTC', false).
This should print out "12:30 pm", but it prints out "00:30 pm" instead. In addition, the %r conversion also has this problem:
?- D = date(2014,11,6,12,30,0,0,'UTC',false), format_time(current_output, "%r", D).
00:30:00 pm
D = date(2014, 11, 6, 12, 30, 0, 0, 'UTC', false).
Also, according to the documentation, the %p conversion should print out "AM" or "PM" in upper-case (this is also the behavior of strftime(), I believe), but it actually prints it in lower-case.
I get these results on SWI-Prolog 7.1.16 on Mac OS X, if it makes a difference.
Prolog pack licensing information is currently a bit muddled. It's often quite difficult to determine which license applies to a specific pack without hunting through the pack source code.
Browsing through some of the packs shows that licensing information is hit-or-miss. Some of the common things I see are:
A first step could be to support a pack.pl license/1 term:
license(License)
License under which the pack has been published. If the pack has been released under multiple licenses, include multiple license/1 terms.
It would then be nice if there was a mechanism to encourage pack authors include a license/1 term in their pack.pl file if no toplevel LICENSE file existed. Perhaps whenever a pack archive is made available for the first time via pack_install/1 a warning message could be printed if a license/1 term is missing?
Shouldn't there be a cut in the 2nd clause of
select_([], _, _, []).
select_([X|XList], X, Y, [Y|YList]) :-
select_(XList, X, Y, YList).
select_([X0|XList], X, Y, [X0|YList]) :-
select_(XList, X, Y, YList).
to suppress the bogus 2nd solution in
?- select(a(_), [a(1)], a(2), X).
X = [a(2)] ;
X = [a(1)].
sorry I'm not confident enough to submit a patch ;-)
In 7.3.30 64-bit on Windows 10 Pro, Environment variables longer than 1019 chars are reported by getenv/2 with correct length but with incorrect chars from 1020 onwards, perhaps including nul, sometimes other text.
This batch file (renamed from .bat to .txt for GitHub upload) demonstrates it:
t.txt
set z=..................................................
set z=%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%%z%
set z=%z%abcdefghijklmnopqrstuvwxyz
rem 50*20 = 1000 dots plus alphabet = 1026 chars
swipl-win.exe -g 'getenv(z,A),atom_length(A,N),write(N-A),nl'
NB this is not (simply) due to length restrictions in Windows; Java correctly offers env vars of this length and longer e.g. 5000 chars.
Typically, only PATH reaches this length, and jpl:setup_jvm barfs on PATH elements containing nul, which is how I spotted this.
cheers - Paul Singleton
Hello!
I downloaded SWI Prolog from http://www.swi-prolog.org/download/stable (http://www.swi-prolog.org/download/stable/src/swipl-7.2.3.tar.gz). I build the software according to INSTALL and README.linux
I created a C program that calls SWI Prolog; I could successfully compile and link the C code by manually providing suitable paths using -I and -L on the gcc command line. However, I could not run it, as the default installation path of swipl shared library is not contained in /etc/ld.so.conf. The shared library is copied to the predefined library directory (/usr/local/lib64/swipl-7.2.3/lib/x86_64-linux/ in my case), but it seems, ldconfig is not called correctly afterwards. So the linker cannot resolve the reference to the shared lib when the binary is executed, as the libswipl is not in the ldconfig cache.
I know there is a workaround using LD_LIBRARY_PATH, but that is just for debugging purposes.
The version of SWI-Prolog you use: 7.2.3
The operating system: openSuse Linux 13.2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SWI-Prolog.h>
int main(void)
{
static char * av[] = {"kb1.plg", NULL};
if( ! PL_initialise(1,av))
{
fprintf(stderr, "error initializing");
PL_halt(1);
}
else
{
printf("success initializing!");
}
PL_halt(0);
return 0;
}
I'm not an experienced user but I've observed the following issue.
The http_cors.pl library in the cliopatria/lib/http location, that comes with the recent cliopatria installation package, seems to be causing trouble when making a pengine call to the cliopatria server from javascript code in Chrome. This ends up in the following error report:
Everything still works fine in IE or when making a call from another prolog process. Can't explain the precise reasons, but things got fixed when I deleted the file and thus (probably) redirected cliopatria to use the corresponding library from the swipl repository.
Cheers,
Szymon
dmsg(M):- format(user_error,'~N~q.~n',[M]),flush_output(user_error).
tAA:verify_attributes(Var, Value, [get_attrs(CVar,AttrsNow),dmsg(tAA:goal_for(Name,Attrs=AttrsNow))]):- copy_term(Var,CVar),sformat(Name,'~w',Var), ignore(get_attrs(Var,Attrs)),dmsg(tAA:va(Var,Value,[])=Attrs).
tBB:verify_attributes(Var, Value, [get_attrs(CVar,AttrsNow),dmsg(tBB:goal_for(Name,Attrs=AttrsNow))]):- copy_term(Var,CVar),sformat(Name,'~w',Var), ignore(get_attrs(Var,Attrs)),dmsg(tBB:va(Var,Value,[])=Attrs).
va(X):- put_attr(X,tAA,'AAA').
vb(X):- put_attr(X,tBB,'BBB').
% swi prolog ignores peer wakeups ..
The following output is incorrect...
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.15-29-g6a6915a)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- va(A),vb(B),A=B.
tBB:va(_G294746,_G294739,[])=att(tBB,'BBB',[]).
tBB:goal_for("_G294746",att(tBB,'BBB',[])=att(tBB,'BBB',[])).
A = B,
put_attr(B, tAA, 'AAA').
2 ?- vb(B),va(A),A=B.
tAA:va(_G294734,_G294727,[])=att(tAA,'AAA',[]).
tAA:goal_for("_G294734",att(tAA,'AAA',[])=att(tAA,'AAA',[])).
B = A,
put_attr(A, tBB, 'BBB').
Here is this corrected...
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.15-33-g5524040-DIRTY)
1 ?- va(A),vb(B),A=B.
tAA:va(_G319347,_G319354,[])=att(tAA,'AAA',[]).
tBB:va(_G319354,_G319347,[])=att(tBB,'BBB',[]).
tBB:goal_for("_G319354",att(tBB,'BBB',[])=att(tBB,'BBB',[])).
tAA:goal_for("_G319347",att(tAA,'AAA',[])=att(tAA,'AAA',[])).
A = B,
put_attr(B, tAA, 'AAA').
2 ?- vb(B),va(A),A=B.
tAA:va(_G319354,_G319347,[])=att(tAA,'AAA',[]).
tBB:va(_G319347,_G319354,[])=att(tBB,'BBB',[]).
tBB:goal_for("_G319347",att(tBB,'BBB',[])=att(tBB,'BBB',[])).
tAA:goal_for("_G319354",att(tAA,'AAA',[])=att(tAA,'AAA',[])).
B = A,
put_attr(A, tBB, 'BBB').
Dears,
I am working to integrate prolog with the sql server 2016, Prolog can insert rows to the database
and read from it, I faced a problem, when I tried to insert a row which contains date colum the error "ༀERROR: ODBC: State S1003: [Microsoft][ODBC Driver Manager] Program type out of range"
Kindly note that it works fine if the row does not have date column
anybody can help me?
?- reverse(Xs,[a]).
Xs = [a] ;
false.
Expected: Xs = [a]. No open choice point.
Indexing heuristics is misguided.
Fix: Exchange arguments of auxiliary predicate lists:reverse/4 from
reverse(Es,Xs0,Xs,Bound) to reverse(Es,Bound,Xs0,Xs)
Item#675
Specs:
I misused use sort(+List, -Sorted)
, calling it with Sorted
as a ground term and List
as partially instantiated, like so:
?- sort([A,B,3], [1,2,3]).
A = 1,
B = 2.
This succeeds just as you'd expect (if ignorant of proper usage). Unaware of my mistake, I continued to misuse the predicate. However, I soon I discovered that it seemed to fail or succeed depending on which elements of List
are left free:
?- sort([1,2,C], [1,2,3]).
false.
I now understand that this is because List
will first be sorted to the standard order of terms ([C,1,2]
in this case) and that does not unify with [1,2,3]
. Moreover, I am aware that I shouldn't use the predicates contrary to their documented modes. My misunderstanding has been corrected.
However, in ##prolog, I was encouraged to file this issue just in case it crossed over to a level of weirdness that would need addressing.
To that end, here are some other strange-seeming results that can be obtained:
?- sort([1,B,3], [1,B,3]).
B = 1.
?- sort([B,A,3], [2,3,3]). % sort is meant to remove duplicates
B = 2,
A = 3.
These might be considered alongside the behavior that Boris remarks in the sort/2
documentation.
(I'll also throw in: Thanks for all the hard work on this wonderful software!)
In Swipl 7.3.33 (downloaded as binary from http://www.swi-prolog.org/download/devel/bin/SWI-Prolog-7.3.33.dmg) has issues with the command line swipl
(swipl is hashed (/Applications/SWI-Prolog.app/Contents/MacOS/swipl)
Hello.
I have implemented a predicate ith0_list_member/3
which is based on clpfd.
It sucks performance-wise, but that's besides the point.
The point is that SWI-Prolog crashes (sometimes, sometimes not):
HTH! Thank you!
All the best, stefan.
stefan@Lenovo-G510 ~ $ uname -a Linux Lenovo-G510 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux stefan@Lenovo-G510 ~ $ swipl Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.15) Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). ?- use_module(library(clpfd)). true. ?- [user]. ith0_list_member(0, [E|_], E). ith0_list_member(I, [_|Es], X) :- I #> 0, I0 #= I-1, ith0_list_member(I0, Es, X). |: |: |: |: |: true. ?- length(Es,1000), time((between(1,1000,_),ith0_list_member(N,Es,X),false;true)). [Thread 1 (main) at Wed Jan 20 18:22:20 2016] pl-attvar.c:174: assignAttVar: Assertion failed: (__PL_ld->stacks.global.top)+8 <= (__PL_ld->stacks.global.max) && (__PL_ld->stacks.trail.top)+6 <= (__PL_ld->stacks.trail.max) C-stack trace labeled "assert_fail": [0] PL_strtod() at ??:? [0x7f8200265420] [1] __assert_fail() at ??:? [0x7f8200228331] [2] destroySourceFile() at ??:? [0x7f820023393b] [3] destroySourceFile() at ??:? [0x7f8200233a51] [4] PL_next_solution() at ??:? [0x7f82001c2af0] [5] pl_skip_list3_va() at ??:? [0x7f82001fc28e] [6] pl_skip_list3_va() at ??:? [0x7f82001fca10] [7] PL_toplevel() at ??:? [0x7f82001b98cd] [8] swipl(main+0x2d) [0x40083d] [9] __libc_start_main() at ??:? [0x7f81ffbcbec5] [10] swipl(+0x881) [0x400881] stefan@Lenovo-G510 ~ $
7.2.3 64-bit Windows 7 Pro
Working directory is NTFS shared folder from another PC; I can create and append to files in it, but access_file/2 says I can't:
3 ?- open('foo', append, S), write(S, bar), close(S).
S = (0000000004879650).
4 ?- access_file('foo', append).
false.
5 ?- open('foo', append, S), write(S, bar), close(S).
S = (0000000004879560).
foo is created & gets barbar as expected.
Am content to work around this; NTFS permissions are complex, I don't fully understand them; this may be due to local peculiarities.
Paul Singleton
Install Ubuntu 16.04
from Bash do
uname -v
the answer should be
#43-Ubuntu SMP Wed Jun 8 19:27:37 UTC 2016
if you're on the right version
swipl
at the query, emacs.
In the editor type this_is_a_test
Expected: Underscores appear
Observed: Underscores don't appear
Observed: Correct behavior, underscores appear
Dear all,
I just found out (the hard way) that ord_subtract/3 is not based on unification like its unordered sister:
?- subtract([1,2],[A],R).
A = 1,
R = [2].
?- ord_subtract([1,2],[A],R).
R = [1, 2].
Jan, is this a bug or a feature? If the latter, this should be made clear from the documentation....
From the current man pages:
subtract(+Set, +Delete, -Result)
Delete all elements in Delete from Set. Deletion is based on unification using memberchk/2. The complexity is |Delete|*|Set|.
ord_subtract(+InOSet, +NotInOSet, -Diff)
Diff is the set holding all elements of InOSet that are not in NotInOSet.
Pertaining to #38 "That is an issue between GNU libreadline and Terminal. Prolog is not involved. It seems to depend on the version of libreadline used and the version of Terminal used. Please report with libreadline "
Well, if so, why does the delete key work fine in Terminal normally but not when swipl is run?
The same is true of iTerm2 (a free Terminal replacement) with swipl.
In macOS Sierra at least, it appear Apple doesn't use libreadline, it goes to libedit, see below:
ls -l /usr/lib/libreadline.dylib
lrwxr-xr-x 1 root wheel 15 Sep 23 13:54 /usr/lib/libreadline.dylib -> libedit.3.dylib
Is this the problem?
And looking at what dynamic libraries Terminal loads, we have:
otool -L /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 492.0.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 774.1.0)
/System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore (compatibility version 1.0.0, current version 539.0.0)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 57.1.0)
/usr/lib/libScreenReader.dylib (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1347.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1495.20.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1347.0.0)
/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1069.0.0)
/System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 1.0.0)
And iTerm2, otool reports:
otool -L iTerm.app/Contents/MacOS/iTerm2
iTerm.app/Contents/MacOS/iTerm2:
/usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 55.1.0)
/System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/NMSSH.framework/Versions/A/NMSSH (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57337.40.83)
/System/Library/Frameworks/ScriptingBridge.framework/Versions/A/ScriptingBridge (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1404.46.0)
@executable_path/../Frameworks/Growl.framework/Versions/A/Growl (compatibility version 1.0.0, current version 1.0.0)
@rpath/ColorPicker.framework/Versions/A/ColorPicker (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
@rpath/Sparkle.framework/Versions/A/Sparkle (compatibility version 1.6.0, current version 1.14.0)
/System/Library/Frameworks/Quartz.framework/Versions/A/Quartz (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1258.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0)
/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData (compatibility version 1.0.0, current version 641.3.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1258.1.0)
/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 600.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 728.9.0)
/System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
SWI 7.x supports string_concat(S1, S2, Result) for concatenating two strings only, but is missing an equivalent to atomic_list_concat for atoms.
http://www.swi-prolog.org/pldoc/doc_for?object=atomic_list_concat/3
I suggest a new predicate 'stringlist_concat(["This", "is", "a", "test"], "This is a test")'
OS X 10.9.2
The following sequence hangs when using the graphical debugger. Similar issues when called from JPL.
$ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.6.5)
?- use_module(library(semweb/rdf_db)).
?- rdf_assert('http://id#1.1','http://rel','http://id#1.2',graph1).
?- gtrace, rdf_update('http://id#1.1','http://rel','http://id#1.2',graph1,graph(graph2)).
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 7.3.0)
1 ?- directory_file_path(D, F, 'foo/bar').
D = foo,
F = bar.
2 ?- directory_file_path(D, bar, 'foo/bar').
D = 'foo/'.
Observed on the latest development release, while playing around on the top level.
Here is a simple way to reproduce:
?- Codes = `This is a code list` ; false.
Codes = [84, 104, 105, 115, 32, 105, 115, 32, 97|...] [write]
Codes = [84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 99, 111, 100, 101, 32, 108, 105, 115, 116] .
?- numlist(1, 1000, L). % You get a nice wall of numbers
Is that a feature?
summary: s/memberchk/member/ in library(http/http_session) line 288 (6.6.6 or 7.1.26)
Empirically, and as reported variously in web forums, modern browsers may send a request with two or more cookies with the same name, including both defunct & valid sessionid cookies - dunno why but it happens.
http_session/3 commits to the first cookie with the expected name, and logged-in users may get "you are not logged in".
The fix above will commit to the first valid sessionid if any, and the user will see the expected behaviour.
When documenting a predicate, say
%! mypredicate(+Stuff:myowntype) is det.
and having described the type myowntype
in a file, e.g., README.txt
(or even better TYPES.txt
), would it be possible to have pldoc create a link on myowntype
to where it is described? (or if there are several myowntype
to an index page that lists the files where the type is described).
Sometimes we have predicates func1(Input, Result), func1(Input, Result) that essentially behave like functions. If we want to apply several functions in sequence to a certain input, we currently have to
call the first function, bind its result to a variable and call the second function with that result. This leads to many variables called 'temp'.
In functional programming languages it is possible to compose functions in a "point-free" style which avoids having to name and use explicit temporary variables. This could be imitated in Prolog as well, such as with
compose(F1, F2, F3, Arg, Result) :-
call(F1, Arg, Temp1) %Get a binding for 'Temp1'
,call(F2, Temp1, Temp2)
,call(F3, Temp2, Result)
.
However i am not sure how to code it like call/[2..] for an arbitrary number of function predicates.
We could use it as
?- compose(plus(1), plus(2), 1, X)
X = 4.
The include predicate goes through a list and only keeps those elements that succeed on a given goal.
The name seems a little vague. In the context of functional programming such an operation on a list is mostly called filter. Thus i suggest adding a new predicate 'filter' as a clone of 'include'.
(Item#680)
Old (and preferable):
/usr/bin/swipl -f none % library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 3,856 bytes Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.10.4) Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam ... ?- [user]. a(1). |: % user://1 compiled 0.00 sec, 712 bytes true. ?- [user]. a(2). Warning: user://2:15: Redefined static procedure a/1 |: % user://2 compiled 0.01 sec, 408 bytes true.
Still like that in 7.3.11-29-g8ac682e. Change before 7.3.14-42-ga83e0df:
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.14-42-ga83e0df) ... ?- [user]. a(1). |: true. ?- [user]. a(2). |: true. ?- a(X). X = 1 ; X = 2.
Expected: No answer X = 1
?- dif(X-Y,1-2),X=Y, Y = 1.
false. % incorrect
This should succeed, like
?- X=Y, X=1, dif(X-Y,1-2).
X = Y, Y = 1.
Since 5.6.36 or earlier. i3a#332
Hello,
I'm using a prover in Prolog written by Naoyuki Tamura: seqprover.pl that you can donwload here: http://bach.istc.kobe-u.ac.jp/seqprover/seqprover.pl . Consult seqprover.pl and then type:
prover.
Then you can test formulas in first order logic, like this one for example:
X@p(X) --> p(a)/\p(b)
With version 6.6.x of SWI-Prolog, you get the same output in pretty printing that in SICTUS, i.e. 👍
-------------------- Ax -------------------- Ax
p(a),X@p(X) --> p(a) p(b),X@p(X) --> p(b)
-------------------- L@ -------------------- L@
X@p(X) --> p(a) X@p(X) --> p(b)
---------------------------------------- R/
X@p(X) --> p(a)/\p(b)
(Have a look on this prover online here : http://bach.istc.kobe-u.ac.jp/seqprover/ )
with version 7.2.x there is no more pretty printing for these formulas, and I guess that the problem comes from the @ or the # (used as name for quantifiers in this program) because this problem does not occur with test of propositional formulas.
I hope that this problem can be solved...
Best wishes,
Jo.
Using SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.9) Ubuntu
When trying to graphically debug a program prolog crashes.
The query is:
?- gen_arcs(1,[0,1],T), maplist(sep,T,Arcs,_).
The error:
[trace] ?- gen_arcs(1,[0,1],T), maplist(sep,T,Arcs,_).
T = [t(arc(1, 0, 1), [1, 0, 1])],
Arcs = [arc(1, 0, 1)] ;
T = [t(arc(1, 1, 1), [1, 1, 1])],
Arcs = [arc(1, 1, 1)] ;
[Thread 1 (main) at Sat Oct 17 18:39:46 2015] pl-write.c:1040: writePrimitive: Assertion failed: 0
C-stack trace labeled "assert_fail":
[0] PL_strtod() at ??:? [0x7fc33e48d7f0]
[1] __assert_fail() at ??:? [0x7fc33e4522c1]
[2] destroyXR() at ??:? [0x7fc33e44d489]
[3] destroyXR() at ??:? [0x7fc33e44dc7b]
[4] destroyXR() at ??:? [0x7fc33e44e340]
[5] destroyXR() at ??:? [0x7fc33e44f250]
[6] utf8_strncmp() at ??:? [0x7fc33e486c01]
[7] PL_next_solution() at ??:? [0x7fc33e3e9145]
[8] PL_call_predicate() at ??:? [0x7fc33e3f23bc]
[9] pl_pce_init() at ??:? [0x7fc33c513b0d]
[10] pl_pce_init() at ??:? [0x7fc33c513b90]
[11] PL_next_solution() at ??:? [0x7fc33e3e917f]
[12] PL_call_predicate() at ??:? [0x7fc33e3f23bc]
[13] pl_pce_init() at ??:? [0x7fc33c513b0d]
[14] pl_pce_init() at ??:? [0x7fc33c513b90]
[15] PL_next_solution() at ??:? [0x7fc33e3e917f]
[16] pl_skip_list3_va() at ??:? [0x7fc33e425fa3]
[17] pl_skip_list3_va() at ??:? [0x7fc33e42615d]
[18] PL_next_solution() at ??:? [0x7fc33e3e9248]
[19] PL_interrupt() at ??:? [0x7fc33e4440c4]
[20] PL_interrupt() at ??:? [0x7fc33e443b63]
[21] PL_next_solution() at ??:? [0x7fc33e3f06e4]
[22] pl_skip_list3_va() at ??:? [0x7fc33e425b2e]
[23] pl_skip_list3_va() at ??:? [0x7fc33e4262b0]
[24] PL_toplevel() at ??:? [0x7fc33e3e314d]
[25] prolog(main+0x2d) [0x40083d]
[26] __libc_start_main() at /build/buildd/eglibc-2.19/csu/libc-start.c:321 [0x7fc33ddf5ec5]
[27] prolog(+0x881) [0x400881]
Aborted (core dumped)
The program is:
:-use_module(library(clpfd)).
fd_length(L, N) :-
N #>= 0,
fd_length(L, N, 0).
fd_length([], N, N0) :-
N #= N0.
fd_length([_|L], N, N0) :-
N1 is N0+1,
N #>= N1,
fd_length(L, N, N1).
equal_truth(X, Y, R) :- X == Y, !, R = true.
equal_truth(X, Y, R) :- ?=(X, Y), !, R = false. % syntactically different
equal_truth(X, Y, R) :- X \= Y, !, R = false. % semantically different
equal_truth(X, Y, R) :- R == true, !, X = Y.
equal_truth(X, X, true).
equal_truth(X, Y, false) :-
dif(X, Y).
=(X, Y, T) :-
equal_truth(X, Y, T).
if_( C_1, Then_0, Else_0) :-
call(C_1, Truth),
functor(Truth,_,0), % safety check
( Truth == true -> Then_0 ; Truth == false, Else_0 ).
list_memberd_t([] ,_,false).
list_memberd_t([Y|Ys],X,Truth) :-
if_(X=Y, Truth=true, list_memberd_t(Ys,X,Truth)).
memberd_t(X,Xs,Truth) :- list_memberd_t(Xs,X,Truth).
list_memberd_truth(Xs,X,Truth) :- list_memberd_t(Xs,X,Truth).
gen_arcs(MaxNodes,Language,Arcs):-
append([Min|_],[Max],Language),
Arc_Label in Min..Max,
Arcs=[t(arc(X,Arc_Label,Z),[X,Arc_Label,Z])],
[X,Z] ins 1..MaxNodes,
1 #= min(X,Z),
label([X,Z]),
label([Arc_Label]).
gen_arcs(Max_Nodes,Language,[t(arc(X,Arc_Label,Z),[X,Arc_Label,Z])|TArcs]):-
append([Min|_],[Max],Language),
Arc_Label in Min..Max,
gen_arcs(Max_Nodes,Language,TArcs),
maplist(sep,TArcs,Arcs,_),
chain([EX,EZ,X,Z],#>=),
label([Arc_Label]),
[X,Z] ins 1..Max_Nodes,
label([X,Z]),
memberd_t(arc(X,Arc_Label,Z),Arcs,false),
memberd_t(arc(EX,_,EZ),Arcs,true).
combined_arcs_vars(Combined,Arcs,Vars):-
maplist(sep,Combined,Arcs,Vars).
sep(t(Arc,Var),Arc,Var).
sep2(arc(Node1,Edge,Node2),Node1,Edge,Node2).
I am able to load a compiled foreign library but not able to see the predicates defined in the foreign library. Can someone help here.
Platform: Macintosh
Operation System: OSX-Yosemite
SWI-Prolog: Pre-built available from swi-prolog.org (Multi-threaded, 64 bits, Version 7.2.3)
gcc: 4.2.1
Foreign Module source code:
#include <SWI-Prolog.h>
static foreign_t
pl_say_hello(term_t to)
{
PL_succeed;
}
install_t
install()
{
PL_register_foreign("say_hello", 1, pl_say_hello, 0);
}
gcc --shared -I/Applications/SWI-Prolog.app/Contents/swipl/include -o hello hello.c /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.3.0/libswipl.a -lgmp -ltermcap
When I load the foreign library, it loads fine. However, I cannot see the say_hello/1 predicate.
2 ?- load_foreign_library(foreign(hello)).
true.
3 ?- current_foreign_library(A, B).
A = foreign(hello),
B = []
A = foreign(readutil),
B = [read_util:read_line_to_codes(_G950, _G951, _G952), read_util:read_line_to_codes(_G941, _G942), read_util:read_stream_to_codes(_G931, _G932, _G933), read_util:read_stream_to_codes(_G922, _G923)].
Got the following errors while starting pengine. It seems the "@" op is not defined or it cannot be found. Also tried with the 32-bit version of SWI-Prolog (version 7.2.3) but got the same errors.
Pengine seems to be running at http://localhost:3030/ as the scratchpad works fine.
The pengine is downloaded from http://pengines.swi-prolog.org/docs/getting_started.html#downloading (Download the latest Pengines).
C:\Users\000\pengines-master>swipl run.pl
ERROR: c:/users/000/pengines-master/storage.pl:66:26: Syntax error: Operator expected
ERROR: c:/users/000/pengines-master/lib/admin/admin.pl:95:36: Syntax error: Operator expected
% Started server at http://localhost:3030/
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.2.3)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
Functionality was fine as late as v7.2.2 but the development edition doesn't support cursor movement in interactive mode.
this msg should be thrown?
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 7.1.26)
Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- [test_module_1].
true.
2 ?- catch(consult(test_module_2), E, true).
ERROR: import/1: No permission to import test_module_2:test_predicate/2 into use
r (already imported from test_module_1)
true.
3 ?-
"SWI-Prolog is linked to the real GNU libreadline as the emulation does not support its requirements.
libreadline comes from Macports or Homebrew or whatever. Except for the binaries distributed on the SWI-Prolog page, I have little control of the version of libreadline used."
I'm sorry but I guess that's what I'm not sure I completely understand. otool -L reports that the binary swipl is NOT (dynamically) linked to libreadline so it's not like it's inadvertantly picking up a wrong version, see below. I guess whoever complied 7.3.x swipl on the mac must have used macports or homebrew that is not fully compatible with later versions of OS X. Can the person who compiled the binary available for download possibly chime in here? Thanks!
otool -L /Applications/SWI-Prolog.app/Contents/MacOS/swipl
/Applications/SWI-Prolog.app/Contents/MacOS/swipl:
@executable_path/../swipl/lib/x86_64-darwin15.6.0/libswipl.dylib (compatibility version 0.0.0, current version 7.3.27)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
Item#677
r :- freeze(_,false), r.
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.3-16-g270f502)
...
?- [user].
r:-freeze(_,false),r.
|: end_of_file.
true.
?- call_residue_vars(r,Vs).
[Thread 1] pl-gc.c:1061: link_attvars: Assertion failed: t
C-stack trace labeled "crash":
[0] save_backtrace() at tai_unpack.c:0 [0x7f1bed40a17b]
[1] __assert_fail() at ??:0 [0x7f1bed3ce2a1]
[2] garbageCollect() at tai_unpack.c:0 [0x7f1bed38dfd4]
[3] ensureGlobalSpace() at tai_unpack.c:0 [0x7f1bed38e27c]
[4] m_qualify_argument() at pl-wam.c:0 [0x7f1bed355b40]
[5] PL_next_solution() at ??:0 [0x7f1bed362475]
[6] query_loop() at tai_unpack.c:0 [0x7f1bed3a111f]
[7] prologToplevel() at tai_unpack.c:0 [0x7f1bed3a197f]
[8] PL_toplevel() at ??:0 [0x7f1bed35d2c5]
[9] /opt/gupu/swipl-devel/bin/swipl(main+0x35) [0x4007e5]
[10] ??() at ??:0 [0x7f1becd7576d]
[11] /opt/gupu/swipl-devel/bin/swipl(+0x82d) [0x40082d]
[FATAL ERROR:
Received signal 6 (abrt) while in 3-th garbage collection]
[Thread 1]: local-overflow: spare=0 (def=4096)
Last resource exception:
No backtrace named exception
Out of local-stack. No room for exception term. Aborting.
I wrote a server with Python, and a client with SWI-Prolog.
The client can send message to the server, but can not receive
message sent from server.
The source of two programs are at below.
1). The server
import socket
if "main" == name:
try:
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(('localhost',8888))
sock.listen(5)
except:
print("init socket err!")
while True:
print('\n listren for client...')
conn,addr = sock.accept()
print('get client')
print(addr)
conn.settimeout(5)
szBuf = conn.recv(1024)
print(byt)
if '0' == szBuf:
conn.send(b'exit')
else:
conn.send(b'welcome client!')
conn.close()
print('end of the service')
2). The client
:- use_module(library(socket)).
create_client :-
setup_call_catcher_cleanup(
tcp_socket(Socket),
tcp_connect(Socket, localhost:8888),
exception(_),
tcp_close_socket(Socket)
),
setup_call_cleanup(
tcp_open_socket(Socket, In, Out),
chat_to_server(In, Out),
close_connection(In, Out)
).
close_connection(In, Out) :-
close(In, [force(true)]),
close(Out, [force(true)]).
chat_to_server(In, Out) :-
write(Out,'....... 12345 .........'),
read(In,Term),
nl,write(Term),nl.
When the client run, the server soon exit and show the error:
Traceback (most recent call last):
File "D:\PyQt4\learn\sockets\server2.py", line 24, in
szBuf = conn.recv(1024)
socket.timeout: timed out
The server then stop untill restart the server.
But if delete the predicate, read(In,Term),
both the client and the server will run normally.
The new clause is as below:
chat_to_server(In, Out) :-
write(Out,'....... 12345 .........').
Why the problem occurred, and how to correct it?
Thanks advance.
On a machine where the latest build was from a git checkout around Dec. 28th, I have now pulled the latest git version. Upon make
, I get:
... cp ./SWI-Prolog.h ../include/SWI-Prolog.h rm -f swipl.prc ./swipl.sh -O -o swipl.prc -b ../boot/init.pl Loading boot file ... [PROLOG SYSTEM ERROR: Thread 1 (main) at Sat Jan 23 19:27:04 2016 Undefined predicate: $set_source_module/1 PROLOG STACK: ]
When I do make clean
, followed by make
, I get the same message.
Eventually, I fixed this issue with git clean -fx
. After that, ./configure && make
compiled the system successfully.
If possible, please update the make dependencies so that make
suffices in such cases.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.