# history

source:
  #export

  import time

  import gym
  import minerl  # noqa

  # OpenCog
  from opencog.logger import log
  from opencog.pln import *
  from opencog.type_constructors import *
  from opencog.utilities import set_default_atomspace

  # ROCCA
  from rocca.envs.wrappers import MineRLWrapper
  from rocca.envs.wrappers.minerl_wrapper import minerl_single_action
  from rocca.agents import OpencogAgent
  from rocca.agents.utils import *

  from rocca.utils import *

source_raw:
  #export

  import time

  import gym
  import minerl  # noqa

  # OpenCog
  from opencog.logger import log
  from opencog.pln import *
  from opencog.type_constructors import *
  from opencog.utilities import set_default_atomspace

  # ROCCA
  from rocca.envs.wrappers import MineRLWrapper
  from rocca.envs.wrappers.minerl_wrapper import minerl_single_action
  from rocca.agents import OpencogAgent
  from rocca.agents.utils import *

  from rocca.utils import *


source:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://localhost:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://localhost:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = "between(1,1000,X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'e2c("How are you?")'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'e2c("How are you?")'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'c80("How are you?")'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'c80("How are you?")'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'true'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'true'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  get_ipython().system('pip install pengines')
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'member(X,[1,2,3])'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  !pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'member(X,[1,2,3])'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'member(X,[1,2,3])'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'member(X,[1,2,3])'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'print_tree(member(X,[1,2,3]))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'print_tree(member(X,[1,2,3]))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'nop(print_tree(member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'nop(print_tree(member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))

source_raw:
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))


source:
  get_ipython().system('pip install urllib')
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))

source_raw:
  !pip install urllib
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))


source:
  get_ipython().system('pip install urllib json')
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))

source_raw:
  !pip install urllib json
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))


source:
  get_ipython().system('pip install json')
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))

source_raw:
  !pip install json
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://localhost:4242"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))


source:
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://logicmoo.org:3020"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))

source_raw:
  from urllib.request import Request, urlopen
  import json

  # Make the URL
  urlbase = "http://logicmoo.org:3020"
  url_action = "/pengine/create"
  url = urlbase + url_action

  # Header is dict not JSON for urllib
  header = dict()
  header["User-Agent"] = "PythonPengine"
  header["Accept"] = "application/json"
  header["Accept-Language"] = "en-us,en;q=0.5"
  header["Content-type"] = "application/json"
  print("Header information.")
  print(header, type(header))

  # Encode the body as json in utf8
  data_ = {}
  data = json.JSONEncoder().encode(data_)
  data_utf8 = data.encode("utf-8")
  print("Printing data information...")
  print(data, type(data))

  # Request using urllib due to request libs broken implementation.
  request_object = Request(url, data=data_utf8, headers=header)
  response = urlopen(request_object)
  response_string_utf8 = response.readall()
  response_string = response_string_utf8.decode("utf-8")


  def parse_create(response_string):
      pengine_id_char_list = []
      pengine_slave_limit_char_list = []
      state = 0
      print(response_string)
      for char in response_string:
          if state == 0 and char.isnumeric():
              print("Found first number")
              state = 1

          if state == 1 and char.isnumeric():
              pengine_id_char_list.append(char)
          elif state == 1:
              state = 2

          if state == 2 and char.isnumeric():
              pengine_slave_limit_char_list.append(char)

      pengine_id = "".join(pengine_id_char_list)
      pengine_slave_limit = "".join(pengine_slave_limit_char_list)
      print("Parse Results: Id: {}, Limit: {}".format(pengine_id, pengine_slave_limit))
      return pengine_id, pengine_slave_limit


  # ToDo: Super fragile parsing!! Only handles one digit pengine slave counts.
  # print(len(response_string))
  # assert len(response_string) == 68
  # print(response_string[8:47], response_string[62])
  # pengine_id = response_string[8:47]
  # pengine_slave_count = response_string[62]
  pengine_id, pengine_slave_count = parse_create(response_string)


  # Start the query cycle.
  print("Starting query")
  # Initial creation is done -- pengine id aquired and slave counts named.
  url_ask = urlbase + "/pengine/send?format=json&id={}".format(pengine_id) # Error: Raises error
  print("URL: ", url_ask)
  # Header has a different Content-type
  header["Content-type"] = "application/x-prolog; charset=UTF-8"
  print("Header: ", header)

  # Create the body.
  body_ask = "ask({}, []).".format("member(X, [1,2,3])") # po.getrequestbodyask
  print("Body: ", body_ask)
  body_utf8 = body_ask.encode("utf-8")
  query_request = Request(url_ask, data=body_utf8, headers=header)
  query_response = urlopen(query_request)
  query_response_utf8 = query_response.readall()
  query_response_string = query_response_utf8.decode("utf-8")
  print("Response received: ", query_response_string)
  query_response_dict = json.JSONDecoder().decode(query_response_string)
  print("Decoded JSON: ", query_response_dict)
  print("Data from JSON: ", query_response_dict['data'])

  # More calls.
  def get_more(urlbase, pengine_id, header):
      ''' This function gets more responses, if they exist.'''
      # Make URL
      print("Getting more...")
      url_next = urlbase + "/pengine/send?format=json&id={}".format(pengine_id)
      print("Next URL: ", url_next)
      # Pass headers as normal.
      # Make body.
      body = "next."
      print("Next body: ", body)
      body_utf8 = body.encode("utf-8")
      print("Headers: ", header)
      next_request = Request(url_next, data=body_utf8, headers=header)
      next_response = urlopen(next_request)
      next_response_utf8 = next_response.readall()
      next_response_string = next_response_utf8.decode("utf-8")
      next_response_dict = json.JSONDecoder().decode(next_response_string)
      return next_response_dict

  print(get_more(urlbase, pengine_id, header))
  print(get_more(urlbase, pengine_id, header))


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '(print_tree(member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '(print_tree(member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '(print_tree(member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '(print_tree(member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine
  from prologterms import TermGenerator, PrologRenderer, Program, Var

  P = TermGenerator()
  X = Var('X')
  Y = Var('Y')
  Z = Var('Z')
  R = PrologRenderer()

  p = Program(
      P.ancestor(X,Y) <= (P.parent(X,Z), P.ancestor(Z,Y)),
      P.ancestor(X,Y) <= P.parent(X,Y),
      P.parent('a','b'),
      P.parent('b','c'),
      P.parent('c','d')
  )

  q = P.ancestor(X,Y)

  factory = PengineBuilder(urlserver="http://localhost:4242",
                           srctext=R.render(p),
                           ask=R.render(q))
  pengine = Pengine(builder=factory, debug=True)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  for p in pengine.currentQuery.availProofs:
      print('{} <- {}'.format(p[X.name], p[Y.name]))

source_raw:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine
  from prologterms import TermGenerator, PrologRenderer, Program, Var

  P = TermGenerator()
  X = Var('X')
  Y = Var('Y')
  Z = Var('Z')
  R = PrologRenderer()

  p = Program(
      P.ancestor(X,Y) <= (P.parent(X,Z), P.ancestor(Z,Y)),
      P.ancestor(X,Y) <= P.parent(X,Y),
      P.parent('a','b'),
      P.parent('b','c'),
      P.parent('c','d')
  )

  q = P.ancestor(X,Y)

  factory = PengineBuilder(urlserver="http://localhost:4242",
                           srctext=R.render(p),
                           ask=R.render(q))
  pengine = Pengine(builder=factory, debug=True)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  for p in pengine.currentQuery.availProofs:
      print('{} <- {}'.format(p[X.name], p[Y.name]))


source:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine
  from prologterms import TermGenerator, PrologRenderer, Program, Var

  P = TermGenerator()
  X = Var('X')
  Y = Var('Y')
  Z = Var('Z')
  R = PrologRenderer()

  p = Program(
      P.ancestor(X,Y) <= (P.parent(X,Z), P.ancestor(Z,Y)),
      P.ancestor(X,Y) <= P.parent(X,Y),
      P.parent('a','b'),
      P.parent('b','c'),
      P.parent('c','d')
  )

  q = P.ancestor(X,Y)

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020",
                           srctext=R.render(p),
                           ask=R.render(q))
  pengine = Pengine(builder=factory, debug=True)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  for p in pengine.currentQuery.availProofs:
      print('{} <- {}'.format(p[X.name], p[Y.name]))

source_raw:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine
  from prologterms import TermGenerator, PrologRenderer, Program, Var

  P = TermGenerator()
  X = Var('X')
  Y = Var('Y')
  Z = Var('Z')
  R = PrologRenderer()

  p = Program(
      P.ancestor(X,Y) <= (P.parent(X,Z), P.ancestor(Z,Y)),
      P.ancestor(X,Y) <= P.parent(X,Y),
      P.parent('a','b'),
      P.parent('b','c'),
      P.parent('c','d')
  )

  q = P.ancestor(X,Y)

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020",
                           srctext=R.render(p),
                           ask=R.render(q))
  pengine = Pengine(builder=factory, debug=True)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  for p in pengine.currentQuery.availProofs:
      print('{} <- {}'.format(p[X.name], p[Y.name]))


source:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine
  from prologterms import TermGenerator, PrologRenderer, Program, Var

  P = TermGenerator()
  X = Var('X')
  Y = Var('Y')
  Z = Var('Z')
  R = PrologRenderer()

  p = Program(
      P.ancestor(X,Y) <= (P.parent(X,Z), P.ancestor(Z,Y)),
      P.ancestor(X,Y) <= P.parent(X,Y),
      P.parent('a','b'),
      P.parent('b','c'),
      P.parent('c','d')
  )

  q = P.ancestor(X,Y)

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020",
                           srctext=R.render(p),
                           ask=R.render(q))
  pengine = Pengine(builder=factory)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  for p in pengine.currentQuery.availProofs:
      print('{} <- {}'.format(p[X.name], p[Y.name]))

source_raw:
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine
  from prologterms import TermGenerator, PrologRenderer, Program, Var

  P = TermGenerator()
  X = Var('X')
  Y = Var('Y')
  Z = Var('Z')
  R = PrologRenderer()

  p = Program(
      P.ancestor(X,Y) <= (P.parent(X,Z), P.ancestor(Z,Y)),
      P.ancestor(X,Y) <= P.parent(X,Y),
      P.parent('a','b'),
      P.parent('b','c'),
      P.parent('c','d')
  )

  q = P.ancestor(X,Y)

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020",
                           srctext=R.render(p),
                           ask=R.render(q))
  pengine = Pengine(builder=factory)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  for p in pengine.currentQuery.availProofs:
      print('{} <- {}'.format(p[X.name], p[Y.name]))


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '((member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '((member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory, debug=True)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q, debug=True)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q, debug=True)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020")
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020")
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q, Debug=True)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q, Debug=True)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'ls'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'X=1'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'X=1'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,wote(ls))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,wote(ls))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=True, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,wote(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,wote(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wets(S,(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wets(S,(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,(write("hi"))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,(write("hi"))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,weto(write("hi"))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,weto(write("hi"))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,weto(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,weto(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,(ls)).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,((current_output(CO),set_property(CO,alias(user_error)),set_property(CO,alias(current_output)),ls))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,((current_output(CO),set_property(CO,alias(user_error)),set_property(CO,alias(current_output)),ls))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'X=wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'X=wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'a(X)'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'a(X)'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'with_no_dmsg(wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),c80("A man farts"))))),assert(a(S))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'with_no_dmsg(wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),c80("A man farts"))))),assert(a(S))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'with_no_dmsg(wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),c80("A man farts")))))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'with_no_dmsg(wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),c80("A man farts")))))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'parse_into("A man farts",X)'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'parse_into("A man farts",X)'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'parse_into("A man farts")'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'parse_into("A man farts")'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = "parse_into('A man farts')"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = "parse_into('A man farts')"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = "a(X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = "a(X)"
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'e2ec("A man waits"),a(X)'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = 'e2ec("A man waits"),a(X)'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),a(X)))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),a(X)))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X))))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X))))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X)))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X)))).'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X)))),write(X),fail'

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X)))),write(X),fail'

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X)))),write(X),fail'
  q = '((e2ec("A man waits"),retract(e2eco(X))))'

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  #q = 'X=((wots(S,((current_output(CO),set_stream(CO,alias(user_error)),set_stream(CO,alias(current_output)),ls))),fail))'
  q = '((e2ec("A man waits"),retract(e2eco(X)))),write(X),fail'
  q = '((e2ec("A man waits"),retract(e2eco(X))))'

  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


source:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '((member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  from IPython.core.display import display, HTML
  display(HTML('<h1>Hello, world!</h1>'))
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)

source_raw:
  #!pip install pengines
  from pengines.Builder import PengineBuilder
  from pengines.Pengine import Pengine

  q = '((member(X,[1,2,3])))'
  factory = PengineBuilder(urlserver="http://logicmoo.org:3020", destroy=False, ask=q)
  pengine = Pengine(builder=factory)
  from IPython.core.display import display, HTML
  display(HTML('<h1>Hello, world!</h1>'))
  # Start query.
  print()
  print(pengine.currentQuery.availProofs, "Has More? ", pengine.currentQuery.hasMore)
  print()
  # Get next query.
  print(pengine.state.current_state)
  while pengine.currentQuery.hasMore:
      pengine.doNext(pengine.currentQuery)
  print(pengine.currentQuery.availProofs)


