def interp_from_unsat_core(clauses1, clauses2, core, interpreted): used_syms = used_symbols_clauses(core) vars = used_variables_clauses(core) if vars: # print "interpolant would require skolem constants" return None core_consts = used_constants_clauses(core) clauses2_consts = used_constants_clauses(clauses2) # print "interp_from_unsat_core core_consts = {}".format(map(str,core_consts)) # print "interp_from_unsat_core clauses2_consts = {}".format(map(str,clauses2_consts)) renaming = dict() i = 0 for v in core_consts: if v not in clauses2_consts or v.is_skolem( ): # and v not in interpreted: renaming[v] = Variable('V' + str(i), Constant(v).get_sort()) i += 1 # print "interp_from_unsat_core core = {}".format(core) # print "interp_from_unsat_core renaming = {}".format(renaming) renamed_core = substitute_constants_clauses(core, renaming) # print "interp_from_unsat_core renamed_core = {}".format(renamed_core) res = simplify_clauses( Clauses([Or(*[negate(c) for c in renamed_core.fmlas])])) # print "interp_from_unsat_core res = {}".format(res) return res
def clauses_to_concept(name, clauses): vars = used_variables_clauses(clauses) # print "clauses_to_concept vars={}".format(vars) ps = [ ProductSpace([NamedSpace(~lit) for lit in clause]) for clause in clauses.triv_clauses() ] ss = ps[0] if len(ps) == 1 else SumSpace(ps) return (Atom(Symbol(name, RelationSort([v.sort for v in vars])), [v for v in vars]), ss)
def updatenvi(mod): ''' nvi = NumVarInv it just calculates the number of quantified variables of each sort in the fcs. ''' lcs = mod.labeled_conjs varsof = {} for lc in lcs: quant_vars = lut.used_variables_clauses(lc.formula) # list # print "var in conjs", quant_vars # <TODO> replace vars such that corresponding quantified vars can be identified for var in quant_vars: sort = var.sort.name name = var.name if sort not in varsof.keys(): varsof[sort] = set([name]) else: varsof[sort].add(name) global numVarInv for sort in varsof.keys(): numVarInv[sort] = len(varsof[sort])
def interp_from_unsat_core(clauses1,clauses2,core,interpreted): used_syms = used_symbols_clauses(core) vars = used_variables_clauses(core) if vars: # print "interpolant would require skolem constants" return None core_consts = used_constants_clauses(core) clauses2_consts = used_constants_clauses(clauses2) # print "interp_from_unsat_core core_consts = {}".format(map(str,core_consts)) # print "interp_from_unsat_core clauses2_consts = {}".format(map(str,clauses2_consts)) renaming = dict() i = 0 for v in core_consts: if v not in clauses2_consts or v.is_skolem(): # and v not in interpreted: renaming[v] = Variable('V' + str(i),Constant(v).get_sort()) i += 1 # print "interp_from_unsat_core core = {}".format(core) # print "interp_from_unsat_core renaming = {}".format(renaming) renamed_core = substitute_constants_clauses(core,renaming) # print "interp_from_unsat_core renamed_core = {}".format(renamed_core) res = simplify_clauses(Clauses([Or(*[negate(c) for c in renamed_core.fmlas])])) # print "interp_from_unsat_core res = {}".format(res) return res
def clauses_to_concept(name,clauses): vars = used_variables_clauses(clauses) # print "clauses_to_concept vars={}".format(vars) ps = [ProductSpace([NamedSpace(~lit) for lit in clause]) for clause in clauses.triv_clauses()] ss = ps[0] if len(ps) == 1 else SumSpace(ps) return (Atom(Symbol(name,RelationSort([v.sort for v in vars])),[v for v in vars]),ss)