diff --git a/test/test_holdouts.py b/test/test_holdouts.py index 43aa7d58..e172a52c 100644 --- a/test/test_holdouts.py +++ b/test/test_holdouts.py @@ -1,10 +1,6 @@ from unittest import TestCase from test.utils import read_holdouts -from test.lin_rec import ( - StrictLinRecMachine, - run_loose_linrec_machine, -) from tm.machine import quick_term_or_rec @@ -21,20 +17,21 @@ TOTAL_HOLDOUTS = 883 -PY_FALSE_POSIIVES = { - "1RB 0RB 0LB 1RC 1LD 0RC 1LB 1LA", - "1RB 0RB 0LC 1RD 1LC 1LA 1LB 0RD", - "1RB 1LD 1LC 1RB 0RC 1LA 0RD 0LC", -} - -RUST_FALSE_POSITIVES = { - "1RB ... 1RC 0RA 0LD 0LB 0RB 1LC", - "1RB 0LD 1LC 1RA ... 1LD 0RD 1LA", - "1RB 0RC 0LB 1LA ... 1RD 1LB 0RD", - "1RB 0RD 0LC 0LA 1LA 1LB 1RA ...", - "1RB 1LA 0LC 0LD ... 1LD 0RD 1RA", - "1RB 1LC 0LA 0RD 1RC 1LB ... 1RA", - "1RB 1LC 0LA 0RD 1RD 1LB ... 1RA", +LR_FALSE_POSITIVES = { + "py": { + "1RB 0RB 0LB 1RC 1LD 0RC 1LB 1LA", + "1RB 0RB 0LC 1RD 1LC 1LA 1LB 0RD", + "1RB 1LD 1LC 1RB 0RC 1LA 0RD 0LC", + }, + "rs": { + "1RB ... 1RC 0RA 0LD 0LB 0RB 1LC", + "1RB 0LD 1LC 1RA ... 1LD 0RD 1LA", + "1RB 0RC 0LB 1LA ... 1RD 1LB 0RD", + "1RB 0RD 0LC 0LA 1LA 1LB 1RA ...", + "1RB 1LA 0LC 0LD ... 1LD 0RD 1RA", + "1RB 1LC 0LA 0RD 1RC 1LB ... 1RA", + "1RB 1LC 0LA 0RD 1RD 1LB ... 1RA", + } } @@ -56,23 +53,10 @@ def test_holdouts(self): TOTAL_HOLDOUTS) for prog in holdouts: - self.assertFalse( - quick_term_or_rec(prog, STEPS), - prog) - - if prog in PY_FALSE_POSIIVES: - self.assertIsNotNone( - run_loose_linrec_machine(prog, 300).infrul) - + if any(prog in progs + for progs in LR_FALSE_POSITIVES.values()): continue - self.assertIsNotNone( - run_loose_linrec_machine(prog, STEPS).xlimit) - - for prog in RUST_FALSE_POSITIVES: - self.assertTrue( + self.assertFalse( quick_term_or_rec(prog, STEPS), prog) - - self.assertIsNotNone( - StrictLinRecMachine(prog).run(STEPS // 2).xlimit) diff --git a/test/test_turing.py b/test/test_turing.py index 03865487..b66652f1 100644 --- a/test/test_turing.py +++ b/test/test_turing.py @@ -9,6 +9,7 @@ # pylint: disable-next = wildcard-import, unused-wildcard-import from test.prog_data import * from test.test_num import assert_num_counts, clear_caches +from test.test_holdouts import LR_FALSE_POSITIVES from test.lin_rec import ( LinRecSampler, run_loose_linrec_machine, @@ -520,6 +521,34 @@ def run_bb( self.analyze(prog) + def test_lr_false_positives(self): + steps = 1_000 + + for progs in LR_FALSE_POSITIVES.values(): + for prog in progs: + self.assertIsNotNone( + StrictLinRecMachine(prog).run(steps).xlimit) + + for prog in LR_FALSE_POSITIVES["py"]: + # good + self.assertFalse( + quick_term_or_rec(prog, steps), + prog) + + # bad + self.assertIsNone( + run_loose_linrec_machine(prog, steps).xlimit) + + for prog in LR_FALSE_POSITIVES["rs"]: + # bad + self.assertTrue( + quick_term_or_rec(prog, steps), + prog) + + # bad + self.assertIsNone( + run_loose_linrec_machine(prog, steps).xlimit) + def test_recur(self): self._test_recur( RECUR_COMPACT