def make_norm_bijection(typ): # TODO SKOLEM ordered_vars = typ.gather_leaves( lambda leaf: isinstance(leaf, TypVar), lambda *args: OrderedDict( (a, True) for a in args)) proto_table = make_enum_table(ordered_vars.keys(), TypVar) table, rev_table = utils.construct_bijection(proto_table) return sub_m.Sub(table), sub_m.Sub(rev_table)
def __init__(self, typ, n): self.tab = make_normalization_table(typ) self.to_nf = sub.Sub(self.tab) self.typ_nf = self.to_nf(typ) self.n_nf = typ.get_next_var_id( n ) # we need to ensure computation will respect the *old* typ and *old* n
def mainProgram(): print("메인프로그램") class1 = sub.Sub(10, 20) print(class1) class2 = sub.Sub2(100000, 200000) print(class2) class2.submethod() ##print("서브에 있는 메서드입니다. ")
def denormalize_one(nf_sub_res): sigma_nf = nf_sub_res.sub sigma_table = {} n = self.n_nf for var_nf, tau_nf in sigma_nf.table.items(): var = from_nf(var_nf) tau = from_nf(tau_nf) sigma_table[var] = tau n = max(n, tau.get_next_var_id()) return sub.SubRes(nf_sub_res.num, sub.Sub(sigma_table), n)
def denormalize_one(self, nf_sub_res, n): sigma_nf = nf_sub_res.sub sigma_table = {} nvi = max(self.tnvi, n) for var_nf, tau_nf in sigma_nf.table.items(): var = self.sub_from_nf(var_nf) tau = self.sub_from_nf(tau_nf) sigma_table[var] = tau nvi = max(nvi, tau.get_next_var_id()) return sub.SubRes(nf_sub_res.num, sub.Sub(sigma_table), nvi)
def successors_typed(self, gamma, n): alpha, n1 = new_var(self.typ, n) typ_f = TypTerm.make_arrow(alpha, self.typ) ret = [(App(UnfinishedLeaf(typ_f), UnfinishedLeaf(alpha), self.typ), sub.Sub(), n1)] for ctx_declaration in gamma.ctx.values(): fresh_res = fresh(ctx_declaration.typ, self.typ, n) mu = sub.mgu(self.typ, fresh_res.typ) if not mu.is_failed(): sigma = mu.restrict(self.typ) leaf = Leaf(ctx_declaration.sym, sigma(self.typ)) ret.append((leaf, sigma, fresh_res.n)) return ret
def subs_uf_smart(self, uf_tree, k, n): uf_leafs = uf_tree.get_unfinished_leafs() num_uf_leafs = len(uf_leafs) num_fin_leafs = uf_tree.size() if num_fin_leafs + num_uf_leafs > k: return [] if num_uf_leafs > 0: hax_typ = TypTerm.make_internal_tuple( [uf_leaf.typ for uf_leaf in uf_leafs]) hax_k = k - num_fin_leafs + num_uf_leafs - 1 return self.subs(hax_k, hax_typ, n) elif num_fin_leafs == k: return [sub.PreSubRes(1, sub.Sub())] else: return []
import sub x = sub.Sub(70, 30) print(x)
import sub a = int(input("enter a number")) b = int(input("enter a number")) c = sub.Sub(a, b) print(c)
def skolemize(self): acc = {} skolemized = self._skolemize_acc(acc) return skolemized, sub_m.Sub(acc)
def make_from_nf_sub(self): rev_tab = {v: k for k, v in self.tab.items()} return sub.Sub(rev_tab)
import sub x = sub.Sub(10, 5) print(x)
def replace_unfinished_leafs_raw(self, new_subtrees): return self, sub.Sub()