Пример #1
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"(.+)\\(.+)", s)
     if not match:
         return None
     sentence1 = from_lean(match[1], context, _sentences_match_div())
     if not sentence1:
         return None
     sentence2 = from_lean(match[2], context, _sentences_match_div())
     if not sentence2:
         return None
     return cls(sentence1, sentence2)
Пример #2
0
 def from_lean(cls, s: str, context=None):
     ineq_symbols = "|".join(MAP_LEAN_INEQ.keys())
     match = re.fullmatch(r"(.+) (" + ineq_symbols + r") (.+)", s)
     if not match:
         return None
     ident1 = from_lean(match[1], context, _sentences_match_inequality())
     if not ident1:
         return None
     ident2 = from_lean(match[3], context, _sentences_match_inequality())
     if not ident2:
         return None
     return cls(ident1, MAP_LEAN_INEQ[match[2]], ident2)
Пример #3
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"\|(.+) - (.+)\|", s)
     if not match:
         return None
     sentence1 = from_lean(match[1], context,
                           _sentences_match_absolutediff())
     if not sentence1:
         return None
     sentence2 = from_lean(match[2], context,
                           _sentences_match_absolutediff())
     if not sentence2:
         return None
     return cls(sentence1, sentence2)
Пример #4
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"∀ (\w+), (.+)", s)
     if not match:
         return None
     sentence = from_lean(match[2], context, _sentences_match_forall())
     if not sentence:
         return None
     return cls(match[1], sentence)
Пример #5
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"(.+);", s)
     if not match:
         return None
     tactic = from_lean(match[1], context, _sentences_match_doallsubgoals())
     if not tactic:
         return None
     return cls(tactic)
Пример #6
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"have (\w+) : (.+) := (\w+) (\w+)", s)
     if not match:
         return None
     sentence = from_lean(match[2], context, _sentences_match_bysentencewith())
     if not sentence:
         return None
     return cls(match[1], sentence, match[3], match[4])
Пример #7
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"have (\w+) : (.+) := by obvious_ineq", s)
     if not match:
         return None
     sentence = from_lean(
         match[2], context, _sentences_match_byinequalityproperties()
     )
     if not sentence:
         return None
     return cls(match[1], sentence)
Пример #8
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"cases (\w+) (\w+) (\w+) with (\w+) (\w+)", s)
     if not match:
         return None
     limit_def = match[1]
     eps = from_lean(match[2], context, _sentences_match_choosenepsilonlimit())
     hyp_eps = match[3]
     n_chosen = match[4]
     hyp_n = match[5]
     return cls(limit_def, eps, hyp_eps, n_chosen, hyp_n)
Пример #9
0
 def from_lean(cls, s: str, context=None):
     match = re.fullmatch(r"intros (\w+) (\w+)", s)
     if not match:
         return None
     if not isinstance(context.current_goal, SequenceLimit) and not isinstance(
         context.current_goal, ComposedSequenceLimit
     ):
         return None
     ident = from_lean(match[1], context, _sentences_match_letgoallimit())
     if not ident:
         return None
     hyp = match[2]
     context.associate(ident.to_lean(), hyp)
     return cls(ident, hyp)
Пример #10
0
def lean_variable_to_nat(s, context):
    sentences_match = COMMON_SENTENCES
    match = from_lean(s, context, sentences_match)
    if not match:
        raise LeanToNaturalError()
    return match.to_natural()