diff --git a/Tests/test_RuleMap/test_sparse_lut.py b/Tests/test_RuleMap/test_sparse_lut.py index 2a9c5bd7..9ec2ba10 100644 --- a/Tests/test_RuleMap/test_sparse_lut.py +++ b/Tests/test_RuleMap/test_sparse_lut.py @@ -1,4 +1,3 @@ -from networkx.generators.random_graphs import fast_gnp_random_graph from pynars.NARS.DataStructures._py.Link import LinkType from pynars.NARS.RuleMap import Interface_SyllogisticRules, RuleMap from pynars.Narsese import Budget diff --git a/pynars/NAL/Functions/ExtendedBooleanFunctions.py b/pynars/NAL/Functions/ExtendedBooleanFunctions.py index d0fb68b8..fd953f08 100644 --- a/pynars/NAL/Functions/ExtendedBooleanFunctions.py +++ b/pynars/NAL/Functions/ExtendedBooleanFunctions.py @@ -1,10 +1,12 @@ -import numpy as np +from functools import reduce +from statistics import mean +from operator import mul Not = lambda x: (1-x) -And = lambda *x: np.prod(x) -Or = lambda *x: 1 - np.prod(1-np.array(x)) -Average = lambda *x: np.mean(x) +And = lambda *x: reduce(mul, x, 1) +Or = lambda *x: 1 - reduce(mul, (1 - xi for xi in x), 1) +Average = lambda *x: mean(x) def Scalar(x): x = 0.5 + 4*(x-0.5)**3 diff --git a/pynars/NARS/RuleMap/add_rule.py b/pynars/NARS/RuleMap/add_rule.py index 94c5d5e3..70cd9ed8 100644 --- a/pynars/NARS/RuleMap/add_rule.py +++ b/pynars/NARS/RuleMap/add_rule.py @@ -8,8 +8,6 @@ from typing_extensions import Protocol from collections import OrderedDict -from numpy import product - from pynars.Config import Enable from pynars.NARS.RuleMap.Interface import Interface_CompositionalRules, Interface_SyllogisticRules, Interface_DecompositionalRules, Interface_TransformRules, Interface_ConditionalRules, Interface_TemporalRules, Interface_VariableRules from pynars.Narsese import Copula, Task diff --git a/pynars/Narsese/_py/Compound.py b/pynars/Narsese/_py/Compound.py index 8a6b50d7..58ee94d5 100644 --- a/pynars/Narsese/_py/Compound.py +++ b/pynars/Narsese/_py/Compound.py @@ -10,7 +10,6 @@ from ordered_set import OrderedSet from typing import Set from pynars.utils.tools import list_contains -import numpy as np from pynars.Global import States @@ -358,9 +357,13 @@ def equal(self, o: Type['Compound']) -> bool: set2: Iterable[Term] = o.terms - self.terms if len(set1) == len(set2) == 0: return True - eq_array = np.array([[term1.equal(term2) - for term2 in set2] for term1 in set1]) - if np.prod(eq_array.sum(axis=0)) > 0 and np.prod(eq_array.sum(axis=1)) > 0: + # ChatGPT: directly returns the result of the logical AND condition, + # checking if all column sums and all row sums are greater than zero. + # This uses the built-in all() function to ensure every sum in each direction (column and row) + # is greater than zero. The zip(*eq_array) unpacks each row of eq_array into columns. + eq_array = [[term1.equal(term2) + for term2 in set2] for term1 in set1] + if all(sum(col) > 0 for col in zip(*eq_array)) and all(sum(row) > 0 for row in eq_array): return True else: return False diff --git a/pynars/Narsese/_py/Term.py b/pynars/Narsese/_py/Term.py index 7d91f11e..ddd8cb47 100644 --- a/pynars/Narsese/_py/Term.py +++ b/pynars/Narsese/_py/Term.py @@ -4,7 +4,6 @@ from typing import Iterable, List, Set, Type from enum import Enum from pynars.utils.IndexVar import IndexVar -from numpy import prod from ordered_set import OrderedSet # from pynars.utils.tools import find_pos_with_pos, find_var_with_pos from copy import copy, deepcopy diff --git a/pynars/Narsese/_py/Truth.py b/pynars/Narsese/_py/Truth.py index 653e1717..9f1ff4cb 100644 --- a/pynars/Narsese/_py/Truth.py +++ b/pynars/Narsese/_py/Truth.py @@ -1,6 +1,5 @@ from pynars.Config import Config from typing import Type -import numpy as np class Truth: # analytic: Type['Truth'] diff --git a/pynars/utils/IndexVar.py b/pynars/utils/IndexVar.py index 2e6503d2..037580c0 100644 --- a/pynars/utils/IndexVar.py +++ b/pynars/utils/IndexVar.py @@ -5,8 +5,6 @@ from ordered_set import OrderedSet from bidict import bidict -from numpy import prod - class IntVar: def __init__(self, num: int) -> None: self.num = int(num) diff --git a/pynars/utils/tools.py b/pynars/utils/tools.py index e8860214..74758548 100644 --- a/pynars/utils/tools.py +++ b/pynars/utils/tools.py @@ -49,8 +49,8 @@ def rand_seed(x: int): import random random.seed(x) - import numpy as np - np.random.seed(x) + # import numpy as np + # np.random.seed(x) # if using pytorch, set its seed! # # import torch diff --git a/requirements-min.txt b/requirements-min.txt new file mode 100644 index 00000000..2b02b515 --- /dev/null +++ b/requirements-min.txt @@ -0,0 +1,15 @@ +# ale-py>=0.7.3 +# git+git://github.com/mila-iqia/atari-representation-learning.git +# AutoROM>=0.4.2 +# AutoROM.accept-rom-license>=0.4.2 +bidict>=0.21.2 +depq>=1.5.5 +jstyleson>=0.0.2 +lark==0.12.0 +ordered-set>=4.0.2 +sty>=1.0.0rc2 +tqdm<=3.1.4 +typing>=3.7.4.3 +typing_extensions>=4.0.1 +sparse-lut>=1.0.0 +miniKanren>=1.0.3 \ No newline at end of file