AI-03 · ARTIFICIAL INTELLIGENCE

제약 충족·논리·지식 표현Constraint satisfaction, logic and knowledge representation

도서관의 두 시간대에서 지원값·되돌아가기·논리적 귀결까지From two library slots to supports, backtracking and logical consequence

실습 6종 · 풀이 포함 연습문제 60개6 labs · 60 exercises with solutions

기초Foundations

1. 세 모둠에 두 시간대를 나누어 준다1. Give three groups two time slots

도서관에서 모둠 A, B, C가 각각 한 번씩 발표합니다. 시간대는 1과 2입니다. A와 B에는 같은 학생이 있고 B와 C에도 같은 학생이 있어, 두 발표를 동시에 들을 수 없습니다. A와 C에는 이 장면에서 정한 그런 겹침이 없습니다. 모든 모둠을 같은 날 한 시간대에 넣는 대신, 겹치는 두 모둠만 서로 다른 시간대에 두려고 합니다.

가정한 발표 배정의 전체 2×2×2=8행
ABCA와 B가 다름B와 C가 다름모두 통과
111아니요아니요아니요
112아니요예아니요
121예예예
122예아니요아니요
211예아니요아니요
212예예예
221아니요예아니요
222아니요아니요아니요

세 칸에 1이나 2를 쓰는 방법은 2×2×2=8개입니다. A=1, B=2, C=1과 A=2, B=1, C=2 두 행만 두 조건을 함께 통과합니다. 이 문제의 첫 목표는 조건을 모두 지키는 행을 찾는 것입니다. 두 행 가운데 하나가 실제로 더 편한지 비교하는 점수는 아직 정하지 않았습니다.

Three library groups A, B and C each give one presentation, in slot 1 or slot 2. A and B share a student, and B and C share a student, so those pairs must use different slots. Our small scene has no such overlap between A and C. We only separate pairs that conflict.

All 2×2×2=8 assignments in the assumed presentation schedule
ABCA differs from BB differs from CBoth pass
111NoNoNo
112NoYesNo
121YesYesYes
122YesNoNo
211YesNoNo
212YesYesYes
221NoYesNo
222NoNoNo

There are eight ways to fill three cells using 1 or 2. Only (A,B,C)=(1,2,1) and (2,1,2) pass both conditions. The first task is to find rows satisfying every condition. We have not yet assigned a preference score that would make one feasible schedule better than the other.

기초Foundations

2. 칸 이름·가능한 값·함께 지킬 조건2. Cell names, possible values and joint conditions

A, B, C는 값을 정해야 하는 변수입니다. 변수 A의 영역은 A에 넣을 수 있는 값의 집합 {1,2}이고, 여기서는 B와 C도 같습니다. 제약은 여러 값을 함께 놓았을 때 지켜야 하는 조건입니다. A≠B는 A나 B를 각각 혼자 검사하는 말이 아니라 두 값을 함께 비교하는 말입니다.

X={A,B,C}DA=DB=DC={1,2}C={A≠B, B≠C}\begin{gathered}X=\{A,B,C\}\\D_A=D_B=D_C=\{1,2\}\\\mathcal C=\{A\ne B,\ B\ne C\}\end{gathered}

이 세 가지를 정하면 유한 영역의 제약 충족 문제, 줄여서 CSP가 됩니다. “A를 1에 넣고 B를 2에 넣는다” 같은 지시 절차를 먼저 적는 대신, 어떤 완성표를 정답으로 인정할지 적었습니다. 같은 문제를 푸는 순서는 여러 가지일 수 있습니다. 영역은 정답이 보장된 값의 목록이 아니라, 아직 시도할 수 있도록 선언한 후보 목록입니다.

A, B and C are variables: cells whose values must be chosen. The domain of A is the set of values it may receive, {1,2}; B and C have the same domain. A constraint states a condition on values considered together. A≠B compares a pair, rather than checking either variable in isolation.

X={A,B,C}DA=DB=DC={1,2}C={A≠B, B≠C}\begin{gathered}X=\{A,B,C\}\\D_A=D_B=D_C=\{1,2\}\\\mathcal C=\{A\ne B,\ B\ne C\}\end{gathered}

These ingredients define a finite-domain constraint satisfaction problem, or CSP. Instead of first prescribing a sequence such as “put A in slot 1, then B in slot 2,” we specify what a valid completed table must satisfy. Different procedures can solve the same problem. A domain lists declared candidates; it does not promise that every candidate belongs to some complete solution.

기초Foundations

3. 일부를 채운 표와 완성한 표를 구별한다3. Distinguish partial and complete assignments

A=1만 썼으면 일부 변수만 정한 부분 배정입니다. 아직 B나 C가 틀렸다고 말할 수는 없습니다. A=1, B=1까지 썼다면 A≠B를 이미 어겼으므로, C에 무엇을 써도 그 가지는 정답이 될 수 없습니다. 반면 A=1, C=1은 현재 주어진 두 제약을 어기지 않습니다. B=2로 완성할 수 있기 때문입니다.

칸을 비워 둔 것과 조건을 어긴 것은 다르다
부분 배정지금 확정된 충돌완성 가능 여부
A=1없음B=2,C=1로 가능
A=1,B=1A≠B 위반불가능
A=1,C=1없음B=2로 가능
A=1,B=2,C=1없음완성된 해

완전 배정은 모든 변수에 영역 안의 값을 하나씩 정한 것입니다. 해는 모든 제약을 동시에 만족하는 완전 배정입니다. 아직 검사하지 않은 빈칸이 있다고 곧 실패인 것은 아니며, 빈칸이 없다고 곧 성공인 것도 아닙니다. 완성 뒤에도 조건을 확인해야 합니다.

A=1 alone is a partial assignment: only some variables have values. It does not yet make B or C wrong. But A=1 and B=1 already violate A≠B, so no choice for C can rescue that branch. In contrast, A=1 and C=1 can be completed by B=2.

An unfilled cell differs from a violated condition
Partial assignmentConflict already fixedCan it be completed?
A=1NoneYes: B=2,C=1
A=1,B=1Violates A≠BNo
A=1,C=1NoneYes: B=2
A=1,B=2,C=1NoneAlready a solution

A complete assignment gives every variable exactly one value from its domain. A solution is a complete assignment satisfying every constraint simultaneously. Unfilled cells do not automatically mean failure, and filled cells do not automatically mean success. The completed row must still pass the constraints.

기초Foundations

4. 같이 허용되는 값의 쌍을 표로 쓴다4. List pairs allowed together

A≠B를 기호 없이도 나타낼 수 있습니다. A와 B가 각각 {1,2}를 쓸 때 허용되는 쌍은 (1,2)와 (2,1)뿐입니다. 이 두 행을 관계표로 저장하면, A=1인 후보에는 B=2라는 맞는 상대가 있다는 것을 바로 찾을 수 있습니다. 이런 상대 값을 지원값이라고 부릅니다.

A≠B의 허용 관계표: 두 예 행만 저장해도 된다
AB관계표에 포함
11아니요
12예
21예
22아니요

관계표의 각 위치가 어느 변수인지 나타내는 순서가 범위(scope)입니다. 범위 [A,B]에서 행 [1,2]는 A=1,B=2입니다. 범위를 [B,A]로 바꾸고 행을 그대로 두면 뜻도 바뀝니다. A<B처럼 방향이 있는 제약에서는 특히 중요합니다. 실습의 변수 이름과 값은 정확한 문자열이어서 "1"과 "01"을 자동으로 같은 값으로 합치지 않습니다.

We can represent A≠B without relying on the symbol. With both domains {1,2}, only pairs (1,2) and (2,1) are allowed. Storing those rows as a relation table makes it easy to find a compatible partner: A=1 has the support B=2.

The allowed relation for A≠B can store just its two Yes rows
ABIncluded in relation
11No
12Yes
21Yes
22No

The ordered variable list for a relation is its scope. Row [1,2] under scope [A,B] means A=1,B=2. Reversing the scope while keeping the row changes its meaning, which matters especially for a directed condition such as A<B. The lab treats names and values as exact strings: "1" and "01" are not silently merged.

기초Foundations

5. 각각 맞는 상대가 있어도 함께 맞지 않을 수 있다5. Separate supports may fail to fit together

기본 발표 문제에 A≠C도 추가해 봅시다. 이제 A, B, C가 모두 서로 달라야 하는데 시간대는 둘뿐입니다. A=1이면 B=2가 필요하고, B≠C 때문에 C=1이어야 합니다. 그러나 A≠C가 깨집니다. A=2부터 시작해도 1과 2를 바꾼 같은 충돌이 생깁니다. 따라서 완성된 해는 0개입니다.

그런데 각 쌍만 보면 모든 값에 지원값이 있습니다. A=1은 A≠B에서 B=2로 지원되고, A≠C에서는 C=2로 지원됩니다. 이 두 지원을 함께 택하면 B와 C가 같아져 B≠C가 깨집니다. 쌍별 검사가 전체 검사를 대신하지 못하는 작은 반례입니다.

각 제약에서 찾은 상대가 하나의 공동 완성표일 필요는 없다
A에 남긴 값A≠B에서 지원A≠C에서 지원두 지원을 함께 쓰면
1B=2C=2B≠C 위반
2B=1C=1B≠C 위반

뒤에서 배울 전파 알고리즘은 이런 지원이 없는 값부터 지웁니다. 값을 하나도 지우지 못하고 끝나도 해가 있다는 결론은 아직 나오지 않습니다. 이 삼각형을 계속 기준 반례로 사용하겠습니다.

Add A≠C to the library problem. All three groups must now use different slots, but only two slots exist. If A=1, then B=2, and B≠C forces C=1, violating A≠C. Starting from A=2 gives the same contradiction with the labels exchanged. There are zero complete solutions.

Nevertheless, every value has support in each pair separately. A=1 is supported by B=2 in A≠B and by C=2 in A≠C. Those two supports cannot be used together because they violate B≠C. This is a small counterexample to replacing global reasoning with pairwise checks.

A partner found in each relation need not form one joint completion
Value retained for ASupport in A≠BSupport in A≠CUsing both supports
1B=2C=2Violates B≠C
2B=1C=1Violates B≠C

The propagation algorithm will remove values lacking support. If it stops without removing anything, that alone does not establish a solution. We will reuse this triangle as a reference counterexample.

기초Foundations

6. 한 변수 조건과 여러 변수 조건6. One-variable and many-variable conditions

A는 시간대 1을 쓸 수 없다는 조건 A≠1은 A 하나만 보는 단항 제약입니다. 기본 두 제약 A≠B, B≠C와 함께 넣으면 A=2, B=1, C=2로 모두 정해집니다. 먼저 A의 영역에서 1을 지우고, 그 결과를 이웃 조건으로 전달한 셈입니다.

반대로 A+B+C=4는 세 변수를 함께 보는 제약입니다. 영역이 {1,2}일 때 허용 행은 (1,1,2), (1,2,1), (2,1,1)입니다. 기본 발표 문제에 이 합 조건까지 더하면 두 해 중 합이 4인 (1,2,1)만 남습니다. 제약을 더하면 기존 해가 사라질 수는 있지만 새로운 해가 생기지는 않습니다.

Sol⁡(C∪{c})⊆Sol⁡(C)\operatorname{Sol}(\mathcal C\cup\{c\})\subseteq\operatorname{Sol}(\mathcal C)

이 포함관계는 변수와 영역을 그대로 두고 제약만 추가할 때의 말입니다. 시간대를 새로 열어 영역을 바꾸는 행동은 다른 변경입니다. 조건과 후보 목록을 따로 적으면 무엇을 바꾸어서 결과가 달라졌는지 설명하기 쉽습니다.

The condition A≠1 concerns one variable, so it is unary. Together with the two original inequalities it forces A=2, B=1, C=2. We first remove 1 from A’s domain and then pass the consequences to neighboring constraints.

In contrast, A+B+C=4 is a three-variable condition. For domains {1,2}, its allowed rows are (1,1,2), (1,2,1) and (2,1,1). Adding it to the original presentation problem retains only (1,2,1), the original solution whose sum is four. Adding a constraint can remove old solutions, but cannot create a new one.

Sol⁡(C∪{c})⊆Sol⁡(C)\operatorname{Sol}(\mathcal C\cup\{c\})\subseteq\operatorname{Sol}(\mathcal C)

This inclusion holds when variables and domains remain fixed and only a constraint is added. Opening a new time slot changes a domain, which is a different operation. Keeping conditions separate from candidate lists helps explain why an outcome changed.

기초Foundations

7. 빈 후보와 할 일 없음은 다르다7. No candidate differs from no task

발표 A가 반드시 있어야 하는데 쓸 수 있는 시간대가 하나도 없으면 영역 D_A가 공집합입니다. 이 경우 완성표는 0개입니다. 반면 발표할 모둠이 아예 없고 지킬 제약도 없다면, 아무것도 쓰지 않는 빈 배정 한 가지가 조건을 모두 만족합니다. “0개 변수의 해는 한 개”라는 약속은 이런 차이를 표현합니다.

곱할 항이 없는 후보 수와 원소가 없는 영역을 구별한다
문제완전 배정 수이유
변수 A, 영역 ∅0A에 쓸 값을 고를 수 없음
변수 없음, 제약 없음1빈 배정 하나
변수 없음, 항상 거짓인 제약0빈 배정도 제약을 어김

일반적으로 유한 영역 D₁,…,Dₙ을 가진 n개 변수의 전체 배정 수는 각 영역 크기의 곱입니다. n은 비음수 정수이고, 빈 곱은 1입니다. 아직 어떤 제약도 검사하지 않은 수이므로, 실제 해 수는 이 수 이하입니다. 해가 없다는 증명과 계산을 끝내기 전에 멈춘 상태도 구별해야 합니다.

n∈Z≥0Nrows=∏i=1n∣Di∣0≤∣Sol⁡∣≤Nrows\begin{gathered}n\in\mathbb Z_{\ge0}\\N_{\rm rows}=\prod_{i=1}^{n}|D_i|\\0\le|\operatorname{Sol}|\le N_{\rm rows}\end{gathered}

If presentation A must take place but has no allowed slot, its domain D_A is empty. There are zero complete assignments. If there are no groups and no constraints at all, however, the empty assignment is one way to satisfy everything. The convention of one solution for zero variables expresses this distinction.

Distinguish an empty product from an empty domain
ProblemComplete assignmentsReason
Variable A with domain ∅0No value can be chosen for A
No variables and no constraints1One empty assignment
No variables and an always-false constraint0Even the empty assignment fails

For n variables with finite domains D₁,…,Dₙ, the number of complete assignments before checking constraints is the product of their domain sizes. Here n is a nonnegative integer and the empty product is one. The number of solutions is at most this number. A proof of no solution also differs from stopping before all necessary work has finished.

n∈Z≥0Nrows=∏i=1n∣Di∣0≤∣Sol⁡∣≤Nrows\begin{gathered}n\in\mathbb Z_{\ge0}\\N_{\rm rows}=\prod_{i=1}^{n}|D_i|\\0\le|\operatorname{Sol}|\le N_{\rm rows}\end{gathered}
기초Foundations

8. 실습 A · 작은 표를 완성하고 해를 센다8. Lab A · Complete a small table and count solutions

먼저 세 모둠·두 시간대와 두 이웃 제약을 선택합니다. 전체 배정 8개와 해 2개를 앞의 손계산 표와 맞춥니다. A≠C를 더하면 해는 0개이고, 기본 문제에 A≠1만 더하면 해는 1개입니다. 어떤 값이 원인이었는지 확인하려면 부분 배정을 한 칸씩 고정해 봅니다.

화면의 해 목록은 대표 행을 저장하는 목록입니다. 저장 한도를 1로 낮춰도 전체 탐색을 끝냈다면 정확한 해 수 2는 그대로입니다. 반대로 탐색 노드 수나 제약표 검사 횟수의 한도에 닿으면 반환한 수는 지금까지 찾은 해 수입니다. 해를 하나 찾았으면 존재는 확인되지만, 하나도 찾기 전에 중단되면 존재 여부는 아직 모릅니다. “계산 한도” 표시는 해 없음이라는 표시가 아닙니다.

이 실습은 브라우저의 자바스크립트로 선언된 유한 표를 계산합니다. 뒤의 Python/R 실행 기록은 별도의 실제 실행 결과로 비교합니다. 표의 값이나 조건이 달라졌다면 원래 문제의 정답을 그대로 옮겨 오지 않고 새 문제를 다시 셉니다.

Begin with three groups, two slots and the two neighboring inequalities. Match eight complete rows and two solutions against the hand-worked table. Adding A≠C gives zero solutions; adding only A≠1 to the original problem gives one. Fix a partial assignment one cell at a time to see which choice causes a conflict.

The displayed witness list stores representative solution rows. Lowering its storage cap to one does not change the exact total of two when enumeration finishes. A node or relation-check limit is different: the returned count then means solutions found so far. Finding a witness confirms existence; stopping before finding any leaves existence unknown. A resource-limit label is not an unsatisfiable label.

The live lab evaluates the declared finite tables in browser JavaScript. The archived Python/R records later in the chapter are separate actual executions used for comparison. Changing a value or constraint creates a new problem whose answers must be recomputed.

기초Foundations

9. 남길 값에는 같은 제약을 통과하는 상대가 필요하다9. A retained value needs a compatible partner

A와 B의 영역이 모두 {1,2,3,4}이고 A<B여야 한다고 합시다. A=3에는 B=4라는 지원이 있지만 A=4에는 더 큰 B가 없습니다. 그래서 A에서 4를 지울 수 있습니다. B=1에도 더 작은 A가 없으므로 B에서 1을 지울 수 있습니다. 남은 A={1,2,3}, B={2,3,4}가 곧 하나의 해인 것은 아닙니다. 가능한 값의 표가 줄어든 것입니다.

지원은 같은 제약의 다른 변수에 현재 남아 있는 값으로 찾아야 한다
살펴보는 값지원의 예판정
A=1B=2남김
A=3B=4남김
A=4없음삭제
B=1없음삭제
B=4A=1남김

현재 영역에서 A의 모든 값에 맞는 B가 있으면 A 쪽 호가 일관되었다고 말합니다. 반대 방향도 따로 확인합니다. 세 변수 이상의 제약에서도 같은 생각을 씁니다. 하나의 값 x를 고정한 뒤, 그 제약 범위 안의 나머지 변수 값을 함께 골라 제약을 통과할 수 있어야 합니다. 이를 일반화 호 일관성, GAC라고 부릅니다.

Let A and B both have domain {1,2,3,4}, with A<B. Value A=3 has support B=4, but A=4 has no larger B and can be removed. Similarly, B=1 has no smaller A. The reduced domains A={1,2,3}, B={2,3,4} are not themselves one solution; they are smaller candidate lists.

Find support using values still present in the other current domains
Value examinedExample supportDecision
A=1B=2Retain
A=3B=4Retain
A=4NoneRemove
B=1NoneRemove
B=4A=1Retain

If every current value of A has a compatible B, that directed arc is consistent. Check the reverse direction separately. For a constraint involving more than two variables, fix one value x and require a simultaneous choice for the other variables in that constraint’s scope. This is generalized arc consistency, or GAC.

기초Foundations

10. 허용 행을 남긴 뒤 각 열에 보이는 값만 남긴다10. Retain compatible rows, then project each column

관계표를 이용하면 지원 검사를 직접 볼 수 있습니다. A<B의 허용 행 중 현재 영역 밖의 값을 쓰는 행을 먼저 지웁니다. 남은 행의 A열에 한 번도 나오지 않는 A값은 지원이 없습니다. 각 열에 보이는 값의 집합을 그 열의 투영이라고 합니다. 이 투영과 현재 영역의 공통 부분만 남기면 됩니다.

RcD={t∈Rc: ti∈Di for all i∈Sc}Dinew=Di∩πi(RcD),i∈Sc\begin{gathered}R_c^D=\{t\in R_c:\ t_i\in D_i\ \text{for all }i\in S_c\}\\D_i^{\rm new}=D_i\cap\pi_i(R_c^D),\quad i\in S_c\end{gathered}

여기서 c의 범위 S_c는 관계표의 열에 대응하는 변수 목록이고, R_c는 처음 선언한 허용 행의 집합입니다. πᵢ는 행의 i번째 변수 값만 모으는 표시입니다. 표가 비어 버리면 현재 후보들로 그 제약을 통과하는 행은 하나도 없습니다. 그 사실만으로도 현재 가지의 불가능성을 보일 수 있습니다.

실습 엔진은 이 남은 관계표를 탐색 가지 안에서 재사용합니다. 한 가지에서 없앤 행을 형제 가지에서도 없앤 것으로 취급하면 정답을 잃을 수 있으므로, 형제 가지는 부모의 표에서 각각 다시 시작합니다.

Relation tables make support checking visible. First discard allowed rows that use values outside the current domains. Any A value absent from the A column of the remaining rows has no support. The set of values appearing in a column is its projection. Intersect that projection with the current domain.

RcD={t∈Rc: ti∈Di for all i∈Sc}Dinew=Di∩πi(RcD),i∈Sc\begin{gathered}R_c^D=\{t\in R_c:\ t_i\in D_i\ \text{for all }i\in S_c\}\\D_i^{\rm new}=D_i\cap\pi_i(R_c^D),\quad i\in S_c\end{gathered}

Here S_c is the ordered variable scope of constraint c, R_c is its original set of allowed rows, and πᵢ collects the values of variable i. If no compatible row remains, this branch cannot satisfy that constraint. An empty relation is already a certificate of impossibility.

The engine reuses compatible relation rows within a search branch. Rows removed in one branch must not also disappear from its sibling: each sibling starts from the parent’s relation state. Sharing mutable filtered tables across siblings could lose valid answers.

기초Foundations

11. 한 번 줄인 결과를 이웃에 다시 전달한다11. Pass a reduction back to neighboring constraints

이제 A,B,C가 각각 {1,2,3,4}를 쓰고 A<B와 B<C를 함께 지켜야 한다고 합시다. A<B만 검사하면 A의 4와 B의 1이 없어집니다. B<C를 검사하면 B의 4와 C의 1,2가 없어집니다. 이때 B가 더 줄었으므로 A<B도 다시 검사해야 합니다. A=3을 지원하던 B=4가 사라졌기 때문입니다.

순서는 바뀔 수 있지만 지원을 잃은 이웃을 다시 검사한다
현재까지 검사A 영역B 영역C 영역
시작1,2,3,41,2,3,41,2,3,4
A<B1,2,32,3,41,2,3,4
B<C1,2,32,33,4
A<B 재검사1,22,33,4

마지막 영역에서 가능한 완성 행을 직접 써 보면 (1,2,3), (1,2,4), (1,3,4), (2,3,4) 네 개입니다. 줄어든 영역의 단순 곱 2×2×2=8개가 모두 해인 것은 아닙니다. 예를 들어 (2,2,3)은 A<B를 어깁니다.

전파의 할 일 목록에는 다시 확인할 제약을 넣습니다. 어떤 영역이 줄면 그 변수를 포함하는 다른 제약이 지원을 잃을 수 있으므로 목록에 되돌려 놓습니다. 영역이 변하지 않았는데 같은 일을 끝없이 반복할 필요는 없습니다.

Now let A,B,C each have domain {1,2,3,4}, with A<B and B<C. Checking A<B removes 4 from A and 1 from B. Checking B<C then removes 4 from B and 1,2 from C. Because B shrank again, revisit A<B: its former support B=4 for A=3 has disappeared.

The order can vary; revisit neighbors whose supports may have vanished
Checks so farDomain of ADomain of BDomain of C
Initial1,2,3,41,2,3,41,2,3,4
A<B1,2,32,3,41,2,3,4
B<C1,2,32,33,4
Revisit A<B1,22,33,4

Enumerating the final candidates gives four solutions: (1,2,3), (1,2,4), (1,3,4) and (2,3,4). The reduced domain product 2×2×2=8 is not the solution count. For example, (2,2,3) still violates A<B.

A propagation worklist records constraints needing another check. Shrinking one domain can remove support in other constraints involving that variable, so those checks return to the list. Unchanged domains do not require endless repeated work.

기초Foundations

12. 지원 없는 값은 실제 해에 들어갈 수 없다12. An unsupported value cannot occur in a solution

왜 이런 삭제가 안전할까요? 삭제 직전의 모든 영역 안에 들어 있는 완전한 해 s가 있다고 가정합니다. 제약 c에서 변수 i의 값 sᵢ를 고정하면, 같은 해에 들어 있는 다른 변수 값들이 c를 만족하는 지원입니다. 따라서 sᵢ는 지원 없는 값이 아니므로 삭제되지 않습니다.

처음에는 원래 해의 모든 값이 원래 영역 안에 있습니다. 한 번 삭제해도 해의 값이 남는다는 논리를 삭제할 때마다 반복하면, 전파가 몇 번 이어져도 원래 해는 사라지지 않습니다. 이것이 삭제에 대한 귀납 증명입니다. 부분 배정을 먼저 고정했다면, 그 부분 배정을 만족하는 원래 해들에 같은 증명을 적용합니다.

Sol⁡(D,C)=Sol⁡(Dpruned,C)\operatorname{Sol}(D,\mathcal C)=\operatorname{Sol}(D^{\rm pruned},\mathcal C)

이 등식은 지원 검사를 정확히 수행했을 때의 말입니다. 관계표의 열 순서를 틀리거나 지원을 덜 살펴보고 “없음”이라고 결론내면 적용되지 않습니다. 계산 한도에 닿은 엔진은 아직 검사하지 않은 후보를 임의로 삭제하지 않습니다. 이미 증명된 삭제만 남기고 중단 이유를 표시합니다.

Why is pruning safe? Suppose s is a complete solution using only the domains present just before a deletion. Fix sᵢ in constraint c. The values of the other variables in that same solution form a support satisfying c. Thus sᵢ is supported and cannot be deleted as unsupported.

Every original solution starts inside the original domains. Since one deletion preserves its values, induction over all deletions shows that propagation never removes an original solution. If a partial assignment was fixed first, apply the same argument to original solutions extending that assignment.

Sol⁡(D,C)=Sol⁡(Dpruned,C)\operatorname{Sol}(D,\mathcal C)=\operatorname{Sol}(D^{\rm pruned},\mathcal C)

This equality requires correct support checks. Reversing relation columns or prematurely declaring a support absent invalidates the reasoning. At a work limit, the engine keeps candidates whose support checks are unfinished. It retains only proven deletions and reports the interruption.

학부 심화 · 선택Advanced undergraduate · optional

13. 가능한 값은 줄기만 하므로 유한하게 멈춘다13. Finite domains can shrink only finitely often

모든 영역에 들어 있는 값의 개수를 합쳐 봅시다. 세 변수에 각각 네 값이면 처음 합은 12입니다. 값을 실제로 지우는 순간 이 합은 적어도 1 줄고, 음수가 될 수는 없습니다. 따라서 실제 삭제는 처음 합보다 많이 일어날 수 없습니다. 한 번의 검사가 유한한 관계표를 보고, 삭제에 의해서만 유한한 이웃 검사를 다시 넣는다면 전체 전파도 끝납니다.

V(D)=∑i=1n∣Di∣∈Z≥0V(D)=\sum_{i=1}^{n}|D_i|\in\mathbb Z_{\ge0}

더 줄일 값이 없어 모든 필요한 검사를 마친 상태를 고정점이라고 부릅니다. 모든 범위를 빠뜨리지 않고 다시 검사하는 전파는 검사 순서를 달리해도 같은 가장 큰 GAC 부분 영역에 도달합니다. 각 삭제가 모든 GAC 부분 영역에서도 없어야 할 값이라는 점을 귀납적으로 쓰면, 어느 순서의 결과도 다른 순서의 결과보다 작을 수 없기 때문입니다.

관계표가 비거나 영역이 비는 모순을 먼저 발견하면 그 지점에서 멈춰도 불가능성은 이미 증명됩니다. 실습에서는 이를 고정점 계산을 끝낸 경우와 구별합니다. 또 브라우저의 작업 한도는 수학적 종료 증명보다 먼저 도달할 수 있습니다. 유한하게 끝난다는 말이 정해 둔 작은 시간 안에 끝난다는 말은 아닙니다.

Add the sizes of all domains. Three four-valued variables start with total 12. Every actual deletion reduces this nonnegative integer by at least one, so there can be at most 12 deletions. If each check inspects a finite relation and only deletions requeue finitely many neighboring checks, propagation terminates.

V(D)=∑i=1n∣Di∣∈Z≥0V(D)=\sum_{i=1}^{n}|D_i|\in\mathbb Z_{\ge0}

A fixed point is reached when all required checks finish without further deletion. A fair exhaustive worklist reaches the same greatest GAC subdomains regardless of check order. Inductively, any value deleted by one sequence must also be absent from every GAC subdomain; hence neither completed sequence can retain less than the other.

Discovering an empty compatible relation or domain proves a contradiction, so the algorithm may stop there without completing a fixed-point calculation. The lab distinguishes these outcomes. A browser work limit may also intervene earlier: mathematical finite termination does not promise completion within a chosen small time budget.

기초Foundations

14. 같은 말도 한꺼번에 쓰면 더 강하게 줄일 수 있다14. A joint relation can prune more than separate pairs

A와 B의 영역은 {1,2}, C의 영역은 {1,2,3}이고 세 값이 모두 달라야 합니다. A와 B가 이미 1과 2를 하나씩 써야 하므로 C는 3이어야 합니다. 이 결론을 세 변수가 모두 다른 허용 행 하나의 관계표로 쓰면 GAC가 C에서 1과 2를 지웁니다. 남는 해는 (1,2,3), (2,1,3)입니다.

해가 같은 두 표현이라도 국소 전파의 힘은 다를 수 있다
표현원래 완성 해GAC 뒤 C 영역
세 쌍 A≠B,A≠C,B≠C같은 두 해1,2,3
세 변수의 allDifferent 관계같은 두 해3

세 쌍으로 따로 쓰면 C=1은 A≠C에서 A=2로 지원되고 B≠C에서도 B=2로 지원됩니다. 그러나 A=B=2는 A≠B를 어깁니다. 전파가 별도 관계의 지원을 함께 묶지 못한 것입니다. 하나의 전역 관계는 그 결합까지 살펴봅니다.

같은 해 집합을 표현한다는 뜻의 동치와, 같은 중간 후보를 남긴다는 뜻은 다릅니다. 큰 관계표는 더 많이 줄일 수도 있지만 저장 행 수가 빠르게 커질 수도 있습니다. 작은 설명용 표에서는 전역 관계를 직접 쓰고, 큰 문제의 전문 allDifferent 알고리즘은 별도 기법으로 연결합니다.

Let A and B have domains {1,2}, and C have domain {1,2,3}, with all three values different. A and B must occupy 1 and 2, so C must be 3. GAC on one joint allDifferent relation removes 1 and 2 from C. The solutions are (1,2,3) and (2,1,3).

Equivalent solution sets can give different local pruning
RepresentationOriginal complete solutionsC domain after GAC
Three pairwise inequalitiesThe same two solutions1,2,3
One three-variable allDifferent relationThe same two solutions3

In separate pairs, C=1 has support A=2 in A≠C and support B=2 in B≠C. But choosing both supports violates A≠B. Separate relation checks do not combine those supports, whereas the global relation does.

Equivalence of solution sets does not imply equality of intermediate candidate lists. A larger relation can prune more while requiring many more stored rows. We use an explicit global table for small examples and distinguish it from specialized allDifferent algorithms for large problems.

기초Foundations

15. 방금 고른 값만 확인할 수도 있다15. Check consequences of the choices already made

기본 두 시간대 문제 A≠B, B≠C에서 A=1을 고정합시다. 앞으로 확인하기, 즉 이 장의 forward checking은 아직 직접 배정하지 않은 변수가 하나 이하로 남은 제약만 검사합니다. A≠B에서는 B=1을 지워 B={2}로 만듭니다. 그러나 B는 아직 탐색에서 직접 배정한 변수가 아니므로 B≠C에는 미배정 변수가 둘입니다. 이 규약에서는 C={1,2}를 그대로 둡니다.

GAC는 B의 영역이 하나로 줄었다는 정보도 계속 전달하여 C=2를 지웁니다. 최종 영역은 A={1}, B={2}, C={1}입니다. 두 절차가 허용하는 완전한 해는 같지만, 남긴 후보와 지금 수행한 검사 수가 다릅니다.

단일 후보 영역을 직접 배정과 구별하는 이 장의 forward 규약
현재 A=1A 영역B 영역C 영역
선언된 배정만 사용한 forward121,2
GAC 고정점121

프로그램마다 forward checking에 단일 영역 자동 배정을 섞기도 합니다. 따라서 이름만 같다고 같은 중간 표가 나오는 것은 아닙니다. 이 장의 실습에서는 직접 배정과 추론으로 남긴 단일 후보를 구분하고, 비교할 때 이 규약을 함께 표시합니다.

Fix A=1 in the two-slot problem A≠B, B≠C. This chapter’s forward checking only inspects constraints with at most one variable not explicitly assigned. It removes B=1 using A≠B, leaving B={2}. But B was not explicitly assigned by search, so B≠C still contains two unassigned variables. Under this convention C remains {1,2}.

GAC continues passing along B’s singleton domain and removes C=2, leaving A={1}, B={2}, C={1}. The full solution set is the same, but current candidates and checks performed differ.

Our forward convention distinguishes a singleton domain from an explicit assignment
With A=1 fixedA domainB domainC domain
Forward from explicit assignments121,2
GAC fixed point121

Some implementations combine forward checking with automatic singleton assignment. Thus identical algorithm names need not imply identical intermediate tables. Our lab keeps explicit assignments separate from inferred singleton domains and states this convention when comparing methods.

기초Foundations

16. 실습 B · 지운 값의 지원을 추적한다16. Lab B · Trace why a value loses support

A<B, B<C와 초기 영역 {1,2,3,4}를 선택하고 전파를 실행합니다. A={1,2}, B={2,3}, C={3,4}를 앞의 표와 맞춥니다. 삭제 기록에서 A=3이 어느 제약 때문에 사라졌는지 찾으세요. 처음 선언한 값 전체가 아니라 현재 남은 값만 지원으로 쓴다는 점을 확인합니다.

이어서 두 색 삼각형을 고릅니다. GAC는 모든 영역을 {1,2}로 남기고 고정점에 도달하지만, 전체 배정 검사에서는 해가 0개입니다. 반대로 A의 영역을 비우면 즉시 모순입니다. “후보가 남음”, “모순 발견”, “계산 한도에 도달” 세 결과를 서로 다른 말로 설명해 봅니다.

이 실습의 관계표 검사 한도는 현재 가지에서 실제 확인한 행 수를 제한합니다. 기록을 몇 줄 보일지 정하는 한도는 계산 경로를 바꾸지 않습니다. 계산을 중단했을 때도 이미 삭제한 값은 지원 없음이 증명된 값이지만, 남은 표가 GAC 고정점이라고 말하지는 않습니다.

Choose A<B, B<C with initial domains {1,2,3,4}. Match the resulting A={1,2}, B={2,3}, C={3,4} against the worked table. Find the constraint responsible for deleting A=3. Supports must use currently retained values, not the entire original list.

Next choose the two-color triangle. GAC reaches a fixed point with every domain still {1,2}, even though complete enumeration finds zero solutions. An empty domain, in contrast, proves a contradiction immediately. Explain “candidates remain,” “contradiction found” and “resource limit reached” as three different outcomes.

The relation-work cap limits rows actually checked within a branch. A separate display-trace cap changes only how many events are shown. If work is interrupted, completed deletions still have a no-support proof, but the remaining domains are not claimed to be a GAC fixed point.

기초Foundations

17. 막히면 마지막 선택만 되돌린다17. Undo the latest choice when a branch fails

A,B,C가 모두 {1,2}를 쓰고 A≠B, B≠C인 기본 문제로 돌아갑니다. A=1을 쓰고 B=1을 시도하면 바로 충돌합니다. A까지 지울 필요는 없습니다. B만 비우고 다음 값 2를 시도합니다. 이어 C=1은 통과하여 (1,2,1)을 얻고, C=2는 실패합니다. A=1에서 가능한 B,C를 모두 살폈다면 그제야 A를 2로 바꿉니다.

선언 순서 A,B,C와 값 순서 1,2를 사용한 되돌아가기
단계부분 배정할 일
1A=1다음 변수 B를 선택
2A=1,B=1충돌, B만 되돌림
3A=1,B=2다음 변수 C를 선택
4A=1,B=2,C=1해를 기록
5A=1,B=2,C=2충돌, C를 되돌림
6A=2나머지 가지도 검사

이처럼 한 값을 정하고 더 깊이 들어갔다가 막히면 이전 선택으로 돌아오는 깊이 우선 절차가 백트래킹, 즉 되돌아가기 탐색입니다. 실패한 선택을 원래 문제의 영구 금지로 적지 않습니다. A=1 가지에서 C=2가 실패해도 A=2 가지의 C=2는 해에 들어갑니다.

Return to A,B,C∈{1,2}, A≠B and B≠C. Choose A=1, then try B=1: this immediately conflicts. There is no need to erase A. Undo B and try its next value, 2. Then C=1 yields (1,2,1), whereas C=2 fails. Only after exhausting B,C under A=1 do we move to A=2.

Backtracking with declared order A,B,C and value order 1,2
StepPartial assignmentNext action
1A=1Select B
2A=1,B=1Conflict; undo B
3A=1,B=2Select C
4A=1,B=2,C=1Record a solution
5A=1,B=2,C=2Conflict; undo C
6A=2Inspect the remaining branch

This depth-first process of choosing, descending and undoing is backtracking search. A failed choice is not a permanent prohibition in the original problem. Although C=2 fails under A=1, it belongs to a solution in the A=2 branch.

학부 심화 · 선택Advanced undergraduate · optional

18. 한 값을 하나씩 모두 시도하면 해를 빠뜨리지 않는다18. Trying every remaining value preserves completeness

탐색의 매 단계에서 현재 배정과 줄어든 영역을 기록합니다. 아직 배정하지 않은 변수 하나를 고르고 그 영역에 남은 값을 각각 한 번씩 시도합니다. 모든 변수를 배정한 뒤 모든 제약을 통과한 행만 해로 기록하면, 기록한 답이 맞다는 건전성이 성립합니다.

빠뜨린 해가 없다는 완전성도 따로 보일 수 있습니다. 현재 부분 배정을 완성하는 해 s를 하나 생각합시다. 다음에 어떤 변수를 골랐든 s가 그 변수에 쓰는 값은 영역에 남아 있습니다. GAC를 사용했다면 앞의 삭제 보존 증명이 이를 보장합니다. 모든 남은 값을 시도하므로 s의 값을 따르는 자식 가지도 방문합니다. 이를 남은 변수 수에 대한 귀납으로 반복하면 s까지 도달합니다.

변수와 영역은 유한하고 매 재귀 단계에서 미배정 변수 수가 하나씩 줄어들므로, 한도 없이 이 절차를 끝내면 유한하게 모든 해를 셀 수 있습니다. 같은 완전 배정은 각 단계의 결정적인 변수 선택과 자신의 값에 따라 하나의 경로만 가지므로 중복 기록되지 않습니다. 자원 한도에 막힌 실행에는 “모든 해를 방문했다”는 부분을 적용하지 않습니다.

At each stage record the partial assignment and reduced domains. Select one unassigned variable and try each of its remaining values once. Record a row only when all variables are assigned and all constraints pass. This establishes soundness: every recorded answer is a solution.

Completeness requires a separate argument. Consider a solution s extending the current assignment. Whichever variable is selected next, its value in s remains in the domain; if GAC was used, pruning preservation proves this. Since every remaining value is tried, the child following s is visited. Induction on the number of unassigned variables then reaches s.

Variables and domains are finite, and each recursive step assigns one additional variable. Without interruption the process therefore terminates and counts all solutions. Each complete assignment follows one path under the deterministic variable-choice rule, so it is not counted twice. A resource-limited run cannot claim that every such path was visited.

기초Foundations

19. 후보가 가장 적은 빈칸을 먼저 고른다19. Choose an unassigned cell with fewest candidates

A의 영역이 {1,2,3}, B는 {1}, C는 {1,2}이고 B≠C, A≠C라고 합시다. A부터 쓰기 전에 후보가 하나뿐인 B를 고르면 B=1이고, 이어 C는 2여야 합니다. 그러면 A는 1 또는 3입니다. 선택의 여지가 작은 곳부터 보면 충돌을 일찍 드러내는 데 도움이 될 수 있습니다.

최소 잔여 값(MRV)은 현재 미배정 변수의 영역 크기를 비교한다
변수현재 후보후보 수
A1,2,33
B11
C1,22

이 규칙을 최소 잔여 값, MRV라고 부릅니다. 후보 수가 같으면 실습에서는 처음 선언한 변수 순서를 따릅니다. 후보 수는 원래 영역이 아니라 현재 전파 뒤의 영역으로 셉니다. 이미 배정된 변수는 다시 선택하지 않습니다.

MRV는 탐색 순서를 정하는 휴리스틱입니다. 모든 값을 끝까지 시도하는 규칙을 유지하면 해 집합은 바뀌지 않습니다. 어떤 문제에서 적은 노드를 방문했다고 다른 모든 문제에서 더 빠르다는 결론은 나오지 않습니다. 전파 자체의 검사 비용과 탐색 노드 수도 함께 봐야 합니다.

Suppose A has domain {1,2,3}, B has {1}, C has {1,2}, with B≠C and A≠C. Choosing the singleton B before A gives B=1, then forces C=2 and leaves A=1 or 3. Starting with less flexible cells can expose a conflict earlier.

Minimum remaining values compares current domains of unassigned variables
VariableCurrent candidatesCandidate count
A1,2,33
B11
C1,22

This is the minimum remaining values heuristic, MRV. Ties in our lab follow original variable order. Count candidates after current propagation, rather than using original domain sizes. Assigned variables are never selected again.

MRV changes search order, not the solution set when all values are still explored. Fewer visited nodes in one problem does not imply faster performance on every problem. Count the cost of propagation as well as the number of search nodes.

기초Foundations

20. 하나 찾기·모두 세기·가장 좋은 답 찾기20. Finding one, counting all and finding the best

기본 발표 문제에서 (1,2,1)을 한 번 찾으면 적어도 해가 하나 있다는 존재 명제는 확인됩니다. 하지만 해가 정확히 하나라는 말은 아직 아닙니다. 다른 가지에서 (2,1,2)가 나옵니다. 전부 세기 위해서는 첫 해를 찾은 뒤에도 탐색을 계속해야 합니다.

또 “A는 가능하면 1을 선호한다”는 점수를 넣으면 다른 문제가 생깁니다. 모든 조건을 지키는 것이 가능성의 문제이고, 가능 행 가운데 점수를 비교하는 것이 최적화의 문제입니다. 이 장의 기본 CSP는 조건을 지키는 해를 셉니다. 먼저 나온 행이 가장 좋은 행이라는 보장은 점수를 정하지도 않은 상태에서는 의미가 없습니다.

같은 실행 결과라도 질문에 따라 필요한 증거가 다르다
요청(1,2,1)을 찾은 직후의 결론
해가 존재하는가예
해가 정확히 몇 개인가남은 가지를 더 검사
가장 좋은 해는 무엇인가선호 점수와 최적화 규칙을 먼저 정의

저장할 해의 개수를 제한하는 옵션은 모든 해를 세는 과제를 바꾸지 않습니다. 예를 들어 두 해를 모두 세되 첫 행 하나만 저장할 수 있습니다. 실행 결과에는 전체 해 수와 저장한 증거 행 수를 따로 적습니다.

Finding (1,2,1) confirms that at least one schedule exists. It does not establish uniqueness: another branch gives (2,1,2). Counting all solutions requires continuing after the first witness.

Adding a preference such as “A prefers slot 1” creates another task. Feasibility asks whether all hard conditions can be met; optimization compares preference scores among feasible rows. Our basic CSP counts solutions satisfying the constraints. Without defining a score, calling the first row “best” has no basis.

Different questions require different evidence from the same run
QuestionConclusion after finding (1,2,1)
Does a solution exist?Yes
How many solutions exist?Inspect the remaining branches
Which solution is best?First define preferences and optimization rules

A storage cap does not change the counting task. The engine can count both solutions while storing only the first witness. It reports the total count separately from the number of stored proof rows.

기초Foundations

21. 작은 영역도 변수가 늘면 곱으로 커진다21. Small domains multiply as variables accumulate

각 변수가 두 값을 쓰면 변수 3개에는 8행, 10개에는 1,024행, 20개에는 1,048,576행이 있습니다. 한 변수씩 늘릴 때 후보 전체가 두 배가 됩니다. 제약과 전파가 일찍 많은 가지를 없애 주는 문제도 있지만, 늘 그렇게 줄어든다는 보장은 없습니다.

전체 배정 수는 제약 검사 전의 상계다
변수 수 n변수마다 두 값인 전체 행 수 2ⁿ
38
101,024
201,048,576

관계표 자체도 입력의 일부입니다. 세 값이 있는 변수 7개에 대한 전역 표는 최대로 3⁷=2,187행이고, 각 행에 값 7개를 저장합니다. 제약 수가 하나라는 이유만으로 입력이 작다고 말할 수 없습니다. 반대로 계산식으로 간단히 쓸 수 있는 제약을 모든 행의 표로 펼치면 저장 비용이 커질 수 있습니다.

이 장의 공개 엔진은 설명 가능한 작은 유한 표로 범위를 정합니다. 변수 12개 이하, 변수당 16값 이하, 관계표의 총 행 수와 셀 수에도 한도를 둡니다. 이는 화면에서 안전하게 실습하기 위한 구현 범위이며, 모든 현실 문제를 이 작은 크기로 표현할 수 있다는 정리는 아닙니다.

With two choices per variable, three variables give eight rows, ten give 1,024, and twenty give 1,048,576. Adding one variable doubles the unrestricted candidate count. Constraints and propagation may eliminate many branches early, but cannot be assumed always to do so.

The full product is an upper bound before testing constraints
Number of variables nUnrestricted rows with two values each: 2ⁿ
38
101,024
201,048,576

Relation tables are part of the input too. A single global table on seven three-valued variables can contain 3⁷=2,187 rows, each storing seven values. Having one constraint does not by itself mean a small input. Expanding a compact arithmetic condition into all allowed rows can increase storage substantially.

Our public engine deliberately accepts small explicit finite tables: at most 12 variables, 16 values per variable, and additional total row and cell limits. These are implementation bounds for interactive learning, not a theorem that every practical problem has such a small representation.

기초Foundations

22. 찾지 못함과 끝까지 없음을 보임22. Not found yet differs from a completed proof of absence

아무 제약도 없는 세 이진 변수 A,B,C를 순서대로 탐색한다고 합시다. 빈 배정인 뿌리를 노드 하나로 세고, 값을 하나 더 정할 때마다 자식 노드를 방문합니다. 전체 노드는 1+2+4+8=15개이고 해는 마지막 깊이의 8개입니다. 노드 한도를 7로 두면 첫 세 해를 찾은 뒤 다음 노드에 들어가지 못해 중단됩니다.

기본 순서 A,B,C와 값 0,1, 깊이 우선 탐색의 한도 예
같은 무제약 문제방문 노드찾은 해정확한 전체 수를 안다
한도 없이 완료158예
노드 한도 773아니요
노드 한도 000아니요

이 구현은 뿌리 방문도 한도에 넣습니다. 한도가 0이면 빈 문제의 빈 해도 확인하기 전에 멈출 수 있습니다. 반면 실제로 해를 하나 기록했으면 전체 수를 몰라도 존재는 확인됩니다. 완료된 실행에서 해 수가 0일 때만 “해 없음”이라고 확정합니다.

사건 기록을 0줄만 보여 주게 해도 탐색 결과는 바뀌지 않습니다. 설명 기록을 생략하는 것, 증거 행을 덜 저장하는 것, 계산을 중단하는 것은 서로 다른 옵션입니다. 보고서에는 중단 이유와 지금까지의 수, 완료 여부를 함께 남깁니다.

Consider three binary variables A,B,C with no constraints, searched in that order. Count the empty root as one node and visit a child after each new assignment. The full tree has 1+2+4+8=15 nodes and eight solutions at the last depth. A node cap of seven stops after the first three solutions, before entering the next node.

Depth-first search with order A,B,C and value order 0,1
The same unconstrained problemNodes visitedSolutions foundExact total established?
Completed without interruption158Yes
Node cap 773No
Node cap 000No

The implementation counts the root against the node budget. With a cap of zero, even the empty solution of an empty problem may remain unconfirmed. Recording one witness does establish existence even before the total is known. Only a completed run with zero solutions establishes unsatisfiability.

Setting the event display cap to zero does not change the search result. Hiding trace events, storing fewer solution rows and interrupting computation are distinct options. Report the stop reason, count so far and completion status together.

기초Foundations

23. 알고리즘 이름보다 원 조건으로 답을 검사한다23. Check an answer without trusting an algorithm name

해 하나를 받았을 때 가장 직접적인 검사는 각 값을 원래 영역과 제약에 다시 넣어 보는 것입니다. A=1,B=2,C=1은 모두 {1,2} 안에 있고 두 부등 조건도 통과합니다. 이 확인에는 같은 탐색 프로그램을 다시 실행할 필요가 없습니다. 해 수가 맞는지 확인하려면 유한 전체 표나 완전한 탐색이 모든 후보를 포함했다는 근거가 더 필요합니다.

변수 이름을 바꾸거나 값의 나열 순서만 바꾸어 비교할 수도 있습니다. 이런 변경은 해 수를 바꾸지 않지만 처음 저장하는 해는 바꿀 수 있습니다. 변수와 영역을 고정하고 제약을 추가하면 해 집합은 줄어들거나 그대로입니다. 이렇게 미리 예측할 수 있는 변화는 유용한 검사 기준입니다.

이 장의 구현은 입력 글자를 프로그램 코드로 실행하지 않고 명시한 관계표를 사용합니다. 별도의 Python/R 프로그램이 유한 열거로 기준 문제를 다시 계산하고, 브라우저에서는 자바스크립트 탐색 과정을 보여 줍니다. 서로 다른 구현의 결과 일치는 선언한 문제에 관한 비교 증거입니다. 그 문제가 현실을 정확히 나타내는지는 다른 질문입니다.

The simplest way to check a proposed solution is to substitute its values into the original domains and constraints. A=1,B=2,C=1 uses declared values and passes both inequalities. This does not require rerunning the same search program. Verifying a solution count requires more: an exhaustive table or a justified complete search must cover every candidate.

Renaming variables or changing only the listed order of values preserves the number of solutions, though it can change the first stored witness. With variables and domains fixed, adding a constraint can only shrink the solution set. Such predictable transformations provide useful checks.

The implementation accepts explicit tables rather than executing code supplied as input text. Separate Python/R programs enumerate reference problems, while the browser displays live JavaScript search. Agreement between implementations is evidence about the declared problem; whether that problem describes a real situation is a separate question.

기초Foundations

24. 실습 C · 같은 해와 다른 탐색 기록24. Lab C · The same solutions, different search records

기본 두 시간대 문제를 선언 순서와 전파 없음으로 실행합니다. 뿌리를 포함한 11노드를 방문하고 해 두 개를 찾는지 확인합니다. 이어 GAC를 켜면 같은 두 해를 유지하면서 이 작은 문제에서는 7노드만 방문합니다. 작은 숫자는 설명용 예의 실제 계산이며, 모든 문제의 속도 순위를 뜻하지 않습니다.

다음에는 삼각형 문제를 고릅니다. GAC만 실행했을 때 남던 두 후보가, 되돌아가기 탐색에서는 최종적으로 해 0개라는 결론으로 이어집니다. 선언 순서와 MRV, forward와 GAC를 바꾸고 해 수·작업 횟수·방문 노드 수를 나란히 비교합니다. 중단 상태가 섞인 결과를 완료된 해 수처럼 비교하지 않습니다.

해 저장 수를 1로 줄인 뒤에도 전체 수가 유지되는지, 기록 표시 수만 바꾸었을 때 숫자가 그대로인지 확인합니다. 작은 표를 손으로 다 셀 수 있을 때 이런 옵션들의 뜻을 먼저 익히면 더 큰 실제 자료 과제를 읽을 때도 무엇이 계산된 것인지 분명해집니다.

Run the basic two-slot problem in declared order with no propagation. Check that it visits 11 nodes including the root and finds two solutions. Turning on GAC retains those two solutions while visiting seven nodes in this small example. These are actual counts for the teaching problem, not a universal speed ranking.

Next select the triangle. Although GAC alone retained both candidates in every domain, backtracking eventually establishes zero solutions. Compare declared order with MRV and forward checking with GAC using solution counts, relation work and visited nodes. Do not compare a cutoff count as if it were a completed total.

Reduce stored witnesses to one and confirm that a completed total stays unchanged. Change only the trace display cap and check that numerical results remain the same. Learning these distinctions while the table can still be enumerated by hand makes the larger source-data tasks easier to interpret.

기초Foundations

25. 문장의 뜻을 정한 뒤 참·거짓을 붙인다25. Define a proposition before assigning truth

“A는 시간대 1에 발표한다”는 완성된 배정표에서 참과 거짓을 판정할 수 있는 문장입니다. 이 문장을 명제 P로, “B는 시간대 1에 발표한다”를 Q로 표시하겠습니다. P=참이라고 쓰려면 P가 무엇을 뜻하는지 먼저 정해야 합니다. 누군가 P의 뜻을 “시간대 1이 더 편하다”로 바꾸면 같은 참 표시가 다른 질문에 답하게 됩니다.

명제 논리는 선언한 각 명제를 참 또는 거짓으로 보고 그 결합 관계를 따집니다. 교실을 직접 관측하거나 입력한 문장이 현실과 맞는지 스스로 보장하지는 않습니다. 배정표가 P의 근거가 될 수 있고, 다른 명제에는 관측 자료·출처·모형 가정이 근거가 될 수 있습니다. 문장의 뜻과 그 진리값의 근거를 나누어 기록하면 지식 표현이 명확해집니다.

“A is in slot 1” can be judged true or false in a completed schedule. Let proposition P represent that statement and Q represent “B is in slot 1.” Writing P=true requires first defining P. Replacing its meaning with “slot 1 is convenient” makes the same truth value answer a different question.

Propositional logic treats each declared proposition as true or false and studies their combinations. It does not itself observe a classroom or guarantee that supplied statements match reality. A schedule can establish P; other propositions may rely on observations, sources or assumptions. Record sentence meaning separately from its evidence.

기초Foundations

26. 부정·그리고·또는을 네 행으로 계산한다26. Compute not, and and or with four rows

P를 “A는 시간대 1”, Q를 “B는 시간대 1”로 정합니다. ¬P는 P가 거짓일 때 참입니다. P∧Q는 둘 다 참일 때만 참입니다. P∨Q는 적어도 하나가 참일 때 참이므로, 둘 다 참인 행도 포함합니다. 일상에서 “둘 중 하나만”을 뜻하고 싶다면 그 조건을 추가로 적어야 합니다.

두 명제의 전체 네 진리값 배정
PQ¬PP∧QP∨Q
거짓거짓참거짓거짓
거짓참참거짓참
참거짓거짓거짓참
참참거짓참참

정확히 하나만 참이라는 배타적 또는는 (P∨Q)∧¬(P∧Q)로 쓸 수 있습니다. 두 시간대만 허용된다는 별도 가정 아래 “A와 B가 다른 시간대”도 P와 Q 가운데 정확히 하나가 참이라는 말이 됩니다. 시간대가 셋 이상이면 P,Q만으로 그 조건을 나타낼 수 없으므로 같은 식을 그대로 옮기지 않습니다.

Define P as “A uses slot 1” and Q as “B uses slot 1.” Negation ¬P is true when P is false. Conjunction P∧Q is true only when both are true. Inclusive disjunction P∨Q is true when at least one is true, including the row where both are true. “Exactly one” requires an additional condition.

All four valuations of two propositions
PQ¬PP∧QP∨Q
FalseFalseTrueFalseFalse
FalseTrueTrueFalseTrue
TrueFalseFalseFalseTrue
TrueTrueFalseTrueTrue

Exclusive or can be written (P∨Q)∧¬(P∧Q). Under the separate assumption of exactly two allowed slots, saying A and B use different slots is equivalent to exactly one of P,Q being true. With three or more slots, P,Q alone no longer encode that condition.

기초Foundations

27. “이면”의 거짓 행은 하나다27. An implication has one false row

P→Q는 “P이면 Q”라는 물질 함의입니다. P가 참인데 Q가 거짓인 행 하나만 배제합니다. 두 시간대 발표에서 P를 “A는 1”, Q를 “B는 2”로 정하면 이 식은 A가 1일 때 B가 2여야 한다는 규칙입니다. A가 1이 아닐 때 B에 관한 추가 정보를 이 식 하나에서 얻지는 못합니다.

함의는 ¬P∨Q와 같고, 동치는 양방향 함의다
PQP→QP↔Q
거짓거짓참참
거짓참참거짓
참거짓거짓거짓
참참참참

Q가 참이라는 사실과 P→Q만으로 P를 결론낼 수 없습니다. 표의 첫 번째 열이 거짓이고 두 번째 열이 참인 행도 두 조건을 만족하기 때문입니다. P↔Q는 반대 방향 Q→P도 함께 요구하여 두 진리값이 같은 행만 남깁니다.

이 화살표는 논리적 진리값의 관계입니다. 원인과 결과를 실험으로 확인했다는 화살표가 아닙니다. 실제 정책 효과나 행동 전이의 증거가 필요하면 관측 설계와 별도 가정을 추가해야 합니다.

Material implication P→Q excludes just one row: P true and Q false. For a two-slot schedule, let P mean “A uses 1” and Q mean “B uses 2.” The implication requires B=2 when A=1. If A is not in slot 1, the implication alone supplies no additional information about B.

Implication equals ¬P∨Q; biconditional requires both directions
PQP→QP↔Q
FalseFalseTrueTrue
FalseTrueTrueFalse
TrueFalseFalseFalse
TrueTrueTrueTrue

Knowing Q and P→Q does not establish P. The row with P false and Q true satisfies both statements too. Biconditional P↔Q also requires Q→P, retaining only rows with equal truth values.

This arrow expresses a truth-functional relationship, not an experimentally established cause-and-effect relationship. Claims about policy effects or action transitions require their own observation design and assumptions.

기초Foundations

28. 문장을 모두 통과한 행이 지식의 모형이다28. A knowledge model passes every supplied sentence

P를 “예약이 확인됨”, Q를 “입장 허용”으로 정하고 지식 문장 P와 P→Q를 함께 줍니다. 네 진리값 행 중 P가 거짓인 두 행은 첫 문장을 어깁니다. P가 참이고 Q가 거짓인 행은 둘째 문장을 어깁니다. 남는 행은 P=참,Q=참 하나입니다.

지식 기반 K={P,P→Q}의 모형 한 개
PQPP→Q두 문장 모두
거짓거짓거짓참아니요
거짓참거짓참아니요
참거짓참거짓아니요
참참참참예

모형은 여기서 모든 명제에 진리값을 하나씩 정한 행입니다. 지식 기반 K는 주어진 문장들의 모음이며, K의 모형은 그 문장을 모두 만족하는 행입니다. “모형”이라는 말이 통계의 예측식이나 실제 세계 전체와 같은 뜻으로 쓰인 것은 아닙니다.

명제가 n개이면 진리값 배정은 2ⁿ개입니다. n=0에서도 빈 진리값 배정 한 개가 있습니다. 문장 목록이 비면 모든 배정이 그 목록을 만족합니다. 반면 문장에 거짓 상수 하나가 있으면 만족하는 모형은 없습니다.

Let P mean “the booking is confirmed” and Q mean “entry is permitted,” with knowledge sentences P and P→Q. Of the four valuations, the two with P false violate the first sentence. The row with P true and Q false violates the second. Only P=true,Q=true remains.

The single model of knowledge base K={P,P→Q}
PQPP→QBoth sentences
FalseFalseFalseTrueNo
FalseTrueFalseTrueNo
TrueFalseTrueFalseNo
TrueTrueTrueTrueYes

A model here is one assignment of truth values to all declared propositions. A knowledge base K is a collection of supplied sentences, and a model of K satisfies every sentence. This use of “model” differs from a statistical prediction formula or a complete description of the physical world.

With n propositions there are 2ⁿ valuations. Even n=0 has one empty valuation. An empty knowledge list is satisfied by all valuations; including the false constant makes the set of models empty.

기초Foundations

29. 남은 모든 행에서 참인지 묻는다29. Ask whether a query is true in every remaining model

앞의 K={P,P→Q}에서는 남은 모형에서 Q가 참이므로 K는 Q를 논리적으로 함의합니다. 이를 K⊨Q라고 씁니다. 반대로 K={P→Q,Q}에는 P가 참인 모형과 거짓인 모형이 모두 있어 K⊨P가 아닙니다. P가 거짓인 모형 한 개가 그 결론을 막는 반모형입니다.

K⊨q⟺∀m (m⊨K⇒m⊨q)K\models q\quad\Longleftrightarrow\quad\forall m\ (m\models K\Rightarrow m\models q)

지식과 양립하는 모형에서 q가 참인 경우도 있고 거짓인 경우도 있으면, 이 지식만으로는 q도 ¬q도 결론낼 수 없습니다. 실습은 이를 미결정으로 표시합니다. 이는 어떤 확률이 정확히 절반이라는 뜻이 아닙니다. 모형들에 확률 분포를 주지 않았기 때문입니다.

빈 지식 기반도 항상 참인 문장은 함의합니다. 예를 들어 P∨¬P는 모든 진리값 행에서 참입니다. 반면 P 자체는 참과 거짓 행이 모두 있어 빈 지식에서 결론나지 않습니다. “아는 사실이 없다”와 “어떤 논리적 결론도 없다”는 같은 말이 아닙니다.

For K={P,P→Q}, Q is true in every remaining model, so K logically entails Q, written K⊨Q. In contrast, K={P→Q,Q} has models with P true and others with P false, so it does not entail P. One model with P false is a countermodel blocking that conclusion.

K⊨q⟺∀m (m⊨K⇒m⊨q)K\models q\quad\Longleftrightarrow\quad\forall m\ (m\models K\Rightarrow m\models q)

If q is true in some compatible models and false in others, neither q nor ¬q follows from this knowledge alone. The lab labels it undetermined. That does not assign probability one half: no probability law over models was supplied.

Even an empty knowledge base entails a tautology such as P∨¬P, which is true under every valuation. It does not entail P itself, because both truth values remain possible. “No supplied facts” differs from “no logical consequences at all.”

기초Foundations

30. 모형이 하나도 없으면 두 결론이 함께 따른다30. An inconsistent base classically entails both conclusions

K에 P와 ¬P를 동시에 넣으면 이를 함께 만족하는 행은 없습니다. 고전 논리의 함의 정의에서는 이때 임의의 q도 ¬q도 K에서 따릅니다. 모든 K 모형을 검사하라는 조건에 반례를 줄 K 모형 자체가 없기 때문입니다. 공집합에 대한 보편 명제가 참인 공허한 함의입니다.

고전적 귀결과 실제 사실 확인을 분리한다
지식 K양립 모형 수K⊨QK⊨¬Q해석
P,P→Q1예아니요일관된 결론
P,¬P0예예먼저 입력 모순을 확인

프로그램이 둘 다 참이라고 반환한다고 현실에서 Q와 ¬Q가 함께 관측되었다는 뜻은 아닙니다. 실습은 양립 모형 수 0과 모순 상태를 먼저 표시합니다. 원문을 점검해 서로 다른 날짜·대상·단위를 같은 명제로 섞었는지, 관측을 잘못 옮겼는지 살펴볼 이유입니다.

모순을 다루는 다른 논리 체계도 있지만 이 실습은 고전 명제 논리의 정의를 사용합니다. 다른 체계의 결론 규칙을 쓰려면 그 규칙을 명시하고 구현도 따로 비교해야 합니다.

If K contains both P and ¬P, no valuation satisfies it. Under classical entailment, both any q and its negation follow from K: there is no model of K that could serve as a counterexample. This is vacuous entailment over an empty set of compatible models.

Separate classical consequence from confirmation of an actual fact
Knowledge KCompatible modelsK⊨QK⊨¬QInterpretation
P,P→Q1YesNoConsistent consequence
P,¬P0YesYesInspect the input contradiction first

A program returning both entailments does not mean that Q and ¬Q were both observed in reality. The lab highlights zero models and the inconsistent status first. Check whether different dates, people or units were combined into one proposition, or a source observation was copied incorrectly.

Other logical systems handle inconsistency differently. This lab uses classical propositional semantics; adopting another system requires stating and implementing its separate consequence rules.

학부 심화 · 선택Advanced undergraduate · optional

31. 한 변수의 값 선택을 참·거짓 문장으로 바꾼다31. Encode a variable’s value choice with Boolean atoms

A의 영역이 {1,2}라면 x_A1과 x_A2를 “A가 각각 1과 2를 쓴다”는 명제로 둡니다. 적어도 한 값을 골라야 하므로 x_A1∨x_A2를 넣고, 둘 다 고르면 안 되므로 ¬x_A1∨¬x_A2도 넣습니다. 이 두 문장을 함께 쓰면 정확히 하나만 참입니다.

xA1∨xA2¬xA1∨¬xA2\begin{gathered}x_{A1}\lor x_{A2}\\\neg x_{A1}\lor\neg x_{A2}\end{gathered}

B도 같은 방법으로 표현합니다. A≠B에서 금지된 두 행 A=1,B=1과 A=2,B=2는 각각 ¬x_A1∨¬x_B1, ¬x_A2∨¬x_B2로 배제합니다. 각 변수의 정확히 하나 조건을 빠뜨리면 값을 하나도 고르지 않은 진리값 행이 잘못 남을 수 있습니다.

일반적인 유한 CSP도 각 값의 선택 명제와 금지 행을 배제하는 절들을 이용해 나타낼 수 있습니다. 정확히 하나 조건 아래 CSP의 완성 해와 Boolean 모형은 일대일로 대응합니다. 원소 없는 영역은 적어도 하나 조건이 빈 논리합인 거짓이 되어 해가 없음을 반영합니다. 이론상 표현과 별개로 실습의 명제 수 한도는 12개이므로, 큰 실제 배정 전체를 그대로 Boolean 입력에 넣지는 않습니다.

For A with domain {1,2}, introduce atoms x_A1 and x_A2 meaning that A takes each value. Require x_A1∨x_A2 to select at least one, and ¬x_A1∨¬x_A2 to prevent selecting both. Together they require exactly one value.

xA1∨xA2¬xA1∨¬xA2\begin{gathered}x_{A1}\lor x_{A2}\\\neg x_{A1}\lor\neg x_{A2}\end{gathered}

Encode B similarly. The forbidden rows A=1,B=1 and A=2,B=2 of A≠B are excluded by clauses ¬x_A1∨¬x_B1 and ¬x_A2∨¬x_B2. Omitting exactly-one conditions can wrongly retain valuations choosing no value at all.

A general finite CSP can likewise use value-selection atoms and clauses excluding forbidden rows. With exactly-one constraints, complete CSP solutions correspond one-to-one to Boolean models. An empty domain produces an empty at-least-one disjunction, which is false. This theoretical representation is separate from the lab’s 12-atom limit; a larger actual roster need not fit directly into its Boolean input.

기초Foundations

32. 실습 D · 반모형을 찾아 결론을 검사한다32. Lab D · Check a conclusion by finding a countermodel

먼저 지식 P, P→Q와 질문 Q를 선택합니다. 네 진리값 행 중 양립하는 모형 하나가 남고 Q가 참인지 확인합니다. 다음에는 지식을 P→Q, Q로 바꾸어 질문 P가 왜 미결정인지 찾습니다. 반모형의 P=거짓,Q=참 행을 직접 읽으면 “이면”의 방향을 바꾸면 안 되는 이유가 보입니다.

P와 ¬P를 동시에 넣어 모형 수 0과 고전적 양쪽 함의를 살펴봅니다. 모순 상태 표시를 빼고 “질문이 확인됐다”라고 보고하지 않습니다. 참 상수·거짓 상수, 빈 그리고·빈 또는도 각각 참·거짓으로 계산되는지 확인합니다.

표시 행 수를 줄여도 엔진은 허용된 명제 전체의 2ⁿ행을 모두 계산합니다. 화면에 일부 행만 보인다는 사실은 미완료 탐색과 다릅니다. 이 실습은 유한 명제 논리의 전수 검사이며, 모든 자연어 추론이나 무한 대상에 대한 일반 논리를 실행한 것은 아닙니다.

Start with knowledge P, P→Q and query Q. Verify that one of four valuations remains compatible and that Q is true there. Then change knowledge to P→Q,Q and ask about P. Read the countermodel P=false,Q=true to see why the implication cannot simply be reversed.

Add P and ¬P together and inspect zero models and both classical entailments. Do not omit the inconsistent status and report the query as factually confirmed. Check the true and false constants and the conventions that empty and is true while empty or is false.

Reducing displayed rows does not stop evaluation: the engine still checks all 2ⁿ valuations within its declared atom limit. A partial table display differs from incomplete search. This is exhaustive finite propositional checking, not an implementation of all natural-language reasoning or unrestricted logic over infinite objects.

기초Foundations

33. 사실과 규칙을 작은 카드로 적는다33. Write facts and rules on small cards

이번에는 확인 예약 B, 나이 조건 충족 E, 입장 허용 A라는 세 원자 문장을 쓰겠습니다. B와 E를 주어진 사실로 적고 “B와 E가 모두 있으면 A”라는 규칙을 둡니다. 사실 카드 두 장이 모두 있으므로 A를 새 카드로 더할 수 있습니다. 이 장면의 규칙은 도서관이 채택했다고 가정한 입장 규칙입니다.

행동의 관측 효과가 아니라 선언된 허용 규칙
종류내용역할
사실B예약 확인이 주어짐
사실E나이 조건 충족이 주어짐
규칙B∧E→A두 전제가 있으면 입장 허용을 도출

전제 원자들을 그리고로 묶고 결론 원자 하나를 갖는 양의 규칙을 확정 Horn 규칙이라고 부릅니다. 여기서는 이미 개별 대상에 관한 원자 이름이 붙은 유한 ground 규칙만 계산합니다. 전제가 없는 규칙은 그 결론을 사실처럼 추가합니다. 부정 전제나 “결론 없음” 제약은 이 API의 입력 언어에 포함하지 않습니다.

Use three atomic statements: B for confirmed booking, E for meeting an age condition, and A for permitted entry. Supply B and E as facts and the rule “if both B and E, then A.” Since both premise cards are present, add A. The scene assumes that the library has adopted this entry rule.

A declared permission rule, not an observed action effect
KindContentRole
FactBConfirmed booking supplied
FactEAge condition supplied
RuleB∧E→ADerive permission when both premises hold

A positive rule with a conjunction of premise atoms and one conclusion atom is a definite Horn rule. This API handles only finite ground rules with already named individual atoms. An empty-premise rule adds its conclusion as a fact. Negative premises and headless denial constraints are outside this API’s input language.

기초Foundations

34. 알고 있는 카드가 규칙을 만족하면 결론을 더한다34. Add a conclusion when known cards satisfy a rule

원자 B,E,A,L을 두고 사실 B,E, 규칙 B∧E→A와 A→L을 둡니다. 처음 카드 집합은 {B,E}입니다. 첫 규칙으로 A를 더하면 {B,E,A}, 둘째 규칙으로 L을 더하면 {B,E,A,L}이 됩니다. 이렇게 알려진 사실에서 앞으로 결론을 쌓는 방법이 전방 연쇄입니다.

각 새 결론에는 규칙 이름과 이미 알려진 전제를 남긴다
단계새 카드근거알고 있는 카드
처음B,E입력 사실B,E
1AB∧E→AB,E,A
2LA→LB,E,A,L

같은 결론이 다른 규칙에서도 나와도 카드는 한 번만 저장합니다. 엔진의 증명 기록은 처음 그 원자를 도출한 규칙과 전제 목록입니다. 규칙 나열 순서를 바꾸면 첫 증명이나 통과 횟수는 바뀔 수 있지만, 끝까지 닫은 카드 집합은 같습니다. 첫 증명이 반드시 가장 짧다는 주장은 하지 않습니다.

P→Q, Q→P만 있고 사실이 없으면 카드가 한 장도 늘지 않습니다. 서로를 가리킨다는 이유만으로 첫 카드를 만들어 내지 않습니다. P를 사실로 추가하면 그때 Q도 도출됩니다. 순환과 근거 없는 시작을 구분하는 예입니다.

Take atoms B,E,A,L, facts B,E, and rules B∧E→A and A→L. Begin with {B,E}; the first rule adds A, and the second adds L. Building conclusions forward from known facts is forward chaining.

Record a rule name and its already known premises for each new conclusion
StageNew cardJustificationKnown cards
InitialB,EInput factsB,E
1AB∧E→AB,E,A
2LA→LB,E,A,L

An atom is stored once even if several rules derive it. The proof record stores the first deriving rule and premise list. Reordering rules can change the first proof or number of passes, but not the completed closure. The first proof is not claimed to be shortest.

With only P→Q and Q→P and no facts, no card is added. A cycle does not create its own initial evidence. Supplying P as a fact then derives Q. This separates cyclic dependencies from a justified starting point.

학부 심화 · 선택Advanced undergraduate · optional

35. 끝까지 더한 집합은 가장 작은 모형이다35. The completed closure is the least model

원자 전체의 유한 집합을 U, 입력 사실 집합을 F라고 합시다. 현재 카드 집합 S에, 모든 전제가 S 안에 있는 규칙들의 결론을 더하는 연산을 T라고 쓰겠습니다. F부터 시작해 더 이상 새 카드가 없을 때까지 반복합니다. 한 번 알려진 카드는 이 양의 규칙 계산에서 지우지 않습니다.

T(S)=S∪F∪{h:(B→h)∈R, B⊆S}S0=F,St+1=T(St)\begin{gathered}T(S)=S\cup F\cup\{h:(B\to h)\in\mathcal R,\ B\subseteq S\}\\S_0=F,\qquad S_{t+1}=T(S_t)\end{gathered}

새 원자를 추가할 수 있는 횟수는 |U| 이하입니다. 따라서 유한하게 멈춥니다. 끝난 집합 S*는 모든 사실을 포함하고, 규칙의 전제가 모두 들어 있으면 결론도 들어 있으므로 모형입니다. 또 어떤 다른 모형 M도 입력 사실을 포함하고 같은 규칙을 지켜야 하므로, 귀납적으로 모든 Sₜ를 포함합니다. 따라서 S*는 모든 모형에 포함되는 가장 작은 모형입니다.

이 양의 ground Horn 언어에서는 원자 q가 모든 모형에서 참일 필요충분조건이 q∈S*입니다. 들어 있으면 모든 모형에 포함되고, 들어 있지 않으면 S* 자체가 q가 거짓인 반모형이기 때문입니다. 일반 명제 문장이나 부정 규칙 전체에 같은 간단한 알고리즘이 완전하다고 확장하지 않습니다.

Let U be the finite set of declared atoms and F the supplied facts. Define T to add conclusions of rules whose premises are all in the current set S. Start at F and repeat until no new card appears. Positive-rule closure never removes a known atom.

T(S)=S∪F∪{h:(B→h)∈R, B⊆S}S0=F,St+1=T(St)\begin{gathered}T(S)=S\cup F\cup\{h:(B\to h)\in\mathcal R,\ B\subseteq S\}\\S_0=F,\qquad S_{t+1}=T(S_t)\end{gathered}

At most |U| distinct atoms can be added, so the process terminates. Its final set S* contains all facts and is closed under every rule, hence is a model. Any other model M must contain the facts and respect the same rules; induction shows it contains every Sₜ. Therefore S* is the least model, contained in every model.

For this positive ground Horn language, an atom q is true in every model exactly when q∈S*. Membership places it in every model; nonmembership makes S* itself a countermodel where q is false. This completeness claim does not extend unchanged to unrestricted propositional formulas or rules with negation.

기초Foundations

36. 도출하지 못함을 곧 거짓이라고 부르지 않는다36. Not derived does not automatically mean false

입력 사실이 B이고 규칙이 B∧E→A뿐이라고 합시다. E가 주어지지 않아 A를 도출할 수 없습니다. 그렇다고 E가 거짓이라는 자료를 얻은 것은 아닙니다. E도 A도 참인 모형과 거짓인 모형이 모두 이 지식과 양립할 수 있습니다. 열린 세계 해석에서는 이런 원자를 미확인으로 둡니다.

닫힌 세계는 추가 선택이며 원자료의 거짓 관측이 아니다
원자양의 전방 연쇄열린 세계 표시닫힌 세계 규약 선택 시
B도출됨참으로 도출참으로 도출
E도출 안 됨미확인규약상 거짓으로 취급
A도출 안 됨미확인규약상 거짓으로 취급

등록 명단처럼 “명단에 없으면 허용하지 않는다”는 업무를 만들 때는 닫힌 세계 규약을 별도로 선택할 수 있습니다. 엔진은 이를 규약에 따른 거짓 취급이라고 표시합니다. 원래 양의 지식에서 ¬E가 고전적으로 따라온다고 표시하지 않습니다.

원자 이름을 notE라고 붙였다고 자동으로 E의 논리적 부정이 되는 것도 아닙니다. 이 API에서 두 문자열은 서로 다른 양의 원자입니다. 둘을 반대 뜻으로 연결하려면 추가 표현 규칙이 필요하고, 고전 명제 API에서는 명시적 부정 연산자를 사용합니다. 결측값을 거짓 사실로 바꾸는 일도 같은 종류의 추가 가정입니다.

Suppose the only fact is B and the only rule is B∧E→A. Without E, A cannot be derived. This does not supply evidence that E is false. Compatible models can make E and A true or leave them false. Under an open-world interpretation these atoms remain unknown.

Closed world is an additional choice, not an observed negative outcome
AtomPositive forward closureOpen-world labelIf a closed-world convention is chosen
BDerivedDerived trueDerived true
ENot derivedUnknownTreated as false by convention
ANot derivedUnknownTreated as false by convention

An administrative task may explicitly adopt “not on the registration list means not permitted.” The engine labels that choice as assumed false under a closed-world convention. It does not claim that ¬E classically follows from the original positive knowledge.

Naming another atom notE does not automatically make it the logical negation of E. They are distinct positive strings in this API. Connecting them as opposites requires additional semantics; use an explicit not operator in the classical propositional API. Turning a missing field into a false fact is likewise an additional assumption.

기초Foundations

37. 새 사실을 더할 때와 사실을 고칠 때37. Adding a fact differs from revising one

같은 양의 규칙 집합에서 사실 F를 더 큰 사실 집합 F′로 늘리면, 예전에 도출한 원자는 계속 도출됩니다. 처음부터 포함 관계 F⊆F′가 있고, 규칙도 원자를 더하기만 하므로 모든 반복 단계에서 포함 관계가 유지됩니다. 이런 성질을 단조성이라고 합니다.

F⊆F′⇒Cl⁡R(F)⊆Cl⁡R(F′)F\subseteq F^\prime\quad\Rightarrow\quad\operatorname{Cl}_{\mathcal R}(F)\subseteq\operatorname{Cl}_{\mathcal R}(F^\prime)

하지만 사실 B가 잘못 입력되어 지워야 하는 상황은 단순한 사실 추가가 아닙니다. B에 기대어 도출한 A와 L도 새 입력에서 다시 계산해야 합니다. 이전 결과를 무조건 남겨 두면 근거 없는 결론이 됩니다. 이 실습의 각 실행은 전달된 사실과 규칙에서 새 닫힘을 계산합니다.

실제 자료의 수정, 날짜가 다른 관측, 허용 규칙의 변경은 출처와 버전을 함께 기록합니다. “언제나 카드를 더해도 된다”는 말은 양의 규칙 체계의 정해진 수학적 입력에 관한 성질이지, 현실의 잘못된 정보를 수정하지 말라는 뜻이 아닙니다.

For the same positive rules, enlarging facts F to F′ cannot remove a previously derived atom. The initial inclusion F⊆F′ persists through every round because rules only add atoms. This property is monotonicity.

F⊆F′⇒Cl⁡R(F)⊆Cl⁡R(F′)F\subseteq F^\prime\quad\Rightarrow\quad\operatorname{Cl}_{\mathcal R}(F)\subseteq\operatorname{Cl}_{\mathcal R}(F^\prime)

Correcting a mistaken fact B by deleting it is different from adding facts. Conclusions A and L that depended on B must be recomputed from the revised input. Keeping the old closure automatically could retain unsupported conclusions. Each lab call computes a new closure from the facts and rules supplied to that call.

Record source and version when observations are corrected, dates differ or permission rules change. Monotonicity is a property of a fixed positive rule system with enlarged mathematical inputs; it does not instruct us to preserve misinformation about the real world.

기초Foundations

38. 대상 목록을 정하면 규칙을 개별 문장으로 펼칠 수 있다38. A declared finite universe allows explicit grounding

대상 집합을 정확히 U={민,준} 두 사람이라고 정하고 “모든 x∈U에 대해 예약 B(x)이면 입장 허용 A(x)”라는 규칙을 생각합니다. 이 유한 범위에서는 B(민)→A(민), B(준)→A(준) 두 규칙으로 펼칠 수 있습니다. B(민)만 사실이면 A(민)은 도출되지만 B(준)이나 A(준)은 이 규칙만으로 도출되지 않습니다.

원자 이름의 아래첨자는 대상 구분을 위한 표기다
범위ground 원자개별 규칙
민B_민,A_민B_민→A_민
준B_준,A_준B_준→A_준

“어떤 x∈U가 예약했다”는 존재 문장은 B(민)∨B(준)입니다. 누군가의 존재를 안다고 어느 개인인지 확정되는 것은 아닙니다. 이 논리합은 결론 하나의 양의 Horn 규칙과도 다릅니다. 일반 명제 API로 진리값 모형을 살펴볼 수 있습니다.

새 대상이 들어오면 U와 펼친 원자·규칙도 바뀝니다. 유한 목록으로 계산한 결과를 모든 가능한 사람에 대한 증명으로 바꾸지 않습니다. 일반 일차 논리는 변수·양화사·함수와 가능한 무한 구조까지 다루므로 이 장의 유한 ground 엔진과 범위를 구별합니다.

Declare exactly two individuals, U={Min, Jun}, and the rule “for every x∈U, booking B(x) implies permission A(x).” In this finite universe, expand it into B(Min)→A(Min) and B(Jun)→A(Jun). Fact B(Min) derives A(Min), but not B(Jun) or A(Jun) from this rule alone.

Subscripts distinguish individuals in the atom names
IndividualGround atomsIndividual rule
MinB_Min,A_MinB_Min→A_Min
JunB_Jun,A_JunB_Jun→A_Jun

The existential statement “some x∈U has a booking” becomes B(Min)∨B(Jun). Knowing that someone exists does not identify which individual. This disjunction also differs from a positive Horn rule with one atomic conclusion. Its compatible valuations can be examined in the propositional API.

Adding a new individual changes U and its grounded atoms and rules. A result computed over a finite list does not become a proof about every possible person. General first-order logic additionally handles variables, quantifiers, functions and potentially infinite structures; its scope exceeds this finite ground engine.

기초Foundations

39. 말의 뜻·자료의 값·규칙의 선택을 함께 기록한다39. Record meanings, observations and chosen rules

국가의 GDP 값, 영상 픽셀, 주문 수량은 출처에서 읽은 관측입니다. “GDP가 정한 경계 이상이면 검토 모둠 H에 넣는다”, “픽셀이 8 이상이면 1로 표시한다”, “한 배송 시간대에는 16개까지 넣는다”는 각각 분류 선택·변환·업무 가정입니다. 이 셋을 실제로 관측한 정책이나 공간 용량과 섞지 않습니다.

입력 근거와 논리적 결과의 역할을 나눈다
기록 층이 장의 예질문
관측주문 행의 수량 6어느 원행에서 왔는가
변환픽셀≥8을 이진값 1로경계와 등호를 어떻게 정했는가
가정 규칙시간대당 수량≤16누가 선택한 계산 조건인가
추론조건을 지키는 배정주어진 규칙에서 무엇이 따르는가

원자료에 계정 번호가 있다고 고유한 한 사람을 확인한 것은 아닙니다. 영상의 제공 시험 행 번호도 작성자 신원을 뜻하지 않습니다. 이 장의 이름표는 원행을 다시 찾기 위한 열쇠로 쓰고, 근거 없는 개인 속성 규칙을 만들지 않습니다.

표현을 잘 만들었다는 평가는 원래 질문에 필요한 구분을 남겼는지 살피는 일입니다. 필요한 시간·단위·대상을 합쳐 버리면 올바른 추론 알고리즘도 다른 질문의 답을 정확히 계산하게 됩니다.

Country GDP, image pixels and invoice quantities are observations read from sources. Grouping GDP above a chosen threshold, binarizing pixels at 8, and imposing a 16-unit delivery-slot capacity are respectively a classification choice, transformation and task assumption. They are not automatically observed policies or physical capacities.

Separate input evidence from logical consequences
LayerExample in this chapterQuestion
ObservationQuantity 6 in an invoice rowWhich original row supplied it?
TransformationPixel≥8 becomes binary 1What threshold and boundary rule were chosen?
Assumed ruleSlot quantity≤16Who chose this computational condition?
InferenceAn allocation satisfying the rulesWhat follows from the supplied conditions?

An account number does not establish the identity of one unique person. A provided test-image row number likewise is not a writer identity. We use source labels to locate original records without inventing personal-attribute rules.

A good representation retains distinctions required by the actual question. If necessary times, units or individuals are merged, even a correct inference algorithm can precisely answer a different question.

기초Foundations

40. 실습 E · 사실 카드와 도출 경로40. Lab E · Facts and derivation paths

사실 B,E와 규칙 B∧E→A, A→L을 넣어 A,L이 어떤 순서로 도출되는지 확인합니다. E를 빼면 열린 세계에서 E,A,L이 미확인인지 살펴봅니다. 닫힌 세계를 켰을 때 표시가 달라지는 것은 새 관측을 받은 결과가 아니라 선택한 규약 때문입니다.

다음에는 사실 없는 P→Q,Q→P 순환을 만듭니다. 아무것도 도출되지 않는지 확인한 뒤 P를 사실로 더합니다. 같은 원자가 여러 규칙으로 나와도 한 번만 저장되고, 각 증명 기록의 전제는 이미 알려진 카드로 이어지는지 직접 따라가 봅니다.

규칙 순서와 기록 표시 한도를 바꾸어도 최종 닫힘 집합은 같아야 합니다. 이 실습은 양의 유한 ground Horn 규칙만 계산하며, 임의의 부정 규칙·확률·현실의 숨은 전제를 자동으로 채워 넣지 않습니다. 다른 언어의 문제라면 그 언어의 의미부터 새로 정합니다.

Supply facts B,E and rules B∧E→A, A→L. Follow the derivations of A and L. Remove E and check that E,A,L remain unknown under open world. A changed label after enabling closed world reflects a chosen convention, not a newly observed fact.

Next build P→Q,Q→P with no facts. Confirm that nothing is derived, then add P. An atom is stored only once even when several rules derive it. Follow each proof’s premises back to cards that were already known.

Changing rule order or the trace display cap must preserve the final closure. This lab computes positive finite ground Horn rules; it does not silently supply negative rules, probabilities or hidden real-world premises. A different language needs its own semantics.

학부 심화 · 선택Advanced undergraduate · optional

41. 나무 모양의 이진 제약에는 더 강한 결론이 있다41. A binary constraint tree permits a stronger conclusion

두 색 삼각형은 순환 때문에 쌍별 지원을 함께 고를 수 없었습니다. 반대로 유한한 변수 그래프가 나무이고, 각 간선에 합쳐진 이진 관계 하나만 있으며, 단항 제약은 이미 영역에 반영했고 모든 영역이 비어 있지 않다고 합시다. 그 이진 관계들이 양방향으로 호 일관되면 해가 존재합니다. 나무가 아닌 그래프 전체에 같은 결론을 옮기지는 않습니다.

증명은 뿌리에 남은 값 하나를 고르는 데서 시작합니다. 부모 값을 정하면 호 일관성 때문에 각 자식에 그 값을 지원하는 값이 적어도 하나 있습니다. 자식마다 하나를 골라 아래로 반복합니다. 나무에는 서로 다른 자식 가지를 다시 묶는 간선이 없으므로 그 선택들이 다른 가지에서 충돌하지 않습니다. 유한 나무를 다 내려가면 모든 간선 제약을 만족합니다.

한 쌍의 변수에 여러 제약이 있다면 그 관계들을 먼저 교집합으로 합쳐 검사해야 합니다. 따로 지원되는 상대가 서로 다르면 동시에 통과하지 못할 수 있기 때문입니다. 거짓인 0항 제약이나 나무 바깥의 다변수 제약도 없다는 전제가 필요합니다. 이 결과가 어디까지 쓸 수 있는지 구조 조건부터 확인합니다.

The two-color triangle failed because separate pairwise supports could not coexist around its cycle. A stronger result holds when the finite variable graph is a tree, each edge has one combined binary relation, unary constraints are already incorporated, and every domain is nonempty. If every edge is arc consistent in both directions, a solution exists.

Choose any retained root value. Once a parent value is chosen, arc consistency supplies at least one supporting value for each child. Choose one and continue downward. A tree has no extra edge reconnecting different child branches, so these choices cannot conflict across branches. Reaching every vertex satisfies all edge constraints.

If several constraints concern the same pair, combine their relations by intersection first. Separately available supports might disagree. The result also excludes a false nullary constraint or additional nonbinary constraints outside the tree representation. Check these structural premises before using the stronger conclusion.

기초Foundations

42. 유한 전수 검사와 표현의 범위를 함께 적는다42. State the scope of a finite exhaustive result

이 장의 세 계산은 모두 유한합니다. CSP는 선언한 변수·영역·관계표의 해를 찾고, 명제 논리는 선언한 n개 원자의 2ⁿ행을 검사하며, Horn 전방 연쇄는 유한 원자 집합 안에서 카드를 더합니다. 각자의 종료 이유와 답의 의미가 다릅니다. 모든 알고리즘에 같은 “인공지능이 판단함”이라는 설명만 붙이지 않습니다.

각 보장은 입력 언어와 완료 조건에 붙는다
계산완료했을 때의 결론별도로 필요한 조건
유한 CSP 열거선언한 표의 전체 해 수모든 가지 검사, 올바른 가지치기
명제 모형 검사모든 양립 모형에서의 귀결명제 의미와 고전 논리 규약
양의 Horn 닫힘원자 귀결의 최소 모형유한 ground 원자와 양의 규칙

예를 들어 명제 API의 화면에 16행만 보이더라도 n=8이면 내부에서는 256행을 계산할 수 있습니다. 반면 CSP의 작업 한도 중단은 실제로 다음 가지를 계산하지 않은 상태입니다. 기록 표시의 생략과 계산의 생략을 나누어 보고합니다.

이론에서 사용하는 “모든 대상”은 선언한 유한 목록인지, 가능한 더 큰 구조인지 밝혀야 합니다. 이 장은 큰 자연어 지식의 사실성이나 일반 일차 논리의 모든 질문을 결정하는 도구를 구현한 것은 아닙니다. 작은 정확한 계산의 장점은 그 범위와 반례를 함께 확인할 수 있다는 데 있습니다.

All three computations here are finite. A CSP solves declared variables, domains and relations; propositional logic checks 2ⁿ valuations of n declared atoms; Horn closure adds cards inside a finite atom set. Their reasons for termination and meanings of an answer differ. “The AI decided” is too vague to describe these distinct guarantees.

Each guarantee belongs to an input language and completion condition
ComputationConclusion after completionAdditional premises
Finite CSP enumerationFull solution count for the declared tablesEvery branch checked; sound pruning
Propositional model checkingConsequence in all compatible modelsDeclared meanings and classical semantics
Positive Horn closureLeast model for atomic consequencesFinite ground atoms and positive rules

For example, a propositional display may show 16 rows while internally checking all 256 valuations for n=8. A CSP work-limit cutoff instead leaves branches genuinely uncomputed. Report display omission separately from omitted computation.

When a theorem says “all individuals,” state whether it means a declared finite list or a larger class of structures. This chapter does not implement factual verification of arbitrary natural-language knowledge or decision of every first-order question. The strength of a small exact computation is that its scope and counterexamples can both be inspected.

기초Foundations

43. 국가 관측을 검토 시간표의 이름표로 쓴다43. Use country observations as labels in a review roster

보관한 세계은행 원 응답에서 2024년 16개국의 1인당 GDP를 2015년 불변 미국 달러 단위로 새로 읽었습니다. 여기서는 학생들이 국가별 관측을 검토할 세 시간대를 만든다고 가정합니다. 경계 30,000 이상인 기록 중 원래 순서의 앞 세 나라 AUS,CAN,DEU와, 그 미만인 앞 세 나라 BRA,CHN,IDN을 사용합니다. 이 경계는 이 장에서 고른 균형 배정 기준입니다.

실제 GDP 관측과 가정한 검토 일정 조건을 함께 적는다
검토 그룹선택한 국가그룹 안에서 지킬 조건
경계 이상AUS,CAN,DEU각각 다른 시간대
경계 미만BRA,CHN,IDN각각 다른 시간대

각 그룹의 세 나라는 서로 다른 1,2,3을 써야 하므로 배정은 3×2×1=6가지입니다. 두 그룹 사이에는 추가 제약이 없어서 전체는 6×6=36가지입니다. 따라서 각 시간대에는 경계 이상 국가 한 곳과 미만 국가 한 곳이 들어갑니다. 이는 선택한 교육용 일정의 성질이지 실제 국가의 회의·정책 배정 기록은 아닙니다.

16개 원 관측과 선택한 여섯 기록의 원행 위치를 함께 보관합니다. 경계나 국가 선택을 바꾸면 새 CSP를 구성해 다시 풉니다. 어떤 나라를 어느 시간대에 넣느냐가 그 나라의 GDP나 다른 결과를 바꾼다는 행동 효과는 이 자료에서 주어지지 않았습니다.

Freshly select 2024 GDP per capita for 16 countries from the retained World Bank response, in constant 2015 US dollars. Construct three student review slots. Choose the first three records at or above 30,000 in retained order, AUS, CAN, DEU, and the first three below it, BRA, CHN, IDN. The threshold is an authored balancing criterion for this task.

Keep observed GDP annotations separate from the assumed review schedule
Review groupSelected countriesWithin-group rule
At or above thresholdAUS,CAN,DEUUse different slots
Below thresholdBRA,CHN,IDNUse different slots

Each group assigns three countries to distinct slots 1,2,3 in 3×2×1=6 ways. No additional constraint links the two groups, giving 6×6=36 schedules. Every slot then contains one country from each group. This is a property of the teaching roster, not an observed international meeting or policy allocation.

Retain all 16 observations and original source positions for the six selected rows. Changing the threshold or selection constructs a new CSP. The observations supply no effect of putting a country in a slot on its GDP or other outcomes.

기초Foundations

44. 숫자 영상의 네 칸을 합계만 보고 복원한다44. Complete four image cells from released margins

UCI optdigits 원 ZIP의 제공 시험 파일 첫 행은 실제 숫자 라벨 0과 64개 픽셀을 담고 있습니다. 0부터 세는 행 6과 7, 열 2와 3의 네 픽셀은 [14,5;6,13]입니다. 이 장에서 경계 8 이상을 1, 미만을 0으로 바꾸면 이진 부분 영상은 [1,0;0,1]입니다. 이진화 경계와 작은 부분 선택은 학습용 선택입니다.

원 픽셀 14,5,6,13에서 정한 실제 이진 부분 영상
부분 행첫 열둘째 열행 합
첫 행101
둘째 행011
열 합11합계 2

이제 네 값을 숨기고 행 합 1,1과 열 합 1,1만 공개합니다. 각 칸이 {0,1}인 CSP의 해는 [1,0;0,1]과 [0,1;1,0] 두 개입니다. 두 표는 네 합계를 모두 만족합니다. 공개한 합계만으로 원래 부분 영상 하나를 유일하게 알 수는 없습니다.

다른 부분 위치나 경계에서는 해가 하나일 수도 있습니다. 여섯 실제 시험 영상마다 해 수를 새로 셉니다. 이는 원 영상 일부 정보의 논리적 양립성을 확인하는 과제이며, 작성자 신원이나 필기 순서를 알아내는 과제가 아닙니다. 원래 픽셀과 라벨은 별도로 보존해 실제 부분이 해 집합에 들어 있는지 확인합니다.

The first provided test row in the original UCI optdigits ZIP contains actual label 0 and 64 pixels. At zero-based rows 6,7 and columns 2,3 the patch is [14,5;6,13]. Binarizing at the author-chosen threshold 8 gives [1,0;0,1]. Both the threshold and patch selection are teaching choices.

An actual binary patch derived from original pixels 14,5,6,13
Patch rowFirst columnSecond columnRow sum
First row101
Second row011
Column sum11Total 2

Hide its four values and release only row sums 1,1 and column sums 1,1. The four binary-variable CSP has two solutions: [1,0;0,1] and [0,1;1,0]. Both satisfy every released margin. These clues alone do not uniquely identify the original patch.

Another location or threshold may yield one solution. Recompute the count for each of the six actual test images. This task checks logical compatibility with partial image information, not writer identity or pen-stroke order. Preserve original pixels and labels separately to verify that the actual patch is among the solutions.

기초Foundations

45. 주문 수량을 세 가정 시간대에 나눈다45. Allocate actual invoice quantities to three assumed slots

UCI Online Retail 원 XLSX의 첫 송장 536365에는 일곱 원행이 있고 수량은 6,6,8,6,6,2,6으로 합이 40입니다. 각 원행 묶음을 쪼개지 않고 세 이름 있는 배송 시간대에 하나씩 넣되, 시간대마다 수량 16 이하라는 가정 조건을 둡니다. 실제 수량은 관측이고 시간대·용량·쪼개지 않음은 이 장의 계산 규칙입니다.

다섯 6개 묶음은 서로 다른 원행으로 구별한다
경우설명배정 수
8개 묶음과 2개 묶음이 같은 시간대그곳에 6개 묶음 하나, 나머지 시간대에 둘씩3×5×6=90
8개와 2개 묶음이 다른 시간대8개 쪽에 6개 하나, 나머지 두 곳에 둘씩3×2×5×6=180
전체두 경우는 겹치지 않음90+180=270

첫 경우에는 8개 묶음이 들어갈 시간대 3개, 함께 들어갈 6개 묶음 5개를 고릅니다. 남은 네 6개 묶음 중 어느 둘을 이름 있는 나머지 첫 시간대에 넣을지 6가지로 고르면 나머지는 정해집니다. 둘째 경우에는 2개 묶음의 다른 시간대 선택이 2가지 더 있습니다. 각 시간대의 최종 수량은 첫 경우 16,12,12 또는 둘째 경우 14,14,12입니다.

조건 없이 각 묶음이 세 곳 중 하나를 택하면 3⁷=2,187행입니다. 용량 16에서는 이 중 270행이 통과합니다. 용량을 13으로 바꾸면 총 용량 39가 실제 합 40보다 작아 해가 없습니다. 이 용량은 무게·부피나 실제 창고 작업을 측정한 값이 아니며, 가능한 일정이 이익을 최대화한다는 뜻도 아닙니다.

The original first invoice 536365 in the UCI Online Retail XLSX has seven lines with quantities 6,6,8,6,6,2,6, totaling 40. Assign each indivisible line batch to one of three named delivery slots, assuming a 16-unit capacity per slot. Quantities are observations; slots, capacity and indivisibility are authored task rules.

The five 6-unit batches remain distinct source lines
CaseAllocation structureCount
8-unit and 2-unit batches togetherOne 6-unit batch joins them; two go in each other slot3×5×6=90
8-unit and 2-unit batches apartOne 6-unit batch joins 8; two go in each other slot3×2×5×6=180
TotalThe cases are disjoint90+180=270

In the first case choose the slot containing 8 in three ways and its accompanying 6-unit line in five ways. Choose two of the four remaining 6-unit lines for the first named remaining slot in six ways; the last slot is then fixed. The second case adds two choices for the different slot containing 2. Final slot loads are 16,12,12 or 14,14,12 respectively.

Without capacity constraints there are 3⁷=2,187 assignments; 270 pass at capacity 16. Capacity 13 gives total capacity 39, below actual quantity 40, and no solution. These units are neither measured mass nor volume, and feasibility does not establish an actual warehouse plan or profit optimum.

기초Foundations

46. 실습 F · 실제 관측과 선택한 제약을 따로 바꾼다46. Lab F · Vary observations and chosen constraints separately

국가 탭에서는 선택된 여섯 관측과 경계 그룹을 먼저 읽고 해 36개를 확인합니다. 영상 탭에서는 첫 시험 영상, 부분 위치 행 6·열 2, 경계 8을 선택해 두 완성 표를 비교합니다. 주문 탭에서는 실제 일곱 수량을 유지한 채 가정 용량을 13,14,16으로 바꾸어 해 수 0,180,270을 비교합니다.

해를 나열한 표와 실제 관측 표는 역할이 다릅니다. 실제 자료 표는 원행 키와 단위를 남기며, 해 표는 우리가 선택한 조건을 통과한 배정입니다. 전파·변수 순서·기록 표시를 바꾸어도 같은 완성 문제를 끝까지 풀었다면 해 수가 같아야 합니다. 중단되면 현재까지 찾은 수라고 표시합니다.

그래프는 현재 화면 폭에 맞추어 다시 그립니다. 짧은 축 이름 옆의 설명과 원행 표에서 전체 조건을 읽을 수 있습니다. 보관 Python/R 예제는 같은 유한 기준 문제를 실제로 다시 실행한 기록이고, 지금 누르는 조작은 브라우저 자바스크립트 계산입니다.

In the country tab inspect the six selected observations and threshold groups, then confirm 36 schedules. In the image tab choose the first test row, patch row 6/column 2 and threshold 8 to compare its two completions. In the invoice tab keep the seven observed quantities while changing assumed capacity to 13,14,16, giving 0,180,270 solutions.

The solution table and observed-data table have different roles. Observations retain source keys and units; solutions satisfy the selected task conditions. Changing propagation, variable order or trace display must preserve the total after a complete run of the same problem. A cutoff instead reports solutions found so far.

Plots redraw at the current screen width. Read full conditions in visible captions and source tables beside short axis labels. Archived Python/R examples are actual separate executions of the finite reference problems; live controls invoke browser JavaScript.

기초Foundations

47. 국가·개인 자료·기업 주문을 다시 읽는다47. Revisit country, individual-record and company cases

국가 · GDP 관측을 검토 슬롯에 배정한다

교실에서 국가별 통계를 함께 검토하려고 세 시간대를 만든다고 합시다. 여섯 팀이 같은 그룹 안에서는 서로 다른 시간대를 쓰도록 정하면, 누구를 어느 시간대에 넣을 수 있을까요? 이 사례는 실제 국가 GDP를 팀의 관측 이름표로 사용하고, 시간표의 규칙은 우리가 새로 정합니다. 국가의 실제 회의나 정책 결정을 관측한 사례로 읽지는 않습니다.

보관 World Bank 원 JSON을 다시 읽어 NY.GDP.PCAP.KD의 2024년 16개 국가 기록을 고릅니다. 단위는 2015년 불변 미국 달러/명입니다. 원 응답의 위치를 1부터 세어 보존하며, 아래 소수 둘째 자리 표시는 읽기용 근삿값입니다. 경계 판정에는 표시된 반올림값 대신 원 수치 토큰의 정확한 유리수 값을 사용합니다.

실제 16개 GDP 관측 · 표시는 근삿값, CSV에는 원 수치 토큰
국가원 응답 위치연도2015 USD/명선택 그룹
AUS21612024≈61486.38H
BRA22062024≈9566.75L
CAN22512024≈45061.39H
CHN22962024≈13119.11L
DEU23412024≈44027.76H
FRA23862024≈39683.40H
GBR24312024≈47900.97H
IDN24762024≈4367.95L
IND25212024≈2366.83L
JPN25662024≈37976.64H
KOR26112024≈37048.43H
MEX26562024≈10284.03L
SGP27012024≈68129.70H
USA27462024≈66856.51H
VNM27912024≈4012.51L
ZAF28362024≈5715.48L

먼저 30,000 이상을 H, 그 미만을 L로 나눕니다. 이 문턱은 국가의 공식 소득 등급이 아니라 이번 검토 과제의 선택 기준입니다. 보관된 순서에서 H 앞 세 곳 AUS,CAN,DEU와 L 앞 세 곳 BRA,CHN,IDN을 선택합니다. 원래 16개 관측을 지우지 않고, 선택된 여섯 곳과 선택 규칙을 별도로 보존합니다.

각 나라 이름을 변수로, {slot1,slot2,slot3}을 각 영역으로 둡니다. H 안의 세 변수에 서로 다른 값, L 안의 세 변수에도 서로 다른 값을 요구합니다. H와 L 사이에는 다른 슬롯이어야 한다는 제약이 없습니다. 따라서 한 시간대에 H 한 곳과 L 한 곳이 들어갈 수 있습니다.

실제 관측 라벨을 쓴 가정 시간표 · C에서는 AUS와 CAN이 같은 슬롯
국가 변수가능한 배정 A가능한 배정 B충돌 배정 C
AUSslot1slot1slot1
CANslot2slot2slot1
DEUslot3slot3slot3
BRAslot1slot3slot1
CHNslot2slot1slot2
IDNslot3slot2slot3

H의 첫 나라에 슬롯 3개 중 하나, 다음 나라에 남은 2개, 마지막 나라에 1개를 고르므로 H는 3×2×1=6가지입니다. L도 6가지이며 한 그룹의 선택이 다른 그룹을 제한하지 않으므로 전체는 6×6=36가지입니다. 변수 6개에 3개 값씩을 제약 없이 쓰는 3⁶=729개 후보와 구별합니다.

AUS를 slot1로 고정하면 H의 나머지 두 나라에 2가지 순서가 남고 L은 여전히 6가지여서 12개입니다. AUS와 CAN을 모두 slot1로 고정하면 H의 다른 슬롯 조건을 이미 어기므로 해는 0개입니다. 빈 슬롯이 남아 있어도 고정된 충돌을 나중에 고칠 수는 없습니다.

36개 중 첫 해를 보여 주는 것과 모든 해를 세는 것은 다른 일입니다. 처음 발견한 배정은 선언한 변수·값 순서를 따른 대표일 뿐 공정성이나 비용이 가장 좋다는 평가를 받지 않았습니다. 선호나 시간 비용을 비교하려면 그 목적 함수를 별도로 정의해야 합니다.

GDP를 두 그룹으로 나눈 단계, 일부 나라를 택한 단계, 슬롯 제약을 정한 단계를 순서대로 적으면 관측과 선택이 섞이지 않습니다. GDP가 높은 나라를 어느 슬롯에 넣는다고 GDP가 바뀐다는 전이는 이 데이터에 없습니다. 여기서 검산하는 것은 선택한 유한 시간표의 양립성과 전체 수입니다.

직접 해보기

H와 L을 모두 같은 세 슬롯 순서로 배정한 A는 허용됩니까? H 한 곳의 값을 바꾸면 어떤 조건부터 확인합니까?

A는 그룹 안에서 세 값이 다르므로 허용됩니다. 값을 바꾼 뒤에는 그 나라의 영역과 같은 그룹 안의 두 비교를 확인합니다. 다른 그룹과 같은 슬롯이라는 이유만으로 거절하지 않습니다.

공개 actual16 CSV는 모든 관측과 원 위치를, assumed36 CSV는 우리가 만든 36개 배정을 보관합니다. Python과 R은 서로 다른 열거 방식으로 36·12·0을 다시 계산합니다. 이 일치는 같은 규칙의 계산을 대조하는 근거이며 원 기관의 행동이나 관측의 정확성을 대신 검증하지는 않습니다.

개인 자료 · 실제 네 픽셀을 합계 단서로 완성한다

이번에는 한 사람이 쓴 숫자의 작은 영상에서 네 칸만 봅니다. 픽셀 네 개를 전부 보여 주지 않고 가로·세로 합계만 공개하면 원래 네 값을 알 수 있을까요? UCI optdigits의 실제 제공 시험 기록을 사용하되, 공개할 단서와 이진화 경계는 이 장에서 정합니다.

원 ZIP의 optdigits.tes에는 1,797행이 있습니다. 여기서는 첫 6행과 각 행의 라벨·64개 픽셀을 새로 읽어 보존합니다. 픽셀은 8×8 표의 행 우선 순서이며 값은 0부터 16입니다. 첫 여섯 라벨은 0,1,2,3,4,5이지만 원행 번호가 필기 작성자의 신원을 뜻하지는 않습니다.

첫 영상의 0부터 세는 행 6·7과 열 2·3은 원 64열에서 p50,p51,p58,p59에 해당합니다. 실제 값은 [14,5;6,13]입니다. 경계 8 이상을 1로 표시하면 [1,0;0,1]입니다. 이는 원 값을 바꾸어 보관하는 것이 아니라 원 픽셀과 별도로 만든 학습용 이진 표현입니다.

첫 제공 시험 원행의 실제 부분 · a,b/c,d의 행 우선 순서
위치원 픽셀선택 이진 값
a141
b50
c60
d131

행 합은 a+b=1, c+d=1이고 열 합은 a+c=1, b+d=1입니다. 이제 a,b,c,d의 영역을 모두 {0,1}로 두고 이 네 등식을 제약으로 사용합니다. 2⁴=16개 후보를 한 행씩 대입하면 두 표만 남습니다.

같은 네 합계를 만족하는 두 이진 표
완성abcd원 부분과 같은가
10110아니오
21001예

a=0을 고르면 첫 행에서 b=1, 첫 열에서 c=1, 둘째 행에서 d=0입니다. a=1이면 반대로 b=c=0,d=1입니다. 두 경우 모두 네 합계를 통과합니다. 따라서 합계는 원 부분을 포함하는 해 집합을 주지만, 원래 표 하나를 유일하게 결정하지는 않습니다.

추가 관측으로 a=1을 공개하면 두 해 중 하나만 남습니다. a=b=1을 동시에 주장하면 첫 행 합 1과 모순되어 해가 없습니다. 여기서 두 번째 주장은 가정한 충돌 예이지 실제 영상의 관측을 바꾼 기록이 아닙니다.

여섯 실제 부분에 같은 위치·경계 규칙을 적용한 결과
제공 시험 원행실제 라벨네 원 픽셀행0,행1,열0,열1 합완성 수
1014,5,6,131,1,1,12
211,16,0,111,1,0,21
3213,16,0,32,0,1,11
438,4,7,131,1,1,12
540,3,0,20,0,0,01
655,4,9,160,2,1,11

원행 2의 부분 [1,16;0,11]은 이진 표 [0,1;0,1]이고 첫 열 합이 0이라 그 열의 두 값이 모두 0입니다. 그 다음 두 행 합이 나머지 두 값을 고정하므로 해가 하나입니다. 모든 영상에 두 완성이 생기는 것은 아닙니다. 원행 1과 4는 두 해, 나머지 네 행은 한 해입니다.

경계 포함도 단서의 일부입니다. 제공 시험 원행 3의 0부터 세는 행 2·3, 열 2·3에 있는 실제 부분 [8,13;1,6]에서 ≥8을 쓰면 [1,1;0,0]이지만 >8을 쓰면 [0,1;0,0]입니다. 좌표·경계·등호 규칙을 남기지 않으면 같은 원 영상에서 다른 CSP를 만들 수 있습니다.

직접 해보기

네 행·열 합이 모두 1이고 a=1일 때 c를 먼저 정해 보세요. 합계가 같은 두 표를 구별하려면 어떤 한 칸을 더 관측하면 될까요?

a+c=1에서 c=0입니다. 두 해는 모든 칸에서 서로 달라 어느 한 칸의 실제 이진 값을 정확히 알면 하나를 고를 수 있습니다. 실제 추가 관측 없이 임의로 고른 값을 관측이라고 부르지는 않습니다.

공개 원 CSV에는 라벨과 64픽셀이 모두 있고, 파생 CSV에는 선택 좌표·네 원 값·이진 값·합계·완성 수가 있습니다. 별도 완성 CSV는 6영상에 대한 총 8개 허용 표를 보관합니다. 이 자료는 부분 정보로부터의 논리적 양립성을 보여 주며 숫자 분류 성능, 작성자 개인정보 또는 일반적인 익명성 보장을 측정한 것은 아닙니다.

기업 · 실제 주문 수량과 가정 슬롯 용량

판매 주문의 일곱 줄을 세 작업 시간대로 나누는 장면입니다. 실제 주문 수량은 주어져 있지만 시간대마다 몇 개를 처리할지, 한 줄을 나눌지, 어떤 비용을 최소화할지는 별도 문제입니다. 이 사례는 수량은 원 파일에서 읽고, 세 시간대·한 줄을 나누지 않음·공통 용량을 학습용 제약으로 정합니다.

UCI Online Retail의 보관 ZIP 안 Online Retail.xlsx를 다시 열어 첫 송장 536365의 원행 1–7을 고릅니다. 원행은 제목 행을 빼고 세므로 워크시트 행은 2–8입니다. 송장·품목·설명·수량·일자 원토큰·단가 원토큰·계정 원토큰·국가를 함께 보존합니다.

첫 실제 송장의 일곱 원행 · 금액을 용량으로 사용하지 않는다
데이터 원행품목 코드실제 수량단가 원토큰계정 원토큰
185123A62.549999999999999817850
27105363.3917850
384406B82.7517850
484029G63.3917850
584029E63.3917850
62275227.6517850
72173064.2517850

단가 첫 원토큰은 2.5499999999999998이고 원 날짜는 40513.351388888892입니다. 수업에서 반올림한 단가나 해석한 달력 표기가 필요하더라도 이 원토큰을 덮어쓰지 않습니다. 현재 CSP가 사용하는 측정값은 수량 [6,6,8,6,6,2,6]이며 합은 40입니다.

일곱 원행을 서로 다른 변수로 두고 각 영역은 {slot1,slot2,slot3}입니다. 같은 수량 6을 가진 다섯 줄도 서로 다른 원행입니다. 제약은 각 슬롯에 들어간 수량 합이 공통 용량 C 이하라는 것입니다. 품목 무게나 부피는 원 자료에서 주어지지 않았으므로 용량의 단위를 무게나 부피로 바꾸지 않습니다.

용량 C=16에서 8개 묶음과 2개 묶음이 같은 슬롯인 경우를 먼저 봅니다. 그 슬롯에 6개 묶음 하나가 더 있어야 나머지 네 6개 묶음을 두 슬롯에 둘씩 나눌 수 있습니다. 8개가 들어갈 슬롯 3가지, 동반 6개 줄 5가지, 남은 네 줄 중 이름 있는 한 슬롯의 두 줄 선택 6가지로 90개입니다.

8과 2가 다른 슬롯이면 8의 슬롯 3가지, 2의 슬롯 2가지, 8과 함께 들어갈 6개 줄 5가지, 나머지 네 줄의 두 줄 선택 6가지로 180개입니다. 두 경우는 겹치지 않아서 전체는 270개입니다. 같은 경우의 수량은 16,12,12이고 다른 경우는 14,14,12입니다.

실제 수량을 유지하고 가정 용량만 바꾸어 전수 열거
가정 용량 C세 슬롯 총 용량완성 수8과2 같은 곳8과2 다른 곳
1236000
1339000
14421800180
164827090180
206012902701020
4012021877291458

C=13이면 총 용량이 39여서 합 40을 담을 수 없습니다. C=14에서는 8+6, 2+6+6, 6+6으로 나누어 14,14,12가 되므로 가능합니다. 전수 계산은 180개를 줍니다. 총 용량이 충분하다는 조건만으로 언제나 쪼갤 수 없는 묶음의 배정이 가능한 것은 아니며, 여기서는 실제 증거 배정도 함께 확인합니다.

C=20에서는 1,290개이고 C=40에서는 모든 3⁷=2,187개 배정이 통과합니다. 같은 변수와 양의 수량에서 C를 늘리면 기존 해는 여전히 허용되므로 해 집합은 줄지 않습니다. 이 포함 관계는 가정 부등식의 수학적 성질이며 실제 기업이 용량을 늘렸을 때의 수익이나 배송 성과를 관측한 결과는 아닙니다.

직접 해보기

C=14에서 원행 (3,1), (6,2,4), (5,7)을 각각 한 슬롯에 넣으면 일곱 줄을 모두 한 번씩 사용합니까? 용량도 통과합니까?

원행 1–7이 중복 없이 모두 들어갑니다. 수량 합은 각각 8+6=14, 2+6+6=14, 6+6=12이므로 용량을 통과합니다. 이 검사는 한 증거의 가능성을 확인하며 다른 가능한 배정 수 180을 혼자 증명하지는 않습니다.

계정 17850은 원 파일의 계정 토큰입니다. 한 계정이 고유한 실제 한 사람이라는 추론이나 원행이 실제 포장 한 상자라는 추론을 덧붙이지 않습니다. 이 과제에서 쪼개지 않는 단위는 선택한 주문 원행이라는 가정입니다.

가능한 270개 중 첫 배정을 가장 싸거나 실제 최적이라고 부르려면 비용·시간·선호 함수와 운영상 의미가 필요합니다. 지금은 그런 목적 함수가 없으므로 가능성·전체 수·중단 상태만 보고합니다. 공개 CSV와 별도 Python/R은 같은 제약의 재현성을 확인하고, 실제 행동 효과는 새로운 관측·설계의 질문으로 남깁니다.

Country · schedule reviews of GDP observations

Imagine three classroom slots for reviewing country statistics. Six teams must use distinct slots within each of two groups. Which schedules are possible? Actual GDP observations annotate the country labels, while the scheduling rules are newly chosen for this lesson. No historical meeting allocation or policy choice is being observed.

Freshly read the retained World Bank JSON and select the sixteen 2024 records for NY.GDP.PCAP.KD, measured in constant 2015 US dollars per person. Keep one-based positions in the original response. The table rounds displays to two decimals, while threshold classification uses the original numerical tokens as exact rational values.

Sixteen actual GDP observations · approximations here; original numerical tokens remain in CSV
CountryOriginal positionYear2015 USD/personChosen group
AUS21612024≈61486.38H
BRA22062024≈9566.75L
CAN22512024≈45061.39H
CHN22962024≈13119.11L
DEU23412024≈44027.76H
FRA23862024≈39683.40H
GBR24312024≈47900.97H
IDN24762024≈4367.95L
IND25212024≈2366.83L
JPN25662024≈37976.64H
KOR26112024≈37048.43H
MEX26562024≈10284.03L
SGP27012024≈68129.70H
USA27462024≈66856.51H
VNM27912024≈4012.51L
ZAF28362024≈5715.48L

Define H by GDP at least 30,000 and L by GDP below 30,000. This is a task threshold, not an official income classification. In retained order select AUS, CAN, DEU from H and BRA, CHN, IDN from L. Keep the original sixteen records as well as the selected six and their selection rule.

Each country label is a variable with domain {slot1,slot2,slot3}. Require distinct values for the three H variables and separately for the three L variables. There is no cross-group inequality. A slot may therefore contain one country from each group.

Assumed schedules over actual observation labels · C repeats a slot within H
Country variableFeasible schedule AFeasible schedule BConflicting schedule C
AUSslot1slot1slot1
CANslot2slot2slot1
DEUslot3slot3slot3
BRAslot1slot3slot1
CHNslot2slot1slot2
IDNslot3slot2slot3

Choose one of three slots for the first H country, one of two unused slots for the second, and the remaining slot for the third. This gives 3×2×1=6 H permutations. L independently has six, so there are 36 complete schedules. This differs from the 3⁶=729 candidate assignments before constraints.

Fixing AUS to slot1 leaves two orders for the other H countries and six L orders, giving twelve schedules. Fixing both AUS and CAN to slot1 violates the H rule immediately, so there are zero completions. Remaining unassigned variables cannot repair a conflict among fixed values.

A displayed first witness and an exhaustive count answer different questions. The first witness follows declared variable and value orders; it has not been scored as fairest or cheapest. Comparing preference or time cost would require an additional objective with a defined interpretation.

Record grouping, six-country selection and slot constraints as separate steps. The data supply no transition saying that a country’s GDP changes when its review slot changes. The calculation verifies compatibility and counts within the chosen finite schedule.

Try it

Is schedule A valid when H and L use the same three-slot order? Which conditions must be checked after changing one H value?

Yes: each group still uses three distinct slots. Check the changed value’s domain and its two within-H comparisons. Sharing a slot with a country in the other group is allowed.

The actual16 CSV preserves observations and original positions; the assumed36 CSV preserves the constructed schedules. Separate Python and R implementations recompute 36, twelve and zero. Agreement supports the declared calculation, while source authenticity and real institutional behavior require different evidence.

Individual record · complete actual pixels from margin clues

Look at four cells inside an actual handwritten-digit record. If only row and column totals are released, can the original cells be recovered? Use actual provided-test optdigits observations while choosing the released clues and threshold for this lesson.

The original optdigits.tes contains 1,797 rows. Freshly retain its first six rows, their labels and all 64 pixels. Values from zero through sixteen form an 8×8 row-major grid. The six labels are zero through five, but a source row number does not identify the writer.

In the first image, zero-based rows six and seven and columns two and three correspond to p50,p51,p58,p59. Their actual values are [14,5;6,13]. Thresholding at values at least eight gives [1,0;0,1]. Preserve this authored binary representation separately from the unchanged original pixels.

Actual first provided-test patch · row-major order a,b/c,d
CellOriginal pixelChosen binary value
a141
b50
c60
d131

Its constraints are a+b=1, c+d=1, a+c=1 and b+d=1. Give each variable domain {0,1}. Substituting all sixteen candidate rows leaves exactly two binary tables.

Two different binary patches satisfy the same four margins
CompletionabcdMatches original
10110No
21001Yes

If a=0, the first row forces b=1, the first column forces c=1, and the second row forces d=0. If a=1, instead b=c=0 and d=1. Both pass all four constraints. The released margins define a feasible set containing the original, rather than uniquely specifying that original.

Revealing an additional actual clue a=1 selects one of the two completions. Asserting a=b=1 would contradict the first-row total and produce zero solutions. The latter is a hypothetical conflicting claim, not an alteration of the observed source pixels.

Same selected coordinates and threshold for six actual images
Provided test rowActual labelFour original pixelsRow0,row1,col0,col1 totalsCompletions
1014,5,6,131,1,1,12
211,16,0,111,1,0,21
3213,16,0,32,0,1,11
438,4,7,131,1,1,12
540,3,0,20,0,0,01
655,4,9,160,2,1,11

Row two has raw patch [1,16;0,11], yielding [0,1;0,1]. Its first-column total zero fixes both first-column cells at zero; the row totals then fix the other two cells. It therefore has one completion. Rows one and four have two; the other four records have one each. Ambiguity depends on the actual clues.

Boundary inclusion is part of the representation. On provided-test row three, zero-based rows two/three and columns two/three give the actual patch [8,13;1,6]; the rule ≥8 yields [1,1;0,0], while >8 yields [0,1;0,0]. Retain coordinates, threshold and equality convention so that another reader constructs the same CSP.

Try it

When all four margins equal one and a=1, determine c first. Which additional cell observation could distinguish the two original completions?

The equation a+c=1 forces c=0. The two completions differ in every cell, so one accurately observed binary cell suffices. A freely chosen extra constraint must not be relabeled as an actual observation.

The original CSV retains labels and all pixels; a derived CSV retains coordinates, threshold, source patch, binary patch, margins and count. Another CSV lists all eight allowed completions across the six records. This illustrates compatibility with partial information, not digit-classification accuracy, writer identity or a general anonymity guarantee.

Company · actual invoice quantities and assumed slot capacities

Imagine allocating seven invoice lines to three work slots. Actual quantities are given, but slot capacities, whether a line may be split, and any cost objective are separate choices. Read the quantities from the source while declaring three slots, indivisible lines and a common capacity for this classroom task.

Freshly open Online Retail.xlsx inside the retained UCI ZIP and select the first invoice, 536365, data rows one through seven. Data-row indices exclude the header, so worksheet rows are two through eight. Preserve invoice, stock code, description, quantity, original date/price/account tokens and country.

Seven actual first-invoice lines · prices are not capacity units
Data rowStock codeActual quantityOriginal price tokenOriginal account token
185123A62.549999999999999817850
27105363.3917850
384406B82.7517850
484029G63.3917850
584029E63.3917850
62275227.6517850
72173064.2517850

The first original price token is 2.5499999999999998 and the original date token is 40513.351388888892. Rounded prices or interpreted calendar displays must not overwrite them. The measured inputs used by this CSP are quantities [6,6,8,6,6,2,6], totaling forty.

Create seven distinct variables, one per source line, each with domain {slot1,slot2,slot3}. The five six-unit lines remain distinct. Require each slot’s quantity sum to be at most C. Source quantities do not supply weights or volumes, so those units must not be substituted for the declared count-based capacity.

At C=16, first suppose the eight-unit and two-unit lines share a slot. They must have one six-unit companion so that the four remaining six-unit lines fit two per remaining slot. Choose the slot in three ways, the companion in five ways, and two of the remaining four lines for the first named remaining slot in six ways: ninety assignments.

If eight and two use different slots, choose the eight slot in three ways, the two slot in two ways, the six-unit companion of eight in five ways and the remaining split in six ways: 180 assignments. The disjoint cases total 270. Their slot-load patterns are respectively 16,12,12 and 14,14,12.

Keep actual quantities fixed; exhaustively vary only the authored common capacity
Assumed capacity CTotal slot capacityCompletionsEight/two togetherEight/two apart
1236000
1339000
14421800180
164827090180
206012902701020
4012021877291458

At C=13 total capacity is 39, less than observed quantity forty, proving infeasibility. At C=14 the groups 8+6, 2+6+6 and 6+6 give a feasible 14,14,12 witness. Enumeration finds 180 assignments. Sufficient total capacity alone need not guarantee a feasible indivisible allocation; a witness is checked here as well.

At C=20 there are 1,290 solutions; at C=40 all 3⁷=2,187 candidate assignments pass. Increasing C with the same variables and quantities preserves every previous solution. This inclusion is a property of the declared inequalities, not an observed effect of an operational capacity change on profit or delivery outcomes.

Try it

At C=14 assign source rows (3,1), (6,2,4), and (5,7) to the three slots. Is every line used once, and do the capacities pass?

Rows one through seven are used exactly once. Loads are 14, fourteen and twelve, so the witness passes. Checking that witness establishes feasibility but does not by itself count all 180 assignments.

Account 17850 is a source token. It does not establish one unique person behind the account, and a source line is not verified to be a physical packed box. Treating each selected invoice line as indivisible is an explicit task assumption.

Calling the first of 270 schedules cheapest or operationally optimal would require an objective with units and an operational interpretation. None is supplied, so report feasibility, count and any cutoff. Public CSVs and separate Python/R implementations support reproduction of the declared problem; action effects remain questions for new evidence and design.

기초Foundations

48. 공식 강의·인물·읽을 질문48. Official lecture, scholar and reading questions

공식 본문 영상: CS50의 Optimization 강의에서 제약 충족과 백트래킹 부분을 봅니다. 먼저 우리 도서관의 두 해를 손으로 적은 뒤, 강의의 변수·영역·제약이 어디에 해당하는지 비교합니다. 최적화라는 큰 제목 아래에서도 조건을 통과하는 답과 선호 점수가 가장 좋은 답은 구분해서 읽습니다.

CS50 공식 강의와 본문 재생창

인물: UBC의 Alan Mackworth 공식 소개는 제약 기반 계산 지능과 지각·추론·행동을 연결하는 연구를 설명합니다. 우리 예에서 “해를 찾는 절차”보다 먼저 “해가 지킬 조건”을 적은 선택이 어떤 장점이 있는지 생각해 봅니다.

UBC · Alan Mackworth 공식 소개

읽기 1: Poole–Mackworth 교재 4.3절의 지원값 정의와 GAC 할 일 목록을 읽고, 왜 값을 지운 뒤 이웃 검사를 다시 넣는지 설명합니다. 고정점의 영역이 모두 비어 있지 않아도 해가 없을 수 있다는 세 번째 경우를 우리 삼각형과 연결합니다.

Artificial Intelligence 3E · Consistency Algorithms

읽기 2: CS50 Knowledge 노트의 모형과 논리적 함의, 전수 모형 검사를 읽습니다. P→Q와 Q만으로 P가 따라오지 않는 반모형을 다시 그리고, 우리 Horn 닫힘과 일반 명제 모형 검사가 같은 입력 언어를 쓰는지 비교합니다.

CS50 · Knowledge 공식 노트

Python · R · 원자료·단위·가공·출처

Official lecture: use the constraint-satisfaction and backtracking portions of CS50’s Optimization lecture. First write the library’s two solutions by hand, then compare the lecture’s variables, domains and constraints. Even within an optimization lecture, distinguish satisfying conditions from maximizing a preference score.

CS50 official lecture and in-page player

Scholar: UBC’s official Alan Mackworth profile connects constraint-based computational intelligence with agents that perceive, reason and act. In our examples, what is gained by stating conditions a solution must satisfy before prescribing a solving procedure?

UBC · Official Alan Mackworth profile

Reading 1: read the support definition and GAC worklist in Poole–Mackworth section 4.3. Explain why shrinking a domain requeues neighboring checks. Connect the third fixed-point case, nonempty domains that may still have no solution, to our triangle.

Artificial Intelligence 3E · Consistency Algorithms

Reading 2: read models, entailment and exhaustive model checking in the official CS50 Knowledge notes. Rebuild a countermodel showing why P→Q together with Q does not establish P. Compare the input language of our Horn closure with that of general propositional model checking.

CS50 · Official Knowledge notes

Python · R · Inputs, units, transformations and sources

Python·R 코드 실행 방법Run the Python/R companions

자료 묶음을 풀고 코드와 실제데이터 폴더를 함께 두세요. 터미널에서 코드 파일이 있는 폴더로 이동해 아래 명령을 실행합니다. 코딩이 처음이라면 손계산과 웹 실습을 먼저 하고, 데이터 사이언스 입문에서 코드를 배운 뒤 돌아와도 됩니다.Extract the bundle, keeping the scripts beside the data folder. In a terminal, enter the script folder and run the commands below. Beginners can complete hand calculations and browser labs first, returning to code after studying introductory data science.

python ai03-reproduce.py
Rscript --vanilla --encoding=UTF-8 ai03-reproduce.R

결과 파일은 각 코드에 지정된 결과 폴더에 저장됩니다. CSV 원자료는 덮어쓰지 않습니다.Result files are saved in the result directory specified by each script; the input CSVs are not overwritten.

영상·학자·함께 읽기Videos, thinkers and guided reading

본문의 질문을 넓히는 선택 학습입니다. 영상을 보기 전 질문을 먼저 읽고, 자신의 답을 쓴 뒤 해설과 비교하세요. 자료의 언어·선수 지식은 각 항목에 표시했습니다.Optional extensions to the chapter. Read the question first, write your answer, then compare with the explanation. Language and prerequisites are indicated below.

제약 충족: 먼저 지킬 조건을 적는다Constraint satisfaction: write the conditions first

Harvard CS50 AI · Optimization

강의의 변수·영역·제약을 도서관 A,B,C에 대응하고 백트래킹이 어떤 선택으로 돌아가는지 설명하세요.Map variables, domains and constraints to library A,B,C, then explain which choice backtracking revisits.

교재 안의 YouTube 플레이어에서 재생합니다. 원영상에서 제공하는 자막은 플레이어의 CC·설정에서 선택할 수 있습니다.Playback stays in this chapter’s YouTube player. Available captions can be selected through CC/settings.

보고 읽은 뒤 답하기Respond after watching/reading 해 한 개를 찾으면 최적이라고 말할 수 있나요?Does one feasible witness establish optimality?

생각을 점검하는 해설Check your reasoning

제약을 통과했다는 것과 목적 함수의 최솟값이라는 것은 다릅니다. 목적 함수가 없으면 가능성만 말합니다.Feasibility differs from minimizing an objective. Without an objective the computation establishes only compatibility.

Alan Mackworth · 조건을 먼저 표현하기Alan Mackworth · represent conditions first

University of British Columbia · official profile

공식 소개의 제약 기반 계산 지능을 읽고, 해를 찾기 전에 조건을 표현하는 이유를 우리 원행 표로 설명하세요.Read the profile’s constraint-based computational intelligence description and explain why conditions precede search in our source-row tasks.

공식 자료 읽기 ↗Read official resource ↗

보고 읽은 뒤 답하기Respond after watching/reading 정확한 해 수는 원 자료의 사실성도 증명하나요?Does an exact count also prove the source observations true?

생각을 점검하는 해설Check your reasoning

정확한 열거는 선언한 입력·조건에 대한 결과입니다. 관측의 출처와 측정은 별도로 대조합니다.Enumeration is conditional on supplied inputs and constraints. Source and measurement claims need separate checks.

지원값과 GAC의 할 일 목록Supports and the GAC worklist

Poole and Mackworth · Artificial Intelligence: Foundations of Computational Agents · 3e §4.3

지원값 정의와 영역 삭제 뒤 할 일 목록을 다시 채우는 이유를 읽으세요. 영역이 비어 있지 않은 세 번째 종료 경우를 두 색 삼각형으로 확인하세요.Read the support definition and why deletions requeue affected checks. Use the two-color triangle to examine the nonempty-domain termination case.

공식 자료 읽기 ↗Read official resource ↗

보고 읽은 뒤 답하기Respond after watching/reading 모든 값에 제약별 지원이 있으면 해가 있나요?Do per-constraint supports guarantee a solution?

생각을 점검하는 해설Check your reasoning

서로 다른 제약의 지원이 함께 양립하지 않을 수 있습니다. 삼각형은 모든 값이 지원되지만 해가 없습니다.Supports from different constraints may not coexist. The triangle retains supports yet has no solution.

명제·모형·논리적 귀결Propositions, models and entailment

Harvard CS50 AI · Knowledge notes

접속사·함의·모형 검사 설명을 읽고 K={P,P→Q}의 모든 행을 직접 적으세요. 양립 모형이 없을 때의 공허한 귀결은 이 장의 별도 고전 논리 정의와 연결합니다.Read connectives, implication and model checking, then enumerate K={P,P→Q}. Connect the no-model vacuity case to this chapter’s explicitly stated classical definition.

공식 자료 읽기 ↗Read official resource ↗

보고 읽은 뒤 답하기Respond after watching/reading P→Q와 Q만으로 P가 따라오나요?Does P follow from P→Q and Q alone?

생각을 점검하는 해설Check your reasoning

P가 거짓이고 Q가 참인 반모형이 남습니다. 관측 Q만으로 함의의 방향을 뒤집지 않습니다.The countermodel P=false,Q=true remains. Observing Q does not reverse the implication.

연습문제 · 계산에서 설명과 증명까지Exercises: calculation, explanation and proof

먼저 혼자 풀고 풀이를 여세요. 숫자와 함께 단위·포함 기준·계산 이유를 확인하세요.Attempt each problem before opening its solution. Check units, inclusion rules and the reason for the calculation.

1. 두 이웃 제약의 해를 센다Count solutions of two neighboring constraints

A,B,C의 영역은 모두 {1,2}이고 A≠B, B≠C를 만족해야 합니다. 전체 배정 수와 모든 해를 구하세요.

A,B,C each have domain {1,2}, with A≠B and B≠C. Find the unrestricted assignment count and list all solutions.

풀이와 확인할 이유Solution and explanation

제약 전에는 2³=8행입니다. B=1이면 A=C=2여야 하므로 (2,1,2), B=2이면 A=C=1이므로 (1,2,1)입니다. 따라서 해는 두 개입니다. A와 C가 달라야 한다는 조건은 주어지지 않았습니다.

There are 2³=8 unrestricted rows. If B=1, A=C=2, giving (2,1,2). If B=2, A=C=1, giving (1,2,1). Thus there are two solutions. No condition requires A and C to differ.

2. 부분 배정으로 한 해를 남긴다Restrict the problem with a partial assignment

A,B,C∈{1,2}, A≠B, B≠C에서 A=1을 고정합니다. 모든 완성 해를 구하고, A=1 고정이 원래 문제와 어떻게 다른지 설명하세요.

For A,B,C∈{1,2}, A≠B and B≠C, fix A=1. Find every completing solution and explain how the fixed assignment changes the original task.

풀이와 확인할 이유Solution and explanation

A≠B 때문에 B=2이고 B≠C 때문에 C=1입니다. 유일한 완성은 (1,2,1)입니다. 원래 문제의 해 중 A=1을 만족하는 부분만 묻는 것이므로, A=2인 원래 해가 틀렸다고 판정한 것은 아닙니다.

A≠B forces B=2, then B≠C forces C=1. The only completion is (1,2,1). We restricted attention to original solutions with A=1; this does not make the original A=2 solution incorrect.

3. 두 색 삼각형의 불가능성을 보인다Prove the two-color triangle impossible

A,B,C의 영역은 {1,2}이고 A≠B, B≠C, A≠C를 모두 요구합니다. A=1과 A=2 두 경우로 나누어 해가 없음을 보이세요.

A,B,C each have domain {1,2}, with A≠B, B≠C and A≠C. Split into cases A=1 and A=2 to prove there is no solution.

풀이와 확인할 이유Solution and explanation

A=1이면 B=2와 C=2가 필요해 B≠C를 어깁니다. A=2이면 B=1과 C=1이 필요해 같은 제약을 어깁니다. A의 모든 값을 검사했으므로 완성 해는 0개입니다.

If A=1, the constraints with A require B=C=2, violating B≠C. If A=2 they require B=C=1, again violating B≠C. These exhaust A’s domain, so there are zero solutions.

4. 단항 제약을 영역에 반영한다Incorporate a unary constraint

변수 A의 원래 영역은 {1,2,3}이고 제약은 A≠2입니다. 줄어든 영역과 해 수를 구하세요. 이어 A=2를 부분 배정으로 강제하면 어떻습니까?

A originally has domain {1,2,3} and constraint A≠2. Find the reduced domain and solution count. What if the partial assignment forces A=2?

풀이와 확인할 이유Solution and explanation

줄어든 영역은 {1,3}이며 한 변수 해는 A=1, A=3 두 개입니다. A=2를 강제하면 원래 영역 안의 입력이기는 하지만 제약을 어겨 완성 해는 0개입니다. 영역 밖 입력의 형식 오류와 영역 안 값의 제약 위반은 다릅니다.

The reduced domain is {1,3}, yielding two solutions, A=1 and A=3. Forcing A=2 is a well-formed value from the original domain but violates the constraint, so it has zero completions. A constraint conflict differs from an out-of-domain input error.

5. 비어 있는 칸과 충돌을 구별한다Distinguish unassigned cells from conflicts

A,B,C∈{1,2}, A≠B, B≠C입니다. 부분 배정 (i) A=1,C=1과 (ii) A=1,B=1이 각각 완성 가능한지, 가능하면 증거 행을 적으세요.

Let A,B,C∈{1,2}, A≠B and B≠C. Can partial assignments (i) A=1,C=1 and (ii) A=1,B=1 be completed? Give a witness when possible.

풀이와 확인할 이유Solution and explanation

(i)는 B=2로 완성하여 (1,2,1)이 됩니다. (ii)는 A≠B를 이미 어겼으므로 C를 무엇으로 채워도 실패합니다. 미배정 변수가 남았다는 이유만으로 두 경우를 모두 미확인 상태로 두어서는 안 됩니다.

(i) extends with B=2 to (1,2,1). In (ii), A≠B is already violated, so no C can repair it. The presence of an unassigned variable does not prevent recognizing a conflict that is already fixed.

6. 방향 있는 관계표를 쓴다Write an ordered relation table

A와 B의 영역은 {1,2,3}입니다. 범위 [A,B]에서 A<B의 허용 행을 모두 쓰세요. 같은 행들을 범위 [B,A]로 읽으면 원래 조건과 같습니까?

A and B have domain {1,2,3}. List the allowed rows for A<B under scope [A,B]. Does reading the same rows under scope [B,A] preserve the original condition?

풀이와 확인할 이유Solution and explanation

허용 행은 [1,2],[1,3],[2,3]입니다. 범위를 [B,A]로만 바꾸면 이들은 B<A를 뜻하므로 원래와 다릅니다. 원래 관계를 새 범위로 쓰려면 각 행의 두 좌표도 바꾸어 [2,1],[3,1],[3,2]로 써야 합니다.

Allowed rows are [1,2],[1,3],[2,3]. Under scope [B,A] those unchanged rows mean B<A. To preserve the original relation under the new scope, reverse each row too: [2,1],[3,1],[3,2].

7. 빈 문제와 빈 영역을 센다Count an empty problem and an empty domain

각 문제의 해 수를 구하세요. (i) 변수도 제약도 없음, (ii) 변수 A 하나의 영역이 공집합이고 제약 없음. 빈 곱의 뜻과 연결하세요.

Find solution counts for (i) no variables and no constraints, and (ii) one variable A with an empty domain and no constraints. Relate the answers to an empty product.

풀이와 확인할 이유Solution and explanation

(i)는 빈 배정 한 개가 있으므로 1개입니다. 곱할 영역 크기가 없는 빈 곱을 1로 둡니다. (ii)는 A에 쓸 값을 고를 수 없어 0개이고, 영역 크기 0을 가진 곱도 0입니다.

(i) has one empty assignment, corresponding to the empty product one. In (ii), no value can be chosen for A, so there are zero assignments; the product contains a zero domain size.

8. 0항 관계의 참과 거짓True and false nullary relations

변수가 없는 CSP에 범위 []인 제약 하나를 넣습니다. 허용 튜플 목록이 (i) [[]], (ii) []인 경우 해 수를 각각 구하세요.

A CSP has no variables and one constraint of scope []. Find solution counts when its allowed tuple list is (i) [[]] and (ii) [].

풀이와 확인할 이유Solution and explanation

범위가 없을 때 가능한 튜플은 빈 튜플 한 개입니다. (i)는 그 빈 튜플을 허용하므로 빈 배정이 통과해 해 1개입니다. (ii)는 빈 튜플조차 허용하지 않는 거짓 제약이므로 해 0개입니다.

A nullary scope has one possible tuple, the empty tuple. List (i) allows it, so the empty assignment passes and the count is one. List (ii) allows no tuple and is an always-false constraint, giving zero solutions.

9. 지원 없는 끝값을 지운다Delete unsupported boundary values

D_A=D_B={1,2,3,4}이고 A<B입니다. A=4와 B=1의 지원을 검사하고, 이 제약 하나의 GAC 고정점 영역을 구하세요.

D_A=D_B={1,2,3,4} and A<B. Check supports for A=4 and B=1, then find the GAC fixed-point domains for this single relation.

풀이와 확인할 이유Solution and explanation

A=4보다 큰 B도, B=1보다 작은 A도 없습니다. 두 값은 삭제됩니다. 남은 A={1,2,3}의 각 값은 더 큰 B에, B={2,3,4}의 각 값은 더 작은 A에 지원되므로 이것이 고정점입니다.

No B is larger than A=4, and no A is smaller than B=1, so remove both. Every value in A={1,2,3} then has a larger B, and every value in B={2,3,4} has a smaller A. These are fixed-point domains.

10. 전파 뒤 해를 직접 열거한다Enumerate solutions after propagation

A,B,C의 초기 영역은 {1,2,3,4}이고 A<B, B<C입니다. GAC 고정점 영역과 모든 완성 해를 구하세요.

A,B,C initially have domain {1,2,3,4}, with A<B and B<C. Find GAC fixed-point domains and list all complete solutions.

풀이와 확인할 이유Solution and explanation

A={1,2}, B={2,3}, C={3,4}가 남습니다. B=2이면 A=1이고 C=3 또는 4입니다. B=3이면 C=4이고 A=1 또는 2입니다. 해는 (1,2,3),(1,2,4),(1,3,4),(2,3,4) 네 개입니다.

Domains become A={1,2}, B={2,3}, C={3,4}. B=2 requires A=1 and C=3 or 4; B=3 requires C=4 and A=1 or 2. The four solutions are (1,2,3),(1,2,4),(1,3,4),(2,3,4).

11. 영역 크기의 곱은 해 수가 아니다Domain products do not count constrained solutions

A={1,2}, B={2,3}, C={3,4}, A<B, B<C에서 영역 크기의 곱은 8입니다. 이것이 정확한 해 수가 아닌 이유를 반례 행과 실제 해 수로 설명하세요.

For A={1,2}, B={2,3}, C={3,4}, A<B and B<C, the product of domain sizes is eight. Explain why this is not the exact solution count, using a failing row and the actual count.

풀이와 확인할 이유Solution and explanation

영역 안의 행 (2,2,3)은 A<B를 어깁니다. 모든 영역 조합을 검사하면 통과하는 것은 (1,2,3),(1,2,4),(1,3,4),(2,3,4) 네 개뿐입니다. 8은 제약 검사 전 후보 수의 상계입니다.

Row (2,2,3) uses domain values but violates A<B. Only (1,2,3),(1,2,4),(1,3,4),(2,3,4) pass all constraints. Eight counts candidate combinations before checking constraints and is an upper bound.

12. 삭제 보존을 한 단계 증명한다Prove one-step pruning preservation

유한 CSP의 현재 영역 안에 완전한 해 s가 있습니다. 제약 c에서 변수 i의 값 v는 다른 현재 변수 값과 어떤 허용 튜플도 만들 수 없어 삭제됩니다. v=s_i일 수 없는 이유를 증명하세요.

A complete solution s lies in the current domains of a finite CSP. Value v of variable i is deleted because it has no allowed tuple with current values in constraint c. Prove that v cannot equal s_i.

풀이와 확인할 이유Solution and explanation

v=s_i라고 가정하면 해 s의 나머지 범위 변수 값들이 모두 현재 영역에 있고 c를 만족합니다. 이 값들이 v의 지원 튜플이 되어 지원이 없다는 전제와 모순입니다. 따라서 s_i는 삭제되지 않습니다. 이를 삭제 횟수에 대해 반복하면 모든 해 보존이 나옵니다.

If v=s_i, the other scope values from solution s are in their current domains and jointly satisfy c. They form a support tuple for v, contradicting its lack of support. Thus s_i is retained; induction over deletions preserves every solution.

13. 고정점에서 해 없음이 가능하다A fixed point can still be unsatisfiable

A,B,C∈{1,2}이고 모든 쌍이 달라야 합니다. 모든 값에 쌍별 지원이 있음을 보이고, 그럼에도 해가 없음을 설명하세요.

A,B,C∈{1,2} and all three pairs must differ. Show that every value has pairwise support, yet no complete solution exists.

풀이와 확인할 이유Solution and explanation

각 쌍의 1은 상대 2로, 2는 상대 1로 지원됩니다. 따라서 쌍별 GAC는 아무것도 지우지 않습니다. 그러나 세 변수에 서로 다른 값 세 개가 필요한데 두 값뿐이라 불가능합니다. 지원 존재는 제약별 조건이고 한 공동 완성의 존재보다 약합니다.

In each pair, 1 is supported by 2 and 2 by 1, so pairwise GAC removes nothing. A complete assignment would require three distinct values but only two exist. Per-constraint supports are weaker than one jointly compatible completion.

14. 전역 관계와 쌍별 관계를 비교한다Compare global and pairwise relations

A,B의 영역은 {1,2}, C는 {1,2,3}이며 세 값이 모두 달라야 합니다. 모든 해와 전역 allDifferent GAC 뒤 C 영역을 구하세요. 쌍별 부등식만으로는 C=1이 왜 남습니까?

A,B have domains {1,2}, C has {1,2,3}, and all three values differ. Find all solutions and C’s domain after global allDifferent GAC. Why can C=1 survive separate pairwise inequalities?

풀이와 확인할 이유Solution and explanation

A,B가 1과 2를 하나씩 쓰므로 C=3이고 해는 (1,2,3),(2,1,3)입니다. 전역 관계는 C를 {3}으로 줄입니다. 쌍별 표현에서 C=1은 A=2와 B=2로 각각 지원되지만 두 지원은 A≠B를 함께 지키지 못합니다.

A,B use 1 and 2 in some order, forcing C=3; solutions are (1,2,3),(2,1,3). The global relation reduces C to {3}. Separately, C=1 has support A=2 and support B=2, but those partners cannot jointly satisfy A≠B.

15. forward의 직접 배정 규약Forward checking from explicit assignments

A,B,C∈{1,2}, A≠B, B≠C에서 A=1만 직접 배정했습니다. forward는 미배정 변수가 하나 이하인 제약만 검사하고, 단일 영역을 자동 배정하지 않습니다. forward와 GAC 뒤 B,C 영역을 비교하세요.

For A,B,C∈{1,2}, A≠B and B≠C, only A=1 is explicitly assigned. Forward checking inspects constraints with at most one unassigned variable and does not auto-assign singleton domains. Compare final B,C domains under forward and GAC.

풀이와 확인할 이유Solution and explanation

forward는 A≠B에서 B={2}로 줄이지만 B≠C에는 직접 미배정 변수가 둘이므로 C={1,2}를 남깁니다. GAC는 B의 단일 영역도 전달하여 C={1}로 줄입니다. 같은 원래 해를 보존하면서 중간 후보가 달라집니다.

Forward reduces B to {2} via A≠B, but B≠C still has two explicitly unassigned variables, leaving C={1,2}. GAC propagates B’s singleton domain and gives C={1}. Both preserve the same original completing solutions.

16. 삭제 횟수의 유한 상계Bound the number of actual deletions

세 변수의 초기 영역 크기가 각각 4이고 전파는 값을 추가하지 않습니다. 실제 값 삭제 횟수의 단순 상계를 구하세요. 최종 영역 크기가 각각 2이면 실제 삭제는 몇 번입니까?

Three variables initially have four values each, and propagation never adds values. Give a simple bound on the number of value deletions. How many values were deleted if each final domain has size two?

풀이와 확인할 이유Solution and explanation

처음 총 값 수는 12이고 삭제마다 1 줄어 음수가 될 수 없으므로 삭제는 최대 12번입니다. 마지막 총 값 수가 6이면 실제 삭제 수는 12−6=6입니다. 제약 재검사는 삭제 없이도 일어날 수 있으므로 검사 횟수와 이 수를 같다고 두지 않습니다.

The initial total is 12 and each deletion lowers this nonnegative integer by one, so at most 12 values can be deleted. A final total of six means exactly 12−6=6 deletions. Constraint checks may make no deletion, so their count differs.

17. 계산 한도 전에 결론을 만들지 않는다Avoid conclusions before a support check completes

A,B의 영역 {1,2,3,4}, 제약 A<B에서 GAC의 관계표 검사 한도를 0으로 둡니다. 엔진이 아무 관계 행도 읽기 전에 멈췄다면 원래 영역을 그대로 남기는 것이 왜 안전하며, 고정점이나 해 없음을 말할 수 없는 이유는 무엇입니까?

For A,B∈{1,2,3,4} with A<B, set the GAC relation-work cap to zero. It stops before reading any relation row. Why is retaining the original domains safe, and why does this establish neither a fixed point nor unsatisfiability?

풀이와 확인할 이유Solution and explanation

삭제를 하지 않으면 원래 해를 잃지 않습니다. 그러나 A=4와 B=1의 지원 없음도 아직 검사하지 않았으므로 영역은 고정점이 아닙니다. 실제로 (1,2) 같은 해가 있으므로 미검사를 실패로 바꿔서는 안 됩니다. 결과는 작업 한도 중단입니다.

Keeping all candidates preserves every original solution. Unsupported values A=4 and B=1 have not yet been checked, so the domains are not established as a fixed point. Solutions such as (1,2) exist; lack of computation must not become failure. The result is a work-limit cutoff.

18. 되돌아가기 노드 수를 센다Count backtracking nodes

A,B,C∈{1,2}, A≠B, B≠C를 A,B,C 및 값 1,2 순서로 풉니다. 뿌리도 노드 하나로 세고, 완전히 배정된 제약을 어긴 노드에서 즉시 멈춥니다. 전파가 없을 때 방문 노드 수와 해 수를 구하세요.

Solve A,B,C∈{1,2}, A≠B and B≠C in order A,B,C and value order 1,2. Count the root as a node and stop a branch when a fully assigned constraint fails. With no propagation, find visited nodes and solution count.

풀이와 확인할 이유Solution and explanation

뿌리 1개, A 선택 2개, B 선택 4개입니다. B에서 두 가지가 충돌해 멈추고, 남은 두 가지에서 C를 각각 둘씩 시도하여 4개 노드를 더 방문합니다. 총 1+2+4+4=11노드이며 그중 완전 해는 두 개입니다.

There is one root, two A nodes and four B nodes. Two B branches conflict; each remaining branch tries both C values, adding four nodes. Total nodes are 1+2+4+4=11, with two complete solutions.

19. MRV의 선택과 동률을 정한다Specify MRV choices and ties

미배정 변수 A,B,C의 현재 영역은 각각 {1,2,3},{1},{1,2}입니다. MRV가 먼저 고를 변수는 무엇입니까? B를 배정한 뒤 A,C의 후보 수가 모두 2이고 선언 순서가 A,B,C라면 다음 변수는 무엇입니까?

Unassigned A,B,C currently have domains {1,2,3},{1},{1,2}. Which variable does MRV select first? After assigning B, if A and C both have two candidates and declared order is A,B,C, which is next?

풀이와 확인할 이유Solution and explanation

처음은 후보 수가 1인 B입니다. 다음에는 A,C가 동률이므로 선언 순서의 앞인 A를 고릅니다. MRV는 현재 미배정 변수의 영역 크기를 사용하며 이미 정한 B는 다시 고르지 않습니다.

First select B, whose current domain has size one. After B is assigned, A and C tie, so declared order selects A. MRV compares current domains of unassigned variables and does not choose B again.

20. 저장 한도는 전체 수를 바꾸지 않는다A witness-storage cap does not change the total

A,B,C∈{1,2}, A≠B, B≠C의 완전 탐색에서 해를 한 행만 저장하도록 했습니다. 저장 행이 (1,2,1)일 때 정확한 전체 해 수는 무엇이며, 왜 “해 한 개”라는 보고는 틀립니까?

Complete enumeration of A,B,C∈{1,2}, A≠B and B≠C stores at most one witness, namely (1,2,1). What is the exact total, and why is reporting “one solution” wrong?

풀이와 확인할 이유Solution and explanation

다른 해 (2,1,2)도 있으므로 전체 수는 2입니다. 완료된 탐색은 두 해를 세되 저장 목록만 한 행으로 제한했습니다. 정확한 수 2, 저장한 수 1, 저장 목록 잘림을 각각 보고해야 합니다.

The other solution is (2,1,2), so the exact count is two. The complete search counted both while limiting only the stored list. Report total two, stored one and a truncated witness list separately.

21. 노드 한도와 찾은 수Node limits and counts found so far

제약 없는 A,B,C가 각각 {0,1}을 씁니다. 변수 A,B,C와 값 0,1 순서의 깊이 우선 탐색에서 빈 뿌리도 1노드로 셉니다. 전체 노드·해 수와 노드 한도 7에서 찾은 해 수를 구하세요.

Unconstrained A,B,C each have domain {0,1}. Search depth-first in variable order A,B,C and value order 0,1, counting the empty root as one node. Find full node/solution counts and solutions found with a node cap of seven.

풀이와 확인할 이유Solution and explanation

전체는 깊이별 1+2+4+8=15노드와 해 8개입니다. 처음 7노드는 빈 뿌리, A=0, B=0, C=0, C=1, B=1, C=0 순서입니다. 해는 (0,0,0),(0,0,1),(0,1,0) 세 개를 찾고 중단됩니다. 3은 전체 수가 아니라 하계입니다.

The full tree has 15 nodes and eight solutions. The first seven visits are root, A=0, B=0, C=0, C=1, B=1, C=0. Thus three solutions are found before cutoff: (0,0,0),(0,0,1),(0,1,0). Three is a lower bound, not the completed total.

22. 영역 크기의 곱과 계산 규모Domain products and computation size

제약 검사 전 각 변수가 3개 값을 가진 변수 7개의 전체 배정 수와, 각 배정을 7셀 관계표 행으로 저장할 때 셀 수를 구하세요. 제약이 하나면 입력이 항상 작은가요?

Seven variables each have three values. Find unrestricted assignment count and the cells needed to store every assignment as a seven-cell relation row. Does one constraint always mean a small input?

풀이와 확인할 이유Solution and explanation

배정은 3⁷=2,187개이고 셀은 2,187×7=15,309개입니다. 제약 하나라도 그 허용 행 전체를 명시하면 큰 표가 될 수 있습니다. 제약 수와 제약 표현의 길이는 다른 입력 규모입니다.

There are 3⁷=2,187 assignments and 15,309 stored cells. A single constraint can still require a long explicit table. The number of constraints differs from the size of their representations.

23. 답 하나를 원 조건에 대입한다Verify a witness against original conditions

A,B,C∈{1,2}, A≠B, B≠C입니다. 프로그램이 (A,B,C)=(1,2,1)을 반환했습니다. 알고리즘을 다시 실행하지 않고 해임을 확인하세요. 이 확인만으로 해가 정확히 하나임도 알 수 있나요?

For A,B,C∈{1,2}, A≠B and B≠C, a program returns (1,2,1). Verify it without rerunning search. Does this establish that exactly one solution exists?

풀이와 확인할 이유Solution and explanation

세 값이 각 영역 안에 있고 1≠2와 2≠1이므로 두 제약을 통과합니다. 따라서 해 하나의 존재는 확인됩니다. 다른 해 (2,1,2)도 있으므로 이 대입 확인은 전체 수나 유일성을 증명하지 않습니다.

All values belong to their domains and both inequalities pass, verifying one witness. It does not prove uniqueness: (2,1,2) is another solution. Existence and exhaustive counting require different evidence.

24. 다시 이름 붙여도 해 수는 같다Renaming preserves the count

A,B,C∈{1,2}, A≠B, B≠C에서 이름을 일대일로 A→X,B→Y,C→Z로 바꾸고 모든 범위도 함께 바꿉니다. 해 수가 보존되는 이유와 원 해 (1,2,1)의 대응을 쓰세요.

Rename A→X,B→Y,C→Z bijectively in A,B,C∈{1,2}, A≠B, B≠C, including every constraint scope. Explain count preservation and map original solution (1,2,1).

풀이와 확인할 이유Solution and explanation

각 원 배정의 값을 대응하는 새 이름에 그대로 옮기면 역변환도 유일합니다. 제약의 비교 값이 같으므로 통과 여부도 같습니다. 해 집합 사이 일대일 대응이 있어 수는 2로 보존되고 대응 해는 X=1,Y=2,Z=1입니다.

Copy each value to the corresponding new name. The mapping has a unique inverse and preserves every constraint’s values, so it bijects solution sets. The count remains two, and the witness becomes X=1,Y=2,Z=1.

25. 조건을 추가하면 무엇이 바뀌는가What changes when a constraint is added?

A,B,C∈{1,2}, A≠B, B≠C의 해 두 개에 조건 A=1을 더합니다. 남는 해를 구하고, 같은 변수·영역에서 제약 추가가 해를 늘릴 수 없는 이유를 보이세요.

The problem A,B,C∈{1,2}, A≠B, B≠C has two solutions. Add A=1, find those retained, and prove that adding a constraint with unchanged variables/domains cannot increase the solution set.

풀이와 확인할 이유Solution and explanation

원 해 (1,2,1),(2,1,2) 중 첫 행만 남습니다. 새 문제의 해는 원 제약과 추가 제약을 모두 만족하므로 반드시 원 문제의 해입니다. 따라서 새 해 집합은 원 해 집합의 부분집합입니다. 영역을 넓히는 변경에는 이 논리를 그대로 적용하지 않습니다.

Only (1,2,1) remains. Any new solution satisfies every old constraint as well as the added one, hence was already an old solution. The new set is a subset. Enlarging a domain is a different operation.

26. 부정과 그리고의 표A table for not and and

P,Q가 각각 참 또는 거짓입니다. 네 (P,Q) 배정을 모두 쓰고 ¬P와 P∧Q를 계산하세요.

P,Q are Boolean propositions. List all four valuations and evaluate ¬P and P∧Q.

풀이와 확인할 이유Solution and explanation

(거짓,거짓),(거짓,참),(참,거짓),(참,참) 순서에서 ¬P는 참,참,거짓,거짓이고 P∧Q는 거짓,거짓,거짓,참입니다. 부정은 P 하나를 뒤집고 그리고는 둘 다 참인 마지막 행만 남깁니다.

In order (false, false),(false, true),(true, false),(true, true), ¬P is true, true, false, false, and P∧Q is false, false, false, true. Negation reverses P; conjunction holds only in the final row.

27. 포함 또는와 정확히 하나Inclusive or versus exactly one

두 Boolean 명제 P,Q에 대해 P∨Q와 (P∨Q)∧¬(P∧Q)가 다른 진리값을 갖는 행을 찾으세요. 각 식이 참인 행 수는 얼마인가요?

For Boolean P,Q, find the valuation where P∨Q and (P∨Q)∧¬(P∧Q) differ. How many valuations satisfy each formula?

풀이와 확인할 이유Solution and explanation

P=Q=참인 행에서 포함 또는는 참이지만 정확히 하나 식은 거짓입니다. 포함 또는는 세 행, 정확히 하나는 (참,거짓),(거짓,참) 두 행에서 참입니다.

They differ when both P and Q are true. Inclusive or has three satisfying valuations; exactly-one has the two valuations (true, false) and (false, true).

28. 함의의 역은 따라오지 않는다The converse does not follow

지식은 P→Q와 Q이며 명제 P,Q만 선언합니다. P가 거짓인 양립 모형을 하나 찾고, P와 ¬P 중 어느 것도 함의되지 않음을 보이세요.

Knowledge consists of P→Q and Q, over atoms P,Q. Find a compatible model with P false and show that neither P nor ¬P is entailed.

풀이와 확인할 이유Solution and explanation

(P,Q)=(거짓,참)이 양립하므로 P는 함의되지 않습니다. (참,참)도 양립하므로 ¬P도 함의되지 않습니다. 지식의 모형은 두 개이고 P는 미결정입니다.

(P,Q)=(false, true) is compatible, blocking entailment of P. The compatible model (true, true) blocks entailment of ¬P. There are two models and P is undetermined.

29. 양방향 조건의 모형 수Models of a biconditional

명제 P,Q만 선언하고 지식은 P↔Q 하나입니다. 모든 양립 모형과 모형 수를 구하세요. 이 지식이 P를 함의합니까?

Declare atoms P,Q and knowledge P↔Q. Find all compatible models and their count. Does this knowledge entail P?

풀이와 확인할 이유Solution and explanation

같은 진리값인 (거짓,거짓),(참,참) 두 행이 모형입니다. 첫 행에서 P가 거짓이므로 P를 함의하지 않습니다. 동치는 두 값이 같다는 조건이지 두 값이 모두 참이라는 조건이 아닙니다.

Models are (false, false) and (true, true). The first falsifies P, so P is not entailed. Equivalence requires equal truth values, not that both be true.

30. 사실과 함의에서 결론을 얻는다Derive a conclusion from a fact and implication

명제 P,Q에 대해 지식 K={P,P→Q}입니다. K의 모든 모형을 찾고 K⊨Q를 정의로 확인하세요.

For atoms P,Q, knowledge is K={P,P→Q}. Find all models and verify K⊨Q by definition.

풀이와 확인할 이유Solution and explanation

P가 참이어야 하고 그때 Q도 참이어야 하므로 유일한 모형은 (참,참)입니다. 모든 K 모형에서 Q가 참이므로 K⊨Q입니다. 이 결론은 주어진 명제 의미와 지식을 전제로 합니다.

P must be true, which forces Q true. The only model is (true, true); Q holds in every K model, hence K⊨Q. The conclusion is conditional on the supplied meanings and knowledge.

31. 확률 없이 미결정을 읽는다Read undetermined without inventing probability

명제 P,Q가 있고 지식은 Q 하나입니다. 질문 P의 참 모형과 거짓 모형을 각각 쓰세요. 지식만으로 P의 확률이 1/2라고 결론낼 수 있나요?

Atoms are P,Q and knowledge is Q alone. Give a compatible model with P true and one with P false. Does this alone establish probability 1/2 for P?

풀이와 확인할 이유Solution and explanation

(참,참)과 (거짓,참)이 모두 모형입니다. 따라서 P와 ¬P 중 어느 쪽도 함의되지 않습니다. 모형들에 어떤 확률을 줄지 정하지 않았으므로 모형 두 개라는 이유만으로 확률 1/2를 정할 수 없습니다.

Both (true, true) and (false, true) are models. Neither P nor ¬P is entailed. No distribution over models was supplied, so counting two models does not by itself assign probability one half.

32. 모순된 지식의 고전적 귀결Classical consequence from inconsistent knowledge

명제 P,Q에 대해 K={P,¬P}입니다. 모형 수와 K⊨Q, K⊨¬Q의 참·거짓을 구하고 실제 Q를 관측했다는 주장과 구분하세요.

For atoms P,Q let K={P,¬P}. Find its model count and truth of K⊨Q and K⊨¬Q, distinguishing these from an observation of Q.

풀이와 확인할 이유Solution and explanation

모형은 0개입니다. 고전적 정의상 반모형을 줄 K 모형이 없어서 두 함의가 모두 참입니다. 이는 입력 지식의 모순과 공허한 함의이지 현실에서 Q와 ¬Q가 확인되었다는 뜻이 아닙니다.

There are zero models. Both entailments hold classically because no K model can counter either. This is vacuity from inconsistent inputs, not empirical confirmation of Q and ¬Q.

33. 빈 지식에서 항상 참인 식A tautology from empty knowledge

명제 P 하나를 선언하고 지식 목록은 비웁니다. 모형 수와 질문 P∨¬P의 함의 여부를 구하세요. 질문 P 자체는 어떻습니까?

Declare one atom P and an empty knowledge list. Find model count and whether P∨¬P is entailed. What about P itself?

풀이와 확인할 이유Solution and explanation

P가 거짓인 행과 참인 행 두 개가 모두 모형입니다. P∨¬P는 두 행에서 모두 참이므로 함의됩니다. P는 거짓인 모형이 있어 함의되지 않습니다.

Both false and true assignments to P are models. P∨¬P holds in both and is entailed. P itself is false in one compatible model and is not entailed.

34. 원자가 없는 논리 계산Logic with no atoms

명제 원자가 하나도 없고 지식 목록도 없습니다. 진리값 배정 수와 빈 그리고·빈 또는의 진리값을 이 장의 규약으로 구하세요.

There are no atoms and the knowledge list is empty. Under this chapter’s conventions, give valuation count and truth of empty and and empty or.

풀이와 확인할 이유Solution and explanation

아무 원자에도 값을 쓰지 않은 빈 배정이 한 개 있습니다. 빈 그리고는 참, 빈 또는는 거짓입니다. 이들을 질문으로 쓰면 각각 함의와 부정 함의가 따르며, 빈 지식 자체가 모순인 것은 아닙니다.

There is one empty valuation. Empty conjunction is true; empty disjunction is false. As queries they are respectively entailed and refuted. The empty knowledge list is consistent.

35. 값 셋에서 정확히 하나를 고른다Choose exactly one of three values

한 CSP 변수 A의 영역이 {1,2,3}입니다. Boolean 원자 x₁,x₂,x₃를 각 값의 선택으로 해석합니다. 정확히 하나 조건을 쓰고, 조건 전과 후의 모형 수를 구하세요.

A CSP variable A has domain {1,2,3}; Boolean atoms x₁,x₂,x₃ indicate its chosen value. Write exactly-one conditions and count valuations before and after imposing them.

풀이와 확인할 이유Solution and explanation

적어도 하나 x₁∨x₂∨x₃와 각 쌍의 동시 선택 금지 ¬x₁∨¬x₂, ¬x₁∨¬x₃, ¬x₂∨¬x₃를 넣습니다. 원래 2³=8배정에서 정확히 한 원자만 참인 세 배정이 남아 CSP의 세 값과 대응합니다.

Require x₁∨x₂∨x₃ and pairwise exclusions ¬x₁∨¬x₂, ¬x₁∨¬x₃, ¬x₂∨¬x₃. Of eight original valuations, three with exactly one true atom remain, corresponding to A’s three values.

36. 이진 CSP와 Boolean 모형의 대응A binary CSP and its Boolean models

A,B∈{1,2}, A≠B를 값 선택 원자 a₁,a₂,b₁,b₂로 나타냅니다. 각 변수의 정확히 하나 조건에 어떤 절을 더해야 하며, 최종 모형 수는 얼마인가요?

Encode A,B∈{1,2}, A≠B using atoms a₁,a₂,b₁,b₂. Beyond exactly-one conditions for each variable, which clauses are needed, and how many models remain?

풀이와 확인할 이유Solution and explanation

A=B=1을 금지하는 ¬a₁∨¬b₁와 A=B=2를 금지하는 ¬a₂∨¬b₂를 더합니다. 모형은 A=1,B=2와 A=2,B=1에 대응하는 두 개입니다. 정확히 하나 조건이 없으면 둘 다 값을 선택하지 않은 거짓 양성 모형이 남을 수 있습니다.

Add ¬a₁∨¬b₁ and ¬a₂∨¬b₂ to forbid equal values. Two models remain, corresponding to A=1,B=2 and A=2,B=1. Without exactly-one constraints, valuations choosing no value can wrongly survive.

37. 두 규칙을 따라 전방으로 간다Follow two forward rules

양의 원자는 B,E,A,L, 사실은 B,E, 규칙은 r₁:B∧E→A와 r₂:A→L입니다. 전방 연쇄의 최종 집합과 A,L의 증명 근거를 쓰세요.

Positive atoms are B,E,A,L; facts are B,E; rules are r₁:B∧E→A and r₂:A→L. Give the final closure and proof justifications for A,L.

풀이와 확인할 이유Solution and explanation

처음 {B,E}에서 r₁으로 A를 더하고 r₂로 L을 더하여 {B,E,A,L}입니다. A의 근거는 사실 B,E와 r₁, L의 근거는 이미 도출한 A와 r₂입니다. 규칙을 거꾸로 나열해도 끝까지 반복하면 같은 집합입니다.

Start from {B,E}, add A via r₁ and L via r₂, reaching {B,E,A,L}. A is justified by facts B,E and r₁; L by derived A and r₂. Reversed rule order yields the same closure after all passes.

38. 순환에 첫 사실이 없을 때A cycle without an initial fact

양의 원자 P,Q와 규칙 P→Q,Q→P만 있고 사실은 없습니다. 닫힘을 구하세요. 이어 사실 P를 추가하면 무엇이 바뀝니까?

Positive atoms P,Q have rules P→Q,Q→P and no facts. Find the closure, then add fact P and recompute.

풀이와 확인할 이유Solution and explanation

처음에는 어느 규칙의 전제도 없어 닫힘은 공집합입니다. 사실 P가 생기면 P→Q로 Q를 더해 {P,Q}가 됩니다. 순환 관계만으로 초기 근거를 만들어 내지 않습니다.

Without facts, neither premise is established and closure is empty. With P supplied, derive Q and obtain {P,Q}. A cycle alone does not generate a seed fact.

39. 최소 모형과 원자 귀결Least model and atomic entailment

유한 양의 ground Horn 규칙과 사실의 닫힘을 S*라고 합니다. S*가 그 지식의 모든 모형에 포함되고 스스로 모형이라고 가정해, 원자 q가 모든 모형에서 참일 필요충분조건이 q∈S*임을 증명하세요.

Let S* be the closure of finite positive ground Horn rules and facts. Given that S* is a model contained in every model, prove an atom q is true in every model exactly when q∈S*.

풀이와 확인할 이유Solution and explanation

q∈S*이면 모든 모형이 S*를 포함하므로 q를 포함합니다. q∉S*이면 S* 자체가 q를 포함하지 않는 모형이어서 “모든 모형에서 참”을 막는 반모형입니다. 이는 이 양의 ground Horn 언어의 원자 질문에 대한 결론입니다.

Membership in S* places q in every model. If q∉S*, the model S* itself is a countermodel to universal truth of q. This result concerns atomic queries in the stated positive ground Horn language.

40. 미확인과 닫힌 세계의 거짓 취급Unknown versus closed-world false-by-convention

양의 원자 B,E,A, 사실 B, 규칙 B∧E→A만 있습니다. E,A의 도출 여부와 열린 세계 표시를 구하세요. 닫힌 세계 옵션을 선택하면 무엇이 추가로 바뀌나요?

Positive atoms are B,E,A, fact B and rule B∧E→A. Determine derivability and open-world labels for E,A. What changes if the closed-world option is chosen?

풀이와 확인할 이유Solution and explanation

E가 없어 A도 도출되지 않습니다. 열린 세계에서 둘 다 미확인입니다. 닫힌 세계는 도출되지 않은 둘을 규약상 거짓으로 취급하지만 새 관측이나 원래 양의 지식에서의 고전적 부정 귀결이 생긴 것은 아닙니다.

Neither E nor A is derived, so both are unknown under open world. Closed world additionally treats nonderived atoms as false by convention. It adds no observed negative evidence or classical negative entailment from the original positive knowledge.

41. Horn 추가 횟수의 유한 상계A finite bound on Horn additions

선언한 원자가 6개이고 처음 사실은 서로 다른 원자 2개입니다. 양의 ground Horn 전방 연쇄는 새 원자를 한 번씩만 추가합니다. 성공적인 새 원자 추가 횟수의 상계와, 순환 규칙이 있어도 종료하는 이유를 설명하세요.

There are six declared atoms and two distinct initial facts. Positive ground Horn forward chaining adds each new atom only once. Bound successful additions and explain termination even with cycles.

풀이와 확인할 이유Solution and explanation

아직 없는 원자가 4개이므로 성공적인 추가는 최대 4번입니다. 한 번의 규칙 훑기가 유한하고 새 추가가 없으면 멈추면 전체도 종료합니다. 규칙 검사 횟수 자체가 4 이하라는 말은 아닙니다. 이미 알려진 결론을 만드는 순환은 새 추가를 일으키지 않습니다.

At most four atoms remain to be added. Each rule pass is finite and a pass with no additions terminates, so the whole computation ends. This does not bound rule checks by four. Cycles with already known conclusions produce no new additions.

42. 양의 지식의 단조성을 증명한다Prove monotonicity of positive knowledge

같은 유한 양의 Horn 규칙 집합에서 사실 F⊆F′입니다. 각 사실 집합에서 전방 연쇄한 닫힘 Cl(F),Cl(F′)에 대해 Cl(F)⊆Cl(F′)를 증명하세요.

Under the same finite positive Horn rules, facts satisfy F⊆F′. Prove Cl(F)⊆Cl(F′) for their forward closures.

풀이와 확인할 이유Solution and explanation

처음 포함 관계가 성립합니다. 작은 집합에서 규칙의 전제가 모두 알려졌다면 큰 집합에도 모두 있으므로 같은 결론을 더할 수 있습니다. 단계별 귀납으로 포함 관계가 유지되고 유한 고정점에서도 성립합니다.

The inclusion holds initially. Every premise known in the smaller set is also known in the larger, so any applicable rule conclusion can be added there too. Induction preserves inclusion through the finite fixed points.

43. 사실 삭제 뒤의 오래된 결론Stale conclusions after deleting a fact

원자는 B,E,A이고 처음 사실 B,E, 규칙 B∧E→A로 A를 도출했습니다. E가 잘못된 사실이라 삭제한 새 입력에서 닫힘을 구하세요. 예전 A를 그대로 두어도 되나요?

Atoms are B,E,A; facts B,E and rule B∧E→A derived A. Delete E as a mistaken fact and compute closure for the revised input. May the old A automatically remain?

풀이와 확인할 이유Solution and explanation

새 사실은 {B}이고 E를 만드는 다른 규칙이 없으므로 닫힘은 {B}입니다. 예전 A는 근거를 잃었으므로 자동 보존하면 안 됩니다. 사실 추가에 대한 단조성 정리를 사실 삭제에 적용하지 않습니다.

The new facts are {B}; no rule supplies E, so closure is {B}. Automatically retaining A would preserve a conclusion whose support was removed. Monotonicity under adding facts does not apply to deleting them.

44. 이름 속 not은 부정 연산이 아니다The letters not are not a negation operator

양의 ground Horn API에서 원자 이름 P와 notP를 선언하고 두 원자를 사실로 넣되 규칙은 없습니다. 이 입력이 고전 명제 지식 {P,¬P}와 같은가요?

In the positive ground Horn API, declare atoms named P and notP, supply both as facts and no rules. Is this the same as classical propositional knowledge {P,¬P}?

풀이와 확인할 이유Solution and explanation

아닙니다. P와 notP는 이 API에서 서로 다른 양의 문자열 원자이고 닫힘은 둘 다 포함합니다. 이름만으로 반대 의미를 부여하지 않습니다. 고전적 모순을 표현하려면 명제 API에서 명시적인 not 연산으로 ¬P를 구성해야 합니다.

No. P and notP are distinct positive string atoms and both enter the closure. A name alone does not impose complementary semantics. Express classical contradiction using the explicit not operator in the propositional API.

45. 유한 대상 규칙을 펼친다Ground a rule over a finite universe

대상은 정확히 민과 준 두 명입니다. 모든 대상 x에 대해 B(x)→A(x)를 가정하고 사실은 B(민)만 있습니다. 두 ground 규칙과 도출 원자를 쓰세요. A(준)이 거짓이라고 결론나나요?

The universe contains exactly Min and Jun. Assume B(x)→A(x) for every declared individual, with sole fact B(Min). Write both ground rules and derived atoms. Is A(Jun) established false?

풀이와 확인할 이유Solution and explanation

규칙은 B(민)→A(민), B(준)→A(준)입니다. 닫힘에는 B(민),A(민)만 들어갑니다. 열린 세계에서는 A(준)은 미확인이지 거짓으로 도출된 것이 아닙니다. 이 유한 목록 밖의 사람에 대한 결론도 내리지 않습니다.

Rules are B(Min)→A(Min) and B(Jun)→A(Jun). Closure contains only B(Min),A(Min). A(Jun) remains unknown under open world, not negatively entailed. No conclusion about individuals outside the declared universe follows.

46. 이진 나무의 지원을 함께 고른다Combine supports on a binary tree

유한한 변수 그래프가 나무이며 간선마다 합쳐진 이진 관계 하나가 있습니다. 단항 제약을 반영한 영역은 모두 비어 있지 않고 양방향 호 일관적이며 다른 제약은 없습니다. 뿌리에 어떤 남은 값을 골라도 완성 해를 만들 수 있음을 설명하세요.

A finite variable graph is a tree, with one combined binary relation per edge. Domains after unary filtering are nonempty and every edge is arc consistent both ways; there are no other constraints. Explain why any retained root value extends to a solution.

풀이와 확인할 이유Solution and explanation

부모 값을 정하면 호 일관성으로 각 자식의 지원값을 하나 고를 수 있습니다. 나무에서는 다른 자식 가지를 잇는 추가 간선이 없어 그 선택들이 충돌하지 않습니다. 아래로 유한하게 반복하면 모든 변수와 간선 조건을 만족합니다.

For each assigned parent value, arc consistency supplies a child support. No extra edge connects separate child branches in a tree, so these choices cannot conflict across branches. Continuing through the finite tree yields a complete solution.

47. 같은 간선의 두 관계를 합쳐야 한다Combine two relations on the same edge

A,B∈{1,2}에 제약 A=B와 A≠B가 따로 있습니다. 단순 변수 그래프는 한 간선으로 된 나무입니다. 각 관계를 따로 호 일관성 검사하면 무엇이 남고, 나무의 해 존재 정리를 바로 적용할 수 없는 이유는 무엇입니까?

A,B∈{1,2} have separate constraints A=B and A≠B. The simple variable graph is a one-edge tree. What survives separate arc-consistency checks, and why does the tree solvability theorem not apply directly?

풀이와 확인할 이유Solution and explanation

각 관계에서 모든 값은 지원되어 두 영역이 그대로 남습니다. 그러나 두 조건을 동시에 만족하는 쌍은 없습니다. 나무 정리의 간선 관계는 같은 쌍의 모든 조건을 합친 관계여야 합니다. 교집합 관계는 공집합이므로 전제가 충족되지 않습니다.

Every value has support in either relation separately, so both domains remain unchanged, yet no pair satisfies both. The tree theorem requires the combined relation per edge. Here that intersection is empty and the theorem’s premises fail.

48. 전파 순서가 달라도 끝 영역이 같은 이유Why fair propagation orders agree

유한한 명시 관계표 CSP에서 GAC는 지원 없는 값만 지우고, 영향을 받은 모든 제약을 공정하게 다시 검사해 모순 없이 고정점에 도달합니다. 임의 GAC 부분 영역의 값은 삭제될 수 없다는 성질을 이용해 두 검사 순서의 최종 영역이 같음을 설명하세요.

In a finite extensional CSP, GAC deletes only unsupported values and fairly revisits every affected constraint, reaching a fixed point without contradiction. Using the fact that no value of any GAC subdomains can be deleted, explain why two completed check orders agree.

풀이와 확인할 이유Solution and explanation

첫 순서의 각 삭제는 어떤 GAC 부분 영역에도 있을 수 없는 값을 지웁니다. 둘째 순서의 최종 영역도 GAC이므로 첫 결과는 둘째 결과를 포함합니다. 순서를 바꾸어 같은 논리를 쓰면 반대 포함도 성립해 두 결과가 같습니다. 한도 중단이나 빠뜨린 검사가 있으면 고정점 전제가 사라집니다.

Every deletion in the first order removes a value absent from any GAC subdomains. The second order’s final domains are GAC, so the first result contains them. Reversing the argument gives the opposite inclusion. Cutoffs or omitted checks invalidate the completed fixed-point premise.

49. 국가 검토 슬롯을 손으로 센다Count the country review slots by hand

실제 GDP 관측에서 선택한 국가 그룹은 H={AUS,CAN,DEU},L={BRA,CHN,IDN}입니다. 세 이름 있는 슬롯 1,2,3에 각 국가를 넣되 각 그룹 안의 세 국가는 서로 다른 슬롯을 쓰고 그룹 사이 추가 제약은 없습니다. 전체 배정 수를 구하세요.

The GDP-based selected groups are H={AUS, CAN, DEU}, L={BRA, CHN, IDN}. Assign each country to named slots 1, 2, 3; within each group all slots differ, with no cross-group constraint. Count complete schedules.

풀이와 확인할 이유Solution and explanation

각 그룹의 배정은 3!=6가지이고 두 선택을 독립적으로 결합하므로 6×6=36가지입니다. 각 슬롯에는 H와 L이 한 곳씩 들어갑니다. 이는 가정 검토 일정의 조합 수이며 실제 국가 배정 기록이나 정책 효과가 아닙니다.

Each group has 3!=6 slot permutations; combine them to obtain 36 schedules. Every slot receives one H and one L country. This counts the authored review task, not observed international allocations or policy effects.

50. 국가 한 곳의 슬롯을 고정한다Fix one country’s slot

H={AUS,CAN,DEU},L={BRA,CHN,IDN}를 세 이름 있는 슬롯에 그룹별 모두 다르게 배정합니다. 다른 제약은 없고 AUS=슬롯1을 추가로 고정합니다. 남는 해 수를 구하세요.

Assign H={AUS, CAN, DEU}, L={BRA, CHN, IDN} to three named slots, with all slots distinct within each group and no other constraints. Fix AUS to slot 1. Count remaining solutions.

풀이와 확인할 이유Solution and explanation

H의 나머지 CAN,DEU는 슬롯2,3에 두 순서로 들어갑니다. L은 여전히 6가지이므로 2×6=12개입니다. AUS를 고정한 선택은 관측 GDP 값을 바꾸는 것이 아니라 허용 일정의 범위를 좁힙니다.

CAN and DEU occupy slots 2, 3 in two orders; L still has six permutations. Thus 12 schedules remain. Fixing AUS restricts the task’s allowed schedules without changing observed GDP.

51. 실제 네 픽셀의 합계 단서Margins of four actual pixels

제공 시험 영상의 실제 부분 픽셀은 [14,5;6,13]입니다. 픽셀≥8을 1, 그 미만을 0으로 바꿉니다. 이진 부분·행 합·열 합을 구하고, 네 합만 공개했을 때 모든 이진 완성을 구하세요.

An actual provided-test image patch is [14,5;6,13]. Map pixel≥8 to 1 and smaller values to 0. Find the binary patch, row/column sums and every binary completion if only those four margins are released.

풀이와 확인할 이유Solution and explanation

이진 부분은 [1,0;0,1]이고 행 합과 열 합은 모두 (1,1)입니다. 합을 만족하는 완성은 [1,0;0,1]과 [0,1;1,0] 두 개입니다. 원 부분은 포함되지만 이 단서만으로 유일하지 않습니다.

The patch becomes [1,0;0,1], with both row and column sums (1,1). Two completions satisfy them: [1,0;0,1] and [0,1;1,0]. The original is feasible but not uniquely determined by these clues.

52. 픽셀 한 칸을 더 공개한다Reveal one additional pixel

네 이진 변수 [a,b;c,d]의 행 합과 열 합은 모두 (1,1)입니다. 추가 단서 a=1을 주면 완성은 몇 개입니까? a=b=1을 동시에 주장하면 어떻습니까?

Binary variables [a,b;c,d] have row sums and column sums both (1,1). How many completions remain after revealing a=1? What if a=b=1 are both asserted?

풀이와 확인할 이유Solution and explanation

a=1이면 첫 행 합에서 b=0, 첫 열 합에서 c=0, 둘째 행 합에서 d=1이므로 한 개입니다. a=b=1이면 첫 행 합이 2가 되어 기존 단서와 모순이고 해가 없습니다. 후자의 추가 주장은 실제 원 관측이라고 주어진 것이 아니라 가정한 모순 예입니다.

a=1 forces b=0, c=0 and d=1, giving one completion. Asserting a=b=1 makes the first row sum two and contradicts its declared margin, leaving zero solutions. The latter is a hypothetical contradictory claim, not an asserted source observation.

53. 이진화의 등호 경계The equality boundary in binarization

실제 영상 부분 [8,13;1,6]에 이진화 규칙을 적용합니다. (i) 픽셀≥8, (ii) 픽셀>8을 1로 표시할 때 두 부분 영상과 전체 1의 수를 구하세요.

Apply binarization to actual patch [8,13;1,6]. Find binary patches and total ones for rules (i) pixel≥8 and (ii) pixel>8.

풀이와 확인할 이유Solution and explanation

(i)는 [1,1;0,0]으로 1이 두 개이고 (ii)는 [0,1;0,0]으로 한 개입니다. 픽셀 8의 경계 포함 여부만 달라집니다. 선택한 규칙을 기록하지 않으면 같은 원 자료에서 다른 제약 단서를 만들 수 있습니다.

(i) gives [1,1;0,0] with two ones; (ii) gives [0,1;0,0] with one. Only the boundary pixel 8 changes. Failing to record the threshold convention can produce different clues from the same original data.

54. 총 용량으로 불가능성을 보인다Use total capacity to prove infeasibility

일곱 구별된 주문 묶음의 수량은 6,6,8,6,6,2,6입니다. 묶음을 쪼개지 않고 세 슬롯에 넣습니다. 각 슬롯 용량이 13이면 왜 불가능합니까? 용량 14일 때 가능한 배정을 하나 쓰세요.

Seven distinct invoice batches have quantities 6, 6, 8, 6, 6, 2, 6, assigned indivisibly to three slots. Why is capacity 13 per slot impossible? Give a feasible allocation at capacity 14.

풀이와 확인할 이유Solution and explanation

수량 합은 40인데 용량 13의 합은 39여서 불가능합니다. 용량 14에서는 원행 (3,1)을 함께 넣어 8+6=14, (6,2,4)를 넣어 2+6+6=14, (5,7)을 넣어 6+6=12로 배정할 수 있습니다.

Total demand is 40 but total capacity is 39. At capacity 14, assign source lines (3, 1) together for 14, lines (6, 2, 4) for 14, and lines (5, 7) for 12. This uses every batch once.

55. 270개 주문 배정의 손계산Count 270 invoice allocations by hand

서로 구별되는 6개짜리 묶음 5개와 8개·2개짜리 묶음 각 1개를 세 이름 있는 슬롯에 쪼개지 않고 넣습니다. 각 용량은 16입니다. 8과 2가 같은 슬롯인 경우와 다른 경우로 나누어 전체 해 수를 구하세요.

Five distinct 6-unit batches and one each of 8 and 2 units must be allocated indivisibly to three named slots, each capacity 16. Count allocations by whether 8 and 2 share a slot.

풀이와 확인할 이유Solution and explanation

같은 슬롯이면 8·2와 함께 6개 묶음 하나가 필요하고 나머지 네 6개 묶음은 둘씩 나뉩니다. 슬롯 3가지×동반 묶음 5가지×남은 네 개 중 이름 있는 한 슬롯의 두 개 선택 6가지로 90입니다. 다른 슬롯이면 8의 슬롯 3가지와 2의 슬롯 2가지, 8에 붙는 6개 묶음 5가지, 남은 분할 6가지로 180입니다. 합은 270입니다.

If 8 and 2 share, they must have one 6-unit companion; the other four 6-unit batches split two per remaining slot. Count 3×5×6=90. If apart, choose the 8 slot in 3 ways, the 2 slot in 2, the 6 companion of 8 in 5, and the remaining two/two split in 6: 180. Total 270.

56. 용량을 늘릴 때 해 집합Solution sets as capacity increases

같은 일곱 양의 수량 묶음과 세 슬롯을 고정합니다. 모든 슬롯에 공통 용량 C를 쓰고 다른 제약은 없습니다. C′≥C이면 용량 C의 모든 해가 C′에서도 해임을 증명하세요. 이것이 실제 배송 효과의 증명인가요?

Keep the same seven positive batches and three slots, with common capacity C and no other constraints. Prove every solution at C remains feasible at C′≥C. Is this evidence of an actual dispatch effect?

풀이와 확인할 이유Solution and explanation

각 슬롯의 같은 수량 합은 C 이하였으므로 더 큰 C′ 이하이기도 합니다. 따라서 해 집합은 포함됩니다. 이는 선택한 용량 부등식의 성질이며 실제 용량 변경이 비용·매출·완료 시간을 바꾼다는 관측 증거가 아닙니다.

Every unchanged slot load was at most C, hence is at most C′. This proves set inclusion for the declared capacity inequality, not an observed effect on dispatch costs, revenue or completion times.

57. 원행 키와 실제 개체Source keys and physical identities

영상 파일의 제공 시험 행 번호와 송장의 원행 번호·계정 토큰을 보존했습니다. 이 키들이 각각 필기 작성자나 고유한 한 사람을 확인한다는 결론이 나오나요? CSP에서 이 키를 쓰는 목적을 설명하세요.

You preserve a provided-test image row number and invoice source-row/account tokens. Do these establish a writer’s identity or one unique person? Explain their role in the CSP tasks.

풀이와 확인할 이유Solution and explanation

아닙니다. 원행 키는 선택한 관측을 다시 찾고 수량·픽셀을 맞추는 데 쓰입니다. 이 자료만으로 작성자 신원이나 계정의 유일한 사람 대응이 주어지지 않습니다. 배정 변수와 관측의 연결은 보존하되 근거 없는 개인 속성을 추가하지 않습니다.

No. These keys locate selected observations and align pixels or quantities. They do not establish writer identity or a unique person behind an account. Preserve the link to observations without adding unsupported personal attributes.

58. 가능한 배정과 가장 좋은 배정A feasible allocation versus the best allocation

실제 주문 수량과 가정 슬롯 용량으로 조건을 통과한 배정 270개를 찾았습니다. 비용·시간·선호 함수는 주어지지 않았습니다. 첫 배정이 가장 싸거나 실제 최적이라고 말할 수 있나요? 필요한 추가 정의는 무엇인가요?

A CSP with actual quantities and assumed slot capacities has 270 feasible allocations. No cost, time or preference function is supplied. May the first be called cheapest or operationally optimal? What further definitions are needed?

풀이와 확인할 이유Solution and explanation

그럴 수 없습니다. 현재 계산은 가능성만 판단합니다. 최적화를 하려면 어떤 비용을 어떤 단위로 각 배정에 붙이는지, 그 비용과 제약이 실제 운영을 어떻게 나타내는지 먼저 정해야 합니다. 해의 순서는 알고리즘의 순서일 뿐 선호 순서가 아닙니다.

No. The computation establishes feasibility only. Optimization requires an objective with units and an account of how it and the constraints represent operations. Search order is not a preference ranking.

59. 안전한 삭제와 미완료 전체 수Safe pruning and an unfinished total

유한 CSP에서 GAC가 지원 없는 값 3개를 정확히 삭제한 뒤 작업 한도에 닿았습니다. 해는 아직 찾지 못했고 모순도 아직 증명하지 못했습니다. 원 해 보존·고정점·해 존재 여부·정확한 전체 수에 대해 각각 무엇을 말할 수 있나요?

GAC correctly deletes three unsupported values in a finite CSP, then hits a work limit before finding a solution; no contradiction has been established. What can be said about preserving original solutions, reaching a fixed point, existence and the exact total?

풀이와 확인할 이유Solution and explanation

완료된 삭제는 원래 해를 보존합니다. 그러나 필요한 검사가 남아 고정점은 확인되지 않았습니다. 증거 해도 없고 완전한 불가능성 증명도 없으므로 존재 여부는 미확인이고, 찾은 수 0은 정확 전체 수가 아닙니다. 중단 이유와 현재까지의 수를 함께 보고합니다.

Completed deletions preserve original solutions. Pending checks prevent a fixed-point claim. Without a witness or completed contradiction proof, existence is unknown; zero found is not the exact total. Report the stop reason and count so far.

60. 관측·가정·추론을 세 문장으로 보고한다Report observations, assumptions and inference separately

세계은행 원 GDP로 국가를 두 그룹에 넣고, 각 그룹의 세 국가를 세 슬롯에 모두 다르게 배정해 해 36개를 얻었습니다. 관측 사실·선택 가정·논리적 결과를 한 문장씩 나누어 쓰세요. Python/R과 JS가 같은 수를 주면 무엇이 추가 확인되나요?

Original World Bank GDP assigns selected countries to two groups; each group’s three countries use three distinct slots, giving 36 solutions. Write separate observation, assumption and inference statements. What does agreement of Python/R and JavaScript additionally check?

풀이와 확인할 이유Solution and explanation

관측은 출처의 연도·단위를 가진 GDP 값과 원행입니다. 가정은 경계와 여섯 국가 선택 및 그룹별 다른 슬롯 규칙입니다. 결과는 그 유한 문제에 해가 36개라는 것입니다. 서로 다른 구현의 일치는 선언한 계산의 재현성을 뒷받침하지만 실제 정책 배정·행동 효과·원자료 진실성을 자동 증명하지 않습니다.

Observations are GDP values with source years, units and row keys. Assumptions are the threshold, six-country selection and within-group distinct-slot rules. The result is 36 solutions of that finite task. Independent implementations support reproducible computation, not observed policy allocation, action effects or automatic data truth.

자료와 출처Data and sources

실습에 추가한 실제 입력과 출처Additional observed lab inputs and provenance

실제 자료 사례Actual-data cases · 원자료·단위·결측·변환·출처Inputs, units, missingness, transformations and sources

자료별 확보일·원행 식별·단위·이용 조건은 출처 기록을 확인하세요. 학습 사본은 제공처의 현재 최신 자료와 다를 수 있습니다.Consult each source record for retrieval dates, row identifiers, units and terms. Teaching copies can differ from current provider releases.

자료사전·출처·이용 조건Data dictionary, sources and terms