CounterScript: Difference between revisions

From BusyBeaverWiki
Jump to navigation Jump to search
Azerty (talk | contribs)
Added more lower bounds.
Azerty (talk | contribs)
→Cryptids: Added cryptid analysis
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''CounterScript''' is a minimal counter-based programming language designed for '''Busy Beaver–style program enumeration and analysis'''.
'''CounterScript''' is a [[Turing-complete]] minimal counter-based esolang. It was created in 2026 by [[User:Azerty|Azerty]] specifically for program enumeration and analysis. CS features a very small instruction set operating over an unbounded set of nonnegative integer variables (''counters''). What make this esolang interesting is that it takes longer programs to compute chaotic/spaghetti functions, compared to [[Turing machine|Turing machines]].


It features a very small instruction set operating over an unbounded set of nonnegative integer variables (''counters'').
'''BBCS'''(n) is the Busy Beaver function for CounterScript programs.
 
'''BBCS'''(n) is the Busy Beaver function for '''CounterScript''' programs.


= Definition =
= Definition =
Line 14: Line 12:
All counters are initialized to <code>0</code> and can grow without bound.
All counters are initialized to <code>0</code> and can grow without bound.


The model is closely related to '''Minsky register machines,''' '''Fractran''' and '''Brainfuck''', and is therefore [[Turing-complete]].
The model is closely related to '''[[Register machine|register machines]],''' '''[[Fractran|FRACTRAN]]''' and '''[[brainfuck]]'''. It can simulate [[Boolfuck]], and is therefore Turing-complete.


== Instructions ==
== Instructions ==
Line 25: Line 23:
|-
|-
|Increment
|Increment
|<code>A++</code>
|<code>A++;</code>
|Increment counter A by 1
|Increment counter A by 1
|-
|-
|Decrement
|Decrement
|<code>A--</code>
|<code>A--;</code>
|Decrement counter A by 1 if A > 0
|Decrement counter A by 1 if A > 0
|-
|-
|While loop
|While loop
|<code>while A {...}</code>
|<code>while A {...}</code>
|Executes the loop body while <code>x > 0</code>
|Executes the loop body while <code>A > 0</code>
|}
|}


== BBCS ==
== Macros ==
<div class="toccolours mw-collapsible">
In order to improve readability we define the following macros.
{| class="wikitable"
!
!Macro
!Definition
!Size
!Function
|-
|Constant Addition
|<code>A+=n;</code>
|increment <code>A</code> by <code>n</code>
|<code>n</code>
|<code>A++; repeated n times</code>
|-
|Transfer
|<code>A>>B*n;</code>
|increment <code>B</code> by <code>A*n</code> then set <code>A</code> to 0
|<code>n+2</code>
|<code>while A {A--; (B++; repeated n times)}</code>
|}
 
== Champions ==
The Busy Beaver function for CounterScript, denoted '''BBCS(n)''', returns the largest score a CounterScript program of length ''n'' can have when halting.
The Busy Beaver function for CounterScript, denoted '''BBCS(n)''', returns the largest score a CounterScript program of length ''n'' can have when halting.


Line 50: Line 69:
!BBCS(n)
!BBCS(n)
!Champion
!Champion
!Counters upon halting
|-
|-
|1
|1
|1
|1
|<code>A++;</code>
|<code>A++;</code>
|<code>1</code>
|-
|-
|2
|2
|2
|2
|<code>A++; A++;</code>
|<code>A+=2;</code>
|<code>2</code>
|-
|-
|3
|3
|3
|3
|<code>A++; A++; A++;</code>
|<code>A+=3;</code>
|<code>3</code>
|-
|-
|4
|4
|4
|4
|<code>A++; A++; A++; A++;</code>
|<code>A+=4;</code>
|<code>4</code>
|-
|-
|5
|5
|5
|5
|<code>A++; A++; A++; A++; A++;</code>
|<code>A+=5;</code>
|<code>5</code>
|-
|-
|6
|6
|6
|6
|<code>A++; A++; A++; A++; A++; A++;</code>
|<code>A+=6;</code>
|<code>6</code>
|-
|-
|7
|7
|7
|7
|<code>A++; A++; A++; A++; A++; A++; A++;</code>
|<code>A+=7;</code>
|<code>7</code>
|-
|-
|8
|8
|9
|9
|<code>A++; A++; A++; while A {A--; B++; B++; B++;}</code>
|<code>A+=3; A>>B*3;</code>
|<code>0 9</code>
|-
|-
|9
|9
|12
|12
|<code>A++; A++; A++; A++; while A {A--; B++; B++; B++;}</code>
|<code>A+=4; A>>B*3;</code>
|<code>0 12</code>
|-
|-
|10
|10
|16
|16
|<code>A++; A++; A++; A++; while A {A--; B++; B++; B++; B++;}</code>
|<code>A+=4; A>>B*4;</code>
|<code>0 16</code>
|-
|-
|11
|11
|≥ 20
|20
|<code>A++; A++; A++; A++; A++; while A {A--; B++; B++; B++; B++;}</code>
|<code>A+=5; A>>B*4;</code>
|<code>0 20</code>
|-
|-
|12
|12
|≥ 25
|≥ 25
|<code>A++; A++; A++; A++; A++; while A {A--; B++; B++; B++; B++; B++;}</code>
|<code>A+=5; A>>B*5;</code>
|<code>0 25</code>
|-
|-
|13
|13
|≥ 30
|≥ 42
|<code>A++; A++; A++; A++; A++; A++; while A {A--; B++; B++; B++; B++; B++;}</code>
|<code>A++; while A {A++; while B {A--; B--; C+=2;} C>>B*2; C++;}</code>
|<code>0 42 1</code>
|-
|-
|14
|14
|≥ 84
|≥ 129
|<code><nowiki>A++; A++; A++; while A {A--; B++; while B {B--; C++; C++;} while C {C--; B++; B++;}}</nowiki></code>
|<code>A++; while A {A++; while B {A--; B--; C+=2;} C>>B*3; C++;}</code>
|<code>0 129 1</code>
|-
|-
|15
|15
|≥ 340
|≥ 340
|<code><nowiki>A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; C++;} while C {C--; B++; B++;}}</nowiki></code>
|<code>A+=4; while A {A--; B++; B>>C*2; C>>B*2;}</code>
|<code>0 340 0</code>
|-
|-
|16
|16
|≥ 1,554
|≥ 1,554
|<code><nowiki>A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; C++; C++;} while C {C--; B++; B++;}}</nowiki></code>
|<code>A+=4; while A {A--; B++; B>>C*3; C>>B*2;}</code>
|<code>0 1554 0</code>
|-
|-
|17
|17
|≥ 9,330
|≥ 9,330
|<code><nowiki>A++; A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; C++; C++;} while C {C--; B++; B++;}}</nowiki></code>
|<code>A+=5; while A {A--; B++; B>>C*3; C>>B*2;}</code>
|<code>0 9330 0</code>
|-
|-
|18
|18
|≥ 66,429
|≥ 66,429
|<code><nowiki>A++; A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; C++; C++;} while C {C--; B++; B++; B++;}}</nowiki></code>
|<code>A+=5; while A {A--; B++; B>>C*3; C>>B*3;}</code>
|<code>0 66429 0</code>
|-
|-
|19
|19
|≥ 597,870
|≥ (3^122 - 3)/2
|<code><nowiki>A++; A++; A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; C++; C++;} while C {C--; B++; B++; B++;}}</nowiki></code>
|<code>A++; while A {A++; while B {A--; B--; C++;} while C {B++; C--; B>>D*3; D>>B;} C++;}</code>
|<code>0 (3^122-3)/2 1</code>
|-
|-
|20
|20
|≥ 4^1365
|≥ 2^65536 - 2
|<code><nowiki>A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; D++;} while D {D--; C++; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A+=4; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}</code>
|<code>0 2^65536-2 0 0</code>
|-
|-
|21
|21
|≥ 4^4^1365
|≥ 2^2^65536 - 2
|<code><nowiki>A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; D++;} while D {D--; C++; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A+=5; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}</code>
|<code>0 2^2^65536-2 0 0</code>
|-
|-
|22
|22
|≥ 4^4^4^1365
|≥ 2^^7 - 2
|<code><nowiki>A++; A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; D++;} while D {D--; C++; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A+=6; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}</code>
|<code>0 2^^7-2 0 0</code>
|-
|-
|23
|23
|≥ 4^4^4^4^1365
|≥ 2^^8 - 2
|<code><nowiki>A++; A++; A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; D++;} while D {D--; C++; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A+=7; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}</code>
|<code>0 2^^8-2 0 0</code>
|-
|-
|24
|24
|≥ 4^4^4^4^4^1365
|≥ 2^^65536 - 2
|<code><nowiki>A++; A++; A++; A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; D++;} while D {D--; C++; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A++; while A {A++; while B {A--; B--; C++;} while C {B++; C--; while B {B--; D++; D>>E*2; E>>D;} D>>B;} C++;}</code>
|
|-
|-
|25
|25
|≥ 2^^2^15
|> 2^^2^^6
|<code><nowiki>A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; while D {D--; E++; E++;} while E {E--; D++;}} while D {D--; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A++; while A {A++; while B {A--; B--; C+=2;} while C {B++; C--; while B {B--; D++; D>>E*2; E>>D;} D>>B;} C++;}</code>
|
|-
|-
|26
|26
|≥ 2^^2^^2^15
|≥ 2^^2^^65536 - 2
|<code><nowiki>A++; A++; A++; A++; while A {A--; B++; while B {B--; C++; while C {C--; D++; while D {D--; E++; E++;} while E {E--; D++;}} while D {D--; C++;}} while C {C--; B++;}}</nowiki></code>
|<code>A+=4; while A {A--; B++; while B {B--; C++; while C {C--; D++; D>>E*2; E>>D;} D>>C;} C>>B;}</code>
|<code>0 2^^2^^65536-2 0 0 0</code>
|-
|-
|65
|64
|> Graham's number
|> Graham's number
|too large to show, see [https://discord.com/channels/960643023006490684/1484108791636033659/1509179336136327310 Discord]
|
|-
|85
|> q(5) (if extant)
|too large to show, see [https://discord.com/channels/960643023006490684/1484108791636033659/1514987825127358615 Discord]
|
|
|}
|}


== Cryptids ==
== Cryptids ==
TODO
No cryptids have been found through exhaustive search of a domain. The smallest known cryptid, a Hydra variant, is of length 23.<syntaxhighlight line="1">
</div>
A++; B++; while B {
  while A {
    A--; C++; E++;
    while D {D--; E--;}
    while E {C++; D++; E--;}
  }
  C>>A; D>>B*3; B--;
}


// start -> (1, 1)
// (2a, b+1) -> (3a, b)
// (2a+1, b) -> (3a+2, b+2)
// (a, 0) -> halt
</syntaxhighlight>
[[Category:Functions]]
[[Category:Functions]]

Latest revision as of 08:47, 11 August 2026

CounterScript is a Turing-complete minimal counter-based esolang. It was created in 2026 by Azerty specifically for program enumeration and analysis. CS features a very small instruction set operating over an unbounded set of nonnegative integer variables (counters). What make this esolang interesting is that it takes longer programs to compute chaotic/spaghetti functions, compared to Turing machines.

BBCS(n) is the Busy Beaver function for CounterScript programs.

Definition

A CounterScript program consists of a finite sequence of instructions drawn from three primitives:

  • Increment a counter
  • Conditional decrement
  • While loop

All counters are initialized to 0 and can grow without bound.

The model is closely related to register machines, FRACTRAN and brainfuck. It can simulate Boolfuck, and is therefore Turing-complete.

Instructions

Instructions are executed one by one from left to right.

Name Command Definition
Increment A++; Increment counter A by 1
Decrement A--; Decrement counter A by 1 if A > 0
While loop while A {...} Executes the loop body while A > 0

Macros

In order to improve readability we define the following macros.

Macro Definition Size Function
Constant Addition A+=n; increment A by n n A++; repeated n times
Transfer A>>B*n; increment B by A*n then set A to 0 n+2 while A {A--; (B++; repeated n times)}

Champions

The Busy Beaver function for CounterScript, denoted BBCS(n), returns the largest score a CounterScript program of length n can have when halting.

The score of a program is the maximum value of its counters.

The length of a CounterScript program is defined as the total number of instructions.

By example, A++; B++; while A {A--; C++; C++;} has length 6 and its score is 2.

n BBCS(n) Champion Counters upon halting
1 1 A++; 1
2 2 A+=2; 2
3 3 A+=3; 3
4 4 A+=4; 4
5 5 A+=5; 5
6 6 A+=6; 6
7 7 A+=7; 7
8 9 A+=3; A>>B*3; 0 9
9 12 A+=4; A>>B*3; 0 12
10 16 A+=4; A>>B*4; 0 16
11 20 A+=5; A>>B*4; 0 20
12 ≥ 25 A+=5; A>>B*5; 0 25
13 ≥ 42 A++; while A {A++; while B {A--; B--; C+=2;} C>>B*2; C++;} 0 42 1
14 ≥ 129 A++; while A {A++; while B {A--; B--; C+=2;} C>>B*3; C++;} 0 129 1
15 ≥ 340 A+=4; while A {A--; B++; B>>C*2; C>>B*2;} 0 340 0
16 ≥ 1,554 A+=4; while A {A--; B++; B>>C*3; C>>B*2;} 0 1554 0
17 ≥ 9,330 A+=5; while A {A--; B++; B>>C*3; C>>B*2;} 0 9330 0
18 ≥ 66,429 A+=5; while A {A--; B++; B>>C*3; C>>B*3;} 0 66429 0
19 ≥ (3^122 - 3)/2 A++; while A {A++; while B {A--; B--; C++;} while C {B++; C--; B>>D*3; D>>B;} C++;} 0 (3^122-3)/2 1
20 ≥ 2^65536 - 2 A+=4; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;} 0 2^65536-2 0 0
21 ≥ 2^2^65536 - 2 A+=5; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;} 0 2^2^65536-2 0 0
22 ≥ 2^^7 - 2 A+=6; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;} 0 2^^7-2 0 0
23 ≥ 2^^8 - 2 A+=7; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;} 0 2^^8-2 0 0
24 ≥ 2^^65536 - 2 A++; while A {A++; while B {A--; B--; C++;} while C {B++; C--; while B {B--; D++; D>>E*2; E>>D;} D>>B;} C++;}
25 > 2^^2^^6 A++; while A {A++; while B {A--; B--; C+=2;} while C {B++; C--; while B {B--; D++; D>>E*2; E>>D;} D>>B;} C++;}
26 ≥ 2^^2^^65536 - 2 A+=4; while A {A--; B++; while B {B--; C++; while C {C--; D++; D>>E*2; E>>D;} D>>C;} C>>B;} 0 2^^2^^65536-2 0 0 0
64 > Graham's number too large to show, see Discord
85 > q(5) (if extant) too large to show, see Discord

Cryptids

No cryptids have been found through exhaustive search of a domain. The smallest known cryptid, a Hydra variant, is of length 23.

A++; B++; while B {
  while A {
    A--; C++; E++;
    while D {D--; E--;}
    while E {C++; D++; E--;}
  }
  C>>A; D>>B*3; B--;
}

// start -> (1, 1)
// (2a, b+1) -> (3a, b)
// (2a+1, b) -> (3a+2, b+2)
// (a, 0) -> halt