Examine individual changes

Abuse Filter navigation (Home | Recent filter changes | Examine past edits | Abuse log)
Jump to navigation Jump to search

This page allows you to examine the variables generated by the Abuse Filter for an individual change.

Variables generated for this change

VariableValue
Edit count of the user (user_editcount)
316
Name of the user account (user_name)
'ChuckEsoteric08'
Age of the user account (user_age)
32126215
Groups (including implicit) the user is in (user_groups)
[ 0 => '*', 1 => 'user', 2 => 'autoconfirmed' ]
Page ID (page_id)
12263
Page namespace (page_namespace)
1
Page title (without namespace) (page_title)
'Bitch'
Full page title (page_prefixedtitle)
'Talk:Bitch'
Action (action)
'edit'
Edit summary/reason (summary)
'Pasted old revision'
Old content model (old_content_model)
'wikitext'
New content model (new_content_model)
'wikitext'
Old page wikitext, before the edit (old_wikitext)
'If an administrator is reading this: I accidentally deleted everything and can't undo so help pls'
New page wikitext, after the edit (new_wikitext)
'{{lowercase}} This is the talk page for [[bitch]].<br> Use this to discuss syntax, programs, or even to prove stuff about the language! <hr> <i>Note:</i> <b>For the sake of everyone's collective sanity, do not delete anything!</b><br> Even if nothing comes out of one of these discussions they are still useful to show thought processes and progress within certain problems.<br> If you don't like what you said or you changed your mind, strike it out (use <code>&lt;strike&gt;&lt;/strike&gt;</code> or <code><nowiki><del></del></nowiki></code>) and write underneath. = Attempts at proving Turing-completeness = Since bitch is a newly created language and is fairly different to a lot of the languages usually used to prove Turing-completeness, a proof is hard to come up with.<br> Below are the attempts currently ongoing. Feel free to join one or add a brand new one! ==[In Progress] Compilation from [[Home Row]] to [[bitch]] by [[User:Helen]]== <i>This section has been redone as of [https://esolangs.org/w/index.php?title=Talk:Bitch&oldid=62789 16:43, 27 May 2019 (UTC)]. The previous version held nothing of use for either proving or showing the process behind proving the computational class of [[bitch]].</i> This proof consists of two parts: a memory equivalence proof, and an operation equivalence proof. In the memory equivalence proof, we will prove that [[Home Row]]'s memory structure can be simulated in (and therefore is equivalent to) [[bitch]]'s.<br> In the operation equivalence proof, we will prove that all [[Home Row]]'s operations can be simulated as a whole using [[bitch]]'s. Any looping inside proof code will prevent looping in a program, due to non-nestable loops in both languages.<br> Since looping must remain possible as part of the equivalence, looping must not be present in proof code. === [Invalid] Memory equivalence === For an <code>n</code>x<code>m</code> [[Home Row]]-like grid to be equivalent to a tape, we have to show that we can either: * Simulate a grid inside a tape - every time we reach a cell whose index is a multiple of <code>grid width</code> (1-indexed) and try to go forwards again, we must go back <code>grid width - 1</code> cells <nowiki>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-</nowiki> every time we want to go down, we must go forwards <code>grid width</code> cells * Simulate a tape inside a grid - every time we want to go forwards in the tape, we must check whether the pointer is at the rightmost end of the grid, and if so, we wrap down to the leftmost end of the next row For the sake of simplicity, neither of these has to be able to go back/up a cell.<br> This means the only way to backtrack is by wrapping back around at the right and bottom edges (for a grid) or at the end (for a tape). Since it is more simple to simulate a tape in [[Home Row]] than it is to simulate a grid in [[bitch]], this proof will show that it is possible to simulate a tape.<br> This means we must be able to check whether we are at the rightmost edge. The simplest way to do this is by filling the rightmost column with zeros and not allowing any zeros inside cells (labelled <code>c<sub>n</sub></code>): c<sub>1 </sub> c<sub>2 </sub> c<sub>3 </sub> c<sub>4 </sub> 0 c<sub>5 </sub> c<sub>6 </sub> c<sub>7 </sub> c<sub>8 </sub> 0 c<sub>9 </sub> c<sub>10</sub> c<sub>11</sub> c<sub>12</sub> 0 c<sub>13</sub> c<sub>14</sub> c<sub>15</sub> c<sub>16</sub> 0 c<sub>17</sub> c<sub>18</sub> c<sub>19</sub> c<sub>20</sub> 0 We must then create a code snippet to prove we can move forwards.<br> For legibility and ease of understanding, two macro-like operations will be used: *<code>l</code> - moves 1 grid space left, equivalent to <code>f f f f</code> :<code>jl</code> is equivalent to <code>jf jf jf jf</code> and not to <code>jf f f f</code>. *<code>u</code> - moves 1 grid space up, equivalent to <code>d d d d</code> :<code>ju</code> is equivalent to <code>jd jd jd jd</code> and not to <code>jd d d d</code>. <u>Move forwards:</u> f <u>Move down if the pointer is on a zero:</u> d ju <u>Move right if the pointer is on a zero:</u> jl f <b><u>Combined:</u></b> f d jdjdjdjd jfjfjfjf f We can navigate the [[Home Row]] grid as if it were a tape, with the limitation that the tape is only 20-cells long.<br> However, this still proves that a grid memory space is equivalent to a tape space, since it shows that any <code>n x m</code> grid is equivalent to <i>at least</i> an <code>(n-1)m</code> tape.<br> Overall size is irrelevant, as [[Turing-completeness|Turing-complete]] actually requires and infinite tape size, and all languages are limited to a finite memory.<br> <hr> I don't believe that the translation of <code>jl</code> works: <code>jf jf jf jf</code> will get stuck when it hits a zero value. I believe the translation is also at odds with the requirement that the <code>c<sub>i</sub></code> values are non-zero... --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) :Both of those are intentional: :*<code>jl</code> is meant to get stuck on zero values :*<code>c<sub>i</sub></code> values are meant to be limited to non-zero values :However this is pretty clumsy and part of the reason I marked this as invalid.<br> :The new proof will hopefully be better, although a proof is pretty trivial and not <i>really</i> necessary but good for completion. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:27, 29 May 2019 (UTC) OTOH, since you're basing the memory on the cell-based storage, you can directly implement arbitrary permutations of <code>c<sub>1</sub> ... c<sub>nm</sub></code>, so the <code>d</code> and <code>f</code> operations can be implemented directly. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) :That's true the operations can most likely be directly implemented on a tape. :I realised shortly after posting this proof that the memory structure I'm using for [[bitch]] is actually simply a cell-based RAM.<br> :For that reason, I invalidated the memory proof and I'm working on a new one. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:27, 29 May 2019 (UTC) <hr> === Operation equivalence === In this proof, it is assumed that the random access cell-based alternative memory structure is being used. There are some trivial equivalences (such as <code>l</code> or <code>j</code>), which we will deal with first.<br> However, there are also some more complex equivalences which will be dealt with individually and with explanations. For the sake of simplicity, we will be using three macro-like operations: * <code>L<i>n</i></code> - loads the <code><i>n</i></code><sup>th</sup> cell, equivalent to [[Talk:bitch#Loading_the_value_of_a_cell|the code for loading the value of a cell]]. * <code>S<i>n</i></code> - sets the <code><i>n</i></code><sup>th</sup> cell, equivalent to [[Talk:bitch#Setting_the_value_of_a_cell|the code for setting the value of a cell]]. ==== Trivial equivalences ==== {| class="wikitable" |- ! [[Home Row]] !! [[bitch]] |- | <code>j</code> || <code>;</code> |- | <code>k</code> at cell <code>n</code> || <code>Ln/&0Sn</code> |- | <code>l</code> || <code>&gt;</code> or <code>&lt;</code> |- | <code>;</code> || <code>.</code> |} Both <code>f</code> and <code>d</code> are not necessary to find an equivalence to, since we already showed that a cell-RAM in [[bitch]] is equivalent to a grid in [[Home Row]]. ==== Addition and Subtraction ==== Addition (and subtraction) for a fixed-size cell is possible with definite looping and therefore can be unrolled to have no looping at all. We remain with the same simple addition algorithm, instead we now write it for a fixed number of loops.<br> We must pick a number of loops such that we guarantee that <code>p = oldP</code> at the end (or equivalently that <code>q = 0</code>).<br> The bit width of the cells is enough to guarantee this. <pre>p <- some cell q <- some cell p <- p XOR q \ q <- (p AND q) LS 1 \ ... > bitwidth times p <- p XOR q / q <- (p AND q) LS 1 /</pre> We can use a pseudo-extension of the cell-RAM to temporarily store <code>p</code> and <code>q</code>.<br> We then perform the <code>n</code> iterations and leave the result in the topmost accumulator. <u>Getting both variables:</u><br> This is the same as the code snippets from [[Talk:bitch#Bitwise_operations_on_two_cells|the code for performing bitwise operations]]. <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0</pre> <u>Storing the next </u><code>p</code><u>value:</u> <pre>|[(2*n)^]n]n&0</pre> <u>Storing the next </u><code>u</code><u>value:</u> <pre>|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0</pre> We then repeat those two code snippets another <code>n-1</code> times.<br> In the combined code, we'll paste this only once. <u>Moving the result into the accumulator:</u> <pre>[(2*n)|]n&(1<<n-1)</pre> <b><u>Combined:</u></b> <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0 |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)</pre> Subtraction can be expressed as two additions - <code>p + ~q + 1</code>. <u>Loading and negating </u><code>q</code><u>:</u> <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)~]n~</pre> <u>Adding 1 to </u><code>~q</code><u>:</u> <pre>|1]n |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)]n</pre> <u>Loading </u><code>p</code><u>:</u> <pre>|[((a+1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)]n</pre> <u>Summing </u><code>p</code><u> and </u><code>~q + 1</code><u>:</u> <pre>|[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n</pre> <u>Moving the result into the accumulator:</u> <pre>[(2*n)|]n&(1<<n-1)</pre> <b><u>Combined:</u></b> <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)~]n~|1]n |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)]n|[((a+1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)]n|[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)</pre> === Conclusion === Since [[bitch]] can successfully emulate [[Home Row]]'s operations and, their memory structures are equivalent, [[bitch]] must be able to solve at least as many problems as [[Home Row]]. This means [[bitch]] is [[Turing-complete]]. <hr> I am pretty sure that [[brainfuck]] cannot compile to [[bitch]], since brainfuck requires nested loops to be [[Turing-complete]]. [[bitch]] can only nest an infinite loop once. I suggest that [[Home Row]] might result a more efficient compilation proof. --[[User:A|A]] ([[User talk:A|talk]]) 11:08, 15 April 2019 (UTC) Of course, I completely forgot about the loops. I had a look at [[Home Row]] and it seems to be all good but I didn't quite understand the loop definition. Is it similar to [[bitch]]'s? - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 13:14, 15 April 2019 (UTC)<br> Oh I understand the loop now. It might be a problem since [[bitch]]'s loops runs for the first time no matter what whereas [[Home Row]]'s runs only if the current memory value is 0. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 13:24, 15 April 2019 (UTC) Anyway, the way of executing loops does not affect its [[Computational class]]. --[[User:A|A]] ([[User talk:A|talk]]) 13:50, 15 April 2019 (UTC)<br> You are understanding the loops the wrong way. It says that the loop will run if the current memory spot is <b>nonzero</b>. --[[User:A|A]] ([[User talk:A|talk]]) 14:55, 15 April 2019 (UTC) Oh of course, my bad. But either way there is no reasonable way to replicate that in [[bitch]] in a general way. I'm glad it doesn't affect the [[Computational class|computational class]]; phew - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:57, 15 April 2019 (UTC)<br> <!--Astonishingly, [[User:int-e|int-e]] has implemented bounded-storage [[brainfuck]], disregarding to this ongoing work. --[[User:A|A]] ([[User talk:A|talk]]) 10:39, 18 May 2019 (UTC)--> <hr> === The compilation probably failed === Home Row requires unbounded memory to be [[Turing-complete]]. However, only a limited 32-bit version of incrementing and decrementing was implemented. So, the attempt had certainly failed. [[User:A|I]] could not find any other [[:Category:Computational models|computational models]] useful for proving whether [[bitch]] is [[Turing-complete]]. --[[User:A|A]] ([[User talk:A|talk]]) 14:05, 13 May 2019 (UTC) [[bitch]]'s cell-based alternative storage is computationally equivalent to [[Home Row]]'s. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 17:18, 13 May 2019 (UTC) :Sorry, but I believe you've missed an important point about [[Home Row]]: its 5<sup>2</sup> cells are unbounded. That is how it manages to be [[Turing-complete]]. So A has a point (with 32 replaced by the now arbitrary, but fixed, bit width) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) ::I didn't say anything before out of pure laziness but below is the logic as to why [[Home Row]]'s and [[bitch]]'s cells are equivalent for the sake of current computation. ::[[bitch]] can simulate arbitrary sized cells. This is computationally the same as [[Home Row]] as no cell can be truly unbounded.<br> ::Even if the cells are allowed to expand as much as necessary, eventually a RAM limit will be hit and the cell will be capped at an arbitrary size limit.<br> ::[[bitch]] will be able to simulate a cell at that size limit as it too is only limited by the same factors. ::The rest of the new (and valid) memory equivalence proof will be up eventually but that is essentially part of it.<br> ::[[bitch]] is TC essentially on a technicality but that is enough (at least until we get truly infinite memory). - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:20, 29 May 2019 (UTC) :::The fact remains that you're not showing Turing-completeness. One can argue, and I would agree, that Turing-completeness is a purely theoretical concept, and that in practice we're usually programming sufficiently large finite automata anyway. (Sometimes we're dealing with analogue signals, but those are noisy.) Note that just like Turing machines, bitch cannot be implemented on real hardware, because it has unbounded memory (both in the accumulator and in the storage). To show that bitch is TC, one needs to implement a Turing-complete formalism (a Turing machine, or something equivalent to a Turing machine) in bitch. :::On the level of finite state machines, programming becomes a matter of compression: how big does a program have to be to operate on a certain number of states? A direct description of FSMs in terms of states and transitions is impractical for real computations--a program of size n can access O(n) states at best. With bitch, compression is possible: Cell-based storage (which you're using here) allows a program of size n to work on 2<sup>O(n)</sup> states. The RAM construction boosts this to 2<sup>2<sup>O(n)</sup></sup>. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:39, 30 May 2019 (UTC) ::::Yeah after thinking about it for a while, I realised I only really showed that it's equivalent to a [[Bounded-storage machine|bounded-storage machine]] with an arbitrarily large bound, which makes it "effectively TC" for all reasonable computation, but still doesn't prove that the language itself is [[Turing-complete]]. ::::Of course by "only really showed" I mean "will only really show" because I'm still working on finishing the new memory equivalence proof but once that's done I'll update this. ::::I think I have an idea for addressing infinite memory in [[bitch]], which would prove its [[Turing-completeness]], but I'll have to do that after this proof. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:41, 30 May 2019 (UTC) === Terminology === You're attempting to show that every [[Home Row]] program can be translated to an equivalent [[bitch]] program, but for an equivalence proof between the two languages, you would need both directions, i.e., you'd also have to translate [[bitch]] programs to [[Home Row]]. What you have (if correct) is a reduction from a bounded cell variant of Home Row to bitch. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) : My bad, I'll fix the title. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:17, 29 May 2019 (UTC) == Some thoughts == The provided implementation has a 63-bit accumulator and bit-storage, which is pretty small, and Java has builtin bigints so you might want to use that. Also, [https://cs.stackexchange.com/questions/2832/is-a-push-down-automaton-with-two-stacks-equivalent-to-a-turing-machine/2833#2833 according to this StackExchange answer], a 2-stack [[Push-down automaton]], which might be emulated using the accumulator and bit-storage, is equivalent to a turing machine. So this could be a possible way of proving TCness. Although the lack of nested loops might be a problem. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 08:50, 17 April 2019 (UTC) : There also seems to be some inconsistency with rapport to <code>&gt;...&lt;</code>: the spec says for <code>&lt;</code> that it "jumps to the nearest <code>&gt;</code>" but the implementation saves the position of a <code>&gt;</code> only when executed. So for example in <code>&gt;#0;&gt;&lt;</code>, should the <code>&lt;</code> jump to the first or second <code>&gt;</code>? :: <del>I will ask [[User:Helen|Helen]]; I have no idea.</del> --[[User:A|A]] ([[User talk:A|talk]]) 11:26, 17 April 2019 (UTC) :: Wait, where did you find that code snippet? ::: I wrote it to show the problem. It's hypothetical, but having a well-defined spec is always a good thing. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:41, 17 April 2019 (UTC) :::: I [https://tio.run/##S8osSc74/99O2UDf2k7ZUN/m/38A ran a similar program] and found that it jumps to the first ">". You are right; the documentation indeed has to be modified.--[[User:A|A]] ([[User talk:A|talk]]) 12:04, 17 April 2019 (UTC) <del>:I think that implementing a 2-stack [[Push-down automaton]] would be trivial, as 2 stacks already have the power of simulating a tape. It might be better if you directly simulate a tape. --[[User:A|A]] ([[User talk:A|talk]]) 14:52, 29 April 2019 (UTC)</del> Spec problem fixed and the rest talked about in [[User talk:Helen|my user talk]]. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 15:16, 17 April 2019 (UTC) === Another idea === It seems that we are having trouble implementing my incrementing/decrementing algorithm. That is why I made a improvement of the incrementing/decrementing algorithm.<br> This is what I typed in a Lua prompt. This improvement is inspired by this: <pre> Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio > ~-1 0 > -~1 2 > </pre> ~-x is equal to x decremented, and -~x is equal to x incremented.<br> -x is the negation of x. ~x is a bitwise NOT.<br> In case you question me about my algorithm, I will add more examples here: <pre> > ~-9 8 > -~9 10 > ~-12 11 > -~12 13 > </pre> These expressions are universal, which means that you can also run it in Java, Python, etc.<br> It requires a front-register, which saves a pseudo-top element of a number that changes dynamically when a new bit is used. Negating inverts the pseudo-top element, and bitwise NOT-ting inverts all the bits from the pseudo-top to the bottom. If there are 8 bits for each cell, 3 bits are sufficient for representing the front-register. However, this results in recursive incrementing the front-register every time a bit is used, which might be quite hard to do.<br> Inverting the bits after the pseudo-top might be sufficient.<br> It is highly probable that I am misunderstanding these expressions.--[[User:A|A]] ([[User talk:A|talk]]) 10:01, 29 April 2019 (UTC) == Bitch might be Turing-incomplete == If we treated the accumulator as a counter, with <code>[1</code> for increment and <code>]1</code> for decrement, we could treat it as a 1-register [[Minsky machine]]. However, ''two'' counters are required for an increment-decrement machine to be Turing complete, as one-counter Turing equivalence requires multiplication and division, which are impossible without a temporary.<br> Then, if we treat the accumulator+shift register as an unbounded bit tape, it still cannot be Turing complete, as we don't have the ability to non-destructively check only one bit of said tape, only checking if all the bits in the accumulator section are zero or at least one bit is non zero.<br> Maybe other models are possible, but it does seem like it's not Turing-complete. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 15:33, 17 April 2019 (UTC) : You can't independently check the value of a specific accumulator. Neither can you increment or decrement them, without making a loop, which would prevent backward state changes due to the non-existence of nested loops or gotos. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:21, 18 April 2019 (UTC) : In addition, I'd like to see an algorithm that can copy a bit in the accumulator to a different position, but *without* using loops, as using a loop in such an atomic operation would instantly break Turing-completeness due to the necessity of a global program loop to apply state changes. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:28, 18 April 2019 (UTC) :: To clarify: what I mean is that bitch doesn't have any way of control flow other than the non-nestable <code>&gt;&lt;</code> construct and conditional forward jumps. However, for Turing completeness, conditional backward jumps are also required. This can be emulated by putting most of the logic in an unconditional loop, but then it is impossible to build inner loops. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:44, 18 April 2019 (UTC) Nevermind, I didn't realize you could put a valid bitch instruction after a OR, which allows copying data from the storage. The article is quite unclear on this point. It might just be Turing complete, actually. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 21:11, 21 April 2019 (UTC) Completely my fault, the ability to nest instructions like that is one of the most important parts of the language but it gets about two sentences on the main article.<br> I'm gonna rewrite most of the main article soon; I've been gathering feedback about things that generally aren't very clear. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:40, 21 April 2019 (UTC) <!--I have tried several Turing-complete computational models. (These include the [[Minsky machine]](proven to be trivial above), the [[I/D machine]](seems to be nice), Tag systems(bitch currently does not support queues; Sequential tag systems are worth a try. If anyone implemented queues, I will be amazed...), the Turing-machine(Worth a try), etc.)--[[User:A|A]] ([[User talk:A|talk]]) 14:21, 13 May 2019 (UTC)--> ==[Unsuccessful] Compilation to Z3 derivative by [[User:Helen]]== This attempt contains programs that might be useful to prove the [[Turing-completeness]] of [[bitch]]. ===[[User:A]] - Basic compilation=== This programming language looks like Konrad Zuse's Z3, which was already proven to be Turing-complete by Raúl Rojas [http://page.mi.fu-berlin.de/rojas/1997/Universal_Computer.pdf here]. First of all, Z3 is capable of executing an infinite loop. This is achieved in bitch as the <code>&gt; &lt;</code> block.<br> Also, Z3 has math operation evaluation capabilities. Z3 can implement 5 operations: addition, subtraction, multiplication, division, and square-rooting.<br> Even though these arithmetic operations have not been shown to be implementable in bitch, only the operations of zeroing a value and incrementing a value will be necessary for Turing-completeness, as mentioned [https://www.cl.cam.ac.uk/~sd601/papers/mov.pdf here]. Raúl Rojas shows that an instruction set with load, store, increment, zero and unconditional branching is Turing-complete.<br> However, Load and Store have to be indirect. They should be nested for at least 2 indices. Also, infinite memory (a requirement for Turing-completeness) can be implemented in the Z3.<br> Finally, Z3 has a way to stop the program by using an invalid operation. That is <code>.</code> in bitch. ===[[User:Helen]] - Implementing arithmatic operations=== This part was proven partially unneccesary, as [[User:A|A]] had found a command set that is easier to compile to [[bitch]]. On the other hand, these programs might make [[bitch]] easier to program in.<br> The conditional snippet below is easy to replicate in bitch: <pre>if (z = i) then 0 else 1</pre> We simply use XOR to check if a number <code>z<code> is equal to some constant <code>i</code> like this: <pre>#z^i;#1</pre> If they are equal, the result of XORing them is automatically 0.<br> If they are not, the result is some non-zero number which we can detect (through the conditional <code>;</code>) and then set the accumulator to 1. Mathematical operations are a bit harder to pull off.<br> I have managed to get an algorithm for addition.<br> <s>Subtraction can be imitated through addition with negatives (due to algorithm overflowing and actually giving the correct number).</s> It can't.<br> I haven't managed to get an algorithm for multiplication or division yet. <hr> <b>Addition:</b><br> Binary addition is very simple. Ignoring carry overs, each digit behaves like this: {| class="wikitable" |- ! a !! b !! a+b |- | 0 || 0 || 0 |- | 0 || 1 || 1 |- | 1 || 0 || 1 |- | 1 || 1 || 0 |} This is equivalent to XOR. In order to get full addition behaviour though (rather than just "fairly close but not really" addition behaviour), we have to consider carry overs.<br> This is how carry overs behave: {| class="wikitable" |- ! a !! b !! a+b's carry |- | 0 || 0 || 0 |- | 0 || 1 || 0 |- | 1 || 0 || 0 |- | 1 || 1 || 1 |} This is equivalent to AND.<br> The carry overs are put onto the digit one order higher though.<br> Therefore, we left shift each carry once. This gives us our full (recursive) algorithm.<br> In pseudocode: <pre>a <- input b <- input oldA <- a+1 while (a != oldA) { withoutCarries <- a XOR b carries <- (a AND b) LS 1 oldA <- a a <- withoutCarries b <- carries }</pre> This is perfectly doable in v4.7* bitch (takes 2 inputs): <pre>\[16|\]32>|[32&4294967295#|0^[16|-281474976710656&]32]15&131070|[31&281470681743360|]16&4294901760|[16#|0&4294967295|[32&281474976710655]32;<|[16/</pre> ===[[User:Helen]] - Proving required operations=== In order to be Turing-complete, a language <i>requires</i> a very minimal instruction set (as shown by Raúl Rojas) and infinite tape (by definition).<br> The required instruction set consists of: load, store, increment, zero and unconditional branching.<br> If a language can do these and can simulate an infinite tape (or an arbitrarily sized tape), it is Turing-complete. In order to show these are true, we must envision the bitch accumulator as a tape.<br> Cells are delimited portions of the tape that are <code>n</code>-bits wide (<code>n</code> being an arbitrary choice of integer width).<br> Addressing is signed, negative numbers meaning backwards in the tape and positive numbers meaning forwards in the tape. Loading and storing values can't really be emulated in bitch but a parallel of setting and accessing cells can be made. ====Setting cells==== Setting a cell to a constant value <code>c</code> can be done: <pre>#c</pre> However, this zeroes the rest of the accumulator which impends simulation of a tape.<br> Therefore, we opt for: <pre>|c</pre> Given that the cell at position 0 is equal to 0, this will set load the value <code>c</code>.<br> However this is dependant on the cell being 0, which is not desirable.<br> There are two options: zeroing the cell at position 0, or moving right/left (arbitrarily) until we find an empty cell.<br> I choose to zero the cell in order to be able to maintain a knowledge of where things are positioned in memory.<br> Furthermore, this doesn't impend one from storing the value at position 0 elsewhere and therefore it is the best option. <hr> With <code>c</code> being the desired constant value and <code>n</code> being the bit-width of the cells in the tape: <pre>|((1<<n)-1)^((1<<n)-1)|c</pre> <i>For the sake of simplicity, brackets represent an expression which must be calculated and put in the source code.</i><br> If <code>n</code> is 8, the code would become: <pre>|255^255|c</pre> ====Accessing cells==== A value at positive position <code>p</code> can be accessed through the following code: <pre>](p*n)</pre> A value at negative position <code>q</code> can be accessed through the following code: <pre>[(q*n)</pre> ====Incrementing==== Incrementing is simply the addition of 1.<br> It is also currently not implemented or working. Incrementing can be done by checking each bit, starting from the rightmost bit going left, until we reach a 0 bit.<br> That 0 bit becomes 1 and all the bits lower than it become 0. In order to check individual bits we must OR individual bits with 1 and check for equality with the previous version.<br> In pseudocode: <pre>number <- input previous <- number n <- 0 while(number | (1<<n) = previous) { n <- n+1 } number <- number | (1<<n) number <- number ^ ((1<<n)-1)</pre> The algorithm is currently a work in progress. <!--<big>THIS IS WRONG</big> <strike>In order for incrementing to be done, a significant amount of setup is required.<br> The starting setup should be of all the used memory in topmost storage and a zeroed accumulator.<br> Given the position <code>p</code> of the number to be incremented in the storage and <code>a</code> as the size of the storage in cells and <code>n</code> as the bit-width of each cell,<br> The following isolates the number from the storage: <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p)*n)&((1<<n)-1)</pre> We then set up the three copies of the number as part of the main search loop. <pre>|[(4n)&(1<<(4n)-1<<(3n))|]n|](2n)</pre> We then 0 the rightmost bit of the topmost number and compare it to the original. If they are not equal, then the bit was a 1 and the search continues. <pre>|(1<<(3n))^(1<<(3n))^]n]2n;<</pre> We then return to the beginning of the loop, where we must set up the next iteration of the search. <pre>&1[(n-1)</pre> We then create 3 copies again and the loop restarts.<br> As part of this we must correctly prepare the initial number for the mainloop.<br> <pre>](n-1)</pre> At the end of the loop, we must correctly format the resulting number and set the memory back to its original condition.<br> <pre>|1|[((a+1)*n)#|0[((a+1)*n)>]1;<[((a+2)*n)&(1<<((a+1)*n)-1)|[((2a-p)*n)&(1<<((2a-p+1)*n)-1<<n)]n|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)&(1<<(a*n))](a*n)</pre> This achieves the above. Collected below is the code necessary to increment, given a cell at position 0 matching the required conditions: <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p)*n)&((1<<n)-1)](n-1)>&1[(n-1)|[(4n)&(1<<(4n)-1<<(3n))|]n|](2n)|(1<<(3n))^(1<<(3n))^]n]2n;<|1|[((a+1)*n)#|0[((a+1)*n)>]1;<[((a+2)*n)&(1<<((a+1)*n)-1)|[((2a-p)*n)&(1<<((2a-p+1)*n)-1<<n)]n|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)&(1<<(a*n))](a*n)</pre> Where <code>p</code> is the 0-indexed position of the cell with the number to increment, starting counting from the leftmost cell; <code>n</code> is the bit-width of the cells; and <code>a</code> is the size of the currently allocated memory in cells.</strike> <big>THIS IS WRONG</big>--> ====Zeroing a cell==== This was done in the section on setting bits but will be restated here with some explanation.<br> Zeroing can be done by ANDing with a number that has the desired bits - the bits you want to zero - zeroed and all other bits as ones.<br> However, due to the arbitrary size of bitch's accumulator, we cannot rely on this (well we can but I choose not too since calculating differences of powers of two is more tedious than changing one digit).<br> Therefore, OR-XORing seems to be most suitable.<br> We can OR to set the desired bits to 1, then XOR to "flip" them, effectively zeroing them. If we want to zero the cell at positive position <code>p</code> with cell size <code>n</code>, we use the following: <pre>]p|((1<<n)-1)^((1<<n)-1)</pre> If we want to zero the cell at negative position <code>q</code> with cell size <code>n</code>, we use the following: <pre>[q|((1<<n)-1)^((1<<n)-1)</pre> Both of these will end with the tape positioned over the cell you just zeroed. ====Unconditional Branching==== bitch lacks in unconditional branching.<br> It is possible to infinitely repeat code but that is all you can do unconditionally. <pre>>code<</pre> = Alternative memory structures = The accumulator-storage combination may be quite limiting in certain circumstances.<br> In this case, some alternative memory structures are implemented below in bitch for ease. == Random access cell-based memory == A cell-based memory can be emulated in bitch.<br> All that is required is an arbitrary choice of bit-width for the cells, and a size (in cells) of the currently allocated memory.<br> We will call the bit-width of cells <code>n</code> and the size of the memory <code>a</code>. In terms of structuring in bitch's accumulator-storage conjunction, the memory will be in topmost storage (closest to the accumulator) and the accumulator will remain empty to be used for calculations. <hr> === Loading the value of a cell === Given a cell indexed <code>p</code> (in a 0-based index where the leftmost cell is 0 and the rightmost is <code>a-1</code>), we can set the accumulator to its value by the following steps. <u>Copying up the entire memory to the accumulator:</u> <pre>|[(a*n)</pre> <u>ANDing the cell that we want:</u> <pre>&(1<<((a-p)*n)-1<<((a-p-1)*n))</pre> <u>Then shift copying it down to the bottom of the accumulator:</u> <pre>|]((a-p-1)*n)&((1<<n)-1)</pre> <b><u>Combined:</u></b> <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)</pre> <hr> === Setting the value of a cell === Given a cell indexed "p" (in a 0-based index where the leftmost cell is 0 and the rightmost is <code>a-1</code>), we can transfer the value from the accumulator to the cell by the following steps. <u>Moving the accumulator value to the correct position to line up with p:</u> <pre>|[((a-p-1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))</pre> <u>Clearing the old value:</u> <pre>[(a*n)|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))</pre> <u>Copying down the new one:</u> <pre>|](a*n)</pre> <u>Clearing the accumulator:</u> <pre>](a*n)&0</pre> <b><u>Combined:</u></b> <pre>|[((a-p-1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))[(a*n)|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)](a*n)&0</pre> <hr> === Bitwise operations on two cells === Performing bitwise operations with two cell arguments is trivial now that we have the load and set.<br> We can use the <code>^^</code> combination to perform arbitrary argument operations without messing with the storage.<br> Given an operation <code>x</code>, we can load two cells 0-indexed <code>p</code> and <code>q</code> and then perform <code>q x p</code>. <u>Loading cell </u><code>p</code><u>:</u> <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)</pre> <u>Loading cell </u><code>q</code><u>:</u> <pre>[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0[(2*n)</pre> <u>Performing binary operation </u><code>x</code><u>:</u> <pre>^^x]n]n&0[n</pre> <b><u>Combined:</u></b> <pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0[(2*n)^^x]n]n&0[n</pre> =[Disproven] Conjecture: [[bitch]] cannot copy one bit from memory to another part of memory while retaining existing data= :'''edit:''' The specific memory copy claim/challenge of this conjecture has been successfully disproven, multiple times over. The more general 'Not TC' part still seems valid, but I'm changing the section heading so it's clear what the 'Disproven' relates to. Section still has value because it prompted useful progress in determining computational class [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:42, 20 May 2019 (UTC) I was following [[Talk:Bitch#Bitch_might_be_Turing-incomplete|TuxCrafting's (now struckthrough) arguments against TC above]], and I don't think the ability to chain instructions helps that much (because they can't be grouped), and the challenge "to see an algorithm that can copy a bit in the accumulator to a different position" is still open. There are multiple ways to formulate this as a challenge, but this is the simplest I could come up with: Create a bitch program that can take an already initialised 3 bit accumulator <code>abc</code> and convert it programatically to <code>abb</code>: abc => abb examples: 011 => 011 (3 => 3) 101 => 100 (5 => 4) 110 => 111 (6 => 7) (As I read it) There is no way to group or order the evaluation of chained operations, and no temporary scratch space to use different parts of the accumulator for a single operation. The accumulator cannot be practically masked in such a way that one sub-part of it can interact with another and re-stored, without losing sub-parts not involved in the operation. Here is the full mapping of expected results: 0 -> 0 1 -> 0 2 -> 3 3 -> 3 4 -> 4 5 -> 4 6 -> 7 7 -> 7 A simple algorithm to do this for three bits is: (abc & 0b110) | ((abc & 0b010) >> 1) This requires grouping and two separate logic operations on the accumulator (abc) as sub steps. Since bitch modifies the accumulator in place, no amount of instruction chaining will help. The logic operations are only useful when combining the accumulator with number literals or user input. Conjecture: * A machine with two independent stacks should be able to copy a value from one stack to the other. A machine that cannot copy a single bit in isolation from anywhere in memory to anywhere else, regardless of the actual datastructures involved, has no hope of simulating two stacks. * There is no way to create a generalised algorithm to perform simple bit copy in bitch, therefore the language cannot simulate two independent storage stacks or accumulators. * It may be possible to produce the results above in bitch by creating effectively a lookup table mapping the input to desired output, but that proves lack of Turing completeness if the only way to produce arbitrary results is to create lookup tables mapping input to output. * The ability to copy data from one memory location to another with destroying all other data is required equally for any TC system involving multiple stacks, multiple counter registers, and equally to cyclic tag systems and cellular automata. If I have somehow missed something in the spec, proving this false does not necessarily mean the language is TC. If there is a clever way to do the copy, I imagine it will require effectively placing an upper bound on the accumulator, and multiple unbounded stacks or accumulators cannot be simulated from a bounded one. I believe this makes bitch a PDA, since one end of the accumulator can be used as a ''single'' stack, and transitions decision can be made based on that. This talk page is getting hard to follow with many sections having questionable statements without attribution. Hopefully this bit copy challenge will be easier to address than a full TC proof. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:48, 7 May 2019 (UTC) : I didn't notice the implemented memory structure was supposed to be bitch because it has parentheses <code>()</code> to group operators (which AFAICT bitch lacks, and is the major hurdle to completing this challenge in pure bitch) and standard bit-shift operators <code><<</code> mixed in with bitch syntax. I am guessing that the intent was to precalculate all those values and substitute them into the bitch source as number literals? This is what I have noticed about all the examples given, and what this challenge is trying to prove: that binary operations cannot be done on two independent ''memory'' locations. It is easy to perform an operation with memory + number literal, but if you have to compute it all before hand and hardcode it into bitch, it's not bitch doing the computation, at least not in a way that is TC. I tried substituting values into that code and couldn't get it to work, can you? The form for this challenge will be something like <code>\[]/</code> where <code>[]</code> is replaced with a bitch algorithm of any size which copies the bit. If it is easy to do, then I have clearly misunderstood something about how the storage behaves and an example would clear up the confusion. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 12:08, 8 May 2019 (UTC) ::In theory you can do any terminating amount of pre-computation "by hand" (which really means as part of compiling into your language). (From [[User_talk:Oerjan#Turing_completeness|Oerjan's user talk]]). --[[User:A|A]] ([[User talk:A|talk]]) 04:02, 9 May 2019 (UTC) : Copying a bit of a 3 bit accumulator can be achieved using the follwing piece of code: <code>&6]3|[2&1[3|]3&7</code> (which also keeps the storage unmodified). One key point here is that chained instructions work on a fresh copy of the state (both accumulator and storage), so <code>|[2</code> and similar instructions leave the storage unmodified. :: For the record: <code>^^]1]1^^[1[1</code> achieves the same copying task (copy second bit to first bit) for any number of bits, using the ^^ trick. Note that this approach specific to copying adjacent bits; copying to a non-adjacent location is harder. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:28, 10 May 2019 (UTC) : More generally, any map with finite domain (old accumulator value to new accumulator value) can be implemented, as for example the ROT13 program on the main page. I don't see how to copy a bit in an unbounded accumulator though, so none of this really brings us any closer to TC-ness. This should be enough to show that bitch can simulate arbitrary PDAs though. For processing input, note that one ''should'' be able to read from input without destroying the storage using <code>&0|\</code>, but the Java interpreter doesn't really support this because each instance of Program creates its own new Scanner that reads a whole line of input... [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 05:43, 9 May 2019 (UTC) :: The algorithm is right there! For larger sizes, the shifts have to be adapted as well: <code>&14]4|[3&1[4|]4&15</code>. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:07, 9 May 2019 (UTC) :: Congratulations! This is a valid solution to the challenge as I stated it. I was surprised it works, but I can now see how, which is a welcome outcome. I think knowing the conditions under which this is possible is helpful too. Like I guessed it places bounds on the storage, and proves the language is at least computationally equivalent to a PDA. Perhaps there is a way to break though this limitation, but it makes the next steps clearer, and provides a clear example of a useful programming technique. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 00:03, 10 May 2019 (UTC) <b>This conjecture is disproven by the old alternative memory structures section as I understand it.</b><br> The variables there are simply the number of cells, the size of the cells and the cell to access.<br> The number of cells and size of cells is simply for customizability and would be fixed by the programmer to a value of their choosing for the entire program (e.g.: 20 and 8).<br> The position variable is simply the position at which the cell is that you want to access.<br> The expressions given are simply the values needed to move and zero parts of the accumulator as necessary, they work with any values. Binary operations on two different locations are very possible and they are the only reason for chaining operators.<br> The code snippet <code>&[8</code> will AND two different values given that they are both 8 bits wide and in the accumulator together, one on top of the other. The tape memory structure doesn't rely on precomputing, it allows for different sized tapes and different sized cells for customizability.<br> The values for the tape code are no less arbitrary than the value 8 in the above code. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:23, 9 May 2019 (UTC) : I seem to have reinvented parts of the "alternative memory structures" section below for GET and PUT, though as far as I can see the main contribution, random access, is new. I don't know why [[User:A|A]] deleted that section... [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 21:10, 9 May 2019 (UTC) : I tried to use your cell based memory structure early on but couldn't get it to work, here is a worked example of what I get: : With 3 bit memory, each cell is 1 bit, and the task is to copy cell 1 to the accumulator (which is slightly different from my challenge, but probably equivalent given some more steps), my abc is 012 in this structure. :* a = 3 (memory size) :* p = 1 (target cell, 0-indexed) :*n = 1 (cell width) :Loading a value from a cell formula, substituting using the values above: <code>|[3&4|]1</code> :I understand that this requires the memory to already be in the storage section, so if I pre-load the storage to 0b010 using <code>#2]3</code>, I would expect to get 1 in the accumulator by running <code>#2]3|[3&4|]1</code>, but that results in 0 in the accumulator and 2 in storage. Trying it with storage initialised to 0b111 (7) results in 0b110 (6) in the accumulator and 0b111 (7) in storage. Perhaps the formulas don't work with a cell width of one, but I don't know under which conditions it does work. I don't think that section should be deleted, it's possible am missing something about how to use the structure properly, or that there is a tiny bug in one part of it that could be identified and fixed as a result of using it for a specific task. This challenge was an attempt to get clarity on how to use the theorised techniques to do a specific task that did not seem obviously trivial to me. I would love to see an working example of your cell-based memory structure applied to the task above, I did try but couldn't make it work. The addition example (I think that is yours too?) was great as I could easily verify it did exactly what it claimed, and then spend time trying to understand how. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 00:20, 10 May 2019 (UTC) :: Yeah sorry for the lack of any examples. :: Given your above values: ::*a = 3 (memory size) ::*n = 1 (cell width) ::*p = 1 (target cell, 0-indexed) :: The following code snippet stores and retrieves 1 from the 2nd position (2 line &lt;pre&gt; tag meant I couldn't indent; anyone who can format well is free to do this over): :: <pre>#1|[1&2[3|2^2|]3]3&0|[3&2|]1&1/</pre> :: This is made up of two main segments:<br> :: <b>The storage segment</b>: :: <pre>|[1&2[3|2^2|]3]3&0</pre> :: <b>The retrieval segment</b>: :: <pre>|[3&2|]1&1</pre> :: Be aware that the TIO is currently not up to date and you'll need to use the interactive version or download the GitHub version.<br> :: Hopefully the TIO will be updated soon. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:09, 11 May 2019 (UTC) :: The solution to the original problem (directly copied and evaluated) would be: :: <pre>]3|[3&2|]1&1|[0&1[3|1^1|]3]3&0[3</pre> :: Which can be shortened to: :: <pre>]3|[3&2|]1&1[3|1^1|]3&7</pre> :: - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:24, 11 May 2019 (UTC) ::: Thanks [[User:Helen|Helen]], that example does indeed fulfil my challenge using your cell based memory structure, congratulations! I see now how it works, that the memory structure is good, and that you had figured out usable memory before I proposed my challenge. Apologies for doubting you! ::: Bitshift operator precedence seems to come after arithmetic operators in most programming languages (C, python, js), so when I used that formula, copied directly from [[Bitch#Loading_the_value_of_a_cell]] section, <code>1<<2-1<<1 = 4</code> which is what I tried for "ANDing the cell that we want" is different from <code>(1<<2)-(1<<1) = 2</code>, which looks like what you intended in the example. That threw me early and I stopped digging deeper. If you don't mind, I'll try to follow the rest of the example and update your [[Bitch#Loading_the_value_of_a_cell]] section if I can make it clearer? [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:26, 20 May 2019 (UTC) :::: Yeah, go ahead! That's perfectly fine by me.<br> :::: I always mentally replace <code>1<<</code> with <code>2^</code> so order of operations is a bit messed up for me on that sorry. :::: Generally feel free to edit stuff as you wish. Go wild! - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 14:41, 27 May 2019 (UTC) = Sketch: A RAM Machine = We sketch a bitch implementation of a machine with a 32 bit accumulator A (stored in bits 0..31 of the accumulator), a 32 bit extended accumulator X (bits 32..63), optional quick-access registers, and up to 2^26 - 1 individually addressable words of RAM. So even if bitch is not TC, it still appears to be a capable programming language. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:41, 9 May 2019 (UTC) :I've used this machinery to make a ''finite memory'' (so non-TC) Brainfuck interpreter; see https://github.com/int-e/bits/blob/master/examples/brainfuck.pp and the resulting https://github.com/int-e/bits/blob/master/examples/brainfuck (not thoroughly tested, may have bugs) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 22:47, 16 May 2019 (UTC) :In case other users get confused of how that preprocessor works, I clarify that the preprocessor takes input from the console and outputs the resulting bitch program. --[[User:A|A]] ([[User talk:A|talk]]) 12:10, 20 May 2019 (UTC) ::<del>How is it supposed to work? (I have inputted a brainfuck program and could not get it to work...) Does it take a program from input or whatever?</del> :::<del>From the .pp file: "[The p]rogram is separated from input by an exclamation mark (!)." Both the program and all input are read from stdin. A possible pitfall is that the exclamation mark is obligatory. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:56, 17 May 2019 (UTC)</del> ::I will be testing your implementation using <code>,[.-[-->++<]>+]</code>, which makes sure that a brainfuck interpreter supports all commands, nested loops, and unbounded memory. Testing halting is trivial... :::Although it is quite slow, the implementation is flawless. --[[User:A|A]] ([[User talk:A|talk]]) 06:51, 18 May 2019 (UTC) ::::I've implemented a (hopefully not too buggy) bitch interpreter in C++ which is a bit faster (in the same github repo) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:24, 21 May 2019 (UTC) ::I have an idea: you could extend the implementation to be unbounded by supplying tape extending operation, if this machinery supports extending the memory. :::First of all, extending memory after initialization is hard, perhaps even impossible, because the design is based on each memory cell containing its own address. (Without that stored address, `poke` doesn't work.) Shifting the existing memory would invalidate the addresses stored in that memory. Oh and I wouldn't know where to even begin doing such an extension without a loop. :::Note also that addresses are bounded. The current implementation uses 16 bit words, both for data and the addresses. Addresses need to be divisible by 32, so at most 2^11 - 1 = 2047 addressable memory cells are supported, and that's what the interpreter provides (minus memory used for stack, program, and registers). :::For the particular application as a Brainfuck interpreter, one could change the memory cell layout to use, for example, a 24 bit address and 8 bit data, increasing the address space to 2^19 - 1 = 512287 cells, but that's a non-trivial effort. An easier approach would be to set the word size to 32 bits (BB=5), with up to 2^27 addressable memory cells. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:56, 17 May 2019 (UTC) ::::Can the word size be set dynamically? If that is a yes, bitch would be Turing-complete. --[[User:A|A]] ([[User talk:A|talk]]) 10:26, 22 May 2019 (UTC) :::::Not with this design; the word size is hardcoded in all of the building blocks (initialization, reading and writing registers, reading and writing memory, arithmetic). --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 11:17, 22 May 2019 (UTC) ::<i>Wow</i>, the macro replacements can act as variables!!! See this program(which seems to be an abuse of this preprocessor): <pre> A=1, ,A, A=2, ,A, </pre> ::This program prints <code>12</code>, which is 1 and 2 combined. This can demonstrate that the word sized can be set dynamically in the preliminary stage; however, there is currently no way to implement unbounded cells using this way. This will not work if you want to extend the cell length though: <pre> CNT=4, BB=CNT, CNT={BB+1}, BB=CNT, ,BB, </pre>--[[User:A|A]] ([[User talk:A|talk]]) 13:04, 22 May 2019 (UTC) ::I am aware about the loop limitations...the maximum 63 loop nesting would be enough, as two loop nestings are sufficient for Turing-completeness ( refer to [https://cs.stackexchange.com/questions/102363/how-many-pairs-of-brackets-are-sufficient-to-make-brainfuck-turing-complete/102500#102500 this page]). --[[User:A|A]] ([[User talk:A|talk]]) 14:35, 18 May 2019 (UTC) :::I meant bitch's limitation of not supporting any nested loops. But you have a point—the same machinery that supports the Brainfuck loops can also support nested loops in general. So the fixed, bounded address size is the real limitation here. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:03, 18 May 2019 (UTC) ::Anyway, nice work!--[[User:A|A]] ([[User talk:A|talk]]) 13:47, 17 May 2019 (UTC) A summary of the construction in this section has found its way to the [[Bitch#Bounded storage|bitch page]] (last week). Is there anything left here that is worth preserving? (I mean the construction itself, not the discussion thereof.) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 08:09, 27 May 2019 (UTC) === Memory === The storage is used for memory. Addresses are 32 bits, the lowest 6 of which are always 0. Each word occupies 64 bits in memory that store the address of the word and the word itself value. The first few addresses may be used as additional registers instead, at the programmer's discretion. === Operations === None of these operations use > or <, so we can use them in loops. The operations are not clean for the ; conditional in the sense that the accumulator may become 0 while an instruction is executed. It should not be too difficult to accomplish that, with some extra care. (The motivation would be that operations that are clean for ; can be used as part of a state machine that manages the control flow.) * load immediate n (clears X): IMM n := ^^n * 32 bit decrement (assumes X = 0): DEC := ]32^1 [32^]32]32&[32 [31^]31]31&[31 ... [2^]2]2&[2 [1^]1]1&[1 &0[32 * 32 bit increment (assumes X = 0): INC := ~]32&0[32 DEC32 ~]32&0[32 * load a register (assumes X = 0, n divisible by 32): GET n := ^^[n]32&0[32 * store a register (assumes X = 0, n divisible by 32): PUT n := [n&-4294967296|]n]n * read a word at address in accumulator: # comment format: # accumulator | reverse storage PEEK := # A | ... A W ... ^^[^32 # A ... A W | ... A W ... ]32&0[32 # W | ... A W ... * store word at address (<2^32 - 8) in accumulator, with value given in upper 32 bit of (extended) accumulator: # comment format: # accumulator | reverse storage POKE := # X A | ... A W (A+64) ... [&4294967295 # X A ... A | W (A+64) ... [32 # X A ... A W | (A+64) ... &-4294967296 # X A ... A 0 | (A+64) ... ^^[32 # X A ... A 0 (A+64) | (A+64) ... ^]&4294967295 # X A ... A X ?? | (A+64) ... ^^]32 # X A ... A X | (A+64) ... ]32 # X A ... A | X (A+64) ... ]&4294967295 # X A | ... A X (A+64) ... * load extended part of accumulator (n divisible by 32) for stores: GETX n := ]32 GET (n+32) [32 * clear extended accumulator: CLEARX := &4294967295 * arithmetic with extended accumulator: XOR := ^]32 AND := &]32 OR := |]32 NOT := ]32~]32~[64 * initialize memory (only needed once, at the start of the program, so using > < ; is okay): INIT := >DEC&-64]64|[64;<[64 <!--* clear storage (not useful for the RAM machine but perhaps in other contexts): CLS := #]0 or #[0 or #|0--> <!--* input without destroying the storage (does not work in the reference interpreter): INP := &0|\--> * Bitwise right shift accumulator A: RSH n := ^^]n * Bitwise left shift accumulator A: LSH n := ^^[n * Swap the two accumulators: XCHG := ^]32^[32^]32 <!--* No operation: NOP := |0 or [0 or ]0 or--> <!--* Halt: HLT := .--> <hr> :Here are some extra instructions I find in Assembly language that might improve the usability of the instruction set(some are very trivial): :* Shifting operations (cyclic left shift, cyclic right shift) --[[User:A|A]] ([[User talk:A|talk]]) 08:04, 12 May 2019 (UTC) :I have a question about the IMM instruction. Couldn't you directly use <code>^x</code>(which works) instead of <code>^^x</code>? --[[User:A|A]] ([[User talk:A|talk]]) 10:19, 10 May 2019 (UTC) ::The point is that <code>^^n</code> sets the accumulator to n independently of the previous value of the accumulator. You could achieve the same effect with <code>&0^n</code>, but that would be one more character. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:06, 10 May 2019 (UTC) :::<del>I think I don't understand the <code>[n^]n]n&[n</code> operations in the decrement implementation. I believe it does carrying, but I can't understand how it achives it. {{unsigned|14:49, 10 May 2019 UTC|A}}</del> ::::<del>Have you tried working out a small example, say a 4 bit decrement starting from 12 = 1100b? [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:20, 10 May 2019 (UTC)</del> :::::<del>Oh right. Sorry. --[[User:A|A]] ([[User talk:A|talk]]) 01:14, 11 May 2019 (UTC)</del> = Sketch: A Stack Machine = We sketch another machine with an accumulator (with 64 bits) and a stack(preserved in the storage).<br> This machine simulation in [[bitch]] is created merely to extend the power of bitch programs.<br> Note: If mixing this stack machine with the RAM machine above is neccesary, the two accumulators must be preserved somewhere inside the storage before using the commands.--[[User:A|A]] ([[User talk:A|talk]]) 11:54, 13 May 2019 (UTC) === Memory === The memory is just an accumulator (stored in the bitch accumulator) and an unbounded stack (stored in the accumulator storage). === Operations === All of the commands do not use loops. * Duplicate the top of the stack <pre>DUP := ^^[32]32</pre> * Push a number onto the stack <pre>PUSH x := ^^x]32</pre> * Pop a number <pre>POP := [32^^0</pre> * Pop a number, outputting it <pre>POPOUT := [32/^^0</pre> * Swap the top 2 elements of the stack <pre>SWP := [64^]32^[32^]32]64</pre> * Push input <pre>PUSHI := &0|\]32</pre> * Increment top of stack <pre>INC := [32~]32&0[32 DEC ~]32&0</pre> * Decrement top of stack <pre>DEC := ^1 [32^]32]32&[32 [31^]31]31&[31 ... [2^]2]2&[2 [1^]1]1&[1 &0</pre> * Check whether two top-of-stacks are equivalent <pre>CHK := ^^[32^[64]32</pre> * Check if top of stack > the second top of stack * Check if top of stack < the second top of stack * Implementation of +, -, *, /, modulo, etc (impossible? *, /, and modulo possibly requires nested loops) * Reverse the stack (impossible?) = Page content deletions = I'd like to point out that with MediaWiki's awful default diff, there's hardly anything ''worse'' for following talk page changes than deleting content. Also deleting other people's talk page contributions, or even your own after others have responded to them, is generally considered inappropriate, except on your own personal talk page. We generally approximate Wikipedia policy here when we don't have a specific different tradition, so I'd sum up my understanding of what is done there: The recommended way to delete content from talk pages that are too big is to only ''move full sections'' to an archive subpage (like Talk:Bitch/Archive 1), and only when there has been no discussion in that section for a reasonably long time (which might depend on how fast discussion is happening). --[[User:Oerjan|Ørjan]] ([[User talk:Oerjan|talk]]) 00:38, 10 May 2019 (UTC) :Sorry, I read that [[User:Salpynx|Salpynx]] noted that this page is too hard to follow, so I removed some of the content. --[[User:A|A]] ([[User talk:A|talk]]) 11:33, 10 May 2019 (UTC) <!--= An interesting discovery = When [[bitch]]'s program counter reaches whitespace, it halts immediately, despite the fact that a command can be executed conditionally after <code>:</code>'s and <code>;</code>'s. Here is a modified [[Truth-machine]], with . replaced with whitespace: <code>\:/: &-2#1>/<</code> It will halt immediately if the input is 1, and it will print 0 if the input is 0. Same as: <pre>\:/: &-2#1>/<</pre> and <pre>\:/: &-2#1>/<</pre> Note that they works in both interpreters.--[[User:A|A]] ([[User talk:A|talk]]) 06:53, 12 May 2019 (UTC) :This is semi-intentional in my interpreter.<br> :By default it ends the program if the next instruction is not valid code (although due to oversights this won't happen on nested instructions).<br> :However this is not part of the language specification (and I'd like to keep it that way) and therefore not really portable. :: This is definitely not portable at this point. My implementation treats <code>: </code> as an invalid instruction and stops parsing the program right there. Anything following an invalid instruction is ignored. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 20:02, 12 May 2019 (UTC) :Still a good discovery though, nice! - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:59, 12 May 2019 (UTC)--> = Sketch: A [[Turing machine|Turing Machine]] = We can implement a Turing machine on a binary alphabet. The main challenge here is to implement bitwise boolean operations that keep (most of) the accumulator intact. It turns out that this isn't too hard if one pads the data with sufficiently many always-zero bits. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 20:53, 23 May 2019 (UTC) :Is the state represented using 1 bit? Also, what does k and q mean? (You don't have to explain the meaning of <code>k:l</code> and <code>r:q</code>; I know them.)--[[User:A|A]] ([[User talk:A|talk]]) 10:19, 24 May 2019 (UTC) ::The state is represented by as many bits as needed for the given Turing machine (the second ''s'' in ''ss'' indicates a plural; this convention comes from Haskell...). ''k'' is an adjacent letter to ''l'' and ''q'' is adjacent to ''r''; I went down (in the alphabet --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 25 May 2019 (UTC)) rather than up to avoid confusion with ''s''. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:00, 24 May 2019 (UTC) :I don't know how that can "avoid confusion". Hmm, l is directly adjacent to s, which might arise confusion: l could be considered part of the ''ss''. Also, you wrote <code>I went down rather than up to avoid confusion with ''s''.</code>; what does ''<code>I</code>'' mean? I did not find ''<code>I</code>'' anywhere in this sketch. ::The alphabet (adjacent letters represent adjacent bits). And "I": a name I call myself. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 08:37, 25 May 2019 (UTC) The contents of this section has moved [[Bitch#A Turing machine|here]]. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 07:43, 27 May 2019 (UTC)'
Unified diff of changes made by edit (edit_diff)
'@@ -1,2 +1,869 @@ -If an administrator is reading this: -I accidentally deleted everything and can't undo so help pls +{{lowercase}} +This is the talk page for [[bitch]].<br> +Use this to discuss syntax, programs, or even to prove stuff about the language! + +<hr> +<i>Note:</i> <b>For the sake of everyone's collective sanity, do not delete anything!</b><br> +Even if nothing comes out of one of these discussions they are still useful to show thought processes and progress within certain problems.<br> +If you don't like what you said or you changed your mind, strike it out (use <code>&lt;strike&gt;&lt;/strike&gt;</code> or <code><nowiki><del></del></nowiki></code>) and write underneath. + += Attempts at proving Turing-completeness = +Since bitch is a newly created language and is fairly different to a lot of the languages usually used to prove Turing-completeness, a proof is hard to come up with.<br> +Below are the attempts currently ongoing. Feel free to join one or add a brand new one! +==[In Progress] Compilation from [[Home Row]] to [[bitch]] by [[User:Helen]]== +<i>This section has been redone as of [https://esolangs.org/w/index.php?title=Talk:Bitch&oldid=62789 16:43, 27 May 2019 (UTC)]. The previous version held nothing of use for either proving or showing the process behind proving the computational class of [[bitch]].</i> + +This proof consists of two parts: a memory equivalence proof, and an operation equivalence proof. + +In the memory equivalence proof, we will prove that [[Home Row]]'s memory structure can be simulated in (and therefore is equivalent to) [[bitch]]'s.<br> +In the operation equivalence proof, we will prove that all [[Home Row]]'s operations can be simulated as a whole using [[bitch]]'s. + +Any looping inside proof code will prevent looping in a program, due to non-nestable loops in both languages.<br> +Since looping must remain possible as part of the equivalence, looping must not be present in proof code. + +=== [Invalid] Memory equivalence === +For an <code>n</code>x<code>m</code> [[Home Row]]-like grid to be equivalent to a tape, we have to show that we can either: +* Simulate a grid inside a tape - every time we reach a cell whose index is a multiple of <code>grid width</code> (1-indexed) and try to go forwards again, we must go back <code>grid width - 1</code> cells +<nowiki>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-</nowiki> every time we want to go down, we must go forwards <code>grid width</code> cells + +* Simulate a tape inside a grid - every time we want to go forwards in the tape, we must check whether the pointer is at the rightmost end of the grid, and if so, we wrap down to the leftmost end of the next row + +For the sake of simplicity, neither of these has to be able to go back/up a cell.<br> +This means the only way to backtrack is by wrapping back around at the right and bottom edges (for a grid) or at the end (for a tape). + +Since it is more simple to simulate a tape in [[Home Row]] than it is to simulate a grid in [[bitch]], this proof will show that it is possible to simulate a tape.<br> +This means we must be able to check whether we are at the rightmost edge. + +The simplest way to do this is by filling the rightmost column with zeros and not allowing any zeros inside cells (labelled <code>c<sub>n</sub></code>): + c<sub>1 </sub> c<sub>2 </sub> c<sub>3 </sub> c<sub>4 </sub> 0 + c<sub>5 </sub> c<sub>6 </sub> c<sub>7 </sub> c<sub>8 </sub> 0 + c<sub>9 </sub> c<sub>10</sub> c<sub>11</sub> c<sub>12</sub> 0 + c<sub>13</sub> c<sub>14</sub> c<sub>15</sub> c<sub>16</sub> 0 + c<sub>17</sub> c<sub>18</sub> c<sub>19</sub> c<sub>20</sub> 0 + +We must then create a code snippet to prove we can move forwards.<br> +For legibility and ease of understanding, two macro-like operations will be used: +*<code>l</code> - moves 1 grid space left, equivalent to <code>f f f f</code> +:<code>jl</code> is equivalent to <code>jf jf jf jf</code> and not to <code>jf f f f</code>. +*<code>u</code> - moves 1 grid space up, equivalent to <code>d d d d</code> +:<code>ju</code> is equivalent to <code>jd jd jd jd</code> and not to <code>jd d d d</code>. + +<u>Move forwards:</u> + f + +<u>Move down if the pointer is on a zero:</u> + d ju + +<u>Move right if the pointer is on a zero:</u> + jl f + +<b><u>Combined:</u></b> + f d jdjdjdjd jfjfjfjf f + +We can navigate the [[Home Row]] grid as if it were a tape, with the limitation that the tape is only 20-cells long.<br> +However, this still proves that a grid memory space is equivalent to a tape space, since it shows that any <code>n x m</code> grid is equivalent to <i>at least</i> an <code>(n-1)m</code> tape.<br> +Overall size is irrelevant, as [[Turing-completeness|Turing-complete]] actually requires and infinite tape size, and all languages are limited to a finite memory.<br> + +<hr> +I don't believe that the translation of <code>jl</code> works: <code>jf jf jf jf</code> will get stuck when it hits a zero value. I believe the translation is also at odds with the requirement that the <code>c<sub>i</sub></code> values are non-zero... --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) +:Both of those are intentional: +:*<code>jl</code> is meant to get stuck on zero values +:*<code>c<sub>i</sub></code> values are meant to be limited to non-zero values + +:However this is pretty clumsy and part of the reason I marked this as invalid.<br> +:The new proof will hopefully be better, although a proof is pretty trivial and not <i>really</i> necessary but good for completion. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:27, 29 May 2019 (UTC) + +OTOH, since you're basing the memory on the cell-based storage, you can directly implement arbitrary permutations of <code>c<sub>1</sub> ... c<sub>nm</sub></code>, so the <code>d</code> and <code>f</code> operations can be implemented directly. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) +:That's true the operations can most likely be directly implemented on a tape. + +:I realised shortly after posting this proof that the memory structure I'm using for [[bitch]] is actually simply a cell-based RAM.<br> +:For that reason, I invalidated the memory proof and I'm working on a new one. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:27, 29 May 2019 (UTC) +<hr> + +=== Operation equivalence === +In this proof, it is assumed that the random access cell-based alternative memory structure is being used. + +There are some trivial equivalences (such as <code>l</code> or <code>j</code>), which we will deal with first.<br> +However, there are also some more complex equivalences which will be dealt with individually and with explanations. + +For the sake of simplicity, we will be using three macro-like operations: +* <code>L<i>n</i></code> - loads the <code><i>n</i></code><sup>th</sup> cell, equivalent to [[Talk:bitch#Loading_the_value_of_a_cell|the code for loading the value of a cell]]. +* <code>S<i>n</i></code> - sets the <code><i>n</i></code><sup>th</sup> cell, equivalent to [[Talk:bitch#Setting_the_value_of_a_cell|the code for setting the value of a cell]]. + +==== Trivial equivalences ==== +{| class="wikitable" +|- +! [[Home Row]] !! [[bitch]] +|- +| <code>j</code> || <code>;</code> +|- +| <code>k</code> at cell <code>n</code> || <code>Ln/&0Sn</code> +|- +| <code>l</code> || <code>&gt;</code> or <code>&lt;</code> +|- +| <code>;</code> || <code>.</code> +|} + +Both <code>f</code> and <code>d</code> are not necessary to find an equivalence to, since we already showed that a cell-RAM in [[bitch]] is equivalent to a grid in [[Home Row]]. + +==== Addition and Subtraction ==== +Addition (and subtraction) for a fixed-size cell is possible with definite looping and therefore can be unrolled to have no looping at all. + +We remain with the same simple addition algorithm, instead we now write it for a fixed number of loops.<br> +We must pick a number of loops such that we guarantee that <code>p = oldP</code> at the end (or equivalently that <code>q = 0</code>).<br> +The bit width of the cells is enough to guarantee this. + +<pre>p <- some cell +q <- some cell + +p <- p XOR q \ +q <- (p AND q) LS 1 \ +... > bitwidth times +p <- p XOR q / +q <- (p AND q) LS 1 /</pre> + +We can use a pseudo-extension of the cell-RAM to temporarily store <code>p</code> and <code>q</code>.<br> +We then perform the <code>n</code> iterations and leave the result in the topmost accumulator. + +<u>Getting both variables:</u><br> +This is the same as the code snippets from [[Talk:bitch#Bitwise_operations_on_two_cells|the code for performing bitwise operations]]. +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0</pre> + +<u>Storing the next </u><code>p</code><u>value:</u> +<pre>|[(2*n)^]n]n&0</pre> + +<u>Storing the next </u><code>u</code><u>value:</u> +<pre>|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0</pre> + +We then repeat those two code snippets another <code>n-1</code> times.<br> +In the combined code, we'll paste this only once. + +<u>Moving the result into the accumulator:</u> +<pre>[(2*n)|]n&(1<<n-1)</pre> + +<b><u>Combined:</u></b> +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0 |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)</pre> + +Subtraction can be expressed as two additions - <code>p + ~q + 1</code>. + +<u>Loading and negating </u><code>q</code><u>:</u> +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)~]n~</pre> + +<u>Adding 1 to </u><code>~q</code><u>:</u> +<pre>|1]n |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)]n</pre> + +<u>Loading </u><code>p</code><u>:</u> +<pre>|[((a+1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)]n</pre> + +<u>Summing </u><code>p</code><u> and </u><code>~q + 1</code><u>:</u> +<pre>|[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n</pre> + +<u>Moving the result into the accumulator:</u> +<pre>[(2*n)|]n&(1<<n-1)</pre> + +<b><u>Combined:</u></b> +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)~]n~|1]n |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)]n|[((a+1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)]n|[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)</pre> + +=== Conclusion === +Since [[bitch]] can successfully emulate [[Home Row]]'s operations and, their memory structures are equivalent, [[bitch]] must be able to solve at least as many problems as [[Home Row]]. + +This means [[bitch]] is [[Turing-complete]]. + +<hr> +I am pretty sure that [[brainfuck]] cannot compile to [[bitch]], since brainfuck requires nested loops to be [[Turing-complete]]. [[bitch]] can only nest an infinite loop once. I suggest that [[Home Row]] might result a more efficient compilation proof. --[[User:A|A]] ([[User talk:A|talk]]) 11:08, 15 April 2019 (UTC) + +Of course, I completely forgot about the loops. I had a look at [[Home Row]] and it seems to be all good but I didn't quite understand the loop definition. Is it similar to [[bitch]]'s? - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 13:14, 15 April 2019 (UTC)<br> +Oh I understand the loop now. It might be a problem since [[bitch]]'s loops runs for the first time no matter what whereas [[Home Row]]'s runs only if the current memory value is 0. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 13:24, 15 April 2019 (UTC) + +Anyway, the way of executing loops does not affect its [[Computational class]]. --[[User:A|A]] ([[User talk:A|talk]]) 13:50, 15 April 2019 (UTC)<br> +You are understanding the loops the wrong way. It says that the loop will run if the current memory spot is <b>nonzero</b>. --[[User:A|A]] ([[User talk:A|talk]]) 14:55, 15 April 2019 (UTC) + +Oh of course, my bad. But either way there is no reasonable way to replicate that in [[bitch]] in a general way. I'm glad it doesn't affect the [[Computational class|computational class]]; phew - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:57, 15 April 2019 (UTC)<br> + +<!--Astonishingly, [[User:int-e|int-e]] has implemented bounded-storage [[brainfuck]], disregarding to this ongoing work. --[[User:A|A]] ([[User talk:A|talk]]) 10:39, 18 May 2019 (UTC)--> +<hr> +=== The compilation probably failed === +Home Row requires unbounded memory to be [[Turing-complete]]. However, only a limited 32-bit version of incrementing and decrementing was implemented. So, the attempt had certainly failed. [[User:A|I]] could not find any other [[:Category:Computational models|computational models]] useful for proving whether [[bitch]] is [[Turing-complete]]. --[[User:A|A]] ([[User talk:A|talk]]) 14:05, 13 May 2019 (UTC) + +[[bitch]]'s cell-based alternative storage is computationally equivalent to [[Home Row]]'s. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 17:18, 13 May 2019 (UTC) + +:Sorry, but I believe you've missed an important point about [[Home Row]]: its 5<sup>2</sup> cells are unbounded. That is how it manages to be [[Turing-complete]]. So A has a point (with 32 replaced by the now arbitrary, but fixed, bit width) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) + +::I didn't say anything before out of pure laziness but below is the logic as to why [[Home Row]]'s and [[bitch]]'s cells are equivalent for the sake of current computation. + +::[[bitch]] can simulate arbitrary sized cells. This is computationally the same as [[Home Row]] as no cell can be truly unbounded.<br> +::Even if the cells are allowed to expand as much as necessary, eventually a RAM limit will be hit and the cell will be capped at an arbitrary size limit.<br> +::[[bitch]] will be able to simulate a cell at that size limit as it too is only limited by the same factors. + +::The rest of the new (and valid) memory equivalence proof will be up eventually but that is essentially part of it.<br> +::[[bitch]] is TC essentially on a technicality but that is enough (at least until we get truly infinite memory). - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:20, 29 May 2019 (UTC) + +:::The fact remains that you're not showing Turing-completeness. One can argue, and I would agree, that Turing-completeness is a purely theoretical concept, and that in practice we're usually programming sufficiently large finite automata anyway. (Sometimes we're dealing with analogue signals, but those are noisy.) Note that just like Turing machines, bitch cannot be implemented on real hardware, because it has unbounded memory (both in the accumulator and in the storage). To show that bitch is TC, one needs to implement a Turing-complete formalism (a Turing machine, or something equivalent to a Turing machine) in bitch. +:::On the level of finite state machines, programming becomes a matter of compression: how big does a program have to be to operate on a certain number of states? A direct description of FSMs in terms of states and transitions is impractical for real computations--a program of size n can access O(n) states at best. With bitch, compression is possible: Cell-based storage (which you're using here) allows a program of size n to work on 2<sup>O(n)</sup> states. The RAM construction boosts this to 2<sup>2<sup>O(n)</sup></sup>. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:39, 30 May 2019 (UTC) + + +::::Yeah after thinking about it for a while, I realised I only really showed that it's equivalent to a [[Bounded-storage machine|bounded-storage machine]] with an arbitrarily large bound, which makes it "effectively TC" for all reasonable computation, but still doesn't prove that the language itself is [[Turing-complete]]. +::::Of course by "only really showed" I mean "will only really show" because I'm still working on finishing the new memory equivalence proof but once that's done I'll update this. + +::::I think I have an idea for addressing infinite memory in [[bitch]], which would prove its [[Turing-completeness]], but I'll have to do that after this proof. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:41, 30 May 2019 (UTC) + +=== Terminology === +You're attempting to show that every [[Home Row]] program can be translated to an equivalent [[bitch]] program, but for an equivalence proof between the two languages, you would need both directions, i.e., you'd also have to translate [[bitch]] programs to [[Home Row]]. What you have (if correct) is a reduction from a bounded cell variant of Home Row to bitch. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC) +: My bad, I'll fix the title. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:17, 29 May 2019 (UTC) + +== Some thoughts == + +The provided implementation has a 63-bit accumulator and bit-storage, which is pretty small, and Java has builtin bigints so you might want to use that. +Also, [https://cs.stackexchange.com/questions/2832/is-a-push-down-automaton-with-two-stacks-equivalent-to-a-turing-machine/2833#2833 according to this StackExchange answer], a 2-stack [[Push-down automaton]], which might be emulated using the accumulator and bit-storage, is equivalent to a turing machine. So this could be a possible way of proving TCness. Although the lack of nested loops might be a problem. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 08:50, 17 April 2019 (UTC) +: There also seems to be some inconsistency with rapport to <code>&gt;...&lt;</code>: the spec says for <code>&lt;</code> that it "jumps to the nearest <code>&gt;</code>" but the implementation saves the position of a <code>&gt;</code> only when executed. So for example in <code>&gt;#0;&gt;&lt;</code>, should the <code>&lt;</code> jump to the first or second <code>&gt;</code>? +:: <del>I will ask [[User:Helen|Helen]]; I have no idea.</del> --[[User:A|A]] ([[User talk:A|talk]]) 11:26, 17 April 2019 (UTC) +:: Wait, where did you find that code snippet? +::: I wrote it to show the problem. It's hypothetical, but having a well-defined spec is always a good thing. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:41, 17 April 2019 (UTC) +:::: I [https://tio.run/##S8osSc74/99O2UDf2k7ZUN/m/38A ran a similar program] and found that it jumps to the first ">". You are right; the documentation indeed has to be modified.--[[User:A|A]] ([[User talk:A|talk]]) 12:04, 17 April 2019 (UTC) +<del>:I think that implementing a 2-stack [[Push-down automaton]] would be trivial, as 2 stacks already have the power of simulating a tape. It might be better if you directly simulate a tape. --[[User:A|A]] ([[User talk:A|talk]]) 14:52, 29 April 2019 (UTC)</del> +Spec problem fixed and the rest talked about in [[User talk:Helen|my user talk]]. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 15:16, 17 April 2019 (UTC) +=== Another idea === +It seems that we are having trouble implementing my incrementing/decrementing algorithm. That is why I made a improvement of the incrementing/decrementing algorithm.<br> +This is what I typed in a Lua prompt. This improvement is inspired by this: +<pre> +Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio +> ~-1 +0 +> -~1 +2 +> +</pre> +~-x is equal to x decremented, and -~x is equal to x incremented.<br> +-x is the negation of x. ~x is a bitwise NOT.<br> +In case you question me about my algorithm, I will add more examples here: +<pre> +> ~-9 +8 +> -~9 +10 +> ~-12 +11 +> -~12 +13 +> +</pre> +These expressions are universal, which means that you can also run it in Java, Python, etc.<br> +It requires a front-register, which saves a pseudo-top element of a number that changes dynamically when a new bit is used. Negating inverts the pseudo-top element, and bitwise NOT-ting inverts all the bits from the pseudo-top to the bottom. If there are 8 bits for each cell, 3 bits are sufficient for representing the front-register. However, this results in recursive incrementing the front-register every time a bit is used, which might be quite hard to do.<br> +Inverting the bits after the pseudo-top might be sufficient.<br> +It is highly probable that I am misunderstanding these expressions.--[[User:A|A]] ([[User talk:A|talk]]) 10:01, 29 April 2019 (UTC) + +== Bitch might be Turing-incomplete == + +If we treated the accumulator as a counter, with <code>[1</code> for increment and <code>]1</code> for decrement, we could treat it as a 1-register [[Minsky machine]]. However, ''two'' counters are required for an increment-decrement machine to be Turing complete, as one-counter Turing equivalence requires multiplication and division, which are impossible without a temporary.<br> +Then, if we treat the accumulator+shift register as an unbounded bit tape, it still cannot be Turing complete, as we don't have the ability to non-destructively check only one bit of said tape, only checking if all the bits in the accumulator section are zero or at least one bit is non zero.<br> +Maybe other models are possible, but it does seem like it's not Turing-complete. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 15:33, 17 April 2019 (UTC) + +: You can't independently check the value of a specific accumulator. Neither can you increment or decrement them, without making a loop, which would prevent backward state changes due to the non-existence of nested loops or gotos. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:21, 18 April 2019 (UTC) + +: In addition, I'd like to see an algorithm that can copy a bit in the accumulator to a different position, but *without* using loops, as using a loop in such an atomic operation would instantly break Turing-completeness due to the necessity of a global program loop to apply state changes. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:28, 18 April 2019 (UTC) + +:: To clarify: what I mean is that bitch doesn't have any way of control flow other than the non-nestable <code>&gt;&lt;</code> construct and conditional forward jumps. However, for Turing completeness, conditional backward jumps are also required. This can be emulated by putting most of the logic in an unconditional loop, but then it is impossible to build inner loops. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:44, 18 April 2019 (UTC) + +Nevermind, I didn't realize you could put a valid bitch instruction after a OR, which allows copying data from the storage. The article is quite unclear on this point. +It might just be Turing complete, actually. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 21:11, 21 April 2019 (UTC) + +Completely my fault, the ability to nest instructions like that is one of the most important parts of the language but it gets about two sentences on the main article.<br> +I'm gonna rewrite most of the main article soon; I've been gathering feedback about things that generally aren't very clear. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:40, 21 April 2019 (UTC) + +<!--I have tried several Turing-complete computational models. (These include the [[Minsky machine]](proven to be trivial above), the [[I/D machine]](seems to be nice), Tag systems(bitch currently does not support queues; Sequential tag systems are worth a try. If anyone implemented queues, I will be amazed...), the Turing-machine(Worth a try), etc.)--[[User:A|A]] ([[User talk:A|talk]]) 14:21, 13 May 2019 (UTC)--> + +==[Unsuccessful] Compilation to Z3 derivative by [[User:Helen]]== +This attempt contains programs that might be useful to prove the [[Turing-completeness]] of [[bitch]]. +===[[User:A]] - Basic compilation=== +This programming language looks like Konrad Zuse's Z3, which was already proven to be Turing-complete by Raúl Rojas [http://page.mi.fu-berlin.de/rojas/1997/Universal_Computer.pdf here]. + +First of all, Z3 is capable of executing an infinite loop. This is achieved in bitch as the <code>&gt; &lt;</code> block.<br> +Also, Z3 has math operation evaluation capabilities. + +Z3 can implement 5 operations: addition, subtraction, multiplication, division, and square-rooting.<br> +Even though these arithmetic operations have not been shown to be implementable in bitch, only the operations of zeroing a value and incrementing a value will be necessary for Turing-completeness, as mentioned [https://www.cl.cam.ac.uk/~sd601/papers/mov.pdf here]. + +Raúl Rojas shows that an instruction set with load, store, increment, zero and unconditional branching is Turing-complete.<br> +However, Load and Store have to be indirect. They should be nested for at least 2 indices. + +Also, infinite memory (a requirement for Turing-completeness) can be implemented in the Z3.<br> + +Finally, Z3 has a way to stop the program by using an invalid operation. That is <code>.</code> in bitch. + +===[[User:Helen]] - Implementing arithmatic operations=== +This part was proven partially unneccesary, as [[User:A|A]] had found a command set that is easier to compile to [[bitch]]. On the other hand, these programs might make [[bitch]] easier to program in.<br> +The conditional snippet below is easy to replicate in bitch: +<pre>if (z = i) then 0 else 1</pre> +We simply use XOR to check if a number <code>z<code> is equal to some constant <code>i</code> like this: +<pre>#z^i;#1</pre> +If they are equal, the result of XORing them is automatically 0.<br> +If they are not, the result is some non-zero number which we can detect (through the conditional <code>;</code>) and then set the accumulator to 1. + +Mathematical operations are a bit harder to pull off.<br> +I have managed to get an algorithm for addition.<br> +<s>Subtraction can be imitated through addition with negatives (due to algorithm overflowing and actually giving the correct number).</s> It can't.<br> +I haven't managed to get an algorithm for multiplication or division yet. + +<hr> +<b>Addition:</b><br> +Binary addition is very simple. + +Ignoring carry overs, each digit behaves like this: +{| class="wikitable" +|- +! a !! b !! a+b +|- +| 0 || 0 || 0 +|- +| 0 || 1 || 1 +|- +| 1 || 0 || 1 +|- +| 1 || 1 || 0 +|} +This is equivalent to XOR. + +In order to get full addition behaviour though (rather than just "fairly close but not really" addition behaviour), we have to consider carry overs.<br> +This is how carry overs behave: +{| class="wikitable" +|- +! a !! b !! a+b's carry +|- +| 0 || 0 || 0 +|- +| 0 || 1 || 0 +|- +| 1 || 0 || 0 +|- +| 1 || 1 || 1 +|} +This is equivalent to AND.<br> +The carry overs are put onto the digit one order higher though.<br> +Therefore, we left shift each carry once. + +This gives us our full (recursive) algorithm.<br> +In pseudocode: +<pre>a <- input +b <- input + +oldA <- a+1 +while (a != oldA) { + withoutCarries <- a XOR b + carries <- (a AND b) LS 1 + + oldA <- a + a <- withoutCarries + b <- carries +}</pre> +This is perfectly doable in v4.7* bitch (takes 2 inputs): +<pre>\[16|\]32>|[32&4294967295#|0^[16|-281474976710656&]32]15&131070|[31&281470681743360|]16&4294901760|[16#|0&4294967295|[32&281474976710655]32;<|[16/</pre> + +===[[User:Helen]] - Proving required operations=== +In order to be Turing-complete, a language <i>requires</i> a very minimal instruction set (as shown by Raúl Rojas) and infinite tape (by definition).<br> +The required instruction set consists of: load, store, increment, zero and unconditional branching.<br> +If a language can do these and can simulate an infinite tape (or an arbitrarily sized tape), it is Turing-complete. + +In order to show these are true, we must envision the bitch accumulator as a tape.<br> +Cells are delimited portions of the tape that are <code>n</code>-bits wide (<code>n</code> being an arbitrary choice of integer width).<br> +Addressing is signed, negative numbers meaning backwards in the tape and positive numbers meaning forwards in the tape. + +Loading and storing values can't really be emulated in bitch but a parallel of setting and accessing cells can be made. + +====Setting cells==== +Setting a cell to a constant value <code>c</code> can be done: +<pre>#c</pre> +However, this zeroes the rest of the accumulator which impends simulation of a tape.<br> +Therefore, we opt for: +<pre>|c</pre> +Given that the cell at position 0 is equal to 0, this will set load the value <code>c</code>.<br> +However this is dependant on the cell being 0, which is not desirable.<br> +There are two options: zeroing the cell at position 0, or moving right/left (arbitrarily) until we find an empty cell.<br> +I choose to zero the cell in order to be able to maintain a knowledge of where things are positioned in memory.<br> +Furthermore, this doesn't impend one from storing the value at position 0 elsewhere and therefore it is the best option. +<hr> +With <code>c</code> being the desired constant value and <code>n</code> being the bit-width of the cells in the tape: +<pre>|((1<<n)-1)^((1<<n)-1)|c</pre> +<i>For the sake of simplicity, brackets represent an expression which must be calculated and put in the source code.</i><br> +If <code>n</code> is 8, the code would become: +<pre>|255^255|c</pre> + +====Accessing cells==== +A value at positive position <code>p</code> can be accessed through the following code: +<pre>](p*n)</pre> + +A value at negative position <code>q</code> can be accessed through the following code: +<pre>[(q*n)</pre> + +====Incrementing==== +Incrementing is simply the addition of 1.<br> +It is also currently not implemented or working. + +Incrementing can be done by checking each bit, starting from the rightmost bit going left, until we reach a 0 bit.<br> +That 0 bit becomes 1 and all the bits lower than it become 0. + +In order to check individual bits we must OR individual bits with 1 and check for equality with the previous version.<br> +In pseudocode: +<pre>number <- input +previous <- number + +n <- 0 + +while(number | (1<<n) = previous) { + n <- n+1 +} + +number <- number | (1<<n) +number <- number ^ ((1<<n)-1)</pre> + +The algorithm is currently a work in progress. +<!--<big>THIS IS WRONG</big> +<strike>In order for incrementing to be done, a significant amount of setup is required.<br> +The starting setup should be of all the used memory in topmost storage and a zeroed accumulator.<br> +Given the position <code>p</code> of the number to be incremented in the storage and <code>a</code> as the size of the storage in cells and <code>n</code> as the bit-width of each cell,<br> +The following isolates the number from the storage: +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p)*n)&((1<<n)-1)</pre> +We then set up the three copies of the number as part of the main search loop. +<pre>|[(4n)&(1<<(4n)-1<<(3n))|]n|](2n)</pre> +We then 0 the rightmost bit of the topmost number and compare it to the original. If they are not equal, then the bit was a 1 and the search continues. +<pre>|(1<<(3n))^(1<<(3n))^]n]2n;<</pre> +We then return to the beginning of the loop, where we must set up the next iteration of the search. +<pre>&1[(n-1)</pre> +We then create 3 copies again and the loop restarts.<br> +As part of this we must correctly prepare the initial number for the mainloop.<br> +<pre>](n-1)</pre> +At the end of the loop, we must correctly format the resulting number and set the memory back to its original condition.<br> +<pre>|1|[((a+1)*n)#|0[((a+1)*n)>]1;<[((a+2)*n)&(1<<((a+1)*n)-1)|[((2a-p)*n)&(1<<((2a-p+1)*n)-1<<n)]n|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)&(1<<(a*n))](a*n)</pre> +This achieves the above. + +Collected below is the code necessary to increment, given a cell at position 0 matching the required conditions: +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p)*n)&((1<<n)-1)](n-1)>&1[(n-1)|[(4n)&(1<<(4n)-1<<(3n))|]n|](2n)|(1<<(3n))^(1<<(3n))^]n]2n;<|1|[((a+1)*n)#|0[((a+1)*n)>]1;<[((a+2)*n)&(1<<((a+1)*n)-1)|[((2a-p)*n)&(1<<((2a-p+1)*n)-1<<n)]n|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)&(1<<(a*n))](a*n)</pre> +Where <code>p</code> is the 0-indexed position of the cell with the number to increment, starting counting from the leftmost cell; <code>n</code> is the bit-width of the cells; and <code>a</code> is the size of the currently allocated memory in cells.</strike> +<big>THIS IS WRONG</big>--> + +====Zeroing a cell==== +This was done in the section on setting bits but will be restated here with some explanation.<br> +Zeroing can be done by ANDing with a number that has the desired bits - the bits you want to zero - zeroed and all other bits as ones.<br> +However, due to the arbitrary size of bitch's accumulator, we cannot rely on this (well we can but I choose not too since calculating differences of powers of two is more tedious than changing one digit).<br> +Therefore, OR-XORing seems to be most suitable.<br> +We can OR to set the desired bits to 1, then XOR to "flip" them, effectively zeroing them. +If we want to zero the cell at positive position <code>p</code> with cell size <code>n</code>, we use the following: +<pre>]p|((1<<n)-1)^((1<<n)-1)</pre> +If we want to zero the cell at negative position <code>q</code> with cell size <code>n</code>, we use the following: +<pre>[q|((1<<n)-1)^((1<<n)-1)</pre> +Both of these will end with the tape positioned over the cell you just zeroed. + +====Unconditional Branching==== +bitch lacks in unconditional branching.<br> +It is possible to infinitely repeat code but that is all you can do unconditionally. +<pre>>code<</pre> + += Alternative memory structures = +The accumulator-storage combination may be quite limiting in certain circumstances.<br> +In this case, some alternative memory structures are implemented below in bitch for ease. +== Random access cell-based memory == +A cell-based memory can be emulated in bitch.<br> +All that is required is an arbitrary choice of bit-width for the cells, and a size (in cells) of the currently allocated memory.<br> +We will call the bit-width of cells <code>n</code> and the size of the memory <code>a</code>. + +In terms of structuring in bitch's accumulator-storage conjunction, the memory will be in topmost storage (closest to the accumulator) and the accumulator will remain empty to be used for calculations. +<hr> +=== Loading the value of a cell === +Given a cell indexed <code>p</code> (in a 0-based index where the leftmost cell is 0 and the rightmost is <code>a-1</code>), we can set the accumulator to its value by the following steps. + +<u>Copying up the entire memory to the accumulator:</u> +<pre>|[(a*n)</pre> + +<u>ANDing the cell that we want:</u> +<pre>&(1<<((a-p)*n)-1<<((a-p-1)*n))</pre> + +<u>Then shift copying it down to the bottom of the accumulator:</u> +<pre>|]((a-p-1)*n)&((1<<n)-1)</pre> + +<b><u>Combined:</u></b> +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)</pre> +<hr> + +=== Setting the value of a cell === +Given a cell indexed "p" (in a 0-based index where the leftmost cell is 0 and the rightmost is <code>a-1</code>), we can transfer the value from the accumulator to the cell by the following steps. + +<u>Moving the accumulator value to the correct position to line up with p:</u> +<pre>|[((a-p-1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))</pre> + +<u>Clearing the old value:</u> +<pre>[(a*n)|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))</pre> + +<u>Copying down the new one:</u> +<pre>|](a*n)</pre> + +<u>Clearing the accumulator:</u> +<pre>](a*n)&0</pre> + +<b><u>Combined:</u></b> +<pre>|[((a-p-1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))[(a*n)|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)](a*n)&0</pre> + +<hr> +=== Bitwise operations on two cells === +Performing bitwise operations with two cell arguments is trivial now that we have the load and set.<br> +We can use the <code>^^</code> combination to perform arbitrary argument operations without messing with the storage.<br> +Given an operation <code>x</code>, we can load two cells 0-indexed <code>p</code> and <code>q</code> and then perform <code>q x p</code>. + +<u>Loading cell </u><code>p</code><u>:</u> +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)</pre> + +<u>Loading cell </u><code>q</code><u>:</u> +<pre>[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0[(2*n)</pre> + +<u>Performing binary operation </u><code>x</code><u>:</u> +<pre>^^x]n]n&0[n</pre> + +<b><u>Combined:</u></b> +<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0[(2*n)^^x]n]n&0[n</pre> + +=[Disproven] Conjecture: [[bitch]] cannot copy one bit from memory to another part of memory while retaining existing data= +:'''edit:''' The specific memory copy claim/challenge of this conjecture has been successfully disproven, multiple times over. The more general 'Not TC' part still seems valid, but I'm changing the section heading so it's clear what the 'Disproven' relates to. Section still has value because it prompted useful progress in determining computational class [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:42, 20 May 2019 (UTC) + +I was following [[Talk:Bitch#Bitch_might_be_Turing-incomplete|TuxCrafting's (now struckthrough) arguments against TC above]], and I don't think the ability to chain instructions helps that much (because they can't be grouped), and the challenge "to see an algorithm that can copy a bit in the accumulator to a different position" is still open. + +There are multiple ways to formulate this as a challenge, but this is the simplest I could come up with: + +Create a bitch program that can take an already initialised 3 bit accumulator <code>abc</code> and convert it programatically to <code>abb</code>: + + abc => abb + +examples: + 011 => 011 (3 => 3) + 101 => 100 (5 => 4) + 110 => 111 (6 => 7) + +(As I read it) There is no way to group or order the evaluation of chained operations, and no temporary scratch space to use different parts of the accumulator for a single operation. The accumulator cannot be practically masked in such a way that one sub-part of it can interact with another and re-stored, without losing sub-parts not involved in the operation. + +Here is the full mapping of expected results: + 0 -> 0 + 1 -> 0 + 2 -> 3 + 3 -> 3 + 4 -> 4 + 5 -> 4 + 6 -> 7 + 7 -> 7 + +A simple algorithm to do this for three bits is: + (abc & 0b110) | ((abc & 0b010) >> 1) + +This requires grouping and two separate logic operations on the accumulator (abc) as sub steps. Since bitch modifies the accumulator in place, no amount of instruction chaining will help. The logic operations are only useful when combining the accumulator with number literals or user input. + +Conjecture: +* A machine with two independent stacks should be able to copy a value from one stack to the other. A machine that cannot copy a single bit in isolation from anywhere in memory to anywhere else, regardless of the actual datastructures involved, has no hope of simulating two stacks. +* There is no way to create a generalised algorithm to perform simple bit copy in bitch, therefore the language cannot simulate two independent storage stacks or accumulators. +* It may be possible to produce the results above in bitch by creating effectively a lookup table mapping the input to desired output, but that proves lack of Turing completeness if the only way to produce arbitrary results is to create lookup tables mapping input to output. +* The ability to copy data from one memory location to another with destroying all other data is required equally for any TC system involving multiple stacks, multiple counter registers, and equally to cyclic tag systems and cellular automata. + +If I have somehow missed something in the spec, proving this false does not necessarily mean the language is TC. If there is a clever way to do the copy, I imagine it will require effectively placing an upper bound on the accumulator, and multiple unbounded stacks or accumulators cannot be simulated from a bounded one. + +I believe this makes bitch a PDA, since one end of the accumulator can be used as a ''single'' stack, and transitions decision can be made based on that. + +This talk page is getting hard to follow with many sections having questionable statements without attribution. Hopefully this bit copy challenge will be easier to address than a full TC proof. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:48, 7 May 2019 (UTC) +: I didn't notice the implemented memory structure was supposed to be bitch because it has parentheses <code>()</code> to group operators (which AFAICT bitch lacks, and is the major hurdle to completing this challenge in pure bitch) and standard bit-shift operators <code><<</code> mixed in with bitch syntax. I am guessing that the intent was to precalculate all those values and substitute them into the bitch source as number literals? This is what I have noticed about all the examples given, and what this challenge is trying to prove: that binary operations cannot be done on two independent ''memory'' locations. It is easy to perform an operation with memory + number literal, but if you have to compute it all before hand and hardcode it into bitch, it's not bitch doing the computation, at least not in a way that is TC. I tried substituting values into that code and couldn't get it to work, can you? The form for this challenge will be something like <code>\[]/</code> where <code>[]</code> is replaced with a bitch algorithm of any size which copies the bit. If it is easy to do, then I have clearly misunderstood something about how the storage behaves and an example would clear up the confusion. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 12:08, 8 May 2019 (UTC) +::In theory you can do any terminating amount of pre-computation "by hand" (which really means as part of compiling into your language). (From [[User_talk:Oerjan#Turing_completeness|Oerjan's user talk]]). --[[User:A|A]] ([[User talk:A|talk]]) 04:02, 9 May 2019 (UTC) +: Copying a bit of a 3 bit accumulator can be achieved using the follwing piece of code: <code>&6]3|[2&1[3|]3&7</code> (which also keeps the storage unmodified). One key point here is that chained instructions work on a fresh copy of the state (both accumulator and storage), so <code>|[2</code> and similar instructions leave the storage unmodified. +:: For the record: <code>^^]1]1^^[1[1</code> achieves the same copying task (copy second bit to first bit) for any number of bits, using the ^^ trick. Note that this approach specific to copying adjacent bits; copying to a non-adjacent location is harder. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:28, 10 May 2019 (UTC) +: More generally, any map with finite domain (old accumulator value to new accumulator value) can be implemented, as for example the ROT13 program on the main page. I don't see how to copy a bit in an unbounded accumulator though, so none of this really brings us any closer to TC-ness. This should be enough to show that bitch can simulate arbitrary PDAs though. For processing input, note that one ''should'' be able to read from input without destroying the storage using <code>&0|\</code>, but the Java interpreter doesn't really support this because each instance of Program creates its own new Scanner that reads a whole line of input... [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 05:43, 9 May 2019 (UTC) +:: The algorithm is right there! For larger sizes, the shifts have to be adapted as well: <code>&14]4|[3&1[4|]4&15</code>. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:07, 9 May 2019 (UTC) + +:: Congratulations! This is a valid solution to the challenge as I stated it. I was surprised it works, but I can now see how, which is a welcome outcome. I think knowing the conditions under which this is possible is helpful too. Like I guessed it places bounds on the storage, and proves the language is at least computationally equivalent to a PDA. Perhaps there is a way to break though this limitation, but it makes the next steps clearer, and provides a clear example of a useful programming technique. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 00:03, 10 May 2019 (UTC) + +<b>This conjecture is disproven by the old alternative memory structures section as I understand it.</b><br> +The variables there are simply the number of cells, the size of the cells and the cell to access.<br> +The number of cells and size of cells is simply for customizability and would be fixed by the programmer to a value of their choosing for the entire program (e.g.: 20 and 8).<br> +The position variable is simply the position at which the cell is that you want to access.<br> +The expressions given are simply the values needed to move and zero parts of the accumulator as necessary, they work with any values. + +Binary operations on two different locations are very possible and they are the only reason for chaining operators.<br> +The code snippet <code>&[8</code> will AND two different values given that they are both 8 bits wide and in the accumulator together, one on top of the other. + +The tape memory structure doesn't rely on precomputing, it allows for different sized tapes and different sized cells for customizability.<br> +The values for the tape code are no less arbitrary than the value 8 in the above code. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:23, 9 May 2019 (UTC) +: I seem to have reinvented parts of the "alternative memory structures" section below for GET and PUT, though as far as I can see the main contribution, random access, is new. I don't know why [[User:A|A]] deleted that section... [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 21:10, 9 May 2019 (UTC) +: I tried to use your cell based memory structure early on but couldn't get it to work, here is a worked example of what I get: +: With 3 bit memory, each cell is 1 bit, and the task is to copy cell 1 to the accumulator (which is slightly different from my challenge, but probably equivalent given some more steps), my abc is 012 in this structure. +:* a = 3 (memory size) +:* p = 1 (target cell, 0-indexed) +:*n = 1 (cell width) + +:Loading a value from a cell formula, substituting using the values above: <code>|[3&4|]1</code> + +:I understand that this requires the memory to already be in the storage section, so if I pre-load the storage to 0b010 using <code>#2]3</code>, I would expect to get 1 in the accumulator by running <code>#2]3|[3&4|]1</code>, but that results in 0 in the accumulator and 2 in storage. Trying it with storage initialised to 0b111 (7) results in 0b110 (6) in the accumulator and 0b111 (7) in storage. Perhaps the formulas don't work with a cell width of one, but I don't know under which conditions it does work. I don't think that section should be deleted, it's possible am missing something about how to use the structure properly, or that there is a tiny bug in one part of it that could be identified and fixed as a result of using it for a specific task. This challenge was an attempt to get clarity on how to use the theorised techniques to do a specific task that did not seem obviously trivial to me. I would love to see an working example of your cell-based memory structure applied to the task above, I did try but couldn't make it work. The addition example (I think that is yours too?) was great as I could easily verify it did exactly what it claimed, and then spend time trying to understand how. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 00:20, 10 May 2019 (UTC) + +:: Yeah sorry for the lack of any examples. + +:: Given your above values: +::*a = 3 (memory size) +::*n = 1 (cell width) +::*p = 1 (target cell, 0-indexed) + +:: The following code snippet stores and retrieves 1 from the 2nd position (2 line &lt;pre&gt; tag meant I couldn't indent; anyone who can format well is free to do this over): +:: <pre>#1|[1&2[3|2^2|]3]3&0|[3&2|]1&1/</pre> + +:: This is made up of two main segments:<br> +:: <b>The storage segment</b>: +:: <pre>|[1&2[3|2^2|]3]3&0</pre> + +:: <b>The retrieval segment</b>: +:: <pre>|[3&2|]1&1</pre> + +:: Be aware that the TIO is currently not up to date and you'll need to use the interactive version or download the GitHub version.<br> +:: Hopefully the TIO will be updated soon. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:09, 11 May 2019 (UTC) + +:: The solution to the original problem (directly copied and evaluated) would be: +:: <pre>]3|[3&2|]1&1|[0&1[3|1^1|]3]3&0[3</pre> + +:: Which can be shortened to: +:: <pre>]3|[3&2|]1&1[3|1^1|]3&7</pre> +:: - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:24, 11 May 2019 (UTC) + +::: Thanks [[User:Helen|Helen]], that example does indeed fulfil my challenge using your cell based memory structure, congratulations! I see now how it works, that the memory structure is good, and that you had figured out usable memory before I proposed my challenge. Apologies for doubting you! +::: Bitshift operator precedence seems to come after arithmetic operators in most programming languages (C, python, js), so when I used that formula, copied directly from [[Bitch#Loading_the_value_of_a_cell]] section, <code>1<<2-1<<1 = 4</code> which is what I tried for "ANDing the cell that we want" is different from <code>(1<<2)-(1<<1) = 2</code>, which looks like what you intended in the example. That threw me early and I stopped digging deeper. If you don't mind, I'll try to follow the rest of the example and update your [[Bitch#Loading_the_value_of_a_cell]] section if I can make it clearer? [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:26, 20 May 2019 (UTC) + +:::: Yeah, go ahead! That's perfectly fine by me.<br> +:::: I always mentally replace <code>1<<</code> with <code>2^</code> so order of operations is a bit messed up for me on that sorry. + +:::: Generally feel free to edit stuff as you wish. Go wild! - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 14:41, 27 May 2019 (UTC) + += Sketch: A RAM Machine = + +We sketch a bitch implementation of a machine with a 32 bit accumulator A (stored in bits 0..31 of the accumulator), +a 32 bit extended accumulator X (bits 32..63), optional quick-access registers, and up to 2^26 - 1 individually addressable words of RAM. +So even if bitch is not TC, it still appears to be a capable programming language. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:41, 9 May 2019 (UTC) +:I've used this machinery to make a ''finite memory'' (so non-TC) Brainfuck interpreter; see https://github.com/int-e/bits/blob/master/examples/brainfuck.pp and the resulting https://github.com/int-e/bits/blob/master/examples/brainfuck (not thoroughly tested, may have bugs) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 22:47, 16 May 2019 (UTC) +:In case other users get confused of how that preprocessor works, I clarify that the preprocessor takes input from the console and outputs the resulting bitch program. --[[User:A|A]] ([[User talk:A|talk]]) 12:10, 20 May 2019 (UTC) +::<del>How is it supposed to work? (I have inputted a brainfuck program and could not get it to work...) Does it take a program from input or whatever?</del> +:::<del>From the .pp file: "[The p]rogram is separated from input by an exclamation mark (!)." Both the program and all input are read from stdin. A possible pitfall is that the exclamation mark is obligatory. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:56, 17 May 2019 (UTC)</del> +::I will be testing your implementation using <code>,[.-[-->++<]>+]</code>, which makes sure that a brainfuck interpreter supports all commands, nested loops, and unbounded memory. Testing halting is trivial... +:::Although it is quite slow, the implementation is flawless. --[[User:A|A]] ([[User talk:A|talk]]) 06:51, 18 May 2019 (UTC) +::::I've implemented a (hopefully not too buggy) bitch interpreter in C++ which is a bit faster (in the same github repo) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:24, 21 May 2019 (UTC) +::I have an idea: you could extend the implementation to be unbounded by supplying tape extending operation, if this machinery supports extending the memory. +:::First of all, extending memory after initialization is hard, perhaps even impossible, because the design is based on each memory cell containing its own address. (Without that stored address, `poke` doesn't work.) Shifting the existing memory would invalidate the addresses stored in that memory. Oh and I wouldn't know where to even begin doing such an extension without a loop. +:::Note also that addresses are bounded. The current implementation uses 16 bit words, both for data and the addresses. Addresses need to be divisible by 32, so at most 2^11 - 1 = 2047 addressable memory cells are supported, and that's what the interpreter provides (minus memory used for stack, program, and registers). +:::For the particular application as a Brainfuck interpreter, one could change the memory cell layout to use, for example, a 24 bit address and 8 bit data, increasing the address space to 2^19 - 1 = 512287 cells, but that's a non-trivial effort. An easier approach would be to set the word size to 32 bits (BB=5), with up to 2^27 addressable memory cells. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:56, 17 May 2019 (UTC) +::::Can the word size be set dynamically? If that is a yes, bitch would be Turing-complete. --[[User:A|A]] ([[User talk:A|talk]]) 10:26, 22 May 2019 (UTC) +:::::Not with this design; the word size is hardcoded in all of the building blocks (initialization, reading and writing registers, reading and writing memory, arithmetic). --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 11:17, 22 May 2019 (UTC) +::<i>Wow</i>, the macro replacements can act as variables!!! See this program(which seems to be an abuse of this preprocessor): +<pre> +A=1, +,A, +A=2, +,A, +</pre> +::This program prints <code>12</code>, which is 1 and 2 combined. This can demonstrate that the word sized can be set dynamically in the preliminary stage; however, there is currently no way to implement unbounded cells using this way. + +This will not work if you want to extend the cell length though: +<pre> +CNT=4, +BB=CNT, +CNT={BB+1}, +BB=CNT, +,BB, +</pre>--[[User:A|A]] ([[User talk:A|talk]]) 13:04, 22 May 2019 (UTC) +::I am aware about the loop limitations...the maximum 63 loop nesting would be enough, as two loop nestings are sufficient for Turing-completeness ( refer to [https://cs.stackexchange.com/questions/102363/how-many-pairs-of-brackets-are-sufficient-to-make-brainfuck-turing-complete/102500#102500 this page]). --[[User:A|A]] ([[User talk:A|talk]]) 14:35, 18 May 2019 (UTC) +:::I meant bitch's limitation of not supporting any nested loops. But you have a point—the same machinery that supports the Brainfuck loops can also support nested loops in general. So the fixed, bounded address size is the real limitation here. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:03, 18 May 2019 (UTC) +::Anyway, nice work!--[[User:A|A]] ([[User talk:A|talk]]) 13:47, 17 May 2019 (UTC) + +A summary of the construction in this section has found its way to the [[Bitch#Bounded storage|bitch page]] (last week). Is there anything left here that is worth preserving? (I mean the construction itself, not the discussion thereof.) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 08:09, 27 May 2019 (UTC) + +=== Memory === + +The storage is used for memory. Addresses are 32 bits, the lowest 6 of +which are always 0. Each word occupies 64 bits in memory that store the +address of the word and the word itself value. + +The first few addresses may be used as additional registers instead, +at the programmer's discretion. + +=== Operations === + +None of these operations use > or <, so we can use them in loops. + +The operations are not clean for the ; conditional in the sense that +the accumulator may become 0 while an instruction is executed. +It should not be too difficult to accomplish that, with some extra care. +(The motivation would be that operations that are clean for ; can be +used as part of a state machine that manages the control flow.) + +* load immediate n (clears X): + + IMM n := ^^n + +* 32 bit decrement (assumes X = 0): + + DEC := + ]32^1 + [32^]32]32&[32 + [31^]31]31&[31 + ... + [2^]2]2&[2 + [1^]1]1&[1 + &0[32 + +* 32 bit increment (assumes X = 0): + + INC := + ~]32&0[32 + DEC32 + ~]32&0[32 + +* load a register (assumes X = 0, n divisible by 32): + + GET n := ^^[n]32&0[32 + +* store a register (assumes X = 0, n divisible by 32): + + PUT n := [n&-4294967296|]n]n + +* read a word at address in accumulator: + + # comment format: # accumulator | reverse storage + PEEK := # A | ... A W ... + ^^[^32 # A ... A W | ... A W ... + ]32&0[32 # W | ... A W ... + +* store word at address (<2^32 - 8) in accumulator, with value given in upper 32 bit of (extended) accumulator: + + # comment format: # accumulator | reverse storage + POKE := # X A | ... A W (A+64) ... + [&4294967295 # X A ... A | W (A+64) ... + [32 # X A ... A W | (A+64) ... + &-4294967296 # X A ... A 0 | (A+64) ... + ^^[32 # X A ... A 0 (A+64) | (A+64) ... + ^]&4294967295 # X A ... A X ?? | (A+64) ... + ^^]32 # X A ... A X | (A+64) ... + ]32 # X A ... A | X (A+64) ... + ]&4294967295 # X A | ... A X (A+64) ... + +* load extended part of accumulator (n divisible by 32) for stores: + + GETX n := + ]32 + GET (n+32) + [32 + +* clear extended accumulator: + + CLEARX := &4294967295 + +* arithmetic with extended accumulator: + + XOR := ^]32 + AND := &]32 + OR := |]32 + NOT := ]32~]32~[64 + +* initialize memory (only needed once, at the start of the program, so using > < ; is okay): + + INIT := + >DEC&-64]64|[64;<[64 + +<!--* clear storage (not useful for the RAM machine but perhaps in other contexts): + CLS := #]0 or #[0 or #|0--> + +<!--* input without destroying the storage (does not work in the reference interpreter): + INP := &0|\--> + +* Bitwise right shift accumulator A: + RSH n := ^^]n + +* Bitwise left shift accumulator A: + LSH n := ^^[n + +* Swap the two accumulators: + XCHG := ^]32^[32^]32 + +<!--* No operation: + NOP := |0 or [0 or ]0 or--> + +<!--* Halt: + HLT := .--> +<hr> +:Here are some extra instructions I find in Assembly language that might improve the usability of the instruction set(some are very trivial): + +:* Shifting operations (cyclic left shift, cyclic right shift) --[[User:A|A]] ([[User talk:A|talk]]) 08:04, 12 May 2019 (UTC) + +:I have a question about the IMM instruction. Couldn't you directly use <code>^x</code>(which works) instead of <code>^^x</code>? --[[User:A|A]] ([[User talk:A|talk]]) 10:19, 10 May 2019 (UTC) +::The point is that <code>^^n</code> sets the accumulator to n independently of the previous value of the accumulator. You could achieve the same effect with <code>&0^n</code>, but that would be one more character. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:06, 10 May 2019 (UTC) +:::<del>I think I don't understand the <code>[n^]n]n&[n</code> operations in the decrement implementation. I believe it does carrying, but I can't understand how it achives it. {{unsigned|14:49, 10 May 2019 UTC|A}}</del> + +::::<del>Have you tried working out a small example, say a 4 bit decrement starting from 12 = 1100b? [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:20, 10 May 2019 (UTC)</del> + +:::::<del>Oh right. Sorry. --[[User:A|A]] ([[User talk:A|talk]]) 01:14, 11 May 2019 (UTC)</del> + += Sketch: A Stack Machine = +We sketch another machine with an accumulator (with 64 bits) and a stack(preserved in the storage).<br> +This machine simulation in [[bitch]] is created merely to extend the power of bitch programs.<br> +Note: If mixing this stack machine with the RAM machine above is neccesary, the two accumulators must be preserved somewhere inside the storage before using the commands.--[[User:A|A]] ([[User talk:A|talk]]) 11:54, 13 May 2019 (UTC) +=== Memory === +The memory is just an accumulator (stored in the bitch accumulator) and an unbounded stack (stored in the accumulator storage). +=== Operations === +All of the commands do not use loops. +* Duplicate the top of the stack +<pre>DUP := ^^[32]32</pre> +* Push a number onto the stack +<pre>PUSH x := ^^x]32</pre> +* Pop a number +<pre>POP := [32^^0</pre> +* Pop a number, outputting it +<pre>POPOUT := [32/^^0</pre> +* Swap the top 2 elements of the stack +<pre>SWP := [64^]32^[32^]32]64</pre> +* Push input +<pre>PUSHI := &0|\]32</pre> +* Increment top of stack +<pre>INC := + [32~]32&0[32 + DEC + ~]32&0</pre> +* Decrement top of stack +<pre>DEC := + ^1 + [32^]32]32&[32 + [31^]31]31&[31 + ... + [2^]2]2&[2 + [1^]1]1&[1 + &0</pre> +* Check whether two top-of-stacks are equivalent +<pre>CHK := ^^[32^[64]32</pre> +* Check if top of stack > the second top of stack +* Check if top of stack < the second top of stack +* Implementation of +, -, *, /, modulo, etc (impossible? *, /, and modulo possibly requires nested loops) +* Reverse the stack (impossible?) + += Page content deletions = + +I'd like to point out that with MediaWiki's awful default diff, there's hardly anything ''worse'' for following talk page changes than deleting content. Also deleting other people's talk page contributions, or even your own after others have responded to them, is generally considered inappropriate, except on your own personal talk page. + +We generally approximate Wikipedia policy here when we don't have a specific different tradition, so I'd sum up my understanding of what is done there: The recommended way to delete content from talk pages that are too big is to only ''move full sections'' to an archive subpage (like Talk:Bitch/Archive 1), and only when there has been no discussion in that section for a reasonably long time (which might depend on how fast discussion is happening). + +--[[User:Oerjan|Ørjan]] ([[User talk:Oerjan|talk]]) 00:38, 10 May 2019 (UTC) +:Sorry, I read that [[User:Salpynx|Salpynx]] noted that this page is too hard to follow, so I removed some of the content. --[[User:A|A]] ([[User talk:A|talk]]) 11:33, 10 May 2019 (UTC) +<!--= An interesting discovery = +When [[bitch]]'s program counter reaches whitespace, it halts immediately, despite the fact that a command can be executed conditionally after <code>:</code>'s and <code>;</code>'s. Here is a modified [[Truth-machine]], with . replaced with whitespace: <code>\:/: &-2#1>/<</code> It will halt immediately if the input is 1, and it will print 0 if the input is 0. Same as: +<pre>\:/: +&-2#1>/<</pre> +and +<pre>\:/: &-2#1>/<</pre> +Note that they works in both interpreters.--[[User:A|A]] ([[User talk:A|talk]]) 06:53, 12 May 2019 (UTC) + +:This is semi-intentional in my interpreter.<br> +:By default it ends the program if the next instruction is not valid code (although due to oversights this won't happen on nested instructions).<br> +:However this is not part of the language specification (and I'd like to keep it that way) and therefore not really portable. +:: This is definitely not portable at this point. My implementation treats <code>: </code> as an invalid instruction and stops parsing the program right there. Anything following an invalid instruction is ignored. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 20:02, 12 May 2019 (UTC) +:Still a good discovery though, nice! - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:59, 12 May 2019 (UTC)--> += Sketch: A [[Turing machine|Turing Machine]] = +We can implement a Turing machine on a binary alphabet. The main challenge here is to implement bitwise boolean operations that keep (most of) the accumulator intact. It turns out that this isn't too hard if one pads the data with sufficiently many always-zero bits. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 20:53, 23 May 2019 (UTC) + +:Is the state represented using 1 bit? Also, what does k and q mean? (You don't have to explain the meaning of <code>k:l</code> and <code>r:q</code>; I know them.)--[[User:A|A]] ([[User talk:A|talk]]) 10:19, 24 May 2019 (UTC) +::The state is represented by as many bits as needed for the given Turing machine (the second ''s'' in ''ss'' indicates a plural; this convention comes from Haskell...). ''k'' is an adjacent letter to ''l'' and ''q'' is adjacent to ''r''; I went down (in the alphabet --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 25 May 2019 (UTC)) rather than up to avoid confusion with ''s''. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:00, 24 May 2019 (UTC) +:I don't know how that can "avoid confusion". Hmm, l is directly adjacent to s, which might arise confusion: l could be considered part of the ''ss''. Also, you wrote <code>I went down rather than up to avoid confusion with ''s''.</code>; what does ''<code>I</code>'' mean? I did not find ''<code>I</code>'' anywhere in this sketch. + +::The alphabet (adjacent letters represent adjacent bits). And "I": a name I call myself. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 08:37, 25 May 2019 (UTC) + +The contents of this section has moved [[Bitch#A Turing machine|here]]. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 07:43, 27 May 2019 (UTC) '
New page size (new_size)
65541
Old page size (old_size)
97
Lines added in edit (added_lines)
[ 0 => '{{lowercase}}', 1 => 'This is the talk page for [[bitch]].<br>', 2 => 'Use this to discuss syntax, programs, or even to prove stuff about the language!', 3 => '', 4 => '<hr>', 5 => '<i>Note:</i> <b>For the sake of everyone's collective sanity, do not delete anything!</b><br>', 6 => 'Even if nothing comes out of one of these discussions they are still useful to show thought processes and progress within certain problems.<br>', 7 => 'If you don't like what you said or you changed your mind, strike it out (use <code>&lt;strike&gt;&lt;/strike&gt;</code> or <code><nowiki><del></del></nowiki></code>) and write underneath.', 8 => '', 9 => '= Attempts at proving Turing-completeness =', 10 => 'Since bitch is a newly created language and is fairly different to a lot of the languages usually used to prove Turing-completeness, a proof is hard to come up with.<br>', 11 => 'Below are the attempts currently ongoing. Feel free to join one or add a brand new one!', 12 => '==[In Progress] Compilation from [[Home Row]] to [[bitch]] by [[User:Helen]]==', 13 => '<i>This section has been redone as of [https://esolangs.org/w/index.php?title=Talk:Bitch&oldid=62789 16:43, 27 May 2019 (UTC)]. The previous version held nothing of use for either proving or showing the process behind proving the computational class of [[bitch]].</i>', 14 => '', 15 => 'This proof consists of two parts: a memory equivalence proof, and an operation equivalence proof.', 16 => '', 17 => 'In the memory equivalence proof, we will prove that [[Home Row]]'s memory structure can be simulated in (and therefore is equivalent to) [[bitch]]'s.<br>', 18 => 'In the operation equivalence proof, we will prove that all [[Home Row]]'s operations can be simulated as a whole using [[bitch]]'s.', 19 => '', 20 => 'Any looping inside proof code will prevent looping in a program, due to non-nestable loops in both languages.<br>', 21 => 'Since looping must remain possible as part of the equivalence, looping must not be present in proof code.', 22 => '', 23 => '=== [Invalid] Memory equivalence ===', 24 => 'For an <code>n</code>x<code>m</code> [[Home Row]]-like grid to be equivalent to a tape, we have to show that we can either:', 25 => '* Simulate a grid inside a tape - every time we reach a cell whose index is a multiple of <code>grid width</code> (1-indexed) and try to go forwards again, we must go back <code>grid width - 1</code> cells', 26 => '<nowiki>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-</nowiki> every time we want to go down, we must go forwards <code>grid width</code> cells', 27 => '', 28 => '* Simulate a tape inside a grid - every time we want to go forwards in the tape, we must check whether the pointer is at the rightmost end of the grid, and if so, we wrap down to the leftmost end of the next row', 29 => '', 30 => 'For the sake of simplicity, neither of these has to be able to go back/up a cell.<br>', 31 => 'This means the only way to backtrack is by wrapping back around at the right and bottom edges (for a grid) or at the end (for a tape).', 32 => '', 33 => 'Since it is more simple to simulate a tape in [[Home Row]] than it is to simulate a grid in [[bitch]], this proof will show that it is possible to simulate a tape.<br>', 34 => 'This means we must be able to check whether we are at the rightmost edge.', 35 => '', 36 => 'The simplest way to do this is by filling the rightmost column with zeros and not allowing any zeros inside cells (labelled <code>c<sub>n</sub></code>):', 37 => ' c<sub>1 </sub> c<sub>2 </sub> c<sub>3 </sub> c<sub>4 </sub> 0', 38 => ' c<sub>5 </sub> c<sub>6 </sub> c<sub>7 </sub> c<sub>8 </sub> 0', 39 => ' c<sub>9 </sub> c<sub>10</sub> c<sub>11</sub> c<sub>12</sub> 0', 40 => ' c<sub>13</sub> c<sub>14</sub> c<sub>15</sub> c<sub>16</sub> 0', 41 => ' c<sub>17</sub> c<sub>18</sub> c<sub>19</sub> c<sub>20</sub> 0', 42 => '', 43 => 'We must then create a code snippet to prove we can move forwards.<br>', 44 => 'For legibility and ease of understanding, two macro-like operations will be used:', 45 => '*<code>l</code> - moves 1 grid space left, equivalent to <code>f f f f</code>', 46 => ':<code>jl</code> is equivalent to <code>jf jf jf jf</code> and not to <code>jf f f f</code>.', 47 => '*<code>u</code> - moves 1 grid space up, equivalent to <code>d d d d</code>', 48 => ':<code>ju</code> is equivalent to <code>jd jd jd jd</code> and not to <code>jd d d d</code>.', 49 => '', 50 => '<u>Move forwards:</u>', 51 => ' f', 52 => '', 53 => '<u>Move down if the pointer is on a zero:</u>', 54 => ' d ju', 55 => '', 56 => '<u>Move right if the pointer is on a zero:</u>', 57 => ' jl f', 58 => '', 59 => '<b><u>Combined:</u></b>', 60 => ' f d jdjdjdjd jfjfjfjf f', 61 => '', 62 => 'We can navigate the [[Home Row]] grid as if it were a tape, with the limitation that the tape is only 20-cells long.<br>', 63 => 'However, this still proves that a grid memory space is equivalent to a tape space, since it shows that any <code>n x m</code> grid is equivalent to <i>at least</i> an <code>(n-1)m</code> tape.<br>', 64 => 'Overall size is irrelevant, as [[Turing-completeness|Turing-complete]] actually requires and infinite tape size, and all languages are limited to a finite memory.<br>', 65 => '', 66 => '<hr>', 67 => 'I don't believe that the translation of <code>jl</code> works: <code>jf jf jf jf</code> will get stuck when it hits a zero value. I believe the translation is also at odds with the requirement that the <code>c<sub>i</sub></code> values are non-zero... --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC)', 68 => ':Both of those are intentional:', 69 => ':*<code>jl</code> is meant to get stuck on zero values', 70 => ':*<code>c<sub>i</sub></code> values are meant to be limited to non-zero values', 71 => '', 72 => ':However this is pretty clumsy and part of the reason I marked this as invalid.<br>', 73 => ':The new proof will hopefully be better, although a proof is pretty trivial and not <i>really</i> necessary but good for completion. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:27, 29 May 2019 (UTC)', 74 => '', 75 => 'OTOH, since you're basing the memory on the cell-based storage, you can directly implement arbitrary permutations of <code>c<sub>1</sub> ... c<sub>nm</sub></code>, so the <code>d</code> and <code>f</code> operations can be implemented directly. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC)', 76 => ':That's true the operations can most likely be directly implemented on a tape.', 77 => '', 78 => ':I realised shortly after posting this proof that the memory structure I'm using for [[bitch]] is actually simply a cell-based RAM.<br>', 79 => ':For that reason, I invalidated the memory proof and I'm working on a new one. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:27, 29 May 2019 (UTC)', 80 => '<hr>', 81 => '', 82 => '=== Operation equivalence ===', 83 => 'In this proof, it is assumed that the random access cell-based alternative memory structure is being used.', 84 => '', 85 => 'There are some trivial equivalences (such as <code>l</code> or <code>j</code>), which we will deal with first.<br>', 86 => 'However, there are also some more complex equivalences which will be dealt with individually and with explanations.', 87 => '', 88 => 'For the sake of simplicity, we will be using three macro-like operations:', 89 => '* <code>L<i>n</i></code> - loads the <code><i>n</i></code><sup>th</sup> cell, equivalent to [[Talk:bitch#Loading_the_value_of_a_cell|the code for loading the value of a cell]].', 90 => '* <code>S<i>n</i></code> - sets the <code><i>n</i></code><sup>th</sup> cell, equivalent to [[Talk:bitch#Setting_the_value_of_a_cell|the code for setting the value of a cell]].', 91 => '', 92 => '==== Trivial equivalences ====', 93 => '{| class="wikitable"', 94 => '|-', 95 => '! [[Home Row]] !! [[bitch]]', 96 => '|-', 97 => '| <code>j</code> || <code>;</code>', 98 => '|-', 99 => '| <code>k</code> at cell <code>n</code> || <code>Ln/&0Sn</code>', 100 => '|-', 101 => '| <code>l</code> || <code>&gt;</code> or <code>&lt;</code>', 102 => '|-', 103 => '| <code>;</code> || <code>.</code>', 104 => '|}', 105 => '', 106 => 'Both <code>f</code> and <code>d</code> are not necessary to find an equivalence to, since we already showed that a cell-RAM in [[bitch]] is equivalent to a grid in [[Home Row]].', 107 => '', 108 => '==== Addition and Subtraction ====', 109 => 'Addition (and subtraction) for a fixed-size cell is possible with definite looping and therefore can be unrolled to have no looping at all.', 110 => '', 111 => 'We remain with the same simple addition algorithm, instead we now write it for a fixed number of loops.<br>', 112 => 'We must pick a number of loops such that we guarantee that <code>p = oldP</code> at the end (or equivalently that <code>q = 0</code>).<br>', 113 => 'The bit width of the cells is enough to guarantee this.', 114 => '', 115 => '<pre>p <- some cell', 116 => 'q <- some cell', 117 => '', 118 => 'p <- p XOR q \', 119 => 'q <- (p AND q) LS 1 \', 120 => '... > bitwidth times', 121 => 'p <- p XOR q /', 122 => 'q <- (p AND q) LS 1 /</pre>', 123 => '', 124 => 'We can use a pseudo-extension of the cell-RAM to temporarily store <code>p</code> and <code>q</code>.<br>', 125 => 'We then perform the <code>n</code> iterations and leave the result in the topmost accumulator.', 126 => '', 127 => '<u>Getting both variables:</u><br>', 128 => 'This is the same as the code snippets from [[Talk:bitch#Bitwise_operations_on_two_cells|the code for performing bitwise operations]].', 129 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0</pre>', 130 => '', 131 => '<u>Storing the next </u><code>p</code><u>value:</u>', 132 => '<pre>|[(2*n)^]n]n&0</pre>', 133 => '', 134 => '<u>Storing the next </u><code>u</code><u>value:</u>', 135 => '<pre>|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0</pre>', 136 => '', 137 => 'We then repeat those two code snippets another <code>n-1</code> times.<br>', 138 => 'In the combined code, we'll paste this only once.', 139 => '', 140 => '<u>Moving the result into the accumulator:</u>', 141 => '<pre>[(2*n)|]n&(1<<n-1)</pre>', 142 => '', 143 => '<b><u>Combined:</u></b>', 144 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0 |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)</pre>', 145 => '', 146 => 'Subtraction can be expressed as two additions - <code>p + ~q + 1</code>.', 147 => '', 148 => '<u>Loading and negating </u><code>q</code><u>:</u>', 149 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)~]n~</pre>', 150 => '', 151 => '<u>Adding 1 to </u><code>~q</code><u>:</u>', 152 => '<pre>|1]n |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)]n</pre>', 153 => '', 154 => '<u>Loading </u><code>p</code><u>:</u>', 155 => '<pre>|[((a+1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)]n</pre>', 156 => '', 157 => '<u>Summing </u><code>p</code><u> and </u><code>~q + 1</code><u>:</u>', 158 => '<pre>|[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n</pre>', 159 => '', 160 => '<u>Moving the result into the accumulator:</u>', 161 => '<pre>[(2*n)|]n&(1<<n-1)</pre>', 162 => '', 163 => '<b><u>Combined:</u></b>', 164 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)~]n~|1]n |[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)]n|[((a+1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)]n|[(2*n)^]n]n&0|[(3*n)&(1<<(2*n)-1)&]n|[(n+1)&(1<<(2*n)-1<<(n+1))|]n&(1<<n-1)[(3*n)&(1<<(4*n)-1<<(2*n))|](2*n)](2*n)&0 ...n [(2*n)|]n&(1<<n-1)</pre>', 165 => '', 166 => '=== Conclusion ===', 167 => 'Since [[bitch]] can successfully emulate [[Home Row]]'s operations and, their memory structures are equivalent, [[bitch]] must be able to solve at least as many problems as [[Home Row]].', 168 => '', 169 => 'This means [[bitch]] is [[Turing-complete]].', 170 => '', 171 => '<hr>', 172 => 'I am pretty sure that [[brainfuck]] cannot compile to [[bitch]], since brainfuck requires nested loops to be [[Turing-complete]]. [[bitch]] can only nest an infinite loop once. I suggest that [[Home Row]] might result a more efficient compilation proof. --[[User:A|A]] ([[User talk:A|talk]]) 11:08, 15 April 2019 (UTC)', 173 => '', 174 => 'Of course, I completely forgot about the loops. I had a look at [[Home Row]] and it seems to be all good but I didn't quite understand the loop definition. Is it similar to [[bitch]]'s? - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 13:14, 15 April 2019 (UTC)<br>', 175 => 'Oh I understand the loop now. It might be a problem since [[bitch]]'s loops runs for the first time no matter what whereas [[Home Row]]'s runs only if the current memory value is 0. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 13:24, 15 April 2019 (UTC)', 176 => '', 177 => 'Anyway, the way of executing loops does not affect its [[Computational class]]. --[[User:A|A]] ([[User talk:A|talk]]) 13:50, 15 April 2019 (UTC)<br>', 178 => 'You are understanding the loops the wrong way. It says that the loop will run if the current memory spot is <b>nonzero</b>. --[[User:A|A]] ([[User talk:A|talk]]) 14:55, 15 April 2019 (UTC)', 179 => '', 180 => 'Oh of course, my bad. But either way there is no reasonable way to replicate that in [[bitch]] in a general way. I'm glad it doesn't affect the [[Computational class|computational class]]; phew - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:57, 15 April 2019 (UTC)<br>', 181 => '', 182 => '<!--Astonishingly, [[User:int-e|int-e]] has implemented bounded-storage [[brainfuck]], disregarding to this ongoing work. --[[User:A|A]] ([[User talk:A|talk]]) 10:39, 18 May 2019 (UTC)-->', 183 => '<hr>', 184 => '=== The compilation probably failed ===', 185 => 'Home Row requires unbounded memory to be [[Turing-complete]]. However, only a limited 32-bit version of incrementing and decrementing was implemented. So, the attempt had certainly failed. [[User:A|I]] could not find any other [[:Category:Computational models|computational models]] useful for proving whether [[bitch]] is [[Turing-complete]]. --[[User:A|A]] ([[User talk:A|talk]]) 14:05, 13 May 2019 (UTC)', 186 => '', 187 => '[[bitch]]'s cell-based alternative storage is computationally equivalent to [[Home Row]]'s. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 17:18, 13 May 2019 (UTC)', 188 => '', 189 => ':Sorry, but I believe you've missed an important point about [[Home Row]]: its 5<sup>2</sup> cells are unbounded. That is how it manages to be [[Turing-complete]]. So A has a point (with 32 replaced by the now arbitrary, but fixed, bit width) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC)', 190 => '', 191 => '::I didn't say anything before out of pure laziness but below is the logic as to why [[Home Row]]'s and [[bitch]]'s cells are equivalent for the sake of current computation.', 192 => '', 193 => '::[[bitch]] can simulate arbitrary sized cells. This is computationally the same as [[Home Row]] as no cell can be truly unbounded.<br>', 194 => '::Even if the cells are allowed to expand as much as necessary, eventually a RAM limit will be hit and the cell will be capped at an arbitrary size limit.<br>', 195 => '::[[bitch]] will be able to simulate a cell at that size limit as it too is only limited by the same factors.', 196 => '', 197 => '::The rest of the new (and valid) memory equivalence proof will be up eventually but that is essentially part of it.<br>', 198 => '::[[bitch]] is TC essentially on a technicality but that is enough (at least until we get truly infinite memory). - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:20, 29 May 2019 (UTC)', 199 => '', 200 => ':::The fact remains that you're not showing Turing-completeness. One can argue, and I would agree, that Turing-completeness is a purely theoretical concept, and that in practice we're usually programming sufficiently large finite automata anyway. (Sometimes we're dealing with analogue signals, but those are noisy.) Note that just like Turing machines, bitch cannot be implemented on real hardware, because it has unbounded memory (both in the accumulator and in the storage). To show that bitch is TC, one needs to implement a Turing-complete formalism (a Turing machine, or something equivalent to a Turing machine) in bitch.', 201 => ':::On the level of finite state machines, programming becomes a matter of compression: how big does a program have to be to operate on a certain number of states? A direct description of FSMs in terms of states and transitions is impractical for real computations--a program of size n can access O(n) states at best. With bitch, compression is possible: Cell-based storage (which you're using here) allows a program of size n to work on 2<sup>O(n)</sup> states. The RAM construction boosts this to 2<sup>2<sup>O(n)</sup></sup>. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:39, 30 May 2019 (UTC)', 202 => '', 203 => '', 204 => '::::Yeah after thinking about it for a while, I realised I only really showed that it's equivalent to a [[Bounded-storage machine|bounded-storage machine]] with an arbitrarily large bound, which makes it "effectively TC" for all reasonable computation, but still doesn't prove that the language itself is [[Turing-complete]].', 205 => '::::Of course by "only really showed" I mean "will only really show" because I'm still working on finishing the new memory equivalence proof but once that's done I'll update this.', 206 => '', 207 => '::::I think I have an idea for addressing infinite memory in [[bitch]], which would prove its [[Turing-completeness]], but I'll have to do that after this proof. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:41, 30 May 2019 (UTC)', 208 => '', 209 => '=== Terminology ===', 210 => 'You're attempting to show that every [[Home Row]] program can be translated to an equivalent [[bitch]] program, but for an equivalence proof between the two languages, you would need both directions, i.e., you'd also have to translate [[bitch]] programs to [[Home Row]]. What you have (if correct) is a reduction from a bounded cell variant of Home Row to bitch. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 28 May 2019 (UTC)', 211 => ': My bad, I'll fix the title. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:17, 29 May 2019 (UTC)', 212 => '', 213 => '== Some thoughts ==', 214 => '', 215 => 'The provided implementation has a 63-bit accumulator and bit-storage, which is pretty small, and Java has builtin bigints so you might want to use that.', 216 => 'Also, [https://cs.stackexchange.com/questions/2832/is-a-push-down-automaton-with-two-stacks-equivalent-to-a-turing-machine/2833#2833 according to this StackExchange answer], a 2-stack [[Push-down automaton]], which might be emulated using the accumulator and bit-storage, is equivalent to a turing machine. So this could be a possible way of proving TCness. Although the lack of nested loops might be a problem. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 08:50, 17 April 2019 (UTC)', 217 => ': There also seems to be some inconsistency with rapport to <code>&gt;...&lt;</code>: the spec says for <code>&lt;</code> that it "jumps to the nearest <code>&gt;</code>" but the implementation saves the position of a <code>&gt;</code> only when executed. So for example in <code>&gt;#0;&gt;&lt;</code>, should the <code>&lt;</code> jump to the first or second <code>&gt;</code>?', 218 => ':: <del>I will ask [[User:Helen|Helen]]; I have no idea.</del> --[[User:A|A]] ([[User talk:A|talk]]) 11:26, 17 April 2019 (UTC)', 219 => ':: Wait, where did you find that code snippet?', 220 => '::: I wrote it to show the problem. It's hypothetical, but having a well-defined spec is always a good thing. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:41, 17 April 2019 (UTC)', 221 => ':::: I [https://tio.run/##S8osSc74/99O2UDf2k7ZUN/m/38A ran a similar program] and found that it jumps to the first ">". You are right; the documentation indeed has to be modified.--[[User:A|A]] ([[User talk:A|talk]]) 12:04, 17 April 2019 (UTC)', 222 => '<del>:I think that implementing a 2-stack [[Push-down automaton]] would be trivial, as 2 stacks already have the power of simulating a tape. It might be better if you directly simulate a tape. --[[User:A|A]] ([[User talk:A|talk]]) 14:52, 29 April 2019 (UTC)</del>', 223 => 'Spec problem fixed and the rest talked about in [[User talk:Helen|my user talk]]. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 15:16, 17 April 2019 (UTC)', 224 => '=== Another idea ===', 225 => 'It seems that we are having trouble implementing my incrementing/decrementing algorithm. That is why I made a improvement of the incrementing/decrementing algorithm.<br>', 226 => 'This is what I typed in a Lua prompt. This improvement is inspired by this:', 227 => '<pre>', 228 => 'Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio', 229 => '> ~-1', 230 => '0', 231 => '> -~1', 232 => '2', 233 => '>', 234 => '</pre>', 235 => '~-x is equal to x decremented, and -~x is equal to x incremented.<br>', 236 => '-x is the negation of x. ~x is a bitwise NOT.<br>', 237 => 'In case you question me about my algorithm, I will add more examples here:', 238 => '<pre>', 239 => '> ~-9', 240 => '8', 241 => '> -~9', 242 => '10', 243 => '> ~-12', 244 => '11', 245 => '> -~12', 246 => '13', 247 => '>', 248 => '</pre>', 249 => 'These expressions are universal, which means that you can also run it in Java, Python, etc.<br>', 250 => 'It requires a front-register, which saves a pseudo-top element of a number that changes dynamically when a new bit is used. Negating inverts the pseudo-top element, and bitwise NOT-ting inverts all the bits from the pseudo-top to the bottom. If there are 8 bits for each cell, 3 bits are sufficient for representing the front-register. However, this results in recursive incrementing the front-register every time a bit is used, which might be quite hard to do.<br>', 251 => 'Inverting the bits after the pseudo-top might be sufficient.<br>', 252 => 'It is highly probable that I am misunderstanding these expressions.--[[User:A|A]] ([[User talk:A|talk]]) 10:01, 29 April 2019 (UTC)', 253 => '', 254 => '== Bitch might be Turing-incomplete ==', 255 => '', 256 => 'If we treated the accumulator as a counter, with <code>[1</code> for increment and <code>]1</code> for decrement, we could treat it as a 1-register [[Minsky machine]]. However, ''two'' counters are required for an increment-decrement machine to be Turing complete, as one-counter Turing equivalence requires multiplication and division, which are impossible without a temporary.<br>', 257 => 'Then, if we treat the accumulator+shift register as an unbounded bit tape, it still cannot be Turing complete, as we don't have the ability to non-destructively check only one bit of said tape, only checking if all the bits in the accumulator section are zero or at least one bit is non zero.<br>', 258 => 'Maybe other models are possible, but it does seem like it's not Turing-complete. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 15:33, 17 April 2019 (UTC)', 259 => '', 260 => ': You can't independently check the value of a specific accumulator. Neither can you increment or decrement them, without making a loop, which would prevent backward state changes due to the non-existence of nested loops or gotos. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:21, 18 April 2019 (UTC)', 261 => '', 262 => ': In addition, I'd like to see an algorithm that can copy a bit in the accumulator to a different position, but *without* using loops, as using a loop in such an atomic operation would instantly break Turing-completeness due to the necessity of a global program loop to apply state changes. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:28, 18 April 2019 (UTC)', 263 => '', 264 => ':: To clarify: what I mean is that bitch doesn't have any way of control flow other than the non-nestable <code>&gt;&lt;</code> construct and conditional forward jumps. However, for Turing completeness, conditional backward jumps are also required. This can be emulated by putting most of the logic in an unconditional loop, but then it is impossible to build inner loops. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 11:44, 18 April 2019 (UTC)', 265 => '', 266 => 'Nevermind, I didn't realize you could put a valid bitch instruction after a OR, which allows copying data from the storage. The article is quite unclear on this point.', 267 => 'It might just be Turing complete, actually. [[User:TuxCrafting|TuxCrafting]] ([[User talk:TuxCrafting|talk]]) 21:11, 21 April 2019 (UTC)', 268 => '', 269 => 'Completely my fault, the ability to nest instructions like that is one of the most important parts of the language but it gets about two sentences on the main article.<br>', 270 => 'I'm gonna rewrite most of the main article soon; I've been gathering feedback about things that generally aren't very clear. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 22:40, 21 April 2019 (UTC)', 271 => '', 272 => '<!--I have tried several Turing-complete computational models. (These include the [[Minsky machine]](proven to be trivial above), the [[I/D machine]](seems to be nice), Tag systems(bitch currently does not support queues; Sequential tag systems are worth a try. If anyone implemented queues, I will be amazed...), the Turing-machine(Worth a try), etc.)--[[User:A|A]] ([[User talk:A|talk]]) 14:21, 13 May 2019 (UTC)-->', 273 => '', 274 => '==[Unsuccessful] Compilation to Z3 derivative by [[User:Helen]]==', 275 => 'This attempt contains programs that might be useful to prove the [[Turing-completeness]] of [[bitch]].', 276 => '===[[User:A]] - Basic compilation===', 277 => 'This programming language looks like Konrad Zuse's Z3, which was already proven to be Turing-complete by Raúl Rojas [http://page.mi.fu-berlin.de/rojas/1997/Universal_Computer.pdf here].', 278 => '', 279 => 'First of all, Z3 is capable of executing an infinite loop. This is achieved in bitch as the <code>&gt; &lt;</code> block.<br>', 280 => 'Also, Z3 has math operation evaluation capabilities.', 281 => '', 282 => 'Z3 can implement 5 operations: addition, subtraction, multiplication, division, and square-rooting.<br>', 283 => 'Even though these arithmetic operations have not been shown to be implementable in bitch, only the operations of zeroing a value and incrementing a value will be necessary for Turing-completeness, as mentioned [https://www.cl.cam.ac.uk/~sd601/papers/mov.pdf here].', 284 => '', 285 => 'Raúl Rojas shows that an instruction set with load, store, increment, zero and unconditional branching is Turing-complete.<br>', 286 => 'However, Load and Store have to be indirect. They should be nested for at least 2 indices.', 287 => '', 288 => 'Also, infinite memory (a requirement for Turing-completeness) can be implemented in the Z3.<br>', 289 => '', 290 => 'Finally, Z3 has a way to stop the program by using an invalid operation. That is <code>.</code> in bitch.', 291 => '', 292 => '===[[User:Helen]] - Implementing arithmatic operations===', 293 => 'This part was proven partially unneccesary, as [[User:A|A]] had found a command set that is easier to compile to [[bitch]]. On the other hand, these programs might make [[bitch]] easier to program in.<br>', 294 => 'The conditional snippet below is easy to replicate in bitch:', 295 => '<pre>if (z = i) then 0 else 1</pre>', 296 => 'We simply use XOR to check if a number <code>z<code> is equal to some constant <code>i</code> like this:', 297 => '<pre>#z^i;#1</pre>', 298 => 'If they are equal, the result of XORing them is automatically 0.<br>', 299 => 'If they are not, the result is some non-zero number which we can detect (through the conditional <code>;</code>) and then set the accumulator to 1.', 300 => '', 301 => 'Mathematical operations are a bit harder to pull off.<br>', 302 => 'I have managed to get an algorithm for addition.<br>', 303 => '<s>Subtraction can be imitated through addition with negatives (due to algorithm overflowing and actually giving the correct number).</s> It can't.<br>', 304 => 'I haven't managed to get an algorithm for multiplication or division yet.', 305 => '', 306 => '<hr>', 307 => '<b>Addition:</b><br>', 308 => 'Binary addition is very simple.', 309 => '', 310 => 'Ignoring carry overs, each digit behaves like this:', 311 => '{| class="wikitable"', 312 => '|-', 313 => '! a !! b !! a+b', 314 => '|-', 315 => '| 0 || 0 || 0', 316 => '|-', 317 => '| 0 || 1 || 1', 318 => '|-', 319 => '| 1 || 0 || 1', 320 => '|-', 321 => '| 1 || 1 || 0', 322 => '|}', 323 => 'This is equivalent to XOR.', 324 => '', 325 => 'In order to get full addition behaviour though (rather than just "fairly close but not really" addition behaviour), we have to consider carry overs.<br>', 326 => 'This is how carry overs behave:', 327 => '{| class="wikitable"', 328 => '|-', 329 => '! a !! b !! a+b's carry', 330 => '|-', 331 => '| 0 || 0 || 0', 332 => '|-', 333 => '| 0 || 1 || 0', 334 => '|-', 335 => '| 1 || 0 || 0', 336 => '|-', 337 => '| 1 || 1 || 1', 338 => '|}', 339 => 'This is equivalent to AND.<br>', 340 => 'The carry overs are put onto the digit one order higher though.<br>', 341 => 'Therefore, we left shift each carry once.', 342 => '', 343 => 'This gives us our full (recursive) algorithm.<br>', 344 => 'In pseudocode:', 345 => '<pre>a <- input', 346 => 'b <- input', 347 => '', 348 => 'oldA <- a+1', 349 => 'while (a != oldA) {', 350 => ' withoutCarries <- a XOR b', 351 => ' carries <- (a AND b) LS 1', 352 => '', 353 => ' oldA <- a', 354 => ' a <- withoutCarries', 355 => ' b <- carries', 356 => '}</pre>', 357 => 'This is perfectly doable in v4.7* bitch (takes 2 inputs):', 358 => '<pre>\[16|\]32>|[32&4294967295#|0^[16|-281474976710656&]32]15&131070|[31&281470681743360|]16&4294901760|[16#|0&4294967295|[32&281474976710655]32;<|[16/</pre>', 359 => '', 360 => '===[[User:Helen]] - Proving required operations===', 361 => 'In order to be Turing-complete, a language <i>requires</i> a very minimal instruction set (as shown by Raúl Rojas) and infinite tape (by definition).<br>', 362 => 'The required instruction set consists of: load, store, increment, zero and unconditional branching.<br>', 363 => 'If a language can do these and can simulate an infinite tape (or an arbitrarily sized tape), it is Turing-complete.', 364 => '', 365 => 'In order to show these are true, we must envision the bitch accumulator as a tape.<br>', 366 => 'Cells are delimited portions of the tape that are <code>n</code>-bits wide (<code>n</code> being an arbitrary choice of integer width).<br>', 367 => 'Addressing is signed, negative numbers meaning backwards in the tape and positive numbers meaning forwards in the tape.', 368 => '', 369 => 'Loading and storing values can't really be emulated in bitch but a parallel of setting and accessing cells can be made.', 370 => '', 371 => '====Setting cells====', 372 => 'Setting a cell to a constant value <code>c</code> can be done:', 373 => '<pre>#c</pre>', 374 => 'However, this zeroes the rest of the accumulator which impends simulation of a tape.<br>', 375 => 'Therefore, we opt for:', 376 => '<pre>|c</pre>', 377 => 'Given that the cell at position 0 is equal to 0, this will set load the value <code>c</code>.<br>', 378 => 'However this is dependant on the cell being 0, which is not desirable.<br>', 379 => 'There are two options: zeroing the cell at position 0, or moving right/left (arbitrarily) until we find an empty cell.<br>', 380 => 'I choose to zero the cell in order to be able to maintain a knowledge of where things are positioned in memory.<br>', 381 => 'Furthermore, this doesn't impend one from storing the value at position 0 elsewhere and therefore it is the best option.', 382 => '<hr>', 383 => 'With <code>c</code> being the desired constant value and <code>n</code> being the bit-width of the cells in the tape:', 384 => '<pre>|((1<<n)-1)^((1<<n)-1)|c</pre>', 385 => '<i>For the sake of simplicity, brackets represent an expression which must be calculated and put in the source code.</i><br>', 386 => 'If <code>n</code> is 8, the code would become:', 387 => '<pre>|255^255|c</pre>', 388 => '', 389 => '====Accessing cells====', 390 => 'A value at positive position <code>p</code> can be accessed through the following code:', 391 => '<pre>](p*n)</pre>', 392 => '', 393 => 'A value at negative position <code>q</code> can be accessed through the following code:', 394 => '<pre>[(q*n)</pre>', 395 => '', 396 => '====Incrementing====', 397 => 'Incrementing is simply the addition of 1.<br>', 398 => 'It is also currently not implemented or working.', 399 => '', 400 => 'Incrementing can be done by checking each bit, starting from the rightmost bit going left, until we reach a 0 bit.<br>', 401 => 'That 0 bit becomes 1 and all the bits lower than it become 0.', 402 => '', 403 => 'In order to check individual bits we must OR individual bits with 1 and check for equality with the previous version.<br>', 404 => 'In pseudocode:', 405 => '<pre>number <- input', 406 => 'previous <- number', 407 => '', 408 => 'n <- 0', 409 => '', 410 => 'while(number | (1<<n) = previous) {', 411 => ' n <- n+1', 412 => '}', 413 => '', 414 => 'number <- number | (1<<n)', 415 => 'number <- number ^ ((1<<n)-1)</pre>', 416 => '', 417 => 'The algorithm is currently a work in progress.', 418 => '<!--<big>THIS IS WRONG</big>', 419 => '<strike>In order for incrementing to be done, a significant amount of setup is required.<br>', 420 => 'The starting setup should be of all the used memory in topmost storage and a zeroed accumulator.<br>', 421 => 'Given the position <code>p</code> of the number to be incremented in the storage and <code>a</code> as the size of the storage in cells and <code>n</code> as the bit-width of each cell,<br>', 422 => 'The following isolates the number from the storage:', 423 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p)*n)&((1<<n)-1)</pre>', 424 => 'We then set up the three copies of the number as part of the main search loop.', 425 => '<pre>|[(4n)&(1<<(4n)-1<<(3n))|]n|](2n)</pre>', 426 => 'We then 0 the rightmost bit of the topmost number and compare it to the original. If they are not equal, then the bit was a 1 and the search continues.', 427 => '<pre>|(1<<(3n))^(1<<(3n))^]n]2n;<</pre>', 428 => 'We then return to the beginning of the loop, where we must set up the next iteration of the search.', 429 => '<pre>&1[(n-1)</pre>', 430 => 'We then create 3 copies again and the loop restarts.<br>', 431 => 'As part of this we must correctly prepare the initial number for the mainloop.<br>', 432 => '<pre>](n-1)</pre>', 433 => 'At the end of the loop, we must correctly format the resulting number and set the memory back to its original condition.<br>', 434 => '<pre>|1|[((a+1)*n)#|0[((a+1)*n)>]1;<[((a+2)*n)&(1<<((a+1)*n)-1)|[((2a-p)*n)&(1<<((2a-p+1)*n)-1<<n)]n|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)&(1<<(a*n))](a*n)</pre>', 435 => 'This achieves the above.', 436 => '', 437 => 'Collected below is the code necessary to increment, given a cell at position 0 matching the required conditions:', 438 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p)*n)&((1<<n)-1)](n-1)>&1[(n-1)|[(4n)&(1<<(4n)-1<<(3n))|]n|](2n)|(1<<(3n))^(1<<(3n))^]n]2n;<|1|[((a+1)*n)#|0[((a+1)*n)>]1;<[((a+2)*n)&(1<<((a+1)*n)-1)|[((2a-p)*n)&(1<<((2a-p+1)*n)-1<<n)]n|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)&(1<<(a*n))](a*n)</pre>', 439 => 'Where <code>p</code> is the 0-indexed position of the cell with the number to increment, starting counting from the leftmost cell; <code>n</code> is the bit-width of the cells; and <code>a</code> is the size of the currently allocated memory in cells.</strike>', 440 => '<big>THIS IS WRONG</big>-->', 441 => '', 442 => '====Zeroing a cell====', 443 => 'This was done in the section on setting bits but will be restated here with some explanation.<br>', 444 => 'Zeroing can be done by ANDing with a number that has the desired bits - the bits you want to zero - zeroed and all other bits as ones.<br>', 445 => 'However, due to the arbitrary size of bitch's accumulator, we cannot rely on this (well we can but I choose not too since calculating differences of powers of two is more tedious than changing one digit).<br>', 446 => 'Therefore, OR-XORing seems to be most suitable.<br>', 447 => 'We can OR to set the desired bits to 1, then XOR to "flip" them, effectively zeroing them.', 448 => 'If we want to zero the cell at positive position <code>p</code> with cell size <code>n</code>, we use the following:', 449 => '<pre>]p|((1<<n)-1)^((1<<n)-1)</pre>', 450 => 'If we want to zero the cell at negative position <code>q</code> with cell size <code>n</code>, we use the following:', 451 => '<pre>[q|((1<<n)-1)^((1<<n)-1)</pre>', 452 => 'Both of these will end with the tape positioned over the cell you just zeroed.', 453 => '', 454 => '====Unconditional Branching====', 455 => 'bitch lacks in unconditional branching.<br>', 456 => 'It is possible to infinitely repeat code but that is all you can do unconditionally.', 457 => '<pre>>code<</pre>', 458 => '', 459 => '= Alternative memory structures =', 460 => 'The accumulator-storage combination may be quite limiting in certain circumstances.<br>', 461 => 'In this case, some alternative memory structures are implemented below in bitch for ease.', 462 => '== Random access cell-based memory ==', 463 => 'A cell-based memory can be emulated in bitch.<br>', 464 => 'All that is required is an arbitrary choice of bit-width for the cells, and a size (in cells) of the currently allocated memory.<br>', 465 => 'We will call the bit-width of cells <code>n</code> and the size of the memory <code>a</code>.', 466 => '', 467 => 'In terms of structuring in bitch's accumulator-storage conjunction, the memory will be in topmost storage (closest to the accumulator) and the accumulator will remain empty to be used for calculations.', 468 => '<hr>', 469 => '=== Loading the value of a cell ===', 470 => 'Given a cell indexed <code>p</code> (in a 0-based index where the leftmost cell is 0 and the rightmost is <code>a-1</code>), we can set the accumulator to its value by the following steps.', 471 => '', 472 => '<u>Copying up the entire memory to the accumulator:</u>', 473 => '<pre>|[(a*n)</pre>', 474 => '', 475 => '<u>ANDing the cell that we want:</u>', 476 => '<pre>&(1<<((a-p)*n)-1<<((a-p-1)*n))</pre>', 477 => '', 478 => '<u>Then shift copying it down to the bottom of the accumulator:</u>', 479 => '<pre>|]((a-p-1)*n)&((1<<n)-1)</pre>', 480 => '', 481 => '<b><u>Combined:</u></b>', 482 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)</pre>', 483 => '<hr>', 484 => '', 485 => '=== Setting the value of a cell ===', 486 => 'Given a cell indexed "p" (in a 0-based index where the leftmost cell is 0 and the rightmost is <code>a-1</code>), we can transfer the value from the accumulator to the cell by the following steps.', 487 => '', 488 => '<u>Moving the accumulator value to the correct position to line up with p:</u>', 489 => '<pre>|[((a-p-1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))</pre>', 490 => '', 491 => '<u>Clearing the old value:</u>', 492 => '<pre>[(a*n)|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))</pre>', 493 => '', 494 => '<u>Copying down the new one:</u>', 495 => '<pre>|](a*n)</pre>', 496 => '', 497 => '<u>Clearing the accumulator:</u>', 498 => '<pre>](a*n)&0</pre>', 499 => '', 500 => '<b><u>Combined:</u></b>', 501 => '<pre>|[((a-p-1)*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))[(a*n)|(1<<((a-p)*n)-1<<((a-p-1)*n))^(1<<((a-p)*n)-1<<((a-p-1)*n))|](a*n)](a*n)&0</pre>', 502 => '', 503 => '<hr>', 504 => '=== Bitwise operations on two cells ===', 505 => 'Performing bitwise operations with two cell arguments is trivial now that we have the load and set.<br>', 506 => 'We can use the <code>^^</code> combination to perform arbitrary argument operations without messing with the storage.<br>', 507 => 'Given an operation <code>x</code>, we can load two cells 0-indexed <code>p</code> and <code>q</code> and then perform <code>q x p</code>.', 508 => '', 509 => '<u>Loading cell </u><code>p</code><u>:</u>', 510 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)</pre>', 511 => '', 512 => '<u>Loading cell </u><code>q</code><u>:</u>', 513 => '<pre>[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0[(2*n)</pre>', 514 => '', 515 => '<u>Performing binary operation </u><code>x</code><u>:</u>', 516 => '<pre>^^x]n]n&0[n</pre>', 517 => '', 518 => '<b><u>Combined:</u></b>', 519 => '<pre>|[(a*n)&(1<<((a-p)*n)-1<<((a-p-1)*n))|]((a-p-1)*n)&((1<<n)-1)[((a+1)*n)|]((a+1)*n)]((a+1)*n)&0|[(a*n)&(1<<((a-q)*n)-1<<((a-q-1)*n))|]((a-q-1)*n)&((1<<n)-1)[((a+1)*n)|[((a+2)*n)]n#|0]((a+2)*n)&0[(2*n)^^x]n]n&0[n</pre>', 520 => '', 521 => '=[Disproven] Conjecture: [[bitch]] cannot copy one bit from memory to another part of memory while retaining existing data=', 522 => ':'''edit:''' The specific memory copy claim/challenge of this conjecture has been successfully disproven, multiple times over. The more general 'Not TC' part still seems valid, but I'm changing the section heading so it's clear what the 'Disproven' relates to. Section still has value because it prompted useful progress in determining computational class [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:42, 20 May 2019 (UTC)', 523 => '', 524 => 'I was following [[Talk:Bitch#Bitch_might_be_Turing-incomplete|TuxCrafting's (now struckthrough) arguments against TC above]], and I don't think the ability to chain instructions helps that much (because they can't be grouped), and the challenge "to see an algorithm that can copy a bit in the accumulator to a different position" is still open.', 525 => '', 526 => 'There are multiple ways to formulate this as a challenge, but this is the simplest I could come up with:', 527 => '', 528 => 'Create a bitch program that can take an already initialised 3 bit accumulator <code>abc</code> and convert it programatically to <code>abb</code>:', 529 => '', 530 => ' abc => abb', 531 => '', 532 => 'examples:', 533 => ' 011 => 011 (3 => 3)', 534 => ' 101 => 100 (5 => 4)', 535 => ' 110 => 111 (6 => 7)', 536 => '', 537 => '(As I read it) There is no way to group or order the evaluation of chained operations, and no temporary scratch space to use different parts of the accumulator for a single operation. The accumulator cannot be practically masked in such a way that one sub-part of it can interact with another and re-stored, without losing sub-parts not involved in the operation.', 538 => '', 539 => 'Here is the full mapping of expected results:', 540 => ' 0 -> 0', 541 => ' 1 -> 0', 542 => ' 2 -> 3', 543 => ' 3 -> 3', 544 => ' 4 -> 4', 545 => ' 5 -> 4', 546 => ' 6 -> 7', 547 => ' 7 -> 7', 548 => '', 549 => 'A simple algorithm to do this for three bits is:', 550 => ' (abc & 0b110) | ((abc & 0b010) >> 1)', 551 => '', 552 => 'This requires grouping and two separate logic operations on the accumulator (abc) as sub steps. Since bitch modifies the accumulator in place, no amount of instruction chaining will help. The logic operations are only useful when combining the accumulator with number literals or user input.', 553 => '', 554 => 'Conjecture: ', 555 => '* A machine with two independent stacks should be able to copy a value from one stack to the other. A machine that cannot copy a single bit in isolation from anywhere in memory to anywhere else, regardless of the actual datastructures involved, has no hope of simulating two stacks.', 556 => '* There is no way to create a generalised algorithm to perform simple bit copy in bitch, therefore the language cannot simulate two independent storage stacks or accumulators.', 557 => '* It may be possible to produce the results above in bitch by creating effectively a lookup table mapping the input to desired output, but that proves lack of Turing completeness if the only way to produce arbitrary results is to create lookup tables mapping input to output. ', 558 => '* The ability to copy data from one memory location to another with destroying all other data is required equally for any TC system involving multiple stacks, multiple counter registers, and equally to cyclic tag systems and cellular automata.', 559 => '', 560 => 'If I have somehow missed something in the spec, proving this false does not necessarily mean the language is TC. If there is a clever way to do the copy, I imagine it will require effectively placing an upper bound on the accumulator, and multiple unbounded stacks or accumulators cannot be simulated from a bounded one.', 561 => '', 562 => 'I believe this makes bitch a PDA, since one end of the accumulator can be used as a ''single'' stack, and transitions decision can be made based on that.', 563 => '', 564 => 'This talk page is getting hard to follow with many sections having questionable statements without attribution. Hopefully this bit copy challenge will be easier to address than a full TC proof. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:48, 7 May 2019 (UTC)', 565 => ': I didn't notice the implemented memory structure was supposed to be bitch because it has parentheses <code>()</code> to group operators (which AFAICT bitch lacks, and is the major hurdle to completing this challenge in pure bitch) and standard bit-shift operators <code><<</code> mixed in with bitch syntax. I am guessing that the intent was to precalculate all those values and substitute them into the bitch source as number literals? This is what I have noticed about all the examples given, and what this challenge is trying to prove: that binary operations cannot be done on two independent ''memory'' locations. It is easy to perform an operation with memory + number literal, but if you have to compute it all before hand and hardcode it into bitch, it's not bitch doing the computation, at least not in a way that is TC. I tried substituting values into that code and couldn't get it to work, can you? The form for this challenge will be something like <code>\[]/</code> where <code>[]</code> is replaced with a bitch algorithm of any size which copies the bit. If it is easy to do, then I have clearly misunderstood something about how the storage behaves and an example would clear up the confusion. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 12:08, 8 May 2019 (UTC)', 566 => '::In theory you can do any terminating amount of pre-computation "by hand" (which really means as part of compiling into your language). (From [[User_talk:Oerjan#Turing_completeness|Oerjan's user talk]]). --[[User:A|A]] ([[User talk:A|talk]]) 04:02, 9 May 2019 (UTC)', 567 => ': Copying a bit of a 3 bit accumulator can be achieved using the follwing piece of code: <code>&6]3|[2&1[3|]3&7</code> (which also keeps the storage unmodified). One key point here is that chained instructions work on a fresh copy of the state (both accumulator and storage), so <code>|[2</code> and similar instructions leave the storage unmodified.', 568 => ':: For the record: <code>^^]1]1^^[1[1</code> achieves the same copying task (copy second bit to first bit) for any number of bits, using the ^^ trick. Note that this approach specific to copying adjacent bits; copying to a non-adjacent location is harder. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:28, 10 May 2019 (UTC)', 569 => ': More generally, any map with finite domain (old accumulator value to new accumulator value) can be implemented, as for example the ROT13 program on the main page. I don't see how to copy a bit in an unbounded accumulator though, so none of this really brings us any closer to TC-ness. This should be enough to show that bitch can simulate arbitrary PDAs though. For processing input, note that one ''should'' be able to read from input without destroying the storage using <code>&0|\</code>, but the Java interpreter doesn't really support this because each instance of Program creates its own new Scanner that reads a whole line of input... [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 05:43, 9 May 2019 (UTC)', 570 => ':: The algorithm is right there! For larger sizes, the shifts have to be adapted as well: <code>&14]4|[3&1[4|]4&15</code>. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:07, 9 May 2019 (UTC)', 571 => '', 572 => ':: Congratulations! This is a valid solution to the challenge as I stated it. I was surprised it works, but I can now see how, which is a welcome outcome. I think knowing the conditions under which this is possible is helpful too. Like I guessed it places bounds on the storage, and proves the language is at least computationally equivalent to a PDA. Perhaps there is a way to break though this limitation, but it makes the next steps clearer, and provides a clear example of a useful programming technique. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 00:03, 10 May 2019 (UTC)', 573 => '', 574 => '<b>This conjecture is disproven by the old alternative memory structures section as I understand it.</b><br>', 575 => 'The variables there are simply the number of cells, the size of the cells and the cell to access.<br>', 576 => 'The number of cells and size of cells is simply for customizability and would be fixed by the programmer to a value of their choosing for the entire program (e.g.: 20 and 8).<br>', 577 => 'The position variable is simply the position at which the cell is that you want to access.<br>', 578 => 'The expressions given are simply the values needed to move and zero parts of the accumulator as necessary, they work with any values.', 579 => '', 580 => 'Binary operations on two different locations are very possible and they are the only reason for chaining operators.<br>', 581 => 'The code snippet <code>&[8</code> will AND two different values given that they are both 8 bits wide and in the accumulator together, one on top of the other.', 582 => '', 583 => 'The tape memory structure doesn't rely on precomputing, it allows for different sized tapes and different sized cells for customizability.<br>', 584 => 'The values for the tape code are no less arbitrary than the value 8 in the above code. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 19:23, 9 May 2019 (UTC)', 585 => ': I seem to have reinvented parts of the "alternative memory structures" section below for GET and PUT, though as far as I can see the main contribution, random access, is new. I don't know why [[User:A|A]] deleted that section... [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 21:10, 9 May 2019 (UTC)', 586 => ': I tried to use your cell based memory structure early on but couldn't get it to work, here is a worked example of what I get:', 587 => ': With 3 bit memory, each cell is 1 bit, and the task is to copy cell 1 to the accumulator (which is slightly different from my challenge, but probably equivalent given some more steps), my abc is 012 in this structure.', 588 => ':* a = 3 (memory size)', 589 => ':* p = 1 (target cell, 0-indexed)', 590 => ':*n = 1 (cell width)', 591 => '', 592 => ':Loading a value from a cell formula, substituting using the values above: <code>|[3&4|]1</code>', 593 => '', 594 => ':I understand that this requires the memory to already be in the storage section, so if I pre-load the storage to 0b010 using <code>#2]3</code>, I would expect to get 1 in the accumulator by running <code>#2]3|[3&4|]1</code>, but that results in 0 in the accumulator and 2 in storage. Trying it with storage initialised to 0b111 (7) results in 0b110 (6) in the accumulator and 0b111 (7) in storage. Perhaps the formulas don't work with a cell width of one, but I don't know under which conditions it does work. I don't think that section should be deleted, it's possible am missing something about how to use the structure properly, or that there is a tiny bug in one part of it that could be identified and fixed as a result of using it for a specific task. This challenge was an attempt to get clarity on how to use the theorised techniques to do a specific task that did not seem obviously trivial to me. I would love to see an working example of your cell-based memory structure applied to the task above, I did try but couldn't make it work. The addition example (I think that is yours too?) was great as I could easily verify it did exactly what it claimed, and then spend time trying to understand how. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 00:20, 10 May 2019 (UTC)', 595 => '', 596 => ':: Yeah sorry for the lack of any examples.', 597 => '', 598 => ':: Given your above values:', 599 => '::*a = 3 (memory size)', 600 => '::*n = 1 (cell width)', 601 => '::*p = 1 (target cell, 0-indexed)', 602 => '', 603 => ':: The following code snippet stores and retrieves 1 from the 2nd position (2 line &lt;pre&gt; tag meant I couldn't indent; anyone who can format well is free to do this over):', 604 => ':: <pre>#1|[1&2[3|2^2|]3]3&0|[3&2|]1&1/</pre>', 605 => '', 606 => ':: This is made up of two main segments:<br>', 607 => ':: <b>The storage segment</b>:', 608 => ':: <pre>|[1&2[3|2^2|]3]3&0</pre>', 609 => '', 610 => ':: <b>The retrieval segment</b>:', 611 => ':: <pre>|[3&2|]1&1</pre>', 612 => '', 613 => ':: Be aware that the TIO is currently not up to date and you'll need to use the interactive version or download the GitHub version.<br>', 614 => ':: Hopefully the TIO will be updated soon. - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:09, 11 May 2019 (UTC)', 615 => '', 616 => ':: The solution to the original problem (directly copied and evaluated) would be:', 617 => ':: <pre>]3|[3&2|]1&1|[0&1[3|1^1|]3]3&0[3</pre>', 618 => '', 619 => ':: Which can be shortened to:', 620 => ':: <pre>]3|[3&2|]1&1[3|1^1|]3&7</pre>', 621 => ':: - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:24, 11 May 2019 (UTC)', 622 => '', 623 => '::: Thanks [[User:Helen|Helen]], that example does indeed fulfil my challenge using your cell based memory structure, congratulations! I see now how it works, that the memory structure is good, and that you had figured out usable memory before I proposed my challenge. Apologies for doubting you!', 624 => '::: Bitshift operator precedence seems to come after arithmetic operators in most programming languages (C, python, js), so when I used that formula, copied directly from [[Bitch#Loading_the_value_of_a_cell]] section, <code>1<<2-1<<1 = 4</code> which is what I tried for "ANDing the cell that we want" is different from <code>(1<<2)-(1<<1) = 2</code>, which looks like what you intended in the example. That threw me early and I stopped digging deeper. If you don't mind, I'll try to follow the rest of the example and update your [[Bitch#Loading_the_value_of_a_cell]] section if I can make it clearer? [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 23:26, 20 May 2019 (UTC)', 625 => '', 626 => ':::: Yeah, go ahead! That's perfectly fine by me.<br>', 627 => ':::: I always mentally replace <code>1<<</code> with <code>2^</code> so order of operations is a bit messed up for me on that sorry.', 628 => '', 629 => ':::: Generally feel free to edit stuff as you wish. Go wild! - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 14:41, 27 May 2019 (UTC)', 630 => '', 631 => '= Sketch: A RAM Machine =', 632 => '', 633 => 'We sketch a bitch implementation of a machine with a 32 bit accumulator A (stored in bits 0..31 of the accumulator),', 634 => 'a 32 bit extended accumulator X (bits 32..63), optional quick-access registers, and up to 2^26 - 1 individually addressable words of RAM.', 635 => 'So even if bitch is not TC, it still appears to be a capable programming language. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:41, 9 May 2019 (UTC)', 636 => ':I've used this machinery to make a ''finite memory'' (so non-TC) Brainfuck interpreter; see https://github.com/int-e/bits/blob/master/examples/brainfuck.pp and the resulting https://github.com/int-e/bits/blob/master/examples/brainfuck (not thoroughly tested, may have bugs) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 22:47, 16 May 2019 (UTC)', 637 => ':In case other users get confused of how that preprocessor works, I clarify that the preprocessor takes input from the console and outputs the resulting bitch program. --[[User:A|A]] ([[User talk:A|talk]]) 12:10, 20 May 2019 (UTC)', 638 => '::<del>How is it supposed to work? (I have inputted a brainfuck program and could not get it to work...) Does it take a program from input or whatever?</del>', 639 => ':::<del>From the .pp file: "[The p]rogram is separated from input by an exclamation mark (!)." Both the program and all input are read from stdin. A possible pitfall is that the exclamation mark is obligatory. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:56, 17 May 2019 (UTC)</del>', 640 => '::I will be testing your implementation using <code>,[.-[-->++<]>+]</code>, which makes sure that a brainfuck interpreter supports all commands, nested loops, and unbounded memory. Testing halting is trivial...', 641 => ':::Although it is quite slow, the implementation is flawless. --[[User:A|A]] ([[User talk:A|talk]]) 06:51, 18 May 2019 (UTC)', 642 => '::::I've implemented a (hopefully not too buggy) bitch interpreter in C++ which is a bit faster (in the same github repo) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:24, 21 May 2019 (UTC)', 643 => '::I have an idea: you could extend the implementation to be unbounded by supplying tape extending operation, if this machinery supports extending the memory.', 644 => ':::First of all, extending memory after initialization is hard, perhaps even impossible, because the design is based on each memory cell containing its own address. (Without that stored address, `poke` doesn't work.) Shifting the existing memory would invalidate the addresses stored in that memory. Oh and I wouldn't know where to even begin doing such an extension without a loop.', 645 => ':::Note also that addresses are bounded. The current implementation uses 16 bit words, both for data and the addresses. Addresses need to be divisible by 32, so at most 2^11 - 1 = 2047 addressable memory cells are supported, and that's what the interpreter provides (minus memory used for stack, program, and registers).', 646 => ':::For the particular application as a Brainfuck interpreter, one could change the memory cell layout to use, for example, a 24 bit address and 8 bit data, increasing the address space to 2^19 - 1 = 512287 cells, but that's a non-trivial effort. An easier approach would be to set the word size to 32 bits (BB=5), with up to 2^27 addressable memory cells. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:56, 17 May 2019 (UTC)', 647 => '::::Can the word size be set dynamically? If that is a yes, bitch would be Turing-complete. --[[User:A|A]] ([[User talk:A|talk]]) 10:26, 22 May 2019 (UTC)', 648 => ':::::Not with this design; the word size is hardcoded in all of the building blocks (initialization, reading and writing registers, reading and writing memory, arithmetic). --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 11:17, 22 May 2019 (UTC)', 649 => '::<i>Wow</i>, the macro replacements can act as variables!!! See this program(which seems to be an abuse of this preprocessor):', 650 => '<pre>', 651 => 'A=1,', 652 => ',A,', 653 => 'A=2,', 654 => ',A,', 655 => '</pre>', 656 => '::This program prints <code>12</code>, which is 1 and 2 combined. This can demonstrate that the word sized can be set dynamically in the preliminary stage; however, there is currently no way to implement unbounded cells using this way.', 657 => '', 658 => 'This will not work if you want to extend the cell length though:', 659 => '<pre>', 660 => 'CNT=4,', 661 => 'BB=CNT,', 662 => 'CNT={BB+1},', 663 => 'BB=CNT,', 664 => ',BB,', 665 => '</pre>--[[User:A|A]] ([[User talk:A|talk]]) 13:04, 22 May 2019 (UTC)', 666 => '::I am aware about the loop limitations...the maximum 63 loop nesting would be enough, as two loop nestings are sufficient for Turing-completeness ( refer to [https://cs.stackexchange.com/questions/102363/how-many-pairs-of-brackets-are-sufficient-to-make-brainfuck-turing-complete/102500#102500 this page]). --[[User:A|A]] ([[User talk:A|talk]]) 14:35, 18 May 2019 (UTC)', 667 => ':::I meant bitch's limitation of not supporting any nested loops. But you have a point—the same machinery that supports the Brainfuck loops can also support nested loops in general. So the fixed, bounded address size is the real limitation here. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 13:03, 18 May 2019 (UTC)', 668 => '::Anyway, nice work!--[[User:A|A]] ([[User talk:A|talk]]) 13:47, 17 May 2019 (UTC)', 669 => '', 670 => 'A summary of the construction in this section has found its way to the [[Bitch#Bounded storage|bitch page]] (last week). Is there anything left here that is worth preserving? (I mean the construction itself, not the discussion thereof.) --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 08:09, 27 May 2019 (UTC)', 671 => '', 672 => '=== Memory ===', 673 => '', 674 => 'The storage is used for memory. Addresses are 32 bits, the lowest 6 of', 675 => 'which are always 0. Each word occupies 64 bits in memory that store the', 676 => 'address of the word and the word itself value.', 677 => '', 678 => 'The first few addresses may be used as additional registers instead,', 679 => 'at the programmer's discretion.', 680 => '', 681 => '=== Operations ===', 682 => '', 683 => 'None of these operations use > or <, so we can use them in loops.', 684 => '', 685 => 'The operations are not clean for the ; conditional in the sense that', 686 => 'the accumulator may become 0 while an instruction is executed.', 687 => 'It should not be too difficult to accomplish that, with some extra care.', 688 => '(The motivation would be that operations that are clean for ; can be', 689 => 'used as part of a state machine that manages the control flow.)', 690 => '', 691 => '* load immediate n (clears X):', 692 => '', 693 => ' IMM n := ^^n', 694 => '', 695 => '* 32 bit decrement (assumes X = 0):', 696 => '', 697 => ' DEC :=', 698 => ' ]32^1', 699 => ' [32^]32]32&[32', 700 => ' [31^]31]31&[31', 701 => ' ...', 702 => ' [2^]2]2&[2', 703 => ' [1^]1]1&[1', 704 => ' &0[32', 705 => '', 706 => '* 32 bit increment (assumes X = 0):', 707 => '', 708 => ' INC :=', 709 => ' ~]32&0[32', 710 => ' DEC32', 711 => ' ~]32&0[32', 712 => '', 713 => '* load a register (assumes X = 0, n divisible by 32):', 714 => '', 715 => ' GET n := ^^[n]32&0[32', 716 => '', 717 => '* store a register (assumes X = 0, n divisible by 32):', 718 => '', 719 => ' PUT n := [n&-4294967296|]n]n', 720 => '', 721 => '* read a word at address in accumulator:', 722 => '', 723 => ' # comment format: # accumulator | reverse storage', 724 => ' PEEK := # A | ... A W ...', 725 => ' ^^[^32 # A ... A W | ... A W ...', 726 => ' ]32&0[32 # W | ... A W ...', 727 => '', 728 => '* store word at address (<2^32 - 8) in accumulator, with value given in upper 32 bit of (extended) accumulator:', 729 => '', 730 => ' # comment format: # accumulator | reverse storage', 731 => ' POKE := # X A | ... A W (A+64) ...', 732 => ' [&4294967295 # X A ... A | W (A+64) ...', 733 => ' [32 # X A ... A W | (A+64) ...', 734 => ' &-4294967296 # X A ... A 0 | (A+64) ...', 735 => ' ^^[32 # X A ... A 0 (A+64) | (A+64) ...', 736 => ' ^]&4294967295 # X A ... A X ?? | (A+64) ...', 737 => ' ^^]32 # X A ... A X | (A+64) ...', 738 => ' ]32 # X A ... A | X (A+64) ...', 739 => ' ]&4294967295 # X A | ... A X (A+64) ...', 740 => '', 741 => '* load extended part of accumulator (n divisible by 32) for stores:', 742 => '', 743 => ' GETX n :=', 744 => ' ]32', 745 => ' GET (n+32)', 746 => ' [32', 747 => '', 748 => '* clear extended accumulator:', 749 => '', 750 => ' CLEARX := &4294967295', 751 => '', 752 => '* arithmetic with extended accumulator:', 753 => '', 754 => ' XOR := ^]32', 755 => ' AND := &]32', 756 => ' OR := |]32', 757 => ' NOT := ]32~]32~[64', 758 => '', 759 => '* initialize memory (only needed once, at the start of the program, so using > < ; is okay):', 760 => '', 761 => ' INIT :=', 762 => ' >DEC&-64]64|[64;<[64', 763 => '', 764 => '<!--* clear storage (not useful for the RAM machine but perhaps in other contexts):', 765 => ' CLS := #]0 or #[0 or #|0-->', 766 => '', 767 => '<!--* input without destroying the storage (does not work in the reference interpreter):', 768 => ' INP := &0|\-->', 769 => '', 770 => '* Bitwise right shift accumulator A:', 771 => ' RSH n := ^^]n', 772 => '', 773 => '* Bitwise left shift accumulator A:', 774 => ' LSH n := ^^[n', 775 => '', 776 => '* Swap the two accumulators:', 777 => ' XCHG := ^]32^[32^]32', 778 => '', 779 => '<!--* No operation:', 780 => ' NOP := |0 or [0 or ]0 or-->', 781 => '', 782 => '<!--* Halt:', 783 => ' HLT := .-->', 784 => '<hr>', 785 => ':Here are some extra instructions I find in Assembly language that might improve the usability of the instruction set(some are very trivial): ', 786 => '', 787 => ':* Shifting operations (cyclic left shift, cyclic right shift) --[[User:A|A]] ([[User talk:A|talk]]) 08:04, 12 May 2019 (UTC)', 788 => '', 789 => ':I have a question about the IMM instruction. Couldn't you directly use <code>^x</code>(which works) instead of <code>^^x</code>? --[[User:A|A]] ([[User talk:A|talk]]) 10:19, 10 May 2019 (UTC)', 790 => '::The point is that <code>^^n</code> sets the accumulator to n independently of the previous value of the accumulator. You could achieve the same effect with <code>&0^n</code>, but that would be one more character. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 14:06, 10 May 2019 (UTC)', 791 => ':::<del>I think I don't understand the <code>[n^]n]n&[n</code> operations in the decrement implementation. I believe it does carrying, but I can't understand how it achives it. {{unsigned|14:49, 10 May 2019 UTC|A}}</del>', 792 => '', 793 => '::::<del>Have you tried working out a small example, say a 4 bit decrement starting from 12 = 1100b? [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 17:20, 10 May 2019 (UTC)</del>', 794 => '', 795 => ':::::<del>Oh right. Sorry. --[[User:A|A]] ([[User talk:A|talk]]) 01:14, 11 May 2019 (UTC)</del>', 796 => '', 797 => '= Sketch: A Stack Machine =', 798 => 'We sketch another machine with an accumulator (with 64 bits) and a stack(preserved in the storage).<br>', 799 => 'This machine simulation in [[bitch]] is created merely to extend the power of bitch programs.<br>', 800 => 'Note: If mixing this stack machine with the RAM machine above is neccesary, the two accumulators must be preserved somewhere inside the storage before using the commands.--[[User:A|A]] ([[User talk:A|talk]]) 11:54, 13 May 2019 (UTC)', 801 => '=== Memory ===', 802 => 'The memory is just an accumulator (stored in the bitch accumulator) and an unbounded stack (stored in the accumulator storage).', 803 => '=== Operations ===', 804 => 'All of the commands do not use loops.', 805 => '* Duplicate the top of the stack', 806 => '<pre>DUP := ^^[32]32</pre>', 807 => '* Push a number onto the stack', 808 => '<pre>PUSH x := ^^x]32</pre>', 809 => '* Pop a number', 810 => '<pre>POP := [32^^0</pre>', 811 => '* Pop a number, outputting it', 812 => '<pre>POPOUT := [32/^^0</pre>', 813 => '* Swap the top 2 elements of the stack', 814 => '<pre>SWP := [64^]32^[32^]32]64</pre>', 815 => '* Push input', 816 => '<pre>PUSHI := &0|\]32</pre>', 817 => '* Increment top of stack', 818 => '<pre>INC := ', 819 => ' [32~]32&0[32', 820 => ' DEC', 821 => ' ~]32&0</pre>', 822 => '* Decrement top of stack', 823 => '<pre>DEC :=', 824 => ' ^1', 825 => ' [32^]32]32&[32', 826 => ' [31^]31]31&[31', 827 => ' ...', 828 => ' [2^]2]2&[2', 829 => ' [1^]1]1&[1', 830 => ' &0</pre>', 831 => '* Check whether two top-of-stacks are equivalent', 832 => '<pre>CHK := ^^[32^[64]32</pre>', 833 => '* Check if top of stack > the second top of stack', 834 => '* Check if top of stack < the second top of stack', 835 => '* Implementation of +, -, *, /, modulo, etc (impossible? *, /, and modulo possibly requires nested loops)', 836 => '* Reverse the stack (impossible?)', 837 => '', 838 => '= Page content deletions =', 839 => '', 840 => 'I'd like to point out that with MediaWiki's awful default diff, there's hardly anything ''worse'' for following talk page changes than deleting content. Also deleting other people's talk page contributions, or even your own after others have responded to them, is generally considered inappropriate, except on your own personal talk page.', 841 => '', 842 => 'We generally approximate Wikipedia policy here when we don't have a specific different tradition, so I'd sum up my understanding of what is done there: The recommended way to delete content from talk pages that are too big is to only ''move full sections'' to an archive subpage (like Talk:Bitch/Archive 1), and only when there has been no discussion in that section for a reasonably long time (which might depend on how fast discussion is happening).', 843 => '', 844 => '--[[User:Oerjan|Ørjan]] ([[User talk:Oerjan|talk]]) 00:38, 10 May 2019 (UTC)', 845 => ':Sorry, I read that [[User:Salpynx|Salpynx]] noted that this page is too hard to follow, so I removed some of the content. --[[User:A|A]] ([[User talk:A|talk]]) 11:33, 10 May 2019 (UTC)', 846 => '<!--= An interesting discovery =', 847 => 'When [[bitch]]'s program counter reaches whitespace, it halts immediately, despite the fact that a command can be executed conditionally after <code>:</code>'s and <code>;</code>'s. Here is a modified [[Truth-machine]], with . replaced with whitespace: <code>\:/: &-2#1>/<</code> It will halt immediately if the input is 1, and it will print 0 if the input is 0. Same as:', 848 => '<pre>\:/:', 849 => '&-2#1>/<</pre>', 850 => 'and', 851 => '<pre>\:/: &-2#1>/<</pre>', 852 => 'Note that they works in both interpreters.--[[User:A|A]] ([[User talk:A|talk]]) 06:53, 12 May 2019 (UTC)', 853 => '', 854 => ':This is semi-intentional in my interpreter.<br>', 855 => ':By default it ends the program if the next instruction is not valid code (although due to oversights this won't happen on nested instructions).<br>', 856 => ':However this is not part of the language specification (and I'd like to keep it that way) and therefore not really portable.', 857 => ':: This is definitely not portable at this point. My implementation treats <code>: </code> as an invalid instruction and stops parsing the program right there. Anything following an invalid instruction is ignored. [[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 20:02, 12 May 2019 (UTC)', 858 => ':Still a good discovery though, nice! - [[User:Helen|Helen]] ([[User talk:Helen|talk]]) 09:59, 12 May 2019 (UTC)-->', 859 => '= Sketch: A [[Turing machine|Turing Machine]] =', 860 => 'We can implement a Turing machine on a binary alphabet. The main challenge here is to implement bitwise boolean operations that keep (most of) the accumulator intact. It turns out that this isn't too hard if one pads the data with sufficiently many always-zero bits. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 20:53, 23 May 2019 (UTC)', 861 => '', 862 => ':Is the state represented using 1 bit? Also, what does k and q mean? (You don't have to explain the meaning of <code>k:l</code> and <code>r:q</code>; I know them.)--[[User:A|A]] ([[User talk:A|talk]]) 10:19, 24 May 2019 (UTC)', 863 => '::The state is represented by as many bits as needed for the given Turing machine (the second ''s'' in ''ss'' indicates a plural; this convention comes from Haskell...). ''k'' is an adjacent letter to ''l'' and ''q'' is adjacent to ''r''; I went down (in the alphabet --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:59, 25 May 2019 (UTC)) rather than up to avoid confusion with ''s''. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 12:00, 24 May 2019 (UTC)', 864 => ':I don't know how that can "avoid confusion". Hmm, l is directly adjacent to s, which might arise confusion: l could be considered part of the ''ss''. Also, you wrote <code>I went down rather than up to avoid confusion with ''s''.</code>; what does ''<code>I</code>'' mean? I did not find ''<code>I</code>'' anywhere in this sketch.', 865 => '', 866 => '::The alphabet (adjacent letters represent adjacent bits). And "I": a name I call myself. [[User:Salpynx|Salpynx]] ([[User talk:Salpynx|talk]]) 08:37, 25 May 2019 (UTC)', 867 => '', 868 => 'The contents of this section has moved [[Bitch#A Turing machine|here]]. --[[User:Int-e|Int-e]] ([[User talk:Int-e|talk]]) 07:43, 27 May 2019 (UTC)' ]
Unix timestamp of change (timestamp)
1657966875