def get_subsuming_decl_(self,lit): modebs,modehs = self.globvals.modeb,self.globvals.modeh modes = flatten([modebs,modehs]) x = {m:self.variabilize_mode_(m) for m in modes} sumsuming = None for m in x: if 'passenger_satisfaction' in m: stop = 'stop' (map_,varmode) = x[m] (subsumes,substitution) = subsumption.theta_subsumes([varmode], [lit], modes_subsumption=True) if subsumes: print('ok!') print(map_) sumsuming = m
def update_support(theory,**kwargs): if isinstance(theory,dict): pass elif isinstance(theory,list) and theory != []: if all(isinstance(x,structs.Clause) for x in theory): # then we need to find the kernel clauses subsumed by each clause in theory if gl.current_var_kernel != [] : var_kernel = gl.current_var_kernel elif 'simple_update' in kwargs and kwargs['simple_update']: generate_kernel(**kwargs) var_kernel = gl.current_var_kernel else: #raise_(excps.KernelSetNotFoundException('No Kernel Set!',gl.logger)) return True for c1 in theory: for c2 in var_kernel: if add_to_support(c1,c2): c1.support.append(c2) elif all(isinstance(x,list) for x in theory): y = [x for y in theory for x in y] return update_support(y,**kwargs) else:pass elif isinstance(theory,tuple): # then we need all x in c1 : c2 \preceq x for (c1,c2) in theory parent,ref = theory[0],theory[1] if isinstance(ref,list): for x in ref: for y in parent.support: if subsumption.theta_subsumes(x.as_str_list,y.as_str_list) : x.support.append(y) elif isinstance(ref,structs.Clause): for y in parent.support: if subsumption.theta_subsumes(ref.as_str_list,y.as_str_list) : ref.support.append(y) else: msg = 'Dont know what to do with this: %s update support (see supported types at utils.update_support)'(ref) raise excps.SupportSetException(msg,gl.logger) else: pass
def add_to_support(add_to,to_add): t1 = subsumption.theta_subsumes(add_to.as_str_list,to_add.as_str_list) t2 = all(not subsumption.theta_subsumes(to_add.as_str_list,x.as_str_list) \ for x in add_to.support) if add_to.support != [] else True return t1 and t2