Package: pyswip
PySwipPySwip in 2020 SurveyThanks for being a member of the PySwip community. We want to know more about you, your interests and any problems you may have with PySwip.Please fill out thePySwip in 2020 Survey.That will help us provide the features you want and resolve the problems with PySwip.The End of Python 2 SupportPython 2 has reached end of life on January 1st, 2020 as documentedhere. So, PySwip 0.2.10 will be the last version which officially supports Python 2.Do you still require Python 2 support? Let us know at:https://github.com/yuce/pyswip/issues/94What's New?See theCHANGELOG.This library is being cleaned up and refactored. Expect API breakage and incompatibility with previous versions.WARNING! PySwip has no Windows installers! If you are a Windows user, seeINSTALL. There are some "free download" sites that claim to be hosting PySwip installers. DO NOT TRUST THEM!Thanks to allcontributors.IntroductionPySwip is a Python - SWI-Prolog bridge enabling to querySWI-Prologin your Python programs.
It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a
Pythonic interface.Since PySwip uses SWI-Prolog as a shared library and ctypes to access it, it doesn't require compilation to be installed.Requirements:Python 2.7 or 3.4 and higher.PyPy is currently not supported.SWI-Prolog 7.2.x and higher.libswiplas a shared library.This is the default on most platforms.Works on Linux, Windows, MacOS and FreeBSD. Should work on other POSIX.InstallIMPORTANT: Make sure the SWI-Prolog architecture is the same as the Python architecture. If you are using a 64bit build of Python, use a 64bit build of SWI-Prolog, etc.*SeeINSTALLfor instructions.ExamplesUsing PrologfrompyswipimportPrologprolog=Prolog()prolog.assertz("father(michael,john)")prolog.assertz("father(michael,gina)")list(prolog.query("father(michael,X)"))==[{'X':'john'},{'X':'gina'}]forsolninprolog.query("father(X,Y)"):print(soln["X"],"is the father of",soln["Y"])# michael is the father of john# michael is the father of ginaAn existing knowledge base stored in a Prolog file can also be consulted,
and queried. Assuming the filename "knowledge_base.pl" and the Python is
being run in the same working directory, it is consulted like so:>>> from pyswip import Prolog
>>> prolog = Prolog()
>>> prolog.consult("knowledge_base.pl")Foreign Functionsfrom__future__importprint_functionfrompyswipimportProlog,registerForeigndefhello(t):print("Hello,",t)hello.arity=1registerForeign(hello)prolog=Prolog()prolog.assertz("father(michael,john)")prolog.assertz("father(michael,gina)")print(list(prolog.query("father(michael,X), hello(X)")))Pythonic interface (Experimental)from__future__importprint_functionfrompyswipimportFunctor,Variable,Query,callassertz=Functor("assertz",1)father=Functor("father",2)call(assertz(father("michael","john")))call(assertz(father("michael","gina")))X=Variable()q=Query(father("michael",X))whileq.nextSolution():print("Hello,",X.value)q.closeQuery()# Outputs:#    Hello, john#    Hello, ginaThe core functionality ofProlog.queryis based on Nathan Denny's public domain prolog.py.Help!Support ForumStack OverflowProjects/Publications that Use or Reference PySwipDo you have a project, video or publication that uses/mentions PySwip?file an issueor send a pull request.If you would like to reference PySwip in a LaTeX document, you can use the providedBibTeX file.BooksBeginning Artificial Intelligence with the Raspberry PiPublicationsAssessment of Graph Databases as a Viable Materiel Solution for the Army's Dynamic Force Structure (DFS) Portal Implementation: Part 3, Risks, Mitigation Approach, and RoadmapTackling Complexity in High Performance Computing ApplicationsSocial Human-Robot Interaction: A New Cognitive and Affective Interaction-Oriented ArchitectureA Planning Module for a ROS-Based Ubiquitous Robot Control System(PDF)A pilot framework developed as a common platform integrating diverse elements of computer aided fixture designIntegration von Prolog und ClioPatria in Python(PDF, German)SELECTSCRIPT: A Query Language for Robotic World Models and SimulationsA Concept for Declarative Information Acquisition in Smart EnvironmentsImplementation on ADHD Diagnostic Expert System based on DSM Diagnostic Criteria(PDF, Korean)Wie sehen Krebsmolekule aus? Vergleich der Gute der Klassifizierung potenziell krebserregender Molekule durch induktiv logische und merkmalsbasierte Lernverfahren(PDF, German)Companion Robots Behaving with Style: Towards Plasticity in Social Human-Robot Interaction(PDF)Semi-automatically Augmenting Attack Trees using an Annotated Attack Tree LibraryA Learning Framework for Tool Creation by a Robot(PDF)VideosAI - blocks world solver interactive plannerPySwip, Prolog, JAVA SCRIPT and HTML(Spanish)GET OUT OF THE MAZE WITH PROLOG AND PYTHON(Spanish)ProjectsnoworkflowSupporting infrastructure to run scientific experiments without a scientific workflow management system.http://gems-uff.github.io/noworkflowSuper PacmanPokemon Weak DetectorFood Recommendations in Hyderabad, IndiaFood Recommendation AI Expert System using a GUI hosted on Flask and a backend developed with PYSWIP and native Prolog.pyswip_envctrlAn environment control module expert system written in PySwip.tic-tac-toeTic-tac-toe game with AI in Prolog and GUI in Python (kivy framework + pyswip).TBM1 - "Getting to Know My Home"Prolog natural language parsing component to control a Scribbler II robot over bluetoothCosmosA new logic programming language.lib-annotated-attack-treesScripts and resources for creating a library of annotated attack trees and using it to refine an annotated attack tree.ClIDECommand-line Intelligent Development EnvironmentArtificial Intelligence INF1771 @ PUC-RioProjects for the Artificial Intelligence class @ PUC-RioAutomobileAdvisorProjekt na systemy ekspertowe pomagający wybrać odpowiedni samochód dla danego klienta na podstawie preferencji (Polish)Prolog Tetris AIJupyter SWI PrologA Jupyter Kernel for SWI-Prolog.Blocks World PlannerA program that allows users to solve the blocks world problem interacting only using the natural language.Blog PostsCalling Prolog from PythonPython v. Prolog: Round 1: Fight!Path Follower: Arduino+Rasp on ROSand itsProject code10 minutes to make a GUI for your SWI-Prolog App via PythonLicenseCopyright (c) 2007-2019 Yüce Tekol

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.