Coverage for src/SymbSyntDec/pastSimple.py: 18%

1 from pylogics_modalities.parsers import parse_pltl

2 from pylogics_modalities.syntax.base import (

3 And as PLTLAnd,

4 Or as PLTLOr,

5 Formula,

6 Implies as PLTLImplies,

7 Not as PLTLNot

8)

9 from pylogics_modalities.syntax.pltl import (

10 Atomic as PLTLAtomic,

11 Before,

12 WeakBefore,

13 Historically,

14 Once

15)

16 from typing import Set

17

18

19 def past_simple_env(formula: Set[PLTLAtomic]) -> Formula:

20 or_u = None

21 for u1 in formula:

22 if or_u == None:

23 or_u = u1

24 and_neg_u = PLTLNot(u1)

25 and_u = u1

26 else:

27 or_u = PLTLOr(or_u, u1)

28 and_neg_u = PLTLAnd(and_neg_u, PLTLNot(u1))

29 and_u = PLTLAnd(and_u, u1)

30 not_and = PLTLNot(and_u)

31

32 phi2 = PLTLImplies(Before(or_u), and_neg_u)

33 phi3 = PLTLImplies(Before(Before(or_u)), or_u)

34 left = Once(PLTLAnd

35 (WeakBefore(parse_pltl("false")), or_u))

36

37 phi1 = PLTLImplies(or_u, not_and)

38 right = Historically(

39 PLTLAnd(phi1, phi2, phi3))

40

41 return PLTLAnd(left, right)

42

43

44 def past_simple_con(formula: Set[PLTLAtomic]) -> Formula:

45 or_c = None

46 for c1 in formula:

47 if or_c == None:

48 or_c = c1

49 and_neg_c = PLTLNot(c1)

50 and_c = c1

51 else:

52 or_c = PLTLOr(or_c, c1)

53 and_neg_c = PLTLAnd(and_neg_c, PLTLNot(c1))

54 and_c = PLTLAnd(and_c, c1)

55 not_and_c = PLTLNot(and_c)

56

57 phi1 = PLTLImplies(Before(and_neg_c), PLTLAnd(or_c, not_and_c))

58 phi2 = PLTLImplies(Before(Before(and_neg_c)), and_neg_c)

59 right = Historically(PLTLAnd(phi1, phi2))

60

61 left = Once(PLTLAnd

62 (WeakBefore(parse_pltl("false")), and_neg_c))

63

64 return PLTLAnd(left, right)

65

66

67'''

68# Examples:

69 formula_str = "!a S H(a)" # should be modifies to ( !a S (false T a))

70 print(formula_str)

71 formula_pltl = parse_pltl(formula_str)

72 print(formula_pltl)

73 formula_modified = modify(formula_pltl) # (since (not a) (triggers false a))

74 print(formula_modified)

75

76 formula_str = "O a" # should be modifies to (true S a)

77 print(formula_str)

78 formula_pltl = parse_pltl(formula_str)

79 print(formula_pltl)

80# (since PropositionalTrue(Logic.PLTL) a)

81 formula_modified = modify(formula_pltl)

82 print(formula_modified)

83

84'''