---
id: wiki-2026-0508-knowledge-graph-foundations
title: Knowledge Graph Foundations
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [KG Foundations, Semantic Web Foundations]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [knowledge-graph, foundations, rdf, ontology]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: python
  framework: rdflib, owlready2
---

# Knowledge Graph Foundations

## 매 한 줄
> **"매 RDF + ontology + reasoning 의 stack"**. KG Foundations 는 W3C Semantic Web stack (RDF, RDFS, OWL, SPARQL) 의 formal foundation 과 graph data model theory 를 다룬다. 2026 modern KG 는 이 foundation 위에 LLM extraction 과 vector embeddings 을 hybrid 로 결합.

## 매 핵심

### 매 Data Model 계층
- **RDF**: triple — (s, p, o), URIs 로 entity 식별
- **RDFS**: schema layer — class, subClassOf, domain, range
- **OWL**: full ontology — equivalence, disjointness, cardinality
- **SHACL**: constraint validation

### 매 Reasoning
- forward chaining: rules → derived triples
- backward chaining: query-driven inference
- DL reasoning (Description Logic): subsumption, consistency

### 매 응용
1. DBpedia, Wikidata: 매 large-scale public KG.
2. Schema.org: 매 web markup ontology.
3. Bio2RDF: 매 life sciences integration.

## 💻 패턴

### RDF graph build
```python
from rdflib import Graph, Namespace, URIRef, Literal, RDF, RDFS

EX = Namespace("http://example.org/")
g = Graph()
g.bind("ex", EX)

g.add((EX.Claude, RDF.type, EX.LLM))
g.add((EX.LLM, RDFS.subClassOf, EX.AISystem))
g.add((EX.Claude, EX.creator, EX.Anthropic))
g.serialize("kg.ttl", format="turtle")
```

### OWL ontology with owlready2
```python
from owlready2 import *

onto = get_ontology("http://example.org/onto.owl")
with onto:
    class AISystem(Thing): pass
    class LLM(AISystem): pass
    class Organization(Thing): pass
    class creator(ObjectProperty):
        domain = [AISystem]
        range = [Organization]

claude = LLM("Claude")
anthropic = Organization("Anthropic")
claude.creator.append(anthropic)
sync_reasoner()  # HermiT reasoner
```

### SPARQL federated query
```python
from SPARQLWrapper import SPARQLWrapper, JSON

s = SPARQLWrapper("https://query.wikidata.org/sparql")
s.setQuery("""
SELECT ?company ?ceo WHERE {
    ?company wdt:P31 wd:Q4830453 .  # company
    ?company wdt:P169 ?ceo .         # CEO
} LIMIT 10
""")
s.setReturnFormat(JSON)
print(s.query().convert())
```

### SHACL validation
```python
from pyshacl import validate
conforms, _, report = validate(
    data_graph=g,
    shacl_graph="shapes.ttl",
    inference="rdfs",
)
```

### Forward chaining inference
```python
def forward_chain(triples, rules):
    derived = set(triples)
    changed = True
    while changed:
        changed = False
        for rule in rules:
            new = rule.apply(derived)
            if new - derived:
                derived |= new
                changed = True
    return derived
```

## 매 결정 기준
| 상황 | Stack |
|---|---|
| public LOD | RDF + SPARQL |
| domain ontology, reasoning | OWL + HermiT/Pellet |
| flexible schema | LPG (Neo4j) |
| validation | SHACL |
| LLM hybrid | RDF + embeddings |

**기본값**: RDF + SPARQL + SHACL.

## 🔗 Graph
- 부모: [[Graph-Theory]] · [[Logic]]
- 변형: [[RDF]] · [[OWL]] · [[Description-Logic]]
- 응용: [[Knowledge Graph]] · [[Semantic-Web]] · [[Wikidata]]
- Adjacent: [[Ontology]] · [[Reasoning-Systems]]

## 🤖 LLM 활용
**언제**: formal semantics, reasoning, standards-compliant interop 필요.
**언제 X**: ad-hoc agent memory — 매 simple key-value 면 충분.

## ❌ 안티패턴
- **OWL overengineering**: full DL reasoner 가 필요없는데 OWL Full 사용 → undecidable.
- **URI minting chaos**: 매 새 entity 마다 random URI → linkability 손실.
- **Closed-world assumption**: RDF 는 OWA — "absent ≠ false".

## 🧪 검증 / 중복
- Verified (W3C RDF 1.1 spec, OWL 2 spec, Hitzler 2009 textbook).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — RDF/OWL/SPARQL stack, reasoning, validation |
