Summary

I demonstrate how Codex is reversible computing.

Janus

Janus is a reversible programming language, i.e. it supports deterministic forward and backward computation by local inversion.

A language like Janus for reversible non- deterministic inference is sorely needed.

Codex

Codex is non-deterministic forward and backward inference.

Example, json <-> jq

Prompt
http://github.com/semiosis/prompts/blob/master/prompts/generate-jq-from-json-1.prompt

pf-generate-jq-from-json/1

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
task: "Generate jq from json"
doc: "Given some json, generate the jq which generates it"
prompt-version: 1
prompt: |+
    cat generated-1.json <<EOD
    {
      "jsonrpc": "John Doe",
      "age": 42
    }
    EOD

    # This is how generated-1.json was generated:
    export NAME="John Doe"
    export AGE=62
    jq -n '{jsonrpc: env.NAME, age: env.AGE}' > generated-1.json

    cat generated-2.json <<EOD
    <json>
    EOD

    # This is how generated-2.json was generated:
    <:pp>export
engine: "OpenAI Codex"
temperature: 0.3
max-generated-tokens: "(* 2 prompt-length)"
top-p: 1.0
stop-sequences:
- " > gen"
cache: on
vars:
- "json"
examples:
- |-
    {
      "jsonrpc": "2.0",
      "id": 2896,
      "result": [
        {
          "name": "port->",
          "kind": 13,
          "location": {
            "uri": "file:///home/shane/scripts/glob-grep.rkt",
            "range": {
              "end": {
                "character": 8,
                "line": 3
              },
              "start": {
                "character": 2,
                "line": 3
              }
            }
          }
        },
      ]
    }
info: on
completion: off
insertion: off

From the example json above, the example jq below was generated, which was able to generate the following json, an exact replica of the original.

Code was generated from output.

1
2
3
4
5
6
7
8
export NAME="port->"
export KIND=13
export LOCATION_URI="file:///home/shane/scripts/glob-grep.rkt"
export LOCATION_RANGE_END_CHARACTER=8
export LOCATION_RANGE_END_LINE=3
export LOCATION_RANGE_START_CHARACTER=2
export LOCATION_RANGE_START_LINE=3
jq -n '{jsonrpc: "2.0", id: 2896, result: [{name: env.NAME, kind: env.KIND, location: {uri: env.LOCATION_URI, range: {end: {character: env.LOCATION_RANGE_END_CHARACTER, line: env.LOCATION_RANGE_END_LINE}, start: {character: env.LOCATION_RANGE_START_CHARACTER, line: env.LOCATION_RANGE_START_LINE}}}}]}'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "jsonrpc": "2.0",
  "id": 2896,
  "result": [
    {
      "name": "port->",
      "kind": 13,
      "location": {
        "uri": "file:///home/shane/scripts/glob-grep.rkt",
        "range": {
          "end": {
            "character": 8,
            "line": 3
          },
          "start": {
            "character": 2,
            "line": 3
          }
        }
      }
    }
  ]
}

Reversible computing

In another sense, the input was generated from the output, and the program was the prompt.

A new language is needed

A language which enforces types is needed. What is the type of the output? JSON. But what does that mean?

Imagine a situation where generated output was chimeric and had no known compiler which could agree on its type. What is actually needed is consensus, somehow.

Therefore, we need language detectors which we agree on. I’m talking about LMs on the blockchain.

A type would then be a prompt to that LM, which validates the type by binary classification. I’ll call this an imaginary type, but the LM (the source of truth) should be agreed upon, so it should be on a blockchain.

This is why I have invested in Ocean.

Demo of above