Beispiel #1
0
def test_eventually_nested_3() -> None:
    formula = LTLEventually(
        LTLAnd(
            LTLVariable("a"),
            LTLEventually(
                LTLVariable("b"),
            ),
        ),
    )

    def get_lookup_table_a_false() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"a": False}

    def get_lookup_table_a_true() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"a": True}

    def get_lookup_table_b_true() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"b": True}

    f: Union[LTLFormula, bool] = formula
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_false)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_false)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_true)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_true)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_b_true)
    assert f
Beispiel #2
0
def test_until_2() -> None:
    formula = LTLUntil(
        LTLVariable("a"),
        LTLVariable("b"),
    )

    def get_lookup_table() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"a": False, "b": True}

    f: Union[LTLFormula, bool] = formula
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table)
    assert f
Beispiel #3
0
def test_get_variable_names() -> None:
    expected = ["a", "b"]

    formula: LTLFormula = LTLEventually(
        LTLAnd(
            LTLVariable("a"),
            LTLEventually(
                LTLVariable("b"),
            ),
        ),
    )
    actual = get_variable_names(formula)

    assert actual == expected
Beispiel #4
0
def test_var(b: bool) -> None:
    formula = LTLVariable("a")

    def get_lookup_table() -> Dict[str, Union[bool, Callable[[], bool]]]:
        lookup_table: Dict[str, Union[bool, Callable[[], bool]]] = {"a": b}
        return lookup_table

    f = ltl_interpret(formula, get_lookup_table)
    assert f is b
Beispiel #5
0
def test_eventually(lst: List[bool]) -> None:
    expected = any(lst)

    f: Union[LTLFormula, bool] = LTLEventually(LTLVariable("a"))
    for b in lst:
        if type(f) is bool:
            break

        def get_lookup_table() -> Dict[str, Union[bool, Callable[[], bool]]]:
            lookup_table: Dict[str, Union[bool, Callable[[], bool]]] = {"a": b}
            return lookup_table

        f = ltl_interpret(cast(LTLFormula, f), get_lookup_table)

    if type(f) is LTLEventually:
        f = False

    assert f is expected
Beispiel #6
0
def test_next(b: bool) -> None:
    f = ltl_interpret(LTLNext(LTLVariable(b)), fail_get_lookup_table)
    assert f == LTLVariable(b)
Beispiel #7
0
def test_if(b0: bool, b1: bool) -> None:
    f = ltl_interpret(
        LTLIf(LTLVariable(b0), LTLVariable(b1)),
        fail_get_lookup_table,
    )
    assert f is (not b0 or b1)
Beispiel #8
0
def test_and(b0: bool, b1: bool) -> None:
    f = ltl_interpret(
        LTLAnd(LTLVariable(b0), LTLVariable(b1)),
        fail_get_lookup_table,
    )
    assert f is (b0 and b1)
Beispiel #9
0
def test_bool(b: bool) -> None:
    f = ltl_interpret(LTLVariable(b), fail_get_lookup_table)
    assert f is b
Beispiel #10
0
def test_always_with_is_final_2() -> None:
    formula = LTLAlways(LTLAlways(LTLVariable("a")))
    f = ltl_interpret(formula, lambda: {"a": True}, is_final=True)
    assert f is True
Beispiel #11
0
def test_eventually_nested_with_is_final() -> None:
    formula = LTLEventually(LTLEventually(LTLVariable("a")))
    f = ltl_interpret(formula, lambda: {"a": False}, is_final=True)
    assert f is False