Beispiel #1
0
    def read(img: Union[str, PicHandler], path: str='D:\\Project\\') -> ElemBlock:
        if isinstance(img, str):
            ph = PicHandler(img, path=path)
        else:
            ph = img
        blocks = Parser.parse(ph.blocksOfPixels(), sensivity=4, merge='math')
        Parser.swap_coordinates(blocks)
        elemBlocks = [FormulaRecognizer.recBlock(block) for block in blocks]

        try:
            f = Formula(elemBlocks)
        except:
            return ElemBlock('', Position(0, 0, 0, 0), ok=False)
        print(f.texCode)
        #ph._show()
        return f.getFormula()
def isNextState(nextFormulas, nextAtom):
    """
        Checks if an atom satisfies a list of formulas with next operator as main connective. 

        :param nextFormulas: List of formulas with next operator as main connective.
        :type nextFormulas: List of :py:class:`~formula.Formula`

        :param nextAtom: Atom.
        :type nextAtom: List of :py:class:`~formula.Formula`

        :returns: ``True`` if the atom satisfies the termporal formulas or ``False`` otherwise.
        :rtype: Boolean

        :Example:

        >>> from modelCheckingGraph import *
        >>> atom = [Formula({'o': {'<>': {'^': {'': 'in=true', '~': {'o': 'x=2'}}}}}),
        ... Formula({'': 'in=true'}), Formula({'o': 'x=2'}), Formula({'': 'x=2'}),
        ... Formula({'<>': {'^': {'': 'in=true', '~': {'o': 'x=2'}}}}),
        ... Formula({'~': {'^': {'': 'in=true', '~': {'o': 'x=2'}}}})]
        >>> 
        >>> formulas = [Formula({'o': 'x=2'})]
        >>> isNextState(formulas,atom)
        True

        .. note::
            We say that an atom satisfies a list of formulas when for all the formulas :math:`\circ\phi` in the list we found a formula :math:`\phi` in the atom.

        .. seealso::
            :py:class:`formula.Formula`

    """
    for formula in nextFormulas:
        next = Formula(formula.getValues())
        if not isInAtom(next.getFormula(), nextAtom):
            return False
    return True