## 3 Mathematical Framework for Consistency
### Mathematical Representation of a Structural Model
#### 3.0.1 Port  
_A port is a singleton containing a symbol \(p\)._  
The ports are atomic elements of the model. They can be used to express variables in the model, states of a component, or other properties. We use symbols to represent this property; the symbol could be interpreted as the port's name. Figure 4: Structure of the pullback. **Definition 10**. : _Connection_  
_A connection is a non-empty, finite set of ports._  
This definition means that a connection is a category that contains the ports that it connects. We can now define the blocks with ports and connections, which are containers in the model. A block is a container that holds other blocks, ports, and connections. Therefore the definition of a block is recursive. **Definition 11**. : _Block_  
_A block is a category B such that:_  
* \(Ob(B)\) _is a finite set of blocks, ports and connections;_
* _For each connection_ \(C\)_, if a port_ \(P\in Ob(B)\) _is such that_ \(P\in Ob(C)\)_, then there exists two functors_ \(r_{P,C}:P\longrightarrow C\) _and_ \(r^{\prime}_{P,C}:C\longrightarrow P\) _in B such that_ \(r_{P,C}\) _maps_ \(p\in P\) _to_ \(P\in Ob(C)\) _and_ \(r^{\prime}_{P,C}\) _maps every element of_ \(C\) _to_ \(p\in Ob(P)\) _and every morphism to_ \(Id_{p}\)_._
* For each connection_ \(C\in Ob(B_{1})\)_, we have_ \(C\in Ob(B)\) _and there is a morphism_ \(\alpha_{C,B_{1}}:C\longrightarrow B_{1}\) _in_ \(B\) _that maps each element of_ \(C\) _to_ \(C\in Ob(B_{1})\)_;_
- For each port_ \(P\in Ob(B_{1})\)_, we have_ \(P\in Ob(B)\) _and there is a morphism_ \(\alpha_{P,B_{1}}:P\longrightarrow B_{1}\) _in_ \(B\) _that maps_ \(p\in P\) _to_ \(P\in Ob(B_{1})\)_;_
- For each block_ \(B_{2}\in Ob(B_{1})\)_, we have_ \(B_{2}\in Ob(B)\) _and there is a morphism_ \(\alpha_{B_{2},B_{1}}:B_{2}\longrightarrow B_{1}\) _that maps every object of_ \(B_{2}\) _to itself in_ \(B_{1}\) _and does the same with morphisms;_ _For each_ \(X\) _in_ \(Ob(B_{1})\)_, there exist a unique block_ \(B^{\prime}\in B\) _(possibly_ \(B_{1}\)_), such that there is no block_ \(B^{\prime\prime}\in B^{\prime}\) _such that_ \(X\in B^{\prime\prime}\)_; we also have either_ \(B^{\prime}=B_{1}\) _or_ \(B^{\prime}\in Ob(B_{1})\)_;_
* _There are no other morphisms in the block than those described here and the morphisms that derive from category theory axioms, i.e., identities and compositions._  
Although this definition can look very complicated, it simply carries the properties of a block to the world of categories. Thus, each point of the definition can be explained straightforwardly. We define two morphisms between a connection and the ports that are in the block and the connection. These morphisms represent the relation between the ports and the connection. The ports are both parts of the connection, and the connection refers to them. The typical structure of a connection in a block is depicted in Figure 5; it corresponds to the connection from Figure 6. We do not assume that all ports of the connection are contained in the block. In a model, we will eventually find an ancestor block containing all the connection's ports. However, connections usually go from one block to another. Thus, there is no reason for all ports to be contained in any block that contains the connection. In Figure 5, the plain arrows represent the \(r_{P1,C},r^{\prime}_{P1,C},r_{P2,C}\) and \(r^{\prime}_{P2,C}\) morphisms, and the dotted arrows represent their compositions. We have morphisms both from the  
Figure 5: Structure of a connection with two ports in a block/model. Figure 6: Example of a system model. ports to the connection and from the connection to the ports. Therefore, we also have morphisms between ports that participate in the same connection because of composition. In the same way, assume we have three ports, P1, P2, and P3, and two connections, C1 between P1 and P2 and C2 between P2 and P3. We will have morphisms between P1 and P3 because of composition, indicating an indirect connection between these ports. The third point of the definition does translate the belonging relation in S2 ML models.