id
stringlengths 14
20
| title
stringlengths 4
181
| text
stringlengths 1
43k
| source
stringclasses 1
value |
|---|---|---|---|
wiki_18_chunk_22
|
APL (programming language)
|
As other vendors were busy developing APL interpreters for new hardware, notably Unix-based microcomputers, APL2 was almost always the standard chosen for new APL interpreter developments. Even today, most APL vendors or their users cite APL2 compatibility, as a selling point for those products. IBM cites its use for problem solving, system design, prototyping, engineering and scientific computations, expert systems, for teaching mathematics and other subjects, visualization and database access.
|
wikipedia
|
wiki_18_chunk_23
|
APL (programming language)
|
Modern implementations
Various implementations of APL by APLX, Dyalog, et al., include extensions for object-oriented programming, support for .NET Framework, XML-array conversion primitives, graphing, operating system interfaces, and lambda calculus expressions.
|
wikipedia
|
wiki_18_chunk_24
|
APL (programming language)
|
Derivative languages
APL has formed the basis of, or influenced, the following languages:
A and A+, an alternative APL, the latter with graphical extensions.
FP, a functional programming language.
Ivy, an interpreter for an APL-like language developed by Rob Pike, and which uses ASCII as input.
J, which was also designed by Iverson, and which uses ASCII with digraphs instead of special symbols.
K, a proprietary variant of APL developed by Arthur Whitney.
LYaPAS, a Soviet extension to APL.
MATLAB, a numerical computation tool.
Nial, a high-level array programming language with a functional programming notation.
Polymorphic Programming Language, an interactive, extensible language with a similar base language.
S, a statistical programming language (usually now seen in the open-source version known as R).
Speakeasy, a numerical computing interactive environment.
Wolfram Language, the programming language of Mathematica.
|
wikipedia
|
wiki_18_chunk_25
|
APL (programming language)
|
Language characteristics Character set
|
wikipedia
|
wiki_18_chunk_26
|
APL (programming language)
|
APL has been criticized and praised for its choice of a unique, non-standard character set. Some who learn it become ardent adherents. In the 1960s and 1970s, few terminal devices or even displays could reproduce the APL character set. The most popular ones employed the IBM Selectric print mechanism used with a special APL type element. One of the early APL line terminals (line-mode operation only, not full screen) was the Texas Instruments TI Model 745 (circa 1977) with the full APL character set which featured half and full duplex telecommunications modes, for interacting with an APL time-sharing service or remote mainframe to run a remote computer job, called an RJE.
|
wikipedia
|
wiki_18_chunk_27
|
APL (programming language)
|
Over time, with the universal use of high-quality graphic displays, printing devices and Unicode support, the APL character font problem has largely been eliminated. However, entering APL characters requires the use of input method editors, keyboard mappings, virtual/on-screen APL symbol sets, or easy-reference printed keyboard cards which can frustrate beginners accustomed to other programming languages. With beginners who have no prior experience with other programming languages, a study involving high school students found that typing and using APL characters did not hinder the students in any measurable way.
|
wikipedia
|
wiki_18_chunk_28
|
APL (programming language)
|
In defense of APL, it requires fewer characters to type, and keyboard mappings become memorized over time. Special APL keyboards are also made and in use today, as are freely downloadable fonts for operating systems such as Microsoft Windows. The reported productivity gains assume that one spends enough time working in the language to make it worthwhile to memorize the symbols, their semantics, and keyboard mappings, not to mention a substantial number of idioms for common tasks.
|
wikipedia
|
wiki_18_chunk_29
|
APL (programming language)
|
Design
Unlike traditionally structured programming languages, APL code is typically structured as chains of monadic or dyadic functions, and operators acting on arrays. APL has many nonstandard primitives (functions and operators) that are indicated by a single symbol or a combination of a few symbols. All primitives are defined to have the same precedence, and always associate to the right. Thus, APL is read or best understood from right-to-left.
|
wikipedia
|
wiki_18_chunk_30
|
APL (programming language)
|
Early APL implementations (circa 1970 or so) had no programming loop-flow control structures, such as do or while loops, and if-then-else constructs. Instead, they used array operations, and use of structured programming constructs was often not necessary, since an operation could be performed on a full array in one statement. For example, the iota function (ι) can replace for-loop iteration: ιN when applied to a scalar positive integer yields a one-dimensional array (vector), 1 2 3 ... N. More recent implementations of APL generally include comprehensive control structures, so that data structure and program control flow can be clearly and cleanly separated.
|
wikipedia
|
wiki_18_chunk_31
|
APL (programming language)
|
The APL environment is called a workspace. In a workspace the user can define programs and data, i.e., the data values exist also outside the programs, and the user can also manipulate the data without having to define a program. In the examples below, the APL interpreter first types six spaces before awaiting the user's input. Its own output starts in column one. The user can save the workspace with all values, programs, and execution status.
|
wikipedia
|
wiki_18_chunk_32
|
APL (programming language)
|
APL uses a set of non-ASCII symbols, which are an extension of traditional arithmetic and algebraic notation. Having single character names for single instruction, multiple data (SIMD) vector functions is one way that APL enables compact formulation of algorithms for data transformation such as computing Conway's Game of Life in one line of code. In nearly all versions of APL, it is theoretically possible to express any computable function in one expression, that is, in one line of code.
|
wikipedia
|
wiki_18_chunk_33
|
APL (programming language)
|
Because of the unusual character set, many programmers use special keyboards with APL keytops to write APL code. Although there are various ways to write APL code using only ASCII characters, in practice it is almost never done. (This may be thought to support Iverson's thesis about notation as a tool of thought.) Most if not all modern implementations use standard keyboard layouts, with special mappings or input method editors to access non-ASCII characters. Historically, the APL font has been distinctive, with uppercase italic alphabetic characters and upright numerals and symbols. Most vendors continue to display the APL character set in a custom font.
|
wikipedia
|
wiki_18_chunk_34
|
APL (programming language)
|
Advocates of APL claim that the examples of so-called write-only code (badly written and almost incomprehensible code) are almost invariably examples of poor programming practice or novice mistakes, which can occur in any language. Advocates also claim that they are far more productive with APL than with more conventional computer languages, and that working software can be implemented in far less time and with far fewer programmers than using other technology.
|
wikipedia
|
wiki_18_chunk_35
|
APL (programming language)
|
They also may claim that because it is compact and terse, APL lends itself well to larger-scale software development and complexity, because the number of lines of code can be reduced greatly. Many APL advocates and practitioners also view standard programming languages such as COBOL and Java as being comparatively tedious. APL is often found where time-to-market is important, such as with trading systems.
|
wikipedia
|
wiki_18_chunk_36
|
APL (programming language)
|
Terminology
APL makes a clear distinction between functions and operators. Functions take arrays (variables or constants or expressions) as arguments, and return arrays as results. Operators (similar to higher-order functions) take functions or arrays as arguments, and derive related functions. For example, the sum function is derived by applying the reduction operator to the addition function. Applying the same reduction operator to the maximum function (which returns the larger of two numbers) derives a function which returns the largest of a group (vector) of numbers. In the J language, Iverson substituted the terms verb for function and adverb or conjunction for operator.
|
wikipedia
|
wiki_18_chunk_37
|
APL (programming language)
|
APL also identifies those features built into the language, and represented by a symbol, or a fixed combination of symbols, as primitives. Most primitives are either functions or operators. Coding APL is largely a process of writing non-primitive functions and (in some versions of APL) operators. However a few primitives are considered to be neither functions nor operators, most noticeably assignment. Some words used in APL literature have meanings that differ from those in both mathematics and the generality of computer science. Syntax
|
wikipedia
|
wiki_18_chunk_38
|
APL (programming language)
|
APL has explicit representations of functions, operators, and syntax, thus providing a basis for the clear and explicit statement of extended facilities in the language, and tools to experiment on them. Examples Hello, world
This displays "Hello, world": 'Hello, world'A design theme in APL is to define default actions in some cases that would produce syntax errors in most other programming languages. The 'Hello, world' string constant above displays, because display is the default action on any expression for which no action is specified explicitly (e.g. assignment, function parameter).
|
wikipedia
|
wiki_18_chunk_39
|
APL (programming language)
|
Exponentiation
Another example of this theme is that exponentiation in APL is written as , which indicates raising 2 to the power 3 (this would be written as in some other languages and in FORTRAN and Python). Many languages use to signify multiplication, as in , but APL chooses to use . However, if no base is specified (as with the statement in APL, or in other languages), most programming languages one would see this as a syntax error. APL, however, assumes the missing base to be the natural logarithm constant e, and interprets as .
|
wikipedia
|
wiki_18_chunk_40
|
APL (programming language)
|
Simple statistics
Suppose that is an array of numbers. Then gives its average. Reading right-to-left, gives the number of elements in X, and since is a dyadic operator, the term to its left is required as well. It is surrounded by parentheses since otherwise X would be taken (so that the summation would be of — each element of X divided by the number of elements in X), and gives the sum of the elements of X. Building on this, the following expression computes standard deviation:
|
wikipedia
|
wiki_18_chunk_41
|
APL (programming language)
|
Naturally, one would define this expression as a function for repeated use rather than rewriting it each time. Further, since assignment is an operator, it can appear within an expression, so the following would place suitable values into T, AV and SD: Pick 6 lottery numbers
This following immediate-mode expression generates a typical set of Pick 6 lottery numbers: six pseudo-random integers ranging from 1 to 40, guaranteed non-repeating, and displays them sorted in ascending order: x[⍋x←6?40]
|
wikipedia
|
wiki_18_chunk_42
|
APL (programming language)
|
The above does a lot, concisely, although it may seem complex to a new APLer. It combines the following APL functions (also called primitives and glyphs):
The first to be executed (APL executes from rightmost to leftmost) is dyadic function ? (named deal when dyadic) that returns a vector consisting of a select number (left argument: 6 in this case) of random integers ranging from 1 to a specified maximum (right argument: 40 in this case), which, if said maximum ≥ vector length, is guaranteed to be non-repeating; thus, generate/create 6 random integers ranging from 1-40.
This vector is then assigned (←) to the variable x, because it is needed later.
This vector is then sorted in ascending order by a monadic ⍋ function, which has as its right argument everything to the right of it up to the next unbalanced close-bracket or close-parenthesis. The result of ⍋ is the indices that will put its argument into ascending order.
Then the output of ⍋ is used to index the variable x, which we saved earlier for this purpose, thereby selecting its items in ascending sequence.
|
wikipedia
|
wiki_18_chunk_43
|
APL (programming language)
|
Since there is no function to the left of the left-most x to tell APL what to do with the result, it simply outputs it to the display (on a single line, separated by spaces) without needing any explicit instruction to do that. ? also has a monadic equivalent called roll, which simply returns one random integer between 1 and its sole operand [to the right of it], inclusive. Thus, a role-playing game program might use the expression ?20 to roll a twenty-sided die.
|
wikipedia
|
wiki_18_chunk_44
|
APL (programming language)
|
Prime numbers
The following expression finds all prime numbers from 1 to R. In both time and space, the calculation complexity is (in Big O notation). (~R∊R∘.×R)/R←1↓⍳R
|
wikipedia
|
wiki_18_chunk_45
|
APL (programming language)
|
Executed from right to left, this means:
Iota ⍳ creates a vector containing integers from 1 to R (if R= 6 at the start of the program, ⍳R is 1 2 3 4 5 6)
Drop first element of this vector (↓ function), i.e., 1. So 1↓⍳R is 2 3 4 5 6
Set R to the new vector (←, assignment primitive), i.e., 2 3 4 5 6
The / replicate operator is dyadic (binary) and the interpreter first evaluates its left argument (fully in parentheses):
Generate outer product of R multiplied by R, i.e., a matrix that is the multiplication table of R by R (°.× operator), i.e.,
|
wikipedia
|
wiki_18_chunk_46
|
APL (programming language)
|
Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix (∈, set inclusion or element of or Epsilon operator), i.e., 0 0 1 0 1
Logically negate (not) values in the vector (change zeros to ones and ones to zeros) (∼, logical not or Tilde operator), i.e., 1 1 0 1 0
Select the items in R for which the corresponding element is 1 (/ replicate operator), i.e., 2 3 5
(Note, this assumes the APL origin is 1, i.e., indices start with 1. APL can be set to use 0 as the origin, so that ι6 is 0 1 2 3 4 5, which is convenient for some calculations.)
|
wikipedia
|
wiki_18_chunk_47
|
APL (programming language)
|
Sorting
The following expression sorts a word list stored in matrix X according to word length: X[⍋X+.≠' ';] Game of Life
The following function "life", written in Dyalog APL, takes a boolean matrix and calculates the new generation according to Conway's Game of Life. It demonstrates the power of APL to implement a complex algorithm in very little code, but it is also very hard to follow unless one has advanced knowledge of APL. life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}
|
wikipedia
|
wiki_18_chunk_48
|
APL (programming language)
|
HTML tags removal
In the following example, also Dyalog, the first line assigns some HTML code to a variable txt and then uses an APL expression to remove all the HTML tags (explanation): txt←'<html><body><p>This is <em>emphasized</em> text.</p></body></html>'
{⍵ /⍨ ~{⍵∨≠\⍵}⍵∊'<>'} txt
This is emphasized text.
|
wikipedia
|
wiki_18_chunk_49
|
APL (programming language)
|
Naming
APL derives its name from the initials of Iverson's book A Programming Language, even though the book describes Iverson's mathematical notation, rather than the implemented programming language described in this article. The name is used only for actual implementations, starting with APL\360. Adin Falkoff coined the name in 1966 during the implementation of APL\360 at IBM: APL is occasionally re-interpreted as Array Programming Language or Array Processing Language, thereby making APL into a backronym.
|
wikipedia
|
wiki_18_chunk_50
|
APL (programming language)
|
Logo
There has always been cooperation between APL vendors, and joint conferences were held on a regular basis from 1969 until 2010. At such conferences, APL merchandise was often handed out, featuring APL motifs or collection of vendor logos. Common were apples (as a pun on the similarity in pronunciation of apple and APL) and the code snippet which are the symbols produced by the classic APL keyboard layout when holding the APL modifier key and typing "APL".
|
wikipedia
|
wiki_18_chunk_51
|
APL (programming language)
|
Despite all these community efforts, no universal vendor-agnostic logo for the programming language emerged. As popular programming languages increasingly have established recognisable logos, Fortran getting one in 2020, British APL Association launched a campaign in the second half of 2021, to establish such a logo for APL.
|
wikipedia
|
wiki_18_chunk_52
|
APL (programming language)
|
Use
APL is used for many purposes including financial and insurance applications, artificial intelligence,
neural networks
and robotics. It has been argued that APL is a calculation tool and not a programming language; its symbolic nature and array capabilities have made it popular with domain experts and data scientists who do not have or require the skills of a computer programmer.
|
wikipedia
|
wiki_18_chunk_53
|
APL (programming language)
|
APL is well suited to image manipulation and computer animation, where graphic transformations can be encoded as matrix multiplications. One of the first commercial computer graphics houses, Digital Effects, produced an APL graphics product named Visions, which was used to create television commercials and animation for the 1982 film Tron. Latterly, the Stormwind boating simulator uses APL to implement its core logic, its interfacing to the rendering pipeline middleware and a major part of its physics engine.
|
wikipedia
|
wiki_18_chunk_54
|
APL (programming language)
|
Today, APL remains in use in a wide range of commercial and scientific applications, for example
investment management,
asset management,
health care,
and DNA profiling,
and by hobbyists. Notable implementations
|
wikipedia
|
wiki_18_chunk_55
|
APL (programming language)
|
APL\360
The first implementation of APL using recognizable APL symbols was APL\360 which ran on the IBM System/360, and was completed in November 1966 though at that time remained in use only within IBM. In 1973 its implementors, Larry Breed, Dick Lathwell and Roger Moore, were awarded the Grace Murray Hopper Award from the Association for Computing Machinery (ACM). It was given "for their work in the design and implementation of APL\360, setting new standards in simplicity, efficiency, reliability and response time for interactive systems."
|
wikipedia
|
wiki_18_chunk_56
|
APL (programming language)
|
In 1975, the IBM 5100 microcomputer offered APL\360 as one of two built-in ROM-based interpreted languages for the computer, complete with a keyboard and display that supported all the special symbols used in the language. Significant developments to APL\360 included CMS/APL, which made use of the virtual storage capabilities of CMS and APLSV, which introduced shared variables, system variables and system functions. It was subsequently ported to the IBM System/370 and VSPC platforms until its final release in 1983, after which it was replaced by APL2.
|
wikipedia
|
wiki_18_chunk_57
|
APL (programming language)
|
APL\1130
In 1968, APL\1130 became the first publicly available APL system, created by IBM for the IBM 1130. It became the most popular IBM Type-III Library software that IBM released. APL*Plus and Sharp APL
|
wikipedia
|
wiki_18_chunk_58
|
APL (programming language)
|
APL*Plus and Sharp APL are versions of APL\360 with added business-oriented extensions such as data formatting and facilities to store APL arrays in external files. They were jointly developed by two companies, employing various members of the original IBM APL\360 development team.
The two companies were I. P. Sharp Associates (IPSA), an APL\360 services company formed in 1964 by Ian Sharp, Roger Moore and others, and STSC, a time-sharing and consulting service company formed in 1969 by Lawrence Breed and others. Together the two developed APL*Plus and thereafter continued to work together but develop APL separately as APL*Plus and Sharp APL. STSC ported APL*Plus to many platforms with versions being made for the VAX 11, PC and UNIX, whereas IPSA took a different approach to the arrival of the personal computer and made Sharp APL available on this platform using additional PC-XT/360 hardware. In 1993, Soliton Incorporated was formed to support Sharp APL and it developed Sharp APL into SAX (Sharp APL for Unix). , APL*Plus continues as APL2000 APL+Win.
|
wikipedia
|
wiki_18_chunk_59
|
APL (programming language)
|
In 1985, Ian Sharp, and Dan Dyer of STSC, jointly received the Kenneth E. Iverson Award for Outstanding Contribution to APL. APL2
APL2 was a significant re-implementation of APL by IBM which was developed from 1971 and first released in 1984. It provides many additions to the language, of which the most notable is nested (non-rectangular) array support. The entire APL2 Products and Services Team was awarded the Iverson Award in 2007. In 2021, IBM sold APL2 to Log-On Software, who develop and sell the product as Log-On APL2.
|
wikipedia
|
wiki_18_chunk_60
|
APL (programming language)
|
APLGOL
In 1972, APLGOL was released as an experimental version of APL that added structured programming language constructs to the language framework. New statements were added for interstatement control, conditional statement execution, and statement structuring, as well as statements to clarify the intent of the algorithm. It was implemented for Hewlett-Packard in 1977.
|
wikipedia
|
wiki_18_chunk_61
|
APL (programming language)
|
Dyalog APL
Dyalog APL was first released by British company Dyalog Ltd. in 1983 and, , is available for AIX, Linux (including on the Raspberry Pi), macOS and Microsoft Windows platforms. It is based on APL2, with extensions to support object-oriented programming and functional programming. Licences are free for personal/non-commercial use.
|
wikipedia
|
wiki_18_chunk_62
|
APL (programming language)
|
In 1995, two of the development team - John Scholes and Peter Donnelly - were awarded the Iverson Award for their work on the interpreter. Gitte Christensen and Morten Kromberg were joint recipients of the Iverson Award in 2016.
|
wikipedia
|
wiki_18_chunk_63
|
APL (programming language)
|
NARS2000
NARS2000 is an open-source APL interpreter written by Bob Smith, a prominent APL developer and implementor from STSC in the 1970s and 1980s. NARS2000 contains advanced features and new datatypes and runs natively on Microsoft Windows, and other platforms under Wine. It is named after a development tool from the 1980s, NARS (Nested Arrays Research System). APLX
|
wikipedia
|
wiki_18_chunk_64
|
APL (programming language)
|
APLX is a cross-platform dialect of APL, based on APL2 and with several extensions, which was first released by British company MicroAPL in 2002. Although no longer in development or on commercial sale it is now available free of charge from Dyalog.
|
wikipedia
|
wiki_18_chunk_65
|
APL (programming language)
|
GNU APL
GNU APL is a free implementation of Extended APL as specified in ISO/IEC 13751:2001 and is thus an implementation of APL2. It runs on Linux (including on the Raspberry Pi), macOS, several BSD dialects, and on Windows (either using Cygwin for full support of all its system functions or as a native 64-bit Windows binary with some of its system functions missing). GNU APL uses Unicode internally and can be scripted. It was written by Jürgen Sauermann.
|
wikipedia
|
wiki_18_chunk_66
|
APL (programming language)
|
Richard Stallman, founder of the GNU Project, was an early adopter of APL, using it to write a text editor as a high school student in the summer of 1969.
|
wikipedia
|
wiki_18_chunk_67
|
APL (programming language)
|
Interpretation and compilation of APL
APL is traditionally an interpreted language, having language characteristics such as weak variable typing not well suited to compilation. However, with arrays as its core data structure it provides opportunities for performance gains through parallelism, parallel computing, massively parallel applications, and very-large-scale integration (VLSI), and from the outset APL has been regarded as a high-performance language - for example, it was noted for the speed with which it could perform complicated matrix operations "because it operates on arrays and performs operations like matrix inversion internally".
|
wikipedia
|
wiki_18_chunk_68
|
APL (programming language)
|
Nevertheless, APL is rarely purely interpreted and compilation or partial compilation techniques that are, or have been, used include the following: Idiom recognition
Most APL interpreters support idiom recognition and evaluate common idioms as single operations. For example, by evaluating the idiom BV/⍳⍴A as a single operation (where BV is a Boolean vector and A is an array), the creation of two intermediate arrays is avoided.
|
wikipedia
|
wiki_18_chunk_69
|
APL (programming language)
|
Optimised bytecode
Weak typing in APL means that a name may reference an array (of any datatype), a function or an operator. In general, the interpreter cannot know in advance which form it will be and must therefore perform analysis, syntax checking etc. at run-time. However, in certain circumstances, it is possible to deduce in advance what type a name is expected to reference and then generate bytecode which can be executed with reduced run-time overhead. This bytecode can also be optimised using compilation techniques such as constant folding or common subexpression elimination. The interpreter will execute the bytecode when present and when any assumptions which have been made are met. Dyalog APL includes support for optimised bytecode.
|
wikipedia
|
wiki_18_chunk_70
|
APL (programming language)
|
Compilation
Compilation of APL has been the subject of research and experiment since the language first became available; the first compiler is considered to be the Burroughs APL-700 which was released around 1971. In order to be able to compile APL, language limitations have to be imposed. APEX is a research APL compiler which was written by Robert Bernecky and is available under the GNU Public License.
|
wikipedia
|
wiki_18_chunk_71
|
APL (programming language)
|
The STSC APL Compiler is a hybrid of a bytecode optimiser and a compiler - it enables compilation of functions to machine code provided that its sub-functions and globals are declared, but the interpreter is still used as a runtime library and to execute functions which do not meet the compilation requirements.
|
wikipedia
|
wiki_18_chunk_72
|
APL (programming language)
|
Standards
APL has been standardized by the American National Standards Institute (ANSI) working group X3J10 and International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), ISO/IEC Joint Technical Committee 1 Subcommittee 22 Working Group 3. The Core APL language is specified in ISO 8485:1989, and the Extended APL language is specified in ISO/IEC 13751:2001. References
|
wikipedia
|
wiki_18_chunk_73
|
APL (programming language)
|
Further reading
An APL Machine (1970 Stanford doctoral dissertation by Philip Abrams)
A Personal History Of APL (1982 article by Michael S. Montalbano)
A Programming Language by Kenneth E. Iverson
APL in Exposition by Kenneth E. Iverson
Brooks, Frederick P.; Kenneth Iverson (1965). Automatic Data Processing, System/360 Edition. .
History of Programming Languages, chapter 14
|
wikipedia
|
wiki_18_chunk_74
|
APL (programming language)
|
Video
The Origins of APL - a 1974 talk show style interview with the original developers of APL.
APL demonstration - a 1975 live demonstration of APL by Professor Bob Spence, Imperial College London.
Conway's Game Of Life in APL - a 2009 tutorial by John Scholes of Dyalog Ltd. which implements Conway's Game of Life in a single line of APL.
50 Years of APL - a 2009 introduction to APL by Graeme Robertson. External links
|
wikipedia
|
wiki_18_chunk_75
|
APL (programming language)
|
Online resources
TryAPL.org, an online APL primer
APL Wiki
APL2C, a source of links to APL compilers Providers
Log-On APL2
Dyalog APL
APLX
APL2000
NARS2000
GNU APL
OpenAPL
|
wikipedia
|
wiki_18_chunk_76
|
APL (programming language)
|
User groups and societies
Finland: Finnish APL Association (FinnAPL)
France: APL et J
Germany: APL-Germany e.V.
Japan: Japan APL Association (JAPLA)
Sweden: Swedish APL User Group (SwedAPL)
Switzerland: Swiss APL User Group (SAUG)
United Kingdom: The British APL Association
United States: ACM SIGPLAN chapter on Array Programming Languages (SIGAPL)
|
wikipedia
|
wiki_18_chunk_77
|
APL (programming language)
|
.NET programming languages
APL programming language family
Array programming languages
Command shells
Dynamic programming languages
Dynamically typed programming languages
Functional languages
IBM software
Programming languages created in 1964
Programming languages with an ISO standard
Programming languages
|
wikipedia
|
wiki_19_chunk_0
|
Kolmogorov complexity
|
In algorithmic information theory (a subfield of computer science and mathematics), the Kolmogorov complexity of an object, such as a piece of text, is the length of a shortest computer program (in a predetermined programming language) that produces the object as output. It is a measure of the computational resources needed to specify the object, and is also known as algorithmic complexity, Solomonoff–Kolmogorov–Chaitin complexity, program-size complexity, descriptive complexity, or algorithmic entropy. It is named after Andrey Kolmogorov, who first published on the subject in 1963.
|
wikipedia
|
wiki_19_chunk_1
|
Kolmogorov complexity
|
The notion of Kolmogorov complexity can be used to state and prove impossibility results akin to Cantor's diagonal argument, Gödel's incompleteness theorem, and Turing's halting problem.
In particular, no program P computing a lower bound for each text's Kolmogorov complexity can return a value essentially larger than P's own length (see section ); hence no single program can compute the exact Kolmogorov complexity for infinitely many texts. Definition
Consider the following two strings of 32 lowercase letters and digits:
|
wikipedia
|
wiki_19_chunk_2
|
Kolmogorov complexity
|
abababababababababababababababab , and
4c1j5b2p0cv4w1x8rx2y39umgw5q85s7
|
wikipedia
|
wiki_19_chunk_3
|
Kolmogorov complexity
|
The first string has a short English-language description, namely "write ab 16 times", which consists of 17 characters. The second one has no obvious simple description (using the same character set) other than writing down the string itself, i.e., "write 4c1j5b2p0cv4w1x8rx2y39umgw5q85s7" which has 38 characters. Hence the operation of writing the first string can be said to have "less complexity" than writing the second.
|
wikipedia
|
wiki_19_chunk_4
|
Kolmogorov complexity
|
More formally, the complexity of a string is the length of the shortest possible description of the string in some fixed universal description language (the sensitivity of complexity relative to the choice of description language is discussed below). It can be shown that the Kolmogorov complexity of any string cannot be more than a few bytes larger than the length of the string itself. Strings like the abab example above, whose Kolmogorov complexity is small relative to the string's size, are not considered to be complex.
|
wikipedia
|
wiki_19_chunk_5
|
Kolmogorov complexity
|
The Kolmogorov complexity can be defined for any mathematical object, but for simplicity the scope of this article is restricted to strings. We must first specify a description language for strings. Such a description language can be based on any computer programming language, such as Lisp, Pascal, or Java. If P is a program which outputs a string x, then P is a description of x. The length of the description is just the length of P as a character string, multiplied by the number of bits in a character (e.g., 7 for ASCII).
|
wikipedia
|
wiki_19_chunk_6
|
Kolmogorov complexity
|
We could, alternatively, choose an encoding for Turing machines, where an encoding is a function which associates to each Turing Machine M a bitstring <M>. If M is a Turing Machine which, on input w, outputs string x, then the concatenated string <M> w is a description of x. For theoretical analysis, this approach is more suited for constructing detailed formal proofs and is generally preferred in the research literature. In this article, an informal approach is discussed. Any string s has at least one description. For example, the second string above is output by the program:
|
wikipedia
|
wiki_19_chunk_7
|
Kolmogorov complexity
|
function GenerateString2()
return "4c1j5b2p0cv4w1x8rx2y39umgw5q85s7" whereas the first string is output by the (much shorter) pseudo-code: function GenerateString1()
return "ab" × 16
|
wikipedia
|
wiki_19_chunk_8
|
Kolmogorov complexity
|
If a description d(s) of a string s is of minimal length (i.e., using the fewest bits), it is called a minimal description of s, and the length of d(s) (i.e. the number of bits in the minimal description) is the Kolmogorov complexity of s, written K(s). Symbolically, K(s) = |d(s)|. The length of the shortest description will depend on the choice of description language; but the effect of changing languages is bounded (a result called the invariance theorem). Invariance theorem
|
wikipedia
|
wiki_19_chunk_9
|
Kolmogorov complexity
|
Informal treatment
There are some description languages which are optimal, in the following sense: given any description of an object in a description language, said description may be used in the optimal description language with a constant overhead. The constant depends only on the languages involved, not on the description of the object, nor the object being described. Here is an example of an optimal description language. A description will have two parts: The first part describes another description language.
The second part is a description of the object in that language.
|
wikipedia
|
wiki_19_chunk_10
|
Kolmogorov complexity
|
In more technical terms, the first part of a description is a computer program (specifically: a compiler for the object's language, written in the description language), with the second part being the input to that computer program which produces the object as output. The invariance theorem follows: Given any description language L, the optimal description language is at least as efficient as L, with some constant overhead.
|
wikipedia
|
wiki_19_chunk_11
|
Kolmogorov complexity
|
Proof: Any description D in L can be converted into a description in the optimal language by first describing L as a computer program P (part 1), and then using the original description D as input to that program (part 2). The
total length of this new description D′ is (approximately): |D′ | = |P| + |D| The length of P is a constant that doesn't depend on D. So, there is at most a constant overhead, regardless of the object described. Therefore, the optimal language is universal up to this additive constant.
|
wikipedia
|
wiki_19_chunk_12
|
Kolmogorov complexity
|
A more formal treatment
Theorem: If K1 and K2 are the complexity functions relative to Turing complete description languages L1 and L2, then there is a constant c – which depends only on the languages L1 and L2 chosen – such that ∀s. −c ≤ K1(s) − K2(s) ≤ c. Proof: By symmetry, it suffices to prove that there is some constant c such that for all strings s K1(s) ≤ K2(s) + c. Now, suppose there is a program in the language L1 which acts as an interpreter for L2:
|
wikipedia
|
wiki_19_chunk_13
|
Kolmogorov complexity
|
function InterpretLanguage(string p) where p is a program in L2. The interpreter is characterized by the following property: Running InterpretLanguage on input p returns the result of running p. Thus, if P is a program in L2 which is a minimal description of s, then InterpretLanguage(P) returns the string s. The length of this description of s is the sum of The length of the program InterpretLanguage, which we can take to be the constant c.
The length of P which by definition is K2(s). This proves the desired upper bound.
|
wikipedia
|
wiki_19_chunk_14
|
Kolmogorov complexity
|
History and context
Algorithmic information theory is the area of computer science that studies Kolmogorov complexity and other complexity measures on strings (or other data structures). The concept and theory of Kolmogorov Complexity is based on a crucial theorem first discovered by Ray Solomonoff, who published it in 1960, describing it in "A Preliminary Report on a General Theory of Inductive Inference" as part of his invention of algorithmic probability. He gave a more complete description in his 1964 publications, "A Formal Theory of Inductive Inference," Part 1 and Part 2 in Information and Control.
|
wikipedia
|
wiki_19_chunk_15
|
Kolmogorov complexity
|
Andrey Kolmogorov later independently published this theorem in Problems Inform. Transmission in 1965. Gregory Chaitin also presents this theorem in J. ACM – Chaitin's paper was submitted October 1966 and revised in December 1968, and cites both Solomonoff's and Kolmogorov's papers.
|
wikipedia
|
wiki_19_chunk_16
|
Kolmogorov complexity
|
The theorem says that, among algorithms that decode strings from their descriptions (codes), there exists an optimal one. This algorithm, for all strings, allows codes as short as allowed by any other algorithm up to an additive constant that depends on the algorithms, but not on the strings themselves. Solomonoff used this algorithm and the code lengths it allows to define a "universal probability" of a string on which inductive inference of the subsequent digits of the string can be based. Kolmogorov used this theorem to define several functions of strings, including complexity, randomness, and information.
|
wikipedia
|
wiki_19_chunk_17
|
Kolmogorov complexity
|
When Kolmogorov became aware of Solomonoff's work, he acknowledged Solomonoff's priority. For several years, Solomonoff's work was better known in the Soviet Union than in the Western World. The general consensus in the scientific community, however, was to associate this type of complexity with Kolmogorov, who was concerned with randomness of a sequence, while Algorithmic Probability became associated with Solomonoff, who focused on prediction using his invention of the universal prior probability distribution. The broader area encompassing descriptional complexity and probability is often called Kolmogorov complexity. The computer scientist Ming Li considers this an example of the Matthew effect: "...to everyone who has, more will be given..."
|
wikipedia
|
wiki_19_chunk_18
|
Kolmogorov complexity
|
There are several other variants of Kolmogorov complexity or algorithmic information. The most widely used one is based on self-delimiting programs, and is mainly due to Leonid Levin (1974). An axiomatic approach to Kolmogorov complexity based on Blum axioms (Blum 1967) was introduced by Mark Burgin in the paper presented for publication by Andrey Kolmogorov. Basic results
In the following discussion, let K(s) be the complexity of the string s.
|
wikipedia
|
wiki_19_chunk_19
|
Kolmogorov complexity
|
It is not hard to see that the minimal description of a string cannot be too much larger than the string itself — the program GenerateString2 above that outputs s is a fixed amount larger than s. Theorem: There is a constant c such that ∀s. K(s) ≤ |s| + c. Uncomputability of Kolmogorov complexity A naive attempt at a program to compute K At first glance it might seem trivial to write a program which can compute K(s) for any s, such as the following:
|
wikipedia
|
wiki_19_chunk_20
|
Kolmogorov complexity
|
function KolmogorovComplexity(string s)
for i = 1 to infinity:
for each string p of length exactly i
if isValidProgram(p) and evaluate(p) == s
return i This program iterates through all possible programs (by iterating through all possible strings and only considering those which are valid programs), starting with the shortest. Each program is executed to find the result produced by that program, comparing it to the input s. If the result matches the length of the program is returned.
|
wikipedia
|
wiki_19_chunk_21
|
Kolmogorov complexity
|
However this will not work because some of the programs p tested will not terminate, e.g. if they contain infinite loops. There is no way to avoid all of these programs by testing them in some way before executing them due to the non-computability of the halting problem. What is more, no program at all can compute the function K, be it ever so sophisticated. This is proven in the following. Formal proof of uncomputability of K
|
wikipedia
|
wiki_19_chunk_22
|
Kolmogorov complexity
|
Theorem: There exist strings of arbitrarily large Kolmogorov complexity. Formally: for each natural number n, there is a string s with K(s) ≥ n. Proof: Otherwise all of the infinitely many possible finite strings could be generated by the finitely many programs with a complexity below n bits. Theorem: K is not a computable function. In other words, there is no program which takes any string s as input and produces the integer K(s) as output.
|
wikipedia
|
wiki_19_chunk_23
|
Kolmogorov complexity
|
The following indirect proof uses a simple Pascal-like language to denote programs; for sake of proof simplicity assume its description (i.e. an interpreter) to have a length of bits.
Assume for contradiction there is a program function KolmogorovComplexity(string s) which takes as input a string s and returns K(s). All programs are of finite length so, for sake of proof simplicity, assume it to be bits.
Now, consider the following program of length bits:
|
wikipedia
|
wiki_19_chunk_24
|
Kolmogorov complexity
|
function GenerateComplexString()
for i = 1 to infinity:
for each string s of length exactly i
if KolmogorovComplexity(s) ≥ 8000000000
return s
|
wikipedia
|
wiki_19_chunk_25
|
Kolmogorov complexity
|
Using KolmogorovComplexity as a subroutine, the program tries every string, starting with the shortest, until it returns a string with Kolmogorov complexity at least bits, i.e. a string that cannot be produced by any program shorter than bits. However, the overall length of the above program that produced s is only bits, which is a contradiction. (If the code of KolmogorovComplexity is shorter, the contradiction remains. If it is longer, the constant used in GenerateComplexString can always be changed appropriately.)
|
wikipedia
|
wiki_19_chunk_26
|
Kolmogorov complexity
|
The above proof uses a contradiction similar to that of the Berry paradox: "The smallest positive integer that cannot be defined in fewer than twenty English words". It is also possible to show the non-computability of K by reduction from the non-computability of the halting problem H, since K and H are Turing-equivalent. There is a corollary, humorously called the "full employment theorem" in the programming language community, stating that there is no perfect size-optimizing compiler. Chain rule for Kolmogorov complexity The chain rule for Kolmogorov complexity states that
|
wikipedia
|
wiki_19_chunk_27
|
Kolmogorov complexity
|
K(X,Y) ≤ K(X) + K(Y|X) + O(log(K(X,Y))). It states that the shortest program that reproduces X and Y is no more than a logarithmic term larger than a program to reproduce X and a program to reproduce Y given X. Using this statement, one can define an analogue of mutual information for Kolmogorov complexity.
|
wikipedia
|
wiki_19_chunk_28
|
Kolmogorov complexity
|
Compression
It is straightforward to compute upper bounds for K(s) – simply compress the string s with some method, implement the corresponding decompressor in the chosen language, concatenate the decompressor to the compressed string, and measure the length of the resulting string – concretely, the size of a self-extracting archive in the given language.
|
wikipedia
|
wiki_19_chunk_29
|
Kolmogorov complexity
|
A string s is compressible by a number c if it has a description whose length does not exceed |s| − c bits. This is equivalent to saying that K(s) ≤ |s| − c. Otherwise, s is incompressible by c. A string incompressible by 1 is said to be simply incompressible – by the pigeonhole principle, which applies because every compressed string maps to only one uncompressed string, incompressible strings must exist, since there are 2n bit strings of length n, but only 2n − 1 shorter strings, that is, strings of length less than n, (i.e. with length 0, 1, ..., n − 1).
|
wikipedia
|
wiki_19_chunk_30
|
Kolmogorov complexity
|
For the same reason, most strings are complex in the sense that they cannot be significantly compressed – their K(s) is not much smaller than |s|, the length of s in bits. To make this precise, fix a value of n. There are 2n bitstrings of length n. The uniform probability distribution on the space of these bitstrings assigns exactly equal weight 2−n to each string of length n.
|
wikipedia
|
wiki_19_chunk_31
|
Kolmogorov complexity
|
Theorem: With the uniform probability distribution on the space of bitstrings of length n, the probability that a string is incompressible by c is at least 1 − 2−c+1 + 2−n. To prove the theorem, note that the number of descriptions of length not exceeding n − c is given by the geometric series: 1 + 2 + 22 + ... + 2n − c = 2n−c+1 − 1. There remain at least 2n − 2n−c+1 + 1
|
wikipedia
|
wiki_19_chunk_32
|
Kolmogorov complexity
|
bitstrings of length n that are incompressible by c. To determine the probability, divide by 2n. Chaitin's incompleteness theorem
|
wikipedia
|
wiki_19_chunk_33
|
Kolmogorov complexity
|
By the above theorem (), most strings are complex in the sense that they cannot be described in any significantly "compressed" way. However, it turns out that the fact that a specific string is complex cannot be formally proven, if the complexity of the string is above a certain threshold. The precise formalization is as follows. First, fix a particular axiomatic system S for the natural numbers. The axiomatic system has to be powerful enough so that, to certain assertions A about complexity of strings, one can associate a formula FA in S. This association must have the following property:
|
wikipedia
|
wiki_19_chunk_34
|
Kolmogorov complexity
|
If FA is provable from the axioms of S, then the corresponding assertion A must be true. This "formalization" can be achieved based on a Gödel numbering. Theorem: There exists a constant L (which only depends on S and on the choice of description language) such that there does not exist a string s for which the statementK(s) ≥ L (as formalized in S) can be proven within S.
|
wikipedia
|
wiki_19_chunk_35
|
Kolmogorov complexity
|
Proof Idea: The proof of this result is modeled on a self-referential construction used in Berry's paradox. We firstly obtain an program which enumerates the proofs within S and we specify a procedure P which takes as an input an integer L and prints the strings x which are within proofs within S of the statement K(x) ≥ L. By then setting L to greater than the length of this procedure P, we have that the required length of a program to print x as stated in K(x) ≥ L as being at least L is then less than the amount L since the string x was printed by the procedure P. This is a contradiction. So it is not possible for the proof system S to prove K(x) ≥ L for L arbitrarily large, in particular, for L larger than the length of the procedure P, (which is finite).
|
wikipedia
|
wiki_19_chunk_36
|
Kolmogorov complexity
|
Proof: We can find an effective enumeration of all the formal proofs in S by some procedure function NthProof(int n) which takes as input n and outputs some proof. This function enumerates all proofs. Some of these are proofs for formulas we do not care about here, since every possible proof in the language of S is produced for some n. Some of these are complexity formulas of the form K(s) ≥ n where s and n are constants in the language of S. There is a procedure function NthProofProvesComplexityFormula(int n)
|
wikipedia
|
wiki_19_chunk_37
|
Kolmogorov complexity
|
which determines whether the nth proof actually proves a complexity formula K(s) ≥ L. The strings s, and the integer L in turn, are computable by procedure: function StringNthProof(int n) function ComplexityLowerBoundNthProof(int n) Consider the following procedure: function GenerateProvablyComplexString(int n)
for i = 1 to infinity:
if NthProofProvesComplexityFormula(i) and ComplexityLowerBoundNthProof(i) ≥ n return StringNthProof(i)
|
wikipedia
|
wiki_19_chunk_38
|
Kolmogorov complexity
|
Given an n, this procedure tries every proof until it finds a string and a proof in the formal system S of the formula K(s) ≥ L for some L ≥ n; if no such proof exists, it loops forever. Finally, consider the program consisting of all these procedure definitions, and a main call: GenerateProvablyComplexString(n0)
|
wikipedia
|
wiki_19_chunk_39
|
Kolmogorov complexity
|
where the constant n0 will be determined later on. The overall program length can be expressed as U+log2(n0), where U is some constant and log2(n0) represents the length of the integer value n0, under the reasonable assumption that it is encoded in binary digits. We will choose n0 to be greater than the program length, that is, such that n0 > U+log2(n0). This is clearly true for n0 sufficiently large, because the left hand side grows linearly in n0 whilst the right hand side grows logarithmically in n0 up to the fixed constant U.
|
wikipedia
|
wiki_19_chunk_40
|
Kolmogorov complexity
|
Then no proof of the form "K(s)≥L" with L≥n0 can be obtained in S, as can be seen by an indirect argument:
If ComplexityLowerBoundNthProof(i) could return a value ≥n0, then the loop inside GenerateProvablyComplexString would eventually terminate, and that procedure would return a string s such that This is a contradiction, Q.E.D. As a consequence, the above program, with the chosen value of n0, must loop forever. Similar ideas are used to prove the properties of Chaitin's constant.
|
wikipedia
|
wiki_19_chunk_41
|
Kolmogorov complexity
|
Minimum message length
|
wikipedia
|
wiki_19_chunk_42
|
Kolmogorov complexity
|
The minimum message length principle of statistical and inductive inference and machine learning was developed by C.S. Wallace and D.M. Boulton in 1968. MML is Bayesian (i.e. it incorporates prior beliefs) and information-theoretic. It has the desirable properties of statistical invariance (i.e. the inference transforms with a re-parametrisation, such as from polar coordinates to Cartesian coordinates), statistical consistency (i.e. even for very hard problems, MML will converge to any underlying model) and efficiency (i.e. the MML model will converge to any true underlying model about as quickly as is possible). C.S. Wallace and D.L. Dowe (1999) showed a formal connection between MML and algorithmic information theory (or Kolmogorov complexity).
|
wikipedia
|
wiki_19_chunk_43
|
Kolmogorov complexity
|
Kolmogorov randomnessKolmogorov randomness defines a string (usually of bits) as being random if and only if every computer program that can produce that string is at least as long as the string itself. To make this precise, a universal computer (or universal Turing machine) must be specified, so that "program" means a program for this universal machine. A random string in this sense is "incompressible" in that it is impossible to "compress" the string into a program that is shorter than the string itself. For every universal computer, there is at least one algorithmically random string of each length. Whether a particular string is random, however, depends on the specific universal computer that is chosen. This is because a universal computer can have a particular string hard-coded in itself, and a program running on this universal computer can then simply refer to this hard-coded string using a short sequence of bits (i.e. much shorter than the string itself).
|
wikipedia
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.