## 2 Fundamentals of the Semantic Web of Things  
The convergence of SIoT and SWoT technologies marks a significant advancement in the development of intelligent and context-aware IoT ecosystems. Combining the social relationships and interactions of SIoT with the rich, machine-interpretable metadata annotated by means of knowledge representation technologies significantly boosts the interoperability of IoT systems, allowing devices from different manufacturers and with varying protocols to interact with each other seamlessly. In the SWoT, knowledge representation involves the formalization of information in order to enhance the ability of interconnected devices to understand, reason, and act based on the rich contextual and relational information inherent in distributed networks. Semantic Web languages and technologies grounded on Description Logics (DLs) [13] are adopted to facilitate sharing and understanding of unambiguous knowledge across heterogeneous ubiquitous micro-devices. When SIoT leverages the SWoT, it benefits from enhanced interoperability through the use of common semantic frameworks and vocabularies. Specifically, this work relies on a general framework for the SWoT [14] based on an evolution of the classical Knowledge Base (KB) model, named a _ubiquitous Knowledge Base_ (u-KB). A u-KB represents a distributed knowledge base whose individuals (i.e., assertional knowledge) are physically tied to micro-devices on the objects disseminated in a reference environment. As shown in Figure 1, the following key elements are exploited in the proposed approach for implementing the reference SWoT framework in a social IoT context:  
* Pervasive sensing and IoT identification technologies exploited at the field layer, interconnecting embedded micro-devices dipped in the environment. Interaction among social devices is performed by means of CoAP protocol ensuring lightweight communication and information dissemination;
* Data acquired by sensing devices exposed at the upper layers in a uniform fashion, according to LDP and LDN guidelines described in Section 4.1. Data are annotated with respect to well-known ontologies and taxonomies, providing a shared understanding of domain knowledge. By integrating these semantic structures, SIoT devices can communicate more effectively, using a common language to describe their functions, states, and interactions;
* u-KB modeling in a _Web Ontology Language_ (_OWL_) 2 [15] subset corresponding to the _Attributive Language with unqualified Number restrictions_ (\(\mathcal{ALN}\)) DL. It provides moderate expressiveness while granting polynomial complexity to both standard and non-standard inference tasks;* Dynamic service/resource discovery and composition processes, detailed in Section 4.2, exploiting semantic matchmaking between ontology-based annotations describing requests and available resources. The following non-standard inference services [16], implemented in _Tiny-ME_ (_the Tiny Matchmaking Engine_) [17], have been adopted to support approximate matches, resource ranking and aggregation for covering complex requests:  
* _Concept Contraction:_ if a request \(\mathcal{R}\) and a supplied resource \(\mathcal{S}\) are not compatible with each other, Contraction determines which part of \(\mathcal{R}\) is conflicting with \(\mathcal{S}\). By giving up only conflicting requirements \(G\) (for _Give up_) in \(\mathcal{R}\), an expression \(K\) (for _Keep_) remains, which is a contracted version of the original request. The solution \(G\) to Contraction represents \"why\" \(\mathcal{R}\) and \(\mathcal{S}\) are not compatible;
* _Concept Abduction_: if request and resource are compatible, but \(\mathcal{S}\) does not satisfy \(\mathcal{R}\) completely, Abduction determines what should be hypothesized in \(\mathcal{S}\) in order to obtain a full match, i.e., to make the subsumption relation true.