
    hj                        S r  " S S5      r\S:X  Gam  \" S5        \" 5       r\" S5        \R                  S5      r\" S\S    35        \" S	\S
    35        \" S5        \R                  S5      r\" S\S    35        \S   (       a  \" S\S    35        \" S5        \R                  S5      r\" S\S    35        \" S\S   S 35        \" S5        \R                  S5      r\" S\S   S    35        \" S5        \" S\	" \R                  5       35        \" S\	" \R                  5       35        \" S\	" \R                  5       35        \" S5        \" S 5        \" S!5        \" S"5        \" S#5        \" S$5        g%g%)&z@
Common Sense Knowledge Base - Basic understanding of the world
c                   2    \ rS rSrS rS rS rS rS rSr	g)	CommonSenseKB   c                 N    0 U l         0 U l        0 U l        U R                  5         g )N)physics_rulessocial_rulespractical_knowledgeload_knowledgeselfs    B/home/james-whalen/eden-agi-project/core/knowledge/common_sense.py__init__CommonSenseKB.__init__   s&    #%     c                 Z    SSSSSSSS.U l         S	S
SSSSS.U l        SSSSSSS.U l        g)z!Load basic common sense knowledgez!Objects fall down without supportz,Solid objects cannot pass through each otherzTime only moves forwardzFire is hot and can burn thingsz)Water flows downward and makes things wetzLight travels in straight linesz)Hot things cool down, cold things warm up)gravitysolid_objectstimefirewaterlighttemperaturez$People greet each other when meetingzPeople prefer personal spacez+In conversation, people take turns speakingz$Helping others is generally positivez"Being truthful is generally valuedz%Saying please and thank you is polite)greetingpersonal_spaceturn_takinghelpinghonesty
politenessz'People need to eat regularly to survivezPeople need sleep to functionz'Tools help accomplish tasks more easilyz"Practice improves skills over timez"Planning ahead helps achieve goalsz.Clear communication prevents misunderstandings)eatingsleepingtoolslearningplanningcommunicationN)r   r   r   r
   s    r   r	   CommonSenseKB.load_knowledge   s`    
 ;K-5@6F
 ?<H=;A
 @7><<M$
 r   c                    UR                  5       n/ n/ nSU;   a  UR                  S5        SU;   d  SU;   a  UR                  S5        SU;   a  SU;   a  UR                  S5        S	U;   d  S
U;   a  UR                  S5        SU;   a  UR                  S5        SU;   a  SU;   a  UR                  S5        SU;   a  SU;   a  UR                  S5        U[        U5      S:H  UUS.$ )z+Check if statement aligns with common sensezfall upz,Objects don't fall upward (violates gravity)zthrough wallzpass throughz+Solid objects can't pass through each otherznever speakconversationzConversations require speakingznever sleepzno sleepzHumans need sleep to survivez	never eatzHumans need food to surviver   fallzAligns with gravity rulespracticeimprovezAligns with learning principles    )	statementmakes_sense
violationsconfirmations)lowerappendlen)r   r+   statement_lowerr-   r.   s        r   check_statementCommonSenseKB.check_statement.   s   #//+
 'LM_,/0QKL O+/0Q>? O+z_/L<=/);< 'Fo,E  !<=(Y/-I  !BC #z?a/$*	
 	
r   c                    UR                  5       n/ n/ nSU;   d  SU;   a/  UR                  U R                  S   5        UR                  S5        SU;   d  SU;   a/  UR                  U R                  S   5        UR                  S5        SU;   d  S	U;   a/  UR                  U R                  S	   5        UR                  S
5        SU;   a/  UR                  U R                  S   5        UR                  S5        SU;   d  SU;   a/  UR                  U R                  S   5        UR                  S5        UUU[        U5      S-  S.$ )z(Apply common sense reasoning to scenariodropr'   r   zObject will fall downwardr   flamezWill be hot, risk of burningmeetr   z#People will likely greet each otherr&   r   zPeople will take turns speakingr(   learnr!   z Skill will improve with practice   )scenariorelevant_knowledgepredictions
confidence)r/   r0   r   r   r   r1   )r   r;   scenario_lowerr<   r=   s        r   reason_aboutCommonSenseKB.reason_aboutR   sN   !) ^#v'?%%d&8&8&CD:;^#w.'@%%d&8&8&@A=> ^#z^'C%%d&7&7
&CDDE^+%%d&7&7&FG@A '7n+D%%d&>&>z&JKAB !"4&01A5	
 	
r   c                 R   UR                  5       n/ nSU;   a  UR                  S5        SU;   a  UR                  S5        SU;   a  UR                  S5        SU;   a  SU;   a  UR                  S	5        S
U;   a  UR                  S5        U(       d  UR                  S5        UUS.$ )z0Explain why something is true using common senser'   z8Because of gravity - all objects are pulled toward Earthsleepz5Because bodies need rest to repair and restore energyeatz1Because bodies need fuel (food) to produce energyr(   r)   zGBecause repetition strengthens neural pathways and builds muscle memoryhotz6Because heat is energy that transfers to other objectsz#I need more context to explain this)questionexplanations)r/   r0   )r   rF   question_lowerrG   s       r   explain_whyCommonSenseKB.explain_whyw   s    !)^# Z[n$ WXN" ST'I,G ijN" XY EF !(
 	
r   )r   r   r   N)
__name__
__module____qualname____firstlineno__r   r	   r3   r@   rI   __static_attributes__ r   r   r   r      s     
D"
H#
J
r   r   __main__zCOMMON SENSE KB TESTu;   
✅ Checking statement: 'Objects fall down due to gravity'z Objects fall down due to gravityz   Makes sense: r,   z   Confirmations: r.   u3   
❌ Checking statement: 'I can walk through walls'zI can walk through wallsr-   z   Violations: u)   
🤔 Reasoning about: 'If I drop a ball'zIf I drop a ballz   Predictions: r=   z   Confidence: r>   z.0%u"   
💡 Why do people need to sleep?zWhy do people need to sleep?z   rG   r*   u   
📚 Knowledge areas:z   Physics rules: z   Social rules: z   Practical knowledge: u   
🌍 Eden now has:z    - Basic physics understandingz   - Social reasoningz   - Practical knowledgez   - Common sense checkingu    
✅ COMMON SENSE KB OPERATIONALN)__doc__r   rK   printkbr3   resultr@   rI   r1   r   r   r   rP   r   r   <module>rV      s  M
 M
^ z	
 !	B 

HI BCF	VM23
45	vo67
89	
@A :;F	VM23
45l| 4567 

67__/0F	VM23
45	OF<05
67 

/0^^:;F	C~&q)*
+,	#%	s2#3#345
67	c"//23
45	$S)?)?%@$A
BC	
 !	
,-	
!"	
$%	
&'	
-.O r   