Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/proposals/same-world-ladder/Bridge.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# OPTIONS --cubical --safe #-}
-- SPDX-License-Identifier: MPL-2.0
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
-- Scratch sketch. Rung B0: a Cubical module imports the Ladder A module.
module Bridge where

open import Agda.Builtin.Cubical.Path using (_≡_)
import Agda.Builtin.Equality as Id
open import Agda.Builtin.List using (List)
open import SameWorld using (module World)

toPath : {A : Set} {x y : A} → x Id.≡ y → x ≡ y
toPath {x = x} Id.refl = λ _ → x

module _ (In W : Set) (step : W → In → W) {P : Set} (see : W → P) where
open World In W step
open View see

-- The Ladder A relation gives a path between experiences.
lift : ∀ {w w′} → w ~ w′ → beh w ≡ beh w′
lift e k is = toPath (e is) k
63 changes: 63 additions & 0 deletions docs/proposals/same-world-ladder/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: CC-BY-SA-4.0
= Same-world proof ladder: sketches
:toc: preamble

Status: *sketch, not admitted* (2026-11-22). These files are a backup of
work in progress. They are not on the theory shelf, they are not in
`verification/proofs/agda/MANIFEST`, and no receipt exists for them. Every
theorem here is `ungraded`.

== What the files are

The question is: when do two subjects see "the same world"? The world is a
deterministic machine (`step : W → In → W`). A view is a function from the
world state to a percept (`see : W → P`).

[cols="2,3,3"]
|===
| File | Content | Invocation that passed

| `SameWorld.agda`
| Ladder A, rungs A0 to A3, A5, A6: `Coherent`, `SameWorld`, `sound`,
`stable`, `_~_`, `Bisimulation`, `greatest`, `weaker`, `Secret.no-leak`,
`Gaslight.not-same`
| `agda --safe --without-K --cubical-compatible --double-check`

| `SameWorldCo.agda`
| Rung A4: the coinductive form (`Beh`, `_≋_`, `Lift`, `one-world`)
| The same flags plus `--guardedness`, which is outside PROOF-POLICY section 2.1

| `Bridge.agda`
| Rung B0: a full Cubical module imports the section 2.1 module
| `agda --cubical --safe --double-check`

| `SameWorldCubical.agda`
| Ladder B, rungs B1 to B4: function extensionality, bisimilar is equal,
the set quotient `W / ~`, `SameWorld` as a fibre
| `agda --cubical --safe --guardedness --double-check`
|===

== What is not established

* The runs used Agda 2.6.3 from an Ubuntu package, on 2026-11-21. The pinned
Guix shell has Agda 2.7.0.1. No run used the pinned shell.
* No Rocq recheck and no Lean recheck exists.
* `SameWorldCo.agda`, `Bridge.agda` and `SameWorldCubical.agda` need an
explicit, separately reviewed proof profile (PROOF-POLICY section 2.1).
No such profile exists.
* Full Cubical Agda supplies postulates in `Agda.Primitive.Cubical`. A
receipt must list them (PROOF-POLICY section 8.4).
* Rungs B5 (univalence) and B6 (pushout) are design only. No file exists.
* `collapse` in rung B3 holds for classes of states only.
* No rung proves that a host program obeys this model. `sound` is true by
construction only if a view is a pure function of the one world state.

== Owner rulings (2026-11-22)

. Home: the general theorems go on the theory shelf of this repository, with
an admission that names `enaction-umwelt/1` as the dependant. The Enaction
instance stays in `enaction-engine`.
. Order: Ladder A first (rungs A0 to A3, A5, A6) under section 2.1. No
profile for `--guardedness` or `--cubical` is written now.

The admission waits for `enaction-umwelt/1`, which does not exist yet.
166 changes: 166 additions & 0 deletions docs/proposals/same-world-ladder/SameWorld.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{-# OPTIONS --safe --without-K --cubical-compatible #-}
-- SPDX-License-Identifier: MPL-2.0
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
-- Scratch sketch, not a receipt. Ladder A, rungs A0 to A3, A5 and A6.
-- No coinduction here. The import cone is Agda.Builtin only.
module SameWorld where

open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.Sigma using (Σ; _,_)
open import Agda.Builtin.List using (List; []; _∷_)
open import Agda.Builtin.Bool using (Bool; true; false)
open import Agda.Builtin.Unit using (⊤; tt)

data ⊥ : Set where

infixr 2 _×_
_×_ : Set → Set → Set
A × B = Σ A (λ _ → B)

sym : {A : Set} {x y : A} → x ≡ y → y ≡ x
sym refl = refl

trans : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl q = q

subst : {A : Set} (C : A → Set) {x y : A} → x ≡ y → C x → C y
subst C refl c = c

------------------------------------------------------------------------
-- A0. Vocabulary. A world is a deterministic machine.
-- In is the input of one tick. W is the world state.

module World (In W : Set) (step : W → In → W) where

run : W → List In → W
run w [] = w
run w (i ∷ is) = run (step w i) is

-- A view (an Umwelt) is a function from the world state to a percept.
module View {P : Set} (see : W → P) where

-- The experience of the subject: the percept after each input word.
beh : W → List In → P
beh w is = see (run w is)

-- A3. Two states that this subject cannot tell apart, whatever happens.
_~_ : W → W → Set
w ~ w′ = ∀ is → beh w is ≡ beh w′ is

~-refl : ∀ {w} → w ~ w
~-refl is = refl

~-sym : ∀ {w w′} → w ~ w′ → w′ ~ w
~-sym e is = sym (e is)

~-trans : ∀ {w w′ w″} → w ~ w′ → w′ ~ w″ → w ~ w″
~-trans e f is = trans (e is) (f is)

record Bisimulation (R : W → W → Set) : Set where
field
now : ∀ {w w′} → R w w′ → see w ≡ see w′
later : ∀ {w w′} → R w w′ → ∀ i → R (step w i) (step w′ i)
open Bisimulation

~-bisim : Bisimulation _~_
now ~-bisim e = e []
later ~-bisim e i is = e (i ∷ is)

-- The coinduction principle, proved by induction on the input word:
-- every bisimulation is inside _~_.
greatest : ∀ {R} → Bisimulation R → ∀ {w w′} → R w w′ → w ~ w′
greatest b r [] = now b r
greatest b r (i ∷ is) = greatest b (later b r i) is

----------------------------------------------------------------------
-- Two subjects.

module Two {P₁ P₂ : Set} (see₁ : W → P₁) (see₂ : W → P₂) where
open View see₁ using () renaming (beh to beh₁)
open View see₂ using () renaming (beh to beh₂)

-- A1. Two percepts of one state. The witness is the state.
Coherent : P₁ → P₂ → Set
Coherent p₁ p₂ = Σ W (λ w → (see₁ w ≡ p₁) × (see₂ w ≡ p₂))

-- A2. Two experiences of one world. The witness is the start state.
SameWorld : (List In → P₁) → (List In → P₂) → Set
SameWorld b₁ b₂ =
Σ W (λ w → (∀ is → beh₁ w is ≡ b₁ is) × (∀ is → beh₂ w is ≡ b₂ is))

-- What a host shows to two seats from one state is of the same world.
sound : ∀ w → SameWorld (beh₁ w) (beh₂ w)
sound w = w , (λ _ → refl) , (λ _ → refl)

after : {P : Set} → (List In → P) → In → List In → P
after b i is = b (i ∷ is)

-- The same world stays the same world after any input.
stable : ∀ {b₁ b₂} → SameWorld b₁ b₂ →
∀ i → SameWorld (after b₁ i) (after b₂ i)
stable (w , e₁ , e₂) i =
step w i , (λ is → e₁ (i ∷ is)) , (λ is → e₂ (i ∷ is))

-- A5. Coherent at each moment. This is weaker than SameWorld.
Moments : (List In → P₁) → (List In → P₂) → Set
Moments b₁ b₂ = ∀ is → Coherent (b₁ is) (b₂ is)

weaker : ∀ {b₁ b₂} → SameWorld b₁ b₂ → Moments b₁ b₂
weaker (w , e₁ , e₂) is = run w is , e₁ is , e₂ is

----------------------------------------------------------------------
-- A6. Unwinding: a hidden input does not change what a seat sees.

module Secret {P : Set} (see : W → P) (hidden : In → Bool)
(_≈_ : W → W → Set)
(≈-trans : ∀ {a b c} → a ≈ b → b ≈ c → a ≈ c)
(out : ∀ {w w′} → w ≈ w′ → see w ≡ see w′)
(same : ∀ {w w′} → w ≈ w′ → ∀ i → step w i ≈ step w′ i)
(hide : ∀ w i → hidden i ≡ true → step w i ≈ w) where

purge : List In → List In
purge [] = []
purge (i ∷ is) with hidden i
... | true = purge is
... | false = i ∷ purge is

lemma : ∀ {w w′} → w ≈ w′ → ∀ is → run w is ≈ run w′ (purge is)
lemma r [] = r
lemma {w} r (i ∷ is) with hidden i in eq
... | true = lemma (≈-trans (hide w i eq) r) is
... | false = lemma (same r i) is

no-leak : ∀ {w} → w ≈ w → ∀ is → see (run w is) ≡ see (run w (purge is))
no-leak r is = out (lemma r is)

------------------------------------------------------------------------
-- A5, the converse fails. Each moment is possible. The story is not.

module Gaslight where

-- The world is one bit that never changes.
-- Subject 1 sees the bit. Subject 2 sees nothing.
still : Bool → ⊤ → Bool
still b _ = b

open World ⊤ Bool still
open Two (λ b → b) (λ _ → tt)

-- An experience that shows true first, and false after that.
turn : List ⊤ → Bool
turn [] = true
turn (_ ∷ _) = false

blank : List ⊤ → ⊤
blank _ = tt

moments : Moments turn blank
moments [] = true , refl , refl
moments (_ ∷ _) = false , refl , refl

T : Bool → Set
T true = ⊤
T false = ⊥

not-same : SameWorld turn blank → ⊥
not-same (w , e₁ , _) = subst T (trans (sym (e₁ [])) (e₁ (tt ∷ []))) tt
63 changes: 63 additions & 0 deletions docs/proposals/same-world-ladder/SameWorldCo.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{-# OPTIONS --safe --without-K --cubical-compatible --guardedness #-}
-- SPDX-License-Identifier: MPL-2.0
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
-- Scratch sketch, not a receipt. Ladder A, rung A4: the coinductive form.
-- This rung needs --guardedness, which is outside the section 2.1 invocation.
module SameWorldCo where

open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.Sigma using (_,_)
open import Agda.Builtin.List using (List; []; _∷_)
open import SameWorld using (module World)

-- The experience as one infinite object (the final coalgebra).
record Beh (In P : Set) : Set where
coinductive
field
head : P
tail : In → Beh In P
open Beh public

-- Bisimilar experiences. In this profile it is a relation, not equality.
record _≋_ {In P : Set} (b b′ : Beh In P) : Set where
coinductive
field
head≡ : head b ≡ head b′
tail≋ : ∀ i → tail b i ≋ tail b′ i
open _≋_ public

-- Two percept alphabets: bisimilar up to a relation between percepts.
record Lift {In P₁ P₂ : Set} (T : P₁ → P₂ → Set)
(b₁ : Beh In P₁) (b₂ : Beh In P₂) : Set where
coinductive
field
headT : T (head b₁) (head b₂)
tailT : ∀ i → Lift T (tail b₁ i) (tail b₂ i)
open Lift public

module _ (In W : Set) (step : W → In → W) where
open World In W step

module _ {P : Set} (see : W → P) where
open View see

unfold : W → Beh In P
head (unfold w) = see w
tail (unfold w) i = unfold (step w i)

-- The coinductive relation and the word relation agree.
~→≋ : ∀ {w w′} → w ~ w′ → unfold w ≋ unfold w′
head≡ (~→≋ e) = e []
tail≋ (~→≋ e) i = ~→≋ (λ is → e (i ∷ is))

≋→~ : ∀ {w w′} → unfold w ≋ unfold w′ → w ~ w′
≋→~ r [] = head≡ r
≋→~ r (i ∷ is) = ≋→~ (tail≋ r i) is

module _ {P₁ P₂ : Set} (see₁ : W → P₁) (see₂ : W → P₂) where
open Two see₁ see₂

-- One world gives two experiences that agree up to Coherent, for ever.
one-world : ∀ w → Lift Coherent (unfold see₁ w) (unfold see₂ w)
headT (one-world w) = w , refl , refl
tailT (one-world w) i = one-world (step w i)
Loading
Loading