# Path: pyke/contexts.py
# class simple_context(object):
# class bc_context(simple_context):
# class variable(pattern.pattern):
# class anonymous(variable):
#     def __init__(self):
#     def dump(self):
#     def bind(self, var_name, var_context, val, val_context = None):
#     def is_bound(self, var):
#     def lookup_data(self, var_name, allow_vars = False, final = None):
#     def lookup(self, var, allow_variable_in_ans = False):
#     def mark(self, save_all_undo = False):
#     def end_save_all_undo(self):
#     def undo_to_mark(self, mark, *var_names_to_undo):
#     def done(self):
#     def _unbind(self, var_name):
#     def __init__(self, rule):
#     def name(self): return self.rule.name
#     def __repr__(self):
#     def create_plan(self, final = None):
#     def __new__(cls, name):
#     def __init__(self, name):
#     def __repr__(self): return '$' + self.name
#     def lookup(self, my_context, allow_variable_in_ans = False):
#     def match_data(self, bindings, my_context, data):
#     def simple_match_pattern(self, bindings, my_context, pattern_b, b_context):
#     def match_pattern(self, bindings, my_context, pattern_b, b_context):
#     def as_data(self, my_context, allow_vars = False, final = None):
#     def is_data(self, my_context):
#     def __init__(self, name):
#     def lookup(self, my_context, allow_variable_in_ans = False):
#     def match_data(self, bindings, my_context, data):
#     def match_pattern(self, bindings, my_context, pattern_b, b_context):
#     def as_data(self, my_context, allow_vars = False, final = None):
#     def is_data(self, my_context):


import sys
import types
import os, os.path
import re
import contextlib
    import itertools
import pyke
from pyke import contexts
        from pyke import (condensedPrint, pattern, fact_base, goal, rule_base,
                          special, target_pkg)
            from pyke import ask_tty

            >>> vars, plan = \
            ...   my_engine.prove_1_goal(
            ...     'bc_example.how_related($person1, $person2, $how_related)',
            ...     person1='bruce',
            ...     person2='m_thomas')
            >>> print "bruce is related to m_thomas as", vars['how_related']
            bruce is related to m_thomas as ('father', 'son')

        If you want more than one answer, see engine.prove_goal.
        '''
        return goal.compile(goal_str).prove_1(self, **args)

    def prove(self, kb_name, entity_name, pat_context, patterns):
        r'''Deprecated.  Use engine.prove_goal.
        '''
        return self.get_kb(kb_name).prove(pat_context, pat_context,
                                          entity_name, patterns)

    def prove_n(self, kb_name, entity_name, fixed_args = (), num_returns = 0):
        '''Returns a context manager for a generator of:
               a tuple of len == num_returns, and a plan (or None).

        Deprecated.  Use engine.prove_goal.
        '''
        if isinstance(fixed_args, types.StringTypes):
            raise TypeError("engine.prove_n: fixed_args must not be a string, "
                            "did you forget a , (%(arg)s) => (%(arg)s,)?" %
                            {'arg': repr(fixed_args)})
        def gen():

# Path: pyke/contexts.py
# class simple_context(object):
# class bc_context(simple_context):
# class variable(pattern.pattern):
# class anonymous(variable):
#     def __init__(self):
#     def dump(self):
#     def bind(self, var_name, var_context, val, val_context = None):
#     def is_bound(self, var):
#     def lookup_data(self, var_name, allow_vars = False, final = None):
#     def lookup(self, var, allow_variable_in_ans = False):
#     def mark(self, save_all_undo = False):
#     def end_save_all_undo(self):
#     def undo_to_mark(self, mark, *var_names_to_undo):
#     def done(self):
#     def _unbind(self, var_name):
#     def __init__(self, rule):
#     def name(self): return self.rule.name
#     def __repr__(self):
#     def create_plan(self, final = None):
#     def __new__(cls, name):
#     def __init__(self, name):
#     def __repr__(self): return '$' + self.name
#     def lookup(self, my_context, allow_variable_in_ans = False):
#     def match_data(self, bindings, my_context, data):
#     def simple_match_pattern(self, bindings, my_context, pattern_b, b_context):
#     def match_pattern(self, bindings, my_context, pattern_b, b_context):
#     def as_data(self, my_context, allow_vars = False, final = None):
#     def is_data(self, my_context):
#     def __init__(self, name):
#     def lookup(self, my_context, allow_variable_in_ans = False):
#     def match_data(self, bindings, my_context, data):
#     def match_pattern(self, bindings, my_context, pattern_b, b_context):
#     def as_data(self, my_context, allow_vars = False, final = None):
#     def is_data(self, my_context):


# Path: pyke/knowledge_engine.py
import sys
import types
import os, os.path
import re
import contextlib
    import itertools
import pyke
from pyke import contexts
        from pyke import (condensedPrint, pattern, fact_base, goal, rule_base,
                          special, target_pkg)
            from pyke import ask_tty


            >>> vars, plan = \
            ...   my_engine.prove_1_goal(
            ...     'bc_example.how_related($person1, $person2, $how_related)',
            ...     person1='bruce',
            ...     person2='m_thomas')
            >>> print "bruce is related to m_thomas as", vars['how_related']
            bruce is related to m_thomas as ('father', 'son')

        If you want more than one answer, see engine.prove_goal.
        '''
        return goal.compile(goal_str).prove_1(self, **args)

    def prove(self, kb_name, entity_name, pat_context, patterns):
        r'''Deprecated.  Use engine.prove_goal.
        '''
        return self.get_kb(kb_name).prove(pat_context, pat_context,
                                          entity_name, patterns)

    def prove_n(self, kb_name, entity_name, fixed_args = (), num_returns = 0):
        '''Returns a context manager for a generator of:
               a tuple of len == num_returns, and a plan (or None).

        Deprecated.  Use engine.prove_goal.
        '''
        if isinstance(fixed_args, types.StringTypes):
            raise TypeError("engine.prove_n: fixed_args must not be a string, "
                            "did you forget a , (%(arg)s) => (%(arg)s,)?" %
                            {'arg': repr(fixed_args)})
        def gen():

            context = contexts.simple_context()