/* Generated by Cython 0.29.32 */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_32"
#define CYTHON_HEX_VERSION 0x001D20F0
#define CYTHON_FUTURE_DIVISION 0
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900)
  #endif
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
#elif defined(PY_NOGIL)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #ifndef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE 1
  #endif
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 0
  #elif !defined(CYTHON_FAST_THREAD_STATE)
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK 0
  #elif !defined(CYTHON_USE_EXC_INFO_STACK)
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #if PY_MAJOR_VERSION < 3
    #include "longintrepr.h"
  #endif
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_DefaultClassType PyType_Type
#if PY_VERSION_HEX >= 0x030B00A1
    static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
                                                    PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                                    PyObject *fv, PyObject *cell, PyObject* fn,
                                                    PyObject *name, int fline, PyObject *lnos) {
        PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
        PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
        const char *fn_cstr=NULL;
        const char *name_cstr=NULL;
        PyCodeObject* co=NULL;
        PyObject *type, *value, *traceback;
        PyErr_Fetch(&type, &value, &traceback);
        if (!(kwds=PyDict_New())) goto end;
        if (!(argcount=PyLong_FromLong(a))) goto end;
        if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
        if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
        if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
        if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
        if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
        if (!(nlocals=PyLong_FromLong(l))) goto end;
        if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
        if (!(stacksize=PyLong_FromLong(s))) goto end;
        if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
        if (!(flags=PyLong_FromLong(f))) goto end;
        if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
        if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
        if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
        if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
        if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
        if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
        if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
        Py_XDECREF((PyObject*)co);
        co = (PyCodeObject*)call_result;
        call_result = NULL;
        if (0) {
            cleanup_code_too:
            Py_XDECREF((PyObject*)co);
            co = NULL;
        }
        end:
        Py_XDECREF(kwds);
        Py_XDECREF(argcount);
        Py_XDECREF(posonlyargcount);
        Py_XDECREF(kwonlyargcount);
        Py_XDECREF(nlocals);
        Py_XDECREF(stacksize);
        Py_XDECREF(replace);
        Py_XDECREF(call_result);
        Py_XDECREF(empty);
        if (type) {
            PyErr_Restore(type, value, traceback);
        }
        return co;
    }
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #if defined(PyUnicode_IS_READY)
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #else
  #define __Pyx_PyUnicode_READY(op)       (0)
  #endif
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #endif
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsHash_t
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  #if !defined(_USE_MATH_DEFINES)
    #define _USE_MATH_DEFINES
  #endif
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__pyDatalog__pyEngine
#define __PYX_HAVE_API__pyDatalog__pyEngine
/* Early includes */
#include <string.h>
#include <stdio.h>
#include "pythread.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "pyDatalog/pyEngine.py",
  "stringsource",
  "pyDatalog/pyEngine.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term;
struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var;
struct __pyx_obj_9pyDatalog_8pyEngine_Var;
struct __pyx_obj_9pyDatalog_8pyEngine_Const;
struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple;
struct __pyx_obj_9pyDatalog_8pyEngine_Operation;
struct __pyx_obj_9pyDatalog_8pyEngine_Literal;
struct __pyx_obj_9pyDatalog_8pyEngine_Clause;
struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching;
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr;
struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete;

/* "pyDatalog/pyEngine.pxd":97
 *     cpdef public schedule_search(self, Subgoal subgoal)
 *     #cpdef public searching(self, Subgoal subgoal)
 *     cpdef public complete(self, Literal literal, object aggregate=*)             # <<<<<<<<<<<<<<
 *     #cpdef public on_completion
 */
struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete {
  int __pyx_n;
  PyObject *aggregate;
};

/* "pyDatalog/pyEngine.pxd":5
 * from cpython cimport bool
 * 
 * cdef class Term(object):             # <<<<<<<<<<<<<<
 *     cdef public object id
 * 
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Term {
  PyObject_HEAD
  PyObject *id;
};


/* "pyDatalog/pyEngine.pxd":8
 *     cdef public object id
 * 
 * cdef class Fresh_var(Term):             # <<<<<<<<<<<<<<
 * 
 *     #def __init__(self) #can't have type
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term __pyx_base;
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Fresh_var *__pyx_vtab;
};


/* "pyDatalog/pyEngine.pxd":20
 *     cpdef public dict unify(self, Term term, dict env)
 * 
 * cdef class Var(Fresh_var):             # <<<<<<<<<<<<<<
 *     cpdef public dict unify(self, Term term, dict env)
 * 
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Var {
  struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var __pyx_base;
};


/* "pyDatalog/pyEngine.pxd":23
 *     cpdef public dict unify(self, Term term, dict env)
 * 
 * cdef class Const(Term):             # <<<<<<<<<<<<<<
 *     cpdef bool is_const(self)
 * 
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Const {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term __pyx_base;
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Const *__pyx_vtab;
};


/* "pyDatalog/pyEngine.pxd":33
 *     cpdef public dict unify(self, Term term, dict env)
 * 
 * cdef class VarTuple(Term):             # <<<<<<<<<<<<<<
 *     cpdef public object _id
 *     cpdef public object is_constant
 */
struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term __pyx_base;
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_VarTuple *__pyx_vtab;
  PyObject *_id;
  PyObject *is_constant;
};


/* "pyDatalog/pyEngine.pxd":44
 *     cpdef public dict unify(self, Term term, dict env)
 * 
 * cdef class Operation(Term):             # <<<<<<<<<<<<<<
 *     cpdef public object operator
 *     cpdef public object operator_id
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Operation {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term __pyx_base;
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Operation *__pyx_vtab;
  PyObject *operator;
  PyObject *operator_id;
  PyObject *lhs;
  PyObject *rhs;
  PyObject *is_constant;
};


/* "pyDatalog/pyEngine.pxd":59
 *     cpdef public dict unify(self, Term term, dict env)
 * 
 * cdef class Literal(object):             # <<<<<<<<<<<<<<
 *     cpdef public list terms
 *     cpdef public object pred
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Literal {
  PyObject_HEAD
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *__pyx_vtab;
  PyObject *terms;
  PyObject *pred;
  PyObject *id;
  PyObject *tag;
  PyObject *aggregate;
};


/* "pyDatalog/pyEngine.pxd":75
 *     cpdef public dict match(self, list terms)
 * 
 * cdef class Clause(object):             # <<<<<<<<<<<<<<
 *     cpdef public Literal head
 *     cpdef public list body
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Clause {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *head;
  PyObject *body;
  PyObject *id;
};


/* "pyDatalog/pyEngine.pxd":80
 *     cpdef public tuple id
 * 
 * cdef class Subgoal(object):             # <<<<<<<<<<<<<<
 *     cpdef public Literal literal
 *     cpdef public object facts
 */
struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal {
  PyObject_HEAD
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *__pyx_vtab;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *literal;
  PyObject *facts;
  PyObject *waiters;
  PyObject *tasks;
  PyObject *clauses;
  PyBoolObject *recursive;
  PyBoolObject *is_done;
  PyObject *on_completion_;
};


/* "pyDatalog/pyEngine.py":169
 *     __slots__ = ['_id', 'id', 'is_constant']
 * 
 *     def __init__(self, _id): # _id is a list of Term             # <<<<<<<<<<<<<<
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ {
  PyObject_HEAD
  PyObject *__pyx_v__id;
};


/* "pyDatalog/pyEngine.py":171
 *     def __init__(self, _id): # _id is a list of Term
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id             # <<<<<<<<<<<<<<
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *__pyx_outer_scope;
  PyObject *__pyx_v_e;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pyDatalog/pyEngine.py":172
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 *         self.is_constant = all(element.is_const() for element in _id)             # <<<<<<<<<<<<<<
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *__pyx_outer_scope;
  PyObject *__pyx_v_element;
};


/* "pyDatalog/pyEngine.py":374
 *         return self._cls
 * 
 *     def parent_classes(self):             # <<<<<<<<<<<<<<
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes {
  PyObject_HEAD
  PyObject *__pyx_v_cls;
  PyObject *__pyx_v_self;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pyDatalog/pyEngine.py":505
 *         return env
 * 
 *     def ask(self):             # <<<<<<<<<<<<<<
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask {
  PyObject_HEAD
  PyObject *__pyx_v_literal;
};


/* "pyDatalog/pyEngine.py":517
 *         if Ts.Goal.facts is True:
 *             return True
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]             # <<<<<<<<<<<<<<
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal = saved_environment
 *         return result
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *__pyx_outer_scope;
  PyObject *__pyx_v_term;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pyDatalog/pyEngine.py":532
 *         self.body = body
 *         self.id = None
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self;
};


/* "pyDatalog/pyEngine.py":533
 *         self.id = None
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *__pyx_outer_scope;
  PyObject *__pyx_v_literal;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "pyDatalog/pyEngine.py":534
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 *     def __neg__(self):
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self;
};


/* "pyDatalog/pyEngine.py":535
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]             # <<<<<<<<<<<<<<
 *     def __neg__(self):
 *         """retract clause"""
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *__pyx_outer_scope;
  PyObject *__pyx_v_literal;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "pyDatalog/pyEngine.py":540
 *         retract(self)
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two clauses are structurally equal
 *             if they have the same id.  A clause's id is used as a key into the
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self;
};


/* "pyDatalog/pyEngine.py":548
 *                 self.id = (self.head.get_fact_id(),)
 *             else:
 *                 self.id = (self.head.get_id(),) + tuple(bodi.get_id() for bodi in self.body)             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *__pyx_outer_scope;
  PyObject *__pyx_v_bodi;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "pyDatalog/pyEngine.py":595
 *     return pred
 * 
 * def assert_(clause):             # <<<<<<<<<<<<<<
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ {
  PyObject_HEAD
  PyObject *__pyx_v_clause;
  PyObject *__pyx_v_pred;
};


/* "pyDatalog/pyEngine.py":608
 *                 clauses.add(clause)
 *         else:
 *             if any(literal.pred.id == pred.id for literal in clause.body):             # <<<<<<<<<<<<<<
 *                 pred.recursive = True
 *             pred.clauses[id_] = clause
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *__pyx_outer_scope;
  PyObject *__pyx_v_literal;
};


/* "pyDatalog/pyEngine.py":633
 *     return clause
 * 
 * def relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses {
  PyObject_HEAD
  PyObject *__pyx_v_facts;
  PyObject *__pyx_v_i;
  PyObject *__pyx_v_literal;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_term;
  PyObject *__pyx_v_v;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pyDatalog/pyEngine.py":1014
 *         return self.next_step()
 * 
 *     def searching(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self;
  PyObject *__pyx_v_subgoal;
};


/* "pyDatalog/pyEngine.py":1026
 *         # restart searching of subgoal, in correct recursive mode
 *         # unless the subgoal is a waiter of self (to prevent infinite loop)
 *         if all(subgoal != waiter[0] for waiter in self.waiters):             # <<<<<<<<<<<<<<
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:
 */
struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr {
  PyObject_HEAD
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *__pyx_outer_scope;
  PyObject *__pyx_v_waiter;
};



/* "pyDatalog/pyEngine.py":68
 * 
 * 
 * class Fresh_var(Term):             # <<<<<<<<<<<<<<
 *     """ a variable created by the search algorithm """
 *     __slots__ = ['id']
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Fresh_var {
  PyBoolObject *(*is_const)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, int __pyx_skip_dispatch);
  PyObject *(*get_tag)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*subst)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*shuffle)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*chase)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*match)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*unify)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Fresh_var *__pyx_vtabptr_9pyDatalog_8pyEngine_Fresh_var;


/* "pyDatalog/pyEngine.py":115
 * 
 * 
 * class Var(Fresh_var):             # <<<<<<<<<<<<<<
 *     """ A variable in a clause or query """
 *     __slots__ = ['id']
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Var {
  struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Fresh_var __pyx_base;
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Var *__pyx_vtabptr_9pyDatalog_8pyEngine_Var;


/* "pyDatalog/pyEngine.py":128
 * 
 * 
 * class Const(Term):             # <<<<<<<<<<<<<<
 *     """ a constant """
 *     __slots__ = ['id']
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Const {
  PyBoolObject *(*is_const)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, int __pyx_skip_dispatch);
  PyObject *(*get_tag)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*subst)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*shuffle)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*chase)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*match)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*unify)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Const *__pyx_vtabptr_9pyDatalog_8pyEngine_Const;


/* "pyDatalog/pyEngine.py":165
 * 
 * 
 * class VarTuple(Term):             # <<<<<<<<<<<<<<
 *     """ a tuple / list of variables, constants or tuples """
 *     __slots__ = ['_id', 'id', 'is_constant']
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_VarTuple {
  PyBoolObject *(*is_const)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, int __pyx_skip_dispatch);
  PyObject *(*get_tag)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*subst)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*shuffle)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*chase)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*unify)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_VarTuple *__pyx_vtabptr_9pyDatalog_8pyEngine_VarTuple;


/* "pyDatalog/pyEngine.py":242
 * 
 * 
 * class Operation(Term):             # <<<<<<<<<<<<<<
 *     """ an arithmetic operation, a slice or a lambda """
 *     counter = util.Counter()
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Operation {
  PyBoolObject *(*is_const)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, int __pyx_skip_dispatch);
  PyObject *(*get_tag)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*subst)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*shuffle)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*chase)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*unify)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Operation *__pyx_vtabptr_9pyDatalog_8pyEngine_Operation;


/* "pyDatalog/pyEngine.py":392
 * 
 * 
 * class Literal(object):             # <<<<<<<<<<<<<<
 *     """ A literal is a predicate and a sequence of terms,
 *         the number of which must match the predicate's arity.
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal {
  PyObject *(*get_tag)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch);
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *(*subst)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*shuffle)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*unify)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch);
  PyObject *(*get_id)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch);
  PyObject *(*get_fact_id)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch);
  PyObject *(*match)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *__pyx_vtabptr_9pyDatalog_8pyEngine_Literal;


/* "pyDatalog/pyEngine.py":665
 * """
 * 
 * class Subgoal(object):             # <<<<<<<<<<<<<<
 *     """
 *     A subgoal has a literal, a set of facts, and an array of waiters.
 */

struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal {
  PyObject *(*fact)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*fact_candidate)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*rule)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, struct __pyx_obj_9pyDatalog_8pyEngine_Clause *, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch);
  PyObject *(*schedule)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*schedule_search)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, int __pyx_skip_dispatch);
  PyObject *(*complete)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete *__pyx_optional_args);
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *__pyx_vtabptr_9pyDatalog_8pyEngine_Subgoal;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
#if CYTHON_FAST_PYCALL
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif // CYTHON_FAST_PYCALL
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* KeywordStringCheck.proto */
static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* dict_setdefault.proto */
static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value, int is_safe_type);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyObjectLookupSpecial.proto */
#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
    PyObject *res;
    PyTypeObject *tp = Py_TYPE(obj);
#if PY_MAJOR_VERSION < 3
    if (unlikely(PyInstance_Check(obj)))
        return __Pyx_PyObject_GetAttrStr(obj, attr_name);
#endif
    res = _PyType_Lookup(tp, attr_name);
    if (likely(res)) {
        descrgetfunc f = Py_TYPE(res)->tp_descr_get;
        if (!f) {
            Py_INCREF(res);
        } else {
            res = f(res, obj, (PyObject *)tp);
        }
    } else {
        PyErr_SetObject(PyExc_AttributeError, attr_name);
    }
    return res;
}
#else
#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
#endif

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* StringJoin.proto */
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddCObj(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* SliceTupleAndList.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* pop.proto */
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
    __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
#else
#define __Pyx_PyList_Pop(L)  __Pyx__PyObject_Pop(L)
#define __Pyx_PyObject_Pop(L)  __Pyx__PyObject_Pop(L)
#endif

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunctionShared.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    size_t defaults_size;  // used by FusedFunction for copying defaults
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* CythonFunction.proto */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* ClassMethod.proto */
#include "descrobject.h"
static CYTHON_UNUSED PyObject* __Pyx_Method_ClassMethod(PyObject *method);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* Print.proto */
static int __Pyx_Print(PyObject*, PyObject *, int);
#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
static PyObject* __pyx_print = 0;
static PyObject* __pyx_print_kwargs = 0;
#endif

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* PrintOne.proto */
static int __Pyx_PrintOne(PyObject* stream, PyObject *o);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_ExcInfoStruct  _PyErr_StackItem
#else
typedef struct {
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
} __Pyx_ExcInfoStruct;
#endif
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    __Pyx_ExcInfoStruct gi_exc_state;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    PyObject *gi_frame;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
static int __Pyx_Coroutine_clear(PyObject *self);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_Coroutine_SwapException(self)
#define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
#else
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
    (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
    }
#endif
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_is_const(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_chase(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_match(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_3Var_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_5Const_is_const(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_5Const_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_5Const_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_5Const_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_5Const_chase(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_5Const_match(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_5Const_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_is_const(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_subst(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_chase(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_unify(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_9Operation_is_const(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Operation_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Operation_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Operation_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Operation_chase(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Operation_unify(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_get_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_get_fact_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_f_9pyDatalog_8pyEngine_7Literal_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_match(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_terms, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_literal, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact_candidate(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_class0, PyObject *__pyx_v_result, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_rule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_clause, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_selected, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_task, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule_search(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_subgoal, int __pyx_skip_dispatch); /* proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_complete(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete *__pyx_optional_args); /* proto*/

/* Module declarations from 'cython' */

/* Module declarations from 'cpython.version' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'pyDatalog.pyEngine' */
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Term = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Var = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Const = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_VarTuple = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Operation = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Literal = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Clause = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine_Subgoal = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct____init__ = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching = 0;
static PyTypeObject *__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr = 0;
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Term__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Fresh_var__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Var__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Var *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Const__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_VarTuple__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Operation__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Literal__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Clause__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *, PyObject *); /*proto*/
static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Subgoal__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "pyDatalog.pyEngine"
extern int __pyx_module_is_main_pyDatalog__pyEngine;
int __pyx_module_is_main_pyDatalog__pyEngine = 0;

/* Implementation of 'pyDatalog.pyEngine' */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_reversed;
static const char __pyx_k_[] = "==";
static const char __pyx_k_1[] = "\\1";
static const char __pyx_k_f[] = "f";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_l[] = "l";
static const char __pyx_k_o[] = "o";
static const char __pyx_k_r[] = "r";
static const char __pyx_k_s[] = "'%s'";
static const char __pyx_k_v[] = "v";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_y[] = "y";
static const char __pyx_k_Db[] = "Db";
static const char __pyx_k_Ts[] = "Ts";
static const char __pyx_k_Y1[] = "Y1";
static const char __pyx_k__2[] = "[";
static const char __pyx_k__3[] = "#";
static const char __pyx_k__4[] = "..";
static const char __pyx_k__5[] = "+";
static const char __pyx_k__6[] = "-";
static const char __pyx_k__7[] = "*";
static const char __pyx_k__8[] = "/";
static const char __pyx_k__9[] = "//";
static const char __pyx_k_db[] = "db";
static const char __pyx_k_eq[] = "__eq__";
static const char __pyx_k_gc[] = "gc";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_in[] = "_in";
static const char __pyx_k_ne[] = "__ne__";
static const char __pyx_k_op[] = "op";
static const char __pyx_k_re[] = "re";
static const char __pyx_k_tl[] = "tl";
static const char __pyx_k_40s[] = "{:40s}.. : ";
static const char __pyx_k_Var[] = "Var";
static const char __pyx_k__10[] = "**";
static const char __pyx_k__11[] = "%";
static const char __pyx_k__12[] = ".";
static const char __pyx_k__13[] = "(";
static const char __pyx_k__14[] = "";
static const char __pyx_k__16[] = "]";
static const char __pyx_k__19[] = "~";
static const char __pyx_k__21[] = "^((~)?)";
static const char __pyx_k__22[] = ",";
static const char __pyx_k__24[] = "&";
static const char __pyx_k__27[] = "  ";
static const char __pyx_k__28[] = "<---";
static const char __pyx_k__29[] = " ";
static const char __pyx_k__33[] = "!=";
static const char __pyx_k__34[] = "<";
static const char __pyx_k__35[] = "<=";
static const char __pyx_k__36[] = ">=";
static const char __pyx_k__37[] = ">";
static const char __pyx_k_add[] = "add";
static const char __pyx_k_arg[] = "arg";
static const char __pyx_k_ask[] = "ask";
static const char __pyx_k_cls[] = "cls";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_end[] = "end";
static const char __pyx_k_env[] = "env";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_lhs[] = "lhs";
static const char __pyx_k_map[] = "map";
static const char __pyx_k_mro[] = "__mro__";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_pos[] = "pos";
static const char __pyx_k_rhs[] = "rhs";
static const char __pyx_k_s_2[] = "%s()";
static const char __pyx_k_s_i[] = "%s/%i";
static const char __pyx_k_s_s[] = "%s(%s)";
static const char __pyx_k_str[] = "__str__";
static const char __pyx_k_sub[] = "sub";
static const char __pyx_k_tag[] = "tag";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_Goal[] = "Goal";
static const char __pyx_k_INFO[] = "INFO";
static const char __pyx_k_Pred[] = "Pred";
static const char __pyx_k_Term[] = "Term";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_atom[] = "atom";
static const char __pyx_k_bodi[] = "bodi";
static const char __pyx_k_body[] = "body";
static const char __pyx_k_call[] = "__call__";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_fact[] = "fact";
static const char __pyx_k_file[] = "file";
static const char __pyx_k_hash[] = "__hash__";
static const char __pyx_k_head[] = "head";
static const char __pyx_k_id_2[] = "_id";
static const char __pyx_k_id_3[] = "id_";
static const char __pyx_k_info[] = "info";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_lock[] = "lock";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_next[] = "next";
static const char __pyx_k_pred[] = "pred";
static const char __pyx_k_prim[] = "prim";
static const char __pyx_k_rule[] = "rule";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_show[] = "show";
static const char __pyx_k_task[] = "task";
static const char __pyx_k_term[] = "term";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_todo[] = "todo";
static const char __pyx_k_util[] = "util";
static const char __pyx_k_Add_s[] = "  Add : %s";
static const char __pyx_k_Const[] = "Const";
static const char __pyx_k_DEBUG[] = "DEBUG";
static const char __pyx_k_Logic[] = "Logic";
static const char __pyx_k_Mixin[] = "Mixin";
static const char __pyx_k_RLock[] = "RLock";
static const char __pyx_k_STACK[] = "STACK :";
static const char __pyx_k_Tasks[] = "Tasks";
static const char __pyx_k_arity[] = "arity";
static const char __pyx_k_chase[] = "chase";
static const char __pyx_k_class[] = "_class";
static const char __pyx_k_clear[] = "clear";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_cls_2[] = "_cls";
static const char __pyx_k_debug[] = "debug";
static const char __pyx_k_deque[] = "deque";
static const char __pyx_k_enter[] = "__enter__";
static const char __pyx_k_facts[] = "facts";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_local[] = "local";
static const char __pyx_k_logic[] = "logic";
static const char __pyx_k_match[] = "match";
static const char __pyx_k_other[] = "other";
static const char __pyx_k_print[] = "print";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_s_s_2[] = "%s <= %s";
static const char __pyx_k_s_s_s[] = "(%s%s%s)";
static const char __pyx_k_slots[] = "__slots__";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_state[] = "state";
static const char __pyx_k_subst[] = "subst";
static const char __pyx_k_task2[] = "task2";
static const char __pyx_k_tasks[] = "tasks";
static const char __pyx_k_terms[] = "terms";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_unify[] = "unify";
static const char __pyx_k_words[] = "words";
static const char __pyx_k_Clause[] = "Clause";
static const char __pyx_k_LAMBDA[] = "LAMBDA";
static const char __pyx_k_Logger[] = "Logger";
static const char __pyx_k_SEARCH[] = "SEARCH";
static const char __pyx_k_Search[] = "Search";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_assert[] = "assert_";
static const char __pyx_k_class0[] = "class0";
static const char __pyx_k_clause[] = "clause";
static const char __pyx_k_dict_2[] = "_dict";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_get_id[] = "get_id";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_insert[] = "insert";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_not_in[] = "_not_in";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_parent[] = "parent";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_prefix[] = "prefix";
static const char __pyx_k_pyD_in[] = "_pyD_in";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_remove[] = "remove";
static const char __pyx_k_rename[] = "rename";
static const char __pyx_k_result[] = "result";
static const char __pyx_k_search[] = "search";
static const char __pyx_k_suffix[] = "suffix";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_xrange[] = "xrange";
static const char __pyx_k_Counter[] = "Counter";
static const char __pyx_k_Literal[] = "Literal";
static const char __pyx_k_Logging[] = "Logging";
static const char __pyx_k_Subgoal[] = "Subgoal";
static const char __pyx_k_Term_of[] = "Term_of";
static const char __pyx_k_clauses[] = "clauses";
static const char __pyx_k_collect[] = "collect";
static const char __pyx_k_compare[] = "compare";
static const char __pyx_k_counter[] = "counter";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_get_tag[] = "get_tag";
static const char __pyx_k_getitem[] = "__getitem__";
static const char __pyx_k_is_done[] = "is done !";
static const char __pyx_k_literal[] = "literal";
static const char __pyx_k_logging[] = "logging";
static const char __pyx_k_pred_id[] = "pred_id";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_rebased[] = "rebased";
static const char __pyx_k_renamed[] = "_renamed";
static const char __pyx_k_replace[] = "replace";
static const char __pyx_k_results[] = "results";
static const char __pyx_k_retract[] = "retract";
static const char __pyx_k_reverse[] = "reverse";
static const char __pyx_k_shuffle[] = "shuffle";
static const char __pyx_k_subgoal[] = "subgoal";
static const char __pyx_k_waiters[] = "waiters";
static const char __pyx_k_weakref[] = "weakref";
static const char __pyx_k_Facts_of[] = "Facts of:";
static const char __pyx_k_Interned[] = "Interned";
static const char __pyx_k_Subgoals[] = "Subgoals";
static const char __pyx_k_VarTuple[] = "VarTuple";
static const char __pyx_k_compare2[] = "compare2";
static const char __pyx_k_complete[] = "complete";
static const char __pyx_k_constant[] = "constant";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_is_const[] = "is_const";
static const char __pyx_k_is_known[] = "is_known";
static const char __pyx_k_literal0[] = "literal0";
static const char __pyx_k_literal1[] = "literal1";
static const char __pyx_k_literal2[] = "literal2";
static const char __pyx_k_new_name[] = "new_name";
static const char __pyx_k_notFound[] = "notFound";
static const char __pyx_k_operator[] = "operator";
static const char __pyx_k_prearity[] = "prearity";
static const char __pyx_k_pyD__s_i[] = "_pyD_%s%i";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_resolver[] = "resolver";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_schedule[] = "schedule";
static const char __pyx_k_selected[] = "selected";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_Fresh_var[] = "Fresh_var";
static const char __pyx_k_Operation[] = "Operation";
static const char __pyx_k_Recursive[] = "Recursive";
static const char __pyx_k_SEARCHING[] = "SEARCHING";
static const char __pyx_k_Searching[] = "Searching";
static const char __pyx_k_Var_unify[] = "Var.unify";
static const char __pyx_k_add_class[] = "add_class";
static const char __pyx_k_aggregate[] = "aggregate";
static const char __pyx_k_base_pred[] = "base_pred";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_equalized[] = "equalized";
static const char __pyx_k_getLogger[] = "getLogger";
static const char __pyx_k_is_done_2[] = "is_done";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_next_step[] = "next_step";
static const char __pyx_k_pred_name[] = "pred_name";
static const char __pyx_k_pyD_class[] = "'_pyD_class'";
static const char __pyx_k_pyD_query[] = "_pyD_query";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_recursive[] = "recursive";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_renamed_2[] = "renamed";
static const char __pyx_k_searching[] = "searching";
static const char __pyx_k_threading[] = "threading";
static const char __pyx_k_ADD_CLAUSE[] = "ADD_CLAUSE";
static const char __pyx_k_Add_clause[] = "Add clause";
static const char __pyx_k_Auto_print[] = "Auto_print";
static const char __pyx_k_Class_dict[] = "Class_dict";
static const char __pyx_k_Clauses_of[] = "Clauses of:";
static const char __pyx_k_New_fact_s[] = "New fact : %s";
static const char __pyx_k_Pred___new[] = "Pred.__new__";
static const char __pyx_k_Pred___str[] = "Pred.__str__";
static const char __pyx_k_add_clause[] = "add_clause";
static const char __pyx_k_appendleft[] = "appendleft";
static const char __pyx_k_base_terms[] = "base_terms";
static const char __pyx_k_comparison[] = "comparison";
static const char __pyx_k_expression[] = "expression";
static const char __pyx_k_pyD_not_in[] = "_pyD_not_in";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_setdefault[] = "setdefault";
static const char __pyx_k_startswith[] = "startswith";
static const char __pyx_k_Const_chase[] = "Const.chase";
static const char __pyx_k_Const_match[] = "Const.match";
static const char __pyx_k_Const_subst[] = "Const.subst";
static const char __pyx_k_Const_unify[] = "Const.unify";
static const char __pyx_k_Literal_ask[] = "Literal.ask";
static const char __pyx_k_NEXT_CLAUSE[] = "NEXT_CLAUSE";
static const char __pyx_k_Next_clause[] = "Next clause";
static const char __pyx_k_OrderedDict[] = "OrderedDict";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_Pred__class[] = "Pred._class";
static const char __pyx_k_Slow_motion[] = "Slow_motion";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_get_fact_id[] = "get_fact_id";
static const char __pyx_k_is_constant[] = "is_constant";
static const char __pyx_k_method_name[] = "method_name";
static const char __pyx_k_next_clause[] = "next_clause";
static const char __pyx_k_pyD_class_2[] = "_pyD_class";
static const char __pyx_k_subst_first[] = "subst_first";
static const char __pyx_k_variable__s[] = "variable_%s";
static const char __pyx_k_Clause_subst[] = "Clause.subst";
static const char __pyx_k_DatalogError[] = "DatalogError";
static const char __pyx_k_Processing_s[] = "Processing : %s";
static const char __pyx_k_Subgoal_fact[] = "Subgoal.fact";
static const char __pyx_k_Subgoal_rule[] = "Subgoal.rule";
static const char __pyx_k_base_literal[] = "base_literal";
static const char __pyx_k_intersection[] = "intersection";
static const char __pyx_k_isEnabledFor[] = "isEnabledFor";
static const char __pyx_k_parent_class[] = "parent_class";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_string_types[] = "string_types";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_use_setstate[] = "use_setstate";
static const char __pyx_k_Clause_get_id[] = "Clause.get_id";
static const char __pyx_k_Clause_rename[] = "Clause.rename";
static const char __pyx_k_Const_get_tag[] = "Const.get_tag";
static const char __pyx_k_Const_shuffle[] = "Const.shuffle";
static const char __pyx_k_Interned___eq[] = "Interned.__eq__";
static const char __pyx_k_Interned___ne[] = "Interned.__ne__";
static const char __pyx_k_Literal_match[] = "Literal.match";
static const char __pyx_k_Literal_subst[] = "Literal.subst";
static const char __pyx_k_Literal_unify[] = "Literal.unify";
static const char __pyx_k_ON_COMPLETION[] = "ON_COMPLETION";
static const char __pyx_k_On_completion[] = "On completion : ";
static const char __pyx_k_Pred_is_known[] = "Pred.is_known";
static const char __pyx_k_Pred_registry[] = "Pred_registry";
static const char __pyx_k_on_completion[] = "on_completion_";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_reset_clauses[] = "reset_clauses";
static const char __pyx_k_AttributeError[] = "AttributeError";
static const char __pyx_k_Const_is_const[] = "Const.is_const";
static const char __pyx_k_Literal_get_id[] = "Literal.get_id";
static const char __pyx_k_Subgoal_search[] = "Subgoal.search";
static const char __pyx_k_VarTuple_chase[] = "VarTuple.chase";
static const char __pyx_k_VarTuple_subst[] = "VarTuple.subst";
static const char __pyx_k_VarTuple_unify[] = "VarTuple.unify";
static const char __pyx_k_fact_candidate[] = "fact_candidate";
static const char __pyx_k_gc_uncollected[] = "gc_uncollected";
static const char __pyx_k_has_SQLAlchemy[] = "has_SQLAlchemy";
static const char __pyx_k_parent_classes[] = "parent_classes";
static const char __pyx_k_Fresh_var_chase[] = "Fresh_var.chase";
static const char __pyx_k_Fresh_var_match[] = "Fresh_var.match";
static const char __pyx_k_Fresh_var_subst[] = "Fresh_var.subst";
static const char __pyx_k_Fresh_var_unify[] = "Fresh_var.unify";
static const char __pyx_k_Interned___hash[] = "Interned.__hash__";
static const char __pyx_k_Literal_get_tag[] = "Literal.get_tag";
static const char __pyx_k_Literal_rebased[] = "Literal.rebased";
static const char __pyx_k_Literal_shuffle[] = "Literal.shuffle";
static const char __pyx_k_On_completion_2[] = "On completion";
static const char __pyx_k_Operation_chase[] = "Operation.chase";
static const char __pyx_k_Operation_subst[] = "Operation.subst";
static const char __pyx_k_Operation_unify[] = "Operation.unify";
static const char __pyx_k_RECURSIVE_STACK[] = "RECURSIVE STACK :";
static const char __pyx_k_Recursive_Tasks[] = "Recursive_Tasks";
static const char __pyx_k_on_completion_2[] = "on_completion";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_schedule_search[] = "schedule_search";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_Literal__renamed[] = "Literal._renamed";
static const char __pyx_k_Python_resolvers[] = "Python_resolvers";
static const char __pyx_k_Subgoal_complete[] = "Subgoal.complete";
static const char __pyx_k_Subgoal_schedule[] = "Subgoal.schedule";
static const char __pyx_k_VarTuple_get_tag[] = "VarTuple.get_tag";
static const char __pyx_k_VarTuple_shuffle[] = "VarTuple.shuffle";
static const char __pyx_k_equals_primitive[] = "equals_primitive";
static const char __pyx_k_pyDatalog_search[] = "pyDatalog_search";
static const char __pyx_k_pyx_unpickle_Var[] = "__pyx_unpickle_Var";
static const char __pyx_k_relevant_clauses[] = "relevant_clauses";
static const char __pyx_k_Already_completed[] = "Already completed !";
static const char __pyx_k_Fresh_var_get_tag[] = "Fresh_var.get_tag";
static const char __pyx_k_Fresh_var_shuffle[] = "Fresh_var.shuffle";
static const char __pyx_k_Literal_equalized[] = "Literal.equalized";
static const char __pyx_k_Operation_get_tag[] = "Operation.get_tag";
static const char __pyx_k_Operation_shuffle[] = "Operation.shuffle";
static const char __pyx_k_Subgoal_next_step[] = "Subgoal.next_step";
static const char __pyx_k_Subgoal_searching[] = "Subgoal.searching";
static const char __pyx_k_VarTuple_is_const[] = "VarTuple.is_const";
static const char __pyx_k_compare_primitive[] = "compare_primitive";
static const char __pyx_k_pyx_unpickle_Term[] = "__pyx_unpickle_Term";
static const char __pyx_k_saved_environment[] = "saved_environment";
static const char __pyx_k_Fresh_var_is_const[] = "Fresh_var.is_const";
static const char __pyx_k_New_fact_s_is_True[] = "New fact : %s is True";
static const char __pyx_k_Operation_is_const[] = "Operation.is_const";
static const char __pyx_k_Pred_reset_clauses[] = "Pred.reset_clauses";
static const char __pyx_k_Subgoal_add_clause[] = "Subgoal.add_clause";
static const char __pyx_k_ask_locals_genexpr[] = "ask.<locals>.genexpr";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_pyDatalog_pyEngine[] = "pyDatalog.pyEngine";
static const char __pyx_k_pyx_unpickle_Const[] = "__pyx_unpickle_Const";
static const char __pyx_k_Literal_get_fact_id[] = "Literal.get_fact_id";
static const char __pyx_k_Literal_subst_first[] = "Literal.subst_first";
static const char __pyx_k_Pred_parent_classes[] = "Pred.parent_classes";
static const char __pyx_k_Subgoal_next_clause[] = "Subgoal.next_clause";
static const char __pyx_k_Var___reduce_cython[] = "Var.__reduce_cython__";
static const char __pyx_k_WeakValueDictionary[] = "WeakValueDictionary";
static const char __pyx_k_pyx_unpickle_Clause[] = "__pyx_unpickle_Clause";
static const char __pyx_k_Term___reduce_cython[] = "Term.__reduce_cython__";
static const char __pyx_k_pyx_unpickle_Literal[] = "__pyx_unpickle_Literal";
static const char __pyx_k_pyx_unpickle_Subgoal[] = "__pyx_unpickle_Subgoal";
static const char __pyx_k_slice_to_variabilize[] = "slice_to_variabilize";
static const char __pyx_k_str___locals_genexpr[] = "__str__.<locals>.genexpr";
static const char __pyx_k_Const___reduce_cython[] = "Const.__reduce_cython__";
static const char __pyx_k_Moving_task_forward_s[] = "Moving task forward : %s";
static const char __pyx_k_Subgoal_on_completion[] = "Subgoal.on_completion";
static const char __pyx_k_Var___setstate_cython[] = "Var.__setstate_cython__";
static const char __pyx_k_get_id_locals_genexpr[] = "get_id.<locals>.genexpr";
static const char __pyx_k_init___locals_genexpr[] = "__init__.<locals>.genexpr";
static const char __pyx_k_pyDatalog_pyEngine_py[] = "pyDatalog/pyEngine.py";
static const char __pyx_k_pyx_unpickle_VarTuple[] = "__pyx_unpickle_VarTuple";
static const char __pyx_k_repr___locals_genexpr[] = "__repr__.<locals>.genexpr";
static const char __pyx_k_Clause___reduce_cython[] = "Clause.__reduce_cython__";
static const char __pyx_k_Const_equals_primitive[] = "Const.equals_primitive";
static const char __pyx_k_Subgoal_fact_candidate[] = "Subgoal.fact_candidate";
static const char __pyx_k_Term___setstate_cython[] = "Term.__setstate_cython__";
static const char __pyx_k_assert__locals_genexpr[] = "assert_.<locals>.genexpr";
static const char __pyx_k_pyx_unpickle_Fresh_var[] = "__pyx_unpickle_Fresh_var";
static const char __pyx_k_pyx_unpickle_Operation[] = "__pyx_unpickle_Operation";
static const char __pyx_k_Const___setstate_cython[] = "Const.__setstate_cython__";
static const char __pyx_k_Literal___reduce_cython[] = "Literal.__reduce_cython__";
static const char __pyx_k_Subgoal___reduce_cython[] = "Subgoal.__reduce_cython__";
static const char __pyx_k_Subgoal_schedule_search[] = "Subgoal.schedule_search";
static const char __pyx_k_Clause___setstate_cython[] = "Clause.__setstate_cython__";
static const char __pyx_k_VarTuple___reduce_cython[] = "VarTuple.__reduce_cython__";
static const char __pyx_k_searching_locals_genexpr[] = "searching.<locals>.genexpr";
static const char __pyx_k_Fresh_var___reduce_cython[] = "Fresh_var.__reduce_cython__";
static const char __pyx_k_Literal___setstate_cython[] = "Literal.__setstate_cython__";
static const char __pyx_k_Operation___reduce_cython[] = "Operation.__reduce_cython__";
static const char __pyx_k_Subgoal___setstate_cython[] = "Subgoal.__setstate_cython__";
static const char __pyx_k_VarTuple_equals_primitive[] = "VarTuple.equals_primitive";
static const char __pyx_k_Fresh_var_equals_primitive[] = "Fresh_var.equals_primitive";
static const char __pyx_k_VarTuple___setstate_cython[] = "VarTuple.__setstate_cython__";
static const char __pyx_k_Fresh_var___setstate_cython[] = "Fresh_var.__setstate_cython__";
static const char __pyx_k_Operation___setstate_cython[] = "Operation.__setstate_cython__";
static const char __pyx_k_pyDatalog_will_use_clause_s[] = "pyDatalog will use clause : %s";
static const char __pyx_k_This_file_is_part_of_pyDatalog[] = "\nThis file is part of pyDatalog, a datalog engine for python.\n\nCopyright (C) 2012 Pierre Carbonnelle\n\nThis library is free software; you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation; either version 2 of the\nLicense, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc.  51 Franklin St, Fifth Floor, Boston, MA 02110-1301\nUSA\n";
static const char __pyx_k_A_predicate_symbol_has_a_name_a[] = " A predicate symbol has a name, an arity, and a database table.  \n        It can also have a function used to implement a primitive.";
static const char __pyx_k_Abstract_class_for_objects_havi[] = " Abstract class for objects having only one instance in memory ";
static const char __pyx_k_Predicate_without_definition_or[] = "Predicate without definition (or error in resolver): %s";
static const char __pyx_k_pyDatalog_uses_pyDatalog_search[] = "pyDatalog uses pyDatalog_search for %s";
static const char __pyx_k_pyDatalog_uses_python_resolvers[] = "pyDatalog uses python resolvers for %s";
static const char __pyx_k_Error_left_hand_side_of_comparis[] = "Error: left hand side of comparison must be bound: %s";
static const char __pyx_k_Error_right_hand_side_must_be_bo[] = "Error: right hand side must be bound: %s";
static const char __pyx_k_Error_right_hand_side_of_compari[] = "Error: right hand side of comparison must be bound: %s";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))";
static const char __pyx_k_Processing_aggregate_or_negation[] = "Processing aggregate or negation";
static const char __pyx_k_pyDatalog_uses__pyD_query_resolv[] = "pyDatalog uses _pyD_query resolvers for %s";
static const char __pyx_k_pyDatalog_uses_aggregate_primiti[] = "pyDatalog uses aggregate primitive for %s";
static const char __pyx_k_pyDatalog_uses_class_resolvers_f[] = "pyDatalog uses class resolvers for %s";
static const char __pyx_k_pyDatalog_uses_comparison_primit[] = "pyDatalog uses comparison primitive for %s";
static const char __pyx_k_pyDatalog_will_search_negation_o[] = "pyDatalog will search negation of %s";
static const char __pyx_k_pyDatalog_will_use_clause_for_co[] = "pyDatalog will use clause for comparison: %s";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_2[] = "Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_3[] = "Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_4[] = "Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_5[] = "Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_6[] = "Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_40s;
static PyObject *__pyx_n_s_ADD_CLAUSE;
static PyObject *__pyx_kp_s_A_predicate_symbol_has_a_name_a;
static PyObject *__pyx_kp_s_Abstract_class_for_objects_havi;
static PyObject *__pyx_kp_s_Add_clause;
static PyObject *__pyx_kp_s_Add_s;
static PyObject *__pyx_kp_s_Already_completed;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_n_s_Auto_print;
static PyObject *__pyx_n_s_Class_dict;
static PyObject *__pyx_n_s_Clause;
static PyObject *__pyx_n_s_Clause___reduce_cython;
static PyObject *__pyx_n_s_Clause___setstate_cython;
static PyObject *__pyx_n_s_Clause_get_id;
static PyObject *__pyx_n_s_Clause_rename;
static PyObject *__pyx_n_s_Clause_subst;
static PyObject *__pyx_kp_s_Clauses_of;
static PyObject *__pyx_n_s_Const;
static PyObject *__pyx_n_s_Const___reduce_cython;
static PyObject *__pyx_n_s_Const___setstate_cython;
static PyObject *__pyx_n_s_Const_chase;
static PyObject *__pyx_n_s_Const_equals_primitive;
static PyObject *__pyx_n_s_Const_get_tag;
static PyObject *__pyx_n_s_Const_is_const;
static PyObject *__pyx_n_s_Const_match;
static PyObject *__pyx_n_s_Const_shuffle;
static PyObject *__pyx_n_s_Const_subst;
static PyObject *__pyx_n_s_Const_unify;
static PyObject *__pyx_n_s_Counter;
static PyObject *__pyx_n_s_DEBUG;
static PyObject *__pyx_n_s_DatalogError;
static PyObject *__pyx_n_s_Db;
static PyObject *__pyx_kp_s_Error_left_hand_side_of_comparis;
static PyObject *__pyx_kp_s_Error_right_hand_side_must_be_bo;
static PyObject *__pyx_kp_s_Error_right_hand_side_of_compari;
static PyObject *__pyx_kp_s_Facts_of;
static PyObject *__pyx_n_s_Fresh_var;
static PyObject *__pyx_n_s_Fresh_var___reduce_cython;
static PyObject *__pyx_n_s_Fresh_var___setstate_cython;
static PyObject *__pyx_n_s_Fresh_var_chase;
static PyObject *__pyx_n_s_Fresh_var_equals_primitive;
static PyObject *__pyx_n_s_Fresh_var_get_tag;
static PyObject *__pyx_n_s_Fresh_var_is_const;
static PyObject *__pyx_n_s_Fresh_var_match;
static PyObject *__pyx_n_s_Fresh_var_shuffle;
static PyObject *__pyx_n_s_Fresh_var_subst;
static PyObject *__pyx_n_s_Fresh_var_unify;
static PyObject *__pyx_n_s_Goal;
static PyObject *__pyx_n_s_INFO;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_4;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_5;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_6;
static PyObject *__pyx_n_s_Interned;
static PyObject *__pyx_n_s_Interned___eq;
static PyObject *__pyx_n_s_Interned___hash;
static PyObject *__pyx_n_s_Interned___ne;
static PyObject *__pyx_n_s_LAMBDA;
static PyObject *__pyx_n_s_Literal;
static PyObject *__pyx_n_s_Literal___reduce_cython;
static PyObject *__pyx_n_s_Literal___setstate_cython;
static PyObject *__pyx_n_s_Literal__renamed;
static PyObject *__pyx_n_s_Literal_ask;
static PyObject *__pyx_n_s_Literal_equalized;
static PyObject *__pyx_n_s_Literal_get_fact_id;
static PyObject *__pyx_n_s_Literal_get_id;
static PyObject *__pyx_n_s_Literal_get_tag;
static PyObject *__pyx_n_s_Literal_match;
static PyObject *__pyx_n_s_Literal_rebased;
static PyObject *__pyx_n_s_Literal_shuffle;
static PyObject *__pyx_n_s_Literal_subst;
static PyObject *__pyx_n_s_Literal_subst_first;
static PyObject *__pyx_n_s_Literal_unify;
static PyObject *__pyx_n_s_Logger;
static PyObject *__pyx_n_s_Logging;
static PyObject *__pyx_n_s_Logic;
static PyObject *__pyx_n_s_Mixin;
static PyObject *__pyx_kp_s_Moving_task_forward_s;
static PyObject *__pyx_n_s_NEXT_CLAUSE;
static PyObject *__pyx_kp_s_New_fact_s;
static PyObject *__pyx_kp_s_New_fact_s_is_True;
static PyObject *__pyx_kp_s_Next_clause;
static PyObject *__pyx_n_s_ON_COMPLETION;
static PyObject *__pyx_kp_s_On_completion;
static PyObject *__pyx_kp_s_On_completion_2;
static PyObject *__pyx_n_s_Operation;
static PyObject *__pyx_n_s_Operation___reduce_cython;
static PyObject *__pyx_n_s_Operation___setstate_cython;
static PyObject *__pyx_n_s_Operation_chase;
static PyObject *__pyx_n_s_Operation_get_tag;
static PyObject *__pyx_n_s_Operation_is_const;
static PyObject *__pyx_n_s_Operation_shuffle;
static PyObject *__pyx_n_s_Operation_subst;
static PyObject *__pyx_n_s_Operation_unify;
static PyObject *__pyx_n_s_OrderedDict;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_Pred;
static PyObject *__pyx_n_s_Pred___new;
static PyObject *__pyx_n_s_Pred___str;
static PyObject *__pyx_n_s_Pred__class;
static PyObject *__pyx_n_s_Pred_is_known;
static PyObject *__pyx_n_s_Pred_parent_classes;
static PyObject *__pyx_n_s_Pred_registry;
static PyObject *__pyx_n_s_Pred_reset_clauses;
static PyObject *__pyx_kp_s_Predicate_without_definition_or;
static PyObject *__pyx_kp_s_Processing_aggregate_or_negation;
static PyObject *__pyx_kp_s_Processing_s;
static PyObject *__pyx_n_s_Python_resolvers;
static PyObject *__pyx_kp_s_RECURSIVE_STACK;
static PyObject *__pyx_n_s_RLock;
static PyObject *__pyx_n_s_Recursive;
static PyObject *__pyx_n_s_Recursive_Tasks;
static PyObject *__pyx_n_s_SEARCH;
static PyObject *__pyx_n_s_SEARCHING;
static PyObject *__pyx_kp_s_STACK;
static PyObject *__pyx_n_s_Search;
static PyObject *__pyx_n_s_Searching;
static PyObject *__pyx_n_s_Slow_motion;
static PyObject *__pyx_n_s_Subgoal;
static PyObject *__pyx_n_s_Subgoal___reduce_cython;
static PyObject *__pyx_n_s_Subgoal___setstate_cython;
static PyObject *__pyx_n_s_Subgoal_add_clause;
static PyObject *__pyx_n_s_Subgoal_complete;
static PyObject *__pyx_n_s_Subgoal_fact;
static PyObject *__pyx_n_s_Subgoal_fact_candidate;
static PyObject *__pyx_n_s_Subgoal_next_clause;
static PyObject *__pyx_n_s_Subgoal_next_step;
static PyObject *__pyx_n_s_Subgoal_on_completion;
static PyObject *__pyx_n_s_Subgoal_rule;
static PyObject *__pyx_n_s_Subgoal_schedule;
static PyObject *__pyx_n_s_Subgoal_schedule_search;
static PyObject *__pyx_n_s_Subgoal_search;
static PyObject *__pyx_n_s_Subgoal_searching;
static PyObject *__pyx_n_s_Subgoals;
static PyObject *__pyx_n_s_Tasks;
static PyObject *__pyx_n_s_Term;
static PyObject *__pyx_n_s_Term___reduce_cython;
static PyObject *__pyx_n_s_Term___setstate_cython;
static PyObject *__pyx_n_s_Term_of;
static PyObject *__pyx_n_s_Ts;
static PyObject *__pyx_n_s_Var;
static PyObject *__pyx_n_s_VarTuple;
static PyObject *__pyx_n_s_VarTuple___reduce_cython;
static PyObject *__pyx_n_s_VarTuple___setstate_cython;
static PyObject *__pyx_n_s_VarTuple_chase;
static PyObject *__pyx_n_s_VarTuple_equals_primitive;
static PyObject *__pyx_n_s_VarTuple_get_tag;
static PyObject *__pyx_n_s_VarTuple_is_const;
static PyObject *__pyx_n_s_VarTuple_shuffle;
static PyObject *__pyx_n_s_VarTuple_subst;
static PyObject *__pyx_n_s_VarTuple_unify;
static PyObject *__pyx_n_s_Var___reduce_cython;
static PyObject *__pyx_n_s_Var___setstate_cython;
static PyObject *__pyx_n_s_Var_unify;
static PyObject *__pyx_n_s_WeakValueDictionary;
static PyObject *__pyx_n_s_Y1;
static PyObject *__pyx_kp_s__10;
static PyObject *__pyx_kp_s__11;
static PyObject *__pyx_kp_s__12;
static PyObject *__pyx_kp_s__13;
static PyObject *__pyx_kp_s__14;
static PyObject *__pyx_kp_s__16;
static PyObject *__pyx_kp_s__19;
static PyObject *__pyx_kp_s__2;
static PyObject *__pyx_kp_s__21;
static PyObject *__pyx_kp_s__22;
static PyObject *__pyx_kp_s__24;
static PyObject *__pyx_kp_s__27;
static PyObject *__pyx_kp_s__28;
static PyObject *__pyx_kp_s__29;
static PyObject *__pyx_kp_s__3;
static PyObject *__pyx_kp_s__33;
static PyObject *__pyx_kp_s__34;
static PyObject *__pyx_kp_s__35;
static PyObject *__pyx_kp_s__36;
static PyObject *__pyx_kp_s__37;
static PyObject *__pyx_kp_s__4;
static PyObject *__pyx_kp_s__5;
static PyObject *__pyx_kp_s__6;
static PyObject *__pyx_kp_s__7;
static PyObject *__pyx_kp_s__8;
static PyObject *__pyx_kp_s__9;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_add_class;
static PyObject *__pyx_n_s_add_clause;
static PyObject *__pyx_n_s_aggregate;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_appendleft;
static PyObject *__pyx_n_s_arg;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_arity;
static PyObject *__pyx_n_s_ask;
static PyObject *__pyx_n_s_ask_locals_genexpr;
static PyObject *__pyx_n_s_assert;
static PyObject *__pyx_n_s_assert__locals_genexpr;
static PyObject *__pyx_n_s_atom;
static PyObject *__pyx_n_s_base_literal;
static PyObject *__pyx_n_s_base_pred;
static PyObject *__pyx_n_s_base_terms;
static PyObject *__pyx_n_s_bodi;
static PyObject *__pyx_n_s_body;
static PyObject *__pyx_n_s_call;
static PyObject *__pyx_n_s_chase;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_class0;
static PyObject *__pyx_n_s_clause;
static PyObject *__pyx_n_s_clauses;
static PyObject *__pyx_n_s_clear;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_cls;
static PyObject *__pyx_n_s_cls_2;
static PyObject *__pyx_n_s_collect;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_compare;
static PyObject *__pyx_n_s_compare2;
static PyObject *__pyx_n_s_compare_primitive;
static PyObject *__pyx_n_s_comparison;
static PyObject *__pyx_n_s_complete;
static PyObject *__pyx_n_s_constant;
static PyObject *__pyx_n_s_counter;
static PyObject *__pyx_n_s_db;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_s_deque;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dict_2;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_env;
static PyObject *__pyx_n_s_eq;
static PyObject *__pyx_n_s_equalized;
static PyObject *__pyx_n_s_equals_primitive;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_n_s_expression;
static PyObject *__pyx_n_s_f;
static PyObject *__pyx_n_s_fact;
static PyObject *__pyx_n_s_fact_candidate;
static PyObject *__pyx_n_s_facts;
static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_gc;
static PyObject *__pyx_n_s_gc_uncollected;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_getLogger;
static PyObject *__pyx_n_s_get_fact_id;
static PyObject *__pyx_n_s_get_id;
static PyObject *__pyx_n_s_get_id_locals_genexpr;
static PyObject *__pyx_n_s_get_tag;
static PyObject *__pyx_n_s_getitem;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_has_SQLAlchemy;
static PyObject *__pyx_n_s_hash;
static PyObject *__pyx_n_s_head;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_id_2;
static PyObject *__pyx_n_s_id_3;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_in;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_info;
static PyObject *__pyx_n_s_init___locals_genexpr;
static PyObject *__pyx_n_s_insert;
static PyObject *__pyx_n_s_intersection;
static PyObject *__pyx_n_s_isEnabledFor;
static PyObject *__pyx_n_s_is_const;
static PyObject *__pyx_n_s_is_constant;
static PyObject *__pyx_kp_s_is_done;
static PyObject *__pyx_n_s_is_done_2;
static PyObject *__pyx_n_s_is_known;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_l;
static PyObject *__pyx_n_s_lhs;
static PyObject *__pyx_n_s_literal;
static PyObject *__pyx_n_s_literal0;
static PyObject *__pyx_n_s_literal1;
static PyObject *__pyx_n_s_literal2;
static PyObject *__pyx_n_s_local;
static PyObject *__pyx_n_s_lock;
static PyObject *__pyx_n_s_logging;
static PyObject *__pyx_n_s_logic;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_map;
static PyObject *__pyx_n_s_match;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_method_name;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_mro;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_ne;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_new_name;
static PyObject *__pyx_n_s_next;
static PyObject *__pyx_n_s_next_clause;
static PyObject *__pyx_n_s_next_step;
static PyObject *__pyx_n_s_notFound;
static PyObject *__pyx_n_s_not_in;
static PyObject *__pyx_n_s_o;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_on_completion;
static PyObject *__pyx_n_s_on_completion_2;
static PyObject *__pyx_n_s_op;
static PyObject *__pyx_n_s_operator;
static PyObject *__pyx_n_s_other;
static PyObject *__pyx_n_s_parent;
static PyObject *__pyx_n_s_parent_class;
static PyObject *__pyx_n_s_parent_classes;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_pos;
static PyObject *__pyx_n_s_prearity;
static PyObject *__pyx_n_s_pred;
static PyObject *__pyx_n_s_pred_id;
static PyObject *__pyx_n_s_pred_name;
static PyObject *__pyx_n_s_prefix;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_prim;
static PyObject *__pyx_n_s_print;
static PyObject *__pyx_kp_s_pyD__s_i;
static PyObject *__pyx_kp_s_pyD_class;
static PyObject *__pyx_n_s_pyD_class_2;
static PyObject *__pyx_n_s_pyD_in;
static PyObject *__pyx_n_s_pyD_not_in;
static PyObject *__pyx_n_s_pyD_query;
static PyObject *__pyx_n_s_pyDatalog_pyEngine;
static PyObject *__pyx_kp_s_pyDatalog_pyEngine_py;
static PyObject *__pyx_n_s_pyDatalog_search;
static PyObject *__pyx_kp_s_pyDatalog_uses__pyD_query_resolv;
static PyObject *__pyx_kp_s_pyDatalog_uses_aggregate_primiti;
static PyObject *__pyx_kp_s_pyDatalog_uses_class_resolvers_f;
static PyObject *__pyx_kp_s_pyDatalog_uses_comparison_primit;
static PyObject *__pyx_kp_s_pyDatalog_uses_pyDatalog_search;
static PyObject *__pyx_kp_s_pyDatalog_uses_python_resolvers;
static PyObject *__pyx_kp_s_pyDatalog_will_search_negation_o;
static PyObject *__pyx_kp_s_pyDatalog_will_use_clause_for_co;
static PyObject *__pyx_kp_s_pyDatalog_will_use_clause_s;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_Clause;
static PyObject *__pyx_n_s_pyx_unpickle_Const;
static PyObject *__pyx_n_s_pyx_unpickle_Fresh_var;
static PyObject *__pyx_n_s_pyx_unpickle_Literal;
static PyObject *__pyx_n_s_pyx_unpickle_Operation;
static PyObject *__pyx_n_s_pyx_unpickle_Subgoal;
static PyObject *__pyx_n_s_pyx_unpickle_Term;
static PyObject *__pyx_n_s_pyx_unpickle_Var;
static PyObject *__pyx_n_s_pyx_unpickle_VarTuple;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_r;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_re;
static PyObject *__pyx_n_s_rebased;
static PyObject *__pyx_n_s_recursive;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_relevant_clauses;
static PyObject *__pyx_n_s_remove;
static PyObject *__pyx_n_s_rename;
static PyObject *__pyx_n_s_renamed;
static PyObject *__pyx_n_s_renamed_2;
static PyObject *__pyx_n_s_replace;
static PyObject *__pyx_n_s_repr___locals_genexpr;
static PyObject *__pyx_n_s_reset_clauses;
static PyObject *__pyx_n_s_resolver;
static PyObject *__pyx_n_s_result;
static PyObject *__pyx_n_s_results;
static PyObject *__pyx_n_s_retract;
static PyObject *__pyx_n_s_reverse;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_n_s_rhs;
static PyObject *__pyx_n_s_rule;
static PyObject *__pyx_kp_s_s;
static PyObject *__pyx_kp_s_s_2;
static PyObject *__pyx_kp_s_s_i;
static PyObject *__pyx_kp_s_s_s;
static PyObject *__pyx_kp_s_s_s_2;
static PyObject *__pyx_kp_s_s_s_s;
static PyObject *__pyx_n_s_saved_environment;
static PyObject *__pyx_n_s_schedule;
static PyObject *__pyx_n_s_schedule_search;
static PyObject *__pyx_n_s_search;
static PyObject *__pyx_n_s_searching;
static PyObject *__pyx_n_s_searching_locals_genexpr;
static PyObject *__pyx_n_s_selected;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_setdefault;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_show;
static PyObject *__pyx_n_s_shuffle;
static PyObject *__pyx_n_s_slice_to_variabilize;
static PyObject *__pyx_n_s_slots;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_startswith;
static PyObject *__pyx_n_s_state;
static PyObject *__pyx_n_s_str;
static PyObject *__pyx_n_s_str___locals_genexpr;
static PyObject *__pyx_n_s_string_types;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_sub;
static PyObject *__pyx_n_s_subgoal;
static PyObject *__pyx_n_s_subst;
static PyObject *__pyx_n_s_subst_first;
static PyObject *__pyx_n_s_suffix;
static PyObject *__pyx_n_s_tag;
static PyObject *__pyx_n_s_task;
static PyObject *__pyx_n_s_task2;
static PyObject *__pyx_n_s_tasks;
static PyObject *__pyx_n_s_term;
static PyObject *__pyx_n_s_terms;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_threading;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_tl;
static PyObject *__pyx_n_s_todo;
static PyObject *__pyx_n_s_unify;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_use_setstate;
static PyObject *__pyx_n_s_util;
static PyObject *__pyx_n_s_v;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_kp_s_variable__s;
static PyObject *__pyx_n_s_waiters;
static PyObject *__pyx_n_s_weakref;
static PyObject *__pyx_n_s_words;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_xrange;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_Term_of(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_atom); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Term_2id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_4Term_2id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_4Term_2id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Term___reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Term_2__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_4get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_6subst(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_8shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_10chase(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_12match(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_14unify(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_16__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_18equals_primitive(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_term, CYTHON_UNUSED PyObject *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_20__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_22__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_3Var___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_2__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_4unify(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_6__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_8__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_5Const___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v__id); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_4get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_6subst(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_8shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_10chase(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_12match(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_14unify(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_16__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_18equals_primitive(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_term, PyObject *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_20__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_22__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8__init___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8__init___3genexpr(PyObject *__pyx_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple___init__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v__id); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_4__len__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_6get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8subst(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_10shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_12chase(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_14unify(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_16__str__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_18equals_primitive(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_term, PyObject *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant___get__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_20__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_22__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_operator, PyObject *__pyx_v_rhs); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_4get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_6subst(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_8shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_10chase(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_12unify(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_14__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_16__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_18__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8Interned___eq__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8Interned_2__hash__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8Interned_4__ne__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_pred_name, PyObject *__pyx_v_arity); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_2is_known(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_pred_id); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_4_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_6parent_classes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_9reset_clauses(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_11__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_pred, PyObject *__pyx_v_terms, PyObject *__pyx_v_prearity, PyObject *__pyx_v_aggregate); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_2_renamed(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_new_name); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_4rebased(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_parent_class); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_6equalized(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_8subst_first(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_10__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_12get_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_14get_fact_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_16get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_18subst(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_20shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_22unify(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_24match(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_terms); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_3ask_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_26ask(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_2id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_28__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_30__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_head, PyObject *__pyx_v_body); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_7__str___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_2__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_8__repr___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_4__repr__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_6__neg__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_6get_id_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_8get_id(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_10subst(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_env, PyObject *__pyx_v_parent_class); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_12rename(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_4head___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_4body___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_2id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_14__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_16__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_2add_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4insert(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pred); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6remove(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pred); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7assert__genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8assert_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_clause); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_10retract(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_clause); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_12relevant_clauses(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_literal); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_literal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_2__repr__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_4search(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_6add_clause(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_clause); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_8fact(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_literal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_10fact_candidate(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_class0, PyObject *__pyx_v_result); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_12rule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_clause, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_selected); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14schedule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_task); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_16schedule_search(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_18next_step(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_20next_clause(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9searching_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_22searching(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_24complete(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal, PyObject *__pyx_v_aggregate); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_26on_completion(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_parent, PyObject *__pyx_v_aggregate); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion____get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion__2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion__4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_28__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_30__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_15show(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_task); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_17equals_primitive(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_literal, PyObject *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_19compare_primitive(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_literal, PyObject *__pyx_v_subgoal); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_21compare(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_l, PyObject *__pyx_v_op, PyObject *__pyx_v_r); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_23compare2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_l, PyObject *__pyx_v_op, PyObject *__pyx_v_r); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_25clear(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_27__pyx_unpickle_Term(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_29__pyx_unpickle_Fresh_var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_31__pyx_unpickle_Var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_33__pyx_unpickle_Const(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_35__pyx_unpickle_VarTuple(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_37__pyx_unpickle_Operation(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_39__pyx_unpickle_Literal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_41__pyx_unpickle_Clause(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_9pyDatalog_8pyEngine_43__pyx_unpickle_Subgoal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Term(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Fresh_var(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Var(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Const(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_VarTuple(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Operation(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Literal(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Clause(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Subgoal(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct____init__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_setdefault = {0, &__pyx_n_s_setdefault, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_40;
static PyObject *__pyx_int_110;
static PyObject *__pyx_int_23793036;
static PyObject *__pyx_int_25690925;
static PyObject *__pyx_int_46030840;
static PyObject *__pyx_int_50874197;
static PyObject *__pyx_int_53105071;
static PyObject *__pyx_int_124008633;
static PyObject *__pyx_int_128353530;
static PyObject *__pyx_int_142517727;
static PyObject *__pyx_int_149462077;
static PyObject *__pyx_int_161349669;
static PyObject *__pyx_int_165197223;
static PyObject *__pyx_int_173413458;
static PyObject *__pyx_int_192985975;
static PyObject *__pyx_int_220575563;
static PyObject *__pyx_int_228449516;
static PyObject *__pyx_int_228639504;
static PyObject *__pyx_int_239816442;
static PyObject *__pyx_int_248641737;
static PyObject *__pyx_slice__20;
static PyObject *__pyx_slice__31;
static PyObject *__pyx_slice__32;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__136;
static PyObject *__pyx_tuple__138;
static PyObject *__pyx_tuple__139;
static PyObject *__pyx_tuple__141;
static PyObject *__pyx_tuple__143;
static PyObject *__pyx_tuple__145;
static PyObject *__pyx_tuple__147;
static PyObject *__pyx_tuple__149;
static PyObject *__pyx_tuple__151;
static PyObject *__pyx_tuple__152;
static PyObject *__pyx_tuple__154;
static PyObject *__pyx_tuple__156;
static PyObject *__pyx_tuple__158;
static PyObject *__pyx_tuple__160;
static PyObject *__pyx_tuple__162;
static PyObject *__pyx_tuple__164;
static PyObject *__pyx_tuple__166;
static PyObject *__pyx_tuple__168;
static PyObject *__pyx_tuple__170;
static PyObject *__pyx_tuple__172;
static PyObject *__pyx_tuple__174;
static PyObject *__pyx_tuple__176;
static PyObject *__pyx_tuple__178;
static PyObject *__pyx_tuple__180;
static PyObject *__pyx_tuple__182;
static PyObject *__pyx_tuple__184;
static PyObject *__pyx_tuple__186;
static PyObject *__pyx_tuple__188;
static PyObject *__pyx_tuple__190;
static PyObject *__pyx_tuple__192;
static PyObject *__pyx_tuple__194;
static PyObject *__pyx_tuple__196;
static PyObject *__pyx_tuple__198;
static PyObject *__pyx_tuple__200;
static PyObject *__pyx_tuple__202;
static PyObject *__pyx_tuple__204;
static PyObject *__pyx_tuple__205;
static PyObject *__pyx_tuple__207;
static PyObject *__pyx_tuple__209;
static PyObject *__pyx_tuple__211;
static PyObject *__pyx_tuple__213;
static PyObject *__pyx_tuple__215;
static PyObject *__pyx_tuple__217;
static PyObject *__pyx_tuple__219;
static PyObject *__pyx_tuple__221;
static PyObject *__pyx_tuple__223;
static PyObject *__pyx_tuple__225;
static PyObject *__pyx_tuple__227;
static PyObject *__pyx_tuple__229;
static PyObject *__pyx_tuple__231;
static PyObject *__pyx_tuple__233;
static PyObject *__pyx_tuple__235;
static PyObject *__pyx_tuple__237;
static PyObject *__pyx_tuple__239;
static PyObject *__pyx_tuple__241;
static PyObject *__pyx_tuple__244;
static PyObject *__pyx_tuple__246;
static PyObject *__pyx_tuple__248;
static PyObject *__pyx_tuple__250;
static PyObject *__pyx_tuple__252;
static PyObject *__pyx_tuple__254;
static PyObject *__pyx_tuple__256;
static PyObject *__pyx_tuple__258;
static PyObject *__pyx_tuple__260;
static PyObject *__pyx_codeobj__18;
static PyObject *__pyx_codeobj__26;
static PyObject *__pyx_codeobj__53;
static PyObject *__pyx_codeobj__55;
static PyObject *__pyx_codeobj__57;
static PyObject *__pyx_codeobj__59;
static PyObject *__pyx_codeobj__61;
static PyObject *__pyx_codeobj__63;
static PyObject *__pyx_codeobj__65;
static PyObject *__pyx_codeobj__67;
static PyObject *__pyx_codeobj__69;
static PyObject *__pyx_codeobj__71;
static PyObject *__pyx_codeobj__73;
static PyObject *__pyx_codeobj__75;
static PyObject *__pyx_codeobj__77;
static PyObject *__pyx_codeobj__79;
static PyObject *__pyx_codeobj__81;
static PyObject *__pyx_codeobj__83;
static PyObject *__pyx_codeobj__85;
static PyObject *__pyx_codeobj__87;
static PyObject *__pyx_codeobj__89;
static PyObject *__pyx_codeobj__91;
static PyObject *__pyx_codeobj__93;
static PyObject *__pyx_codeobj__95;
static PyObject *__pyx_codeobj__97;
static PyObject *__pyx_codeobj__99;
static PyObject *__pyx_codeobj__101;
static PyObject *__pyx_codeobj__103;
static PyObject *__pyx_codeobj__105;
static PyObject *__pyx_codeobj__107;
static PyObject *__pyx_codeobj__109;
static PyObject *__pyx_codeobj__111;
static PyObject *__pyx_codeobj__113;
static PyObject *__pyx_codeobj__115;
static PyObject *__pyx_codeobj__117;
static PyObject *__pyx_codeobj__119;
static PyObject *__pyx_codeobj__121;
static PyObject *__pyx_codeobj__123;
static PyObject *__pyx_codeobj__125;
static PyObject *__pyx_codeobj__127;
static PyObject *__pyx_codeobj__129;
static PyObject *__pyx_codeobj__131;
static PyObject *__pyx_codeobj__133;
static PyObject *__pyx_codeobj__135;
static PyObject *__pyx_codeobj__137;
static PyObject *__pyx_codeobj__140;
static PyObject *__pyx_codeobj__142;
static PyObject *__pyx_codeobj__144;
static PyObject *__pyx_codeobj__146;
static PyObject *__pyx_codeobj__148;
static PyObject *__pyx_codeobj__150;
static PyObject *__pyx_codeobj__153;
static PyObject *__pyx_codeobj__155;
static PyObject *__pyx_codeobj__157;
static PyObject *__pyx_codeobj__159;
static PyObject *__pyx_codeobj__161;
static PyObject *__pyx_codeobj__163;
static PyObject *__pyx_codeobj__165;
static PyObject *__pyx_codeobj__167;
static PyObject *__pyx_codeobj__169;
static PyObject *__pyx_codeobj__171;
static PyObject *__pyx_codeobj__173;
static PyObject *__pyx_codeobj__175;
static PyObject *__pyx_codeobj__177;
static PyObject *__pyx_codeobj__179;
static PyObject *__pyx_codeobj__181;
static PyObject *__pyx_codeobj__183;
static PyObject *__pyx_codeobj__185;
static PyObject *__pyx_codeobj__187;
static PyObject *__pyx_codeobj__189;
static PyObject *__pyx_codeobj__191;
static PyObject *__pyx_codeobj__193;
static PyObject *__pyx_codeobj__195;
static PyObject *__pyx_codeobj__197;
static PyObject *__pyx_codeobj__199;
static PyObject *__pyx_codeobj__201;
static PyObject *__pyx_codeobj__203;
static PyObject *__pyx_codeobj__206;
static PyObject *__pyx_codeobj__208;
static PyObject *__pyx_codeobj__210;
static PyObject *__pyx_codeobj__212;
static PyObject *__pyx_codeobj__214;
static PyObject *__pyx_codeobj__216;
static PyObject *__pyx_codeobj__218;
static PyObject *__pyx_codeobj__220;
static PyObject *__pyx_codeobj__222;
static PyObject *__pyx_codeobj__224;
static PyObject *__pyx_codeobj__226;
static PyObject *__pyx_codeobj__228;
static PyObject *__pyx_codeobj__230;
static PyObject *__pyx_codeobj__232;
static PyObject *__pyx_codeobj__234;
static PyObject *__pyx_codeobj__236;
static PyObject *__pyx_codeobj__238;
static PyObject *__pyx_codeobj__240;
static PyObject *__pyx_codeobj__242;
static PyObject *__pyx_codeobj__243;
static PyObject *__pyx_codeobj__245;
static PyObject *__pyx_codeobj__247;
static PyObject *__pyx_codeobj__249;
static PyObject *__pyx_codeobj__251;
static PyObject *__pyx_codeobj__253;
static PyObject *__pyx_codeobj__255;
static PyObject *__pyx_codeobj__257;
static PyObject *__pyx_codeobj__259;
static PyObject *__pyx_codeobj__261;
/* Late includes */

/* "pyDatalog/pyEngine.py":53
 * #       DATA TYPES          #####################################
 * 
 * def Term_of(atom):             # <<<<<<<<<<<<<<
 *     """ factory function for Term """
 *     if isinstance(atom, Term):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_1Term_of(PyObject *__pyx_self, PyObject *__pyx_v_atom); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_Term_of[] = " factory function for Term ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_1Term_of = {"Term_of", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_1Term_of, METH_O, __pyx_doc_9pyDatalog_8pyEngine_Term_of};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_1Term_of(PyObject *__pyx_self, PyObject *__pyx_v_atom) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("Term_of (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_Term_of(__pyx_self, ((PyObject *)__pyx_v_atom));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_Term_of(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_atom) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("Term_of", 0);

  /* "pyDatalog/pyEngine.py":55
 * def Term_of(atom):
 *     """ factory function for Term """
 *     if isinstance(atom, Term):             # <<<<<<<<<<<<<<
 *         return atom
 *     elif isinstance(atom, (list, tuple, util.xrange)):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_atom, __pyx_ptype_9pyDatalog_8pyEngine_Term); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":56
 *     """ factory function for Term """
 *     if isinstance(atom, Term):
 *         return atom             # <<<<<<<<<<<<<<
 *     elif isinstance(atom, (list, tuple, util.xrange)):
 *         return VarTuple(tuple(map(Term_of, atom)))
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_atom);
    __pyx_r = __pyx_v_atom;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":55
 * def Term_of(atom):
 *     """ factory function for Term """
 *     if isinstance(atom, Term):             # <<<<<<<<<<<<<<
 *         return atom
 *     elif isinstance(atom, (list, tuple, util.xrange)):
 */
  }

  /* "pyDatalog/pyEngine.py":57
 *     if isinstance(atom, Term):
 *         return atom
 *     elif isinstance(atom, (list, tuple, util.xrange)):             # <<<<<<<<<<<<<<
 *         return VarTuple(tuple(map(Term_of, atom)))
 *     else:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_util); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_xrange); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = PyList_Check(__pyx_v_atom); 
  __pyx_t_5 = (__pyx_t_1 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = PyTuple_Check(__pyx_v_atom); 
  __pyx_t_1 = (__pyx_t_5 != 0);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = PyObject_IsInstance(__pyx_v_atom, __pyx_t_4); 
  __pyx_t_5 = (__pyx_t_1 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = (__pyx_t_2 != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":58
 *         return atom
 *     elif isinstance(atom, (list, tuple, util.xrange)):
 *         return VarTuple(tuple(map(Term_of, atom)))             # <<<<<<<<<<<<<<
 *     else:
 *         return Const(atom)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_atom);
    __Pyx_GIVEREF(__pyx_v_atom);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_atom);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":57
 *     if isinstance(atom, Term):
 *         return atom
 *     elif isinstance(atom, (list, tuple, util.xrange)):             # <<<<<<<<<<<<<<
 *         return VarTuple(tuple(map(Term_of, atom)))
 *     else:
 */
  }

  /* "pyDatalog/pyEngine.py":60
 *         return VarTuple(tuple(map(Term_of, atom)))
 *     else:
 *         return Const(atom)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const), __pyx_v_atom); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":53
 * #       DATA TYPES          #####################################
 * 
 * def Term_of(atom):             # <<<<<<<<<<<<<<
 *     """ factory function for Term """
 *     if isinstance(atom, Term):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Term_of", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":6
 * 
 * cdef class Term(object):
 *     cdef public object id             # <<<<<<<<<<<<<<
 * 
 * cdef class Fresh_var(Term):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Term_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Term_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Term_2id___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Term_2id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->id);
  __pyx_r = __pyx_v_self->id;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Term_2id_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_4Term_2id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Term_2id_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_4Term_2id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Term_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Term_1__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Term_1__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Term_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Term___reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Term___reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.id,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->id);
  __Pyx_GIVEREF(__pyx_v_self->id);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->id);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.id is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.id is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->id != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.id is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Term); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, None), state
 *     else:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Term__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Term); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Term.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Term__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Term_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Term_3__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Term_3__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Term_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Term_2__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Term_2__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Term__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Term__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Term__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Term.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":72
 *     __slots__ = ['id']
 *     tl = threading.local()
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         Fresh_var.tl.counter = Fresh_var.tl.counter +1
 *         self.id = ('f', Fresh_var.tl.counter) #id
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":73
 *     tl = threading.local()
 *     def __init__(self):
 *         Fresh_var.tl.counter = Fresh_var.tl.counter +1             # <<<<<<<<<<<<<<
 *         self.id = ('f', Fresh_var.tl.counter) #id
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var), __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_counter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var), __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_counter, __pyx_t_1) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":74
 *     def __init__(self):
 *         Fresh_var.tl.counter = Fresh_var.tl.counter +1
 *         self.id = ('f', Fresh_var.tl.counter) #id             # <<<<<<<<<<<<<<
 * 
 *     def is_const(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var), __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_f);
  __Pyx_GIVEREF(__pyx_n_s_f);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_f);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.id);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.id);
  __pyx_v_self->__pyx_base.id = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":72
 *     __slots__ = ['id']
 *     tl = threading.local()
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         Fresh_var.tl.counter = Fresh_var.tl.counter +1
 *         self.id = ('f', Fresh_var.tl.counter) #id
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":76
 *         self.id = ('f', Fresh_var.tl.counter) #id
 * 
 *     def is_const(self):             # <<<<<<<<<<<<<<
 *         return False
 *     def get_tag(self, env): #id
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_is_const(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, int __pyx_skip_dispatch) {
  PyBoolObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_3is_const)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 76, __pyx_L1_error)
        __pyx_r = ((PyBoolObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":77
 * 
 *     def is_const(self):
 *         return False             # <<<<<<<<<<<<<<
 *     def get_tag(self, env): #id
 *         return env.setdefault(self.id, ('v', len(env)))
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(Py_False);
  __pyx_r = ((PyBoolObject *)Py_False);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":76
 *         self.id = ('f', Fresh_var.tl.counter) #id
 * 
 *     def is_const(self):             # <<<<<<<<<<<<<<
 *         return False
 *     def get_tag(self, env): #id
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_3is_const = {"is_const", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_3is_const, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_const (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_2is_const(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_is_const(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":78
 *     def is_const(self):
 *         return False
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_5get_tag)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":79
 *         return False
 *     def get_tag(self, env): #id
 *         return env.setdefault(self.id, ('v', len(env)))             # <<<<<<<<<<<<<<
 * 
 *     def subst(self, env): #unify
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 79, __pyx_L1_error)
  }
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 79, __pyx_L1_error)
  }
  __pyx_t_5 = PyDict_Size(__pyx_v_env); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 79, __pyx_L1_error)
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_v);
  __Pyx_GIVEREF(__pyx_n_s_v);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_v);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_SetDefault(__pyx_v_env, __pyx_v_self->__pyx_base.id, __pyx_t_2, -1L); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":78
 *     def is_const(self):
 *         return False
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_5get_tag = {"get_tag", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_5get_tag, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tag (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 78, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_4get_tag(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_4get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_9Fresh_var_get_tag(__pyx_v_self, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":81
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_7subst)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 81, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":82
 * 
 *     def subst(self, env): #unify
 *         return env.get(self.id, self)             # <<<<<<<<<<<<<<
 *     def shuffle(self, env): #shuffle
 *         return env.setdefault(self.id, Fresh_var())
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 82, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_env, __pyx_v_self->__pyx_base.id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 82, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":81
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_7subst = {"subst", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_7subst, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 81, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_6subst(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_6subst(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_subst(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":83
 *     def subst(self, env): #unify
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shuffle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_9shuffle)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 83, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":84
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle
 *         return env.setdefault(self.id, Fresh_var())             # <<<<<<<<<<<<<<
 *     def chase(self, env): #unify
 *         # try ... except is not faster
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 84, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_env, __pyx_v_self->__pyx_base.id, __pyx_t_1, -1L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 84, __pyx_L1_error)
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":83
 *     def subst(self, env): #unify
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_9shuffle = {"shuffle", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_9shuffle, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("shuffle (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 83, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_8shuffle(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_8shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_shuffle(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":85
 *     def shuffle(self, env): #shuffle
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         # try ... except is not faster
 *         return env[self.id].chase(env) if self.id in env else self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_chase(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_11chase)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 85, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":87
 *     def chase(self, env): #unify
 *         # try ... except is not faster
 *         return env[self.id].chase(env) if self.id in env else self             # <<<<<<<<<<<<<<
 * 
 *     def match(self, constant, env):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 87, __pyx_L1_error)
  }
  __pyx_t_5 = (__Pyx_PyDict_ContainsTF(__pyx_v_self->__pyx_base.id, __pyx_v_env, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 87, __pyx_L1_error)
  if ((__pyx_t_5 != 0)) {
    if (unlikely(__pyx_v_env == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 87, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_env, __pyx_v_self->__pyx_base.id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_chase); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 87, __pyx_L1_error)
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  } else {
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_t_1 = ((PyObject *)__pyx_v_self);
  }
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":85
 *     def shuffle(self, env): #shuffle
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         # try ... except is not faster
 *         return env[self.id].chase(env) if self.id in env else self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_11chase = {"chase", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_11chase, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("chase (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 85, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_10chase(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_10chase(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_chase(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":89
 *         return env[self.id].chase(env) if self.id in env else self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         if self.id not in env:
 *             env[self.id] = constant
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_13match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_match(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("match", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_match); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_13match)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_constant), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_constant), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 89, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_constant));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_constant));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_constant));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 89, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":90
 * 
 *     def match(self, constant, env):
 *         if self.id not in env:             # <<<<<<<<<<<<<<
 *             env[self.id] = constant
 *             return env
 */
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 90, __pyx_L1_error)
  }
  __pyx_t_7 = (__Pyx_PyDict_ContainsTF(__pyx_v_self->__pyx_base.id, __pyx_v_env, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 90, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":91
 *     def match(self, constant, env):
 *         if self.id not in env:
 *             env[self.id] = constant             # <<<<<<<<<<<<<<
 *             return env
 *         elif env[self.id] == constant: # dead code ?
 */
    if (unlikely(__pyx_v_env == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 91, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_env, __pyx_v_self->__pyx_base.id, ((PyObject *)__pyx_v_constant)) < 0)) __PYX_ERR(0, 91, __pyx_L1_error)

    /* "pyDatalog/pyEngine.py":92
 *         if self.id not in env:
 *             env[self.id] = constant
 *             return env             # <<<<<<<<<<<<<<
 *         elif env[self.id] == constant: # dead code ?
 *             return env
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":90
 * 
 *     def match(self, constant, env):
 *         if self.id not in env:             # <<<<<<<<<<<<<<
 *             env[self.id] = constant
 *             return env
 */
  }

  /* "pyDatalog/pyEngine.py":93
 *             env[self.id] = constant
 *             return env
 *         elif env[self.id] == constant: # dead code ?             # <<<<<<<<<<<<<<
 *             return env
 *         else: # dead code ?
 */
  if (unlikely(__pyx_v_env == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 93, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_env, __pyx_v_self->__pyx_base.id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_v_constant), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 93, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":94
 *             return env
 *         elif env[self.id] == constant: # dead code ?
 *             return env             # <<<<<<<<<<<<<<
 *         else: # dead code ?
 *             return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":93
 *             env[self.id] = constant
 *             return env
 *         elif env[self.id] == constant: # dead code ?             # <<<<<<<<<<<<<<
 *             return env
 *         else: # dead code ?
 */
  }

  /* "pyDatalog/pyEngine.py":96
 *             return env
 *         else: # dead code ?
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     def unify(self, term, env):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":89
 *         return env[self.id].chase(env) if self.id in env else self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         if self.id not in env:
 *             env[self.id] = constant
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_13match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_13match = {"match", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_13match, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_13match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("match (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_constant,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_constant)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("match", 1, 2, 2, 1); __PYX_ERR(0, 89, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "match") < 0)) __PYX_ERR(0, 89, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_constant = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("match", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 89, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_constant), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "constant", 0))) __PYX_ERR(0, 89, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 89, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_12match(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), __pyx_v_constant, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_12match(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("match", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_9Fresh_var_match(__pyx_v_self, __pyx_v_constant, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":98
 *             return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_15unify)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 98, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_term));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_term));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_term));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 98, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":99
 * 
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):             # <<<<<<<<<<<<<<
 *             env[term.id] = self
 *             return env
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Fresh_var); 
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":100
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self             # <<<<<<<<<<<<<<
 *             return env
 *         if isinstance(term, (Const, VarTuple)):
 */
    if (unlikely(__pyx_v_env == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 100, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_env, __pyx_v_term->id, ((PyObject *)__pyx_v_self)) < 0)) __PYX_ERR(0, 100, __pyx_L1_error)

    /* "pyDatalog/pyEngine.py":101
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 *             return env             # <<<<<<<<<<<<<<
 *         if isinstance(term, (Const, VarTuple)):
 *             env[self.id] = term
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":99
 * 
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):             # <<<<<<<<<<<<<<
 *             env[term.id] = self
 *             return env
 */
  }

  /* "pyDatalog/pyEngine.py":102
 *             env[term.id] = self
 *             return env
 *         if isinstance(term, (Const, VarTuple)):             # <<<<<<<<<<<<<<
 *             env[self.id] = term
 *             return env
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Const); 
  __pyx_t_9 = (__pyx_t_7 != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_9 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
  __pyx_t_7 = (__pyx_t_9 != 0);
  __pyx_t_8 = __pyx_t_7;
  __pyx_L5_bool_binop_done:;
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "pyDatalog/pyEngine.py":103
 *             return env
 *         if isinstance(term, (Const, VarTuple)):
 *             env[self.id] = term             # <<<<<<<<<<<<<<
 *             return env
 *         if isinstance(term, Operation):
 */
    if (unlikely(__pyx_v_env == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 103, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_env, __pyx_v_self->__pyx_base.id, ((PyObject *)__pyx_v_term)) < 0)) __PYX_ERR(0, 103, __pyx_L1_error)

    /* "pyDatalog/pyEngine.py":104
 *         if isinstance(term, (Const, VarTuple)):
 *             env[self.id] = term
 *             return env             # <<<<<<<<<<<<<<
 *         if isinstance(term, Operation):
 *             return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":102
 *             env[term.id] = self
 *             return env
 *         if isinstance(term, (Const, VarTuple)):             # <<<<<<<<<<<<<<
 *             env[self.id] = term
 *             return env
 */
  }

  /* "pyDatalog/pyEngine.py":105
 *             env[self.id] = term
 *             return env
 *         if isinstance(term, Operation):             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Operation); 
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":106
 *             return env
 *         if isinstance(term, Operation):
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":105
 *             env[self.id] = term
 *             return env
 *         if isinstance(term, Operation):             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  }

  /* "pyDatalog/pyEngine.py":98
 *             return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */

  /* function exit code */
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_15unify = {"unify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_15unify, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unify (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, 1); __PYX_ERR(0, 98, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "unify") < 0)) __PYX_ERR(0, 98, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 98, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "term", 0))) __PYX_ERR(0, 98, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 98, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_14unify(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), __pyx_v_term, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_14unify(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_9Fresh_var_unify(__pyx_v_self, __pyx_v_term, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":108
 *             return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "variable_%s" % self.id[1]
 *     def equals_primitive(self, term, subgoal):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_17__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_17__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_16__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_16__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":109
 * 
 *     def __str__(self):
 *         return "variable_%s" % self.id[1]             # <<<<<<<<<<<<<<
 *     def equals_primitive(self, term, subgoal):
 *         """ by default, self==term fails """
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->__pyx_base.id, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_variable__s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":108
 *             return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "variable_%s" % self.id[1]
 *     def equals_primitive(self, term, subgoal):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":110
 *     def __str__(self):
 *         return "variable_%s" % self.id[1]
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         """ by default, self==term fails """
 *         return None
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_19equals_primitive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_9Fresh_var_18equals_primitive[] = " by default, self==term fails ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_19equals_primitive = {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_19equals_primitive, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_9Fresh_var_18equals_primitive};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_19equals_primitive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_term = 0;
  CYTHON_UNUSED PyObject *__pyx_v_subgoal = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equals_primitive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_subgoal,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subgoal)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, 1); __PYX_ERR(0, 110, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "equals_primitive") < 0)) __PYX_ERR(0, 110, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = values[0];
    __pyx_v_subgoal = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 110, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_18equals_primitive(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), __pyx_v_term, __pyx_v_subgoal);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_18equals_primitive(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_term, CYTHON_UNUSED PyObject *__pyx_v_subgoal) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equals_primitive", 0);

  /* "pyDatalog/pyEngine.py":112
 *     def equals_primitive(self, term, subgoal):
 *         """ by default, self==term fails """
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":110
 *     def __str__(self):
 *         return "variable_%s" % self.id[1]
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         """ by default, self==term fails """
 *         return None
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_21__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_21__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_20__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_20__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.id,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.id);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.id);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->__pyx_base.id);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.id is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.id is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->__pyx_base.id != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.id is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Fresh_var); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, None), state
 *     else:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Fresh_var__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Fresh_var); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Fresh_var__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_23__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_23__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_22__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Fresh_var_22__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Fresh_var__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Fresh_var__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Fresh_var__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Fresh_var.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":118
 *     """ A variable in a clause or query """
 *     __slots__ = ['id']
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.id = ('f', name) #id
 * 
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_3Var_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_3Var_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 118, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_name = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 118, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_3Var___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_v_self), __pyx_v_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_3Var___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, PyObject *__pyx_v_name) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":119
 *     __slots__ = ['id']
 *     def __init__(self, name):
 *         self.id = ('f', name) #id             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_f);
  __Pyx_GIVEREF(__pyx_n_s_f);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_f);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_name);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.id);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.id);
  __pyx_v_self->__pyx_base.__pyx_base.id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":118
 *     """ A variable in a clause or query """
 *     __slots__ = ['id']
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.id = ('f', name) #id
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":121
 *         self.id = ('f', name) #id
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self.id[1]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_3__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_3Var_2__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_2__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":122
 * 
 *     def __str__(self):
 *         return self.id[1]             # <<<<<<<<<<<<<<
 * 
 *     def unify(self, term, env):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->__pyx_base.__pyx_base.id, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":121
 *         self.id = ('f', name) #id
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self.id[1]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":124
 *         return self.id[1]
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return Fresh_var.unify(self, term, env)
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_5unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_3Var_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_3Var_5unify)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_term));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_term));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_term));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 124, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":125
 * 
 *     def unify(self, term, env):
 *         return Fresh_var.unify(self, term, env)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_9Fresh_var_unify(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v_self), __pyx_v_term, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":124
 *         return self.id[1]
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return Fresh_var.unify(self, term, env)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_5unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_3Var_5unify = {"unify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_3Var_5unify, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_5unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unify (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, 1); __PYX_ERR(0, 124, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "unify") < 0)) __PYX_ERR(0, 124, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 124, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "term", 0))) __PYX_ERR(0, 124, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 124, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_3Var_4unify(((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_v_self), __pyx_v_term, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_4unify(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_3Var_unify(__pyx_v_self, __pyx_v_term, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_3Var_7__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_3Var_7__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_3Var_6__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_6__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.id,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.id);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.id);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->__pyx_base.__pyx_base.id);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.id is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.id is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->__pyx_base.__pyx_base.id != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.id is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Var); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, None), state
 *     else:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Var__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Var); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Var__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_3Var_9__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_3Var_9__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3Var_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_3Var_8__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_3Var_8__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Var__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Var__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Var__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Var.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":132
 *     __slots__ = ['id']
 * 
 *     def __init__(self, _id):             # <<<<<<<<<<<<<<
 *         self.id = _id
 * 
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_5Const_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_5Const_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__id = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_id_2,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id_2)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 132, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v__id = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 132, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), __pyx_v__id);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_5Const___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v__id) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":133
 * 
 *     def __init__(self, _id):
 *         self.id = _id             # <<<<<<<<<<<<<<
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 */
  __Pyx_INCREF(__pyx_v__id);
  __Pyx_GIVEREF(__pyx_v__id);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.id);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.id);
  __pyx_v_self->__pyx_base.id = __pyx_v__id;

  /* "pyDatalog/pyEngine.py":132
 *     __slots__ = ['id']
 * 
 *     def __init__(self, _id):             # <<<<<<<<<<<<<<
 *         self.id = _id
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":135
 *         self.id = _id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_5Const_is_const(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, int __pyx_skip_dispatch) {
  PyBoolObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_3is_const)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 135, __pyx_L1_error)
        __pyx_r = ((PyBoolObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":136
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def get_tag(self, env): #id
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(Py_True);
  __pyx_r = ((PyBoolObject *)Py_True);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":135
 *         self.id = _id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_3is_const = {"is_const", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_3is_const, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_const (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_2is_const(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_5Const_is_const(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":138
 *         return True
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_5Const_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_5get_tag)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":139
 * 
 *     def get_tag(self, env): #id
 *         return self.id             # <<<<<<<<<<<<<<
 * 
 *     def subst(self, env): #unify
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.id);
  __pyx_r = __pyx_v_self->__pyx_base.id;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":138
 *         return True
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_5get_tag = {"get_tag", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_5get_tag, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tag (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 138, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_4get_tag(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_4get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_5Const_get_tag(__pyx_v_self, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":141
 *         return self.id
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 *     def shuffle(self, env): #shuffle
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_5Const_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_7subst)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 141, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":142
 * 
 *     def subst(self, env): #unify
 *         return self             # <<<<<<<<<<<<<<
 *     def shuffle(self, env): #shuffle
 *         return self
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":141
 *         return self.id
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 *     def shuffle(self, env): #shuffle
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_7subst = {"subst", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_7subst, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 141, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_6subst(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_6subst(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_5Const_subst(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":143
 *     def subst(self, env): #unify
 *         return self
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return self
 *     def chase(self, env): #unify
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_5Const_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shuffle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_9shuffle)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 143, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":144
 *         return self
 *     def shuffle(self, env): #shuffle
 *         return self             # <<<<<<<<<<<<<<
 *     def chase(self, env): #unify
 *         return self
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":143
 *     def subst(self, env): #unify
 *         return self
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return self
 *     def chase(self, env): #unify
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_9shuffle = {"shuffle", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_9shuffle, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("shuffle (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 143, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_8shuffle(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_8shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_5Const_shuffle(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":145
 *     def shuffle(self, env): #shuffle
 *         return self
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_5Const_chase(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_11chase)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 145, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":146
 *         return self
 *     def chase(self, env): #unify
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def match(self, constant, env):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":145
 *     def shuffle(self, env): #shuffle
 *         return self
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_11chase = {"chase", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_11chase, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("chase (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 145, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_10chase(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_10chase(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_5Const_chase(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":148
 *         return self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_13match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_5Const_match(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("match", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_match); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_13match)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_constant), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_constant), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_constant));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_constant));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_constant));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 148, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":149
 * 
 *     def match(self, constant, env):
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def unify(self, term, env):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":148
 *         return self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_13match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_13match = {"match", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_5Const_13match, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_13match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("match (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_constant,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_constant)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("match", 1, 2, 2, 1); __PYX_ERR(0, 148, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "match") < 0)) __PYX_ERR(0, 148, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_constant = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("match", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 148, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_constant), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "constant", 0))) __PYX_ERR(0, 148, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 148, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_12match(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), __pyx_v_constant, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_12match(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_constant, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("match", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_5Const_match(__pyx_v_self, __pyx_v_constant, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":151
 *         return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_5Const_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_5Const_15unify)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_term));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_term));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_term));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 151, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":152
 * 
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):             # <<<<<<<<<<<<<<
 *             env[term.id] = self
 *             return env
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Fresh_var); 
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":153
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self             # <<<<<<<<<<<<<<
 *             return env
 *         return None
 */
    if (unlikely(__pyx_v_env == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 153, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_env, __pyx_v_term->id, ((PyObject *)__pyx_v_self)) < 0)) __PYX_ERR(0, 153, __pyx_L1_error)

    /* "pyDatalog/pyEngine.py":154
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 *             return env             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":152
 * 
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):             # <<<<<<<<<<<<<<
 *             env[term.id] = self
 *             return env
 */
  }

  /* "pyDatalog/pyEngine.py":155
 *             env[term.id] = self
 *             return env
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":151
 *         return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_15unify = {"unify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_5Const_15unify, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unify (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, 1); __PYX_ERR(0, 151, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "unify") < 0)) __PYX_ERR(0, 151, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 151, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "term", 0))) __PYX_ERR(0, 151, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 151, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_14unify(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), __pyx_v_term, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_14unify(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_5Const_unify(__pyx_v_self, __pyx_v_term, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":157
 *         return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_17__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_17__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_16__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_16__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":158
 * 
 *     def __str__(self):
 *         return "'%s'" % self.id             # <<<<<<<<<<<<<<
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_s, __pyx_v_self->__pyx_base.id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":157
 *         return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":159
 *     def __str__(self):
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_19equals_primitive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_19equals_primitive = {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_5Const_19equals_primitive, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_19equals_primitive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_term = 0;
  PyObject *__pyx_v_subgoal = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equals_primitive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_subgoal,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subgoal)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, 1); __PYX_ERR(0, 159, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "equals_primitive") < 0)) __PYX_ERR(0, 159, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = values[0];
    __pyx_v_subgoal = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 159, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_18equals_primitive(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), __pyx_v_term, __pyx_v_subgoal);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_18equals_primitive(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v_term, PyObject *__pyx_v_subgoal) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("equals_primitive", 0);

  /* "pyDatalog/pyEngine.py":160
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.             # <<<<<<<<<<<<<<
 *             literal = Literal("==", [self, self])
 *             return subgoal.fact(literal)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_self->__pyx_base.id, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":161
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])             # <<<<<<<<<<<<<<
 *             return subgoal.fact(literal)
 * 
 */
    __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_kp_s_);
    __Pyx_GIVEREF(__pyx_kp_s_);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":162
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 *             return subgoal.fact(literal)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_fact); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, ((PyObject *)__pyx_v_literal)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_literal));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":160
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.             # <<<<<<<<<<<<<<
 *             literal = Literal("==", [self, self])
 *             return subgoal.fact(literal)
 */
  }

  /* "pyDatalog/pyEngine.py":159
 *     def __str__(self):
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_literal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_21__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_21__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_20__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_20__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.id,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.id);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.id);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->__pyx_base.id);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.id is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.id,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.id is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->__pyx_base.id != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.id is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Const); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, None), state
 *     else:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Const__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Const); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_192985975);
    __Pyx_GIVEREF(__pyx_int_192985975);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_192985975);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Const__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5Const_23__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_23__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5Const_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_5Const_22__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_5Const_22__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Const__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Const__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Const__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Const.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":169
 *     __slots__ = ['_id', 'id', 'is_constant']
 * 
 *     def __init__(self, _id): # _id is a list of Term             # <<<<<<<<<<<<<<
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__id = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_id_2,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_id_2)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 169, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v__id = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 169, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), __pyx_v__id);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":171
 *     def __init__(self, _id): # _id is a list of Term
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id             # <<<<<<<<<<<<<<
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8__init___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 171, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___2generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_init___locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 171, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id)) { __Pyx_RaiseClosureNameError("_id"); __PYX_ERR(0, 171, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v__id; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 171, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_e, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 171, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___5generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":172
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 *         self.is_constant = all(element.is_const() for element in _id)             # <<<<<<<<<<<<<<
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8__init___3genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 172, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___5generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_init___locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 172, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___5generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 172, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id)) { __Pyx_RaiseClosureNameError("_id"); __PYX_ERR(0, 172, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v__id; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 172, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 172, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 172, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_element);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_element, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_element, __pyx_n_s_is_const); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 172, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = ((!__pyx_t_7) != 0);
    if (__pyx_t_8) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":169
 *     __slots__ = ['_id', 'id', 'is_constant']
 * 
 *     def __init__(self, _id): # _id is a list of Term             # <<<<<<<<<<<<<<
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 */

static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple___init__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v__id) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *__pyx_cur_scope;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___2generator2 = 0;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___5generator3 = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct____init__(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct____init__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 169, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v__id = __pyx_v__id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v__id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v__id);

  /* "pyDatalog/pyEngine.py":170
 * 
 *     def __init__(self, _id): # _id is a list of Term
 *         self._id = _id             # <<<<<<<<<<<<<<
 *         self.id =  tuple(e.id for e in _id) #id
 *         self.is_constant = all(element.is_const() for element in _id)
 */
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v__id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v__id);
  __Pyx_GOTREF(__pyx_v_self->_id);
  __Pyx_DECREF(__pyx_v_self->_id);
  __pyx_v_self->_id = __pyx_cur_scope->__pyx_v__id;

  /* "pyDatalog/pyEngine.py":171
 *     def __init__(self, _id): # _id is a list of Term
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id             # <<<<<<<<<<<<<<
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 */
  __pyx_t_1 = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8__init___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.id);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.id);
  __pyx_v_self->__pyx_base.id = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":172
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 *         self.is_constant = all(element.is_const() for element in _id)             # <<<<<<<<<<<<<<
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 */
  __pyx_t_2 = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8__init___3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->is_constant);
  __Pyx_DECREF(__pyx_v_self->is_constant);
  __pyx_v_self->is_constant = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":169
 *     __slots__ = ['_id', 'id', 'is_constant']
 * 
 *     def __init__(self, _id): # _id is a list of Term             # <<<<<<<<<<<<<<
 *         self._id = _id
 *         self.id =  tuple(e.id for e in _id) #id
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___2generator2);
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_8VarTuple_8__init___5generator3);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":174
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return self.is_constant
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_is_const(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, int __pyx_skip_dispatch) {
  PyBoolObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3is_const)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 174, __pyx_L1_error)
        __pyx_r = ((PyBoolObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":175
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 *         return self.is_constant             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(((__pyx_v_self->is_constant) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self->is_constant, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_self->is_constant);
  __pyx_r = ((PyBoolObject *)__pyx_v_self->is_constant);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":174
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return self.is_constant
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_3is_const = {"is_const", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3is_const, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_const (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_2is_const(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_8VarTuple_is_const(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":177
 *         return self.is_constant
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self._id)
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_5__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_5__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_4__len__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_4__len__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "pyDatalog/pyEngine.py":178
 * 
 *     def __len__(self):
 *         return len(self._id)             # <<<<<<<<<<<<<<
 * 
 *     def get_tag(self, env): #id
 */
  __pyx_t_1 = __pyx_v_self->_id;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":177
 *         return self.is_constant
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self._id)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":180
 *         return len(self._id)
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self.id
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_7get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_7get_tag)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":181
 * 
 *     def get_tag(self, env): #id
 *         if self.is_constant: # can use lazy property only for constants             # <<<<<<<<<<<<<<
 *             return self.id
 *         #Cython version for : return tuple(t.get_tag(env) for t in self._id) #id
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->is_constant); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 181, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":182
 *     def get_tag(self, env): #id
 *         if self.is_constant: # can use lazy property only for constants
 *             return self.id             # <<<<<<<<<<<<<<
 *         #Cython version for : return tuple(t.get_tag(env) for t in self._id) #id
 *         result = []
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_self->__pyx_base.id);
    __pyx_r = __pyx_v_self->__pyx_base.id;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":181
 * 
 *     def get_tag(self, env): #id
 *         if self.is_constant: # can use lazy property only for constants             # <<<<<<<<<<<<<<
 *             return self.id
 *         #Cython version for : return tuple(t.get_tag(env) for t in self._id) #id
 */
  }

  /* "pyDatalog/pyEngine.py":184
 *             return self.id
 *         #Cython version for : return tuple(t.get_tag(env) for t in self._id) #id
 *         result = []             # <<<<<<<<<<<<<<
 *         for t in self._id:
 *             result.append(t.get_tag(env))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":185
 *         #Cython version for : return tuple(t.get_tag(env) for t in self._id) #id
 *         result = []
 *         for t in self._id:             # <<<<<<<<<<<<<<
 *             result.append(t.get_tag(env))
 *         return tuple(result)
 */
  if (likely(PyList_CheckExact(__pyx_v_self->_id)) || PyTuple_CheckExact(__pyx_v_self->_id)) {
    __pyx_t_1 = __pyx_v_self->_id; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 185, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 185, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 185, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":186
 *         result = []
 *         for t in self._id:
 *             result.append(t.get_tag(env))             # <<<<<<<<<<<<<<
 *         return tuple(result)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_get_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 186, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":185
 *         #Cython version for : return tuple(t.get_tag(env) for t in self._id) #id
 *         result = []
 *         for t in self._id:             # <<<<<<<<<<<<<<
 *             result.append(t.get_tag(env))
 *         return tuple(result)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":187
 *         for t in self._id:
 *             result.append(t.get_tag(env))
 *         return tuple(result)             # <<<<<<<<<<<<<<
 * 
 *     def subst(self, env): #unify
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":180
 *         return len(self._id)
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self.id
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_7get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_7get_tag = {"get_tag", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_7get_tag, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_7get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tag (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 180, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_6get_tag(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_6get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_8VarTuple_get_tag(__pyx_v_self, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":189
 *         return tuple(result)
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_9subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_subst(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_t = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_9subst)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 189, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":190
 * 
 *     def subst(self, env): #unify
 *         if self.is_constant: # can use lazy property only for constants             # <<<<<<<<<<<<<<
 *             return self
 *         #Cython version for : return VarTuple(tuple(element.subst(env) for element in self._id))
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->is_constant); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 190, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":191
 *     def subst(self, env): #unify
 *         if self.is_constant: # can use lazy property only for constants
 *             return self             # <<<<<<<<<<<<<<
 *         #Cython version for : return VarTuple(tuple(element.subst(env) for element in self._id))
 *         result = []
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":190
 * 
 *     def subst(self, env): #unify
 *         if self.is_constant: # can use lazy property only for constants             # <<<<<<<<<<<<<<
 *             return self
 *         #Cython version for : return VarTuple(tuple(element.subst(env) for element in self._id))
 */
  }

  /* "pyDatalog/pyEngine.py":193
 *             return self
 *         #Cython version for : return VarTuple(tuple(element.subst(env) for element in self._id))
 *         result = []             # <<<<<<<<<<<<<<
 *         for t in self._id:
 *             result.append(t.subst(env))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":194
 *         #Cython version for : return VarTuple(tuple(element.subst(env) for element in self._id))
 *         result = []
 *         for t in self._id:             # <<<<<<<<<<<<<<
 *             result.append(t.subst(env))
 *         return VarTuple(result)
 */
  if (likely(PyList_CheckExact(__pyx_v_self->_id)) || PyTuple_CheckExact(__pyx_v_self->_id)) {
    __pyx_t_1 = __pyx_v_self->_id; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 194, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 194, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":195
 *         result = []
 *         for t in self._id:
 *             result.append(t.subst(env))             # <<<<<<<<<<<<<<
 *         return VarTuple(result)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_subst); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":194
 *         #Cython version for : return VarTuple(tuple(element.subst(env) for element in self._id))
 *         result = []
 *         for t in self._id:             # <<<<<<<<<<<<<<
 *             result.append(t.subst(env))
 *         return VarTuple(result)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":196
 *         for t in self._id:
 *             result.append(t.subst(env))
 *         return VarTuple(result)             # <<<<<<<<<<<<<<
 * 
 *     def shuffle(self, env): #shuffle
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple), __pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":189
 *         return tuple(result)
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_9subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_9subst = {"subst", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_9subst, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_9subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 189, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8subst(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_8subst(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_8VarTuple_subst(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":198
 *         return VarTuple(result)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_element = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shuffle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11shuffle)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 198, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":199
 * 
 *     def shuffle(self, env): #shuffle
 *         if self.is_constant:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->is_constant); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 199, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":200
 *     def shuffle(self, env): #shuffle
 *         if self.is_constant:
 *             return self             # <<<<<<<<<<<<<<
 *         else:
 *             result = []
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":199
 * 
 *     def shuffle(self, env): #shuffle
 *         if self.is_constant:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

  /* "pyDatalog/pyEngine.py":202
 *             return self
 *         else:
 *             result = []             # <<<<<<<<<<<<<<
 *             for element in self._id:
 *                 result.append(element.shuffle(env))
 */
  /*else*/ {
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_result = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":203
 *         else:
 *             result = []
 *             for element in self._id:             # <<<<<<<<<<<<<<
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)
 */
    if (likely(PyList_CheckExact(__pyx_v_self->_id)) || PyTuple_CheckExact(__pyx_v_self->_id)) {
      __pyx_t_1 = __pyx_v_self->_id; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 203, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 203, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 203, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_7(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 203, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":204
 *             result = []
 *             for element in self._id:
 *                 result.append(element.shuffle(env))             # <<<<<<<<<<<<<<
 *             return VarTuple(result)
 *     def chase(self, env): #unify
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":203
 *         else:
 *             result = []
 *             for element in self._id:             # <<<<<<<<<<<<<<
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":205
 *             for element in self._id:
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)             # <<<<<<<<<<<<<<
 *     def chase(self, env): #unify
 *         if self.is_constant:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple), __pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":198
 *         return VarTuple(result)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_element);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_11shuffle = {"shuffle", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11shuffle, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("shuffle (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 198, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_10shuffle(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_10shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_8VarTuple_shuffle(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":206
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_13chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_chase(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_t = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_13chase)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 206, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":207
 *             return VarTuple(result)
 *     def chase(self, env): #unify
 *         if self.is_constant:             # <<<<<<<<<<<<<<
 *             return self
 *         #Cython version for : return VarTuple(tuple(element.chase(env) for element in self._id))
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->is_constant); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 207, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":208
 *     def chase(self, env): #unify
 *         if self.is_constant:
 *             return self             # <<<<<<<<<<<<<<
 *         #Cython version for : return VarTuple(tuple(element.chase(env) for element in self._id))
 *         result = []
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v_self);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":207
 *             return VarTuple(result)
 *     def chase(self, env): #unify
 *         if self.is_constant:             # <<<<<<<<<<<<<<
 *             return self
 *         #Cython version for : return VarTuple(tuple(element.chase(env) for element in self._id))
 */
  }

  /* "pyDatalog/pyEngine.py":210
 *             return self
 *         #Cython version for : return VarTuple(tuple(element.chase(env) for element in self._id))
 *         result = []             # <<<<<<<<<<<<<<
 *         for t in self._id:
 *             result.append(t.chase(env))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":211
 *         #Cython version for : return VarTuple(tuple(element.chase(env) for element in self._id))
 *         result = []
 *         for t in self._id:             # <<<<<<<<<<<<<<
 *             result.append(t.chase(env))
 *         return VarTuple(result)
 */
  if (likely(PyList_CheckExact(__pyx_v_self->_id)) || PyTuple_CheckExact(__pyx_v_self->_id)) {
    __pyx_t_1 = __pyx_v_self->_id; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 211, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 211, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 211, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 211, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":212
 *         result = []
 *         for t in self._id:
 *             result.append(t.chase(env))             # <<<<<<<<<<<<<<
 *         return VarTuple(result)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_chase); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 212, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":211
 *         #Cython version for : return VarTuple(tuple(element.chase(env) for element in self._id))
 *         result = []
 *         for t in self._id:             # <<<<<<<<<<<<<<
 *             result.append(t.chase(env))
 *         return VarTuple(result)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":213
 *         for t in self._id:
 *             result.append(t.chase(env))
 *         return VarTuple(result)             # <<<<<<<<<<<<<<
 * 
 *     # def match is not needed here
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple), __pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":206
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_13chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_13chase = {"chase", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_13chase, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_13chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("chase (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 206, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_12chase(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_12chase(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_8VarTuple_chase(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":217
 *     # def match is not needed here
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_8VarTuple_unify(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_e1 = NULL;
  PyObject *__pyx_v_e2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_INCREF(__pyx_v_env);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_15unify)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 217, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_term));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_term));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_term));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 217, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":218
 * 
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):             # <<<<<<<<<<<<<<
 *             env[term.id] = self
 *             return env
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Fresh_var); 
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":219
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self             # <<<<<<<<<<<<<<
 *             return env
 *         if isinstance(term, Const):
 */
    if (unlikely(__pyx_v_env == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 219, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_env, __pyx_v_term->id, ((PyObject *)__pyx_v_self)) < 0)) __PYX_ERR(0, 219, __pyx_L1_error)

    /* "pyDatalog/pyEngine.py":220
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 *             return env             # <<<<<<<<<<<<<<
 *         if isinstance(term, Const):
 *             return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":218
 * 
 *     def unify(self, term, env):
 *         if isinstance(term, Fresh_var):             # <<<<<<<<<<<<<<
 *             env[term.id] = self
 *             return env
 */
  }

  /* "pyDatalog/pyEngine.py":221
 *             env[term.id] = self
 *             return env
 *         if isinstance(term, Const):             # <<<<<<<<<<<<<<
 *             return None
 *         if isinstance(term, VarTuple):
 */
  __pyx_t_8 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Const); 
  __pyx_t_7 = (__pyx_t_8 != 0);
  if (__pyx_t_7) {

    /* "pyDatalog/pyEngine.py":222
 *             return env
 *         if isinstance(term, Const):
 *             return None             # <<<<<<<<<<<<<<
 *         if isinstance(term, VarTuple):
 *             if len(self._id) != len(term._id):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":221
 *             env[term.id] = self
 *             return env
 *         if isinstance(term, Const):             # <<<<<<<<<<<<<<
 *             return None
 *         if isinstance(term, VarTuple):
 */
  }

  /* "pyDatalog/pyEngine.py":223
 *         if isinstance(term, Const):
 *             return None
 *         if isinstance(term, VarTuple):             # <<<<<<<<<<<<<<
 *             if len(self._id) != len(term._id):
 *                 return None
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":224
 *             return None
 *         if isinstance(term, VarTuple):
 *             if len(self._id) != len(term._id):             # <<<<<<<<<<<<<<
 *                 return None
 *             for e1, e2 in zip(term._id, self._id):
 */
    __pyx_t_1 = __pyx_v_self->_id;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 224, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_term), __pyx_n_s_id_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 224, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = ((__pyx_t_9 != __pyx_t_10) != 0);
    if (__pyx_t_8) {

      /* "pyDatalog/pyEngine.py":225
 *         if isinstance(term, VarTuple):
 *             if len(self._id) != len(term._id):
 *                 return None             # <<<<<<<<<<<<<<
 *             for e1, e2 in zip(term._id, self._id):
 *                 if e1.id != e2.id:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "pyDatalog/pyEngine.py":224
 *             return None
 *         if isinstance(term, VarTuple):
 *             if len(self._id) != len(term._id):             # <<<<<<<<<<<<<<
 *                 return None
 *             for e1, e2 in zip(term._id, self._id):
 */
    }

    /* "pyDatalog/pyEngine.py":226
 *             if len(self._id) != len(term._id):
 *                 return None
 *             for e1, e2 in zip(term._id, self._id):             # <<<<<<<<<<<<<<
 *                 if e1.id != e2.id:
 *                     env = e1.unify(e2, env)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_term), __pyx_n_s_id_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_self->_id);
    __Pyx_GIVEREF(__pyx_v_self->_id);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->_id);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 226, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_11)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 226, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 226, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_11(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 226, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 226, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_6 = __pyx_t_12(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_4), 2) < 0) __PYX_ERR(0, 226, __pyx_L1_error)
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 226, __pyx_L1_error)
        __pyx_L10_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_e1, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_e2, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pyDatalog/pyEngine.py":227
 *                 return None
 *             for e1, e2 in zip(term._id, self._id):
 *                 if e1.id != e2.id:             # <<<<<<<<<<<<<<
 *                     env = e1.unify(e2, env)
 *                     if env is None: return env
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_e1, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_e2, __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_8) {

        /* "pyDatalog/pyEngine.py":228
 *             for e1, e2 in zip(term._id, self._id):
 *                 if e1.id != e2.id:
 *                     env = e1.unify(e2, env)             # <<<<<<<<<<<<<<
 *                     if env is None: return env
 *             return env
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_e1, __pyx_n_s_unify); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 228, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_e2, __pyx_v_env};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 228, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_e2, __pyx_v_env};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 228, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (__pyx_t_1) {
            __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
          }
          __Pyx_INCREF(__pyx_v_e2);
          __Pyx_GIVEREF(__pyx_v_e2);
          PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_e2);
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 228, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 228, __pyx_L1_error)
        __Pyx_DECREF_SET(__pyx_v_env, ((PyObject*)__pyx_t_3));
        __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":229
 *                 if e1.id != e2.id:
 *                     env = e1.unify(e2, env)
 *                     if env is None: return env             # <<<<<<<<<<<<<<
 *             return env
 *         if isinstance(term, Operation):
 */
        __pyx_t_8 = (__pyx_v_env == ((PyObject*)Py_None));
        __pyx_t_7 = (__pyx_t_8 != 0);
        if (__pyx_t_7) {
          __Pyx_XDECREF(__pyx_r);
          __Pyx_INCREF(__pyx_v_env);
          __pyx_r = __pyx_v_env;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L0;
        }

        /* "pyDatalog/pyEngine.py":227
 *                 return None
 *             for e1, e2 in zip(term._id, self._id):
 *                 if e1.id != e2.id:             # <<<<<<<<<<<<<<
 *                     env = e1.unify(e2, env)
 *                     if env is None: return env
 */
      }

      /* "pyDatalog/pyEngine.py":226
 *             if len(self._id) != len(term._id):
 *                 return None
 *             for e1, e2 in zip(term._id, self._id):             # <<<<<<<<<<<<<<
 *                 if e1.id != e2.id:
 *                     env = e1.unify(e2, env)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":230
 *                     env = e1.unify(e2, env)
 *                     if env is None: return env
 *             return env             # <<<<<<<<<<<<<<
 *         if isinstance(term, Operation):
 *             return None
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_env);
    __pyx_r = __pyx_v_env;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":223
 *         if isinstance(term, Const):
 *             return None
 *         if isinstance(term, VarTuple):             # <<<<<<<<<<<<<<
 *             if len(self._id) != len(term._id):
 *                 return None
 */
  }

  /* "pyDatalog/pyEngine.py":231
 *                     if env is None: return env
 *             return env
 *         if isinstance(term, Operation):             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_7 = __Pyx_TypeCheck(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Operation); 
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":232
 *             return env
 *         if isinstance(term, Operation):
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":231
 *                     if env is None: return env
 *             return env
 *         if isinstance(term, Operation):             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  }

  /* "pyDatalog/pyEngine.py":217
 *     # def match is not needed here
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */

  /* function exit code */
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e1);
  __Pyx_XDECREF(__pyx_v_e2);
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_15unify = {"unify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_15unify, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_15unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unify (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, 1); __PYX_ERR(0, 217, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "unify") < 0)) __PYX_ERR(0, 217, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 217, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "term", 0))) __PYX_ERR(0, 217, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 217, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_14unify(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), __pyx_v_term, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_14unify(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_8VarTuple_unify(__pyx_v_self, __pyx_v_term, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":234
 *             return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_17__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_17__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_16__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_16__str__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":235
 * 
 *     def __str__(self):
 *         return "'%s'" % str([str(e) for e in self.id])             # <<<<<<<<<<<<<<
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_v_self->__pyx_base.id)) || PyTuple_CheckExact(__pyx_v_self->__pyx_base.id)) {
    __pyx_t_2 = __pyx_v_self->__pyx_base.id; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_self->__pyx_base.id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 235, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 235, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 235, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_e); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 235, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":234
 *             return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":236
 *     def __str__(self):
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_19equals_primitive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_19equals_primitive = {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_19equals_primitive, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_19equals_primitive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_term = 0;
  PyObject *__pyx_v_subgoal = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equals_primitive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_subgoal,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subgoal)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, 1); __PYX_ERR(0, 236, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "equals_primitive") < 0)) __PYX_ERR(0, 236, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = values[0];
    __pyx_v_subgoal = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 236, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_18equals_primitive(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), __pyx_v_term, __pyx_v_subgoal);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_18equals_primitive(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_term, PyObject *__pyx_v_subgoal) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("equals_primitive", 0);

  /* "pyDatalog/pyEngine.py":237
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.             # <<<<<<<<<<<<<<
 *             literal = Literal("==", [self, self])
 *             return subgoal.fact(literal)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_self->__pyx_base.id, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":238
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])             # <<<<<<<<<<<<<<
 *             return subgoal.fact(literal)
 * 
 */
    __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_kp_s_);
    __Pyx_GIVEREF(__pyx_kp_s_);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":239
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 *             return subgoal.fact(literal)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_fact); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, ((PyObject *)__pyx_v_literal)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_literal));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":237
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):
 *         if self.id == term.id:          # Both terms are constant and equal.             # <<<<<<<<<<<<<<
 *             literal = Literal("==", [self, self])
 *             return subgoal.fact(literal)
 */
  }

  /* "pyDatalog/pyEngine.py":236
 *     def __str__(self):
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_literal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":34
 * 
 * cdef class VarTuple(Term):
 *     cpdef public object _id             # <<<<<<<<<<<<<<
 *     cpdef public object is_constant
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_id);
  __pyx_r = __pyx_v_self->_id;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_id);
  __Pyx_DECREF(__pyx_v_self->_id);
  __pyx_v_self->_id = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_3_id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_id);
  __Pyx_DECREF(__pyx_v_self->_id);
  __pyx_v_self->_id = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":35
 * cdef class VarTuple(Term):
 *     cpdef public object _id
 *     cpdef public object is_constant             # <<<<<<<<<<<<<<
 * 
 *     cpdef bool is_const(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant___get__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->is_constant);
  __pyx_r = __pyx_v_self->is_constant;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->is_constant);
  __Pyx_DECREF(__pyx_v_self->is_constant);
  __pyx_v_self->is_constant = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_11is_constant_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->is_constant);
  __Pyx_DECREF(__pyx_v_self->is_constant);
  __pyx_v_self->is_constant = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_21__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_21__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_20__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_20__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._id, self.id, self.is_constant)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_id);
  __Pyx_GIVEREF(__pyx_v_self->_id);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_id);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.id);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.id);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->__pyx_base.id);
  __Pyx_INCREF(__pyx_v_self->is_constant);
  __Pyx_GIVEREF(__pyx_v_self->is_constant);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->is_constant);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._id, self.id, self.is_constant)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self._id, self.id, self.is_constant)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._id is not None or self.id is not None or self.is_constant is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._id, self.id, self.is_constant)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._id is not None or self.id is not None or self.is_constant is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->_id != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->__pyx_base.id != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->is_constant != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    __pyx_t_3 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._id is not None or self.id is not None or self.is_constant is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self._id is not None or self.id is not None or self.is_constant is not None
 *     if use_setstate:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_VarTuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_161349669);
    __Pyx_GIVEREF(__pyx_int_161349669);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_161349669);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._id is not None or self.id is not None or self.is_constant is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, None), state
 *     else:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VarTuple__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_VarTuple); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_161349669);
    __Pyx_GIVEREF(__pyx_int_161349669);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_161349669);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VarTuple__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_23__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_23__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8VarTuple_22__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8VarTuple_22__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_VarTuple__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_VarTuple__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VarTuple__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.VarTuple.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":245
 *     """ an arithmetic operation, a slice or a lambda """
 *     counter = util.Counter()
 *     def __init__(self, lhs, operator, rhs):             # <<<<<<<<<<<<<<
 *         self.operator = operator
 *         self.operator_id = 'l' + str(Operation.counter.next()) if isinstance(self.operator, type(util.LAMBDA)) else str(self.operator)
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_lhs = 0;
  PyObject *__pyx_v_operator = 0;
  PyObject *__pyx_v_rhs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lhs,&__pyx_n_s_operator,&__pyx_n_s_rhs,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lhs)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_operator)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 245, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rhs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 245, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 245, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_lhs = values[0];
    __pyx_v_operator = values[1];
    __pyx_v_rhs = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 245, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), __pyx_v_lhs, __pyx_v_operator, __pyx_v_rhs);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_operator, PyObject *__pyx_v_rhs) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":246
 *     counter = util.Counter()
 *     def __init__(self, lhs, operator, rhs):
 *         self.operator = operator             # <<<<<<<<<<<<<<
 *         self.operator_id = 'l' + str(Operation.counter.next()) if isinstance(self.operator, type(util.LAMBDA)) else str(self.operator)
 *         self.lhs = lhs
 */
  __Pyx_INCREF(__pyx_v_operator);
  __Pyx_GIVEREF(__pyx_v_operator);
  __Pyx_GOTREF(__pyx_v_self->operator);
  __Pyx_DECREF(__pyx_v_self->operator);
  __pyx_v_self->operator = __pyx_v_operator;

  /* "pyDatalog/pyEngine.py":247
 *     def __init__(self, lhs, operator, rhs):
 *         self.operator = operator
 *         self.operator_id = 'l' + str(Operation.counter.next()) if isinstance(self.operator, type(util.LAMBDA)) else str(self.operator)             # <<<<<<<<<<<<<<
 *         self.lhs = lhs
 *         self.rhs = rhs
 */
  __pyx_t_2 = __pyx_v_self->operator;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_util); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_LAMBDA); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = PyObject_IsInstance(__pyx_t_2, ((PyObject *)Py_TYPE(__pyx_t_4))); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if ((__pyx_t_5 != 0)) {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation), __pyx_n_s_counter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_next); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Add(__pyx_n_s_l, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_self->operator); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->operator_id);
  __Pyx_DECREF(__pyx_v_self->operator_id);
  __pyx_v_self->operator_id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":248
 *         self.operator = operator
 *         self.operator_id = 'l' + str(Operation.counter.next()) if isinstance(self.operator, type(util.LAMBDA)) else str(self.operator)
 *         self.lhs = lhs             # <<<<<<<<<<<<<<
 *         self.rhs = rhs
 *         self.is_constant = False
 */
  __Pyx_INCREF(__pyx_v_lhs);
  __Pyx_GIVEREF(__pyx_v_lhs);
  __Pyx_GOTREF(__pyx_v_self->lhs);
  __Pyx_DECREF(__pyx_v_self->lhs);
  __pyx_v_self->lhs = __pyx_v_lhs;

  /* "pyDatalog/pyEngine.py":249
 *         self.operator_id = 'l' + str(Operation.counter.next()) if isinstance(self.operator, type(util.LAMBDA)) else str(self.operator)
 *         self.lhs = lhs
 *         self.rhs = rhs             # <<<<<<<<<<<<<<
 *         self.is_constant = False
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id
 */
  __Pyx_INCREF(__pyx_v_rhs);
  __Pyx_GIVEREF(__pyx_v_rhs);
  __Pyx_GOTREF(__pyx_v_self->rhs);
  __Pyx_DECREF(__pyx_v_self->rhs);
  __pyx_v_self->rhs = __pyx_v_rhs;

  /* "pyDatalog/pyEngine.py":250
 *         self.lhs = lhs
 *         self.rhs = rhs
 *         self.is_constant = False             # <<<<<<<<<<<<<<
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id
 * 
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->is_constant);
  __Pyx_DECREF(__pyx_v_self->is_constant);
  __pyx_v_self->is_constant = Py_False;

  /* "pyDatalog/pyEngine.py":251
 *         self.rhs = rhs
 *         self.is_constant = False
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id             # <<<<<<<<<<<<<<
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->operator_id);
  __Pyx_GIVEREF(__pyx_v_self->operator_id);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->operator_id);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.id);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.id);
  __pyx_v_self->__pyx_base.id = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":245
 *     """ an arithmetic operation, a slice or a lambda """
 *     counter = util.Counter()
 *     def __init__(self, lhs, operator, rhs):             # <<<<<<<<<<<<<<
 *         self.operator = operator
 *         self.operator_id = 'l' + str(Operation.counter.next()) if isinstance(self.operator, type(util.LAMBDA)) else str(self.operator)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":253
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return False
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyBoolObject *__pyx_f_9pyDatalog_8pyEngine_9Operation_is_const(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, int __pyx_skip_dispatch) {
  PyBoolObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_const); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Operation_3is_const)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 253, __pyx_L1_error)
        __pyx_r = ((PyBoolObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":254
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def get_tag(self, env): #id
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(Py_False);
  __pyx_r = ((PyBoolObject *)Py_False);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":253
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return False
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_3is_const = {"is_const", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_3is_const, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3is_const(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_const (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_2is_const(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_2is_const(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_const", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Operation_is_const(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.is_const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":256
 *         return False
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Operation_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Operation_5get_tag)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":257
 * 
 *     def get_tag(self, env): #id
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))             # <<<<<<<<<<<<<<
 * 
 *     def subst(self, env): #unify
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lhs, __pyx_n_s_get_tag); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->rhs, __pyx_n_s_get_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->operator_id);
  __Pyx_GIVEREF(__pyx_v_self->operator_id);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->operator_id);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":256
 *         return False
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_5get_tag = {"get_tag", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_5get_tag, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_5get_tag(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tag (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 256, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_4get_tag(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_4get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_9Operation_get_tag(__pyx_v_self, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":259
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Operation_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_lhs = NULL;
  PyObject *__pyx_v_rhs = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_attribute = NULL;
  PyObject *__pyx_v_e = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Operation_7subst)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 259, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":260
 * 
 *     def subst(self, env): #unify
 *         lhs = self.lhs.subst(env)             # <<<<<<<<<<<<<<
 *         rhs = self.rhs.subst(env)
 *         try:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lhs, __pyx_n_s_subst); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_lhs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":261
 *     def subst(self, env): #unify
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)             # <<<<<<<<<<<<<<
 *         try:
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->rhs, __pyx_n_s_subst); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rhs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":262
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 *         try:             # <<<<<<<<<<<<<<
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "pyDatalog/pyEngine.py":263
 *         rhs = self.rhs.subst(env)
 *         try:
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():             # <<<<<<<<<<<<<<
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 *                 if isinstance(rhs, VarTuple): # a slice
 */
      __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__2, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 263, __pyx_L3_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_8 = __pyx_t_9;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_10 = __Pyx_TypeCheck(__pyx_v_lhs, __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
      __pyx_t_11 = (__pyx_t_10 != 0);
      if (!__pyx_t_11) {
      } else {
        __pyx_t_9 = __pyx_t_11;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_11 = __Pyx_TypeCheck(__pyx_v_lhs, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
      __pyx_t_10 = (__pyx_t_11 != 0);
      __pyx_t_9 = __pyx_t_10;
      __pyx_L13_bool_binop_done:;
      __pyx_t_10 = (__pyx_t_9 != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_8 = __pyx_t_10;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 263, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __pyx_t_10;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_8) {

        /* "pyDatalog/pyEngine.py":264
 *         try:
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id             # <<<<<<<<<<<<<<
 *                 if isinstance(rhs, VarTuple): # a slice
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))
 */
        __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_lhs, __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
        if ((__pyx_t_8 != 0)) {
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __pyx_t_2;
          __pyx_t_2 = 0;
        } else {
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __pyx_t_2;
          __pyx_t_2 = 0;
        }
        __pyx_v_v = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":265
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 *                 if isinstance(rhs, VarTuple): # a slice             # <<<<<<<<<<<<<<
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))
 *                 return Term_of(v.__getitem__(rhs.id))
 */
        __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_rhs, __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
        __pyx_t_10 = (__pyx_t_8 != 0);
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":266
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 *                 if isinstance(rhs, VarTuple): # a slice
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))             # <<<<<<<<<<<<<<
 *                 return Term_of(v.__getitem__(rhs.id))
 *             if self.operator == '#' and isinstance(rhs, VarTuple):
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_getitem); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)(&PySlice_Type)), __pyx_t_13, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_13)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_13, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_12);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_4)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 266, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":265
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 *                 if isinstance(rhs, VarTuple): # a slice             # <<<<<<<<<<<<<<
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))
 *                 return Term_of(v.__getitem__(rhs.id))
 */
        }

        /* "pyDatalog/pyEngine.py":267
 *                 if isinstance(rhs, VarTuple): # a slice
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))
 *                 return Term_of(v.__getitem__(rhs.id))             # <<<<<<<<<<<<<<
 *             if self.operator == '#' and isinstance(rhs, VarTuple):
 *                 return Term_of(len(rhs))
 */
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_getitem); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 267, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_13, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_12);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 267, __pyx_L3_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
        __pyx_t_1 = 0;
        goto __pyx_L7_try_return;

        /* "pyDatalog/pyEngine.py":263
 *         rhs = self.rhs.subst(env)
 *         try:
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():             # <<<<<<<<<<<<<<
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 *                 if isinstance(rhs, VarTuple): # a slice
 */
      }

      /* "pyDatalog/pyEngine.py":268
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))
 *                 return Term_of(v.__getitem__(rhs.id))
 *             if self.operator == '#' and isinstance(rhs, VarTuple):             # <<<<<<<<<<<<<<
 *                 return Term_of(len(rhs))
 *             if self.operator == '..' and rhs.is_const():
 */
      __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__3, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 268, __pyx_L3_error)
      if (__pyx_t_8) {
      } else {
        __pyx_t_10 = __pyx_t_8;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_8 = __Pyx_TypeCheck(__pyx_v_rhs, __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
      __pyx_t_9 = (__pyx_t_8 != 0);
      __pyx_t_10 = __pyx_t_9;
      __pyx_L17_bool_binop_done:;
      if (__pyx_t_10) {

        /* "pyDatalog/pyEngine.py":269
 *                 return Term_of(v.__getitem__(rhs.id))
 *             if self.operator == '#' and isinstance(rhs, VarTuple):
 *                 return Term_of(len(rhs))             # <<<<<<<<<<<<<<
 *             if self.operator == '..' and rhs.is_const():
 *                 return Term_of(range(rhs.id))
 */
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_14 = PyObject_Length(__pyx_v_rhs); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 269, __pyx_L3_error)
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 269, __pyx_L3_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
        __pyx_t_1 = 0;
        goto __pyx_L7_try_return;

        /* "pyDatalog/pyEngine.py":268
 *                     return Term_of(v.__getitem__(slice(*rhs.id)))
 *                 return Term_of(v.__getitem__(rhs.id))
 *             if self.operator == '#' and isinstance(rhs, VarTuple):             # <<<<<<<<<<<<<<
 *                 return Term_of(len(rhs))
 *             if self.operator == '..' and rhs.is_const():
 */
      }

      /* "pyDatalog/pyEngine.py":270
 *             if self.operator == '#' and isinstance(rhs, VarTuple):
 *                 return Term_of(len(rhs))
 *             if self.operator == '..' and rhs.is_const():             # <<<<<<<<<<<<<<
 *                 return Term_of(range(rhs.id))
 *             if lhs.is_const() and rhs.is_const():
 */
      __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__4, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 270, __pyx_L3_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_10 = __pyx_t_9;
        goto __pyx_L20_bool_binop_done;
      }
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 270, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = __pyx_t_9;
      __pyx_L20_bool_binop_done:;
      if (__pyx_t_10) {

        /* "pyDatalog/pyEngine.py":271
 *                 return Term_of(len(rhs))
 *             if self.operator == '..' and rhs.is_const():
 *                 return Term_of(range(rhs.id))             # <<<<<<<<<<<<<<
 *             if lhs.is_const() and rhs.is_const():
 *                 # calculate expression of constants
 */
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 271, __pyx_L3_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
        __pyx_t_1 = 0;
        goto __pyx_L7_try_return;

        /* "pyDatalog/pyEngine.py":270
 *             if self.operator == '#' and isinstance(rhs, VarTuple):
 *                 return Term_of(len(rhs))
 *             if self.operator == '..' and rhs.is_const():             # <<<<<<<<<<<<<<
 *                 return Term_of(range(rhs.id))
 *             if lhs.is_const() and rhs.is_const():
 */
      }

      /* "pyDatalog/pyEngine.py":272
 *             if self.operator == '..' and rhs.is_const():
 *                 return Term_of(range(rhs.id))
 *             if lhs.is_const() and rhs.is_const():             # <<<<<<<<<<<<<<
 *                 # calculate expression of constants
 *                 if self.operator == '+':
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 272, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_9) {
      } else {
        __pyx_t_10 = __pyx_t_9;
        goto __pyx_L23_bool_binop_done;
      }
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 272, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = __pyx_t_9;
      __pyx_L23_bool_binop_done:;
      if (__pyx_t_10) {

        /* "pyDatalog/pyEngine.py":274
 *             if lhs.is_const() and rhs.is_const():
 *                 # calculate expression of constants
 *                 if self.operator == '+':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id + rhs.id)
 *                 elif self.operator == '-':
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__5, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 274, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":275
 *                 # calculate expression of constants
 *                 if self.operator == '+':
 *                     return Term_of(lhs.id + rhs.id)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '-':
 *                     return Term_of(lhs.id - rhs.id)
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_12 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 275, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 275, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":274
 *             if lhs.is_const() and rhs.is_const():
 *                 # calculate expression of constants
 *                 if self.operator == '+':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id + rhs.id)
 *                 elif self.operator == '-':
 */
        }

        /* "pyDatalog/pyEngine.py":276
 *                 if self.operator == '+':
 *                     return Term_of(lhs.id + rhs.id)
 *                 elif self.operator == '-':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id - rhs.id)
 *                 elif self.operator == '*':
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__6, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 276, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":277
 *                     return Term_of(lhs.id + rhs.id)
 *                 elif self.operator == '-':
 *                     return Term_of(lhs.id - rhs.id)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '*':
 *                     return Term_of(lhs.id * rhs.id)
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 277, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = PyNumber_Subtract(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 277, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 277, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":276
 *                 if self.operator == '+':
 *                     return Term_of(lhs.id + rhs.id)
 *                 elif self.operator == '-':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id - rhs.id)
 *                 elif self.operator == '*':
 */
        }

        /* "pyDatalog/pyEngine.py":278
 *                 elif self.operator == '-':
 *                     return Term_of(lhs.id - rhs.id)
 *                 elif self.operator == '*':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id * rhs.id)
 *                 elif self.operator == '/':
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__7, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 278, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":279
 *                     return Term_of(lhs.id - rhs.id)
 *                 elif self.operator == '*':
 *                     return Term_of(lhs.id * rhs.id)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '/':
 *                     return Term_of(lhs.id / rhs.id)
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_12 = PyNumber_Multiply(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 279, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 279, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":278
 *                 elif self.operator == '-':
 *                     return Term_of(lhs.id - rhs.id)
 *                 elif self.operator == '*':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id * rhs.id)
 *                 elif self.operator == '/':
 */
        }

        /* "pyDatalog/pyEngine.py":280
 *                 elif self.operator == '*':
 *                     return Term_of(lhs.id * rhs.id)
 *                 elif self.operator == '/':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id / rhs.id)
 *                 elif self.operator == '//':
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__8, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 280, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":281
 *                     return Term_of(lhs.id * rhs.id)
 *                 elif self.operator == '/':
 *                     return Term_of(lhs.id / rhs.id)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '//':
 *                     return Term_of(lhs.id // rhs.id)
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 281, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 281, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":280
 *                 elif self.operator == '*':
 *                     return Term_of(lhs.id * rhs.id)
 *                 elif self.operator == '/':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id / rhs.id)
 *                 elif self.operator == '//':
 */
        }

        /* "pyDatalog/pyEngine.py":282
 *                 elif self.operator == '/':
 *                     return Term_of(lhs.id / rhs.id)
 *                 elif self.operator == '//':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id // rhs.id)
 *                 elif self.operator == '**':
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__9, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 282, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":283
 *                     return Term_of(lhs.id / rhs.id)
 *                 elif self.operator == '//':
 *                     return Term_of(lhs.id // rhs.id)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '**':
 *                     return Term_of(lhs.id ** rhs.id)
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_12 = PyNumber_FloorDivide(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 283, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_12);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 283, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":282
 *                 elif self.operator == '/':
 *                     return Term_of(lhs.id / rhs.id)
 *                 elif self.operator == '//':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id // rhs.id)
 *                 elif self.operator == '**':
 */
        }

        /* "pyDatalog/pyEngine.py":284
 *                 elif self.operator == '//':
 *                     return Term_of(lhs.id // rhs.id)
 *                 elif self.operator == '**':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id ** rhs.id)
 *                 elif self.operator == '%':
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__10, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 284, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":285
 *                     return Term_of(lhs.id // rhs.id)
 *                 elif self.operator == '**':
 *                     return Term_of(lhs.id ** rhs.id)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '%':
 *                     return Term_of(lhs.id.format(*(rhs.id)))
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 285, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = PyNumber_Power(__pyx_t_12, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 285, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":284
 *                 elif self.operator == '//':
 *                     return Term_of(lhs.id // rhs.id)
 *                 elif self.operator == '**':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id ** rhs.id)
 *                 elif self.operator == '%':
 */
        }

        /* "pyDatalog/pyEngine.py":286
 *                 elif self.operator == '**':
 *                     return Term_of(lhs.id ** rhs.id)
 *                 elif self.operator == '%':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id.format(*(rhs.id)))
 *                 elif isinstance(self.operator, type(util.LAMBDA)):
 */
        __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__11, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 286, __pyx_L3_error)
        if (__pyx_t_10) {

          /* "pyDatalog/pyEngine.py":287
 *                     return Term_of(lhs.id ** rhs.id)
 *                 elif self.operator == '%':
 *                     return Term_of(lhs.id.format(*(rhs.id)))             # <<<<<<<<<<<<<<
 *                 elif isinstance(self.operator, type(util.LAMBDA)):
 *                     return Term_of(self.operator(*(rhs.id)))
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_12, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 287, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":286
 *                 elif self.operator == '**':
 *                     return Term_of(lhs.id ** rhs.id)
 *                 elif self.operator == '%':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id.format(*(rhs.id)))
 *                 elif isinstance(self.operator, type(util.LAMBDA)):
 */
        }

        /* "pyDatalog/pyEngine.py":288
 *                 elif self.operator == '%':
 *                     return Term_of(lhs.id.format(*(rhs.id)))
 *                 elif isinstance(self.operator, type(util.LAMBDA)):             # <<<<<<<<<<<<<<
 *                     return Term_of(self.operator(*(rhs.id)))
 *                 elif self.operator == '.':
 */
        __pyx_t_1 = __pyx_v_self->operator;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_LAMBDA); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = PyObject_IsInstance(__pyx_t_1, ((PyObject *)Py_TYPE(__pyx_t_4))); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 288, __pyx_L3_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = (__pyx_t_10 != 0);
        if (__pyx_t_9) {

          /* "pyDatalog/pyEngine.py":289
 *                     return Term_of(lhs.id.format(*(rhs.id)))
 *                 elif isinstance(self.operator, type(util.LAMBDA)):
 *                     return Term_of(self.operator(*(rhs.id)))             # <<<<<<<<<<<<<<
 *                 elif self.operator == '.':
 *                     v = lhs.id
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 289, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_self->operator, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          __pyx_t_4 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_12, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 289, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_4);
          __pyx_t_4 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":288
 *                 elif self.operator == '%':
 *                     return Term_of(lhs.id.format(*(rhs.id)))
 *                 elif isinstance(self.operator, type(util.LAMBDA)):             # <<<<<<<<<<<<<<
 *                     return Term_of(self.operator(*(rhs.id)))
 *                 elif self.operator == '.':
 */
        }

        /* "pyDatalog/pyEngine.py":290
 *                 elif isinstance(self.operator, type(util.LAMBDA)):
 *                     return Term_of(self.operator(*(rhs.id)))
 *                 elif self.operator == '.':             # <<<<<<<<<<<<<<
 *                     v = lhs.id
 *                     for attribute in rhs.id.split(".") :
 */
        __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__12, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 290, __pyx_L3_error)
        if (__pyx_t_9) {

          /* "pyDatalog/pyEngine.py":291
 *                     return Term_of(self.operator(*(rhs.id)))
 *                 elif self.operator == '.':
 *                     v = lhs.id             # <<<<<<<<<<<<<<
 *                     for attribute in rhs.id.split(".") :
 *                         v = getattr(v, attribute)
 */
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_v_v = __pyx_t_4;
          __pyx_t_4 = 0;

          /* "pyDatalog/pyEngine.py":292
 *                 elif self.operator == '.':
 *                     v = lhs.id
 *                     for attribute in rhs.id.split(".") :             # <<<<<<<<<<<<<<
 *                         v = getattr(v, attribute)
 *                     return Term_of(v)
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_kp_s__12) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s__12);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
            __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_14 = 0;
            __pyx_t_15 = NULL;
          } else {
            __pyx_t_14 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_15 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 292, __pyx_L3_error)
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          for (;;) {
            if (likely(!__pyx_t_15)) {
              if (likely(PyList_CheckExact(__pyx_t_2))) {
                if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_2)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 292, __pyx_L3_error)
                #else
                __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L3_error)
                __Pyx_GOTREF(__pyx_t_4);
                #endif
              } else {
                if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 292, __pyx_L3_error)
                #else
                __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L3_error)
                __Pyx_GOTREF(__pyx_t_4);
                #endif
              }
            } else {
              __pyx_t_4 = __pyx_t_15(__pyx_t_2);
              if (unlikely(!__pyx_t_4)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 292, __pyx_L3_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_XDECREF_SET(__pyx_v_attribute, __pyx_t_4);
            __pyx_t_4 = 0;

            /* "pyDatalog/pyEngine.py":293
 *                     v = lhs.id
 *                     for attribute in rhs.id.split(".") :
 *                         v = getattr(v, attribute)             # <<<<<<<<<<<<<<
 *                     return Term_of(v)
 *                 elif self.operator == '(':
 */
            __pyx_t_4 = __Pyx_GetAttr(__pyx_v_v, __pyx_v_attribute); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_4);
            __pyx_t_4 = 0;

            /* "pyDatalog/pyEngine.py":292
 *                 elif self.operator == '.':
 *                     v = lhs.id
 *                     for attribute in rhs.id.split(".") :             # <<<<<<<<<<<<<<
 *                         v = getattr(v, attribute)
 *                     return Term_of(v)
 */
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":294
 *                     for attribute in rhs.id.split(".") :
 *                         v = getattr(v, attribute)
 *                     return Term_of(v)             # <<<<<<<<<<<<<<
 *                 elif self.operator == '(':
 *                     return Term_of(lhs.id.__call__(*(rhs.id)))
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_v) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_v);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 294, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
          __pyx_t_2 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":290
 *                 elif isinstance(self.operator, type(util.LAMBDA)):
 *                     return Term_of(self.operator(*(rhs.id)))
 *                 elif self.operator == '.':             # <<<<<<<<<<<<<<
 *                     v = lhs.id
 *                     for attribute in rhs.id.split(".") :
 */
        }

        /* "pyDatalog/pyEngine.py":295
 *                         v = getattr(v, attribute)
 *                     return Term_of(v)
 *                 elif self.operator == '(':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id.__call__(*(rhs.id)))
 *                 assert False # dead code
 */
        __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_self->operator, __pyx_kp_s__13, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 295, __pyx_L3_error)
        if (__pyx_t_9) {

          /* "pyDatalog/pyEngine.py":296
 *                     return Term_of(v)
 *                 elif self.operator == '(':
 *                     return Term_of(lhs.id.__call__(*(rhs.id)))             # <<<<<<<<<<<<<<
 *                 assert False # dead code
 *             return Operation(lhs, self.operator, rhs)
 */
          __Pyx_XDECREF(((PyObject *)__pyx_r));
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_lhs, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_call); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_rhs, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 296, __pyx_L3_error)
          __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
          __pyx_t_2 = 0;
          goto __pyx_L7_try_return;

          /* "pyDatalog/pyEngine.py":295
 *                         v = getattr(v, attribute)
 *                     return Term_of(v)
 *                 elif self.operator == '(':             # <<<<<<<<<<<<<<
 *                     return Term_of(lhs.id.__call__(*(rhs.id)))
 *                 assert False # dead code
 */
        }

        /* "pyDatalog/pyEngine.py":297
 *                 elif self.operator == '(':
 *                     return Term_of(lhs.id.__call__(*(rhs.id)))
 *                 assert False # dead code             # <<<<<<<<<<<<<<
 *             return Operation(lhs, self.operator, rhs)
 *         except Exception as e:
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          if (unlikely(!0)) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 297, __pyx_L3_error)
          }
        }
        #endif

        /* "pyDatalog/pyEngine.py":272
 *             if self.operator == '..' and rhs.is_const():
 *                 return Term_of(range(rhs.id))
 *             if lhs.is_const() and rhs.is_const():             # <<<<<<<<<<<<<<
 *                 # calculate expression of constants
 *                 if self.operator == '+':
 */
      }

      /* "pyDatalog/pyEngine.py":298
 *                     return Term_of(lhs.id.__call__(*(rhs.id)))
 *                 assert False # dead code
 *             return Operation(lhs, self.operator, rhs)             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             return Term_of(e)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_lhs);
      __Pyx_GIVEREF(__pyx_v_lhs);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_lhs);
      __Pyx_INCREF(__pyx_v_self->operator);
      __Pyx_GIVEREF(__pyx_v_self->operator);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->operator);
      __Pyx_INCREF(__pyx_v_rhs);
      __Pyx_GIVEREF(__pyx_v_rhs);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_rhs);
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_4);
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "pyDatalog/pyEngine.py":262
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 *         try:             # <<<<<<<<<<<<<<
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pyDatalog/pyEngine.py":299
 *                 assert False # dead code
 *             return Operation(lhs, self.operator, rhs)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             return Term_of(e)
 * 
 */
    __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_16) {
      __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 299, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __pyx_v_e = __pyx_t_2;

      /* "pyDatalog/pyEngine.py":300
 *             return Operation(lhs, self.operator, rhs)
 *         except Exception as e:
 *             return Term_of(e)             # <<<<<<<<<<<<<<
 * 
 *     def shuffle(self, env): #shuffle
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 300, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_v_e) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_e);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 300, __pyx_L5_except_error)
      __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "pyDatalog/pyEngine.py":262
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 *         try:             # <<<<<<<<<<<<<<
 *             if self.operator == '[' and isinstance(lhs, (VarTuple, Const)) and rhs.is_const():
 *                 v = lhs._id if isinstance(lhs, VarTuple) else lhs.id
 */
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":259
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lhs);
  __Pyx_XDECREF(__pyx_v_rhs);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_attribute);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_7subst = {"subst", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_7subst, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_7subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 259, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_6subst(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_6subst(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Operation_subst(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":302
 *             return Term_of(e)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Operation_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shuffle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Operation_9shuffle)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 302, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":303
 * 
 *     def shuffle(self, env): #shuffle
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))             # <<<<<<<<<<<<<<
 * 
 *     def chase(self, env): #unify
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lhs, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->rhs, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->operator);
  __Pyx_GIVEREF(__pyx_v_self->operator);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->operator);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":302
 *             return Term_of(e)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_9shuffle = {"shuffle", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_9shuffle, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_9shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("shuffle (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 302, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_8shuffle(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_8shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Operation_shuffle(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":305
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_f_9pyDatalog_8pyEngine_9Operation_chase(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chase); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Operation_11chase)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Term))))) __PYX_ERR(0, 305, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":306
 * 
 *     def chase(self, env): #unify
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))             # <<<<<<<<<<<<<<
 * 
 *     def unify(self, term, env):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lhs, __pyx_n_s_chase); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->rhs, __pyx_n_s_chase); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->operator);
  __Pyx_GIVEREF(__pyx_v_self->operator);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->operator);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":305
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_11chase = {"chase", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_11chase, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11chase(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("chase (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 305, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_10chase(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_10chase(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chase", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_9Operation_chase(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.chase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":308
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_13unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_9Operation_unify(CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, CYTHON_UNUSED PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_9Operation_13unify)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_term), __pyx_v_env};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_term));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_term));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_term));
          __Pyx_INCREF(__pyx_v_env);
          __Pyx_GIVEREF(__pyx_v_env);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_env);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 308, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":309
 * 
 *     def unify(self, term, env):
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":308
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_13unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_13unify = {"unify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_9Operation_13unify, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_13unify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term = 0;
  PyObject *__pyx_v_env = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unify (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,&__pyx_n_s_env,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_term)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, 1); __PYX_ERR(0, 308, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "unify") < 0)) __PYX_ERR(0, 308, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_term = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)values[0]);
    __pyx_v_env = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("unify", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 308, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_term), __pyx_ptype_9pyDatalog_8pyEngine_Term, 1, "term", 0))) __PYX_ERR(0, 308, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 308, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_12unify(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), __pyx_v_term, __pyx_v_env);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_12unify(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v_term, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_9Operation_unify(__pyx_v_self, __pyx_v_term, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":311
 *         return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "(%s%s%s)" % (str(self.lhs), str(self.operator), str(self.rhs))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_15__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_15__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_14__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_14__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":312
 * 
 *     def __str__(self):
 *         return "(%s%s%s)" % (str(self.lhs), str(self.operator), str(self.rhs))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_self->lhs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_self->operator); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_self->rhs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":311
 *         return None
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "(%s%s%s)" % (str(self.lhs), str(self.operator), str(self.rhs))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":45
 * 
 * cdef class Operation(Term):
 *     cpdef public object operator             # <<<<<<<<<<<<<<
 *     cpdef public object operator_id
 *     cpdef public object lhs
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->operator);
  __pyx_r = __pyx_v_self->operator;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->operator);
  __Pyx_DECREF(__pyx_v_self->operator);
  __pyx_v_self->operator = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_8operator_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->operator);
  __Pyx_DECREF(__pyx_v_self->operator);
  __pyx_v_self->operator = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":46
 * cdef class Operation(Term):
 *     cpdef public object operator
 *     cpdef public object operator_id             # <<<<<<<<<<<<<<
 *     cpdef public object lhs
 *     cpdef public object rhs
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->operator_id);
  __pyx_r = __pyx_v_self->operator_id;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->operator_id);
  __Pyx_DECREF(__pyx_v_self->operator_id);
  __pyx_v_self->operator_id = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11operator_id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->operator_id);
  __Pyx_DECREF(__pyx_v_self->operator_id);
  __pyx_v_self->operator_id = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":47
 *     cpdef public object operator
 *     cpdef public object operator_id
 *     cpdef public object lhs             # <<<<<<<<<<<<<<
 *     cpdef public object rhs
 *     cpdef public object is_constant
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->lhs);
  __pyx_r = __pyx_v_self->lhs;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->lhs);
  __Pyx_DECREF(__pyx_v_self->lhs);
  __pyx_v_self->lhs = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3lhs_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->lhs);
  __Pyx_DECREF(__pyx_v_self->lhs);
  __pyx_v_self->lhs = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":48
 *     cpdef public object operator_id
 *     cpdef public object lhs
 *     cpdef public object rhs             # <<<<<<<<<<<<<<
 *     cpdef public object is_constant
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->rhs);
  __pyx_r = __pyx_v_self->rhs;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->rhs);
  __Pyx_DECREF(__pyx_v_self->rhs);
  __pyx_v_self->rhs = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_3rhs_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->rhs);
  __Pyx_DECREF(__pyx_v_self->rhs);
  __pyx_v_self->rhs = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":49
 *     cpdef public object lhs
 *     cpdef public object rhs
 *     cpdef public object is_constant             # <<<<<<<<<<<<<<
 * 
 *     cpdef bool is_const(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->is_constant);
  __pyx_r = __pyx_v_self->is_constant;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->is_constant);
  __Pyx_DECREF(__pyx_v_self->is_constant);
  __pyx_v_self->is_constant = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_9Operation_11is_constant_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->is_constant);
  __Pyx_DECREF(__pyx_v_self->is_constant);
  __pyx_v_self->is_constant = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_17__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_17__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_16__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_16__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.id, self.is_constant, self.lhs, self.operator, self.operator_id, self.rhs)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.id);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.id);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->__pyx_base.id);
  __Pyx_INCREF(__pyx_v_self->is_constant);
  __Pyx_GIVEREF(__pyx_v_self->is_constant);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->is_constant);
  __Pyx_INCREF(__pyx_v_self->lhs);
  __Pyx_GIVEREF(__pyx_v_self->lhs);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->lhs);
  __Pyx_INCREF(__pyx_v_self->operator);
  __Pyx_GIVEREF(__pyx_v_self->operator);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_self->operator);
  __Pyx_INCREF(__pyx_v_self->operator_id);
  __Pyx_GIVEREF(__pyx_v_self->operator_id);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_self->operator_id);
  __Pyx_INCREF(__pyx_v_self->rhs);
  __Pyx_GIVEREF(__pyx_v_self->rhs);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_v_self->rhs);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.id, self.is_constant, self.lhs, self.operator, self.operator_id, self.rhs)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.id, self.is_constant, self.lhs, self.operator, self.operator_id, self.rhs)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.id is not None or self.is_constant is not None or self.lhs is not None or self.operator is not None or self.operator_id is not None or self.rhs is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.id, self.is_constant, self.lhs, self.operator, self.operator_id, self.rhs)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.id is not None or self.is_constant is not None or self.lhs is not None or self.operator is not None or self.operator_id is not None or self.rhs is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->__pyx_base.id != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->is_constant != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->lhs != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->operator != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->operator_id != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->rhs != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None or self.is_constant is not None or self.lhs is not None or self.operator is not None or self.operator_id is not None or self.rhs is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.id is not None or self.is_constant is not None or self.lhs is not None or self.operator is not None or self.operator_id is not None or self.rhs is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Operation); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_149462077);
    __Pyx_GIVEREF(__pyx_int_149462077);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_149462077);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.id is not None or self.is_constant is not None or self.lhs is not None or self.operator is not None or self.operator_id is not None or self.rhs is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, None), state
 *     else:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Operation__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Operation); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_149462077);
    __Pyx_GIVEREF(__pyx_int_149462077);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_149462077);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Operation__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9Operation_19__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_19__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9Operation_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_9Operation_18__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_9Operation_18__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Operation__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Operation__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Operation__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Operation.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":318
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 *     def __eq__(self, other):             # <<<<<<<<<<<<<<
 *         return self is other
 *     def __hash__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8Interned_1__eq__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8Interned_1__eq__ = {"__eq__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_8Interned_1__eq__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8Interned_1__eq__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_other = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__eq__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_other,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__eq__", 1, 2, 2, 1); __PYX_ERR(0, 318, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__eq__") < 0)) __PYX_ERR(0, 318, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_other = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__eq__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 318, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Interned.__eq__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8Interned___eq__(__pyx_self, __pyx_v_self, __pyx_v_other);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8Interned___eq__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__eq__", 0);

  /* "pyDatalog/pyEngine.py":319
 *     notFound = object()
 *     def __eq__(self, other):
 *         return self is other             # <<<<<<<<<<<<<<
 *     def __hash__(self):
 *         return id(self)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = (__pyx_v_self == __pyx_v_other);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":318
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 *     def __eq__(self, other):             # <<<<<<<<<<<<<<
 *         return self is other
 *     def __hash__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Interned.__eq__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":320
 *     def __eq__(self, other):
 *         return self is other
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return id(self)
 *     def __ne__(self, other):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8Interned_3__hash__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8Interned_3__hash__ = {"__hash__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8Interned_3__hash__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8Interned_3__hash__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hash__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8Interned_2__hash__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8Interned_2__hash__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__hash__", 0);

  /* "pyDatalog/pyEngine.py":321
 *         return self is other
 *     def __hash__(self):
 *         return id(self)             # <<<<<<<<<<<<<<
 *     def __ne__(self, other):
 *         return self is not other
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":320
 *     def __eq__(self, other):
 *         return self is other
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return id(self)
 *     def __ne__(self, other):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Interned.__hash__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":322
 *     def __hash__(self):
 *         return id(self)
 *     def __ne__(self, other):             # <<<<<<<<<<<<<<
 *         return self is not other
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8Interned_5__ne__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_8Interned_5__ne__ = {"__ne__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_8Interned_5__ne__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_8Interned_5__ne__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_other = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ne__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_other,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_other)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__ne__", 1, 2, 2, 1); __PYX_ERR(0, 322, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__ne__") < 0)) __PYX_ERR(0, 322, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_other = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__ne__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 322, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Interned.__ne__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8Interned_4__ne__(__pyx_self, __pyx_v_self, __pyx_v_other);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8Interned_4__ne__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__ne__", 0);

  /* "pyDatalog/pyEngine.py":323
 *         return id(self)
 *     def __ne__(self, other):
 *         return self is not other             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = (__pyx_v_self != __pyx_v_other);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":322
 *     def __hash__(self):
 *         return id(self)
 *     def __ne__(self, other):             # <<<<<<<<<<<<<<
 *         return self is not other
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Interned.__ne__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":330
 *         It can also have a function used to implement a primitive."""
 *     lock = threading.RLock()
 *     def __new__(cls, pred_name, arity):             # <<<<<<<<<<<<<<
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Pred_1__new__ = {"__new__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_4Pred_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_pred_name = 0;
  PyObject *__pyx_v_arity = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_pred_name,&__pyx_n_s_arity,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pred_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 1); __PYX_ERR(0, 330, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 2); __PYX_ERR(0, 330, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 330, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_cls = values[0];
    __pyx_v_pred_name = values[1];
    __pyx_v_arity = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 330, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Pred___new__(__pyx_self, __pyx_v_cls, __pyx_v_pred_name, __pyx_v_arity);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_pred_name, PyObject *__pyx_v_arity) {
  PyObject *__pyx_v__id = NULL;
  PyObject *__pyx_v_o = NULL;
  PyObject *__pyx_v_words = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *__pyx_t_15 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__new__", 0);

  /* "pyDatalog/pyEngine.py":331
 *     lock = threading.RLock()
 *     def __new__(cls, pred_name, arity):
 *         assert isinstance(pred_name, util.string_types)             # <<<<<<<<<<<<<<
 *         _id = '%s/%i' % (pred_name, arity)
 *         with Pred.lock:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_string_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = PyObject_IsInstance(__pyx_v_pred_name, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!(__pyx_t_3 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 331, __pyx_L1_error)
    }
  }
  #endif

  /* "pyDatalog/pyEngine.py":332
 *     def __new__(cls, pred_name, arity):
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)             # <<<<<<<<<<<<<<
 *         with Pred.lock:
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_pred_name);
  __Pyx_GIVEREF(__pyx_v_pred_name);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pred_name);
  __Pyx_INCREF(__pyx_v_arity);
  __Pyx_GIVEREF(__pyx_v_arity);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_arity);
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_i, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v__id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":333
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 *         with Pred.lock:             # <<<<<<<<<<<<<<
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 *             if o is Interned.notFound:
 */
  /*with:*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_exit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 333, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        /*try:*/ {

          /* "pyDatalog/pyEngine.py":334
 *         _id = '%s/%i' % (pred_name, arity)
 *         with Pred.lock:
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)             # <<<<<<<<<<<<<<
 *             if o is Interned.notFound:
 *                 o = object.__new__(cls) # o is the ref that keeps it alive
 */
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Pred_registry); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Interned); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_notFound); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 334, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = NULL;
          __pyx_t_10 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_5)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
              __pyx_t_10 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v__id, __pyx_t_6};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v__id, __pyx_t_6};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 334, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            if (__pyx_t_5) {
              __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
            }
            __Pyx_INCREF(__pyx_v__id);
            __Pyx_GIVEREF(__pyx_v__id);
            PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v__id);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_6);
            __pyx_t_6 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v_o = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":335
 *         with Pred.lock:
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 *             if o is Interned.notFound:             # <<<<<<<<<<<<<<
 *                 o = object.__new__(cls) # o is the ref that keeps it alive
 *                 o.id = _id
 */
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Interned); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_notFound); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_3 = (__pyx_v_o == __pyx_t_1);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_12 = (__pyx_t_3 != 0);
          if (__pyx_t_12) {

            /* "pyDatalog/pyEngine.py":336
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 *             if o is Interned.notFound:
 *                 o = object.__new__(cls) # o is the ref that keeps it alive             # <<<<<<<<<<<<<<
 *                 o.id = _id
 *                 o.name = pred_name
 */
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_11 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
              if (likely(__pyx_t_11)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_11);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_2, function);
              }
            }
            __pyx_t_1 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_11, __pyx_v_cls) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_cls);
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF_SET(__pyx_v_o, __pyx_t_1);
            __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":337
 *             if o is Interned.notFound:
 *                 o = object.__new__(cls) # o is the ref that keeps it alive
 *                 o.id = _id             # <<<<<<<<<<<<<<
 *                 o.name = pred_name
 *                 o.arity = arity
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_id, __pyx_v__id) < 0) __PYX_ERR(0, 337, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":338
 *                 o = object.__new__(cls) # o is the ref that keeps it alive
 *                 o.id = _id
 *                 o.name = pred_name             # <<<<<<<<<<<<<<
 *                 o.arity = arity
 *                 o.prearity = None
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_name, __pyx_v_pred_name) < 0) __PYX_ERR(0, 338, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":339
 *                 o.id = _id
 *                 o.name = pred_name
 *                 o.arity = arity             # <<<<<<<<<<<<<<
 *                 o.prearity = None
 *                 words = o.name.split('.')
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_arity, __pyx_v_arity) < 0) __PYX_ERR(0, 339, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":340
 *                 o.name = pred_name
 *                 o.arity = arity
 *                 o.prearity = None             # <<<<<<<<<<<<<<
 *                 words = o.name.split('.')
 *                 o.prefix, o.suffix = (words[0], words[1].split('[')[0]) if 1 < len(words) else ('','')
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_prearity, Py_None) < 0) __PYX_ERR(0, 340, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":341
 *                 o.arity = arity
 *                 o.prearity = None
 *                 words = o.name.split('.')             # <<<<<<<<<<<<<<
 *                 o.prefix, o.suffix = (words[0], words[1].split('[')[0]) if 1 < len(words) else ('','')
 *                 words = pred_name.split(']')
 */
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 341, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11);
              if (likely(__pyx_t_2)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_11, function);
              }
            }
            __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_2, __pyx_kp_s__12) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_kp_s__12);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_v_words = __pyx_t_1;
            __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":342
 *                 o.prearity = None
 *                 words = o.name.split('.')
 *                 o.prefix, o.suffix = (words[0], words[1].split('[')[0]) if 1 < len(words) else ('','')             # <<<<<<<<<<<<<<
 *                 words = pred_name.split(']')
 *                 o.comparison = words[1] if 1 < len(words) else '' # for f[X]<Y
 */
            __pyx_t_13 = PyObject_Length(__pyx_v_words); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 342, __pyx_L7_error)
            if (((1 < __pyx_t_13) != 0)) {
              __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_words, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_11);
              __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_words, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_6 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                if (likely(__pyx_t_6)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_5, function);
                }
              }
              __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_kp_s__2) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_s__2);
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_11);
              PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_11);
              __Pyx_GIVEREF(__pyx_t_5);
              PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
              __pyx_t_11 = 0;
              __pyx_t_5 = 0;
              __pyx_t_1 = __pyx_t_2;
              __pyx_t_2 = 0;
            } else {
              __Pyx_INCREF(__pyx_tuple__15);
              __pyx_t_1 = __pyx_tuple__15;
            }
            if (likely(__pyx_t_1 != Py_None)) {
              PyObject* sequence = __pyx_t_1;
              Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
              if (unlikely(size != 2)) {
                if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                __PYX_ERR(0, 342, __pyx_L7_error)
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_5);
              #else
              __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 342, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              #endif
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            } else {
              __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 342, __pyx_L7_error)
            }
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_prefix, __pyx_t_2) < 0) __PYX_ERR(0, 342, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_suffix, __pyx_t_5) < 0) __PYX_ERR(0, 342, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "pyDatalog/pyEngine.py":343
 *                 words = o.name.split('.')
 *                 o.prefix, o.suffix = (words[0], words[1].split('[')[0]) if 1 < len(words) else ('','')
 *                 words = pred_name.split(']')             # <<<<<<<<<<<<<<
 *                 o.comparison = words[1] if 1 < len(words) else '' # for f[X]<Y
 * 
 */
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred_name, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 343, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_2 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
              if (likely(__pyx_t_2)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_5, function);
              }
            }
            __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_2, __pyx_kp_s__16) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_s__16);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF_SET(__pyx_v_words, __pyx_t_1);
            __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":344
 *                 o.prefix, o.suffix = (words[0], words[1].split('[')[0]) if 1 < len(words) else ('','')
 *                 words = pred_name.split(']')
 *                 o.comparison = words[1] if 1 < len(words) else '' # for f[X]<Y             # <<<<<<<<<<<<<<
 * 
 *                 o.db = OrderedDict()
 */
            __pyx_t_13 = PyObject_Length(__pyx_v_words); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 344, __pyx_L7_error)
            if (((1 < __pyx_t_13) != 0)) {
              __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_words, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 344, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_1 = __pyx_t_5;
              __pyx_t_5 = 0;
            } else {
              __Pyx_INCREF(__pyx_kp_s__14);
              __pyx_t_1 = __pyx_kp_s__14;
            }
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_comparison, __pyx_t_1) < 0) __PYX_ERR(0, 344, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":346
 *                 o.comparison = words[1] if 1 < len(words) else '' # for f[X]<Y
 * 
 *                 o.db = OrderedDict()             # <<<<<<<<<<<<<<
 *                 o.clauses = OrderedDict()
 *                 # one index per term. An index is a dictionary of sets
 */
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_2 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
              if (likely(__pyx_t_2)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_5, function);
              }
            }
            __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_db, __pyx_t_1) < 0) __PYX_ERR(0, 346, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":347
 * 
 *                 o.db = OrderedDict()
 *                 o.clauses = OrderedDict()             # <<<<<<<<<<<<<<
 *                 # one index per term. An index is a dictionary of sets
 *                 o.index = [{} for i in range(int(o.arity))]
 */
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 347, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_2 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
              if (likely(__pyx_t_2)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_5, function);
              }
            }
            __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_clauses, __pyx_t_1) < 0) __PYX_ERR(0, 347, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":349
 *                 o.clauses = OrderedDict()
 *                 # one index per term. An index is a dictionary of sets
 *                 o.index = [{} for i in range(int(o.arity))]             # <<<<<<<<<<<<<<
 *                 o.prim = None
 *                 o.expression = None
 */
            __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_arity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 349, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 349, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
              __pyx_t_2 = __pyx_t_5; __Pyx_INCREF(__pyx_t_2); __pyx_t_13 = 0;
              __pyx_t_14 = NULL;
            } else {
              __pyx_t_13 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_14 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 349, __pyx_L7_error)
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            for (;;) {
              if (likely(!__pyx_t_14)) {
                if (likely(PyList_CheckExact(__pyx_t_2))) {
                  if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_2)) break;
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_13); __Pyx_INCREF(__pyx_t_5); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 349, __pyx_L7_error)
                  #else
                  __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 349, __pyx_L7_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  #endif
                } else {
                  if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_13); __Pyx_INCREF(__pyx_t_5); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 349, __pyx_L7_error)
                  #else
                  __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 349, __pyx_L7_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  #endif
                }
              } else {
                __pyx_t_5 = __pyx_t_14(__pyx_t_2);
                if (unlikely(!__pyx_t_5)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                    else __PYX_ERR(0, 349, __pyx_L7_error)
                  }
                  break;
                }
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5);
              __pyx_t_5 = 0;
              __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 349, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 349, __pyx_L7_error)
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_index, __pyx_t_1) < 0) __PYX_ERR(0, 349, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":350
 *                 # one index per term. An index is a dictionary of sets
 *                 o.index = [{} for i in range(int(o.arity))]
 *                 o.prim = None             # <<<<<<<<<<<<<<
 *                 o.expression = None
 *                 o.recursive = False
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_prim, Py_None) < 0) __PYX_ERR(0, 350, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":351
 *                 o.index = [{} for i in range(int(o.arity))]
 *                 o.prim = None
 *                 o.expression = None             # <<<<<<<<<<<<<<
 *                 o.recursive = False
 *                 Logic.tl.logic.Pred_registry[_id] = o
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_expression, Py_None) < 0) __PYX_ERR(0, 351, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":352
 *                 o.prim = None
 *                 o.expression = None
 *                 o.recursive = False             # <<<<<<<<<<<<<<
 *                 Logic.tl.logic.Pred_registry[_id] = o
 *         return o
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_o, __pyx_n_s_recursive, Py_False) < 0) __PYX_ERR(0, 352, __pyx_L7_error)

            /* "pyDatalog/pyEngine.py":353
 *                 o.expression = None
 *                 o.recursive = False
 *                 Logic.tl.logic.Pred_registry[_id] = o             # <<<<<<<<<<<<<<
 *         return o
 * 
 */
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Pred_registry); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_v__id, __pyx_v_o) < 0)) __PYX_ERR(0, 353, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "pyDatalog/pyEngine.py":335
 *         with Pred.lock:
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 *             if o is Interned.notFound:             # <<<<<<<<<<<<<<
 *                 o = object.__new__(cls) # o is the ref that keeps it alive
 *                 o.id = _id
 */
          }

          /* "pyDatalog/pyEngine.py":333
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 *         with Pred.lock:             # <<<<<<<<<<<<<<
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 *             if o is Interned.notFound:
 */
        }
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L12_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(0, 333, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_11 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 333, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 333, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (__pyx_t_12 < 0) __PYX_ERR(0, 333, __pyx_L9_except_error)
          __pyx_t_3 = ((!(__pyx_t_12 != 0)) != 0);
          if (__pyx_t_3) {
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_XGIVEREF(__pyx_t_5);
            __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_5);
            __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_5 = 0; 
            __PYX_ERR(0, 333, __pyx_L9_except_error)
          }
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L1_error;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        __pyx_L12_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_4) {
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__17, NULL);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 333, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    goto __pyx_L19;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L1_error;
    __pyx_L19:;
  }

  /* "pyDatalog/pyEngine.py":354
 *                 o.recursive = False
 *                 Logic.tl.logic.Pred_registry[_id] = o
 *         return o             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_o)) { __Pyx_RaiseUnboundLocalError("o"); __PYX_ERR(0, 354, __pyx_L1_error) }
  __Pyx_INCREF(__pyx_v_o);
  __pyx_r = __pyx_v_o;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":330
 *         It can also have a function used to implement a primitive."""
 *     lock = threading.RLock()
 *     def __new__(cls, pred_name, arity):             # <<<<<<<<<<<<<<
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__id);
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_XDECREF(__pyx_v_words);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":357
 * 
 *     @classmethod
 *     def is_known(cls, pred_id):             # <<<<<<<<<<<<<<
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_3is_known(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Pred_3is_known = {"is_known", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_4Pred_3is_known, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_3is_known(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_pred_id = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_known (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_pred_id,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pred_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("is_known", 1, 2, 2, 1); __PYX_ERR(0, 357, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "is_known") < 0)) __PYX_ERR(0, 357, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_cls = values[0];
    __pyx_v_pred_id = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("is_known", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 357, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.is_known", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Pred_2is_known(__pyx_self, __pyx_v_cls, __pyx_v_pred_id);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_2is_known(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_pred_id) {
  PyObject *__pyx_v_prefix = NULL;
  PyObject *__pyx_v_rebased = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_known", 0);
  __Pyx_INCREF(__pyx_v_cls);

  /* "pyDatalog/pyEngine.py":359
 *     def is_known(cls, pred_id):
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'             # <<<<<<<<<<<<<<
 *         if prefix in Class_dict:
 *             for cls in Class_dict[prefix].__mro__:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred_id, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s__12) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s__12);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_prefix = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":360
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 *         if prefix in Class_dict:             # <<<<<<<<<<<<<<
 *             for cls in Class_dict[prefix].__mro__:
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Class_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_prefix, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":361
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 *         if prefix in Class_dict:
 *             for cls in Class_dict[prefix].__mro__:             # <<<<<<<<<<<<<<
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 *                 if rebased in Logic.tl.logic.Db:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Class_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_prefix); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_mro); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 361, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_7(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 361, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF_SET(__pyx_v_cls, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":362
 *         if prefix in Class_dict:
 *             for cls in Class_dict[prefix].__mro__:
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence             # <<<<<<<<<<<<<<
 *                 if rebased in Logic.tl.logic.Db:
 *                     return True
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred_id, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls, __pyx_n_s_name_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 362, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_v_prefix, __pyx_t_8, __pyx_int_1};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_v_prefix, __pyx_t_8, __pyx_int_1};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_INCREF(__pyx_v_prefix);
        __Pyx_GIVEREF(__pyx_v_prefix);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_prefix);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_int_1);
        __pyx_t_8 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_rebased, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":363
 *             for cls in Class_dict[prefix].__mro__:
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 *                 if rebased in Logic.tl.logic.Db:             # <<<<<<<<<<<<<<
 *                     return True
 *         return False
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Db); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_rebased, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = (__pyx_t_5 != 0);
      if (__pyx_t_4) {

        /* "pyDatalog/pyEngine.py":364
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 *                 if rebased in Logic.tl.logic.Db:
 *                     return True             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_True);
        __pyx_r = Py_True;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;

        /* "pyDatalog/pyEngine.py":363
 *             for cls in Class_dict[prefix].__mro__:
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 *                 if rebased in Logic.tl.logic.Db:             # <<<<<<<<<<<<<<
 *                     return True
 *         return False
 */
      }

      /* "pyDatalog/pyEngine.py":361
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 *         if prefix in Class_dict:
 *             for cls in Class_dict[prefix].__mro__:             # <<<<<<<<<<<<<<
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 *                 if rebased in Logic.tl.logic.Db:
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":360
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 *         if prefix in Class_dict:             # <<<<<<<<<<<<<<
 *             for cls in Class_dict[prefix].__mro__:
 *                 rebased = pred_id.replace(prefix, cls.__name__, 1) # only the first occurrence
 */
  }

  /* "pyDatalog/pyEngine.py":365
 *                 if rebased in Logic.tl.logic.Db:
 *                     return True
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def _class(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":357
 * 
 *     @classmethod
 *     def is_known(cls, pred_id):             # <<<<<<<<<<<<<<
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.is_known", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_prefix);
  __Pyx_XDECREF(__pyx_v_rebased);
  __Pyx_XDECREF(__pyx_v_cls);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":367
 *         return False
 * 
 *     def _class(self):             # <<<<<<<<<<<<<<
 *         """determine the python class for a prefixed predicate (and caches it)"""
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_5_class(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_4Pred_4_class[] = "determine the python class for a prefixed predicate (and caches it)";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Pred_5_class = {"_class", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Pred_5_class, METH_O, __pyx_doc_9pyDatalog_8pyEngine_4Pred_4_class};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_5_class(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_class (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Pred_4_class(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_4_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_class", 0);

  /* "pyDatalog/pyEngine.py":370
 *         """determine the python class for a prefixed predicate (and caches it)"""
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 *         if not hasattr(self, '_cls'):             # <<<<<<<<<<<<<<
 *             self._cls = Class_dict.get(self.prefix, '') if self.prefix else None
 *         return self._cls
 */
  __pyx_t_1 = __Pyx_HasAttr(__pyx_v_self, __pyx_n_s_cls_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 370, __pyx_L1_error)
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":371
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 *         if not hasattr(self, '_cls'):
 *             self._cls = Class_dict.get(self.prefix, '') if self.prefix else None             # <<<<<<<<<<<<<<
 *         return self._cls
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_prefix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Class_dict); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_prefix); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_kp_s__14};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_kp_s__14};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
        __Pyx_INCREF(__pyx_kp_s__14);
        __Pyx_GIVEREF(__pyx_kp_s__14);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_kp_s__14);
        __pyx_t_5 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_3 = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __Pyx_INCREF(Py_None);
      __pyx_t_3 = Py_None;
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_cls_2, __pyx_t_3) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":370
 *         """determine the python class for a prefixed predicate (and caches it)"""
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 *         if not hasattr(self, '_cls'):             # <<<<<<<<<<<<<<
 *             self._cls = Class_dict.get(self.prefix, '') if self.prefix else None
 *         return self._cls
 */
  }

  /* "pyDatalog/pyEngine.py":372
 *         if not hasattr(self, '_cls'):
 *             self._cls = Class_dict.get(self.prefix, '') if self.prefix else None
 *         return self._cls             # <<<<<<<<<<<<<<
 * 
 *     def parent_classes(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cls_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":367
 *         return False
 * 
 *     def _class(self):             # <<<<<<<<<<<<<<
 *         """determine the python class for a prefixed predicate (and caches it)"""
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred._class", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_4Pred_8generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":374
 *         return self._cls
 * 
 *     def parent_classes(self):             # <<<<<<<<<<<<<<
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_7parent_classes(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_4Pred_6parent_classes[] = " iterator of the parent classes that have pyDatalog capabilities";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Pred_7parent_classes = {"parent_classes", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Pred_7parent_classes, METH_O, __pyx_doc_9pyDatalog_8pyEngine_4Pred_6parent_classes};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_7parent_classes(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("parent_classes (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Pred_6parent_classes(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_6parent_classes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parent_classes", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 374, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_4Pred_8generator, __pyx_codeobj__18, (PyObject *) __pyx_cur_scope, __pyx_n_s_parent_classes, __pyx_n_s_Pred_parent_classes, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.parent_classes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_4Pred_8generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("parent_classes", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L12_resume_from_yield;
    case 2: goto __pyx_L13_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 374, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":376
 *     def parent_classes(self):
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():             # <<<<<<<<<<<<<<
 *             for cls in self._cls.__mro__:
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "pyDatalog/pyEngine.py":377
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 *             for cls in self._cls.__mro__:             # <<<<<<<<<<<<<<
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):
 *                     yield cls
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_cls_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_mro); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 377, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 377, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 377, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_6(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 377, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_cls);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_cls, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":378
 *         if self._class():
 *             for cls in self._cls.__mro__:
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):             # <<<<<<<<<<<<<<
 *                     yield cls
 *         else:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_cls, __pyx_n_s_name_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Class_dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = (__pyx_t_7 != 0);
      if (__pyx_t_8) {
      } else {
        __pyx_t_4 = __pyx_t_8;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_cls, __pyx_n_s_name_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_Mixin, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 378, __pyx_L1_error)
      if (__pyx_t_7) {
      } else {
        __pyx_t_8 = __pyx_t_7;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_object, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 378, __pyx_L1_error)
      __pyx_t_8 = __pyx_t_7;
      __pyx_L10_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = (__pyx_t_8 != 0);
      __pyx_t_4 = __pyx_t_7;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_4) {

        /* "pyDatalog/pyEngine.py":379
 *             for cls in self._cls.__mro__:
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):
 *                     yield cls             # <<<<<<<<<<<<<<
 *         else:
 *             yield None
 */
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_cls);
        __pyx_r = __pyx_cur_scope->__pyx_v_cls;
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, yielding value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L12_resume_from_yield:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
        __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 379, __pyx_L1_error)

        /* "pyDatalog/pyEngine.py":378
 *         if self._class():
 *             for cls in self._cls.__mro__:
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):             # <<<<<<<<<<<<<<
 *                     yield cls
 *         else:
 */
      }

      /* "pyDatalog/pyEngine.py":377
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 *             for cls in self._cls.__mro__:             # <<<<<<<<<<<<<<
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):
 *                     yield cls
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":376
 *     def parent_classes(self):
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():             # <<<<<<<<<<<<<<
 *             for cls in self._cls.__mro__:
 *                 if cls.__name__ in Class_dict and cls.__name__ not in ('Mixin', 'object'):
 */
    goto __pyx_L4;
  }

  /* "pyDatalog/pyEngine.py":381
 *                     yield cls
 *         else:
 *             yield None             # <<<<<<<<<<<<<<
 * 
 *     def reset_clauses(self):
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L13_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 381, __pyx_L1_error)
  }
  __pyx_L4:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pyDatalog/pyEngine.py":374
 *         return self._cls
 * 
 *     def parent_classes(self):             # <<<<<<<<<<<<<<
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("parent_classes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":383
 *             yield None
 * 
 *     def reset_clauses(self):             # <<<<<<<<<<<<<<
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_10reset_clauses(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_4Pred_9reset_clauses[] = " clears the database of clauses for the predicate ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Pred_10reset_clauses = {"reset_clauses", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Pred_10reset_clauses, METH_O, __pyx_doc_9pyDatalog_8pyEngine_4Pred_9reset_clauses};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_10reset_clauses(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset_clauses (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Pred_9reset_clauses(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_9reset_clauses(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_clause = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reset_clauses", 0);

  /* "pyDatalog/pyEngine.py":385
 *     def reset_clauses(self):
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():             # <<<<<<<<<<<<<<
 *             retract(clause)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_clauses); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 385, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 385, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 385, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_clause, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":386
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():
 *             retract(clause)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_retract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_v_clause) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_clause);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":385
 *     def reset_clauses(self):
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():             # <<<<<<<<<<<<<<
 *             retract(clause)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":383
 *             yield None
 * 
 *     def reset_clauses(self):             # <<<<<<<<<<<<<<
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.reset_clauses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_clause);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":388
 *             retract(clause)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s()" % self.name
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_12__str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_4Pred_12__str__ = {"__str__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Pred_12__str__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_4Pred_12__str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4Pred_11__str__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4Pred_11__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":389
 * 
 *     def __str__(self):
 *         return "%s()" % self.name             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_s_2, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":388
 *             retract(clause)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s()" % self.name
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Pred.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":397
 *     """
 *     __slots__ = ['terms', 'pred', 'id', 'tag', 'aggregate']
 *     def __init__(self, pred, terms, prearity=None, aggregate=None):             # <<<<<<<<<<<<<<
 *         self.terms = terms
 *         self.aggregate = aggregate
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pred = 0;
  PyObject *__pyx_v_terms = 0;
  PyObject *__pyx_v_prearity = 0;
  PyObject *__pyx_v_aggregate = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pred,&__pyx_n_s_terms,&__pyx_n_s_prearity,&__pyx_n_s_aggregate,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pred)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_terms)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); __PYX_ERR(0, 397, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_prearity);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_aggregate);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 397, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pred = values[0];
    __pyx_v_terms = values[1];
    __pyx_v_prearity = values[2];
    __pyx_v_aggregate = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 397, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), __pyx_v_pred, __pyx_v_terms, __pyx_v_prearity, __pyx_v_aggregate);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_pred, PyObject *__pyx_v_terms, PyObject *__pyx_v_prearity, PyObject *__pyx_v_aggregate) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":398
 *     __slots__ = ['terms', 'pred', 'id', 'tag', 'aggregate']
 *     def __init__(self, pred, terms, prearity=None, aggregate=None):
 *         self.terms = terms             # <<<<<<<<<<<<<<
 *         self.aggregate = aggregate
 *         self.id, self.tag = None, None
 */
  if (!(likely(PyList_CheckExact(__pyx_v_terms))||((__pyx_v_terms) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_terms)->tp_name), 0))) __PYX_ERR(0, 398, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_terms;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->terms);
  __Pyx_DECREF(__pyx_v_self->terms);
  __pyx_v_self->terms = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":399
 *     def __init__(self, pred, terms, prearity=None, aggregate=None):
 *         self.terms = terms
 *         self.aggregate = aggregate             # <<<<<<<<<<<<<<
 *         self.id, self.tag = None, None
 *         if isinstance(pred, util.string_types):
 */
  __Pyx_INCREF(__pyx_v_aggregate);
  __Pyx_GIVEREF(__pyx_v_aggregate);
  __Pyx_GOTREF(__pyx_v_self->aggregate);
  __Pyx_DECREF(__pyx_v_self->aggregate);
  __pyx_v_self->aggregate = __pyx_v_aggregate;

  /* "pyDatalog/pyEngine.py":400
 *         self.terms = terms
 *         self.aggregate = aggregate
 *         self.id, self.tag = None, None             # <<<<<<<<<<<<<<
 *         if isinstance(pred, util.string_types):
 *             self.pred = Pred(pred, len(terms))
 */
  __pyx_t_1 = Py_None;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = Py_None;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->tag);
  __Pyx_DECREF(__pyx_v_self->tag);
  __pyx_v_self->tag = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":401
 *         self.aggregate = aggregate
 *         self.id, self.tag = None, None
 *         if isinstance(pred, util.string_types):             # <<<<<<<<<<<<<<
 *             self.pred = Pred(pred, len(terms))
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_string_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_pred, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "pyDatalog/pyEngine.py":402
 *         self.id, self.tag = None, None
 *         if isinstance(pred, util.string_types):
 *             self.pred = Pred(pred, len(terms))             # <<<<<<<<<<<<<<
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 *             if pred.startswith('~'): #pred
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_Length(__pyx_v_terms); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 402, __pyx_L1_error)
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_pred, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_pred, __pyx_t_6};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 402, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_pred);
      __Pyx_GIVEREF(__pyx_v_pred);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_pred);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->pred);
    __Pyx_DECREF(__pyx_v_self->pred);
    __pyx_v_self->pred = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":403
 *         if isinstance(pred, util.string_types):
 *             self.pred = Pred(pred, len(terms))
 *             self.pred.prearity = len(terms) if prearity is None else prearity             # <<<<<<<<<<<<<<
 *             if pred.startswith('~'): #pred
 *                 self.pred.base_pred = Pred(pred[1:], len(terms))
 */
    __pyx_t_4 = (__pyx_v_prearity == Py_None);
    if ((__pyx_t_4 != 0)) {
      __pyx_t_5 = PyObject_Length(__pyx_v_terms); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 403, __pyx_L1_error)
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __pyx_t_2;
      __pyx_t_2 = 0;
    } else {
      __Pyx_INCREF(__pyx_v_prearity);
      __pyx_t_1 = __pyx_v_prearity;
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self->pred, __pyx_n_s_prearity, __pyx_t_1) < 0) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":404
 *             self.pred = Pred(pred, len(terms))
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 *             if pred.startswith('~'): #pred             # <<<<<<<<<<<<<<
 *                 self.pred.base_pred = Pred(pred[1:], len(terms))
 *                 self.pred.base_pred.prearity = self.pred.prearity
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_startswith); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_kp_s__19) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s__19);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 404, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":405
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 *             if pred.startswith('~'): #pred
 *                 self.pred.base_pred = Pred(pred[1:], len(terms))             # <<<<<<<<<<<<<<
 *                 self.pred.base_pred.prearity = self.pred.prearity
 *         else:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_PyObject_GetSlice(__pyx_v_pred, 1, 0, NULL, NULL, &__pyx_slice__20, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 405, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = PyObject_Length(__pyx_v_terms); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 405, __pyx_L1_error)
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 405, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_9, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_9, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_8, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_8, __pyx_t_6);
        __pyx_t_9 = 0;
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self->pred, __pyx_n_s_base_pred, __pyx_t_1) < 0) __PYX_ERR(0, 405, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":406
 *             if pred.startswith('~'): #pred
 *                 self.pred.base_pred = Pred(pred[1:], len(terms))
 *                 self.pred.base_pred.prearity = self.pred.prearity             # <<<<<<<<<<<<<<
 *         else:
 *             self.pred = pred
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_prearity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_base_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_prearity, __pyx_t_1) < 0) __PYX_ERR(0, 406, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":404
 *             self.pred = Pred(pred, len(terms))
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 *             if pred.startswith('~'): #pred             # <<<<<<<<<<<<<<
 *                 self.pred.base_pred = Pred(pred[1:], len(terms))
 *                 self.pred.base_pred.prearity = self.pred.prearity
 */
    }

    /* "pyDatalog/pyEngine.py":401
 *         self.aggregate = aggregate
 *         self.id, self.tag = None, None
 *         if isinstance(pred, util.string_types):             # <<<<<<<<<<<<<<
 *             self.pred = Pred(pred, len(terms))
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":408
 *                 self.pred.base_pred.prearity = self.pred.prearity
 *         else:
 *             self.pred = pred             # <<<<<<<<<<<<<<
 *             # TODO assert self.pred.prearity == (prearity or len(terms)), "Error: Incorrect mix of predicates and functions : %s" % str(self)
 * 
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_pred);
    __Pyx_GIVEREF(__pyx_v_pred);
    __Pyx_GOTREF(__pyx_v_self->pred);
    __Pyx_DECREF(__pyx_v_self->pred);
    __pyx_v_self->pred = __pyx_v_pred;
  }
  __pyx_L3:;

  /* "pyDatalog/pyEngine.py":397
 *     """
 *     __slots__ = ['terms', 'pred', 'id', 'tag', 'aggregate']
 *     def __init__(self, pred, terms, prearity=None, aggregate=None):             # <<<<<<<<<<<<<<
 *         self.terms = terms
 *         self.aggregate = aggregate
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":411
 *             # TODO assert self.pred.prearity == (prearity or len(terms)), "Error: Incorrect mix of predicates and functions : %s" % str(self)
 * 
 *     def _renamed(self, new_name):             # <<<<<<<<<<<<<<
 *         _id = '%s/%i' % (new_name, len(self.terms))
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_3_renamed(PyObject *__pyx_v_self, PyObject *__pyx_v_new_name); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_3_renamed = {"_renamed", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_3_renamed, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_3_renamed(PyObject *__pyx_v_self, PyObject *__pyx_v_new_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_renamed (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_2_renamed(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_new_name));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_2_renamed(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_new_name) {
  PyObject *__pyx_v__id = NULL;
  PyObject *__pyx_v_pred = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_renamed", 0);

  /* "pyDatalog/pyEngine.py":412
 * 
 *     def _renamed(self, new_name):
 *         _id = '%s/%i' % (new_name, len(self.terms))             # <<<<<<<<<<<<<<
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)
 */
  __pyx_t_1 = __pyx_v_self->terms;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 412, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_new_name);
  __Pyx_GIVEREF(__pyx_v_new_name);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_new_name);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_i, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v__id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":413
 *     def _renamed(self, new_name):
 *         _id = '%s/%i' % (new_name, len(self.terms))
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)             # <<<<<<<<<<<<<<
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tl); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Pred_registry); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v__id, __pyx_v_new_name};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v__id, __pyx_v_new_name};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v__id);
    __Pyx_GIVEREF(__pyx_v__id);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v__id);
    __Pyx_INCREF(__pyx_v_new_name);
    __Pyx_GIVEREF(__pyx_v_new_name);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_new_name);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_pred = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":414
 *         _id = '%s/%i' % (new_name, len(self.terms))
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)             # <<<<<<<<<<<<<<
 * 
 *     def rebased(self, parent_class):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_List(__pyx_v_self->terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_pred);
  __Pyx_GIVEREF(__pyx_v_pred);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_pred);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_prearity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_prearity, __pyx_t_6) < 0) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_aggregate, __pyx_v_self->aggregate) < 0) __PYX_ERR(0, 414, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":411
 *             # TODO assert self.pred.prearity == (prearity or len(terms)), "Error: Incorrect mix of predicates and functions : %s" % str(self)
 * 
 *     def _renamed(self, new_name):             # <<<<<<<<<<<<<<
 *         _id = '%s/%i' % (new_name, len(self.terms))
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal._renamed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v__id);
  __Pyx_XDECREF(__pyx_v_pred);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":416
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)
 * 
 *     def rebased(self, parent_class):             # <<<<<<<<<<<<<<
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_5rebased(PyObject *__pyx_v_self, PyObject *__pyx_v_parent_class); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_4rebased[] = " returns a literal prefixed by parent class ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_5rebased = {"rebased", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_5rebased, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Literal_4rebased};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_5rebased(PyObject *__pyx_v_self, PyObject *__pyx_v_parent_class) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rebased (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_4rebased(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_parent_class));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_4rebased(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_parent_class) {
  PyObject *__pyx_v_pred = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rebased", 0);

  /* "pyDatalog/pyEngine.py":418
 *     def rebased(self, parent_class):
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred             # <<<<<<<<<<<<<<
 *         if not parent_class or not pred._class() or parent_class == pred._class():
 *             return self
 */
  __pyx_t_1 = __pyx_v_self->pred;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_pred = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":419
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred
 *         if not parent_class or not pred._class() or parent_class == pred._class():             # <<<<<<<<<<<<<<
 *             return self
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_parent_class); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 419, __pyx_L1_error)
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_class); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_4) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_class); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_parent_class, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":420
 *         pred = self.pred
 *         if not parent_class or not pred._class() or parent_class == pred._class():
 *             return self             # <<<<<<<<<<<<<<
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":419
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred
 *         if not parent_class or not pred._class() or parent_class == pred._class():             # <<<<<<<<<<<<<<
 *             return self
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 */
  }

  /* "pyDatalog/pyEngine.py":421
 *         if not parent_class or not pred._class() or parent_class == pred._class():
 *             return self
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))             # <<<<<<<<<<<<<<
 * 
 *     def equalized(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_renamed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_re); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sub); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_class); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  __pyx_t_7 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_name_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyNumber_Add(__pyx_kp_s__21, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_kp_s__12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_parent_class, __pyx_n_s_name_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_10 = PyNumber_Add(__pyx_kp_s_1, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyNumber_Add(__pyx_t_10, __pyx_kp_s__12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = NULL;
  __pyx_t_12 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_12 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_9, __pyx_t_7, __pyx_t_10};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_9, __pyx_t_7, __pyx_t_10};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_13 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, __pyx_t_10);
    __pyx_t_9 = 0;
    __pyx_t_7 = 0;
    __pyx_t_10 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":416
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)
 * 
 *     def rebased(self, parent_class):             # <<<<<<<<<<<<<<
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.rebased", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pred);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":423
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 * 
 *     def equalized(self):             # <<<<<<<<<<<<<<
 *         """ returns a new literal with '==' instead of comparison """
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_7equalized(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_6equalized[] = " returns a new literal with '==' instead of comparison ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_7equalized = {"equalized", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_7equalized, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_6equalized};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_7equalized(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equalized (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_6equalized(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_6equalized(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("equalized", 0);

  /* "pyDatalog/pyEngine.py":425
 *     def equalized(self):
 *         """ returns a new literal with '==' instead of comparison """
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))             # <<<<<<<<<<<<<<
 * 
 *     def subst_first(self, env): #prefixed
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_renamed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_replace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_comparison); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_kp_s_};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_kp_s_};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
    __Pyx_INCREF(__pyx_kp_s_);
    __Pyx_GIVEREF(__pyx_kp_s_);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_kp_s_);
    __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":423
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 * 
 *     def equalized(self):             # <<<<<<<<<<<<<<
 *         """ returns a new literal with '==' instead of comparison """
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.equalized", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":427
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 * 
 *     def subst_first(self, env): #prefixed             # <<<<<<<<<<<<<<
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_9subst_first(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_8subst_first[] = " substitute the first term of prefixed literal, using env ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_9subst_first = {"subst_first", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_9subst_first, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Literal_8subst_first};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_9subst_first(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst_first (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_8subst_first(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_env));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_8subst_first(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst_first", 0);

  /* "pyDatalog/pyEngine.py":429
 *     def subst_first(self, env): #prefixed
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:             # <<<<<<<<<<<<<<
 *             self.terms[0] = self.terms[0].subst(env)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_prefix); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":430
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:
 *             self.terms[0] = self.terms[0].subst(env)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    if (unlikely(__pyx_v_self->terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 430, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_self->terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_subst); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__pyx_v_self->terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 430, __pyx_L1_error)
    }
    if (unlikely(__Pyx_SetItemInt(__pyx_v_self->terms, 0, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":429
 *     def subst_first(self, env): #prefixed
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:             # <<<<<<<<<<<<<<
 *             self.terms[0] = self.terms[0].subst(env)
 * 
 */
  }

  /* "pyDatalog/pyEngine.py":427
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 * 
 *     def subst_first(self, env): #prefixed             # <<<<<<<<<<<<<<
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.subst_first", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":432
 *             self.terms[0] = self.terms[0].subst(env)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_11__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_11__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_10__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_10__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "pyDatalog/pyEngine.py":433
 * 
 *     def __str__(self):
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))             # <<<<<<<<<<<<<<
 * 
 *     def get_id(self): #id
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 433, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_self->terms; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 433, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_term); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_replace); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__22, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":432
 *             self.terms[0] = self.terms[0].subst(env)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":435
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two literals are structurally the
 *             same if they have the same id.  """
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_13get_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_get_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_id", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_13get_id)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 435, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":438
 *         """ The id's encoding ensures that two literals are structurally the
 *             same if they have the same id.  """
 *         if not self.id: # cached             # <<<<<<<<<<<<<<
 *             #Cython for : self.id = (self.pred.id,) + tuple(term.id for term in self.terms)
 *             result = [self.pred.id,]
 */
  __pyx_t_5 = (__pyx_v_self->id != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->id) != 0);
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {

    /* "pyDatalog/pyEngine.py":440
 *         if not self.id: # cached
 *             #Cython for : self.id = (self.pred.id,) + tuple(term.id for term in self.terms)
 *             result = [self.pred.id,]             # <<<<<<<<<<<<<<
 *             for term in self.terms:
 *                 result.append(term.id)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_result = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":441
 *             #Cython for : self.id = (self.pred.id,) + tuple(term.id for term in self.terms)
 *             result = [self.pred.id,]
 *             for term in self.terms:             # <<<<<<<<<<<<<<
 *                 result.append(term.id)
 *             self.id = tuple(result)
 */
    if (unlikely(__pyx_v_self->terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 441, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_self->terms; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
    for (;;) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":442
 *             result = [self.pred.id,]
 *             for term in self.terms:
 *                 result.append(term.id)             # <<<<<<<<<<<<<<
 *             self.id = tuple(result)
 *         return self.id
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 442, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":441
 *             #Cython for : self.id = (self.pred.id,) + tuple(term.id for term in self.terms)
 *             result = [self.pred.id,]
 *             for term in self.terms:             # <<<<<<<<<<<<<<
 *                 result.append(term.id)
 *             self.id = tuple(result)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":443
 *             for term in self.terms:
 *                 result.append(term.id)
 *             self.id = tuple(result)             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */
    __pyx_t_2 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->id);
    __Pyx_DECREF(__pyx_v_self->id);
    __pyx_v_self->id = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":438
 *         """ The id's encoding ensures that two literals are structurally the
 *             same if they have the same id.  """
 *         if not self.id: # cached             # <<<<<<<<<<<<<<
 *             #Cython for : self.id = (self.pred.id,) + tuple(term.id for term in self.terms)
 *             result = [self.pred.id,]
 */
  }

  /* "pyDatalog/pyEngine.py":444
 *                 result.append(term.id)
 *             self.id = tuple(result)
 *         return self.id             # <<<<<<<<<<<<<<
 * 
 *     def get_fact_id(self): #id
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->id);
  __pyx_r = __pyx_v_self->id;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":435
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two literals are structurally the
 *             same if they have the same id.  """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.get_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_13get_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_12get_id[] = " The id's encoding ensures that two literals are structurally the\n            same if they have the same id.  ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_13get_id = {"get_id", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_13get_id, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_12get_id};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_13get_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_id (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_12get_id(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_12get_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_id", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Literal_get_id(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.get_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":446
 *         return self.id
 * 
 *     def get_fact_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id of a known fact is limited by its prearity
 *             Prearity is used to ensure unicity of results of functions like pred[2]==1 """
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_15get_fact_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_get_fact_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_fact_id", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_fact_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_15get_fact_id)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 446, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 446, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":449
 *         """ The id of a known fact is limited by its prearity
 *             Prearity is used to ensure unicity of results of functions like pred[2]==1 """
 *         return self.get_id()[:1+self.pred.prearity]             # <<<<<<<<<<<<<<
 * 
 *     def get_tag(self): #id
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->__pyx_vtab)->get_id(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 449, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_prearity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_AddCObj(__pyx_int_1, __pyx_t_2, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = (__pyx_t_3 == Py_None);
  if (__pyx_t_6) {
    __pyx_t_5 = PY_SSIZE_T_MAX;
  } else {
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 449, __pyx_L1_error)
    __pyx_t_5 = __pyx_t_7;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyTuple_GetSlice(__pyx_t_1, 0, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":446
 *         return self.id
 * 
 *     def get_fact_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id of a known fact is limited by its prearity
 *             Prearity is used to ensure unicity of results of functions like pred[2]==1 """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.get_fact_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_15get_fact_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_14get_fact_id[] = " The id of a known fact is limited by its prearity\n            Prearity is used to ensure unicity of results of functions like pred[2]==1 ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_15get_fact_id = {"get_fact_id", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_15get_fact_id, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_14get_fact_id};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_15get_fact_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_fact_id (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_14get_fact_id(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_14get_fact_id(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_fact_id", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Literal_get_fact_id(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.get_fact_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":451
 *         return self.get_id()[:1+self.pred.prearity]
 * 
 *     def get_tag(self): #id             # <<<<<<<<<<<<<<
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_17get_tag(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_17get_tag)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 451, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":453
 *     def get_tag(self): #id
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached             # <<<<<<<<<<<<<<
 *             env = {}
 *             #Cython equivalent for : self.tag = (self.pred.id,) + tuple(term.get_tag(env) for term in self.terms)
 */
  __pyx_t_5 = (__pyx_v_self->tag != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_self->tag) != 0);
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {

    /* "pyDatalog/pyEngine.py":454
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached
 *             env = {}             # <<<<<<<<<<<<<<
 *             #Cython equivalent for : self.tag = (self.pred.id,) + tuple(term.get_tag(env) for term in self.terms)
 *             result = [self.pred.id,]
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_env = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":456
 *             env = {}
 *             #Cython equivalent for : self.tag = (self.pred.id,) + tuple(term.get_tag(env) for term in self.terms)
 *             result = [self.pred.id,]             # <<<<<<<<<<<<<<
 *             for term in self.terms:
 *                 result.append(term.get_tag(env))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pred, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_result = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":457
 *             #Cython equivalent for : self.tag = (self.pred.id,) + tuple(term.get_tag(env) for term in self.terms)
 *             result = [self.pred.id,]
 *             for term in self.terms:             # <<<<<<<<<<<<<<
 *                 result.append(term.get_tag(env))
 *             self.tag = tuple(result)
 */
    if (unlikely(__pyx_v_self->terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 457, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_self->terms; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
    for (;;) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 457, __pyx_L1_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":458
 *             result = [self.pred.id,]
 *             for term in self.terms:
 *                 result.append(term.get_tag(env))             # <<<<<<<<<<<<<<
 *             self.tag = tuple(result)
 *         return self.tag
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_get_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 458, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":457
 *             #Cython equivalent for : self.tag = (self.pred.id,) + tuple(term.get_tag(env) for term in self.terms)
 *             result = [self.pred.id,]
 *             for term in self.terms:             # <<<<<<<<<<<<<<
 *                 result.append(term.get_tag(env))
 *             self.tag = tuple(result)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":459
 *             for term in self.terms:
 *                 result.append(term.get_tag(env))
 *             self.tag = tuple(result)             # <<<<<<<<<<<<<<
 *         return self.tag
 * 
 */
    __pyx_t_2 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->tag);
    __Pyx_DECREF(__pyx_v_self->tag);
    __pyx_v_self->tag = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":453
 *     def get_tag(self): #id
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached             # <<<<<<<<<<<<<<
 *             env = {}
 *             #Cython equivalent for : self.tag = (self.pred.id,) + tuple(term.get_tag(env) for term in self.terms)
 */
  }

  /* "pyDatalog/pyEngine.py":460
 *                 result.append(term.get_tag(env))
 *             self.tag = tuple(result)
 *         return self.tag             # <<<<<<<<<<<<<<
 * 
 *     def subst(self, env): #unify
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->tag);
  __pyx_r = __pyx_v_self->tag;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":451
 *         return self.get_id()[:1+self.pred.prearity]
 * 
 *     def get_tag(self): #id             # <<<<<<<<<<<<<<
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_17get_tag(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_16get_tag[] = " the tag is used as a key by the subgoal table ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_17get_tag = {"get_tag", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_17get_tag, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_16get_tag};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_17get_tag(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_tag (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_16get_tag(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_16get_tag(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_tag", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Literal_get_tag(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.get_tag", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":462
 *         return self.tag
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if not env: return self
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_19subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_f_9pyDatalog_8pyEngine_7Literal_subst(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_term = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_19subst)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(0, 462, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":463
 * 
 *     def subst(self, env): #unify
 *         if not env: return self             # <<<<<<<<<<<<<<
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 *         result = []
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_env); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 463, __pyx_L1_error)
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":465
 *         if not env: return self
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 *         result = []             # <<<<<<<<<<<<<<
 *         for term in self.terms:
 *             result.append(term if isinstance(term, Const) else term.subst(env))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":466
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 *         result = []
 *         for term in self.terms:             # <<<<<<<<<<<<<<
 *             result.append(term if isinstance(term, Const) else term.subst(env))
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 */
  if (unlikely(__pyx_v_self->terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 466, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_self->terms; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
  for (;;) {
    if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 466, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":467
 *         result = []
 *         for term in self.terms:
 *             result.append(term if isinstance(term, Const) else term.subst(env))             # <<<<<<<<<<<<<<
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_term, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
    if ((__pyx_t_6 != 0)) {
      __Pyx_INCREF(__pyx_v_term);
      __pyx_t_2 = __pyx_v_term;
    } else {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_subst); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 467, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 467, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 467, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":466
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 *         result = []
 *         for term in self.terms:             # <<<<<<<<<<<<<<
 *             result.append(term if isinstance(term, Const) else term.subst(env))
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":468
 *         for term in self.terms:
 *             result.append(term if isinstance(term, Const) else term.subst(env))
 *         return Literal(self.pred, result, aggregate=self.aggregate)             # <<<<<<<<<<<<<<
 * 
 *     def shuffle(self, env): #shuffle
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->pred);
  __Pyx_GIVEREF(__pyx_v_self->pred);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->pred);
  __Pyx_INCREF(__pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_result);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_aggregate, __pyx_v_self->aggregate) < 0) __PYX_ERR(0, 468, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":462
 *         return self.tag
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if not env: return self
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_19subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_19subst = {"subst", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_19subst, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_19subst(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 462, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_18subst(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_18subst(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_9pyDatalog_8pyEngine_7Literal_subst(__pyx_v_self, __pyx_v_env, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":470
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         result = []
 *         for term in self.terms:
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_21shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shuffle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_21shuffle)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":471
 * 
 *     def shuffle(self, env): #shuffle
 *         result = []             # <<<<<<<<<<<<<<
 *         for term in self.terms:
 *             result.append(term if isinstance(term, Const) else term.shuffle(env))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":472
 *     def shuffle(self, env): #shuffle
 *         result = []
 *         for term in self.terms:             # <<<<<<<<<<<<<<
 *             result.append(term if isinstance(term, Const) else term.shuffle(env))
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 */
  if (unlikely(__pyx_v_self->terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 472, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_self->terms; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 472, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":473
 *         result = []
 *         for term in self.terms:
 *             result.append(term if isinstance(term, Const) else term.shuffle(env))             # <<<<<<<<<<<<<<
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 */
    __pyx_t_6 = __Pyx_TypeCheck(__pyx_v_term, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
    if ((__pyx_t_6 != 0)) {
      __Pyx_INCREF(__pyx_v_term);
      __pyx_t_2 = __pyx_v_term;
    } else {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 473, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 473, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":472
 *     def shuffle(self, env): #shuffle
 *         result = []
 *         for term in self.terms:             # <<<<<<<<<<<<<<
 *             result.append(term if isinstance(term, Const) else term.shuffle(env))
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":474
 *         for term in self.terms:
 *             result.append(term if isinstance(term, Const) else term.shuffle(env))
 *         return Literal(self.pred, result, aggregate=self.aggregate)             # <<<<<<<<<<<<<<
 * 
 *     def unify(self, other): #unify
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->pred);
  __Pyx_GIVEREF(__pyx_v_self->pred);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->pred);
  __Pyx_INCREF(__pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_result);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_aggregate, __pyx_v_self->aggregate) < 0) __PYX_ERR(0, 474, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":470
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         result = []
 *         for term in self.terms:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_21shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_21shuffle = {"shuffle", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_21shuffle, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_21shuffle(PyObject *__pyx_v_self, PyObject *__pyx_v_env) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("shuffle (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_env), (&PyDict_Type), 1, "env", 1))) __PYX_ERR(0, 470, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_20shuffle(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject*)__pyx_v_env));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_20shuffle(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_env) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("shuffle", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Literal_shuffle(__pyx_v_self, __pyx_v_env, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.shuffle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":476
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def unify(self, other): #unify             # <<<<<<<<<<<<<<
 *         if self.pred != other.pred: return None
 *         env = {}
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_23unify(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_unify(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_other, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_v_otherterm = NULL;
  PyObject *__pyx_v_literal_i = NULL;
  PyObject *__pyx_v_other_i = NULL;
  int __pyx_v_todo;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_new_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_23unify)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_other)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 476, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 476, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":477
 * 
 *     def unify(self, other): #unify
 *         if self.pred != other.pred: return None             # <<<<<<<<<<<<<<
 *         env = {}
 *         for term, otherterm in zip(self.terms, other.terms):
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_self->pred, __pyx_v_other->pred, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 477, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":478
 *     def unify(self, other): #unify
 *         if self.pred != other.pred: return None
 *         env = {}             # <<<<<<<<<<<<<<
 *         for term, otherterm in zip(self.terms, other.terms):
 *             literal_i = term if isinstance(term, Const) else term.chase(env)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_env = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":479
 *         if self.pred != other.pred: return None
 *         env = {}
 *         for term, otherterm in zip(self.terms, other.terms):             # <<<<<<<<<<<<<<
 *             literal_i = term if isinstance(term, Const) else term.chase(env)
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->terms);
  __Pyx_GIVEREF(__pyx_v_self->terms);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->terms);
  __Pyx_INCREF(__pyx_v_other->terms);
  __Pyx_GIVEREF(__pyx_v_other->terms);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_other->terms);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 479, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 479, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 479, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 479, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 479, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 479, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_otherterm, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pyDatalog/pyEngine.py":480
 *         env = {}
 *         for term, otherterm in zip(self.terms, other.terms):
 *             literal_i = term if isinstance(term, Const) else term.chase(env)             # <<<<<<<<<<<<<<
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)
 *             if literal_i.id != other_i.id:
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_term, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
    if ((__pyx_t_5 != 0)) {
      __Pyx_INCREF(__pyx_v_term);
      __pyx_t_2 = __pyx_v_term;
    } else {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_chase); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 480, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __Pyx_XDECREF_SET(__pyx_v_literal_i, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":481
 *         for term, otherterm in zip(self.terms, other.terms):
 *             literal_i = term if isinstance(term, Const) else term.chase(env)
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)             # <<<<<<<<<<<<<<
 *             if literal_i.id != other_i.id:
 *                 env = literal_i.unify(other_i, env)
 */
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_otherterm, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
    if ((__pyx_t_5 != 0)) {
      __Pyx_INCREF(__pyx_v_otherterm);
      __pyx_t_2 = __pyx_v_otherterm;
    } else {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_otherterm, __pyx_n_s_chase); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 481, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __Pyx_XDECREF_SET(__pyx_v_other_i, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":482
 *             literal_i = term if isinstance(term, Const) else term.chase(env)
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)
 *             if literal_i.id != other_i.id:             # <<<<<<<<<<<<<<
 *                 env = literal_i.unify(other_i, env)
 *                 if env is None: return env
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal_i, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_other_i, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 482, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_5) {

      /* "pyDatalog/pyEngine.py":483
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)
 *             if literal_i.id != other_i.id:
 *                 env = literal_i.unify(other_i, env)             # <<<<<<<<<<<<<<
 *                 if env is None: return env
 *         todo = True
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal_i, __pyx_n_s_unify); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 483, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_other_i, __pyx_v_env};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 483, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_other_i, __pyx_v_env};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 483, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 483, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__pyx_t_2) {
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
        }
        __Pyx_INCREF(__pyx_v_other_i);
        __Pyx_GIVEREF(__pyx_v_other_i);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_v_other_i);
        __Pyx_INCREF(__pyx_v_env);
        __Pyx_GIVEREF(__pyx_v_env);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_v_env);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 483, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_env, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":484
 *             if literal_i.id != other_i.id:
 *                 env = literal_i.unify(other_i, env)
 *                 if env is None: return env             # <<<<<<<<<<<<<<
 *         todo = True
 *         while todo:
 */
      __pyx_t_5 = (__pyx_v_env == Py_None);
      __pyx_t_11 = (__pyx_t_5 != 0);
      if (__pyx_t_11) {
        __Pyx_XDECREF(__pyx_r);
        if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 484, __pyx_L1_error)
        __Pyx_INCREF(__pyx_v_env);
        __pyx_r = ((PyObject*)__pyx_v_env);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }

      /* "pyDatalog/pyEngine.py":482
 *             literal_i = term if isinstance(term, Const) else term.chase(env)
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)
 *             if literal_i.id != other_i.id:             # <<<<<<<<<<<<<<
 *                 env = literal_i.unify(other_i, env)
 *                 if env is None: return env
 */
    }

    /* "pyDatalog/pyEngine.py":479
 *         if self.pred != other.pred: return None
 *         env = {}
 *         for term, otherterm in zip(self.terms, other.terms):             # <<<<<<<<<<<<<<
 *             literal_i = term if isinstance(term, Const) else term.chase(env)
 *             other_i = otherterm if isinstance(otherterm, Const) else otherterm.chase(env)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":485
 *                 env = literal_i.unify(other_i, env)
 *                 if env is None: return env
 *         todo = True             # <<<<<<<<<<<<<<
 *         while todo:
 *             todo = False
 */
  __pyx_v_todo = 1;

  /* "pyDatalog/pyEngine.py":486
 *                 if env is None: return env
 *         todo = True
 *         while todo:             # <<<<<<<<<<<<<<
 *             todo = False
 *             for key, value in env.items(): # 2nd pass for issue #14
 */
  while (1) {
    __pyx_t_11 = (__pyx_v_todo != 0);
    if (!__pyx_t_11) break;

    /* "pyDatalog/pyEngine.py":487
 *         todo = True
 *         while todo:
 *             todo = False             # <<<<<<<<<<<<<<
 *             for key, value in env.items(): # 2nd pass for issue #14
 *                 if not isinstance(value, Const):
 */
    __pyx_v_todo = 0;

    /* "pyDatalog/pyEngine.py":488
 *         while todo:
 *             todo = False
 *             for key, value in env.items(): # 2nd pass for issue #14             # <<<<<<<<<<<<<<
 *                 if not isinstance(value, Const):
 *                     new_value = value.chase(env)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_env, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 488, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 488, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 488, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_7(__pyx_t_3);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 488, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 488, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L14_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_8 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_8)) goto __pyx_L14_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_2), 2) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L15_unpacking_done;
        __pyx_L14_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 488, __pyx_L1_error)
        __pyx_L15_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "pyDatalog/pyEngine.py":489
 *             todo = False
 *             for key, value in env.items(): # 2nd pass for issue #14
 *                 if not isinstance(value, Const):             # <<<<<<<<<<<<<<
 *                     new_value = value.chase(env)
 *                     if env[key].id != new_value.id:
 */
      __pyx_t_11 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
      __pyx_t_5 = ((!(__pyx_t_11 != 0)) != 0);
      if (__pyx_t_5) {

        /* "pyDatalog/pyEngine.py":490
 *             for key, value in env.items(): # 2nd pass for issue #14
 *                 if not isinstance(value, Const):
 *                     new_value = value.chase(env)             # <<<<<<<<<<<<<<
 *                     if env[key].id != new_value.id:
 *                         env[key]= new_value
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_chase); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 490, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_4, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF_SET(__pyx_v_new_value, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":491
 *                 if not isinstance(value, Const):
 *                     new_value = value.chase(env)
 *                     if env[key].id != new_value.id:             # <<<<<<<<<<<<<<
 *                         env[key]= new_value
 *                         todo = True
 */
        __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_env, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 491, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_value, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = PyObject_RichCompare(__pyx_t_8, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 491, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 491, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_5) {

          /* "pyDatalog/pyEngine.py":492
 *                     new_value = value.chase(env)
 *                     if env[key].id != new_value.id:
 *                         env[key]= new_value             # <<<<<<<<<<<<<<
 *                         todo = True
 *         return env
 */
          if (unlikely(PyObject_SetItem(__pyx_v_env, __pyx_v_key, __pyx_v_new_value) < 0)) __PYX_ERR(0, 492, __pyx_L1_error)

          /* "pyDatalog/pyEngine.py":493
 *                     if env[key].id != new_value.id:
 *                         env[key]= new_value
 *                         todo = True             # <<<<<<<<<<<<<<
 *         return env
 * 
 */
          __pyx_v_todo = 1;

          /* "pyDatalog/pyEngine.py":491
 *                 if not isinstance(value, Const):
 *                     new_value = value.chase(env)
 *                     if env[key].id != new_value.id:             # <<<<<<<<<<<<<<
 *                         env[key]= new_value
 *                         todo = True
 */
        }

        /* "pyDatalog/pyEngine.py":489
 *             todo = False
 *             for key, value in env.items(): # 2nd pass for issue #14
 *                 if not isinstance(value, Const):             # <<<<<<<<<<<<<<
 *                     new_value = value.chase(env)
 *                     if env[key].id != new_value.id:
 */
      }

      /* "pyDatalog/pyEngine.py":488
 *         while todo:
 *             todo = False
 *             for key, value in env.items(): # 2nd pass for issue #14             # <<<<<<<<<<<<<<
 *                 if not isinstance(value, Const):
 *                     new_value = value.chase(env)
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "pyDatalog/pyEngine.py":494
 *                         env[key]= new_value
 *                         todo = True
 *         return env             # <<<<<<<<<<<<<<
 * 
 *     def match(self, terms):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 494, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_env);
  __pyx_r = ((PyObject*)__pyx_v_env);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":476
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def unify(self, other): #unify             # <<<<<<<<<<<<<<
 *         if self.pred != other.pred: return None
 *         env = {}
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XDECREF(__pyx_v_otherterm);
  __Pyx_XDECREF(__pyx_v_literal_i);
  __Pyx_XDECREF(__pyx_v_other_i);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_new_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_23unify(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_23unify = {"unify", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_23unify, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_23unify(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unify (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_9pyDatalog_8pyEngine_Literal, 1, "other", 0))) __PYX_ERR(0, 476, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_22unify(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_22unify(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unify", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Literal_unify(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.unify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":496
 *         return env
 * 
 *     def match(self, terms):             # <<<<<<<<<<<<<<
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_25match(PyObject *__pyx_v_self, PyObject *__pyx_v_terms); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Literal_match(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_terms, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_v_factterm = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("match", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_match); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Literal_25match)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_terms) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_terms);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 496, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 496, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":498
 *     def match(self, terms):
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}             # <<<<<<<<<<<<<<
 *         for term, factterm in zip(self.terms, terms):
 *             if term.id != factterm.id:
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 498, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_env = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":499
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}
 *         for term, factterm in zip(self.terms, terms):             # <<<<<<<<<<<<<<
 *             if term.id != factterm.id:
 *                 env = term.match(factterm, env)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->terms);
  __Pyx_GIVEREF(__pyx_v_self->terms);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->terms);
  __Pyx_INCREF(__pyx_v_terms);
  __Pyx_GIVEREF(__pyx_v_terms);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_terms);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 499, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 499, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 499, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 499, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 499, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 499, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 499, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 499, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 499, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 499, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_factterm, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pyDatalog/pyEngine.py":500
 *         env = {}
 *         for term, factterm in zip(self.terms, terms):
 *             if term.id != factterm.id:             # <<<<<<<<<<<<<<
 *                 env = term.match(factterm, env)
 *                 if env is None: return env
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_factterm, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_9) {

      /* "pyDatalog/pyEngine.py":501
 *         for term, factterm in zip(self.terms, terms):
 *             if term.id != factterm.id:
 *                 env = term.match(factterm, env)             # <<<<<<<<<<<<<<
 *                 if env is None: return env
 *         return env
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_match); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_factterm, __pyx_v_env};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_factterm, __pyx_v_env};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_2) {
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
        }
        __Pyx_INCREF(__pyx_v_factterm);
        __Pyx_GIVEREF(__pyx_v_factterm);
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_10, __pyx_v_factterm);
        __Pyx_INCREF(__pyx_v_env);
        __Pyx_GIVEREF(__pyx_v_env);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_10, __pyx_v_env);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_env, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":502
 *             if term.id != factterm.id:
 *                 env = term.match(factterm, env)
 *                 if env is None: return env             # <<<<<<<<<<<<<<
 *         return env
 * 
 */
      __pyx_t_9 = (__pyx_v_env == Py_None);
      __pyx_t_11 = (__pyx_t_9 != 0);
      if (__pyx_t_11) {
        __Pyx_XDECREF(__pyx_r);
        if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 502, __pyx_L1_error)
        __Pyx_INCREF(__pyx_v_env);
        __pyx_r = ((PyObject*)__pyx_v_env);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }

      /* "pyDatalog/pyEngine.py":500
 *         env = {}
 *         for term, factterm in zip(self.terms, terms):
 *             if term.id != factterm.id:             # <<<<<<<<<<<<<<
 *                 env = term.match(factterm, env)
 *                 if env is None: return env
 */
    }

    /* "pyDatalog/pyEngine.py":499
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}
 *         for term, factterm in zip(self.terms, terms):             # <<<<<<<<<<<<<<
 *             if term.id != factterm.id:
 *                 env = term.match(factterm, env)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":503
 *                 env = term.match(factterm, env)
 *                 if env is None: return env
 *         return env             # <<<<<<<<<<<<<<
 * 
 *     def ask(self):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_env);
  __pyx_r = ((PyObject*)__pyx_v_env);
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":496
 *         return env
 * 
 *     def match(self, terms):             # <<<<<<<<<<<<<<
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XDECREF(__pyx_v_factterm);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_25match(PyObject *__pyx_v_self, PyObject *__pyx_v_terms); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_24match[] = " Does a fact unify with a fact known to contain only constant terms? ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_25match = {"match", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_25match, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Literal_24match};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_25match(PyObject *__pyx_v_self, PyObject *__pyx_v_terms) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("match (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_terms), (&PyList_Type), 1, "terms", 1))) __PYX_ERR(0, 496, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_24match(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject*)__pyx_v_terms));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_24match(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_terms) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("match", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Literal_match(__pyx_v_self, __pyx_v_terms, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":505
 *         return env
 * 
 *     def ask(self):             # <<<<<<<<<<<<<<
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_27ask(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Literal_26ask[] = " Invoke the tasks. Each task may append new tasks on the schedule.";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_27ask = {"ask", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_27ask, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_26ask};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_27ask(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ask (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_26ask(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_7Literal_3ask_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":517
 *         if Ts.Goal.facts is True:
 *             return True
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]             # <<<<<<<<<<<<<<
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal = saved_environment
 *         return result
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_3ask_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 517, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_7Literal_3ask_2generator4, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ask_locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.ask.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_7Literal_3ask_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 517, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_literal)) { __Pyx_RaiseClosureNameError("literal"); __PYX_ERR(0, 517, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 517, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_term);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_term, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 517, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":505
 *         return env
 * 
 *     def ask(self):             # <<<<<<<<<<<<<<
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_26ask(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *__pyx_cur_scope;
  PyObject *__pyx_v_Ts = NULL;
  PyObject *__pyx_v_saved_environment = NULL;
  PyObject *__pyx_v_todo = NULL;
  PyObject *__pyx_v_arg = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_7Literal_3ask_2generator4 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ask", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 505, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }

  /* "pyDatalog/pyEngine.py":507
 *     def ask(self):
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic             # <<<<<<<<<<<<<<
 *         saved_environment = Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Subgoals, Ts.Goal = list(), deque(), {}, Subgoal(self)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_Ts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":508
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 *         saved_environment = Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal             # <<<<<<<<<<<<<<
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Subgoals, Ts.Goal = list(), deque(), {}, Subgoal(self)
 *         Ts.gc_uncollected, Ts.Recursive = True, False
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Subgoals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_saved_environment = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":509
 *         Ts = Logic.tl.logic
 *         saved_environment = Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Subgoals, Ts.Goal = list(), deque(), {}, Subgoal(self)             # <<<<<<<<<<<<<<
 *         Ts.gc_uncollected, Ts.Recursive = True, False
 *         todo, arg = (SEARCH, (Ts.Goal, ))
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_deque); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks, __pyx_t_6) < 0) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks, __pyx_t_5) < 0) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Subgoals, __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal, __pyx_t_3) < 0) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":510
 *         saved_environment = Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Subgoals, Ts.Goal = list(), deque(), {}, Subgoal(self)
 *         Ts.gc_uncollected, Ts.Recursive = True, False             # <<<<<<<<<<<<<<
 *         todo, arg = (SEARCH, (Ts.Goal, ))
 *         while todo:
 */
  __pyx_t_3 = Py_True;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = Py_False;
  __Pyx_INCREF(__pyx_t_4);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_gc_uncollected, __pyx_t_3) < 0) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive, __pyx_t_4) < 0) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pyDatalog/pyEngine.py":511
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Subgoals, Ts.Goal = list(), deque(), {}, Subgoal(self)
 *         Ts.gc_uncollected, Ts.Recursive = True, False
 *         todo, arg = (SEARCH, (Ts.Goal, ))             # <<<<<<<<<<<<<<
 *         while todo:
 *             todo, arg = todo(*arg)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_todo = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_arg = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "pyDatalog/pyEngine.py":512
 *         Ts.gc_uncollected, Ts.Recursive = True, False
 *         todo, arg = (SEARCH, (Ts.Goal, ))
 *         while todo:             # <<<<<<<<<<<<<<
 *             todo, arg = todo(*arg)
 * 
 */
  while (1) {
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_todo); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 512, __pyx_L1_error)
    if (!__pyx_t_7) break;

    /* "pyDatalog/pyEngine.py":513
 *         todo, arg = (SEARCH, (Ts.Goal, ))
 *         while todo:
 *             todo, arg = todo(*arg)             # <<<<<<<<<<<<<<
 * 
 *         if Ts.Goal.facts is True:
 */
    __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_v_arg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_todo, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 513, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 513, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 513, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_6), 2) < 0) __PYX_ERR(0, 513, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 513, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_3);
    __pyx_t_3 = 0;
  }

  /* "pyDatalog/pyEngine.py":515
 *             todo, arg = todo(*arg)
 * 
 *         if Ts.Goal.facts is True:             # <<<<<<<<<<<<<<
 *             return True
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_facts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_3 == Py_True);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = (__pyx_t_7 != 0);
  if (__pyx_t_9) {

    /* "pyDatalog/pyEngine.py":516
 * 
 *         if Ts.Goal.facts is True:
 *             return True             # <<<<<<<<<<<<<<
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal = saved_environment
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":515
 *             todo, arg = todo(*arg)
 * 
 *         if Ts.Goal.facts is True:             # <<<<<<<<<<<<<<
 *             return True
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]
 */
  }

  /* "pyDatalog/pyEngine.py":517
 *         if Ts.Goal.facts is True:
 *             return True
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]             # <<<<<<<<<<<<<<
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal = saved_environment
 *         return result
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_facts); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_literal);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_literal, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __pyx_pf_9pyDatalog_8pyEngine_7Literal_3ask_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":518
 *             return True
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal = saved_environment             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  if (1) {
    PyObject* sequence = __pyx_v_saved_environment;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 5)) {
      if (size > 5) __Pyx_RaiseTooManyValuesError(5);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 518, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 4); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_2);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[5] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_6,&__pyx_t_5,&__pyx_t_2};
      for (i=0; i < 5; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks, __pyx_t_3) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks, __pyx_t_4) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive, __pyx_t_6) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Subgoals, __pyx_t_5) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal, __pyx_t_2) < 0) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":519
 *         result = [ tuple(term.id for term in literal.terms) for literal in list(Ts.Goal.facts.values())]
 *         Ts.Tasks, Ts.Recursive_Tasks, Ts.Recursive, Ts.Subgoals, Ts.Goal = saved_environment
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":505
 *         return env
 * 
 *     def ask(self):             # <<<<<<<<<<<<<<
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.ask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Ts);
  __Pyx_XDECREF(__pyx_v_saved_environment);
  __Pyx_XDECREF(__pyx_v_todo);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_7Literal_3ask_2generator4);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":60
 * 
 * cdef class Literal(object):
 *     cpdef public list terms             # <<<<<<<<<<<<<<
 *     cpdef public object pred
 *     cpdef public tuple id
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->terms);
  __pyx_r = __pyx_v_self->terms;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 60, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->terms);
  __Pyx_DECREF(__pyx_v_self->terms);
  __pyx_v_self->terms = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.terms.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_5terms_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->terms);
  __Pyx_DECREF(__pyx_v_self->terms);
  __pyx_v_self->terms = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":61
 * cdef class Literal(object):
 *     cpdef public list terms
 *     cpdef public object pred             # <<<<<<<<<<<<<<
 *     cpdef public tuple id
 *     cpdef public tuple tag
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->pred);
  __pyx_r = __pyx_v_self->pred;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->pred);
  __Pyx_DECREF(__pyx_v_self->pred);
  __pyx_v_self->pred = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_4pred_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->pred);
  __Pyx_DECREF(__pyx_v_self->pred);
  __pyx_v_self->pred = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":62
 *     cpdef public list terms
 *     cpdef public object pred
 *     cpdef public tuple id             # <<<<<<<<<<<<<<
 *     cpdef public tuple tag
 *     cpdef public object aggregate
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_2id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->id);
  __pyx_r = __pyx_v_self->id;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 62, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.id.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_2id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":63
 *     cpdef public object pred
 *     cpdef public tuple id
 *     cpdef public tuple tag             # <<<<<<<<<<<<<<
 *     cpdef public object aggregate
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->tag);
  __pyx_r = __pyx_v_self->tag;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 63, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tag);
  __Pyx_DECREF(__pyx_v_self->tag);
  __pyx_v_self->tag = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.tag.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_3tag_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->tag);
  __Pyx_DECREF(__pyx_v_self->tag);
  __pyx_v_self->tag = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":64
 *     cpdef public tuple id
 *     cpdef public tuple tag
 *     cpdef public object aggregate             # <<<<<<<<<<<<<<
 * 
 *     cpdef public tuple get_tag(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->aggregate);
  __pyx_r = __pyx_v_self->aggregate;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->aggregate);
  __Pyx_DECREF(__pyx_v_self->aggregate);
  __pyx_v_self->aggregate = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Literal_9aggregate_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->aggregate);
  __Pyx_DECREF(__pyx_v_self->aggregate);
  __pyx_v_self->aggregate = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_29__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_29__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_29__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_29__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_28__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_28__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.aggregate, self.id, self.pred, self.tag, self.terms)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->aggregate);
  __Pyx_GIVEREF(__pyx_v_self->aggregate);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->aggregate);
  __Pyx_INCREF(__pyx_v_self->id);
  __Pyx_GIVEREF(__pyx_v_self->id);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->id);
  __Pyx_INCREF(__pyx_v_self->pred);
  __Pyx_GIVEREF(__pyx_v_self->pred);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->pred);
  __Pyx_INCREF(__pyx_v_self->tag);
  __Pyx_GIVEREF(__pyx_v_self->tag);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_self->tag);
  __Pyx_INCREF(__pyx_v_self->terms);
  __Pyx_GIVEREF(__pyx_v_self->terms);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_self->terms);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.aggregate, self.id, self.pred, self.tag, self.terms)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.aggregate, self.id, self.pred, self.tag, self.terms)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.aggregate is not None or self.id is not None or self.pred is not None or self.tag is not None or self.terms is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.aggregate, self.id, self.pred, self.tag, self.terms)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.aggregate is not None or self.id is not None or self.pred is not None or self.tag is not None or self.terms is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->aggregate != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->id != ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->pred != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->tag != ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->terms != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    __pyx_t_3 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.aggregate is not None or self.id is not None or self.pred is not None or self.tag is not None or self.terms is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.aggregate is not None or self.id is not None or self.pred is not None or self.tag is not None or self.terms is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Literal); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_239816442);
    __Pyx_GIVEREF(__pyx_int_239816442);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_239816442);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.aggregate is not None or self.id is not None or self.pred is not None or self.tag is not None or self.terms is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, None), state
 *     else:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Literal__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Literal); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_239816442);
    __Pyx_GIVEREF(__pyx_int_239816442);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_239816442);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Literal__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_31__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Literal_31__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_31__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Literal_31__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Literal_30__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Literal_30__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Literal__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Literal__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Literal__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Literal.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":528
 *     __slots__ = ['head', 'body', 'id']
 * 
 *     def __init__(self, head, body):             # <<<<<<<<<<<<<<
 *         self.head = head
 *         self.body = body
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_head = 0;
  PyObject *__pyx_v_body = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_head,&__pyx_n_s_body,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_head)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_body)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 528, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 528, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_head = values[0];
    __pyx_v_body = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 528, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self), __pyx_v_head, __pyx_v_body);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_head, PyObject *__pyx_v_body) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":529
 * 
 *     def __init__(self, head, body):
 *         self.head = head             # <<<<<<<<<<<<<<
 *         self.body = body
 *         self.id = None
 */
  if (!(likely(((__pyx_v_head) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_head, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(0, 529, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_head;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->head);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->head));
  __pyx_v_self->head = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":530
 *     def __init__(self, head, body):
 *         self.head = head
 *         self.body = body             # <<<<<<<<<<<<<<
 *         self.id = None
 *     def __str__(self):
 */
  if (!(likely(PyList_CheckExact(__pyx_v_body))||((__pyx_v_body) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_body)->tp_name), 0))) __PYX_ERR(0, 530, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_body;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->body);
  __Pyx_DECREF(__pyx_v_self->body);
  __pyx_v_self->body = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":531
 *         self.head = head
 *         self.body = body
 *         self.id = None             # <<<<<<<<<<<<<<
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = ((PyObject*)Py_None);

  /* "pyDatalog/pyEngine.py":528
 *     __slots__ = ['head', 'body', 'id']
 * 
 *     def __init__(self, head, body):             # <<<<<<<<<<<<<<
 *         self.head = head
 *         self.body = body
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":532
 *         self.body = body
 *         self.id = None
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_3__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_3__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_2__str__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_7__str___2generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":533
 *         self.id = None
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_7__str___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 533, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_6Clause_7__str___2generator5, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_str___locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 533, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_7__str___2generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 533, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 533, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->body == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 533, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->body; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 533, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_literal);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_literal, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_cur_scope->__pyx_v_literal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 533, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 533, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":532
 *         self.body = body
 *         self.id = None
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_2__str__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *__pyx_cur_scope;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_7__str___2generator5 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 532, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "pyDatalog/pyEngine.py":533
 *         self.id = None
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_cur_scope->__pyx_v_self->head)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_pf_9pyDatalog_8pyEngine_6Clause_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__24, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_2, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":532
 *         self.body = body
 *         self.id = None
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_6Clause_7__str___2generator5);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":534
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 *     def __neg__(self):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_5__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_5__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4__repr__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_8__repr___2generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":535
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]             # <<<<<<<<<<<<<<
 *     def __neg__(self):
 *         """retract clause"""
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_8__repr___genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 535, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_6Clause_8__repr___2generator6, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_repr___locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__repr__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_8__repr___2generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 535, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 535, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->body == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 535, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->body; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 535, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_literal);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_literal, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_cur_scope->__pyx_v_literal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 535, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":534
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 *     def __neg__(self):
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_4__repr__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *__pyx_cur_scope;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_8__repr___2generator6 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 534, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "pyDatalog/pyEngine.py":535
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]             # <<<<<<<<<<<<<<
 *     def __neg__(self):
 *         """retract clause"""
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_cur_scope->__pyx_v_self->head)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_pf_9pyDatalog_8pyEngine_6Clause_8__repr___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__24, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_2, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_GetSlice(__pyx_t_3, 0, 50); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":534
 *     def __str__(self):
 *         return "%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body))
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 *     def __neg__(self):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_6Clause_8__repr___2generator6);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":536
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         """retract clause"""
 *         retract(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_7__neg__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_6Clause_6__neg__[] = "retract clause";
#if CYTHON_UPDATE_DESCRIPTOR_DOC
struct wrapperbase __pyx_wrapperbase_9pyDatalog_8pyEngine_6Clause_6__neg__;
#endif
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_7__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_6__neg__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_6__neg__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__neg__", 0);

  /* "pyDatalog/pyEngine.py":538
 *     def __neg__(self):
 *         """retract clause"""
 *         retract(self)             # <<<<<<<<<<<<<<
 * 
 *     def get_id(self): #id
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_retract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":536
 *     def __repr__(self):
 *         return ("%s <= %s" % (str(self.head), '&'.join(str(literal) for literal in self.body)))[:50]
 *     def __neg__(self):             # <<<<<<<<<<<<<<
 *         """retract clause"""
 *         retract(self)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__neg__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":540
 *         retract(self)
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two clauses are structurally equal
 *             if they have the same id.  A clause's id is used as a key into the
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_9get_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_6Clause_8get_id[] = " The id's encoding ensures that two clauses are structurally equal\n            if they have the same id.  A clause's id is used as a key into the\n            clause database. ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_6Clause_9get_id = {"get_id", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_9get_id, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_6Clause_8get_id};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_9get_id(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_id (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_8get_id(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_6get_id_2generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":548
 *                 self.id = (self.head.get_fact_id(),)
 *             else:
 *                 self.id = (self.head.get_id(),) + tuple(bodi.get_id() for bodi in self.body)             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_6get_id_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 548, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_6Clause_6get_id_2generator7, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_get_id_locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.get_id.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_6get_id_2generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 548, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 548, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->body == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 548, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->body; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 548, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_bodi);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_bodi, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_bodi, __pyx_n_s_get_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 548, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":540
 *         retract(self)
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two clauses are structurally equal
 *             if they have the same id.  A clause's id is used as a key into the
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_8get_id(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *__pyx_cur_scope;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_6Clause_6get_id_2generator7 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_id", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 540, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "pyDatalog/pyEngine.py":544
 *             if they have the same id.  A clause's id is used as a key into the
 *             clause database. """
 *         if self.id is None: # cached             # <<<<<<<<<<<<<<
 *             if not self.body: #if it is a fact
 *                 self.id = (self.head.get_fact_id(),)
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->id == ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":545
 *             clause database. """
 *         if self.id is None: # cached
 *             if not self.body: #if it is a fact             # <<<<<<<<<<<<<<
 *                 self.id = (self.head.get_fact_id(),)
 *             else:
 */
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_self->body != Py_None)&&(PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_self->body) != 0);
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (__pyx_t_1) {

      /* "pyDatalog/pyEngine.py":546
 *         if self.id is None: # cached
 *             if not self.body: #if it is a fact
 *                 self.id = (self.head.get_fact_id(),)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.id = (self.head.get_id(),) + tuple(bodi.get_id() for bodi in self.body)
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_cur_scope->__pyx_v_self->head->__pyx_vtab)->get_fact_id(__pyx_cur_scope->__pyx_v_self->head, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->id);
      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->id);
      __pyx_cur_scope->__pyx_v_self->id = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pyDatalog/pyEngine.py":545
 *             clause database. """
 *         if self.id is None: # cached
 *             if not self.body: #if it is a fact             # <<<<<<<<<<<<<<
 *                 self.id = (self.head.get_fact_id(),)
 *             else:
 */
      goto __pyx_L4;
    }

    /* "pyDatalog/pyEngine.py":548
 *                 self.id = (self.head.get_fact_id(),)
 *             else:
 *                 self.id = (self.head.get_id(),) + tuple(bodi.get_id() for bodi in self.body)             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */
    /*else*/ {
      __pyx_t_4 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_cur_scope->__pyx_v_self->head->__pyx_vtab)->get_id(__pyx_cur_scope->__pyx_v_self->head, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __pyx_pf_9pyDatalog_8pyEngine_6Clause_6get_id_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->id);
      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->id);
      __pyx_cur_scope->__pyx_v_self->id = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L4:;

    /* "pyDatalog/pyEngine.py":544
 *             if they have the same id.  A clause's id is used as a key into the
 *             clause database. """
 *         if self.id is None: # cached             # <<<<<<<<<<<<<<
 *             if not self.body: #if it is a fact
 *                 self.id = (self.head.get_fact_id(),)
 */
  }

  /* "pyDatalog/pyEngine.py":549
 *             else:
 *                 self.id = (self.head.get_id(),) + tuple(bodi.get_id() for bodi in self.body)
 *         return self.id             # <<<<<<<<<<<<<<
 * 
 *     def subst(self, env, parent_class=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->id);
  __pyx_r = __pyx_cur_scope->__pyx_v_self->id;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":540
 *         retract(self)
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two clauses are structurally equal
 *             if they have the same id.  A clause's id is used as a key into the
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.get_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_6Clause_6get_id_2generator7);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":551
 *         return self.id
 * 
 *     def subst(self, env, parent_class=None):             # <<<<<<<<<<<<<<
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_11subst(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_6Clause_10subst[] = " apply the env mapping and rebase to parent_class, if any ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_6Clause_11subst = {"subst", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_6Clause_11subst, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_6Clause_10subst};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_11subst(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_env = 0;
  PyObject *__pyx_v_parent_class = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("subst (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_env,&__pyx_n_s_parent_class,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_env)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parent_class);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "subst") < 0)) __PYX_ERR(0, 551, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_env = values[0];
    __pyx_v_parent_class = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("subst", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 551, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_10subst(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self), __pyx_v_env, __pyx_v_parent_class);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_10subst(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_env, PyObject *__pyx_v_parent_class) {
  PyObject *__pyx_v_bodi = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("subst", 0);

  /* "pyDatalog/pyEngine.py":553
 *     def subst(self, env, parent_class=None):
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self             # <<<<<<<<<<<<<<
 *         if not parent_class:
 *             return Clause(self.head.subst(env),
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_env); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 553, __pyx_L1_error)
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_parent_class); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 553, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_3) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":554
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self
 *         if not parent_class:             # <<<<<<<<<<<<<<
 *             return Clause(self.head.subst(env),
 *                            [bodi.subst(env) for bodi in self.body])
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_parent_class); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 554, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":555
 *         if not env and not parent_class: return self
 *         if not parent_class:
 *             return Clause(self.head.subst(env),             # <<<<<<<<<<<<<<
 *                            [bodi.subst(env) for bodi in self.body])
 *         return Clause(self.head.subst(env).rebased(parent_class),
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 555, __pyx_L1_error)
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->head->__pyx_vtab)->subst(__pyx_v_self->head, ((PyObject*)__pyx_v_env), 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "pyDatalog/pyEngine.py":556
 *         if not parent_class:
 *             return Clause(self.head.subst(env),
 *                            [bodi.subst(env) for bodi in self.body])             # <<<<<<<<<<<<<<
 *         return Clause(self.head.subst(env).rebased(parent_class),
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 */
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__pyx_v_self->body == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 556, __pyx_L1_error)
    }
    __pyx_t_6 = __pyx_v_self->body; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
    for (;;) {
      if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_8); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 556, __pyx_L1_error)
      #else
      __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 556, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_bodi, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bodi, __pyx_n_s_subst); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 556, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_8 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 556, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 556, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "pyDatalog/pyEngine.py":555
 *         if not env and not parent_class: return self
 *         if not parent_class:
 *             return Clause(self.head.subst(env),             # <<<<<<<<<<<<<<
 *                            [bodi.subst(env) for bodi in self.body])
 *         return Clause(self.head.subst(env).rebased(parent_class),
 */
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":554
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self
 *         if not parent_class:             # <<<<<<<<<<<<<<
 *             return Clause(self.head.subst(env),
 *                            [bodi.subst(env) for bodi in self.body])
 */
  }

  /* "pyDatalog/pyEngine.py":557
 *             return Clause(self.head.subst(env),
 *                            [bodi.subst(env) for bodi in self.body])
 *         return Clause(self.head.subst(env).rebased(parent_class),             # <<<<<<<<<<<<<<
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 557, __pyx_L1_error)
  __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->head->__pyx_vtab)->subst(__pyx_v_self->head, ((PyObject*)__pyx_v_env), 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_rebased); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_v_parent_class) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_parent_class);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pyDatalog/pyEngine.py":558
 *                            [bodi.subst(env) for bodi in self.body])
 *         return Clause(self.head.subst(env).rebased(parent_class),
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])             # <<<<<<<<<<<<<<
 * 
 *     def rename(self):
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (unlikely(__pyx_v_self->body == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 558, __pyx_L1_error)
  }
  __pyx_t_6 = __pyx_v_self->body; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
  for (;;) {
    if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_8); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 558, __pyx_L1_error)
    #else
    __pyx_t_8 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_bodi, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bodi, __pyx_n_s_subst); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    __pyx_t_9 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_rebased); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_9, __pyx_v_parent_class) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_parent_class);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":557
 *             return Clause(self.head.subst(env),
 *                            [bodi.subst(env) for bodi in self.body])
 *         return Clause(self.head.subst(env).rebased(parent_class),             # <<<<<<<<<<<<<<
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 * 
 */
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __pyx_t_5 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":551
 *         return self.id
 * 
 *     def subst(self, env, parent_class=None):             # <<<<<<<<<<<<<<
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.subst", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bodi);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":560
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 * 
 *     def rename(self):             # <<<<<<<<<<<<<<
 *         """ returns the clause with fresh variables """
 *         env = {}
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_13rename(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_6Clause_12rename[] = " returns the clause with fresh variables ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_6Clause_13rename = {"rename", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_13rename, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_6Clause_12rename};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_13rename(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rename (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_12rename(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_12rename(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_bodi = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rename", 0);

  /* "pyDatalog/pyEngine.py":562
 *     def rename(self):
 *         """ returns the clause with fresh variables """
 *         env = {}             # <<<<<<<<<<<<<<
 *         return Clause(self.head.shuffle(env),
 *                            [bodi.shuffle(env) for bodi in self.body])
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_env = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":563
 *         """ returns the clause with fresh variables """
 *         env = {}
 *         return Clause(self.head.shuffle(env),             # <<<<<<<<<<<<<<
 *                            [bodi.shuffle(env) for bodi in self.body])
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->head->__pyx_vtab)->shuffle(__pyx_v_self->head, __pyx_v_env, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "pyDatalog/pyEngine.py":564
 *         env = {}
 *         return Clause(self.head.shuffle(env),
 *                            [bodi.shuffle(env) for bodi in self.body])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->body == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 564, __pyx_L1_error)
  }
  __pyx_t_3 = __pyx_v_self->body; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 564, __pyx_L1_error)
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_bodi, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_bodi, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":563
 *         """ returns the clause with fresh variables """
 *         env = {}
 *         return Clause(self.head.shuffle(env),             # <<<<<<<<<<<<<<
 *                            [bodi.shuffle(env) for bodi in self.body])
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":560
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 * 
 *     def rename(self):             # <<<<<<<<<<<<<<
 *         """ returns the clause with fresh variables """
 *         env = {}
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.rename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_bodi);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":76
 * 
 * cdef class Clause(object):
 *     cpdef public Literal head             # <<<<<<<<<<<<<<
 *     cpdef public list body
 *     cpdef public tuple id
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_4head___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->head));
  __pyx_r = ((PyObject *)__pyx_v_self->head);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(2, 76, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->head);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->head));
  __pyx_v_self->head = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.head.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4head_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->head);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->head));
  __pyx_v_self->head = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":77
 * cdef class Clause(object):
 *     cpdef public Literal head
 *     cpdef public list body             # <<<<<<<<<<<<<<
 *     cpdef public tuple id
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_4body___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->body);
  __pyx_r = __pyx_v_self->body;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 77, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->body);
  __Pyx_DECREF(__pyx_v_self->body);
  __pyx_v_self->body = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.body.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_4body_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->body);
  __Pyx_DECREF(__pyx_v_self->body);
  __pyx_v_self->body = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":78
 *     cpdef public Literal head
 *     cpdef public list body
 *     cpdef public tuple id             # <<<<<<<<<<<<<<
 * 
 * cdef class Subgoal(object):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_2id___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->id);
  __pyx_r = __pyx_v_self->id;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyTuple_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 78, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.id.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_6Clause_2id_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->id);
  __Pyx_DECREF(__pyx_v_self->id);
  __pyx_v_self->id = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_6Clause_15__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_15__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_14__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_14__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.body, self.head, self.id)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->body);
  __Pyx_GIVEREF(__pyx_v_self->body);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->body);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->head));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->head));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self->head));
  __Pyx_INCREF(__pyx_v_self->id);
  __Pyx_GIVEREF(__pyx_v_self->id);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->id);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.body, self.head, self.id)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.body, self.head, self.id)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.body is not None or self.head is not None or self.id is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.body, self.head, self.id)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.body is not None or self.head is not None or self.id is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->body != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->head) != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->id != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    __pyx_t_3 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.body is not None or self.head is not None or self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.body is not None or self.head is not None or self.id is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Clause); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_228449516);
    __Pyx_GIVEREF(__pyx_int_228449516);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_228449516);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.body is not None or self.head is not None or self.id is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, None), state
 *     else:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Clause__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Clause); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_228449516);
    __Pyx_GIVEREF(__pyx_int_228449516);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_228449516);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Clause__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_6Clause_17__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_17__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_6Clause_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6Clause_16__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6Clause_16__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Clause__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Clause__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Clause__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Clause.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":567
 * 
 * 
 * def add_class(cls, name):             # <<<<<<<<<<<<<<
 *     """ Update the list of pyDatalog-capable classes, and update clauses accordingly"""
 *     # this is needed because class definition could occur after clause definition
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3add_class(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_2add_class[] = " Update the list of pyDatalog-capable classes, and update clauses accordingly";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_3add_class = {"add_class", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_3add_class, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_2add_class};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_3add_class(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_name = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_class (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_name,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_class", 1, 2, 2, 1); __PYX_ERR(0, 567, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_class") < 0)) __PYX_ERR(0, 567, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_cls = values[0];
    __pyx_v_name = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_class", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 567, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.add_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_2add_class(__pyx_self, __pyx_v_cls, __pyx_v_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_2add_class(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_name) {
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_pred = NULL;
  PyObject *__pyx_v_clause = NULL;
  PyObject *__pyx_v_literal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_class", 0);

  /* "pyDatalog/pyEngine.py":570
 *     """ Update the list of pyDatalog-capable classes, and update clauses accordingly"""
 *     # this is needed because class definition could occur after clause definition
 *     Class_dict[name] = cls             # <<<<<<<<<<<<<<
 *     #prefixed replace the first term of each functional comparison literal for that class..
 *     env = {Var(name).id: Const('_pyD_class')}
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Class_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_name, __pyx_v_cls) < 0)) __PYX_ERR(0, 570, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":572
 *     Class_dict[name] = cls
 *     #prefixed replace the first term of each functional comparison literal for that class..
 *     env = {Var(name).id: Const('_pyD_class')}             # <<<<<<<<<<<<<<
 *     for pred in Logic.tl.logic.Db.values():
 *         for clause in pred.db.values():
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Var), __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const), __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, ((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_t_2)->__pyx_base.__pyx_base.id, __pyx_t_3) < 0) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_env = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":573
 *     #prefixed replace the first term of each functional comparison literal for that class..
 *     env = {Var(name).id: Const('_pyD_class')}
 *     for pred in Logic.tl.logic.Db.values():             # <<<<<<<<<<<<<<
 *         for clause in pred.db.values():
 *             clause.head.subst_first(env)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 573, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 573, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 573, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 573, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_pred, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":574
 *     env = {Var(name).id: Const('_pyD_class')}
 *     for pred in Logic.tl.logic.Db.values():
 *         for clause in pred.db.values():             # <<<<<<<<<<<<<<
 *             clause.head.subst_first(env)
 *             for literal in clause.body:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 574, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 574, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 574, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 574, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_8(__pyx_t_6);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 574, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_clause, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":575
 *     for pred in Logic.tl.logic.Db.values():
 *         for clause in pred.db.values():
 *             clause.head.subst_first(env)             # <<<<<<<<<<<<<<
 *             for literal in clause.body:
 *                 literal.subst_first(env)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_subst_first); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_2, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_env);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":576
 *         for clause in pred.db.values():
 *             clause.head.subst_first(env)
 *             for literal in clause.body:             # <<<<<<<<<<<<<<
 *                 literal.subst_first(env)
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
        __pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 576, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 576, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      for (;;) {
        if (likely(!__pyx_t_11)) {
          if (likely(PyList_CheckExact(__pyx_t_9))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_9)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 576, __pyx_L1_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 576, __pyx_L1_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          }
        } else {
          __pyx_t_1 = __pyx_t_11(__pyx_t_9);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 576, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_v_literal, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":577
 *             clause.head.subst_first(env)
 *             for literal in clause.body:
 *                 literal.subst_first(env)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_subst_first); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_12, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":576
 *         for clause in pred.db.values():
 *             clause.head.subst_first(env)
 *             for literal in clause.body:             # <<<<<<<<<<<<<<
 *                 literal.subst_first(env)
 * 
 */
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "pyDatalog/pyEngine.py":574
 *     env = {Var(name).id: Const('_pyD_class')}
 *     for pred in Logic.tl.logic.Db.values():
 *         for clause in pred.db.values():             # <<<<<<<<<<<<<<
 *             clause.head.subst_first(env)
 *             for literal in clause.body:
 */
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "pyDatalog/pyEngine.py":573
 *     #prefixed replace the first term of each functional comparison literal for that class..
 *     env = {Var(name).id: Const('_pyD_class')}
 *     for pred in Logic.tl.logic.Db.values():             # <<<<<<<<<<<<<<
 *         for clause in pred.db.values():
 *             clause.head.subst_first(env)
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":567
 * 
 * 
 * def add_class(cls, name):             # <<<<<<<<<<<<<<
 *     """ Update the list of pyDatalog-capable classes, and update clauses accordingly"""
 *     # this is needed because class definition could occur after clause definition
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pyDatalog.pyEngine.add_class", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_pred);
  __Pyx_XDECREF(__pyx_v_clause);
  __Pyx_XDECREF(__pyx_v_literal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":584
 * # The database stores predicates that contain clauses.
 * 
 * def insert(pred):             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Db[pred.id] = pred
 *     return pred
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5insert(PyObject *__pyx_self, PyObject *__pyx_v_pred); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_5insert = {"insert", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5insert, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_5insert(PyObject *__pyx_self, PyObject *__pyx_v_pred) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("insert (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_4insert(__pyx_self, ((PyObject *)__pyx_v_pred));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_4insert(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pred) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("insert", 0);

  /* "pyDatalog/pyEngine.py":585
 * 
 * def insert(pred):
 *     Logic.tl.logic.Db[pred.id] = pred             # <<<<<<<<<<<<<<
 *     return pred
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_1, __pyx_v_pred) < 0)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":586
 * def insert(pred):
 *     Logic.tl.logic.Db[pred.id] = pred
 *     return pred             # <<<<<<<<<<<<<<
 * 
 * def remove(pred):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_pred);
  __pyx_r = __pyx_v_pred;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":584
 * # The database stores predicates that contain clauses.
 * 
 * def insert(pred):             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Db[pred.id] = pred
 *     return pred
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pyDatalog.pyEngine.insert", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":588
 *     return pred
 * 
 * def remove(pred):             # <<<<<<<<<<<<<<
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7remove(PyObject *__pyx_self, PyObject *__pyx_v_pred); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7remove = {"remove", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7remove, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7remove(PyObject *__pyx_self, PyObject *__pyx_v_pred) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_6remove(__pyx_self, ((PyObject *)__pyx_v_pred));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_6remove(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pred) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove", 0);

  /* "pyDatalog/pyEngine.py":589
 * 
 * def remove(pred):
 *     if pred.id in Logic.tl.logic.Pred_registry:             # <<<<<<<<<<<<<<
 *         del Logic.tl.logic.Pred_registry[pred.id]
 *     if pred.id in Logic.tl.logic.Db:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Pred_registry); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":590
 * def remove(pred):
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]             # <<<<<<<<<<<<<<
 *     if pred.id in Logic.tl.logic.Db:
 *         del Logic.tl.logic.Db[pred.id]
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Pred_registry); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyObject_DelItem(__pyx_t_1, __pyx_t_3) < 0)) __PYX_ERR(0, 590, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":589
 * 
 * def remove(pred):
 *     if pred.id in Logic.tl.logic.Pred_registry:             # <<<<<<<<<<<<<<
 *         del Logic.tl.logic.Pred_registry[pred.id]
 *     if pred.id in Logic.tl.logic.Db:
 */
  }

  /* "pyDatalog/pyEngine.py":591
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]
 *     if pred.id in Logic.tl.logic.Db:             # <<<<<<<<<<<<<<
 *         del Logic.tl.logic.Db[pred.id]
 *     return pred
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_t_3, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (__pyx_t_4) {

    /* "pyDatalog/pyEngine.py":592
 *         del Logic.tl.logic.Pred_registry[pred.id]
 *     if pred.id in Logic.tl.logic.Db:
 *         del Logic.tl.logic.Db[pred.id]             # <<<<<<<<<<<<<<
 *     return pred
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Db); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyObject_DelItem(__pyx_t_3, __pyx_t_2) < 0)) __PYX_ERR(0, 592, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":591
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]
 *     if pred.id in Logic.tl.logic.Db:             # <<<<<<<<<<<<<<
 *         del Logic.tl.logic.Db[pred.id]
 *     return pred
 */
  }

  /* "pyDatalog/pyEngine.py":593
 *     if pred.id in Logic.tl.logic.Db:
 *         del Logic.tl.logic.Db[pred.id]
 *     return pred             # <<<<<<<<<<<<<<
 * 
 * def assert_(clause):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_pred);
  __pyx_r = __pyx_v_pred;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":588
 *     return pred
 * 
 * def remove(pred):             # <<<<<<<<<<<<<<
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pyDatalog.pyEngine.remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":595
 *     return pred
 * 
 * def assert_(clause):             # <<<<<<<<<<<<<<
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9assert_(PyObject *__pyx_self, PyObject *__pyx_v_clause); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_8assert_[] = " Add a safe clause to the database ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_9assert_ = {"assert_", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9assert_, METH_O, __pyx_doc_9pyDatalog_8pyEngine_8assert_};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_9assert_(PyObject *__pyx_self, PyObject *__pyx_v_clause) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("assert_ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_8assert_(__pyx_self, ((PyObject *)__pyx_v_clause));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_7assert__2generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":608
 *                 clauses.add(clause)
 *         else:
 *             if any(literal.pred.id == pred.id for literal in clause.body):             # <<<<<<<<<<<<<<
 *                 pred.recursive = True
 *             pred.clauses[id_] = clause
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7assert__genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 608, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_7assert__2generator8, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_assert__locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.assert_.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_7assert__2generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 608, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_clause)) { __Pyx_RaiseClosureNameError("clause"); __PYX_ERR(0, 608, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 608, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_literal);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_literal, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_pred)) { __Pyx_RaiseClosureNameError("pred"); __PYX_ERR(0, 608, __pyx_L1_error) }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_pred, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_7) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":595
 *     return pred
 * 
 * def assert_(clause):             # <<<<<<<<<<<<<<
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_8assert_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_clause) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *__pyx_cur_scope;
  PyObject *__pyx_v_id_ = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_v_clauses = NULL;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_7assert__2generator8 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("assert_", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 595, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_clause = __pyx_v_clause;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_clause);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_clause);

  /* "pyDatalog/pyEngine.py":597
 * def assert_(clause):
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred             # <<<<<<<<<<<<<<
 * 
 *     if not pred.prim:                   # Ignore assertions for primitives.
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_pred = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":599
 *     pred = clause.head.pred
 * 
 *     if not pred.prim:                   # Ignore assertions for primitives.             # <<<<<<<<<<<<<<
 *         id_ = clause.get_id()
 *         retract(clause) # to ensure unicity of functions
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_pred, __pyx_n_s_prim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 599, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (__pyx_t_4) {

    /* "pyDatalog/pyEngine.py":600
 * 
 *     if not pred.prim:                   # Ignore assertions for primitives.
 *         id_ = clause.get_id()             # <<<<<<<<<<<<<<
 *         retract(clause) # to ensure unicity of functions
 *         pred.db[id_] = clause
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_clause, __pyx_n_s_get_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 600, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 600, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_id_ = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":601
 *     if not pred.prim:                   # Ignore assertions for primitives.
 *         id_ = clause.get_id()
 *         retract(clause) # to ensure unicity of functions             # <<<<<<<<<<<<<<
 *         pred.db[id_] = clause
 *         if not clause.body: # if it is a fact, update indexes
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_retract); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_cur_scope->__pyx_v_clause) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_cur_scope->__pyx_v_clause);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":602
 *         id_ = clause.get_id()
 *         retract(clause) # to ensure unicity of functions
 *         pred.db[id_] = clause             # <<<<<<<<<<<<<<
 *         if not clause.body: # if it is a fact, update indexes
 *             for i, term in enumerate(clause.head.terms):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_pred, __pyx_n_s_db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_v_id_, __pyx_cur_scope->__pyx_v_clause) < 0)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":603
 *         retract(clause) # to ensure unicity of functions
 *         pred.db[id_] = clause
 *         if not clause.body: # if it is a fact, update indexes             # <<<<<<<<<<<<<<
 *             for i, term in enumerate(clause.head.terms):
 *                 clauses = pred.index[i].setdefault(term.id, set()) # create a set if needed
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 603, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = ((!__pyx_t_4) != 0);
    if (__pyx_t_3) {

      /* "pyDatalog/pyEngine.py":604
 *         pred.db[id_] = clause
 *         if not clause.body: # if it is a fact, update indexes
 *             for i, term in enumerate(clause.head.terms):             # <<<<<<<<<<<<<<
 *                 clauses = pred.index[i].setdefault(term.id, set()) # create a set if needed
 *                 clauses.add(clause)
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_2 = __pyx_int_0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_terms); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
        __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
        __pyx_t_7 = NULL;
      } else {
        __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 604, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      for (;;) {
        if (likely(!__pyx_t_7)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 604, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            #endif
          } else {
            if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 604, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            #endif
          }
        } else {
          __pyx_t_5 = __pyx_t_7(__pyx_t_1);
          if (unlikely(!__pyx_t_5)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 604, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_5);
        __pyx_t_5 = 0;
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
        __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2);
        __pyx_t_2 = __pyx_t_5;
        __pyx_t_5 = 0;

        /* "pyDatalog/pyEngine.py":605
 *         if not clause.body: # if it is a fact, update indexes
 *             for i, term in enumerate(clause.head.terms):
 *                 clauses = pred.index[i].setdefault(term.id, set()) # create a set if needed             # <<<<<<<<<<<<<<
 *                 clauses.add(clause)
 *         else:
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_pred, __pyx_n_s_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_8, __pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_setdefault); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PySet_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 605, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
            __pyx_t_12 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
          __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 605, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_10};
          __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 605, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 605, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          if (__pyx_t_11) {
            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __pyx_t_11 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 605, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF_SET(__pyx_v_clauses, __pyx_t_5);
        __pyx_t_5 = 0;

        /* "pyDatalog/pyEngine.py":606
 *             for i, term in enumerate(clause.head.terms):
 *                 clauses = pred.index[i].setdefault(term.id, set()) # create a set if needed
 *                 clauses.add(clause)             # <<<<<<<<<<<<<<
 *         else:
 *             if any(literal.pred.id == pred.id for literal in clause.body):
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_clauses, __pyx_n_s_add); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 606, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_5 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_13, __pyx_cur_scope->__pyx_v_clause) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_cur_scope->__pyx_v_clause);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 606, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "pyDatalog/pyEngine.py":604
 *         pred.db[id_] = clause
 *         if not clause.body: # if it is a fact, update indexes
 *             for i, term in enumerate(clause.head.terms):             # <<<<<<<<<<<<<<
 *                 clauses = pred.index[i].setdefault(term.id, set()) # create a set if needed
 *                 clauses.add(clause)
 */
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":603
 *         retract(clause) # to ensure unicity of functions
 *         pred.db[id_] = clause
 *         if not clause.body: # if it is a fact, update indexes             # <<<<<<<<<<<<<<
 *             for i, term in enumerate(clause.head.terms):
 *                 clauses = pred.index[i].setdefault(term.id, set()) # create a set if needed
 */
      goto __pyx_L4;
    }

    /* "pyDatalog/pyEngine.py":608
 *                 clauses.add(clause)
 *         else:
 *             if any(literal.pred.id == pred.id for literal in clause.body):             # <<<<<<<<<<<<<<
 *                 pred.recursive = True
 *             pred.clauses[id_] = clause
 */
    /*else*/ {
      __pyx_t_2 = __pyx_pf_9pyDatalog_8pyEngine_7assert__genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 608, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_3) {

        /* "pyDatalog/pyEngine.py":609
 *         else:
 *             if any(literal.pred.id == pred.id for literal in clause.body):
 *                 pred.recursive = True             # <<<<<<<<<<<<<<
 *             pred.clauses[id_] = clause
 *         insert(pred)
 */
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_pred, __pyx_n_s_recursive, Py_True) < 0) __PYX_ERR(0, 609, __pyx_L1_error)

        /* "pyDatalog/pyEngine.py":608
 *                 clauses.add(clause)
 *         else:
 *             if any(literal.pred.id == pred.id for literal in clause.body):             # <<<<<<<<<<<<<<
 *                 pred.recursive = True
 *             pred.clauses[id_] = clause
 */
      }

      /* "pyDatalog/pyEngine.py":610
 *             if any(literal.pred.id == pred.id for literal in clause.body):
 *                 pred.recursive = True
 *             pred.clauses[id_] = clause             # <<<<<<<<<<<<<<
 *         insert(pred)
 *     return clause
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_pred, __pyx_n_s_clauses); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_id_, __pyx_cur_scope->__pyx_v_clause) < 0)) __PYX_ERR(0, 610, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;

    /* "pyDatalog/pyEngine.py":611
 *                 pred.recursive = True
 *             pred.clauses[id_] = clause
 *         insert(pred)             # <<<<<<<<<<<<<<
 *     return clause
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_insert); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_cur_scope->__pyx_v_pred) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_cur_scope->__pyx_v_pred);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":599
 *     pred = clause.head.pred
 * 
 *     if not pred.prim:                   # Ignore assertions for primitives.             # <<<<<<<<<<<<<<
 *         id_ = clause.get_id()
 *         retract(clause) # to ensure unicity of functions
 */
  }

  /* "pyDatalog/pyEngine.py":612
 *             pred.clauses[id_] = clause
 *         insert(pred)
 *     return clause             # <<<<<<<<<<<<<<
 * 
 * def retract(clause):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_clause);
  __pyx_r = __pyx_cur_scope->__pyx_v_clause;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":595
 *     return pred
 * 
 * def assert_(clause):             # <<<<<<<<<<<<<<
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("pyDatalog.pyEngine.assert_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_id_);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XDECREF(__pyx_v_clauses);
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_7assert__2generator8);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":614
 *     return clause
 * 
 * def retract(clause):             # <<<<<<<<<<<<<<
 *     """ retract a clause from the database"""
 *     pred = clause.head.pred
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_11retract(PyObject *__pyx_self, PyObject *__pyx_v_clause); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_10retract[] = " retract a clause from the database";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_11retract = {"retract", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_11retract, METH_O, __pyx_doc_9pyDatalog_8pyEngine_10retract};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_11retract(PyObject *__pyx_self, PyObject *__pyx_v_clause) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("retract (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_10retract(__pyx_self, ((PyObject *)__pyx_v_clause));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_10retract(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_clause) {
  PyObject *__pyx_v_pred = NULL;
  PyObject *__pyx_v_id_ = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_term = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("retract", 0);
  __Pyx_INCREF(__pyx_v_clause);

  /* "pyDatalog/pyEngine.py":616
 * def retract(clause):
 *     """ retract a clause from the database"""
 *     pred = clause.head.pred             # <<<<<<<<<<<<<<
 *     id_ = clause.get_id()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_pred = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":617
 *     """ retract a clause from the database"""
 *     pred = clause.head.pred
 *     id_ = clause.get_id()             # <<<<<<<<<<<<<<
 * 
 *     if id_ in pred.db:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_get_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_id_ = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":619
 *     id_ = clause.get_id()
 * 
 *     if id_ in pred.db:             # <<<<<<<<<<<<<<
 *         if not clause.body: # if it is a fact, update indexes
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_id_, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":620
 * 
 *     if id_ in pred.db:
 *         if not clause.body: # if it is a fact, update indexes             # <<<<<<<<<<<<<<
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 *             for i, term in enumerate(clause.head.terms):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = ((!__pyx_t_5) != 0);
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":621
 *     if id_ in pred.db:
 *         if not clause.body: # if it is a fact, update indexes
 *             clause = pred.db[id_] # make sure it is identical to the one in the index             # <<<<<<<<<<<<<<
 *             for i, term in enumerate(clause.head.terms):
 *                 pred.index[i][term.id].remove(clause)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_id_); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_clause, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":622
 *         if not clause.body: # if it is a fact, update indexes
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 *             for i, term in enumerate(clause.head.terms):             # <<<<<<<<<<<<<<
 *                 pred.index[i][term.id].remove(clause)
 *                 # TODO del pred.index[i][term] if the set is empty
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_1 = __pyx_int_0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_terms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
        __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
        __pyx_t_7 = NULL;
      } else {
        __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 622, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      for (;;) {
        if (likely(!__pyx_t_7)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 622, __pyx_L1_error)
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          } else {
            if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 622, __pyx_L1_error)
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          }
        } else {
          __pyx_t_3 = __pyx_t_7(__pyx_t_2);
          if (unlikely(!__pyx_t_3)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 622, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_XDECREF_SET(__pyx_v_term, __pyx_t_3);
        __pyx_t_3 = 0;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
        __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1);
        __pyx_t_1 = __pyx_t_3;
        __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":623
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 *             for i, term in enumerate(clause.head.terms):
 *                 pred.index[i][term.id].remove(clause)             # <<<<<<<<<<<<<<
 *                 # TODO del pred.index[i][term] if the set is empty
 *         else:
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_8, __pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_remove); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_10, __pyx_v_clause) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_clause);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":622
 *         if not clause.body: # if it is a fact, update indexes
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 *             for i, term in enumerate(clause.head.terms):             # <<<<<<<<<<<<<<
 *                 pred.index[i][term.id].remove(clause)
 *                 # TODO del pred.index[i][term] if the set is empty
 */
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":620
 * 
 *     if id_ in pred.db:
 *         if not clause.body: # if it is a fact, update indexes             # <<<<<<<<<<<<<<
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 *             for i, term in enumerate(clause.head.terms):
 */
      goto __pyx_L4;
    }

    /* "pyDatalog/pyEngine.py":626
 *                 # TODO del pred.index[i][term] if the set is empty
 *         else:
 *             del pred.clauses[id_]             # <<<<<<<<<<<<<<
 *         del pred.db[id_]  # remove clause from pred.db
 *     # delete it completely if it's a temporary query predicate
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_clauses); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_DelItem(__pyx_t_1, __pyx_v_id_) < 0)) __PYX_ERR(0, 626, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;

    /* "pyDatalog/pyEngine.py":627
 *         else:
 *             del pred.clauses[id_]
 *         del pred.db[id_]  # remove clause from pred.db             # <<<<<<<<<<<<<<
 *     # delete it completely if it's a temporary query predicate
 *     if pred.name.startswith('_pyD_query') and len(pred.db) == 0 and pred.prim == None:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_db); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 627, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyObject_DelItem(__pyx_t_1, __pyx_v_id_) < 0)) __PYX_ERR(0, 627, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":619
 *     id_ = clause.get_id()
 * 
 *     if id_ in pred.db:             # <<<<<<<<<<<<<<
 *         if not clause.body: # if it is a fact, update indexes
 *             clause = pred.db[id_] # make sure it is identical to the one in the index
 */
  }

  /* "pyDatalog/pyEngine.py":629
 *         del pred.db[id_]  # remove clause from pred.db
 *     # delete it completely if it's a temporary query predicate
 *     if pred.name.startswith('_pyD_query') and len(pred.db) == 0 and pred.prim == None:             # <<<<<<<<<<<<<<
 *         remove(pred)
 *     return clause
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_startswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_n_s_pyD_query) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_s_pyD_query);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_db); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((__pyx_t_6 == 0) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred, __pyx_n_s_prim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __pyx_t_5;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_4) {

    /* "pyDatalog/pyEngine.py":630
 *     # delete it completely if it's a temporary query predicate
 *     if pred.name.startswith('_pyD_query') and len(pred.db) == 0 and pred.prim == None:
 *         remove(pred)             # <<<<<<<<<<<<<<
 *     return clause
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_remove); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_v_pred) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_pred);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":629
 *         del pred.db[id_]  # remove clause from pred.db
 *     # delete it completely if it's a temporary query predicate
 *     if pred.name.startswith('_pyD_query') and len(pred.db) == 0 and pred.prim == None:             # <<<<<<<<<<<<<<
 *         remove(pred)
 *     return clause
 */
  }

  /* "pyDatalog/pyEngine.py":631
 *     if pred.name.startswith('_pyD_query') and len(pred.db) == 0 and pred.prim == None:
 *         remove(pred)
 *     return clause             # <<<<<<<<<<<<<<
 * 
 * def relevant_clauses(literal):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_clause);
  __pyx_r = __pyx_v_clause;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":614
 *     return clause
 * 
 * def retract(clause):             # <<<<<<<<<<<<<<
 *     """ retract a clause from the database"""
 *     pred = clause.head.pred
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pyDatalog.pyEngine.retract", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pred);
  __Pyx_XDECREF(__pyx_v_id_);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_term);
  __Pyx_XDECREF(__pyx_v_clause);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_14generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":633
 *     return clause
 * 
 * def relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_13relevant_clauses(PyObject *__pyx_self, PyObject *__pyx_v_literal); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_12relevant_clauses[] = " returns matching clauses for a literal query, using index ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_13relevant_clauses = {"relevant_clauses", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_13relevant_clauses, METH_O, __pyx_doc_9pyDatalog_8pyEngine_12relevant_clauses};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_13relevant_clauses(PyObject *__pyx_self, PyObject *__pyx_v_literal) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("relevant_clauses (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_12relevant_clauses(__pyx_self, ((PyObject *)__pyx_v_literal));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_12relevant_clauses(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_literal) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("relevant_clauses", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 633, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_literal = __pyx_v_literal;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_literal);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_literal);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_14generator1, __pyx_codeobj__26, (PyObject *) __pyx_cur_scope, __pyx_n_s_relevant_clauses, __pyx_n_s_relevant_clauses, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.relevant_clauses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_14generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("relevant_clauses", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_yield;
    case 2: goto __pyx_L13_resume_from_yield;
    case 3: goto __pyx_L16_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 633, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":635
 * def relevant_clauses(literal):
 *     """ returns matching clauses for a literal query, using index """
 *     result = None             # <<<<<<<<<<<<<<
 *     for i, term in enumerate(literal.terms):
 *         if term.is_const():
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_cur_scope->__pyx_v_result = Py_None;

  /* "pyDatalog/pyEngine.py":636
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 *     for i, term in enumerate(literal.terms):             # <<<<<<<<<<<<<<
 *         if term.is_const():
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 636, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 636, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 636, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 636, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_term);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_term, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":637
 *     result = None
 *     for i, term in enumerate(literal.terms):
 *         if term.is_const():             # <<<<<<<<<<<<<<
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 *             result = facts if result is None else result.intersection(facts)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_term, __pyx_n_s_is_const); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_8) {

      /* "pyDatalog/pyEngine.py":638
 *     for i, term in enumerate(literal.terms):
 *         if term.is_const():
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set             # <<<<<<<<<<<<<<
 *             result = facts if result is None else result.intersection(facts)
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_get); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_term, __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PySet_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_6, __pyx_t_9};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_6, __pyx_t_9};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 638, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
        __pyx_t_6 = 0;
        __pyx_t_9 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_facts);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_facts, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":639
 *         if term.is_const():
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 *             result = facts if result is None else result.intersection(facts)             # <<<<<<<<<<<<<<
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb
 *         for v in literal.pred.db.values():
 */
      __pyx_t_8 = (__pyx_cur_scope->__pyx_v_result == Py_None);
      if ((__pyx_t_8 != 0)) {
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_facts);
        __pyx_t_2 = __pyx_cur_scope->__pyx_v_facts;
      } else {
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_result, __pyx_n_s_intersection); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_9 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
          }
        }
        __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_9, __pyx_cur_scope->__pyx_v_facts) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_cur_scope->__pyx_v_facts);
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 639, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_2 = __pyx_t_7;
        __pyx_t_7 = 0;
      }
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_result);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":637
 *     result = None
 *     for i, term in enumerate(literal.terms):
 *         if term.is_const():             # <<<<<<<<<<<<<<
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 *             result = facts if result is None else result.intersection(facts)
 */
    }

    /* "pyDatalog/pyEngine.py":636
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 *     for i, term in enumerate(literal.terms):             # <<<<<<<<<<<<<<
 *         if term.is_const():
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":640
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 *             result = facts if result is None else result.intersection(facts)
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb             # <<<<<<<<<<<<<<
 *         for v in literal.pred.db.values():
 *             yield v
 */
  __pyx_t_8 = (__pyx_cur_scope->__pyx_v_result == Py_None);
  __pyx_t_13 = (__pyx_t_8 != 0);
  if (__pyx_t_13) {

    /* "pyDatalog/pyEngine.py":641
 *             result = facts if result is None else result.intersection(facts)
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb
 *         for v in literal.pred.db.values():             # <<<<<<<<<<<<<<
 *             yield v
 *     else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_db); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 641, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 641, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 641, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_5(__pyx_t_3);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 641, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":642
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb
 *         for v in literal.pred.db.values():
 *             yield v             # <<<<<<<<<<<<<<
 *     else:
 *         for v in literal.pred.clauses.values():
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
      __pyx_r = __pyx_cur_scope->__pyx_v_v;
      __Pyx_XGIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L10_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_3);
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 642, __pyx_L1_error)

      /* "pyDatalog/pyEngine.py":641
 *             result = facts if result is None else result.intersection(facts)
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb
 *         for v in literal.pred.db.values():             # <<<<<<<<<<<<<<
 *             yield v
 *     else:
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":640
 *             facts = literal.pred.index[i].get(term.id, set()) # default : a set
 *             result = facts if result is None else result.intersection(facts)
 *     if result is None: # no constants found in literal, thus could not filter literal.pred.deb             # <<<<<<<<<<<<<<
 *         for v in literal.pred.db.values():
 *             yield v
 */
    goto __pyx_L7;
  }

  /* "pyDatalog/pyEngine.py":644
 *             yield v
 *     else:
 *         for v in literal.pred.clauses.values():             # <<<<<<<<<<<<<<
 *             yield v
 *         for v in result:
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_clauses); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 644, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 644, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 644, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 644, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":645
 *     else:
 *         for v in literal.pred.clauses.values():
 *             yield v             # <<<<<<<<<<<<<<
 *         for v in result:
 *             yield v
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
      __pyx_r = __pyx_cur_scope->__pyx_v_v;
      __Pyx_XGIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L13_resume_from_yield:;
      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_1);
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 645, __pyx_L1_error)

      /* "pyDatalog/pyEngine.py":644
 *             yield v
 *     else:
 *         for v in literal.pred.clauses.values():             # <<<<<<<<<<<<<<
 *             yield v
 *         for v in result:
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":646
 *         for v in literal.pred.clauses.values():
 *             yield v
 *         for v in result:             # <<<<<<<<<<<<<<
 *             yield v
 * 
 */
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_result)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_result)) {
      __pyx_t_1 = __pyx_cur_scope->__pyx_v_result; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 646, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 646, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 646, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 646, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":647
 *             yield v
 *         for v in result:
 *             yield v             # <<<<<<<<<<<<<<
 * 
 * ################# Subgoals ###############################
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
      __pyx_r = __pyx_cur_scope->__pyx_v_v;
      __Pyx_XGIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L16_resume_from_yield:;
      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_1);
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 647, __pyx_L1_error)

      /* "pyDatalog/pyEngine.py":646
 *         for v in literal.pred.clauses.values():
 *             yield v
 *         for v in result:             # <<<<<<<<<<<<<<
 *             yield v
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L7:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pyDatalog/pyEngine.py":633
 *     return clause
 * 
 * def relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("relevant_clauses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":671
 *     """
 *     __slots__ = ['literal', 'facts', 'waiters', 'tasks', 'clauses', 'recursive', 'is_done', 'on_completion_']
 *     def __init__(self, literal):             # <<<<<<<<<<<<<<
 *         self.literal = literal
 *         self.facts = {}
 */

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_literal = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_literal,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_literal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 671, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_literal = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 671, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal___init__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), __pyx_v_literal);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal___init__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_literal) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pyDatalog/pyEngine.py":672
 *     __slots__ = ['literal', 'facts', 'waiters', 'tasks', 'clauses', 'recursive', 'is_done', 'on_completion_']
 *     def __init__(self, literal):
 *         self.literal = literal             # <<<<<<<<<<<<<<
 *         self.facts = {}
 *         self.waiters = []
 */
  if (!(likely(((__pyx_v_literal) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_literal, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(0, 672, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_literal;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->literal);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->literal));
  __pyx_v_self->literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":673
 *     def __init__(self, literal):
 *         self.literal = literal
 *         self.facts = {}             # <<<<<<<<<<<<<<
 *         self.waiters = []
 *         self.recursive = literal.pred.recursive
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->facts);
  __Pyx_DECREF(__pyx_v_self->facts);
  __pyx_v_self->facts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":674
 *         self.literal = literal
 *         self.facts = {}
 *         self.waiters = []             # <<<<<<<<<<<<<<
 *         self.recursive = literal.pred.recursive
 *         self.tasks = deque() if self.recursive else list()
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 674, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->waiters);
  __Pyx_DECREF(__pyx_v_self->waiters);
  __pyx_v_self->waiters = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":675
 *         self.facts = {}
 *         self.waiters = []
 *         self.recursive = literal.pred.recursive             # <<<<<<<<<<<<<<
 *         self.tasks = deque() if self.recursive else list()
 *         self.clauses = []
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_recursive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 675, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->recursive);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->recursive));
  __pyx_v_self->recursive = ((PyBoolObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":676
 *         self.waiters = []
 *         self.recursive = literal.pred.recursive
 *         self.tasks = deque() if self.recursive else list()             # <<<<<<<<<<<<<<
 *         self.clauses = []
 *         # subgoal is done when a partial literal is true
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->recursive)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 676, __pyx_L1_error)
  if (__pyx_t_3) {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_deque); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 676, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->tasks);
  __Pyx_DECREF(__pyx_v_self->tasks);
  __pyx_v_self->tasks = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":677
 *         self.recursive = literal.pred.recursive
 *         self.tasks = deque() if self.recursive else list()
 *         self.clauses = []             # <<<<<<<<<<<<<<
 *         # subgoal is done when a partial literal is true
 *         # or when one fact is found for a function of constants
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->clauses);
  __Pyx_DECREF(__pyx_v_self->clauses);
  __pyx_v_self->clauses = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":680
 *         # subgoal is done when a partial literal is true
 *         # or when one fact is found for a function of constants
 *         self.is_done = False             # <<<<<<<<<<<<<<
 *         self.on_completion_ = []
 * 
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->is_done);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->is_done));
  __pyx_v_self->is_done = ((PyBoolObject *)Py_False);

  /* "pyDatalog/pyEngine.py":681
 *         # or when one fact is found for a function of constants
 *         self.is_done = False
 *         self.on_completion_ = []             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->on_completion_);
  __Pyx_DECREF(__pyx_v_self->on_completion_);
  __pyx_v_self->on_completion_ = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":671
 *     """
 *     __slots__ = ['literal', 'facts', 'waiters', 'tasks', 'clauses', 'recursive', 'is_done', 'on_completion_']
 *     def __init__(self, literal):             # <<<<<<<<<<<<<<
 *         self.literal = literal
 *         self.facts = {}
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":683
 *         self.on_completion_ = []
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return str(self.literal)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_3__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_2__repr__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_2__repr__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "pyDatalog/pyEngine.py":684
 * 
 *     def __repr__(self):
 *         return str(self.literal)             # <<<<<<<<<<<<<<
 * 
 *     def search(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_v_self->literal)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":683
 *         self.on_completion_ = []
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return str(self.literal)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":686
 *         return str(self.literal)
 * 
 *     def search(self):             # <<<<<<<<<<<<<<
 *         """
 *         Search for derivations of the literal associated with this subgoal
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5search(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_4search[] = " \n        Search for derivations of the literal associated with this subgoal \n        aka SLG_SUBGOAL in the reference article\n        ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_5search = {"search", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5search, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_4search};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5search(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("search (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_4search(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_4search(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal0 = NULL;
  PyObject *__pyx_v_class0 = NULL;
  PyObject *__pyx_v_terms = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_base_literal = NULL;
  PyObject *__pyx_v__class = NULL;
  PyObject *__pyx_v_literal = NULL;
  PyObject *__pyx_v_resolver = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_method_name = NULL;
  PyObject *__pyx_v_results = NULL;
  PyObject *__pyx_v_base_terms = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_clause = NULL;
  PyObject *__pyx_v_renamed = NULL;
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_literal1 = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v_Y1 = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal2 = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete __pyx_t_19;
  int __pyx_t_20;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("search", 0);

  /* "pyDatalog/pyEngine.py":691
 *         aka SLG_SUBGOAL in the reference article
 *         """
 *         literal0 = self.literal             # <<<<<<<<<<<<<<
 *         class0 = literal0.pred._class()
 *         terms = literal0.terms
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->literal);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_literal0 = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":692
 *         """
 *         literal0 = self.literal
 *         class0 = literal0.pred._class()             # <<<<<<<<<<<<<<
 *         terms = literal0.terms
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal0->pred, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_class0 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":693
 *         literal0 = self.literal
 *         class0 = literal0.pred._class()
 *         terms = literal0.terms             # <<<<<<<<<<<<<<
 * 
 *         if class0 and terms[1].is_const() and terms[1].id is None: return self.next_step()
 */
  __pyx_t_1 = __pyx_v_literal0->terms;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_terms = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":695
 *         terms = literal0.terms
 * 
 *         if class0 and terms[1].is_const() and terms[1].id is None: return self.next_step()             # <<<<<<<<<<<<<<
 *         if hasattr(literal0.pred, 'base_pred'): # this is a negated literal
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_class0); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 695, __pyx_L1_error)
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  if (unlikely(__pyx_v_terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 695, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  if (unlikely(__pyx_v_terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 695, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (__pyx_t_3 == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_4 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "pyDatalog/pyEngine.py":696
 * 
 *         if class0 and terms[1].is_const() and terms[1].id is None: return self.next_step()
 *         if hasattr(literal0.pred, 'base_pred'): # this is a negated literal             # <<<<<<<<<<<<<<
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)
 */
  __pyx_t_3 = __pyx_v_literal0->pred;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_HasAttr(__pyx_t_3, __pyx_n_s_base_pred); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 696, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = (__pyx_t_4 != 0);
  if (__pyx_t_6) {

    /* "pyDatalog/pyEngine.py":697
 *         if class0 and terms[1].is_const() and terms[1].id is None: return self.next_step()
 *         if hasattr(literal0.pred, 'base_pred'): # this is a negated literal
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)
 *             base_literal = Literal(literal0.pred.base_pred, terms)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {
    } else {
      __pyx_t_6 = __pyx_t_4;
      goto __pyx_L9_bool_binop_done;
    }
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __pyx_t_4;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_6) {

      /* "pyDatalog/pyEngine.py":698
 *         if hasattr(literal0.pred, 'base_pred'): # this is a negated literal
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)             # <<<<<<<<<<<<<<
 *             base_literal = Literal(literal0.pred.base_pred, terms)
 *             self.complete(base_literal)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_pyDatalog_will_search_negation_o, ((PyObject *)__pyx_v_literal0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 698, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":697
 *         if class0 and terms[1].is_const() and terms[1].id is None: return self.next_step()
 *         if hasattr(literal0.pred, 'base_pred'): # this is a negated literal
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)
 *             base_literal = Literal(literal0.pred.base_pred, terms)
 */
    }

    /* "pyDatalog/pyEngine.py":699
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)
 *             base_literal = Literal(literal0.pred.base_pred, terms)             # <<<<<<<<<<<<<<
 *             self.complete(base_literal)
 *             return self.next_step()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal0->pred, __pyx_n_s_base_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_terms);
    __Pyx_GIVEREF(__pyx_v_terms);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_terms);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_base_literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":700
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)
 *             base_literal = Literal(literal0.pred.base_pred, terms)
 *             self.complete(base_literal)             # <<<<<<<<<<<<<<
 *             return self.next_step()
 * 
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->complete(__pyx_v_self, __pyx_v_base_literal, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 700, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":701
 *             base_literal = Literal(literal0.pred.base_pred, terms)
 *             self.complete(base_literal)
 *             return self.next_step()             # <<<<<<<<<<<<<<
 * 
 *         for _class in literal0.pred.parent_classes():
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":696
 * 
 *         if class0 and terms[1].is_const() and terms[1].id is None: return self.next_step()
 *         if hasattr(literal0.pred, 'base_pred'): # this is a negated literal             # <<<<<<<<<<<<<<
 *             if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                 Logger.debug("pyDatalog will search negation of %s" % literal0)
 */
  }

  /* "pyDatalog/pyEngine.py":703
 *             return self.next_step()
 * 
 *         for _class in literal0.pred.parent_classes():             # <<<<<<<<<<<<<<
 *             literal = literal0.rebased(_class)
 * 
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal0->pred, __pyx_n_s_parent_classes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_7 = __pyx_t_3; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 703, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_7))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 703, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 703, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_9(__pyx_t_7);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 703, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v__class, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":704
 * 
 *         for _class in literal0.pred.parent_classes():
 *             literal = literal0.rebased(_class)             # <<<<<<<<<<<<<<
 * 
 *             if Python_resolvers:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_literal0), __pyx_n_s_rebased); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v__class) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v__class);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 704, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_literal, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":706
 *             literal = literal0.rebased(_class)
 * 
 *             if Python_resolvers:             # <<<<<<<<<<<<<<
 *                 resolver = literal.pred.id if literal.pred.id in Python_resolvers \
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Python_resolvers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_6) {

      /* "pyDatalog/pyEngine.py":707
 * 
 *             if Python_resolvers:
 *                 resolver = literal.pred.id if literal.pred.id in Python_resolvers \             # <<<<<<<<<<<<<<
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 *                 if resolver in Python_resolvers:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Python_resolvers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 707, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((__pyx_t_6 != 0)) {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_3 = __pyx_t_1;
        __pyx_t_1 = 0;
      } else {

        /* "pyDatalog/pyEngine.py":708
 *             if Python_resolvers:
 *                 resolver = literal.pred.id if literal.pred.id in Python_resolvers \
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")             # <<<<<<<<<<<<<<
 *                 if resolver in Python_resolvers:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_arity); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Add(__pyx_t_10, __pyx_kp_s__8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 708, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_12 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s__8, __pyx_t_11};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s__8, __pyx_t_11};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        {
          __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 708, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_INCREF(__pyx_kp_s__8);
          __Pyx_GIVEREF(__pyx_kp_s__8);
          PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_kp_s__8);
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_11);
          __pyx_t_11 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_3 = __pyx_t_1;
        __pyx_t_1 = 0;
      }
      __Pyx_XDECREF_SET(__pyx_v_resolver, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":709
 *                 resolver = literal.pred.id if literal.pred.id in Python_resolvers \
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 *                 if resolver in Python_resolvers:             # <<<<<<<<<<<<<<
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Python_resolvers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_v_resolver, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 709, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = (__pyx_t_6 != 0);
      if (__pyx_t_4) {

        /* "pyDatalog/pyEngine.py":710
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 *                 if resolver in Python_resolvers:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 *                     for result in Python_resolvers[resolver](*terms):
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L16_bool_binop_done;
        }
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 710, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = __pyx_t_6;
        __pyx_L16_bool_binop_done:;
        if (__pyx_t_4) {

          /* "pyDatalog/pyEngine.py":711
 *                 if resolver in Python_resolvers:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)             # <<<<<<<<<<<<<<
 *                     for result in Python_resolvers[resolver](*terms):
 *                         self.fact_candidate(class0, result)
 */
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 711, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_uses_python_resolvers, __pyx_v_literal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_13, function);
            }
          }
          __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_2);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 711, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pyDatalog/pyEngine.py":710
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 *                 if resolver in Python_resolvers:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 *                     for result in Python_resolvers[resolver](*terms):
 */
        }

        /* "pyDatalog/pyEngine.py":712
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 *                     for result in Python_resolvers[resolver](*terms):             # <<<<<<<<<<<<<<
 *                         self.fact_candidate(class0, result)
 *                     return self.next_step()
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Python_resolvers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_resolver); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 712, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PySequence_Tuple(__pyx_v_terms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
          __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_14 = 0;
          __pyx_t_15 = NULL;
        } else {
          __pyx_t_14 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_15 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 712, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        for (;;) {
          if (likely(!__pyx_t_15)) {
            if (likely(PyList_CheckExact(__pyx_t_3))) {
              if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_3)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_2); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 712, __pyx_L1_error)
              #else
              __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              #endif
            } else {
              if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_2); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 712, __pyx_L1_error)
              #else
              __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              #endif
            }
          } else {
            __pyx_t_2 = __pyx_t_15(__pyx_t_3);
            if (unlikely(!__pyx_t_2)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 712, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":713
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 *                     for result in Python_resolvers[resolver](*terms):
 *                         self.fact_candidate(class0, result)             # <<<<<<<<<<<<<<
 *                     return self.next_step()
 *             if _class:
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_v_result, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":712
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 *                     for result in Python_resolvers[resolver](*terms):             # <<<<<<<<<<<<<<
 *                         self.fact_candidate(class0, result)
 *                     return self.next_step()
 */
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":714
 *                     for result in Python_resolvers[resolver](*terms):
 *                         self.fact_candidate(class0, result)
 *                     return self.next_step()             # <<<<<<<<<<<<<<
 *             if _class:
 *                 # TODO add special method for custom comparison
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 714, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L0;

        /* "pyDatalog/pyEngine.py":709
 *                 resolver = literal.pred.id if literal.pred.id in Python_resolvers \
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 *                 if resolver in Python_resolvers:             # <<<<<<<<<<<<<<
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses python resolvers for %s" % literal)
 */
      }

      /* "pyDatalog/pyEngine.py":706
 *             literal = literal0.rebased(_class)
 * 
 *             if Python_resolvers:             # <<<<<<<<<<<<<<
 *                 resolver = literal.pred.id if literal.pred.id in Python_resolvers \
 *                         else literal.pred.id.replace(r'/', str(literal.pred.arity)+r"/")
 */
    }

    /* "pyDatalog/pyEngine.py":715
 *                         self.fact_candidate(class0, result)
 *                     return self.next_step()
 *             if _class:             # <<<<<<<<<<<<<<
 *                 # TODO add special method for custom comparison
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v__class); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 715, __pyx_L1_error)
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":717
 *             if _class:
 *                 # TODO add special method for custom comparison
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed             # <<<<<<<<<<<<<<
 *                 if literal.pred.suffix and method_name in _class.__dict__:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_suffix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arity); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_t_13, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_13);
      __pyx_t_2 = 0;
      __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyString_Format(__pyx_kp_s_pyD__s_i, __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_method_name, ((PyObject*)__pyx_t_13));
      __pyx_t_13 = 0;

      /* "pyDatalog/pyEngine.py":718
 *                 # TODO add special method for custom comparison
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed
 *                 if literal.pred.suffix and method_name in _class.__dict__:             # <<<<<<<<<<<<<<
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 */
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_suffix); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L22_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v__class, __pyx_n_s_dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_v_method_name, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 718, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = (__pyx_t_6 != 0);
      __pyx_t_4 = __pyx_t_5;
      __pyx_L22_bool_binop_done:;
      if (__pyx_t_4) {

        /* "pyDatalog/pyEngine.py":719
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed
 *                 if literal.pred.suffix and method_name in _class.__dict__:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 *                     for result in getattr(_class, method_name)(*(terms[1:])):
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_5) {
        } else {
          __pyx_t_4 = __pyx_t_5;
          goto __pyx_L25_bool_binop_done;
        }
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_Logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_logging); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_13, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 719, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = __pyx_t_5;
        __pyx_L25_bool_binop_done:;
        if (__pyx_t_4) {

          /* "pyDatalog/pyEngine.py":720
 *                 if literal.pred.suffix and method_name in _class.__dict__:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)             # <<<<<<<<<<<<<<
 *                     for result in getattr(_class, method_name)(*(terms[1:])):
 *                         self.fact_candidate(class0, (terms[0],) + result)
 */
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_uses_class_resolvers_f, __pyx_v_literal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_13 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_13)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_13, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pyDatalog/pyEngine.py":719
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed
 *                 if literal.pred.suffix and method_name in _class.__dict__:
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 *                     for result in getattr(_class, method_name)(*(terms[1:])):
 */
        }

        /* "pyDatalog/pyEngine.py":721
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 *                     for result in getattr(_class, method_name)(*(terms[1:])):             # <<<<<<<<<<<<<<
 *                         self.fact_candidate(class0, (terms[0],) + result)
 *                     return self.next_step()
 */
        __pyx_t_3 = __Pyx_GetAttr(__pyx_v__class, __pyx_v_method_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 721, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(__pyx_v_terms == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 721, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_terms, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
          __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_14 = 0;
          __pyx_t_15 = NULL;
        } else {
          __pyx_t_14 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_15 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 721, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        for (;;) {
          if (likely(!__pyx_t_15)) {
            if (likely(PyList_CheckExact(__pyx_t_2))) {
              if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_2)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 721, __pyx_L1_error)
              #else
              __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
            } else {
              if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 721, __pyx_L1_error)
              #else
              __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
            }
          } else {
            __pyx_t_1 = __pyx_t_15(__pyx_t_2);
            if (unlikely(!__pyx_t_1)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 721, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "pyDatalog/pyEngine.py":722
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 *                     for result in getattr(_class, method_name)(*(terms[1:])):
 *                         self.fact_candidate(class0, (terms[0],) + result)             # <<<<<<<<<<<<<<
 *                     return self.next_step()
 *                 if '_pyD_query' in _class.__dict__:
 */
          if (unlikely(__pyx_v_terms == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 722, __pyx_L1_error)
          }
          __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 722, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_t_1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 722, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pyDatalog/pyEngine.py":721
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 *                     for result in getattr(_class, method_name)(*(terms[1:])):             # <<<<<<<<<<<<<<
 *                         self.fact_candidate(class0, (terms[0],) + result)
 *                     return self.next_step()
 */
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":723
 *                     for result in getattr(_class, method_name)(*(terms[1:])):
 *                         self.fact_candidate(class0, (terms[0],) + result)
 *                     return self.next_step()             # <<<<<<<<<<<<<<
 *                 if '_pyD_query' in _class.__dict__:
 *                     try: # call class._pyD_query
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L0;

        /* "pyDatalog/pyEngine.py":718
 *                 # TODO add special method for custom comparison
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed
 *                 if literal.pred.suffix and method_name in _class.__dict__:             # <<<<<<<<<<<<<<
 *                     if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                         Logger.debug("pyDatalog uses class resolvers for %s" % literal)
 */
      }

      /* "pyDatalog/pyEngine.py":724
 *                         self.fact_candidate(class0, (terms[0],) + result)
 *                     return self.next_step()
 *                 if '_pyD_query' in _class.__dict__:             # <<<<<<<<<<<<<<
 *                     try: # call class._pyD_query
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v__class, __pyx_n_s_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_s_pyD_query, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 724, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = (__pyx_t_4 != 0);
      if (__pyx_t_5) {

        /* "pyDatalog/pyEngine.py":725
 *                     return self.next_step()
 *                 if '_pyD_query' in _class.__dict__:
 *                     try: # call class._pyD_query             # <<<<<<<<<<<<<<
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 */
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          /*try:*/ {

            /* "pyDatalog/pyEngine.py":726
 *                 if '_pyD_query' in _class.__dict__:
 *                     try: # call class._pyD_query
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:             # <<<<<<<<<<<<<<
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                             Logic.tl.logic.gc_uncollected = False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_gc_uncollected); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (__pyx_t_4) {
            } else {
              __pyx_t_5 = __pyx_t_4;
              goto __pyx_L39_bool_binop_done;
            }
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v__class, __pyx_n_s_has_SQLAlchemy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 726, __pyx_L30_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_6 = ((!__pyx_t_4) != 0);
            __pyx_t_5 = __pyx_t_6;
            __pyx_L39_bool_binop_done:;
            if (__pyx_t_5) {

              /* "pyDatalog/pyEngine.py":727
 *                     try: # call class._pyD_query
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct             # <<<<<<<<<<<<<<
 *                             Logic.tl.logic.gc_uncollected = False
 *                         results = list(_class._pyD_query(literal.pred.name, terms[1:]))
 */
              __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 727, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_collect); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_2 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
                if (likely(__pyx_t_2)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_2);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_1, function);
                }
              }
              __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 727, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "pyDatalog/pyEngine.py":728
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                             Logic.tl.logic.gc_uncollected = False             # <<<<<<<<<<<<<<
 *                         results = list(_class._pyD_query(literal.pred.name, terms[1:]))
 *                     except AttributeError:
 */
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 728, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 728, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_gc_uncollected, Py_False) < 0) __PYX_ERR(0, 728, __pyx_L30_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "pyDatalog/pyEngine.py":726
 *                 if '_pyD_query' in _class.__dict__:
 *                     try: # call class._pyD_query
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:             # <<<<<<<<<<<<<<
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                             Logic.tl.logic.gc_uncollected = False
 */
            }

            /* "pyDatalog/pyEngine.py":729
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                             Logic.tl.logic.gc_uncollected = False
 *                         results = list(_class._pyD_query(literal.pred.name, terms[1:]))             # <<<<<<<<<<<<<<
 *                     except AttributeError:
 *                         pass
 */
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v__class, __pyx_n_s_pyD_query); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 729, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(__pyx_v_terms == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              __PYX_ERR(0, 729, __pyx_L30_error)
            }
            __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_terms, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_11 = NULL;
            __pyx_t_12 = 0;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
              if (likely(__pyx_t_11)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_11);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_1, function);
                __pyx_t_12 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_1)) {
              PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_13, __pyx_t_2};
              __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 729, __pyx_L30_error)
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
              PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_13, __pyx_t_2};
              __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 729, __pyx_L30_error)
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            } else
            #endif
            {
              __pyx_t_10 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 729, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_10);
              if (__pyx_t_11) {
                __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
              }
              __Pyx_GIVEREF(__pyx_t_13);
              PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_12, __pyx_t_13);
              __Pyx_GIVEREF(__pyx_t_2);
              PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_12, __pyx_t_2);
              __pyx_t_13 = 0;
              __pyx_t_2 = 0;
              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 729, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L30_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF_SET(__pyx_v_results, __pyx_t_1);
            __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":725
 *                     return self.next_step()
 *                 if '_pyD_query' in _class.__dict__:
 *                     try: # call class._pyD_query             # <<<<<<<<<<<<<<
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 */
          }

          /* "pyDatalog/pyEngine.py":733
 *                         pass
 *                     else:
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                             Logger.debug("pyDatalog uses _pyD_query resolvers for %s" % literal)
 *                         for result in results:
 */
          /*else:*/ {
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (__pyx_t_6) {
            } else {
              __pyx_t_5 = __pyx_t_6;
              goto __pyx_L42_bool_binop_done;
            }
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
              if (likely(__pyx_t_3)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_10, function);
              }
            }
            __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2);
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 733, __pyx_L32_except_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_5 = __pyx_t_6;
            __pyx_L42_bool_binop_done:;
            if (__pyx_t_5) {

              /* "pyDatalog/pyEngine.py":734
 *                     else:
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog uses _pyD_query resolvers for %s" % literal)             # <<<<<<<<<<<<<<
 *                         for result in results:
 *                             self.fact_candidate(class0, (terms[0],) + result)
 */
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_Logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 734, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_10 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_uses__pyD_query_resolv, __pyx_v_literal); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 734, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_3 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
                if (likely(__pyx_t_3)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_2, function);
                }
              }
              __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_10);
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "pyDatalog/pyEngine.py":733
 *                         pass
 *                     else:
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                             Logger.debug("pyDatalog uses _pyD_query resolvers for %s" % literal)
 *                         for result in results:
 */
            }

            /* "pyDatalog/pyEngine.py":735
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog uses _pyD_query resolvers for %s" % literal)
 *                         for result in results:             # <<<<<<<<<<<<<<
 *                             self.fact_candidate(class0, (terms[0],) + result)
 *                         return self.next_step()
 */
            __pyx_t_1 = __pyx_v_results; __Pyx_INCREF(__pyx_t_1); __pyx_t_14 = 0;
            for (;;) {
              if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_1)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_2); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 735, __pyx_L32_except_error)
              #else
              __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              #endif
              __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_2);
              __pyx_t_2 = 0;

              /* "pyDatalog/pyEngine.py":736
 *                             Logger.debug("pyDatalog uses _pyD_query resolvers for %s" % literal)
 *                         for result in results:
 *                             self.fact_candidate(class0, (terms[0],) + result)             # <<<<<<<<<<<<<<
 *                         return self.next_step()
 *             if literal.pred.prim: # X==Y, X < Y+Z
 */
              if (unlikely(__pyx_v_terms == Py_None)) {
                PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
                __PYX_ERR(0, 736, __pyx_L32_except_error)
              }
              __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 736, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_GIVEREF(__pyx_t_2);
              PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
              __pyx_t_2 = 0;
              __pyx_t_2 = PyNumber_Add(__pyx_t_10, __pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_10 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_t_2, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 736, __pyx_L32_except_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

              /* "pyDatalog/pyEngine.py":735
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog uses _pyD_query resolvers for %s" % literal)
 *                         for result in results:             # <<<<<<<<<<<<<<
 *                             self.fact_candidate(class0, (terms[0],) + result)
 *                         return self.next_step()
 */
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "pyDatalog/pyEngine.py":737
 *                         for result in results:
 *                             self.fact_candidate(class0, (terms[0],) + result)
 *                         return self.next_step()             # <<<<<<<<<<<<<<
 *             if literal.pred.prim: # X==Y, X < Y+Z
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 737, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_2 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
              if (likely(__pyx_t_2)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_10, function);
              }
            }
            __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 737, __pyx_L32_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_r = __pyx_t_1;
            __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            goto __pyx_L33_except_return;
          }
          __pyx_L30_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "pyDatalog/pyEngine.py":730
 *                             Logic.tl.logic.gc_uncollected = False
 *                         results = list(_class._pyD_query(literal.pred.name, terms[1:]))
 *                     except AttributeError:             # <<<<<<<<<<<<<<
 *                         pass
 *                     else:
 */
          __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
          if (__pyx_t_12) {
            __Pyx_ErrRestore(0,0,0);
            goto __pyx_L31_exception_handled;
          }
          goto __pyx_L32_except_error;
          __pyx_L32_except_error:;

          /* "pyDatalog/pyEngine.py":725
 *                     return self.next_step()
 *                 if '_pyD_query' in _class.__dict__:
 *                     try: # call class._pyD_query             # <<<<<<<<<<<<<<
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 *                             gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 */
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
          goto __pyx_L1_error;
          __pyx_L33_except_return:;
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
          goto __pyx_L0;
          __pyx_L31_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        }

        /* "pyDatalog/pyEngine.py":724
 *                         self.fact_candidate(class0, (terms[0],) + result)
 *                     return self.next_step()
 *                 if '_pyD_query' in _class.__dict__:             # <<<<<<<<<<<<<<
 *                     try: # call class._pyD_query
 *                         if Logic.tl.logic.gc_uncollected and not _class.has_SQLAlchemy:
 */
      }

      /* "pyDatalog/pyEngine.py":715
 *                         self.fact_candidate(class0, result)
 *                     return self.next_step()
 *             if _class:             # <<<<<<<<<<<<<<
 *                 # TODO add special method for custom comparison
 *                 method_name = '_pyD_%s%i' % (literal.pred.suffix, int(literal.pred.arity - 1)) #prefixed
 */
    }

    /* "pyDatalog/pyEngine.py":738
 *                             self.fact_candidate(class0, (terms[0],) + result)
 *                         return self.next_step()
 *             if literal.pred.prim: # X==Y, X < Y+Z             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 738, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_prim); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 738, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 738, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_5) {

      /* "pyDatalog/pyEngine.py":739
 *                         return self.next_step()
 *             if literal.pred.prim: # X==Y, X < Y+Z
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)
 *                 literal.pred.prim(literal, self)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_Logging); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_6) {
      } else {
        __pyx_t_5 = __pyx_t_6;
        goto __pyx_L48_bool_binop_done;
      }
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 739, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_5 = __pyx_t_6;
      __pyx_L48_bool_binop_done:;
      if (__pyx_t_5) {

        /* "pyDatalog/pyEngine.py":740
 *             if literal.pred.prim: # X==Y, X < Y+Z
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)             # <<<<<<<<<<<<<<
 *                 literal.pred.prim(literal, self)
 *                 return self.next_step()
 */
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 740, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_uses_comparison_primit, __pyx_v_literal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 740, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":739
 *                         return self.next_step()
 *             if literal.pred.prim: # X==Y, X < Y+Z
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)
 *                 literal.pred.prim(literal, self)
 */
      }

      /* "pyDatalog/pyEngine.py":741
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)
 *                 literal.pred.prim(literal, self)             # <<<<<<<<<<<<<<
 *                 return self.next_step()
 *             elif literal.aggregate:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_prim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_literal, ((PyObject *)__pyx_v_self)};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 741, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_literal, ((PyObject *)__pyx_v_self)};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 741, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 741, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_INCREF(__pyx_v_literal);
        __Pyx_GIVEREF(__pyx_v_literal);
        PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_12, __pyx_v_literal);
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_12, ((PyObject *)__pyx_v_self));
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 741, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "pyDatalog/pyEngine.py":742
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)
 *                 literal.pred.prim(literal, self)
 *                 return self.next_step()             # <<<<<<<<<<<<<<
 *             elif literal.aggregate:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 742, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 742, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L0;

      /* "pyDatalog/pyEngine.py":738
 *                             self.fact_candidate(class0, (terms[0],) + result)
 *                         return self.next_step()
 *             if literal.pred.prim: # X==Y, X < Y+Z             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses comparison primitive for %s" % literal)
 */
    }

    /* "pyDatalog/pyEngine.py":743
 *                 literal.pred.prim(literal, self)
 *                 return self.next_step()
 *             elif literal.aggregate:             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_aggregate); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_5) {

      /* "pyDatalog/pyEngine.py":744
 *                 return self.next_step()
 *             elif literal.aggregate:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 *                 base_terms = list(terms[:-1])
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_Logging); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (__pyx_t_6) {
      } else {
        __pyx_t_5 = __pyx_t_6;
        goto __pyx_L51_bool_binop_done;
      }
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_10 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 744, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_5 = __pyx_t_6;
      __pyx_L51_bool_binop_done:;
      if (__pyx_t_5) {

        /* "pyDatalog/pyEngine.py":745
 *             elif literal.aggregate:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)             # <<<<<<<<<<<<<<
 *                 base_terms = list(terms[:-1])
 *                 for i in literal.aggregate.slice_to_variabilize:
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 745, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_uses_aggregate_primiti, __pyx_v_literal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 745, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_10 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 745, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":744
 *                 return self.next_step()
 *             elif literal.aggregate:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 *                 base_terms = list(terms[:-1])
 */
      }

      /* "pyDatalog/pyEngine.py":746
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 *                 base_terms = list(terms[:-1])             # <<<<<<<<<<<<<<
 *                 for i in literal.aggregate.slice_to_variabilize:
 *                     base_terms[i] = Fresh_var()
 */
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 746, __pyx_L1_error)
      }
      __pyx_t_10 = __Pyx_PyList_GetSlice(__pyx_v_terms, 0, -1L); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_3 = PySequence_List(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_base_terms = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":747
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 *                 base_terms = list(terms[:-1])
 *                 for i in literal.aggregate.slice_to_variabilize:             # <<<<<<<<<<<<<<
 *                     base_terms[i] = Fresh_var()
 *                 base_literal = Literal(literal.pred.name, base_terms) # without aggregate to avoid infinite loop
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_aggregate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_slice_to_variabilize); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
        __pyx_t_3 = __pyx_t_10; __Pyx_INCREF(__pyx_t_3); __pyx_t_14 = 0;
        __pyx_t_15 = NULL;
      } else {
        __pyx_t_14 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_15 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 747, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      for (;;) {
        if (likely(!__pyx_t_15)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_10); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 747, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 747, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          } else {
            if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_10); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 747, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 747, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          }
        } else {
          __pyx_t_10 = __pyx_t_15(__pyx_t_3);
          if (unlikely(!__pyx_t_10)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 747, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":748
 *                 base_terms = list(terms[:-1])
 *                 for i in literal.aggregate.slice_to_variabilize:
 *                     base_terms[i] = Fresh_var()             # <<<<<<<<<<<<<<
 *                 base_literal = Literal(literal.pred.name, base_terms) # without aggregate to avoid infinite loop
 *                 self.complete(base_literal, literal.aggregate)
 */
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 748, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (unlikely(PyObject_SetItem(__pyx_v_base_terms, __pyx_v_i, __pyx_t_10) < 0)) __PYX_ERR(0, 748, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":747
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 *                 base_terms = list(terms[:-1])
 *                 for i in literal.aggregate.slice_to_variabilize:             # <<<<<<<<<<<<<<
 *                     base_terms[i] = Fresh_var()
 *                 base_literal = Literal(literal.pred.name, base_terms) # without aggregate to avoid infinite loop
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":749
 *                 for i in literal.aggregate.slice_to_variabilize:
 *                     base_terms[i] = Fresh_var()
 *                 base_literal = Literal(literal.pred.name, base_terms) # without aggregate to avoid infinite loop             # <<<<<<<<<<<<<<
 *                 self.complete(base_literal, literal.aggregate)
 *                 return self.next_step()
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_base_terms);
      __Pyx_GIVEREF(__pyx_v_base_terms);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_base_terms);
      __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_base_literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_10);
      __pyx_t_10 = 0;

      /* "pyDatalog/pyEngine.py":750
 *                     base_terms[i] = Fresh_var()
 *                 base_literal = Literal(literal.pred.name, base_terms) # without aggregate to avoid infinite loop
 *                 self.complete(base_literal, literal.aggregate)             # <<<<<<<<<<<<<<
 *                 return self.next_step()
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_aggregate); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_19.__pyx_n = 1;
      __pyx_t_19.aggregate = __pyx_t_10;
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->complete(__pyx_v_self, __pyx_v_base_literal, 0, &__pyx_t_19); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":751
 *                 base_literal = Literal(literal.pred.name, base_terms) # without aggregate to avoid infinite loop
 *                 self.complete(base_literal, literal.aggregate)
 *                 return self.next_step()             # <<<<<<<<<<<<<<
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y
 *                 assert self.clauses == []
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L0;

      /* "pyDatalog/pyEngine.py":743
 *                 literal.pred.prim(literal, self)
 *                 return self.next_step()
 *             elif literal.aggregate:             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses aggregate primitive for %s" % literal)
 */
    }

    /* "pyDatalog/pyEngine.py":752
 *                 self.complete(base_literal, literal.aggregate)
 *                 return self.next_step()
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y             # <<<<<<<<<<<<<<
 *                 assert self.clauses == []
 *                 for clause in relevant_clauses(literal):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Db); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_t_10, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "pyDatalog/pyEngine.py":753
 *                 return self.next_step()
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y
 *                 assert self.clauses == []             # <<<<<<<<<<<<<<
 *                 for clause in relevant_clauses(literal):
 *                     renamed = clause.rename()
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 753, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = PyObject_RichCompare(__pyx_v_self->clauses, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 753, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 753, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_6)) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 753, __pyx_L1_error)
        }
      }
      #endif

      /* "pyDatalog/pyEngine.py":754
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y
 *                 assert self.clauses == []
 *                 for clause in relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_relevant_clauses); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_10 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_literal) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_literal);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 754, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
        __pyx_t_1 = __pyx_t_10; __Pyx_INCREF(__pyx_t_1); __pyx_t_14 = 0;
        __pyx_t_15 = NULL;
      } else {
        __pyx_t_14 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 754, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      for (;;) {
        if (likely(!__pyx_t_15)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_10); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 754, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 754, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          } else {
            if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_10); __pyx_t_14++; if (unlikely(0 < 0)) __PYX_ERR(0, 754, __pyx_L1_error)
            #else
            __pyx_t_10 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 754, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            #endif
          }
        } else {
          __pyx_t_10 = __pyx_t_15(__pyx_t_1);
          if (unlikely(!__pyx_t_10)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 754, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_XDECREF_SET(__pyx_v_clause, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":755
 *                 assert self.clauses == []
 *                 for clause in relevant_clauses(literal):
 *                     renamed = clause.rename()             # <<<<<<<<<<<<<<
 *                     env = literal.unify(renamed.head)
 *                     if env != None:
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_rename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 755, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_10 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 755, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_renamed, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":756
 *                 for clause in relevant_clauses(literal):
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)             # <<<<<<<<<<<<<<
 *                     if env != None:
 *                         clause = renamed.subst(env, class0)
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_unify); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_renamed, __pyx_n_s_head); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 756, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_10 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_13, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 756, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_env, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":757
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 *                     if env != None:             # <<<<<<<<<<<<<<
 *                         clause = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
        __pyx_t_10 = PyObject_RichCompare(__pyx_v_env, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 757, __pyx_L1_error)
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 757, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_6) {

          /* "pyDatalog/pyEngine.py":758
 *                     env = literal.unify(renamed.head)
 *                     if env != None:
 *                         clause = renamed.subst(env, class0)             # <<<<<<<<<<<<<<
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_renamed, __pyx_n_s_subst); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = NULL;
          __pyx_t_12 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
              __pyx_t_12 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_env, __pyx_v_class0};
            __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 758, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_GOTREF(__pyx_t_10);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_env, __pyx_v_class0};
            __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 758, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_GOTREF(__pyx_t_10);
          } else
          #endif
          {
            __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 758, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            if (__pyx_t_2) {
              __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2); __pyx_t_2 = NULL;
            }
            __Pyx_INCREF(__pyx_v_env);
            __Pyx_GIVEREF(__pyx_v_env);
            PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_v_env);
            __Pyx_INCREF(__pyx_v_class0);
            __Pyx_GIVEREF(__pyx_v_class0);
            PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_v_class0);
            __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 758, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF_SET(__pyx_v_clause, __pyx_t_10);
          __pyx_t_10 = 0;

          /* "pyDatalog/pyEngine.py":759
 *                     if env != None:
 *                         clause = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))
 */
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_Logging); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__pyx_t_5) {
          } else {
            __pyx_t_6 = __pyx_t_5;
            goto __pyx_L59_bool_binop_done;
          }
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_13);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_13, function);
            }
          }
          __pyx_t_10 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_2);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_6 = __pyx_t_5;
          __pyx_L59_bool_binop_done:;
          if (__pyx_t_6) {

            /* "pyDatalog/pyEngine.py":760
 *                         clause = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)             # <<<<<<<<<<<<<<
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))
 *                 if self.clauses:
 */
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_Logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 760, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_13 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_will_use_clause_s, __pyx_v_clause); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 760, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_3 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
              if (likely(__pyx_t_3)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_2, function);
              }
            }
            __pyx_t_10 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13);
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 760, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "pyDatalog/pyEngine.py":759
 *                     if env != None:
 *                         clause = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))
 */
          }

          /* "pyDatalog/pyEngine.py":761
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))             # <<<<<<<<<<<<<<
 *                 if self.clauses:
 *                     self.schedule((NEXT_CLAUSE, (self,)))
 */
          if (unlikely(__pyx_v_self->clauses == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
            __PYX_ERR(0, 761, __pyx_L1_error)
          }
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 761, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(((PyObject *)__pyx_v_self));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
          PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
          __Pyx_INCREF(__pyx_v_clause);
          __Pyx_GIVEREF(__pyx_v_clause);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_clause);
          __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 761, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_2);
          __pyx_t_10 = 0;
          __pyx_t_2 = 0;
          __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_self->clauses, __pyx_t_13); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 761, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "pyDatalog/pyEngine.py":757
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 *                     if env != None:             # <<<<<<<<<<<<<<
 *                         clause = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
        }

        /* "pyDatalog/pyEngine.py":754
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y
 *                 assert self.clauses == []
 *                 for clause in relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 */
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":762
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))
 *                 if self.clauses:             # <<<<<<<<<<<<<<
 *                     self.schedule((NEXT_CLAUSE, (self,)))
 *                 return self.next_step()
 */
      __pyx_t_6 = (__pyx_v_self->clauses != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->clauses) != 0);
      if (__pyx_t_6) {

        /* "pyDatalog/pyEngine.py":763
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))
 *                 if self.clauses:
 *                     self.schedule((NEXT_CLAUSE, (self,)))             # <<<<<<<<<<<<<<
 *                 return self.next_step()
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_NEXT_CLAUSE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 763, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 763, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_v_self));
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 763, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_13);
        __pyx_t_1 = 0;
        __pyx_t_13 = 0;
        __pyx_t_13 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 763, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "pyDatalog/pyEngine.py":762
 *                             Logger.debug("pyDatalog will use clause : %s" % clause)
 *                         self.clauses.append((ADD_CLAUSE, (self, clause)))
 *                 if self.clauses:             # <<<<<<<<<<<<<<
 *                     self.schedule((NEXT_CLAUSE, (self,)))
 *                 return self.next_step()
 */
      }

      /* "pyDatalog/pyEngine.py":764
 *                 if self.clauses:
 *                     self.schedule((NEXT_CLAUSE, (self,)))
 *                 return self.next_step()             # <<<<<<<<<<<<<<
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)
 *                 literal1 = literal.equalized()
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_13 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_13;
      __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L0;

      /* "pyDatalog/pyEngine.py":752
 *                 self.complete(base_literal, literal.aggregate)
 *                 return self.next_step()
 *             elif literal.pred.id in Logic.tl.logic.Db: # has a datalog definition, e.g. p(X), p[X]==Y             # <<<<<<<<<<<<<<
 *                 assert self.clauses == []
 *                 for clause in relevant_clauses(literal):
 */
    }

    /* "pyDatalog/pyEngine.py":765
 *                     self.schedule((NEXT_CLAUSE, (self,)))
 *                 return self.next_step()
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)             # <<<<<<<<<<<<<<
 *                 literal1 = literal.equalized()
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition
 */
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_comparison); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_6) {

      /* "pyDatalog/pyEngine.py":766
 *                 return self.next_step()
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)
 *                 literal1 = literal.equalized()             # <<<<<<<<<<<<<<
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition
 *                     Y1 = Fresh_var()
 */
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_equalized); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
        }
      }
      __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_13);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 766, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF_SET(__pyx_v_literal1, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":767
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)
 *                 literal1 = literal.equalized()
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition             # <<<<<<<<<<<<<<
 *                     Y1 = Fresh_var()
 *                     literal1.terms[-1] = Y1
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal1, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Db); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_t_13, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 767, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = (__pyx_t_6 != 0);
      if (__pyx_t_5) {

        /* "pyDatalog/pyEngine.py":768
 *                 literal1 = literal.equalized()
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition
 *                     Y1 = Fresh_var()             # <<<<<<<<<<<<<<
 *                     literal1.terms[-1] = Y1
 *                     literal2 = Literal(literal.pred.comparison, [Y1, terms[-1]])
 */
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_Y1 = ((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":769
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition
 *                     Y1 = Fresh_var()
 *                     literal1.terms[-1] = Y1             # <<<<<<<<<<<<<<
 *                     literal2 = Literal(literal.pred.comparison, [Y1, terms[-1]])
 *                     clause = Clause(literal, [literal1, literal2])
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal1, __pyx_n_s_terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 769, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(__Pyx_SetItemInt(__pyx_t_1, -1L, ((PyObject *)__pyx_v_Y1), long, 1, __Pyx_PyInt_From_long, 0, 1, 1) < 0)) __PYX_ERR(0, 769, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":770
 *                     Y1 = Fresh_var()
 *                     literal1.terms[-1] = Y1
 *                     literal2 = Literal(literal.pred.comparison, [Y1, terms[-1]])             # <<<<<<<<<<<<<<
 *                     clause = Clause(literal, [literal1, literal2])
 *                     renamed = clause.rename()
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 770, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_comparison); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 770, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(__pyx_v_terms == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 770, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_terms, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 770, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 770, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_Y1));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_Y1));
        PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_Y1));
        __Pyx_GIVEREF(__pyx_t_1);
        PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 770, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
        __pyx_t_13 = 0;
        __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 770, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_literal2 = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":771
 *                     literal1.terms[-1] = Y1
 *                     literal2 = Literal(literal.pred.comparison, [Y1, terms[-1]])
 *                     clause = Clause(literal, [literal1, literal2])             # <<<<<<<<<<<<<<
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 */
        __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_literal1);
        __Pyx_GIVEREF(__pyx_v_literal1);
        PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_literal1);
        __Pyx_INCREF(((PyObject *)__pyx_v_literal2));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_literal2));
        PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_literal2));
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_literal);
        __Pyx_GIVEREF(__pyx_v_literal);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_literal);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_clause = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":772
 *                     literal2 = Literal(literal.pred.comparison, [Y1, terms[-1]])
 *                     clause = Clause(literal, [literal1, literal2])
 *                     renamed = clause.rename()             # <<<<<<<<<<<<<<
 *                     env = literal.unify(renamed.head)
 *                     if env != None:
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_rename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 772, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_13) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_13) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 772, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_renamed = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":773
 *                     clause = Clause(literal, [literal1, literal2])
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)             # <<<<<<<<<<<<<<
 *                     if env != None:
 *                         renamed = renamed.subst(env, class0)
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_unify); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 773, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_renamed, __pyx_n_s_head); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 773, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_10, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_13);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 773, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_env = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":774
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 *                     if env != None:             # <<<<<<<<<<<<<<
 *                         renamed = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
        __pyx_t_2 = PyObject_RichCompare(__pyx_v_env, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 774, __pyx_L1_error)
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 774, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_5) {

          /* "pyDatalog/pyEngine.py":775
 *                     env = literal.unify(renamed.head)
 *                     if env != None:
 *                         renamed = renamed.subst(env, class0)             # <<<<<<<<<<<<<<
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog will use clause for comparison: %s" % renamed)
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_renamed, __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 775, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = NULL;
          __pyx_t_12 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_13)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
              __pyx_t_12 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_env, __pyx_v_class0};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 775, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_2);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_env, __pyx_v_class0};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 775, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_GOTREF(__pyx_t_2);
          } else
          #endif
          {
            __pyx_t_10 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 775, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            if (__pyx_t_13) {
              __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_13); __pyx_t_13 = NULL;
            }
            __Pyx_INCREF(__pyx_v_env);
            __Pyx_GIVEREF(__pyx_v_env);
            PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_12, __pyx_v_env);
            __Pyx_INCREF(__pyx_v_class0);
            __Pyx_GIVEREF(__pyx_v_class0);
            PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_12, __pyx_v_class0);
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 775, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF_SET(__pyx_v_renamed, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":776
 *                     if env != None:
 *                         renamed = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                             Logger.debug("pyDatalog will use clause for comparison: %s" % renamed)
 *                         self.schedule((ADD_CLAUSE, (self, renamed)))
 */
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_6) {
          } else {
            __pyx_t_5 = __pyx_t_6;
            goto __pyx_L65_bool_binop_done;
          }
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_10, function);
            }
          }
          __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_1, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_13);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 776, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_5 = __pyx_t_6;
          __pyx_L65_bool_binop_done:;
          if (__pyx_t_5) {

            /* "pyDatalog/pyEngine.py":777
 *                         renamed = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog will use clause for comparison: %s" % renamed)             # <<<<<<<<<<<<<<
 *                         self.schedule((ADD_CLAUSE, (self, renamed)))
 *                     return self.next_step()
 */
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_Logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 777, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_debug); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 777, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_10 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_will_use_clause_for_co, __pyx_v_renamed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 777, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_1 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13);
              if (likely(__pyx_t_1)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_13, function);
              }
            }
            __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_1, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_10);
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 777, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "pyDatalog/pyEngine.py":776
 *                     if env != None:
 *                         renamed = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                             Logger.debug("pyDatalog will use clause for comparison: %s" % renamed)
 *                         self.schedule((ADD_CLAUSE, (self, renamed)))
 */
          }

          /* "pyDatalog/pyEngine.py":778
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                             Logger.debug("pyDatalog will use clause for comparison: %s" % renamed)
 *                         self.schedule((ADD_CLAUSE, (self, renamed)))             # <<<<<<<<<<<<<<
 *                     return self.next_step()
 * 
 */
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 778, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 778, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_INCREF(((PyObject *)__pyx_v_self));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
          PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_v_self));
          __Pyx_INCREF(__pyx_v_renamed);
          __Pyx_GIVEREF(__pyx_v_renamed);
          PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_renamed);
          __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 778, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13);
          __pyx_t_2 = 0;
          __pyx_t_13 = 0;
          __pyx_t_13 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_10), 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 778, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "pyDatalog/pyEngine.py":774
 *                     renamed = clause.rename()
 *                     env = literal.unify(renamed.head)
 *                     if env != None:             # <<<<<<<<<<<<<<
 *                         renamed = renamed.subst(env, class0)
 *                         if Logging and Logger.isEnabledFor(logging.DEBUG):
 */
        }

        /* "pyDatalog/pyEngine.py":779
 *                             Logger.debug("pyDatalog will use clause for comparison: %s" % renamed)
 *                         self.schedule((ADD_CLAUSE, (self, renamed)))
 *                     return self.next_step()             # <<<<<<<<<<<<<<
 * 
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 779, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_2 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
          }
        }
        __pyx_t_13 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 779, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_r = __pyx_t_13;
        __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L0;

        /* "pyDatalog/pyEngine.py":767
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)
 *                 literal1 = literal.equalized()
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition             # <<<<<<<<<<<<<<
 *                     Y1 = Fresh_var()
 *                     literal1.terms[-1] = Y1
 */
      }

      /* "pyDatalog/pyEngine.py":765
 *                     self.schedule((NEXT_CLAUSE, (self,)))
 *                 return self.next_step()
 *             elif literal.pred.comparison: # p[X]<=Y => consider translating to (p[X]==Y1) & (Y1<Y)             # <<<<<<<<<<<<<<
 *                 literal1 = literal.equalized()
 *                 if literal1.pred.id in Logic.tl.logic.Db: # equality has a datalog definition
 */
    }

    /* "pyDatalog/pyEngine.py":703
 *             return self.next_step()
 * 
 *         for _class in literal0.pred.parent_classes():             # <<<<<<<<<<<<<<
 *             literal = literal0.rebased(_class)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "pyDatalog/pyEngine.py":781
 *                     return self.next_step()
 * 
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes             # <<<<<<<<<<<<<<
 *             try:
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_class0); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 781, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":782
 * 
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes
 *             try:             # <<<<<<<<<<<<<<
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_16);
      /*try:*/ {

        /* "pyDatalog/pyEngine.py":783
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes
 *             try:
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:             # <<<<<<<<<<<<<<
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                     Logic.tl.logic.gc_uncollected = False
 */
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Logic); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_tl); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_logic); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_gc_uncollected); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (__pyx_t_6) {
        } else {
          __pyx_t_5 = __pyx_t_6;
          goto __pyx_L75_bool_binop_done;
        }
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_class0, __pyx_n_s_has_SQLAlchemy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 783, __pyx_L68_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_4 = ((!__pyx_t_6) != 0);
        __pyx_t_5 = __pyx_t_4;
        __pyx_L75_bool_binop_done:;
        if (__pyx_t_5) {

          /* "pyDatalog/pyEngine.py":784
 *             try:
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct             # <<<<<<<<<<<<<<
 *                     Logic.tl.logic.gc_uncollected = False
 *                 results = tuple(class0.pyDatalog_search(literal))
 */
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_gc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 784, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_collect); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 784, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
            if (likely(__pyx_t_7)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_10, function);
            }
          }
          __pyx_t_13 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 784, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "pyDatalog/pyEngine.py":785
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                     Logic.tl.logic.gc_uncollected = False             # <<<<<<<<<<<<<<
 *                 results = tuple(class0.pyDatalog_search(literal))
 *             except AttributeError:
 */
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_Logic); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 785, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_tl); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_logic); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 785, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_13, __pyx_n_s_gc_uncollected, Py_False) < 0) __PYX_ERR(0, 785, __pyx_L68_error)
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "pyDatalog/pyEngine.py":783
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes
 *             try:
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:             # <<<<<<<<<<<<<<
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                     Logic.tl.logic.gc_uncollected = False
 */
        }

        /* "pyDatalog/pyEngine.py":786
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 *                     Logic.tl.logic.gc_uncollected = False
 *                 results = tuple(class0.pyDatalog_search(literal))             # <<<<<<<<<<<<<<
 *             except AttributeError:
 *                 pass
 */
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_class0, __pyx_n_s_pyDatalog_search); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 786, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 786, __pyx_L68_error) }
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
          }
        }
        __pyx_t_13 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_7, __pyx_v_literal) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_literal);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 786, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PySequence_Tuple(__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 786, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF_SET(__pyx_v_results, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":782
 * 
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes
 *             try:             # <<<<<<<<<<<<<<
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 */
      }

      /* "pyDatalog/pyEngine.py":790
 *                 pass
 *             else:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                     Logger.debug("pyDatalog uses pyDatalog_search for %s" % literal)
 *                 for result in results:
 */
      /*else:*/ {
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_Logging); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_4) {
        } else {
          __pyx_t_5 = __pyx_t_4;
          goto __pyx_L78_bool_binop_done;
        }
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_Logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_logging); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
          if (likely(__pyx_t_13)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_7, function);
          }
        }
        __pyx_t_10 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_13, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 790, __pyx_L70_except_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_5 = __pyx_t_4;
        __pyx_L78_bool_binop_done:;
        if (__pyx_t_5) {

          /* "pyDatalog/pyEngine.py":791
 *             else:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses pyDatalog_search for %s" % literal)             # <<<<<<<<<<<<<<
 *                 for result in results:
 *                     self.fact_candidate(class0, result)
 */
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 791, __pyx_L70_except_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L70_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 791, __pyx_L70_except_error) }
          __pyx_t_7 = __Pyx_PyString_FormatSafe(__pyx_kp_s_pyDatalog_uses_pyDatalog_search, __pyx_v_literal); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 791, __pyx_L70_except_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_13 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_13)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_10 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_13, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 791, __pyx_L70_except_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "pyDatalog/pyEngine.py":790
 *                 pass
 *             else:
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *                     Logger.debug("pyDatalog uses pyDatalog_search for %s" % literal)
 *                 for result in results:
 */
        }

        /* "pyDatalog/pyEngine.py":792
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses pyDatalog_search for %s" % literal)
 *                 for result in results:             # <<<<<<<<<<<<<<
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()
 */
        __pyx_t_10 = __pyx_v_results; __Pyx_INCREF(__pyx_t_10); __pyx_t_8 = 0;
        for (;;) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 792, __pyx_L70_except_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_10, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 792, __pyx_L70_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
          __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":793
 *                     Logger.debug("pyDatalog uses pyDatalog_search for %s" % literal)
 *                 for result in results:
 *                     self.fact_candidate(class0, result)             # <<<<<<<<<<<<<<
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_v_result, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 793, __pyx_L70_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":792
 *                 if Logging and Logger.isEnabledFor(logging.DEBUG):
 *                     Logger.debug("pyDatalog uses pyDatalog_search for %s" % literal)
 *                 for result in results:             # <<<<<<<<<<<<<<
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()
 */
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "pyDatalog/pyEngine.py":794
 *                 for result in results:
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()             # <<<<<<<<<<<<<<
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 794, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_10 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 794, __pyx_L70_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_10;
        __pyx_t_10 = 0;
        goto __pyx_L71_except_return;
      }
      __pyx_L68_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pyDatalog/pyEngine.py":787
 *                     Logic.tl.logic.gc_uncollected = False
 *                 results = tuple(class0.pyDatalog_search(literal))
 *             except AttributeError:             # <<<<<<<<<<<<<<
 *                 pass
 *             else:
 */
      __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
      if (__pyx_t_12) {
        __Pyx_ErrRestore(0,0,0);
        goto __pyx_L69_exception_handled;
      }
      goto __pyx_L70_except_error;
      __pyx_L70_except_error:;

      /* "pyDatalog/pyEngine.py":782
 * 
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes
 *             try:             # <<<<<<<<<<<<<<
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 *                     gc.collect() # to make sure pyDatalog.metaMixin.__refs__[cls] is correct
 */
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      goto __pyx_L1_error;
      __pyx_L71_except_return:;
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      goto __pyx_L0;
      __pyx_L69_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16);
    }

    /* "pyDatalog/pyEngine.py":781
 *                     return self.next_step()
 * 
 *         if class0: # a.p[X]==Y, a.p[X]<y, to access instance attributes             # <<<<<<<<<<<<<<
 *             try:
 *                 if Logic.tl.logic.gc_uncollected and not class0.has_SQLAlchemy:
 */
    goto __pyx_L67;
  }

  /* "pyDatalog/pyEngine.py":795
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \             # <<<<<<<<<<<<<<
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 */
  if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 795, __pyx_L1_error) }
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_comparison); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L82_bool_binop_done;
  }
  if (unlikely(__pyx_v_terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 795, __pyx_L1_error)
  }
  __pyx_t_8 = PyList_GET_SIZE(__pyx_v_terms); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 795, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_8 == 3) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L82_bool_binop_done;
  }

  /* "pyDatalog/pyEngine.py":796
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y             # <<<<<<<<<<<<<<
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 *             v = getattr(terms[0].id, literal.pred.suffix)
 */
  if (unlikely(__pyx_v_terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 795, __pyx_L1_error)
  }

  /* "pyDatalog/pyEngine.py":795
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \             # <<<<<<<<<<<<<<
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 */
  __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_is_const); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_2 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L82_bool_binop_done;
  }

  /* "pyDatalog/pyEngine.py":796
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y             # <<<<<<<<<<<<<<
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 *             v = getattr(terms[0].id, literal.pred.suffix)
 */
  if (unlikely(__pyx_v_terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 796, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_7, __pyx_n_s_pyD_class_2, Py_NE)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_5 = __pyx_t_4;
    goto __pyx_L82_bool_binop_done;
  }
  if (unlikely(__pyx_v_terms == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 796, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_const); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  __pyx_t_7 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_5 = __pyx_t_4;
  __pyx_L82_bool_binop_done:;

  /* "pyDatalog/pyEngine.py":795
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \             # <<<<<<<<<<<<<<
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 */
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":798
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 *             v = getattr(terms[0].id, literal.pred.suffix)             # <<<<<<<<<<<<<<
 *             if isinstance(terms[1], VarTuple): # a slice
 *                 v = v.__getitem__(slice(*terms[1].id))
 */
    if (unlikely(__pyx_v_terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 798, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 798, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_suffix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_GetAttr(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_v = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "pyDatalog/pyEngine.py":799
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 *             v = getattr(terms[0].id, literal.pred.suffix)
 *             if isinstance(terms[1], VarTuple): # a slice             # <<<<<<<<<<<<<<
 *                 v = v.__getitem__(slice(*terms[1].id))
 *             else:
 */
    if (unlikely(__pyx_v_terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 799, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 799, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_t_7, __pyx_ptype_9pyDatalog_8pyEngine_VarTuple); 
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":800
 *             v = getattr(terms[0].id, literal.pred.suffix)
 *             if isinstance(terms[1], VarTuple): # a slice
 *                 v = v.__getitem__(slice(*terms[1].id))             # <<<<<<<<<<<<<<
 *             else:
 *                 v = v.__getitem__(terms[1].id)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_getitem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 800, __pyx_L1_error)
      }
      __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PySequence_Tuple(__pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_Call(((PyObject *)(&PySlice_Type)), __pyx_t_10, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_7 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_10, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 800, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "pyDatalog/pyEngine.py":799
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 *             v = getattr(terms[0].id, literal.pred.suffix)
 *             if isinstance(terms[1], VarTuple): # a slice             # <<<<<<<<<<<<<<
 *                 v = v.__getitem__(slice(*terms[1].id))
 *             else:
 */
      goto __pyx_L87;
    }

    /* "pyDatalog/pyEngine.py":802
 *                 v = v.__getitem__(slice(*terms[1].id))
 *             else:
 *                 v = v.__getitem__(terms[1].id)             # <<<<<<<<<<<<<<
 *             if terms[2].is_const() and compare(v, literal.pred.comparison, terms[2].id):
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))
 */
    /*else*/ {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_getitem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 802, __pyx_L1_error)
      }
      __pyx_t_13 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_7 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_13, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 802, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_7);
      __pyx_t_7 = 0;
    }
    __pyx_L87:;

    /* "pyDatalog/pyEngine.py":803
 *             else:
 *                 v = v.__getitem__(terms[1].id)
 *             if terms[2].is_const() and compare(v, literal.pred.comparison, terms[2].id):             # <<<<<<<<<<<<<<
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))
 *             elif literal.pred.comparison == "==" and not terms[2].is_const():
 */
    if (unlikely(__pyx_v_terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 803, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_terms, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_const); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    __pyx_t_7 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L89_bool_binop_done;
    }
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_compare); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 803, __pyx_L1_error) }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_comparison); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(__pyx_v_terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 803, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_terms, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_v, __pyx_t_13, __pyx_t_1};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 803, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_v_v, __pyx_t_13, __pyx_t_1};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 803, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 803, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_12, __pyx_v_v);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_12, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_12, __pyx_t_1);
      __pyx_t_13 = 0;
      __pyx_t_1 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 803, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_4 = __pyx_t_5;
    __pyx_L89_bool_binop_done:;
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":804
 *                 v = v.__getitem__(terms[1].id)
 *             if terms[2].is_const() and compare(v, literal.pred.comparison, terms[2].id):
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))             # <<<<<<<<<<<<<<
 *             elif literal.pred.comparison == "==" and not terms[2].is_const():
 *                 self.fact_candidate(class0, (terms[0], terms[1], v))
 */
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 804, __pyx_L1_error)
      }
      __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 804, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 804, __pyx_L1_error)
      }
      __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 804, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 804, __pyx_L1_error)
      }
      __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_terms, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
      __pyx_t_7 = 0;
      __pyx_t_10 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_t_1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":803
 *             else:
 *                 v = v.__getitem__(terms[1].id)
 *             if terms[2].is_const() and compare(v, literal.pred.comparison, terms[2].id):             # <<<<<<<<<<<<<<
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))
 *             elif literal.pred.comparison == "==" and not terms[2].is_const():
 */
      goto __pyx_L88;
    }

    /* "pyDatalog/pyEngine.py":805
 *             if terms[2].is_const() and compare(v, literal.pred.comparison, terms[2].id):
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))
 *             elif literal.pred.comparison == "==" and not terms[2].is_const():             # <<<<<<<<<<<<<<
 *                 self.fact_candidate(class0, (terms[0], terms[1], v))
 *             else:
 */
    if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 805, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_comparison); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_kp_s_, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L91_bool_binop_done;
    }
    if (unlikely(__pyx_v_terms == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 805, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_terms, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_const); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_10);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 805, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = ((!__pyx_t_5) != 0);
    __pyx_t_4 = __pyx_t_6;
    __pyx_L91_bool_binop_done:;
    if (likely(__pyx_t_4)) {

      /* "pyDatalog/pyEngine.py":806
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))
 *             elif literal.pred.comparison == "==" and not terms[2].is_const():
 *                 self.fact_candidate(class0, (terms[0], terms[1], v))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise util.DatalogError("Error: right hand side of comparison must be bound: %s"
 */
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 806, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_terms, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__pyx_v_terms == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 806, __pyx_L1_error)
      }
      __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_terms, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_v);
      __pyx_t_1 = 0;
      __pyx_t_10 = 0;
      __pyx_t_10 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_t_3, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 806, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "pyDatalog/pyEngine.py":805
 *             if terms[2].is_const() and compare(v, literal.pred.comparison, terms[2].id):
 *                 self.fact_candidate(class0, (terms[0], terms[1], terms[2]))
 *             elif literal.pred.comparison == "==" and not terms[2].is_const():             # <<<<<<<<<<<<<<
 *                 self.fact_candidate(class0, (terms[0], terms[1], v))
 *             else:
 */
      goto __pyx_L88;
    }

    /* "pyDatalog/pyEngine.py":808
 *                 self.fact_candidate(class0, (terms[0], terms[1], v))
 *             else:
 *                 raise util.DatalogError("Error: right hand side of comparison must be bound: %s"             # <<<<<<<<<<<<<<
 *                                     % literal.pred.id, None, None)
 *             return self.next_step()
 */
    /*else*/ {
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_util); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 808, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DatalogError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 808, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":809
 *             else:
 *                 raise util.DatalogError("Error: right hand side of comparison must be bound: %s"
 *                                     % literal.pred.id, None, None)             # <<<<<<<<<<<<<<
 *             return self.next_step()
 * 
 */
      if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 809, __pyx_L1_error) }
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Error_right_hand_side_of_compari, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 809, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      __pyx_t_12 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_12 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, Py_None, Py_None};
        __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 808, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, Py_None, Py_None};
        __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 808, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_13 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 808, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_3);
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, Py_None);
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_12, Py_None);
        __pyx_t_3 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 808, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 808, __pyx_L1_error)
    }
    __pyx_L88:;

    /* "pyDatalog/pyEngine.py":810
 *                 raise util.DatalogError("Error: right hand side of comparison must be bound: %s"
 *                                     % literal.pred.id, None, None)
 *             return self.next_step()             # <<<<<<<<<<<<<<
 * 
 *         raise AttributeError("Predicate without definition (or error in resolver): %s" % literal.pred.id)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_13 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_10 = (__pyx_t_13) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_13) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_10;
    __pyx_t_10 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":795
 *                     self.fact_candidate(class0, result)
 *                 return self.next_step()
 *         elif literal.pred.comparison and len(terms)==3 and terms[0].is_const() \             # <<<<<<<<<<<<<<
 *         and terms[0].id != '_pyD_class' and terms[1].is_const(): # X.a[1]==Y
 *             # do not use pyDatalog_search as the variable may not be in a pyDatalog class
 */
  }
  __pyx_L67:;

  /* "pyDatalog/pyEngine.py":812
 *             return self.next_step()
 * 
 *         raise AttributeError("Predicate without definition (or error in resolver): %s" % literal.pred.id)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (unlikely(!__pyx_v_literal)) { __Pyx_RaiseUnboundLocalError("literal"); __PYX_ERR(0, 812, __pyx_L1_error) }
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Predicate_without_definition_or, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 812, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":686
 *         return str(self.literal)
 * 
 *     def search(self):             # <<<<<<<<<<<<<<
 *         """
 *         Search for derivations of the literal associated with this subgoal
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.search", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_literal0);
  __Pyx_XDECREF(__pyx_v_class0);
  __Pyx_XDECREF(__pyx_v_terms);
  __Pyx_XDECREF((PyObject *)__pyx_v_base_literal);
  __Pyx_XDECREF(__pyx_v__class);
  __Pyx_XDECREF(__pyx_v_literal);
  __Pyx_XDECREF(__pyx_v_resolver);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_method_name);
  __Pyx_XDECREF(__pyx_v_results);
  __Pyx_XDECREF(__pyx_v_base_terms);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_clause);
  __Pyx_XDECREF(__pyx_v_renamed);
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_literal1);
  __Pyx_XDECREF((PyObject *)__pyx_v_Y1);
  __Pyx_XDECREF((PyObject *)__pyx_v_literal2);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":817
 *     ################## add derived facts and use rules ##############
 * 
 *     def add_clause(self, clause):             # <<<<<<<<<<<<<<
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7add_clause(PyObject *__pyx_v_self, PyObject *__pyx_v_clause); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_6add_clause[] = " SLG_NEWCLAUSE in the reference article ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_7add_clause = {"add_clause", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7add_clause, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_6add_clause};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7add_clause(PyObject *__pyx_v_self, PyObject *__pyx_v_clause) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_clause (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_6add_clause(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_clause));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_6add_clause(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_clause) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_clause", 0);

  /* "pyDatalog/pyEngine.py":819
 *     def add_clause(self, clause):
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed             # <<<<<<<<<<<<<<
 *             if Slow_motion: print("Already completed !")
 *             return self.next_step() # no need to keep looking if THE answer is found already
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->is_done)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 819, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":820
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed
 *             if Slow_motion: print("Already completed !")             # <<<<<<<<<<<<<<
 *             return self.next_step() # no need to keep looking if THE answer is found already
 *         if not clause.body:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 820, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_1) {
      if (__Pyx_PrintOne(0, __pyx_kp_s_Already_completed) < 0) __PYX_ERR(0, 820, __pyx_L1_error)
    }

    /* "pyDatalog/pyEngine.py":821
 *         if self.is_done: # for speed
 *             if Slow_motion: print("Already completed !")
 *             return self.next_step() # no need to keep looking if THE answer is found already             # <<<<<<<<<<<<<<
 *         if not clause.body:
 *             self.fact(clause.head)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 821, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 821, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":819
 *     def add_clause(self, clause):
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed             # <<<<<<<<<<<<<<
 *             if Slow_motion: print("Already completed !")
 *             return self.next_step() # no need to keep looking if THE answer is found already
 */
  }

  /* "pyDatalog/pyEngine.py":822
 *             if Slow_motion: print("Already completed !")
 *             return self.next_step() # no need to keep looking if THE answer is found already
 *         if not clause.body:             # <<<<<<<<<<<<<<
 *             self.fact(clause.head)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 822, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = ((!__pyx_t_1) != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":823
 *             return self.next_step() # no need to keep looking if THE answer is found already
 *         if not clause.body:
 *             self.fact(clause.head)             # <<<<<<<<<<<<<<
 *         else:
 *             self.rule(clause, clause.body[0])
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact(__pyx_v_self, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":822
 *             if Slow_motion: print("Already completed !")
 *             return self.next_step() # no need to keep looking if THE answer is found already
 *         if not clause.body:             # <<<<<<<<<<<<<<
 *             self.fact(clause.head)
 *         else:
 */
    goto __pyx_L5;
  }

  /* "pyDatalog/pyEngine.py":825
 *             self.fact(clause.head)
 *         else:
 *             self.rule(clause, clause.body[0])             # <<<<<<<<<<<<<<
 *         return self.next_step()
 * 
 */
  /*else*/ {
    if (!(likely(((__pyx_v_clause) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_clause, __pyx_ptype_9pyDatalog_8pyEngine_Clause))))) __PYX_ERR(0, 825, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(0, 825, __pyx_L1_error)
    __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->rule(__pyx_v_self, ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v_clause), ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L5:;

  /* "pyDatalog/pyEngine.py":826
 *         else:
 *             self.rule(clause, clause.body[0])
 *         return self.next_step()             # <<<<<<<<<<<<<<
 * 
 *     def fact(self, literal):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":817
 *     ################## add derived facts and use rules ##############
 * 
 *     def add_clause(self, clause):             # <<<<<<<<<<<<<<
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.add_clause", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":828
 *         return self.next_step()
 * 
 *     def fact(self, literal):             # <<<<<<<<<<<<<<
 *         """
 *         Store a derived fact, and inform all waiters of the fact too.
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9fact(PyObject *__pyx_v_self, PyObject *__pyx_v_literal); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_literal, int __pyx_skip_dispatch) {
  int __pyx_v_all_const;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_subgoal = NULL;
  PyObject *__pyx_v_clause = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_resolvent = NULL;
  PyObject *__pyx_v_fact_id = NULL;
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_bodi = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fact", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fact); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 828, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9fact)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_literal) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_literal);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 828, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":833
 *         SLG_ANSWER in the reference article
 *         """
 *         all_const = True # Cython equivalent for all(t.is_const() for t in literal.terms)             # <<<<<<<<<<<<<<
 *         if literal is not True:
 *             for t in literal.terms:
 */
  __pyx_v_all_const = 1;

  /* "pyDatalog/pyEngine.py":834
 *         """
 *         all_const = True # Cython equivalent for all(t.is_const() for t in literal.terms)
 *         if literal is not True:             # <<<<<<<<<<<<<<
 *             for t in literal.terms:
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 */
  __pyx_t_5 = (__pyx_v_literal != Py_True);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "pyDatalog/pyEngine.py":835
 *         all_const = True # Cython equivalent for all(t.is_const() for t in literal.terms)
 *         if literal is not True:
 *             for t in literal.terms:             # <<<<<<<<<<<<<<
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                     all_const = False
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 835, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 835, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 835, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_8(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 835, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":836
 *         if literal is not True:
 *             for t in literal.terms:
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed             # <<<<<<<<<<<<<<
 *                     all_const = False
 *                     break
 */
      __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_t, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
      __pyx_t_9 = (__pyx_t_5 != 0);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_6 = __pyx_t_9;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 836, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 836, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 836, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_t_9;
      __pyx_L7_bool_binop_done:;
      __pyx_t_9 = ((!__pyx_t_6) != 0);
      if (__pyx_t_9) {

        /* "pyDatalog/pyEngine.py":837
 *             for t in literal.terms:
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                     all_const = False             # <<<<<<<<<<<<<<
 *                     break
 *         if literal is True or not all_const:
 */
        __pyx_v_all_const = 0;

        /* "pyDatalog/pyEngine.py":838
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                     all_const = False
 *                     break             # <<<<<<<<<<<<<<
 *         if literal is True or not all_const:
 *             if self.facts != True: # if already True, do not advise its waiters again
 */
        goto __pyx_L5_break;

        /* "pyDatalog/pyEngine.py":836
 *         if literal is not True:
 *             for t in literal.terms:
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed             # <<<<<<<<<<<<<<
 *                     all_const = False
 *                     break
 */
      }

      /* "pyDatalog/pyEngine.py":835
 *         all_const = True # Cython equivalent for all(t.is_const() for t in literal.terms)
 *         if literal is not True:
 *             for t in literal.terms:             # <<<<<<<<<<<<<<
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                     all_const = False
 */
    }
    __pyx_L5_break:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":834
 *         """
 *         all_const = True # Cython equivalent for all(t.is_const() for t in literal.terms)
 *         if literal is not True:             # <<<<<<<<<<<<<<
 *             for t in literal.terms:
 *                 if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 */
  }

  /* "pyDatalog/pyEngine.py":839
 *                     all_const = False
 *                     break
 *         if literal is True or not all_const:             # <<<<<<<<<<<<<<
 *             if self.facts != True: # if already True, do not advise its waiters again
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 */
  __pyx_t_6 = (__pyx_v_literal == Py_True);
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_9 = __pyx_t_5;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_5 = ((!(__pyx_v_all_const != 0)) != 0);
  __pyx_t_9 = __pyx_t_5;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_9) {

    /* "pyDatalog/pyEngine.py":840
 *                     break
 *         if literal is True or not all_const:
 *             if self.facts != True: # if already True, do not advise its waiters again             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_self->facts, Py_True, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 840, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 840, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_9) {

      /* "pyDatalog/pyEngine.py":841
 *         if literal is True or not all_const:
 *             if self.facts != True: # if already True, do not advise its waiters again
 *                 if Logging and Logger.isEnabledFor(logging.INFO):             # <<<<<<<<<<<<<<
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 *                 self.facts, self.is_done = True, True
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_5) {
      } else {
        __pyx_t_9 = __pyx_t_5;
        goto __pyx_L14_bool_binop_done;
      }
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_INFO); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 841, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __pyx_t_5;
      __pyx_L14_bool_binop_done:;
      if (__pyx_t_9) {

        /* "pyDatalog/pyEngine.py":842
 *             if self.facts != True: # if already True, do not advise its waiters again
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s is True" % str(self.literal))             # <<<<<<<<<<<<<<
 *                 self.facts, self.is_done = True, True
 *                 for subgoal, clause in self.waiters:
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_v_self->literal)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_New_fact_s_is_True, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 842, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":841
 *         if literal is True or not all_const:
 *             if self.facts != True: # if already True, do not advise its waiters again
 *                 if Logging and Logger.isEnabledFor(logging.INFO):             # <<<<<<<<<<<<<<
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 *                 self.facts, self.is_done = True, True
 */
      }

      /* "pyDatalog/pyEngine.py":843
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 *                 self.facts, self.is_done = True, True             # <<<<<<<<<<<<<<
 *                 for subgoal, clause in self.waiters:
 *                     resolvent = Clause(clause.head, clause.body[1:])
 */
      __pyx_t_2 = Py_True;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_4 = Py_True;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_v_self->facts);
      __Pyx_DECREF(__pyx_v_self->facts);
      __pyx_v_self->facts = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_v_self->is_done);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->is_done));
      __pyx_v_self->is_done = ((PyBoolObject *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pyDatalog/pyEngine.py":844
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 *                 self.facts, self.is_done = True, True
 *                 for subgoal, clause in self.waiters:             # <<<<<<<<<<<<<<
 *                     resolvent = Clause(clause.head, clause.body[1:])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 */
      if (unlikely(__pyx_v_self->waiters == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 844, __pyx_L1_error)
      }
      __pyx_t_4 = __pyx_v_self->waiters; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      for (;;) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 844, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 844, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
          PyObject* sequence = __pyx_t_2;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 844, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          #else
          __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 844, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
          index = 0; __pyx_t_1 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L18_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_1);
          index = 1; __pyx_t_3 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L18_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 844, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L19_unpacking_done;
          __pyx_L18_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 844, __pyx_L1_error)
          __pyx_L19_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_subgoal, __pyx_t_1);
        __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_clause, __pyx_t_3);
        __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":845
 *                 self.facts, self.is_done = True, True
 *                 for subgoal, clause in self.waiters:
 *                     resolvent = Clause(clause.head, clause.body[1:])             # <<<<<<<<<<<<<<
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 self.waiters = []
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_3, 1, 0, NULL, NULL, &__pyx_slice__20, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
        __pyx_t_2 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 845, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_resolvent, ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_t_1));
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":846
 *                 for subgoal, clause in self.waiters:
 *                     resolvent = Clause(clause.head, clause.body[1:])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))             # <<<<<<<<<<<<<<
 *                 self.waiters = []
 *         elif self.facts is not True:
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_schedule); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 846, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 846, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 846, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_v_subgoal);
        __Pyx_GIVEREF(__pyx_v_subgoal);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_subgoal);
        __Pyx_INCREF(((PyObject *)__pyx_v_resolvent));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_resolvent));
        PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v_resolvent));
        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 846, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_10);
        __pyx_t_2 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_10, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_12);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 846, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":844
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 *                 self.facts, self.is_done = True, True
 *                 for subgoal, clause in self.waiters:             # <<<<<<<<<<<<<<
 *                     resolvent = Clause(clause.head, clause.body[1:])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 */
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pyDatalog/pyEngine.py":847
 *                     resolvent = Clause(clause.head, clause.body[1:])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 self.waiters = []             # <<<<<<<<<<<<<<
 *         elif self.facts is not True:
 *             fact_id = literal.get_fact_id()
 */
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 847, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_v_self->waiters);
      __Pyx_DECREF(__pyx_v_self->waiters);
      __pyx_v_self->waiters = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pyDatalog/pyEngine.py":840
 *                     break
 *         if literal is True or not all_const:
 *             if self.facts != True: # if already True, do not advise its waiters again             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s is True" % str(self.literal))
 */
    }

    /* "pyDatalog/pyEngine.py":839
 *                     all_const = False
 *                     break
 *         if literal is True or not all_const:             # <<<<<<<<<<<<<<
 *             if self.facts != True: # if already True, do not advise its waiters again
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 */
    goto __pyx_L9;
  }

  /* "pyDatalog/pyEngine.py":848
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 self.waiters = []
 *         elif self.facts is not True:             # <<<<<<<<<<<<<<
 *             fact_id = literal.get_fact_id()
 *             if not self.facts.get(fact_id):
 */
  __pyx_t_9 = (__pyx_v_self->facts != Py_True);
  __pyx_t_5 = (__pyx_t_9 != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":849
 *                 self.waiters = []
 *         elif self.facts is not True:
 *             fact_id = literal.get_fact_id()             # <<<<<<<<<<<<<<
 *             if not self.facts.get(fact_id):
 *                 self.facts[fact_id] = literal
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_get_fact_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 849, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 849, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_fact_id = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "pyDatalog/pyEngine.py":850
 *         elif self.facts is not True:
 *             fact_id = literal.get_fact_id()
 *             if not self.facts.get(fact_id):             # <<<<<<<<<<<<<<
 *                 self.facts[fact_id] = literal
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->facts, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_fact_id) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_fact_id);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 850, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_9 = ((!__pyx_t_5) != 0);
    if (__pyx_t_9) {

      /* "pyDatalog/pyEngine.py":851
 *             fact_id = literal.get_fact_id()
 *             if not self.facts.get(fact_id):
 *                 self.facts[fact_id] = literal             # <<<<<<<<<<<<<<
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s" % str(literal))
 */
      if (unlikely(PyObject_SetItem(__pyx_v_self->facts, __pyx_v_fact_id, __pyx_v_literal) < 0)) __PYX_ERR(0, 851, __pyx_L1_error)

      /* "pyDatalog/pyEngine.py":852
 *             if not self.facts.get(fact_id):
 *                 self.facts[fact_id] = literal
 *                 if Logging and Logger.isEnabledFor(logging.INFO):             # <<<<<<<<<<<<<<
 *                     Logger.info("New fact : %s" % str(literal))
 *                 for subgoal, clause in self.waiters:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Logging); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_5) {
      } else {
        __pyx_t_9 = __pyx_t_5;
        goto __pyx_L22_bool_binop_done;
      }
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_INFO); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_12) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_12);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 852, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = __pyx_t_5;
      __pyx_L22_bool_binop_done:;
      if (__pyx_t_9) {

        /* "pyDatalog/pyEngine.py":853
 *                 self.facts[fact_id] = literal
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s" % str(literal))             # <<<<<<<<<<<<<<
 *                 for subgoal, clause in self.waiters:
 *                     # Resolve the selected literal of a clause with a literal.
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 853, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_literal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_New_fact_s, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_12);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_12, function);
          }
        }
        __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_1);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 853, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyDatalog/pyEngine.py":852
 *             if not self.facts.get(fact_id):
 *                 self.facts[fact_id] = literal
 *                 if Logging and Logger.isEnabledFor(logging.INFO):             # <<<<<<<<<<<<<<
 *                     Logger.info("New fact : %s" % str(literal))
 *                 for subgoal, clause in self.waiters:
 */
      }

      /* "pyDatalog/pyEngine.py":854
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s" % str(literal))
 *                 for subgoal, clause in self.waiters:             # <<<<<<<<<<<<<<
 *                     # Resolve the selected literal of a clause with a literal.
 *                     # The selected literal is the first literal in body of a rule.
 */
      if (unlikely(__pyx_v_self->waiters == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 854, __pyx_L1_error)
      }
      __pyx_t_4 = __pyx_v_self->waiters; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
      for (;;) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_12); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 854, __pyx_L1_error)
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 854, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
          PyObject* sequence = __pyx_t_12;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 854, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          #else
          __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 854, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_10 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 854, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
          index = 0; __pyx_t_1 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L26_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_1);
          index = 1; __pyx_t_3 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L26_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 854, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L27_unpacking_done;
          __pyx_L26_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 854, __pyx_L1_error)
          __pyx_L27_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_subgoal, __pyx_t_1);
        __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_clause, __pyx_t_3);
        __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":858
 *                     # The selected literal is the first literal in body of a rule.
 *                     # A new clause is generated that has a body with one less literal.
 *                     env = clause.body[0].unify(literal)             # <<<<<<<<<<<<<<
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 858, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 858, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unify); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 858, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_12 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_v_literal) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_literal);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 858, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_env, __pyx_t_12);
        __pyx_t_12 = 0;

        /* "pyDatalog/pyEngine.py":859
 *                     # A new clause is generated that has a body with one less literal.
 *                     env = clause.body[0].unify(literal)
 *                     assert env != None             # <<<<<<<<<<<<<<
 *                     resolvent = Clause(clause.head.subst(env),
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_12 = PyObject_RichCompare(__pyx_v_env, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 859, __pyx_L1_error)
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 859, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_9)) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 859, __pyx_L1_error)
          }
        }
        #endif

        /* "pyDatalog/pyEngine.py":860
 *                     env = clause.body[0].unify(literal)
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),             # <<<<<<<<<<<<<<
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_head); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 860, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_subst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 860, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_12 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_env);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 860, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":861
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])             # <<<<<<<<<<<<<<
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant
 */
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 861, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_clause, __pyx_n_s_body); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 861, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = __Pyx_PyObject_GetSlice(__pyx_t_3, 1, 0, NULL, NULL, &__pyx_slice__20, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 861, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
          __pyx_t_3 = __pyx_t_10; __Pyx_INCREF(__pyx_t_3); __pyx_t_13 = 0;
          __pyx_t_8 = NULL;
        } else {
          __pyx_t_13 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 861, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 861, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        for (;;) {
          if (likely(!__pyx_t_8)) {
            if (likely(PyList_CheckExact(__pyx_t_3))) {
              if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_3)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_10 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_10); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 861, __pyx_L1_error)
              #else
              __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 861, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
              #endif
            } else {
              if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_10); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 861, __pyx_L1_error)
              #else
              __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 861, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
              #endif
            }
          } else {
            __pyx_t_10 = __pyx_t_8(__pyx_t_3);
            if (unlikely(!__pyx_t_10)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 861, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_XDECREF_SET(__pyx_v_bodi, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_bodi, __pyx_n_s_subst); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 861, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_14 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_14)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_14);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          __pyx_t_10 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_14, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 861, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 861, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "pyDatalog/pyEngine.py":860
 *                     env = clause.body[0].unify(literal)
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),             # <<<<<<<<<<<<<<
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 */
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 860, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
        __pyx_t_12 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 860, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_resolvent, ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_t_1));
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":862
 *                     resolvent = Clause(clause.head.subst(env),
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))             # <<<<<<<<<<<<<<
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_schedule); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_v_subgoal);
        __Pyx_GIVEREF(__pyx_v_subgoal);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_subgoal);
        __Pyx_INCREF(((PyObject *)__pyx_v_resolvent));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_resolvent));
        PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v_resolvent));
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10);
        __pyx_t_12 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 862, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":854
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 *                     Logger.info("New fact : %s" % str(literal))
 *                 for subgoal, clause in self.waiters:             # <<<<<<<<<<<<<<
 *                     # Resolve the selected literal of a clause with a literal.
 *                     # The selected literal is the first literal in body of a rule.
 */
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pyDatalog/pyEngine.py":863
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant             # <<<<<<<<<<<<<<
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)
 *                     for i in range(self.literal.pred.prearity):
 */
      __pyx_t_4 = __pyx_v_self->facts;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_7 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 863, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = ((__pyx_t_7 == 1) != 0);
      if (__pyx_t_9) {

        /* "pyDatalog/pyEngine.py":864
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)             # <<<<<<<<<<<<<<
 *                     for i in range(self.literal.pred.prearity):
 *                         t = self.literal.terms[i]
 */
        __pyx_v_all_const = 1;

        /* "pyDatalog/pyEngine.py":865
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)
 *                     for i in range(self.literal.pred.prearity):             # <<<<<<<<<<<<<<
 *                         t = self.literal.terms[i]
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->literal->pred, __pyx_n_s_prearity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 865, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 865, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
          __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
          __pyx_t_8 = NULL;
        } else {
          __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 865, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 865, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        for (;;) {
          if (likely(!__pyx_t_8)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 865, __pyx_L1_error)
              #else
              __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 865, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
            } else {
              if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 865, __pyx_L1_error)
              #else
              __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 865, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
            }
          } else {
            __pyx_t_1 = __pyx_t_8(__pyx_t_4);
            if (unlikely(!__pyx_t_1)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 865, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "pyDatalog/pyEngine.py":866
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)
 *                     for i in range(self.literal.pred.prearity):
 *                         t = self.literal.terms[i]             # <<<<<<<<<<<<<<
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                             all_const = False
 */
          if (unlikely(__pyx_v_self->literal->terms == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 866, __pyx_L1_error)
          }
          __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_self->literal->terms, __pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 866, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "pyDatalog/pyEngine.py":867
 *                     for i in range(self.literal.pred.prearity):
 *                         t = self.literal.terms[i]
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed             # <<<<<<<<<<<<<<
 *                             all_const = False
 *                             break
 */
          __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_t, __pyx_ptype_9pyDatalog_8pyEngine_Const); 
          __pyx_t_6 = (__pyx_t_5 != 0);
          if (!__pyx_t_6) {
          } else {
            __pyx_t_9 = __pyx_t_6;
            goto __pyx_L34_bool_binop_done;
          }
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_is_const); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 867, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 867, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_9 = __pyx_t_6;
          __pyx_L34_bool_binop_done:;
          __pyx_t_6 = ((!__pyx_t_9) != 0);
          if (__pyx_t_6) {

            /* "pyDatalog/pyEngine.py":868
 *                         t = self.literal.terms[i]
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                             all_const = False             # <<<<<<<<<<<<<<
 *                             break
 *                     if all_const:
 */
            __pyx_v_all_const = 0;

            /* "pyDatalog/pyEngine.py":869
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 *                             all_const = False
 *                             break             # <<<<<<<<<<<<<<
 *                     if all_const:
 *                         if Slow_motion: print("is done !")
 */
            goto __pyx_L32_break;

            /* "pyDatalog/pyEngine.py":867
 *                     for i in range(self.literal.pred.prearity):
 *                         t = self.literal.terms[i]
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed             # <<<<<<<<<<<<<<
 *                             all_const = False
 *                             break
 */
          }

          /* "pyDatalog/pyEngine.py":865
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)
 *                     for i in range(self.literal.pred.prearity):             # <<<<<<<<<<<<<<
 *                         t = self.literal.terms[i]
 *                         if not(isinstance(t, Const) or t.is_const()): # use isinstance for speed
 */
        }
        __pyx_L32_break:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyDatalog/pyEngine.py":870
 *                             all_const = False
 *                             break
 *                     if all_const:             # <<<<<<<<<<<<<<
 *                         if Slow_motion: print("is done !")
 *                         self.is_done = True
 */
        __pyx_t_6 = (__pyx_v_all_const != 0);
        if (__pyx_t_6) {

          /* "pyDatalog/pyEngine.py":871
 *                             break
 *                     if all_const:
 *                         if Slow_motion: print("is done !")             # <<<<<<<<<<<<<<
 *                         self.is_done = True
 *                         self.waiters = []
 */
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 871, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 871, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_6) {
            if (__Pyx_PrintOne(0, __pyx_kp_s_is_done) < 0) __PYX_ERR(0, 871, __pyx_L1_error)
          }

          /* "pyDatalog/pyEngine.py":872
 *                     if all_const:
 *                         if Slow_motion: print("is done !")
 *                         self.is_done = True             # <<<<<<<<<<<<<<
 *                         self.waiters = []
 * 
 */
          __Pyx_INCREF(Py_True);
          __Pyx_GIVEREF(Py_True);
          __Pyx_GOTREF(__pyx_v_self->is_done);
          __Pyx_DECREF(((PyObject *)__pyx_v_self->is_done));
          __pyx_v_self->is_done = ((PyBoolObject *)Py_True);

          /* "pyDatalog/pyEngine.py":873
 *                         if Slow_motion: print("is done !")
 *                         self.is_done = True
 *                         self.waiters = []             # <<<<<<<<<<<<<<
 * 
 *     def fact_candidate(self, class0, result):
 */
          __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 873, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_v_self->waiters);
          __Pyx_DECREF(__pyx_v_self->waiters);
          __pyx_v_self->waiters = ((PyObject*)__pyx_t_4);
          __pyx_t_4 = 0;

          /* "pyDatalog/pyEngine.py":870
 *                             all_const = False
 *                             break
 *                     if all_const:             # <<<<<<<<<<<<<<
 *                         if Slow_motion: print("is done !")
 *                         self.is_done = True
 */
        }

        /* "pyDatalog/pyEngine.py":863
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 if len(self.facts)==1:  # stop if one fact for a function of constant             # <<<<<<<<<<<<<<
 *                     all_const = True # Cython equivalent for all(self.literal.terms[i].is_const() for i in range(self.literal.pred.prearity)
 *                     for i in range(self.literal.pred.prearity):
 */
      }

      /* "pyDatalog/pyEngine.py":850
 *         elif self.facts is not True:
 *             fact_id = literal.get_fact_id()
 *             if not self.facts.get(fact_id):             # <<<<<<<<<<<<<<
 *                 self.facts[fact_id] = literal
 *                 if Logging and Logger.isEnabledFor(logging.INFO):
 */
    }

    /* "pyDatalog/pyEngine.py":848
 *                     subgoal.schedule((ADD_CLAUSE, (subgoal, resolvent)))
 *                 self.waiters = []
 *         elif self.facts is not True:             # <<<<<<<<<<<<<<
 *             fact_id = literal.get_fact_id()
 *             if not self.facts.get(fact_id):
 */
  }
  __pyx_L9:;

  /* "pyDatalog/pyEngine.py":828
 *         return self.next_step()
 * 
 *     def fact(self, literal):             # <<<<<<<<<<<<<<
 *         """
 *         Store a derived fact, and inform all waiters of the fact too.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.fact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_subgoal);
  __Pyx_XDECREF(__pyx_v_clause);
  __Pyx_XDECREF((PyObject *)__pyx_v_resolvent);
  __Pyx_XDECREF(__pyx_v_fact_id);
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_bodi);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9fact(PyObject *__pyx_v_self, PyObject *__pyx_v_literal); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_8fact[] = " \n        Store a derived fact, and inform all waiters of the fact too. \n        SLG_ANSWER in the reference article\n        ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_9fact = {"fact", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9fact, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_8fact};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9fact(PyObject *__pyx_v_self, PyObject *__pyx_v_literal) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fact (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_8fact(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_literal));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_8fact(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_literal) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fact", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact(__pyx_v_self, __pyx_v_literal, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.fact", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":875
 *                         self.waiters = []
 * 
 *     def fact_candidate(self, class0, result):             # <<<<<<<<<<<<<<
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact_candidate(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_class0, PyObject *__pyx_v_result, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fact_candidate", 0);
  __Pyx_INCREF(__pyx_v_result);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fact_candidate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_class0, __pyx_v_result};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_class0, __pyx_v_result};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(__pyx_v_class0);
          __Pyx_GIVEREF(__pyx_v_class0);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_class0);
          __Pyx_INCREF(__pyx_v_result);
          __Pyx_GIVEREF(__pyx_v_result);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_result);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 875, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":877
 *     def fact_candidate(self, class0, result):
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:             # <<<<<<<<<<<<<<
 *             self.fact(True)
 *             return
 */
  __pyx_t_7 = (__pyx_v_result == Py_True);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":878
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:
 *             self.fact(True)             # <<<<<<<<<<<<<<
 *             return
 *         if len(result) != len(self.literal.terms):
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact(__pyx_v_self, Py_True, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 878, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":879
 *         if result is True:
 *             self.fact(True)
 *             return             # <<<<<<<<<<<<<<
 *         if len(result) != len(self.literal.terms):
 *             return
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":877
 *     def fact_candidate(self, class0, result):
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:             # <<<<<<<<<<<<<<
 *             self.fact(True)
 *             return
 */
  }

  /* "pyDatalog/pyEngine.py":880
 *             self.fact(True)
 *             return
 *         if len(result) != len(self.literal.terms):             # <<<<<<<<<<<<<<
 *             return
 *         result = [Term_of(r) for r in result]
 */
  __pyx_t_9 = PyObject_Length(__pyx_v_result); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 880, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_self->literal->terms;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 880, __pyx_L1_error)
  }
  __pyx_t_10 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 880, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = ((__pyx_t_9 != __pyx_t_10) != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":881
 *             return
 *         if len(result) != len(self.literal.terms):
 *             return             # <<<<<<<<<<<<<<
 *         result = [Term_of(r) for r in result]
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":880
 *             self.fact(True)
 *             return
 *         if len(result) != len(self.literal.terms):             # <<<<<<<<<<<<<<
 *             return
 *         result = [Term_of(r) for r in result]
 */
  }

  /* "pyDatalog/pyEngine.py":882
 *         if len(result) != len(self.literal.terms):
 *             return
 *         result = [Term_of(r) for r in result]             # <<<<<<<<<<<<<<
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed
 *             return
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_v_result)) || PyTuple_CheckExact(__pyx_v_result)) {
    __pyx_t_2 = __pyx_v_result; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 882, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 882, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 882, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_11(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 882, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_r, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_v_r) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_r);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 882, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":883
 *             return
 *         result = [Term_of(r) for r in result]
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed             # <<<<<<<<<<<<<<
 *             return
 *         if self.literal.match(result) != None:
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_class0); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 883, __pyx_L1_error)
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_result, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = PyObject_IsInstance(__pyx_t_1, __pyx_v_class0); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = ((!(__pyx_t_7 != 0)) != 0);
  __pyx_t_8 = __pyx_t_12;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":884
 *         result = [Term_of(r) for r in result]
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed
 *             return             # <<<<<<<<<<<<<<
 *         if self.literal.match(result) != None:
 *             self.fact(Literal(self.literal.pred.name, result))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":883
 *             return
 *         result = [Term_of(r) for r in result]
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed             # <<<<<<<<<<<<<<
 *             return
 *         if self.literal.match(result) != None:
 */
  }

  /* "pyDatalog/pyEngine.py":885
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed
 *             return
 *         if self.literal.match(result) != None:             # <<<<<<<<<<<<<<
 *             self.fact(Literal(self.literal.pred.name, result))
 * 
 */
  if (!(likely(PyList_CheckExact(__pyx_v_result))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_result)->tp_name), 0))) __PYX_ERR(0, 885, __pyx_L1_error)
  __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->literal->__pyx_vtab)->match(__pyx_v_self->literal, ((PyObject*)__pyx_v_result), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":886
 *             return
 *         if self.literal.match(result) != None:
 *             self.fact(Literal(self.literal.pred.name, result))             # <<<<<<<<<<<<<<
 * 
 *     def rule(self, clause, selected):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->literal->pred, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 886, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 886, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_result);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 886, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->fact(__pyx_v_self, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 886, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":885
 *         if class0 and result[1].id and not isinstance(result[1].id, class0): #prefixed
 *             return
 *         if self.literal.match(result) != None:             # <<<<<<<<<<<<<<
 *             self.fact(Literal(self.literal.pred.name, result))
 * 
 */
  }

  /* "pyDatalog/pyEngine.py":875
 *                         self.waiters = []
 * 
 *     def fact_candidate(self, class0, result):             # <<<<<<<<<<<<<<
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.fact_candidate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_10fact_candidate[] = " add result as a candidate fact of class0 for subgoal";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate = {"fact_candidate", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_10fact_candidate};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_class0 = 0;
  PyObject *__pyx_v_result = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fact_candidate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_class0,&__pyx_n_s_result,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_class0)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_result)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fact_candidate", 1, 2, 2, 1); __PYX_ERR(0, 875, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fact_candidate") < 0)) __PYX_ERR(0, 875, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_class0 = values[0];
    __pyx_v_result = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fact_candidate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 875, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.fact_candidate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_10fact_candidate(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), __pyx_v_class0, __pyx_v_result);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_10fact_candidate(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_class0, PyObject *__pyx_v_result) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fact_candidate", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact_candidate(__pyx_v_self, __pyx_v_class0, __pyx_v_result, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.fact_candidate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":888
 *             self.fact(Literal(self.literal.pred.name, result))
 * 
 *     def rule(self, clause, selected):             # <<<<<<<<<<<<<<
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_13rule(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_rule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_clause, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_selected, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_sg = NULL;
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_resolvent = NULL;
  PyObject *__pyx_v_fact = NULL;
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_v_bodi = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rule", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rule); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_13rule)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_clause), ((PyObject *)__pyx_v_selected)};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 888, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_clause), ((PyObject *)__pyx_v_selected)};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 888, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 888, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_clause));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_clause));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_clause));
          __Pyx_INCREF(((PyObject *)__pyx_v_selected));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_selected));
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)__pyx_v_selected));
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 888, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":890
 *     def rule(self, clause, selected):
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())             # <<<<<<<<<<<<<<
 *         if sg != None: # selected subgoal exists already
 *             if sg.facts is True:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Subgoals); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_selected->__pyx_vtab)->get_tag(__pyx_v_selected, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_sg = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":891
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 *         if sg != None: # selected subgoal exists already             # <<<<<<<<<<<<<<
 *             if sg.facts is True:
 *                 resolvent = Clause(clause.head, clause.body[1:])
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_sg, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "pyDatalog/pyEngine.py":892
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 *         if sg != None: # selected subgoal exists already
 *             if sg.facts is True:             # <<<<<<<<<<<<<<
 *                 resolvent = Clause(clause.head, clause.body[1:])
 *                 self.schedule((ADD_CLAUSE, (self, resolvent)))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sg, __pyx_n_s_facts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = (__pyx_t_1 == Py_True);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = (__pyx_t_7 != 0);
    if (__pyx_t_8) {

      /* "pyDatalog/pyEngine.py":893
 *         if sg != None: # selected subgoal exists already
 *             if sg.facts is True:
 *                 resolvent = Clause(clause.head, clause.body[1:])             # <<<<<<<<<<<<<<
 *                 self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             else:
 */
      if (unlikely(__pyx_v_clause->body == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 893, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_clause->body, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 893, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 893, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_clause->head));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_clause->head));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_clause->head));
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 893, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_resolvent = ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":894
 *             if sg.facts is True:
 *                 resolvent = Clause(clause.head, clause.body[1:])
 *                 self.schedule((ADD_CLAUSE, (self, resolvent)))             # <<<<<<<<<<<<<<
 *             else:
 *                 for fact in sg.facts.values(): # catch-up with facts already established
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 894, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 894, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_resolvent));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_resolvent));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_resolvent));
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 894, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 894, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":892
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 *         if sg != None: # selected subgoal exists already
 *             if sg.facts is True:             # <<<<<<<<<<<<<<
 *                 resolvent = Clause(clause.head, clause.body[1:])
 *                 self.schedule((ADD_CLAUSE, (self, resolvent)))
 */
      goto __pyx_L4;
    }

    /* "pyDatalog/pyEngine.py":896
 *                 self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             else:
 *                 for fact in sg.facts.values(): # catch-up with facts already established             # <<<<<<<<<<<<<<
 *                     env = clause.body[0].unify(fact)
 *                     assert env != None
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sg, __pyx_n_s_facts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
        __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
      } else {
        __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 896, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 896, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      for (;;) {
        if (likely(!__pyx_t_10)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 896, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 896, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          } else {
            if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 896, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 896, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          }
        } else {
          __pyx_t_2 = __pyx_t_10(__pyx_t_1);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 896, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XDECREF_SET(__pyx_v_fact, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":897
 *             else:
 *                 for fact in sg.facts.values(): # catch-up with facts already established
 *                     env = clause.body[0].unify(fact)             # <<<<<<<<<<<<<<
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),
 */
        if (unlikely(__pyx_v_clause->body == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 897, __pyx_L1_error)
        }
        __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_clause->body, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 897, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_unify); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 897, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_v_fact) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_fact);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 897, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF_SET(__pyx_v_env, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":898
 *                 for fact in sg.facts.values(): # catch-up with facts already established
 *                     env = clause.body[0].unify(fact)
 *                     assert env != None             # <<<<<<<<<<<<<<
 *                     resolvent = Clause(clause.head.subst(env),
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_2 = PyObject_RichCompare(__pyx_v_env, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 898, __pyx_L1_error)
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 898, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 898, __pyx_L1_error)
          }
        }
        #endif

        /* "pyDatalog/pyEngine.py":899
 *                     env = clause.body[0].unify(fact)
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),             # <<<<<<<<<<<<<<
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))
 */
        if (!(likely(PyDict_CheckExact(__pyx_v_env))||((__pyx_v_env) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_env)->tp_name), 0))) __PYX_ERR(0, 899, __pyx_L1_error)
        __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_clause->head->__pyx_vtab)->subst(__pyx_v_clause->head, ((PyObject*)__pyx_v_env), 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);

        /* "pyDatalog/pyEngine.py":900
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])             # <<<<<<<<<<<<<<
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself
 */
        __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 900, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (unlikely(__pyx_v_clause->body == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 900, __pyx_L1_error)
        }
        __pyx_t_3 = __Pyx_PyList_GetSlice(__pyx_v_clause->body, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        for (;;) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 900, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
          __Pyx_XDECREF_SET(__pyx_v_bodi, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_bodi, __pyx_n_s_subst); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 900, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
            if (likely(__pyx_t_13)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_12, function);
            }
          }
          __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_env);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 900, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyDatalog/pyEngine.py":899
 *                     env = clause.body[0].unify(fact)
 *                     assert env != None
 *                     resolvent = Clause(clause.head.subst(env),             # <<<<<<<<<<<<<<
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))
 */
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
        __pyx_t_2 = 0;
        __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_resolvent, ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_t_6));
        __pyx_t_6 = 0;

        /* "pyDatalog/pyEngine.py":901
 *                     resolvent = Clause(clause.head.subst(env),
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))             # <<<<<<<<<<<<<<
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself
 *                 self.schedule((SEARCHING, (self, sg )))
 */
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
        __Pyx_INCREF(((PyObject *)__pyx_v_resolvent));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_resolvent));
        PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_resolvent));
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
        __pyx_t_6 = 0;
        __pyx_t_4 = 0;
        __pyx_t_4 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "pyDatalog/pyEngine.py":896
 *                 self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             else:
 *                 for fact in sg.facts.values(): # catch-up with facts already established             # <<<<<<<<<<<<<<
 *                     env = clause.body[0].unify(fact)
 *                     assert env != None
 */
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;

    /* "pyDatalog/pyEngine.py":902
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself             # <<<<<<<<<<<<<<
 *                 self.schedule((SEARCHING, (self, sg )))
 *             if not sg.is_done:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sg, __pyx_n_s_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 902, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_sg, ((PyObject *)__pyx_v_self), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 902, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 902, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __pyx_t_7;
    __pyx_L10_bool_binop_done:;
    if (__pyx_t_8) {

      /* "pyDatalog/pyEngine.py":903
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself
 *                 self.schedule((SEARCHING, (self, sg )))             # <<<<<<<<<<<<<<
 *             if not sg.is_done:
 *                 sg.waiters.append((self, clause)) # add me to sg's waiters
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 903, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 903, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_sg);
      __Pyx_GIVEREF(__pyx_v_sg);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_sg);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 903, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
      __pyx_t_1 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 903, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "pyDatalog/pyEngine.py":902
 *                                        [bodi.subst(env) for bodi in clause.body[1:] ])
 *                     self.schedule((ADD_CLAUSE, (self, resolvent)))
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself             # <<<<<<<<<<<<<<
 *                 self.schedule((SEARCHING, (self, sg )))
 *             if not sg.is_done:
 */
    }

    /* "pyDatalog/pyEngine.py":904
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself
 *                 self.schedule((SEARCHING, (self, sg )))
 *             if not sg.is_done:             # <<<<<<<<<<<<<<
 *                 sg.waiters.append((self, clause)) # add me to sg's waiters
 *         else: # new subgoal --> create it and launch it
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_sg, __pyx_n_s_is_done_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 904, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = ((!__pyx_t_8) != 0);
    if (__pyx_t_7) {

      /* "pyDatalog/pyEngine.py":905
 *                 self.schedule((SEARCHING, (self, sg )))
 *             if not sg.is_done:
 *                 sg.waiters.append((self, clause)) # add me to sg's waiters             # <<<<<<<<<<<<<<
 *         else: # new subgoal --> create it and launch it
 *             sg = Subgoal(selected)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_sg, __pyx_n_s_waiters); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 905, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 905, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_clause));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_clause));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_clause));
      __pyx_t_14 = __Pyx_PyObject_Append(__pyx_t_4, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 905, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":904
 *             if sg.tasks and sg != self: # no need to say that I'm searching myself
 *                 self.schedule((SEARCHING, (self, sg )))
 *             if not sg.is_done:             # <<<<<<<<<<<<<<
 *                 sg.waiters.append((self, clause)) # add me to sg's waiters
 *         else: # new subgoal --> create it and launch it
 */
    }

    /* "pyDatalog/pyEngine.py":891
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 *         if sg != None: # selected subgoal exists already             # <<<<<<<<<<<<<<
 *             if sg.facts is True:
 *                 resolvent = Clause(clause.head, clause.body[1:])
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":907
 *                 sg.waiters.append((self, clause)) # add me to sg's waiters
 *         else: # new subgoal --> create it and launch it
 *             sg = Subgoal(selected)             # <<<<<<<<<<<<<<
 *             sg.waiters.append((self, clause))
 *             self.schedule_search(sg)
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), ((PyObject *)__pyx_v_selected)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_sg, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":908
 *         else: # new subgoal --> create it and launch it
 *             sg = Subgoal(selected)
 *             sg.waiters.append((self, clause))             # <<<<<<<<<<<<<<
 *             self.schedule_search(sg)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_sg, __pyx_n_s_waiters); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 908, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 908, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_clause));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_clause));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_clause));
    __pyx_t_14 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_t_4); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 908, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pyDatalog/pyEngine.py":909
 *             sg = Subgoal(selected)
 *             sg.waiters.append((self, clause))
 *             self.schedule_search(sg)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    if (!(likely(__Pyx_TypeTest(__pyx_v_sg, __pyx_ptype_9pyDatalog_8pyEngine_Subgoal)))) __PYX_ERR(0, 909, __pyx_L1_error)
    __pyx_t_4 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule_search(__pyx_v_self, ((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_sg), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 909, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "pyDatalog/pyEngine.py":888
 *             self.fact(Literal(self.literal.pred.name, result))
 * 
 *     def rule(self, clause, selected):             # <<<<<<<<<<<<<<
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.rule", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sg);
  __Pyx_XDECREF((PyObject *)__pyx_v_resolvent);
  __Pyx_XDECREF(__pyx_v_fact);
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XDECREF(__pyx_v_bodi);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_13rule(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_12rule[] = " Use a newly derived rule. SLG_POSITIVE in the reference article ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_13rule = {"rule", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_13rule, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_12rule};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_13rule(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_clause = 0;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_selected = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rule (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_clause,&__pyx_n_s_selected,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_clause)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_selected)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rule", 1, 2, 2, 1); __PYX_ERR(0, 888, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rule") < 0)) __PYX_ERR(0, 888, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_clause = ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)values[0]);
    __pyx_v_selected = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rule", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 888, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.rule", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_clause), __pyx_ptype_9pyDatalog_8pyEngine_Clause, 1, "clause", 0))) __PYX_ERR(0, 888, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_selected), __pyx_ptype_9pyDatalog_8pyEngine_Literal, 1, "selected", 0))) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_12rule(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), __pyx_v_clause, __pyx_v_selected);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_12rule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v_clause, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_selected) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rule", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Subgoal_rule(__pyx_v_self, __pyx_v_clause, __pyx_v_selected, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.rule", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":916
 *     # by delaying the evaluation of some functions
 * 
 *     def schedule(self, task):             # <<<<<<<<<<<<<<
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_15schedule(PyObject *__pyx_v_self, PyObject *__pyx_v_task); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_task, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_sg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("schedule", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_schedule); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_15schedule)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_task);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 916, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":918
 *     def schedule(self, task):
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))             # <<<<<<<<<<<<<<
 *         if task[0] is SEARCH:
 *             # not done in Subgoal.complete() for speed reason
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 918, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 918, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_show); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_task);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Add_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "pyDatalog/pyEngine.py":919
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))
 *         if task[0] is SEARCH:             # <<<<<<<<<<<<<<
 *             # not done in Subgoal.complete() for speed reason
 *             if Slow_motion:
 */
  if (unlikely(__pyx_v_task == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 919, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_task, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__pyx_t_2 == __pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "pyDatalog/pyEngine.py":921
 *         if task[0] is SEARCH:
 *             # not done in Subgoal.complete() for speed reason
 *             if Slow_motion:             # <<<<<<<<<<<<<<
 *                 sg = Logic.tl.logic.Subgoals.get(self.literal.get_tag())
 *                 if sg != None: # selected subgoal exists already
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 921, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 921, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_6) {

      /* "pyDatalog/pyEngine.py":922
 *             # not done in Subgoal.complete() for speed reason
 *             if Slow_motion:
 *                 sg = Logic.tl.logic.Subgoals.get(self.literal.get_tag())             # <<<<<<<<<<<<<<
 *                 if sg != None: # selected subgoal exists already
 *                     assert False
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Subgoals); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->literal->__pyx_vtab)->get_tag(__pyx_v_self->literal, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 922, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_sg = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":923
 *             if Slow_motion:
 *                 sg = Logic.tl.logic.Subgoals.get(self.literal.get_tag())
 *                 if sg != None: # selected subgoal exists already             # <<<<<<<<<<<<<<
 *                     assert False
 * 
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_sg, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 923, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 923, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_6) {

        /* "pyDatalog/pyEngine.py":924
 *                 sg = Logic.tl.logic.Subgoals.get(self.literal.get_tag())
 *                 if sg != None: # selected subgoal exists already
 *                     assert False             # <<<<<<<<<<<<<<
 * 
 *             Logic.tl.logic.Subgoals[self.literal.get_tag()] = self
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          if (unlikely(!0)) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 924, __pyx_L1_error)
          }
        }
        #endif

        /* "pyDatalog/pyEngine.py":923
 *             if Slow_motion:
 *                 sg = Logic.tl.logic.Subgoals.get(self.literal.get_tag())
 *                 if sg != None: # selected subgoal exists already             # <<<<<<<<<<<<<<
 *                     assert False
 * 
 */
      }

      /* "pyDatalog/pyEngine.py":921
 *         if task[0] is SEARCH:
 *             # not done in Subgoal.complete() for speed reason
 *             if Slow_motion:             # <<<<<<<<<<<<<<
 *                 sg = Logic.tl.logic.Subgoals.get(self.literal.get_tag())
 *                 if sg != None: # selected subgoal exists already
 */
    }

    /* "pyDatalog/pyEngine.py":926
 *                     assert False
 * 
 *             Logic.tl.logic.Subgoals[self.literal.get_tag()] = self             # <<<<<<<<<<<<<<
 *         if self.recursive:
 *             Logic.tl.logic.Recursive_Tasks.appendleft(task)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Subgoals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_self->literal->__pyx_vtab)->get_tag(__pyx_v_self->literal, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_1, ((PyObject *)__pyx_v_self)) < 0)) __PYX_ERR(0, 926, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":919
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))
 *         if task[0] is SEARCH:             # <<<<<<<<<<<<<<
 *             # not done in Subgoal.complete() for speed reason
 *             if Slow_motion:
 */
  }

  /* "pyDatalog/pyEngine.py":927
 * 
 *             Logic.tl.logic.Subgoals[self.literal.get_tag()] = self
 *         if self.recursive:             # <<<<<<<<<<<<<<
 *             Logic.tl.logic.Recursive_Tasks.appendleft(task)
 *             self.tasks.appendleft(task)
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->recursive)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 927, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "pyDatalog/pyEngine.py":928
 *             Logic.tl.logic.Subgoals[self.literal.get_tag()] = self
 *         if self.recursive:
 *             Logic.tl.logic.Recursive_Tasks.appendleft(task)             # <<<<<<<<<<<<<<
 *             self.tasks.appendleft(task)
 *         else:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_appendleft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_task);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 928, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":929
 *         if self.recursive:
 *             Logic.tl.logic.Recursive_Tasks.appendleft(task)
 *             self.tasks.appendleft(task)             # <<<<<<<<<<<<<<
 *         else:
 *             Logic.tl.logic.Tasks.append(task)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->tasks, __pyx_n_s_appendleft); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 929, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_task);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 929, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":927
 * 
 *             Logic.tl.logic.Subgoals[self.literal.get_tag()] = self
 *         if self.recursive:             # <<<<<<<<<<<<<<
 *             Logic.tl.logic.Recursive_Tasks.appendleft(task)
 *             self.tasks.appendleft(task)
 */
    goto __pyx_L7;
  }

  /* "pyDatalog/pyEngine.py":931
 *             self.tasks.appendleft(task)
 *         else:
 *             Logic.tl.logic.Tasks.append(task)             # <<<<<<<<<<<<<<
 *             self.tasks.append(task)
 * 
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_v_task); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 931, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":932
 *         else:
 *             Logic.tl.logic.Tasks.append(task)
 *             self.tasks.append(task)             # <<<<<<<<<<<<<<
 * 
 *     def schedule_search(self, subgoal):
 */
    __pyx_t_7 = __Pyx_PyObject_Append(__pyx_v_self->tasks, __pyx_v_task); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 932, __pyx_L1_error)
  }
  __pyx_L7:;

  /* "pyDatalog/pyEngine.py":916
 *     # by delaying the evaluation of some functions
 * 
 *     def schedule(self, task):             # <<<<<<<<<<<<<<
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.schedule", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_15schedule(PyObject *__pyx_v_self, PyObject *__pyx_v_task); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_14schedule[] = " Schedule a task for later invocation ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_15schedule = {"schedule", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_15schedule, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_14schedule};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_15schedule(PyObject *__pyx_v_self, PyObject *__pyx_v_task) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("schedule (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_task), (&PyTuple_Type), 1, "task", 1))) __PYX_ERR(0, 916, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14schedule(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject*)__pyx_v_task));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14schedule(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_task) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("schedule", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule(__pyx_v_self, __pyx_v_task, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.schedule", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":934
 *             self.tasks.append(task)
 * 
 *     def schedule_search(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_17schedule_search(PyObject *__pyx_v_self, PyObject *__pyx_v_subgoal); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule_search(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_subgoal, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("schedule_search", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_schedule_search); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 934, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_17schedule_search)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_subgoal)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_subgoal));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 934, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":936
 *     def schedule_search(self, subgoal):
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive             # <<<<<<<<<<<<<<
 *         if self.recursive:
 *             if subgoal.recursive:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_subgoal->recursive);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Recursive, __pyx_t_1) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":937
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive
 *         if self.recursive:             # <<<<<<<<<<<<<<
 *             if subgoal.recursive:
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->recursive)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 937, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":938
 *         Logic.tl.logic.Recursive = subgoal.recursive
 *         if self.recursive:
 *             if subgoal.recursive:             # <<<<<<<<<<<<<<
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_subgoal->recursive)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 938, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "pyDatalog/pyEngine.py":939
 *         if self.recursive:
 *             if subgoal.recursive:
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first             # <<<<<<<<<<<<<<
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 *             else:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 939, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 939, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 939, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_subgoal->__pyx_vtab)->schedule(__pyx_v_subgoal, ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 939, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":940
 *             if subgoal.recursive:
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last             # <<<<<<<<<<<<<<
 *             else:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 940, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 940, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 940, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
      __pyx_t_1 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 940, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":938
 *         Logic.tl.logic.Recursive = subgoal.recursive
 *         if self.recursive:
 *             if subgoal.recursive:             # <<<<<<<<<<<<<<
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 */
      goto __pyx_L4;
    }

    /* "pyDatalog/pyEngine.py":942
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 *             else:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last             # <<<<<<<<<<<<<<
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 *         else:
 */
    /*else*/ {
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":943
 *             else:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first             # <<<<<<<<<<<<<<
 *         else:
 *             if subgoal.recursive:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 943, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 943, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 943, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_subgoal->__pyx_vtab)->schedule(__pyx_v_subgoal, ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 943, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;

    /* "pyDatalog/pyEngine.py":937
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive
 *         if self.recursive:             # <<<<<<<<<<<<<<
 *             if subgoal.recursive:
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":945
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 *         else:
 *             if subgoal.recursive:             # <<<<<<<<<<<<<<
 *                 self.schedule((SEARCHING, (self, subgoal ))) # first !
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # last !
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_subgoal->recursive)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 945, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "pyDatalog/pyEngine.py":946
 *         else:
 *             if subgoal.recursive:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # first !             # <<<<<<<<<<<<<<
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # last !
 *             else:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
      __pyx_t_1 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":947
 *             if subgoal.recursive:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # first !
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # last !             # <<<<<<<<<<<<<<
 *             else:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 947, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 947, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_subgoal->__pyx_vtab)->schedule(__pyx_v_subgoal, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":945
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 *         else:
 *             if subgoal.recursive:             # <<<<<<<<<<<<<<
 *                 self.schedule((SEARCHING, (self, subgoal ))) # first !
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # last !
 */
      goto __pyx_L5;
    }

    /* "pyDatalog/pyEngine.py":949
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # last !
 *             else:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last             # <<<<<<<<<<<<<<
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 * 
 */
    /*else*/ {
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":950
 *             else:
 *                 self.schedule((SEARCHING, (self, subgoal ))) # last
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first             # <<<<<<<<<<<<<<
 * 
 *     def next_step(self):
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 950, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 950, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_subgoal));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_subgoal));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_subgoal));
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
      __pyx_t_1 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_subgoal->__pyx_vtab)->schedule(__pyx_v_subgoal, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 950, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_L5:;
  }
  __pyx_L3:;

  /* "pyDatalog/pyEngine.py":934
 *             self.tasks.append(task)
 * 
 *     def schedule_search(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.schedule_search", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_17schedule_search(PyObject *__pyx_v_self, PyObject *__pyx_v_subgoal); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_16schedule_search[] = " schedule SEARCH before SEARCHING, if possible ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_17schedule_search = {"schedule_search", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_17schedule_search, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_16schedule_search};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_17schedule_search(PyObject *__pyx_v_self, PyObject *__pyx_v_subgoal) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("schedule_search (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_subgoal), __pyx_ptype_9pyDatalog_8pyEngine_Subgoal, 1, "subgoal", 0))) __PYX_ERR(0, 934, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_16schedule_search(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_subgoal));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_16schedule_search(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_subgoal) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("schedule_search", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule_search(__pyx_v_self, __pyx_v_subgoal, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.schedule_search", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":952
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 * 
 *     def next_step(self):             # <<<<<<<<<<<<<<
 *         """ returns the next step in the resolution """
 *         Ts = Logic.tl.logic
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_19next_step(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_18next_step[] = " returns the next step in the resolution ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_19next_step = {"next_step", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_19next_step, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_18next_step};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_19next_step(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("next_step (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_18next_step(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_18next_step(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_v_Ts = NULL;
  PyObject *__pyx_v_fact = NULL;
  PyObject *__pyx_v_task = NULL;
  PyObject *__pyx_v_tasks = NULL;
  PyObject *__pyx_v_task2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("next_step", 0);

  /* "pyDatalog/pyEngine.py":954
 *     def next_step(self):
 *         """ returns the next step in the resolution """
 *         Ts = Logic.tl.logic             # <<<<<<<<<<<<<<
 *         # self.print_()
 *         if Slow_motion:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 954, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_Ts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":956
 *         Ts = Logic.tl.logic
 *         # self.print_()
 *         if Slow_motion:             # <<<<<<<<<<<<<<
 *             if self.facts is not True:
 *                 print("Facts of:" + str(self))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 956, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":957
 *         # self.print_()
 *         if Slow_motion:
 *             if self.facts is not True:             # <<<<<<<<<<<<<<
 *                 print("Facts of:" + str(self))
 *                 for fact in self.facts:
 */
    __pyx_t_3 = (__pyx_v_self->facts != Py_True);
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":958
 *         if Slow_motion:
 *             if self.facts is not True:
 *                 print("Facts of:" + str(self))             # <<<<<<<<<<<<<<
 *                 for fact in self.facts:
 *                     print("  " + str(fact))
 */
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 958, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyNumber_Add(__pyx_kp_s_Facts_of, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 958, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 958, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":959
 *             if self.facts is not True:
 *                 print("Facts of:" + str(self))
 *                 for fact in self.facts:             # <<<<<<<<<<<<<<
 *                     print("  " + str(fact))
 *             print("Clauses of:" + str(self))
 */
      if (likely(PyList_CheckExact(__pyx_v_self->facts)) || PyTuple_CheckExact(__pyx_v_self->facts)) {
        __pyx_t_2 = __pyx_v_self->facts; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
        __pyx_t_6 = NULL;
      } else {
        __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_self->facts); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 959, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 959, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_6)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 959, __pyx_L1_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 959, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          } else {
            if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 959, __pyx_L1_error)
            #else
            __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 959, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
          }
        } else {
          __pyx_t_1 = __pyx_t_6(__pyx_t_2);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 959, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_v_fact, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":960
 *                 print("Facts of:" + str(self))
 *                 for fact in self.facts:
 *                     print("  " + str(fact))             # <<<<<<<<<<<<<<
 *             print("Clauses of:" + str(self))
 *             for task in self.clauses:
 */
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_v_fact); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 960, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = PyNumber_Add(__pyx_kp_s__27, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 960, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_7) < 0) __PYX_ERR(0, 960, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "pyDatalog/pyEngine.py":959
 *             if self.facts is not True:
 *                 print("Facts of:" + str(self))
 *                 for fact in self.facts:             # <<<<<<<<<<<<<<
 *                     print("  " + str(fact))
 *             print("Clauses of:" + str(self))
 */
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":957
 *         # self.print_()
 *         if Slow_motion:
 *             if self.facts is not True:             # <<<<<<<<<<<<<<
 *                 print("Facts of:" + str(self))
 *                 for fact in self.facts:
 */
    }

    /* "pyDatalog/pyEngine.py":961
 *                 for fact in self.facts:
 *                     print("  " + str(fact))
 *             print("Clauses of:" + str(self))             # <<<<<<<<<<<<<<
 *             for task in self.clauses:
 *                 print("  " + show(task))
 */
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 961, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyNumber_Add(__pyx_kp_s_Clauses_of, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 961, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_7) < 0) __PYX_ERR(0, 961, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pyDatalog/pyEngine.py":962
 *                     print("  " + str(fact))
 *             print("Clauses of:" + str(self))
 *             for task in self.clauses:             # <<<<<<<<<<<<<<
 *                 print("  " + show(task))
 *             if self.on_completion_:
 */
    if (unlikely(__pyx_v_self->clauses == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 962, __pyx_L1_error)
    }
    __pyx_t_7 = __pyx_v_self->clauses; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 962, __pyx_L1_error)
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 962, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_task, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":963
 *             print("Clauses of:" + str(self))
 *             for task in self.clauses:
 *                 print("  " + show(task))             # <<<<<<<<<<<<<<
 *             if self.on_completion_:
 *                 print("On completion : ")
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_show); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_task);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Add(__pyx_kp_s__27, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 963, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":962
 *                     print("  " + str(fact))
 *             print("Clauses of:" + str(self))
 *             for task in self.clauses:             # <<<<<<<<<<<<<<
 *                 print("  " + show(task))
 *             if self.on_completion_:
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "pyDatalog/pyEngine.py":964
 *             for task in self.clauses:
 *                 print("  " + show(task))
 *             if self.on_completion_:             # <<<<<<<<<<<<<<
 *                 print("On completion : ")
 *                 for task in self.on_completion_:
 */
    __pyx_t_4 = (__pyx_v_self->on_completion_ != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->on_completion_) != 0);
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":965
 *                 print("  " + show(task))
 *             if self.on_completion_:
 *                 print("On completion : ")             # <<<<<<<<<<<<<<
 *                 for task in self.on_completion_:
 *                     print("  " + show(task))
 */
      if (__Pyx_PrintOne(0, __pyx_kp_s_On_completion) < 0) __PYX_ERR(0, 965, __pyx_L1_error)

      /* "pyDatalog/pyEngine.py":966
 *             if self.on_completion_:
 *                 print("On completion : ")
 *                 for task in self.on_completion_:             # <<<<<<<<<<<<<<
 *                     print("  " + show(task))
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))
 */
      if (unlikely(__pyx_v_self->on_completion_ == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 966, __pyx_L1_error)
      }
      __pyx_t_7 = __pyx_v_self->on_completion_; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0;
      for (;;) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 966, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 966, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_XDECREF_SET(__pyx_v_task, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":967
 *                 print("On completion : ")
 *                 for task in self.on_completion_:
 *                     print("  " + show(task))             # <<<<<<<<<<<<<<
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))
 *             for task in reversed(Ts.Tasks):
 */
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_show); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 967, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_task);
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 967, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_Add(__pyx_kp_s__27, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 967, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 967, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":966
 *             if self.on_completion_:
 *                 print("On completion : ")
 *                 for task in self.on_completion_:             # <<<<<<<<<<<<<<
 *                     print("  " + show(task))
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))
 */
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pyDatalog/pyEngine.py":964
 *             for task in self.clauses:
 *                 print("  " + show(task))
 *             if self.on_completion_:             # <<<<<<<<<<<<<<
 *                 print("On completion : ")
 *                 for task in self.on_completion_:
 */
    }

    /* "pyDatalog/pyEngine.py":968
 *                 for task in self.on_completion_:
 *                     print("  " + show(task))
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))             # <<<<<<<<<<<<<<
 *             for task in reversed(Ts.Tasks):
 *                 print("  " + show(task))
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (((!__pyx_t_4) != 0)) {
      __Pyx_INCREF(__pyx_kp_s__28);
      __pyx_t_7 = __pyx_kp_s__28;
    } else {
      __Pyx_INCREF(__pyx_kp_s__14);
      __pyx_t_7 = __pyx_kp_s__14;
    }
    __pyx_t_2 = PyNumber_Add(__pyx_kp_s_STACK, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":969
 *                     print("  " + show(task))
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))
 *             for task in reversed(Ts.Tasks):             # <<<<<<<<<<<<<<
 *                 print("  " + show(task))
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 969, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_reversed, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 969, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) {
      __pyx_t_2 = __pyx_t_7; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 969, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 969, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 969, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 969, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 969, __pyx_L1_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 969, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_2);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 969, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_task, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "pyDatalog/pyEngine.py":970
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))
 *             for task in reversed(Ts.Tasks):
 *                 print("  " + show(task))             # <<<<<<<<<<<<<<
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))
 *             for task in reversed(Ts.Recursive_Tasks):
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_show); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 970, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_task);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 970, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Add(__pyx_kp_s__27, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 970, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 970, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":969
 *                     print("  " + show(task))
 *             print("STACK :" + ("<---" if not Ts.Recursive else ""))
 *             for task in reversed(Ts.Tasks):             # <<<<<<<<<<<<<<
 *                 print("  " + show(task))
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":971
 *             for task in reversed(Ts.Tasks):
 *                 print("  " + show(task))
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))             # <<<<<<<<<<<<<<
 *             for task in reversed(Ts.Recursive_Tasks):
 *                 print("  " + show(task))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
      __Pyx_INCREF(__pyx_kp_s__28);
      __pyx_t_2 = __pyx_kp_s__28;
    } else {
      __Pyx_INCREF(__pyx_kp_s__14);
      __pyx_t_2 = __pyx_kp_s__14;
    }
    __pyx_t_1 = PyNumber_Add(__pyx_kp_s_RECURSIVE_STACK, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 971, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":972
 *                 print("  " + show(task))
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))
 *             for task in reversed(Ts.Recursive_Tasks):             # <<<<<<<<<<<<<<
 *                 print("  " + show(task))
 *             print(" ")
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_reversed, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 972, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 972, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 972, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_6(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 972, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_task, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":973
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))
 *             for task in reversed(Ts.Recursive_Tasks):
 *                 print("  " + show(task))             # <<<<<<<<<<<<<<
 *             print(" ")
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_show); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_task);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Add(__pyx_kp_s__27, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 973, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_7) < 0) __PYX_ERR(0, 973, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "pyDatalog/pyEngine.py":972
 *                 print("  " + show(task))
 *             print("RECURSIVE STACK :" + ("<---" if Ts.Recursive else ""))
 *             for task in reversed(Ts.Recursive_Tasks):             # <<<<<<<<<<<<<<
 *                 print("  " + show(task))
 *             print(" ")
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":974
 *             for task in reversed(Ts.Recursive_Tasks):
 *                 print("  " + show(task))
 *             print(" ")             # <<<<<<<<<<<<<<
 * 
 *         task = (None, None); tasks = None
 */
    if (__Pyx_PrintOne(0, __pyx_kp_s__29) < 0) __PYX_ERR(0, 974, __pyx_L1_error)

    /* "pyDatalog/pyEngine.py":956
 *         Ts = Logic.tl.logic
 *         # self.print_()
 *         if Slow_motion:             # <<<<<<<<<<<<<<
 *             if self.facts is not True:
 *                 print("Facts of:" + str(self))
 */
  }

  /* "pyDatalog/pyEngine.py":976
 *             print(" ")
 * 
 *         task = (None, None); tasks = None             # <<<<<<<<<<<<<<
 *         if not Ts.Goal.is_done:
 *             if Ts.Recursive:
 */
  __Pyx_INCREF(__pyx_tuple__30);
  __Pyx_XDECREF_SET(__pyx_v_task, __pyx_tuple__30);
  __Pyx_INCREF(Py_None);
  __pyx_v_tasks = Py_None;

  /* "pyDatalog/pyEngine.py":977
 * 
 *         task = (None, None); tasks = None
 *         if not Ts.Goal.is_done:             # <<<<<<<<<<<<<<
 *             if Ts.Recursive:
 *                 if Ts.Recursive_Tasks:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Goal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_is_done_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_3 = ((!__pyx_t_4) != 0);
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":978
 *         task = (None, None); tasks = None
 *         if not Ts.Goal.is_done:
 *             if Ts.Recursive:             # <<<<<<<<<<<<<<
 *                 if Ts.Recursive_Tasks:
 *                     task = Ts.Recursive_Tasks.pop()
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 978, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_3) {

      /* "pyDatalog/pyEngine.py":979
 *         if not Ts.Goal.is_done:
 *             if Ts.Recursive:
 *                 if Ts.Recursive_Tasks:             # <<<<<<<<<<<<<<
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 979, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 979, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_3) {

        /* "pyDatalog/pyEngine.py":980
 *             if Ts.Recursive:
 *                 if Ts.Recursive_Tasks:
 *                     task = Ts.Recursive_Tasks.pop()             # <<<<<<<<<<<<<<
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Tasks:
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 980, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 980, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":981
 *                 if Ts.Recursive_Tasks:
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks             # <<<<<<<<<<<<<<
 *                 elif Ts.Tasks:
 *                     Ts.Recursive = False
 */
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 981, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 981, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 981, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_tasks, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":979
 *         if not Ts.Goal.is_done:
 *             if Ts.Recursive:
 *                 if Ts.Recursive_Tasks:             # <<<<<<<<<<<<<<
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks
 */
        goto __pyx_L18;
      }

      /* "pyDatalog/pyEngine.py":982
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Tasks:             # <<<<<<<<<<<<<<
 *                     Ts.Recursive = False
 *                     task = Ts.Tasks.pop()
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 982, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_3) {

        /* "pyDatalog/pyEngine.py":983
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Tasks:
 *                     Ts.Recursive = False             # <<<<<<<<<<<<<<
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks
 */
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive, Py_False) < 0) __PYX_ERR(0, 983, __pyx_L1_error)

        /* "pyDatalog/pyEngine.py":984
 *                 elif Ts.Tasks:
 *                     Ts.Recursive = False
 *                     task = Ts.Tasks.pop()             # <<<<<<<<<<<<<<
 *                     tasks = task[1][0].tasks
 *             else:
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 984, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyObject_Pop(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 984, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "pyDatalog/pyEngine.py":985
 *                     Ts.Recursive = False
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks             # <<<<<<<<<<<<<<
 *             else:
 *                 if Ts.Tasks:
 */
        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 985, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 985, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tasks); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 985, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF_SET(__pyx_v_tasks, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "pyDatalog/pyEngine.py":982
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Tasks:             # <<<<<<<<<<<<<<
 *                     Ts.Recursive = False
 *                     task = Ts.Tasks.pop()
 */
      }
      __pyx_L18:;

      /* "pyDatalog/pyEngine.py":978
 *         task = (None, None); tasks = None
 *         if not Ts.Goal.is_done:
 *             if Ts.Recursive:             # <<<<<<<<<<<<<<
 *                 if Ts.Recursive_Tasks:
 *                     task = Ts.Recursive_Tasks.pop()
 */
      goto __pyx_L17;
    }

    /* "pyDatalog/pyEngine.py":987
 *                     tasks = task[1][0].tasks
 *             else:
 *                 if Ts.Tasks:             # <<<<<<<<<<<<<<
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks
 */
    /*else*/ {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 987, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 987, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_3) {

        /* "pyDatalog/pyEngine.py":988
 *             else:
 *                 if Ts.Tasks:
 *                     task = Ts.Tasks.pop()             # <<<<<<<<<<<<<<
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Recursive_Tasks:
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 988, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 988, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":989
 *                 if Ts.Tasks:
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks             # <<<<<<<<<<<<<<
 *                 elif Ts.Recursive_Tasks:
 *                     Ts.Recursive = True
 */
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 989, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF_SET(__pyx_v_tasks, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":987
 *                     tasks = task[1][0].tasks
 *             else:
 *                 if Ts.Tasks:             # <<<<<<<<<<<<<<
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks
 */
        goto __pyx_L19;
      }

      /* "pyDatalog/pyEngine.py":990
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Recursive_Tasks:             # <<<<<<<<<<<<<<
 *                     Ts.Recursive = True
 *                     task = Ts.Recursive_Tasks.pop()
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 990, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_3) {

        /* "pyDatalog/pyEngine.py":991
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Recursive_Tasks:
 *                     Ts.Recursive = True             # <<<<<<<<<<<<<<
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks
 */
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive, Py_True) < 0) __PYX_ERR(0, 991, __pyx_L1_error)

        /* "pyDatalog/pyEngine.py":992
 *                 elif Ts.Recursive_Tasks:
 *                     Ts.Recursive = True
 *                     task = Ts.Recursive_Tasks.pop()             # <<<<<<<<<<<<<<
 *                     tasks = task[1][0].tasks
 *             task2 = tasks.pop() if tasks else (None, None)
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 992, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyObject_Pop(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 992, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "pyDatalog/pyEngine.py":993
 *                     Ts.Recursive = True
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks             # <<<<<<<<<<<<<<
 *             task2 = tasks.pop() if tasks else (None, None)
 *             assert task == task2 # make sure we are in sync, and not lose tasks
 */
        __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 993, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 993, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tasks); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 993, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF_SET(__pyx_v_tasks, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "pyDatalog/pyEngine.py":990
 *                     task = Ts.Tasks.pop()
 *                     tasks = task[1][0].tasks
 *                 elif Ts.Recursive_Tasks:             # <<<<<<<<<<<<<<
 *                     Ts.Recursive = True
 *                     task = Ts.Recursive_Tasks.pop()
 */
      }
      __pyx_L19:;
    }
    __pyx_L17:;

    /* "pyDatalog/pyEngine.py":994
 *                     task = Ts.Recursive_Tasks.pop()
 *                     tasks = task[1][0].tasks
 *             task2 = tasks.pop() if tasks else (None, None)             # <<<<<<<<<<<<<<
 *             assert task == task2 # make sure we are in sync, and not lose tasks
 *         if Slow_motion:
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_tasks); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 994, __pyx_L1_error)
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 994, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __pyx_t_1;
      __pyx_t_1 = 0;
    } else {
      __Pyx_INCREF(__pyx_tuple__30);
      __pyx_t_7 = __pyx_tuple__30;
    }
    __pyx_v_task2 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "pyDatalog/pyEngine.py":995
 *                     tasks = task[1][0].tasks
 *             task2 = tasks.pop() if tasks else (None, None)
 *             assert task == task2 # make sure we are in sync, and not lose tasks             # <<<<<<<<<<<<<<
 *         if Slow_motion:
 *             print("Processing : %s" % show(task))
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_task, __pyx_v_task2, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 995, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 995, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_3)) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 995, __pyx_L1_error)
      }
    }
    #endif

    /* "pyDatalog/pyEngine.py":977
 * 
 *         task = (None, None); tasks = None
 *         if not Ts.Goal.is_done:             # <<<<<<<<<<<<<<
 *             if Ts.Recursive:
 *                 if Ts.Recursive_Tasks:
 */
  }

  /* "pyDatalog/pyEngine.py":996
 *             task2 = tasks.pop() if tasks else (None, None)
 *             assert task == task2 # make sure we are in sync, and not lose tasks
 *         if Slow_motion:             # <<<<<<<<<<<<<<
 *             print("Processing : %s" % show(task))
 *         return task
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 996, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":997
 *             assert task == task2 # make sure we are in sync, and not lose tasks
 *         if Slow_motion:
 *             print("Processing : %s" % show(task))             # <<<<<<<<<<<<<<
 *         return task
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_show); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_7 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_task);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Processing_s, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 997, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":996
 *             task2 = tasks.pop() if tasks else (None, None)
 *             assert task == task2 # make sure we are in sync, and not lose tasks
 *         if Slow_motion:             # <<<<<<<<<<<<<<
 *             print("Processing : %s" % show(task))
 *         return task
 */
  }

  /* "pyDatalog/pyEngine.py":998
 *         if Slow_motion:
 *             print("Processing : %s" % show(task))
 *         return task             # <<<<<<<<<<<<<<
 * 
 *     def next_clause(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_task);
  __pyx_r = __pyx_v_task;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":952
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 * 
 *     def next_step(self):             # <<<<<<<<<<<<<<
 *         """ returns the next step in the resolution """
 *         Ts = Logic.tl.logic
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.next_step", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Ts);
  __Pyx_XDECREF(__pyx_v_fact);
  __Pyx_XDECREF(__pyx_v_task);
  __Pyx_XDECREF(__pyx_v_tasks);
  __Pyx_XDECREF(__pyx_v_task2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1000
 *         return task
 * 
 *     def next_clause(self):             # <<<<<<<<<<<<<<
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_21next_clause(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_21next_clause = {"next_clause", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_21next_clause, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_21next_clause(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("next_clause (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_20next_clause(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_20next_clause(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_v_task = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("next_clause", 0);

  /* "pyDatalog/pyEngine.py":1001
 * 
 *     def next_clause(self):
 *         task = None             # <<<<<<<<<<<<<<
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 *             task = self.next_step()
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_task = Py_None;

  /* "pyDatalog/pyEngine.py":1002
 *     def next_clause(self):
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause             # <<<<<<<<<<<<<<
 *             task = self.next_step()
 *         elif self.clauses:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->tasks); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1002, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":1003
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 *             task = self.next_step()             # <<<<<<<<<<<<<<
 *         elif self.clauses:
 *             task = self.clauses.pop()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1002
 *     def next_clause(self):
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause             # <<<<<<<<<<<<<<
 *             task = self.next_step()
 *         elif self.clauses:
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":1004
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 *             task = self.next_step()
 *         elif self.clauses:             # <<<<<<<<<<<<<<
 *             task = self.clauses.pop()
 *         elif self.on_completion_:
 */
  __pyx_t_1 = (__pyx_v_self->clauses != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->clauses) != 0);
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":1005
 *             task = self.next_step()
 *         elif self.clauses:
 *             task = self.clauses.pop()             # <<<<<<<<<<<<<<
 *         elif self.on_completion_:
 *             task = self.on_completion_.pop()
 */
    if (unlikely(__pyx_v_self->clauses == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
      __PYX_ERR(0, 1005, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyList_Pop(__pyx_v_self->clauses); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1005, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1004
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 *             task = self.next_step()
 *         elif self.clauses:             # <<<<<<<<<<<<<<
 *             task = self.clauses.pop()
 *         elif self.on_completion_:
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":1006
 *         elif self.clauses:
 *             task = self.clauses.pop()
 *         elif self.on_completion_:             # <<<<<<<<<<<<<<
 *             task = self.on_completion_.pop()
 * 
 */
  __pyx_t_1 = (__pyx_v_self->on_completion_ != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->on_completion_) != 0);
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":1007
 *             task = self.clauses.pop()
 *         elif self.on_completion_:
 *             task = self.on_completion_.pop()             # <<<<<<<<<<<<<<
 * 
 *         if task:
 */
    if (unlikely(__pyx_v_self->on_completion_ == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
      __PYX_ERR(0, 1007, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyList_Pop(__pyx_v_self->on_completion_); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1007, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1006
 *         elif self.clauses:
 *             task = self.clauses.pop()
 *         elif self.on_completion_:             # <<<<<<<<<<<<<<
 *             task = self.on_completion_.pop()
 * 
 */
  }
  __pyx_L3:;

  /* "pyDatalog/pyEngine.py":1009
 *             task = self.on_completion_.pop()
 * 
 *         if task:             # <<<<<<<<<<<<<<
 *             self.schedule((NEXT_CLAUSE, (self,)))
 *             return task
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_task); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1009, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":1010
 * 
 *         if task:
 *             self.schedule((NEXT_CLAUSE, (self,)))             # <<<<<<<<<<<<<<
 *             return task
 *         return self.next_step()
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_NEXT_CLAUSE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1010, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1010, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1010, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_4), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1010, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pyDatalog/pyEngine.py":1011
 *         if task:
 *             self.schedule((NEXT_CLAUSE, (self,)))
 *             return task             # <<<<<<<<<<<<<<
 *         return self.next_step()
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_task);
    __pyx_r = __pyx_v_task;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":1009
 *             task = self.on_completion_.pop()
 * 
 *         if task:             # <<<<<<<<<<<<<<
 *             self.schedule((NEXT_CLAUSE, (self,)))
 *             return task
 */
  }

  /* "pyDatalog/pyEngine.py":1012
 *             self.schedule((NEXT_CLAUSE, (self,)))
 *             return task
 *         return self.next_step()             # <<<<<<<<<<<<<<
 * 
 *     def searching(self, subgoal):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1012, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1000
 *         return task
 * 
 *     def next_clause(self):             # <<<<<<<<<<<<<<
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.next_clause", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_task);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1014
 *         return self.next_step()
 * 
 *     def searching(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_23searching(PyObject *__pyx_v_self, PyObject *__pyx_v_subgoal); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_22searching[] = " task used to relaunch searching of subgoal";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_23searching = {"searching", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_23searching, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_22searching};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_23searching(PyObject *__pyx_v_self, PyObject *__pyx_v_subgoal) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("searching (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_22searching(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_subgoal));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_9pyDatalog_8pyEngine_7Subgoal_9searching_2generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "pyDatalog/pyEngine.py":1026
 *         # restart searching of subgoal, in correct recursive mode
 *         # unless the subgoal is a waiter of self (to prevent infinite loop)
 *         if all(subgoal != waiter[0] for waiter in self.waiters):             # <<<<<<<<<<<<<<
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9searching_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1026, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9pyDatalog_8pyEngine_7Subgoal_9searching_2generator9, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_searching_locals_genexpr, __pyx_n_s_pyDatalog_pyEngine); if (unlikely(!gen)) __PYX_ERR(0, 1026, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.searching.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_9pyDatalog_8pyEngine_7Subgoal_9searching_2generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1026, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1026, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->waiters == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 1026, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->waiters; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1026, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_waiter);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_waiter, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_subgoal)) { __Pyx_RaiseClosureNameError("subgoal"); __PYX_ERR(0, 1026, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_waiter, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_subgoal, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1026, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1026, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = ((!__pyx_t_5) != 0);
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1014
 *         return self.next_step()
 * 
 *     def searching(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 */

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_22searching(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_subgoal) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *__pyx_cur_scope;
  PyObject *__pyx_v_Ts = NULL;
  PyObject *__pyx_v_pos = NULL;
  PyObject *__pyx_v_task = NULL;
  PyObject *__pyx_gb_9pyDatalog_8pyEngine_7Subgoal_9searching_2generator9 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("searching", 0);
  __pyx_cur_scope = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *)__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching(__pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1014, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_subgoal = __pyx_v_subgoal;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_subgoal);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_subgoal);

  /* "pyDatalog/pyEngine.py":1016
 *     def searching(self, subgoal):
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic             # <<<<<<<<<<<<<<
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed
 *             if subgoal.on_completion_: # find the completion task for self
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_Ts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1017
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed             # <<<<<<<<<<<<<<
 *             if subgoal.on_completion_: # find the completion task for self
 *                 for pos, task in enumerate(subgoal.on_completion_):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_clauses); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = ((!__pyx_t_5) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":1018
 *         Ts = Logic.tl.logic
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed
 *             if subgoal.on_completion_: # find the completion task for self             # <<<<<<<<<<<<<<
 *                 for pos, task in enumerate(subgoal.on_completion_):
 *                     if task[1][1] == self:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_on_completion); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1018, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1018, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "pyDatalog/pyEngine.py":1019
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed
 *             if subgoal.on_completion_: # find the completion task for self
 *                 for pos, task in enumerate(subgoal.on_completion_):             # <<<<<<<<<<<<<<
 *                     if task[1][1] == self:
 *                         subgoal.on_completion_.pop(pos) # don't do it again
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_1 = __pyx_int_0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_on_completion); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1019, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
        __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1019, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1019, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_6))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 1019, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1019, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 1019, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1019, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          }
        } else {
          __pyx_t_2 = __pyx_t_8(__pyx_t_6);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 1019, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XDECREF_SET(__pyx_v_task, __pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_1);
        __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1019, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1);
        __pyx_t_1 = __pyx_t_2;
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1020
 *             if subgoal.on_completion_: # find the completion task for self
 *                 for pos, task in enumerate(subgoal.on_completion_):
 *                     if task[1][1] == self:             # <<<<<<<<<<<<<<
 *                         subgoal.on_completion_.pop(pos) # don't do it again
 *                         return task
 */
        __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1020, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1020, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)__pyx_cur_scope->__pyx_v_self), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1020, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1020, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_3) {

          /* "pyDatalog/pyEngine.py":1021
 *                 for pos, task in enumerate(subgoal.on_completion_):
 *                     if task[1][1] == self:
 *                         subgoal.on_completion_.pop(pos) # don't do it again             # <<<<<<<<<<<<<<
 *                         return task
 *             return self.next_step()
 */
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_on_completion); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1021, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_pop); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1021, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
            if (likely(__pyx_t_9)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_9);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_10, function);
            }
          }
          __pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_9, __pyx_v_pos) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_pos);
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1021, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "pyDatalog/pyEngine.py":1022
 *                     if task[1][1] == self:
 *                         subgoal.on_completion_.pop(pos) # don't do it again
 *                         return task             # <<<<<<<<<<<<<<
 *             return self.next_step()
 *         # restart searching of subgoal, in correct recursive mode
 */
          __Pyx_XDECREF(__pyx_r);
          __Pyx_INCREF(__pyx_v_task);
          __pyx_r = __pyx_v_task;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L0;

          /* "pyDatalog/pyEngine.py":1020
 *             if subgoal.on_completion_: # find the completion task for self
 *                 for pos, task in enumerate(subgoal.on_completion_):
 *                     if task[1][1] == self:             # <<<<<<<<<<<<<<
 *                         subgoal.on_completion_.pop(pos) # don't do it again
 *                         return task
 */
        }

        /* "pyDatalog/pyEngine.py":1019
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed
 *             if subgoal.on_completion_: # find the completion task for self
 *                 for pos, task in enumerate(subgoal.on_completion_):             # <<<<<<<<<<<<<<
 *                     if task[1][1] == self:
 *                         subgoal.on_completion_.pop(pos) # don't do it again
 */
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":1018
 *         Ts = Logic.tl.logic
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed
 *             if subgoal.on_completion_: # find the completion task for self             # <<<<<<<<<<<<<<
 *                 for pos, task in enumerate(subgoal.on_completion_):
 *                     if task[1][1] == self:
 */
    }

    /* "pyDatalog/pyEngine.py":1023
 *                         subgoal.on_completion_.pop(pos) # don't do it again
 *                         return task
 *             return self.next_step()             # <<<<<<<<<<<<<<
 *         # restart searching of subgoal, in correct recursive mode
 *         # unless the subgoal is a waiter of self (to prevent infinite loop)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1023, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1023, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":1017
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 *         if not(subgoal.tasks) and not(subgoal.clauses): # subgoal is completed             # <<<<<<<<<<<<<<
 *             if subgoal.on_completion_: # find the completion task for self
 *                 for pos, task in enumerate(subgoal.on_completion_):
 */
  }

  /* "pyDatalog/pyEngine.py":1026
 *         # restart searching of subgoal, in correct recursive mode
 *         # unless the subgoal is a waiter of self (to prevent infinite loop)
 *         if all(subgoal != waiter[0] for waiter in self.waiters):             # <<<<<<<<<<<<<<
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:
 */
  __pyx_t_1 = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9searching_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1026, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "pyDatalog/pyEngine.py":1027
 *         # unless the subgoal is a waiter of self (to prevent infinite loop)
 *         if all(subgoal != waiter[0] for waiter in self.waiters):
 *             task = (SEARCHING, (self, subgoal))             # <<<<<<<<<<<<<<
 *             if task not in self.tasks:
 *                 self.schedule(task)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_self));
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_subgoal);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_subgoal);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_subgoal);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_v_task = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1028
 *         if all(subgoal != waiter[0] for waiter in self.waiters):
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:             # <<<<<<<<<<<<<<
 *                 self.schedule(task)
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use
 */
    __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_task, __pyx_cur_scope->__pyx_v_self->tasks, Py_NE)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1028, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":1029
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:
 *                 self.schedule(task)             # <<<<<<<<<<<<<<
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use
 *                 task = subgoal.tasks[-1]
 */
      if (!(likely(PyTuple_CheckExact(__pyx_v_task))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_task)->tp_name), 0))) __PYX_ERR(0, 1029, __pyx_L1_error)
      __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->schedule(__pyx_cur_scope->__pyx_v_self, ((PyObject*)__pyx_v_task), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pyDatalog/pyEngine.py":1028
 *         if all(subgoal != waiter[0] for waiter in self.waiters):
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:             # <<<<<<<<<<<<<<
 *                 self.schedule(task)
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use
 */
    }

    /* "pyDatalog/pyEngine.py":1030
 *             if task not in self.tasks:
 *                 self.schedule(task)
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use             # <<<<<<<<<<<<<<
 *                 task = subgoal.tasks[-1]
 *                 if Slow_motion:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1030, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1030, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":1031
 *                 self.schedule(task)
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use
 *                 task = subgoal.tasks[-1]             # <<<<<<<<<<<<<<
 *                 if Slow_motion:
 *                     print("Moving task forward : %s" % show(task))
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1031, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1031, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_task, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":1032
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use
 *                 task = subgoal.tasks[-1]
 *                 if Slow_motion:             # <<<<<<<<<<<<<<
 *                     print("Moving task forward : %s" % show(task))
 *                 if subgoal.recursive: # find the last occurence of task
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Slow_motion); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1032, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1032, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_4) {

        /* "pyDatalog/pyEngine.py":1033
 *                 task = subgoal.tasks[-1]
 *                 if Slow_motion:
 *                     print("Moving task forward : %s" % show(task))             # <<<<<<<<<<<<<<
 *                 if subgoal.recursive: # find the last occurence of task
 *                     Ts.Recursive_Tasks.reverse()
 */
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_show); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1033, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_task);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1033, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Moving_task_forward_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1033, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_2) < 0) __PYX_ERR(0, 1033, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1032
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use
 *                 task = subgoal.tasks[-1]
 *                 if Slow_motion:             # <<<<<<<<<<<<<<
 *                     print("Moving task forward : %s" % show(task))
 *                 if subgoal.recursive: # find the last occurence of task
 */
      }

      /* "pyDatalog/pyEngine.py":1034
 *                 if Slow_motion:
 *                     print("Moving task forward : %s" % show(task))
 *                 if subgoal.recursive: # find the last occurence of task             # <<<<<<<<<<<<<<
 *                     Ts.Recursive_Tasks.reverse()
 *                     Ts.Recursive_Tasks.remove(task) #TODO this may raise an error ?
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_recursive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1034, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1034, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_4) {

        /* "pyDatalog/pyEngine.py":1035
 *                     print("Moving task forward : %s" % show(task))
 *                 if subgoal.recursive: # find the last occurence of task
 *                     Ts.Recursive_Tasks.reverse()             # <<<<<<<<<<<<<<
 *                     Ts.Recursive_Tasks.remove(task) #TODO this may raise an error ?
 *                     Ts.Recursive_Tasks.reverse()
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1035, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reverse); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1035, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1035, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1036
 *                 if subgoal.recursive: # find the last occurence of task
 *                     Ts.Recursive_Tasks.reverse()
 *                     Ts.Recursive_Tasks.remove(task) #TODO this may raise an error ?             # <<<<<<<<<<<<<<
 *                     Ts.Recursive_Tasks.reverse()
 *                     Ts.Recursive_Tasks.append(task)
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1036, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_remove); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1036, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_task);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1036, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1037
 *                     Ts.Recursive_Tasks.reverse()
 *                     Ts.Recursive_Tasks.remove(task) #TODO this may raise an error ?
 *                     Ts.Recursive_Tasks.reverse()             # <<<<<<<<<<<<<<
 *                     Ts.Recursive_Tasks.append(task)
 *                 else:
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1037, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reverse); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1037, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1037, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1038
 *                     Ts.Recursive_Tasks.remove(task) #TODO this may raise an error ?
 *                     Ts.Recursive_Tasks.reverse()
 *                     Ts.Recursive_Tasks.append(task)             # <<<<<<<<<<<<<<
 *                 else:
 *                     Ts.Tasks.remove(task) #TODO this may raise an error ?
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive_Tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1038, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_v_task); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1038, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1034
 *                 if Slow_motion:
 *                     print("Moving task forward : %s" % show(task))
 *                 if subgoal.recursive: # find the last occurence of task             # <<<<<<<<<<<<<<
 *                     Ts.Recursive_Tasks.reverse()
 *                     Ts.Recursive_Tasks.remove(task) #TODO this may raise an error ?
 */
        goto __pyx_L14;
      }

      /* "pyDatalog/pyEngine.py":1040
 *                     Ts.Recursive_Tasks.append(task)
 *                 else:
 *                     Ts.Tasks.remove(task) #TODO this may raise an error ?             # <<<<<<<<<<<<<<
 *                     Ts.Tasks.append(task)
 *             elif subgoal.clauses:
 */
      /*else*/ {
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1040, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_remove); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1040, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_v_task) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_task);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1040, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1041
 *                 else:
 *                     Ts.Tasks.remove(task) #TODO this may raise an error ?
 *                     Ts.Tasks.append(task)             # <<<<<<<<<<<<<<
 *             elif subgoal.clauses:
 *                 assert False #TODO needs a test case
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ts, __pyx_n_s_Tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1041, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_v_task); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1041, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __pyx_L14:;

      /* "pyDatalog/pyEngine.py":1030
 *             if task not in self.tasks:
 *                 self.schedule(task)
 *             if subgoal.tasks: # place first subgoal task on top of stack, for immediate use             # <<<<<<<<<<<<<<
 *                 task = subgoal.tasks[-1]
 *                 if Slow_motion:
 */
      goto __pyx_L12;
    }

    /* "pyDatalog/pyEngine.py":1042
 *                     Ts.Tasks.remove(task) #TODO this may raise an error ?
 *                     Ts.Tasks.append(task)
 *             elif subgoal.clauses:             # <<<<<<<<<<<<<<
 *                 assert False #TODO needs a test case
 *             Ts.Recursive = subgoal.recursive
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_clauses); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1042, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1042, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":1043
 *                     Ts.Tasks.append(task)
 *             elif subgoal.clauses:
 *                 assert False #TODO needs a test case             # <<<<<<<<<<<<<<
 *             Ts.Recursive = subgoal.recursive
 *         return self.next_step()
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!0)) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 1043, __pyx_L1_error)
        }
      }
      #endif

      /* "pyDatalog/pyEngine.py":1042
 *                     Ts.Tasks.remove(task) #TODO this may raise an error ?
 *                     Ts.Tasks.append(task)
 *             elif subgoal.clauses:             # <<<<<<<<<<<<<<
 *                 assert False #TODO needs a test case
 *             Ts.Recursive = subgoal.recursive
 */
    }
    __pyx_L12:;

    /* "pyDatalog/pyEngine.py":1044
 *             elif subgoal.clauses:
 *                 assert False #TODO needs a test case
 *             Ts.Recursive = subgoal.recursive             # <<<<<<<<<<<<<<
 *         return self.next_step()
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_subgoal, __pyx_n_s_recursive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1044, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_Ts, __pyx_n_s_Recursive, __pyx_t_2) < 0) __PYX_ERR(0, 1044, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1026
 *         # restart searching of subgoal, in correct recursive mode
 *         # unless the subgoal is a waiter of self (to prevent infinite loop)
 *         if all(subgoal != waiter[0] for waiter in self.waiters):             # <<<<<<<<<<<<<<
 *             task = (SEARCHING, (self, subgoal))
 *             if task not in self.tasks:
 */
  }

  /* "pyDatalog/pyEngine.py":1045
 *                 assert False #TODO needs a test case
 *             Ts.Recursive = subgoal.recursive
 *         return self.next_step()             # <<<<<<<<<<<<<<
 * 
 *     def complete(self, literal, aggregate=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1014
 *         return self.next_step()
 * 
 *     def searching(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.searching", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Ts);
  __Pyx_XDECREF(__pyx_v_pos);
  __Pyx_XDECREF(__pyx_v_task);
  __Pyx_XDECREF(__pyx_gb_9pyDatalog_8pyEngine_7Subgoal_9searching_2generator9);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1047
 *         return self.next_step()
 * 
 *     def complete(self, literal, aggregate=None):             # <<<<<<<<<<<<<<
 *         """makes sure that subgoal is completed before calling post_thunk and resuming processing"""
 *         #TODO check for infinite loops
 */

static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_25complete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyObject *__pyx_f_9pyDatalog_8pyEngine_7Subgoal_complete(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete *__pyx_optional_args) {
  PyObject *__pyx_v_aggregate = ((PyObject *)Py_None);
  PyObject *__pyx_v_subgoal = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("complete", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_aggregate = __pyx_optional_args->aggregate;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
    if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
      PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_complete); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_25complete)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_literal), __pyx_v_aggregate};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1047, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_literal), __pyx_v_aggregate};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1047, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1047, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_literal));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_literal));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_literal));
          __Pyx_INCREF(__pyx_v_aggregate);
          __Pyx_GIVEREF(__pyx_v_aggregate);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_aggregate);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1047, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
      __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
      __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
      if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
        __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
    }
    #endif
  }

  /* "pyDatalog/pyEngine.py":1051
 *         #TODO check for infinite loops
 *         # example : p(X) <= ~q(X); q(X) <= ~ p(X); creates an infinite loop
 *         subgoal = Logic.tl.logic.Subgoals.get(literal.get_tag())             # <<<<<<<<<<<<<<
 *         if subgoal is None: # selected subgoal does not exist yet
 *             subgoal = Subgoal(literal)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Subgoals); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal *)__pyx_v_literal->__pyx_vtab)->get_tag(__pyx_v_literal, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_subgoal = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1052
 *         # example : p(X) <= ~q(X); q(X) <= ~ p(X); creates an infinite loop
 *         subgoal = Logic.tl.logic.Subgoals.get(literal.get_tag())
 *         if subgoal is None: # selected subgoal does not exist yet             # <<<<<<<<<<<<<<
 *             subgoal = Subgoal(literal)
 *             self.schedule_search(subgoal)
 */
  __pyx_t_7 = (__pyx_v_subgoal == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "pyDatalog/pyEngine.py":1053
 *         subgoal = Logic.tl.logic.Subgoals.get(literal.get_tag())
 *         if subgoal is None: # selected subgoal does not exist yet
 *             subgoal = Subgoal(literal)             # <<<<<<<<<<<<<<
 *             self.schedule_search(subgoal)
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), ((PyObject *)__pyx_v_literal)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_subgoal, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":1054
 *         if subgoal is None: # selected subgoal does not exist yet
 *             subgoal = Subgoal(literal)
 *             self.schedule_search(subgoal)             # <<<<<<<<<<<<<<
 *         else:
 *             self.schedule((SEARCHING, (self, subgoal)))
 */
    if (!(likely(__Pyx_TypeTest(__pyx_v_subgoal, __pyx_ptype_9pyDatalog_8pyEngine_Subgoal)))) __PYX_ERR(0, 1054, __pyx_L1_error)
    __pyx_t_1 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule_search(__pyx_v_self, ((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_subgoal), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1054, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":1052
 *         # example : p(X) <= ~q(X); q(X) <= ~ p(X); creates an infinite loop
 *         subgoal = Logic.tl.logic.Subgoals.get(literal.get_tag())
 *         if subgoal is None: # selected subgoal does not exist yet             # <<<<<<<<<<<<<<
 *             subgoal = Subgoal(literal)
 *             self.schedule_search(subgoal)
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":1056
 *             self.schedule_search(subgoal)
 *         else:
 *             self.schedule((SEARCHING, (self, subgoal)))             # <<<<<<<<<<<<<<
 *         subgoal.on_completion_.append( (ON_COMPLETION, (subgoal, self, aggregate)) )
 * 
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_subgoal);
    __Pyx_GIVEREF(__pyx_v_subgoal);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_subgoal);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = ((struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self->__pyx_vtab)->schedule(__pyx_v_self, ((PyObject*)__pyx_t_3), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1056, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "pyDatalog/pyEngine.py":1057
 *         else:
 *             self.schedule((SEARCHING, (self, subgoal)))
 *         subgoal.on_completion_.append( (ON_COMPLETION, (subgoal, self, aggregate)) )             # <<<<<<<<<<<<<<
 * 
 *     def on_completion(self, parent, aggregate):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_on_completion); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ON_COMPLETION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_subgoal);
  __Pyx_GIVEREF(__pyx_v_subgoal);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_subgoal);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self));
  __Pyx_INCREF(__pyx_v_aggregate);
  __Pyx_GIVEREF(__pyx_v_aggregate);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_aggregate);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_t_6); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1057, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":1047
 *         return self.next_step()
 * 
 *     def complete(self, literal, aggregate=None):             # <<<<<<<<<<<<<<
 *         """makes sure that subgoal is completed before calling post_thunk and resuming processing"""
 *         #TODO check for infinite loops
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_subgoal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_25complete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_24complete[] = "makes sure that subgoal is completed before calling post_thunk and resuming processing";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_25complete = {"complete", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_25complete, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_24complete};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_25complete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal = 0;
  PyObject *__pyx_v_aggregate = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("complete (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_literal,&__pyx_n_s_aggregate,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_literal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_aggregate);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "complete") < 0)) __PYX_ERR(0, 1047, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)values[0]);
    __pyx_v_aggregate = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("complete", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1047, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_literal), __pyx_ptype_9pyDatalog_8pyEngine_Literal, 1, "literal", 0))) __PYX_ERR(0, 1047, __pyx_L1_error)
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_24complete(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), __pyx_v_literal, __pyx_v_aggregate);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_24complete(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v_literal, PyObject *__pyx_v_aggregate) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("complete", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.aggregate = __pyx_v_aggregate;
  __pyx_t_1 = __pyx_vtabptr_9pyDatalog_8pyEngine_Subgoal->complete(__pyx_v_self, __pyx_v_literal, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.complete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1059
 *         subgoal.on_completion_.append( (ON_COMPLETION, (subgoal, self, aggregate)) )
 * 
 *     def on_completion(self, parent, aggregate):             # <<<<<<<<<<<<<<
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *             Logger.debug('Processing aggregate or negation')
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_27on_completion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_27on_completion = {"on_completion", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_27on_completion, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_27on_completion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parent = 0;
  PyObject *__pyx_v_aggregate = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_completion (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_parent,&__pyx_n_s_aggregate,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parent)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_aggregate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("on_completion", 1, 2, 2, 1); __PYX_ERR(0, 1059, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "on_completion") < 0)) __PYX_ERR(0, 1059, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_parent = values[0];
    __pyx_v_aggregate = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("on_completion", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1059, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.on_completion", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_26on_completion(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), __pyx_v_parent, __pyx_v_aggregate);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_26on_completion(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_parent, PyObject *__pyx_v_aggregate) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("on_completion", 0);

  /* "pyDatalog/pyEngine.py":1060
 * 
 *     def on_completion(self, parent, aggregate):
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *             Logger.debug('Processing aggregate or negation')
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isEnabledFor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_logging); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DEBUG); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":1061
 *     def on_completion(self, parent, aggregate):
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *             Logger.debug('Processing aggregate or negation')             # <<<<<<<<<<<<<<
 * 
 *         if aggregate:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_kp_s_Processing_aggregate_or_negation) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_Processing_aggregate_or_negation);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1061, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1060
 * 
 *     def on_completion(self, parent, aggregate):
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):             # <<<<<<<<<<<<<<
 *             Logger.debug('Processing aggregate or negation')
 * 
 */
  }

  /* "pyDatalog/pyEngine.py":1063
 *             Logger.debug('Processing aggregate or negation')
 * 
 *         if aggregate:             # <<<<<<<<<<<<<<
 *             aggregate.complete(self, parent)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_aggregate); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1063, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pyDatalog/pyEngine.py":1064
 * 
 *         if aggregate:
 *             aggregate.complete(self, parent)             # <<<<<<<<<<<<<<
 *         else:
 *             assert hasattr(parent.literal.pred, 'base_pred') # parent is a negation
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_aggregate, __pyx_n_s_complete); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1064, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_parent};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1064, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_parent};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1064, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1064, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_parent);
      __Pyx_GIVEREF(__pyx_v_parent);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_v_parent);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1064, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1063
 *             Logger.debug('Processing aggregate or negation')
 * 
 *         if aggregate:             # <<<<<<<<<<<<<<
 *             aggregate.complete(self, parent)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "pyDatalog/pyEngine.py":1066
 *             aggregate.complete(self, parent)
 *         else:
 *             assert hasattr(parent.literal.pred, 'base_pred') # parent is a negation             # <<<<<<<<<<<<<<
 *             if not self.facts:
 *                 parent.fact(True)
 */
  /*else*/ {
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_parent, __pyx_n_s_literal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1066, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_pred); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1066, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_HasAttr(__pyx_t_6, __pyx_n_s_base_pred); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1066, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!(__pyx_t_1 != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 1066, __pyx_L1_error)
      }
    }
    #endif

    /* "pyDatalog/pyEngine.py":1067
 *         else:
 *             assert hasattr(parent.literal.pred, 'base_pred') # parent is a negation
 *             if not self.facts:             # <<<<<<<<<<<<<<
 *                 parent.fact(True)
 *         return self.next_step()
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->facts); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1067, __pyx_L1_error)
    __pyx_t_3 = ((!__pyx_t_1) != 0);
    if (__pyx_t_3) {

      /* "pyDatalog/pyEngine.py":1068
 *             assert hasattr(parent.literal.pred, 'base_pred') # parent is a negation
 *             if not self.facts:
 *                 parent.fact(True)             # <<<<<<<<<<<<<<
 *         return self.next_step()
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_parent, __pyx_n_s_fact); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1068, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, Py_True) : __Pyx_PyObject_CallOneArg(__pyx_t_2, Py_True);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1068, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "pyDatalog/pyEngine.py":1067
 *         else:
 *             assert hasattr(parent.literal.pred, 'base_pred') # parent is a negation
 *             if not self.facts:             # <<<<<<<<<<<<<<
 *                 parent.fact(True)
 *         return self.next_step()
 */
    }
  }
  __pyx_L6:;

  /* "pyDatalog/pyEngine.py":1069
 *             if not self.facts:
 *                 parent.fact(True)
 *         return self.next_step()             # <<<<<<<<<<<<<<
 * 
 * # op codes are defined after class Subgoal is defined
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next_step); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1059
 *         subgoal.on_completion_.append( (ON_COMPLETION, (subgoal, self, aggregate)) )
 * 
 *     def on_completion(self, parent, aggregate):             # <<<<<<<<<<<<<<
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *             Logger.debug('Processing aggregate or negation')
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.on_completion", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":81
 * 
 * cdef class Subgoal(object):
 *     cpdef public Literal literal             # <<<<<<<<<<<<<<
 *     cpdef public object facts
 *     cpdef public list waiters
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->literal));
  __pyx_r = ((PyObject *)__pyx_v_self->literal);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(2, 81, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->literal);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->literal));
  __pyx_v_self->literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.literal.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7literal_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->literal);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->literal));
  __pyx_v_self->literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":82
 * cdef class Subgoal(object):
 *     cpdef public Literal literal
 *     cpdef public object facts             # <<<<<<<<<<<<<<
 *     cpdef public list waiters
 *     cpdef public object tasks
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->facts);
  __pyx_r = __pyx_v_self->facts;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->facts);
  __Pyx_DECREF(__pyx_v_self->facts);
  __pyx_v_self->facts = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5facts_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->facts);
  __Pyx_DECREF(__pyx_v_self->facts);
  __pyx_v_self->facts = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":83
 *     cpdef public Literal literal
 *     cpdef public object facts
 *     cpdef public list waiters             # <<<<<<<<<<<<<<
 *     cpdef public object tasks
 *     cpdef public list clauses
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->waiters);
  __pyx_r = __pyx_v_self->waiters;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 83, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->waiters);
  __Pyx_DECREF(__pyx_v_self->waiters);
  __pyx_v_self->waiters = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.waiters.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7waiters_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->waiters);
  __Pyx_DECREF(__pyx_v_self->waiters);
  __pyx_v_self->waiters = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":84
 *     cpdef public object facts
 *     cpdef public list waiters
 *     cpdef public object tasks             # <<<<<<<<<<<<<<
 *     cpdef public list clauses
 *     cpdef public bool recursive
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->tasks);
  __pyx_r = __pyx_v_self->tasks;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->tasks);
  __Pyx_DECREF(__pyx_v_self->tasks);
  __pyx_v_self->tasks = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_5tasks_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->tasks);
  __Pyx_DECREF(__pyx_v_self->tasks);
  __pyx_v_self->tasks = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":85
 *     cpdef public list waiters
 *     cpdef public object tasks
 *     cpdef public list clauses             # <<<<<<<<<<<<<<
 *     cpdef public bool recursive
 *     cpdef public bool is_done
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->clauses);
  __pyx_r = __pyx_v_self->clauses;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 85, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->clauses);
  __Pyx_DECREF(__pyx_v_self->clauses);
  __pyx_v_self->clauses = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.clauses.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7clauses_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->clauses);
  __Pyx_DECREF(__pyx_v_self->clauses);
  __pyx_v_self->clauses = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":86
 *     cpdef public object tasks
 *     cpdef public list clauses
 *     cpdef public bool recursive             # <<<<<<<<<<<<<<
 *     cpdef public bool is_done
 *     cpdef public list on_completion_
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->recursive));
  __pyx_r = ((PyObject *)__pyx_v_self->recursive);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 86, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->recursive);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->recursive));
  __pyx_v_self->recursive = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.recursive.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_9recursive_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->recursive);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->recursive));
  __pyx_v_self->recursive = ((PyBoolObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":87
 *     cpdef public list clauses
 *     cpdef public bool recursive
 *     cpdef public bool is_done             # <<<<<<<<<<<<<<
 *     cpdef public list on_completion_
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done___get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done___get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->is_done));
  __pyx_r = ((PyObject *)__pyx_v_self->is_done);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done_2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done_2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 87, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->is_done);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->is_done));
  __pyx_v_self->is_done = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.is_done.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done_4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_7is_done_4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->is_done);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->is_done));
  __pyx_v_self->is_done = ((PyBoolObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.pxd":88
 *     cpdef public bool recursive
 *     cpdef public bool is_done
 *     cpdef public list on_completion_             # <<<<<<<<<<<<<<
 * 
 *     #cpdef public add_clause(self, Clause clause)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion____get__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion____get__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->on_completion_);
  __pyx_r = __pyx_v_self->on_completion_;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion__2__set__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion__2__set__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(2, 88, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->on_completion_);
  __Pyx_DECREF(__pyx_v_self->on_completion_);
  __pyx_v_self->on_completion_ = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.on_completion_.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion__4__del__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_14on_completion__4__del__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->on_completion_);
  __Pyx_DECREF(__pyx_v_self->on_completion_);
  __pyx_v_self->on_completion_ = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_29__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_29__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_29__reduce_cython__, METH_NOARGS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_29__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_28__reduce_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_28__reduce_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.clauses, self.facts, self.is_done, self.literal, self.on_completion_, self.recursive, self.tasks, self.waiters)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->clauses);
  __Pyx_GIVEREF(__pyx_v_self->clauses);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->clauses);
  __Pyx_INCREF(__pyx_v_self->facts);
  __Pyx_GIVEREF(__pyx_v_self->facts);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->facts);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->is_done));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->is_done));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_self->is_done));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->literal));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->literal));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_self->literal));
  __Pyx_INCREF(__pyx_v_self->on_completion_);
  __Pyx_GIVEREF(__pyx_v_self->on_completion_);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_self->on_completion_);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->recursive));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->recursive));
  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_v_self->recursive));
  __Pyx_INCREF(__pyx_v_self->tasks);
  __Pyx_GIVEREF(__pyx_v_self->tasks);
  PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_v_self->tasks);
  __Pyx_INCREF(__pyx_v_self->waiters);
  __Pyx_GIVEREF(__pyx_v_self->waiters);
  PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_v_self->waiters);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.clauses, self.facts, self.is_done, self.literal, self.on_completion_, self.recursive, self.tasks, self.waiters)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.clauses, self.facts, self.is_done, self.literal, self.on_completion_, self.recursive, self.tasks, self.waiters)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.clauses is not None or self.facts is not None or self.is_done is not None or self.literal is not None or self.on_completion_ is not None or self.recursive is not None or self.tasks is not None or self.waiters is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.clauses, self.facts, self.is_done, self.literal, self.on_completion_, self.recursive, self.tasks, self.waiters)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.clauses is not None or self.facts is not None or self.is_done is not None or self.literal is not None or self.on_completion_ is not None or self.recursive is not None or self.tasks is not None or self.waiters is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->clauses != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->facts != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (((PyObject *)__pyx_v_self->is_done) != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->literal) != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->on_completion_ != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->recursive) != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->tasks != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->waiters != ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.clauses is not None or self.facts is not None or self.is_done is not None or self.literal is not None or self.on_completion_ is not None or self.recursive is not None or self.tasks is not None or self.waiters is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.clauses is not None or self.facts is not None or self.is_done is not None or self.literal is not None or self.on_completion_ is not None or self.recursive is not None or self.tasks is not None or self.waiters is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Subgoal); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_25690925);
    __Pyx_GIVEREF(__pyx_int_25690925);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_25690925);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.clauses is not None or self.facts is not None or self.is_done is not None or self.literal is not None or self.on_completion_ is not None or self.recursive is not None or self.tasks is not None or self.waiters is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, None), state
 *     else:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Subgoal__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Subgoal); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_25690925);
    __Pyx_GIVEREF(__pyx_int_25690925);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_25690925);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Subgoal__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_31__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_31__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_31__setstate_cython__, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_31__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_7Subgoal_30__setstate_cython__(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_7Subgoal_30__setstate_cython__(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Subgoal__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Subgoal__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Subgoal__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pyDatalog.pyEngine.Subgoal.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1078
 * ON_COMPLETION = Subgoal.on_completion
 * 
 * def show(task):             # <<<<<<<<<<<<<<
 *     if task == (None, None):
 *         return
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_16show(PyObject *__pyx_self, PyObject *__pyx_v_task); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_16show = {"show", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_16show, METH_O, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_16show(PyObject *__pyx_self, PyObject *__pyx_v_task) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("show (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_15show(__pyx_self, ((PyObject *)__pyx_v_task));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_15show(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_task) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("show", 0);

  /* "pyDatalog/pyEngine.py":1079
 * 
 * def show(task):
 *     if task == (None, None):             # <<<<<<<<<<<<<<
 *         return
 *     result = {SEARCHING: "Searching",
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_task, __pyx_tuple__30, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1079, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1079, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "pyDatalog/pyEngine.py":1080
 * def show(task):
 *     if task == (None, None):
 *         return             # <<<<<<<<<<<<<<
 *     result = {SEARCHING: "Searching",
 *               SEARCH: "Search",
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "pyDatalog/pyEngine.py":1079
 * 
 * def show(task):
 *     if task == (None, None):             # <<<<<<<<<<<<<<
 *         return
 *     result = {SEARCHING: "Searching",
 */
  }

  /* "pyDatalog/pyEngine.py":1081
 *     if task == (None, None):
 *         return
 *     result = {SEARCHING: "Searching",             # <<<<<<<<<<<<<<
 *               SEARCH: "Search",
 *               ADD_CLAUSE: "Add clause",
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SEARCHING); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_s_Searching) < 0) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1082
 *         return
 *     result = {SEARCHING: "Searching",
 *               SEARCH: "Search",             # <<<<<<<<<<<<<<
 *               ADD_CLAUSE: "Add clause",
 *               NEXT_CLAUSE: "Next clause",
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SEARCH); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1082, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_n_s_Search) < 0) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1083
 *     result = {SEARCHING: "Searching",
 *               SEARCH: "Search",
 *               ADD_CLAUSE: "Add clause",             # <<<<<<<<<<<<<<
 *               NEXT_CLAUSE: "Next clause",
 *               ON_COMPLETION: "On completion"}
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ADD_CLAUSE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_kp_s_Add_clause) < 0) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1084
 *               SEARCH: "Search",
 *               ADD_CLAUSE: "Add clause",
 *               NEXT_CLAUSE: "Next clause",             # <<<<<<<<<<<<<<
 *               ON_COMPLETION: "On completion"}
 *     result = "{:40s}.. : ".format(str(task[1][0])[:40]) + result[task[0]] + " " + str(task[1][1:])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_NEXT_CLAUSE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_kp_s_Next_clause) < 0) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1085
 *               ADD_CLAUSE: "Add clause",
 *               NEXT_CLAUSE: "Next clause",
 *               ON_COMPLETION: "On completion"}             # <<<<<<<<<<<<<<
 *     result = "{:40s}.. : ".format(str(task[1][0])[:40]) + result[task[0]] + " " + str(task[1][1:])
 *     return result if len(result)<110 else result[:110]
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ON_COMPLETION); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_kp_s_On_completion_2) < 0) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1086
 *               NEXT_CLAUSE: "Next clause",
 *               ON_COMPLETION: "On completion"}
 *     result = "{:40s}.. : ".format(str(task[1][0])[:40]) + result[task[0]] + " " + str(task[1][1:])             # <<<<<<<<<<<<<<
 *     return result if len(result)<110 else result[:110]
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_40s, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_4, 0, 40, NULL, NULL, &__pyx_slice__31, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_task, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_result, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_kp_s__29); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_task, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_3, 1, 0, NULL, NULL, &__pyx_slice__20, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1087
 *               ON_COMPLETION: "On completion"}
 *     result = "{:40s}.. : ".format(str(task[1][0])[:40]) + result[task[0]] + " " + str(task[1][1:])
 *     return result if len(result)<110 else result[:110]             # <<<<<<<<<<<<<<
 * 
 * # PRIMITIVES   ##################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = PyObject_Length(__pyx_v_result); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1087, __pyx_L1_error)
  if (((__pyx_t_6 < 0x6E) != 0)) {
    __Pyx_INCREF(__pyx_v_result);
    __pyx_t_1 = __pyx_v_result;
  } else {
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_result, 0, 0x6E, NULL, NULL, &__pyx_slice__32, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1087, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1078
 * ON_COMPLETION = Subgoal.on_completion
 * 
 * def show(task):             # <<<<<<<<<<<<<<
 *     if task == (None, None):
 *         return
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.show", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1116
 * """
 * 
 * def equals_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_18equals_primitive(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_18equals_primitive = {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_18equals_primitive, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_18equals_primitive(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_literal = 0;
  PyObject *__pyx_v_subgoal = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("equals_primitive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_literal,&__pyx_n_s_subgoal,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_literal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subgoal)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, 1); __PYX_ERR(0, 1116, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "equals_primitive") < 0)) __PYX_ERR(0, 1116, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_literal = values[0];
    __pyx_v_subgoal = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("equals_primitive", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1116, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_17equals_primitive(__pyx_self, __pyx_v_literal, __pyx_v_subgoal);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_17equals_primitive(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_literal, PyObject *__pyx_v_subgoal) {
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_env = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("equals_primitive", 0);

  /* "pyDatalog/pyEngine.py":1117
 * 
 * def equals_primitive(literal, subgoal):
 *     x = literal.terms[0]             # <<<<<<<<<<<<<<
 *     y = literal.terms[1]
 *     env = x.unify(y, {})# Both terms must unify,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_x = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1118
 * def equals_primitive(literal, subgoal):
 *     x = literal.terms[0]
 *     y = literal.terms[1]             # <<<<<<<<<<<<<<
 *     env = x.unify(y, {})# Both terms must unify,
 *     if env != None:                     # and at least one of them
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_y = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1119
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 *     env = x.unify(y, {})# Both terms must unify,             # <<<<<<<<<<<<<<
 *     if env != None:                     # and at least one of them
 *         x = x.subst(env)          # must be a constant.
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_unify); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_y, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_y, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_y);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_env = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1120
 *     y = literal.terms[1]
 *     env = x.unify(y, {})# Both terms must unify,
 *     if env != None:                     # and at least one of them             # <<<<<<<<<<<<<<
 *         x = x.subst(env)          # must be a constant.
 *         y = y.subst(env)
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_env, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1120, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1120, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "pyDatalog/pyEngine.py":1121
 *     env = x.unify(y, {})# Both terms must unify,
 *     if env != None:                     # and at least one of them
 *         x = x.subst(env)          # must be a constant.             # <<<<<<<<<<<<<<
 *         y = y.subst(env)
 *     #unbound: can't raise error if both are still unbound, because split(a,b,c) would fail (see test.py)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_subst); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":1122
 *     if env != None:                     # and at least one of them
 *         x = x.subst(env)          # must be a constant.
 *         y = y.subst(env)             # <<<<<<<<<<<<<<
 *     #unbound: can't raise error if both are still unbound, because split(a,b,c) would fail (see test.py)
 *     return x.equals_primitive(y, subgoal)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_subst); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_v_env) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_env);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pyDatalog/pyEngine.py":1120
 *     y = literal.terms[1]
 *     env = x.unify(y, {})# Both terms must unify,
 *     if env != None:                     # and at least one of them             # <<<<<<<<<<<<<<
 *         x = x.subst(env)          # must be a constant.
 *         y = y.subst(env)
 */
  }

  /* "pyDatalog/pyEngine.py":1124
 *         y = y.subst(env)
 *     #unbound: can't raise error if both are still unbound, because split(a,b,c) would fail (see test.py)
 *     return x.equals_primitive(y, subgoal)             # <<<<<<<<<<<<<<
 * 
 * def compare_primitive(literal, subgoal):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_equals_primitive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_y, __pyx_v_subgoal};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_y, __pyx_v_subgoal};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_y);
    __Pyx_INCREF(__pyx_v_subgoal);
    __Pyx_GIVEREF(__pyx_v_subgoal);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_subgoal);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1116
 * """
 * 
 * def equals_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.equals_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_env);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1126
 *     return x.equals_primitive(y, subgoal)
 * 
 * def compare_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_20compare_primitive(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_20compare_primitive = {"compare_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_20compare_primitive, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_20compare_primitive(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_literal = 0;
  PyObject *__pyx_v_subgoal = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compare_primitive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_literal,&__pyx_n_s_subgoal,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_literal)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subgoal)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compare_primitive", 1, 2, 2, 1); __PYX_ERR(0, 1126, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compare_primitive") < 0)) __PYX_ERR(0, 1126, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_literal = values[0];
    __pyx_v_subgoal = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compare_primitive", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1126, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.compare_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_19compare_primitive(__pyx_self, __pyx_v_literal, __pyx_v_subgoal);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_19compare_primitive(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_literal, PyObject *__pyx_v_subgoal) {
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("compare_primitive", 0);
  __Pyx_INCREF(__pyx_v_literal);

  /* "pyDatalog/pyEngine.py":1127
 * 
 * def compare_primitive(literal, subgoal):
 *     x = literal.terms[0]             # <<<<<<<<<<<<<<
 *     y = literal.terms[1]
 *     if not x.is_const():
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_x = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1128
 * def compare_primitive(literal, subgoal):
 *     x = literal.terms[0]
 *     y = literal.terms[1]             # <<<<<<<<<<<<<<
 *     if not x.is_const():
 *         if literal.pred.name == '_pyD_in':
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_terms); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_y = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1129
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 *     if not x.is_const():             # <<<<<<<<<<<<<<
 *         if literal.pred.name == '_pyD_in':
 *             if not y.is_const:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1129, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((!__pyx_t_4) != 0);
  if (__pyx_t_5) {

    /* "pyDatalog/pyEngine.py":1130
 *     y = literal.terms[1]
 *     if not x.is_const():
 *         if literal.pred.name == '_pyD_in':             # <<<<<<<<<<<<<<
 *             if not y.is_const:
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_pyD_in, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1130, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(__pyx_t_5)) {

      /* "pyDatalog/pyEngine.py":1131
 *     if not x.is_const():
 *         if literal.pred.name == '_pyD_in':
 *             if not y.is_const:             # <<<<<<<<<<<<<<
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 *             for v in y.id:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1131, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = ((!__pyx_t_5) != 0);
      if (unlikely(__pyx_t_4)) {

        /* "pyDatalog/pyEngine.py":1132
 *         if literal.pred.name == '_pyD_in':
 *             if not y.is_const:
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)             # <<<<<<<<<<<<<<
 *             for v in y.id:
 *                 literal = Literal(literal.pred.name, [Term_of(v), y])
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DatalogError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Error_right_hand_side_must_be_bo, __pyx_v_literal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1132, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, Py_None, Py_None};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1132, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, Py_None, Py_None};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1132, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1132, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          if (__pyx_t_6) {
            __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, Py_None);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, Py_None);
          __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1132, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_ERR(0, 1132, __pyx_L1_error)

        /* "pyDatalog/pyEngine.py":1131
 *     if not x.is_const():
 *         if literal.pred.name == '_pyD_in':
 *             if not y.is_const:             # <<<<<<<<<<<<<<
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 *             for v in y.id:
 */
      }

      /* "pyDatalog/pyEngine.py":1133
 *             if not y.is_const:
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 *             for v in y.id:             # <<<<<<<<<<<<<<
 *                 literal = Literal(literal.pred.name, [Term_of(v), y])
 *                 subgoal.fact(literal)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
        __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
      } else {
        __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1133, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      for (;;) {
        if (likely(!__pyx_t_10)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1133, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          } else {
            if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1133, __pyx_L1_error)
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1133, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          }
        } else {
          __pyx_t_2 = __pyx_t_10(__pyx_t_3);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 1133, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "pyDatalog/pyEngine.py":1134
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 *             for v in y.id:
 *                 literal = Literal(literal.pred.name, [Term_of(v), y])             # <<<<<<<<<<<<<<
 *                 subgoal.fact(literal)
 *         else:
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Term_of); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_v_v) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_v);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_2);
        PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
        __Pyx_INCREF(__pyx_v_y);
        __Pyx_GIVEREF(__pyx_v_y);
        PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_y);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
        __pyx_t_8 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF_SET(__pyx_v_literal, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":1135
 *             for v in y.id:
 *                 literal = Literal(literal.pred.name, [Term_of(v), y])
 *                 subgoal.fact(literal)             # <<<<<<<<<<<<<<
 *         else:
 *             raise util.DatalogError("Error: left hand side of comparison must be bound: %s"
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_fact); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_v_literal) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_literal);
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "pyDatalog/pyEngine.py":1133
 *             if not y.is_const:
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 *             for v in y.id:             # <<<<<<<<<<<<<<
 *                 literal = Literal(literal.pred.name, [Term_of(v), y])
 *                 subgoal.fact(literal)
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":1130
 *     y = literal.terms[1]
 *     if not x.is_const():
 *         if literal.pred.name == '_pyD_in':             # <<<<<<<<<<<<<<
 *             if not y.is_const:
 *                 raise util.DatalogError("Error: right hand side must be bound: %s" % literal, None, None)
 */
      goto __pyx_L4;
    }

    /* "pyDatalog/pyEngine.py":1137
 *                 subgoal.fact(literal)
 *         else:
 *             raise util.DatalogError("Error: left hand side of comparison must be bound: %s"             # <<<<<<<<<<<<<<
 *                                     % literal.pred.id, None, None)
 *     elif y.is_const():
 */
    /*else*/ {
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DatalogError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1137, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "pyDatalog/pyEngine.py":1138
 *         else:
 *             raise util.DatalogError("Error: left hand side of comparison must be bound: %s"
 *                                     % literal.pred.id, None, None)             # <<<<<<<<<<<<<<
 *     elif y.is_const():
 *         if compare(x.id, literal.pred.name, y.id):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Error_left_hand_side_of_comparis, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, Py_None, Py_None};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1137, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_1, Py_None, Py_None};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1137, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_1);
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, Py_None);
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, Py_None);
        __pyx_t_1 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 1137, __pyx_L1_error)
    }
    __pyx_L4:;

    /* "pyDatalog/pyEngine.py":1129
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 *     if not x.is_const():             # <<<<<<<<<<<<<<
 *         if literal.pred.name == '_pyD_in':
 *             if not y.is_const:
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":1139
 *             raise util.DatalogError("Error: left hand side of comparison must be bound: %s"
 *                                     % literal.pred.id, None, None)
 *     elif y.is_const():             # <<<<<<<<<<<<<<
 *         if compare(x.id, literal.pred.name, y.id):
 *             subgoal.fact(True)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_is_const); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1139, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(__pyx_t_4)) {

    /* "pyDatalog/pyEngine.py":1140
 *                                     % literal.pred.id, None, None)
 *     elif y.is_const():
 *         if compare(x.id, literal.pred.name, y.id):             # <<<<<<<<<<<<<<
 *             subgoal.fact(True)
 *     else:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compare); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_6, __pyx_t_8, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1140, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_6, __pyx_t_8, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1140, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_7, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_7, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_7, __pyx_t_1);
      __pyx_t_6 = 0;
      __pyx_t_8 = 0;
      __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1140, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {

      /* "pyDatalog/pyEngine.py":1141
 *     elif y.is_const():
 *         if compare(x.id, literal.pred.name, y.id):
 *             subgoal.fact(True)             # <<<<<<<<<<<<<<
 *     else:
 *         raise util.DatalogError("Error: right hand side of comparison must be bound: %s"
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_subgoal, __pyx_n_s_fact); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_3 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_12, Py_True) : __Pyx_PyObject_CallOneArg(__pyx_t_2, Py_True);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1141, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "pyDatalog/pyEngine.py":1140
 *                                     % literal.pred.id, None, None)
 *     elif y.is_const():
 *         if compare(x.id, literal.pred.name, y.id):             # <<<<<<<<<<<<<<
 *             subgoal.fact(True)
 *     else:
 */
    }

    /* "pyDatalog/pyEngine.py":1139
 *             raise util.DatalogError("Error: left hand side of comparison must be bound: %s"
 *                                     % literal.pred.id, None, None)
 *     elif y.is_const():             # <<<<<<<<<<<<<<
 *         if compare(x.id, literal.pred.name, y.id):
 *             subgoal.fact(True)
 */
    goto __pyx_L3;
  }

  /* "pyDatalog/pyEngine.py":1143
 *             subgoal.fact(True)
 *     else:
 *         raise util.DatalogError("Error: right hand side of comparison must be bound: %s"             # <<<<<<<<<<<<<<
 *                                 % literal.pred.id, None, None)
 * 
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DatalogError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pyDatalog/pyEngine.py":1144
 *     else:
 *         raise util.DatalogError("Error: right hand side of comparison must be bound: %s"
 *                                 % literal.pred.id, None, None)             # <<<<<<<<<<<<<<
 * 
 * # generic comparison function
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_literal, __pyx_n_s_pred); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Error_right_hand_side_of_compari, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_2, Py_None, Py_None};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1143, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_2, Py_None, Py_None};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1143, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_2);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, Py_None);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, Py_None);
      __pyx_t_2 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 1143, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "pyDatalog/pyEngine.py":1126
 *     return x.equals_primitive(y, subgoal)
 * 
 * def compare_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("pyDatalog.pyEngine.compare_primitive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_literal);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1147
 * 
 * # generic comparison function
 * def compare(l,op,r):             # <<<<<<<<<<<<<<
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_22compare(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_22compare = {"compare", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_22compare, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_22compare(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_l = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_r = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compare (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_l,&__pyx_n_s_op,&__pyx_n_s_r,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_l)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compare", 1, 3, 3, 1); __PYX_ERR(0, 1147, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compare", 1, 3, 3, 2); __PYX_ERR(0, 1147, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compare") < 0)) __PYX_ERR(0, 1147, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_l = values[0];
    __pyx_v_op = values[1];
    __pyx_v_r = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compare", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1147, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.compare", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_21compare(__pyx_self, __pyx_v_l, __pyx_v_op, __pyx_v_r);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_21compare(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_l, PyObject *__pyx_v_op, PyObject *__pyx_v_r) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("compare", 0);

  /* "pyDatalog/pyEngine.py":1148
 * # generic comparison function
 * def compare(l,op,r):
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \             # <<<<<<<<<<<<<<
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 * def compare2(l,op,r):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_pyD_in, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
  if (__pyx_t_2) {
    __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_l, __pyx_v_r, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_pyD_not_in, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
    if (__pyx_t_3) {
      __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_l, __pyx_v_r, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1148, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __pyx_t_6;
      __pyx_t_6 = 0;
    } else {
      __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_kp_s_, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
      if (__pyx_t_5) {
        __pyx_t_7 = PyObject_RichCompare(__pyx_v_l, __pyx_v_r, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1148, __pyx_L1_error)
        __pyx_t_6 = __pyx_t_7;
        __pyx_t_7 = 0;
      } else {
        __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_kp_s__33, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
        if (__pyx_t_8) {
          __pyx_t_9 = PyObject_RichCompare(__pyx_v_l, __pyx_v_r, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1148, __pyx_L1_error)
          __pyx_t_7 = __pyx_t_9;
          __pyx_t_9 = 0;
        } else {
          __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_kp_s__34, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1148, __pyx_L1_error)
          if (__pyx_t_10) {
            __pyx_t_11 = PyObject_RichCompare(__pyx_v_l, __pyx_v_r, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1148, __pyx_L1_error)
            __pyx_t_9 = __pyx_t_11;
            __pyx_t_11 = 0;
          } else {

            /* "pyDatalog/pyEngine.py":1149
 * def compare(l,op,r):
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None             # <<<<<<<<<<<<<<
 * def compare2(l,op,r):
 *     return l._in(r) if op=='_pyD_in' else l._not_in(r) if op=='_pyD_not_in' else compare(l,op,r)
 */
            __pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_kp_s__35, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 1149, __pyx_L1_error)
            if (__pyx_t_12) {
              __pyx_t_13 = PyObject_RichCompare(__pyx_v_l, __pyx_v_r, Py_LE); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1149, __pyx_L1_error)
              __pyx_t_11 = __pyx_t_13;
              __pyx_t_13 = 0;
            } else {
              __pyx_t_14 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_kp_s__36, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 1149, __pyx_L1_error)
              if (__pyx_t_14) {
                __pyx_t_15 = PyObject_RichCompare(__pyx_v_l, __pyx_v_r, Py_GE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1149, __pyx_L1_error)
                __pyx_t_13 = __pyx_t_15;
                __pyx_t_15 = 0;
              } else {
                __pyx_t_16 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_kp_s__37, Py_EQ)); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 1149, __pyx_L1_error)
                if (__pyx_t_16) {
                  __pyx_t_17 = PyObject_RichCompare(__pyx_v_l, __pyx_v_r, Py_GT); __Pyx_XGOTREF(__pyx_t_17); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1149, __pyx_L1_error)
                  __pyx_t_15 = __pyx_t_17;
                  __pyx_t_17 = 0;
                } else {
                  __Pyx_INCREF(Py_None);
                  __pyx_t_15 = Py_None;
                }
                __pyx_t_13 = __pyx_t_15;
                __pyx_t_15 = 0;
              }
              __pyx_t_11 = __pyx_t_13;
              __pyx_t_13 = 0;
            }
            __pyx_t_9 = __pyx_t_11;
            __pyx_t_11 = 0;
          }
          __pyx_t_7 = __pyx_t_9;
          __pyx_t_9 = 0;
        }
        __pyx_t_6 = __pyx_t_7;
        __pyx_t_7 = 0;
      }
      __pyx_t_4 = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1147
 * 
 * # generic comparison function
 * def compare(l,op,r):             # <<<<<<<<<<<<<<
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("pyDatalog.pyEngine.compare", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1150
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 * def compare2(l,op,r):             # <<<<<<<<<<<<<<
 *     return l._in(r) if op=='_pyD_in' else l._not_in(r) if op=='_pyD_not_in' else compare(l,op,r)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_24compare2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_24compare2 = {"compare2", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_24compare2, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_24compare2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_l = 0;
  PyObject *__pyx_v_op = 0;
  PyObject *__pyx_v_r = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compare2 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_l,&__pyx_n_s_op,&__pyx_n_s_r,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_l)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compare2", 1, 3, 3, 1); __PYX_ERR(0, 1150, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("compare2", 1, 3, 3, 2); __PYX_ERR(0, 1150, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compare2") < 0)) __PYX_ERR(0, 1150, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_l = values[0];
    __pyx_v_op = values[1];
    __pyx_v_r = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compare2", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1150, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.compare2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_23compare2(__pyx_self, __pyx_v_l, __pyx_v_op, __pyx_v_r);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_23compare2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_l, PyObject *__pyx_v_op, PyObject *__pyx_v_r) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("compare2", 0);

  /* "pyDatalog/pyEngine.py":1151
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 * def compare2(l,op,r):
 *     return l._in(r) if op=='_pyD_in' else l._not_in(r) if op=='_pyD_not_in' else compare(l,op,r)             # <<<<<<<<<<<<<<
 * 
 * # Initialization   ##################################################
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_pyD_in, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1151, __pyx_L1_error)
  if (__pyx_t_2) {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_l, __pyx_n_s_in); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_r) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_r);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_v_op, __pyx_n_s_pyD_not_in, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1151, __pyx_L1_error)
    if (__pyx_t_6) {
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_l, __pyx_n_s_not_in); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_v_r) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_r);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_compare); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1151, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_8 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_l, __pyx_v_op, __pyx_v_r};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1151, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_l, __pyx_v_op, __pyx_v_r};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1151, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(__pyx_v_l);
        __Pyx_GIVEREF(__pyx_v_l);
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_l);
        __Pyx_INCREF(__pyx_v_op);
        __Pyx_GIVEREF(__pyx_v_op);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_op);
        __Pyx_INCREF(__pyx_v_r);
        __Pyx_GIVEREF(__pyx_v_r);
        PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_v_r);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pyDatalog/pyEngine.py":1150
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 * def compare2(l,op,r):             # <<<<<<<<<<<<<<
 *     return l._in(r) if op=='_pyD_in' else l._not_in(r) if op=='_pyD_not_in' else compare(l,op,r)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pyDatalog.pyEngine.compare2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pyDatalog/pyEngine.py":1155
 * # Initialization   ##################################################
 * 
 * def clear():             # <<<<<<<<<<<<<<
 *     """ clears the logic """
 *     Logic.tl.logic.Db = {}
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_26clear(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_9pyDatalog_8pyEngine_25clear[] = " clears the logic ";
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_26clear = {"clear", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_26clear, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_25clear};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_26clear(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_25clear(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_25clear(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clear", 0);

  /* "pyDatalog/pyEngine.py":1157
 * def clear():
 *     """ clears the logic """
 *     Logic.tl.logic.Db = {}             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Pred_registry = weakref.WeakValueDictionary()
 *     Logic.tl.logic.Subgoals = {}
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Db, __pyx_t_1) < 0) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1158
 *     """ clears the logic """
 *     Logic.tl.logic.Db = {}
 *     Logic.tl.logic.Pred_registry = weakref.WeakValueDictionary()             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Subgoals = {}
 *     Logic.tl.logic.Tasks = None
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_weakref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_WeakValueDictionary); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_logic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_Pred_registry, __pyx_t_2) < 0) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1159
 *     Logic.tl.logic.Db = {}
 *     Logic.tl.logic.Pred_registry = weakref.WeakValueDictionary()
 *     Logic.tl.logic.Subgoals = {}             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Tasks = None
 *     Logic.tl.logic.Recursive_Tasks = None
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Subgoals, __pyx_t_3) < 0) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1160
 *     Logic.tl.logic.Pred_registry = weakref.WeakValueDictionary()
 *     Logic.tl.logic.Subgoals = {}
 *     Logic.tl.logic.Tasks = None             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Recursive_Tasks = None
 *     Logic.tl.logic.Recursive = False
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Tasks, Py_None) < 0) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1161
 *     Logic.tl.logic.Subgoals = {}
 *     Logic.tl.logic.Tasks = None
 *     Logic.tl.logic.Recursive_Tasks = None             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Recursive = False
 *     Logic.tl.logic.Goal = None
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Recursive_Tasks, Py_None) < 0) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1162
 *     Logic.tl.logic.Tasks = None
 *     Logic.tl.logic.Recursive_Tasks = None
 *     Logic.tl.logic.Recursive = False             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Goal = None
 *     Logic.tl.logic.gc_uncollected = False
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Recursive, Py_False) < 0) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1163
 *     Logic.tl.logic.Recursive_Tasks = None
 *     Logic.tl.logic.Recursive = False
 *     Logic.tl.logic.Goal = None             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.gc_uncollected = False
 *     Fresh_var.tl.counter = 0
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_Goal, Py_None) < 0) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1164
 *     Logic.tl.logic.Recursive = False
 *     Logic.tl.logic.Goal = None
 *     Logic.tl.logic.gc_uncollected = False             # <<<<<<<<<<<<<<
 *     Fresh_var.tl.counter = 0
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_gc_uncollected, Py_False) < 0) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1165
 *     Logic.tl.logic.Goal = None
 *     Logic.tl.logic.gc_uncollected = False
 *     Fresh_var.tl.counter = 0             # <<<<<<<<<<<<<<
 * 
 *     insert(Pred("==", 2)).prim = equals_primitive
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var), __pyx_n_s_tl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_counter, __pyx_int_0) < 0) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1167
 *     Fresh_var.tl.counter = 0
 * 
 *     insert(Pred("==", 2)).prim = equals_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("<" , 2)).prim = compare_primitive
 *     insert(Pred("<=", 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_equals_primitive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Pred); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_prim, __pyx_t_2) < 0) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1168
 * 
 *     insert(Pred("==", 2)).prim = equals_primitive
 *     insert(Pred("<" , 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("<=", 2)).prim = compare_primitive
 *     insert(Pred("!=", 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Pred); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_prim, __pyx_t_3) < 0) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1169
 *     insert(Pred("==", 2)).prim = equals_primitive
 *     insert(Pred("<" , 2)).prim = compare_primitive
 *     insert(Pred("<=", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("!=", 2)).prim = compare_primitive
 *     insert(Pred(">=", 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Pred); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_prim, __pyx_t_2) < 0) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1170
 *     insert(Pred("<" , 2)).prim = compare_primitive
 *     insert(Pred("<=", 2)).prim = compare_primitive
 *     insert(Pred("!=", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred(">=", 2)).prim = compare_primitive
 *     insert(Pred(">" , 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Pred); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_prim, __pyx_t_3) < 0) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1171
 *     insert(Pred("<=", 2)).prim = compare_primitive
 *     insert(Pred("!=", 2)).prim = compare_primitive
 *     insert(Pred(">=", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred(">" , 2)).prim = compare_primitive
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Pred); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_prim, __pyx_t_2) < 0) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1172
 *     insert(Pred("!=", 2)).prim = compare_primitive
 *     insert(Pred(">=", 2)).prim = compare_primitive
 *     insert(Pred(">" , 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive
 *     insert(Pred("_pyD_not_in", 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Pred); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_prim, __pyx_t_3) < 0) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1173
 *     insert(Pred(">=", 2)).prim = compare_primitive
 *     insert(Pred(">" , 2)).prim = compare_primitive
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("_pyD_not_in", 2)).prim = compare_primitive
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Pred); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_n_s_prim, __pyx_t_2) < 0) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":1174
 *     insert(Pred(">" , 2)).prim = compare_primitive
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive
 *     insert(Pred("_pyD_not_in", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_compare_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Pred); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_prim, __pyx_t_3) < 0) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":1155
 * # Initialization   ##################################################
 * 
 * def clear():             # <<<<<<<<<<<<<<
 *     """ clears the logic """
 *     Logic.tl.logic.Db = {}
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pyDatalog.pyEngine.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Term(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_28__pyx_unpickle_Term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_28__pyx_unpickle_Term = {"__pyx_unpickle_Term", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_28__pyx_unpickle_Term, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_28__pyx_unpickle_Term(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Term (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Term", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Term", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Term") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Term", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Term", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_27__pyx_unpickle_Term(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_27__pyx_unpickle_Term(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Term", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__46, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Term.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Term.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Term.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Term), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Term.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Term.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Term__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Term.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Term(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Term", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Term__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Term *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Term__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->id);
  __Pyx_DECREF(__pyx_v___pyx_result->id);
  __pyx_v___pyx_result->id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Term__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Fresh_var(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_30__pyx_unpickle_Fresh_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_30__pyx_unpickle_Fresh_var = {"__pyx_unpickle_Fresh_var", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_30__pyx_unpickle_Fresh_var, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_30__pyx_unpickle_Fresh_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Fresh_var (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Fresh_var", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Fresh_var", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Fresh_var") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Fresh_var", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Fresh_var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_29__pyx_unpickle_Fresh_var(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_29__pyx_unpickle_Fresh_var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Fresh_var", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__46, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Fresh_var.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Fresh_var.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Fresh_var.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Fresh_var.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Fresh_var.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Fresh_var__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Fresh_var.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Fresh_var(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Fresh_var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Fresh_var__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Fresh_var__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.id);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.id);
  __pyx_v___pyx_result->__pyx_base.id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Fresh_var__set_state(<Fresh_var> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Fresh_var__set_state(Fresh_var __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Fresh_var__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Var(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_32__pyx_unpickle_Var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_32__pyx_unpickle_Var = {"__pyx_unpickle_Var", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_32__pyx_unpickle_Var, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_32__pyx_unpickle_Var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Var (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Var", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Var", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Var") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Var", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_31__pyx_unpickle_Var(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_31__pyx_unpickle_Var(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Var", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__46, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Var.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Var.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Var.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Var), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Var.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Var.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Var__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Var.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Var(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Var", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Var__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Var *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Var__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.id);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.id);
  __pyx_v___pyx_result->__pyx_base.__pyx_base.id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Var__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Const(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_34__pyx_unpickle_Const(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_34__pyx_unpickle_Const = {"__pyx_unpickle_Const", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_34__pyx_unpickle_Const, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_34__pyx_unpickle_Const(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Const (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Const", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Const", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Const") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Const", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_33__pyx_unpickle_Const(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_33__pyx_unpickle_Const(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Const", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__46, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Const.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Const.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Const.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Const.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Const.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Const__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 *     __pyx_result = Const.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Const(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Const", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Const__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Const *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Const__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.id);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.id);
  __pyx_v___pyx_result->__pyx_base.id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Const__set_state(<Const> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Const__set_state(Const __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Const__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_VarTuple(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_36__pyx_unpickle_VarTuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_36__pyx_unpickle_VarTuple = {"__pyx_unpickle_VarTuple", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_36__pyx_unpickle_VarTuple, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_36__pyx_unpickle_VarTuple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_VarTuple (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VarTuple", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VarTuple", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_VarTuple") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_VarTuple", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_VarTuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_35__pyx_unpickle_VarTuple(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_35__pyx_unpickle_VarTuple(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VarTuple", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x99e0025, 0xda0c310, 0x32a51af):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__47, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x99e0025, 0xda0c310, 0x32a51af):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)
 *     __pyx_result = VarTuple.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0x99e0025, 0xda0c310, 0x32a51af):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = VarTuple.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x99e0025, 0xda0c310, 0x32a51af):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)
 *     __pyx_result = VarTuple.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)
 *     __pyx_result = VarTuple.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = VarTuple.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_VarTuple__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x99e0025, 0xda0c310, 0x32a51af) = (_id, id, is_constant))" % __pyx_checksum)
 *     __pyx_result = VarTuple.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VarTuple(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_VarTuple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_VarTuple__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_VarTuple__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_id);
  __Pyx_DECREF(__pyx_v___pyx_result->_id);
  __pyx_v___pyx_result->_id = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.id);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.id);
  __pyx_v___pyx_result->__pyx_base.id = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->is_constant);
  __Pyx_DECREF(__pyx_v___pyx_result->is_constant);
  __pyx_v___pyx_result->is_constant = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 3) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_VarTuple__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Operation(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_38__pyx_unpickle_Operation(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_38__pyx_unpickle_Operation = {"__pyx_unpickle_Operation", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_38__pyx_unpickle_Operation, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_38__pyx_unpickle_Operation(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Operation (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Operation", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Operation", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Operation") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Operation", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Operation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_37__pyx_unpickle_Operation(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_37__pyx_unpickle_Operation(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Operation", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x8e89c3d, 0x16b0d8c, 0x2be5ff8):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__48, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x8e89c3d, 0x16b0d8c, 0x2be5ff8):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)
 *     __pyx_result = Operation.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0x8e89c3d, 0x16b0d8c, 0x2be5ff8):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Operation.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x8e89c3d, 0x16b0d8c, 0x2be5ff8):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)
 *     __pyx_result = Operation.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)
 *     __pyx_result = Operation.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Operation.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Operation__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e89c3d, 0x16b0d8c, 0x2be5ff8) = (id, is_constant, lhs, operator, operator_id, rhs))" % __pyx_checksum)
 *     __pyx_result = Operation.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Operation(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Operation", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Operation__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Operation__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.id);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.id);
  __pyx_v___pyx_result->__pyx_base.id = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->is_constant);
  __Pyx_DECREF(__pyx_v___pyx_result->is_constant);
  __pyx_v___pyx_result->is_constant = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->lhs);
  __Pyx_DECREF(__pyx_v___pyx_result->lhs);
  __pyx_v___pyx_result->lhs = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->operator);
  __Pyx_DECREF(__pyx_v___pyx_result->operator);
  __pyx_v___pyx_result->operator = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->operator_id);
  __Pyx_DECREF(__pyx_v___pyx_result->operator_id);
  __pyx_v___pyx_result->operator_id = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->rhs);
  __Pyx_DECREF(__pyx_v___pyx_result->rhs);
  __pyx_v___pyx_result->rhs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 6) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[6])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[6])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Operation__set_state(<Operation> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Operation__set_state(Operation __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]; __pyx_result.is_constant = __pyx_state[1]; __pyx_result.lhs = __pyx_state[2]; __pyx_result.operator = __pyx_state[3]; __pyx_result.operator_id = __pyx_state[4]; __pyx_result.rhs = __pyx_state[5]
 *     if len(__pyx_state) > 6 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Operation__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Literal(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_40__pyx_unpickle_Literal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_40__pyx_unpickle_Literal = {"__pyx_unpickle_Literal", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_40__pyx_unpickle_Literal, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_40__pyx_unpickle_Literal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Literal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Literal", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Literal", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Literal") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Literal", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Literal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_39__pyx_unpickle_Literal(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_39__pyx_unpickle_Literal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Literal", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xe4b4efa, 0x7a684fa, 0x3084755):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__49, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xe4b4efa, 0x7a684fa, 0x3084755):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)
 *     __pyx_result = Literal.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xe4b4efa, 0x7a684fa, 0x3084755):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Literal.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xe4b4efa, 0x7a684fa, 0x3084755):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)
 *     __pyx_result = Literal.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)
 *     __pyx_result = Literal.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Literal.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Literal__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xe4b4efa, 0x7a684fa, 0x3084755) = (aggregate, id, pred, tag, terms))" % __pyx_checksum)
 *     __pyx_result = Literal.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Literal(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Literal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Literal__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Literal__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->aggregate);
  __Pyx_DECREF(__pyx_v___pyx_result->aggregate);
  __pyx_v___pyx_result->aggregate = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->id);
  __Pyx_DECREF(__pyx_v___pyx_result->id);
  __pyx_v___pyx_result->id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pred);
  __Pyx_DECREF(__pyx_v___pyx_result->pred);
  __pyx_v___pyx_result->pred = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->tag);
  __Pyx_DECREF(__pyx_v___pyx_result->tag);
  __pyx_v___pyx_result->tag = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->terms);
  __Pyx_DECREF(__pyx_v___pyx_result->terms);
  __pyx_v___pyx_result->terms = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 5) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[5])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[5])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Literal__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Clause(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_42__pyx_unpickle_Clause(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_42__pyx_unpickle_Clause = {"__pyx_unpickle_Clause", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_42__pyx_unpickle_Clause, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_42__pyx_unpickle_Clause(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Clause (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Clause", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Clause", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Clause") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Clause", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Clause", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_41__pyx_unpickle_Clause(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_41__pyx_unpickle_Clause(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Clause", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__50, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)
 *     __pyx_result = Clause.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Clause.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_5, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)
 *     __pyx_result = Clause.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)
 *     __pyx_result = Clause.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Clause.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Clause__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xd9ddcec, 0xed1f8c9, 0x9d8b5a7) = (body, head, id))" % __pyx_checksum)
 *     __pyx_result = Clause.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Clause(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Clause", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Clause__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Clause *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Clause__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->body);
  __Pyx_DECREF(__pyx_v___pyx_result->body);
  __pyx_v___pyx_result->body = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->head);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->head));
  __pyx_v___pyx_result->head = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->id);
  __Pyx_DECREF(__pyx_v___pyx_result->id);
  __pyx_v___pyx_result->id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 3) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Clause__set_state(<Clause> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Clause__set_state(Clause __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.body = __pyx_state[0]; __pyx_result.head = __pyx_state[1]; __pyx_result.id = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Clause__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Subgoal(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_44__pyx_unpickle_Subgoal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9pyDatalog_8pyEngine_44__pyx_unpickle_Subgoal = {"__pyx_unpickle_Subgoal", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_44__pyx_unpickle_Subgoal, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9pyDatalog_8pyEngine_44__pyx_unpickle_Subgoal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Subgoal (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Subgoal", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Subgoal", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Subgoal") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Subgoal", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Subgoal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9pyDatalog_8pyEngine_43__pyx_unpickle_Subgoal(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9pyDatalog_8pyEngine_43__pyx_unpickle_Subgoal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Subgoal", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x188032d, 0xd25b74b, 0x76438b9):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__51, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x188032d, 0xd25b74b, 0x76438b9):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)
 *     __pyx_result = Subgoal.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0x188032d, 0xd25b74b, 0x76438b9):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Subgoal.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x188032d, 0xd25b74b, 0x76438b9):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)
 *     __pyx_result = Subgoal.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)
 *     __pyx_result = Subgoal.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Subgoal.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Subgoal__set_state(((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x188032d, 0xd25b74b, 0x76438b9) = (clauses, facts, is_done, literal, on_completion_, recursive, tasks, waiters))" % __pyx_checksum)
 *     __pyx_result = Subgoal.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Subgoal(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Subgoal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]
 *     if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_9pyDatalog_8pyEngine___pyx_unpickle_Subgoal__set_state(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Subgoal__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[8])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->clauses);
  __Pyx_DECREF(__pyx_v___pyx_result->clauses);
  __pyx_v___pyx_result->clauses = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->facts);
  __Pyx_DECREF(__pyx_v___pyx_result->facts);
  __pyx_v___pyx_result->facts = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->is_done);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->is_done));
  __pyx_v___pyx_result->is_done = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9pyDatalog_8pyEngine_Literal))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->literal);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->literal));
  __pyx_v___pyx_result->literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->on_completion_);
  __Pyx_DECREF(__pyx_v___pyx_result->on_completion_);
  __pyx_v___pyx_result->on_completion_ = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->recursive);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->recursive));
  __pyx_v___pyx_result->recursive = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->tasks);
  __Pyx_DECREF(__pyx_v___pyx_result->tasks);
  __pyx_v___pyx_result->tasks = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->waiters);
  __Pyx_DECREF(__pyx_v___pyx_result->waiters);
  __pyx_v___pyx_result->waiters = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]
 *     if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[8])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 8) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]
 *     if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[8])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]
 *     if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[8])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Subgoal__set_state(<Subgoal> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Subgoal__set_state(Subgoal __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.clauses = __pyx_state[0]; __pyx_result.facts = __pyx_state[1]; __pyx_result.is_done = __pyx_state[2]; __pyx_result.literal = __pyx_state[3]; __pyx_result.on_completion_ = __pyx_state[4]; __pyx_result.recursive = __pyx_state[5]; __pyx_result.tasks = __pyx_state[6]; __pyx_result.waiters = __pyx_state[7]
 *     if len(__pyx_state) > 8 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pyDatalog.pyEngine.__pyx_unpickle_Subgoal__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Term(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Term *)o);
  p->id = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->id);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine_Term(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *)o;
  if (p->id) {
    e = (*v)(p->id, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine_Term(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine_Term *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *)o;
  tmp = ((PyObject*)p->id);
  p->id = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_4Term_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_4Term_id(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_4Term_2id_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Term[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Term_1__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_4Term_3__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9pyDatalog_8pyEngine_Term[] = {
  {(char *)"id", __pyx_getprop_9pyDatalog_8pyEngine_4Term_id, __pyx_setprop_9pyDatalog_8pyEngine_4Term_id, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Term = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Term", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Term), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Term, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Term, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Term, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9pyDatalog_8pyEngine_Term, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Term, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Fresh_var __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Fresh_var(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *p;
  PyObject *o = __pyx_tp_new_9pyDatalog_8pyEngine_Term(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyDatalog_8pyEngine_Fresh_var;
  return o;
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Fresh_var[] = {
  {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_19equals_primitive, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_9Fresh_var_18equals_primitive},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_21__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_23__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Fresh_var = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Fresh_var", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_17__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " a variable created by the search algorithm ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Term, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Term, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Fresh_var, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_9Fresh_var_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Fresh_var, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Var __pyx_vtable_9pyDatalog_8pyEngine_Var;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Var(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Var *p;
  PyObject *o = __pyx_tp_new_9pyDatalog_8pyEngine_Fresh_var(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Var *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Fresh_var*)__pyx_vtabptr_9pyDatalog_8pyEngine_Var;
  return o;
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Var[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_3Var_7__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_3Var_9__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Var = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Var", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Var), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_3Var_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " A variable in a clause or query ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Term, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Term, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Var, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_3Var_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Var, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Const __pyx_vtable_9pyDatalog_8pyEngine_Const;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Const(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Const *p;
  PyObject *o = __pyx_tp_new_9pyDatalog_8pyEngine_Term(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Const *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyDatalog_8pyEngine_Const;
  return o;
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Const[] = {
  {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_5Const_19equals_primitive, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_21__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_5Const_23__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Const = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Const", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Const), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_5Const_17__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " a constant ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Term, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Term, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Const, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_5Const_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Const, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_VarTuple __pyx_vtable_9pyDatalog_8pyEngine_VarTuple;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_VarTuple(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *p;
  PyObject *o = __pyx_tp_new_9pyDatalog_8pyEngine_Term(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyDatalog_8pyEngine_VarTuple;
  p->_id = Py_None; Py_INCREF(Py_None);
  p->is_constant = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine_VarTuple(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *p = (struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_id);
  Py_CLEAR(p->is_constant);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term(o);
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine_VarTuple(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *p = (struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)o;
  e = __pyx_tp_traverse_9pyDatalog_8pyEngine_Term(o, v, a); if (e) return e;
  if (p->_id) {
    e = (*v)(p->_id, a); if (e) return e;
  }
  if (p->is_constant) {
    e = (*v)(p->is_constant, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine_VarTuple(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *p = (struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *)o;
  __pyx_tp_clear_9pyDatalog_8pyEngine_Term(o);
  tmp = ((PyObject*)p->_id);
  p->_id = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->is_constant);
  p->is_constant = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_8VarTuple__id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_8VarTuple__id(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_3_id_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_8VarTuple_is_constant(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_8VarTuple_is_constant(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_11is_constant_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_VarTuple[] = {
  {"equals_primitive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_19equals_primitive, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_21__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_8VarTuple_23__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9pyDatalog_8pyEngine_VarTuple[] = {
  {(char *)"_id", __pyx_getprop_9pyDatalog_8pyEngine_8VarTuple__id, __pyx_setprop_9pyDatalog_8pyEngine_8VarTuple__id, (char *)0, 0},
  {(char *)"is_constant", __pyx_getprop_9pyDatalog_8pyEngine_8VarTuple_is_constant, __pyx_setprop_9pyDatalog_8pyEngine_8VarTuple_is_constant, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_VarTuple = {
  __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_5__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VarTuple = {
  __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_5__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_VarTuple = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.VarTuple", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_VarTuple, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_VarTuple, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VarTuple, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_17__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " a tuple / list of variables, constants or tuples ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_VarTuple, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_VarTuple, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_VarTuple, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9pyDatalog_8pyEngine_VarTuple, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_8VarTuple_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_VarTuple, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Operation __pyx_vtable_9pyDatalog_8pyEngine_Operation;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Operation(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Operation *p;
  PyObject *o = __pyx_tp_new_9pyDatalog_8pyEngine_Term(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyDatalog_8pyEngine_Operation;
  p->operator = Py_None; Py_INCREF(Py_None);
  p->operator_id = Py_None; Py_INCREF(Py_None);
  p->lhs = Py_None; Py_INCREF(Py_None);
  p->rhs = Py_None; Py_INCREF(Py_None);
  p->is_constant = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine_Operation(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Operation *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->operator);
  Py_CLEAR(p->operator_id);
  Py_CLEAR(p->lhs);
  Py_CLEAR(p->rhs);
  Py_CLEAR(p->is_constant);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Term(o);
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine_Operation(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine_Operation *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)o;
  e = __pyx_tp_traverse_9pyDatalog_8pyEngine_Term(o, v, a); if (e) return e;
  if (p->operator) {
    e = (*v)(p->operator, a); if (e) return e;
  }
  if (p->operator_id) {
    e = (*v)(p->operator_id, a); if (e) return e;
  }
  if (p->lhs) {
    e = (*v)(p->lhs, a); if (e) return e;
  }
  if (p->rhs) {
    e = (*v)(p->rhs, a); if (e) return e;
  }
  if (p->is_constant) {
    e = (*v)(p->is_constant, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine_Operation(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine_Operation *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Operation *)o;
  __pyx_tp_clear_9pyDatalog_8pyEngine_Term(o);
  tmp = ((PyObject*)p->operator);
  p->operator = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->operator_id);
  p->operator_id = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->lhs);
  p->lhs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->rhs);
  p->rhs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->is_constant);
  p->is_constant = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_9Operation_operator(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_9Operation_operator(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_8operator_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_9Operation_operator_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_9Operation_operator_id(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_11operator_id_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_9Operation_lhs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_9Operation_lhs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_3lhs_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_9Operation_rhs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_9Operation_rhs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_3rhs_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_9Operation_is_constant(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_9Operation_is_constant(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_9Operation_11is_constant_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Operation[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_17__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_9Operation_19__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9pyDatalog_8pyEngine_Operation[] = {
  {(char *)"operator", __pyx_getprop_9pyDatalog_8pyEngine_9Operation_operator, __pyx_setprop_9pyDatalog_8pyEngine_9Operation_operator, (char *)0, 0},
  {(char *)"operator_id", __pyx_getprop_9pyDatalog_8pyEngine_9Operation_operator_id, __pyx_setprop_9pyDatalog_8pyEngine_9Operation_operator_id, (char *)0, 0},
  {(char *)"lhs", __pyx_getprop_9pyDatalog_8pyEngine_9Operation_lhs, __pyx_setprop_9pyDatalog_8pyEngine_9Operation_lhs, (char *)0, 0},
  {(char *)"rhs", __pyx_getprop_9pyDatalog_8pyEngine_9Operation_rhs, __pyx_setprop_9pyDatalog_8pyEngine_9Operation_rhs, (char *)0, 0},
  {(char *)"is_constant", __pyx_getprop_9pyDatalog_8pyEngine_9Operation_is_constant, __pyx_setprop_9pyDatalog_8pyEngine_9Operation_is_constant, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Operation = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Operation", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Operation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Operation, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_9Operation_15__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " an arithmetic operation, a slice or a lambda ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Operation, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Operation, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Operation, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9pyDatalog_8pyEngine_Operation, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_9Operation_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Operation, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Literal __pyx_vtable_9pyDatalog_8pyEngine_Literal;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Literal(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyDatalog_8pyEngine_Literal;
  p->terms = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->pred = Py_None; Py_INCREF(Py_None);
  p->id = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->tag = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->aggregate = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine_Literal(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->terms);
  Py_CLEAR(p->pred);
  Py_CLEAR(p->id);
  Py_CLEAR(p->tag);
  Py_CLEAR(p->aggregate);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine_Literal(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)o;
  if (p->terms) {
    e = (*v)(p->terms, a); if (e) return e;
  }
  if (p->pred) {
    e = (*v)(p->pred, a); if (e) return e;
  }
  if (p->id) {
    e = (*v)(p->id, a); if (e) return e;
  }
  if (p->tag) {
    e = (*v)(p->tag, a); if (e) return e;
  }
  if (p->aggregate) {
    e = (*v)(p->aggregate, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine_Literal(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine_Literal *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)o;
  tmp = ((PyObject*)p->terms);
  p->terms = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pred);
  p->pred = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->id);
  p->id = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tag);
  p->tag = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->aggregate);
  p->aggregate = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Literal_terms(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Literal_terms(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_5terms_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Literal_pred(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Literal_pred(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_4pred_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Literal_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Literal_id(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_2id_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Literal_tag(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Literal_tag(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_3tag_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Literal_aggregate(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Literal_aggregate(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Literal_9aggregate_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Literal[] = {
  {"_renamed", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_3_renamed, METH_O, 0},
  {"rebased", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_5rebased, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Literal_4rebased},
  {"equalized", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_7equalized, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_6equalized},
  {"subst_first", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_9subst_first, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Literal_8subst_first},
  {"ask", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_27ask, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Literal_26ask},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_29__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Literal_31__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9pyDatalog_8pyEngine_Literal[] = {
  {(char *)"terms", __pyx_getprop_9pyDatalog_8pyEngine_7Literal_terms, __pyx_setprop_9pyDatalog_8pyEngine_7Literal_terms, (char *)0, 0},
  {(char *)"pred", __pyx_getprop_9pyDatalog_8pyEngine_7Literal_pred, __pyx_setprop_9pyDatalog_8pyEngine_7Literal_pred, (char *)0, 0},
  {(char *)"id", __pyx_getprop_9pyDatalog_8pyEngine_7Literal_id, __pyx_setprop_9pyDatalog_8pyEngine_7Literal_id, (char *)0, 0},
  {(char *)"tag", __pyx_getprop_9pyDatalog_8pyEngine_7Literal_tag, __pyx_setprop_9pyDatalog_8pyEngine_7Literal_tag, (char *)0, 0},
  {(char *)"aggregate", __pyx_getprop_9pyDatalog_8pyEngine_7Literal_aggregate, __pyx_setprop_9pyDatalog_8pyEngine_7Literal_aggregate, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Literal = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Literal", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Literal), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Literal, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_7Literal_11__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " A literal is a predicate and a sequence of terms, \n        the number of which must match the predicate's arity.\n    ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Literal, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Literal, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Literal, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9pyDatalog_8pyEngine_Literal, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_7Literal_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Literal, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Clause(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)o);
  p->head = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)Py_None); Py_INCREF(Py_None);
  p->body = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->id = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine_Clause(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->head);
  Py_CLEAR(p->body);
  Py_CLEAR(p->id);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine_Clause(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)o;
  if (p->head) {
    e = (*v)(((PyObject *)p->head), a); if (e) return e;
  }
  if (p->body) {
    e = (*v)(p->body, a); if (e) return e;
  }
  if (p->id) {
    e = (*v)(p->id, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine_Clause(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine_Clause *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)o;
  tmp = ((PyObject*)p->head);
  p->head = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->body);
  p->body = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->id);
  p->id = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_6Clause_head(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_6Clause_head(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_6Clause_4head_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_6Clause_body(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_6Clause_body(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_6Clause_4body_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_6Clause_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_6Clause_id(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_6Clause_2id_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Clause[] = {
  {"get_id", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_9get_id, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_6Clause_8get_id},
  {"subst", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_6Clause_11subst, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9pyDatalog_8pyEngine_6Clause_10subst},
  {"rename", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_13rename, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_6Clause_12rename},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_15__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_6Clause_17__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9pyDatalog_8pyEngine_Clause[] = {
  {(char *)"head", __pyx_getprop_9pyDatalog_8pyEngine_6Clause_head, __pyx_setprop_9pyDatalog_8pyEngine_6Clause_head, (char *)0, 0},
  {(char *)"body", __pyx_getprop_9pyDatalog_8pyEngine_6Clause_body, __pyx_setprop_9pyDatalog_8pyEngine_6Clause_body, (char *)0, 0},
  {(char *)"id", __pyx_getprop_9pyDatalog_8pyEngine_6Clause_id, __pyx_setprop_9pyDatalog_8pyEngine_6Clause_id, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Clause = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  __pyx_pw_9pyDatalog_8pyEngine_6Clause_7__neg__, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Clause = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Clause", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Clause), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Clause, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_9pyDatalog_8pyEngine_6Clause_5__repr__, /*tp_repr*/
  &__pyx_tp_as_number_Clause, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_9pyDatalog_8pyEngine_6Clause_3__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  " A clause asserts that its head is true if every literal in its body is\n        true.  If there are no literals in the body, the clause is a fact\n    ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Clause, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Clause, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Clause, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9pyDatalog_8pyEngine_Clause, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_6Clause_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Clause, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_9pyDatalog_8pyEngine_Subgoal __pyx_vtable_9pyDatalog_8pyEngine_Subgoal;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine_Subgoal(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)o);
  p->__pyx_vtab = __pyx_vtabptr_9pyDatalog_8pyEngine_Subgoal;
  p->literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)Py_None); Py_INCREF(Py_None);
  p->facts = Py_None; Py_INCREF(Py_None);
  p->waiters = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->tasks = Py_None; Py_INCREF(Py_None);
  p->clauses = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->recursive = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  p->is_done = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  p->on_completion_ = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine_Subgoal(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->literal);
  Py_CLEAR(p->facts);
  Py_CLEAR(p->waiters);
  Py_CLEAR(p->tasks);
  Py_CLEAR(p->clauses);
  Py_CLEAR(p->recursive);
  Py_CLEAR(p->is_done);
  Py_CLEAR(p->on_completion_);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine_Subgoal(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)o;
  if (p->literal) {
    e = (*v)(((PyObject *)p->literal), a); if (e) return e;
  }
  if (p->facts) {
    e = (*v)(p->facts, a); if (e) return e;
  }
  if (p->waiters) {
    e = (*v)(p->waiters, a); if (e) return e;
  }
  if (p->tasks) {
    e = (*v)(p->tasks, a); if (e) return e;
  }
  if (p->clauses) {
    e = (*v)(p->clauses, a); if (e) return e;
  }
  if (p->recursive) {
    e = (*v)(((PyObject *)p->recursive), a); if (e) return e;
  }
  if (p->is_done) {
    e = (*v)(((PyObject *)p->is_done), a); if (e) return e;
  }
  if (p->on_completion_) {
    e = (*v)(p->on_completion_, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine_Subgoal(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *p = (struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)o;
  tmp = ((PyObject*)p->literal);
  p->literal = ((struct __pyx_obj_9pyDatalog_8pyEngine_Literal *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->facts);
  p->facts = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->waiters);
  p->waiters = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tasks);
  p->tasks = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->clauses);
  p->clauses = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->recursive);
  p->recursive = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->is_done);
  p->is_done = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->on_completion_);
  p->on_completion_ = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_literal(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_literal(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7literal_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_facts(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_facts(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5facts_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_waiters(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_waiters(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7waiters_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_tasks(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_tasks(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5tasks_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_clauses(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_clauses(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7clauses_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_recursive(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_recursive(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_9recursive_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_is_done(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_is_done(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7is_done_5__del__(o);
  }
}

static PyObject *__pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_on_completion_(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__1__get__(o);
}

static int __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_on_completion_(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__3__set__(o, v);
  }
  else {
    return __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_14on_completion__5__del__(o);
  }
}

static PyMethodDef __pyx_methods_9pyDatalog_8pyEngine_Subgoal[] = {
  {"search", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_5search, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_4search},
  {"add_clause", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_7add_clause, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_6add_clause},
  {"next_step", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_19next_step, METH_NOARGS, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_18next_step},
  {"next_clause", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_21next_clause, METH_NOARGS, 0},
  {"searching", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_23searching, METH_O, __pyx_doc_9pyDatalog_8pyEngine_7Subgoal_22searching},
  {"on_completion", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_27on_completion, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_29__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_9pyDatalog_8pyEngine_7Subgoal_31__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_9pyDatalog_8pyEngine_Subgoal[] = {
  {(char *)"literal", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_literal, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_literal, (char *)0, 0},
  {(char *)"facts", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_facts, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_facts, (char *)0, 0},
  {(char *)"waiters", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_waiters, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_waiters, (char *)0, 0},
  {(char *)"tasks", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_tasks, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_tasks, (char *)0, 0},
  {(char *)"clauses", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_clauses, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_clauses, (char *)0, 0},
  {(char *)"recursive", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_recursive, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_recursive, (char *)0, 0},
  {(char *)"is_done", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_is_done, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_is_done, (char *)0, 0},
  {(char *)"on_completion_", __pyx_getprop_9pyDatalog_8pyEngine_7Subgoal_on_completion_, __pyx_setprop_9pyDatalog_8pyEngine_7Subgoal_on_completion_, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine_Subgoal = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.Subgoal", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine_Subgoal, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_3__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    A subgoal has a literal, a set of facts, and an array of waiters.\n    A waiter is a pair containing a subgoal and a clause.\n    ", /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine_Subgoal, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine_Subgoal, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9pyDatalog_8pyEngine_Subgoal, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_9pyDatalog_8pyEngine_Subgoal, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_9pyDatalog_8pyEngine_7Subgoal_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine_Subgoal, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct____init__[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct____init__ = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct____init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct____init__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct____init__[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct____init__];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct____init__(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v__id);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct____init__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct____init__[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct____init__++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct____init__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *)o;
  if (p->__pyx_v__id) {
    e = (*v)(p->__pyx_v__id, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct____init__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__ *)o;
  tmp = ((PyObject*)p->__pyx_v__id);
  p->__pyx_v__id = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct____init__", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct____init__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct____init__, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct____init__, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct____init__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct____init__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_element);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_element) {
    e = (*v)(p->__pyx_v_element, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_2_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_cls);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes *)o;
  if (p->__pyx_v_cls) {
    e = (*v)(p->__pyx_v_cls, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_3_parent_classes", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_literal);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *)o;
  if (p->__pyx_v_literal) {
    e = (*v)(p->__pyx_v_literal, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask *)o;
  tmp = ((PyObject*)p->__pyx_v_literal);
  p->__pyx_v_literal = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_4_ask", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_term);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_term) {
    e = (*v)(p->__pyx_v_term, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_5_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_6___str__", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_literal);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_literal) {
    e = (*v)(p->__pyx_v_literal, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_7_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_8___repr__", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_literal);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_literal) {
    e = (*v)(p->__pyx_v_literal, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_9_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9pyDatalog_8pyEngine_Clause *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_10_get_id", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_bodi);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_bodi) {
    e = (*v)(p->__pyx_v_bodi, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_11_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_clause);
  Py_CLEAR(p->__pyx_v_pred);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *)o;
  if (p->__pyx_v_clause) {
    e = (*v)(p->__pyx_v_clause, a); if (e) return e;
  }
  if (p->__pyx_v_pred) {
    e = (*v)(p->__pyx_v_pred, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ *)o;
  tmp = ((PyObject*)p->__pyx_v_clause);
  p->__pyx_v_clause = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_pred);
  p->__pyx_v_pred = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_12_assert_", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_literal);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_literal) {
    e = (*v)(p->__pyx_v_literal, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_13_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_facts);
  Py_CLEAR(p->__pyx_v_i);
  Py_CLEAR(p->__pyx_v_literal);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_term);
  Py_CLEAR(p->__pyx_v_v);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses *)o;
  if (p->__pyx_v_facts) {
    e = (*v)(p->__pyx_v_facts, a); if (e) return e;
  }
  if (p->__pyx_v_i) {
    e = (*v)(p->__pyx_v_i, a); if (e) return e;
  }
  if (p->__pyx_v_literal) {
    e = (*v)(p->__pyx_v_literal, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_term) {
    e = (*v)(p->__pyx_v_term, a); if (e) return e;
  }
  if (p->__pyx_v_v) {
    e = (*v)(p->__pyx_v_v, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_14_relevant_clauses", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_subgoal);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_subgoal) {
    e = (*v)(p->__pyx_v_subgoal, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_subgoal);
  p->__pyx_v_subgoal = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_15_searching", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching, /*tp_traverse*/
  __pyx_tp_clear_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr[8];
static int __pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr = 0;

static PyObject *__pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr)))) {
    o = (PyObject*)__pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr[--__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr(PyObject *o) {
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_waiter);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr)))) {
    __pyx_freelist_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr[__pyx_freecount_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr++] = ((struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *p = (struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_waiter) {
    e = (*v)(p->__pyx_v_waiter, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "pyDatalog.pyEngine.__pyx_scope_struct_16_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_pyEngine(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_pyEngine},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "pyEngine",
    __pyx_k_This_file_is_part_of_pyDatalog, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_40s, __pyx_k_40s, sizeof(__pyx_k_40s), 0, 0, 1, 0},
  {&__pyx_n_s_ADD_CLAUSE, __pyx_k_ADD_CLAUSE, sizeof(__pyx_k_ADD_CLAUSE), 0, 0, 1, 1},
  {&__pyx_kp_s_A_predicate_symbol_has_a_name_a, __pyx_k_A_predicate_symbol_has_a_name_a, sizeof(__pyx_k_A_predicate_symbol_has_a_name_a), 0, 0, 1, 0},
  {&__pyx_kp_s_Abstract_class_for_objects_havi, __pyx_k_Abstract_class_for_objects_havi, sizeof(__pyx_k_Abstract_class_for_objects_havi), 0, 0, 1, 0},
  {&__pyx_kp_s_Add_clause, __pyx_k_Add_clause, sizeof(__pyx_k_Add_clause), 0, 0, 1, 0},
  {&__pyx_kp_s_Add_s, __pyx_k_Add_s, sizeof(__pyx_k_Add_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Already_completed, __pyx_k_Already_completed, sizeof(__pyx_k_Already_completed), 0, 0, 1, 0},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s_Auto_print, __pyx_k_Auto_print, sizeof(__pyx_k_Auto_print), 0, 0, 1, 1},
  {&__pyx_n_s_Class_dict, __pyx_k_Class_dict, sizeof(__pyx_k_Class_dict), 0, 0, 1, 1},
  {&__pyx_n_s_Clause, __pyx_k_Clause, sizeof(__pyx_k_Clause), 0, 0, 1, 1},
  {&__pyx_n_s_Clause___reduce_cython, __pyx_k_Clause___reduce_cython, sizeof(__pyx_k_Clause___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Clause___setstate_cython, __pyx_k_Clause___setstate_cython, sizeof(__pyx_k_Clause___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Clause_get_id, __pyx_k_Clause_get_id, sizeof(__pyx_k_Clause_get_id), 0, 0, 1, 1},
  {&__pyx_n_s_Clause_rename, __pyx_k_Clause_rename, sizeof(__pyx_k_Clause_rename), 0, 0, 1, 1},
  {&__pyx_n_s_Clause_subst, __pyx_k_Clause_subst, sizeof(__pyx_k_Clause_subst), 0, 0, 1, 1},
  {&__pyx_kp_s_Clauses_of, __pyx_k_Clauses_of, sizeof(__pyx_k_Clauses_of), 0, 0, 1, 0},
  {&__pyx_n_s_Const, __pyx_k_Const, sizeof(__pyx_k_Const), 0, 0, 1, 1},
  {&__pyx_n_s_Const___reduce_cython, __pyx_k_Const___reduce_cython, sizeof(__pyx_k_Const___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Const___setstate_cython, __pyx_k_Const___setstate_cython, sizeof(__pyx_k_Const___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Const_chase, __pyx_k_Const_chase, sizeof(__pyx_k_Const_chase), 0, 0, 1, 1},
  {&__pyx_n_s_Const_equals_primitive, __pyx_k_Const_equals_primitive, sizeof(__pyx_k_Const_equals_primitive), 0, 0, 1, 1},
  {&__pyx_n_s_Const_get_tag, __pyx_k_Const_get_tag, sizeof(__pyx_k_Const_get_tag), 0, 0, 1, 1},
  {&__pyx_n_s_Const_is_const, __pyx_k_Const_is_const, sizeof(__pyx_k_Const_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_Const_match, __pyx_k_Const_match, sizeof(__pyx_k_Const_match), 0, 0, 1, 1},
  {&__pyx_n_s_Const_shuffle, __pyx_k_Const_shuffle, sizeof(__pyx_k_Const_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_Const_subst, __pyx_k_Const_subst, sizeof(__pyx_k_Const_subst), 0, 0, 1, 1},
  {&__pyx_n_s_Const_unify, __pyx_k_Const_unify, sizeof(__pyx_k_Const_unify), 0, 0, 1, 1},
  {&__pyx_n_s_Counter, __pyx_k_Counter, sizeof(__pyx_k_Counter), 0, 0, 1, 1},
  {&__pyx_n_s_DEBUG, __pyx_k_DEBUG, sizeof(__pyx_k_DEBUG), 0, 0, 1, 1},
  {&__pyx_n_s_DatalogError, __pyx_k_DatalogError, sizeof(__pyx_k_DatalogError), 0, 0, 1, 1},
  {&__pyx_n_s_Db, __pyx_k_Db, sizeof(__pyx_k_Db), 0, 0, 1, 1},
  {&__pyx_kp_s_Error_left_hand_side_of_comparis, __pyx_k_Error_left_hand_side_of_comparis, sizeof(__pyx_k_Error_left_hand_side_of_comparis), 0, 0, 1, 0},
  {&__pyx_kp_s_Error_right_hand_side_must_be_bo, __pyx_k_Error_right_hand_side_must_be_bo, sizeof(__pyx_k_Error_right_hand_side_must_be_bo), 0, 0, 1, 0},
  {&__pyx_kp_s_Error_right_hand_side_of_compari, __pyx_k_Error_right_hand_side_of_compari, sizeof(__pyx_k_Error_right_hand_side_of_compari), 0, 0, 1, 0},
  {&__pyx_kp_s_Facts_of, __pyx_k_Facts_of, sizeof(__pyx_k_Facts_of), 0, 0, 1, 0},
  {&__pyx_n_s_Fresh_var, __pyx_k_Fresh_var, sizeof(__pyx_k_Fresh_var), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var___reduce_cython, __pyx_k_Fresh_var___reduce_cython, sizeof(__pyx_k_Fresh_var___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var___setstate_cython, __pyx_k_Fresh_var___setstate_cython, sizeof(__pyx_k_Fresh_var___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_chase, __pyx_k_Fresh_var_chase, sizeof(__pyx_k_Fresh_var_chase), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_equals_primitive, __pyx_k_Fresh_var_equals_primitive, sizeof(__pyx_k_Fresh_var_equals_primitive), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_get_tag, __pyx_k_Fresh_var_get_tag, sizeof(__pyx_k_Fresh_var_get_tag), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_is_const, __pyx_k_Fresh_var_is_const, sizeof(__pyx_k_Fresh_var_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_match, __pyx_k_Fresh_var_match, sizeof(__pyx_k_Fresh_var_match), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_shuffle, __pyx_k_Fresh_var_shuffle, sizeof(__pyx_k_Fresh_var_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_subst, __pyx_k_Fresh_var_subst, sizeof(__pyx_k_Fresh_var_subst), 0, 0, 1, 1},
  {&__pyx_n_s_Fresh_var_unify, __pyx_k_Fresh_var_unify, sizeof(__pyx_k_Fresh_var_unify), 0, 0, 1, 1},
  {&__pyx_n_s_Goal, __pyx_k_Goal, sizeof(__pyx_k_Goal), 0, 0, 1, 1},
  {&__pyx_n_s_INFO, __pyx_k_INFO, sizeof(__pyx_k_INFO), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2, __pyx_k_Incompatible_checksums_0x_x_vs_0_2, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3, __pyx_k_Incompatible_checksums_0x_x_vs_0_3, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_3), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_4, __pyx_k_Incompatible_checksums_0x_x_vs_0_4, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_4), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_5, __pyx_k_Incompatible_checksums_0x_x_vs_0_5, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_5), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_6, __pyx_k_Incompatible_checksums_0x_x_vs_0_6, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_6), 0, 0, 1, 0},
  {&__pyx_n_s_Interned, __pyx_k_Interned, sizeof(__pyx_k_Interned), 0, 0, 1, 1},
  {&__pyx_n_s_Interned___eq, __pyx_k_Interned___eq, sizeof(__pyx_k_Interned___eq), 0, 0, 1, 1},
  {&__pyx_n_s_Interned___hash, __pyx_k_Interned___hash, sizeof(__pyx_k_Interned___hash), 0, 0, 1, 1},
  {&__pyx_n_s_Interned___ne, __pyx_k_Interned___ne, sizeof(__pyx_k_Interned___ne), 0, 0, 1, 1},
  {&__pyx_n_s_LAMBDA, __pyx_k_LAMBDA, sizeof(__pyx_k_LAMBDA), 0, 0, 1, 1},
  {&__pyx_n_s_Literal, __pyx_k_Literal, sizeof(__pyx_k_Literal), 0, 0, 1, 1},
  {&__pyx_n_s_Literal___reduce_cython, __pyx_k_Literal___reduce_cython, sizeof(__pyx_k_Literal___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Literal___setstate_cython, __pyx_k_Literal___setstate_cython, sizeof(__pyx_k_Literal___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Literal__renamed, __pyx_k_Literal__renamed, sizeof(__pyx_k_Literal__renamed), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_ask, __pyx_k_Literal_ask, sizeof(__pyx_k_Literal_ask), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_equalized, __pyx_k_Literal_equalized, sizeof(__pyx_k_Literal_equalized), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_get_fact_id, __pyx_k_Literal_get_fact_id, sizeof(__pyx_k_Literal_get_fact_id), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_get_id, __pyx_k_Literal_get_id, sizeof(__pyx_k_Literal_get_id), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_get_tag, __pyx_k_Literal_get_tag, sizeof(__pyx_k_Literal_get_tag), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_match, __pyx_k_Literal_match, sizeof(__pyx_k_Literal_match), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_rebased, __pyx_k_Literal_rebased, sizeof(__pyx_k_Literal_rebased), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_shuffle, __pyx_k_Literal_shuffle, sizeof(__pyx_k_Literal_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_subst, __pyx_k_Literal_subst, sizeof(__pyx_k_Literal_subst), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_subst_first, __pyx_k_Literal_subst_first, sizeof(__pyx_k_Literal_subst_first), 0, 0, 1, 1},
  {&__pyx_n_s_Literal_unify, __pyx_k_Literal_unify, sizeof(__pyx_k_Literal_unify), 0, 0, 1, 1},
  {&__pyx_n_s_Logger, __pyx_k_Logger, sizeof(__pyx_k_Logger), 0, 0, 1, 1},
  {&__pyx_n_s_Logging, __pyx_k_Logging, sizeof(__pyx_k_Logging), 0, 0, 1, 1},
  {&__pyx_n_s_Logic, __pyx_k_Logic, sizeof(__pyx_k_Logic), 0, 0, 1, 1},
  {&__pyx_n_s_Mixin, __pyx_k_Mixin, sizeof(__pyx_k_Mixin), 0, 0, 1, 1},
  {&__pyx_kp_s_Moving_task_forward_s, __pyx_k_Moving_task_forward_s, sizeof(__pyx_k_Moving_task_forward_s), 0, 0, 1, 0},
  {&__pyx_n_s_NEXT_CLAUSE, __pyx_k_NEXT_CLAUSE, sizeof(__pyx_k_NEXT_CLAUSE), 0, 0, 1, 1},
  {&__pyx_kp_s_New_fact_s, __pyx_k_New_fact_s, sizeof(__pyx_k_New_fact_s), 0, 0, 1, 0},
  {&__pyx_kp_s_New_fact_s_is_True, __pyx_k_New_fact_s_is_True, sizeof(__pyx_k_New_fact_s_is_True), 0, 0, 1, 0},
  {&__pyx_kp_s_Next_clause, __pyx_k_Next_clause, sizeof(__pyx_k_Next_clause), 0, 0, 1, 0},
  {&__pyx_n_s_ON_COMPLETION, __pyx_k_ON_COMPLETION, sizeof(__pyx_k_ON_COMPLETION), 0, 0, 1, 1},
  {&__pyx_kp_s_On_completion, __pyx_k_On_completion, sizeof(__pyx_k_On_completion), 0, 0, 1, 0},
  {&__pyx_kp_s_On_completion_2, __pyx_k_On_completion_2, sizeof(__pyx_k_On_completion_2), 0, 0, 1, 0},
  {&__pyx_n_s_Operation, __pyx_k_Operation, sizeof(__pyx_k_Operation), 0, 0, 1, 1},
  {&__pyx_n_s_Operation___reduce_cython, __pyx_k_Operation___reduce_cython, sizeof(__pyx_k_Operation___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Operation___setstate_cython, __pyx_k_Operation___setstate_cython, sizeof(__pyx_k_Operation___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Operation_chase, __pyx_k_Operation_chase, sizeof(__pyx_k_Operation_chase), 0, 0, 1, 1},
  {&__pyx_n_s_Operation_get_tag, __pyx_k_Operation_get_tag, sizeof(__pyx_k_Operation_get_tag), 0, 0, 1, 1},
  {&__pyx_n_s_Operation_is_const, __pyx_k_Operation_is_const, sizeof(__pyx_k_Operation_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_Operation_shuffle, __pyx_k_Operation_shuffle, sizeof(__pyx_k_Operation_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_Operation_subst, __pyx_k_Operation_subst, sizeof(__pyx_k_Operation_subst), 0, 0, 1, 1},
  {&__pyx_n_s_Operation_unify, __pyx_k_Operation_unify, sizeof(__pyx_k_Operation_unify), 0, 0, 1, 1},
  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_Pred, __pyx_k_Pred, sizeof(__pyx_k_Pred), 0, 0, 1, 1},
  {&__pyx_n_s_Pred___new, __pyx_k_Pred___new, sizeof(__pyx_k_Pred___new), 0, 0, 1, 1},
  {&__pyx_n_s_Pred___str, __pyx_k_Pred___str, sizeof(__pyx_k_Pred___str), 0, 0, 1, 1},
  {&__pyx_n_s_Pred__class, __pyx_k_Pred__class, sizeof(__pyx_k_Pred__class), 0, 0, 1, 1},
  {&__pyx_n_s_Pred_is_known, __pyx_k_Pred_is_known, sizeof(__pyx_k_Pred_is_known), 0, 0, 1, 1},
  {&__pyx_n_s_Pred_parent_classes, __pyx_k_Pred_parent_classes, sizeof(__pyx_k_Pred_parent_classes), 0, 0, 1, 1},
  {&__pyx_n_s_Pred_registry, __pyx_k_Pred_registry, sizeof(__pyx_k_Pred_registry), 0, 0, 1, 1},
  {&__pyx_n_s_Pred_reset_clauses, __pyx_k_Pred_reset_clauses, sizeof(__pyx_k_Pred_reset_clauses), 0, 0, 1, 1},
  {&__pyx_kp_s_Predicate_without_definition_or, __pyx_k_Predicate_without_definition_or, sizeof(__pyx_k_Predicate_without_definition_or), 0, 0, 1, 0},
  {&__pyx_kp_s_Processing_aggregate_or_negation, __pyx_k_Processing_aggregate_or_negation, sizeof(__pyx_k_Processing_aggregate_or_negation), 0, 0, 1, 0},
  {&__pyx_kp_s_Processing_s, __pyx_k_Processing_s, sizeof(__pyx_k_Processing_s), 0, 0, 1, 0},
  {&__pyx_n_s_Python_resolvers, __pyx_k_Python_resolvers, sizeof(__pyx_k_Python_resolvers), 0, 0, 1, 1},
  {&__pyx_kp_s_RECURSIVE_STACK, __pyx_k_RECURSIVE_STACK, sizeof(__pyx_k_RECURSIVE_STACK), 0, 0, 1, 0},
  {&__pyx_n_s_RLock, __pyx_k_RLock, sizeof(__pyx_k_RLock), 0, 0, 1, 1},
  {&__pyx_n_s_Recursive, __pyx_k_Recursive, sizeof(__pyx_k_Recursive), 0, 0, 1, 1},
  {&__pyx_n_s_Recursive_Tasks, __pyx_k_Recursive_Tasks, sizeof(__pyx_k_Recursive_Tasks), 0, 0, 1, 1},
  {&__pyx_n_s_SEARCH, __pyx_k_SEARCH, sizeof(__pyx_k_SEARCH), 0, 0, 1, 1},
  {&__pyx_n_s_SEARCHING, __pyx_k_SEARCHING, sizeof(__pyx_k_SEARCHING), 0, 0, 1, 1},
  {&__pyx_kp_s_STACK, __pyx_k_STACK, sizeof(__pyx_k_STACK), 0, 0, 1, 0},
  {&__pyx_n_s_Search, __pyx_k_Search, sizeof(__pyx_k_Search), 0, 0, 1, 1},
  {&__pyx_n_s_Searching, __pyx_k_Searching, sizeof(__pyx_k_Searching), 0, 0, 1, 1},
  {&__pyx_n_s_Slow_motion, __pyx_k_Slow_motion, sizeof(__pyx_k_Slow_motion), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal, __pyx_k_Subgoal, sizeof(__pyx_k_Subgoal), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal___reduce_cython, __pyx_k_Subgoal___reduce_cython, sizeof(__pyx_k_Subgoal___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal___setstate_cython, __pyx_k_Subgoal___setstate_cython, sizeof(__pyx_k_Subgoal___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_add_clause, __pyx_k_Subgoal_add_clause, sizeof(__pyx_k_Subgoal_add_clause), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_complete, __pyx_k_Subgoal_complete, sizeof(__pyx_k_Subgoal_complete), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_fact, __pyx_k_Subgoal_fact, sizeof(__pyx_k_Subgoal_fact), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_fact_candidate, __pyx_k_Subgoal_fact_candidate, sizeof(__pyx_k_Subgoal_fact_candidate), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_next_clause, __pyx_k_Subgoal_next_clause, sizeof(__pyx_k_Subgoal_next_clause), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_next_step, __pyx_k_Subgoal_next_step, sizeof(__pyx_k_Subgoal_next_step), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_on_completion, __pyx_k_Subgoal_on_completion, sizeof(__pyx_k_Subgoal_on_completion), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_rule, __pyx_k_Subgoal_rule, sizeof(__pyx_k_Subgoal_rule), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_schedule, __pyx_k_Subgoal_schedule, sizeof(__pyx_k_Subgoal_schedule), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_schedule_search, __pyx_k_Subgoal_schedule_search, sizeof(__pyx_k_Subgoal_schedule_search), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_search, __pyx_k_Subgoal_search, sizeof(__pyx_k_Subgoal_search), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoal_searching, __pyx_k_Subgoal_searching, sizeof(__pyx_k_Subgoal_searching), 0, 0, 1, 1},
  {&__pyx_n_s_Subgoals, __pyx_k_Subgoals, sizeof(__pyx_k_Subgoals), 0, 0, 1, 1},
  {&__pyx_n_s_Tasks, __pyx_k_Tasks, sizeof(__pyx_k_Tasks), 0, 0, 1, 1},
  {&__pyx_n_s_Term, __pyx_k_Term, sizeof(__pyx_k_Term), 0, 0, 1, 1},
  {&__pyx_n_s_Term___reduce_cython, __pyx_k_Term___reduce_cython, sizeof(__pyx_k_Term___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Term___setstate_cython, __pyx_k_Term___setstate_cython, sizeof(__pyx_k_Term___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Term_of, __pyx_k_Term_of, sizeof(__pyx_k_Term_of), 0, 0, 1, 1},
  {&__pyx_n_s_Ts, __pyx_k_Ts, sizeof(__pyx_k_Ts), 0, 0, 1, 1},
  {&__pyx_n_s_Var, __pyx_k_Var, sizeof(__pyx_k_Var), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple, __pyx_k_VarTuple, sizeof(__pyx_k_VarTuple), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple___reduce_cython, __pyx_k_VarTuple___reduce_cython, sizeof(__pyx_k_VarTuple___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple___setstate_cython, __pyx_k_VarTuple___setstate_cython, sizeof(__pyx_k_VarTuple___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_chase, __pyx_k_VarTuple_chase, sizeof(__pyx_k_VarTuple_chase), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_equals_primitive, __pyx_k_VarTuple_equals_primitive, sizeof(__pyx_k_VarTuple_equals_primitive), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_get_tag, __pyx_k_VarTuple_get_tag, sizeof(__pyx_k_VarTuple_get_tag), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_is_const, __pyx_k_VarTuple_is_const, sizeof(__pyx_k_VarTuple_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_shuffle, __pyx_k_VarTuple_shuffle, sizeof(__pyx_k_VarTuple_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_subst, __pyx_k_VarTuple_subst, sizeof(__pyx_k_VarTuple_subst), 0, 0, 1, 1},
  {&__pyx_n_s_VarTuple_unify, __pyx_k_VarTuple_unify, sizeof(__pyx_k_VarTuple_unify), 0, 0, 1, 1},
  {&__pyx_n_s_Var___reduce_cython, __pyx_k_Var___reduce_cython, sizeof(__pyx_k_Var___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Var___setstate_cython, __pyx_k_Var___setstate_cython, sizeof(__pyx_k_Var___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_Var_unify, __pyx_k_Var_unify, sizeof(__pyx_k_Var_unify), 0, 0, 1, 1},
  {&__pyx_n_s_WeakValueDictionary, __pyx_k_WeakValueDictionary, sizeof(__pyx_k_WeakValueDictionary), 0, 0, 1, 1},
  {&__pyx_n_s_Y1, __pyx_k_Y1, sizeof(__pyx_k_Y1), 0, 0, 1, 1},
  {&__pyx_kp_s__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 0, 1, 0},
  {&__pyx_kp_s__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 0, 1, 0},
  {&__pyx_kp_s__12, __pyx_k__12, sizeof(__pyx_k__12), 0, 0, 1, 0},
  {&__pyx_kp_s__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 1, 0},
  {&__pyx_kp_s__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 0, 1, 0},
  {&__pyx_kp_s__16, __pyx_k__16, sizeof(__pyx_k__16), 0, 0, 1, 0},
  {&__pyx_kp_s__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 0, 1, 0},
  {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  {&__pyx_kp_s__21, __pyx_k__21, sizeof(__pyx_k__21), 0, 0, 1, 0},
  {&__pyx_kp_s__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 0, 1, 0},
  {&__pyx_kp_s__24, __pyx_k__24, sizeof(__pyx_k__24), 0, 0, 1, 0},
  {&__pyx_kp_s__27, __pyx_k__27, sizeof(__pyx_k__27), 0, 0, 1, 0},
  {&__pyx_kp_s__28, __pyx_k__28, sizeof(__pyx_k__28), 0, 0, 1, 0},
  {&__pyx_kp_s__29, __pyx_k__29, sizeof(__pyx_k__29), 0, 0, 1, 0},
  {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
  {&__pyx_kp_s__33, __pyx_k__33, sizeof(__pyx_k__33), 0, 0, 1, 0},
  {&__pyx_kp_s__34, __pyx_k__34, sizeof(__pyx_k__34), 0, 0, 1, 0},
  {&__pyx_kp_s__35, __pyx_k__35, sizeof(__pyx_k__35), 0, 0, 1, 0},
  {&__pyx_kp_s__36, __pyx_k__36, sizeof(__pyx_k__36), 0, 0, 1, 0},
  {&__pyx_kp_s__37, __pyx_k__37, sizeof(__pyx_k__37), 0, 0, 1, 0},
  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
  {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0},
  {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0},
  {&__pyx_kp_s__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 0, 1, 0},
  {&__pyx_kp_s__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 1, 0},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_class, __pyx_k_add_class, sizeof(__pyx_k_add_class), 0, 0, 1, 1},
  {&__pyx_n_s_add_clause, __pyx_k_add_clause, sizeof(__pyx_k_add_clause), 0, 0, 1, 1},
  {&__pyx_n_s_aggregate, __pyx_k_aggregate, sizeof(__pyx_k_aggregate), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_appendleft, __pyx_k_appendleft, sizeof(__pyx_k_appendleft), 0, 0, 1, 1},
  {&__pyx_n_s_arg, __pyx_k_arg, sizeof(__pyx_k_arg), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_arity, __pyx_k_arity, sizeof(__pyx_k_arity), 0, 0, 1, 1},
  {&__pyx_n_s_ask, __pyx_k_ask, sizeof(__pyx_k_ask), 0, 0, 1, 1},
  {&__pyx_n_s_ask_locals_genexpr, __pyx_k_ask_locals_genexpr, sizeof(__pyx_k_ask_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_assert, __pyx_k_assert, sizeof(__pyx_k_assert), 0, 0, 1, 1},
  {&__pyx_n_s_assert__locals_genexpr, __pyx_k_assert__locals_genexpr, sizeof(__pyx_k_assert__locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_atom, __pyx_k_atom, sizeof(__pyx_k_atom), 0, 0, 1, 1},
  {&__pyx_n_s_base_literal, __pyx_k_base_literal, sizeof(__pyx_k_base_literal), 0, 0, 1, 1},
  {&__pyx_n_s_base_pred, __pyx_k_base_pred, sizeof(__pyx_k_base_pred), 0, 0, 1, 1},
  {&__pyx_n_s_base_terms, __pyx_k_base_terms, sizeof(__pyx_k_base_terms), 0, 0, 1, 1},
  {&__pyx_n_s_bodi, __pyx_k_bodi, sizeof(__pyx_k_bodi), 0, 0, 1, 1},
  {&__pyx_n_s_body, __pyx_k_body, sizeof(__pyx_k_body), 0, 0, 1, 1},
  {&__pyx_n_s_call, __pyx_k_call, sizeof(__pyx_k_call), 0, 0, 1, 1},
  {&__pyx_n_s_chase, __pyx_k_chase, sizeof(__pyx_k_chase), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_class0, __pyx_k_class0, sizeof(__pyx_k_class0), 0, 0, 1, 1},
  {&__pyx_n_s_clause, __pyx_k_clause, sizeof(__pyx_k_clause), 0, 0, 1, 1},
  {&__pyx_n_s_clauses, __pyx_k_clauses, sizeof(__pyx_k_clauses), 0, 0, 1, 1},
  {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  {&__pyx_n_s_cls_2, __pyx_k_cls_2, sizeof(__pyx_k_cls_2), 0, 0, 1, 1},
  {&__pyx_n_s_collect, __pyx_k_collect, sizeof(__pyx_k_collect), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_compare, __pyx_k_compare, sizeof(__pyx_k_compare), 0, 0, 1, 1},
  {&__pyx_n_s_compare2, __pyx_k_compare2, sizeof(__pyx_k_compare2), 0, 0, 1, 1},
  {&__pyx_n_s_compare_primitive, __pyx_k_compare_primitive, sizeof(__pyx_k_compare_primitive), 0, 0, 1, 1},
  {&__pyx_n_s_comparison, __pyx_k_comparison, sizeof(__pyx_k_comparison), 0, 0, 1, 1},
  {&__pyx_n_s_complete, __pyx_k_complete, sizeof(__pyx_k_complete), 0, 0, 1, 1},
  {&__pyx_n_s_constant, __pyx_k_constant, sizeof(__pyx_k_constant), 0, 0, 1, 1},
  {&__pyx_n_s_counter, __pyx_k_counter, sizeof(__pyx_k_counter), 0, 0, 1, 1},
  {&__pyx_n_s_db, __pyx_k_db, sizeof(__pyx_k_db), 0, 0, 1, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_s_deque, __pyx_k_deque, sizeof(__pyx_k_deque), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dict_2, __pyx_k_dict_2, sizeof(__pyx_k_dict_2), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_env, __pyx_k_env, sizeof(__pyx_k_env), 0, 0, 1, 1},
  {&__pyx_n_s_eq, __pyx_k_eq, sizeof(__pyx_k_eq), 0, 0, 1, 1},
  {&__pyx_n_s_equalized, __pyx_k_equalized, sizeof(__pyx_k_equalized), 0, 0, 1, 1},
  {&__pyx_n_s_equals_primitive, __pyx_k_equals_primitive, sizeof(__pyx_k_equals_primitive), 0, 0, 1, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_expression, __pyx_k_expression, sizeof(__pyx_k_expression), 0, 0, 1, 1},
  {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
  {&__pyx_n_s_fact, __pyx_k_fact, sizeof(__pyx_k_fact), 0, 0, 1, 1},
  {&__pyx_n_s_fact_candidate, __pyx_k_fact_candidate, sizeof(__pyx_k_fact_candidate), 0, 0, 1, 1},
  {&__pyx_n_s_facts, __pyx_k_facts, sizeof(__pyx_k_facts), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 0, 1, 1},
  {&__pyx_n_s_gc_uncollected, __pyx_k_gc_uncollected, sizeof(__pyx_k_gc_uncollected), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  {&__pyx_n_s_get_fact_id, __pyx_k_get_fact_id, sizeof(__pyx_k_get_fact_id), 0, 0, 1, 1},
  {&__pyx_n_s_get_id, __pyx_k_get_id, sizeof(__pyx_k_get_id), 0, 0, 1, 1},
  {&__pyx_n_s_get_id_locals_genexpr, __pyx_k_get_id_locals_genexpr, sizeof(__pyx_k_get_id_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get_tag, __pyx_k_get_tag, sizeof(__pyx_k_get_tag), 0, 0, 1, 1},
  {&__pyx_n_s_getitem, __pyx_k_getitem, sizeof(__pyx_k_getitem), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_has_SQLAlchemy, __pyx_k_has_SQLAlchemy, sizeof(__pyx_k_has_SQLAlchemy), 0, 0, 1, 1},
  {&__pyx_n_s_hash, __pyx_k_hash, sizeof(__pyx_k_hash), 0, 0, 1, 1},
  {&__pyx_n_s_head, __pyx_k_head, sizeof(__pyx_k_head), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_id_2, __pyx_k_id_2, sizeof(__pyx_k_id_2), 0, 0, 1, 1},
  {&__pyx_n_s_id_3, __pyx_k_id_3, sizeof(__pyx_k_id_3), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_in, __pyx_k_in, sizeof(__pyx_k_in), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  {&__pyx_n_s_init___locals_genexpr, __pyx_k_init___locals_genexpr, sizeof(__pyx_k_init___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_insert, __pyx_k_insert, sizeof(__pyx_k_insert), 0, 0, 1, 1},
  {&__pyx_n_s_intersection, __pyx_k_intersection, sizeof(__pyx_k_intersection), 0, 0, 1, 1},
  {&__pyx_n_s_isEnabledFor, __pyx_k_isEnabledFor, sizeof(__pyx_k_isEnabledFor), 0, 0, 1, 1},
  {&__pyx_n_s_is_const, __pyx_k_is_const, sizeof(__pyx_k_is_const), 0, 0, 1, 1},
  {&__pyx_n_s_is_constant, __pyx_k_is_constant, sizeof(__pyx_k_is_constant), 0, 0, 1, 1},
  {&__pyx_kp_s_is_done, __pyx_k_is_done, sizeof(__pyx_k_is_done), 0, 0, 1, 0},
  {&__pyx_n_s_is_done_2, __pyx_k_is_done_2, sizeof(__pyx_k_is_done_2), 0, 0, 1, 1},
  {&__pyx_n_s_is_known, __pyx_k_is_known, sizeof(__pyx_k_is_known), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
  {&__pyx_n_s_lhs, __pyx_k_lhs, sizeof(__pyx_k_lhs), 0, 0, 1, 1},
  {&__pyx_n_s_literal, __pyx_k_literal, sizeof(__pyx_k_literal), 0, 0, 1, 1},
  {&__pyx_n_s_literal0, __pyx_k_literal0, sizeof(__pyx_k_literal0), 0, 0, 1, 1},
  {&__pyx_n_s_literal1, __pyx_k_literal1, sizeof(__pyx_k_literal1), 0, 0, 1, 1},
  {&__pyx_n_s_literal2, __pyx_k_literal2, sizeof(__pyx_k_literal2), 0, 0, 1, 1},
  {&__pyx_n_s_local, __pyx_k_local, sizeof(__pyx_k_local), 0, 0, 1, 1},
  {&__pyx_n_s_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 0, 1, 1},
  {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  {&__pyx_n_s_logic, __pyx_k_logic, sizeof(__pyx_k_logic), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_n_s_match, __pyx_k_match, sizeof(__pyx_k_match), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_method_name, __pyx_k_method_name, sizeof(__pyx_k_method_name), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_mro, __pyx_k_mro, sizeof(__pyx_k_mro), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_ne, __pyx_k_ne, sizeof(__pyx_k_ne), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_new_name, __pyx_k_new_name, sizeof(__pyx_k_new_name), 0, 0, 1, 1},
  {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
  {&__pyx_n_s_next_clause, __pyx_k_next_clause, sizeof(__pyx_k_next_clause), 0, 0, 1, 1},
  {&__pyx_n_s_next_step, __pyx_k_next_step, sizeof(__pyx_k_next_step), 0, 0, 1, 1},
  {&__pyx_n_s_notFound, __pyx_k_notFound, sizeof(__pyx_k_notFound), 0, 0, 1, 1},
  {&__pyx_n_s_not_in, __pyx_k_not_in, sizeof(__pyx_k_not_in), 0, 0, 1, 1},
  {&__pyx_n_s_o, __pyx_k_o, sizeof(__pyx_k_o), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_on_completion, __pyx_k_on_completion, sizeof(__pyx_k_on_completion), 0, 0, 1, 1},
  {&__pyx_n_s_on_completion_2, __pyx_k_on_completion_2, sizeof(__pyx_k_on_completion_2), 0, 0, 1, 1},
  {&__pyx_n_s_op, __pyx_k_op, sizeof(__pyx_k_op), 0, 0, 1, 1},
  {&__pyx_n_s_operator, __pyx_k_operator, sizeof(__pyx_k_operator), 0, 0, 1, 1},
  {&__pyx_n_s_other, __pyx_k_other, sizeof(__pyx_k_other), 0, 0, 1, 1},
  {&__pyx_n_s_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 0, 1, 1},
  {&__pyx_n_s_parent_class, __pyx_k_parent_class, sizeof(__pyx_k_parent_class), 0, 0, 1, 1},
  {&__pyx_n_s_parent_classes, __pyx_k_parent_classes, sizeof(__pyx_k_parent_classes), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
  {&__pyx_n_s_prearity, __pyx_k_prearity, sizeof(__pyx_k_prearity), 0, 0, 1, 1},
  {&__pyx_n_s_pred, __pyx_k_pred, sizeof(__pyx_k_pred), 0, 0, 1, 1},
  {&__pyx_n_s_pred_id, __pyx_k_pred_id, sizeof(__pyx_k_pred_id), 0, 0, 1, 1},
  {&__pyx_n_s_pred_name, __pyx_k_pred_name, sizeof(__pyx_k_pred_name), 0, 0, 1, 1},
  {&__pyx_n_s_prefix, __pyx_k_prefix, sizeof(__pyx_k_prefix), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_prim, __pyx_k_prim, sizeof(__pyx_k_prim), 0, 0, 1, 1},
  {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  {&__pyx_kp_s_pyD__s_i, __pyx_k_pyD__s_i, sizeof(__pyx_k_pyD__s_i), 0, 0, 1, 0},
  {&__pyx_kp_s_pyD_class, __pyx_k_pyD_class, sizeof(__pyx_k_pyD_class), 0, 0, 1, 0},
  {&__pyx_n_s_pyD_class_2, __pyx_k_pyD_class_2, sizeof(__pyx_k_pyD_class_2), 0, 0, 1, 1},
  {&__pyx_n_s_pyD_in, __pyx_k_pyD_in, sizeof(__pyx_k_pyD_in), 0, 0, 1, 1},
  {&__pyx_n_s_pyD_not_in, __pyx_k_pyD_not_in, sizeof(__pyx_k_pyD_not_in), 0, 0, 1, 1},
  {&__pyx_n_s_pyD_query, __pyx_k_pyD_query, sizeof(__pyx_k_pyD_query), 0, 0, 1, 1},
  {&__pyx_n_s_pyDatalog_pyEngine, __pyx_k_pyDatalog_pyEngine, sizeof(__pyx_k_pyDatalog_pyEngine), 0, 0, 1, 1},
  {&__pyx_kp_s_pyDatalog_pyEngine_py, __pyx_k_pyDatalog_pyEngine_py, sizeof(__pyx_k_pyDatalog_pyEngine_py), 0, 0, 1, 0},
  {&__pyx_n_s_pyDatalog_search, __pyx_k_pyDatalog_search, sizeof(__pyx_k_pyDatalog_search), 0, 0, 1, 1},
  {&__pyx_kp_s_pyDatalog_uses__pyD_query_resolv, __pyx_k_pyDatalog_uses__pyD_query_resolv, sizeof(__pyx_k_pyDatalog_uses__pyD_query_resolv), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_uses_aggregate_primiti, __pyx_k_pyDatalog_uses_aggregate_primiti, sizeof(__pyx_k_pyDatalog_uses_aggregate_primiti), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_uses_class_resolvers_f, __pyx_k_pyDatalog_uses_class_resolvers_f, sizeof(__pyx_k_pyDatalog_uses_class_resolvers_f), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_uses_comparison_primit, __pyx_k_pyDatalog_uses_comparison_primit, sizeof(__pyx_k_pyDatalog_uses_comparison_primit), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_uses_pyDatalog_search, __pyx_k_pyDatalog_uses_pyDatalog_search, sizeof(__pyx_k_pyDatalog_uses_pyDatalog_search), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_uses_python_resolvers, __pyx_k_pyDatalog_uses_python_resolvers, sizeof(__pyx_k_pyDatalog_uses_python_resolvers), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_will_search_negation_o, __pyx_k_pyDatalog_will_search_negation_o, sizeof(__pyx_k_pyDatalog_will_search_negation_o), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_will_use_clause_for_co, __pyx_k_pyDatalog_will_use_clause_for_co, sizeof(__pyx_k_pyDatalog_will_use_clause_for_co), 0, 0, 1, 0},
  {&__pyx_kp_s_pyDatalog_will_use_clause_s, __pyx_k_pyDatalog_will_use_clause_s, sizeof(__pyx_k_pyDatalog_will_use_clause_s), 0, 0, 1, 0},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Clause, __pyx_k_pyx_unpickle_Clause, sizeof(__pyx_k_pyx_unpickle_Clause), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Const, __pyx_k_pyx_unpickle_Const, sizeof(__pyx_k_pyx_unpickle_Const), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Fresh_var, __pyx_k_pyx_unpickle_Fresh_var, sizeof(__pyx_k_pyx_unpickle_Fresh_var), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Literal, __pyx_k_pyx_unpickle_Literal, sizeof(__pyx_k_pyx_unpickle_Literal), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Operation, __pyx_k_pyx_unpickle_Operation, sizeof(__pyx_k_pyx_unpickle_Operation), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Subgoal, __pyx_k_pyx_unpickle_Subgoal, sizeof(__pyx_k_pyx_unpickle_Subgoal), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Term, __pyx_k_pyx_unpickle_Term, sizeof(__pyx_k_pyx_unpickle_Term), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Var, __pyx_k_pyx_unpickle_Var, sizeof(__pyx_k_pyx_unpickle_Var), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_VarTuple, __pyx_k_pyx_unpickle_VarTuple, sizeof(__pyx_k_pyx_unpickle_VarTuple), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
  {&__pyx_n_s_rebased, __pyx_k_rebased, sizeof(__pyx_k_rebased), 0, 0, 1, 1},
  {&__pyx_n_s_recursive, __pyx_k_recursive, sizeof(__pyx_k_recursive), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_relevant_clauses, __pyx_k_relevant_clauses, sizeof(__pyx_k_relevant_clauses), 0, 0, 1, 1},
  {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
  {&__pyx_n_s_rename, __pyx_k_rename, sizeof(__pyx_k_rename), 0, 0, 1, 1},
  {&__pyx_n_s_renamed, __pyx_k_renamed, sizeof(__pyx_k_renamed), 0, 0, 1, 1},
  {&__pyx_n_s_renamed_2, __pyx_k_renamed_2, sizeof(__pyx_k_renamed_2), 0, 0, 1, 1},
  {&__pyx_n_s_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 0, 1, 1},
  {&__pyx_n_s_repr___locals_genexpr, __pyx_k_repr___locals_genexpr, sizeof(__pyx_k_repr___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_reset_clauses, __pyx_k_reset_clauses, sizeof(__pyx_k_reset_clauses), 0, 0, 1, 1},
  {&__pyx_n_s_resolver, __pyx_k_resolver, sizeof(__pyx_k_resolver), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_n_s_results, __pyx_k_results, sizeof(__pyx_k_results), 0, 0, 1, 1},
  {&__pyx_n_s_retract, __pyx_k_retract, sizeof(__pyx_k_retract), 0, 0, 1, 1},
  {&__pyx_n_s_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 0, 1, 1},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_n_s_rhs, __pyx_k_rhs, sizeof(__pyx_k_rhs), 0, 0, 1, 1},
  {&__pyx_n_s_rule, __pyx_k_rule, sizeof(__pyx_k_rule), 0, 0, 1, 1},
  {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_2, __pyx_k_s_2, sizeof(__pyx_k_s_2), 0, 0, 1, 0},
  {&__pyx_kp_s_s_i, __pyx_k_s_i, sizeof(__pyx_k_s_i), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_2, __pyx_k_s_s_2, sizeof(__pyx_k_s_s_2), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s, __pyx_k_s_s_s, sizeof(__pyx_k_s_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_saved_environment, __pyx_k_saved_environment, sizeof(__pyx_k_saved_environment), 0, 0, 1, 1},
  {&__pyx_n_s_schedule, __pyx_k_schedule, sizeof(__pyx_k_schedule), 0, 0, 1, 1},
  {&__pyx_n_s_schedule_search, __pyx_k_schedule_search, sizeof(__pyx_k_schedule_search), 0, 0, 1, 1},
  {&__pyx_n_s_search, __pyx_k_search, sizeof(__pyx_k_search), 0, 0, 1, 1},
  {&__pyx_n_s_searching, __pyx_k_searching, sizeof(__pyx_k_searching), 0, 0, 1, 1},
  {&__pyx_n_s_searching_locals_genexpr, __pyx_k_searching_locals_genexpr, sizeof(__pyx_k_searching_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_selected, __pyx_k_selected, sizeof(__pyx_k_selected), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_setdefault, __pyx_k_setdefault, sizeof(__pyx_k_setdefault), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_show, __pyx_k_show, sizeof(__pyx_k_show), 0, 0, 1, 1},
  {&__pyx_n_s_shuffle, __pyx_k_shuffle, sizeof(__pyx_k_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_slice_to_variabilize, __pyx_k_slice_to_variabilize, sizeof(__pyx_k_slice_to_variabilize), 0, 0, 1, 1},
  {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
  {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1},
  {&__pyx_n_s_str, __pyx_k_str, sizeof(__pyx_k_str), 0, 0, 1, 1},
  {&__pyx_n_s_str___locals_genexpr, __pyx_k_str___locals_genexpr, sizeof(__pyx_k_str___locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_string_types, __pyx_k_string_types, sizeof(__pyx_k_string_types), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 0, 0, 1, 1},
  {&__pyx_n_s_subgoal, __pyx_k_subgoal, sizeof(__pyx_k_subgoal), 0, 0, 1, 1},
  {&__pyx_n_s_subst, __pyx_k_subst, sizeof(__pyx_k_subst), 0, 0, 1, 1},
  {&__pyx_n_s_subst_first, __pyx_k_subst_first, sizeof(__pyx_k_subst_first), 0, 0, 1, 1},
  {&__pyx_n_s_suffix, __pyx_k_suffix, sizeof(__pyx_k_suffix), 0, 0, 1, 1},
  {&__pyx_n_s_tag, __pyx_k_tag, sizeof(__pyx_k_tag), 0, 0, 1, 1},
  {&__pyx_n_s_task, __pyx_k_task, sizeof(__pyx_k_task), 0, 0, 1, 1},
  {&__pyx_n_s_task2, __pyx_k_task2, sizeof(__pyx_k_task2), 0, 0, 1, 1},
  {&__pyx_n_s_tasks, __pyx_k_tasks, sizeof(__pyx_k_tasks), 0, 0, 1, 1},
  {&__pyx_n_s_term, __pyx_k_term, sizeof(__pyx_k_term), 0, 0, 1, 1},
  {&__pyx_n_s_terms, __pyx_k_terms, sizeof(__pyx_k_terms), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_tl, __pyx_k_tl, sizeof(__pyx_k_tl), 0, 0, 1, 1},
  {&__pyx_n_s_todo, __pyx_k_todo, sizeof(__pyx_k_todo), 0, 0, 1, 1},
  {&__pyx_n_s_unify, __pyx_k_unify, sizeof(__pyx_k_unify), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_use_setstate, __pyx_k_use_setstate, sizeof(__pyx_k_use_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_kp_s_variable__s, __pyx_k_variable__s, sizeof(__pyx_k_variable__s), 0, 0, 1, 0},
  {&__pyx_n_s_waiters, __pyx_k_waiters, sizeof(__pyx_k_waiters), 0, 0, 1, 1},
  {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
  {&__pyx_n_s_words, __pyx_k_words, sizeof(__pyx_k_words), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 315, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(0, 58, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 226, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 271, __pyx_L1_error)
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 321, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 604, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 730, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 969, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "pyDatalog/pyEngine.py":342
 *                 o.prearity = None
 *                 words = o.name.split('.')
 *                 o.prefix, o.suffix = (words[0], words[1].split('[')[0]) if 1 < len(words) else ('','')             # <<<<<<<<<<<<<<
 *                 words = pred_name.split(']')
 *                 o.comparison = words[1] if 1 < len(words) else '' # for f[X]<Y
 */
  __pyx_tuple__15 = PyTuple_Pack(2, __pyx_kp_s__14, __pyx_kp_s__14); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "pyDatalog/pyEngine.py":333
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 *         with Pred.lock:             # <<<<<<<<<<<<<<
 *             o = Logic.tl.logic.Pred_registry.get(_id, Interned.notFound)
 *             if o is Interned.notFound:
 */
  __pyx_tuple__17 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "pyDatalog/pyEngine.py":405
 *             self.pred.prearity = len(terms) if prearity is None else prearity
 *             if pred.startswith('~'): #pred
 *                 self.pred.base_pred = Pred(pred[1:], len(terms))             # <<<<<<<<<<<<<<
 *                 self.pred.base_pred.prearity = self.pred.prearity
 *         else:
 */
  __pyx_slice__20 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__20);
  __Pyx_GIVEREF(__pyx_slice__20);

  /* "pyDatalog/pyEngine.py":433
 * 
 *     def __str__(self):
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))             # <<<<<<<<<<<<<<
 * 
 *     def get_id(self): #id
 */
  __pyx_tuple__23 = PyTuple_Pack(2, __pyx_kp_s_pyD_class, __pyx_kp_s__7); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "pyDatalog/pyEngine.py":572
 *     Class_dict[name] = cls
 *     #prefixed replace the first term of each functional comparison literal for that class..
 *     env = {Var(name).id: Const('_pyD_class')}             # <<<<<<<<<<<<<<
 *     for pred in Logic.tl.logic.Db.values():
 *         for clause in pred.db.values():
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_n_s_pyD_class_2); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "pyDatalog/pyEngine.py":976
 *             print(" ")
 * 
 *         task = (None, None); tasks = None             # <<<<<<<<<<<<<<
 *         if not Ts.Goal.is_done:
 *             if Ts.Recursive:
 */
  __pyx_tuple__30 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 976, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "pyDatalog/pyEngine.py":1086
 *               NEXT_CLAUSE: "Next clause",
 *               ON_COMPLETION: "On completion"}
 *     result = "{:40s}.. : ".format(str(task[1][0])[:40]) + result[task[0]] + " " + str(task[1][1:])             # <<<<<<<<<<<<<<
 *     return result if len(result)<110 else result[:110]
 * 
 */
  __pyx_slice__31 = PySlice_New(Py_None, __pyx_int_40, Py_None); if (unlikely(!__pyx_slice__31)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__31);
  __Pyx_GIVEREF(__pyx_slice__31);

  /* "pyDatalog/pyEngine.py":1087
 *               ON_COMPLETION: "On completion"}
 *     result = "{:40s}.. : ".format(str(task[1][0])[:40]) + result[task[0]] + " " + str(task[1][1:])
 *     return result if len(result)<110 else result[:110]             # <<<<<<<<<<<<<<
 * 
 * # PRIMITIVES   ##################################################
 */
  __pyx_slice__32 = PySlice_New(Py_None, __pyx_int_110, Py_None); if (unlikely(!__pyx_slice__32)) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__32);
  __Pyx_GIVEREF(__pyx_slice__32);

  /* "pyDatalog/pyEngine.py":1167
 *     Fresh_var.tl.counter = 0
 * 
 *     insert(Pred("==", 2)).prim = equals_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("<" , 2)).prim = compare_primitive
 *     insert(Pred("<=", 2)).prim = compare_primitive
 */
  __pyx_tuple__38 = PyTuple_Pack(2, __pyx_kp_s_, __pyx_int_2); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "pyDatalog/pyEngine.py":1168
 * 
 *     insert(Pred("==", 2)).prim = equals_primitive
 *     insert(Pred("<" , 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("<=", 2)).prim = compare_primitive
 *     insert(Pred("!=", 2)).prim = compare_primitive
 */
  __pyx_tuple__39 = PyTuple_Pack(2, __pyx_kp_s__34, __pyx_int_2); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "pyDatalog/pyEngine.py":1169
 *     insert(Pred("==", 2)).prim = equals_primitive
 *     insert(Pred("<" , 2)).prim = compare_primitive
 *     insert(Pred("<=", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("!=", 2)).prim = compare_primitive
 *     insert(Pred(">=", 2)).prim = compare_primitive
 */
  __pyx_tuple__40 = PyTuple_Pack(2, __pyx_kp_s__35, __pyx_int_2); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "pyDatalog/pyEngine.py":1170
 *     insert(Pred("<" , 2)).prim = compare_primitive
 *     insert(Pred("<=", 2)).prim = compare_primitive
 *     insert(Pred("!=", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred(">=", 2)).prim = compare_primitive
 *     insert(Pred(">" , 2)).prim = compare_primitive
 */
  __pyx_tuple__41 = PyTuple_Pack(2, __pyx_kp_s__33, __pyx_int_2); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "pyDatalog/pyEngine.py":1171
 *     insert(Pred("<=", 2)).prim = compare_primitive
 *     insert(Pred("!=", 2)).prim = compare_primitive
 *     insert(Pred(">=", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred(">" , 2)).prim = compare_primitive
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive
 */
  __pyx_tuple__42 = PyTuple_Pack(2, __pyx_kp_s__36, __pyx_int_2); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "pyDatalog/pyEngine.py":1172
 *     insert(Pred("!=", 2)).prim = compare_primitive
 *     insert(Pred(">=", 2)).prim = compare_primitive
 *     insert(Pred(">" , 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive
 *     insert(Pred("_pyD_not_in", 2)).prim = compare_primitive
 */
  __pyx_tuple__43 = PyTuple_Pack(2, __pyx_kp_s__37, __pyx_int_2); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1172, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "pyDatalog/pyEngine.py":1173
 *     insert(Pred(">=", 2)).prim = compare_primitive
 *     insert(Pred(">" , 2)).prim = compare_primitive
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 *     insert(Pred("_pyD_not_in", 2)).prim = compare_primitive
 */
  __pyx_tuple__44 = PyTuple_Pack(2, __pyx_n_s_pyD_in, __pyx_int_2); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "pyDatalog/pyEngine.py":1174
 *     insert(Pred(">" , 2)).prim = compare_primitive
 *     insert(Pred("_pyD_in", 2)).prim = compare_primitive
 *     insert(Pred("_pyD_not_in", 2)).prim = compare_primitive             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__45 = PyTuple_Pack(2, __pyx_n_s_pyD_not_in, __pyx_int_2); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xb80bb77, 0xa561452, 0x87ea5df):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb80bb77, 0xa561452, 0x87ea5df) = (id))" % __pyx_checksum)
 */
  __pyx_tuple__46 = PyTuple_Pack(3, __pyx_int_192985975, __pyx_int_173413458, __pyx_int_142517727); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);
  __pyx_tuple__47 = PyTuple_Pack(3, __pyx_int_161349669, __pyx_int_228639504, __pyx_int_53105071); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_tuple__48 = PyTuple_Pack(3, __pyx_int_149462077, __pyx_int_23793036, __pyx_int_46030840); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);
  __pyx_tuple__49 = PyTuple_Pack(3, __pyx_int_239816442, __pyx_int_128353530, __pyx_int_50874197); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_tuple__50 = PyTuple_Pack(3, __pyx_int_228449516, __pyx_int_248641737, __pyx_int_165197223); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);
  __pyx_tuple__51 = PyTuple_Pack(3, __pyx_int_25690925, __pyx_int_220575563, __pyx_int_124008633); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "pyDatalog/pyEngine.py":53
 * #       DATA TYPES          #####################################
 * 
 * def Term_of(atom):             # <<<<<<<<<<<<<<
 *     """ factory function for Term """
 *     if isinstance(atom, Term):
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_n_s_atom); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);
  __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_Term_of, 53, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 53, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__54 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);
  __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Term__set_state(self, __pyx_state)
 */
  __pyx_tuple__56 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);
  __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":76
 *         self.id = ('f', Fresh_var.tl.counter) #id
 * 
 *     def is_const(self):             # <<<<<<<<<<<<<<
 *         return False
 *     def get_tag(self, env): #id
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);
  __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_is_const, 76, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 76, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":78
 *     def is_const(self):
 *         return False
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 */
  __pyx_tuple__60 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);
  __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_tag, 78, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 78, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":81
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle
 */
  __pyx_tuple__62 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);
  __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst, 81, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 81, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":83
 *     def subst(self, env): #unify
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify
 */
  __pyx_tuple__64 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);
  __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_shuffle, 83, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 83, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":85
 *     def shuffle(self, env): #shuffle
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         # try ... except is not faster
 *         return env[self.id].chase(env) if self.id in env else self
 */
  __pyx_tuple__66 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);
  __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_chase, 85, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 85, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":89
 *         return env[self.id].chase(env) if self.id in env else self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         if self.id not in env:
 *             env[self.id] = constant
 */
  __pyx_tuple__68 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_constant, __pyx_n_s_env); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);
  __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_match, 89, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(0, 89, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":98
 *             return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */
  __pyx_tuple__70 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_env); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);
  __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__70, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_unify, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) __PYX_ERR(0, 98, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":110
 *     def __str__(self):
 *         return "variable_%s" % self.id[1]
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         """ by default, self==term fails """
 *         return None
 */
  __pyx_tuple__72 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_subgoal); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);
  __pyx_codeobj__73 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_equals_primitive, 110, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__73)) __PYX_ERR(0, 110, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__74 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);
  __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Fresh_var__set_state(self, __pyx_state)
 */
  __pyx_tuple__76 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);
  __pyx_codeobj__77 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__76, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__77)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":124
 *         return self.id[1]
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return Fresh_var.unify(self, term, env)
 * 
 */
  __pyx_tuple__78 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_env); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);
  __pyx_codeobj__79 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__78, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_unify, 124, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__79)) __PYX_ERR(0, 124, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__80 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);
  __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Var__set_state(self, __pyx_state)
 */
  __pyx_tuple__82 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);
  __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__82, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":135
 *         self.id = _id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);
  __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_is_const, 135, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) __PYX_ERR(0, 135, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":138
 *         return True
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */
  __pyx_tuple__86 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);
  __pyx_codeobj__87 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__86, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_tag, 138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__87)) __PYX_ERR(0, 138, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":141
 *         return self.id
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 *     def shuffle(self, env): #shuffle
 */
  __pyx_tuple__88 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);
  __pyx_codeobj__89 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__88, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst, 141, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__89)) __PYX_ERR(0, 141, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":143
 *     def subst(self, env): #unify
 *         return self
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return self
 *     def chase(self, env): #unify
 */
  __pyx_tuple__90 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);
  __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__90, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_shuffle, 143, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) __PYX_ERR(0, 143, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":145
 *     def shuffle(self, env): #shuffle
 *         return self
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_tuple__92 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);
  __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__92, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_chase, 145, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 145, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":148
 *         return self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_tuple__94 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_constant, __pyx_n_s_env); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);
  __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__94, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_match, 148, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 148, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":151
 *         return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */
  __pyx_tuple__96 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_env); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);
  __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_unify, 151, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(0, 151, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":159
 *     def __str__(self):
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */
  __pyx_tuple__98 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_subgoal, __pyx_n_s_literal); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);
  __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__98, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_equals_primitive, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 159, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__100 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);
  __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__100, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Const__set_state(self, __pyx_state)
 */
  __pyx_tuple__102 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);
  __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__102, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":174
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return self.is_constant
 * 
 */
  __pyx_tuple__104 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);
  __pyx_codeobj__105 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__104, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_is_const, 174, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__105)) __PYX_ERR(0, 174, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":180
 *         return len(self._id)
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self.id
 */
  __pyx_tuple__106 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_codeobj__107 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__106, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_tag, 180, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__107)) __PYX_ERR(0, 180, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":189
 *         return tuple(result)
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self
 */
  __pyx_tuple__108 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);
  __pyx_codeobj__109 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__108, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst, 189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__109)) __PYX_ERR(0, 189, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":198
 *         return VarTuple(result)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */
  __pyx_tuple__110 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);
  __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_shuffle, 198, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(0, 198, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":206
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */
  __pyx_tuple__112 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);
  __pyx_codeobj__113 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_chase, 206, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__113)) __PYX_ERR(0, 206, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":217
 *     # def match is not needed here
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */
  __pyx_tuple__114 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_env); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);
  __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_unify, 217, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(0, 217, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":236
 *     def __str__(self):
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */
  __pyx_tuple__116 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_subgoal, __pyx_n_s_literal); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);
  __pyx_codeobj__117 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__116, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_equals_primitive, 236, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__117)) __PYX_ERR(0, 236, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__118 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);
  __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VarTuple__set_state(self, __pyx_state)
 */
  __pyx_tuple__120 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);
  __pyx_codeobj__121 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__121)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":253
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_tuple__122 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);
  __pyx_codeobj__123 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__122, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_is_const, 253, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__123)) __PYX_ERR(0, 253, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":256
 *         return False
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 */
  __pyx_tuple__124 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);
  __pyx_codeobj__125 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__124, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_tag, 256, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__125)) __PYX_ERR(0, 256, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":259
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 */
  __pyx_tuple__126 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);
  __pyx_codeobj__127 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst, 259, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__127)) __PYX_ERR(0, 259, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":302
 *             return Term_of(e)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 */
  __pyx_tuple__128 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);
  __pyx_codeobj__129 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__128, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_shuffle, 302, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__129)) __PYX_ERR(0, 302, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":305
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 */
  __pyx_tuple__130 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);
  __pyx_codeobj__131 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__130, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_chase, 305, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__131)) __PYX_ERR(0, 305, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":308
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_tuple__132 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_term, __pyx_n_s_env); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_codeobj__133 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__132, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_unify, 308, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__133)) __PYX_ERR(0, 308, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__134 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);
  __pyx_codeobj__135 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__134, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__135)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Operation__set_state(self, __pyx_state)
 */
  __pyx_tuple__136 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__136)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);
  __pyx_codeobj__137 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__136, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__137)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":315
 * 
 * 
 * class Interned(object):             # <<<<<<<<<<<<<<
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 */
  __pyx_tuple__138 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__138)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);

  /* "pyDatalog/pyEngine.py":318
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 *     def __eq__(self, other):             # <<<<<<<<<<<<<<
 *         return self is other
 *     def __hash__(self):
 */
  __pyx_tuple__139 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_other); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__139);
  __Pyx_GIVEREF(__pyx_tuple__139);
  __pyx_codeobj__140 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__139, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_eq, 318, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__140)) __PYX_ERR(0, 318, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":320
 *     def __eq__(self, other):
 *         return self is other
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return id(self)
 *     def __ne__(self, other):
 */
  __pyx_tuple__141 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__141)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__141);
  __Pyx_GIVEREF(__pyx_tuple__141);
  __pyx_codeobj__142 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__141, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_hash, 320, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__142)) __PYX_ERR(0, 320, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":322
 *     def __hash__(self):
 *         return id(self)
 *     def __ne__(self, other):             # <<<<<<<<<<<<<<
 *         return self is not other
 * 
 */
  __pyx_tuple__143 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_other); if (unlikely(!__pyx_tuple__143)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__143);
  __Pyx_GIVEREF(__pyx_tuple__143);
  __pyx_codeobj__144 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__143, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_ne, 322, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__144)) __PYX_ERR(0, 322, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":330
 *         It can also have a function used to implement a primitive."""
 *     lock = threading.RLock()
 *     def __new__(cls, pred_name, arity):             # <<<<<<<<<<<<<<
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 */
  __pyx_tuple__145 = PyTuple_Pack(7, __pyx_n_s_cls, __pyx_n_s_pred_name, __pyx_n_s_arity, __pyx_n_s_id_2, __pyx_n_s_o, __pyx_n_s_words, __pyx_n_s_i); if (unlikely(!__pyx_tuple__145)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_GIVEREF(__pyx_tuple__145);
  __pyx_codeobj__146 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__145, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_new, 330, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__146)) __PYX_ERR(0, 330, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":357
 * 
 *     @classmethod
 *     def is_known(cls, pred_id):             # <<<<<<<<<<<<<<
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 */
  __pyx_tuple__147 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_pred_id, __pyx_n_s_prefix, __pyx_n_s_rebased); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);
  __pyx_codeobj__148 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__147, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_is_known, 357, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__148)) __PYX_ERR(0, 357, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":367
 *         return False
 * 
 *     def _class(self):             # <<<<<<<<<<<<<<
 *         """determine the python class for a prefixed predicate (and caches it)"""
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 */
  __pyx_tuple__149 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__149)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__149);
  __Pyx_GIVEREF(__pyx_tuple__149);
  __pyx_codeobj__150 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__149, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_class, 367, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__150)) __PYX_ERR(0, 367, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":374
 *         return self._cls
 * 
 *     def parent_classes(self):             # <<<<<<<<<<<<<<
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 */
  __pyx_tuple__151 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_cls); if (unlikely(!__pyx_tuple__151)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__151);
  __Pyx_GIVEREF(__pyx_tuple__151);
  __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__151, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_parent_classes, 374, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 374, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":383
 *             yield None
 * 
 *     def reset_clauses(self):             # <<<<<<<<<<<<<<
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():
 */
  __pyx_tuple__152 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_clause); if (unlikely(!__pyx_tuple__152)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__152);
  __Pyx_GIVEREF(__pyx_tuple__152);
  __pyx_codeobj__153 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__152, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_reset_clauses, 383, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__153)) __PYX_ERR(0, 383, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":388
 *             retract(clause)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s()" % self.name
 * 
 */
  __pyx_tuple__154 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__154)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__154);
  __Pyx_GIVEREF(__pyx_tuple__154);
  __pyx_codeobj__155 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__154, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_str, 388, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__155)) __PYX_ERR(0, 388, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":411
 *             # TODO assert self.pred.prearity == (prearity or len(terms)), "Error: Incorrect mix of predicates and functions : %s" % str(self)
 * 
 *     def _renamed(self, new_name):             # <<<<<<<<<<<<<<
 *         _id = '%s/%i' % (new_name, len(self.terms))
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)
 */
  __pyx_tuple__156 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_new_name, __pyx_n_s_id_2, __pyx_n_s_pred); if (unlikely(!__pyx_tuple__156)) __PYX_ERR(0, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__156);
  __Pyx_GIVEREF(__pyx_tuple__156);
  __pyx_codeobj__157 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__156, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_renamed, 411, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__157)) __PYX_ERR(0, 411, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":416
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)
 * 
 *     def rebased(self, parent_class):             # <<<<<<<<<<<<<<
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred
 */
  __pyx_tuple__158 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_parent_class, __pyx_n_s_pred); if (unlikely(!__pyx_tuple__158)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__158);
  __Pyx_GIVEREF(__pyx_tuple__158);
  __pyx_codeobj__159 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__158, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_rebased, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__159)) __PYX_ERR(0, 416, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":423
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 * 
 *     def equalized(self):             # <<<<<<<<<<<<<<
 *         """ returns a new literal with '==' instead of comparison """
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 */
  __pyx_tuple__160 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__160)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__160);
  __Pyx_GIVEREF(__pyx_tuple__160);
  __pyx_codeobj__161 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__160, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_equalized, 423, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__161)) __PYX_ERR(0, 423, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":427
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 * 
 *     def subst_first(self, env): #prefixed             # <<<<<<<<<<<<<<
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:
 */
  __pyx_tuple__162 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__162)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__162);
  __Pyx_GIVEREF(__pyx_tuple__162);
  __pyx_codeobj__163 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__162, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst_first, 427, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__163)) __PYX_ERR(0, 427, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":435
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two literals are structurally the
 *             same if they have the same id.  """
 */
  __pyx_tuple__164 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__164)) __PYX_ERR(0, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__164);
  __Pyx_GIVEREF(__pyx_tuple__164);
  __pyx_codeobj__165 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__164, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_id, 435, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__165)) __PYX_ERR(0, 435, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":446
 *         return self.id
 * 
 *     def get_fact_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id of a known fact is limited by its prearity
 *             Prearity is used to ensure unicity of results of functions like pred[2]==1 """
 */
  __pyx_tuple__166 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__166)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__166);
  __Pyx_GIVEREF(__pyx_tuple__166);
  __pyx_codeobj__167 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__166, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_fact_id, 446, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__167)) __PYX_ERR(0, 446, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":451
 *         return self.get_id()[:1+self.pred.prearity]
 * 
 *     def get_tag(self): #id             # <<<<<<<<<<<<<<
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached
 */
  __pyx_tuple__168 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__168)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__168);
  __Pyx_GIVEREF(__pyx_tuple__168);
  __pyx_codeobj__169 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__168, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_tag, 451, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__169)) __PYX_ERR(0, 451, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":462
 *         return self.tag
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if not env: return self
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 */
  __pyx_tuple__170 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__170)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__170);
  __Pyx_GIVEREF(__pyx_tuple__170);
  __pyx_codeobj__171 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__170, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst, 462, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__171)) __PYX_ERR(0, 462, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":470
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         result = []
 *         for term in self.terms:
 */
  __pyx_tuple__172 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_env); if (unlikely(!__pyx_tuple__172)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__172);
  __Pyx_GIVEREF(__pyx_tuple__172);
  __pyx_codeobj__173 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__172, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_shuffle, 470, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__173)) __PYX_ERR(0, 470, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":476
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def unify(self, other): #unify             # <<<<<<<<<<<<<<
 *         if self.pred != other.pred: return None
 *         env = {}
 */
  __pyx_tuple__174 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_other); if (unlikely(!__pyx_tuple__174)) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__174);
  __Pyx_GIVEREF(__pyx_tuple__174);
  __pyx_codeobj__175 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__174, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_unify, 476, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__175)) __PYX_ERR(0, 476, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":496
 *         return env
 * 
 *     def match(self, terms):             # <<<<<<<<<<<<<<
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}
 */
  __pyx_tuple__176 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_terms); if (unlikely(!__pyx_tuple__176)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__176);
  __Pyx_GIVEREF(__pyx_tuple__176);
  __pyx_codeobj__177 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__176, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_match, 496, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__177)) __PYX_ERR(0, 496, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":505
 *         return env
 * 
 *     def ask(self):             # <<<<<<<<<<<<<<
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 */
  __pyx_tuple__178 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_Ts, __pyx_n_s_saved_environment, __pyx_n_s_todo, __pyx_n_s_arg, __pyx_n_s_result, __pyx_n_s_literal, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__178)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__178);
  __Pyx_GIVEREF(__pyx_tuple__178);
  __pyx_codeobj__179 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__178, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_ask, 505, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__179)) __PYX_ERR(0, 505, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__180 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__180)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__180);
  __Pyx_GIVEREF(__pyx_tuple__180);
  __pyx_codeobj__181 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__180, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__181)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Literal__set_state(self, __pyx_state)
 */
  __pyx_tuple__182 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__182)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__182);
  __Pyx_GIVEREF(__pyx_tuple__182);
  __pyx_codeobj__183 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__182, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__183)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":540
 *         retract(self)
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two clauses are structurally equal
 *             if they have the same id.  A clause's id is used as a key into the
 */
  __pyx_tuple__184 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__184)) __PYX_ERR(0, 540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__184);
  __Pyx_GIVEREF(__pyx_tuple__184);
  __pyx_codeobj__185 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__184, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_get_id, 540, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__185)) __PYX_ERR(0, 540, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":551
 *         return self.id
 * 
 *     def subst(self, env, parent_class=None):             # <<<<<<<<<<<<<<
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self
 */
  __pyx_tuple__186 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_env, __pyx_n_s_parent_class, __pyx_n_s_bodi); if (unlikely(!__pyx_tuple__186)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__186);
  __Pyx_GIVEREF(__pyx_tuple__186);
  __pyx_codeobj__187 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__186, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_subst, 551, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__187)) __PYX_ERR(0, 551, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":560
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 * 
 *     def rename(self):             # <<<<<<<<<<<<<<
 *         """ returns the clause with fresh variables """
 *         env = {}
 */
  __pyx_tuple__188 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_env, __pyx_n_s_bodi); if (unlikely(!__pyx_tuple__188)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__188);
  __Pyx_GIVEREF(__pyx_tuple__188);
  __pyx_codeobj__189 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__188, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_rename, 560, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__189)) __PYX_ERR(0, 560, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__190 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__190)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__190);
  __Pyx_GIVEREF(__pyx_tuple__190);
  __pyx_codeobj__191 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__190, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__191)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Clause__set_state(self, __pyx_state)
 */
  __pyx_tuple__192 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__192)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__192);
  __Pyx_GIVEREF(__pyx_tuple__192);
  __pyx_codeobj__193 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__192, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__193)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":567
 * 
 * 
 * def add_class(cls, name):             # <<<<<<<<<<<<<<
 *     """ Update the list of pyDatalog-capable classes, and update clauses accordingly"""
 *     # this is needed because class definition could occur after clause definition
 */
  __pyx_tuple__194 = PyTuple_Pack(6, __pyx_n_s_cls, __pyx_n_s_name, __pyx_n_s_env, __pyx_n_s_pred, __pyx_n_s_clause, __pyx_n_s_literal); if (unlikely(!__pyx_tuple__194)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__194);
  __Pyx_GIVEREF(__pyx_tuple__194);
  __pyx_codeobj__195 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__194, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_add_class, 567, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__195)) __PYX_ERR(0, 567, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":584
 * # The database stores predicates that contain clauses.
 * 
 * def insert(pred):             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Db[pred.id] = pred
 *     return pred
 */
  __pyx_tuple__196 = PyTuple_Pack(1, __pyx_n_s_pred); if (unlikely(!__pyx_tuple__196)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__196);
  __Pyx_GIVEREF(__pyx_tuple__196);
  __pyx_codeobj__197 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__196, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_insert, 584, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__197)) __PYX_ERR(0, 584, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":588
 *     return pred
 * 
 * def remove(pred):             # <<<<<<<<<<<<<<
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]
 */
  __pyx_tuple__198 = PyTuple_Pack(1, __pyx_n_s_pred); if (unlikely(!__pyx_tuple__198)) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__198);
  __Pyx_GIVEREF(__pyx_tuple__198);
  __pyx_codeobj__199 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__198, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_remove, 588, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__199)) __PYX_ERR(0, 588, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":595
 *     return pred
 * 
 * def assert_(clause):             # <<<<<<<<<<<<<<
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred
 */
  __pyx_tuple__200 = PyTuple_Pack(8, __pyx_n_s_clause, __pyx_n_s_pred, __pyx_n_s_id_3, __pyx_n_s_i, __pyx_n_s_term, __pyx_n_s_clauses, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__200)) __PYX_ERR(0, 595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__200);
  __Pyx_GIVEREF(__pyx_tuple__200);
  __pyx_codeobj__201 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__200, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_assert, 595, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__201)) __PYX_ERR(0, 595, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":614
 *     return clause
 * 
 * def retract(clause):             # <<<<<<<<<<<<<<
 *     """ retract a clause from the database"""
 *     pred = clause.head.pred
 */
  __pyx_tuple__202 = PyTuple_Pack(5, __pyx_n_s_clause, __pyx_n_s_pred, __pyx_n_s_id_3, __pyx_n_s_i, __pyx_n_s_term); if (unlikely(!__pyx_tuple__202)) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__202);
  __Pyx_GIVEREF(__pyx_tuple__202);
  __pyx_codeobj__203 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__202, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_retract, 614, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__203)) __PYX_ERR(0, 614, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":633
 *     return clause
 * 
 * def relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 */
  __pyx_tuple__204 = PyTuple_Pack(6, __pyx_n_s_literal, __pyx_n_s_result, __pyx_n_s_i, __pyx_n_s_term, __pyx_n_s_facts, __pyx_n_s_v); if (unlikely(!__pyx_tuple__204)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__204);
  __Pyx_GIVEREF(__pyx_tuple__204);
  __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__204, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_relevant_clauses, 633, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 633, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":686
 *         return str(self.literal)
 * 
 *     def search(self):             # <<<<<<<<<<<<<<
 *         """
 *         Search for derivations of the literal associated with this subgoal
 */
  __pyx_tuple__205 = PyTuple_Pack(20, __pyx_n_s_self, __pyx_n_s_literal0, __pyx_n_s_class0, __pyx_n_s_terms, __pyx_n_s_base_literal, __pyx_n_s_class, __pyx_n_s_literal, __pyx_n_s_resolver, __pyx_n_s_result, __pyx_n_s_method_name, __pyx_n_s_results, __pyx_n_s_base_terms, __pyx_n_s_i, __pyx_n_s_clause, __pyx_n_s_renamed_2, __pyx_n_s_env, __pyx_n_s_literal1, __pyx_n_s_Y1, __pyx_n_s_literal2, __pyx_n_s_v); if (unlikely(!__pyx_tuple__205)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__205);
  __Pyx_GIVEREF(__pyx_tuple__205);
  __pyx_codeobj__206 = (PyObject*)__Pyx_PyCode_New(1, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__205, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_search, 686, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__206)) __PYX_ERR(0, 686, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":817
 *     ################## add derived facts and use rules ##############
 * 
 *     def add_clause(self, clause):             # <<<<<<<<<<<<<<
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed
 */
  __pyx_tuple__207 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_clause); if (unlikely(!__pyx_tuple__207)) __PYX_ERR(0, 817, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__207);
  __Pyx_GIVEREF(__pyx_tuple__207);
  __pyx_codeobj__208 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__207, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_add_clause, 817, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__208)) __PYX_ERR(0, 817, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":828
 *         return self.next_step()
 * 
 *     def fact(self, literal):             # <<<<<<<<<<<<<<
 *         """
 *         Store a derived fact, and inform all waiters of the fact too.
 */
  __pyx_tuple__209 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_literal); if (unlikely(!__pyx_tuple__209)) __PYX_ERR(0, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__209);
  __Pyx_GIVEREF(__pyx_tuple__209);
  __pyx_codeobj__210 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__209, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_fact, 828, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__210)) __PYX_ERR(0, 828, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":875
 *                         self.waiters = []
 * 
 *     def fact_candidate(self, class0, result):             # <<<<<<<<<<<<<<
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:
 */
  __pyx_tuple__211 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_class0, __pyx_n_s_result); if (unlikely(!__pyx_tuple__211)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__211);
  __Pyx_GIVEREF(__pyx_tuple__211);
  __pyx_codeobj__212 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__211, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_fact_candidate, 875, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__212)) __PYX_ERR(0, 875, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":888
 *             self.fact(Literal(self.literal.pred.name, result))
 * 
 *     def rule(self, clause, selected):             # <<<<<<<<<<<<<<
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 */
  __pyx_tuple__213 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_clause, __pyx_n_s_selected); if (unlikely(!__pyx_tuple__213)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__213);
  __Pyx_GIVEREF(__pyx_tuple__213);
  __pyx_codeobj__214 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__213, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_rule, 888, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__214)) __PYX_ERR(0, 888, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":916
 *     # by delaying the evaluation of some functions
 * 
 *     def schedule(self, task):             # <<<<<<<<<<<<<<
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))
 */
  __pyx_tuple__215 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_task); if (unlikely(!__pyx_tuple__215)) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__215);
  __Pyx_GIVEREF(__pyx_tuple__215);
  __pyx_codeobj__216 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__215, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_schedule, 916, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__216)) __PYX_ERR(0, 916, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":934
 *             self.tasks.append(task)
 * 
 *     def schedule_search(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive
 */
  __pyx_tuple__217 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_subgoal); if (unlikely(!__pyx_tuple__217)) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__217);
  __Pyx_GIVEREF(__pyx_tuple__217);
  __pyx_codeobj__218 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__217, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_schedule_search, 934, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__218)) __PYX_ERR(0, 934, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":952
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 * 
 *     def next_step(self):             # <<<<<<<<<<<<<<
 *         """ returns the next step in the resolution """
 *         Ts = Logic.tl.logic
 */
  __pyx_tuple__219 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_Ts, __pyx_n_s_fact, __pyx_n_s_task, __pyx_n_s_tasks, __pyx_n_s_task2); if (unlikely(!__pyx_tuple__219)) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__219);
  __Pyx_GIVEREF(__pyx_tuple__219);
  __pyx_codeobj__220 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__219, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_next_step, 952, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__220)) __PYX_ERR(0, 952, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1000
 *         return task
 * 
 *     def next_clause(self):             # <<<<<<<<<<<<<<
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 */
  __pyx_tuple__221 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_task); if (unlikely(!__pyx_tuple__221)) __PYX_ERR(0, 1000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__221);
  __Pyx_GIVEREF(__pyx_tuple__221);
  __pyx_codeobj__222 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__221, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_next_clause, 1000, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__222)) __PYX_ERR(0, 1000, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1014
 *         return self.next_step()
 * 
 *     def searching(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 */
  __pyx_tuple__223 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_subgoal, __pyx_n_s_Ts, __pyx_n_s_pos, __pyx_n_s_task, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__223)) __PYX_ERR(0, 1014, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__223);
  __Pyx_GIVEREF(__pyx_tuple__223);
  __pyx_codeobj__224 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__223, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_searching, 1014, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__224)) __PYX_ERR(0, 1014, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1047
 *         return self.next_step()
 * 
 *     def complete(self, literal, aggregate=None):             # <<<<<<<<<<<<<<
 *         """makes sure that subgoal is completed before calling post_thunk and resuming processing"""
 *         #TODO check for infinite loops
 */
  __pyx_tuple__225 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_literal, __pyx_n_s_aggregate); if (unlikely(!__pyx_tuple__225)) __PYX_ERR(0, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__225);
  __Pyx_GIVEREF(__pyx_tuple__225);
  __pyx_codeobj__226 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__225, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_complete, 1047, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__226)) __PYX_ERR(0, 1047, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1059
 *         subgoal.on_completion_.append( (ON_COMPLETION, (subgoal, self, aggregate)) )
 * 
 *     def on_completion(self, parent, aggregate):             # <<<<<<<<<<<<<<
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *             Logger.debug('Processing aggregate or negation')
 */
  __pyx_tuple__227 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_parent, __pyx_n_s_aggregate); if (unlikely(!__pyx_tuple__227)) __PYX_ERR(0, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__227);
  __Pyx_GIVEREF(__pyx_tuple__227);
  __pyx_codeobj__228 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__227, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_on_completion_2, 1059, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__228)) __PYX_ERR(0, 1059, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_tuple__229 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_state, __pyx_n_s_dict_2, __pyx_n_s_use_setstate); if (unlikely(!__pyx_tuple__229)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__229);
  __Pyx_GIVEREF(__pyx_tuple__229);
  __pyx_codeobj__230 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__229, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__230)) __PYX_ERR(1, 1, __pyx_L1_error)

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Subgoal__set_state(self, __pyx_state)
 */
  __pyx_tuple__231 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__231)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__231);
  __Pyx_GIVEREF(__pyx_tuple__231);
  __pyx_codeobj__232 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__231, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__232)) __PYX_ERR(1, 16, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1078
 * ON_COMPLETION = Subgoal.on_completion
 * 
 * def show(task):             # <<<<<<<<<<<<<<
 *     if task == (None, None):
 *         return
 */
  __pyx_tuple__233 = PyTuple_Pack(2, __pyx_n_s_task, __pyx_n_s_result); if (unlikely(!__pyx_tuple__233)) __PYX_ERR(0, 1078, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__233);
  __Pyx_GIVEREF(__pyx_tuple__233);
  __pyx_codeobj__234 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__233, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_show, 1078, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__234)) __PYX_ERR(0, 1078, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1116
 * """
 * 
 * def equals_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */
  __pyx_tuple__235 = PyTuple_Pack(5, __pyx_n_s_literal, __pyx_n_s_subgoal, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_env); if (unlikely(!__pyx_tuple__235)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__235);
  __Pyx_GIVEREF(__pyx_tuple__235);
  __pyx_codeobj__236 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__235, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_equals_primitive, 1116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__236)) __PYX_ERR(0, 1116, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1126
 *     return x.equals_primitive(y, subgoal)
 * 
 * def compare_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */
  __pyx_tuple__237 = PyTuple_Pack(5, __pyx_n_s_literal, __pyx_n_s_subgoal, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_v); if (unlikely(!__pyx_tuple__237)) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__237);
  __Pyx_GIVEREF(__pyx_tuple__237);
  __pyx_codeobj__238 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__237, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_compare_primitive, 1126, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__238)) __PYX_ERR(0, 1126, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1147
 * 
 * # generic comparison function
 * def compare(l,op,r):             # <<<<<<<<<<<<<<
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 */
  __pyx_tuple__239 = PyTuple_Pack(3, __pyx_n_s_l, __pyx_n_s_op, __pyx_n_s_r); if (unlikely(!__pyx_tuple__239)) __PYX_ERR(0, 1147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__239);
  __Pyx_GIVEREF(__pyx_tuple__239);
  __pyx_codeobj__240 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__239, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_compare, 1147, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__240)) __PYX_ERR(0, 1147, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1150
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 * def compare2(l,op,r):             # <<<<<<<<<<<<<<
 *     return l._in(r) if op=='_pyD_in' else l._not_in(r) if op=='_pyD_not_in' else compare(l,op,r)
 * 
 */
  __pyx_tuple__241 = PyTuple_Pack(3, __pyx_n_s_l, __pyx_n_s_op, __pyx_n_s_r); if (unlikely(!__pyx_tuple__241)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__241);
  __Pyx_GIVEREF(__pyx_tuple__241);
  __pyx_codeobj__242 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__241, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_compare2, 1150, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__242)) __PYX_ERR(0, 1150, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":1155
 * # Initialization   ##################################################
 * 
 * def clear():             # <<<<<<<<<<<<<<
 *     """ clears the logic """
 *     Logic.tl.logic.Db = {}
 */
  __pyx_codeobj__243 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyDatalog_pyEngine_py, __pyx_n_s_clear, 1155, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__243)) __PYX_ERR(0, 1155, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_Term(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__244 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__244)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__244);
  __Pyx_GIVEREF(__pyx_tuple__244);
  __pyx_codeobj__245 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__244, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Term, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__245)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__246 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__246)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__246);
  __Pyx_GIVEREF(__pyx_tuple__246);
  __pyx_codeobj__247 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__246, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Fresh_var, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__247)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__248 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__248)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__248);
  __Pyx_GIVEREF(__pyx_tuple__248);
  __pyx_codeobj__249 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__248, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Var, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__249)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__250 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__250)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__250);
  __Pyx_GIVEREF(__pyx_tuple__250);
  __pyx_codeobj__251 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__250, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Const, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__251)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__252 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__252)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__252);
  __Pyx_GIVEREF(__pyx_tuple__252);
  __pyx_codeobj__253 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__252, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_VarTuple, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__253)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__254 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__254)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__254);
  __Pyx_GIVEREF(__pyx_tuple__254);
  __pyx_codeobj__255 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__254, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Operation, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__255)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__256 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__256)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__256);
  __Pyx_GIVEREF(__pyx_tuple__256);
  __pyx_codeobj__257 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__256, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Literal, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__257)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__258 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__258)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__258);
  __Pyx_GIVEREF(__pyx_tuple__258);
  __pyx_codeobj__259 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__258, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Clause, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__259)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__260 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__260)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__260);
  __Pyx_GIVEREF(__pyx_tuple__260);
  __pyx_codeobj__261 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__260, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Subgoal, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__261)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_setdefault.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_40 = PyInt_FromLong(40); if (unlikely(!__pyx_int_40)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_110 = PyInt_FromLong(110); if (unlikely(!__pyx_int_110)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_23793036 = PyInt_FromLong(23793036L); if (unlikely(!__pyx_int_23793036)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_25690925 = PyInt_FromLong(25690925L); if (unlikely(!__pyx_int_25690925)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_46030840 = PyInt_FromLong(46030840L); if (unlikely(!__pyx_int_46030840)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_50874197 = PyInt_FromLong(50874197L); if (unlikely(!__pyx_int_50874197)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_53105071 = PyInt_FromLong(53105071L); if (unlikely(!__pyx_int_53105071)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_124008633 = PyInt_FromLong(124008633L); if (unlikely(!__pyx_int_124008633)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_128353530 = PyInt_FromLong(128353530L); if (unlikely(!__pyx_int_128353530)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_142517727 = PyInt_FromLong(142517727L); if (unlikely(!__pyx_int_142517727)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_149462077 = PyInt_FromLong(149462077L); if (unlikely(!__pyx_int_149462077)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_161349669 = PyInt_FromLong(161349669L); if (unlikely(!__pyx_int_161349669)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_165197223 = PyInt_FromLong(165197223L); if (unlikely(!__pyx_int_165197223)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_173413458 = PyInt_FromLong(173413458L); if (unlikely(!__pyx_int_173413458)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_192985975 = PyInt_FromLong(192985975L); if (unlikely(!__pyx_int_192985975)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_220575563 = PyInt_FromLong(220575563L); if (unlikely(!__pyx_int_220575563)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_228449516 = PyInt_FromLong(228449516L); if (unlikely(!__pyx_int_228449516)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_228639504 = PyInt_FromLong(228639504L); if (unlikely(!__pyx_int_228639504)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_239816442 = PyInt_FromLong(239816442L); if (unlikely(!__pyx_int_239816442)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_248641737 = PyInt_FromLong(248641737L); if (unlikely(!__pyx_int_248641737)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Term) < 0) __PYX_ERR(0, 63, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Term.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Term.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Term.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Term.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Term, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Term) < 0) __PYX_ERR(0, 63, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Term) < 0) __PYX_ERR(0, 63, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Term = &__pyx_type_9pyDatalog_8pyEngine_Term;
  __pyx_vtabptr_9pyDatalog_8pyEngine_Fresh_var = &__pyx_vtable_9pyDatalog_8pyEngine_Fresh_var;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.is_const = (PyBoolObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_is_const;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.get_tag = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_get_tag;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.subst = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_subst;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.shuffle = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_shuffle;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.chase = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_chase;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.match = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_match;
  __pyx_vtable_9pyDatalog_8pyEngine_Fresh_var.unify = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Fresh_var_unify;
  __pyx_type_9pyDatalog_8pyEngine_Fresh_var.tp_base = __pyx_ptype_9pyDatalog_8pyEngine_Term;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Fresh_var) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Fresh_var.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Fresh_var.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Fresh_var.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Fresh_var.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_Fresh_var.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_Fresh_var) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Fresh_var, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Fresh_var) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Fresh_var) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Fresh_var = &__pyx_type_9pyDatalog_8pyEngine_Fresh_var;
  __pyx_vtabptr_9pyDatalog_8pyEngine_Var = &__pyx_vtable_9pyDatalog_8pyEngine_Var;
  __pyx_vtable_9pyDatalog_8pyEngine_Var.__pyx_base = *__pyx_vtabptr_9pyDatalog_8pyEngine_Fresh_var;
  __pyx_vtable_9pyDatalog_8pyEngine_Var.__pyx_base.unify = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Fresh_var *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_3Var_unify;
  __pyx_type_9pyDatalog_8pyEngine_Var.tp_base = __pyx_ptype_9pyDatalog_8pyEngine_Fresh_var;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Var) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Var.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Var.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Var.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Var.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_Var.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_Var) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Var, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Var) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Var) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Var = &__pyx_type_9pyDatalog_8pyEngine_Var;
  __pyx_vtabptr_9pyDatalog_8pyEngine_Const = &__pyx_vtable_9pyDatalog_8pyEngine_Const;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.is_const = (PyBoolObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_is_const;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.get_tag = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_get_tag;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.subst = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_subst;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.shuffle = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_shuffle;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.chase = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_chase;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.match = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_match;
  __pyx_vtable_9pyDatalog_8pyEngine_Const.unify = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Const *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_5Const_unify;
  __pyx_type_9pyDatalog_8pyEngine_Const.tp_base = __pyx_ptype_9pyDatalog_8pyEngine_Term;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Const) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Const.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Const.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Const.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Const.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_Const.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_Const) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Const, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Const) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Const) < 0) __PYX_ERR(0, 128, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Const = &__pyx_type_9pyDatalog_8pyEngine_Const;
  __pyx_vtabptr_9pyDatalog_8pyEngine_VarTuple = &__pyx_vtable_9pyDatalog_8pyEngine_VarTuple;
  __pyx_vtable_9pyDatalog_8pyEngine_VarTuple.is_const = (PyBoolObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_8VarTuple_is_const;
  __pyx_vtable_9pyDatalog_8pyEngine_VarTuple.get_tag = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_8VarTuple_get_tag;
  __pyx_vtable_9pyDatalog_8pyEngine_VarTuple.subst = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_8VarTuple_subst;
  __pyx_vtable_9pyDatalog_8pyEngine_VarTuple.shuffle = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_8VarTuple_shuffle;
  __pyx_vtable_9pyDatalog_8pyEngine_VarTuple.chase = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_8VarTuple_chase;
  __pyx_vtable_9pyDatalog_8pyEngine_VarTuple.unify = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_VarTuple *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_8VarTuple_unify;
  __pyx_type_9pyDatalog_8pyEngine_VarTuple.tp_base = __pyx_ptype_9pyDatalog_8pyEngine_Term;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_VarTuple) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_VarTuple.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_VarTuple.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_VarTuple.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_VarTuple.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_VarTuple.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_VarTuple) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_VarTuple, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_VarTuple) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_VarTuple) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_VarTuple = &__pyx_type_9pyDatalog_8pyEngine_VarTuple;
  __pyx_vtabptr_9pyDatalog_8pyEngine_Operation = &__pyx_vtable_9pyDatalog_8pyEngine_Operation;
  __pyx_vtable_9pyDatalog_8pyEngine_Operation.is_const = (PyBoolObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Operation_is_const;
  __pyx_vtable_9pyDatalog_8pyEngine_Operation.get_tag = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Operation_get_tag;
  __pyx_vtable_9pyDatalog_8pyEngine_Operation.subst = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Operation_subst;
  __pyx_vtable_9pyDatalog_8pyEngine_Operation.shuffle = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Operation_shuffle;
  __pyx_vtable_9pyDatalog_8pyEngine_Operation.chase = (struct __pyx_obj_9pyDatalog_8pyEngine_Term *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Operation_chase;
  __pyx_vtable_9pyDatalog_8pyEngine_Operation.unify = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Operation *, struct __pyx_obj_9pyDatalog_8pyEngine_Term *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_9Operation_unify;
  __pyx_type_9pyDatalog_8pyEngine_Operation.tp_base = __pyx_ptype_9pyDatalog_8pyEngine_Term;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Operation) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Operation.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Operation.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Operation.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Operation.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_Operation.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_Operation) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Operation, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Operation) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Operation) < 0) __PYX_ERR(0, 242, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Operation = &__pyx_type_9pyDatalog_8pyEngine_Operation;
  __pyx_vtabptr_9pyDatalog_8pyEngine_Literal = &__pyx_vtable_9pyDatalog_8pyEngine_Literal;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.get_tag = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_get_tag;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.subst = (struct __pyx_obj_9pyDatalog_8pyEngine_Literal *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_subst;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.shuffle = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_shuffle;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.unify = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_unify;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.get_id = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_get_id;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.get_fact_id = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_get_fact_id;
  __pyx_vtable_9pyDatalog_8pyEngine_Literal.match = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Literal_match;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Literal) < 0) __PYX_ERR(0, 392, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Literal.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Literal.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Literal.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Literal.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_Literal.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_Literal) < 0) __PYX_ERR(0, 392, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Literal, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Literal) < 0) __PYX_ERR(0, 392, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Literal) < 0) __PYX_ERR(0, 392, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Literal = &__pyx_type_9pyDatalog_8pyEngine_Literal;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Clause) < 0) __PYX_ERR(0, 522, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Clause.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Clause.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Clause.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Clause.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_UPDATE_DESCRIPTOR_DOC
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Clause, "__neg__"); if (unlikely(!wrapper)) __PYX_ERR(0, 522, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_9pyDatalog_8pyEngine_6Clause_6__neg__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_9pyDatalog_8pyEngine_6Clause_6__neg__.doc = __pyx_doc_9pyDatalog_8pyEngine_6Clause_6__neg__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9pyDatalog_8pyEngine_6Clause_6__neg__;
    }
  }
  #endif
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Clause, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Clause) < 0) __PYX_ERR(0, 522, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Clause) < 0) __PYX_ERR(0, 522, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Clause = &__pyx_type_9pyDatalog_8pyEngine_Clause;
  __pyx_vtabptr_9pyDatalog_8pyEngine_Subgoal = &__pyx_vtable_9pyDatalog_8pyEngine_Subgoal;
  __pyx_vtable_9pyDatalog_8pyEngine_Subgoal.fact = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact;
  __pyx_vtable_9pyDatalog_8pyEngine_Subgoal.fact_candidate = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Subgoal_fact_candidate;
  __pyx_vtable_9pyDatalog_8pyEngine_Subgoal.rule = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, struct __pyx_obj_9pyDatalog_8pyEngine_Clause *, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Subgoal_rule;
  __pyx_vtable_9pyDatalog_8pyEngine_Subgoal.schedule = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, PyObject *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule;
  __pyx_vtable_9pyDatalog_8pyEngine_Subgoal.schedule_search = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, int __pyx_skip_dispatch))__pyx_f_9pyDatalog_8pyEngine_7Subgoal_schedule_search;
  __pyx_vtable_9pyDatalog_8pyEngine_Subgoal.complete = (PyObject *(*)(struct __pyx_obj_9pyDatalog_8pyEngine_Subgoal *, struct __pyx_obj_9pyDatalog_8pyEngine_Literal *, int __pyx_skip_dispatch, struct __pyx_opt_args_9pyDatalog_8pyEngine_7Subgoal_complete *__pyx_optional_args))__pyx_f_9pyDatalog_8pyEngine_7Subgoal_complete;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine_Subgoal) < 0) __PYX_ERR(0, 665, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine_Subgoal.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine_Subgoal.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine_Subgoal.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine_Subgoal.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_9pyDatalog_8pyEngine_Subgoal.tp_dict, __pyx_vtabptr_9pyDatalog_8pyEngine_Subgoal) < 0) __PYX_ERR(0, 665, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Subgoal, (PyObject *)&__pyx_type_9pyDatalog_8pyEngine_Subgoal) < 0) __PYX_ERR(0, 665, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9pyDatalog_8pyEngine_Subgoal) < 0) __PYX_ERR(0, 665, __pyx_L1_error)
  __pyx_ptype_9pyDatalog_8pyEngine_Subgoal = &__pyx_type_9pyDatalog_8pyEngine_Subgoal;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct____init__ = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct____init__;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr) < 0) __PYX_ERR(0, 172, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_2_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes) < 0) __PYX_ERR(0, 374, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_3_parent_classes;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask) < 0) __PYX_ERR(0, 505, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_4_ask;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr) < 0) __PYX_ERR(0, 517, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_5_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__) < 0) __PYX_ERR(0, 532, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__ = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_6___str__;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr) < 0) __PYX_ERR(0, 533, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_7_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__ = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_8___repr__;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr) < 0) __PYX_ERR(0, 535, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_9_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_10_get_id;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr) < 0) __PYX_ERR(0, 548, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_11_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_) < 0) __PYX_ERR(0, 595, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_ = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_12_assert_;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr) < 0) __PYX_ERR(0, 608, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_13_genexpr;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses) < 0) __PYX_ERR(0, 633, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_14_relevant_clauses;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching) < 0) __PYX_ERR(0, 1014, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_15_searching;
  if (PyType_Ready(&__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr) < 0) __PYX_ERR(0, 1026, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr.tp_dictoffset && __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr = &__pyx_type_9pyDatalog_8pyEngine___pyx_scope_struct_16_genexpr;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(5, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initpyEngine(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initpyEngine(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_pyEngine(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_pyEngine(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_pyEngine(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'pyEngine' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pyEngine(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  PyEval_InitThreads();
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("pyEngine", __pyx_methods, __pyx_k_This_file_is_part_of_pyDatalog, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_pyDatalog__pyEngine) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "pyDatalog.pyEngine")) {
      if (unlikely(PyDict_SetItemString(modules, "pyDatalog.pyEngine", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "pyDatalog/pyEngine.py":29
 * """
 * 
 * from collections import deque, OrderedDict             # <<<<<<<<<<<<<<
 * import gc
 * import logging
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_deque);
  __Pyx_GIVEREF(__pyx_n_s_deque);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_deque);
  __Pyx_INCREF(__pyx_n_s_OrderedDict);
  __Pyx_GIVEREF(__pyx_n_s_OrderedDict);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_OrderedDict);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_deque); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_deque, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":30
 * 
 * from collections import deque, OrderedDict
 * import gc             # <<<<<<<<<<<<<<
 * import logging
 * import re
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_gc, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gc, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":31
 * from collections import deque, OrderedDict
 * import gc
 * import logging             # <<<<<<<<<<<<<<
 * import re
 * import threading
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":32
 * import gc
 * import logging
 * import re             # <<<<<<<<<<<<<<
 * import threading
 * import weakref
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_re, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_2) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":33
 * import logging
 * import re
 * import threading             # <<<<<<<<<<<<<<
 * import weakref
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_threading, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":34
 * import re
 * import threading
 * import weakref             # <<<<<<<<<<<<<<
 * 
 * from . import util
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_weakref, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_weakref, __pyx_t_2) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":36
 * import weakref
 * 
 * from . import util             # <<<<<<<<<<<<<<
 * 
 * Logging = False # True --> Logging is activated.  Kept for performance reason
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_util);
  __pyx_t_1 = __Pyx_Import(__pyx_kp_s__14, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":38
 * from . import util
 * 
 * Logging = False # True --> Logging is activated.  Kept for performance reason             # <<<<<<<<<<<<<<
 * 
 * Auto_print = False # True => automatically prints the result of a query
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logging, Py_False) < 0) __PYX_ERR(0, 38, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":40
 * Logging = False # True --> Logging is activated.  Kept for performance reason
 * 
 * Auto_print = False # True => automatically prints the result of a query             # <<<<<<<<<<<<<<
 * Slow_motion = False # True => detail print of the stack of tasks at each step
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Auto_print, Py_False) < 0) __PYX_ERR(0, 40, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":41
 * 
 * Auto_print = False # True => automatically prints the result of a query
 * Slow_motion = False # True => detail print of the stack of tasks at each step             # <<<<<<<<<<<<<<
 * 
 * Python_resolvers = {} # dictionary  of python functions that can resolve a predicate
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Slow_motion, Py_False) < 0) __PYX_ERR(0, 41, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":43
 * Slow_motion = False # True => detail print of the stack of tasks at each step
 * 
 * Python_resolvers = {} # dictionary  of python functions that can resolve a predicate             # <<<<<<<<<<<<<<
 * Logic = None # place holder for Logic class from Logic module
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Python_resolvers, __pyx_t_1) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":44
 * 
 * Python_resolvers = {} # dictionary  of python functions that can resolve a predicate
 * Logic = None # place holder for Logic class from Logic module             # <<<<<<<<<<<<<<
 * 
 * # Keep a dictionary of classes with datalog capabilities.
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logic, Py_None) < 0) __PYX_ERR(0, 44, __pyx_L1_error)

  /* "pyDatalog/pyEngine.py":47
 * 
 * # Keep a dictionary of classes with datalog capabilities.
 * Class_dict = {}             # <<<<<<<<<<<<<<
 * 
 * Logger = logging.getLogger(__name__)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Class_dict, __pyx_t_1) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":49
 * Class_dict = {}
 * 
 * Logger = logging.getLogger(__name__)             # <<<<<<<<<<<<<<
 * 
 * #       DATA TYPES          #####################################
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Logger, __pyx_t_3) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":53
 * #       DATA TYPES          #####################################
 * 
 * def Term_of(atom):             # <<<<<<<<<<<<<<
 *     """ factory function for Term """
 *     if isinstance(atom, Term):
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_1Term_of, 0, __pyx_n_s_Term_of, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Term_of, __pyx_t_3) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Term_1__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Term___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__55)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Term->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Term);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Term, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Term__set_state(self, __pyx_state)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Term_3__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Term___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Term->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Term);

  /* "pyDatalog/pyEngine.py":70
 * class Fresh_var(Term):
 *     """ a variable created by the search algorithm """
 *     __slots__ = ['id']             # <<<<<<<<<<<<<<
 *     tl = threading.local()
 *     def __init__(self):
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_id);
  __Pyx_GIVEREF(__pyx_n_s_id);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_id);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_slots, __pyx_t_3) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":71
 *     """ a variable created by the search algorithm """
 *     __slots__ = ['id']
 *     tl = threading.local()             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         Fresh_var.tl.counter = Fresh_var.tl.counter +1
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_threading); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_local); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_tl, __pyx_t_3) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":76
 *         self.id = ('f', Fresh_var.tl.counter) #id
 * 
 *     def is_const(self):             # <<<<<<<<<<<<<<
 *         return False
 *     def get_tag(self, env): #id
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_3is_const, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_is_const, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_is_const, __pyx_t_3) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":78
 *     def is_const(self):
 *         return False
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_5get_tag, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_get_tag, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_get_tag, __pyx_t_3) < 0) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":81
 *         return env.setdefault(self.id, ('v', len(env)))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_7subst, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_subst, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_subst, __pyx_t_3) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":83
 *     def subst(self, env): #unify
 *         return env.get(self.id, self)
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_9shuffle, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_shuffle, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_shuffle, __pyx_t_3) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":85
 *     def shuffle(self, env): #shuffle
 *         return env.setdefault(self.id, Fresh_var())
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         # try ... except is not faster
 *         return env[self.id].chase(env) if self.id in env else self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_11chase, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_chase, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_chase, __pyx_t_3) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":89
 *         return env[self.id].chase(env) if self.id in env else self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         if self.id not in env:
 *             env[self.id] = constant
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_13match, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_match, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_match, __pyx_t_3) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":98
 *             return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_15unify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_unify, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_unify, __pyx_t_3) < 0) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":110
 *     def __str__(self):
 *         return "variable_%s" % self.id[1]
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         """ by default, self==term fails """
 *         return None
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_19equals_primitive, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var_equals_primitive, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__73)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_equals_primitive, __pyx_t_3) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_21__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Fresh_var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Fresh_var__set_state(self, __pyx_state)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Fresh_var_23__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Fresh_var___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__77)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Fresh_var);

  /* "pyDatalog/pyEngine.py":117
 * class Var(Fresh_var):
 *     """ A variable in a clause or query """
 *     __slots__ = ['id']             # <<<<<<<<<<<<<<
 *     def __init__(self, name):
 *         self.id = ('f', name) #id
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_id);
  __Pyx_GIVEREF(__pyx_n_s_id);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_id);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Var->tp_dict, __pyx_n_s_slots, __pyx_t_3) < 0) __PYX_ERR(0, 117, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Var);

  /* "pyDatalog/pyEngine.py":124
 *         return self.id[1]
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return Fresh_var.unify(self, term, env)
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_3Var_5unify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Var_unify, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__79)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Var->tp_dict, __pyx_n_s_unify, __pyx_t_3) < 0) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Var);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_3Var_7__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Var___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Var->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Var);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Var, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Var__set_state(self, __pyx_state)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_3Var_9__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Var___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__83)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Var->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Var);

  /* "pyDatalog/pyEngine.py":130
 * class Const(Term):
 *     """ a constant """
 *     __slots__ = ['id']             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, _id):
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_id);
  __Pyx_GIVEREF(__pyx_n_s_id);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_id);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_slots, __pyx_t_3) < 0) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":135
 *         self.id = _id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_3is_const, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_is_const, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__85)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_is_const, __pyx_t_3) < 0) __PYX_ERR(0, 135, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":138
 *         return True
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return self.id
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_5get_tag, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_get_tag, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__87)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_get_tag, __pyx_t_3) < 0) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":141
 *         return self.id
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 *     def shuffle(self, env): #shuffle
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_7subst, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_subst, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__89)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_subst, __pyx_t_3) < 0) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":143
 *     def subst(self, env): #unify
 *         return self
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return self
 *     def chase(self, env): #unify
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_9shuffle, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_shuffle, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__91)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_shuffle, __pyx_t_3) < 0) __PYX_ERR(0, 143, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":145
 *     def shuffle(self, env): #shuffle
 *         return self
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_11chase, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_chase, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__93)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_chase, __pyx_t_3) < 0) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":148
 *         return self
 * 
 *     def match(self, constant, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_13match, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_match, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__95)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_match, __pyx_t_3) < 0) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":151
 *         return None
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_15unify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_unify, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__97)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_unify, __pyx_t_3) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":159
 *     def __str__(self):
 *         return "'%s'" % self.id
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_19equals_primitive, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const_equals_primitive, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__99)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_equals_primitive, __pyx_t_3) < 0) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_21__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__101)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Const, (type(self), 0xb80bb77, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Const__set_state(self, __pyx_state)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5Const_23__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Const___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__103)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Const->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Const);

  /* "pyDatalog/pyEngine.py":167
 * class VarTuple(Term):
 *     """ a tuple / list of variables, constants or tuples """
 *     __slots__ = ['_id', 'id', 'is_constant']             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, _id): # _id is a list of Term
 */
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_id_2);
  __Pyx_GIVEREF(__pyx_n_s_id_2);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_id_2);
  __Pyx_INCREF(__pyx_n_s_id);
  __Pyx_GIVEREF(__pyx_n_s_id);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_id);
  __Pyx_INCREF(__pyx_n_s_is_constant);
  __Pyx_GIVEREF(__pyx_n_s_is_constant);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_is_constant);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_slots, __pyx_t_3) < 0) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":174
 *         self.is_constant = all(element.is_const() for element in _id)
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return self.is_constant
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_3is_const, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_is_const, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__105)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_is_const, __pyx_t_3) < 0) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":180
 *         return len(self._id)
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self.id
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_7get_tag, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_get_tag, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__107)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_get_tag, __pyx_t_3) < 0) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":189
 *         return tuple(result)
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant: # can use lazy property only for constants
 *             return self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_9subst, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_subst, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__109)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_subst, __pyx_t_3) < 0) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":198
 *         return VarTuple(result)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_11shuffle, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_shuffle, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__111)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_shuffle, __pyx_t_3) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":206
 *                 result.append(element.shuffle(env))
 *             return VarTuple(result)
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         if self.is_constant:
 *             return self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_13chase, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_chase, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__113)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_chase, __pyx_t_3) < 0) __PYX_ERR(0, 206, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":217
 *     # def match is not needed here
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         if isinstance(term, Fresh_var):
 *             env[term.id] = self
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_15unify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_unify, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__115)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_unify, __pyx_t_3) < 0) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":236
 *     def __str__(self):
 *         return "'%s'" % str([str(e) for e in self.id])
 *     def equals_primitive(self, term, subgoal):             # <<<<<<<<<<<<<<
 *         if self.id == term.id:          # Both terms are constant and equal.
 *             literal = Literal("==", [self, self])
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_19equals_primitive, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple_equals_primitive, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__117)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_equals_primitive, __pyx_t_3) < 0) __PYX_ERR(0, 236, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_21__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__119)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_VarTuple, (type(self), 0x99e0025, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_VarTuple__set_state(self, __pyx_state)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8VarTuple_23__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_VarTuple___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__121)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_VarTuple->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_VarTuple);

  /* "pyDatalog/pyEngine.py":244
 * class Operation(Term):
 *     """ an arithmetic operation, a slice or a lambda """
 *     counter = util.Counter()             # <<<<<<<<<<<<<<
 *     def __init__(self, lhs, operator, rhs):
 *         self.operator = operator
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_counter, __pyx_t_3) < 0) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":253
 *         self.id = (self.lhs.id, self.operator_id, self.rhs.id) #id
 * 
 *     def is_const(self): # for backward compatibility with custom resolvers             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_3is_const, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation_is_const, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__123)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_is_const, __pyx_t_3) < 0) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":256
 *         return False
 * 
 *     def get_tag(self, env): #id             # <<<<<<<<<<<<<<
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_5get_tag, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation_get_tag, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__125)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_get_tag, __pyx_t_3) < 0) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":259
 *         return (self.lhs.get_tag(env), self.operator_id, self.rhs.get_tag(env))
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         lhs = self.lhs.subst(env)
 *         rhs = self.rhs.subst(env)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_7subst, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation_subst, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__127)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_subst, __pyx_t_3) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":302
 *             return Term_of(e)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_9shuffle, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation_shuffle, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__129)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_shuffle, __pyx_t_3) < 0) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":305
 *         return Operation(self.lhs.shuffle(env), self.operator, self.rhs.shuffle(env))
 * 
 *     def chase(self, env): #unify             # <<<<<<<<<<<<<<
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_11chase, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation_chase, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__131)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_chase, __pyx_t_3) < 0) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":308
 *         return Operation(self.lhs.chase(env), self.operator, self.rhs.chase(env))
 * 
 *     def unify(self, term, env):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_13unify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation_unify, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__133)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_unify, __pyx_t_3) < 0) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_17__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__135)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Operation, (type(self), 0x8e89c3d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Operation__set_state(self, __pyx_state)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9Operation_19__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Operation___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__137)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Operation->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Operation);

  /* "pyDatalog/pyEngine.py":315
 * 
 * 
 * class Interned(object):             # <<<<<<<<<<<<<<
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 */
  __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__138); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_3, __pyx_tuple__138, __pyx_n_s_Interned, __pyx_n_s_Interned, (PyObject *) NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_kp_s_Abstract_class_for_objects_havi); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "pyDatalog/pyEngine.py":317
 * class Interned(object):
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()             # <<<<<<<<<<<<<<
 *     def __eq__(self, other):
 *         return self is other
 */
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_notFound, __pyx_t_2) < 0) __PYX_ERR(0, 317, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":318
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 *     def __eq__(self, other):             # <<<<<<<<<<<<<<
 *         return self is other
 *     def __hash__(self):
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8Interned_1__eq__, 0, __pyx_n_s_Interned___eq, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__140)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_eq, __pyx_t_2) < 0) __PYX_ERR(0, 318, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":320
 *     def __eq__(self, other):
 *         return self is other
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return id(self)
 *     def __ne__(self, other):
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8Interned_3__hash__, 0, __pyx_n_s_Interned___hash, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__142)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_hash, __pyx_t_2) < 0) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":322
 *     def __hash__(self):
 *         return id(self)
 *     def __ne__(self, other):             # <<<<<<<<<<<<<<
 *         return self is not other
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_8Interned_5__ne__, 0, __pyx_n_s_Interned___ne, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__144)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_ne, __pyx_t_2) < 0) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pyDatalog/pyEngine.py":315
 * 
 * 
 * class Interned(object):             # <<<<<<<<<<<<<<
 *     """ Abstract class for objects having only one instance in memory """
 *     notFound = object()
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_3, __pyx_n_s_Interned, __pyx_tuple__138, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Interned, __pyx_t_2) < 0) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pyDatalog/pyEngine.py":326
 * 
 * 
 * class Pred(Interned):             # <<<<<<<<<<<<<<
 *     """ A predicate symbol has a name, an arity, and a database table.
 *         It can also have a function used to implement a primitive."""
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Interned); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_3, __pyx_t_1, __pyx_n_s_Pred, __pyx_n_s_Pred, (PyObject *) NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_kp_s_A_predicate_symbol_has_a_name_a); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "pyDatalog/pyEngine.py":329
 *     """ A predicate symbol has a name, an arity, and a database table.
 *         It can also have a function used to implement a primitive."""
 *     lock = threading.RLock()             # <<<<<<<<<<<<<<
 *     def __new__(cls, pred_name, arity):
 *         assert isinstance(pred_name, util.string_types)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_threading); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_RLock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_lock, __pyx_t_4) < 0) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pyDatalog/pyEngine.py":330
 *         It can also have a function used to implement a primitive."""
 *     lock = threading.RLock()
 *     def __new__(cls, pred_name, arity):             # <<<<<<<<<<<<<<
 *         assert isinstance(pred_name, util.string_types)
 *         _id = '%s/%i' % (pred_name, arity)
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Pred_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_Pred___new, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__146)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_new, __pyx_t_4) < 0) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pyDatalog/pyEngine.py":357
 * 
 *     @classmethod
 *     def is_known(cls, pred_id):             # <<<<<<<<<<<<<<
 *         #TODO look at _pyD_ methods in classes, to detect more
 *         prefix = pred_id.split('.')[0] # we assumes it has a '.'
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Pred_3is_known, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_Pred_is_known, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__148)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "pyDatalog/pyEngine.py":356
 *         return o
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def is_known(cls, pred_id):
 *         #TODO look at _pyD_ methods in classes, to detect more
 */
  __pyx_t_6 = __Pyx_Method_ClassMethod(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_is_known, __pyx_t_6) < 0) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":367
 *         return False
 * 
 *     def _class(self):             # <<<<<<<<<<<<<<
 *         """determine the python class for a prefixed predicate (and caches it)"""
 *         # cannot be done at initialization, because the global Class_dict is not filled in yet
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Pred_5_class, 0, __pyx_n_s_Pred__class, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__150)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_class, __pyx_t_6) < 0) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":374
 *         return self._cls
 * 
 *     def parent_classes(self):             # <<<<<<<<<<<<<<
 *         " iterator of the parent classes that have pyDatalog capabilities"
 *         if self._class():
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Pred_7parent_classes, 0, __pyx_n_s_Pred_parent_classes, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_parent_classes, __pyx_t_6) < 0) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":383
 *             yield None
 * 
 *     def reset_clauses(self):             # <<<<<<<<<<<<<<
 *         """ clears the database of clauses for the predicate """
 *         for clause in self.clauses.values():
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Pred_10reset_clauses, 0, __pyx_n_s_Pred_reset_clauses, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__153)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_reset_clauses, __pyx_t_6) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":388
 *             retract(clause)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s()" % self.name
 * 
 */
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_4Pred_12__str__, 0, __pyx_n_s_Pred___str, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__155)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_str, __pyx_t_6) < 0) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "pyDatalog/pyEngine.py":326
 * 
 * 
 * class Pred(Interned):             # <<<<<<<<<<<<<<
 *     """ A predicate symbol has a name, an arity, and a database table.
 *         It can also have a function used to implement a primitive."""
 */
  __pyx_t_6 = __Pyx_Py3ClassCreate(__pyx_t_3, __pyx_n_s_Pred, __pyx_t_1, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Pred, __pyx_t_6) < 0) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":396
 *         the number of which must match the predicate's arity.
 *     """
 *     __slots__ = ['terms', 'pred', 'id', 'tag', 'aggregate']             # <<<<<<<<<<<<<<
 *     def __init__(self, pred, terms, prearity=None, aggregate=None):
 *         self.terms = terms
 */
  __pyx_t_1 = PyList_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_terms);
  __Pyx_GIVEREF(__pyx_n_s_terms);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_terms);
  __Pyx_INCREF(__pyx_n_s_pred);
  __Pyx_GIVEREF(__pyx_n_s_pred);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_pred);
  __Pyx_INCREF(__pyx_n_s_id);
  __Pyx_GIVEREF(__pyx_n_s_id);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_id);
  __Pyx_INCREF(__pyx_n_s_tag);
  __Pyx_GIVEREF(__pyx_n_s_tag);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_tag);
  __Pyx_INCREF(__pyx_n_s_aggregate);
  __Pyx_GIVEREF(__pyx_n_s_aggregate);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_aggregate);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_slots, __pyx_t_1) < 0) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":411
 *             # TODO assert self.pred.prearity == (prearity or len(terms)), "Error: Incorrect mix of predicates and functions : %s" % str(self)
 * 
 *     def _renamed(self, new_name):             # <<<<<<<<<<<<<<
 *         _id = '%s/%i' % (new_name, len(self.terms))
 *         pred= Logic.tl.logic.Pred_registry.get(_id, new_name)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_3_renamed, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal__renamed, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__157)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_renamed, __pyx_t_1) < 0) __PYX_ERR(0, 411, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":416
 *         return Literal(pred, list(self.terms), prearity=self.pred.prearity, aggregate=self.aggregate)
 * 
 *     def rebased(self, parent_class):             # <<<<<<<<<<<<<<
 *         """ returns a literal prefixed by parent class """
 *         pred = self.pred
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_5rebased, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_rebased, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__159)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_rebased, __pyx_t_1) < 0) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":423
 *         return self._renamed(re.sub('^((~)?)'+pred._class().__name__+'.', r'\1'+parent_class.__name__+'.', pred.name))
 * 
 *     def equalized(self):             # <<<<<<<<<<<<<<
 *         """ returns a new literal with '==' instead of comparison """
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_7equalized, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_equalized, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__161)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_equalized, __pyx_t_1) < 0) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":427
 *         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
 * 
 *     def subst_first(self, env): #prefixed             # <<<<<<<<<<<<<<
 *         """ substitute the first term of prefixed literal, using env """
 *         if self.pred.prefix:
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_9subst_first, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_subst_first, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__163)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_subst_first, __pyx_t_1) < 0) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":435
 *         return "%s(%s)" % (self.pred.name, ','.join([str(term).replace("'_pyD_class'", '*') for term in self.terms]))
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two literals are structurally the
 *             same if they have the same id.  """
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_13get_id, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_get_id, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__165)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_get_id, __pyx_t_1) < 0) __PYX_ERR(0, 435, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":446
 *         return self.id
 * 
 *     def get_fact_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id of a known fact is limited by its prearity
 *             Prearity is used to ensure unicity of results of functions like pred[2]==1 """
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_15get_fact_id, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_get_fact_id, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__167)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_get_fact_id, __pyx_t_1) < 0) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":451
 *         return self.get_id()[:1+self.pred.prearity]
 * 
 *     def get_tag(self): #id             # <<<<<<<<<<<<<<
 *         """ the tag is used as a key by the subgoal table """
 *         if not self.tag: # cached
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_17get_tag, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_get_tag, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__169)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_get_tag, __pyx_t_1) < 0) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":462
 *         return self.tag
 * 
 *     def subst(self, env): #unify             # <<<<<<<<<<<<<<
 *         if not env: return self
 *         #Cython equivalent for : return Literal(self.pred, [term.subst(env) for term in self.terms], aggregate=self.aggregate)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_19subst, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_subst, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__171)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_subst, __pyx_t_1) < 0) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":470
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def shuffle(self, env): #shuffle             # <<<<<<<<<<<<<<
 *         result = []
 *         for term in self.terms:
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_21shuffle, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_shuffle, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__173)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_shuffle, __pyx_t_1) < 0) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":476
 *         return Literal(self.pred, result, aggregate=self.aggregate)
 * 
 *     def unify(self, other): #unify             # <<<<<<<<<<<<<<
 *         if self.pred != other.pred: return None
 *         env = {}
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_23unify, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_unify, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__175)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_unify, __pyx_t_1) < 0) __PYX_ERR(0, 476, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":496
 *         return env
 * 
 *     def match(self, terms):             # <<<<<<<<<<<<<<
 *         """ Does a fact unify with a fact known to contain only constant terms? """
 *         env = {}
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_25match, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_match, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__177)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_match, __pyx_t_1) < 0) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":505
 *         return env
 * 
 *     def ask(self):             # <<<<<<<<<<<<<<
 *         """ Invoke the tasks. Each task may append new tasks on the schedule."""
 *         Ts = Logic.tl.logic
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_27ask, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal_ask, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__179)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_ask, __pyx_t_1) < 0) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_29__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__181)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Literal, (type(self), 0xe4b4efa, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Literal__set_state(self, __pyx_state)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Literal_31__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Literal___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__183)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Literal->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Literal);

  /* "pyDatalog/pyEngine.py":526
 *         true.  If there are no literals in the body, the clause is a fact
 *     """
 *     __slots__ = ['head', 'body', 'id']             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, head, body):
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_head);
  __Pyx_GIVEREF(__pyx_n_s_head);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_head);
  __Pyx_INCREF(__pyx_n_s_body);
  __Pyx_GIVEREF(__pyx_n_s_body);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_body);
  __Pyx_INCREF(__pyx_n_s_id);
  __Pyx_GIVEREF(__pyx_n_s_id);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_id);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause->tp_dict, __pyx_n_s_slots, __pyx_t_1) < 0) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Clause);

  /* "pyDatalog/pyEngine.py":540
 *         retract(self)
 * 
 *     def get_id(self): #id             # <<<<<<<<<<<<<<
 *         """ The id's encoding ensures that two clauses are structurally equal
 *             if they have the same id.  A clause's id is used as a key into the
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_6Clause_9get_id, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Clause_get_id, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__185)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause->tp_dict, __pyx_n_s_get_id, __pyx_t_1) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Clause);

  /* "pyDatalog/pyEngine.py":551
 *         return self.id
 * 
 *     def subst(self, env, parent_class=None):             # <<<<<<<<<<<<<<
 *         """ apply the env mapping and rebase to parent_class, if any """
 *         if not env and not parent_class: return self
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_6Clause_11subst, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Clause_subst, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__187)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause->tp_dict, __pyx_n_s_subst, __pyx_t_1) < 0) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Clause);

  /* "pyDatalog/pyEngine.py":560
 *                         [bodi.subst(env).rebased(parent_class) for bodi in self.body])
 * 
 *     def rename(self):             # <<<<<<<<<<<<<<
 *         """ returns the clause with fresh variables """
 *         env = {}
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_6Clause_13rename, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Clause_rename, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__189)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause->tp_dict, __pyx_n_s_rename, __pyx_t_1) < 0) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Clause);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_6Clause_15__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Clause___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__191)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Clause);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Clause, (type(self), 0xd9ddcec, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Clause__set_state(self, __pyx_state)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_6Clause_17__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Clause___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__193)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Clause->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Clause);

  /* "pyDatalog/pyEngine.py":567
 * 
 * 
 * def add_class(cls, name):             # <<<<<<<<<<<<<<
 *     """ Update the list of pyDatalog-capable classes, and update clauses accordingly"""
 *     # this is needed because class definition could occur after clause definition
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_3add_class, 0, __pyx_n_s_add_class, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__195)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_class, __pyx_t_1) < 0) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":584
 * # The database stores predicates that contain clauses.
 * 
 * def insert(pred):             # <<<<<<<<<<<<<<
 *     Logic.tl.logic.Db[pred.id] = pred
 *     return pred
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_5insert, 0, __pyx_n_s_insert, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__197)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_insert, __pyx_t_1) < 0) __PYX_ERR(0, 584, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":588
 *     return pred
 * 
 * def remove(pred):             # <<<<<<<<<<<<<<
 *     if pred.id in Logic.tl.logic.Pred_registry:
 *         del Logic.tl.logic.Pred_registry[pred.id]
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7remove, 0, __pyx_n_s_remove, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__199)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_remove, __pyx_t_1) < 0) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":595
 *     return pred
 * 
 * def assert_(clause):             # <<<<<<<<<<<<<<
 *     """ Add a safe clause to the database """
 *     pred = clause.head.pred
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_9assert_, 0, __pyx_n_s_assert, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__201)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_assert, __pyx_t_1) < 0) __PYX_ERR(0, 595, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":614
 *     return clause
 * 
 * def retract(clause):             # <<<<<<<<<<<<<<
 *     """ retract a clause from the database"""
 *     pred = clause.head.pred
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_11retract, 0, __pyx_n_s_retract, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__203)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_retract, __pyx_t_1) < 0) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":633
 *     return clause
 * 
 * def relevant_clauses(literal):             # <<<<<<<<<<<<<<
 *     """ returns matching clauses for a literal query, using index """
 *     result = None
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_13relevant_clauses, 0, __pyx_n_s_relevant_clauses, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_relevant_clauses, __pyx_t_1) < 0) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":670
 *     A waiter is a pair containing a subgoal and a clause.
 *     """
 *     __slots__ = ['literal', 'facts', 'waiters', 'tasks', 'clauses', 'recursive', 'is_done', 'on_completion_']             # <<<<<<<<<<<<<<
 *     def __init__(self, literal):
 *         self.literal = literal
 */
  __pyx_t_1 = PyList_New(8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_literal);
  __Pyx_GIVEREF(__pyx_n_s_literal);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_literal);
  __Pyx_INCREF(__pyx_n_s_facts);
  __Pyx_GIVEREF(__pyx_n_s_facts);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_facts);
  __Pyx_INCREF(__pyx_n_s_waiters);
  __Pyx_GIVEREF(__pyx_n_s_waiters);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_waiters);
  __Pyx_INCREF(__pyx_n_s_tasks);
  __Pyx_GIVEREF(__pyx_n_s_tasks);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_tasks);
  __Pyx_INCREF(__pyx_n_s_clauses);
  __Pyx_GIVEREF(__pyx_n_s_clauses);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_clauses);
  __Pyx_INCREF(__pyx_n_s_recursive);
  __Pyx_GIVEREF(__pyx_n_s_recursive);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_recursive);
  __Pyx_INCREF(__pyx_n_s_is_done_2);
  __Pyx_GIVEREF(__pyx_n_s_is_done_2);
  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_is_done_2);
  __Pyx_INCREF(__pyx_n_s_on_completion);
  __Pyx_GIVEREF(__pyx_n_s_on_completion);
  PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_s_on_completion);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_slots, __pyx_t_1) < 0) __PYX_ERR(0, 670, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":686
 *         return str(self.literal)
 * 
 *     def search(self):             # <<<<<<<<<<<<<<
 *         """
 *         Search for derivations of the literal associated with this subgoal
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_5search, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_search, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__206)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_search, __pyx_t_1) < 0) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":817
 *     ################## add derived facts and use rules ##############
 * 
 *     def add_clause(self, clause):             # <<<<<<<<<<<<<<
 *         """ SLG_NEWCLAUSE in the reference article """
 *         if self.is_done: # for speed
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_7add_clause, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_add_clause, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__208)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_add_clause, __pyx_t_1) < 0) __PYX_ERR(0, 817, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":828
 *         return self.next_step()
 * 
 *     def fact(self, literal):             # <<<<<<<<<<<<<<
 *         """
 *         Store a derived fact, and inform all waiters of the fact too.
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_9fact, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_fact, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__210)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_fact, __pyx_t_1) < 0) __PYX_ERR(0, 828, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":875
 *                         self.waiters = []
 * 
 *     def fact_candidate(self, class0, result):             # <<<<<<<<<<<<<<
 *         """ add result as a candidate fact of class0 for subgoal"""
 *         if result is True:
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_11fact_candidate, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_fact_candidate, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__212)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_fact_candidate, __pyx_t_1) < 0) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":888
 *             self.fact(Literal(self.literal.pred.name, result))
 * 
 *     def rule(self, clause, selected):             # <<<<<<<<<<<<<<
 *         """ Use a newly derived rule. SLG_POSITIVE in the reference article """
 *         sg = Logic.tl.logic.Subgoals.get(selected.get_tag())
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_13rule, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_rule, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__214)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_rule, __pyx_t_1) < 0) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":916
 *     # by delaying the evaluation of some functions
 * 
 *     def schedule(self, task):             # <<<<<<<<<<<<<<
 *         """ Schedule a task for later invocation """
 *         if Slow_motion: print("  Add : %s" % show(task))
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_15schedule, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_schedule, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__216)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_schedule, __pyx_t_1) < 0) __PYX_ERR(0, 916, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":934
 *             self.tasks.append(task)
 * 
 *     def schedule_search(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ schedule SEARCH before SEARCHING, if possible """
 *         Logic.tl.logic.Recursive = subgoal.recursive
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_17schedule_search, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_schedule_search, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__218)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_schedule_search, __pyx_t_1) < 0) __PYX_ERR(0, 934, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":952
 *                 subgoal.schedule((SEARCH, (subgoal, ))) # first
 * 
 *     def next_step(self):             # <<<<<<<<<<<<<<
 *         """ returns the next step in the resolution """
 *         Ts = Logic.tl.logic
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_19next_step, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_next_step, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__220)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_next_step, __pyx_t_1) < 0) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":1000
 *         return task
 * 
 *     def next_clause(self):             # <<<<<<<<<<<<<<
 *         task = None
 *         if self.tasks: # still some tasks to do --> postpone next_clause
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_21next_clause, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_next_clause, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__222)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_next_clause, __pyx_t_1) < 0) __PYX_ERR(0, 1000, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":1014
 *         return self.next_step()
 * 
 *     def searching(self, subgoal):             # <<<<<<<<<<<<<<
 *         """ task used to relaunch searching of subgoal"""
 *         Ts = Logic.tl.logic
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_23searching, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_searching, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__224)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1014, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_searching, __pyx_t_1) < 0) __PYX_ERR(0, 1014, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":1047
 *         return self.next_step()
 * 
 *     def complete(self, literal, aggregate=None):             # <<<<<<<<<<<<<<
 *         """makes sure that subgoal is completed before calling post_thunk and resuming processing"""
 *         #TODO check for infinite loops
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_25complete, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_complete, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__226)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_complete, __pyx_t_1) < 0) __PYX_ERR(0, 1047, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":1059
 *         subgoal.on_completion_.append( (ON_COMPLETION, (subgoal, self, aggregate)) )
 * 
 *     def on_completion(self, parent, aggregate):             # <<<<<<<<<<<<<<
 *         if Logging and Logger.isEnabledFor(logging.DEBUG):
 *             Logger.debug('Processing aggregate or negation')
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_27on_completion, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal_on_completion, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__228)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_on_completion_2, __pyx_t_1) < 0) __PYX_ERR(0, 1059, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_29__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal___reduce_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__230)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Subgoal, (type(self), 0x188032d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Subgoal__set_state(self, __pyx_state)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_7Subgoal_31__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Subgoal___setstate_cython, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__232)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal->tp_dict, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_9pyDatalog_8pyEngine_Subgoal);

  /* "pyDatalog/pyEngine.py":1072
 * 
 * # op codes are defined after class Subgoal is defined
 * SEARCHING = Subgoal.searching             # <<<<<<<<<<<<<<
 * SEARCH = Subgoal.search
 * ADD_CLAUSE = Subgoal.add_clause
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), __pyx_n_s_searching); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_SEARCHING, __pyx_t_1) < 0) __PYX_ERR(0, 1072, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1073
 * # op codes are defined after class Subgoal is defined
 * SEARCHING = Subgoal.searching
 * SEARCH = Subgoal.search             # <<<<<<<<<<<<<<
 * ADD_CLAUSE = Subgoal.add_clause
 * NEXT_CLAUSE = Subgoal.next_clause
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), __pyx_n_s_search); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_SEARCH, __pyx_t_1) < 0) __PYX_ERR(0, 1073, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1074
 * SEARCHING = Subgoal.searching
 * SEARCH = Subgoal.search
 * ADD_CLAUSE = Subgoal.add_clause             # <<<<<<<<<<<<<<
 * NEXT_CLAUSE = Subgoal.next_clause
 * ON_COMPLETION = Subgoal.on_completion
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), __pyx_n_s_add_clause); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ADD_CLAUSE, __pyx_t_1) < 0) __PYX_ERR(0, 1074, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1075
 * SEARCH = Subgoal.search
 * ADD_CLAUSE = Subgoal.add_clause
 * NEXT_CLAUSE = Subgoal.next_clause             # <<<<<<<<<<<<<<
 * ON_COMPLETION = Subgoal.on_completion
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), __pyx_n_s_next_clause); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1075, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_NEXT_CLAUSE, __pyx_t_1) < 0) __PYX_ERR(0, 1075, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1076
 * ADD_CLAUSE = Subgoal.add_clause
 * NEXT_CLAUSE = Subgoal.next_clause
 * ON_COMPLETION = Subgoal.on_completion             # <<<<<<<<<<<<<<
 * 
 * def show(task):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_9pyDatalog_8pyEngine_Subgoal), __pyx_n_s_on_completion_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ON_COMPLETION, __pyx_t_1) < 0) __PYX_ERR(0, 1076, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1078
 * ON_COMPLETION = Subgoal.on_completion
 * 
 * def show(task):             # <<<<<<<<<<<<<<
 *     if task == (None, None):
 *         return
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_16show, 0, __pyx_n_s_show, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__234)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1078, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_show, __pyx_t_1) < 0) __PYX_ERR(0, 1078, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1116
 * """
 * 
 * def equals_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_18equals_primitive, 0, __pyx_n_s_equals_primitive, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__236)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_equals_primitive, __pyx_t_1) < 0) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1126
 *     return x.equals_primitive(y, subgoal)
 * 
 * def compare_primitive(literal, subgoal):             # <<<<<<<<<<<<<<
 *     x = literal.terms[0]
 *     y = literal.terms[1]
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_20compare_primitive, 0, __pyx_n_s_compare_primitive, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__238)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compare_primitive, __pyx_t_1) < 0) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1147
 * 
 * # generic comparison function
 * def compare(l,op,r):             # <<<<<<<<<<<<<<
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_22compare, 0, __pyx_n_s_compare, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__240)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compare, __pyx_t_1) < 0) __PYX_ERR(0, 1147, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1150
 *     return l in r if op=='_pyD_in' else l not in r if op=='_pyD_not_in' else l==r if op=='==' else l!=r if op=='!=' else l<r if op=='<' \
 *         else l<=r if op=='<=' else l>=r if op=='>=' else l>r if op=='>' else None
 * def compare2(l,op,r):             # <<<<<<<<<<<<<<
 *     return l._in(r) if op=='_pyD_in' else l._not_in(r) if op=='_pyD_not_in' else compare(l,op,r)
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_24compare2, 0, __pyx_n_s_compare2, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__242)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compare2, __pyx_t_1) < 0) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1155
 * # Initialization   ##################################################
 * 
 * def clear():             # <<<<<<<<<<<<<<
 *     """ clears the logic """
 *     Logic.tl.logic.Db = {}
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_26clear, 0, __pyx_n_s_clear, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__243)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_clear, __pyx_t_1) < 0) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Term(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_28__pyx_unpickle_Term, 0, __pyx_n_s_pyx_unpickle_Term, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__245)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Term, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Term__set_state(<Term> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Term__set_state(Term __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_30__pyx_unpickle_Fresh_var, 0, __pyx_n_s_pyx_unpickle_Fresh_var, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__247)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Fresh_var, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Var(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_32__pyx_unpickle_Var, 0, __pyx_n_s_pyx_unpickle_Var, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__249)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Var, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Var__set_state(<Var> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Var__set_state(Var __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.id = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_34__pyx_unpickle_Const, 0, __pyx_n_s_pyx_unpickle_Const, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__251)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Const, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_VarTuple(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_36__pyx_unpickle_VarTuple, 0, __pyx_n_s_pyx_unpickle_VarTuple, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__253)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_VarTuple, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_VarTuple__set_state(<VarTuple> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_VarTuple__set_state(VarTuple __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._id = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.is_constant = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_38__pyx_unpickle_Operation, 0, __pyx_n_s_pyx_unpickle_Operation, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__255)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Operation, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Literal(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_40__pyx_unpickle_Literal, 0, __pyx_n_s_pyx_unpickle_Literal, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__257)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Literal, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Literal__set_state(<Literal> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Literal__set_state(Literal __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.aggregate = __pyx_state[0]; __pyx_result.id = __pyx_state[1]; __pyx_result.pred = __pyx_state[2]; __pyx_result.tag = __pyx_state[3]; __pyx_result.terms = __pyx_state[4]
 *     if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_42__pyx_unpickle_Clause, 0, __pyx_n_s_pyx_unpickle_Clause, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__259)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Clause, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Subgoal(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_9pyDatalog_8pyEngine_44__pyx_unpickle_Subgoal, 0, __pyx_n_s_pyx_unpickle_Subgoal, NULL, __pyx_n_s_pyDatalog_pyEngine, __pyx_d, ((PyObject *)__pyx_codeobj__261)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Subgoal, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pyDatalog/pyEngine.py":1
 * """             # <<<<<<<<<<<<<<
 * This file is part of pyDatalog, a datalog engine for python.
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init pyDatalog.pyEngine", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init pyDatalog.pyEngine");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* KeywordStringCheck */
static int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* dict_setdefault */
static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value,
                                                       CYTHON_UNUSED int is_safe_type) {
    PyObject* value;
#if PY_VERSION_HEX >= 0x030400A0
    if ((1)) {
        value = PyDict_SetDefault(d, key, default_value);
        if (unlikely(!value)) return NULL;
        Py_INCREF(value);
#else
    if (is_safe_type == 1 || (is_safe_type == -1 &&
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
            (PyUnicode_CheckExact(key) || PyString_CheckExact(key) || PyLong_CheckExact(key)))) {
        value = PyDict_GetItemWithError(d, key);
        if (unlikely(!value)) {
            if (unlikely(PyErr_Occurred()))
                return NULL;
            if (unlikely(PyDict_SetItem(d, key, default_value) == -1))
                return NULL;
            value = default_value;
        }
        Py_INCREF(value);
#else
            (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key) || PyLong_CheckExact(key)))) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            if (unlikely(PyDict_SetItem(d, key, default_value) == -1))
                return NULL;
            value = default_value;
        }
        Py_INCREF(value);
#endif
#endif
    } else {
        value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_setdefault, d, key, default_value);
    }
    return value;
}

/* ArgTypeTest */
    static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* CallUnboundCMethod1 */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* dict_getitem_default */
    static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
    if ((1));
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    }
#endif
    else {
        if (default_value == Py_None)
            value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
        else
            value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
    }
    return value;
}

/* DictGetItem */
    #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* RaiseDoubleKeywords */
    static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
    static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* GetItemInt */
    static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* None */
    static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* RaiseTooManyValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
    static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
    static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* BytesEquals */
    static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
    static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* GetTopmostException */
    #if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
    #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* GetException */
    #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* RaiseNoneIterError */
    static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* None */
    static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* ObjectGetItem */
    #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* HasAttr */
    static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* SliceObject */
    static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* SetItemInt */
    static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
#else
    if (is_list || PySequence_Check(o))
#endif
    {
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* StringJoin */
    #if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* PyIntBinop */
    #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        const long a = intval;
        long x;
        long b = PyInt_AS_LONG(op2);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op2))) {
        const long a = intval;
        long b, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG lla = intval;
        PY_LONG_LONG llb, llx;
#endif
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            b = likely(size) ? digits[0] : 0;
            if (size == -1) b = -b;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op2)) {
        const long a = intval;
        double b = PyFloat_AS_DOUBLE(op2);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* SliceTupleAndList */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

/* PyIntBinop */
    #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* RaiseException */
    #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* PyObjectGetMethod */
    static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
    static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
    static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* PyObjectCallMethod0 */
    static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method = NULL, *result = NULL;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_CallOneArg(method, obj);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) goto bad;
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* CallUnboundCMethod0 */
    static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* pop */
    static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
    if (Py_TYPE(L) == &PySet_Type) {
        return PySet_Pop(L);
    }
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
    if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        __Pyx_SET_SIZE(L, Py_SIZE(L) - 1);
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
    return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
}
#endif

/* Import */
    static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
    static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* PyObject_GenericGetAttrNoDict */
    #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
    #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* PyObjectGetAttrStrNoError */
    static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
    static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_getstate = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
    PyObject *getstate = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate);
#else
    getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate);
    if (!getstate && PyErr_Occurred()) {
        goto __PYX_BAD;
    }
#endif
    if (getstate) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate);
#else
        object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate);
        if (!object_getstate && PyErr_Occurred()) {
            goto __PYX_BAD;
        }
#endif
        if (object_getstate != getstate) {
            goto __PYX_GOOD;
        }
    }
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
    Py_XDECREF(object_getstate);
    Py_XDECREF(getstate);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* SetVTable */
    static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* TypeImport */
    #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* FetchCommonType */
    static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunctionShared */
    #include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    Py_INCREF(m->func_qualname);
    return m->func_qualname;
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
                                       PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    if (unlikely(op == NULL))
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults_size = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
#if PY_MAJOR_VERSION < 3
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
#endif
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            PyErr_Format(PyExc_TypeError,
                         "unbound method %.200S() needs an argument",
                         cyfunc->func_qualname);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    m->defaults_size = size;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* CythonFunction */
    static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    PyObject *op = __Pyx_CyFunction_Init(
        PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
        ml, flags, qualname, closure, module, globals, code
    );
    if (likely(op)) {
        PyObject_GC_Track(op);
    }
    return op;
}

/* CalculateMetaclass */
    static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* Py3ClassCreate */
    static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* ClassMethod */
    static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
        return PyClassMethod_New(method);
    }
#else
#if CYTHON_COMPILING_IN_PYSTON || CYTHON_COMPILING_IN_PYPY
    if (PyMethodDescr_Check(method))
#else
    #if PY_MAJOR_VERSION == 2
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    #else
    PyTypeObject *methoddescr_type = &PyMethodDescr_Type;
    #endif
    if (__Pyx_TypeCheck(method, methoddescr_type))
#endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) {
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else {
        return PyClassMethod_New(method);
    }
}

/* CLineInTraceback */
    #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
    static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
    #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = NULL;
    PyObject *py_funcname = NULL;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_srcfile = NULL;
    py_srcfile = PyString_FromString(filename);
    if (!py_srcfile) goto bad;
    #endif
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        funcname = PyUnicode_AsUTF8(py_funcname);
        if (!funcname) goto bad;
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        if (!py_funcname) goto bad;
        #endif
    }
    #if PY_MAJOR_VERSION < 3
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    #else
    py_code = PyCode_NewEmpty(filename, funcname, py_line);
    #endif
    Py_XDECREF(py_funcname);  // XDECREF since it's only set on Py3 if cline
    return py_code;
bad:
    Py_XDECREF(py_funcname);
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_srcfile);
    #endif
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject *ptype, *pvalue, *ptraceback;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) {
            /* If the code object creation fails, then we should clear the
               fetched exception references and propagate the new exception */
            Py_XDECREF(ptype);
            Py_XDECREF(pvalue);
            Py_XDECREF(ptraceback);
            goto bad;
        }
        __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
    #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* Print */
    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject((char *)"stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}
static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
    int i;
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        PyObject* v;
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                goto error;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            goto error;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0) {
                switch (s[len-1]) {
                    case ' ': break;
                    case '\f': case '\r': case '\n': case '\t': case '\v':
                        PyFile_SoftSpace(f, 0);
                        break;
                    default:  break;
                }
            }
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            goto error;
        PyFile_SoftSpace(f, 0);
    }
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
}
#else
static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (unlikely(!__pyx_print)) {
        __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
        if (!__pyx_print)
            return -1;
    }
    if (stream) {
        kwargs = PyDict_New();
        if (unlikely(!kwargs))
            return -1;
        if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
            goto bad;
        if (!newline) {
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                goto bad;
            if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                goto bad;
            }
            Py_DECREF(end_string);
        }
    } else if (!newline) {
        if (unlikely(!__pyx_print_kwargs)) {
            __pyx_print_kwargs = PyDict_New();
            if (unlikely(!__pyx_print_kwargs))
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                return -1;
            if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
        Py_DECREF(kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
bad:
    if (kwargs != __pyx_print_kwargs)
        Py_XDECREF(kwargs);
    return -1;
}
#endif

/* CIntFromPy */
    static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* PrintOne */
    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    if (PyFile_SoftSpace(f, 0)) {
        if (PyFile_WriteString(" ", f) < 0)
            goto error;
    }
    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
        goto error;
    if (PyFile_WriteString("\n", f) < 0)
        goto error;
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
    /* the line below is just to avoid C compiler
     * warnings about unused functions */
    return __Pyx_Print(f, NULL, 0);
}
#else
static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
    int res;
    PyObject* arg_tuple = PyTuple_Pack(1, o);
    if (unlikely(!arg_tuple))
        return -1;
    res = __Pyx_Print(stream, arg_tuple, 1);
    Py_DECREF(arg_tuple);
    return res;
}
#endif

/* CIntFromPy */
    static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* FastTypeChecks */
    #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* SwapException */
    #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* CoroutineBase */
    #include <structmember.h>
#include <frameobject.h>
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *t, *v, *tb;
    t = exc_state->exc_type;
    v = exc_state->exc_value;
    tb = exc_state->exc_traceback;
    exc_state->exc_type = NULL;
    exc_state->exc_value = NULL;
    exc_state->exc_traceback = NULL;
    Py_XDECREF(t);
    Py_XDECREF(v);
    Py_XDECREF(tb);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    __Pyx_ExcInfoStruct *exc_state;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    exc_state = &self->gi_exc_state;
    if (exc_state->exc_type) {
        #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
        #else
        if (exc_state->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            assert(f->f_back == NULL);
            #if PY_VERSION_HEX >= 0x030B00A1
            f->f_back = PyThreadState_GetFrame(tstate);
            #else
            Py_XINCREF(tstate->frame);
            f->f_back = tstate->frame;
            #endif
        }
        #endif
    }
#if CYTHON_USE_EXC_INFO_STACK
    exc_state->previous_item = tstate->exc_info;
    tstate->exc_info = exc_state;
#else
    if (exc_state->exc_type) {
        __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(exc_state);
        __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    }
#endif
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
#if CYTHON_USE_EXC_INFO_STACK
    exc_state = &self->gi_exc_state;
    tstate->exc_info = exc_state->previous_item;
    exc_state->previous_item = NULL;
    __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
#endif
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *exc_tb = exc_state->exc_traceback;
    if (likely(exc_tb)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
static CYTHON_INLINE
PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
#if PY_VERSION_HEX <= 0x030A00A1
    return _PyGen_Send(gen, arg);
#else
    PyObject *result;
    if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
        if (PyAsyncGen_CheckExact(gen)) {
            assert(result == Py_None);
            PyErr_SetNone(PyExc_StopAsyncIteration);
        }
        else if (result == Py_None) {
            PyErr_SetNone(PyExc_StopIteration);
        }
        else {
            _PyGen_SetStopIterationValue(result);
        }
        Py_CLEAR(result);
    }
    return result;
#endif
}
#endif
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
            ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
}
static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
    return __Pyx_Coroutine_Close(self);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
    Py_VISIT(exc_state->exc_type);
    Py_VISIT(exc_state->exc_value);
    Py_VISIT(exc_state->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_frame);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (Py_REFCNT(self) > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    __Pyx_SET_REFCNT(self, 1);
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    assert(Py_REFCNT(self) > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = Py_REFCNT(self);
        _Py_NewReference(self);
        __Pyx_SET_REFCNT(self, refcnt);
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(Py_TYPE(self)) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *frame = self->gi_frame;
    if (!frame) {
        if (unlikely(!self->gi_code)) {
            Py_RETURN_NONE;
        }
        frame = (PyObject *) PyFrame_New(
            PyThreadState_Get(),            /*PyThreadState *tstate,*/
            (PyCodeObject*) self->gi_code,  /*PyCodeObject *code,*/
            __pyx_d,                 /*PyObject *globals,*/
            0                               /*PyObject *locals*/
        );
        if (unlikely(!frame))
            return NULL;
        self->gi_frame = frame;
    }
    Py_INCREF(frame);
    return frame;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->gi_exc_state.exc_type = NULL;
    gen->gi_exc_state.exc_value = NULL;
    gen->gi_exc_state.exc_traceback = NULL;
#if CYTHON_USE_EXC_INFO_STACK
    gen->gi_exc_state.previous_item = NULL;
#endif
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    gen->gi_frame = NULL;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
    static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
    #ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Generator */
    static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
     (char*) PyDoc_STR("Frame of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
    0,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

/* CheckBinaryVersion */
    static int __Pyx_check_binary_version(void) {
    char ctversion[5];
    int same=1, i, found_dot;
    const char* rt_from_call = Py_GetVersion();
    PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    found_dot = 0;
    for (i = 0; i < 4; i++) {
        if (!ctversion[i]) {
            same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
            break;
        }
        if (rt_from_call[i] != ctversion[i]) {
            same = 0;
            break;
        }
    }
    if (!same) {
        char rtversion[5] = {'\0'};
        char message[200];
        for (i=0; i<4; ++i) {
            if (rt_from_call[i] == '.') {
                if (found_dot) break;
                found_dot = 1;
            } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
                break;
            }
            rtversion[i] = rt_from_call[i];
        }
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* InitStrings */
    static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
    return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
#if PY_MAJOR_VERSION < 3
  } else if (likely(PyInt_CheckExact(o))) {
    return PyInt_AS_LONG(o);
#endif
  } else {
    Py_ssize_t ival;
    PyObject *x;
    x = PyNumber_Index(o);
    if (!x) return -1;
    ival = PyInt_AsLong(x);
    Py_DECREF(x);
    return ival;
  }
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
