Experimental project. For given proposal or equation it generate its implementation (context or sample space
The main idea is that such samples can give you better understanding of a proposal itself, especially if such proposal have been taken from some abstract math theory.
from tokentranslator.db_models.model_main import TokenizerDB
from tokentranslator.env.clause.clause_main import Clause
model = TokenizerDB()
# switch to clauses db:
model.change_dialect_db("cs")
clause = Clause("abelian(G) \\and subgroup(H, G,) => abelian(H)", db=model)
clause.parser.parse()
# now import and use sampling:
from proposalsampler.sampling.slambda.tests_slambda_main import test_ventries
from proposalsampler.sampling.slambda import slambda_main as sm
# for this example test_ventries[3] is init data for proposal clause:
test_ventries[3] =
{'G': ('(1,4)(2,3)', '(1,3)(2,4)'),
"['s', 1, 0, 0]": True,
"['s', 1, 1, 0]": True,
'idd': "['s']",
'successors_count': 0}
# so group G is given but group H is not, and must be found
# during sampling:
sampler = sm.Sampler(clause.net_out, test_ventries[3])
sampler.run()
# if successors found, they entries would look like:
{'G': ('(1,4)(2,3)', '(1,3)(2,4)'), 'H': ('(1,3)(2,4)', '(1,4)(2,3)')", ['s', 1, 1, 0]": True, "['s', 1, 0, 0]": True, 'idd': "['s', 4, 3, 0]", 'successors_count': 0, 'checked_nodes': ["['s']", "['s', 1]", "['s', 1, 1, 0]", "['s', 1, 0, 0]", "['s', 0, 0]"], 'failure_statuses': {}, 'parent_idd': "['s', 4, 3]", "['s']": True, "['s', 0, 0]": True, "['s', 1]": True}
# so group H found and in this case H = Group('(1,3)(2,4)', '(1,4)(2,3)') (= G but proposal is still holding)
# if no results were generated, try run again.
>>> e = Equation("f(a*x+b*y)=a*f(x)+b*f(y)")
>>> e.parser.parse()
>>> e.sampling.sympy.sampling_vars()
>>> # or e.sampling.sympy.sampling_subs()
>>> e.sampling.sympy.show_rand()
>>> # or "".join(e.eq_tree.flatten('rand_sympy'))
sin(0.243*0.570+0.369*0.078)=0.243*sin(0.570)+0.369*sin(0.078)
pip install -r requirements.txt
pip install proposalsampler
There is also a GUI for this project at
https://github.com/tokentranslator-group/tokentranslator-gui
see tests/test_list.txt
Probabilistic Models of Cognition: https://probmods.org/
(eng: George Pólya: Mathematics and Plausible Reasoning, Princeton University Press 1954, 2 volumes (Vol. 1: Induction and Analogy in Mathematics, Vol. 2: Patterns of Plausible Inference)
(ru: Джордж Пойа: Математика и правдоподобные рассуждения)