အခု ကျွန်တော်တို့ရဲ့ AI ကို ပိုမိုပြည့်စုံသော "Legal Reasoning Agent" တစ်ခုဖြစ်လာစေဖို့ "ကာကွယ်ခုခံပိုင်ခွင့်" (Right of Private Defense) Logic ကို ထပ်ဖြည့်ပါမယ်။
ဥပဒေယုတ္တိဗေဒ (Legal Logic) အရ အမှုတစ်ခုကို စစ်ဆေးရာမှာ အစီအစဉ်တကျ (Hierarchy) ရှိဖို့ လိုအပ်တယ်။
Actus Reus: လူသေမှု ဖြစ်သလား? (မဖြစ်ရင် လူသတ်မှု မဟုတ်)။
General Exceptions: ကာကွယ်ခုခံပိုင်ခွင့် အရ လုပ်တာလား? (ဟုတ်ရင် အပြစ်မရှိ/ကွင်းလုံးကျွတ်)။
Prima Facie Murder: သေစေလိုသော စေတနာ (Mens Rea) ပါသလား? (မပါရင် လူသတ်မှု မဟုတ်)။
Special Exceptions: ရန်စခံရလို့လား (Provocation)? (ဟုတ်ရင် လူသတ်မှုကနေ လျော့ပေါ့)။
၎င်း ယုတ္တိဗေဒ အစီအစဉ်အတိုင်း အလုပ်လုပ်မဲ့ Python ကုဒ်အပြည့်အစုံက အောက်ပါအတိုင်းဖြစ်တယ်။
Created on Tue Jan 20 18:45:41 2026
@author: kks
"""
import re
class AdvancedLegalAI:
def __init__(self):
print("--- AI Legal Inference System Initialized ---")
print("System loaded with: Penal Code Section 300 & Private Defense Logic")
# အဆင့် (၁) - NLU (စာသားမှ အချက်အလက် ထုတ်နုတ်ခြင်း)
def extract_facts(self, text):
text = text.lower()
facts = {
"death_occurred": False, # လူသေမှု
"intent_to_kill": False, # သေစေလိုသောစိတ်
"intent_injury": False, # ဒဏ်ရာရစေလိုသောစိတ်
"sufficient_injury": False, # သေစေလောက်သော ဒဏ်ရာ
# For Provocation (Section 300 Exception 1)
"is_provoked": False,
"sudden_and_grave": False,
"loss_of_control": False,
# For Self-Defense (Section 96)
"under_imminent_threat": False, # ဘေးအန္တရာယ် ကျရောက်နေခြင်း
"act_was_defensive": False # ကာကွယ်ရန် ပြုလုပ်ခြင်း
}
# Keywords for Death
if any(w in text for w in ["died", "dead", "killed", "fatal"]):
facts["death_occurred"] = True
# Keywords for Intent (Mens Rea)
if any(w in text for w in ["intentionally", "purpose", "plan", "murdered"]):
facts["intent_to_kill"] = True
if any(w in text for w in ["stabbed", "shot", "hit", "cut"]):
facts["intent_injury"] = True
facts["sufficient_injury"] = True # Demo purposes
# Keywords for Provocation
if "provoked" in text or "insulted" in text:
facts["is_provoked"] = True
if "sudden" in text and "grave" in text:
facts["sudden_and_grave"] = True
if "lost control" in text or "anger" in text:
facts["loss_of_control"] = True
# Keywords for Self-Defense (New Feature)
# အန္တရာယ်ကျရောက်ခြင်း (Threat)
if any(w in text for w in ["attacked", "danger", "threatened", "gunpoint"]):
facts["under_imminent_threat"] = True
# ကာကွယ်ခြင်း (Defensive Act)
if any(w in text for w in ["defend", "protect", "saved himself"]):
facts["act_was_defensive"] = True
return facts
# အဆင့် (၂) - Inference Engine (ဥပဒေ ယုတ္တိဗေဒ အဆုံးအဖြတ်)
def determine_verdict(self, facts):
# LOGIC LEVEL 1: Actus Reus (အပြုအမူ)
if not facts["death_occurred"]:
return "CASE DISMISSED: No death occurred. (လူသေဆုံးခြင်း မရှိပါ)"
# LOGIC LEVEL 2: General Exceptions (Self-Defense)
# Section 96: Nothing is an offence which is done in the exercise of the right of private defense.
is_self_defense = facts["under_imminent_threat"] and facts["act_was_defensive"]
if is_self_defense:
return "NOT GUILTY: Act done in Private Defense (Section 96). (ကာကွယ်ခုခံပိုင်ခွင့်အရ အပြစ်မရှိပါ)"
# LOGIC LEVEL 3: Establish Murder Prima Facie (Mens Rea)
has_intent = facts["intent_to_kill"] or (facts["intent_injury"] and facts["sufficient_injury"])
if not has_intent:
return "NOT MURDER: Accidental or Negligent. (ရည်ရွယ်ချက် မရှိသဖြင့် လူသတ်မှု မမြောက်ပါ)"
# LOGIC LEVEL 4: Special Exceptions (Provocation)
# Section 300 Exception 1
valid_provocation = (facts["is_provoked"] and
facts["sudden_and_grave"] and
facts["loss_of_control"])
if valid_provocation:
return "REDUCED CHARGE: Culpable Homicide not amounting to Murder. (Provocation ကြောင့် လျော့ပေါ့)"
# LOGIC LEVEL 5: Default Verdict
return "GUILTY: Murder under Section 300. (လူသတ်မှု ထင်ရှားသည်)"
# Main Processing Function
def process_case(self, scenario_text):
print(f"\n[Input Scenario]: \"{scenario_text}\"")
# 1. Understand Facts
facts = self.extract_facts(scenario_text)
# 2. Print AI's Understanding (Debug View)
defense_status = "YES" if (facts['under_imminent_threat'] and facts['act_was_defensive']) else "NO"
print(f"[AI Reasoning] Self-Defense Detected? -> {defense_status}")
# 3. Final Judgment
verdict = self.determine_verdict(facts)
print(f"[FINAL VERDICT]: {verdict}")
print("-" * 60)
# --- PROGRAM EXECUTION ---
# AI Agent ကို စတင်ခြင်း
ai_judge = AdvancedLegalAI()
# Scenario 1: Self-Defense (ကာကွယ်ခုခံခြင်း)
# ရှင်းလင်းချက်: John က တိုက်ခိုက်ခံရပြီး သူ့ကိုယ်သူ ကာကွယ်ရင်း တဖက်လူ သေသွားခြင်း
case_1 = "A stranger attacked John with a knife. To defend himself from the danger, John hit the stranger and the stranger died."
ai_judge.process_case(case_1)
# Scenario 2: Pure Murder (ရိုးရိုး လူသတ်မှု)
# ရှင်းလင်းချက်: ရည်ရွယ်ချက်ရှိရှိ သတ်ဖြတ်ခြင်း
case_2 = "John planned carefully and intentionally killed his enemy with a gun."
ai_judge.process_case(case_2)
# Scenario 3: Provocation (ရန်စခံရ၍ ကျူးလွန်ခြင်း)
# ရှင်းလင်းချက်: ကြီးလေးသော ရန်စမှုကြောင့် စိတ်လိုက်မာန်ပါ ဖြစ်သွားခြင်း
case_3 = "The victim provoked John with sudden and grave insults. John lost control of his anger and stabbed the victim to death."
ai_judge.process_case(case_3)
ကုဒ်၏ အလုပ်လုပ်ပုံ အသေးစိတ်ရှင်းလင်းချက်
AIMA စာအုပ်မှာပါတဲ့ Logic-Based Agent ရဲ့ သဘောတရားအတိုင်း ဒီပရိုဂရမ်က အောက်ပါအတိုင်း အလုပ်လုပ်ပါတယ်။
Fact Extraction (အချက်အလက် စုဆောင်းခြင်း):
extract_factsfunction သည် User ၏ စာသားထဲမှdefend,attacked,dangerစသည့် စကားလုံးများကို ရှာဖွေသည်။ တွေ့ရှိပါကunder_imminent_threatနှင့်act_was_defensiveဆိုသည့် Logic ခလုတ်များကိုTrueအဖြစ် ပြောင်းပေးလိုက်သည်။
Logic Priority (ယုတ္တိဗေဒ ဦးစားပေးအဆင့်):
ကုဒ်ထဲတွင်
if is_self_defense:ကိုhas_intent(ရည်ရွယ်ချက်) မစစ်ဆေးမီ အရင်ဆုံး စစ်ဆေးထားသည်ကို သတိပြုပါ။အဘယ်ကြောင့်ဆိုသော် ဥပဒေအရ ကာကွယ်ခုခံပိုင်ခွင့် (Private Defense) သည် General Exception ဖြစ်သည်။ လူတစ်ယောက်ကို သေစေလိုသော စေတနာဖြင့် သတ်လိုက်လျှင်ပင်၊ ထိုသို့သတ်ခြင်းသည် မိမိအသက်အန္တရာယ်ကို ကာကွယ်ရန် ဖြစ်ပါက ဥပဒေအရ အပြစ်မရှိ (Not Guilty) ဖြစ်သွားသောကြောင့် ဖြစ်သည်။ AI ၏ Logic Flow သည် ဤဥပဒေ သဘောတရားကို လိုက်နာထားခြင်း ဖြစ်သည်။
Result (ရလဒ်):
အကယ်၍ Scenario 1 ကဲ့သို့ "Attacked" နှင့် "Defend" ပါလာပါက AI သည် လူသတ်မှု (Murder) ဟု မဆုံးဖြတ်ဘဲ "Not Guilty (Section 96)" ဟု အဖြေမှန် ထုတ်ပေးနိုင်သွားပြီ ဖြစ်သည်။
ဒီလောက်ဆိုရင် မိတ်ဆွေအနေနဲ့ Python ကိုသုံးပြီး ဥပဒေရေးရာ Logic တွေကို AI အေးဂျင့်တစ်ခုအဖြစ် ဘယ်လို ဖန်တီးရမလဲဆိုတာ ကောင်းကောင်း သဘောပေါက်သွားပြီလို့ ယူဆပါတယ်။ လက်တွေ့မှာ ဒီထက်ပိုရှုပ်ထွေးတဲ့ ဥပဒေပုဒ်မတွေ (ဥပမာ - ပူးပေါင်းကြံစည်မှု) ကို ထပ်ချဲ့ထွင် စမ်းသပ်နိုင်ပါတယ်။
အထူးသတိပြုရန်။
၁။ အခုနမူနာပေးထားတဲ့ ပရိုဂရမ်ဟာ လုံးဝ ခြောက်ပြစ်ကင်း သဲလဲစင် ပြည့်စုံတဲ့ ပရိုဂရမ် တစ်ခုမဟုတ်ပါဘူး။ သဘောတရားကို နားလည်ဖို့ အဓိကထားပြီး ဥပမာ Demonstration ပြတဲ့ သဘောလောက်ပဲ ဖြစ်ပါတယ်။ ဒါကို အခြေခံပြီး မိမိ စိတ်ကူးရှိသလို ထပ်မံ ချဲ့ပြင် ပြင်ဆင် ဖြည့်စွက် နိုင်ပါတယ်။
၂။ case_3 = "The victim provoked John with sudden and grave insults. John lost control of his anger and stabbed the victim to death." မှာ၊ ပရိုဂရမ်က မိတ်ဆွေမျှော်လင့်တဲ့ ရလာဒ်ကို ပြမှာ မဟုတ်ပါဘူး။ မှားယွင်းဆုံးဖြတ်ပါလိမ့်မယ်။ အဲ့တာကိုတော့ ကိုယ်တိုင် error ရှာပြီး ပြင်ဆင်ဖြည့်စွက်ကြည့်ပါ။
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.