# Clandestine Endorsement

Paradigm(s) Declarative User:Hakerh400 2023 Not applicable Implemented .txt

Clandestine Endorsement is an esolang invented by User:Hakerh400 in 2023.

## Overview

This language outputs the first ${\displaystyle n}$ digits of a specific infinite binary sequence ${\displaystyle L}$ define below.

Informally, the sequence ${\displaystyle L}$ is built up iteratively by trying to keep the equal distribution of all possible sublists. We start with the empty sequence and then we iteratively append bits so that the distribution of any possible sublist of length ${\displaystyle n}$ (for any ${\displaystyle n}$ smaller than the current length of the sequence) is as close to ${\displaystyle 2^{-n}}$ as possible. When in doubt, we append ${\displaystyle 0}$.

We start with the empty sequence and we append bit ${\displaystyle 0}$. Now, if we append ${\displaystyle 0}$, then ${\displaystyle 0}$ will appear two times, while ${\displaystyle 1}$ will not appear at all. On the other hand, if we append ${\displaystyle 1}$, then both ${\displaystyle 0}$ and ${\displaystyle 1}$ will appear once, which is exactly the distribution we want. Therefore we append ${\displaystyle 1}$ and now we have ${\displaystyle 01}$. The next bit is ${\displaystyle 0}$, because both ${\displaystyle 0}$ and ${\displaystyle 1}$ would give the same distribution "cost", so we choose ${\displaystyle 0}$. How exactly the distribution cost is calculated is explained below (the function ${\displaystyle R(l)}$).

The real number ${\displaystyle 0.L}$ in base ${\displaystyle 2}$ (sequence ${\displaystyle L}$ treated as binary digits) is probably a normal number, since the construction of ${\displaystyle L}$ literally tries to keep the distribution of every possible sublist as close to ${\displaystyle 2^{-n}}$ as possible.

## Definitions

A sequence of type ${\displaystyle T}$ is a function ${\displaystyle \alpha \mapsto T}$ where ${\displaystyle \alpha \leq \omega }$ is an ordinal that represents the length of the sequence and ${\displaystyle \omega }$ is the smallest transfinite ordinal. Sequence is finite iff ${\displaystyle \alpha <\omega }$.

A list is a finite sequence. Empty list is denoted by ${\displaystyle \epsilon }$. Length of a list ${\displaystyle l}$ is denoted by ${\displaystyle |l|}$. List concatenation is represented by ${\displaystyle +}$.

Every list is a sublist of itself. If list ${\displaystyle l_{1}}$ is a sublist of ${\displaystyle l}$, then ${\displaystyle l_{1}}$ is also a sublist of any list obtained by inserting one element to the beginning or end of ${\displaystyle l}$.

The set of all sequences of bits of length ${\displaystyle \alpha }$ is represented as ${\displaystyle \{0,1\}^{\alpha }}$.

Function ${\displaystyle C:\{0,1\}^{m}\times \{0,1\}^{n}\mapsto \mathbb {N} }$ for ${\displaystyle m,n\in \mathbb {N} }$, denoted as ${\displaystyle C(l_{1},l)}$, represents the number of sublists ${\displaystyle l_{1}}$ in ${\displaystyle l}$. For any list ${\displaystyle l}$, ${\displaystyle C(\epsilon ,l)=|l|+1}$ and ${\displaystyle C(l,l)=1}$.

Function ${\displaystyle R_{i}:\{0,1\}^{n}\mapsto \mathbb {R} }$ is defined for all ${\displaystyle i,n\in \mathbb {N} }$ as

${\displaystyle R_{i}(l)=\sum _{l_{1}\in \{0,1\}^{i}}\left|C(l_{1},l)-{\frac {n-i+1}{2^{i}}}\right|}$

Function ${\displaystyle R:\{0,1\}^{n}\mapsto \mathbb {R} }$ is defined for all ${\displaystyle n\in \mathbb {N} }$ as

${\displaystyle R(l)=\sum _{i=1}^{n-1}R_{i}(l)}$

Sequence ${\displaystyle L}$ is the infinite sequence of bits whose every finite prefix ${\displaystyle l+b}$, where ${\displaystyle b}$ is a single bit, has the property that

${\displaystyle b=\displaystyle {\begin{cases}0,&R(l+0)\leq R(l+1)\\1,&{\text{otherwise}}\end{cases}}}$

## Syntax

Source code consists of number ${\displaystyle n\in \mathbb {N} }$. There is no input. The output is the prefix ${\displaystyle l}$ of ${\displaystyle L}$ such that ${\displaystyle |l|=n}$.

## Example

Input: 1000

Output:

0101100111000101000011110101101110000100110100100011111001011101000001101100101011111000001011001100
0111011010011110001000101010011111101110010000001101010110000110010010111101101111000000100101001101
1111100110001001001110101000110101110111100000010101011010001110011111010000100011001101100011101001
0110110000011111110101000010111001001000011101100101001110001101110101111001000001011010100101011000
1000000011111111011001100111001010001011110100110000110111000100111101110100010000101011100001101001
1011010110010011111000110000000010111111010101001001100111100110101010100011101111100001000100101101
1011100111011000000111000101100011001011111010000010010001010010111111100110100001100011110110101110
1001000000011001010111101110011001000111100101010110110100010011101111111100001010000011000101101001
1000010011101110101001101100001111000111001000101110110101000000001000110111101011111011001001010100
0111110011100001011001101001010000111110111100100110001010110101100000111001111010001000110110111110


This represents the first thousand elements of sequence ${\displaystyle L}$.