ceetle/model/
tl_syntax.rs1use std::fmt;
2
3pub enum CTLFormula<T: PartialEq> {
7 True,
8 False,
9 Atom(T),
10 And(Box<CTLFormula<T>>, Box<CTLFormula<T>>),
11 Or(Box<CTLFormula<T>>, Box<CTLFormula<T>>),
12 Not(Box<CTLFormula<T>>),
13 Imply(Box<CTLFormula<T>>, Box<CTLFormula<T>>),
14 AG(Box<CTLFormula<T>>),
15 AF(Box<CTLFormula<T>>),
16 AX(Box<CTLFormula<T>>),
17 AU(Box<CTLFormula<T>>, Box<CTLFormula<T>>),
18 EG(Box<CTLFormula<T>>),
19 EF(Box<CTLFormula<T>>),
20 EX(Box<CTLFormula<T>>),
21 EU(Box<CTLFormula<T>>, Box<CTLFormula<T>>),
22}
23
24impl<T: fmt::Display + PartialEq> fmt::Display for CTLFormula<T> {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match self {
28 Self::True => {
29 write!(f, "⊤")
30 }
31 Self::False => {
32 write!(f, "⊥")
33 }
34 Self::Atom(value) => {
35 write!(f, "{}", value)
36 }
37 Self::And(value, value2) => {
38 write!(f, "({}∧{})", value, value2)
39 }
40 Self::Or(value, value2) => {
41 write!(f, "({}∨{})", value, value2)
42 }
43 Self::Not(value) => {
44 write!(f, "¬{}", value)
45 }
46 Self::Imply(value, value2) => {
47 write!(f, "({}→{})", value, value2)
48 }
49 Self::AG(value) => {
50 write!(f, "AG{}", value)
51 }
52 Self::AF(value) => {
53 write!(f, "AF{}", value)
54 }
55 Self::AX(value) => {
56 write!(f, "AX{}", value)
57 }
58 Self::AU(value, value2) => {
59 write!(f, "A[{} U {}]", value, value2)
60 }
61 Self::EG(value) => {
62 write!(f, "EG{}", value)
63 }
64 Self::EF(value) => {
65 write!(f, "EF{}", value)
66 }
67 Self::EX(value) => {
68 write!(f, "EX{}", value)
69 }
70 Self::EU(value, value2) => {
71 write!(f, "E[{} U {}]", value, value2)
72 }
73 }
74 }
75}