def substitute(clause, _vars, skolem_constants): _map = dict(zip(_vars, skolem_constants)) if isinstance(clause, basestring): term = functs.parse(clause) return _substitute(term, _map, []) elif isinstance(clause, list): return [_substitute(functs.parse(x), _map, []) for x in clause] else: raise excps.ParsingException("Ill-formed term: %s") % (clause)
def substitute(clause,_vars,skolem_constants): _map = dict(zip(_vars,skolem_constants)) if isinstance(clause,basestring): term = functs.parse(clause) return _substitute(term,_map,[]) elif isinstance(clause,list): return [_substitute(functs.parse(x),_map,[]) for x in clause] else: raise excps.ParsingException('Ill-formed term: %s')%(clause)
def variabilize_clause_literal(lit,used_vars_map,var_count,**all_plmrks): _lit = lit.as_string if all_plmrks == {}: symlist = ['+','-'] # variabilize input or output placemarkers only: else: if all_plmrks['all_plmrks']: symlist = ['+','-','#'] # variabilize each term that corresponds to a placemarker: to_be_varbed = {k:lit.terms_types_map[k] for k in lit.terms_types_map if any(x in lit.terms_types_map[k] for x in symlist)} vars_actually_used = [] vars_terms_map = {} for key in to_be_varbed: var = None if key in used_vars_map: var = used_vars_map[key] else: var_count += 1 var = 'X'+str(var_count) used_vars_map[key] = var #_lit = _lit.replace(key,var) vars_actually_used.append(var) vars_terms_map.update({key:var}) _lit = subsumption._substitute(functs.parse(_lit), vars_terms_map, []) return (_lit,used_vars_map,var_count,vars_actually_used) """