Abramo Bagnara | 8 Feb 13:01
Picon

Multi argument indexing or indexing on single argument different from first?


The expectations to get equivalent or better performance in the
fill_table/search_table variant wrt fill_table1/search_table1 is unfounded?

Your hint is still to code manual hashing when we need a composed key?

$ cat q.pl
:- dynamic(p/3).

fill_table(0) :-
    !.
fill_table(N) :-
    succ(N1, N),
    A is random(1000),
    B is random(1000),
    C is random(1000),
    assertz(p(A, B, C)),
    assertion(p(A, B, C)),
    fill_table(N1).

search_table(0, C, C) :-
    !.
search_table(N, C, C1) :-
    succ(N1, N),
    A is random(1000),
    B is random(1000),
    (p(A, B, _C) ->
        succ(C, C0)
    ;
        C0 = C
(Continue reading)

Jan Wielemaker | 8 Feb 11:48
Picon
Picon

Ann: SWI-Prolog 6.0.0

Hi,

I've uploaded SWI-Prolog 6.0.0, based on the current development GIT
(which is 5.11.37 with some bug-fixes). Bumping the major version to 6
is a rather arbitrary choice in a project that works with a frequent
release cycle. The changes since 5.0 certainly justify it. I think that
just-in-time multi-argument indexing is nice execuse for a major version
step.

This release should be compatible with 5.10.5 for almost all user
programs. Most of the incompatible changes are due to cleanup of
previously undocumented features that support the development
environment.  If you experience trouble, check warnings and check
the changes flagged "MODIFIED:" below.

Besides the usual cleanup and patches, a few developments stand out:

   - Introduction of just-in-time multi-argument indexing is now
     part of the stable release.

   - Can be compiled using MinGW.  This version is still rather
     experimental.  Thanks to Roberto Bagnara and Keri Harris.

   - Development APIs have been abstracted to support the PDT
     Eclipse based IDE.  Thanks to Guenter Kniesel and his team.

   - Memory management has been moved from the old custom allocator
     to system malloc.  The consequences may vary, but in general
     it seems that modern allocators deal better in fighting memory
     fragmentation, at the cost of slighly worse performance and a
(Continue reading)

Samer Abdallah | 7 Feb 15:26
Picon

Hang due to multithreaded access to Matlab interface foreign library

Hi,
thought I'd share this with the list even though I have now solved
the problem thanks to some pointers from Jan.

Basically, as was getting a total lock-up of the Prolog system in
an application that uses my Matlab interface library plml. (see
http://www.swi-prolog.org/contrib/ ) The effect was intermittent 
and not deterministically reproducible. The reason turned out to
be this: I was calling the Matlab engine API seemingly in single 
threaded fashion, but from a secondary thread in a mutithreaded
application; what I didn't notice was that the garbage collector
could be called simultaneously in another thread, and since I
am using BLOB atoms to manage some Matlab reasources, to be
released via garbage collection, this meant that occasionally, the
Matlab engine API was called from two threads at the same time.
This is no good as it caused the garbage collection thread to block
and thereby lock up the whole system.

Jan suggested a couple of options below. I went for the first option,
and it did the trick: I put a blocking mutex lock around all calls to the Matlab
engine API, except inside the release method of the BLOB atom class
that was causing the problem, which now has a non-blocking mutex lock.
If the mutex is locked when the garbage collector is run, the release method
returns FALSE to say that the atom cannot be reclaimed at this
time. The garbage collector simply leaves it and attempts to release it the 
next time it is run.

Anyway, I thought that might be a useful nugget of information to go
on the list. The latest version of the plml library is available here:
	https://code.soundsoftware.ac.uk/projects/plml
(Continue reading)

Fernando Guzmán | 6 Feb 02:15
Gravatar

Stand alone executable

I have compiled a stand-alone executable using swipl-ld in a linux machine running swipl 5.10.2.  The
stand-alone runs perfectly in the machine it was compiled. 

When I try to run this executable in another linux machine, identical to the first, except that it doesn't
have swipl installed, I get the error: 

% error while loading shared libraries: libswipl.so.5.10.2: cannot open shared object file: No such file
or directory 

(How) Can I create a stand-alone executable that includes and doesn't look for the swipl libraries? 

--
Fernando Guzman
fer <at> math.binghamton.edu

-------------- next part --------------
HTML attachment scrubbed and removed
Stassa Patsantzis | 4 Feb 23:54
Picon
Favicon

"ERROR: text_buffer <-matching_bracket: Argument 2 (bracket):"

Hi, list. 

I'm getting the following error when I enter a carriage return in PceEmacs: 

ERROR: text_buffer <-matching_bracket: Argument 2 (bracket): `[char]' expected, found `[integer,number,41,125,93]
ERROR: text_buffer <-matching_bracket: Argument 2 (bracket): `[char]' expected, found `[integer,number,41,125,93]
ERROR: text_buffer <-matching_bracket: Argument 2 (bracket): `[char]' expected, found `[integer,number,41,125,93]

(The error repeats three times for each cr). 

From what I can tell this happens when I compile the following code: 

    member -->
      [Value, Type],
      { type([Value, Type], []) }.

    member --> [Value, Type],
      { type([Value, Set], []),
      member([Set, Type], [])}.

    type --> [integer, number].
    type --> [1, integer].
    type --> [2, integer].
    type --> [a, alpha].
    type --> [b, alpha].

Note that [41,125,93] are the codes for ')}]'. Not sure how those end up inside my diff list. 

Other files don't have the same problem and if I start by loading a different file again no problem. There are
no problems with runnig, it's just the editor. 
(Continue reading)

Derek Jones | 1 Feb 21:50
Picon
Favicon

Slightly OT: Emacs mode for simple rule files

Hi all,

I like color syntax highlighting.

I use emacs in viper mode for code editing usually (call me a luser! I 
don't care :-D - been doing that for decades since I looOOove vi and 
err, don't love emacs so much, but I love emacs' flexibility and it's 
color syntax highlighting way better than vim and friends.)

Anyhow - I have a simple external expert system rule file - something 
like this:

----------------

goal result1

if
  answer1  and               % Something or the other
  answer2  and               % something else...
  answer3
then
  result1 cf 46

etc.

I have hacked emacs lisp files before but really don't like doing so. 
(Yes, I even have the O'Reilly books).

Wondered if anyone had a mode they had used for something like this. 
I've been looking at the generic and derived modes on the emacs wiki and 
(Continue reading)

Liu, Songqing | 31 Jan 18:42
Favicon
Gravatar

Query

Dear Sir:
I am a computer science graduate student in UNO, I want to do some works
about the interface between JAVA and PROLOG.
I have a problem in learning the interface from JAVA to PROLOG. When I
compile the java examples using JPL.JAR in Eclipse, it shows the error:
"SWI-Prolog: [FATAL ERROR: Could not find system resources]".
 My environment variables setup :

JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0
Classpath: .;%JAVA_HOME%\lib.;%JAVA_HOME%\bin.;C:\Program Files (x86)\pl\bin
Path: %JAVA_HOME%\bin;C:\Program Files (x86)\pl\bin
SWI-PROLOG: C:\Program Files (x86)\pl

Another question is: when I do "run.bat" in the example directory in dos
shell, it says " should no have     \pl\lib\jpl.jar"

Thanks for your help

Songqing
-------------- next part --------------
HTML attachment scrubbed and removed
Jan Wielemaker | 30 Jan 19:46
Picon
Picon

thread_get_message/3 (was: Re: call_with_time_limit(T, thread_get_message(Msg)) broken recently)

Hi Samer,

[Back to the list because this is getting more general]

On 01/30/2012 05:28 PM, Samer Abdallah wrote:
>> It always works fine if the target thread is
>> nicely running Prolog code, but if it runs something that is blocking it
>> depends on the OS and what exactly it is blocking on. In Unix, it
>> generally works fine if the blocking call can be interrupted and the
>> calling code does something like:
>>
>>    for(;;)
>>    { if ( some_blocking_call_fails&&  errno == EINTR )
>>      { if ( PL_handle_signals()<  0 )
>>          <return to Prolog with failure>
>>        continue;
>>      }
>>      <do something useful>
>>      break;
>>    }
>>
>
> Hi Jan,
> This is useful information! - so if I write a foreign predicate that I want
> to be interruptible by an alarm, I need to include something like this?
> I'll try to include this in my Matlab execution function and see what happens.

You can always call PL_handle_signals().  thread_signal/2 sends a signal
with an empty handler to the target thread.  This normally causes (most)
blocking system calls to return with an error-return code and set errno to
(Continue reading)

Jan Wielemaker | 30 Jan 17:21
Favicon
Gravatar

Ann: SWI-Prolog 5.11.37

Hi,

I've uploaded SWI-Prolog 5.11.37. Mainly bugfixes that won't affect many
users. Hopefully this fixes (work around) the keyboard delay issues that
notably affect MacOS X.  Thanks to the research by Samer.

Most of the other changes is cleanup to support Boehm-GC for managing
memory for both Prolog and packages. Eventually, it is likely that
SWI-Prolog will switch to (a custom version of) Boehm-GC, but this will
take a while. So far, the benefits are a few (minor) fixes in memory
management.

	Cheers --- Jan

===================================
SWI-Prolog Changelog since V5.11.36
===================================

  * ENHANCED: Work around readline slow response issues by lowering
    the timeout.  Samer Abdallah.  It is very unclear when this lower
    timeout is needed.  Anyway, the worst case is a little more activity
    in idle interactive sessions.

  * FIXED: Suppress empty messages in print_message_lines/3.

  * ADDED: thread_get_message/3, providing a timeout option.  After
    discussion on the list, initiated by Samer Abdallah.

  * FIXED: min_member/2 acted as max_member/2.  Chris Kaltwasser.

(Continue reading)

Oliver Scholz | 28 Jan 20:56
Picon
Picon
Gravatar

unit tests and assertion/1

Hello!

I'm new to Prolog. In order to learn it, I'm trying to write a small 
program. I'd feel much better doing so, if I could track my progress 
with unit tests.

I compiled and installed SWI-Prolog 5.10.5 from source. I'm using the 
exact examples from: http://www.swi-prolog.org/pldoc/package/plunit.html

But when I type run_tests in the listener, after consulting a file 
containing tests, I simply get:

% No tests to run
true.

Originally I had installed SWI via apt-get (version 5.10.4, IIRC). 
Loading files containing tests would simply throw an error. Looking into 
/usr/lib/swi-prolog/library/, I couldn't see any package pertaining to 
the test library, so I assumed it was for some reason omitted. If this 
is correct, does that simply mean that the unit test library is broken?

Since my needs are actually simple, I wouldn't need a sophisticated 
library, as long as I can get SWI to throw an error, if a predicate 
fails. So, I looked into `assertion', which from the description would 
seem to be what I need. However:

?- assertion(4 == 5).
true.

What am I missing?
(Continue reading)

Chris Kaltwasser | 28 Jan 15:49
Favicon

min_list/2 gives max

Hello,

I am finding that min_member/2 is returning the largest member of a
list just as max_member/2 does. I want something that will give me the
smallest member.

For example:

?- min_member(X,[1,2,3]).
X = 3.

?- max_member(X,[1,2,3]).
X = 3.

I see the text in the documentation is consistent with this behaviour
as both hold that the first argument is the largest member even though
their names are different  ( Min and Max. )

My guess is that this is a bug, but I could easily be missing something.

Thank you for any enlightenment on this topic.

Cheers,
Chris

Gmane