module A201602.Try13 where
open import Data.Maybe using (Maybe ; just ; nothing)
open import Data.Nat using (ℕ ; zero ; suc)
open import Data.Product using (Σ) renaming (_,_ to ⟨_,_⟩)
infixl 9 !_ 𝑣_
infixl 8 𝜋₀_ 𝜋₀²_ 𝜋₀ⁿ_ 𝜋₁_ 𝜋₁²_ 𝜋₁ⁿ_
infixl 7 _∘_ _∘²_ _∘ⁿ_
infixr 6 ⇑_ ⇑²_ ⇑ⁿ_ ⇓_ ⇓²_ ⇓ⁿ_
infixr 5 𝜆_·_ 𝜆²_·_ 𝜆ⁿ_·_
infixr 4 _∶_
infixr 3 ¬_
infixr 2 _‘_
infixl 2 _,_ _∧_
infixr 1 _⊃_ _⊃⊂_
infixr 0 _⊢_∷_ ⊩_ ⊩_∷_ ⊩_∷_∷_
Var : Set
Var = ℕ
mutual
data Ty : Set where
⊥ : Ty
_⊃_ : Ty → Ty → Ty
_∧_ : Ty → Ty → Ty
_∶_ : Tm → Ty → Ty
data Tm : Set where
𝑣_ : Var → Tm
𝜆[_]_·_ : ℕ → Var → Tm → Tm
_∘[_]_ : Tm → ℕ → Tm → Tm
𝑝[_]⟨_,_⟩ : ℕ → Tm → Tm → Tm
𝜋₀[_]_ : ℕ → Tm → Tm
𝜋₁[_]_ : ℕ → Tm → Tm
!_ : Tm → Tm
⇑[_]_ : ℕ → Tm → Tm
⇓[_]_ : ℕ → Tm → Tm
⊤ : Ty
⊤ = ⊥ ⊃ ⊥
¬_ : Ty → Ty
¬ A = A ⊃ ⊥
_⊃⊂_ : Ty → Ty → Ty
A ⊃⊂ B = A ⊃ B ∧ B ⊃ A
𝜆_·_ : Var → Tm → Tm
𝜆 x · t = 𝜆[ 1 ] x · t
_∘_ : Tm → Tm → Tm
t ∘ s = t ∘[ 1 ] s
𝑝⟨_,_⟩ : Tm → Tm → Tm
𝑝⟨ t , s ⟩ = 𝑝[ 1 ]⟨ t , s ⟩
𝜋₀_ : Tm → Tm
𝜋₀ t = 𝜋₀[ 1 ] t
𝜋₁_ : Tm → Tm
𝜋₁ t = 𝜋₁[ 1 ] t
⇑_ : Tm → Tm
⇑ t = ⇑[ 1 ] t
⇓_ : Tm → Tm
⇓ t = ⇓[ 1 ] t
𝜆²_·_ : Var → Tm → Tm
𝜆² x₂ · t₂ = 𝜆[ 2 ] x₂ · t₂
_∘²_ : Tm → Tm → Tm
t₂ ∘² s₂ = t₂ ∘[ 2 ] s₂
𝑝²⟨_,_⟩ : Tm → Tm → Tm
𝑝²⟨ t₂ , s₂ ⟩ = 𝑝[ 2 ]⟨ t₂ , s₂ ⟩
𝜋₀²_ : Tm → Tm
𝜋₀² t₂ = 𝜋₀[ 2 ] t₂
𝜋₁²_ : Tm → Tm
𝜋₁² t₂ = 𝜋₁[ 2 ] t₂
⇑²_ : Tm → Tm
⇑² t₂ = ⇑[ 2 ] t₂
⇓²_ : Tm → Tm
⇓² t₂ = ⇓[ 2 ] t₂
data Vec (X : Set) : ℕ → Set where
[] : Vec X zero
_‘_ : ∀{n} → X → Vec X n → Vec X (suc n)
append : ∀{n} {X : Set}
→ Vec X n → X → Vec X (suc n)
append [] y = y ‘ []
append (x ‘ xs) y = x ‘ append xs y
foldr : ∀{n} {X : Set} (Y : ℕ → Set)
→ (∀{k} → X → Y k → Y (suc k)) → Y zero → Vec X n → Y n
foldr Y f y₀ [] = y₀
foldr Y f y₀ (x ‘ xs) = f x (foldr Y f y₀ xs)
ixMap : ∀{n} {X Y : Set}
→ (ℕ → X → Y) → Vec X n → Vec Y n
ixMap {zero} f [] = []
ixMap {suc n} f (x ‘ xs) = f (suc n) x ‘ ixMap f xs
ixZipWith : ∀{n} {X Y Z : Set}
→ (ℕ → X → Y → Z) → Vec X n → Vec Y n → Vec Z n
ixZipWith {zero} f [] [] = []
ixZipWith {suc n} f (x ‘ xs) (y ‘ ys) = f (suc n) x y ‘ ixZipWith f xs ys
map : ∀{n} {X Y : Set}
→ (X → Y) → Vec X n → Vec Y n
map f = ixMap (λ _ x → f x)
zip : ∀{n} {X Y Z : Set}
→ (X → Y → Z) → Vec X n → Vec Y n → Vec Z n
zip f = ixZipWith (λ _ x y → f x y)
[_] : {X : Set} → X → Vec X 1
[ x ] = x ‘ []
[_∷_] : {X : Set} → X → X → Vec X 2
[ x₂ ∷ x ] = x₂ ‘ x ‘ []
Vars : ℕ → Set
Vars = Vec Var
Tms : ℕ → Set
Tms = Vec Tm
𝜆ⁿ_·_ : ∀{n} → Vars n → Tms n → Tms n
𝜆ⁿ_·_ = ixZipWith 𝜆[_]_·_
_∘ⁿ_ : ∀{n} → Tms n → Tms n → Tms n
_∘ⁿ_ = ixZipWith (λ n t s → t ∘[ n ] s)
𝑝ⁿ⟨_,_⟩ : ∀{n} → Tms n → Tms n → Tms n
𝑝ⁿ⟨_,_⟩ = ixZipWith 𝑝[_]⟨_,_⟩
𝜋₀ⁿ_ : ∀{n} → Tms n → Tms n
𝜋₀ⁿ_ = ixMap 𝜋₀[_]_
𝜋₁ⁿ_ : ∀{n} → Tms n → Tms n
𝜋₁ⁿ_ = ixMap 𝜋₁[_]_
⇑ⁿ_ : ∀{n} → Tms n → Tms n
⇑ⁿ_ = ixMap ⇑[_]_
⇓ⁿ_ : ∀{n} → Tms n → Tms n
⇓ⁿ_ = ixMap ⇓[_]_
record Hyp (n : ℕ) : Set where
constructor ⟨_∷_⟩
field
tms : Tms n
ty : Ty
data Cx : ℕ → Set where
∅ : Cx zero
_,_ : ∀{m n} → Cx m → Hyp n → Cx (suc m)
data _∈_ : ∀{m n} → Hyp n → Cx m → Set where
Z : ∀{m n} {Γ : Cx m} {A : Hyp n}
→ A ∈ (Γ , A)
S_ : ∀{m n k} {Γ : Cx m} {A : Hyp n} {B : Hyp k}
→ A ∈ Γ
→ A ∈ (Γ , B)
data _⊢_∷_ {m : ℕ} (Γ : Cx m) : ∀{n} → Tms n → Ty → Set where
M𝑣 : ∀{A n} {ts : Tms n}
→ ⟨ ts ∷ A ⟩ ∈ Γ
→ Γ ⊢ ts ∷ A
M𝜆 : ∀{A B n} {xs : Vars n} {ts : Tms n}
→ Γ , ⟨ map 𝑣_ xs ∷ A ⟩ ⊢ ts ∷ B
→ Γ ⊢ 𝜆ⁿ xs · ts ∷ A ⊃ B
M∘ : ∀{A B n} {ts ss : Tms n}
→ Γ ⊢ ts ∷ A ⊃ B → Γ ⊢ ss ∷ A
→ Γ ⊢ ts ∘ⁿ ss ∷ B
M𝑝 : ∀{A B n} {ts ss : Tms n}
→ Γ ⊢ ts ∷ A → Γ ⊢ ss ∷ B
→ Γ ⊢ 𝑝ⁿ⟨ ts , ss ⟩ ∷ A ∧ B
M𝜋₀ : ∀{A B n} {ts : Tms n}
→ Γ ⊢ ts ∷ A ∧ B
→ Γ ⊢ 𝜋₀ⁿ ts ∷ A
M𝜋₁ : ∀{A B n} {ts : Tms n}
→ Γ ⊢ ts ∷ A ∧ B
→ Γ ⊢ 𝜋₁ⁿ ts ∷ B
M⇑ : ∀{A u n} {ts : Tms n}
→ Γ ⊢ ts ∷ u ∶ A
→ Γ ⊢ ⇑ⁿ ts ∷ ! u ∶ u ∶ A
M⇓ : ∀{A u n} {ts : Tms n}
→ Γ ⊢ ts ∷ u ∶ A
→ Γ ⊢ ⇓ⁿ ts ∷ A
M⁻ : ∀{A u n} {ts : Tms n}
→ Γ ⊢ ts ∷ u ∶ A
→ Γ ⊢ append ts u ∷ A
M⁺ : ∀{A u n} {ts : Tms n}
→ Γ ⊢ append ts u ∷ A
→ Γ ⊢ ts ∷ u ∶ A
_⊢_ : ∀{m n} → Cx m → Hyp n → Set
Γ ⊢ ⟨ ts ∷ A ⟩ = Γ ⊢ ts ∷ A
⊩_ : Ty → Set
⊩ A = ∀{m} {Γ : Cx m} → Γ ⊢ [] ∷ A
⊩_∷_ : Tm → Ty → Set
⊩ t ∷ A = ∀{m} {Γ : Cx m} → Γ ⊢ [ t ] ∷ A
⊩_∷_∷_ : Tm → Tm → Ty → Set
⊩ t₂ ∷ t ∷ A = ∀{m} {Γ : Cx m} → Γ ⊢ [ t₂ ∷ t ] ∷ A
eI⁰ : ∀{A}
→ ⊩ A ⊃ A
eI⁰ = M𝜆 (M𝑣 Z)
eI¹ : ∀{A x}
→ ⊩ 𝜆 x · 𝑣 x
∷ A ⊃ A
eI¹ = M𝜆 (M𝑣 Z)
eI² : ∀{A x u}
→ ⊩ 𝜆² u · 𝑣 u
∷ 𝜆 x · 𝑣 x
∷ A ⊃ A
eI² = M𝜆 (M𝑣 Z)
eK⁰ : ∀{A B}
→ ⊩ A ⊃ B ⊃ A
eK⁰ = M𝜆 (M𝜆 (M𝑣 (S Z)))
eK¹ : ∀{A B x y}
→ ⊩ 𝜆 x · 𝜆 y · 𝑣 x
∷ A ⊃ B ⊃ A
eK¹ = M𝜆 (M𝜆 (M𝑣 (S Z)))
eK² : ∀{A B x y u v}
→ ⊩ 𝜆² u · 𝜆² v · 𝑣 u
∷ 𝜆 x · 𝜆 y · 𝑣 x
∷ A ⊃ B ⊃ A
eK² = M𝜆 (M𝜆 (M𝑣 (S Z)))
eS⁰ : ∀{A B C}
→ ⊩ (A ⊃ B ⊃ C) ⊃ (A ⊃ B) ⊃ A ⊃ C
eS⁰ = M𝜆 (M𝜆 (M𝜆 (M∘ (M∘ (M𝑣 (S S Z))
(M𝑣 Z))
(M∘ (M𝑣 (S Z))
(M𝑣 Z)))))
eS¹ : ∀{A B C f g x}
→ ⊩ 𝜆 f · 𝜆 g · 𝜆 x · (𝑣 f ∘ 𝑣 x) ∘ (𝑣 g ∘ 𝑣 x)
∷ (A ⊃ B ⊃ C) ⊃ (A ⊃ B) ⊃ A ⊃ C
eS¹ = M𝜆 (M𝜆 (M𝜆 (M∘ (M∘ (M𝑣 (S S Z))
(M𝑣 Z))
(M∘ (M𝑣 (S Z))
(M𝑣 Z)))))
eS² : ∀{A B C f g x p q u}
→ ⊩ 𝜆² p · 𝜆² q · 𝜆² u · (𝑣 p ∘² 𝑣 u) ∘² (𝑣 q ∘² 𝑣 u)
∷ 𝜆 f · 𝜆 g · 𝜆 x · (𝑣 f ∘ 𝑣 x) ∘ (𝑣 g ∘ 𝑣 x)
∷ (A ⊃ B ⊃ C) ⊃ (A ⊃ B) ⊃ A ⊃ C
eS² = M𝜆 (M𝜆 (M𝜆 (M∘ (M∘ (M𝑣 (S S Z))
(M𝑣 Z))
(M∘ (M𝑣 (S Z))
(M𝑣 Z)))))
axK⁰ : ∀{A B f x}
→ ⊩ (f ∶ (A ⊃ B)) ⊃ x ∶ A ⊃ (f ∘ x) ∶ B
axK⁰ = M𝜆 (M𝜆 (M⁺ (M∘ (M⁻ (M𝑣 (S Z)))
(M⁻ (M𝑣 Z)))))
axK¹ : ∀{A B f x p u}
→ ⊩ 𝜆 p · 𝜆 u · 𝑣 p ∘² 𝑣 u
∷ f ∶ (A ⊃ B) ⊃ x ∶ A ⊃ (f ∘ x) ∶ B
axK¹ = M𝜆 (M𝜆 (M⁺ (M∘ (M⁻ (M𝑣 (S Z)))
(M⁻ (M𝑣 Z)))))
axT⁰ : ∀{A x}
→ ⊩ x ∶ A ⊃ A
axT⁰ = M𝜆 (M⇓ (M𝑣 Z))
ax4⁰ : ∀{A x}
→ ⊩ x ∶ A ⊃ ! x ∶ x ∶ A
ax4⁰ = M𝜆 (M⇑ (M𝑣 Z))
e11 : ∀{A x y}
→ ⊩ 𝜆 y · ⇓ 𝑣 y
∷ x ∶ A ⊃ A
e11 = M𝜆 (M⇓ (M𝑣 Z))
e12 : ∀{A x y}
→ ⊩ 𝜆 y · ⇑ 𝑣 y
∷ x ∶ A ⊃ ! x ∶ x ∶ A
e12 = M𝜆 (M⇑ (M𝑣 Z))
e13 : ∀{A B x y u v}
→ ⊩ 𝜆² u · 𝜆² v · 𝑝²⟨ 𝑣 u , 𝑣 v ⟩
∷ 𝜆 x · 𝜆 y · 𝑝⟨ 𝑣 x , 𝑣 y ⟩
∷ A ⊃ B ⊃ A ∧ B
e13 = M𝜆 (M𝜆 (M𝑝 (M𝑣 (S Z))
(M𝑣 Z)))
e14 : ∀{A B x y u v}
→ ⊩ 𝜆 u · 𝜆 v · ⇑ 𝑝²⟨ 𝑣 u , 𝑣 v ⟩
∷ x ∶ A ⊃ y ∶ B ⊃ ! 𝑝⟨ x , y ⟩ ∶ 𝑝⟨ x , y ⟩ ∶ (A ∧ B)
e14 = M𝜆 (M𝜆 (M⇑ (M⁺ (M𝑝 (M⁻ (M𝑣 (S Z)))
(M⁻ (M𝑣 Z))))))
ex1 : ∀{A B x y u v}
→ ⊩ 𝜆 u · 𝜆 v · 𝑝²⟨ 𝑣 u , 𝑣 v ⟩
∷ x ∶ A ⊃ y ∶ B ⊃ 𝑝⟨ x , y ⟩ ∶ (A ∧ B)
ex1 = M𝜆 (M𝜆 (M⁺ (M𝑝 (M⁻ (M𝑣 (S Z)))
(M⁻ (M𝑣 Z)))))
ex2 : ∀{A B x y u}
→ ⊩ 𝜆 u · ⇑ 𝑝²⟨ 𝜋₀ 𝑣 u , 𝜋₁ 𝑣 u ⟩
∷ x ∶ A ∧ y ∶ B ⊃ ! 𝑝⟨ x , y ⟩ ∶ 𝑝⟨ x , y ⟩ ∶ (A ∧ B)
ex2 = M𝜆 (M⇑ (M⁺ (M𝑝 (M⁻ (M𝜋₀ (M𝑣 Z)))
(M⁻ (M𝜋₁ (M𝑣 Z))))))
ex3 : ∀{A B x y u}
→ ⊩ 𝜆 u · 𝑝²⟨ 𝜋₀ 𝑣 u , 𝜋₁ 𝑣 u ⟩
∷ x ∶ A ∧ y ∶ B ⊃ 𝑝⟨ x , y ⟩ ∶ (A ∧ B)
ex3 = M𝜆 (M⁺ (M𝑝 (M⁻ (M𝜋₀ (M𝑣 Z)))
(M⁻ (M𝜋₁ (M𝑣 Z)))))
e2 : ∀{A x₃ x₂ x₁}
→ ⊩ 𝜆² x₃ · ⇓² ⇑² 𝑣 x₃
∷ 𝜆 x₂ · ⇓ ⇑ 𝑣 x₂
∷ x₁ ∶ A ⊃ x₁ ∶ A
e2 = M𝜆 (M⇓ (M⇑ (M𝑣 Z)))
e2′ : ∀{A x₃ x₂ x₁}
→ ⊩ 𝜆² x₃ · 𝑣 x₃
∷ 𝜆 x₂ · 𝑣 x₂
∷ x₁ ∶ A ⊃ x₁ ∶ A
e2′ = M𝜆 (M𝑣 Z)
data _≲_ : ∀{m m′} → Cx m → Cx m′ → Set where
base : ∅ ≲ ∅
keep : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≲ Γ′
→ (Γ , A) ≲ (Γ′ , A)
drop : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≲ Γ′
→ Γ ≲ (Γ′ , A)
∅≲Γ : ∀{m} {Γ : Cx m} → ∅ ≲ Γ
∅≲Γ {Γ = ∅} = base
∅≲Γ {Γ = Γ , A} = drop ∅≲Γ
Γ≲Γ : ∀{m} {Γ : Cx m} → Γ ≲ Γ
Γ≲Γ {Γ = ∅} = base
Γ≲Γ {Γ = Γ , A} = keep Γ≲Γ
wk∈ : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≲ Γ′ → A ∈ Γ
→ A ∈ Γ′
wk∈ base ()
wk∈ (keep P) Z = Z
wk∈ (keep P) (S i) = S wk∈ P i
wk∈ (drop P) i = S wk∈ P i
wk⊢ : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≲ Γ′ → Γ ⊢ A
→ Γ′ ⊢ A
wk⊢ P (M𝑣 i) = M𝑣 (wk∈ P i)
wk⊢ P (M𝜆 D) = M𝜆 (wk⊢ (keep P) D)
wk⊢ P (M∘ D D′) = M∘ (wk⊢ P D) (wk⊢ P D′)
wk⊢ P (M𝑝 D D′) = M𝑝 (wk⊢ P D) (wk⊢ P D′)
wk⊢ P (M𝜋₀ D) = M𝜋₀ (wk⊢ P D)
wk⊢ P (M𝜋₁ D) = M𝜋₁ (wk⊢ P D)
wk⊢ P (M⇑ D) = M⇑ (wk⊢ P D)
wk⊢ P (M⇓ D) = M⇓ (wk⊢ P D)
wk⊢ P (M⁻ D) = M⁻ (wk⊢ P D)
wk⊢ P (M⁺ D) = M⁺ (wk⊢ P D)
data _≳_ : ∀{m m′} → Cx m → Cx m′ → Set where
base : ∅ ≳ ∅
once : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≳ Γ′
→ (Γ , A) ≳ (Γ′ , A)
more : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≳ Γ′
→ ((Γ , A) , A) ≳ (Γ′ , A)
cn∈ : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≳ Γ′ → A ∈ Γ
→ A ∈ Γ′
cn∈ base ()
cn∈ (once P) Z = Z
cn∈ (once P) (S i) = S cn∈ P i
cn∈ (more P) Z = Z
cn∈ (more P) (S i) = cn∈ (once P) i
cn⊢ : ∀{m m′ n} {Γ : Cx m} {Γ′ : Cx m′} {A : Hyp n}
→ Γ ≳ Γ′ → Γ ⊢ A
→ Γ′ ⊢ A
cn⊢ P (M𝑣 i) = M𝑣 (cn∈ P i)
cn⊢ P (M𝜆 D) = M𝜆 (cn⊢ (once P) D)
cn⊢ P (M∘ D D′) = M∘ (cn⊢ P D) (cn⊢ P D′)
cn⊢ P (M𝑝 D D′) = M𝑝 (cn⊢ P D) (cn⊢ P D′)
cn⊢ P (M𝜋₀ D) = M𝜋₀ (cn⊢ P D)
cn⊢ P (M𝜋₁ D) = M𝜋₁ (cn⊢ P D)
cn⊢ P (M⇑ D) = M⇑ (cn⊢ P D)
cn⊢ P (M⇓ D) = M⇓ (cn⊢ P D)
cn⊢ P (M⁻ D) = M⁻ (cn⊢ P D)
cn⊢ P (M⁺ D) = M⁺ (cn⊢ P D)
data _≈_ : ∀{m} → Cx m → Cx m → Set where
base : ∅ ≈ ∅
just : ∀{m n} {Γ Γ′ : Cx m} {A : Hyp n}
→ Γ ≈ Γ′
→ (Γ , A) ≈ (Γ′ , A)
same : ∀{m n k} {Γ Γ′ : Cx m} {A : Hyp n} {B : Hyp k}
→ Γ ≈ Γ′
→ ((Γ , A) , B) ≈ ((Γ′ , A) , B)
diff : ∀{m n k} {Γ Γ′ : Cx m} {A : Hyp n} {B : Hyp k}
→ Γ ≈ Γ′
→ ((Γ , B) , A) ≈ ((Γ′ , A) , B)
ex∈ : ∀{m n} {Γ Γ′ : Cx m} {A : Hyp n}
→ Γ ≈ Γ′ → A ∈ Γ
→ A ∈ Γ′
ex∈ base ()
ex∈ (just P) Z = Z
ex∈ (just P) (S i) = S ex∈ P i
ex∈ (same P) Z = Z
ex∈ (same P) (S Z) = S Z
ex∈ (same P) (S (S i)) = S (S ex∈ P i)
ex∈ (diff P) Z = S Z
ex∈ (diff P) (S Z) = Z
ex∈ (diff P) (S (S i)) = S (S ex∈ P i)
ex⊢ : ∀{m n} {Γ Γ′ : Cx m} {A : Hyp n}
→ Γ ≈ Γ′ → Γ ⊢ A
→ Γ′ ⊢ A
ex⊢ P (M𝑣 i) = M𝑣 (ex∈ P i)
ex⊢ P (M𝜆 D) = M𝜆 (ex⊢ (just P) D)
ex⊢ P (M∘ D D′) = M∘ (ex⊢ P D) (ex⊢ P D′)
ex⊢ P (M𝑝 D D′) = M𝑝 (ex⊢ P D) (ex⊢ P D′)
ex⊢ P (M𝜋₀ D) = M𝜋₀ (ex⊢ P D)
ex⊢ P (M𝜋₁ D) = M𝜋₁ (ex⊢ P D)
ex⊢ P (M⇑ D) = M⇑ (ex⊢ P D)
ex⊢ P (M⇓ D) = M⇓ (ex⊢ P D)
ex⊢ P (M⁻ D) = M⁻ (ex⊢ P D)
ex⊢ P (M⁺ D) = M⁺ (ex⊢ P D)
prefixHyp : ∀{n} → Tm → Hyp n → Hyp (suc n)
prefixHyp t ⟨ ts ∷ A ⟩ = ⟨ t ‘ ts ∷ A ⟩
prefixCx : ∀{m} → Tms m → Cx m → Cx m
prefixCx [] ∅ = ∅
prefixCx (t ‘ ts) (Γ , h) = prefixCx ts Γ , prefixHyp t h
int∈ : ∀{m n} {xs : Vars m} {Γ : Cx m} {A : Hyp n}
→ A ∈ Γ
→ Σ Var (λ x → prefixHyp (𝑣 x) A ∈ prefixCx (map 𝑣_ xs) Γ)
int∈ {xs = []} ()
int∈ {xs = x ‘ xs} Z = ⟨ x , Z ⟩
int∈ {xs = x ‘ xs} (S i) = let ⟨ y , j ⟩ = int∈ {xs = xs} i in ⟨ y , S j ⟩
postulate
fresh : Var