Skip to content

Commit 756fdb0

Browse files
committed
and and not passing
1 parent f880576 commit 756fdb0

File tree

4 files changed

+100
-107
lines changed

4 files changed

+100
-107
lines changed

neurallogic/hard_not.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def soft_not(w: float, x: float) -> float:
1919

2020

2121
def hard_not(w: bool, x: bool) -> bool:
22+
# ~(x ^ w)
2223
return jax.numpy.logical_not(jax.numpy.logical_xor(x, w))
2324

2425

neurallogic/symbolic_primitives.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,42 +122,40 @@ def unary_operator(operator: str, x: list):
122122

123123

124124
@dispatch
125-
def binary_infix_operator(operator: str, a: str, b: str, bracket: bool = False) -> str:
126-
if bracket:
127-
return f"({a} {operator} {b})"
125+
def binary_infix_operator(operator: str, a: str, b: str) -> str:
128126
return f"{a} {operator} {b}"
129127

130128

131129
@dispatch
132-
def binary_infix_operator(operator: str, a: numpy.ndarray, b: numpy.ndarray, bracket: bool = False):
133-
return numpy.vectorize(binary_infix_operator, otypes=[object])(operator, a, b, bracket)
130+
def binary_infix_operator(operator: str, a: numpy.ndarray, b: numpy.ndarray):
131+
return numpy.vectorize(binary_infix_operator, otypes=[object])(operator, a, b)
134132

135133

136134
@dispatch
137-
def binary_infix_operator(operator: str, a: list, b: numpy.ndarray, bracket: bool = False):
138-
return binary_infix_operator(operator, numpy.array(a), b, bracket)
135+
def binary_infix_operator(operator: str, a: list, b: numpy.ndarray):
136+
return binary_infix_operator(operator, numpy.array(a), b)
139137

140138

141139
@dispatch
142-
def binary_infix_operator(operator: str, a: numpy.ndarray, b: list, bracket: bool = False):
143-
return binary_infix_operator(operator, a, numpy.array(b), bracket)
140+
def binary_infix_operator(operator: str, a: numpy.ndarray, b: list):
141+
return binary_infix_operator(operator, a, numpy.array(b))
144142

145143

146144
@dispatch
147-
def binary_infix_operator(operator: str, a: str, b: int, bracket: bool = False):
148-
return binary_infix_operator(operator, a, str(b), bracket)
145+
def binary_infix_operator(operator: str, a: str, b: int):
146+
return binary_infix_operator(operator, a, str(b))
149147

150148
@dispatch
151-
def binary_infix_operator(operator: str, a: numpy.ndarray, b: float, bracket: bool = False):
152-
return binary_infix_operator(operator, a, str(b), bracket)
149+
def binary_infix_operator(operator: str, a: numpy.ndarray, b: float):
150+
return binary_infix_operator(operator, a, str(b))
153151

154152
@dispatch
155-
def binary_infix_operator(operator: str, a: str, b: float, bracket: bool = False):
156-
return binary_infix_operator(operator, a, str(b), bracket)
153+
def binary_infix_operator(operator: str, a: str, b: float):
154+
return binary_infix_operator(operator, a, str(b))
157155

158156
@dispatch
159-
def binary_infix_operator(operator: str, a: numpy.ndarray, b: jax.numpy.ndarray, bracket: bool = False):
160-
return binary_infix_operator(operator, a, numpy.array(b), bracket)
157+
def binary_infix_operator(operator: str, a: numpy.ndarray, b: jax.numpy.ndarray):
158+
return binary_infix_operator(operator, a, numpy.array(b))
161159

162160

163161
def all_concrete_values(data):
@@ -185,7 +183,7 @@ def symbolic_ne(*args, **kwargs):
185183
if all_concrete_values([*args]):
186184
return numpy.not_equal(*args, **kwargs)
187185
else:
188-
return binary_infix_operator("!=", *args, **kwargs)
186+
return "(" + binary_infix_operator("!=", *args, **kwargs) + ")"
189187

190188
def symbolic_gt(*args, **kwargs):
191189
if all_concrete_values([*args]):
@@ -204,14 +202,14 @@ def symbolic_or(*args, **kwargs):
204202
if all_concrete_values([*args]):
205203
return numpy.logical_or(*args, **kwargs)
206204
else:
207-
return binary_infix_operator("or", *args, **kwargs, bracket=True)
205+
return "(" + binary_infix_operator("or", *args, **kwargs) + ")"
208206

209207

210208
def symbolic_xor(*args, **kwargs):
211209
if all_concrete_values([*args]):
212210
return numpy.logical_xor(*args, **kwargs)
213211
else:
214-
return binary_infix_operator("^", *args, **kwargs, bracket=False)
212+
return binary_infix_operator("^", *args, **kwargs)
215213

216214

217215

tests/test_hard_and.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,17 @@ def test_net(type, x):
198198
symbolic_input = ['x1', 'x2']
199199
symbolic_output = symbolic.apply(hard_weights, symbolic_input)
200200
# Check the form of the symbolic expression
201-
assert numpy.array_equal(symbolic_output, ['True and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or True) and (True and (x1 != 0 or False) and (x2 != 0 or False) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or True)',
202-
'True and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or False) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or True)',
203-
'True and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or True) and (True and (x1 != 0 or False) and (x2 != 0 or False) != 0 or True) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or True)',
204-
'True and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or True) and (True and (x1 != 0 or False) and (x2 != 0 or False) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or False) and (True and (x1 != 0 or False) and (x2 != 0 or True) != 0 or False)'])
201+
assert numpy.array_equal(symbolic_output, ['True and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or True) and ((True and ((x1 != 0) or False) and ((x2 != 0) or False) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or True)',
202+
'True and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or False) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or True)',
203+
'True and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or True) and ((True and ((x1 != 0) or False) and ((x2 != 0) or False) != 0) or True) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or True)',
204+
'True and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or True) and ((True and ((x1 != 0) or False) and ((x2 != 0) or False) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or False) and ((True and ((x1 != 0) or False) and ((x2 != 0) or True) != 0) or False)'])
205205

206206
# Compute symbolic result with symbolic inputs and symbolic weights
207207
symbolic_output = symbolic.apply(symbolic_weights, symbolic_input)
208208
# Check the form of the symbolic expression
209-
assert numpy.array_equal(symbolic_output, ['True and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(False != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(True != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(False != 0))',
210-
'True and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(True != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(False != 0))',
211-
'True and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(False != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(True != 0)) != 0 or not(False != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(False != 0))',
212-
'True and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(False != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(True != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(True != 0)) and (True and (x1 != 0 or not(True != 0)) and (x2 != 0 or not(False != 0)) != 0 or not(True != 0))'])
209+
assert numpy.array_equal(symbolic_output, ['True and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((False != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((True != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((False != 0)))',
210+
'True and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((True != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((False != 0)))',
211+
'True and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((False != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((True != 0))) != 0) or not((False != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((False != 0)))',
212+
'True and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((False != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((True != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((True != 0))) and ((True and ((x1 != 0) or not((True != 0))) and ((x2 != 0) or not((False != 0))) != 0) or not((True != 0)))'])
213213

214214

tests/test_hard_not.py

Lines changed: 73 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_net(type, x):
170170
soft, hard, symbolic = neural_logic_net.net(test_net)
171171

172172
# Compute soft result
173-
soft_input = jax.numpy.array([0.0, 0.0])
173+
soft_input = jax.numpy.array([1.0, 0.0])
174174
weights = soft.init(random.PRNGKey(0), soft_input)
175175
soft_result = soft.apply(weights, numpy.array(soft_input))
176176

@@ -186,92 +186,86 @@ def test_net(type, x):
186186
# Check that the symbolic result is the same as the hard result
187187
assert numpy.array_equal(symbolic_output, hard_result)
188188

189+
# Compute symbolic result with symbolic inputs and symbolic weights, but where the symbols can be evaluated
190+
symbolic_input = ['True', 'False']
191+
symbolic_weights = symbolic_generation.make_symbolic(hard_weights)
192+
symbolic_output = symbolic.apply(symbolic_weights, symbolic_input)
193+
symbolic_output = symbolic_generation.eval_symbolic_expression(symbolic_output)
194+
# Check that the symbolic result is the same as the hard result
195+
assert numpy.array_equal(symbolic_output, hard_result)
196+
189197
# Compute symbolic result with symbolic inputs and non-symbolic weights
190198
symbolic_input = ['x1', 'x2']
191199
symbolic_output = symbolic.apply(hard_weights, symbolic_input)
192200
# Check the form of the symbolic expression
193-
"""
194-
assert numpy.array_equal(symbolic_output, ['not(not(x1 != 0 ^ True) != 0 ^ True)',
195-
'not(not(x2 != 0 ^ True) != 0 ^ True)',
196-
'not(not(x1 != 0 ^ False) != 0 ^ False)',
197-
'not(not(x2 != 0 ^ False) != 0 ^ False)',
198-
'not(not(x1 != 0 ^ True) != 0 ^ False)',
199-
'not(not(x2 != 0 ^ True) != 0 ^ True)',
200-
'not(not(x1 != 0 ^ False) != 0 ^ False)',
201-
'not(not(x2 != 0 ^ False) != 0 ^ False)',
202-
'not(not(x1 != 0 ^ True) != 0 ^ True)',
203-
'not(not(x2 != 0 ^ True) != 0 ^ False)',
204-
'not(not(x1 != 0 ^ False) != 0 ^ True)',
205-
'not(not(x2 != 0 ^ False) != 0 ^ True)',
206-
'not(not(x1 != 0 ^ True) != 0 ^ False)',
207-
'not(not(x2 != 0 ^ True) != 0 ^ False)',
208-
'not(not(x1 != 0 ^ False) != 0 ^ True)',
209-
'not(not(x2 != 0 ^ False) != 0 ^ True)',
210-
'not(not(x1 != 0 ^ True) != 0 ^ False)',
211-
'not(not(x2 != 0 ^ True) != 0 ^ True)',
212-
'not(not(x1 != 0 ^ False) != 0 ^ False)',
213-
'not(not(x2 != 0 ^ False) != 0 ^ False)',
214-
'not(not(x1 != 0 ^ True) != 0 ^ True)',
215-
'not(not(x2 != 0 ^ True) != 0 ^ True)',
216-
'not(not(x1 != 0 ^ False) != 0 ^ False)',
217-
'not(not(x2 != 0 ^ False) != 0 ^ True)',
218-
'not(not(x1 != 0 ^ True) != 0 ^ True)',
219-
'not(not(x2 != 0 ^ True) != 0 ^ False)',
220-
'not(not(x1 != 0 ^ False) != 0 ^ False)',
221-
'not(not(x2 != 0 ^ False) != 0 ^ False)',
222-
'not(not(x1 != 0 ^ True) != 0 ^ False)',
223-
'not(not(x2 != 0 ^ True) != 0 ^ True)',
224-
'not(not(x1 != 0 ^ False) != 0 ^ False)',
225-
'not(not(x2 != 0 ^ False) != 0 ^ False)'])
226-
"""
201+
assert numpy.array_equal(symbolic_output, ['not((not((x1 != 0) ^ True) != 0) ^ True)',
202+
'not((not((x2 != 0) ^ True) != 0) ^ True)',
203+
'not((not((x1 != 0) ^ False) != 0) ^ False)',
204+
'not((not((x2 != 0) ^ False) != 0) ^ False)',
205+
'not((not((x1 != 0) ^ True) != 0) ^ False)',
206+
'not((not((x2 != 0) ^ True) != 0) ^ True)',
207+
'not((not((x1 != 0) ^ False) != 0) ^ False)',
208+
'not((not((x2 != 0) ^ False) != 0) ^ False)',
209+
'not((not((x1 != 0) ^ True) != 0) ^ True)',
210+
'not((not((x2 != 0) ^ True) != 0) ^ False)',
211+
'not((not((x1 != 0) ^ False) != 0) ^ True)',
212+
'not((not((x2 != 0) ^ False) != 0) ^ True)',
213+
'not((not((x1 != 0) ^ True) != 0) ^ False)',
214+
'not((not((x2 != 0) ^ True) != 0) ^ False)',
215+
'not((not((x1 != 0) ^ False) != 0) ^ True)',
216+
'not((not((x2 != 0) ^ False) != 0) ^ True)',
217+
'not((not((x1 != 0) ^ True) != 0) ^ False)',
218+
'not((not((x2 != 0) ^ True) != 0) ^ True)',
219+
'not((not((x1 != 0) ^ False) != 0) ^ False)',
220+
'not((not((x2 != 0) ^ False) != 0) ^ False)',
221+
'not((not((x1 != 0) ^ True) != 0) ^ True)',
222+
'not((not((x2 != 0) ^ True) != 0) ^ True)',
223+
'not((not((x1 != 0) ^ False) != 0) ^ False)',
224+
'not((not((x2 != 0) ^ False) != 0) ^ True)',
225+
'not((not((x1 != 0) ^ True) != 0) ^ True)',
226+
'not((not((x2 != 0) ^ True) != 0) ^ False)',
227+
'not((not((x1 != 0) ^ False) != 0) ^ False)',
228+
'not((not((x2 != 0) ^ False) != 0) ^ False)',
229+
'not((not((x1 != 0) ^ True) != 0) ^ False)',
230+
'not((not((x2 != 0) ^ True) != 0) ^ True)',
231+
'not((not((x1 != 0) ^ False) != 0) ^ False)',
232+
'not((not((x2 != 0) ^ False) != 0) ^ False)'])
227233

228234
# Compute symbolic result with symbolic inputs and symbolic weights
229-
symbolic_weights = symbolic_generation.make_symbolic(hard_weights)
230235
symbolic_output = symbolic.apply(symbolic_weights, symbolic_input)
231236
# Check the form of the symbolic expression
232-
"""
233-
assert numpy.array_equal(symbolic_output, ['not(not(x1 != 0 ^ True != 0) != 0 ^ True != 0)',
234-
'not(not(x2 != 0 ^ True != 0) != 0 ^ True != 0)',
235-
'not(not(x1 != 0 ^ False != 0) != 0 ^ False != 0)',
236-
'not(not(x2 != 0 ^ False != 0) != 0 ^ False != 0)',
237-
'not(not(x1 != 0 ^ True != 0) != 0 ^ False != 0)',
238-
'not(not(x2 != 0 ^ True != 0) != 0 ^ True != 0)',
239-
'not(not(x1 != 0 ^ False != 0) != 0 ^ False != 0)',
240-
'not(not(x2 != 0 ^ False != 0) != 0 ^ False != 0)',
241-
'not(not(x1 != 0 ^ True != 0) != 0 ^ True != 0)',
242-
'not(not(x2 != 0 ^ True != 0) != 0 ^ False != 0)',
243-
'not(not(x1 != 0 ^ False != 0) != 0 ^ True != 0)',
244-
'not(not(x2 != 0 ^ False != 0) != 0 ^ True != 0)',
245-
'not(not(x1 != 0 ^ True != 0) != 0 ^ False != 0)',
246-
'not(not(x2 != 0 ^ True != 0) != 0 ^ False != 0)',
247-
'not(not(x1 != 0 ^ False != 0) != 0 ^ True != 0)',
248-
'not(not(x2 != 0 ^ False != 0) != 0 ^ True != 0)',
249-
'not(not(x1 != 0 ^ True != 0) != 0 ^ False != 0)',
250-
'not(not(x2 != 0 ^ True != 0) != 0 ^ True != 0)',
251-
'not(not(x1 != 0 ^ False != 0) != 0 ^ False != 0)',
252-
'not(not(x2 != 0 ^ False != 0) != 0 ^ False != 0)',
253-
'not(not(x1 != 0 ^ True != 0) != 0 ^ True != 0)',
254-
'not(not(x2 != 0 ^ True != 0) != 0 ^ True != 0)',
255-
'not(not(x1 != 0 ^ False != 0) != 0 ^ False != 0)',
256-
'not(not(x2 != 0 ^ False != 0) != 0 ^ True != 0)',
257-
'not(not(x1 != 0 ^ True != 0) != 0 ^ True != 0)',
258-
'not(not(x2 != 0 ^ True != 0) != 0 ^ False != 0)',
259-
'not(not(x1 != 0 ^ False != 0) != 0 ^ False != 0)',
260-
'not(not(x2 != 0 ^ False != 0) != 0 ^ False != 0)',
261-
'not(not(x1 != 0 ^ True != 0) != 0 ^ False != 0)',
262-
'not(not(x2 != 0 ^ True != 0) != 0 ^ True != 0)',
263-
'not(not(x1 != 0 ^ False != 0) != 0 ^ False != 0)',
264-
'not(not(x2 != 0 ^ False != 0) != 0 ^ False != 0)'])
265-
"""
237+
assert numpy.array_equal(symbolic_output, ['not((not((x1 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
238+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
239+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
240+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
241+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
242+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
243+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
244+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
245+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
246+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
247+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (True != 0))',
248+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (True != 0))',
249+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
250+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
251+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (True != 0))',
252+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (True != 0))',
253+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
254+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
255+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
256+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
257+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
258+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
259+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
260+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (True != 0))',
261+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
262+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
263+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
264+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
265+
'not((not((x1 != 0) ^ (True != 0)) != 0) ^ (False != 0))',
266+
'not((not((x2 != 0) ^ (True != 0)) != 0) ^ (True != 0))',
267+
'not((not((x1 != 0) ^ (False != 0)) != 0) ^ (False != 0))',
268+
'not((not((x2 != 0) ^ (False != 0)) != 0) ^ (False != 0))'])
266269

267-
# Compute symbolic result with symbolic inputs and symbolic weights, but where the symbols can be evaluated
268-
symbolic_input = ['True', 'False']
269-
symbolic_output = symbolic.apply(symbolic_weights, symbolic_input)
270-
print(f'symbolic_output = {symbolic_output}')
271-
symbolic_output = symbolic_generation.eval_symbolic_expression(symbolic_output)
272-
# Check that the symbolic result is the same as the hard result
273-
print(f'symbolic_output = {symbolic_output}')
274-
print(f'hard_result = {hard_result}')
275-
assert numpy.array_equal(symbolic_output, hard_result)
276270

277271

0 commit comments

Comments
 (0)