# Path: tensorlog/simple.py
# class Compiler(object):
# class Builder(object):
# class RuleCollectionWrapper(parser.RuleCollection):
# class DBWrapper(object):
# class SchemaWrapper(dbschema.TypedSchema):
# class RuleWrapper(parser.Rule):
# class Options(object):
# class Experiment(Options):
#   def __init__(self,target='tensorflow',db=None,prog=None,rule_features=True,autoset_db_params=True,summary_file=None):
#   def get_cross_compiler(self):
#   def get_program(self):
#   def get_database(self):
#   def proof_count(self,mode,inputs=None):
#   def inference(self,mode,inputs=None):
#   def loss(self,mode,inputs=None):
#   def mark_db_predicate_trainable(self,mode):
#   def trainable_db_variables(self,mode,for_optimization=False):
#   def input_placeholder_name(self,mode):
#   def input_placeholder(self,mode):
#   def target_output_placeholder_name(self,mode):
#   def target_output_placeholder(self,mode):
#   def db_param_list(self):
#   def db_param_is_set(self,param_id):
#   def get_db_param_value(self,param_id):
#   def set_db_param_value(self,param_id,value):
#   def set_all_db_params_to_learned_values(self,session):
#   def serialize_db(self,dir_name):
#   def serialize_program(self,dir_name):
#   def _as_dataset(self,spec):
#   def load_dataset(self,dataset_spec):
#   def load_small_dataset(self,dataset_spec):
#   def annotate_small_dataset(self,dset):
#     def wrapped_xy_pair(mode): return (self.xc.wrapInput(dset.getX(mode)), self.xc.wrapInput(dset.getY(mode)))
#   def modes_to_learn(self,dataset_obj):
#   def minibatches(self,dataset_obj,batch_size=100,shuffle_first=True):
#   def load_big_dataset(self,dataset_spec,verbose=True):
#   def annotate_big_dataset(self,dset):
#       def rows_per_gigabyte(c): return (1024.0*1024.0*1024.0) / (c*4.0)
#   def __init__(self):
#   def __setattr__(self,name,value):
#   def _split(comma_or_space_sep_names):
#   def variable(variable_name):
#   def variables(space_sep_variable_names):
#   def types(space_sep_type_names):
#   def rule_id(type_name,rule_id):
#   def rule_ids(type_name,space_sep_rule_ids):
#     def goal_builder(rule_id):
#   def predicate(predicate_name):
#   def predicates(space_sep_predicate_names):
#     def goal_builder(pred_name):
#       def builder(*args):
#   def __iadd__(self,other):
#   def __init__(self):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def _set_to_value(self,other):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def __iadd__(self,other):
#   def _combine(x,y):
#   def __and__(self,other):
#   def __or__(self,other):
#   def __floordiv__(self,other):
#   def __le__(self,other):
#   def __repr__(self):
#   def __init__(self):
#   def set_from_command_line(self,argv):
#   def as_dictionary(self):
#   def option_usage(self):
#   def __init__(self):
#   def run(self):
#     UX,UY = test[self.mode]


import tensorflow as tf
import expt
from tensorlog import simple


def runMain():
  # generate the data for a 10-by-10 grid
  (factFile,trainFile,testFile) = expt.genInputs(16)

  # generate the rules - for transitive closure
  b = simple.Builder()
  path,edge = b.predicates("path,edge")
  X,Y,Z = b.variables("X,Y,Z")
  b.rules += path(X,Y) <= edge(X,Y)
  b.rules += path(X,Y) <= edge(X,Z) & path(Z,Y)

  # construct a Compiler object

# Path: tensorlog/simple.py
# class Compiler(object):
# class Builder(object):
# class RuleCollectionWrapper(parser.RuleCollection):
# class DBWrapper(object):
# class SchemaWrapper(dbschema.TypedSchema):
# class RuleWrapper(parser.Rule):
# class Options(object):
# class Experiment(Options):
#   def __init__(self,target='tensorflow',db=None,prog=None,rule_features=True,autoset_db_params=True,summary_file=None):
#   def get_cross_compiler(self):
#   def get_program(self):
#   def get_database(self):
#   def proof_count(self,mode,inputs=None):
#   def inference(self,mode,inputs=None):
#   def loss(self,mode,inputs=None):
#   def mark_db_predicate_trainable(self,mode):
#   def trainable_db_variables(self,mode,for_optimization=False):
#   def input_placeholder_name(self,mode):
#   def input_placeholder(self,mode):
#   def target_output_placeholder_name(self,mode):
#   def target_output_placeholder(self,mode):
#   def db_param_list(self):
#   def db_param_is_set(self,param_id):
#   def get_db_param_value(self,param_id):
#   def set_db_param_value(self,param_id,value):
#   def set_all_db_params_to_learned_values(self,session):
#   def serialize_db(self,dir_name):
#   def serialize_program(self,dir_name):
#   def _as_dataset(self,spec):
#   def load_dataset(self,dataset_spec):
#   def load_small_dataset(self,dataset_spec):
#   def annotate_small_dataset(self,dset):
#     def wrapped_xy_pair(mode): return (self.xc.wrapInput(dset.getX(mode)), self.xc.wrapInput(dset.getY(mode)))
#   def modes_to_learn(self,dataset_obj):
#   def minibatches(self,dataset_obj,batch_size=100,shuffle_first=True):
#   def load_big_dataset(self,dataset_spec,verbose=True):
#   def annotate_big_dataset(self,dset):
#       def rows_per_gigabyte(c): return (1024.0*1024.0*1024.0) / (c*4.0)
#   def __init__(self):
#   def __setattr__(self,name,value):
#   def _split(comma_or_space_sep_names):
#   def variable(variable_name):
#   def variables(space_sep_variable_names):
#   def types(space_sep_type_names):
#   def rule_id(type_name,rule_id):
#   def rule_ids(type_name,space_sep_rule_ids):
#     def goal_builder(rule_id):
#   def predicate(predicate_name):
#   def predicates(space_sep_predicate_names):
#     def goal_builder(pred_name):
#       def builder(*args):
#   def __iadd__(self,other):
#   def __init__(self):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def _set_to_value(self,other):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def __iadd__(self,other):
#   def _combine(x,y):
#   def __and__(self,other):
#   def __or__(self,other):
#   def __floordiv__(self,other):
#   def __le__(self,other):
#   def __repr__(self):
#   def __init__(self):
#   def set_from_command_line(self,argv):
#   def as_dictionary(self):
#   def option_usage(self):
#   def __init__(self):
#   def run(self):
#     UX,UY = test[self.mode]


# Path: datasets/grid/demo.py
import tensorflow as tf
import expt
from tensorlog import simple



def runMain():
  # generate the data for a 10-by-10 grid
  (factFile,trainFile,testFile) = expt.genInputs(16)

  # generate the rules - for transitive closure
  b = simple.Builder()
  path,edge = b.predicates("path,edge")
  X,Y,Z = b.variables("X,Y,Z")
  b.rules += path(X,Y) <= edge(X,Y)
  b.rules += path(X,Y) <= edge(X,Z) & path(Z,Y)

  # construct a Compiler object

  tlog = simple.Compiler(db=factFile,prog=b.rules)