Пример #1
0
def total_ordering(*relations):
    '''
    Return a conjunction of relations in the total ordering style.
    For example, "a > b >= c = d > e" is a total ordering style for
    "(a > b) and (b >= c) and (c = d) and (d > e)".
    '''
    from proveit.logic import And
    conjunction = And(*relations)
    conjunction = conjunction.with_total_ordering_style()
    if conjunction.operands.is_single():
        # A single relation is a trivial total ordering.
        return conjunction.operands[0]
    return conjunction
Пример #2
0
def total_ordering(*relations, prove=False):
    '''
    Return a conjunction of relations in the total ordering style.
    For example, "a > b >= c = d > e" is a total ordering style for
    "(a > b) and (b >= c) and (c = d) and (d > e)".  If there is a
    single relation, just return the relation.  If 'prove' is True,
    return a proven Judgment.
    '''
    from proveit import ExprRange
    from proveit.logic import And
    if len(relations) == 1 and not isinstance(relations[0], ExprRange):
        # Return a trivial, singular relation.
        relation = relations[0]
        if prove: relation = relation.prove()
        return relation
    # Return a conjunction with the proper style.
    conjunction = And(*relations)
    conjunction = conjunction.with_total_ordering_style()
    if prove:
        # Prove via composition.
        # Allow automation to prove the length requirement.
        return conjunction.conclude_via_composition(automation=True)
    return conjunction