From 1200d6820136efa72f1db8fc397c5818dd2fb625 Mon Sep 17 00:00:00 2001 From: Nick Drozd Date: Tue, 3 Sep 2024 13:43:21 -0400 Subject: [PATCH] Cut tree_gen.py --- .github/workflows/ci.yml | 4 -- Makefile | 25 ----------- tree_gen.py | 89 ---------------------------------------- 3 files changed, 118 deletions(-) delete mode 100644 tree_gen.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4dffeb9..3b36cf6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,10 +41,6 @@ jobs: make coverage make test-all - - name: Tree Gen - run: | - make generate - Mac-Idris: runs-on: macos-latest diff --git a/Makefile b/Makefile index d5eca268..953deb6b 100644 --- a/Makefile +++ b/Makefile @@ -122,28 +122,3 @@ mutmut : profile : $(MAKE) -C perf - -## Program files (non-phony) ########### - -TIME = time -p -TREE = $(PYTHON) tree_gen.py - -3-2.prog : - $(TIME) $(TREE) 3 2 | sort > $@ - -2-3.prog : - $(TIME) $(TREE) 2 3 | sort > $@ - -4-2.prog : - $(TIME) $(TREE) 4 2 | tee $@ - sort -o $@ $@ - -2-4.prog : - $(TIME) $(TREE) 2 4 | tee $@ - sort -o $@ $@ - -5-2.prog : - $(TIME) $(TREE) 5 2 > $@ - -generate : 3-2.prog 2-3.prog - wc -l *.prog diff --git a/tree_gen.py b/tree_gen.py deleted file mode 100644 index 1f5563ae..00000000 --- a/tree_gen.py +++ /dev/null @@ -1,89 +0,0 @@ -from __future__ import annotations - -from argparse import ArgumentParser - -from tm.reason import cant_halt, cant_spin_out -from tm.machine import Machine, quick_term_or_rec - -from tm.tree import run_tree_gen - - -STATES: int -COLORS: int - -def run_variations( - prog: str, - sim_lim: int, - *, - lin_rec: int = 1_000, - block_steps: int = 1_000, -) -> Machine | None: - if quick_term_or_rec(prog, lin_rec): - return None - - machine = Machine( - prog, - opt_macro = block_steps, - params = (STATES, COLORS), - ).run(sim_lim = sim_lim) - - if machine.infrul: - return None - - return machine - - -def run_print(prog: str) -> None: - if (machine := run_variations(prog, 10_000)) is None: - return - - if machine.simple_termination and machine.rulapp > 1_000: - print(machine) - return - - print(prog) - - -def filter_halt(prog: str) -> None: - if cant_halt(prog, depth = 100): - return - - run_print(prog) - - -def filter_spin_out(prog: str) -> None: - if cant_spin_out(prog, depth = 100): - return - - run_print(prog) - - -if __name__ == '__main__': - parser = ArgumentParser() - - parser.add_argument('states', type = int) - parser.add_argument('colors', type = int) - - parser.add_argument('--steps', type = int, default = 200) - - parser.add_argument('--halt', action = 'store_true') - - parser.add_argument('--progfile', type = str) - - args = parser.parse_args() - - if (progfile := args.progfile) is None: - BRANCHES = None - else: - with open(progfile) as progs: - BRANCHES = [prog.strip() for prog in progs.readlines()] - - STATES = args.states - COLORS = args.colors - - run_tree_gen( - params = (STATES, COLORS), - halt = args.halt, - steps = args.steps, - output = filter_halt if args.halt else filter_spin_out, - )