def get_substitution(generic_atom, specific_atom):
    """
    If `generic_atom` can be unified with the `specific_atom`, returns the
    substitution of the terms of `generic_atom` that unifies it with
    `specific_atom`; otherwise, returns `None`.

    :param generic_atom: the generic atom
    :type generic_atom: Atom
    :param specific_atom: the specific atom
    :type specific_atom: Atom
    :return: the substitution of the `generic_atom` terms
    :rtype: Dict[Term, Term]
    """
    if generic_atom.predicate != specific_atom.predicate:
        return None

    substitutions = dict()
    for i in range(generic_atom.arity()):
        generic_term = generic_atom.terms[i]
        specific_term = specific_atom.terms[i]

        if generic_term.is_constant() and generic_term != specific_term:
            return None
        else:
            substitution = substitutions.get(generic_term, None)
            if substitution is None:
                substitutions[generic_term] = specific_term
            elif substitution != specific_term:
                return None

    return substitutions