bowen-xu / PyNARS

MIT License
26 stars 8 forks source link

Add simple eventbuffer and generate temporal results for #95 #96

Closed ccrock4t closed 5 months ago

ccrock4t commented 5 months ago

I added a simple version of event buffer.

This buffer holds first-order events, sorted by time.

The purpose of this buffer is to generate temporal implication statements, e.g., (A &/ B =/> C) and compound events, e.g., (A &/ B).

The operation for generating temporal statements is exhaustive.

The oldest events are at the lowest index, the newest events are at the highest index. The larger the event's timestamp, the newer it is.

github-actions[bot] commented 5 months ago

dev.txt - DEV BRANCH: FAILED (failures=55, errors=13) pr.txt - PR BRANCH: FAILED (failures=55, errors=12)

--- dev.txt 2024-03-10 03:01:24.410362525 +0000
+++ pr.txt  2024-03-10 03:01:24.414362518 +0000
@@ -93,7 +93,7 @@
 test_uni_decomposition_3 (test_NAL3.TEST_NAL3)
 'What differs boys from gials are being strong. ... FAIL
 test_structural_transformation_0 (test_NAL4.TEST_NAL4)
-'Structural transformation ... FAIL
+'Structural transformation ... ok
 test_structural_transformation_1 (test_NAL4.TEST_NAL4)
 'Structural transformation ... ok
 test_structural_transformation_10 (test_NAL4.TEST_NAL4)
@@ -140,7 +140,7 @@
 test_conditional_deduction_0 (test_NAL5.TEST_NAL5)
 'Detachment ... ok
 test_conditional_deduction_compound_eliminate_0 (test_NAL5.TEST_NAL5)
-'conditional deduction ... FAIL
+'conditional deduction ... ok
 test_conditional_deduction_compound_eliminate_1 (test_NAL5.TEST_NAL5)
 'conditional deduction ... ok
 test_conditional_deduction_compound_replace_0 (test_NAL5.TEST_NAL5)
@@ -226,7 +226,7 @@
 test_multiple_variables_introduction_0 (test_NAL6.TEST_NAL6)
 'Multiple variables introduction ... FAIL
 test_multiple_variables_introduction_1 (test_NAL6.TEST_NAL6)
-'Multiple variables introduction ... FAIL
+'Multiple variables introduction ... ok
 test_nlp1 (test_NAL6.TEST_NAL6)
 <(\,REPRESENT,_,CAT) --> cat>. %1.00;0.90% ... ok
 test_nlp2 (test_NAL6.TEST_NAL6)
@@ -260,11 +260,11 @@
 test_unification_4 (test_NAL6.TEST_NAL6)
 'Variable unification ... ok
 test_unification_5 (test_NAL6.TEST_NAL6)
-'Variable unification ... ERROR
+'Variable unification ... ok
 test_unification_5_1 (test_NAL6.TEST_NAL6)
 'Variable unification ... ok
 test_unification_6 (test_NAL6.TEST_NAL6)
-'Variable unification ... ok
+'Variable unification ... FAIL
 test_unification_a1 (test_NAL6.TEST_NAL6)
 'Variable unification ... FAIL
 test_variable_elimination_deduction (test_NAL6.TEST_NAL6)
@@ -315,7 +315,7 @@
 test_inference_on_tense_1 (test_NAL7.TEST_NAL7)
 ' inference on tense ... FAIL
 test_inference_on_tense_2 (test_NAL7.TEST_NAL7)
-' inference on tense ... ok
+' inference on tense ... FAIL
 test_analogy_0_0__0 (test_NAL7.TEST_NAL7_ANALOGY) ... ok
 test_analogy_0_0__1 (test_NAL7.TEST_NAL7_ANALOGY) ... ok
 test_analogy_0_0__2 (test_NAL7.TEST_NAL7_ANALOGY) ... ok
@@ -353,7 +353,7 @@
 test_1_13_var (test_NAL8.TEST_NAL8)
 nal8.1.13.nal ... ERROR
 test_1_14 (test_NAL8.TEST_NAL8)
-nal8.1.14.nal ... ok
+nal8.1.14.nal ... FAIL
 test_1_16 (test_NAL8.TEST_NAL8)
 nal8.1.16.nal ... FAIL
 test_1_2 (test_NAL8.TEST_NAL8)
ccrock4t commented 5 months ago

If we want to compose 4-component implication such as (&/,A,B,C) =/> D wouldn't this result in n^4 and so on for longer sequences? @maxeeem

Yep, I agree if we are exhaustively creating all compounds, the time complexity will depend how many components we want to piece together at a time (i.e., how many nested For loops). For now since we only want the most simple version, we will only do the 3 components, which includes the precondition $A$, operation $B$, and postcondition $C$.

To include more components in the compounds, such a 4-component implications, we could explicitly create them (which, as you mentioned would worsen the time complexity). Alternatively, we could try to let NAL implicitly handle them by simplifying expressions. For example, we can consider letting compound events like (&/,A,B) into the EventBuffer. Then the event would fit into a "3-component" implication (&/,(&/,A,B),C =/> D), which simplifies to the 4-component implication (&/,A,B,C =/> D)

bowen-xu commented 5 months ago

@ccrock4t Good work! Do you have test-case(s) on the event-buffer?

ccrock4t commented 5 months ago

Sure, I can add them

ccrock4t commented 5 months ago

@bowen-xu Some tests are added now, in a new Buffer Test file

ccrock4t commented 5 months ago

The flow is like this:

image