def abs_to_rel_tuple(target: tuple, namespace: tuple):
    """
    >>> tg = ("aaa", "bbb", "ddd")
    >>> ns = ("aaa", "bbb", "ccc")
    >>> abs_to_rel_tuple(tg, ns)
    ('..', 'ddd')
    >>> tg == rel_to_abs_tuple(abs_to_rel_tuple(tg, ns), ns)
    True

    >>> tg = ("aaa", "bbb")
    >>> ns = ("aaa", "bbb", "ccc")
    >>> abs_to_rel_tuple(tg, ns)
    ('..',)
    >>> tg == rel_to_abs_tuple(abs_to_rel_tuple(tg, ns), ns)
    True

    >>> tg = ("aaa", "bbb", "ddd")
    >>> ns = ("aaa", "bbb")
    >>> abs_to_rel_tuple(tg, ns)
    ('.', 'ddd')
    >>> tg == rel_to_abs_tuple(abs_to_rel_tuple(tg, ns), ns)
    True

    >>> tg = ("eee", "fff")
    >>> ns = ("aaa",)
    >>> abs_to_rel_tuple(tg, ns)
    ('..', 'eee', 'fff')
    >>> tg == rel_to_abs_tuple(abs_to_rel_tuple(tg, ns), ns)
    True

    >>> tg = ("aaa",)
    >>> ns = ("aaa", "bbb", "ccc", "ddd")
    >>> abs_to_rel_tuple(tg, ns)
    ('....',)
    >>> tg == rel_to_abs_tuple(abs_to_rel_tuple(tg, ns), ns)
    True

    >>> tg = ("ddd",)
    >>> ns = ("aaa", "bbb", "ccc")
    >>> abs_to_rel_tuple(tg, ns)
    ('....', 'ddd')
    >>> tg == rel_to_abs_tuple(abs_to_rel_tuple(tg, ns), ns)
    True
    """
    tg = target
    ns = namespace
    tglen = len(tg)
    nslen = len(ns)
    shared = 0
    while shared < min(tglen, nslen) and tg[shared] == ns[shared]:
        shared += 1
    dots = nslen - shared + 1
    names = tglen - shared
    return ('.' * dots,) + tg[tglen - names:]
