summaryrefslogtreecommitdiff
path: root/modeling/prod_multi.py
blob: 4b4e7c55eb6d22b0b3cfa40c4022e4fa71f49cdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3


def multiplication(Model):
    prods = []

    # TODO: switch operands so less steps are needed
    # switch_mul = Model.productionstring(
    #     name="switch_mul",
    #     string="""
    #     =g>
    #     =imaginal>
    #     ==>
    #     =imaginal>
    # """,
    # )
    # prods.append(switch_mul)

    start_mul = Model.productionstring(
        name="start_mul",
        string="""
        =g>
        isa         math_goal
        op          mul
        =imaginal>
        isa          math_op
        op           mul
        arg1        ~0
        arg1        ~1
        arg2        ~0
        arg1        ~1
        arg1        =mul
        arg2        =arg
        ones2       =ones
        tens2       =tens
        hundreds2   =huns
        ==>
        !g>
        show        terminal
        +g>
        isa         math_goal
        op          add
        task        mul
        +imaginal>
        isa          math_op
        op          add
        arg1        =arg
        ones1       =ones
        tens1       =tens
        hundreds1   =huns
        arg2        =arg
        ones2       =ones
        tens2       =tens
        hundreds2   =huns
        mul_counter =mul
        +retrieval>
        isa         math_op
        op          add
        arg1        =arg
        arg2        =arg
    """,
    )
    prods.append(start_mul)

    count_mul = Model.productionstring(
        name="count_mul",
        string="""
        =g>
        isa         math_goal
        op          add_done
        task        mul
        =imaginal>
        isa         math_op
        op          add
        mul_counter =counter
        ==>
        =g>
        isa         math_goal
        op          count_done
        +retrieval>
        isa         math_op
        op          add
        arg1        1
        result      =counter
        """
    )

    step_mul = Model.productionstring(
        name="step_mul",
        string="""
        =g>
        isa         math_goal
        op          count_done
        task        mul
        =imaginal>
        isa         math_op
        op          add
        hundreds_ans    =hun_ans
        tens_ans        =ten_ans
        ones_ans        =one_ans
        mul_counter     =mul_counter
        =retrieval>
        isa         math_op
        op          add
        result      =mul_counter
        arg2        =new_counter
        ==>
        =g>
        isa         math_goal
        op          mul
        task        mul
        +imaginal>
        isa         math_op
        op          mul
        arg1        =new_counter
        ones1       =new_counter
        hundreds2   =hun_ans
        tens2       =ten_ans
        ones2       =one_ans
        mul_counter =new_counter
    """,
    )
    prods.append(step_mul)

    return prods