K Notation

K Notation is a notation defined using Python 3 by Googology User GoogolBoss.Mission: Infinity. K Notation. https://sites.google.com/view/mission-infinity/k-notation/k-notation. Retrieved 09/07/2022. It's defined by different parts:
*Part I - Simple K Notation
*Part II - Linear K Notation
The value of a K Notation expression is the output of the KSolve method (it may be either a natural or another expression).
K Notation is written in form \(\text{K#(b)}\) where # is an array while b is either a natural or anoter string in the form described here.
Simple K Notation rules:
K0(n) = n+1
Kx+1(n) = Kn+1 (where K0 = n and Kx+1 = Kx(Kx))
==Analysis==
According to GoogolBoss' analysis:
* Part I has strength \(f_\omega(n)\)
* Part II has strength \(f_{\omega^\omega}(n)\)
==Solving Script==
GoogolBoss provided a program that solves the notation step by step to help understanding it.
==Code ==
Part I code:
def KValid(text: str):
 if (text == ""):
 return False
 text = text.replace(" ", "")
 if (not text[0] == 'K'):
 return False
 return True
def KTCheck(text: str, ch: str):
 x = 0
 for c in text:
 if (c == ch):
 x += 1
 if (c == ch):
 x -= 1
 if x == 0:
 return True
 return False
def KTFind(text: str, i: int, ch: str):
 x = 0
 y = -1
 for c in text:
 y += 1
 if (c == ch):
 x += 1
 if (x == i):
 return y
 return -1
def KTFindEnd(text: str, i: int, ch: str):
 x = 0
 y = -1
 text = text[::-1]
 for c in text:
 y += 1
 if (c == ch):
 x += 1
 if (x == i):
 return len(text) - y - 1
 return -1
def KNest(text: str, rs: str, fs: str, t: int):
 if (t < 1):
 return text.replace(rs, fs)
 return text.replace(rs, KNest(text, rs, fs, t-1))
def KSolve(text: str):
 text = text.replace(" ", "")
 if (not KValid(text)):
 return text
 while (text[KTFind(text, 1, '(') + 1] == 'K'):
 subtext = text[KTFind(text, 1, '(') + 1:KTFindEnd(text, 1, ')')]
 text = text[0:KTFind(text, 1, '(') + 1] + KSolve(subtext) + text[KTFindEnd(text, 1, ')'):len(text)]
 return text
 inputn = int(text[KTFind(text, 1, '(') + 1:KTFindEnd(text, 1, ')')])
 if (inputn < 0):
 return text
 index = int(text[KTFind(text, 1, 'K') + 1:KTFindEnd(text, 1, '(')])
 if (index < 0):
 return text
 if (index == 0):
 return (inputn + 1).__str__()
 return KNest("K" + (index - 1).__str__() + "(_)", "_", inputn.__str__(), inputn)
Part II code:
def KValid(text: str):
 if (text == ""):
 return False
 text = text.replace(" ", "")
 if (not text[0] == 'K'):
 return False
 return True
def KTCheck(text: str, ch: str):
 for c in text:
 if (c == ch):
 return True
 return False
def KTFind(text: str, i: int, ch: str):
 if (i == 0):
 return -1
 x = 0
 y = -1
 for c in text:
 y += 1
 if (c == ch):
 x += 1
 if (x == i):
 return y
 return -1
def KTFindEnd(text: str, i: int, ch: str):
 if (i == 0):
 return len(text)
 x = 0
 y = -1
 text = text[::-1]
 for c in text:
 y += 1
 if (c == ch):
 x += 1
 if (x == i):
 return len(text) - y - 1
 return -1
def KNest(text: str, rs: str, fs: str, t: int):
 if (t < 1):
 return text.replace(rs, fs)
 return text.replace(rs, KNest(text, rs, fs, t-1))
def KOpt(text: str):
 if (KTCheck(text, ",")):
 if (int(text[KTFindEnd(text, 1, ",") + 1:len(text)]) == 0):
 text = KOpt(text[0:KTFindEnd(text, 1, ",")])
 return text
def KLim(text: str):
 if (KTCheck(text, ',')):
 return int(text[0:KTFind(text, 1, ',')]) == 0
 return int(text[0:len(text)]) == 0
def KPre(text: str):
 if (KTCheck(text, ',')):
 f = (int(text[0:KTFind(text, 1, ',')]) - 1).__str__()
 return f + text[KTFind(text, 1, ',')::1]
 f = (int(text[0:len(text)]) - 1).__str__()
 return f
def KDiag(text: str, number: int):
 i = 1
 while (int((text + ",")[KTFind(text, i, ',') + 1:KTFind(text, i + 1, ',')]) < 1):
 i += 1
 return text[0:KTFind(text, i - 1, ',') + 1] + number.__str__() + "," + (int((text + ",")[KTFind(text, i, ',') + 1:KTFind(text, i + 1, ',')]) - 1).__str__() + (text + ",")[KTFind(text, i + 1, ','):len(text)]
def KSolve(text: str):
 text = text.replace(" ", "")
 if (not KValid(text)):
 return text
 while (text[KTFind(text, 1, '(') + 1] == 'K'):
 subtext = text[KTFind(text, 1, '(') + 1:KTFindEnd(text, 1, ')')]
 text = text[0:KTFind(text, 1, '(') + 1] + KSolve(subtext) + text[KTFindEnd(text, 1, ')'):len(text)]
 return text
 inputn = int(text[KTFind(text, 1, '(') + 1:KTFindEnd(text, 1, ')')])
 if (inputn < 0):
 return text
 index = KOpt(text[KTFind(text, 1, 'K') + 1:KTFindEnd(text, 1, '(')])
 if (index == "0"):
 return (inputn + 1).__str__()
 if (not KLim(index)):
 return KNest("K" + KPre(index) + "(_)", "_", inputn.__str__(), inputn)
 
 return "K" + KOpt(KDiag(index, inputn)) + "(" + inputn.__str__() + ")"
==Examples==
K0(0) = 1
K1(4) = K0(K0(K0(K0(K0(4))))) = K0(K0(K0(K0(5)))) = K0(K0(K0(6))) = K0(K0(7)) = K0(8) = 9
K2(6) = K1(K1(K1(K1(K1(K1(K1(6))))))) = 895
K0,4(3) = K3,3(3) = K2,3(K2,3(K2,3(K2,3(3))))
K0,0,5,2(5) = K0,5,4,2(5) = K5,4,4,2(5) = K4,4,4,2(K4,4,4,2(K4,4,4,2(K4,4,4,2(K4,4,4,2(K4,4,4,2(5))))))
==Sources==
Category:Numbers and functions by GoogolBoss