Skip to content

Commit fd653ba

Browse files
authored
Merge pull request #41 from ghost242/ai/knowledge-base-with-set
fix(symbolicai): not rendered katex expressions in post 2 for knowled…
2 parents d8f06e7 + 4fa840a commit fd653ba

1 file changed

Lines changed: 43 additions & 19 deletions

File tree

docs/ai/symbolic/2025-12-27-set-theory-for-kb.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,25 @@ tag: ["Knowledge Base", "Set Theory", "Logic"]
2323
2424
이걸 집합으로 표현하면 이러하다.
2525

26-
> 1. $Socrates \in Human$
27-
> 2. $Human \subseteq Mortal$
28-
> 3. Then, $Socrates \in Mortal$
26+
$$
27+
\begin{array}{ll}
28+
&&Socrates \in Human &\text{(1)}\\
29+
&&Human \subseteq Mortal &\text{(2)}\\
30+
\cr
31+
&\therefore &Socrates \in Mortal &\text{(3)}\\
32+
\end{array}
33+
$$
2934

3035
위 수식들은 "`Socrates``Human`의 속해있고, `Human``Mortal`의 부분집합이기 때문에, `Socrates`는 Mortal에 속한다", 라는 논리를 표현한다. 이렇게 표현했을 때 집합의 요소들과 `Knowledge Base`의 요소가 어떻게 연관되는지 알 수 있다.
3136

32-
> * Element ↔ Socrates
33-
> * Fact ↔ $Socrates \in Human$
34-
> * Rule ↔ $Human \subseteq Mortal$
35-
> * Query ↔ $Socrates \in Mortal$
37+
$$
38+
\begin{array}{ll}
39+
\text{Element }&\leftrightarrow &Socrates\\
40+
\text{Fact }&\leftrightarrow &Socrates \in Human\\
41+
\text{Rule }&\leftrightarrow &Human \subseteq Mortal\\
42+
\text{Query }&\leftrightarrow &Socrates \in Mortal\\
43+
\end{array}
44+
$$
3645

3746
여기서 Query는 3단논법에서는 결론에 해당하지만, `Inference Engine`이 입력받는 질의로도 이해할 수 있다. 만약 $Socrates \in Mortal$ 가 Query가 아니고 이미 `Knowledge Base`에 있는 정보라면, `Fact`로 분류할 수도 있다.
3847

@@ -110,13 +119,17 @@ graph
110119
end
111120
```
112121

113-
> 1. $Atom = \{Hydrogen, Neon\}$
114-
> 2. $God = \{Athena\}$
115-
> 3. $Insect = \{Fly, Ladybug\}$
116-
> 4. $Human = \{Socrates\}$
117-
> 5. $Immortal \supseteq Atom \cup God \text{ and } \emptyset \equiv Atom \cap God$
118-
> 6. $Mortal \supseteq Insect \cup Human \text{ and } \emptyset \equiv Insect \cap Human$
119-
> 7. $U \supseteq Immortal \cup Mortal \text{ and } \emptyset \equiv Immortal \cap Mortal$
122+
$$
123+
\begin{array}{llllll}
124+
&Atom = \{Hydrogen, Neon\} &&&&\text{(1)}\\
125+
&God = \{Athena\} &&&&\text{(2)}\\
126+
&Insect = \{Fly, Ladybug\} &&&&\text{(3)}\\
127+
&Human = \{Socrates\} &&&&\text{(4)}\\
128+
&Immortal \supseteq Atom \cup God &\text{ and } \emptyset &\equiv &Atom \cap God &\text{(5)}\\
129+
&Mortal \supseteq Insect \cup Human &\text{ and } \emptyset &\equiv &Insect \cap Human &\text{(6)}\\
130+
&U \supseteq Immortal \cup Mortal &\text{ and } \emptyset &\equiv &Immortal \cap Mortal &\text{(7)}\\
131+
\end{array}
132+
$$
120133

121134
이 수식에서 1에서 4까지 집합을 정의하고, 5에서 7까지는 집합간의 포함관계를 정의한 내용이다. 위에 정의되어있는 집합들에 대한 포함관계가 중요한데, Immortal과 Mortal, Atom과 God, Insect와 Human은 각각이 서로소인 관계라는 것이다. 물론 현실세계의 모델을 `Knowledge Base``Fact``Rule`로 구축한다면 이보다는 훨씬 복잡한 집합 구조가 필요할 것이다.
122135

@@ -128,15 +141,26 @@ graph
128141

129142
또한 새로운 `Fact`가 입력될 때 기존의 논리 구조에 대해서도 적합한지 검증할 때도 유용하게 활용할 수 있다. 위의 `Knowledge Base`에 새로운 `Fact`인 "Socrates는 Immortal이다"를 입력한다고 가정해보면, 수학적 모델을 배제한 상태로 논리적으로 모순인지 알기위해서는 일일이 `Fact`와 연결된 `Rule`을 대조하면서 찾아내야 한다. 하지만 이걸 집합으로 표현해보면 간단히 모순이 발생하고 있음을 알 수 있다.
130143

131-
$\text{If }Socrates \in Immortal,$
144+
$$
145+
\text{If }Socrates \in Immortal,
146+
$$
132147

133148
위의 명제를 참으로 가정하고 정의되어있는 `Knowledge Base`를 전개해보면 아래와 같이 표현된다.
134149

135-
> 1. $U \supseteq Mortal \cup Immortal \text{ and } \emptyset \equiv Mortal \cap Immortal$</br>
136-
> 2. $Socrates \in Mortal$</br>
137-
> 3. $\therefore Socrates \in Mortal \text{ and } Socrates \in Immortal$</br>
150+
$$
151+
\begin{array}{lllll}
152+
&&U \supseteq Mortal \cup Immortal &\text{ and } &\emptyset \equiv Mortal \cap Immortal &\text{(1)}\\
153+
&&Socrates \in Mortal &&&\text{(2)}\\
154+
\cr
155+
&\therefore &Socrates \in Mortal &\text{ and } &Socrates \in Immortal &\text{(3)}\\
156+
\end{array}\\
157+
$$
138158

139-
1번을 통해 `Mortal``Immortal`의 교집합이 공집합임을 알 수 있고, 2를 통해서 Socrates는 Mortal에 속하는 요소임을 알 수 있다. 그런데 초기 가정인 $Socrates \in Immortal$이 참이기 때문에 결론에서 Socrates는 Mortal에 속하면서 동시에 Immortal에 속하게된다. 이 내용을 수식으로 표현한 것이 3번인데, 이 자체가 모순이기 때문에 이 가정 자체가 거짓이라는 것을 알 수 있다.
159+
1번을 통해 `Mortal``Immortal`가 서로소임을 알 수 있고, 2를 통해서 Socrates는 Mortal에 속하는 요소임을 알 수 있다. 그런데 초기 가정인,
160+
161+
$$Socrates \in Immortal$$
162+
163+
이 관계를 참으로 가정하였기 때문에 결론에서 Socrates는 Mortal에 속하면서 동시에 Immortal에 속하게된다. 이 내용을 수식으로 표현한 것이 3번인데, 이 자체가 모순이기 때문에 이 가정 자체가 거짓이라는 것을 알 수 있다.
140164

141165
다시 말해, `Knowledge Base`는 논리적 모순이 없음을 증명하고, 새로운 `Fact`를 검증할 때 집합을 통해 정의한 모델을 활용하면 빠르고 명확하게 결과를 얻어낼 수 있다.
142166

0 commit comments

Comments
 (0)