def same_schema(atom1, atom2, theoryname=None):
    """Return True if ATOM1 and ATOM2 have the same schema.

    THEORYNAME is the default theory name.
    """
    if not atom1.table.same(atom2.table, theoryname):
        return False
    if len(atom1.arguments) != len(atom2.arguments):
        return False
    return True
