1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

FAQ

Does Pyke support negative logic?

  • Yes, using the notany clause.

Will Pyke run on Python3.x?

  • Yes, there is a second file release in sourceforge whose name starts with "pyke3" for the Python 3 version of Pyke.

How do I distribute my application that uses Pyke?

  • Read this wiki page.

Can Pyke do pattern matching on arbitrary Python objects?

  • Currently Pyke can not directly do pattern matching on arbitrary Python objects. But you may (in spite of what the documentation says) use Python objects as arguments to facts or goals, or within tuples. But the only pattern that you may use on them is a pattern variable to match the whole object. You may then use the check premise to test the object's suitability for use within a particular rule. But note that though Pyke automatically reruns forward-chaining rules when new facts are asserted, it will not rerun rules when the object changes.

Does Pyke support Prolog "cuts"?

How do I access my engine object from within my rules?

  • Both forward-chaining and backward-chaining rules have a variable called engine that you can use directly within Python code fragments within your rules. (Note: But this is not available to the Python code in the with clause of your backward-chaining rules).

How can I assert new facts from a backward-chaining rule?

  • Use the python clause to call the assert_ function on the engine object (available to all rules as an implicit engine variable within rule).

Does Pyke do fact retraction?

  • Not at this time. This may be added in a future release.

Can Pyke be run in a threaded environment?

Pyke was not designed to be multi-threaded. However, if you use Pyke to do automatic programming, I believe that the plans produced by Pyke would be thread safe -- if the code that you write in the "with" clauses is thread safe. Thinking about it, the backward-chaining should be relatively thread-safe, except for the statistics gathering. But using case_specific facts, forward-chaining rules, or question bases would definitely be a problem with threads.

This might be a good project for somebody to tackle to see what it would take to make Pyke thread safe. Though Pyke wasn't designed to be thread safe, it may not be that difficult to do this.

If I create several engine objects, can I run each one in a separate thread?

A pool of engine objects, each running in only one thread, might cause a problem if they weren't all created from the same version of .krb files. For example, if you created one engine object, then changed a .krb file, then created a second engine object; it could cause problems for the first engine object if you still try to use it without re-creating it.

Also, it looks like there would be problems with the Pyke compiler not being thread safe. So create the first engine object and wait for it to return from the constructor (which is where the Pyke compiler runs, if needed) before creating the remaining engine objects. Creating subsequent engine objects in different threads should be OK if they don't need to run the Pyke compiler.

I must say though that I have never tried multiple engine objects in a threaded environment, so can't guarantee it will work. If anybody tries this, please share your findings with the rest of us!