Code
https://github.com/semiosis/pen.el
Prompts
https://github.com/semiosis/prompts/
Disclaimer
Please contribute as this is an open source project! It’s very hard to find free prompts online currently and that’s because everyone is out for themselves. Please support open source. Thank you.
Glossary
http://github.com/semiosis/glossaries-gh/blob/master/imaginary-programming.txt
Thesis
https://github.com/semiosis/imaginary-programming-thesis/blob/master/thesis.org

Summary

This is a demonstration of an imaginary programming environment. There may be nothing else like it in the world today.

The world needs to get ready for the next generations of Large LMs, such as GPT-4.

Indeed, they will be able to dream up the entire experience of a textual user interface by inferring how it changes based on keyboard input. That is because a tty is simple text stream.

A current generation GPT trained on tty recordings would most certainly probably be able to do this already, but with GPT-4 and future LMs comes convenience in the form of prompt tuning.

An imaginary programming environment is one of the supported features of pen.el.

What does it mean to be imaginary?

Several of the components of a normal programming environment are replaced by functions that infer rather than evaluate.

These components are replaced by GPT-3 and Codex prompts.

Imaginary seems to be a good word because:

  • GPT-3 is imagining the environment, the code and the output.
  • the languages are kinda like imaginary numbers. They are all understood within the same language model, kinda like a coordinate space.
  • It lets you be very imaginative!

The implications

  • There are no interpreters or compilers being used but you can still generate code using words and evaluate code by inference.
  • All requests take the same amount of time to run.
  • All languages have equally facilitated environments.
  • You may program in any language.
  • It runs broken code.
  • One day you may design new languages within the latent space of GPT-3, without doing any programming.
  • You may have an interpreter for languages with no interpreter, such as C++.
  • You may have code completion for scripting languages without a completion engine.
  • You may use it for languages which are dead and an interpreter is not available.
  • It’s great for thought experiments.

Literate programming

According to Wikipedia, literate programming is a programming paradigm introduced by Donald Knuth in which a computer program is given an explanation of its logic in a NL, such as English, interspersed with snippets of macros and traditional source code, from which compilable source code can be generated.

The approach is used in scientific computing and in data science routinely for reproducible research and open access purposes.

Literate programming tools are used by millions of programmers today.

Literate programming
https://en.wikipedia.org/wiki/Literate%5Fprogramming

Imaginary programming

Imaginary programming (IP) seems to be orthogonal to literate programming. Imaginary programming is a programming paradigm in which a computer program’s behaviour exists in relativity to LMs. To make an analogy, imaginary programming is a type of programming, where much like pure- functional, the code who’s behaviour depends on the output of a LM, either pending or precomputed, stands apart from the part that has no such association.

What is deemed imaginary is code that uses or is waiting on output from a LM and its behaviour is so altered by it. What is deemed ordinary is code which is not imaginary.

A distinction is made between grounded and non-grounded imaginary programming. Non-grounded imaginary programming may also be called pure imaginary programming.

If a function has a LM as a parameter affecting its behaviour and besides from that has no other imaginary inputs then it is considered grounded. If a function has a LM as a parameter affecting its behaviour and contains other imaginary inputs then it is considered tethered'.

If an imaginary function relies on the output of functions that have in the past used a LM as a parameter, but does not contain a reference to specific LM used then it is considered non-grounded or pure imaginary.

A function can be both tethered and pure imaginary.

Pure imaginary code is still code in a similar way to how pure functional code is considered code and may be used to create useful datastructures and algorithms.

Ordinary programming is programming with functions that do not have an imaginary dimension (they do not take a LM as a parameter and the result of ordinary code is not polluted by a LM).

Holographic programming is like imaginary programming but where the LMs are trained on software. Holographic code, therefore, may employ associations made between elements of the original code, how that code is used and how it is described, to build applications. Holographic programming lets you use the latent space of a LM as a kind of hyperspace to enable things like:

  • bridge the usage of an application with the application’s code
  • imaginary reflection
  • inference in place of computation

Current progress

Some of the plumbing, including the interpreter and the autocompletion system are in an MVP stage.

Latest GPT-3 Demonstration (Aug 25, 2021)

Original Demonstration (April 2, 2021)

Prompts and demonstrations

Linter (Update: Sep 1, 2021)

Reformatter and Syntax corrector (Update: Sep 1, 2021)

Prompts

kickstarter

This prompt initiates the imaginary interpreter / REPL.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
include: Generic Interpreter/3
task: Imagine a <language> interpreter
language: python
subprompts:
- kickstarter: |+
    Python 3.8.5 (default, Jan 27 2021, 15:41:15)
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help.

    In [1]:    
prompt: |+
    <history><expression>
    <:pp>Out    
user-prompt: "^In \\[[0-9]*\\]: "
# Unfortunately, we can't generate the next In
# prompt because we need to match on it with stop-sequences.
# So the user prompt must be reconstructed manually.
stop-sequences:
- "In ["
# Create a user prompt with the number incremented.
# This is like postprocessor but happens even later.
# It is used in special circumstances when the prompt history is also required.
postpostprocessor: pen-str python-gen-next-user-prompt
vars:
- history
- expression
var-defaults:
- kickstarter
examples:
- "In [1]: "
- "5 + 5"

conjugator

This prompt is part of the interpreter conjugator, and enables the imaginary interpreter to continue the “conversation” more optimally than the kickstarter prompt.

Conjugation is comprised of melding and a sliding window.

iλ, a family of imaginary programming libraries

1
(ifilter (ilist 10 "tennis players") "is male")

Examplary (a example-oriented programming language)

1
2
3
4
5
6
7
8
(defprompt ("lines of code" regex)
  :task "Convert lines to regex"
  :gen "examplary-edit-generator shane"
  :filter "grex"
  :examples '(("example 1\nexample2")
              ("example 2\nexample3" "^example [23]$")
              ("pi4\npi5" "^pi[45]$" "pi4\npi5"))
  :lm-command "openai-complete.sh")