From 6cb9ee72ba1b2dffcbe418129a110c1d0bbcc0b3 Mon Sep 17 00:00:00 2001 From: "Dobbertin, Niclas" Date: Fri, 10 May 2024 09:08:22 +0200 Subject: progress --- modeling/prod_addition.py | 316 ++++++++++++++++++++++++++++++---------------- 1 file changed, 209 insertions(+), 107 deletions(-) (limited to 'modeling/prod_addition.py') diff --git a/modeling/prod_addition.py b/modeling/prod_addition.py index 3c7e888..b96820c 100644 --- a/modeling/prod_addition.py +++ b/modeling/prod_addition.py @@ -4,22 +4,19 @@ def addition(Model): prods = [] - start_add = Model.productionstring( - name="start_add", + # Try retrieve result from DM + add_start = Model.productionstring( + name="add_start", string=""" =g> isa math_goal op add - task calc - =imaginal> - isa math_op - op add - ones1 =num1 - ones2 =num2 - ones_ans None + arg1 =num1 + arg2 =num2 + ones_ans None ==> - =imaginal> - isa math_op + =g> + isa math_goal ones_ans busy +retrieval> isa math_op @@ -28,17 +25,112 @@ def addition(Model): arg2 =num2 """, ) - prods.append(start_add) + prods.append(add_start) - add_ones = Model.productionstring( - name="add_ones", + # Can remember addition fact, addition done + add_retrieve_success = Model.productionstring( + name="add_retrieve_success", string=""" =g> isa math_goal - task calc - =imaginal> + op add + arg1 =num1 + arg2 =num2 + =retrieval> + isa math_op + op add + arg1 =num1 + arg2 =num2 + result =result + ==> + =g> + isa math_goal + op done + +imaginal> isa math_op op add + arg1 =num1 + arg2 =num2 + result =result + ~retrieval> + """ + ) + prods.append(add_retrieve_success) + + # Cannot remember addition fact, split arguments into digits for column add + add_retrieve_failure = Model.productionstring( + name="add_retrieve_failure", + string=""" + =g> + isa math_goal + op add + arg1 =num1 + arg2 =num2 + ?retrieval> + state error + ==> + ~retrieval> + +retrieval> + isa number + number =num1 + ~retrieval> + +retrieval> + isa number + number =num2 + """ + ) + prods.append(add_retrieve_failure) + + add_expand_arg1 = Model.productionstring( + name="number_expand_arg1", + string=""" + =g> + isa math_goal + op add + arg1 =num + =retrieval> + isa number + number =num + ones =one + tens =ten + hundreds =hun + ==> + =g> + ones1 =one + tens1 =ten + hundreds1 =hun + """ + ) + prods.append(add_expand_arg1) + + add_expand_arg2 = Model.productionstring( + name="number_expand_arg2", + string=""" + =g> + isa math_goal + op add + arg2 =num + =retrieval> + isa number + number =num + ones =one + tens =ten + hundreds =hun + ==> + =g> + ones2 =one + tens2 =ten + hundreds2 =hun + """ + ) + prods.append(add_expand_arg2) + + add_ones = Model.productionstring( + name="add_ones", + string=""" + =g> + isa math_goal + op add ones_ans busy ones1 =num1 ones2 =num2 @@ -48,10 +140,10 @@ def addition(Model): arg2 =num2 result =result ==> - =imaginal> - isa math_op + =g> + isa math_goal ones_ans =result - carry_ones busy + carry busy +retrieval> isa math_op op add @@ -66,13 +158,10 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add tens1 =num1 tens2 =num2 - carry_ones busy + carry busy ones_ans =ones =retrieval> isa math_op @@ -81,10 +170,10 @@ def addition(Model): result =ones arg2 =remainder ==> - =imaginal> - isa math_op + =g> + isa math_goal op add - carry_ones 1 + carry 1 tens_ans busy ones_ans =remainder +retrieval> @@ -101,20 +190,17 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add tens1 =num1 tens2 =num2 ones_ans =ones - carry_ones busy + carry busy ?retrieval> state error ==> - =imaginal> - isa math_op - carry_ones None + =g> + isa math_goal + carry None tens_ans busy ~retrieval> +retrieval> @@ -130,21 +216,18 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add tens_ans busy - carry_ones None + carry None =retrieval> isa math_op op add result =sum ==> - =imaginal> - isa math_op + =g> + isa math_goal tens_ans =sum - carry_tens busy + carry busy +retrieval> isa math_op op add @@ -159,14 +242,11 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add tens_ans busy tens1 =num1 tens2 =num2 - carry_ones 1 + carry 1 =retrieval> isa math_op op add @@ -174,9 +254,9 @@ def addition(Model): arg1 =num1 arg2 =num2 ==> - =imaginal> - isa math_op - carry_ones None + =g> + isa math_goal + carry None ~retrieval> +retrieval> isa math_op @@ -193,13 +273,10 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add hundreds1 =num1 hundreds2 =num2 - carry_tens busy + carry busy tens_ans =tens =retrieval> isa math_op @@ -208,10 +285,10 @@ def addition(Model): result =tens arg2 =remainder ==> - =imaginal> - isa math_op + =g> + isa math_goal op add - carry_tens 1 + carry 1 hundreds_ans busy tens_ans =remainder +retrieval> @@ -228,20 +305,17 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add hundreds1 =num1 hundreds2 =num2 tens_ans =tens - carry_tens busy + carry busy ?retrieval> state error ==> - =imaginal> - isa math_op - carry_tens None + =g> + isa math_goal + carry None hundreds_ans busy ~retrieval> +retrieval> @@ -257,12 +331,9 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add hundreds_ans busy - carry_tens None + carry None =retrieval> isa math_op op add @@ -270,9 +341,7 @@ def addition(Model): ==> =g> isa math_goal - task done - =imaginal> - isa math_op + op add_result hundreds_ans =sum """, ) @@ -283,14 +352,11 @@ def addition(Model): string=""" =g> isa math_goal - task calc - =imaginal> - isa math_op - op add + op add hundreds_ans busy hundreds1 =num1 hundreds2 =num2 - carry_tens 1 + carry 1 =retrieval> isa math_op op add @@ -298,9 +364,9 @@ def addition(Model): arg1 =num1 arg2 =num2 ==> - =imaginal> - isa math_op - carry_tens None + =g> + isa math_goal + carry None ~retrieval> +retrieval> isa math_op @@ -311,37 +377,73 @@ def addition(Model): ) prods.append(add_hundreds_carry) - addition_done = Model.productionstring( - name="addition_done", + add_result_contract = Model.productionstring( + name="add_result_contract", string=""" =g> isa math_goal - task done - =imaginal> - isa math_op - op add - arg1 =arg1 - ones1 =ones1 - tens1 =tens1 - hundreds1 =huns1 - arg2 =arg2 - ones2 =ones2 - tens2 =tens2 - hundreds2 =huns2 + op add_result + ones_ans =one + tens_ans =ten + hundreds_ans =hun ==> + ~retrieval> +retrieval> - isa math_op + isa number + ones =one + tens =ten + hundreds =hun + """ + ) + prods.append(add_result_contract) + + add_contract_done = Model.productionstring( + name="add_contract_done", + string=""" + =g> + isa math_goal + op add_result + arg1 =arg1 + arg2 =arg2 + ones_ans =one + tens_ans =ten + hundreds_ans =hun + =retrieval> + isa number + number =result + ones =one + tens =ten + hundreds =hun + ==> + =g> + isa math_goal op add - arg1 =arg1 - ones1 =ones1 - tens1 =tens1 - hundreds1 =huns1 - arg2 =arg2 - ones2 =ones2 - tens2 =tens2 - hundreds2 =huns2 + result =result """ ) - prods.append(addition_done) + prods.append(add_contract_done) + add_done = Model.productionstring( + name="add_done", + string=""" + =g> + isa math_goal + op add + arg1 =arg1 + arg2 =arg2 + result ~None + result =result + ==> + +imaginal> + isa math_op + op add + arg1 =arg1 + arg2 =arg2 + result =result + =g> + isa math_goal + op done + """ + ) + prods.append(add_done) return prods -- cgit v1.2.3