def is_valid_total_length(index,
                          date_to_sent_mapping,
                          all_sent_dates,
                          timeline_properties):
    """
    Checks whether adding the sentence in focus would not violate
    the constraint of limiting the total number of sentences in a
    timeline.

    Corresponds to the AsMDS constrained described in Martschat and Markert
    (2018).
    
    Params:
        index (int): Index of the sentence in focus.
        date_to_sent_mapping (dict(datetime.datetime, list(tilse.data.sentences.Sentence)): 
            Mapping of dates in a timeline to the sentences in the summary for this date
            (describes the partial timeline constructed so far).
        all_sent_dates (list(datetime.dateime)): Dates for all sentences. In particular,
            `all_sent_dates[index]` is the date of the sentence in focus.
        timeline_properties (tilse.models.timeline_properties.TimelineProperties):
            Properties of the timeline to predict.
            
    Returns:
        False if (i) date of the sentence in focus is before start or after end date of the 
        timeline as defined in `timeline_properties` or (ii) adding the sentence in focus
        would lead to a timeline with more sentences than `timeline_properties.num_sentences`;
        True otherwise.
    """
    selected_date = all_sent_dates[index]

    if selected_date < timeline_properties.start \
            or selected_date > timeline_properties.end:
        return False

    return sum([len(sents) for sents in date_to_sent_mapping.values()]) \
           < timeline_properties.num_sentences