import re


def reduce_logic_text(text):
    """
    remove all existing logic forms in text
    text = "In rhombus ABCD, [LengthOf(Line(A, B), 2x+3)] and [LengthOf(Line(B, C), 5x)]. [Find(x)]."
    reduced_text = In rhombus ABCD,  and . .
    """
    # remove [exp]
    text = " " + text
    text = re.sub(r'\[.+?\]', "", text)  # non-greedy mode，shorter matched text is better

    # ignore nonsense words
    nonsense = ['\.', '\,', '\?', '\s\s']
    nonsense += [' in ', ' if ', ' so ', ' to ', ' is ']
    nonsense += [' and ', ' use ', ' for ', ' let ']
    nonsense += [' with ', ' that ', 'unit', 'then']
    nonsense += ['given', 'assume', 'number', 'inscribed', 'necessary', 'centimeter']
    nonsense += ['if necessary', ' formed by ', 'consisting of']
    nonsense += ['Round| to nearest whole number', 'Round| nearest \w+( of \w+|)', '(side|angle) measure',
                 'whole number', 'degree']
    nonsense += ['Which of following statements about is true']
    nonsense += ['Which of following facts would be sufficient prove']
    nonsense += ['Hint: Draw auxiliary line']
    nonsense += ['which cannot be true']
    nonsense += ['lengths of bases of']

    for word in nonsense:
        pattern = re.compile(word, re.IGNORECASE)
        text = pattern.sub(" ", text)

    text = re.sub(r'[\s]+', r' ', text)
    text = text.strip()

    return text