def replaceNthNT(term: PPTerm, ntId: int, newSubTerm: PPTerm) -> PPTerm: newTerm = ASTUtils.applyTdOnce(term, ASTUtils.isNthNT(ntId), lambda nt: newSubTerm) return newTerm
def expandNthNT(term: PPTerm, ntId: int, expand: Callable[[PPTermNT], PPTerm]) -> PPTerm: newTerm = ASTUtils.applyTdOnce(term, ASTUtils.isNthNT(ntId), expand) return newTerm