From 3fcf103c9da2444ee3f93f92ac4c811a987b5e90 Mon Sep 17 00:00:00 2001 From: "Dobbertin, Niclas" Date: Fri, 10 May 2024 17:34:53 +0200 Subject: working on procedures --- modeling/prod_addition.py | 309 +++++++++++++++++++++++----------------------- 1 file changed, 155 insertions(+), 154 deletions(-) (limited to 'modeling/prod_addition.py') diff --git a/modeling/prod_addition.py b/modeling/prod_addition.py index b96820c..a56fc73 100644 --- a/modeling/prod_addition.py +++ b/modeling/prod_addition.py @@ -14,10 +14,11 @@ def addition(Model): arg1 =num1 arg2 =num2 ones_ans None + ?retrieval> + state free ==> =g> isa math_goal - ones_ans busy +retrieval> isa math_op op add @@ -46,14 +47,15 @@ def addition(Model): =g> isa math_goal op done - +imaginal> - isa math_op - op add - arg1 =num1 - arg2 =num2 result =result + +imaginal> + isa math_op + op add + arg1 =num1 + arg2 =num2 + result =result ~retrieval> - """ + """, ) prods.append(add_retrieve_success) @@ -64,66 +66,27 @@ def addition(Model): =g> isa math_goal op add - arg1 =num1 - arg2 =num2 + ones1 =num1 + ones2 =num2 + ones_carry ~busy + tens_carry ~busy + tens_ans ~busy + hundreds_ans ~busy ?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 + ones_ans busy + +retrieval> + isa math_op 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) + arg1 =num1 + arg2 =num2 - 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) + prods.append(add_retrieve_failure) add_ones = Model.productionstring( name="add_ones", @@ -136,6 +99,7 @@ def addition(Model): ones2 =num2 =retrieval> isa math_op + op add arg1 =num1 arg2 =num2 result =result @@ -143,7 +107,7 @@ def addition(Model): =g> isa math_goal ones_ans =result - carry busy + ones_carry busy +retrieval> isa math_op op add @@ -161,7 +125,7 @@ def addition(Model): op add tens1 =num1 tens2 =num2 - carry busy + ones_carry busy ones_ans =ones =retrieval> isa math_op @@ -173,9 +137,10 @@ def addition(Model): =g> isa math_goal op add - carry 1 + ones_carry 1 tens_ans busy ones_ans =remainder + ~retrieval> +retrieval> isa math_op op add @@ -194,13 +159,14 @@ def addition(Model): tens1 =num1 tens2 =num2 ones_ans =ones - carry busy + ones_carry busy + tens_ans None ?retrieval> state error ==> =g> isa math_goal - carry None + ones_carry None tens_ans busy ~retrieval> +retrieval> @@ -211,31 +177,33 @@ def addition(Model): ) prods.append(no_carry_ones) - add_tens_done = Model.productionstring( - name="add_tens_done", + add_tens = Model.productionstring( + name="add_tens", string=""" =g> isa math_goal op add tens_ans busy - carry None + tens1 =num1 + tens2 =num2 =retrieval> isa math_op op add + arg1 =num1 + arg2 =num2 result =sum ==> =g> isa math_goal tens_ans =sum - carry busy + tens_carry busy +retrieval> isa math_op op add arg1 10 result =sum - """, - ) - prods.append(add_tens_done) + """,) + prods.append(add_tens) add_tens_carry = Model.productionstring( name="add_tens_carry", @@ -243,30 +211,48 @@ def addition(Model): =g> isa math_goal op add - tens_ans busy + tens_ans =ten_ans tens1 =num1 tens2 =num2 - carry 1 - =retrieval> - isa math_op - op add - result =sum - arg1 =num1 - arg2 =num2 + ones_carry 1 + ?retrieval> + state free ==> =g> isa math_goal - carry None - ~retrieval> +retrieval> isa math_op op add arg1 1 - arg2 =sum + arg2 =ten_ans """, ) prods.append(add_tens_carry) + add_tens_carry_done = Model.productionstring( + name="add_tens_carry_done", + string=""" + =g> + isa math_goal + op add + tens_ans =ten_ans + tens1 =num1 + tens2 =num2 + ones_carry 1 + =retrieval> + isa math_op + op add + arg1 1 + arg2 =ten_ans + result =result + ==> + =g> + isa math_goal + tens_ans =result + ones_carry None + """, + ) + prods.append(add_tens_carry_done) process_carry_tens = Model.productionstring( name="process_carry_tens", @@ -274,9 +260,7 @@ def addition(Model): =g> isa math_goal op add - hundreds1 =num1 - hundreds2 =num2 - carry busy + tens_carry busy tens_ans =tens =retrieval> isa math_op @@ -288,14 +272,9 @@ def addition(Model): =g> isa math_goal op add - carry 1 - hundreds_ans busy + tens_carry 1 tens_ans =remainder - +retrieval> - isa math_op - op add - arg1 =num1 - arg2 =num2 + ~retrieval> """, ) prods.append(process_carry_tens) @@ -306,34 +285,53 @@ def addition(Model): =g> isa math_goal op add - hundreds1 =num1 - hundreds2 =num2 tens_ans =tens - carry busy + tens_carry busy ?retrieval> state error ==> =g> isa math_goal - carry None - hundreds_ans busy + tens_carry None ~retrieval> + """, + ) + prods.append(no_carry_tens) + + add_hundreds_start = Model.productionstring( + name="add_hundreds_start", + string=""" + =g> + isa math_goal + op add + ones_carry None + tens_ans ~None + hundreds1 =hun1 + hundreds2 =hun2 + ?retrieval> + state free + ==> + =g> + isa math_goal + hundreds_ans busy +retrieval> isa math_op - arg1 =num1 - arg2 =num2 + op add + arg1 =hun1 + arg2 =hun2 """, ) - prods.append(no_carry_tens) + prods.append(add_hundreds_start) - add_hundreds_done = Model.productionstring( - name="add_hundreds_done", + add_hundreds = Model.productionstring( + name="add_hundreds", string=""" =g> isa math_goal op add hundreds_ans busy - carry None + tens_carry None + ones_carry None =retrieval> isa math_op op add @@ -341,11 +339,12 @@ def addition(Model): ==> =g> isa math_goal - op add_result + op add_done hundreds_ans =sum + ~retrieval> """, ) - prods.append(add_hundreds_done) + prods.append(add_hundreds) add_hundreds_carry = Model.productionstring( name="add_hundreds_carry", @@ -356,7 +355,8 @@ def addition(Model): hundreds_ans busy hundreds1 =num1 hundreds2 =num2 - carry 1 + tens_carry 1 + ones_carry None =retrieval> isa math_op op add @@ -366,7 +366,7 @@ def addition(Model): ==> =g> isa math_goal - carry None + tens_carry None ~retrieval> +retrieval> isa math_op @@ -377,58 +377,58 @@ def addition(Model): ) prods.append(add_hundreds_carry) - add_result_contract = Model.productionstring( - name="add_result_contract", - string=""" - =g> - isa math_goal - op add_result - ones_ans =one - tens_ans =ten - hundreds_ans =hun - ==> - ~retrieval> - +retrieval> - isa number - ones =one - tens =ten - hundreds =hun - """ - ) - prods.append(add_result_contract) + # add_result_contract = Model.productionstring( + # name="add_result_contract", + # string=""" + # =g> + # isa math_goal + # op add_result + # ones_ans =one + # tens_ans =ten + # hundreds_ans =hun + # ==> + # ~retrieval> + # +retrieval> + # 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 - result =result - """ - ) - prods.append(add_contract_done) + # 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 + # result =result + # """ + # ) + # prods.append(add_contract_done) add_done = Model.productionstring( name="add_done", string=""" =g> isa math_goal - op add + op add_done arg1 =arg1 arg2 =arg2 result ~None @@ -443,7 +443,8 @@ def addition(Model): =g> isa math_goal op done - """ - ) + ~retrieval> + """, + ) prods.append(add_done) return prods -- cgit v1.2.3