Skip to content

Commit

Permalink
Add Green machines
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Oct 20, 2023
1 parent 0b270ff commit 164a59e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
25 changes: 25 additions & 0 deletions test/prog_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
# Milton Green (1964)
"1RB ... 0L_ ...": (1, 2),
"1RB 1R_ 0RC 1RC 0RD 0RC 1RE 1LA 0RF 0RE 1LF 1LD": (35, 436),
"1RB 1RC 0RD 0RB 1R_ 1RA 1RE 1LF 0RG 0RE 0RC 1RB 1LG 1LD": (22961, 197_700_005),

# Lynn (1971)
"1RB 1RA 1LC 0LD 0RA 1LB 1R_ 0LE 1RC 1RB": (15, 435),
Expand Down Expand Up @@ -1387,6 +1388,12 @@
"1RB 0LC 1LA 1RD 1RA 0LE 1RA 0RB 1LF 1LC 1RD 1R_": (6.7, 47),
"1RB 0LC 1LA 1RD 0LB 0LE 1RA 0RB 1LF 1LC 1RD 1R_": (6.7, 47),
"1RB 0RC 0LA 0RD 1RD 1R_ 1LE 0LD 1RF 1LB 1RA 1RE": (2.5, 21),

# Green-8
"1LB 1R_ 0LC 1LC 0LD 0LC 1LE 1RA 0LF 0LE 1LG 1RD 0LH 0LG 1RH 1RF": "((-3 + (7 *",

# Green-9
"1RB 1RC 0RD 0RB 1R_ 1RA 1RE 1LF 0RG 0RE 0RC 1RB 1RH 1LD 0RI 0RH 1LI 1LG": "((-1 + (7 * (3",
}

PROVER_SPINOUT: ProverEst = {
Expand Down Expand Up @@ -1462,6 +1469,11 @@

ALGEBRA: dict[str, dict[str, tuple[int, str, str]]] = {
"halt": {
"1LB 1R_ 0LC 1LC 0LD 0LC 1LE 1RA 0LF 0LE 1LG 1RD 0LH 0LG 1RH 1RF": (
186,
"((-3 + (7 * (3 ** 93))) // 2)",
"(10 ** 45)",
),
"1RB 1LA 3LA 3RC 2LC 2LB 1RB 1RA 2LA 3LC 1R_ 1LB": (
227,
"((-4 + (19 * (2 ** 4320))) // 3)",
Expand Down Expand Up @@ -1542,6 +1554,11 @@
"((23 + (49 * (2 ** ((-124 + (49 * (2 ** ((-34 + (49 * (2 ** ((62 + (49 * (2 ** 15172))) // 27)))) // 27)))) // 27)))) // 9)",
"(10 ↑↑ 5)",
),
"1RB 1RC 0RD 0RB 1R_ 1RA 1RE 1LF 0RG 0RE 0RC 1RB 1RH 1LD 0RI 0RH 1LI 1LG": (
1793,
"((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** ((-1 + (7 * (3 ** 31))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 2)))) // 4)",
"(10 ↑↑ 30)",
),
},

"count_apps": {
Expand All @@ -1557,6 +1574,14 @@
),
},

"ops_times": {
"1LB 1R_ 0LC 1LC 0LD 0LC 1LE 1RA 0LF 0LE 1LG 1RD 0LH 0LG 1LI 1RF 0LJ 0LI 1RJ 1RH": (
1966,
"3",
"3",
)
},

"inapplicable_op": {
"1RB 3RB 5RA 1LB 5LA 2LB 2LA 2RA 4RB 1R_ 3LB 2LA": (
1799,
Expand Down
3 changes: 3 additions & 0 deletions test/test_coverage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable = line-too-long

from unittest import TestCase

from tm.machine import (
Expand Down Expand Up @@ -143,6 +145,7 @@ def test_prover(self):
"1RB 3LA 4LB 0RB 1RA 3LA 2LA 2RA 4LA 1RA 5RB 1R_",
"1RB 3RB 5RA 1LB 5LA 2LB 2LA 2RA 4RB 1R_ 3LB 2LA",
"1RB 0LB 1R_ 3LA 0LC 3RB 3RC 1LB 2RB 2LA 3RA 1LC",
"1LB 1R_ 0LC 1LC 0LD 0LC 1LE 1RA 0LF 0LE 1LG 1RD 0LH 0LG 1LI 1RF 0LJ 0LI 1RJ 1RH",
)

for prog in progs:
Expand Down
8 changes: 4 additions & 4 deletions test/test_turing.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,10 @@ def test_algebra(self):
marks.estimate()))

assert_num_counts({
"adds": 28585,
"divs": 5722,
"exps": 9248,
"muls": 6464,
"adds": 29842,
"divs": 6729,
"exps": 9382,
"muls": 6767,
})


Expand Down
2 changes: 1 addition & 1 deletion tm/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def apply_mult(count: Count, times: Count, mul: int, add: int) -> Count:


def apply_ops(count: Count, times: Count, ops: OpSeq) -> Count:
if not isinstance(times, int): # no-cover
if not isinstance(times, int):
raise RuleLimit('ops_times')

result = count
Expand Down

0 comments on commit 164a59e

Please sign in to comment.