def test_fix_indices_main(self): expr = parse_expr("Forall(i,j,k,m) (a_i_j_k=1 * b_i_m=1)") result = _fix_indices({"i": 1, "j": 2, "k": 3}, expr) expected_result = ForallExpr(["m"], BinOp("*", _get_is_true("a", 1, 2, 3), _get_is_true("b", 1, "m"))) self.assertEqual(str(expected_result), str(result))
def test_fix_indices_main(self): expr = parse_expr('Forall(i,j,k,m) (a_i_j_k=1 * b_i_m=1)') result = _fix_indices({'i': 1, 'j': 2, 'k': 3}, expr) expected_result = ForallExpr(['m'], BinOp('*', _get_is_true('a', 1, 2, 3), _get_is_true('b', 1, 'm'))) self.assertEqual(str(expected_result), str(result))
def test_fix_indices_partially_fixed(self): a_i_1 = _get_is_true("a", "i", 1) c_0 = _get_is_true("c", 0) expr = ForallExpr(["i"], BinOp("*", a_i_1, c_0)) result = _fix_indices({"i": 2}, expr) a_2_1 = _get_is_true("a", 2, 1) expected_result = BinOp("*", a_2_1, c_0) self.assertEqual(str(result), str(expected_result))
def test_fix_indices_partially_fixed(self): a_i_1 = _get_is_true('a', 'i', 1) c_0 = _get_is_true('c', 0) expr = ForallExpr(['i'], BinOp('*', a_i_1, c_0)) result = _fix_indices({'i': 2}, expr) a_2_1 = _get_is_true('a', 2, 1) expected_result = BinOp('*', a_2_1, c_0) self.assertEqual(str(result), str(expected_result))