You can subscribe to this list here.
| 2000 |
Jan
|
Feb
(53) |
Mar
(15) |
Apr
(61) |
May
(159) |
Jun
(87) |
Jul
(28) |
Aug
(8) |
Sep
(37) |
Oct
(12) |
Nov
(29) |
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(21) |
Feb
(51) |
Mar
(44) |
Apr
(21) |
May
(12) |
Jun
(39) |
Jul
(51) |
Aug
(24) |
Sep
(5) |
Oct
(11) |
Nov
(9) |
Dec
(15) |
| 2002 |
Jan
(30) |
Feb
(74) |
Mar
(23) |
Apr
(41) |
May
(10) |
Jun
(6) |
Jul
(49) |
Aug
(32) |
Sep
(42) |
Oct
(31) |
Nov
(18) |
Dec
(19) |
| 2003 |
Jan
(5) |
Feb
(4) |
Mar
(23) |
Apr
(40) |
May
(7) |
Jun
(14) |
Jul
(21) |
Aug
(2) |
Sep
(15) |
Oct
(4) |
Nov
(34) |
Dec
(11) |
| 2004 |
Jan
(34) |
Feb
(21) |
Mar
(1) |
Apr
(3) |
May
(8) |
Jun
(31) |
Jul
(37) |
Aug
(48) |
Sep
(28) |
Oct
(19) |
Nov
(18) |
Dec
(4) |
| 2005 |
Jan
(27) |
Feb
(15) |
Mar
(27) |
Apr
(17) |
May
(10) |
Jun
|
Jul
(62) |
Aug
(13) |
Sep
(16) |
Oct
(41) |
Nov
(36) |
Dec
(30) |
| 2006 |
Jan
(55) |
Feb
(40) |
Mar
(55) |
Apr
(25) |
May
(27) |
Jun
(44) |
Jul
(4) |
Aug
(20) |
Sep
(27) |
Oct
(68) |
Nov
(10) |
Dec
(8) |
| 2007 |
Jan
(70) |
Feb
(52) |
Mar
(43) |
Apr
(18) |
May
(25) |
Jun
(18) |
Jul
(32) |
Aug
(82) |
Sep
(90) |
Oct
(86) |
Nov
(10) |
Dec
(10) |
| 2008 |
Jan
(18) |
Feb
(41) |
Mar
(9) |
Apr
(19) |
May
(16) |
Jun
(12) |
Jul
(40) |
Aug
(13) |
Sep
(31) |
Oct
(26) |
Nov
(57) |
Dec
(41) |
| 2009 |
Jan
(15) |
Feb
(41) |
Mar
(39) |
Apr
(51) |
May
(40) |
Jun
(46) |
Jul
(54) |
Aug
(18) |
Sep
(10) |
Oct
(19) |
Nov
(5) |
Dec
(15) |
| 2010 |
Jan
(15) |
Feb
(10) |
Mar
(8) |
Apr
(4) |
May
(9) |
Jun
(4) |
Jul
(4) |
Aug
(6) |
Sep
(4) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
| 2011 |
Jan
(3) |
Feb
(15) |
Mar
(14) |
Apr
(9) |
May
(5) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
(21) |
Jul
(3) |
Aug
(16) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
|
Feb
(2) |
Mar
(13) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Paulo M. <pm...@lo...> - 2015-01-07 01:47:31
|
Hi, The stable release of the third generation of Logtalk (3.x) is now available at: http://logtalk.org/ Logtalk is an open source object-oriented logic programming language that extends and leverages the Prolog language with a feature set suitable for programming in the large. Logtalk supports modern code encapsulation and code reuse mechanisms without compromising the declarative programming features of Prolog. Logtalk is implemented in highly portable code and can use most modern and standards compliant Prolog implementations as a back-end compiler. The Logtalk distribution features portable libraries and portable assertions, documenting, diagraming, and unit testing tools, plus extensive code editing and publishing support. It also includes extensive documentation and a large number of programming examples. Highlights compared with the previous generation of Logtalk (2.x) include: - faster compiler and runtime - refined language semantics - stricter language syntax - improved compiler lint checker - new message forwarding and message delegation support - new structured message printing mechanism - new structured question asking mechanism - major improvements to reflection support - make functionality and support for absolute and relative source file paths - extended coinduction support - new Prolog conformance unit test suite - extended Logtalk unit test suites - new programming examples Also included in this release are new and improved developer tools: - new assertions and ports profiler tools - improved debugger with new trace options and support for source file line breakpoints - improved unit test framework with support for full code coverage, determinism tests, input/output tests, and new test dialects - improved diagrams tool with support for file loading and dependency diagrams, entity and predicate cross-reference diagrams, diagrams of Prolog module applications, and extended options including URL linking options to documentation and source code repositories - improved documenting tool with support for exporting Markdown text files, extended linking options, and more complete coverage of entity and predicate properties Supported Prolog compilers: - B-Prolog 7.8 or later versions - CxProlog 0.97.7 or later versions - ECLiPSe 6.1#143 or later versions - GNU Prolog 1.4.2 or later versions - Lean Prolog 3.8.8 or later versions (experimental) - Qu-Prolog 9.0 or later versions - Quintus Prolog 3.3~3.5 (experimental) - SICStus Prolog 4.1.0 or later versions - SWI Prolog 6.0.0 or later versions - XSB 3.5.0 or later versions - YAP 6.3.4 or later versions Logtalk development and feature set benefit on a regular base from cooperation with academic partners, in particular those working on programming languages and tools research. Commercial contracts further help in funding continuous Logtalk development. Contact us regarding cooperation opportunities. For Logtalk (and Prolog) commercial consulting and development services, see: http://logtalk.pt/ Happy New Year, Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pm...@lo...> Web: <http://logtalk.org/> ----------------------------------------------------------------- |
|
From: Paulo M. <pm...@lo...> - 2014-09-03 09:24:36
|
[apologies in case of multiple receptions] Hi, Logtalk 3.00.0 Release Candidate 1 is now available for downloading at: http://logtalk.org/ Logtalk is an object-oriented logic programming language that extends and leverages the Prolog language with a feature set suitable for programming in the large. Written in highly portable code, it can use most modern Prolog implementations as a back-end compiler. As a multi-paradigm language, it includes support for both prototypes and classes, protocols (interfaces), categories (components), event-driven programming, and high-level multi-threading programming. Its distribution includes full documentation, portable libraries, a comprehensive set of portable developer tools, and a large number of programming examples to help get you started. Logtalk can also be used as a highly portable layer on top of Prolog, as a Prolog library used together other libraries, and as a porting tool. It subsumes Prolog modules by both being able to compile modules as objects and by providing a portable implementation of the de facto common core Prolog module features. Developer tool highlights include a unit testing framework supporting full code coverage at the clause level and determinism tests; a sophisticated diagramming tool able to illustrate library, entity, and predicate relations; a documenting tool capable of of generating API documentation in e.g. HTML and PDF; and a port profiler tool for performance analysis of actual predicate execution. This is a near final release of the third generation of Logtalk. Only documentation and bug fixes are expected before the final, stable, release, which is expected later this month. Interested parties are invited to test their applications, specially if migrating from Logtalk 2.x. This release fixes long standing meta-predicate execution context issues inherited from Logtalk 2.x, improves meta-predicate semantics by ensuring that meta-arguments are always called with the caller full execution context, refines and improves multifile predicate semantics, adds a new token to the structured message printing mechanism, features a new port profiler tool, improves the debugger and diagrams tools, fixes all known bugs, includes documentation and unit test updates, and SWI-Prolog, XSB, and YAP compatibility improvements. For details and a complete list of changes, please consult the release notes at: https://github.com/LogtalkDotOrg/logtalk3/blob/master/RELEASE_NOTES.md The new port profiler tool is described at: http://forums.logtalk.org/viewtopic.php?f=21&t=240 Happy logtalking! Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pm...@lo...> Web: <http://logtalk.org/> ----------------------------------------------------------------- |
|
From: Paulo M. <pm...@lo...> - 2014-04-09 00:36:35
|
Hi, Logtalk 3.00.0 Beta 1 was released today and its available at: https://github.com/LogtalkDotOrg/logtalk3 Detailed release notes can be consulted here: https://github.com/LogtalkDotOrg/logtalk3/blob/master/RELEASE_NOTES.md Installers and general information on Logtalk are available at: http://logtalk.org/ Logtalk is an open source object-oriented logic programming language that extends and leverages the Prolog language with a feature set suitable for programming in the large. Logtalk supports modern code encapsulation and code reuse mechanisms without compromising the declarative programming features of Prolog. Logtalk is implemented in highly portable code and can use most modern and standards compliant Prolog implementations as a back-end compiler. The Logtalk distribution features portable libraries and portable assertions, documenting, diagraming, and unit testing tools, plus extensive code editing and publishing support. It also includes extensive documentation and a large number of programming examples. Despite the "beta" tag, this release is quite stable and it was extensively tested. Feedback is sought and most welcome on all aspects of Logtalk, including features, tools, documentation, portability, and licensing terms. Planned features for upcoming releases include extended portable libraries and a metrics tool. Support for entity (hierarchical) namespaces is also being considered. Logtalk development and feature set benefit on a regular base from cooperation with academic partners, in particular those working on programming languages and tools research. Commercial contracts further help in funding continuous Logtalk development. Contact us regarding cooperation opportunities. For Logtalk commercial consulting and development services, see: http://logtalk.pt/ Happy logtalking, Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pm...@lo...> Web: <http://logtalk.org/> ----------------------------------------------------------------- |
|
From: Paulo M. <pm...@lo...> - 2013-04-25 15:23:05
|
Hi, The Prolog Unicode 6.2 resources developed by VivoMind LLC are now available as public domain software at: https://github.com/VivoMind The VivoMind Prolog Unicode Resources are a set of plain Prolog files resulting from the conversion of most (but not all) official UCD 6.1 files and updated for the changes in the 6.2 standard. A set of auxiliary predicates is also included to simplify using the provided tables of code point properties. Some of the original data was split in individual files per code point property to make it easier to load only the resources required by a specific application. Enjoy, Arun Majumdar Paulo Moura |
|
From: Miguel C. <mc...@de...> - 2013-03-28 12:28:35
|
Interprolog bugs, patches etc. should be reported to int...@de.... It's likely that other means emerge in the not too distant future. The present list is for XSB Prolog issues. I will react to your hashCode() comments in a separate email. Thanks, Miguel Miguel Calejo Declarativa mc...@de... http://www.declarativa.pt telefone: +351-22-030-1580 fax: +351-22-030-1511 UPTEC - Parque de Ciência e Tecnologia da Universidade do Porto Rua Actor Ferreira da Silva 100 4200-298 Porto Portugal On Mar 28, 2013, at 12:02 , Sergio Castro wrote: > you are welcome :) > > In the meanwhile, I discovered a couple of other small problems when working with TermNode instances and Hash tables. In the current version the "equals" method has been overridden in the TermModel class, but not the "hashCode()" method and this could lead to bugs rather difficult to debug when working with maps (as it was my case when I found it). > > This is a (tool generated) implementation for hashCode() in the TermModel class: > > public int hashCode() { > final int prime = 31; > int result = 1; > result = prime * result + Arrays.hashCode(children); > result = prime * result + ((node == null) ? 0 : node.hashCode()); > return result; > } > > Note that in order to this code can work correctly, it is also needed to provide a hashCode() implementation in the VariableNode class, since instances of this class can be the node of the term model (or any of its children). > > A tool generated implementation for hashCode() in the VariableNode class follows: > > public int hashCode() { > final int prime = 31; > int result = 1; > result = prime * result + ((number == null) ? 0 : number.hashCode()); > return result; > } > > > Please let me know if in the future there is a more convenient way to submit bug patches to the project. > > cheers, > > Sergio > > > De : Miguel Calejo <mc...@de...> > À : Sergio Castro <ser...@ya...> > Cc : "xsb...@li..." <xsb...@li...> > Envoyé le : Lundi 25 mars 2013 16h50 > Objet : Re: [Xsb-development] bug in the NativeEngine class at InterProlog ? > > You're correct, thanks for fixing that:-) > Miguel > > On Mar 20, 2013, at 23:04 , Sergio Castro wrote: > >> Hi, >> >> Not sure but I think I found a bug in the InterProlog NativeEngine class. >> >> Currently the constructor loads the XSB native library with this code: >> >> public NativeEngine(String XSB_BIN_DIR, String[] XSB_ARGS, boolean debug, boolean loadFromJar) { >> super(XSB_BIN_DIR,debug,loadFromJar); >> numberOfInstances++; >> if (numberOfInstances > 1) >> throw new IPException("Can't have more than one instance of NativeEngine"); >> // On creation of the first NativeEngine instance, the XSB.dll is loaded. >> // First, xsbBinDir and xsbBinDir\xsb.dll are tested for existence. >> // If they do exist, then the dll is loaded from this xsb.dll. If >> // either do not, then the System Path is used to locate xsb.dll. >> >> >> if (numberOfInstances == 1) { >> File xsbDLLFile = null; >> if (XSB_BIN_DIR != null) { >> File providedBinDirectory = new File(XSB_BIN_DIR); >> xsbDLLFile = new File(providedBinDirectory, "xsb.dll"); >> } >> if (isWindowsOS() && xsbDLLFile != null && xsbDLLFile.exists()) { >> System.load(xsbDLLFile.getAbsolutePath()); >> } else { >> System.loadLibrary("xsb"); >> } >> } >> ... >> >> } >> >> >> The constructor checks if the library exists in the bin directory sent as first argument. Otherwise it tries to find the library according to the entries in "java.library.path" (with a call to System.loadLibrary("xsb")). >> The problem is that this will work only on Windows (given the explicit condition "isWindowsOS()"), otherwise the bin directory sent as argument is just ignored and will go directly to try to load the library according to the entries in "java.library.path". >> >> Instead, the code should be something like this : >> >> if (numberOfInstances == 1) { >> File libraryFile = null; >> if (XSB_BIN_DIR != null) { >> File providedBinDirectory = new File(XSB_BIN_DIR); >> if(isWindowsOS()) >> libraryFile = new File(providedBinDirectory, "xsb.dll"); >> else >> libraryFile = new File(providedBinDirectory, "xsb"); >> } >> if (libraryFile != null && libraryFile.exists()) { >> System.load(libraryFile.getAbsolutePath()); >> } else { >> System.loadLibrary("xsb"); >> } >> } >> >> --- >> >> my two cents :) >> >> cheers, >> >> Sergio >> >> ------------------------------------------------------------------------------ >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________ >> Xsb-development mailing list >> Xsb...@li... >> https://lists.sourceforge.net/lists/listinfo/xsb-development > > > |
|
From: Sergio C. <ser...@ya...> - 2013-03-28 12:02:15
|
you are welcome :)
In the meanwhile, I discovered a couple of other small problems when working with TermNode instances and Hash tables. In the current version the "equals" method has been overridden in the TermModel class, but not the "hashCode()" method and this could lead to bugs rather difficult to debug when working with maps (as it was my case when I found it).
This is a (tool generated) implementation for hashCode() in the TermModel class:
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(children);
result = prime * result + ((node == null) ? 0 : node.hashCode());
return result;
}
Note that in order to this code can work correctly, it is also needed to provide a hashCode() implementation in the VariableNode class, since instances of this class can be the node of the term model (or any of its children).
A tool generated implementation for hashCode() in the VariableNode class follows:
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((number == null) ? 0 : number.hashCode());
return result;
}
Please let me know if in the future there is a more convenient way to submit bug patches to the project.
cheers,
Sergio
>________________________________
> De : Miguel Calejo <mc...@de...>
>À : Sergio Castro <ser...@ya...>
>Cc : "xsb...@li..." <xsb...@li...>
>Envoyé le : Lundi 25 mars 2013 16h50
>Objet : Re: [Xsb-development] bug in the NativeEngine class at InterProlog ?
>
>
>You're correct, thanks for fixing that:-)
>Miguel
>
>
>On Mar 20, 2013, at 23:04 , Sergio Castro wrote:
>
>Hi,
>>
>>Not sure but I think I found a bug in the InterProlog NativeEngine class.
>>
>>Currently the constructor loads the XSB native library with this code:
>>
>>public NativeEngine(String XSB_BIN_DIR, String[] XSB_ARGS, boolean debug, boolean loadFromJar) {
>> super(XSB_BIN_DIR,debug,loadFromJar);
>> numberOfInstances++;
>> if (numberOfInstances > 1)
>> throw new IPException("Can't have more than one instance of NativeEngine");
>> // On creation of the first NativeEngine instance, the XSB.dll is loaded.
>> // First, xsbBinDir
and xsbBinDir\xsb.dll are tested for existence.
>> // If they do exist, then the dll is loaded from this xsb.dll. If
>> // either do not, then the System Path is used to locate xsb.dll.
>>
>>
>> if (numberOfInstances == 1) {
>> File xsbDLLFile = null;
>> if (XSB_BIN_DIR != null) {
>> File providedBinDirectory = new File(XSB_BIN_DIR);
>> xsbDLLFile = new File(providedBinDirectory,
"xsb.dll");
>> }
>> if (isWindowsOS() && xsbDLLFile != null && xsbDLLFile.exists()) {
>> System.load(xsbDLLFile.getAbsolutePath());
>> } else {
>> System.loadLibrary("xsb");
>> }
>> }
>> ...
>>
>>}
>>
>>
>>The constructor checks if the library exists in the bin directory sent as first argument. Otherwise it tries to find the library according to the entries in "java.library.path" (with a call to
System.loadLibrary("xsb")).
>>The problem is that this will work only on Windows (given the explicit condition "isWindowsOS()"), otherwise the bin directory sent as argument is just ignored and will go directly to try to load the library according to the entries in "java.library.path".
>>
>>Instead, the code should be something like this :
>>
>>if (numberOfInstances == 1) {
>> File libraryFile = null;
>> if (XSB_BIN_DIR != null) {
>> File providedBinDirectory = new File(XSB_BIN_DIR);
>> if(isWindowsOS())
>> libraryFile = new
File(providedBinDirectory, "xsb.dll");
>> else
>> libraryFile = new File(providedBinDirectory, "xsb");
>> }
>> if (libraryFile != null && libraryFile.exists()) {
>> System.load(libraryFile.getAbsolutePath());
>> } else {
>> System.loadLibrary("xsb");
>> }
>>
}
>>
>>---
>>
>>my two cents :)
>>
>>cheers,
>>
>>Sergio
>>
>>------------------------------------------------------------------------------
>>Everyone hates slow websites. So do we.
>>Make your web apps faster with AppDynamics
>>Download AppDynamics Lite for free today:
>>http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________
>>Xsb-development mailing list
>>Xsb...@li...
>>https://lists.sourceforge.net/lists/listinfo/xsb-development
>>
>
>
> |
|
From: Miguel C. <mc...@de...> - 2013-03-25 15:51:14
|
You're correct, thanks for fixing that:-)
Miguel
On Mar 20, 2013, at 23:04 , Sergio Castro wrote:
> Hi,
>
> Not sure but I think I found a bug in the InterProlog NativeEngine class.
>
> Currently the constructor loads the XSB native library with this code:
>
> public NativeEngine(String XSB_BIN_DIR, String[] XSB_ARGS, boolean debug, boolean loadFromJar) {
> super(XSB_BIN_DIR,debug,loadFromJar);
> numberOfInstances++;
> if (numberOfInstances > 1)
> throw new IPException("Can't have more than one instance of NativeEngine");
> // On creation of the first NativeEngine instance, the XSB.dll is loaded.
> // First, xsbBinDir and xsbBinDir\xsb.dll are tested for existence.
> // If they do exist, then the dll is loaded from this xsb.dll. If
> // either do not, then the System Path is used to locate xsb.dll.
>
>
> if (numberOfInstances == 1) {
> File xsbDLLFile = null;
> if (XSB_BIN_DIR != null) {
> File providedBinDirectory = new File(XSB_BIN_DIR);
> xsbDLLFile = new File(providedBinDirectory, "xsb.dll");
> }
> if (isWindowsOS() && xsbDLLFile != null && xsbDLLFile.exists()) {
> System.load(xsbDLLFile.getAbsolutePath());
> } else {
> System.loadLibrary("xsb");
> }
> }
> ...
>
> }
>
>
> The constructor checks if the library exists in the bin directory sent as first argument. Otherwise it tries to find the library according to the entries in "java.library.path" (with a call to System.loadLibrary("xsb")).
> The problem is that this will work only on Windows (given the explicit condition "isWindowsOS()"), otherwise the bin directory sent as argument is just ignored and will go directly to try to load the library according to the entries in "java.library.path".
>
> Instead, the code should be something like this :
>
> if (numberOfInstances == 1) {
> File libraryFile = null;
> if (XSB_BIN_DIR != null) {
> File providedBinDirectory = new File(XSB_BIN_DIR);
> if(isWindowsOS())
> libraryFile = new File(providedBinDirectory, "xsb.dll");
> else
> libraryFile = new File(providedBinDirectory, "xsb");
> }
> if (libraryFile != null && libraryFile.exists()) {
> System.load(libraryFile.getAbsolutePath());
> } else {
> System.loadLibrary("xsb");
> }
> }
>
> ---
>
> my two cents :)
>
> cheers,
>
> Sergio
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________
> Xsb-development mailing list
> Xsb...@li...
> https://lists.sourceforge.net/lists/listinfo/xsb-development
|
|
From: Sergio C. <ser...@ya...> - 2013-03-20 23:04:15
|
Hi,
Not sure but I think I found a bug in the InterProlog NativeEngine class.
Currently the constructor loads the XSB native library with this code:
public NativeEngine(String XSB_BIN_DIR, String[] XSB_ARGS, boolean debug, boolean loadFromJar) {
super(XSB_BIN_DIR,debug,loadFromJar);
numberOfInstances++;
if (numberOfInstances > 1)
throw new IPException("Can't have more than one instance of NativeEngine");
// On creation of the first NativeEngine instance, the XSB.dll is loaded.
// First, xsbBinDir and xsbBinDir\xsb.dll are tested for existence.
// If they do exist, then the dll is loaded from this xsb.dll. If
// either do not, then the System Path is used to locate xsb.dll.
if (numberOfInstances == 1) {
File xsbDLLFile = null;
if (XSB_BIN_DIR != null) {
File providedBinDirectory = new File(XSB_BIN_DIR);
xsbDLLFile = new File(providedBinDirectory, "xsb.dll");
}
if (isWindowsOS() && xsbDLLFile != null && xsbDLLFile.exists()) {
System.load(xsbDLLFile.getAbsolutePath());
} else {
System.loadLibrary("xsb");
}
}
...
}
The constructor checks if the library exists in the bin directory sent as first argument. Otherwise it tries to find the library according to the entries in "java.library.path" (with a call to System.loadLibrary("xsb")).
The problem is that this will work only on Windows (given the explicit condition "isWindowsOS()"), otherwise the bin directory sent as argument is just ignored and will go directly to try to load the library according to the entries in "java.library.path".
Instead, the code should be something like this :
if (numberOfInstances == 1) {
File libraryFile = null;
if (XSB_BIN_DIR != null) {
File providedBinDirectory = new File(XSB_BIN_DIR);
if(isWindowsOS())
libraryFile = new File(providedBinDirectory, "xsb.dll");
else
libraryFile = new File(providedBinDirectory, "xsb");
}
if (libraryFile != null && libraryFile.exists()) {
System.load(libraryFile.getAbsolutePath());
} else {
System.loadLibrary("xsb");
}
}
---
my two cents :)
cheers,
Sergio |
|
From: Sergio C. <ser...@ya...> - 2013-03-18 23:38:44
|
Thanks a lot Michael. It is quite more clear now.
regards,
Sergio
>________________________________
> De : Michael Kifer <mic...@st...>
>À : xsb...@li...; ser...@ya...
>Envoyé le : Mardi 19 mars 2013 0h28
>Objet : Re: [Xsb-development] Question about Hilog terms in XSB
>
>
>
>
>
>On 03/18/2013 05:55 PM, Sergio Castro wrote:
>
>I see. And about Silk is the same story ?. It also uses its own implementation of HiLog instead of XSB's native one ?
>>
>Yes. SILK is actually a layer on top of flora.
>
>
>
>>I am wondering if a correct conclusion of this is that I should
avoid to use the XSB implementation of HiLog in new Prolog
projects ?
>The main problem with the implementation of HiLog in XSB is that it
does not work well with modules and there are other surprises.
>Flora avoids using XSB modules altogether and instead implements its
own module system, which is integrated with HiLog.
>
>
>and if eventually I am interested in doing something with HiLog in the future I should take a look to Flora ?
>>
>Flora is much more than just HiLog, so you might want to look into
it for other reasons also.
>
>--
>
> --- michael
>
>
>
>
>>-Sergio
>>
>>
>>
>>
>>
>>>________________________________
>>> De : David Warren <wa...@cs...>
>>>À : Miguel Calejo <mc...@de...>; Sergio Castro <ser...@ya...>
>>>Cc : "xsb...@li..." <xsb...@li...>
>>>Envoyé le : Lundi 18 mars 2013 21h03
>>>Objet : RE: [Xsb-development] Question about Hilog terms in XSB
>>>
>>>
>>>
>>>Actually Flora, which is implemented with a translator to XSB source code, does support the Flora version of HiLog. But it does not use XSB’s implementation of HiLog. It uses its own translation to standard prolog predicates. Michael Kifer (and his student who wrote the Flora compiler) found that XSB’s support for HiLog did not really provide the functionality they wanted, so they rolled their own.
>>>-David
>>>
>>>From:Miguel Calejo [mailto:mc...@de...]
>>>Sent: Monday, March 18, 2013 10:50 AM
>>>To: Sergio Castro
>>>Cc: xsb...@li...
>>>Subject: Re: [Xsb-development] Question about Hilog terms in XSB
>>>
>>>Rather important: http://flora.sourceforge.net/ , http://silk.semwebcentral.org/
>>>On Mar 18, 2013, at 12:45 , Sergio Castro wrote:
>>>
>>>
>>>
>>>
>>>I am wondering how important is for XSB the support for proper Hilog terms (i.e. compounds having as functors arbitrary terms). Are there many XSB projects currently using this feature ? which of them for example ?
>>>I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N.
>>>Specifically, I would like to understand if the usage of Hilog terms have further applications and if it is still regarded as a powerful feature in a Prolog like logic language, or if it is supported in XSB rather for historical reasons.
>>>
>>>cheers,
>>>
>>>Sergio
>>>
>>>------------------------------------------------------------------------------
>>>Everyone hates slow websites. So do we.
>>>Make your web apps faster with AppDynamics
>>>Download AppDynamics Lite for free today:
>>>http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________
>>>Xsb-development mailing list
>>>Xsb...@li...
>>>https://lists.sourceforge.net/lists/listinfo/xsb-development
>>>
>>>
>>>
>
>
> |
|
From: Michael K. <mic...@st...> - 2013-03-18 23:28:26
|
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" text="#000000"
bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 03/18/2013 05:55 PM, Sergio Castro
wrote:<br>
</div>
<blockquote
cite="mid:db8...@HU..."
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt">
I see. And about Silk is the same story ?. It also uses its own
implementation of HiLog instead of XSB's native one ?<br>
</div>
</blockquote>
<br>
Yes. SILK is actually a layer on top of flora. <br>
<br>
<blockquote
cite="mid:db8...@HU..."
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt">
<br>
I am wondering if a correct conclusion of this is that I should
avoid to use the XSB implementation of HiLog in new Prolog
projects ?</div>
</blockquote>
<br>
The main problem with the implementation of HiLog in XSB is that it
does not work well with modules and there are other surprises.<br>
Flora avoids using XSB modules altogether and instead implements its
own module system, which is integrated with HiLog.<br>
<br>
<blockquote
cite="mid:db8...@HU..."
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt"> and if eventually I am
interested in doing something with HiLog in the future I should
take a look to Flora ?<br>
</div>
</blockquote>
<br>
Flora is much more than just HiLog, so you might want to look into
it for other reasons also. <br>
<br>
--<br>
<br>
--- michael<br>
<br>
<br>
<blockquote
cite="mid:db8...@HU..."
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt">
<br>
-Sergio<br>
<br>
<div><br>
<blockquote style="border-left: 2px solid rgb(16, 16, 255);
margin-left: 5px; margin-top: 5px; padding-left: 5px;">
<div style="font-family: arial, helvetica, sans-serif;
font-size: 12pt;">
<div style="font-family: times new roman, new york, times,
serif; font-size: 12pt;">
<div dir="ltr"><font size="2" face="Arial">
<hr size="1">
<b><span style="font-weight:bold;">De :</span></b>
David Warren <a class="moz-txt-link-rfc2396E" href="mailto:wa...@cs..."><wa...@cs...></a><br>
<b><span style="font-weight: bold;">À :</span></b>
Miguel Calejo <a class="moz-txt-link-rfc2396E" href="mailto:mc...@de..."><mc...@de...></a>; Sergio
Castro <a class="moz-txt-link-rfc2396E" href="mailto:ser...@ya..."><ser...@ya...></a>
<br>
<b><span style="font-weight: bold;">Cc :</span></b>
<a class="moz-txt-link-rfc2396E" href="mailto:xsb...@li...">"xsb...@li..."</a>
<a class="moz-txt-link-rfc2396E" href="mailto:xsb...@li..."><xsb...@li...></a>
<br>
<b><span style="font-weight: bold;">Envoyé le :</span></b>
Lundi 18 mars 2013 21h03<br>
<b><span style="font-weight: bold;">Objet :</span></b>
RE: [Xsb-development] Question about Hilog terms in
XSB<br>
</font></div>
<br>
<div id="yiv1196965755">
<style><!--
#yiv1196965755
_filtered #yiv1196965755 {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
_filtered #yiv1196965755 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
_filtered #yiv1196965755 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
#yiv1196965755
#yiv1196965755 p.yiv1196965755MsoNormal, #yiv1196965755 li.yiv1196965755MsoNormal, #yiv1196965755 div.yiv1196965755MsoNormal
{margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman", "serif";}
#yiv1196965755 a:link, #yiv1196965755 span.yiv1196965755MsoHyperlink
{color:blue;text-decoration:underline;}
#yiv1196965755 a:visited, #yiv1196965755 span.yiv1196965755MsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
#yiv1196965755 code
{font-family:"Courier New";}
#yiv1196965755 span.yiv1196965755comment-copy
{}
#yiv1196965755 span.yiv1196965755EmailStyle19
{font-family:"Calibri", "sans-serif";color:#1F497D;}
#yiv1196965755 .yiv1196965755MsoChpDefault
{font-size:10.0pt;}
_filtered #yiv1196965755 {margin:1.0in 1.0in 1.0in 1.0in;}
#yiv1196965755 div.yiv1196965755WordSection1
{}
--></style>
<div>
<div class="yiv1196965755WordSection1">
<div class="yiv1196965755MsoNormal"><span
style="font-size:14.0pt;color:#1F497D;">Actually
Flora, which is implemented with a translator
to XSB source code, does support the Flora
version of HiLog. But it does not use XSB’s
implementation of HiLog. It uses its own
translation to standard prolog predicates.
Michael Kifer (and his student who wrote the
Flora compiler) found that XSB’s support for
HiLog did not really provide the functionality
they wanted, so they rolled their own.</span></div>
<div class="yiv1196965755MsoNormal"><span
style="font-size:14.0pt;color:#1F497D;">-David</span></div>
<div class="yiv1196965755MsoNormal"><span
style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0in 0in 0in;">
<div class="yiv1196965755MsoNormal"><b><span
style="font-size:10.0pt;">From:</span></b><span
style="font-size:10.0pt;"> Miguel Calejo
[<a class="moz-txt-link-freetext" href="mailto:mc...@de...">mailto:mc...@de...</a>]
<br>
<b>Sent:</b> Monday, March 18, 2013 10:50
AM<br>
<b>To:</b> Sergio Castro<br>
<b>Cc:</b>
<a class="moz-txt-link-abbreviated" href="mailto:xsb...@li...">xsb...@li...</a><br>
<b>Subject:</b> Re: [Xsb-development]
Question about Hilog terms in XSB</span></div>
</div>
</div>
<div class="yiv1196965755MsoNormal"> </div>
<div class="yiv1196965755MsoNormal">Rather
important: <a moz-do-not-send="true"
rel="nofollow" target="_blank"
href="http://flora.sourceforge.net/">http://flora.sourceforge.net/</a>
, <a moz-do-not-send="true" rel="nofollow"
target="_blank"
href="http://silk.semwebcentral.org/">http://silk.semwebcentral.org/</a></div>
<div>
<div>
<div class="yiv1196965755MsoNormal">On Mar 18,
2013, at 12:45 , Sergio Castro wrote:</div>
</div>
<div class="yiv1196965755MsoNormal"><br>
<br>
</div>
<div>
<div>
<div>
<div class="yiv1196965755MsoNormal"
style="background:white;"><span
style="color:black;"> </span></div>
</div>
<div>
<div class="yiv1196965755MsoNormal"
style="background:white;"><span
style="color:black;">I am wondering
how important is for XSB the support
for proper Hilog terms (i.e. compounds
having as functors arbitrary terms).
Are there many XSB projects currently
using this feature ? which of them for
example ?</span></div>
</div>
<div>
<div class="yiv1196965755MsoNormal"
style="background:white;"><span
style="color:black;">I ask since as
far as I understand
<span
class="yiv1196965755comment-copy">higher
order programming is equally
possible using the ISO built-in
</span></span><code><span
style="font-size:10.0pt;color:black;">call/N.</span></code><span
style="color:black;"></span></div>
</div>
<div>
<div class="yiv1196965755MsoNormal"
style="background:white;"><span
style="color:black;">Specifically, I
would like to understand if the usage
of Hilog terms have further
applications and if it is still
regarded as a powerful feature in a
Prolog like logic language, or if it
is supported in XSB rather for
historical reasons.</span></div>
</div>
<div class="yiv1196965755MsoNormal"
style="background:white;"><span
style="color:black;"><br>
cheers,<br>
<br>
Sergio</span></div>
<div>
<blockquote
style="border:none;border-left:solid
#1010FF 1.5pt;padding:0in 0in 0in
4.0pt;margin-left:3.75pt;margin-top:3.75pt;margin-bottom:5.0pt;">
<div class="yiv1196965755MsoNormal"
style="background:white;"><span
style="color:black;"> </span></div>
</blockquote>
</div>
</div>
</div>
<div class="yiv1196965755MsoNormal">------------------------------------------------------------------------------<br>
Everyone hates slow websites. So do we.<br>
Make your web apps faster with AppDynamics<br>
Download AppDynamics Lite for free today:<br>
<a moz-do-not-send="true" rel="nofollow"
target="_blank"
href="http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________">http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________</a><br>
Xsb-development mailing list<br>
<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:Xsb...@li..."
target="_blank"
href="mailto:Xsb...@li...">Xsb...@li...</a><br>
<a moz-do-not-send="true" rel="nofollow"
target="_blank"
href="https://lists.sourceforge.net/lists/listinfo/xsb-development">https://lists.sourceforge.net/lists/listinfo/xsb-development</a></div>
</div>
<div class="yiv1196965755MsoNormal"> </div>
</div>
</div>
</div>
<br>
<br>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>
|
|
From: Sergio C. <ser...@ya...> - 2013-03-18 22:03:31
|
The predicate read_atom_to_term/3 is answering an open list of variables (in its third argument), like in this example:
?- read_atom_to_term('x(Var)', T, V).
T = x(_h248)
V = [vv(Var,_h248)|_h254];
Is this a bug ?.
cheers,
Sergio |
|
From: Sergio C. <ser...@ya...> - 2013-03-18 21:55:09
|
I see. And about Silk is the same story ?. It also uses its own implementation of HiLog instead of XSB's native one ? I am wondering if a correct conclusion of this is that I should avoid to use the XSB implementation of HiLog in new Prolog projects ?, and if eventually I am interested in doing something with HiLog in the future I should take a look to Flora ? -Sergio >________________________________ > De : David Warren <wa...@cs...> >À : Miguel Calejo <mc...@de...>; Sergio Castro <ser...@ya...> >Cc : "xsb...@li..." <xsb...@li...> >Envoyé le : Lundi 18 mars 2013 21h03 >Objet : RE: [Xsb-development] Question about Hilog terms in XSB > > > >Actually Flora, which is implemented with a translator to XSB source code, does support the Flora version of HiLog. But it does not use XSB’s implementation of HiLog. It uses its own translation to standard prolog predicates. Michael Kifer (and his student who wrote the Flora compiler) found that XSB’s support for HiLog did not really provide the functionality they wanted, so they rolled their own. >-David > >From:Miguel Calejo [mailto:mc...@de...] >Sent: Monday, March 18, 2013 10:50 AM >To: Sergio Castro >Cc: xsb...@li... >Subject: Re: [Xsb-development] Question about Hilog terms in XSB > >Rather important: http://flora.sourceforge.net/ , http://silk.semwebcentral.org/ >On Mar 18, 2013, at 12:45 , Sergio Castro wrote: > > > > >I am wondering how important is for XSB the support for proper Hilog terms (i.e. compounds having as functors arbitrary terms). Are there many XSB projects currently using this feature ? which of them for example ? >I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N. >Specifically, I would like to understand if the usage of Hilog terms have further applications and if it is still regarded as a powerful feature in a Prolog like logic language, or if it is supported in XSB rather for historical reasons. > >cheers, > >Sergio > >------------------------------------------------------------------------------ >Everyone hates slow websites. So do we. >Make your web apps faster with AppDynamics >Download AppDynamics Lite for free today: >http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________ >Xsb-development mailing list >Xsb...@li... >https://lists.sourceforge.net/lists/listinfo/xsb-development > > > |
|
From: Michael K. <mic...@st...> - 2013-03-18 16:55:57
|
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" text="#000000"
bgcolor="#FFFFFF">
Sergio,<br>
In XSB itself, HiLog is not well-developed, so I am not sure if it
is being used.<br>
However, in FLORA-2, which is a higher language that is built on top
of XSB, HiLog is fully developed and is very important. Likewise,
SILK is heavily using HiLog. <br>
<br>
As to call/1, this does only a small part of what HiLog does.
However, since HiLog is implemented by a transform to XSB,
everything can be done in XSB itself if you are willing to write
very complex terms yourself.<br>
<br>
--<br>
<br>
--- michael<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 03/18/2013 08:45 AM, Sergio Castro
wrote:<br>
</div>
<blockquote
cite="mid:136...@we..."
type="cite">
<div style="color:#000; background-color:#fff; font-family:arial,
helvetica, sans-serif;font-size:12pt">
<div><br>
<span></span></div>
<div>I am wondering how important is for XSB the support for
proper Hilog terms (i.e. compounds having as functors
arbitrary terms). Are there many XSB projects currently using
this feature ? which of them for example ?</div>
<div>I ask since as far as I understand <span
class="yiv385932578comment-copy">higher order programming is
equally possible using the ISO built-in <code>call/N.</code></span></div>
<div>Specifically, I would like to understand if the usage of
Hilog terms have further applications and if it is still
regarded as a powerful feature in a Prolog like logic
language, or if it is supported in XSB rather for historical
reasons.<br>
</div>
<br>
cheers,<br>
<br>
Sergio<br>
<div><br>
<blockquote style="border-left: 2px solid rgb(16, 16, 255);
margin-left: 5px; margin-top: 5px; padding-left: 5px;">
<div style="font-family: arial, helvetica, sans-serif;
font-size: 12pt;"> </div>
</blockquote>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
<a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/appdyn_d2d_mar">http://p.sf.net/sfu/appdyn_d2d_mar</a></pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Xsb-development mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Xsb...@li...">Xsb...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/xsb-development">https://lists.sourceforge.net/lists/listinfo/xsb-development</a>
</pre>
</blockquote>
<br>
</body>
</html>
|
|
From: Miguel C. <mc...@de...> - 2013-03-18 14:49:25
|
Rather important: http://flora.sourceforge.net/ , http://silk.semwebcentral.org/ On Mar 18, 2013, at 12:45 , Sergio Castro wrote: > > I am wondering how important is for XSB the support for proper Hilog terms (i.e. compounds having as functors arbitrary terms). Are there many XSB projects currently using this feature ? which of them for example ? > I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N. > Specifically, I would like to understand if the usage of Hilog terms have further applications and if it is still regarded as a powerful feature in a Prolog like logic language, or if it is supported in XSB rather for historical reasons. > > cheers, > > Sergio > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________ > Xsb-development mailing list > Xsb...@li... > https://lists.sourceforge.net/lists/listinfo/xsb-development |
|
From: Sergio C. <ser...@ya...> - 2013-03-18 14:09:50
|
I see, thanks Miguel!. >________________________________ > De : Miguel Calejo <mc...@de...> >À : Sergio Castro <ser...@ya...> >Cc : "xsb...@li..." <xsb...@li...> >Envoyé le : Lundi 18 mars 2013 14h49 >Objet : Re: [Xsb-development] Question about Hilog terms in XSB > > >Rather important: http://flora.sourceforge.net/ , http://silk.semwebcentral.org/ > >On Mar 18, 2013, at 12:45 , Sergio Castro wrote: > > >> >>I am wondering how important is for XSB the support for proper Hilog terms (i.e. compounds having as functors arbitrary terms). Are there many XSB projects currently using this feature ? which of them for example ? >>I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N. >>Specifically, I would like to understand if the usage of Hilog terms have further applications and if it is still regarded as a powerful feature in a Prolog like logic language, or if it is supported in XSB rather for historical reasons. >> >>cheers, >> >>Sergio >> >> >>------------------------------------------------------------------------------ >>Everyone hates slow websites. So do we. >>Make your web apps faster with AppDynamics >>Download AppDynamics Lite for free today: >>http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________ >>Xsb-development mailing list >>Xsb...@li... >>https://lists.sourceforge.net/lists/listinfo/xsb-development >> > > > |
|
From: Sergio C. <ser...@ya...> - 2013-03-18 12:45:57
|
I am wondering how important is for XSB the support for proper Hilog terms (i.e. compounds having as functors arbitrary terms). Are there many XSB projects currently using this feature ? which of them for example ? I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N. Specifically, I would like to understand if the usage of Hilog terms have further applications and if it is still regarded as a powerful feature in a Prolog like logic language, or if it is supported in XSB rather for historical reasons. cheers, Sergio |
|
From: Paulo M. <pm...@lo...> - 2013-03-01 07:46:34
|
Hi, I'm passing the option "-verbo" to reconsult/2 but it seems to be not operational. I still get in the output the name of the file being compiled and the cputime used. Is this a know bug? Cheers, Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pm...@lo...> Web: <http://logtalk.org/> ----------------------------------------------------------------- |
|
From: Paulo M. <pm...@lo...> - 2013-02-11 17:26:16
|
Hi, Logtalk 3.00.0 Alpha 9 was released today and its available at: https://github.com/LogtalkDotOrg/logtalk3 Detailed release notes can be consulted here: https://github.com/LogtalkDotOrg/logtalk3/blob/master/RELEASE_NOTES.md General information on Logtalk is available at: http://logtalk.org/ Despite the "alpha" tag, this release is better on all aspects compared with the current "stable" version, 2.44.1, thanks to its new features, exhaustive code reviews, fixes for several corner cases, a new set of unit tests, and improved developing tools. In particular, Logtalk 3 adds support for structured message printing and for message forwarding and delegation. Feedback is sought and most welcome on all aspects of Logtalk, including features, tools, documentation, portability, and licensing terms. But please do so preferably in the Logtalk discussion forums (http://forums.logtalk.org/) or by mail to the developer. Cheers, Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pm...@lo...> Web: <http://logtalk.org/> ----------------------------------------------------------------- |
|
From: Roberto B. <ba...@cs...> - 2013-02-08 16:39:44
|
C expressions like INT_MIN % -1 are undefined behavior in C11
(the 2011 revision of the C standard). This was a pragmatic
decision due to the fact that many compilers (notably, GCC)
did and do miscompile that expression on some popular targets.
It looks like XSB is affected:
$ xsb
[xsb_configuration loaded]
[sysinitrc loaded]
XSB Version 3.3.7 (Pignoletto) of August 12, 2012
[x86_64-unknown-linux-gnu 64 bits; mode: optimal; engine: slg-wam; scheduling: local]
[Patch date: 2012/08/12 15:03:17]
| ?- X is 9223372036854775807, Y is -X -1, Z is Y rem -1.
Floating point exception (core dumped)
--
Prof. Roberto Bagnara
Applied Formal Methods Laboratory - University of Parma, Italy
mailto:ba...@cs...
BUGSENG srl - http://bugseng.com
mailto:rob...@bu...
|
|
From: Paulo M. <pm...@lo...> - 2012-12-12 17:31:47
|
Hi, Is there a way to access the command line arguments used when starting XSB? I couldn't locate such functionality browsing the documentation. Cheers, Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pm...@lo...> Web: <http://logtalk.org/> ----------------------------------------------------------------- |
|
From: Miguel C. <mc...@de...> - 2012-11-21 02:15:26
|
When logging attributed vars these are output within a bad list. For example: ..... na([_attv0x11e4c2868 ,Goal,132). % misses closing bracket ] , has a space instead ..... Seems something in either sprint_term or sprint_answer_template ... Thanks Miguel Calejo Declarativa mc...@de... http://www.declarativa.pt telefone: +351-22-030-1580 fax: +351-22-030-1511 UPTEC - Parque de Ciência e Tecnologia da Universidade do Porto Rua Actor Ferreira da Silva 100 4200-298 Porto Portugal |
|
From: K. A. <k_a...@ya...> - 2012-10-10 17:03:23
|
The query answering primitives in the C<-->XSB interface seem to break when the given goals and/or results are large-ish. For instance, suppose that the following straightforward definition of append (on user-defined lists, not on native Prolog lists) has been loaded: append(nil,X,X). append(cons(X,L1),L2,cons(X,R)) :- append(L1,L2,R). and let goal be the string "append(x,y,Result)" where x and y are ground cons-nil lists of integer numerals from 1 to 100K and from 100K to 200K respectively. I.e., x1 and x2 are cons(100000,cons(99999,... cons(1,nil) ...)) and cons(200000,... cons(100000,nil)...) respectively. So, goal has ~200K nodes and Result should have ~200K nodes as well. Then the following query code chokes (causes a segmentation fault): XSB_StrDefine(return_string); xsb_query_string_string(CTXTc goal,&return_string,"|"); That shouldn't happen, both b/c there's plenty of memory on the machine, and - more importantly - b/c the specification of xsb_query_string_string claims that it will return an appropriate error code (via XSB_ERROR) if something catastrophic happens. The exact same code works fine when the terms are smaller. The "fixed string" interface, using xsb_query_string_string_b, does not fare better: rc = xsb_query_string_string_b(CTXTc goal,return_string,ret_size,&ans_len,"|"); This seg-faults when the goal and the result is large-ish, *even* if return_string has more than enough space to hold the result and ret_size has the right value. (E.g., try this with goal = append(x1,x2,Result) where x1 has 100K integer elements and x2 has 200K integer elements.) I'm using the single-threaded engine. Keep in mind that for today's standard terms with 200K-500K nodes are fairly small. E.g., SAT/SMT solvers routinely have to deal with terms/formulas with millions of nodes, and one might want to use XSB to manipulate such objects (I would!). Any suggestions on how to get around this (or any fixes) will be appreciated. Thanks, K. > > |
|
From: K. A. <k_a...@ya...> - 2012-08-27 15:32:52
|
I just did a fresh install of XSB on a different Linux box,
using the exact same sources I had used before (which I had
downloaded from the XSB site in July: XSB version 3.3.6), and
with the exact same version of gcc as before (which is, btw,
identical to yours: gcc 4.1.2 20080704 - Red Hat 4.1.2-52),
and I got the exact same error. See below for the screen shot.
I then did another fresh install with the XSB sources that
were posted on the XSB site in August (XSB version 3.3.7) and
with *those* sources the problem doesn't appear. Conclusion #1:
This is a problem that went away in the August sources, as of
version 3.3.7. Conclusion #2: Given that gcc incompatibility is
ruled out, there is definitely a "floundering" bug in XSB 3.3.6
(this is easily verified: I can post the tarballed distribution
of XSB 3.3.6 that I got in July online, along with the example,
so that anyone could try it out on any Linux machine with the
right version of gcc; there is no way they wouldn't get the
floundering error), which, to my mind anyway, would still call
for explanation.
Thanks,
K.
root@reason-dmz bin]# gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@reason-dmz bin]# ./xsb-mt
[xsb_configuration loaded]
[sysinitrc loaded]
XSB Version 3.3.6 (Pignoletto) of January 2, 2012
[x86_64-unknown-linux-gnu 64 bits; mode: optimal; engine: multi-threading; scheduling: local]
[Patch date: 2012/01/09 03:50:32]
| ?- consult('prelude.P').
[prelude loaded, cpu time used: 0.0010 seconds]
yes
| ?- assert(parentOf(a,b,[])).
yes
| ?- thread_create(findall(X/Y/L,familyOfP(X,Y,L),R), Id), thread_join(Id,E).
++Error[XSB/Runtime/P]: [Miscellaneous] [th 1] Floundering goal in tnot/1 familyOfP(_v329030656
X = _h167
Y = _h181
L = _h195
R = _h257
Id = 1
E = exception(error(misc_error,[th 1] Floundering goal in tnot/1 familyOfP(_v329030656,[[Forward Continuation...,... standard:call/1,... standard:call/1,... standard:call/1],Backward Continuation...]))
--- On Mon, 8/27/12, Terrance Swift <ts...@cs...> wrote:
From: Terrance Swift <ts...@cs...>
Subject: RE: Bug in multi-threaded XSB?
To: "K. A." <k_a...@ya...>, "David Warren" <wa...@cs...>
Cc: "Xsb...@li..." <Xsb...@li...>
Date: Monday, August 27, 2012, 8:57 AM
Ok , this is weird. I can't reproduce on Linux, either (version info below)
I'm wondering whether it would help to download a new version of XSB (either 3.3.7 or directly from CVS) and see if that helps anything.
AFAIK, I"m doing what you're doing so the problem must either be in the linux/C compiler you're using, (mine is gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) or in your version of XSB. So I guess the next
XSB Version 3.3.6 (Pignoletto) of January 2, 2012
[x86_64-unknown-linux-gnu 64 bits; mode: optimal; engine: multi-threading; schedu\
ling: local]
[Patch date: 2012/03/09 18:27:01]
| ?- consult('prelude.P').
[Compiling ./prelude]
[prelude compiled, cpu time used: 0.1170 seconds]
[prelude loaded]
yes
| ?- assert(parentOf(a,b,[])).
yes
| ?- thread_create(findall(X/Y/L,familyOfP(X,Y,L),R),Id), thread_join(Id,ExitCode\
).
X = _h52
Y = _h66
L = _h80
R = _h142
Id = 1
ExitCode = true
yes
| ?- shell('uname -a').
Linux fermi 2.6.18-308.4.1.el5 #1 SMP Tue Apr 17 17:08:00 EDT 2012 x86_64 x86_64 \
x86_64 GNU/Linux
yes
From: K. A. [k_a...@ya...]
Sent: Sunday, August 26, 2012 3:57 PM
To: David Warren; Terrance Swift
Cc: Xsb...@li...
Subject: RE: Bug in multi-threaded XSB?
Hi Terry,
I'm not sure what code you have in the files that you cite
(no files were actually attached to your email), but the
interaction with xsb shown below is a verbatim screen shot.
This time I've actually attached prelude.P as a separate
file that you can save and then 'consult' directly.
K.
--------------------------------------------------------------------------------
[root@reason new]$ ./xsb
[xsb_configuration loaded]
[sysinitrc loaded]
XSB Version 3.3.6 (Pignoletto) of January 2, 2012
[x86_64-unknown-linux-gnu 64 bits; mode: optimal; engine: multi-threading; scheduling: local]
[Patch date: 2012/01/09 03:50:32]
| ?- consult('prelude.P').
[Compiling ./prelude]
[prelude compiled, cpu time used: 0.1060 seconds]
[prelude loaded, cpu time used: 0.0010 seconds]
yes
| ?- assert(parentOf(a,b,[])).
yes
| ?- thread_create(findall(X/Y/L,familyOfP(X,Y,L),R),Id), thread_join(Id,ExitCode).
++Error[XSB/Runtime/P]: [Miscellaneous] [th 1] Floundering goal in tnot/1 familyOfP(_v212918432
X = _h51
Y = _h65
L = _h79
R = _h141
Id = 1
ExitCode = exception(error(misc_error,[th 1] Floundering goal in tnot/1 familyOfP(_v212918432,[[Forward Continuation...,... standard:call/1,... standard:call/1,... standard:call/1],Backward Continuation...]))
--------------------------------------------------------------------------------
--- On Sun, 8/26/12, Terrance Swift
<ts...@cs...> wrote:
From: Terrance Swift <ts...@cs...>
Subject: RE: Bug in multi-threaded XSB?
To: "K. A." <k_a...@ya...>, "David Warren" <wa...@cs...>
Cc: "Xsb...@li..." <Xsb...@li...>
Date: Sunday, August 26, 2012, 11:17 AM
I tried a couple of ways, but I haven't yet been able to reproduce the error -- at least not yet.
The attached file ka.P has your code in it, plus various predicates of the form mytest<...> that call things in different ways. The file ka1.P consults ka.P and then does the same thing. I must be missing something that you are doing?
Terry
PS: in the code you sent a parenthesis was missing as shown below. This was the only change to your code that I'm aware of making...
thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),Id), >>>)<<<< thread_join(Id,ExitCode)
From: K. A. [k_a...@ya...]
Sent: Tuesday, August 21, 2012 4:56 PM
To: David Warren
Cc: Xsb...@li...; Terrance Swift
Subject: Re: Bug in multi-threaded XSB?
Hi David, Terry,
The manual lists abolish_all_private_tables/0 (in Chapter 6)
as a "standard predicate", described on p. 100 as predicates
"which are always available to the Prolog interpreter and do
not need to be imported or loaded explicitly as do other Prolog
predicates." Terry has volunteered to fix that in the manual
(thanks!).
I've run into what appears to be a threading bug though, which
I hope that Terry can shed some light on. Per Terry's suggestion,
I've declared privately tabled versions of all my shared dynamic
predicates, by appending the capital letter 'P' at the end of
each predicate's name (e.g., if I have a shared dynamic predicate
'before' then I introduce a privately tabled predicate 'beforeP').
Then I define the privately tabled versions to be supersets of the shared ones (again, as Terry suggested), e.g.:
beforeP(X,Y,Z) :- before(X,Y,Z).
However, I'm running into another thread issue, which is
(again) a discepancy between doing something on the main
thread and doing the exact same thing on a spawned thread.
This time I was able to reproduce the problem in pure
XSB - no C involved. Consider the following interaction
with XSB:
consult('prelude.P').
assert(parentOf(a,b,[])).
findall(X/Y/L,familyOfP(X,Y,L),R), write(R).
(See below for the contents of prelude.P.)
This works fine (because it's done on the main thread):
it correctly reasons out that a is familyOfP b, b is familyOfP a,
etc. Now I *should* get the same result when I evaluate
this query on a spawned thread. But I don't. When I do:
consult('prelude.P').
assert(parentOf(a,b,[])).
thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),Id), thread_join(Id,ExitCode).
I get the following odd error:
| ?- thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),write(R)),Id), thread_join(Id,ExitCode).
++Error[XSB/Runtime/P]: [Miscellaneous] [th 1] Floundering goal in tnot/1 familyOfP(_v185356496
X = _h171
Y = _h185
L = _h199
R = _h261
Id = 1
ExitCode = exception(error(misc_error,[th 1] Floundering goal
in tnot/1 familyOfP(_v185356496,[[Forward Continuation...,...
standard:call/1,... standard:call_c/1,... standard:call/1,...
standard:call/1],Backward Continuation...]))
This is especially perplexing given that there is no negation
anywhere, tabled or otherwise. How/where does floundering enter
the picture? I've actually run into a number of such "floundering"
errors recently while trying to do seemingly innocuous things on
spawned threads. (I've forwarded some such errors before to David,
though we were both stumped by the nature of the error message.)
Again, I've only seen such errors on spawned threads, never on
the main XSB thread. Clarification/feedback would be appreciated.
Thanks,
Konstantine
The contents of prelude.P are pasted below. Most of this stuff
is irrelevant to the problem, but I've spent the last 3 hours
throwing away the majority of the stuff from prelude.P. What's left
is, I think, pretty manageable and readable:
:- import append/3 from basics.
appendAll([],[]).
appendAll([H|T],L) :- appendAll(T,L1), append(H,L1,L).
append3(L1,L2,L3,L) :- append(L1,L2,R), append(L3,R,L).
append4(L1,L2,L3,L4,L) :- append3(L1,L2,L3,R), append(L4,R,L).
append5(L1,L2,L3,L4,L5,L) :- append4(L1,L2,L3,L4,R), append(L5,R,L).
/*****************************************************************************
Private tabled predicate declarations
******************************************************************************/
:- table afterP/3 as private.
:- table beforeP/3 as private.
:- table dateAfterP/3 as private.
:- table dateBeforeP/3 as private.
:- table intervalAfterP/3 as private.
:- table intervalBeforeP/3 as private.
:- table differentFromP/3 as private.
:- table knowsOfP/3 as private.
:- table relatedPersonOfP/3 as private.
:- table familyOfP/3 as private.
:- table auntOfP/3 as private.
:- table cousinOfP/3 as private.
:- table nephewOfP/3 as private.
:- table nieceOfP/3 as private.
:- table uncleOfP/3 as private.
:- table ancestorOfP/3 as private.
:- table grandParentOfP/3 as private.
:- table grandMotherOfP/3 as private.
:- table grandFatherOfP/3 as private.
:- table parentOfP/3 as private.
:- table fatherOfP/3 as private.
:- table motherOfP/3 as private.
:- table descendantOfP/3 as private.
:- table childOfP/3 as private.
:- table daughterOfP/3 as private.
:- table sonOfP/3 as private.
:- table grandChildOfP/3 as private.
:- table grandsonOfP/3 as private.
:- table granddaughterOfP/3 as private.
:- table inLawOfP/3 as private.
:- table brotherInLawOfP/3 as private.
:- table daughterInLawOfP/3 as private.
:- table fatherInLawOfP/3 as private.
:- table motherInLawOfP/3 as private.
:- table sisterInLawOfP/3 as private.
:- table sonInLawOfP/3 as private.
:- table siblingOfP/3 as private.
:- table brotherOfP/3 as private.
:- table sisterOfP/3 as private.
:- table spouseOfP/3 as private.
:- table husbandOfP/3 as private.
:- table wifeOfP/3 as private.
:- table unknownPersonRelationP/3 as private.
:- table endsInDateP/3 as private.
:- table startsInDateP/3 as private.
:- table expirationDateP/3 as private.
:- table hasLocationP/3 as private.
:- table ownedByP/3 as private.
:- table involvedP/3 as private.
:- table occursInP/3 as private.
:- table occursDuringP/3 as private.
:- table operationAreaP/3 as private.
:- table ownerOfP/3 as private.
:- table relatedEventP/3 as private.
:- table teacherP/3 as private.
:- table relationObjectP/3 as private.
:- table studentP/3 as private.
:- table ageP/3 as private.
:- table dateDayP/3 as private.
:- table dateMonthP/3 as private.
:- table dateYearP/3 as private.
:- table descriptionP/3 as private.
:- table dateP/1 as private.
:- table dateIntervalP/1 as private.
:- table eventP/1 as private.
:- table locationP/1 as private.
:- table cityP/1 as private.
:- table countryP/1 as private.
:- table regionP/1 as private.
:- table stateP/1 as private.
/*****************************************************************************
Dynamic predicate declarations
******************************************************************************/
:- dynamic after/3 as shared.
:- dynamic before/3 as shared.
:- dynamic dateAfter/3 as shared.
:- dynamic dateBefore/3 as shared.
:- dynamic intervalAfter/3 as shared.
:- dynamic intervalBefore/3 as shared.
:- dynamic differentFrom/3 as shared.
:- dynamic knowsOf/3 as shared.
:- dynamic relatedPersonOf/3 as shared.
:- dynamic familyOf/3 as shared.
:- dynamic auntOf/3 as shared.
:- dynamic cousinOf/3 as shared.
:- dynamic nephewOf/3 as shared.
:- dynamic nieceOf/3 as shared.
:- dynamic uncleOf/3 as shared.
:- dynamic ancestorOf/3 as shared.
:- dynamic grandParentOf/3 as shared.
:- dynamic grandMotherOf/3 as shared.
:- dynamic grandFatherOf/3 as shared.
:- dynamic parentOf/3 as shared.
:- dynamic fatherOf/3 as shared.
:- dynamic motherOf/3 as shared.
:- dynamic descendantOf/3 as shared.
:- dynamic childOf/3 as shared.
:- dynamic daughterOf/3 as shared.
:- dynamic sonOf/3 as shared.
:- dynamic grandChildOf/3 as shared.
:- dynamic grandsonOf/3 as shared.
:- dynamic granddaughterOf/3 as shared.
:- dynamic inLawOf/3 as shared.
:- dynamic brotherInLawOf/3 as shared.
:- dynamic daughterInLawOf/3 as shared.
:- dynamic fatherInLawOf/3 as shared.
:- dynamic motherInLawOf/3 as shared.
:- dynamic sisterInLawOf/3 as shared.
:- dynamic sonInLawOf/3 as shared.
:- dynamic siblingOf/3 as shared.
:- dynamic brotherOf/3 as shared.
:- dynamic sisterOf/3 as shared.
:- dynamic spouseOf/3 as shared.
:- dynamic husbandOf/3 as shared.
:- dynamic wifeOf/3 as shared.
:- dynamic unknownPersonRelation/3 as shared.
:- dynamic endsInDate/3 as shared.
:- dynamic startsInDate/3 as shared.
:- dynamic expirationDate/3 as shared.
:- dynamic hasLocation/3 as shared.
:- dynamic ownedBy/3 as shared.
:- dynamic involved/3 as shared.
:- dynamic occursIn/3 as shared.
:- dynamic occursDuring/3 as shared.
:- dynamic operationArea/3 as shared.
:- dynamic ownerOf/3 as shared.
:- dynamic relatedEvent/3 as shared.
:- dynamic teacher/3 as shared.
:- dynamic relationObject/3 as shared.
:- dynamic student/3 as shared.
:- dynamic age/3 as shared.
:- dynamic dateDay/3 as shared.
:- dynamic dateMonth/3 as shared.
:- dynamic dateYear/3 as shared.
:- dynamic description/3 as shared.
:- dynamic date/1 as shared.
:- dynamic dateInterval/1 as shared.
:- dynamic event/1 as shared.
:- dynamic location/1 as shared.
:- dynamic city/1 as shared.
:- dynamic country/1 as shared.
:- dynamic region/1 as shared.
:- dynamic state/1 as shared.
/****************************************************************/
/*****************************************************************************
Private predicate definitions
******************************************************************************/
afterP(X,Y,L) :- after(X,Y,L).
beforeP(X,Y,L) :- before(X,Y,L).
dateAfterP(X,Y,L) :- dateAfter(X,Y,L).
dateBeforeP(X,Y,L) :- dateBefore(X,Y,L).
intervalAfterP(X,Y,L) :- intervalAfter(X,Y,L).
intervalBeforeP(X,Y,L) :- intervalBefore(X,Y,L).
differentFromP(X,Y,L) :- differentFrom(X,Y,L).
knowsOfP(X,Y,L) :- knowsOf(X,Y,L).
relatedPersonOfP(X,Y,L) :- relatedPersonOf(X,Y,L).
familyOfP(X,Y,L) :- familyOf(X,Y,L).
auntOfP(X,Y,L) :- auntOf(X,Y,L).
cousinOfP(X,Y,L) :- cousinOf(X,Y,L).
nephewOfP(X,Y,L) :- nephewOf(X,Y,L).
nieceOfP(X,Y,L) :- nieceOf(X,Y,L).
uncleOfP(X,Y,L) :- uncleOf(X,Y,L).
ancestorOfP(X,Y,L) :- ancestorOf(X,Y,L).
grandParentOfP(X,Y,L) :- grandParentOf(X,Y,L).
grandMotherOfP(X,Y,L) :- grandMotherOf(X,Y,L).
grandFatherOfP(X,Y,L) :- grandFatherOf(X,Y,L).
parentOfP(X,Y,L) :- parentOf(X,Y,L).
fatherOfP(X,Y,L) :- fatherOf(X,Y,L).
motherOfP(X,Y,L) :- motherOf(X,Y,L).
descendantOfP(X,Y,L) :- descendantOf(X,Y,L).
childOfP(X,Y,L) :- childOf(X,Y,L).
daughterOfP(X,Y,L) :- daughterOf(X,Y,L).
sonOfP(X,Y,L) :- sonOf(X,Y,L).
grandChildOfP(X,Y,L) :- grandChildOf(X,Y,L).
grandsonOfP(X,Y,L) :- grandsonOf(X,Y,L).
granddaughterOfP(X,Y,L) :- granddaughterOf(X,Y,L).
inLawOfP(X,Y,L) :- inLawOf(X,Y,L).
brotherInLawOfP(X,Y,L) :- brotherInLawOf(X,Y,L).
daughterInLawOfP(X,Y,L) :- daughterInLawOf(X,Y,L).
fatherInLawOfP(X,Y,L) :- fatherInLawOf(X,Y,L).
motherInLawOfP(X,Y,L) :- motherInLawOf(X,Y,L).
sisterInLawOfP(X,Y,L) :- sisterInLawOf(X,Y,L).
sonInLawOfP(X,Y,L) :- sonInLawOf(X,Y,L).
siblingOfP(X,Y,L) :- siblingOf(X,Y,L).
brotherOfP(X,Y,L) :- brotherOf(X,Y,L).
sisterOfP(X,Y,L) :- sisterOf(X,Y,L).
spouseOfP(X,Y,L) :- spouseOf(X,Y,L).
husbandOfP(X,Y,L) :- husbandOf(X,Y,L).
wifeOfP(X,Y,L) :- wifeOf(X,Y,L).
unknownPersonRelationP(X,Y,L) :- unknownPersonRelation(X,Y,L).
endsInDateP(X,Y,L) :- endsInDate(X,Y,L).
startsInDateP(X,Y,L) :- startsInDate(X,Y,L).
expirationDateP(X,Y,L) :- expirationDate(X,Y,L).
hasLocationP(X,Y,L) :- hasLocation(X,Y,L).
ownedByP(X,Y,L) :- ownedBy(X,Y,L).
involvedP(X,Y,L) :- involved(X,Y,L).
occursInP(X,Y,L) :- occursIn(X,Y,L).
occursDuringP(X,Y,L) :- occursDuring(X,Y,L).
operationAreaP(X,Y,L) :- operationArea(X,Y,L).
ownerOfP(X,Y,L) :- ownerOf(X,Y,L).
relatedEventP(X,Y,L) :- relatedEvent(X,Y,L).
teacherP(X,Y,L) :- teacher(X,Y,L).
relationObjectP(X,Y,L) :- relationObject(X,Y,L).
studentP(X,Y,L) :- student(X,Y,L).
ageP(X,Y,L) :- age(X,Y,L).
dateDayP(X,Y,L) :- dateDay(X,Y,L).
dateMonthP(X,Y,L) :- dateMonth(X,Y,L).
dateYearP(X,Y,L) :- dateYear(X,Y,L).
descriptionP(X,Y,L) :- description(X,Y,L).
dateP(X) :- date(X).
dateIntervalP(X) :- dateInterval(X).
eventP(X) :- event(X).
locationP(X) :- location(X).
cityP(X) :- city(X).
countryP(X) :- country(X).
regionP(X) :- region(X).
stateP(X) :- state(X).
schoolP(X) :- school(X).
personP(X) :- person(X).
relationP(X) :- relation(X).
directRelationP(X) :- directRelation(X).
acquaintanceP(X) :- acquaintance(X).
cohabitationP(X) :- cohabitation(X).
colleagueshipP(X) :- colleagueship(X).
enmityP(X) :- enmity(X).
friendshipP(X) :- friendship(X).
neighborhoodP(X) :- neighborhood(X).
teachingP(X) :- teaching(X).
indirectRelationP(X) :- indirectRelation(X).
/*****************************************************************************
Subproperty rules
******************************************************************************/
relationObjectP(X,Y,L) :- studentP(X,Y,L).
relationSubjectP(X,Y,L) :- teacherP(X,Y,L).
differentFromP(X,Y,L) :- knowsOfP(X,Y,L).
knowsOfP(X,Y,L) :- relatedPersonOfP(X,Y,L).
relatedPersonOfP(X,Y,L) :- unknownPersonRelationP(X,Y,L).
relatedPersonOfP(X,Y,L) :- familyOfP(X,Y,L).
familyOfP(X,Y,L) :- spouseOfP(X,Y,L).
spouseOfP(X,Y,L) :- wifeOfP(X,Y,L).
spouseOfP(X,Y,L) :- husbandOfP(X,Y,L).
familyOfP(X,Y,L) :- siblingOfP(X,Y,L).
siblingOfP(X,Y,L) :- sisterOfP(X,Y,L).
siblingOfP(X,Y,L) :- brotherOfP(X,Y,L).
familyOfP(X,Y,L) :- inLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- sonInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- sisterInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- motherInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- fatherInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- daughterInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- brotherInLawOfP(X,Y,L).
familyOfP(X,Y,L) :- descendantOfP(X,Y,L).
descendantOfP(X,Y,L) :- grandChildOfP(X,Y,L).
grandChildOfP(X,Y,L) :- granddaughterOfP(X,Y,L).
grandChildOfP(X,Y,L) :- grandsonOfP(X,Y,L).
descendantOfP(X,Y,L) :- childOfP(X,Y,L).
childOfP(X,Y,L) :- sonOfP(X,Y,L).
childOfP(X,Y,L) :- daughterOfP(X,Y,L).
familyOfP(X,Y,L) :- ancestorOfP(X,Y,L).
ancestorOfP(X,Y,L) :- parentOfP(X,Y,L).
parentOfP(X,Y,L) :- motherOfP(X,Y,L).
parentOfP(X,Y,L) :- fatherOfP(X,Y,L).
ancestorOfP(X,Y,L) :- grandParentOfP(X,Y,L).
grandParentOfP(X,Y,L) :- grandFatherOfP(X,Y,L).
grandParentOfP(X,Y,L) :- grandMotherOfP(X,Y,L).
familyOfP(X,Y,L) :- uncleOfP(X,Y,L).
familyOfP(X,Y,L) :- nieceOfP(X,Y,L).
familyOfP(X,Y,L) :- nephewOfP(X,Y,L).
familyOfP(X,Y,L) :- cousinOfP(X,Y,L).
familyOfP(X,Y,L) :- auntOfP(X,Y,L).
/*****************************************************************************
Symmetry rules
******************************************************************************/
relatedPersonOfP(X,Y,L) :- relatedPersonOfP(Y,X,L).
intervalOverlapP(X,Y,L) :- intervalOverlapP(Y,X,L).
familyOfP(X,Y,L) :- familyOfP(Y,X,L).
cousinOfP(X,Y,L) :- cousinOfP(Y,X,L).
siblingOfP(X,Y,L) :- siblingOfP(Y,X,L).
spouseOfP(X,Y,L) :- spouseOfP(Y,X,L).
/*****************************************************************************
Transitivity rules
******************************************************************************/
beforeP(X,Y,L) :- beforeP(X,Z,L1), beforeP(Z,Y,L2), append(L1,L2,L).
afterP(X,Y,L) :- afterP(X,Z,L1), afterP(Z,Y,L2), append(L1,L2,L).
dateAfterP(X,Y,L) :- dateAfterP(X,Z,L1), dateAfterP(Z,Y,L2), append(L1,L2,L).
dateBeforeP(X,Y,L) :- dateBeforeP(X,Z,L1), dateBeforeP(Z,Y,L2), append(L1,L2,L).
intervalAfterP(X,Y,L) :- intervalAfterP(X,Z,L1), intervalAfterP(Z,Y,L2), append(L1,L2,L).
intervalBeforeP(X,Y,L) :- intervalBeforeP(X,Z,L1), intervalBeforeP(Z,Y,L2), append(L1,L2,L).
relatedPersonOfP(X,Y,L) :- relatedPersonOfP(X,Z,L1), relatedPersonOfP(Z,Y,L2), append(L1,L2,L).
familyOfP(X,Y,L) :- familyOfP(X,Z,L1), familyOfP(Z,Y,L2), append(L1,L2,L).
ancestorOfP(X,Y,L) :- ancestorOfP(X,Z,L1), ancestorOfP(Z,Y,L2), append(L1,L2,L).
cousinOfP(X,Y,L) :- cousinOfP(X,Z,L1), cousinOfP(Z,Y,L2), append(L1,L2,L).
descendantOfP(X,Y,L) :- descendantOfP(X,Z,L1), descendantOfP(Z,Y,L2), append(L1,L2,L).
siblingOfP(X,Y,L) :- siblingOfP(X,Z,L1), siblingOfP(Z,Y,L2), append(L1,L2,L).
hasLocationP(X,Y,L) :- hasLocationP(X,Z,L1), hasLocationP(Z,Y,L2), append(L1,L2,L).
/*****************************************************************************
Inverse rules
******************************************************************************/
beforeP(X,Y,L) :- afterP(Y,X,L).
afterP(X,Y,L) :- beforeP(Y,X,L).
dateBeforeP(X,Y,L) :- dateAfterP(Y,X,L).
dateAfterP(X,Y,L) :- dateBeforeP(Y,X,L).
intervalBeforeP(X,Y,L) :- intervalAfterP(Y,X,L).
intervalAfterP(X,Y,L) :- intervalBeforeP(Y,X,L).
ancestorOfP(X,Y,L) :- descendantOfP(Y,X,L).
descendantOfP(X,Y,L) :- ancestorOfP(Y,X,L).
childOfP(X,Y,L) :- parentOfP(Y,X,L).
parentOfP(X,Y,L) :- childOfP(Y,X,L).
grandChildOfP(X,Y,L) :- grandParentOfP(Y,X,L).
grandParentOfP(X,Y,L) :- grandChildOfP(Y,X,L).
ownedByP(X,Y,L) :- ownerOfP(Y,X,L).
ownerOfP(X,Y,L) :- ownedByP(Y,X,L).
/*****************************************************************************
Property-Chain rules
******************************************************************************/
uncleOfP(X1,X3,L) :- brotherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
uncleOfP(X1,X4,L) :- husbandOfP(X1,X2,L1), sisterOfP(X2,X3,L2), parentOfP(X3,X4,L3), append3(L1,L2,L3,L).
parentOfP(X1,X3,L) :- parentOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
nieceOfP(X1,X3,L) :- daughterOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
nephewOfP(X1,X3,L) :- sonOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
sonInLawOfP(X1,X3,L) :- husbandOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
sisterInLawOfP(X1,X3,L) :- sisterOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
sisterInLawOfP(X1,X3,L) :- wifeOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
motherInLawOfP(X1,X3,L) :- motherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
fatherInLawOfP(X1,X3,L) :- fatherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
daughterInLawOfP(X1,X3,L) :- wifeOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
brotherInLawOfP(X1,X3,L) :- brotherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
brotherInLawOfP(X1,X3,L) :- husbandOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
grandMotherOfP(X1,X3,L) :- motherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
grandFatherOfP(X1,X3,L) :- fatherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
grandsonOfP(X1,X3,L) :- sonOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
granddaughterOfP(X1,X3,L) :- daughterOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
On Aug 21, 2012, at 12:34 PM, David Warren <wa...@cs...> wrote:
abolish_all_private_tables/0 is defined in thread.P, so I guess you need to import it from there.
The manual should say what module a predicate is defined in, and if it doesn't say it's a standard predicate, then it must be imported
-David
-----Original Message-----
From: K. A. [mailto:k_a...@ya...]
Sent: Tuesday, August 21, 2012 10:47 AM
To: Xsb...@li...; David Warren; Terrance Swift
Subject: RE: Bug in multi-threaded XSB?
That's good to hear. After checking with the manual I thought that I would want to call abolish_all_private_tables/0 on a thread poised to answer a query. (This is described on p. 237 of vol. I.) However, when I try that I get:
"Error: [XSB/Runtime/P]: [Existence (No procedure usermod:
abolish_all_private_tables/0 exists)] []"
The command-line version doesn't seem to recognize this predicate either. Do I need to import it first from somewhere?
If that doesn't work, what other alternatives are there for destroying private tables?
Thanks,
K.
--- On Tue, 8/21/12, Terrance Swift <ts...@cs...> wrote:
From: Terrance Swift <ts...@cs...>
Subject: RE: Bug in multi-threaded XSB?
To: "K. A." <k_a...@ya...>,
"Xsb...@li..."
<Xsb...@li...>, "David Warren"
<wa...@cs...>
Date: Tuesday, August 21, 2012, 8:02 AM Absolutely -- private tables
are handled just as tables in the single threaded engine, so you can
abolish them whenever it makes sense in the single threaded engine.
Heap gc for threads works just as in the single-threaded engine, and
private dynamic code also works as in the st-engine.
Terry
________________________________________
From: K. A. [k_a...@ya...]
Sent: Monday, August 20, 2012 10:08 PM
To:
Xsb...@li...;
David Warren; Terrance Swift
Subject: RE: Bug in multi-threaded XSB?
Hi Terry,
Thanks for the suggestion. One question: Can a private thread table be
explicitly abolished on that thread while other threads are running?
If so, then your suggestion could work with the unkillable threads
created by xsb_ccall_thread_create - I can maintain a queue of 20 or
so such threads and reuse them to answer queries, since I can't kill
them.
(This would obviously be unworkable in general, but in this case it's
unlikely that I'll have more than 20 concurrent queries at any given
time, so it might be viable.) But this presupposes that I can abolish
their private tables while other threads are running. If not, then I'd
have to continually spawn new threads to answer new queries, and if
these threads never quit then I'll be out of memory before too long.
Thanks,
Konstantine
--- On Mon, 8/20/12, Terrance Swift <ts...@cs...>
wrote:
From: Terrance Swift <ts...@cs...>
Subject: RE: Bug in multi-threaded XSB?
To: "K. A." <k_a...@ya...>,
"Xsb...@li..."
<Xsb...@li...>,
"David Warren" <wa...@cs...>
Date: Monday, August 20, 2012, 9:34 AM Here is the simple attached
file.
A couple of people have written large applications
with
MT-XSB but they probably did not use all the features
you
are trying to use, and MT-XSB is certainly less stable
than
single-threaded XSB. I wish I had sufficient time
to
help every user, but looking very briefly at your code,
its
impossible to understand.
1) Why you can't remove the C/XSB interface, at least
for
debugging
2) Why you can't use thread exiting, at least for
debugging
(actually its not an issue from the prolog level,
threads
exit once they have been joined.)
3) How many of the problems in XSB and how many are
multi-programming errors of yours. No offense, everybody makes
MT-programming errors.
I hope you'll take seriously the suggestions I gave you
to
start breaking down the program to help isolate the bugs. I'll try
to fix the bugs I can once they
become
clear to me.
Terry
________________________________________
From: K. A. [k_a...@ya...]
Sent: Sunday, August 19, 2012 7:06 PM
To:
Xsb...@li...;
David Warren; Terrance Swift
Subject: RE: Bug in multi-threaded XSB?
Hi Terry,
Thanks for the reply.
You're absolutely right that sharing tables can (and most probably
would) lead to problems with concurrently executing threads.
In principle, it shouldn't. In local
evaluation, there is a
mechanism to share concurrently evaluated
shared
tables which
I think is described in the manual, and is
described
in gory
detail in Marques and Swift, 2008 ICLP.
It shouldn't, as long as there are no insertions while concurrent
queries are being answered. But if there are such insertions (as is
almost always the case in question-answering systems), then these
will not occur with abolished tables but
rather
with whatever tables happen to be in effect at
insertion
time,
which will in turn depend on the state of the various active queries
at the time. This will most likely invalidate
the
insertions
and lead to wrong results. It seems to me that what
one
really
needs is the ability to spawn a query at time t with a
*fresh* (empty)
set of tables and with whatever data happens to be in
the
database at t. I don't know if, with private predicates/tables,
there is a way to forcibly copy the contents of one thread's
predicates/tables into another. If so, then this could
be
readily implemented in XSB as things stand. But if
not,
then
I don't see how XSB's tabling can be used to implement
a
system that does concurrent updates/queries.
However if you are using MT XSB, I strongly
recommend first
testing out the programming idioms you use from
the
command-line
shell, then putting things into the C-XSB
interface. XSB's
MT C-Prolog interface is quite ambitious, but
as a
result it
may have some undiagnosed bugs. Just as
importantly, XSB-only
code will be far, far easier to debug.
I'm sure that's the case, but I would think that the
point
of having a C<-->XSB interface is to facilitate
things
that,
for some reason or other, cannot be easily done
exclusively
in XSB. If I could program the whole thing in XSB by itself, I
could, but I can't. Moreover, it may well be that
some
bugs
are peculiar to the C<-->XSB interface and are
not
reproducible
when the code is expressed purely in XSB. What happens
to
them?
So I tried declaring
tables to be private, *but* it seems you cannot
have
shared dynamic predicates with private tables. The predicates
themselves (the facts in the database)
have
to be "dynamic as shared", because otherwise a new
thread
spawned to answer a query would not have any
usable
facts
to work with. But again, the combination "table p/2
as
private"
with "dynamic p/2 as shared" does not seem to be
allowed
by XSB
(perhaps someone can set me straight if I'm
missing
something).
I haven't looked at your code, but in principle
you
can do this.
See the attached file, though I'm sure that
your
program is much
more complex than the attached file.
I didn't see an attached file - could you please
resend?
I'd be very interested to see how this could be done.
At any rate, we're still left with the more narrow
question
of why in the world the query threads in this
particular
example are not exiting when they are explicitly
killed.
XSB threads should exit when they are killed,
although there are cases ?>>where this doesn't happen. For instance
if the thread is waiting on
I/O,
or waiting on a mutex, etc. the waiting thread
needs
to be signaled, to >>wake up, quit doing whatever
it
is
doing, and exit. XSB has a lot of OS
interfaces, and I haven't yet >>handled this in
every
single case. In addition, when a thread is
killed
it must clean up after itself, and free what
ever
mutexes, db_cursors, >>etc. that it has (but may
not
be currently working
on). While XSB can and does do this for
some
resources, it doesn't >>always have full
knowledge of
all of the resources a thread has taken.
So
getting thread cancellation to work in any system is awkward, and
requires a lot from both the
system and
the user.
In pretty much any MT system, its better to
have the
thread itself exit, >>and save thread
cancellation for
special cases.
Well, these are all special cases unfortunately -
these
threads
*never* exit by themselves because for some reason
which I
don't
quite understand, they go into a read-eval loop
*after*
they
are finished evaluating the goal that they were
intended
to answer. As far as I can see there is no mechanism
in
the C<-->XSB interface to create a thread to do
a
specific
job and then quit. The only way to do that would be to execute
embedded XSB code using thread_create, but
then
keeping track of the thread id and getting the thread to communicate
properly becomes very difficult
because,
again, we are not in XSB proper but in the embedded
C/XSB
world. So xsb_ccall_thread_create seems to be the only viable
option, but again, these threads don't quit by
themselves,
so killing them is the only option (and an absolute
must,
because it seems that when multiple threads are
active,
tables cannot be abolished, resources cannot be
reclaimed,
etc.).
So if you can show me how your program works from
the
command-line >interface, I'll help debug at that level. Once we are
sure the program is >doing
what
you want at that level, we can see how to add the
C-XSB
interface.
Like I said earlier, this seems to assume that the bug will be
reproducible in pure XSB, and I'm not at all sure about that. The C
code sample is very small so I hope someone will be able to take a
look at it and reach a (tentative, at least) verdict. In the
meanwhile
I'll try to take the client/server I've written in C
and
re-express it in pure XSB using the samples given in
the
/examples/sockets directory of the distribution. Is
there
anyone in particular in this list to whom I should
direct
questions pertaining to that client/server code?
Many thanks,
Konstantine
--- On Sat, 8/18/12, David Warren <wa...@cs...>
wrote:
From: David Warren <wa...@cs...>
Subject: RE: Bug in multi-threaded XSB?
To: "K. A." <k_a...@ya...>,
"Xsb...@li..."
<Xsb...@li...>
Cc: "Terrance Swift" <ts...@cs...>
Date: Saturday, August 18, 2012, 12:17 PM
I strongly suspect it is because you
are sharing the tables and that other thread is
not
exiting
(or at least XSB doesn't know it has exited.)
I would suggest that you don't use shared tables
but
private
tables. If they are not causing this problem now,
they
certainly will if you run a multithreaded query
service
where you have a number of queries and some can
update
the
underlying data.
-David
-----Original Message-----
From: K. A. [mailto:k_a...@ya...]
Sent: Friday, August 17, 2012 5:24 PM
To:
Xsb...@li...
Cc: David Warren; Terrance Swift
Subject: Bug in multi-threaded XSB?
Could someone please explain to me why the
following C
code
fails to find any answers to the last query in
the
main
function - the parentOf(X,Y,L) query?
Note that every insertion does an
abolish_all_tables
first,
and that right before each insertion or query in
main,
there
should be (as far as I can see) only one XSB
thread
active -
the main one.
I assume this is a bug in multi-threaded XSB
unless
someone
can provide an alternative explanation.
If you put the C code below in a file test.c, you
can
make
the program as follows:
gcc -c -I/home/.../XSB/emu
-I/home/.../XSB/config/x86_64-unknown-linux-gnu-mt
-O3
-fno-strict-aliasing -Wall -pipe -D_GNU_SOURCE
test.c
gcc -o test.out -lm -ldl -Wl -export-dynamic
-lpthread
/home/.../XSB/config/x86_64-unknown-linux-gnu-mt/saved.o/xsb.o
test.o
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <pthread.h>
#include <ctype.h>
#include "cinterf.h"
#include "varstring_xsb.h"
#include "context.h"
void doInsert(char* insertion_command,th_context*
th){
int
res = xsb_command_string(th,
"abolish_all_tables.");
res =
xsb_command_string(th, insertion_command);}
void doCommand(char* cmd,th_context* th){ int res
=
xsb_command_string(th, cmd);}
struct QueryArgs {
char* query;
th_context* th;};
void* doQuery(void* args) {
struct QueryArgs * pt = (struct QueryArgs *)
args;
char* query = (*pt).query;
th_context* th = (*pt).th;
XSB_StrDefine(retstr);
th_context* new_query_thread;
xsb_ccall_thread_create(th,&new_query_thread);
int rc =
xsb_query_string_string(new_query_thread,query,&retstr,"|");
int answer_count = 0;
while ((rc == XSB_SUCCESS) &&
(++answer_count))
{
printf("\nAnswer: %s\n",retstr.string);
rc = xsb_next_string(new_query_thread,
&retstr,"|");
}
printf("\n%d answers for this query:
%s\n",answer_count,query);
xsb_kill_thread(new_query_thread);
return NULL;}
void answerQuery(char* query,th_context* th){
void* exit_status;
pthread_t new_thread;
struct QueryArgs args = {.query = query, .th =
th};
pthread_create(&new_thread,NULL,doQuery,(void*)
&args);
pthread_join(new_thread,&exit_status);
}
int main() {
char init_string[MAXPATHLEN];
char* xsbHome = getenv("XSB_HOME");
strcpy(init_string, xsbHome);
xsb_init_string(init_string);
th_context *main_th = xsb_get_main_thread();
doCommand("consult('prelude.P').",xsb_get_main_thread());
doCommand("load_dyn('main.P').",xsb_get_main_thread());
doInsert("assert(auntOf(woman9,foo,[])).",xsb_get_main_thread());
answerQuery("familyOf(X,Y,L).",xsb_get_main_thread());
doInsert("assertAll([parentOf(man2,man3,[1/555]),parentOf(man1,man2,[7
/982,1/34])]).",xsb_get_main_thread());
answerQuery("parentOf(X,Y,L).",xsb_get_main_thread());
xsb_close(xsb_get_main_thread());
return 0;}
The contents of the other 2 files are as follows:
/************* Contents of prelude.P :
***************/
assertAll([]).
assertAll([H|T]) :- asserta(H),assertAll(T).
/************* Contents of main.P :
***************/
:- import append/3 from basics.
:- table motherOf/3 as shared.
:- table fatherOf/3 as shared.
:- table parentOf/3 as shared.
:- table ancestorOf/3 as shared.
:- table auntOf/3 as shared.
:- table familyOf/3 as shared.
:- dynamic motherOf/3 as shared.
:- dynamic fatherOf/3 as shared.
:- dynamic parentOf/3 as shared.
:- dynamic ancestorOf/3 as shared.
:- dynamic auntOf/3 as shared.
:- dynamic familyOf/3 as shared.
familyOf(X,Y,L) :- ancestorOf(X,Y,L).
ancestorOf(X,Y,L) :- parentOf(X,Y,L).
parentOf(X,Y,L) :- motherOf(X,Y,L).
parentOf(X,Y,L) :- fatherOf(X,Y,L).
familyOf(X,Y,L) :- auntOf(X,Y,L).
familyOf(X,Y,L) :- familyOf(Y,X,L).
ancestorOf(X,Y,L) :- ancestorOf(X,Z,L1),
ancestorOf(Z,Y,L2),
append(L1,L2,L).
|
|
From: K. A. <k_a...@ya...> - 2012-08-24 23:05:58
|
Hi Terry (and David),
I was wondering if there are any news
on the floundering issue.
In the meanwhile I have what appears to be another
bug to report. I am using the basic loop structure
that's shown in the manual to get answers to a query:
XSB_StrDefine(return_string);
int rc = xsb_query_string_string(query_thread, goal,&return_string,"|");
while (rc == XSB_SUCCESS) {
char* answer = return_string.string;
// do stuff with answer ...
rc = xsb_next_string(query_thread, &return_string,"|");
if (rc == XSB_ERROR)
... print some error message ...
}
The loop starts out fine, processes a few answers, but then
on some iteration and for some reason I don't understand, the
call to xsb_next_string crashes the system with the error message:
"Partial forward continuation." The query is well-formed,
so I don't quite understand the crash. It seems that the loop
should conclude with the remaining answers, if any. At any rate,
even if the call to xsb_next_string causes an error on the
n^th iteration, shouldn't that be captured in the value of
rc and handled by the next line, if (rc == XSB_ERROR)?
That's question #1.
Question #2: After digging around a bit, it appears that
the call to xsb_next_string inside the while loop crashes
when it's time to resolve a rule whose body involves
both static and dynamic predicates. Before that point,
all of the rules considered involved only dynamic predicates.
But the minute a mixed-body rule is examined, xsb_next_string
breaks. Is that a coincidence or is it meaningful?
Unsurprisingly btw, this is not reproducible in pure XSB.
When I spawn a thread to do the same query in the command-line
interface, I get the right answers without an error.
As usual, any feedback will be highly appreciated.
Thanks,
Konstantine
On Aug 22, 2012, at 10:25 AM, Terrance Swift <ts...@cs...> wrote:
> Yes, that is an odd error. I'll take a look ASAP -- today is pretty booked, but I should have time this evening or tomorrow morning.
>
> Terry
>
> From: K. A. [k_a...@ya...]
> Sent: Tuesday, August 21, 2012 4:56 PM
> To: David Warren
> Cc: Xsb...@li...; Terrance Swift
> Subject: Re: Bug in multi-threaded XSB?
>
> Hi David, Terry,
>
> The manual lists abolish_all_private_tables/0 (in Chapter 6)
> as a "standard predicate", described on p. 100 as predicates
> "which are always available to the Prolog interpreter and do
> not need to be imported or loaded explicitly as do other Prolog
> predicates." Terry has volunteered to fix that in the manual
> (thanks!).
>
> I've run into what appears to be a threading bug though, which
> I hope that Terry can shed some light on. Per Terry's suggestion,
> I've declared privately tabled versions of all my shared dynamic
> predicates, by appending the capital letter 'P' at the end of
> each predicate's name (e.g., if I have a shared dynamic predicate
> 'before' then I introduce a privately tabled predicate 'beforeP').
> Then I define the privately tabled versions to be supersets of the shared ones (again, as Terry suggested), e.g.:
>
> beforeP(X,Y,Z) :- before(X,Y,Z).
>
> However, I'm running into another thread issue, which is
> (again) a discepancy between doing something on the main
> thread and doing the exact same thing on a spawned thread.
> This time I was able to reproduce the problem in pure
> XSB - no C involved. Consider the following interaction
> with XSB:
>
> consult('prelude.P').
> assert(parentOf(a,b,[])).
> findall(X/Y/L,familyOfP(X,Y,L),R), write(R).
>
> (See below for the contents of prelude.P.)
>
> This works fine (because it's done on the main thread):
> it correctly reasons out that a is familyOfP b, b is familyOfP a,
> etc. Now I *should* get the same result when I evaluate
> this query on a spawned thread. But I don't. When I do:
>
> consult('prelude.P').
> assert(parentOf(a,b,[])).
> thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),Id), thread_join(Id,ExitCode).
>
> I get the following odd error:
>
> | ?- thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),write(R)),Id), thread_join(Id,ExitCode).
> ++Error[XSB/Runtime/P]: [Miscellaneous] [th 1] Floundering goal in tnot/1 familyOfP(_v185356496
>
> X = _h171
> Y = _h185
> L = _h199
> R = _h261
> Id = 1
>
> ExitCode = exception(error(misc_error,[th 1] Floundering goal
> in tnot/1 familyOfP(_v185356496,[[Forward Continuation...,...
> standard:call/1,... standard:call_c/1,... standard:call/1,...
> standard:call/1],Backward Continuation...]))
>
> This is especially perplexing given that there is no negation
> anywhere, tabled or otherwise. How/where does floundering enter
> the picture? I've actually run into a number of such "floundering"
> errors recently while trying to do seemingly innocuous things on
> spawned threads. (I've forwarded some such errors before to David,
> though we were both stumped by the nature of the error message.)
> Again, I've only seen such errors on spawned threads, never on
> the main XSB thread. Clarification/feedback would be appreciated.
> Thanks,
>
> Konstantine
>
> The contents of prelude.P are pasted below. Most of this stuff
> is irrelevant to the problem, but I've spent the last 3 hours
> throwing away the majority of the stuff from prelude.P. What's left
> is, I think, pretty manageable and readable:
>
> :- import append/3 from basics.
>
> appendAll([],[]).
> appendAll([H|T],L) :- appendAll(T,L1), append(H,L1,L).
>
> append3(L1,L2,L3,L) :- append(L1,L2,R), append(L3,R,L).
> append4(L1,L2,L3,L4,L) :- append3(L1,L2,L3,R), append(L4,R,L).
> append5(L1,L2,L3,L4,L5,L) :- append4(L1,L2,L3,L4,R), append(L5,R,L).
>
>
> /*****************************************************************************
> Private tabled predicate declarations
> ******************************************************************************/
>
> :- table afterP/3 as private.
> :- table beforeP/3 as private.
> :- table dateAfterP/3 as private.
> :- table dateBeforeP/3 as private.
> :- table intervalAfterP/3 as private.
> :- table intervalBeforeP/3 as private.
> :- table differentFromP/3 as private.
> :- table knowsOfP/3 as private.
> :- table relatedPersonOfP/3 as private.
> :- table familyOfP/3 as private.
> :- table auntOfP/3 as private.
> :- table cousinOfP/3 as private.
> :- table nephewOfP/3 as private.
> :- table nieceOfP/3 as private.
> :- table uncleOfP/3 as private.
> :- table ancestorOfP/3 as private.
> :- table grandParentOfP/3 as private.
> :- table grandMotherOfP/3 as private.
> :- table grandFatherOfP/3 as private.
> :- table parentOfP/3 as private.
> :- table fatherOfP/3 as private.
> :- table motherOfP/3 as private.
> :- table descendantOfP/3 as private.
> :- table childOfP/3 as private.
> :- table daughterOfP/3 as private.
> :- table sonOfP/3 as private.
> :- table grandChildOfP/3 as private.
> :- table grandsonOfP/3 as private.
> :- table granddaughterOfP/3 as private.
> :- table inLawOfP/3 as private.
> :- table brotherInLawOfP/3 as private.
> :- table daughterInLawOfP/3 as private.
> :- table fatherInLawOfP/3 as private.
> :- table motherInLawOfP/3 as private.
> :- table sisterInLawOfP/3 as private.
> :- table sonInLawOfP/3 as private.
> :- table siblingOfP/3 as private.
> :- table brotherOfP/3 as private.
> :- table sisterOfP/3 as private.
> :- table spouseOfP/3 as private.
> :- table husbandOfP/3 as private.
> :- table wifeOfP/3 as private.
> :- table unknownPersonRelationP/3 as private.
> :- table endsInDateP/3 as private.
> :- table startsInDateP/3 as private.
> :- table expirationDateP/3 as private.
> :- table hasLocationP/3 as private.
> :- table ownedByP/3 as private.
> :- table involvedP/3 as private.
> :- table occursInP/3 as private.
> :- table occursDuringP/3 as private.
> :- table operationAreaP/3 as private.
> :- table ownerOfP/3 as private.
> :- table relatedEventP/3 as private.
> :- table teacherP/3 as private.
> :- table relationObjectP/3 as private.
> :- table studentP/3 as private.
> :- table ageP/3 as private.
> :- table dateDayP/3 as private.
> :- table dateMonthP/3 as private.
> :- table dateYearP/3 as private.
> :- table descriptionP/3 as private.
> :- table dateP/1 as private.
> :- table dateIntervalP/1 as private.
> :- table eventP/1 as private.
> :- table locationP/1 as private.
> :- table cityP/1 as private.
> :- table countryP/1 as private.
> :- table regionP/1 as private.
> :- table stateP/1 as private.
>
> /*****************************************************************************
> Dynamic predicate declarations
> ******************************************************************************/
>
> :- dynamic after/3 as shared.
> :- dynamic before/3 as shared.
> :- dynamic dateAfter/3 as shared.
> :- dynamic dateBefore/3 as shared.
> :- dynamic intervalAfter/3 as shared.
> :- dynamic intervalBefore/3 as shared.
> :- dynamic differentFrom/3 as shared.
> :- dynamic knowsOf/3 as shared.
> :- dynamic relatedPersonOf/3 as shared.
> :- dynamic familyOf/3 as shared.
> :- dynamic auntOf/3 as shared.
> :- dynamic cousinOf/3 as shared.
> :- dynamic nephewOf/3 as shared.
> :- dynamic nieceOf/3 as shared.
> :- dynamic uncleOf/3 as shared.
> :- dynamic ancestorOf/3 as shared.
> :- dynamic grandParentOf/3 as shared.
> :- dynamic grandMotherOf/3 as shared.
> :- dynamic grandFatherOf/3 as shared.
> :- dynamic parentOf/3 as shared.
> :- dynamic fatherOf/3 as shared.
> :- dynamic motherOf/3 as shared.
> :- dynamic descendantOf/3 as shared.
> :- dynamic childOf/3 as shared.
> :- dynamic daughterOf/3 as shared.
> :- dynamic sonOf/3 as shared.
> :- dynamic grandChildOf/3 as shared.
> :- dynamic grandsonOf/3 as shared.
> :- dynamic granddaughterOf/3 as shared.
> :- dynamic inLawOf/3 as shared.
> :- dynamic brotherInLawOf/3 as shared.
> :- dynamic daughterInLawOf/3 as shared.
> :- dynamic fatherInLawOf/3 as shared.
> :- dynamic motherInLawOf/3 as shared.
> :- dynamic sisterInLawOf/3 as shared.
> :- dynamic sonInLawOf/3 as shared.
> :- dynamic siblingOf/3 as shared.
> :- dynamic brotherOf/3 as shared.
> :- dynamic sisterOf/3 as shared.
> :- dynamic spouseOf/3 as shared.
> :- dynamic husbandOf/3 as shared.
> :- dynamic wifeOf/3 as shared.
> :- dynamic unknownPersonRelation/3 as shared.
> :- dynamic endsInDate/3 as shared.
> :- dynamic startsInDate/3 as shared.
> :- dynamic expirationDate/3 as shared.
> :- dynamic hasLocation/3 as shared.
> :- dynamic ownedBy/3 as shared.
> :- dynamic involved/3 as shared.
> :- dynamic occursIn/3 as shared.
> :- dynamic occursDuring/3 as shared.
> :- dynamic operationArea/3 as shared.
> :- dynamic ownerOf/3 as shared.
> :- dynamic relatedEvent/3 as shared.
> :- dynamic teacher/3 as shared.
> :- dynamic relationObject/3 as shared.
> :- dynamic student/3 as shared.
> :- dynamic age/3 as shared.
> :- dynamic dateDay/3 as shared.
> :- dynamic dateMonth/3 as shared.
> :- dynamic dateYear/3 as shared.
> :- dynamic description/3 as shared.
> :- dynamic date/1 as shared.
> :- dynamic dateInterval/1 as shared.
> :- dynamic event/1 as shared.
> :- dynamic location/1 as shared.
> :- dynamic city/1 as shared.
> :- dynamic country/1 as shared.
> :- dynamic region/1 as shared.
> :- dynamic state/1 as shared.
>
> /****************************************************************/
>
> /*****************************************************************************
> Private predicate definitions
> ******************************************************************************/
>
> afterP(X,Y,L) :- after(X,Y,L).
> beforeP(X,Y,L) :- before(X,Y,L).
> dateAfterP(X,Y,L) :- dateAfter(X,Y,L).
> dateBeforeP(X,Y,L) :- dateBefore(X,Y,L).
> intervalAfterP(X,Y,L) :- intervalAfter(X,Y,L).
> intervalBeforeP(X,Y,L) :- intervalBefore(X,Y,L).
> differentFromP(X,Y,L) :- differentFrom(X,Y,L).
> knowsOfP(X,Y,L) :- knowsOf(X,Y,L).
> relatedPersonOfP(X,Y,L) :- relatedPersonOf(X,Y,L).
> familyOfP(X,Y,L) :- familyOf(X,Y,L).
> auntOfP(X,Y,L) :- auntOf(X,Y,L).
> cousinOfP(X,Y,L) :- cousinOf(X,Y,L).
> nephewOfP(X,Y,L) :- nephewOf(X,Y,L).
> nieceOfP(X,Y,L) :- nieceOf(X,Y,L).
> uncleOfP(X,Y,L) :- uncleOf(X,Y,L).
> ancestorOfP(X,Y,L) :- ancestorOf(X,Y,L).
> grandParentOfP(X,Y,L) :- grandParentOf(X,Y,L).
> grandMotherOfP(X,Y,L) :- grandMotherOf(X,Y,L).
> grandFatherOfP(X,Y,L) :- grandFatherOf(X,Y,L).
> parentOfP(X,Y,L) :- parentOf(X,Y,L).
> fatherOfP(X,Y,L) :- fatherOf(X,Y,L).
> motherOfP(X,Y,L) :- motherOf(X,Y,L).
> descendantOfP(X,Y,L) :- descendantOf(X,Y,L).
> childOfP(X,Y,L) :- childOf(X,Y,L).
> daughterOfP(X,Y,L) :- daughterOf(X,Y,L).
> sonOfP(X,Y,L) :- sonOf(X,Y,L).
> grandChildOfP(X,Y,L) :- grandChildOf(X,Y,L).
> grandsonOfP(X,Y,L) :- grandsonOf(X,Y,L).
> granddaughterOfP(X,Y,L) :- granddaughterOf(X,Y,L).
> inLawOfP(X,Y,L) :- inLawOf(X,Y,L).
> brotherInLawOfP(X,Y,L) :- brotherInLawOf(X,Y,L).
> daughterInLawOfP(X,Y,L) :- daughterInLawOf(X,Y,L).
> fatherInLawOfP(X,Y,L) :- fatherInLawOf(X,Y,L).
> motherInLawOfP(X,Y,L) :- motherInLawOf(X,Y,L).
> sisterInLawOfP(X,Y,L) :- sisterInLawOf(X,Y,L).
> sonInLawOfP(X,Y,L) :- sonInLawOf(X,Y,L).
> siblingOfP(X,Y,L) :- siblingOf(X,Y,L).
> brotherOfP(X,Y,L) :- brotherOf(X,Y,L).
> sisterOfP(X,Y,L) :- sisterOf(X,Y,L).
> spouseOfP(X,Y,L) :- spouseOf(X,Y,L).
> husbandOfP(X,Y,L) :- husbandOf(X,Y,L).
> wifeOfP(X,Y,L) :- wifeOf(X,Y,L).
> unknownPersonRelationP(X,Y,L) :- unknownPersonRelation(X,Y,L).
> endsInDateP(X,Y,L) :- endsInDate(X,Y,L).
> startsInDateP(X,Y,L) :- startsInDate(X,Y,L).
> expirationDateP(X,Y,L) :- expirationDate(X,Y,L).
> hasLocationP(X,Y,L) :- hasLocation(X,Y,L).
> ownedByP(X,Y,L) :- ownedBy(X,Y,L).
> involvedP(X,Y,L) :- involved(X,Y,L).
> occursInP(X,Y,L) :- occursIn(X,Y,L).
> occursDuringP(X,Y,L) :- occursDuring(X,Y,L).
> operationAreaP(X,Y,L) :- operationArea(X,Y,L).
> ownerOfP(X,Y,L) :- ownerOf(X,Y,L).
> relatedEventP(X,Y,L) :- relatedEvent(X,Y,L).
> teacherP(X,Y,L) :- teacher(X,Y,L).
> relationObjectP(X,Y,L) :- relationObject(X,Y,L).
> studentP(X,Y,L) :- student(X,Y,L).
> ageP(X,Y,L) :- age(X,Y,L).
> dateDayP(X,Y,L) :- dateDay(X,Y,L).
> dateMonthP(X,Y,L) :- dateMonth(X,Y,L).
> dateYearP(X,Y,L) :- dateYear(X,Y,L).
> descriptionP(X,Y,L) :- description(X,Y,L).
> dateP(X) :- date(X).
> dateIntervalP(X) :- dateInterval(X).
> eventP(X) :- event(X).
> locationP(X) :- location(X).
> cityP(X) :- city(X).
> countryP(X) :- country(X).
> regionP(X) :- region(X).
> stateP(X) :- state(X).
> schoolP(X) :- school(X).
> personP(X) :- person(X).
> relationP(X) :- relation(X).
> directRelationP(X) :- directRelation(X).
> acquaintanceP(X) :- acquaintance(X).
> cohabitationP(X) :- cohabitation(X).
> colleagueshipP(X) :- colleagueship(X).
> enmityP(X) :- enmity(X).
> friendshipP(X) :- friendship(X).
> neighborhoodP(X) :- neighborhood(X).
> teachingP(X) :- teaching(X).
> indirectRelationP(X) :- indirectRelation(X).
>
>
> /*****************************************************************************
> Subproperty rules
> ******************************************************************************/
>
> relationObjectP(X,Y,L) :- studentP(X,Y,L).
> relationSubjectP(X,Y,L) :- teacherP(X,Y,L).
> differentFromP(X,Y,L) :- knowsOfP(X,Y,L).
> knowsOfP(X,Y,L) :- relatedPersonOfP(X,Y,L).
> relatedPersonOfP(X,Y,L) :- unknownPersonRelationP(X,Y,L).
> relatedPersonOfP(X,Y,L) :- familyOfP(X,Y,L).
> familyOfP(X,Y,L) :- spouseOfP(X,Y,L).
> spouseOfP(X,Y,L) :- wifeOfP(X,Y,L).
> spouseOfP(X,Y,L) :- husbandOfP(X,Y,L).
> familyOfP(X,Y,L) :- siblingOfP(X,Y,L).
> siblingOfP(X,Y,L) :- sisterOfP(X,Y,L).
> siblingOfP(X,Y,L) :- brotherOfP(X,Y,L).
> familyOfP(X,Y,L) :- inLawOfP(X,Y,L).
> inLawOfP(X,Y,L) :- sonInLawOfP(X,Y,L).
> inLawOfP(X,Y,L) :- sisterInLawOfP(X,Y,L).
> inLawOfP(X,Y,L) :- motherInLawOfP(X,Y,L).
> inLawOfP(X,Y,L) :- fatherInLawOfP(X,Y,L).
> inLawOfP(X,Y,L) :- daughterInLawOfP(X,Y,L).
> inLawOfP(X,Y,L) :- brotherInLawOfP(X,Y,L).
> familyOfP(X,Y,L) :- descendantOfP(X,Y,L).
> descendantOfP(X,Y,L) :- grandChildOfP(X,Y,L).
> grandChildOfP(X,Y,L) :- granddaughterOfP(X,Y,L).
> grandChildOfP(X,Y,L) :- grandsonOfP(X,Y,L).
> descendantOfP(X,Y,L) :- childOfP(X,Y,L).
> childOfP(X,Y,L) :- sonOfP(X,Y,L).
> childOfP(X,Y,L) :- daughterOfP(X,Y,L).
> familyOfP(X,Y,L) :- ancestorOfP(X,Y,L).
> ancestorOfP(X,Y,L) :- parentOfP(X,Y,L).
> parentOfP(X,Y,L) :- motherOfP(X,Y,L).
> parentOfP(X,Y,L) :- fatherOfP(X,Y,L).
> ancestorOfP(X,Y,L) :- grandParentOfP(X,Y,L).
> grandParentOfP(X,Y,L) :- grandFatherOfP(X,Y,L).
> grandParentOfP(X,Y,L) :- grandMotherOfP(X,Y,L).
> familyOfP(X,Y,L) :- uncleOfP(X,Y,L).
> familyOfP(X,Y,L) :- nieceOfP(X,Y,L).
> familyOfP(X,Y,L) :- nephewOfP(X,Y,L).
> familyOfP(X,Y,L) :- cousinOfP(X,Y,L).
> familyOfP(X,Y,L) :- auntOfP(X,Y,L).
>
> /*****************************************************************************
> Symmetry rules
> ******************************************************************************/
>
> relatedPersonOfP(X,Y,L) :- relatedPersonOfP(Y,X,L).
> intervalOverlapP(X,Y,L) :- intervalOverlapP(Y,X,L).
> familyOfP(X,Y,L) :- familyOfP(Y,X,L).
> cousinOfP(X,Y,L) :- cousinOfP(Y,X,L).
> siblingOfP(X,Y,L) :- siblingOfP(Y,X,L).
> spouseOfP(X,Y,L) :- spouseOfP(Y,X,L).
>
> /*****************************************************************************
> Transitivity rules
> ******************************************************************************/
>
> beforeP(X,Y,L) :- beforeP(X,Z,L1), beforeP(Z,Y,L2), append(L1,L2,L).
> afterP(X,Y,L) :- afterP(X,Z,L1), afterP(Z,Y,L2), append(L1,L2,L).
> dateAfterP(X,Y,L) :- dateAfterP(X,Z,L1), dateAfterP(Z,Y,L2), append(L1,L2,L).
> dateBeforeP(X,Y,L) :- dateBeforeP(X,Z,L1), dateBeforeP(Z,Y,L2), append(L1,L2,L).
> intervalAfterP(X,Y,L) :- intervalAfterP(X,Z,L1), intervalAfterP(Z,Y,L2), append(L1,L2,L).
> intervalBeforeP(X,Y,L) :- intervalBeforeP(X,Z,L1), intervalBeforeP(Z,Y,L2), append(L1,L2,L).
> relatedPersonOfP(X,Y,L) :- relatedPersonOfP(X,Z,L1), relatedPersonOfP(Z,Y,L2), append(L1,L2,L).
> familyOfP(X,Y,L) :- familyOfP(X,Z,L1), familyOfP(Z,Y,L2), append(L1,L2,L).
> ancestorOfP(X,Y,L) :- ancestorOfP(X,Z,L1), ancestorOfP(Z,Y,L2), append(L1,L2,L).
> cousinOfP(X,Y,L) :- cousinOfP(X,Z,L1), cousinOfP(Z,Y,L2), append(L1,L2,L).
> descendantOfP(X,Y,L) :- descendantOfP(X,Z,L1), descendantOfP(Z,Y,L2), append(L1,L2,L).
> siblingOfP(X,Y,L) :- siblingOfP(X,Z,L1), siblingOfP(Z,Y,L2), append(L1,L2,L).
> hasLocationP(X,Y,L) :- hasLocationP(X,Z,L1), hasLocationP(Z,Y,L2), append(L1,L2,L).
>
> /*****************************************************************************
> Inverse rules
> ******************************************************************************/
>
> beforeP(X,Y,L) :- afterP(Y,X,L).
> afterP(X,Y,L) :- beforeP(Y,X,L).
> dateBeforeP(X,Y,L) :- dateAfterP(Y,X,L).
> dateAfterP(X,Y,L) :- dateBeforeP(Y,X,L).
> intervalBeforeP(X,Y,L) :- intervalAfterP(Y,X,L).
> intervalAfterP(X,Y,L) :- intervalBeforeP(Y,X,L).
> ancestorOfP(X,Y,L) :- descendantOfP(Y,X,L).
> descendantOfP(X,Y,L) :- ancestorOfP(Y,X,L).
> childOfP(X,Y,L) :- parentOfP(Y,X,L).
> parentOfP(X,Y,L) :- childOfP(Y,X,L).
> grandChildOfP(X,Y,L) :- grandParentOfP(Y,X,L).
> grandParentOfP(X,Y,L) :- grandChildOfP(Y,X,L).
> ownedByP(X,Y,L) :- ownerOfP(Y,X,L).
> ownerOfP(X,Y,L) :- ownedByP(Y,X,L).
>
>
> /*****************************************************************************
> Property-Chain rules
> ******************************************************************************/
>
> uncleOfP(X1,X3,L) :- brotherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
> uncleOfP(X1,X4,L) :- husbandOfP(X1,X2,L1), sisterOfP(X2,X3,L2), parentOfP(X3,X4,L3), append3(L1,L2,L3,L).
> parentOfP(X1,X3,L) :- parentOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
> nieceOfP(X1,X3,L) :- daughterOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
> nephewOfP(X1,X3,L) :- sonOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
> sonInLawOfP(X1,X3,L) :- husbandOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
> sisterInLawOfP(X1,X3,L) :- sisterOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
> sisterInLawOfP(X1,X3,L) :- wifeOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
> motherInLawOfP(X1,X3,L) :- motherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
> fatherInLawOfP(X1,X3,L) :- fatherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
> daughterInLawOfP(X1,X3,L) :- wifeOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
> brotherInLawOfP(X1,X3,L) :- brotherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
> brotherInLawOfP(X1,X3,L) :- husbandOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
> grandMotherOfP(X1,X3,L) :- motherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
> grandFatherOfP(X1,X3,L) :- fatherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
> grandsonOfP(X1,X3,L) :- sonOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
> granddaughterOfP(X1,X3,L) :- daughterOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
>
>
> On Aug 21, 2012, at 12:34 PM, David Warren <wa...@cs...> wrote:
>
>> abolish_all_private_tables/0 is defined in thread.P, so I guess you need to import it from there.
>> The manual should say what module a predicate is defined in, and if it doesn't say it's a standard predicate, then it must be imported
>>
>> -David
>>
>> -----Original Message-----
>> From: K. A. [mailto:k_a...@ya...]
>> Sent: Tuesday, August 21, 2012 10:47 AM
>> To: Xsb...@li...; David Warren; Terrance Swift
>> Subject: RE: Bug in multi-threaded XSB?
>>
>> That's good to hear. After checking with the manual I thought that I would want to call abolish_all_private_tables/0 on a thread poised to answer a query. (This is described on p. 237 of vol. I.) However, when I try that I get:
>>
>> "Error: [XSB/Runtime/P]: [Existence (No procedure usermod:
>> abolish_all_private_tables/0 exists)] []"
>>
>> The command-line version doesn't seem to recognize this predicate either. Do I need to import it first from somewhere?
>> If that doesn't work, what other alternatives are there for destroying private tables?
>>
>> Thanks,
>>
>> K.
>>
>> --- On Tue, 8/21/12, Terrance Swift <ts...@cs...> wrote:
>>
>>> From: Terrance Swift <ts...@cs...>
>>
>>> Subject: RE: Bug in multi-threaded XSB?
>>
>>> To: "K. A." <k_a...@ya...>,
>>
>>> "Xsb...@li..."
>>
>>> <Xsb...@li...>, "David Warren"
>>
>>> <wa...@cs...>
>>
>>> Date: Tuesday, August 21, 2012, 8:02 AM Absolutely -- private tables
>>
>>> are handled just as tables in the single threaded engine, so you can
>>
>>> abolish them whenever it makes sense in the single threaded engine.
>>
>>> Heap gc for threads works just as in the single-threaded engine, and
>>
>>> private dynamic code also works as in the st-engine.
>>
>>>
>>
>>> Terry
>>
>>>
>>
>>> ________________________________________
>>
>>> From: K. A. [k_a...@ya...]
>>
>>> Sent: Monday, August 20, 2012 10:08 PM
>>
>>> To: Xsb...@li...;
>>
>>> David Warren; Terrance Swift
>>
>>> Subject: RE: Bug in multi-threaded XSB?
>>
>>>
>>
>>> Hi Terry,
>>
>>>
>>
>>> Thanks for the suggestion. One question: Can a private thread table be
>>
>>> explicitly abolished on that thread while other threads are running?
>>
>>> If so, then your suggestion could work with the unkillable threads
>>
>>> created by xsb_ccall_thread_create - I can maintain a queue of 20 or
>>
>>> so such threads and reuse them to answer queries, since I can't kill
>>
>>> them.
>>
>>> (This would obviously be unworkable in general, but in this case it's
>>
>>> unlikely that I'll have more than 20 concurrent queries at any given
>>
>>> time, so it might be viable.) But this presupposes that I can abolish
>>
>>> their private tables while other threads are running. If not, then I'd
>>
>>> have to continually spawn new threads to answer new queries, and if
>>
>>> these threads never quit then I'll be out of memory before too long.
>>
>>>
>>
>>> Thanks,
>>
>>>
>>
>>> Konstantine
>>
>>>
>>
>>> --- On Mon, 8/20/12, Terrance Swift <ts...@cs...>
>>
>>> wrote:
>>
>>>
>>
>>>
>>>> From: Terrance Swift <ts...@cs...>
>>>
>>
>>>
>>>> Subject: RE: Bug in multi-threaded XSB?
>>>
>>
>>>
>>>> To: "K. A." <k_a...@ya...>,
>>>
>>
>>> "Xsb...@li..."
>>
>>> <Xsb...@li...>,
>>
>>> "David Warren" <wa...@cs...>
>>
>>>
>>>> Date: Monday, August 20, 2012, 9:34 AM Here is the simple attached
>>>
>>
>>>
>>>> file.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> A couple of people have written large applications
>>>
>>
>>> with
>>
>>>
>>>> MT-XSB but they probably did not use all the features
>>>
>>
>>> you
>>
>>>
>>>> are trying to use, and MT-XSB is certainly less stable
>>>
>>
>>> than
>>
>>>
>>>> single-threaded XSB. I wish I had sufficient time
>>>
>>
>>> to
>>
>>>
>>>> help every user, but looking very briefly at your code,
>>>
>>
>>> its
>>
>>>
>>>> impossible to understand.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> 1) Why you can't remove the C/XSB interface, at least
>>>
>>
>>> for
>>
>>>
>>>> debugging
>>>
>>
>>>
>>>> 2) Why you can't use thread exiting, at least for
>>>
>>
>>> debugging
>>
>>>
>>>> (actually its not an issue from the prolog level,
>>>
>>
>>> threads
>>
>>>
>>>> exit once they have been joined.)
>>>
>>
>>>
>>>> 3) How many of the problems in XSB and how many are
>>>
>>
>>>
>>>> multi-programming errors of yours. No offense, everybody makes
>>>
>>
>>>
>>>> MT-programming errors.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> I hope you'll take seriously the suggestions I gave you
>>>
>>
>>> to
>>
>>>
>>>> start breaking down the program to help isolate the bugs. I'll try
>>>
>>
>>>
>>>> to fix the bugs I can once they
>>>
>>
>>> become
>>
>>>
>>>> clear to me.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Terry
>>>
>>
>>>
>>>> ________________________________________
>>>
>>
>>>
>>>> From: K. A. [k_a...@ya...]
>>>
>>
>>>
>>>> Sent: Sunday, August 19, 2012 7:06 PM
>>>
>>
>>>
>>>> To: Xsb...@li...;
>>>
>>
>>>
>>>> David Warren; Terrance Swift
>>>
>>
>>>
>>>> Subject: RE: Bug in multi-threaded XSB?
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Hi Terry,
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Thanks for the reply.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> You're absolutely right that sharing tables can (and most probably
>>>>
>>>
>>
>>>
>>>>
>>>>> would) lead to problems with concurrently executing threads.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>>> In principle, it shouldn't. In local
>>>>>
>>>>
>>>
>>
>>>
>>>> evaluation, there is a
>>>
>>
>>>
>>>>
>>>>>
>>>>>> mechanism to share concurrently evaluated
>>>>>
>>>>
>>>
>>
>>> shared
>>
>>>
>>>> tables which
>>>
>>
>>>
>>>>
>>>>>
>>>>>> I think is described in the manual, and is
>>>>>
>>>>
>>>
>>
>>> described
>>
>>>
>>>> in gory
>>>
>>
>>>
>>>>
>>>>>
>>>>>> detail in Marques and Swift, 2008 ICLP.
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> It shouldn't, as long as there are no insertions while concurrent
>>>
>>
>>>
>>>> queries are being answered. But if there are such insertions (as is
>>>
>>
>>>
>>>> almost always the case in question-answering systems), then these
>>>
>>
>>>
>>>> will not occur with abolished tables but
>>>
>>
>>> rather
>>
>>>
>>>> with whatever tables happen to be in effect at
>>>
>>
>>> insertion
>>
>>>
>>>> time,
>>>
>>
>>>
>>>> which will in turn depend on the state of the various active queries
>>>
>>
>>>
>>>> at the time. This will most likely invalidate
>>>
>>
>>> the
>>
>>>
>>>> insertions
>>>
>>
>>>
>>>> and lead to wrong results. It seems to me that what
>>>
>>
>>> one
>>
>>>
>>>> really
>>>
>>
>>>
>>>> needs is the ability to spawn a query at time t with a
>>>
>>
>>>
>>>> *fresh* (empty)
>>>
>>
>>>
>>>> set of tables and with whatever data happens to be in
>>>
>>
>>> the
>>
>>>
>>>> database at t. I don't know if, with private predicates/tables,
>>>
>>
>>>
>>>> there is a way to forcibly copy the contents of one thread's
>>>
>>
>>>
>>>> predicates/tables into another. If so, then this could
>>>
>>
>>> be
>>
>>>
>>>> readily implemented in XSB as things stand. But if
>>>
>>
>>> not,
>>
>>>
>>>> then
>>>
>>
>>>
>>>> I don't see how XSB's tabling can be used to implement
>>>
>>
>>> a
>>
>>>
>>>> system that does concurrent updates/queries.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>>> However if you are using MT XSB, I strongly
>>>>>
>>>>
>>>
>>
>>>
>>>> recommend first
>>>
>>
>>>
>>>>
>>>>>
>>>>>> testing out the programming idioms you use from
>>>>>
>>>>
>>>
>>
>>> the
>>
>>>
>>>> command-line
>>>
>>
>>>
>>>>
>>>>>
>>>>>> shell, then putting things into the C-XSB
>>>>>
>>>>
>>>
>>
>>>
>>>> interface. XSB's
>>>
>>
>>>
>>>>
>>>>>
>>>>>> MT C-Prolog interface is quite ambitious, but
>>>>>
>>>>
>>>
>>
>>> as a
>>
>>>
>>>> result it
>>>
>>
>>>
>>>>
>>>>>
>>>>>> may have some undiagnosed bugs. Just as
>>>>>
>>>>
>>>
>>
>>>
>>>> importantly, XSB-only
>>>
>>
>>>
>>>>
>>>>>
>>>>>> code will be far, far easier to debug.
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> I'm sure that's the case, but I would think that the
>>>
>>
>>> point
>>
>>>
>>>> of having a C<-->XSB interface is to facilitate
>>>
>>
>>> things
>>
>>>
>>>> that,
>>>
>>
>>>
>>>> for some reason or other, cannot be easily done
>>>
>>
>>> exclusively
>>
>>>
>>>> in XSB. If I could program the whole thing in XSB by itself, I
>>>
>>
>>>
>>>> could, but I can't. Moreover, it may well be that
>>>
>>
>>> some
>>
>>>
>>>> bugs
>>>
>>
>>>
>>>> are peculiar to the C<-->XSB interface and are
>>>
>>
>>> not
>>
>>>
>>>> reproducible
>>>
>>
>>>
>>>> when the code is expressed purely in XSB. What happens
>>>
>>
>>> to
>>
>>>
>>>> them?
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> So I tried declaring
>>>>
>>>
>>
>>>
>>>>
>>>>> tables to be private, *but* it seems you cannot
>>>>
>>>
>>
>>> have
>>
>>>
>>>>
>>>>> shared dynamic predicates with private tables. The predicates
>>>>
>>>
>>
>>>
>>>>
>>>>> themselves (the facts in the database)
>>>>
>>>
>>
>>> have
>>
>>>
>>>>
>>>>> to be "dynamic as shared", because otherwise a new
>>>>
>>>
>>
>>>
>>>> thread
>>>
>>
>>>
>>>>
>>>>> spawned to answer a query would not have any
>>>>
>>>
>>
>>> usable
>>
>>>
>>>> facts
>>>
>>
>>>
>>>>
>>>>> to work with. But again, the combination "table p/2
>>>>
>>>
>>
>>> as
>>
>>>
>>>> private"
>>>
>>
>>>
>>>>
>>>>> with "dynamic p/2 as shared" does not seem to be
>>>>
>>>
>>
>>> allowed
>>
>>>
>>>> by XSB
>>>
>>
>>>
>>>>
>>>>> (perhaps someone can set me straight if I'm
>>>>
>>>
>>
>>> missing
>>
>>>
>>>> something).
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>>> I haven't looked at your code, but in principle
>>>>>
>>>>
>>>
>>
>>> you
>>
>>>
>>>> can do this.
>>>
>>
>>>
>>>>
>>>>>
>>>>>> See the attached file, though I'm sure that
>>>>>
>>>>
>>>
>>
>>> your
>>
>>>
>>>> program is much
>>>
>>
>>>
>>>>
>>>>>
>>>>>> more complex than the attached file.
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> I didn't see an attached file - could you please
>>>
>>
>>> resend?
>>
>>>
>>>> I'd be very interested to see how this could be done.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> At any rate, we're still left with the more narrow
>>>>
>>>
>>
>>>
>>>> question
>>>
>>
>>>
>>>>
>>>>> of why in the world the query threads in this
>>>>
>>>
>>
>>>
>>>> particular
>>>
>>
>>>
>>>>
>>>>> example are not exiting when they are explicitly
>>>>
>>>
>>
>>>
>>>> killed.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>>> XSB threads should exit when they are killed,
>>>>>
>>>>
>>>
>>
>>>
>>>> although there are cases ?>>where this doesn't happen. For instance
>>>
>>
>>>
>>>> if the thread is waiting on
>>>
>>
>>> I/O,
>>
>>>
>>>>
>>>>>
>>>>>> or waiting on a mutex, etc. the waiting thread
>>>>>
>>>>
>>>
>>
>>> needs
>>
>>>
>>>> to be signaled, to >>wake up, quit doing whatever
>>>
>>
>>> it
>>
>>>
>>>> is
>>>
>>
>>>
>>>>
>>>>>
>>>>>> doing, and exit. XSB has a lot of OS
>>>>>
>>>>
>>>
>>
>>>
>>>> interfaces, and I haven't yet >>handled this in
>>>
>>
>>> every
>>
>>>
>>>> single case. In addition, when a thread is
>>>
>>
>>> killed
>>
>>>
>>>>
>>>>>
>>>>>> it must clean up after itself, and free what
>>>>>
>>>>
>>>
>>
>>> ever
>>
>>>
>>>> mutexes, db_cursors, >>etc. that it has (but may
>>>
>>
>>> not
>>
>>>
>>>> be currently working
>>>
>>
>>>
>>>>
>>>>>
>>>>>> on). While XSB can and does do this for
>>>>>
>>>>
>>>
>>
>>> some
>>
>>>
>>>> resources, it doesn't >>always have full
>>>
>>
>>> knowledge of
>>
>>>
>>>> all of the resources a thread has taken.
>>>
>>
>>>
>>>>
>>>>> So
>>>>
>>>
>>
>>>
>>>> getting thread cancellation to work in any system is awkward, and
>>>
>>
>>>
>>>>
>>>>>
>>>>>> requires a lot from both the
>>>>>
>>>>
>>>
>>
>>> system and
>>
>>>
>>>> the user.
>>>
>>
>>>
>>>>
>>>>>
>>>>>> In pretty much any MT system, its better to
>>>>>
>>>>
>>>
>>
>>> have the
>>
>>>
>>>> thread itself exit, >>and save thread
>>>
>>
>>> cancellation for
>>
>>>
>>>> special cases.
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Well, these are all special cases unfortunately -
>>>
>>
>>> these
>>
>>>
>>>> threads
>>>
>>
>>>
>>>> *never* exit by themselves because for some reason
>>>
>>
>>> which I
>>
>>>
>>>> don't
>>>
>>
>>>
>>>> quite understand, they go into a read-eval loop
>>>
>>
>>> *after*
>>
>>>
>>>> they
>>>
>>
>>>
>>>> are finished evaluating the goal that they were
>>>
>>
>>> intended
>>
>>>
>>>> to answer. As far as I can see there is no mechanism
>>>
>>
>>> in
>>
>>>
>>>> the C<-->XSB interface to create a thread to do
>>>
>>
>>> a
>>
>>>
>>>> specific
>>>
>>
>>>
>>>> job and then quit. The only way to do that would be to execute
>>>
>>
>>>
>>>> embedded XSB code using thread_create, but
>>>
>>
>>> then
>>
>>>
>>>> keeping track of the thread id and getting the thread to communicate
>>>
>>
>>>
>>>> properly becomes very difficult
>>>
>>
>>> because,
>>
>>>
>>>> again, we are not in XSB proper but in the embedded
>>>
>>
>>> C/XSB
>>
>>>
>>>> world. So xsb_ccall_thread_create seems to be the only viable
>>>
>>
>>>
>>>> option, but again, these threads don't quit by
>>>
>>
>>> themselves,
>>
>>>
>>>> so killing them is the only option (and an absolute
>>>
>>
>>> must,
>>
>>>
>>>> because it seems that when multiple threads are
>>>
>>
>>> active,
>>
>>>
>>>> tables cannot be abolished, resources cannot be
>>>
>>
>>> reclaimed,
>>
>>>
>>>> etc.).
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> So if you can show me how your program works from
>>>>
>>>
>>
>>> the
>>
>>>
>>>> command-line >interface, I'll help debug at that level. Once we are
>>>
>>
>>>
>>>> sure the program is >doing
>>>
>>
>>> what
>>
>>>
>>>> you want at that level, we can see how to add the
>>>
>>
>>> C-XSB
>>
>>>
>>>>
>>>>> interface.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Like I said earlier, this seems to assume that the bug will be
>>>
>>
>>>
>>>> reproducible in pure XSB, and I'm not at all sure about that. The C
>>>
>>
>>>
>>>> code sample is very small so I hope someone will be able to take a
>>>
>>
>>>
>>>> look at it and reach a (tentative, at least) verdict. In the
>>>
>>
>>> meanwhile
>>
>>>
>>>> I'll try to take the client/server I've written in C
>>>
>>
>>> and
>>
>>>
>>>> re-express it in pure XSB using the samples given in
>>>
>>
>>> the
>>
>>>
>>>> /examples/sockets directory of the distribution. Is
>>>
>>
>>> there
>>
>>>
>>>> anyone in particular in this list to whom I should
>>>
>>
>>> direct
>>
>>>
>>>> questions pertaining to that client/server code?
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Many thanks,
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> Konstantine
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>> --- On Sat, 8/18/12, David Warren <wa...@cs...>
>>>
>>
>>>
>>>> wrote:
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> From: David Warren <wa...@cs...>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Subject: RE: Bug in multi-threaded XSB?
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> To: "K. A." <k_a...@ya...>,
>>>>
>>>
>>
>>>
>>>> "Xsb...@li..."
>>>
>>
>>>
>>>> <Xsb...@li...>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Cc: "Terrance Swift" <ts...@cs...>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Date: Saturday, August 18, 2012, 12:17 PM
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> I strongly suspect it is because you
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> are sharing the tables and that other thread is
>>>>
>>>
>>
>>> not
>>
>>>
>>>> exiting
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> (or at least XSB doesn't know it has exited.)
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> I would suggest that you don't use shared tables
>>>>
>>>
>>
>>> but
>>
>>>
>>>> private
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> tables. If they are not causing this problem now,
>>>>
>>>
>>
>>> they
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> certainly will if you run a multithreaded query
>>>>
>>>
>>
>>>
>>>> service
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> where you have a number of queries and some can
>>>>
>>>
>>
>>> update
>>
>>>
>>>> the
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> underlying data.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> -David
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> -----Original Message-----
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> From: K. A. [mailto:k_a...@ya...]
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Sent: Friday, August 17, 2012 5:24 PM
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> To: Xsb...@li...
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Cc: David Warren; Terrance Swift
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Subject: Bug in multi-threaded XSB?
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Could someone please explain to me why the
>>>>
>>>
>>
>>> following C
>>
>>>
>>>> code
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> fails to find any answers to the last query in
>>>>
>>>
>>
>>> the
>>
>>>
>>>> main
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> function - the parentOf(X,Y,L) query?
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> Note that every insertion does an
>>>>
>>>
>>
>>> abolish_all_tables
>>
>>>
>>>> first,
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> and that right before each insertion or query in
>>>>
>>>
>>
>>> main,
>>
>>>
>>>> there
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> should be (as far as I can see) only one XSB
>>>>
>>>
>>
>>> thread
>>
>>>
>>>> active -
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> the main one.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> I assume this is a bug in multi-threaded XSB
>>>>
>>>
>>
>>> unless
>>
>>>
>>>> someone
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> can provide an alternative explanation.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> If you put the C code below in a file test.c, you
>>>>
>>>
>>
>>> can
>>
>>>
>>>> make
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> the program as follows:
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> gcc -c -I/home/.../XSB/emu
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> -I/home/.../XSB/config/x86_64-unknown-linux-gnu-mt
>>>>
>>>
>>
>>> -O3
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> -fno-strict-aliasing -Wall -pipe -D_GNU_SOURCE
>>>>
>>>
>>
>>> test.c
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> gcc -o test.out -lm -ldl -Wl -export-dynamic
>>>>
>>>
>>
>>> -lpthread
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>> /home/.../XSB/config/x86_64-unknown-linux-gnu-mt/saved.o/xsb.o
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> test.o
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <stdio.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <unistd.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <stdlib.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <string.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <sys/types.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <pthread.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include <ctype.h>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include "cinterf.h"
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include "varstring_xsb.h"
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> #include "context.h"
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> void doInsert(char* insertion_command,th_context*
>>>>
>>>
>>
>>> th){
>>
>>>
>>>> int
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> res = xsb_command_string(th,
>>>>
>>>
>>
>>> "abolish_all_tables.");
>>
>>>
>>>> res =
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> xsb_command_string(th, insertion_command);}
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> void doCommand(char* cmd,th_context* th){ int res
>>>>
>>>
>>
>>> =
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> xsb_command_string(th, cmd);}
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> struct QueryArgs {
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> char* query;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> th_context* th;};
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> void* doQuery(void* args) {
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> struct QueryArgs * pt = (struct QueryArgs *)
>>>>
>>>
>>
>>> args;
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> char* query = (*pt).query;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> th_context* th = (*pt).th;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> XSB_StrDefine(retstr);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> th_context* new_query_thread;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>> xsb_ccall_thread_create(th,&new_query_thread);
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> int rc =
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>> xsb_query_string_string(new_query_thread,query,&retstr,"|");
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> int answer_count = 0;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> while ((rc == XSB_SUCCESS) &&
>>>>
>>>
>>
>>>
>>>> (++answer_count))
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> {
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> printf("\nAnswer: %s\n",retstr.string);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> rc = xsb_next_string(new_query_thread,
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> &retstr,"|");
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> }
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> printf("\n%d answers for this query:
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> %s\n",answer_count,query);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> xsb_kill_thread(new_query_thread);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> return NULL;}
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> void answerQuery(char* query,th_context* th){
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> void* exit_status;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> pthread_t new_thread;
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> struct QueryArgs args = {.query = query, .th =
>>>>
>>>
>>
>>> th};
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>> pthread_create(&new_thread,NULL,doQuery,(void*)
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> &args);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> pthread_join(new_thread,&exit_status);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> }
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> int main() {
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> char init_string[MAXPATHLEN];
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> char* xsbHome = getenv("XSB_HOME");
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> strcpy(init_string, xsbHome);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> xsb_init_string(init_string);
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> th_context *main_th = xsb_get_main_thread();
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>> doCommand("consult('prelude.P').",xsb_get_main_thread());
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>> doCommand("load_dyn('main.P').",xsb_get_main_thread());
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>> doInsert("assert(auntOf(woman9,foo,[])).",xsb_get_main_thread());
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>> answerQuery("familyOf(X,Y,L).",xsb_get_main_thread());
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>> doInsert("assertAll([parentOf(man2,man3,[1/555]),parentOf(man1,man2,[7
>>
>>> /982,1/34])]).",xsb_get_main_thread());
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>> answerQuery("parentOf(X,Y,L).",xsb_get_main_thread());
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> xsb_close(xsb_get_main_thread());
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> return 0;}
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> The contents of the other 2 files are as follows:
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> /************* Contents of prelude.P :
>>>>
>>>
>>
>>>
>>>> ***************/
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> assertAll([]).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> assertAll([H|T]) :- asserta(H),assertAll(T).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> /************* Contents of main.P :
>>>>
>>>
>>
>>> ***************/
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- import append/3 from basics.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- table motherOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- table fatherOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- table parentOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- table ancestorOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- table auntOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- table familyOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- dynamic motherOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- dynamic fatherOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- dynamic parentOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- dynamic ancestorOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- dynamic auntOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> :- dynamic familyOf/3 as shared.
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> familyOf(X,Y,L) :- ancestorOf(X,Y,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> ancestorOf(X,Y,L) :- parentOf(X,Y,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> parentOf(X,Y,L) :- motherOf(X,Y,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> parentOf(X,Y,L) :- fatherOf(X,Y,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> familyOf(X,Y,L) :- auntOf(X,Y,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> familyOf(X,Y,L) :- familyOf(Y,X,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> ancestorOf(X,Y,L) :- ancestorOf(X,Z,L1),
>>>>
>>>
>>
>>>
>>>> ancestorOf(Z,Y,L2),
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>> append(L1,L2,L).
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>>>
>>>
>>
>>>
>>
>
|
|
From: K. A. <k_a...@ya...> - 2012-08-21 20:56:38
|
Hi David, Terry,
The manual lists abolish_all_private_tables/0 (in Chapter 6)
as a "standard predicate", described on p. 100 as predicates
"which are always available to the Prolog interpreter and do
not need to be imported or loaded explicitly as do other Prolog
predicates." Terry has volunteered to fix that in the manual
(thanks!).
I've run into what appears to be a threading bug though, which
I hope that Terry can shed some light on. Per Terry's suggestion,
I've declared privately tabled versions of all my shared dynamic
predicates, by appending the capital letter 'P' at the end of
each predicate's name (e.g., if I have a shared dynamic predicate
'before' then I introduce a privately tabled predicate 'beforeP').
Then I define the privately tabled versions to be supersets of the shared ones (again, as Terry suggested), e.g.:
beforeP(X,Y,Z) :- before(X,Y,Z).
However, I'm running into another thread issue, which is
(again) a discepancy between doing something on the main
thread and doing the exact same thing on a spawned thread.
This time I was able to reproduce the problem in pure
XSB - no C involved. Consider the following interaction
with XSB:
consult('prelude.P').
assert(parentOf(a,b,[])).
findall(X/Y/L,familyOfP(X,Y,L),R), write(R).
(See below for the contents of prelude.P.)
This works fine (because it's done on the main thread):
it correctly reasons out that a is familyOfP b, b is familyOfP a,
etc. Now I *should* get the same result when I evaluate
this query on a spawned thread. But I don't. When I do:
consult('prelude.P').
assert(parentOf(a,b,[])).
thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),Id), thread_join(Id,ExitCode).
I get the following odd error:
| ?- thread_create((findall(X/Y/L,familyOfP(X,Y,L),R),write(R)),Id), thread_join(Id,ExitCode).
++Error[XSB/Runtime/P]: [Miscellaneous] [th 1] Floundering goal in tnot/1 familyOfP(_v185356496
X = _h171
Y = _h185
L = _h199
R = _h261
Id = 1
ExitCode = exception(error(misc_error,[th 1] Floundering goal
in tnot/1 familyOfP(_v185356496,[[Forward Continuation...,...
standard:call/1,... standard:call_c/1,... standard:call/1,...
standard:call/1],Backward Continuation...]))
This is especially perplexing given that there is no negation
anywhere, tabled or otherwise. How/where does floundering enter
the picture? I've actually run into a number of such "floundering"
errors recently while trying to do seemingly innocuous things on
spawned threads. (I've forwarded some such errors before to David,
though we were both stumped by the nature of the error message.)
Again, I've only seen such errors on spawned threads, never on
the main XSB thread. Clarification/feedback would be appreciated.
Thanks,
Konstantine
The contents of prelude.P are pasted below. Most of this stuff
is irrelevant to the problem, but I've spent the last 3 hours
throwing away the majority of the stuff from prelude.P. What's left
is, I think, pretty manageable and readable:
:- import append/3 from basics.
appendAll([],[]).
appendAll([H|T],L) :- appendAll(T,L1), append(H,L1,L).
append3(L1,L2,L3,L) :- append(L1,L2,R), append(L3,R,L).
append4(L1,L2,L3,L4,L) :- append3(L1,L2,L3,R), append(L4,R,L).
append5(L1,L2,L3,L4,L5,L) :- append4(L1,L2,L3,L4,R), append(L5,R,L).
/*****************************************************************************
Private tabled predicate declarations
******************************************************************************/
:- table afterP/3 as private.
:- table beforeP/3 as private.
:- table dateAfterP/3 as private.
:- table dateBeforeP/3 as private.
:- table intervalAfterP/3 as private.
:- table intervalBeforeP/3 as private.
:- table differentFromP/3 as private.
:- table knowsOfP/3 as private.
:- table relatedPersonOfP/3 as private.
:- table familyOfP/3 as private.
:- table auntOfP/3 as private.
:- table cousinOfP/3 as private.
:- table nephewOfP/3 as private.
:- table nieceOfP/3 as private.
:- table uncleOfP/3 as private.
:- table ancestorOfP/3 as private.
:- table grandParentOfP/3 as private.
:- table grandMotherOfP/3 as private.
:- table grandFatherOfP/3 as private.
:- table parentOfP/3 as private.
:- table fatherOfP/3 as private.
:- table motherOfP/3 as private.
:- table descendantOfP/3 as private.
:- table childOfP/3 as private.
:- table daughterOfP/3 as private.
:- table sonOfP/3 as private.
:- table grandChildOfP/3 as private.
:- table grandsonOfP/3 as private.
:- table granddaughterOfP/3 as private.
:- table inLawOfP/3 as private.
:- table brotherInLawOfP/3 as private.
:- table daughterInLawOfP/3 as private.
:- table fatherInLawOfP/3 as private.
:- table motherInLawOfP/3 as private.
:- table sisterInLawOfP/3 as private.
:- table sonInLawOfP/3 as private.
:- table siblingOfP/3 as private.
:- table brotherOfP/3 as private.
:- table sisterOfP/3 as private.
:- table spouseOfP/3 as private.
:- table husbandOfP/3 as private.
:- table wifeOfP/3 as private.
:- table unknownPersonRelationP/3 as private.
:- table endsInDateP/3 as private.
:- table startsInDateP/3 as private.
:- table expirationDateP/3 as private.
:- table hasLocationP/3 as private.
:- table ownedByP/3 as private.
:- table involvedP/3 as private.
:- table occursInP/3 as private.
:- table occursDuringP/3 as private.
:- table operationAreaP/3 as private.
:- table ownerOfP/3 as private.
:- table relatedEventP/3 as private.
:- table teacherP/3 as private.
:- table relationObjectP/3 as private.
:- table studentP/3 as private.
:- table ageP/3 as private.
:- table dateDayP/3 as private.
:- table dateMonthP/3 as private.
:- table dateYearP/3 as private.
:- table descriptionP/3 as private.
:- table dateP/1 as private.
:- table dateIntervalP/1 as private.
:- table eventP/1 as private.
:- table locationP/1 as private.
:- table cityP/1 as private.
:- table countryP/1 as private.
:- table regionP/1 as private.
:- table stateP/1 as private.
/*****************************************************************************
Dynamic predicate declarations
******************************************************************************/
:- dynamic after/3 as shared.
:- dynamic before/3 as shared.
:- dynamic dateAfter/3 as shared.
:- dynamic dateBefore/3 as shared.
:- dynamic intervalAfter/3 as shared.
:- dynamic intervalBefore/3 as shared.
:- dynamic differentFrom/3 as shared.
:- dynamic knowsOf/3 as shared.
:- dynamic relatedPersonOf/3 as shared.
:- dynamic familyOf/3 as shared.
:- dynamic auntOf/3 as shared.
:- dynamic cousinOf/3 as shared.
:- dynamic nephewOf/3 as shared.
:- dynamic nieceOf/3 as shared.
:- dynamic uncleOf/3 as shared.
:- dynamic ancestorOf/3 as shared.
:- dynamic grandParentOf/3 as shared.
:- dynamic grandMotherOf/3 as shared.
:- dynamic grandFatherOf/3 as shared.
:- dynamic parentOf/3 as shared.
:- dynamic fatherOf/3 as shared.
:- dynamic motherOf/3 as shared.
:- dynamic descendantOf/3 as shared.
:- dynamic childOf/3 as shared.
:- dynamic daughterOf/3 as shared.
:- dynamic sonOf/3 as shared.
:- dynamic grandChildOf/3 as shared.
:- dynamic grandsonOf/3 as shared.
:- dynamic granddaughterOf/3 as shared.
:- dynamic inLawOf/3 as shared.
:- dynamic brotherInLawOf/3 as shared.
:- dynamic daughterInLawOf/3 as shared.
:- dynamic fatherInLawOf/3 as shared.
:- dynamic motherInLawOf/3 as shared.
:- dynamic sisterInLawOf/3 as shared.
:- dynamic sonInLawOf/3 as shared.
:- dynamic siblingOf/3 as shared.
:- dynamic brotherOf/3 as shared.
:- dynamic sisterOf/3 as shared.
:- dynamic spouseOf/3 as shared.
:- dynamic husbandOf/3 as shared.
:- dynamic wifeOf/3 as shared.
:- dynamic unknownPersonRelation/3 as shared.
:- dynamic endsInDate/3 as shared.
:- dynamic startsInDate/3 as shared.
:- dynamic expirationDate/3 as shared.
:- dynamic hasLocation/3 as shared.
:- dynamic ownedBy/3 as shared.
:- dynamic involved/3 as shared.
:- dynamic occursIn/3 as shared.
:- dynamic occursDuring/3 as shared.
:- dynamic operationArea/3 as shared.
:- dynamic ownerOf/3 as shared.
:- dynamic relatedEvent/3 as shared.
:- dynamic teacher/3 as shared.
:- dynamic relationObject/3 as shared.
:- dynamic student/3 as shared.
:- dynamic age/3 as shared.
:- dynamic dateDay/3 as shared.
:- dynamic dateMonth/3 as shared.
:- dynamic dateYear/3 as shared.
:- dynamic description/3 as shared.
:- dynamic date/1 as shared.
:- dynamic dateInterval/1 as shared.
:- dynamic event/1 as shared.
:- dynamic location/1 as shared.
:- dynamic city/1 as shared.
:- dynamic country/1 as shared.
:- dynamic region/1 as shared.
:- dynamic state/1 as shared.
/****************************************************************/
/*****************************************************************************
Private predicate definitions
******************************************************************************/
afterP(X,Y,L) :- after(X,Y,L).
beforeP(X,Y,L) :- before(X,Y,L).
dateAfterP(X,Y,L) :- dateAfter(X,Y,L).
dateBeforeP(X,Y,L) :- dateBefore(X,Y,L).
intervalAfterP(X,Y,L) :- intervalAfter(X,Y,L).
intervalBeforeP(X,Y,L) :- intervalBefore(X,Y,L).
differentFromP(X,Y,L) :- differentFrom(X,Y,L).
knowsOfP(X,Y,L) :- knowsOf(X,Y,L).
relatedPersonOfP(X,Y,L) :- relatedPersonOf(X,Y,L).
familyOfP(X,Y,L) :- familyOf(X,Y,L).
auntOfP(X,Y,L) :- auntOf(X,Y,L).
cousinOfP(X,Y,L) :- cousinOf(X,Y,L).
nephewOfP(X,Y,L) :- nephewOf(X,Y,L).
nieceOfP(X,Y,L) :- nieceOf(X,Y,L).
uncleOfP(X,Y,L) :- uncleOf(X,Y,L).
ancestorOfP(X,Y,L) :- ancestorOf(X,Y,L).
grandParentOfP(X,Y,L) :- grandParentOf(X,Y,L).
grandMotherOfP(X,Y,L) :- grandMotherOf(X,Y,L).
grandFatherOfP(X,Y,L) :- grandFatherOf(X,Y,L).
parentOfP(X,Y,L) :- parentOf(X,Y,L).
fatherOfP(X,Y,L) :- fatherOf(X,Y,L).
motherOfP(X,Y,L) :- motherOf(X,Y,L).
descendantOfP(X,Y,L) :- descendantOf(X,Y,L).
childOfP(X,Y,L) :- childOf(X,Y,L).
daughterOfP(X,Y,L) :- daughterOf(X,Y,L).
sonOfP(X,Y,L) :- sonOf(X,Y,L).
grandChildOfP(X,Y,L) :- grandChildOf(X,Y,L).
grandsonOfP(X,Y,L) :- grandsonOf(X,Y,L).
granddaughterOfP(X,Y,L) :- granddaughterOf(X,Y,L).
inLawOfP(X,Y,L) :- inLawOf(X,Y,L).
brotherInLawOfP(X,Y,L) :- brotherInLawOf(X,Y,L).
daughterInLawOfP(X,Y,L) :- daughterInLawOf(X,Y,L).
fatherInLawOfP(X,Y,L) :- fatherInLawOf(X,Y,L).
motherInLawOfP(X,Y,L) :- motherInLawOf(X,Y,L).
sisterInLawOfP(X,Y,L) :- sisterInLawOf(X,Y,L).
sonInLawOfP(X,Y,L) :- sonInLawOf(X,Y,L).
siblingOfP(X,Y,L) :- siblingOf(X,Y,L).
brotherOfP(X,Y,L) :- brotherOf(X,Y,L).
sisterOfP(X,Y,L) :- sisterOf(X,Y,L).
spouseOfP(X,Y,L) :- spouseOf(X,Y,L).
husbandOfP(X,Y,L) :- husbandOf(X,Y,L).
wifeOfP(X,Y,L) :- wifeOf(X,Y,L).
unknownPersonRelationP(X,Y,L) :- unknownPersonRelation(X,Y,L).
endsInDateP(X,Y,L) :- endsInDate(X,Y,L).
startsInDateP(X,Y,L) :- startsInDate(X,Y,L).
expirationDateP(X,Y,L) :- expirationDate(X,Y,L).
hasLocationP(X,Y,L) :- hasLocation(X,Y,L).
ownedByP(X,Y,L) :- ownedBy(X,Y,L).
involvedP(X,Y,L) :- involved(X,Y,L).
occursInP(X,Y,L) :- occursIn(X,Y,L).
occursDuringP(X,Y,L) :- occursDuring(X,Y,L).
operationAreaP(X,Y,L) :- operationArea(X,Y,L).
ownerOfP(X,Y,L) :- ownerOf(X,Y,L).
relatedEventP(X,Y,L) :- relatedEvent(X,Y,L).
teacherP(X,Y,L) :- teacher(X,Y,L).
relationObjectP(X,Y,L) :- relationObject(X,Y,L).
studentP(X,Y,L) :- student(X,Y,L).
ageP(X,Y,L) :- age(X,Y,L).
dateDayP(X,Y,L) :- dateDay(X,Y,L).
dateMonthP(X,Y,L) :- dateMonth(X,Y,L).
dateYearP(X,Y,L) :- dateYear(X,Y,L).
descriptionP(X,Y,L) :- description(X,Y,L).
dateP(X) :- date(X).
dateIntervalP(X) :- dateInterval(X).
eventP(X) :- event(X).
locationP(X) :- location(X).
cityP(X) :- city(X).
countryP(X) :- country(X).
regionP(X) :- region(X).
stateP(X) :- state(X).
schoolP(X) :- school(X).
personP(X) :- person(X).
relationP(X) :- relation(X).
directRelationP(X) :- directRelation(X).
acquaintanceP(X) :- acquaintance(X).
cohabitationP(X) :- cohabitation(X).
colleagueshipP(X) :- colleagueship(X).
enmityP(X) :- enmity(X).
friendshipP(X) :- friendship(X).
neighborhoodP(X) :- neighborhood(X).
teachingP(X) :- teaching(X).
indirectRelationP(X) :- indirectRelation(X).
/*****************************************************************************
Subproperty rules
******************************************************************************/
relationObjectP(X,Y,L) :- studentP(X,Y,L).
relationSubjectP(X,Y,L) :- teacherP(X,Y,L).
differentFromP(X,Y,L) :- knowsOfP(X,Y,L).
knowsOfP(X,Y,L) :- relatedPersonOfP(X,Y,L).
relatedPersonOfP(X,Y,L) :- unknownPersonRelationP(X,Y,L).
relatedPersonOfP(X,Y,L) :- familyOfP(X,Y,L).
familyOfP(X,Y,L) :- spouseOfP(X,Y,L).
spouseOfP(X,Y,L) :- wifeOfP(X,Y,L).
spouseOfP(X,Y,L) :- husbandOfP(X,Y,L).
familyOfP(X,Y,L) :- siblingOfP(X,Y,L).
siblingOfP(X,Y,L) :- sisterOfP(X,Y,L).
siblingOfP(X,Y,L) :- brotherOfP(X,Y,L).
familyOfP(X,Y,L) :- inLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- sonInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- sisterInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- motherInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- fatherInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- daughterInLawOfP(X,Y,L).
inLawOfP(X,Y,L) :- brotherInLawOfP(X,Y,L).
familyOfP(X,Y,L) :- descendantOfP(X,Y,L).
descendantOfP(X,Y,L) :- grandChildOfP(X,Y,L).
grandChildOfP(X,Y,L) :- granddaughterOfP(X,Y,L).
grandChildOfP(X,Y,L) :- grandsonOfP(X,Y,L).
descendantOfP(X,Y,L) :- childOfP(X,Y,L).
childOfP(X,Y,L) :- sonOfP(X,Y,L).
childOfP(X,Y,L) :- daughterOfP(X,Y,L).
familyOfP(X,Y,L) :- ancestorOfP(X,Y,L).
ancestorOfP(X,Y,L) :- parentOfP(X,Y,L).
parentOfP(X,Y,L) :- motherOfP(X,Y,L).
parentOfP(X,Y,L) :- fatherOfP(X,Y,L).
ancestorOfP(X,Y,L) :- grandParentOfP(X,Y,L).
grandParentOfP(X,Y,L) :- grandFatherOfP(X,Y,L).
grandParentOfP(X,Y,L) :- grandMotherOfP(X,Y,L).
familyOfP(X,Y,L) :- uncleOfP(X,Y,L).
familyOfP(X,Y,L) :- nieceOfP(X,Y,L).
familyOfP(X,Y,L) :- nephewOfP(X,Y,L).
familyOfP(X,Y,L) :- cousinOfP(X,Y,L).
familyOfP(X,Y,L) :- auntOfP(X,Y,L).
/*****************************************************************************
Symmetry rules
******************************************************************************/
relatedPersonOfP(X,Y,L) :- relatedPersonOfP(Y,X,L).
intervalOverlapP(X,Y,L) :- intervalOverlapP(Y,X,L).
familyOfP(X,Y,L) :- familyOfP(Y,X,L).
cousinOfP(X,Y,L) :- cousinOfP(Y,X,L).
siblingOfP(X,Y,L) :- siblingOfP(Y,X,L).
spouseOfP(X,Y,L) :- spouseOfP(Y,X,L).
/*****************************************************************************
Transitivity rules
******************************************************************************/
beforeP(X,Y,L) :- beforeP(X,Z,L1), beforeP(Z,Y,L2), append(L1,L2,L).
afterP(X,Y,L) :- afterP(X,Z,L1), afterP(Z,Y,L2), append(L1,L2,L).
dateAfterP(X,Y,L) :- dateAfterP(X,Z,L1), dateAfterP(Z,Y,L2), append(L1,L2,L).
dateBeforeP(X,Y,L) :- dateBeforeP(X,Z,L1), dateBeforeP(Z,Y,L2), append(L1,L2,L).
intervalAfterP(X,Y,L) :- intervalAfterP(X,Z,L1), intervalAfterP(Z,Y,L2), append(L1,L2,L).
intervalBeforeP(X,Y,L) :- intervalBeforeP(X,Z,L1), intervalBeforeP(Z,Y,L2), append(L1,L2,L).
relatedPersonOfP(X,Y,L) :- relatedPersonOfP(X,Z,L1), relatedPersonOfP(Z,Y,L2), append(L1,L2,L).
familyOfP(X,Y,L) :- familyOfP(X,Z,L1), familyOfP(Z,Y,L2), append(L1,L2,L).
ancestorOfP(X,Y,L) :- ancestorOfP(X,Z,L1), ancestorOfP(Z,Y,L2), append(L1,L2,L).
cousinOfP(X,Y,L) :- cousinOfP(X,Z,L1), cousinOfP(Z,Y,L2), append(L1,L2,L).
descendantOfP(X,Y,L) :- descendantOfP(X,Z,L1), descendantOfP(Z,Y,L2), append(L1,L2,L).
siblingOfP(X,Y,L) :- siblingOfP(X,Z,L1), siblingOfP(Z,Y,L2), append(L1,L2,L).
hasLocationP(X,Y,L) :- hasLocationP(X,Z,L1), hasLocationP(Z,Y,L2), append(L1,L2,L).
/*****************************************************************************
Inverse rules
******************************************************************************/
beforeP(X,Y,L) :- afterP(Y,X,L).
afterP(X,Y,L) :- beforeP(Y,X,L).
dateBeforeP(X,Y,L) :- dateAfterP(Y,X,L).
dateAfterP(X,Y,L) :- dateBeforeP(Y,X,L).
intervalBeforeP(X,Y,L) :- intervalAfterP(Y,X,L).
intervalAfterP(X,Y,L) :- intervalBeforeP(Y,X,L).
ancestorOfP(X,Y,L) :- descendantOfP(Y,X,L).
descendantOfP(X,Y,L) :- ancestorOfP(Y,X,L).
childOfP(X,Y,L) :- parentOfP(Y,X,L).
parentOfP(X,Y,L) :- childOfP(Y,X,L).
grandChildOfP(X,Y,L) :- grandParentOfP(Y,X,L).
grandParentOfP(X,Y,L) :- grandChildOfP(Y,X,L).
ownedByP(X,Y,L) :- ownerOfP(Y,X,L).
ownerOfP(X,Y,L) :- ownedByP(Y,X,L).
/*****************************************************************************
Property-Chain rules
******************************************************************************/
uncleOfP(X1,X3,L) :- brotherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
uncleOfP(X1,X4,L) :- husbandOfP(X1,X2,L1), sisterOfP(X2,X3,L2), parentOfP(X3,X4,L3), append3(L1,L2,L3,L).
parentOfP(X1,X3,L) :- parentOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
nieceOfP(X1,X3,L) :- daughterOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
nephewOfP(X1,X3,L) :- sonOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
sonInLawOfP(X1,X3,L) :- husbandOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
sisterInLawOfP(X1,X3,L) :- sisterOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
sisterInLawOfP(X1,X3,L) :- wifeOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
motherInLawOfP(X1,X3,L) :- motherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
fatherInLawOfP(X1,X3,L) :- fatherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
daughterInLawOfP(X1,X3,L) :- wifeOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
brotherInLawOfP(X1,X3,L) :- brotherOfP(X1,X2,L1), spouseOfP(X2,X3,L2), append(L1,L2,L).
brotherInLawOfP(X1,X3,L) :- husbandOfP(X1,X2,L1), siblingOfP(X2,X3,L2), append(L1,L2,L).
grandMotherOfP(X1,X3,L) :- motherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
grandFatherOfP(X1,X3,L) :- fatherOfP(X1,X2,L1), parentOfP(X2,X3,L2), append(L1,L2,L).
grandsonOfP(X1,X3,L) :- sonOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
granddaughterOfP(X1,X3,L) :- daughterOfP(X1,X2,L1), childOfP(X2,X3,L2), append(L1,L2,L).
On Aug 21, 2012, at 12:34 PM, David Warren <wa...@cs...> wrote:
> abolish_all_private_tables/0 is defined in thread.P, so I guess you need to import it from there.
> The manual should say what module a predicate is defined in, and if it doesn't say it's a standard predicate, then it must be imported
>
> -David
>
> -----Original Message-----
> From: K. A. [mailto:k_a...@ya...]
> Sent: Tuesday, August 21, 2012 10:47 AM
> To: Xsb...@li...; David Warren; Terrance Swift
> Subject: RE: Bug in multi-threaded XSB?
>
> That's good to hear. After checking with the manual I thought that I would want to call abolish_all_private_tables/0 on a thread poised to answer a query. (This is described on p. 237 of vol. I.) However, when I try that I get:
>
> "Error: [XSB/Runtime/P]: [Existence (No procedure usermod:
> abolish_all_private_tables/0 exists)] []"
>
> The command-line version doesn't seem to recognize this predicate either. Do I need to import it first from somewhere?
> If that doesn't work, what other alternatives are there for destroying private tables?
>
> Thanks,
>
> K.
>
> --- On Tue, 8/21/12, Terrance Swift <ts...@cs...> wrote:
>
>> From: Terrance Swift <ts...@cs...>
>> Subject: RE: Bug in multi-threaded XSB?
>> To: "K. A." <k_a...@ya...>,
>> "Xsb...@li..."
>> <Xsb...@li...>, "David Warren"
>> <wa...@cs...>
>> Date: Tuesday, August 21, 2012, 8:02 AM Absolutely -- private tables
>> are handled just as tables in the single threaded engine, so you can
>> abolish them whenever it makes sense in the single threaded engine.
>> Heap gc for threads works just as in the single-threaded engine, and
>> private dynamic code also works as in the st-engine.
>>
>> Terry
>>
>> ________________________________________
>> From: K. A. [k_a...@ya...]
>> Sent: Monday, August 20, 2012 10:08 PM
>> To: Xsb...@li...;
>> David Warren; Terrance Swift
>> Subject: RE: Bug in multi-threaded XSB?
>>
>> Hi Terry,
>>
>> Thanks for the suggestion. One question: Can a private thread table be
>> explicitly abolished on that thread while other threads are running?
>> If so, then your suggestion could work with the unkillable threads
>> created by xsb_ccall_thread_create - I can maintain a queue of 20 or
>> so such threads and reuse them to answer queries, since I can't kill
>> them.
>> (This would obviously be unworkable in general, but in this case it's
>> unlikely that I'll have more than 20 concurrent queries at any given
>> time, so it might be viable.) But this presupposes that I can abolish
>> their private tables while other threads are running. If not, then I'd
>> have to continually spawn new threads to answer new queries, and if
>> these threads never quit then I'll be out of memory before too long.
>>
>> Thanks,
>>
>> Konstantine
>>
>> --- On Mon, 8/20/12, Terrance Swift <ts...@cs...>
>> wrote:
>>
>>> From: Terrance Swift <ts...@cs...>
>>> Subject: RE: Bug in multi-threaded XSB?
>>> To: "K. A." <k_a...@ya...>,
>> "Xsb...@li..."
>> <Xsb...@li...>,
>> "David Warren" <wa...@cs...>
>>> Date: Monday, August 20, 2012, 9:34 AM Here is the simple attached
>>> file.
>>>
>>> A couple of people have written large applications
>> with
>>> MT-XSB but they probably did not use all the features
>> you
>>> are trying to use, and MT-XSB is certainly less stable
>> than
>>> single-threaded XSB. I wish I had sufficient time
>> to
>>> help every user, but looking very briefly at your code,
>> its
>>> impossible to understand.
>>>
>>> 1) Why you can't remove the C/XSB interface, at least
>> for
>>> debugging
>>> 2) Why you can't use thread exiting, at least for
>> debugging
>>> (actually its not an issue from the prolog level,
>> threads
>>> exit once they have been joined.)
>>> 3) How many of the problems in XSB and how many are
>>> multi-programming errors of yours. No offense, everybody makes
>>> MT-programming errors.
>>>
>>> I hope you'll take seriously the suggestions I gave you
>> to
>>> start breaking down the program to help isolate the bugs. I'll try
>>> to fix the bugs I can once they
>> become
>>> clear to me.
>>>
>>> Terry
>>> ________________________________________
>>> From: K. A. [k_a...@ya...]
>>> Sent: Sunday, August 19, 2012 7:06 PM
>>> To: Xsb...@li...;
>>> David Warren; Terrance Swift
>>> Subject: RE: Bug in multi-threaded XSB?
>>>
>>> Hi Terry,
>>>
>>> Thanks for the reply.
>>>
>>>> You're absolutely right that sharing tables can (and most probably
>>>> would) lead to problems with concurrently executing threads.
>>>
>>>>> In principle, it shouldn't. In local
>>> evaluation, there is a
>>>>> mechanism to share concurrently evaluated
>> shared
>>> tables which
>>>>> I think is described in the manual, and is
>> described
>>> in gory
>>>>> detail in Marques and Swift, 2008 ICLP.
>>>
>>> It shouldn't, as long as there are no insertions while concurrent
>>> queries are being answered. But if there are such insertions (as is
>>> almost always the case in question-answering systems), then these
>>> will not occur with abolished tables but
>> rather
>>> with whatever tables happen to be in effect at
>> insertion
>>> time,
>>> which will in turn depend on the state of the various active queries
>>> at the time. This will most likely invalidate
>> the
>>> insertions
>>> and lead to wrong results. It seems to me that what
>> one
>>> really
>>> needs is the ability to spawn a query at time t with a
>>> *fresh* (empty)
>>> set of tables and with whatever data happens to be in
>> the
>>> database at t. I don't know if, with private predicates/tables,
>>> there is a way to forcibly copy the contents of one thread's
>>> predicates/tables into another. If so, then this could
>> be
>>> readily implemented in XSB as things stand. But if
>> not,
>>> then
>>> I don't see how XSB's tabling can be used to implement
>> a
>>> system that does concurrent updates/queries.
>>>
>>>>> However if you are using MT XSB, I strongly
>>> recommend first
>>>>> testing out the programming idioms you use from
>> the
>>> command-line
>>>>> shell, then putting things into the C-XSB
>>> interface. XSB's
>>>>> MT C-Prolog interface is quite ambitious, but
>> as a
>>> result it
>>>>> may have some undiagnosed bugs. Just as
>>> importantly, XSB-only
>>>>> code will be far, far easier to debug.
>>>
>>> I'm sure that's the case, but I would think that the
>> point
>>> of having a C<-->XSB interface is to facilitate
>> things
>>> that,
>>> for some reason or other, cannot be easily done
>> exclusively
>>> in XSB. If I could program the whole thing in XSB by itself, I
>>> could, but I can't. Moreover, it may well be that
>> some
>>> bugs
>>> are peculiar to the C<-->XSB interface and are
>> not
>>> reproducible
>>> when the code is expressed purely in XSB. What happens
>> to
>>> them?
>>>
>>>> So I tried declaring
>>>> tables to be private, *but* it seems you cannot
>> have
>>>> shared dynamic predicates with private tables. The predicates
>>>> themselves (the facts in the database)
>> have
>>>> to be "dynamic as shared", because otherwise a new
>>> thread
>>>> spawned to answer a query would not have any
>> usable
>>> facts
>>>> to work with. But again, the combination "table p/2
>> as
>>> private"
>>>> with "dynamic p/2 as shared" does not seem to be
>> allowed
>>> by XSB
>>>> (perhaps someone can set me straight if I'm
>> missing
>>> something).
>>>
>>>>> I haven't looked at your code, but in principle
>> you
>>> can do this.
>>>>> See the attached file, though I'm sure that
>> your
>>> program is much
>>>>> more complex than the attached file.
>>>
>>> I didn't see an attached file - could you please
>> resend?
>>> I'd be very interested to see how this could be done.
>>>
>>>> At any rate, we're still left with the more narrow
>>> question
>>>> of why in the world the query threads in this
>>> particular
>>>> example are not exiting when they are explicitly
>>> killed.
>>>
>>>>> XSB threads should exit when they are killed,
>>> although there are cases ?>>where this doesn't happen. For instance
>>> if the thread is waiting on
>> I/O,
>>>>> or waiting on a mutex, etc. the waiting thread
>> needs
>>> to be signaled, to >>wake up, quit doing whatever
>> it
>>> is
>>>>> doing, and exit. XSB has a lot of OS
>>> interfaces, and I haven't yet >>handled this in
>> every
>>> single case. In addition, when a thread is
>> killed
>>>>> it must clean up after itself, and free what
>> ever
>>> mutexes, db_cursors, >>etc. that it has (but may
>> not
>>> be currently working
>>>>> on). While XSB can and does do this for
>> some
>>> resources, it doesn't >>always have full
>> knowledge of
>>> all of the resources a thread has taken.
>>>> So
>>> getting thread cancellation to work in any system is awkward, and
>>>>> requires a lot from both the
>> system and
>>> the user.
>>>>> In pretty much any MT system, its better to
>> have the
>>> thread itself exit, >>and save thread
>> cancellation for
>>> special cases.
>>>
>>> Well, these are all special cases unfortunately -
>> these
>>> threads
>>> *never* exit by themselves because for some reason
>> which I
>>> don't
>>> quite understand, they go into a read-eval loop
>> *after*
>>> they
>>> are finished evaluating the goal that they were
>> intended
>>> to answer. As far as I can see there is no mechanism
>> in
>>> the C<-->XSB interface to create a thread to do
>> a
>>> specific
>>> job and then quit. The only way to do that would be to execute
>>> embedded XSB code using thread_create, but
>> then
>>> keeping track of the thread id and getting the thread to communicate
>>> properly becomes very difficult
>> because,
>>> again, we are not in XSB proper but in the embedded
>> C/XSB
>>> world. So xsb_ccall_thread_create seems to be the only viable
>>> option, but again, these threads don't quit by
>> themselves,
>>> so killing them is the only option (and an absolute
>> must,
>>> because it seems that when multiple threads are
>> active,
>>> tables cannot be abolished, resources cannot be
>> reclaimed,
>>> etc.).
>>>
>>>> So if you can show me how your program works from
>> the
>>> command-line >interface, I'll help debug at that level. Once we are
>>> sure the program is >doing
>> what
>>> you want at that level, we can see how to add the
>> C-XSB
>>>> interface.
>>>
>>> Like I said earlier, this seems to assume that the bug will be
>>> reproducible in pure XSB, and I'm not at all sure about that. The C
>>> code sample is very small so I hope someone will be able to take a
>>> look at it and reach a (tentative, at least) verdict. In the
>> meanwhile
>>> I'll try to take the client/server I've written in C
>> and
>>> re-express it in pure XSB using the samples given in
>> the
>>> /examples/sockets directory of the distribution. Is
>> there
>>> anyone in particular in this list to whom I should
>> direct
>>> questions pertaining to that client/server code?
>>>
>>> Many thanks,
>>>
>>> Konstantine
>>>
>>>
>>> --- On Sat, 8/18/12, David Warren <wa...@cs...>
>>> wrote:
>>>
>>>
>>>
>>>> From: David Warren <wa...@cs...>
>>>
>>>> Subject: RE: Bug in multi-threaded XSB?
>>>
>>>> To: "K. A." <k_a...@ya...>,
>>> "Xsb...@li..."
>>> <Xsb...@li...>
>>>
>>>> Cc: "Terrance Swift" <ts...@cs...>
>>>
>>>> Date: Saturday, August 18, 2012, 12:17 PM
>>>
>>>> I strongly suspect it is because you
>>>
>>>> are sharing the tables and that other thread is
>> not
>>> exiting
>>>
>>>> (or at least XSB doesn't know it has exited.)
>>>
>>>> I would suggest that you don't use shared tables
>> but
>>> private
>>>
>>>> tables. If they are not causing this problem now,
>> they
>>>
>>>> certainly will if you run a multithreaded query
>>> service
>>>
>>>> where you have a number of queries and some can
>> update
>>> the
>>>
>>>> underlying data.
>>>
>>>> -David
>>>
>>>>
>>>
>>>> -----Original Message-----
>>>
>>>> From: K. A. [mailto:k_a...@ya...]
>>>
>>>>
>>>
>>>> Sent: Friday, August 17, 2012 5:24 PM
>>>
>>>> To: Xsb...@li...
>>>
>>>> Cc: David Warren; Terrance Swift
>>>
>>>> Subject: Bug in multi-threaded XSB?
>>>
>>>>
>>>
>>>> Could someone please explain to me why the
>> following C
>>> code
>>>
>>>> fails to find any answers to the last query in
>> the
>>> main
>>>
>>>> function - the parentOf(X,Y,L) query?
>>>
>>>>
>>>
>>>> Note that every insertion does an
>> abolish_all_tables
>>> first,
>>>
>>>> and that right before each insertion or query in
>> main,
>>> there
>>>
>>>> should be (as far as I can see) only one XSB
>> thread
>>> active -
>>>
>>>> the main one.
>>>
>>>>
>>>
>>>> I assume this is a bug in multi-threaded XSB
>> unless
>>> someone
>>>
>>>> can provide an alternative explanation.
>>>
>>>>
>>>
>>>> If you put the C code below in a file test.c, you
>> can
>>> make
>>>
>>>> the program as follows:
>>>
>>>>
>>>
>>>> gcc -c -I/home/.../XSB/emu
>>>
>>>> -I/home/.../XSB/config/x86_64-unknown-linux-gnu-mt
>> -O3
>>>
>>>> -fno-strict-aliasing -Wall -pipe -D_GNU_SOURCE
>> test.c
>>>
>>>>
>>>
>>>> gcc -o test.out -lm -ldl -Wl -export-dynamic
>> -lpthread
>>>
>>>>
>>>
>> /home/.../XSB/config/x86_64-unknown-linux-gnu-mt/saved.o/xsb.o
>>>
>>>> test.o
>>>
>>>>
>>>
>>>> #include <stdio.h>
>>>
>>>> #include <unistd.h>
>>>
>>>> #include <stdlib.h>
>>>
>>>> #include <string.h>
>>>
>>>> #include <sys/types.h>
>>>
>>>> #include <pthread.h>
>>>
>>>> #include <ctype.h>
>>>
>>>> #include "cinterf.h"
>>>
>>>> #include "varstring_xsb.h"
>>>
>>>> #include "context.h"
>>>
>>>>
>>>
>>>> void doInsert(char* insertion_command,th_context*
>> th){
>>> int
>>>
>>>> res = xsb_command_string(th,
>> "abolish_all_tables.");
>>> res =
>>>
>>>> xsb_command_string(th, insertion_command);}
>>>
>>>>
>>>
>>>> void doCommand(char* cmd,th_context* th){ int res
>> =
>>>
>>>> xsb_command_string(th, cmd);}
>>>
>>>>
>>>
>>>> struct QueryArgs {
>>>
>>>> char* query;
>>>
>>>> th_context* th;};
>>>
>>>>
>>>
>>>> void* doQuery(void* args) {
>>>
>>>> struct QueryArgs * pt = (struct QueryArgs *)
>> args;
>>>
>>>> char* query = (*pt).query;
>>>
>>>> th_context* th = (*pt).th;
>>>
>>>> XSB_StrDefine(retstr);
>>>
>>>> th_context* new_query_thread;
>>>
>>>>
>> xsb_ccall_thread_create(th,&new_query_thread);
>>>
>>>> int rc =
>>>
>>>>
>>>
>> xsb_query_string_string(new_query_thread,query,&retstr,"|");
>>>
>>>> int answer_count = 0;
>>>
>>>> while ((rc == XSB_SUCCESS) &&
>>> (++answer_count))
>>>
>>>> {
>>>
>>>> printf("\nAnswer: %s\n",retstr.string);
>>>
>>>> rc = xsb_next_string(new_query_thread,
>>>
>>>> &retstr,"|");
>>>
>>>> }
>>>
>>>> printf("\n%d answers for this query:
>>>
>>>> %s\n",answer_count,query);
>>>
>>>> xsb_kill_thread(new_query_thread);
>>>
>>>> return NULL;}
>>>
>>>>
>>>
>>>> void answerQuery(char* query,th_context* th){
>>>
>>>> void* exit_status;
>>>
>>>> pthread_t new_thread;
>>>
>>>> struct QueryArgs args = {.query = query, .th =
>> th};
>>>
>>>>
>> pthread_create(&new_thread,NULL,doQuery,(void*)
>>>
>>>> &args);
>>>
>>>> pthread_join(new_thread,&exit_status);
>>>
>>>> }
>>>
>>>>
>>>
>>>> int main() {
>>>
>>>> char init_string[MAXPATHLEN];
>>>
>>>> char* xsbHome = getenv("XSB_HOME");
>>>
>>>> strcpy(init_string, xsbHome);
>>>
>>>> xsb_init_string(init_string);
>>>
>>>> th_context *main_th = xsb_get_main_thread();
>>>
>>>>
>>>
>>>>
>>>
>> doCommand("consult('prelude.P').",xsb_get_main_thread());
>>>
>>>>
>>>
>> doCommand("load_dyn('main.P').",xsb_get_main_thread());
>>>
>>>>
>>>
>>>>
>>>
>> doInsert("assert(auntOf(woman9,foo,[])).",xsb_get_main_thread());
>>>
>>>>
>> answerQuery("familyOf(X,Y,L).",xsb_get_main_thread());
>>>
>>>>
>>>
>>>>
>>>
>> doInsert("assertAll([parentOf(man2,man3,[1/555]),parentOf(man1,man2,[7
>> /982,1/34])]).",xsb_get_main_thread());
>>>
>>>>
>> answerQuery("parentOf(X,Y,L).",xsb_get_main_thread());
>>>
>>>> xsb_close(xsb_get_main_thread());
>>>
>>>> return 0;}
>>>
>>>>
>>>
>>>> The contents of the other 2 files are as follows:
>>>
>>>>
>>>
>>>> /************* Contents of prelude.P :
>>> ***************/
>>>
>>>> assertAll([]).
>>>
>>>> assertAll([H|T]) :- asserta(H),assertAll(T).
>>>
>>>>
>>>
>>>> /************* Contents of main.P :
>> ***************/
>>>
>>>> :- import append/3 from basics.
>>>
>>>> :- table motherOf/3 as shared.
>>>
>>>> :- table fatherOf/3 as shared.
>>>
>>>> :- table parentOf/3 as shared.
>>>
>>>> :- table ancestorOf/3 as shared.
>>>
>>>> :- table auntOf/3 as shared.
>>>
>>>> :- table familyOf/3 as shared.
>>>
>>>> :- dynamic motherOf/3 as shared.
>>>
>>>> :- dynamic fatherOf/3 as shared.
>>>
>>>> :- dynamic parentOf/3 as shared.
>>>
>>>> :- dynamic ancestorOf/3 as shared.
>>>
>>>> :- dynamic auntOf/3 as shared.
>>>
>>>> :- dynamic familyOf/3 as shared.
>>>
>>>>
>>>
>>>> familyOf(X,Y,L) :- ancestorOf(X,Y,L).
>>>
>>>> ancestorOf(X,Y,L) :- parentOf(X,Y,L).
>>>
>>>> parentOf(X,Y,L) :- motherOf(X,Y,L).
>>>
>>>> parentOf(X,Y,L) :- fatherOf(X,Y,L).
>>>
>>>> familyOf(X,Y,L) :- auntOf(X,Y,L).
>>>
>>>> familyOf(X,Y,L) :- familyOf(Y,X,L).
>>>
>>>> ancestorOf(X,Y,L) :- ancestorOf(X,Z,L1),
>>> ancestorOf(Z,Y,L2),
>>>
>>>> append(L1,L2,L).
>>>
>>>>
>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
|