Пример #1
0
    def _setSpecificationInitialConditionsToCurrent(self, proj):
        """ Remove any existing initial conditions from the guarantees portion of the LTL specification
            and replace them with the current state of the system.

            Propositions that don't exist in both old and new specifications are ignored in the process."""

        # TODO: support doing this at the language level too?
        # TODO: what if state changes during resynthesis? should we be less restrictive?

        # parse the spec so we can manipulate it
        ltl_filename = proj.getFilenamePrefix() + ".ltl"
        assumptions, guarantees = LTLFormula.fromLTLFile(ltl_filename)

        # TODO: do we need to remove too? what about env?
        # add in current system state to make strategy smaller
        ltl_current_state = self.getCurrentStateAsLTL() # TODO: constrain to props in new spec
        gc = guarantees.getConjuncts()

        if ltl_current_state != "":
            gc.append(LTLFormula.fromString(ltl_current_state))

        # write the file back
        createLTLfile(ltl_filename, assumptions, gc)
Пример #2
0
    def _setSpecificationInitialConditionsToCurrent(self, proj):
        """ Remove any existing initial conditions from the guarantees portion of the LTL specification
            and replace them with the current state of the system.

            Propositions that don't exist in both old and new specifications are ignored in the process."""

        # TODO: support doing this at the language level too?
        # TODO: what if state changes during resynthesis? should we be less restrictive?

        # parse the spec so we can manipulate it
        ltl_filename = proj.getFilenamePrefix() + ".ltl"
        assumptions, guarantees = LTLFormula.fromLTLFile(ltl_filename)

        # TODO: do we need to remove too? what about env?
        # add in current system state to make strategy smaller
        ltl_current_state = self.getCurrentStateAsLTL() # TODO: constrain to props in new spec
        gc = guarantees.getConjuncts()

        if ltl_current_state != "":
            gc.append(LTLFormula.fromString(ltl_current_state))

        # write the file back
        createLTLfile(ltl_filename, assumptions, gc)
Пример #3
0
def createNecessaryFillerSpec(spec_part):
    """ Both assumptions guarantees need to have at least one each of
        initial, safety, and liveness.  If any are not present,
        create trivial TRUE ones. """

    if spec_part.strip() == "":
        filler_spec = ["TRUE", "[](TRUE)", "[]<>(TRUE)"]
    else:
        formula = LTLFormula.fromString(spec_part)
        filler_spec = []
        if not formula.getConjunctsByType(LTLFormulaType.INITIAL):
            filler_spec.append("TRUE")
        if not formula.getConjunctsByType(LTLFormulaType.SAFETY):
            filler_spec.append("[](TRUE)")
        if not formula.getConjunctsByType(LTLFormulaType.LIVENESS):
            filler_spec.append("[]<>(TRUE)")

    return " & ".join(filler_spec)
Пример #4
0
def createNecessaryFillerSpec(spec_part):
    """ Both assumptions guarantees need to have at least one each of
        initial, safety, and liveness.  If any are not present,
        create trivial TRUE ones. """

    if spec_part.strip() == "":
        filler_spec = ["TRUE", "[](TRUE)", "[]<>(TRUE)"]
    else:
        formula = LTLFormula.fromString(spec_part)
        filler_spec = []
        if not formula.getConjunctsByType(LTLFormulaType.INITIAL):
            filler_spec.append("TRUE")
        if not formula.getConjunctsByType(LTLFormulaType.SAFETY):
            filler_spec.append("[](TRUE)")
        if not formula.getConjunctsByType(LTLFormulaType.LIVENESS):
            filler_spec.append("[]<>(TRUE)")

    return " & ".join(filler_spec)