From d872df8121c64beb142faf95bcab76fa5e53db0d Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 19 Feb 2023 15:35:13 +0100 Subject: cannot_solve_list tracking what we can and can't solve --- cache.md | 5 +++++ cache.pickle | Bin 14497 -> 15133 bytes cannot_solve.md | 4 ++++ solve.py | 13 +++++++++++++ 4 files changed, 22 insertions(+) diff --git a/cache.md b/cache.md index f96c5bc..7fb7f96 100644 --- a/cache.md +++ b/cache.md @@ -109,4 +109,9 @@ (('(λa b. a a b)', '(λa b c. a c)'), ('(λx y. x)', '(λx y. y)')): ['(λb. (λe f. f))', '(λa b. b)', '(λc d. c)'] (('(λa b c. b a)', '(λa b c. b b)'), ('(λx y. x)', '(λx y. y)')): ['(λp. p (λe f. f) (λc d. c))', '(λa. a)', '(λb a c c. (λc d. c))', '(λe f. f)'] (('(λa b. a (b b b))', '(λa b c. a (b c c))'), ('(λx y. x)', '(λx y. y)')): ['(λc d. c)', '(λa. (λc d. c))', '(λa b. b)', '(λa b. a a a)', '(λa b c. c b c c)'] +(('(λa b c. b a)', '(λa b. b a b)'), ('(λx y. x)', '(λx y. y)')): ['(λc d. c)', '(λa b. a a b)', '(λa b. b)', '(λa b. b)'] +(('(λa b. b b b)', '(λa b c. b a)'), ('(λx y. x)', '(λx y. y)')): ['(λa b. a)', '(λa b. a)', '(λa b. b)', '(λe f. f)', '(λb. (λe f. f))', '(λa. a)', '(λa b. a)'] +(('(λa b c. a a (b b a))', '(λa b. a a (b a))'), ('(λx y. x)', '(λx y. y)')): ['(λe f. f)', '(λa b. a)', '(λa. a)'] +(('(λa b. a a (b a b))', '(λa b c. a a (b c))'), ('(λx y. x)', '(λx y. y)')): ['(λb. (λe f. f))', '(λa b c. c b b c)', '(λa. (λc d. c))', '(λa b. b)'] +(('(λa b. a (b a b) a)', '(λa b. a (λc. c c a) a)'), ('(λx y. x)', '(λx y. y)')): ['(λp. p (λe f. f) (λc d. c))', '(λa b c. a c c c)', '(λa b. b)'] ``` \ No newline at end of file diff --git a/cache.pickle b/cache.pickle index 48541bc..5ec1307 100644 Binary files a/cache.pickle and b/cache.pickle differ diff --git a/cannot_solve.md b/cannot_solve.md index 73ccfb9..cd6328c 100644 --- a/cannot_solve.md +++ b/cannot_solve.md @@ -21,3 +21,7 @@ - `(λa b. a λc. c b b) | (λa b. a λc. c b)` - `(λa b. a λc. c c a) | (λa b. a λc. c c b)` - `(λa b. a λc. c c b) | (λa b. a (b b))` +- `(λa b. a (λc. b a a) a) | (λa b. a (λc. b c) a)` +- `(λa b. a (λc. b (a b) a) a) | (λa b. a (λc. b (a a) a) a)` +- `(λa b. a λc. b c) | (λa b. a λc. b a a)` +- `(λa b. a (a b b) a) | (λa b. a (λc. b c b) a)` diff --git a/solve.py b/solve.py index f3ec8e0..6ec7ff3 100644 --- a/solve.py +++ b/solve.py @@ -16,6 +16,9 @@ alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', #with open('cache.pickle', 'wb') as handle: # pickle.dump(cache, handle, protocol=pickle.HIGHEST_PROTOCOL) +with open('cannot_solve.pickle', 'rb') as handle: + cannot_solve_list = pickle.load(handle) + with open('cache.pickle', 'rb') as handle: cache = pickle.load(handle) @@ -611,6 +614,9 @@ while True: t = "(" + p.readline().decode().strip() + ")" print(f"{t=}") + if (s, t) in cannot_solve_list: + raise ValueError('We know that we can not solve this, as it is in the cannot_solve_list') + p.readuntil(b"beta-reduces to ") goal_s = p.readline().decode().strip() print(f"{goal_s=}") @@ -654,10 +660,17 @@ while True: except: print("SOMETHING WENT HORRIBLY WRONG!") + # handle saving the "cannot_solve" items print(f"CANNOT SOLVE {s=} {t=}") + cannot_solve = open("./cannot_solve.md", "a") cannot_solve.write(f"- `{s} | {t}`\n") + cannot_solve_list.append((s, t)) + + with open('cannot_solve.pickle', 'wb') as handle: + pickle.dump(cannot_solve_list, handle, protocol=pickle.HIGHEST_PROTOCOL) + # handle saving the cached items print(f"level {level}, cache hits: {cache_hits}") try: del cache[last_added_to_cache] -- cgit 1.4.1