misc_bugs_when_compiling_problog
This commit is contained in:
		
							
								
								
									
										1
									
								
								C/text.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								C/text.c
									
									
									
									
									
								
							@@ -814,7 +814,6 @@ write_buffer( void *s0, seq_tv_t *out, encoding_t enc, int minimal, size_t leng
 | 
			
		||||
	if (out->type & (YAP_STRING_WITH_BUFFER|YAP_STRING_MALLOC) ) {
 | 
			
		||||
	 char *s = s0;
 | 
			
		||||
	 size_t n = strlen( s )+1;
 | 
			
		||||
	 memcpy( out->val.c, s0, n*sizeof(wchar_t));
 | 
			
		||||
   	 out->val.c[n] = '\0';
 | 
			
		||||
	 sz_end = n+1;
 | 
			
		||||
	} else {
 | 
			
		||||
 
 | 
			
		||||
@@ -72,11 +72,11 @@ if (MPI_C_FOUND)
 | 
			
		||||
 | 
			
		||||
  add_library (yap_mpi SHARED ${MPI_SOURCES})
 | 
			
		||||
 | 
			
		||||
  target_link_libraries(yap_mpi libYap ${MPI_LIBRARIES})
 | 
			
		||||
  target_link_libraries(yap_mpi libYap ${MPI_C_LIBRARIES})
 | 
			
		||||
 | 
			
		||||
  set_target_properties (yap_mpi PROPERTIES PREFIX "")
 | 
			
		||||
 | 
			
		||||
  include_directories (${MPI_INCLUDE_DIRS})
 | 
			
		||||
  include_directories (${MPI_C_INCLUDE_PATH})
 | 
			
		||||
 | 
			
		||||
  add_definitions (-DHAVE_MPI_H=1)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -558,21 +558,6 @@ file_property(File, Type, Size, Date, Permissions, LinkName) :-
 | 
			
		||||
	handle_system_internal(Error, off, file_property(File)).
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
file_exists(File, Permissions) :-
 | 
			
		||||
	var(File), !,
 | 
			
		||||
	throw(error(instantiation_error,file_exists(File, Permissions))).
 | 
			
		||||
file_exists(File, Permissions) :-
 | 
			
		||||
	\+ atom(File), !,
 | 
			
		||||
	throw(error(type_error(atom,File),file_exists(File, Permissions))).
 | 
			
		||||
file_exists(IFile, Permissions) :-
 | 
			
		||||
	true_file_name(IFile, File),
 | 
			
		||||
	file_property(File, _Type, _Size, _Date, FPermissions, _, Error),
 | 
			
		||||
	var(Error),
 | 
			
		||||
	process_permissions(Permissions, Perms),
 | 
			
		||||
	FPermissions /\ Perms =:= Perms.
 | 
			
		||||
 | 
			
		||||
process_permissions(Number, Number) :- integer(Number).
 | 
			
		||||
 | 
			
		||||
%
 | 
			
		||||
% environment manipulation.
 | 
			
		||||
%
 | 
			
		||||
 
 | 
			
		||||
@@ -113,7 +113,7 @@ Int Yap_peek(int sno) {
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  /* buffer the character */
 | 
			
		||||
  if (s->encoding == LOCAL_encoding) {
 | 
			
		||||
  if (s->encoding == Yap_SystemEncoding() && 0) {
 | 
			
		||||
    ch = fgetwc(s->file);
 | 
			
		||||
    ungetwc(ch, s->file);
 | 
			
		||||
    return ch;
 | 
			
		||||
@@ -122,7 +122,7 @@ Int Yap_peek(int sno) {
 | 
			
		||||
    olinecount = s->linecount;
 | 
			
		||||
    olinepos = s->linepos;
 | 
			
		||||
    ch = s->stream_wgetc(sno);
 | 
			
		||||
    if (ch == EOFCHAR) {
 | 
			
		||||
  if (ch == EOFCHAR) {
 | 
			
		||||
      s->stream_getc = EOFPeek;
 | 
			
		||||
      s->stream_wgetc = EOFWPeek;
 | 
			
		||||
      s->status |= Push_Eof_Stream_f;
 | 
			
		||||
@@ -136,7 +136,7 @@ Int Yap_peek(int sno) {
 | 
			
		||||
    unsigned char cs[8];
 | 
			
		||||
    size_t n = put_utf8(cs, ch);
 | 
			
		||||
    while (n--) {
 | 
			
		||||
      ungetc(cs[n - 1], s->file);
 | 
			
		||||
      ungetc(cs[n], s->file);
 | 
			
		||||
    }
 | 
			
		||||
  } else if (s->encoding == ENC_UTF16_BE) {
 | 
			
		||||
    /* do the ungetc as if a write .. */
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,9 @@ static char SccsId[] = "%W% %G%";
 | 
			
		||||
#if HAVE_WCTYPE_H
 | 
			
		||||
#include <wctype.h>
 | 
			
		||||
#endif
 | 
			
		||||
#if HAVE_LOCALE_H
 | 
			
		||||
#include <locale.h>
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#if HAVE_IO_H
 | 
			
		||||
/* Windows */
 | 
			
		||||
@@ -135,29 +138,40 @@ static encoding_t enc_os_default( encoding_t rc)\
 | 
			
		||||
  return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static encoding_t DefaultEncoding(void) {
 | 
			
		||||
  int i = 0;
 | 
			
		||||
  while (encvs[i]) {
 | 
			
		||||
      char *v = getenv(encvs[i]);
 | 
			
		||||
encoding_t Yap_SystemEncoding(void) {
 | 
			
		||||
  int i = -1;
 | 
			
		||||
  while (i == -1 || encvs[i]) {
 | 
			
		||||
    char *v;
 | 
			
		||||
    if ( i == -1 ) {
 | 
			
		||||
      if ((v = setlocale(LC_CTYPE, NULL)) == NULL ||
 | 
			
		||||
	  !strcmp(v,"C")) {
 | 
			
		||||
	if ((v = getenv("LC_CTYPE")))
 | 
			
		||||
	  setlocale(LC_CTYPE, v);
 | 
			
		||||
	else if ((v = getenv("LANG")))
 | 
			
		||||
	  setlocale(LC_CTYPE, v);
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
	v = getenv(encvs[i]);
 | 
			
		||||
    }
 | 
			
		||||
      if (v) {
 | 
			
		||||
          int j = 0;
 | 
			
		||||
          size_t sz = strlen(v);
 | 
			
		||||
          const char *coding;
 | 
			
		||||
          while ((coding = ematches[j].s) != NULL) {
 | 
			
		||||
              size_t sz2 = strlen(coding);
 | 
			
		||||
              if (sz2 > sz) {
 | 
			
		||||
                  j++;
 | 
			
		||||
                  continue;
 | 
			
		||||
                }
 | 
			
		||||
              if (!strcmp(coding+(sz-sz2), v) ) {
 | 
			
		||||
                  return enc_os_default(ematches[j].e);
 | 
			
		||||
	    char *v1;
 | 
			
		||||
	    if ((v1 = strstr(v, coding)) &&
 | 
			
		||||
		strlen(v1) == strlen(coding)) {
 | 
			
		||||
                  return ematches[j].e;
 | 
			
		||||
                }
 | 
			
		||||
              j++;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
      i++;
 | 
			
		||||
    }
 | 
			
		||||
  return enc_os_default(ENC_ISO_ASCII);
 | 
			
		||||
  return ENC_ISO_ASCII;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static encoding_t DefaultEncoding(void) {
 | 
			
		||||
  return enc_os_default(Yap_SystemEncoding());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
encoding_t Yap_DefaultEncoding(void) {
 | 
			
		||||
 
 | 
			
		||||
@@ -43,6 +43,7 @@ typedef enum {
 | 
			
		||||
 | 
			
		||||
/// read the current environment, as set by the user or as Initial
 | 
			
		||||
encoding_t Yap_DefaultEncoding(void);
 | 
			
		||||
encoding_t Yap_SystemEncoding(void);
 | 
			
		||||
void Yap_SetDefaultEncoding(encoding_t new_encoding);
 | 
			
		||||
 | 
			
		||||
#if HAVE_XLOCALE_H
 | 
			
		||||
 
 | 
			
		||||
@@ -261,8 +261,8 @@ void Yap_DefaultStreamOps(StreamDesc *st) {
 | 
			
		||||
    Yap_ConsoleOps(st);
 | 
			
		||||
  }
 | 
			
		||||
#ifndef _WIN32
 | 
			
		||||
  else if (st->file != NULL) {
 | 
			
		||||
    if (st->encoding == LOCAL_encoding) {
 | 
			
		||||
  else if (st->file != NULL && 0 && !(st->status &  InMemory_Stream_f)) {
 | 
			
		||||
    if (st->encoding == Yap_SystemEncoding()) {
 | 
			
		||||
      st->stream_wgetc = get_wchar_from_file;
 | 
			
		||||
    } else
 | 
			
		||||
      st->stream_wgetc = get_wchar_from_FILE;
 | 
			
		||||
@@ -1137,7 +1137,6 @@ do_open(Term file_name, Term t2,
 | 
			
		||||
  const char *s_encoding;
 | 
			
		||||
  encoding_t encoding;
 | 
			
		||||
  Term tenc;
 | 
			
		||||
 | 
			
		||||
  // original file name
 | 
			
		||||
  if (IsVarTerm(file_name)) {
 | 
			
		||||
    Yap_Error(INSTANTIATION_ERROR, file_name, "open/3");
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								os/mem.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								os/mem.c
									
									
									
									
									
								
							@@ -130,10 +130,10 @@ int Yap_open_buf_read_stream(const char *nbuf, size_t nchars, encoding_t *encp,
 | 
			
		||||
    encoding = LOCAL_encoding;
 | 
			
		||||
#if MAY_READ
 | 
			
		||||
  // like any file stream.
 | 
			
		||||
  f = fmemopen((void *)nbuf, nchars, "r");
 | 
			
		||||
  st->file = f = fmemopen((void *)nbuf, nchars, "r");
 | 
			
		||||
  flags = Input_Stream_f | InMemory_Stream_f | Seekable_Stream_f;
 | 
			
		||||
#else
 | 
			
		||||
  f = NULL;
 | 
			
		||||
  sT->file =  f = NULL;
 | 
			
		||||
  flags = Input_Stream_f | InMemory_Stream_f;
 | 
			
		||||
#endif
 | 
			
		||||
  Yap_initStream(sno, f, NULL, TermNil, encoding, flags, AtomRead);
 | 
			
		||||
@@ -369,7 +369,8 @@ bool Yap_CloseMemoryStream(int sno) {
 | 
			
		||||
  } else {
 | 
			
		||||
#if MAY_READ
 | 
			
		||||
    fclose(GLOBAL_Stream[sno].file);
 | 
			
		||||
    Yap_FreeAtomSpace(GLOBAL_Stream[sno].nbuf);
 | 
			
		||||
    if (GLOBAL_Stream[sno].status & FreeOnClose_Stream_f)
 | 
			
		||||
      free(GLOBAL_Stream[sno].nbuf);
 | 
			
		||||
#else
 | 
			
		||||
    if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE)
 | 
			
		||||
      Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										51
									
								
								os/streams.c
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								os/streams.c
									
									
									
									
									
								
							@@ -890,42 +890,7 @@ void Yap_CloseStreams(int loud) {
 | 
			
		||||
  for (sno = 3; sno < MaxStreams; ++sno) {
 | 
			
		||||
    if (GLOBAL_Stream[sno].status & Free_Stream_f)
 | 
			
		||||
      continue;
 | 
			
		||||
    if ((GLOBAL_Stream[sno].status & Popen_Stream_f)) {
 | 
			
		||||
#if _MSC_VER
 | 
			
		||||
 | 
			
		||||
      _pclose(GLOBAL_Stream[sno].file);
 | 
			
		||||
#else
 | 
			
		||||
      pclose(GLOBAL_Stream[sno].file);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    if (GLOBAL_Stream[sno].status & (Pipe_Stream_f | Socket_Stream_f))
 | 
			
		||||
      close(GLOBAL_Stream[sno].u.pipe.fd);
 | 
			
		||||
#if USE_SOCKET
 | 
			
		||||
    else if (GLOBAL_Stream[sno].status & (Socket_Stream_f)) {
 | 
			
		||||
      Yap_CloseSocket(GLOBAL_Stream[sno].u.socket.fd,
 | 
			
		||||
                      GLOBAL_Stream[sno].u.socket.flags,
 | 
			
		||||
                      GLOBAL_Stream[sno].u.socket.domain);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    else if (GLOBAL_Stream[sno].status & InMemory_Stream_f) {
 | 
			
		||||
      if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE) {
 | 
			
		||||
        Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf);
 | 
			
		||||
      } else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) {
 | 
			
		||||
        free(GLOBAL_Stream[sno].u.mem_string.buf);
 | 
			
		||||
      }
 | 
			
		||||
    } else if (!(GLOBAL_Stream[sno].status & Null_Stream_f)) {
 | 
			
		||||
      fclose(GLOBAL_Stream[sno].file);
 | 
			
		||||
    } else {
 | 
			
		||||
      if (loud)
 | 
			
		||||
        fprintf(Yap_stderr, "%% YAP Error: while closing stream: %s\n",
 | 
			
		||||
                RepAtom(GLOBAL_Stream[sno].name)->StrOfAE);
 | 
			
		||||
    }
 | 
			
		||||
    if (LOCAL_c_input_stream == sno) {
 | 
			
		||||
      LOCAL_c_input_stream = StdInStream;
 | 
			
		||||
    } else if (LOCAL_c_output_stream == sno) {
 | 
			
		||||
      LOCAL_c_output_stream = StdOutStream;
 | 
			
		||||
    }
 | 
			
		||||
    GLOBAL_Stream[sno].status = Free_Stream_f;
 | 
			
		||||
    CloseStream( sno );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -947,10 +912,16 @@ static void CloseStream(int sno) {
 | 
			
		||||
    close(GLOBAL_Stream[sno].u.pipe.fd);
 | 
			
		||||
  } else if (GLOBAL_Stream[sno].status & (InMemory_Stream_f)) {
 | 
			
		||||
    Yap_CloseMemoryStream(sno);
 | 
			
		||||
    if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE)
 | 
			
		||||
      Yap_FreeAtomSpace(GLOBAL_Stream[sno].u.mem_string.buf);
 | 
			
		||||
    else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) {
 | 
			
		||||
      free(GLOBAL_Stream[sno].u.mem_string.buf);
 | 
			
		||||
    if (GLOBAL_Stream[sno].file == NULL) {
 | 
			
		||||
      char *s = GLOBAL_Stream[sno].u.mem_string.buf;
 | 
			
		||||
      if (s == LOCAL_FileNameBuf ||
 | 
			
		||||
	  s == LOCAL_FileNameBuf2)
 | 
			
		||||
	return;
 | 
			
		||||
      if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_CODE)
 | 
			
		||||
	Yap_FreeAtomSpace(s);
 | 
			
		||||
      else if (GLOBAL_Stream[sno].u.mem_string.src == MEM_BUF_MALLOC) {
 | 
			
		||||
	free(s);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  GLOBAL_Stream[sno].status = Free_Stream_f;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								os/sysbits.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								os/sysbits.c
									
									
									
									
									
								
							@@ -521,14 +521,17 @@ static const char *myrealpath(const char *path, char *out) {
 | 
			
		||||
    if (errno == ENOENT || errno == EACCES) {
 | 
			
		||||
      char base[YAP_FILENAME_MAX];
 | 
			
		||||
      strncpy(base, path, YAP_FILENAME_MAX - 1);
 | 
			
		||||
      rc = realpath(dirname((char *)path), NULL);
 | 
			
		||||
      rc = realpath(dirname(base), NULL);
 | 
			
		||||
 | 
			
		||||
      if (rc) {
 | 
			
		||||
        const char *b = basename(base);
 | 
			
		||||
        size_t e = strlen(rc);
 | 
			
		||||
        size_t bs = strlen(b);
 | 
			
		||||
 | 
			
		||||
        rc = realloc(rc, e + bs + 2);
 | 
			
		||||
	if (rc != out &&
 | 
			
		||||
	  rc != base) {
 | 
			
		||||
	  rc = realloc(rc, e + bs + 2);
 | 
			
		||||
	}
 | 
			
		||||
#if _WIN32
 | 
			
		||||
        if (rc[e - 1] != '\\' && rc[e - 1] != '/') {
 | 
			
		||||
          rc[e] = '\\';
 | 
			
		||||
@@ -797,7 +800,7 @@ static Term
 | 
			
		||||
 *
 | 
			
		||||
 * @return
 | 
			
		||||
 */
 | 
			
		||||
static Int prolog_realpath(USES_REGS1) {
 | 
			
		||||
static Int real_path(USES_REGS1) {
 | 
			
		||||
  Term t1 = Deref(ARG1);
 | 
			
		||||
  const char *cmd;
 | 
			
		||||
 | 
			
		||||
@@ -2145,7 +2148,7 @@ void Yap_InitSysPreds(void) {
 | 
			
		||||
  Yap_InitCPred("prolog_to_os_filename", 2, prolog_to_os_filename,
 | 
			
		||||
                SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("absolute_file_system_path", 2, absolute_file_system_path, 0);
 | 
			
		||||
  Yap_InitCPred("real_path", 2, prolog_realpath, 0);
 | 
			
		||||
  Yap_InitCPred("real_path", 2, real_path, 0);
 | 
			
		||||
  Yap_InitCPred("true_file_name", 2, true_file_name, SyncPredFlag);
 | 
			
		||||
  Yap_InitCPred("true_file_name", 3, true_file_name3, SyncPredFlag);
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
 
 | 
			
		||||
@@ -187,7 +187,7 @@
 | 
			
		||||
% free-of-charge patent license to make, have made, use, offer to sell,
 | 
			
		||||
% sell, import and otherwise transfer the Package with respect to any
 | 
			
		||||
% patent claims licensable by the Copyright Holder that are necessarily
 | 
			
		||||
% infringed by the Package. If you institute patent litigation
 | 
			
		||||
% infringed by the Pack<age. If you institute patent litigation
 | 
			
		||||
% (including a cross-claim or counterclaim) against any party alleging
 | 
			
		||||
% that the Package constitutes direct or contributory patent
 | 
			
		||||
% infringement, then this Artistic License to you shall terminate on the
 | 
			
		||||
@@ -429,7 +429,7 @@ flag_validate_integer(Value):-
 | 
			
		||||
 | 
			
		||||
flag_validate_directory.
 | 
			
		||||
flag_validate_directory(Value):-
 | 
			
		||||
  atomic(Value),
 | 
			
		||||
    atomic(Value),
 | 
			
		||||
  catch(file_exists(Value), _, fail),
 | 
			
		||||
  file_property(Value, type(directory)), !.
 | 
			
		||||
flag_validate_directory(Value):-
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +0,0 @@
 | 
			
		||||
@x0
 | 
			
		||||
1.8030419430
 | 
			
		||||
@x1
 | 
			
		||||
1.5711506586
 | 
			
		||||
@x2
 | 
			
		||||
0.3874470553
 | 
			
		||||
@x3
 | 
			
		||||
0.7696186145
 | 
			
		||||
@x4
 | 
			
		||||
0.3435736975
 | 
			
		||||
@x5
 | 
			
		||||
-0.7166347511
 | 
			
		||||
@x6
 | 
			
		||||
0.9712276641
 | 
			
		||||
@x7
 | 
			
		||||
-1.4049657589
 | 
			
		||||
@@ -730,7 +730,7 @@ update_query(QueryID,Symbol,What_To_Update) :-
 | 
			
		||||
	  problog_flag(sigmoid_slope,Slope),
 | 
			
		||||
	  problog_dir(PD),
 | 
			
		||||
	  ((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
 | 
			
		||||
      convert_filename_to_problog_path('simplecudd', Simplecudd),
 | 
			
		||||
      convert_filename_to_problog_path('problogbdd', Simplecudd),
 | 
			
		||||
	  atomic_concat([Simplecudd,
 | 
			
		||||
			 ' -i "', Probabilities_File, '"',
 | 
			
		||||
			 ' -l "', Query_Directory,'/query_',QueryID, '"',
 | 
			
		||||
 
 | 
			
		||||
@@ -353,7 +353,8 @@ do_learning_intern(Iterations,Epsilon) :-
 | 
			
		||||
 | 
			
		||||
	format_learning(1,'~nIteration ~d of ~d~n',[CurrentIteration,EndIteration]),
 | 
			
		||||
	logger_set_variable(iteration,CurrentIteration),
 | 
			
		||||
 | 
			
		||||
	leash(none),
 | 
			
		||||
%	trace,
 | 
			
		||||
	write_probabilities_file,
 | 
			
		||||
 | 
			
		||||
	once(llh_testset),
 | 
			
		||||
@@ -410,14 +411,14 @@ init_learning :-
 | 
			
		||||
	learning_initialized,
 | 
			
		||||
	!.
 | 
			
		||||
init_learning :-
 | 
			
		||||
	convert_filename_to_problog_path('simplecudd_lfi', Path),
 | 
			
		||||
	convert_filename_to_problog_path('problogbdd_lfi', Path),
 | 
			
		||||
	(
 | 
			
		||||
	 file_exists(Path)
 | 
			
		||||
	->
 | 
			
		||||
	 true;
 | 
			
		||||
	 (
 | 
			
		||||
	  problog_path(PD),
 | 
			
		||||
	  format(user_error, 'WARNING: Can not find file: simplecudd_lfi. Please place file in problog path: ~q~n',[PD]),
 | 
			
		||||
	  format(user_error, 'WARNING: Can not find file: problogbdd_lfi. Please place file in problog path: ~q~n',[PD]),
 | 
			
		||||
	  fail
 | 
			
		||||
	 )
 | 
			
		||||
	),
 | 
			
		||||
@@ -457,7 +458,7 @@ init_learning :-
 | 
			
		||||
	format_learning(3,'~q training example(s)~n',[TrainingExampleCount]),
 | 
			
		||||
 | 
			
		||||
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
	% Create arrays for probabilties and counting tables
 | 
			
		||||
	% Create arrays for probabilities and counting tables
 | 
			
		||||
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
	once(initialize_fact_probabilities),
 | 
			
		||||
	problog:probclause_id(N),
 | 
			
		||||
@@ -471,7 +472,6 @@ init_learning :-
 | 
			
		||||
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
	% build BDD script for every example
 | 
			
		||||
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
 | 
			
		||||
	once(init_queries),
 | 
			
		||||
 | 
			
		||||
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
			
		||||
@@ -613,10 +613,11 @@ init_queries :-
 | 
			
		||||
	format_learning(2,'Build BDDs for examples~n',[]),
 | 
			
		||||
	forall(user:example(Training_ID),
 | 
			
		||||
	       (
 | 
			
		||||
		format_learning(3,'training example ~q: ',[Training_ID]),
 | 
			
		||||
		   format_learning(3,'training example ~q: ',[Training_ID]),
 | 
			
		||||
		init_one_query(Training_ID,training)
 | 
			
		||||
	       )
 | 
			
		||||
	      ),
 | 
			
		||||
		   writeln(Training_ID),
 | 
			
		||||
 | 
			
		||||
	forall(
 | 
			
		||||
	       (
 | 
			
		||||
@@ -885,7 +886,7 @@ update_query(QueryID,ClusterID ,Method,Command,PID,Output_File_Name) :-
 | 
			
		||||
	create_bdd_output_file_name(QueryID,ClusterID,Iteration,Output_File_Name),
 | 
			
		||||
	create_bdd_file_name(QueryID,ClusterID,BDD_File_Name),
 | 
			
		||||
 | 
			
		||||
	convert_filename_to_problog_path('simplecudd_lfi',Absolute_Name),
 | 
			
		||||
	convert_filename_to_problog_path('problogbdd_lfi',Absolute_Name),
 | 
			
		||||
 | 
			
		||||
	atomic_concat([Absolute_Name,
 | 
			
		||||
		       ' -i "', Input_File_Name, '"',
 | 
			
		||||
 
 | 
			
		||||
@@ -1438,11 +1438,11 @@ static foreign_t python_to_term(PyObject *pVal, term_t t) {
 | 
			
		||||
      return address_to_term(pVal, t);
 | 
			
		||||
    Py_ssize_t sz = PyUnicode_GetSize(pValR) + 1;
 | 
			
		||||
#if PY_MAJOR_VERSION < 3
 | 
			
		||||
    s = malloc(sizeof(char) * sz);
 | 
			
		||||
    char *s = malloc(sizeof(char) * sz);
 | 
			
		||||
    PyObject *us = PyUnicode_EncodeUTF8((const Py_UNICODE *)pValR, sz, NULL);
 | 
			
		||||
    PyString_AsStringAndSize(us, &s, &sz);
 | 
			
		||||
    foreign_t rc = repr_term(s, sz, t);
 | 
			
		||||
    free(s);
 | 
			
		||||
    free((void *)s);
 | 
			
		||||
    return rc;
 | 
			
		||||
#else
 | 
			
		||||
    // new interface
 | 
			
		||||
@@ -2150,9 +2150,8 @@ static foreign_t python_run_script(term_t cmd, term_t fun) {
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static foreign_t python_builtin(out) {
 | 
			
		||||
static foreign_t python_builtin(term_t out) {
 | 
			
		||||
  return address_to_term(py_Builtin, out);
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static foreign_t init_python(void) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1361,7 +1361,7 @@ not(G) :-    \+ '$execute'(G).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
'$bootstrap' :-
 | 
			
		||||
    bootstrap('init.yap').
 | 
			
		||||
    bootstrap('pl/init.yap'),
 | 
			
		||||
    module(user),
 | 
			
		||||
    '$live'.
 | 
			
		||||
 | 
			
		||||
@@ -1575,7 +1575,7 @@ catch(G, C, A) :-
 | 
			
		||||
	'$catch'(M:G,_,[C|A]).
 | 
			
		||||
 | 
			
		||||
'$catch'(MG,_,_) :-
 | 
			
		||||
'$$save_by'(CP0),
 | 
			
		||||
	'$$save_by'(CP0),
 | 
			
		||||
	'$execute'(MG),
 | 
			
		||||
	'$$save_by'(CP1),
 | 
			
		||||
    % remove catch
 | 
			
		||||
 
 | 
			
		||||
@@ -11,54 +11,7 @@
 | 
			
		||||
* File:		checker.yap						 *
 | 
			
		||||
* comments:	style checker for Prolog				 *
 | 
			
		||||
*									 *
 | 
			
		||||
* Last rev:     $Date: 2008-03-31 22:56:22 $,$Author: vsc $						 *
 | 
			
		||||
* $Log: not supported by cvs2svn $
 | 
			
		||||
* Revision 1.23  2007/11/26 23:43:09  vsc
 | 
			
		||||
* fixes to support threads and assert correctly, even if inefficiently.
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.22  2006/11/17 12:10:46  vsc
 | 
			
		||||
* style_checker was failing on DCGs
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.21  2006/03/24 16:26:31  vsc
 | 
			
		||||
* code review
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.20  2005/11/05 23:56:10  vsc
 | 
			
		||||
* should have meta-predicate definitions for calls,
 | 
			
		||||
*   multifile and discontiguous.
 | 
			
		||||
* have discontiguous as a builtin, not just as a
 | 
			
		||||
*   declaration.
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.19  2005/10/28 17:38:50  vsc
 | 
			
		||||
* sveral updates
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.18  2005/04/20 20:06:11  vsc
 | 
			
		||||
* try to improve error handling and warnings from within consults.
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.17  2005/04/20 04:08:20  vsc
 | 
			
		||||
* fix warnings
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.16  2005/01/13 05:47:27  vsc
 | 
			
		||||
* lgamma broke arithmetic optimisation
 | 
			
		||||
* integer_y has type y
 | 
			
		||||
* pass original source to checker (and maybe even use option in parser)
 | 
			
		||||
* use warning mechanism for checker messages.
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.15  2004/06/29 19:12:01  vsc
 | 
			
		||||
* fix checker messages
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.14  2004/06/29 19:04:46  vsc
 | 
			
		||||
* fix multithreaded version
 | 
			
		||||
* include new version of Ricardo's profiler
 | 
			
		||||
* new predicat atomic_concat
 | 
			
		||||
* allow multithreaded-debugging
 | 
			
		||||
* small fixes
 | 
			
		||||
*
 | 
			
		||||
* Revision 1.13  2004/03/19 11:35:42  vsc
 | 
			
		||||
* trim_trail for default machine
 | 
			
		||||
* be more aggressive about try-retry-trust chains.
 | 
			
		||||
*    - handle cases where block starts with a wait
 | 
			
		||||
*    - don't use _killed instructions, just let the thing rot by itself.
 | 
			
		||||
*                                                                  *
 | 
			
		||||
* Last rev:     $Date: 2008-03-31 22:56:22 $,$Author: vsc $		 *
 | 
			
		||||
*									 *
 | 
			
		||||
*************************************************************************/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -263,7 +263,7 @@ This is similar to <tt>call_cleanup/1</tt> with an additional
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
call_cleanup(Goal, Cleanup) :-
 | 
			
		||||
	setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup).
 | 
			
		||||
	setup_call_catcher_cleanup(true, Goal, _Catcher, Cleanup).
 | 
			
		||||
 | 
			
		||||
call_cleanup(Goal, Catcher, Cleanup) :-
 | 
			
		||||
	setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup).
 | 
			
		||||
@@ -617,7 +617,7 @@ halt :-
 | 
			
		||||
 | 
			
		||||
/** @pred  halt(+  _I_) is iso
 | 
			
		||||
 | 
			
		||||
Halts Prolog, and exits to the calling application returning the code
 | 
			
		||||
Halts Prolog, and exits to 1the calling application returning the code
 | 
			
		||||
given by the integer  _I_.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 
 | 
			
		||||
@@ -70,7 +70,7 @@ attr_unify_hook(DelayList, _) :-
 | 
			
		||||
	wake_delays(DelayList).
 | 
			
		||||
	
 | 
			
		||||
wake_delays([]).
 | 
			
		||||
wake_delays(Delay.List) :-
 | 
			
		||||
wake_delays([Delay|List]) :-
 | 
			
		||||
	wake_delay(Delay),
 | 
			
		||||
	wake_delays(List).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								pl/debug.yap
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								pl/debug.yap
									
									
									
									
									
								
							@@ -521,6 +521,10 @@ be lost.
 | 
			
		||||
    current_prolog_flag( debug, false),
 | 
			
		||||
    !,
 | 
			
		||||
    '$execute_nonstop'(G,M).
 | 
			
		||||
'$spycall'(once(G), M, _, _) :-
 | 
			
		||||
 	 CP is '$last_choice_pt',
 | 
			
		||||
	 '$debugger_input',
 | 
			
		||||
	once('$do_spy'(G, M, CP, spy)).
 | 
			
		||||
'$spycall'(G, M, _, _) :-
 | 
			
		||||
	'__NB_getval__'('$debug_jump',true, fail),
 | 
			
		||||
	!,
 | 
			
		||||
@@ -1033,13 +1037,15 @@ be lost.
 | 
			
		||||
	'$debugger_skip_loop_spy2'(CPs,CPs1).
 | 
			
		||||
'$debugger_skip_loop_spy2'(CPs,CPs).
 | 
			
		||||
 | 
			
		||||
'$debugger_expand_meta_call'( G, M, G1 ) :-
 | 
			
		||||
    '$expand_meta_call'( G, M, G0 ),
 | 
			
		||||
'$debugger_expand_meta_call'( G, VL, G2 ) :-
 | 
			
		||||
    '$expand_meta_call'( G, VL, G0 ),
 | 
			
		||||
    '$yap_strip_module'( G0, M, G1 ),
 | 
			
		||||
    (
 | 
			
		||||
	'$is_system_predicate'(G0,M) ->
 | 
			
		||||
	    '$debugger_process_meta_arguments'(G0, M, G1)
 | 
			
		||||
	    '$debugger_process_meta_arguments'(G1, M, G2)
 | 
			
		||||
	    ,writeln(d:G2)
 | 
			
		||||
     ;
 | 
			
		||||
     G1 = G0
 | 
			
		||||
     G1 = G2
 | 
			
		||||
    ).
 | 
			
		||||
 | 
			
		||||
'$debugger_process_meta_arguments'(G, M, G1) :-
 | 
			
		||||
 
 | 
			
		||||
@@ -218,7 +218,7 @@ considered.
 | 
			
		||||
	'$assert_list'(Clauses, Context, Module, VL, Pos).
 | 
			
		||||
 | 
			
		||||
'$assert_list'([], _Context, _Module, _VL, _Pos).
 | 
			
		||||
'$assert_list'(Clause.Clauses, Context, Module, VL, Pos) :-
 | 
			
		||||
'$assert_list'([Clause|Clauses], Context, Module, VL, Pos) :-
 | 
			
		||||
	'$command'(Clause, VL, Pos, Context),
 | 
			
		||||
	'$assert_list'(Clauses, Context, Module, VL, Pos).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -84,8 +84,6 @@ Grammar related built-in predicates:
 | 
			
		||||
        {}/3,
 | 
			
		||||
        ('|')/4], ['$do_error'/2]).
 | 
			
		||||
 | 
			
		||||
:- use_module( library( expand_macros ) ).
 | 
			
		||||
 | 
			
		||||
% :- meta_predicate ^(?,0,?).
 | 
			
		||||
% ^(Xs, Goal, Xs) :- call(Goal).
 | 
			
		||||
 | 
			
		||||
@@ -285,10 +283,6 @@ prolog:'\\+'(A, S0, S) :-
 | 
			
		||||
 | 
			
		||||
:- dynamic system:goal_expansion/2.
 | 
			
		||||
 | 
			
		||||
:- dynamic prolog:'$goal_expansion_allowed'/0.
 | 
			
		||||
 | 
			
		||||
prolog:'$goal_expansion_allowed'.
 | 
			
		||||
 | 
			
		||||
'$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal) :-
 | 
			
		||||
    catch(prolog:'$translate_rule'(
 | 
			
		||||
          (pseudo_nt --> Mod:NT), Rule),
 | 
			
		||||
@@ -323,7 +317,6 @@ do_c_built_in('C'(A,B,C), _, _, (A=[B|C])) :- !.
 | 
			
		||||
 | 
			
		||||
do_c_built_in(phrase(NT,Xs0, Xs),Mod, _, NewGoal) :- 
 | 
			
		||||
    nonvar(NT), nonvar(Mod), !,
 | 
			
		||||
    '$goal_expansion_allowed',
 | 
			
		||||
    '$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal).
 | 
			
		||||
    
 | 
			
		||||
do_c_built_in(phrase(NT,Xs),Mod,_,NewGoal) :-
 | 
			
		||||
 
 | 
			
		||||
@@ -322,7 +322,7 @@ portray_clause(Clause) :-
 | 
			
		||||
	!,
 | 
			
		||||
	N is M+1,
 | 
			
		||||
	'$list_transform'(L,N).
 | 
			
		||||
'$list_transform'('$VAR'(-1).L,M) :- !,
 | 
			
		||||
'$list_transform'(['$VAR'(-1)|L],M) :- !,
 | 
			
		||||
	'$list_transform'(L,M).
 | 
			
		||||
'$list_transform'(_.L,M) :-
 | 
			
		||||
'$list_transform'([_|L],M) :-
 | 
			
		||||
	'$list_transform'(L,M).
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								pl/meta.yap
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								pl/meta.yap
									
									
									
									
									
								
							@@ -70,7 +70,7 @@ meta_predicate declaration
 | 
			
		||||
 | 
			
		||||
% I assume the clause has been processed, so the
 | 
			
		||||
% var case is long gone! Yes :)
 | 
			
		||||
'$clean_cuts'(G,(yap_hacks:current_choicepoint(DCP),NG)) :-
 | 
			
		||||
'$clean_cuts'(G,('$current_choicepoint'(DCP),NG)) :-
 | 
			
		||||
	'$conj_has_cuts'(G,DCP,NG,OK), OK == ok, !.
 | 
			
		||||
'$clean_cuts'(G,G).
 | 
			
		||||
 | 
			
		||||
@@ -284,7 +284,7 @@ meta_predicate declaration
 | 
			
		||||
'$expand_goals'(\+A,\+A1,(AO-> false;true),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	'$expand_goals'(A,A1,AO,HM,SM,BM,HVars).
 | 
			
		||||
'$expand_goals'(once(A),once(A1),
 | 
			
		||||
	(yap_hacks:current_choice_point(CP),AO,'$$cut_by'(CP)),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	('$current_choice_point'(CP),AO,'$$cut_by'(CP)),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
 | 
			
		||||
        '$clean_cuts'(AO0, CP, AO).
 | 
			
		||||
'$expand_goals'(ignore(A),ignore(A1),
 | 
			
		||||
@@ -299,19 +299,19 @@ meta_predicate declaration
 | 
			
		||||
'$expand_goals'(not(A),not(A1),(AO -> fail; true),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	'$expand_goals'(A,A1,AO,HM,SM,BM,HVars).
 | 
			
		||||
'$expand_goals'(if(A,B,C),if(A1,B1,C1),
 | 
			
		||||
	(yap_hacks:current_choicepoint(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	('$current_choicepoint'(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
 | 
			
		||||
	'$expand_goals'(B,B1,BO,HM,SM,BM,HVars),
 | 
			
		||||
	'$expand_goals'(C,C1,CO,HM,SM,BM,HVars),
 | 
			
		||||
        '$clean_cuts'(AO0, DCP, AO).
 | 
			
		||||
'$expand_goals'((A*->B;C),(A1*->B1;C1),
 | 
			
		||||
	(yap_hacks:current_choicepoint(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	('$current_choicepoint'(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
 | 
			
		||||
	'$expand_goals'(B,B1,BO,HM,SM,BM,HVars),
 | 
			
		||||
	'$expand_goals'(C,C1,CO,HM,SM,BM,HVars),
 | 
			
		||||
    '$clean_cuts'(AO0, DCP, AO).
 | 
			
		||||
'$expand_goals'((A*->B),(A1*->B1),
 | 
			
		||||
	(yap_hacks:current_choicepoint(DCP),AO,BO),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	('$current_choicepoint'(DCP),AO,BO),HM,SM,BM,HVars) :- !,
 | 
			
		||||
	'$expand_goals'(A,A1,AO0,HM,SM,BM,HVars),
 | 
			
		||||
	'$expand_goals'(B,B1,BO,HM,SM,BM,HVars),
 | 
			
		||||
    '$clean_cuts'(AO0, DCP, AO).
 | 
			
		||||
 
 | 
			
		||||
@@ -762,12 +762,12 @@ compile_predicates(Ps) :-
 | 
			
		||||
	'$compile_predicate'(P, M, Call).
 | 
			
		||||
'$compile_predicate'(Na/Ar, Mod, _Call) :-
 | 
			
		||||
	functor(G, Na, Ar),
 | 
			
		||||
	findall((G.B),clause(Mod:G,B),Cls),
 | 
			
		||||
	findall([G|B],clause(Mod:G,B),Cls),
 | 
			
		||||
	abolish(Mod:Na,Ar),
 | 
			
		||||
	'$add_all'(Cls, Mod).
 | 
			
		||||
 | 
			
		||||
'$add_all'([], _).
 | 
			
		||||
'$add_all'((G.B).Cls, Mod) :-
 | 
			
		||||
'$add_all'([[G|B]|Cls], Mod) :-
 | 
			
		||||
	assert_static(Mod:(G:-B)),
 | 
			
		||||
	'$add_all'(Cls, Mod).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -298,7 +298,7 @@ Note that all/3 will fail if no answers are found.
 | 
			
		||||
all(T, G same X,S) :- !, all(T same X,G,Sx), '$$produce'(Sx,S,X).
 | 
			
		||||
all(T,G,S) :-
 | 
			
		||||
	'$init_db_queue'(Ref),
 | 
			
		||||
	( '$catch'(Error,'$clean_findall'(Ref,Error),_),
 | 
			
		||||
	( catch(G, Error,'$clean_findall'(Ref,Error) ),
 | 
			
		||||
	  '$execute'(G),
 | 
			
		||||
	  '$db_enqueue'(Ref, T),
 | 
			
		||||
	  fail
 | 
			
		||||
 
 | 
			
		||||
@@ -330,7 +330,7 @@ alarm(Number, Goal, Left) :-
 | 
			
		||||
	USecs is integer((Number-Secs)*1000000) mod 1000000,
 | 
			
		||||
	on_signal(sig_alarm, _, Goal),
 | 
			
		||||
	'$alarm'(Secs, USecs, Left, _).
 | 
			
		||||
alarm([Interval|USecs], Goal, Left.LUSecs) :-
 | 
			
		||||
alarm([Interval|USecs], Goal, [Left|LUSecs]) :-
 | 
			
		||||
	on_signal(sig_alarm, _, Goal),
 | 
			
		||||
	'$alarm'(Interval, USecs, Left, LUSecs).
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ a postfix operator.
 | 
			
		||||
 | 
			
		||||
'$check_top_op'(_, _, [], _) :- !.
 | 
			
		||||
'$check_top_op'(P, T, [Op|NV], G) :- !,
 | 
			
		||||
	'$check_ops'(P, T, Op.NV, G).
 | 
			
		||||
	'$check_ops'(P, T, [Op|NV], G).
 | 
			
		||||
'$check_top_op'(P, T, V, G) :-
 | 
			
		||||
	atom(V), !,
 | 
			
		||||
	'$check_op_name'(P, T, V, G).
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user