diff --git a/Law-expert_system/Family_Court_GUI/Family_Court_GUI.py b/Law-expert_system/Family_Court_GUI/Family_Court_GUI.py new file mode 100644 index 0000000..96c0a97 --- /dev/null +++ b/Law-expert_system/Family_Court_GUI/Family_Court_GUI.py @@ -0,0 +1,439 @@ +import tkinter +import tkinter.messagebox +import customtkinter +from tkinter import * +from PIL import Image , ImageTk +import sys +import os + +customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light" +customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue" + + +class App(customtkinter.CTk): + def __init__(self): + super().__init__() + + # configure window + self.title("Family Court") + self.attributes('-fullscreen',True) + self.geometry(f"{1080}x{580}") + + # app_w =1080 + # app_h =580 + # screen_w = self.winfo_screenwidth() + # screen_h = self.winfo_screenheight() + # x=(screen_w / 2) - (app_w / 2) + # y=(screen_h / 2) - (app_h / 2) + + # self.geometry(f"{app_w}x{app_h}+{int(x)}+{int(y)}") + # self.eval('tk::PlaceWindow . center') + # bg = PhotoImage(file="law1.png") + # limg= Label(self, i=bg) + + # configure grid layout (4x4) + self.grid_columnconfigure(1, weight=0) + self.grid_columnconfigure((2, 3), weight=0) + self.grid_rowconfigure((0, 1, 2), weight=1) + + # create sidebar frame with widgets + self.sidebar_frame = customtkinter.CTkFrame(self, width=140, corner_radius=0) + self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsew") + self.sidebar_frame.grid_rowconfigure(4, weight=1) + + self.logo_label = customtkinter.CTkLabel(self.sidebar_frame, text="Family Court", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=0, padx=20, pady=(20, 10)) + + self.sidebar_button_1 = customtkinter.CTkButton(self.sidebar_frame,text="Incubation",command=self.sidebar_button1_event) + self.sidebar_button_1.grid(row=1, column=0, padx=20, pady=10) + + self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, text="Alimony",command=self.sidebar_button2_event) + self.sidebar_button_2.grid(row=2, column=0, padx=20, pady=10) + + self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, text="Restart",fg_color="#FF5D5D",command=self.reset) + self.sidebar_button_2.grid(row=9, column=0, padx=20, pady=10) + + self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, text="Exit",fg_color="#FF5D5D",command=self.destroy) + self.sidebar_button_2.grid(row=10, column=0, padx=20, pady=10) + + self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="Appearance Mode:", anchor="w") + self.appearance_mode_label.grid(row=5, column=0, padx=20, pady=(10, 0)) + self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=[ "Dark","Light", "System"], + command=self.change_appearance_mode_event) + self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10)) + + self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="UI Scaling:", anchor="w") + self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0)) + self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["80%", "90%", "100%", "110%", "120%"], + command=self.change_scaling_event) + self.scaling_optionemenu.grid(row=8, column=0, padx=20, pady=(10, 20)) + + def change_appearance_mode_event(self, new_appearance_mode: str): + customtkinter.set_appearance_mode(new_appearance_mode) + + def change_scaling_event(self, new_scaling: str): + new_scaling_float = int(new_scaling.replace("%", "")) / 100 + customtkinter.set_widget_scaling(new_scaling_float) + + def sidebar_button2_event(self): + self.button1_frame = customtkinter.CTkFrame(self, width=820, corner_radius=0) + self.button1_frame.grid(row=0, column=1, rowspan=4, sticky="nsew") + self.button1_frame.grid_rowconfigure(4, weight=1) + + self.logo_label = customtkinter.CTkLabel(self.button1_frame, text="Alimony", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.ans1_frame = customtkinter.CTkFrame(self,width=140, corner_radius=0) + self.ans1_frame.grid(row=0, column=2, rowspan=4, sticky="nsew") + self.ans1_frame.grid_rowconfigure(10, weight=1) + + self.logo_label = customtkinter.CTkLabel(self.ans1_frame, text="Answer", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=2, padx=20, pady=(20, 10)) + + self.radio_var = tkinter.IntVar(value=0) + self.radio_var1 = tkinter.IntVar(value=0) + self.radio_var2 = tkinter.IntVar(value=0) + self.radio_var3 = tkinter.IntVar(value=0) + self.radio_var4 = tkinter.IntVar(value=0) + self.radio_var5 = tkinter.IntVar(value=0) + self.radio_var6 = tkinter.IntVar(value=0) + self.radio_var7= tkinter.IntVar(value=0) + self.radio_var8 = tkinter.IntVar(value=0) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Does the mother have the incubation?" ) + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var, value= 1 ,command=self.q1_ans) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var, value= 2,command=self.q1_ans) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Is the child under 2 years?" ) + self.label_radio_group.grid(row=2, column=1, columnspan=1, padx=10, pady=10, sticky="") + self.radio_button_7 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var1, value= 1 ,command=self.q1_ans) + self.radio_button_7.grid(row=2, column=2, pady=10, padx=5, sticky="n") + self.radio_button_8 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var1, value= 2,command=self.q1_ans) + self.radio_button_8.grid(row=2, column=3, pady=10, padx=5, sticky="n") + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="is the wife staying in the house?" ) + self.label_radio_group.grid(row=3, column=1, columnspan=1, padx=10, pady=10, sticky="") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var2, value= 1 ,command=self.q1_ans) + self.radio_button_1.grid(row=3, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var2, value= 2,command=self.q1_ans) + self.radio_button_2.grid(row=3, column=3, pady=10, padx=5, sticky="n") + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Is the husband rich enough to pay a servant?" ) + self.label_radio_group.grid(row=4, column=1, columnspan=1, padx=10, pady=10, sticky="") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var3, value= 1 ,command=self.q1_ans) + self.radio_button_1.grid(row=4, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var3, value= 2,command=self.q1_ans) + self.radio_button_2.grid(row=4, column=3, pady=10, padx=5, sticky="n") + + + self.scaling_label = customtkinter.CTkLabel(self.radiobutton_frame, text="What is the kind of divorce?", anchor="w") + self.scaling_label.grid(row=5, column=1, padx=20, pady=(10, 0)) + self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.radiobutton_frame ,values=[" ","Normal divorce", "Divorced for harm", "Wife divorced the Husband", "None of the above",], + command=self.divorce_ans) + self.scaling_optionemenu.grid(row=6, column=1, padx=20, pady=(10, 20)) + + + + def sidebar_button1_event(self): + self.button1_frame = customtkinter.CTkFrame(self, width=820, corner_radius=0) + self.button1_frame.grid(row=0, column=1, rowspan=4, sticky="nsew") + self.button1_frame.grid_rowconfigure(4, weight=1) + + self.logo_label = customtkinter.CTkLabel(self.button1_frame, text="Incubation", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.ans1_frame = customtkinter.CTkFrame(self,width=140, corner_radius=0) + self.ans1_frame.grid(row=0, column=2, rowspan=4, sticky="nsew") + self.ans1_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans1_frame, text="Answer", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=2, padx=20, pady=(20, 10)) + + self.radio_var = tkinter.IntVar(value=0) + self.radio_var1 = tkinter.IntVar(value=0) + self.radio_var2 = tkinter.IntVar(value=0) + self.radio_var3 = tkinter.IntVar(value=0) + self.radio_var4 = tkinter.IntVar(value=0) + self.radio_var5 = tkinter.IntVar(value=0) + self.radio_var6 = tkinter.IntVar(value=0) + self.radio_var7= tkinter.IntVar(value=0) + self.radio_var8 = tkinter.IntVar(value=0) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Do you have a girl under 17 or a boy under 15?" ) + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var, value= 1 ,command=self.q2_ans) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var, value= 2,command=self.q2_ans) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + + def q1_ans(self): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + if((str(self.radio_var.get()))== "1"): + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="husband will pay money for kids incubation \nhusband will pay money for kids to live a suitable life" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + self.radio_button_7 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var1, value= 1 ,command=self.q1_ans) + self.radio_button_7.grid(row=2, column=2, pady=10, padx=5, sticky="n") + self.radio_button_8 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var1, value= 2,command=self.q1_ans) + self.radio_button_8.grid(row=2, column=3, pady=10, padx=5, sticky="n") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var2, value= 1 ,command=self.q1_ans) + self.radio_button_1.grid(row=3, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var2, value= 2,command=self.q1_ans) + self.radio_button_2.grid(row=3, column=3, pady=10, padx=5, sticky="n") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var3, value= 1 ,command=self.q1_ans) + self.radio_button_1.grid(row=4, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var3, value= 2,command=self.q1_ans) + self.radio_button_2.grid(row=4, column=3, pady=10, padx=5, sticky="n") + elif((str(self.radio_var.get()))== "2"): + self.radio_button_7 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var1, value= 1 ,command=self.q1_ans,state = DISABLED) + self.radio_button_7.grid(row=2, column=2, pady=10, padx=5, sticky="n") + self.radio_button_8 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var1, value= 2,command=self.q1_ans, state= DISABLED) + self.radio_button_8.grid(row=2, column=3, pady=10, padx=5, sticky="n") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var2, value= 1 ,command=self.q1_ans, state=DISABLED) + self.radio_button_1.grid(row=3, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var2, value= 2,command=self.q1_ans, state=DISABLED) + self.radio_button_2.grid(row=3, column=3, pady=10, padx=5, sticky="n") + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var3, value= 1 ,command=self.q1_ans, state=DISABLED) + self.radio_button_1.grid(row=4, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var3, value= 2,command=self.q1_ans, state=DISABLED) + self.radio_button_2.grid(row=4, column=3, pady=10, padx=5, sticky="n") + if((str(self.radio_var1.get()))== "1"): + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="husband will pay for breastfeeding" ) + self.logo_label.grid(row=2, column=2, padx=20, pady=(20, 10)) + if((str(self.radio_var2.get()))== "2"): + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="husband will pay rent for kids house" ) + self.logo_label.grid(row=3, column=2, padx=20, pady=(20, 10)) + if((str(self.radio_var3.get()))== "1"): + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="husband will pay for a servant" ) + self.logo_label.grid(row=4, column=2, padx=20, pady=(20, 10)) + + def divorce_handle(self): + self.ans3_frame = customtkinter.CTkFrame(self.ans2_frame,width=140, corner_radius=0) + self.ans3_frame.grid(row=5, column=2, rowspan=4, sticky="nsew") + self.ans3_frame.grid_rowconfigure(10, weight=1) + if((str(self.radio_var4.get()))== "2"): + self.logo_label = customtkinter.CTkLabel(self.ans3_frame, text="husband pay 24 month expense of the monthly aliment\nhusband pay 3 month expense of the monthly aliment" ) + self.logo_label.grid(row=5, column=2, padx=20, pady=(20, 10)) + if((str(self.radio_var5.get()))== "1"): + self.logo_label = customtkinter.CTkLabel(self.ans3_frame, text="husband pay after divorce money" ) + self.logo_label.grid(row=6, column=2, padx=20, pady=(20, 10)) + if((str(self.radio_var6.get()))== "2"): + self.logo_label = customtkinter.CTkLabel(self.ans3_frame, text="husband pay expense from 2 to 5 years of the monthly aliment\nhusband pay 3 month expense of the monthly aliment" ) + self.logo_label.grid(row=5, column=2, padx=20, pady=(20, 10)) + + def q2_ans(self): + if((str(self.radio_var.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="there is no incubation the children free to choose who to live with" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.logo_label = customtkinter.CTkLabel(self.radiobutton_frame, text="Mother check",text_color="#FBE4C9", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If mother not alive or alive suffering from any of these enter y if not enter n\n1- she is insane\n2- she is proven cheating on her husband\n3- she will travel outside the country and take the kids\n4- she is married to a stranger from the child\n5- she did practice professions that violate religion and the law\n6- She is not trusted, such as if she frequently go out and leave the child alone?") + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var1, value= 1 ,command=self.mother_state) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var1, value= 2,command=self.mother_state) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + def mother_state(self): + if((str(self.radio_var1.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the mother will have the incubation" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.logo_label = customtkinter.CTkLabel(self.radiobutton_frame, text="Father check",text_color="#FBE4C9", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If father not alive or alive suffering from any of these enter y if not enter n\n1- he is insane\n2- he has commit crimes before\n3- he is immoral\n4- he do not have a woman in the house to raise the children\n5- he will travel outside the country and take the kids\n6- it been 6 months before the father raised the case without an acceptable excuse?") + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var2, value= 1 ,command=self.father_state) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var2, value= 2,command=self.father_state) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + def father_state(self): + if((str(self.radio_var2.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the father will have the incubation" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.logo_label = customtkinter.CTkLabel(self.radiobutton_frame, text="Mother's mother check",text_color="#FBE4C9", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If mother's mother not alive or alive suffering from any of these enter y if not enter n\n1- she is insane\n2- she is proven cheating on her husband\n3- she will travel outside the country and take the kids\n4- she is married to a stranger from the child\n5- she did practice professions that violate religion and the law\n6- She is not trusted, such as if she frequently go out and leave the child alone?") + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var3, value= 1 ,command=self.mothermother_state) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var3, value= 2,command=self.mothermother_state) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + def mothermother_state(self): + if((str(self.radio_var3.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the mother's mother will have the incubation" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.logo_label = customtkinter.CTkLabel(self.radiobutton_frame, text="Father's mother check",text_color="#FBE4C9", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If father's mother not alive or alive suffering from any of these enter y if not enter n\n1- she is insane\n2- she is proven cheating on her husband\n3- she will travel outside the country and take the kids\n4- she is married to a stranger from the child\n5- she did practice professions that violate religion and the law\n6- She is not trusted, such as if she frequently go out and leave the child alone?") + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var4, value= 1 ,command=self.fathermother_state) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var4, value= 2,command=self.fathermother_state) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + def fathermother_state(self): + if((str(self.radio_var4.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the father's mother will have the incubation" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.logo_label = customtkinter.CTkLabel(self.radiobutton_frame, text="Mother's sister check",text_color="#FBE4C9", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If mother's sister not alive or alive suffering from any of these enter y if not enter n\n1- she is insane\n2- she is proven cheating on her husband\n3- she will travel outside the country and take the kids\n4- she is married to a stranger from the child\n5- she did practice professions that violate religion and the law\n6- She is not trusted, such as if she frequently go out and leave the child alone?") + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var5, value= 1 ,command=self.mothersister_state) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var5, value= 2,command=self.mothersister_state) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + def mothersister_state(self): + if((str(self.radio_var5.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the mother's sister will have the incubation" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.radiobutton_frame = customtkinter.CTkFrame(self.button1_frame) + self.radiobutton_frame.grid(row=1, column=1, padx=(20, 20), pady=(20, 0), sticky="nsew") + + self.logo_label = customtkinter.CTkLabel(self.radiobutton_frame, text="Father's sister check",text_color="#FBE4C9", font=customtkinter.CTkFont(size=20, weight="bold")) + self.logo_label.grid(row=0, column=1, padx=20, pady=(20, 10)) + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If father's sister not alive or alive suffering from any of these enter y if not enter n\n1- she is insane\n2- she is proven cheating on her husband\n3- she will travel outside the country and take the kids\n4- she is married to a stranger from the child\n5- she did practice professions that violate religion and the law\n6- She is not trusted, such as if she frequently go out and leave the child alone?") + self.label_radio_group.grid(row=1, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var6, value= 1 ,command=self.fathersister_state) + self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var6, value= 2,command=self.fathersister_state) + self.radio_button_2.grid(row=1, column=3, pady=10, padx=5, sticky="n") + + def fathersister_state(self): + if((str(self.radio_var6.get()))== "2"): + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the father's sister will have the incubation" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + else: + self.ans2_frame = customtkinter.CTkFrame(self.ans1_frame,width=140, corner_radius=0) + self.ans2_frame.grid(row=1, column=2, rowspan=4, sticky="nsew") + self.ans2_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans2_frame, text="the child will go to a shelter",text_color="#FF5D5D" ) + self.logo_label.grid(row=1, column=2, padx=20, pady=(20, 10)) + + + def divorce_ans(self, divorce_type: str): + if(divorce_type=="Normal divorce"): + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If the wife have done any of these defects enter y if not enter n\n1- prevented herself from her husband without a legitimate excuse\n2- left their home without a legitimate excuse\n3- prevented her husband from entering their house without a legitimate excuse\n4- A case was issued restricting her freedom in the rights of her husband\n5- She broke her commitment to her husband?") + self.label_radio_group.grid(row=7, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var4, value= 1 ,command=self.divorce_handle) + self.radio_button_1.grid(row=7, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var4, value= 2,command=self.divorce_handle) + self.radio_button_2.grid(row=7, column=3, pady=10, padx=5, sticky="n") + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Is the after divorce money in the marriage contract?") + self.label_radio_group.grid(row=8, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var5, value= 1 ,command=self.divorce_handle) + self.radio_button_1.grid(row=8, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var5, value= 2,command=self.divorce_handle) + self.radio_button_2.grid(row=8, column=3, pady=10, padx=5, sticky="n") + + + elif(divorce_type=="Divorced for harm"): + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="If the wife have done any of these defects enter y if not enter n\n1- prevented herself from her husband without a legitimate excuse\n2- left their home without a legitimate excuse\n3- prevented her husband from entering their house without a legitimate excuse\n4- A case was issued restricting her freedom in the rights of her husband\n5- She broke her commitment to her husband?") + self.label_radio_group.grid(row=7, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var6, value= 1 ,command=self.divorce_handle) + self.radio_button_1.grid(row=7, column=2, pady=10, padx=20, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var6, value= 2,command=self.divorce_handle) + self.radio_button_2.grid(row=7, column=3, pady=10, padx=5, sticky="n") + + self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Is the after divorce money in the marriage contract?") + self.label_radio_group.grid(row=8, column=1, columnspan=1, padx=10, pady=10, sticky="") + + self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="true", variable=self.radio_var5, value= 1 ,command=self.divorce_handle) + self.radio_button_1.grid(row=8, column=2, pady=10, padx=5, sticky="n") + self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame,text="False", variable=self.radio_var5, value= 2,command=self.divorce_handle) + self.radio_button_2.grid(row=8, column=3, pady=10, padx=5, sticky="n") + + elif(divorce_type=="Wife divorced the Husband"): + self.ans3_frame = customtkinter.CTkFrame(self.ans2_frame,width=140, corner_radius=0) + self.ans3_frame.grid(row=6, column=2, rowspan=4, sticky="nsew") + self.ans3_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans3_frame, text="the wife will give up on all her rights\nthe wife will give husband money before marriage back",text_color="#FF5D5D",font=customtkinter.CTkFont(size=12, weight="bold") ) + self.logo_label.grid(row=6, column=2, padx=20, pady=(20, 10)) + + elif(divorce_type=="None of the above"): + self.ans3_frame = customtkinter.CTkFrame(self.ans2_frame,width=140, corner_radius=0) + self.ans3_frame.grid(row=6, column=2, rowspan=4, sticky="nsew") + self.ans3_frame.grid_rowconfigure(10, weight=1) + self.logo_label = customtkinter.CTkLabel(self.ans3_frame, text="That's impossible" ,text_color="#FF5D5D",font=customtkinter.CTkFont(size=12, weight="bold")) + self.logo_label.grid(row=6, column=2, padx=20, pady=(20, 10)) + + + def reset(self): + self.destroy() + app = App() + app.mainloop() + +if __name__ == "__main__": + app = App() + app.mainloop() diff --git a/Law-expert_system/GUI_screen_shots.pdf b/Law-expert_system/GUI_screen_shots.pdf new file mode 100644 index 0000000..85f1441 Binary files /dev/null and b/Law-expert_system/GUI_screen_shots.pdf differ diff --git a/Law-expert_system/Project_Intro_Logic.pdf b/Law-expert_system/Project_Intro_Logic.pdf new file mode 100644 index 0000000..f320c05 Binary files /dev/null and b/Law-expert_system/Project_Intro_Logic.pdf differ diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/__init__.py b/Law-expert_system/pythonProject/Law_system/compiled_krb/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/__init__.cpython-38.pyc b/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..84224d9 Binary files /dev/null and b/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/__init__.cpython-38.pyc differ diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/compiled_pyke_files.cpython-38.pyc b/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/compiled_pyke_files.cpython-38.pyc new file mode 100644 index 0000000..1c44a0c Binary files /dev/null and b/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/compiled_pyke_files.cpython-38.pyc differ diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/rules_bc.cpython-38.pyc b/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/rules_bc.cpython-38.pyc new file mode 100644 index 0000000..3bf981d Binary files /dev/null and b/Law-expert_system/pythonProject/Law_system/compiled_krb/__pycache__/rules_bc.cpython-38.pyc differ diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/compiled_pyke_files.py b/Law-expert_system/pythonProject/Law_system/compiled_krb/compiled_pyke_files.py new file mode 100644 index 0000000..9accfb6 --- /dev/null +++ b/Law-expert_system/pythonProject/Law_system/compiled_krb/compiled_pyke_files.py @@ -0,0 +1,24 @@ +# compiled_pyke_files.py + +from pyke import target_pkg + +pyke_version = '1.1.1' +compiler_version = 1 +target_pkg_version = 1 + +try: + loader = __loader__ +except NameError: + loader = None + +def get_target_pkg(): + return target_pkg.target_pkg(__name__, __file__, pyke_version, loader, { + ('', '', 'facts.kfb'): + [1671883621.1383839, 'facts.fbc'], + ('', '', 'questions.kqb'): + [1671883621.15832, 'questions.qbc'], + ('', '', 'rules.krb'): + [1671883621.214132, 'rules_bc.py'], + }, + compiler_version) + diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/facts.fbc b/Law-expert_system/pythonProject/Law_system/compiled_krb/facts.fbc new file mode 100644 index 0000000..b67babf Binary files /dev/null and b/Law-expert_system/pythonProject/Law_system/compiled_krb/facts.fbc differ diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/questions.qbc b/Law-expert_system/pythonProject/Law_system/compiled_krb/questions.qbc new file mode 100644 index 0000000..8598bbb Binary files /dev/null and b/Law-expert_system/pythonProject/Law_system/compiled_krb/questions.qbc differ diff --git a/Law-expert_system/pythonProject/Law_system/compiled_krb/rules_bc.py b/Law-expert_system/pythonProject/Law_system/compiled_krb/rules_bc.py new file mode 100644 index 0000000..b3f90a1 --- /dev/null +++ b/Law-expert_system/pythonProject/Law_system/compiled_krb/rules_bc.py @@ -0,0 +1,1134 @@ +# rules_bc.py + +from pyke import contexts, pattern, bc_rule + +pyke_version = '1.1.1' +compiler_version = 1 + +def no_money(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.no_money: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_M_have_incubation', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.no_money: got unexpected plan from when clause 2" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def inc(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.inc: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_M_have_incubation', context, + (rule.pattern(0),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.inc: got unexpected plan from when clause 2" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def kids(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.kids: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_M_have_incubation', context, + (rule.pattern(0),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.kids: got unexpected plan from when clause 2" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def brea(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.brea: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_M_have_incubation', context, + (rule.pattern(0),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.brea: got unexpected plan from when clause 2" + with engine.prove('questions', 'is_child_under_2years', context, + (rule.pattern(0),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.brea: got unexpected plan from when clause 3" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def house(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.house: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_M_have_incubation', context, + (rule.pattern(0),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.house: got unexpected plan from when clause 2" + with engine.prove('questions', 'is_wife_staying_your_house', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.house: got unexpected plan from when clause 3" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def servant(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.servant: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_M_have_incubation', context, + (rule.pattern(0),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.servant: got unexpected plan from when clause 2" + with engine.prove('questions', 'is_D_rich', context, + (rule.pattern(0),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.servant: got unexpected plan from when clause 3" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def her_divorce(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.her_divorce: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.her_divorce: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (2,): + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def her_div(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.her_div: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.her_div: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (2,): + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def harm_expense(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.harm_expense: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.harm_expense: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (3,): + with engine.prove('questions', 'any_defect', context, + (rule.pattern(2),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.harm_expense: got unexpected plan from when clause 4" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def not_harm_expense(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.not_harm_expense: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.not_harm_expense: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (1,): + with engine.prove('questions', 'any_defect', context, + (rule.pattern(2),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.not_harm_expense: got unexpected plan from when clause 4" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def expense(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.expense: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.expense: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (1,3): + with engine.prove('questions', 'any_defect', context, + (rule.pattern(2),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.expense: got unexpected plan from when clause 4" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def after_divorce(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.after_divorce: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.after_divorce: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (1,3): + with engine.prove('questions', 'is_it_in_contract', context, + (rule.pattern(0),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.after_divorce: got unexpected plan from when clause 4" + with engine.prove('questions', 'any_defect', context, + (rule.pattern(2),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.after_divorce: got unexpected plan from when clause 5" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def aft_divorce(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.aft_divorce: got unexpected plan from when clause 1" + with engine.prove('questions', 'ch_div_st', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.aft_divorce: got unexpected plan from when clause 2" + if context.lookup_data('ans') in (1,3): + with engine.prove('questions', 'is_it_in_contract', context, + (rule.pattern(2),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.aft_divorce: got unexpected plan from when clause 4" + with engine.prove('questions', 'is_there_witness', context, + (rule.pattern(0),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.aft_divorce: got unexpected plan from when clause 5" + with engine.prove('questions', 'any_defect', context, + (rule.pattern(2),)) \ + as gen_6: + for x_6 in gen_6: + assert x_6 is None, \ + "rules.aft_divorce: got unexpected plan from when clause 6" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(0),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.incubation: got unexpected plan from when clause 2" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def m_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.m_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.m_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(0),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.m_incubation: got unexpected plan from when clause 3" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def f_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.f_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.f_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.f_incubation: got unexpected plan from when clause 3" + with engine.prove('questions', 'any_def_f', context, + (rule.pattern(0),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.f_incubation: got unexpected plan from when clause 4" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def mm_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.mm_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.mm_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.mm_incubation: got unexpected plan from when clause 3" + with engine.prove('questions', 'any_def_f', context, + (rule.pattern(1),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.mm_incubation: got unexpected plan from when clause 4" + with engine.prove('questions', 'any_def_mm', context, + (rule.pattern(0),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.mm_incubation: got unexpected plan from when clause 5" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def fm_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.fm_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.fm_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.fm_incubation: got unexpected plan from when clause 3" + with engine.prove('questions', 'any_def_f', context, + (rule.pattern(1),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.fm_incubation: got unexpected plan from when clause 4" + with engine.prove('questions', 'any_def_mm', context, + (rule.pattern(1),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.fm_incubation: got unexpected plan from when clause 5" + with engine.prove('questions', 'any_def_fm', context, + (rule.pattern(0),)) \ + as gen_6: + for x_6 in gen_6: + assert x_6 is None, \ + "rules.fm_incubation: got unexpected plan from when clause 6" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def ms_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 3" + with engine.prove('questions', 'any_def_f', context, + (rule.pattern(1),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 4" + with engine.prove('questions', 'any_def_mm', context, + (rule.pattern(1),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 5" + with engine.prove('questions', 'any_def_fm', context, + (rule.pattern(1),)) \ + as gen_6: + for x_6 in gen_6: + assert x_6 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 6" + with engine.prove('questions', 'any_def_ms', context, + (rule.pattern(0),)) \ + as gen_7: + for x_7 in gen_7: + assert x_7 is None, \ + "rules.ms_incubation: got unexpected plan from when clause 7" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def fs_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 3" + with engine.prove('questions', 'any_def_f', context, + (rule.pattern(1),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 4" + with engine.prove('questions', 'any_def_mm', context, + (rule.pattern(1),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 5" + with engine.prove('questions', 'any_def_fm', context, + (rule.pattern(1),)) \ + as gen_6: + for x_6 in gen_6: + assert x_6 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 6" + with engine.prove('questions', 'any_def_ms', context, + (rule.pattern(1),)) \ + as gen_7: + for x_7 in gen_7: + assert x_7 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 7" + with engine.prove('questions', 'any_def_fs', context, + (rule.pattern(0),)) \ + as gen_8: + for x_8 in gen_8: + assert x_8 is None, \ + "rules.fs_incubation: got unexpected plan from when clause 8" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def no_incubation(rule, arg_patterns, arg_context): + engine = rule.rule_base.engine + patterns = rule.goal_arg_patterns() + if len(arg_patterns) == len(patterns): + context = contexts.bc_context(rule) + try: + if all(map(lambda pat, arg: + pat.match_pattern(context, context, + arg, arg_context), + patterns, + arg_patterns)): + rule.rule_base.num_bc_rules_matched += 1 + with engine.prove('questions', 'is_it_divorce_case', context, + (rule.pattern(0),)) \ + as gen_1: + for x_1 in gen_1: + assert x_1 is None, \ + "rules.no_incubation: got unexpected plan from when clause 1" + with engine.prove('questions', 'is_ch_und_15', context, + (rule.pattern(1),)) \ + as gen_2: + for x_2 in gen_2: + assert x_2 is None, \ + "rules.no_incubation: got unexpected plan from when clause 2" + with engine.prove('questions', 'any_def_m', context, + (rule.pattern(1),)) \ + as gen_3: + for x_3 in gen_3: + assert x_3 is None, \ + "rules.no_incubation: got unexpected plan from when clause 3" + with engine.prove('questions', 'any_def_f', context, + (rule.pattern(1),)) \ + as gen_4: + for x_4 in gen_4: + assert x_4 is None, \ + "rules.no_incubation: got unexpected plan from when clause 4" + with engine.prove('questions', 'any_def_mm', context, + (rule.pattern(1),)) \ + as gen_5: + for x_5 in gen_5: + assert x_5 is None, \ + "rules.no_incubation: got unexpected plan from when clause 5" + with engine.prove('questions', 'any_def_fm', context, + (rule.pattern(1),)) \ + as gen_6: + for x_6 in gen_6: + assert x_6 is None, \ + "rules.no_incubation: got unexpected plan from when clause 6" + with engine.prove('questions', 'any_def_ms', context, + (rule.pattern(1),)) \ + as gen_7: + for x_7 in gen_7: + assert x_7 is None, \ + "rules.no_incubation: got unexpected plan from when clause 7" + with engine.prove('questions', 'any_def_fs', context, + (rule.pattern(1),)) \ + as gen_8: + for x_8 in gen_8: + assert x_8 is None, \ + "rules.no_incubation: got unexpected plan from when clause 8" + rule.rule_base.num_bc_rule_successes += 1 + yield + rule.rule_base.num_bc_rule_failures += 1 + finally: + context.done() + +def populate(engine): + This_rule_base = engine.get_create('rules') + + bc_rule.bc_rule('no_money', This_rule_base, 'what_to_happen', + no_money, None, + (pattern.pattern_literal('husband_will_not_pay_money_for_kids_incubation'),), + (), + (pattern.pattern_literal(True), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('inc', This_rule_base, 'what_to_happen', + inc, None, + (pattern.pattern_literal('husband_will_pay_money_for_kids_incubation'),), + (), + (pattern.pattern_literal(True),)) + + bc_rule.bc_rule('kids', This_rule_base, 'what_to_happen', + kids, None, + (pattern.pattern_literal('husband_will_pay_money_for_kids_to_live_a_suitable_life'),), + (), + (pattern.pattern_literal(True),)) + + bc_rule.bc_rule('brea', This_rule_base, 'what_to_happen', + brea, None, + (pattern.pattern_literal('husband_will_pay_for_breastfeeding'),), + (), + (pattern.pattern_literal(True),)) + + bc_rule.bc_rule('house', This_rule_base, 'what_to_happen', + house, None, + (pattern.pattern_literal('husband_will_pay_rent_for_kids_house'),), + (), + (pattern.pattern_literal(True), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('servant', This_rule_base, 'what_to_happen', + servant, None, + (pattern.pattern_literal('husband_will_pay_for_a_servant'),), + (), + (pattern.pattern_literal(True),)) + + bc_rule.bc_rule('her_divorce', This_rule_base, 'what_to_happen', + her_divorce, None, + (pattern.pattern_literal('the_wife_will_give_up_on_all_her_rights'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'),)) + + bc_rule.bc_rule('her_div', This_rule_base, 'what_to_happen', + her_div, None, + (pattern.pattern_literal('the_wife_will_give_husband_money_before_marriage_back'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'),)) + + bc_rule.bc_rule('harm_expense', This_rule_base, 'what_to_happen', + harm_expense, None, + (pattern.pattern_literal('husband_pay_expense_from_2to5_years_of_the_monthly_aliment'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('not_harm_expense', This_rule_base, 'what_to_happen', + not_harm_expense, None, + (pattern.pattern_literal('husband_pay_24_month_expense_of_the_monthly_aliment'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('expense', This_rule_base, 'what_to_happen', + expense, None, + (pattern.pattern_literal('husband_pay_3_month_expense_of_the_monthly_aliment'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('after_divorce', This_rule_base, 'what_to_happen', + after_divorce, None, + (pattern.pattern_literal('husband_pay_after_divorce_money'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('aft_divorce', This_rule_base, 'what_to_happen', + aft_divorce, None, + (pattern.pattern_literal('husband_pay_after_divorce_money'),), + (), + (pattern.pattern_literal(True), + contexts.variable('ans'), + pattern.pattern_literal(False),)) + + bc_rule.bc_rule('incubation', This_rule_base, 'what_to_happen', + incubation, None, + (pattern.pattern_literal('there_is_no_incubation_the_children_free_to_choose_who_to_live_with'),), + (), + (pattern.pattern_literal(False),)) + + bc_rule.bc_rule('m_incubation', This_rule_base, 'what_to_happen', + m_incubation, None, + (pattern.pattern_literal('the_mother_will_have_the_incubation'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + bc_rule.bc_rule('f_incubation', This_rule_base, 'what_to_happen', + f_incubation, None, + (pattern.pattern_literal('the_father_will_have_the_incubation'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + bc_rule.bc_rule('mm_incubation', This_rule_base, 'what_to_happen', + mm_incubation, None, + (pattern.pattern_literal('the_mothers_mother_will_have_the_incubation'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + bc_rule.bc_rule('fm_incubation', This_rule_base, 'what_to_happen', + fm_incubation, None, + (pattern.pattern_literal('the_fathers_mother_will_have_the_incubation'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + bc_rule.bc_rule('ms_incubation', This_rule_base, 'what_to_happen', + ms_incubation, None, + (pattern.pattern_literal('the_mothers_sister_will_have_the_incubation'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + bc_rule.bc_rule('fs_incubation', This_rule_base, 'what_to_happen', + fs_incubation, None, + (pattern.pattern_literal('the_fathers_sister_will_have_the_incubation'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + bc_rule.bc_rule('no_incubation', This_rule_base, 'what_to_happen', + no_incubation, None, + (pattern.pattern_literal('the_child_will_go_to_a_shelter'),), + (), + (pattern.pattern_literal(False), + pattern.pattern_literal(True),)) + + +Krb_filename = '..\\rules.krb' +Krb_lineno_map = ( + ((14, 18), (2, 2)), + ((20, 25), (4, 4)), + ((26, 31), (5, 5)), + ((44, 48), (8, 8)), + ((50, 55), (10, 10)), + ((56, 61), (11, 11)), + ((74, 78), (14, 14)), + ((80, 85), (16, 16)), + ((86, 91), (17, 17)), + ((104, 108), (20, 20)), + ((110, 115), (22, 22)), + ((116, 121), (23, 23)), + ((122, 127), (24, 24)), + ((140, 144), (27, 27)), + ((146, 151), (29, 29)), + ((152, 157), (30, 30)), + ((158, 163), (31, 31)), + ((176, 180), (34, 34)), + ((182, 187), (36, 36)), + ((188, 193), (37, 37)), + ((194, 199), (38, 38)), + ((212, 216), (41, 41)), + ((218, 223), (43, 43)), + ((224, 229), (44, 44)), + ((230, 230), (45, 45)), + ((243, 247), (48, 48)), + ((249, 254), (50, 50)), + ((255, 260), (51, 51)), + ((261, 261), (52, 52)), + ((274, 278), (55, 55)), + ((280, 285), (57, 57)), + ((286, 291), (58, 58)), + ((292, 292), (59, 59)), + ((293, 298), (60, 60)), + ((311, 315), (63, 63)), + ((317, 322), (65, 65)), + ((323, 328), (66, 66)), + ((329, 329), (67, 67)), + ((330, 335), (68, 68)), + ((348, 352), (71, 71)), + ((354, 359), (73, 73)), + ((360, 365), (74, 74)), + ((366, 366), (75, 75)), + ((367, 372), (76, 76)), + ((385, 389), (79, 79)), + ((391, 396), (81, 81)), + ((397, 402), (82, 82)), + ((403, 403), (83, 83)), + ((404, 409), (84, 84)), + ((410, 415), (85, 85)), + ((428, 432), (88, 88)), + ((434, 439), (90, 90)), + ((440, 445), (91, 91)), + ((446, 446), (92, 92)), + ((447, 452), (93, 93)), + ((453, 458), (94, 94)), + ((459, 464), (95, 95)), + ((477, 481), (98, 98)), + ((483, 488), (100, 100)), + ((489, 494), (101, 101)), + ((507, 511), (104, 104)), + ((513, 518), (106, 106)), + ((519, 524), (107, 107)), + ((525, 530), (108, 108)), + ((543, 547), (111, 111)), + ((549, 554), (113, 113)), + ((555, 560), (114, 114)), + ((561, 566), (115, 115)), + ((567, 572), (116, 116)), + ((585, 589), (119, 119)), + ((591, 596), (121, 121)), + ((597, 602), (122, 122)), + ((603, 608), (123, 123)), + ((609, 614), (124, 124)), + ((615, 620), (125, 125)), + ((633, 637), (129, 129)), + ((639, 644), (131, 131)), + ((645, 650), (132, 132)), + ((651, 656), (133, 133)), + ((657, 662), (134, 134)), + ((663, 668), (135, 135)), + ((669, 674), (136, 136)), + ((687, 691), (139, 139)), + ((693, 698), (141, 141)), + ((699, 704), (142, 142)), + ((705, 710), (143, 143)), + ((711, 716), (144, 144)), + ((717, 722), (145, 145)), + ((723, 728), (146, 146)), + ((729, 734), (147, 147)), + ((747, 751), (150, 150)), + ((753, 758), (152, 152)), + ((759, 764), (153, 153)), + ((765, 770), (154, 154)), + ((771, 776), (155, 155)), + ((777, 782), (156, 156)), + ((783, 788), (157, 157)), + ((789, 794), (158, 158)), + ((795, 800), (159, 159)), + ((813, 817), (162, 162)), + ((819, 824), (164, 164)), + ((825, 830), (165, 165)), + ((831, 836), (166, 166)), + ((837, 842), (167, 167)), + ((843, 848), (168, 168)), + ((849, 854), (169, 169)), + ((855, 860), (170, 170)), + ((861, 866), (171, 171)), +) diff --git a/Law-expert_system/pythonProject/Law_system/facts.kfb b/Law-expert_system/pythonProject/Law_system/facts.kfb new file mode 100644 index 0000000..b28b04f --- /dev/null +++ b/Law-expert_system/pythonProject/Law_system/facts.kfb @@ -0,0 +1,3 @@ + + + diff --git a/Law-expert_system/pythonProject/Law_system/main.py b/Law-expert_system/pythonProject/Law_system/main.py new file mode 100644 index 0000000..3b1b3b6 --- /dev/null +++ b/Law-expert_system/pythonProject/Law_system/main.py @@ -0,0 +1,26 @@ +import contextlib +import sys + +from pyke import knowledge_engine +from pyke import krb_traceback + +engine = knowledge_engine.engine(__file__) + +def family_court(): + + engine.reset() + + engine.activate('rules') + + try: + with engine.prove_goal('rules.what_to_happen($event)') as rule: + for vars, plan in rule: + print("%s" % (vars['event'])) + except Exception: + krb_traceback.print_exc() + sys.exit(1) + + print() + print("thanks for using our system") +family_court() + diff --git a/Law-expert_system/pythonProject/Law_system/questions.kqb b/Law-expert_system/pythonProject/Law_system/questions.kqb new file mode 100644 index 0000000..e60573d --- /dev/null +++ b/Law-expert_system/pythonProject/Law_system/questions.kqb @@ -0,0 +1,138 @@ +# questions.kqb +is_it_divorce_case($ans) + If it is aliment case enter y if it is incubation n? + --- + $ans =yn + +is_M_have_incubation($ans) + Does the mother have the incubation? + --- + $ans =yn + +is_child_under_2years($ans) + Is the child under 2 years? + --- + $ans =yn + +is_wife_staying_your_house($ans) + is the wife staying in the house? + --- + $ans =yn + +is_D_rich($ans) + Is the husband rich enough to pay a servant? + --- + $ans =yn + +ch_div_st($ans) + What is the kind of divorce? + --- + $ans = select_1 + 1: Normal divorce + 2: Wife divorced the Husband + 3: Divorced for harm + 4: None of the above + ! Sorry, that is impossible + +any_defect($ans) + If the wife have done any of these defects enter y if not enter n + 1! prevented herself from her husband without a legitimate excuse + 2! left their home without a legitimate excuse + 3! prevented her husband from entering their house without a legitimate excuse + 4! A case was issued restricting her freedom in the rights of her husband + 5! She broke her commitment to her husband? + --- + $ans =yn + +is_it_in_contract($ans) + Is the after divorce money in the marriage contract? + --- + $ans =yn + +is_there_witness($ans) + Is there any witness on the contract? + --- + $ans =yn + + +is_ch_und_15($ans) + Do you have a girl under 17 or a boy under 15? + --- + $ans=yn + + +any_def_m($ans) + If mother not alive or alive suffering from any of these enter y if not enter n + 1! she is insane + 2! have diseases prevent her from raising the children + 3! she is addicted to drugs + 4! she is proven cheating on her husband + 5! she will travel outside the country and take the kids + 6! she is married to a stranger from the child + 7! she did practice professions that violate religion and the law + 8! She is not trusted, such as if she frequently go out and leave the child alone? + --- + $ans =yn + +any_def_f($ans) + If father not alive or alive suffering from any of these enter y if not enter n + 1! he is insane + 2! he has commit crimes before + 3! he is immoral + 4! he do not have a woman in the house to raise the children + 5! he will travel outside the country and take the kids + 6! it been 6 months before the father raised the case without an acceptable excuse? + --- + $ans =yn + +any_def_mm($ans) + If mothers mother dead or alive suffering from any of these enter y if not enter n + 1! she is insane + 2! have diseases prevent her from raising the children + 3! she is addicted to drugs + 4! she is proven cheating on her husband + 5! she will travel outside the country and take the kids + 6! she is married to a stranger from the child + 7! she did practice professions that violate religion and the law + 8! She is not trusted, such as if she frequently go out and leave the child alone? + --- + $ans =yn + +any_def_fm($ans) + If fathers mother dead or alive suffers from any of these enter y if not enter n + 1! she is insane + 2! have diseases prevent her from raising the children + 3! she is addicted to drugs + 4! she is proven cheating on her husband + 5! she will travel outside the country and take the kids + 6! she is married to a stranger from the child + 7! she did practice professions that violate religion and the law + 8! She is not trusted, such as if she frequently go out and leave the child alone? + --- + $ans =yn + +any_def_ms($ans) + If mothers sister dead or alive suffers from any of these enter y if not enter n + 1! she is insane + 2! have diseases prevent her from raising the children + 3! she is addicted to drugs + 4! she is proven cheating on her husband + 5! she will travel outside the country and take the kids + 6! she is married to a stranger from the child + 7! she did practice professions that violate religion and the law + 8! She is not trusted, such as if she frequently go out and leave the child alone? + --- + $ans =yn + +any_def_fs($ans) + If fathers sister dead or alive suffers from any of these enter y if not enter n + 1! she is insane + 2! have diseases prevent her from raising the children + 3! she is addicted to drugs + 4! she is proven cheating on her husband + 5! she will travel outside the country and take the kids + 6! she is married to a stranger from the child + 7! she did practice professions that violate religion and the law + 8! She is not trusted, such as if she frequently go out and leave the child alone? + --- + $ans =yn diff --git a/Law-expert_system/pythonProject/Law_system/rules.krb b/Law-expert_system/pythonProject/Law_system/rules.krb new file mode 100644 index 0000000..7341ecb --- /dev/null +++ b/Law-expert_system/pythonProject/Law_system/rules.krb @@ -0,0 +1,171 @@ +no_money + use what_to_happen(husband_will_not_pay_money_for_kids_incubation) + when + questions.is_it_divorce_case(True) + questions.is_M_have_incubation(False) + +inc + use what_to_happen(husband_will_pay_money_for_kids_incubation) + when + questions.is_it_divorce_case(True) + questions.is_M_have_incubation(True) + +kids + use what_to_happen(husband_will_pay_money_for_kids_to_live_a_suitable_life) + when + questions.is_it_divorce_case(True) + questions.is_M_have_incubation(True) + +brea + use what_to_happen(husband_will_pay_for_breastfeeding) + when + questions.is_it_divorce_case(True) + questions.is_M_have_incubation(True) + questions.is_child_under_2years(True) + +house + use what_to_happen(husband_will_pay_rent_for_kids_house) + when + questions.is_it_divorce_case(True) + questions.is_M_have_incubation(True) + questions.is_wife_staying_your_house(False) + +servant + use what_to_happen(husband_will_pay_for_a_servant) + when + questions.is_it_divorce_case(True) + questions.is_M_have_incubation(True) + questions.is_D_rich(True) + +her_divorce + use what_to_happen(the_wife_will_give_up_on_all_her_rights) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (2,) + +her_div + use what_to_happen(the_wife_will_give_husband_money_before_marriage_back) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (2,) + +harm_expense + use what_to_happen(husband_pay_expense_from_2to5_years_of_the_monthly_aliment) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (3,) + questions.any_defect(False) + +not_harm_expense + use what_to_happen(husband_pay_24_month_expense_of_the_monthly_aliment) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (1,) + questions.any_defect(False) + +expense + use what_to_happen(husband_pay_3_month_expense_of_the_monthly_aliment) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (1,3) + questions.any_defect(False) + +after_divorce + use what_to_happen(husband_pay_after_divorce_money) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (1,3) + questions.is_it_in_contract(True) + questions.any_defect(False) + +aft_divorce + use what_to_happen(husband_pay_after_divorce_money) + when + questions.is_it_divorce_case(True) + questions.ch_div_st($ans) + check $ans in (1,3) + questions.is_it_in_contract(False) + questions.is_there_witness(True) + questions.any_defect(False) + +incubation + use what_to_happen(there_is_no_incubation_the_children_free_to_choose_who_to_live_with) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(False) + +m_incubation + use what_to_happen(the_mother_will_have_the_incubation) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(False) + +f_incubation + use what_to_happen(the_father_will_have_the_incubation) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(True) + questions.any_def_f(False) + +mm_incubation + use what_to_happen(the_mothers_mother_will_have_the_incubation) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(True) + questions.any_def_f(True) + questions.any_def_mm(False) + + +fm_incubation + use what_to_happen(the_fathers_mother_will_have_the_incubation) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(True) + questions.any_def_f(True) + questions.any_def_mm(True) + questions.any_def_fm(False) + +ms_incubation + use what_to_happen(the_mothers_sister_will_have_the_incubation) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(True) + questions.any_def_f(True) + questions.any_def_mm(True) + questions.any_def_fm(True) + questions.any_def_ms(False) + +fs_incubation + use what_to_happen(the_fathers_sister_will_have_the_incubation) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(True) + questions.any_def_f(True) + questions.any_def_mm(True) + questions.any_def_fm(True) + questions.any_def_ms(True) + questions.any_def_fs(False) + +no_incubation + use what_to_happen(the_child_will_go_to_a_shelter) + when + questions.is_it_divorce_case(False) + questions.is_ch_und_15(True) + questions.any_def_m(True) + questions.any_def_f(True) + questions.any_def_mm(True) + questions.any_def_fm(True) + questions.any_def_ms(True) + questions.any_def_fs(True) \ No newline at end of file