I want to modify multiplication so that it also pushes a copy of the second operand - 1 on top of the result but I can't really read the multiplication code well enough to figure out where to place it
I have stacks of expressions instead of stacks of numbers. Expressions are defined by a list of numbers representing coefficients. An expression of [7] represents the number 7, an expression of [0, 5] represents 5*A, [0, 0, 9] represents 9*B, etc.
The stacks are initially empty. Each time an empty stack is popped, it returns a new expression of the form [0, 0, ..., 1] representing a new variable never before seen.
Expressions can be added or negated, which is really easy to do by just adding the lists of numbers together item-by-item.
Here's my proposed auto-golfing method for simple snippets: interpret the snippet like the above examples to figure out exactly what it does, and then the auto-golfer attempts to find other snippets that do the same thing.
The first step will be brute-forcing a lot of short programs to build up a decent table. Then, there are probably intelligent ways to attempt to combine short snippets so that they give the target snippet.
Looks like the easiest way to brute force is to convert to binary, pad to a multiple of 3 bits, and taking three bits at a time, take two bits to select paren type, one bit to decide whether to put it beside or inside
@PhiNotPi Wow, the progress you've made looks really nice! I have a couple quick questions. 1) Is the code on github or something similar yet? I'd like to look at it. 2) I think I understand the array syntax you're using, but I'm not positive. What does (({}){}) output? (Double the TOS) what about (()()())?
Left input arity 1
[0, 2]
Right input arity 0
retval [0, 2]
I've added "retval" to represent the return value of the expression. Two arbitrary snippets typically need to have the same return value to be equivalent, but in some cases (like inside <n>) the return value doesn't matter.
for the second snippet:
processed (()()())
Left input arity 0
[3]
Right input arity 0
retval [3]
I think I have a cool idea as to how to represent these operations (once again, ignoring [] and {n}): as matrices.
Hmm, OK. It makes sense now, but it seems like there needs to be a way to distinguish which stack the retval goes to. Because the TOS in the retval is the top of the left stack, but it's pushed on to the right
I've already filtered for stuff like <<>>, now I'm working on eliminating <><> and also choosing a single ordering when multiple orderings are identical, like ()<> instead of <>().
I've gotten the 135 down to 82 length-6 snippets.
I'm pretty sure {{...}} is totally redundant.
But I'm not generating any looping code right now.
I'm bumping it up to length-8 snippets for testing... 1134 unfiltered.
In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. They are named after the Belgian mathematician Eugène Charles Catalan (1814–1894).
Using zero-based numbering, the nth Catalan number is given directly in terms of binomial coefficients by
C
n
=
1
n
+
1
...
The asterisk means that it is filtered out. The "check against" means something got through the filter that shouldn't have (although there is a slim chance of hash collision). The "possible unique" means that something may have been incorrectly blocked. Most of those "uniques" are actually duplicates of snippets that hadn't been tried yet.
looks like I need to implement [...<>] == [...]<> and <...<>> == <...><>
Doing some benchmarks on CraneFlak on my crappy netbook, it looks like it runs about 8 times faster than the Ruby Brain-Flak interpreter once initialization time becomes small enough compared to the overall running time.