PNPL

From Esolang
Jump to navigation Jump to search
Prime Number Programming Language
Paradigm(s) imperative
Designed by User:Henry
Appeared in 2025
Memory system Cell-based
Dimensions one-dimensional
Computational class Turing complete
Reference implementation PNPL
Influenced by Brainfuck
File extension(s) .p, .pp, .pn

Prime Number Programming Language (PNPL) is a Brainfuck-equivalent esoteric language that revolves around prime numbers and the uniqueness of their products.

Language Overview

In PNPL, all valid programs are natural numbers, whose behavior is determined by the fundamental theorem of arithmetic (FTA henceforth).

Recall that, because of FTA, every positive integer can be expressed as a singular product of distinct prime numbers raised to integer exponents; since the set of prime numbers is totally ordered, the first prime in its factorization denotes the first instruction, and its exponent the operation to be performed.

There are a total of 8 possible commands in PNPL; therefore, any correct PNPL program is of the form

Command List

PNPL's operations have been deliberately chosen in order to be computationally equivalent to Brainfuck:

Exponent Brainfuck cognate Description
0 Do nothing.
1 > Moves the memory pointer to the right.
2 < Moves the memory pointer to the left.
3 + Increases the memory cell at the pointer by one.
4 - Decreases the memory cell at the pointer by one.
5 [ Jumps past the matching loop ending (exponent 6) if the cell at the pointer is 0.
6 ] Jumps back to the matching loop start (exponent 5) if the cell at the pointer is nonzero.
7 , Inputs a character and stores it in the cell at the pointer.
8 . Outputs the character encoded by the cell at the pointer.

The isomorphism between Brainfuck and PNPL programs directly implies the Turing completeness of the latter.

Example Programs

Because of the parallelism described above, translating Brainfuck programs directly to PNPL turns out to be fairly straightforward. Thus, below are listed a few of these compilations:

Hello World!

This program outputs "Hello World!":

95574716920541832711315723394931296401531143389924142594357030810143074319957591795873835084110687899409148334860835555928926963361037250427532689404617010732769843187181412968039323815090096635440236701815872402872904961774345101433170959211832869157070111419701571088969524850767897304348184334738612492361619826757728784471440655921493306156603783042956385512946180770877459482382468696555148640620583270708667115450227262107040704978879636851649993189261392334043574747899797187517995282402994635658233535137644324695276372288061089816312011818008673505642493061939693073647869629408216864965878004751344904297999391321302381304099216816838888546224473686274373001206571569503980258001292572336432089484558547675224258905755923015195681797215859058388406776381551085290092888611282556437111775709776555933637685143245211853765552812520529445826378119059680519185528887493520643348046298921540131046257465436245645773642461000

Square Numbers

This one outputs the square numbers from 0 to 10000, converted from Daniel B Cristofani (cristofdathevanetdotcom)'s program:

2858413457867639962590880946167285114362437318190931299382164515883855457629029246314726234235269352760594492871993359866092344797253918651275424053200660759062941830829295482950331666615336607156650878653579924180603758380335175940467638471668935425337032377732698017598402227890261769533023500360263526767416836979065323345602845163706860067542240439593168040573548082902634760009572498484256013796571612037247449429026763068146483673244447467356006669193099507548921282974271809830670928621188786931710806140446119912992465877290424799514237476019816803619653353737663727266407457050121746592920671333998575595505516662692607445348069621666361467962513852897568926365940335685827218164934141958878313435723024542817961306391369229528292446499869426176390177825610979438515013687714780855910286193956667840433790017272118054737883123515032093245140448277644850738029992671860669016060973094490510813669819336061255375406576052381199803204950485567655002512254333847438549802081104081546479898832262543229262323350717110211860966201919924168561314422108228659586555288426386883279116520781080781672547807176636358276742944927116844641817246986609145829239243156760418829169068105839227394764541228956054894714254476948936124992039902476674672942781267534694512174072769726152795557031119681077378174532484367113350840001323730641520690391234134533947612272132513152813890372610355685944723063069001239519633871219274202724159884245328263140275270682655186310771957881335123195115602099264886941789222399361221453020733862729000

Pi Calculation

Finally, Felix Nawothnig's (felix.nawothnig@t-online.de) yapi.b has been translated as well, yielding the following code:

191559382959407342500495009685907244171541171242769034129550873488197726633687781852395630715824995378665087118018843051761477826872561988463237601558116724563018022141161610558699480416985767800652444489505462056559616343190832406876113141740625670650836409875208679794947956011769568426567225765159293343267481572318502483597717328275230470333130498483414594452884641679155795466275412279131970624933578230564786524656651366301524028266507551836940255045146880141851893274960568977790792849672811854250309863595908297643970561504360095438512761624185717139147087601667013902287452614493825782878322189720526100229566804081625413487753971921809608511789576350684697210432246768179044389145341537010365476491097531649736267341820383412154741282342089601915503332661377325861185625756378975704060576668775035819890362972137204642733794357798729168442940739383959587920202862866367229102619344019293227495477671525667097840940660888437068819344711304984832599389000701645423334077282888167108759778618108148192892390966663690614641130032842191693565856676035089754754537312318713304371275663990411718292188187899096375457416669686430656834510231054393238090916881309029415687977647447322430998643076910281525395501523924048709649389820167876201524081522221828245110596864956777821850033974953767975146784013462783042235188959393134159943909886941156200880260561751411116129398708699125175843604891929552750024189586208252021294503957590486773010014948524774006576376645931027761362587689802498064867923315702041072108632714361660959798559678814176016874672412826354081756394828901355982033118773784270239161264837462793132740031771449383592801508505277974902198191450447867677267258272534106318823474938013615692381554657822157636922359114172611055428644060374714806453326453618762415454920327527945388369331294822262596029890984829899557164302614851958344464014988025843722206116899024985209410569269332640466303323621297057061594214450941932593774233982128880340619649508018319382649402995412425837107545311705093616196469774296642559618912104868012351662223394105498026695396434041705542685429879038184218256548973329634268094483229202631472284410541962230568844047153575272736367904236858352128089969488984482764199571291997226678303790092314998487733451786635114146398924762954548513879490757119595332096649054628917286515574868101671974979418085083414457196266836659906190427005205686080139754108534698451425206866242287670630135194548871030565133286496689006036462593585527839451851244466012284228897957945886690451512651447697391053046122918138504749372661915362358874211013983685860104518314041792805238224887818443996541126624019849068419184978476299991716935076857099960755894877864541137630323757634091220215648311052523015388342705235777664214267303667958232472821803531608264372783383264178391302133353654246789976011457892465490912679307860165973866672223687819176002107266946680854201180935158604696952881024292873370334944424611752544091820262805549353061488437786616160391082751458038637845185123725954067711178057045917447079950688273860975426720818084121064984073358710862092151076822731569667591899511915882565103874514838066616775633984609440131582165615771709963661198841120913483429539011385002561898596157783629682399450811783253551334774523370700326611826376684953751416386655559843382421632482638166380741424259192465949233601356729581767647793837115807238360153615179540574316352880160360564856939037134502180892618053891484453182598340712274360928146554143834288379226811967373051329333593115376831164081326783472054440656732872226823269999436284738589629197366721095478882603520741018878012901899350433864401708805560516909906002563488592859054267309197264863436279011352168870799974550700331052185296723014084451927897124018751783299027179683821233049257688293461866363784880290496846305971942805016460550224803364049270380394192213628302096653631109600829688386427984812919412266423384149871759669980209992624974379463268203597558996526349195481878717116469555344127076247178918173683290988742889007297288728425487333765914218690503400972761928408390649304676382279071152330784219145608351727450267422334074696396137252982959130282746852051663722075952326099271124503256401307298365159436807586882435881549000295311730295080843677422493366265101260576281535466720300008049900189268523662222751258015306512911777885652748136323590723031969095814841001946491538248149718395726255275724532132629681578390549513452358182816129716021412902880977781832433430878168134375931478476561701161546059294690417940974587129510790592756055514386982544477042546337911829835329074708020996103182620186200413208622708414884209102348152247603089450214181103659390328652748839471061623722780868459993284686046328800872856944249686609268927878709635414010989350540291991013251032487597286330213994757048533681977280973109711089279880486805451743728452459321654394579846092640533310893391748670058191132624943632602306518460319363262280850173573729523760129608823664532676220595985690892786368991168565103142631900286872568635698276079231718636583959748828289781198598782266908947839098513131788407053785048720212001081409355795084173223708611011644993536774773186255792160588261240716739539811551272516291638295193537794590294440604045143699088660492031971837721721423810294716643610492065090029999882479985122407977981936195964449975510177737652526046186320935603721708645301618671403257021765688674711211775084394227766262010268283327484969610745323022582786342799803296242769727302907993901229985212443595290415543524945341405750380367938171885408225995653673598826136703789874119354695532260104781873391291917131129979214240002200391948779824558839191424096361407612374388426285182413652318123614132115523315649356687639468860662543631733857366385194846877700083691940547418250944481824075035961705721856035364038627394209129464333344039250

Possible Modifications

The instruction set of this language may be expanded even further to include multiple operands for every command. This can be achieved by considering each instruction a "program" on its own, that is:

Here, denotes the th instruction, its opcode and its th argument. Overall, an extended PNPL program would be of the form:

This architecture is indeed more versatile in the theoretical frame, yet in practice programs scale much more rapidly, in such a manner that turns out to be unfeasible to handle in reasonable time and memory constraints.

History

Originally, this language was named pirho () and was published as my final project for the ESTALMAT program. Although its foundations in the FTA were the same, its syntax was highly troublesome, thus, PNPL is meant to be a revised version of the concept.

External resources