def fv(self, kind, env): if env.isBoundVar(self): return Concat(None) def simpleType(x): if isinstance(x, Id): return x.symbol if isinstance(x, List): return simpleType(x.arg) return None if kind in map(lambda x: simpleType(x), env.boundVars(self)): result = SetSub(None) result.lhs = FV(kind, self, None) result.rhs = Concat(None) result.rhs.elements = set(env.boundVars(self)) return result if kind not in self.symbol.deepVars(): return Concat(None) if self.symbol == kind: return self return FV(kind, self, None)
def subst(self, new, old, env, symbols): if env.isBoundVar(self): return self if env.provesIn(old, env.boundVars(self)): return self if env.provesEq(self, old): return new sym = old if isinstance(old, Id): sym = old.symbol if self.symbol == sym and env.provesNE(self, old): return self if not env.provesIn(sym, self.symbol.deepVars()): return self result = Subst(None) result.body = self result.lhs = new result.rhs = old return result
def subst(self, new, old, env, symbols): if self == old: #check bindings if old in env.boundVars(self): return self else: return new else: return self