Judgment GADT & Layers¶
The Judgment GADT is the proof term of our system — a data structure
that records the full reasoning chain from base rule through all override
layers.
The GADT¶
data Judgment (layers :: [Type]) where
JBase :: Verdict -> ArticleRef -> Text -> Judgment '[l]
JOverride :: Judgment prev -> Verdict -> ArticleRef -> Text
-> Judgment (l ': prev)
JDelegate :: Judgment prev -> Judgment (l ': prev)
Constructors¶
JBase — A base-layer judgment. The bottom of the stack; no further
delegation. Contains the verdict, the statutory reference, and the
reasoning text.
JOverride — An override. This layer consulted the lower layers
(stored in prev) and decided to override their verdict.
JDelegate — A pass-through. This layer had no opinion and delegated
entirely to the lower layers.
Type-Level Guarantees¶
The layers type parameter ensures structural correctness:
JBaseproducesJudgment '[l]— exactly one layerJOverrideandJDelegateproduceJudgment (l ': prev)— adding one layer on top- The
previnJOverride/JDelegatehas typeJudgment prev— the sub-proof
This means:
- Layer count matches. A 3-layer stack produces a
Judgmentwith exactly 3 layers in its type. - No orphan overrides. An override always references the sub-proof it overrides.
- No fabricated delegations. A delegation always carries the delegated-to judgment.
Verdict Extraction¶
verdict :: Judgment layers -> Verdict
verdict (JBase v _ _) = v
verdict (JOverride _ v _ _) = v
verdict (JDelegate prev) = verdict prev
verdict extracts the final verdict — the topmost non-delegated verdict.
It is total (pattern-matches all constructors) — this is verified by
the Agda sketch.
Layer Tokens¶
Layers are uninhabited types used as type-level tags:
Core Tokens (deontic-core)¶
| Token | Korean | Meaning |
|---|---|---|
Base |
원칙 | General rule |
Proviso |
단서 | Proviso/exception |
SpecialRule |
특칙 | Lex specialis |
Domain Tokens (deontic-kr-civil)¶
| Token | Korean | Meaning | Articles |
|---|---|---|---|
Ratification |
추인 | Principal's ratification | §130, §132 |
ApparentAuth |
표현대리 | Apparent authority | §125-129 |
Presumption |
추정 | Rebuttable presumption (default) | §197, §200 |
Rebuttal |
반증 | Rebuttal of presumption | §197, §200 |
Expiration |
시효만료 | Prescription expiration | §162 |
Interruption |
시효중단 | Prescription interruption | §168, §174 |
ContributoryNeg |
과실상계 | Contributory negligence | §763→§396 |
FormException |
등기예외 | Exception to formality | §187 |
ShortPrescription |
단기시효 | Short acquisitive prescription | §245② |
CreditorDefense |
채권자과실 | Creditor's own fault defense | §390 |
BuyerKnowledge |
매수인악의 | Buyer knew of defect | §580② |
RenewalRight |
묵시적갱신 | Implicit lease renewal | §639 |
Step Extraction¶
The Deontic.Render module extracts steps from a judgment:
data Step = Step
{ stepKind :: StepKind -- Applied | Overridden | Delegated
, stepVerdict :: Verdict
, stepArticle :: ArticleRef
, stepSourceText :: Text
}
judgmentSteps :: Judgment layers -> [Step]
This converts the recursive GADT into a flat list of reasoning steps,
bottom-up. JDelegate constructors are omitted from the output (they
carry no independent reasoning).
Example: Full Reasoning Chain¶
For an unauthorized agency act (§130) with ratification:
The judgment structure:
JDelegate -- ApparentAuth: no apparent authority facts
(JOverride -- Ratification: Ratified ∈ facts → Valid
(JBase Pending ...) -- Base: unauthorized → Pending
Valid
(ArticleRef "민법" 132 Nothing)
"본인이 추인하여 유권대리와 동일한 효력이 생겼다.")
Steps extracted:
Applied— §130: base rule, verdictPending(unauthorized agent)Overridden— §132: ratification overrides toValid
Note: the ApparentAuth layer delegated (no apparent authority facts), so
it doesn't appear in the steps.