1
use merc_aterm::ATerm;
2
use merc_data::DataSpecification;
3
use merc_ldd::Ldd;
4

            
5
/// Represents a symbolic LTS encoded by a disjunctive transition relation and a set of states.
6
pub struct SymbolicLts {
7
    data_specification: DataSpecification,
8

            
9
    states: Ldd,
10

            
11
    /// A singleton LDD representing the initial state.
12
    initial_state: Ldd,
13

            
14
    summand_groups: Vec<SummandGroup>,
15
}
16

            
17
impl SymbolicLts {
18
    /// Creates a new symbolic LTS.
19
1
    pub fn new(
20
1
        data_specification: DataSpecification,
21
1
        states: Ldd,
22
1
        initial_state: Ldd,
23
1
        summand_groups: Vec<SummandGroup>,
24
1
    ) -> Self {
25
1
        Self {
26
1
            data_specification,
27
1
            states,
28
1
            initial_state,
29
1
            summand_groups,
30
1
        }
31
1
    }
32

            
33
    /// Returns the data specification of the LTS.
34
    pub fn data_specification(&self) -> &DataSpecification {
35
        &self.data_specification
36
    }
37

            
38
    /// Returns the LDD representing the set of states.
39
    pub fn states(&self) -> &Ldd {
40
        &self.states
41
    }
42

            
43
    /// Returns the LDD representing the initial state.
44
    pub fn initial_state(&self) -> &Ldd {
45
        &self.initial_state
46
    }
47

            
48
    /// Returns an iterator over the summand groups.
49
    pub fn summand_groups(&self) -> &[SummandGroup] {
50
        &self.summand_groups
51
    }
52
}
53

            
54
/// Represents a short vector transition relation for a group of summands.
55
///
56
/// # Details
57
///
58
/// A short transition vector is part of a transition relation T -> U, where we
59
/// store T' -> U' with T' being the projection of T on the read parameters and
60
/// U' the projection of U on the write parameters, as a LDD. Formally,
61
///
62
/// (t, u) in (T -> U)  iff  (t', u') in (T' -> U') where t' and u' are the projections
63
///     of t and u on the read and write parameters respectively.
64
pub struct SummandGroup {
65
    read_parameters: Vec<ATerm>,
66
    write_parameters: Vec<ATerm>,
67

            
68
    /// The transition relation T' -> U' for this summand group.
69
    relation: Ldd,
70
}
71

            
72
impl SummandGroup {
73
    /// Creates a new summand group.
74
101
    pub fn new(read_parameters: Vec<ATerm>, write_parameters: Vec<ATerm>, relation: Ldd) -> Self {
75
101
        Self {
76
101
            read_parameters,
77
101
            write_parameters,
78
101
            relation,
79
101
        }
80
101
    }
81

            
82
    /// Returns the transition relation LDD for this summand group.
83
    pub fn relation(&self) -> &Ldd {
84
        &self.relation
85
    }
86

            
87
    /// Returns the read parameters for this summand group.
88
    pub fn read_parameters(&self) -> &[ATerm] {
89
        &self.read_parameters
90
    }
91

            
92
    /// Returns the write parameters for this summand group.
93
    pub fn write_parameters(&self) -> &[ATerm] {
94
        &self.write_parameters
95
    }
96
}