Skip to content
Snippets Groups Projects
Commit 2b99239d authored by Max New's avatar Max New
Browse files

Begin porting syntax to GTT and new Context rep

parent e24a9c26
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,6 @@ open import Common.Later hiding (next) ...@@ -9,8 +9,6 @@ open import Common.Later hiding (next)
module Syntax.Types where module Syntax.Types where
open import Cubical.Foundations.Prelude renaming (comp to compose) open import Cubical.Foundations.Prelude renaming (comp to compose)
open import Cubical.Data.Nat hiding (_·_) renaming (ℕ to Nat) open import Cubical.Data.Nat hiding (_·_) renaming (ℕ to Nat)
open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary
...@@ -20,12 +18,9 @@ open import Cubical.Foundations.Isomorphism ...@@ -20,12 +18,9 @@ open import Cubical.Foundations.Isomorphism
open import Cubical.Data.List open import Cubical.Data.List
using (List ; length ; map ; _++_ ; cons-inj₁ ; cons-inj₂) using (List ; length ; map ; _++_ ; cons-inj₁ ; cons-inj₂)
renaming ([] to · ; _∷_ to _::_) renaming ([] to · ; _∷_ to _::_)
open import Cubical.Data.Empty renaming (rec to exFalso) open import Cubical.Data.Empty renaming (rec to exFalso)
open import Syntax.Context as Context
import Syntax.DeBruijnCommon
private private
variable variable
...@@ -37,33 +32,27 @@ private ...@@ -37,33 +32,27 @@ private
data Interval : Type where data Interval : Type where
l r : Interval l r : Interval
data IntExt : Type where
Int Ext : IntExt
data iCtx : Type where data iCtx : Type where
Empty : iCtx Empty : iCtx
Full : iCtx Full : iCtx
private data Ty : iCtx -> Type
variable
α : IntExt
data Ty : {α : IntExt} -> iCtx -> Type ty-endpt : Interval -> Ty Full -> Ty Empty
ty-endpt : ∀ {α} -> Interval -> Ty {α} Full -> Ty {α} Empty _⊑_ : Ty Empty -> Ty Empty -> Type
A ⊑ B = Σ[ c ∈ Ty Full ] ((ty-endpt l c ≡ A) × (ty-endpt r c ≡ B))
data Ty where data Ty where
nat : ∀ {α Ξ} -> Ty {α} Ξ nat : ∀ {Ξ} -> Ty Ξ
dyn : ∀ {α Ξ} -> Ty {α} Ξ dyn : ∀ {Ξ} -> Ty Ξ
_⇀_ : ∀ {α Ξ} -> Ty {α} Ξ -> Ty {α} Ξ -> Ty {α} Ξ _⇀_ : ∀ {Ξ} -> Ty Ξ -> Ty Ξ -> Ty Ξ
inj-nat : ∀ {α} -> Ty {α} Full inj-nat : Ty Full
inj-arr : ∀ {α} -> Ty {α} Full inj-arr : Ty Full
comp : ∀ {α} -> (c : Ty {α} Full) -> (d : Ty {α} Full) -> comp : ∀ (c : Ty Full) -> (d : Ty Full) ->
(ty-endpt l c ≡ ty-endpt r d) -> Ty {α} Full (ty-endpt l c ≡ ty-endpt r d) -> Ty Full
-- order-set : isSet (Ty Full) -- isProp⊑ : ∀ {A B : Ty }
▹ : ∀ {Ξ} -> Ty {Int} Ξ -> Ty {Int} Ξ
ty-endpt p nat = nat ty-endpt p nat = nat
ty-endpt p dyn = dyn ty-endpt p dyn = dyn
...@@ -74,26 +63,27 @@ ty-endpt l inj-arr = (dyn ⇀ dyn) -- inj-arr : (dyn -> dyn) ⊑ dyn ...@@ -74,26 +63,27 @@ ty-endpt l inj-arr = (dyn ⇀ dyn) -- inj-arr : (dyn -> dyn) ⊑ dyn
ty-endpt r inj-arr = dyn ty-endpt r inj-arr = dyn
ty-endpt l (comp c d _) = ty-endpt l d ty-endpt l (comp c d _) = ty-endpt l d
ty-endpt r (comp c d _) = ty-endpt r c ty-endpt r (comp c d _) = ty-endpt r c
ty-endpt p (▹ A) = ▹ (ty-endpt p A)
_[_/i] : ∀ {α} -> Ty {α} Full -> Interval -> Ty {α} Empty
_[_/i] : Ty Full -> Interval -> Ty Empty
c [ p /i] = ty-endpt p c c [ p /i] = ty-endpt p c
ty-left : ∀ {α} -> Ty {α} Full -> Ty Empty ty-left : Ty Full -> Ty Empty
ty-left = ty-endpt l ty-left = ty-endpt l
ty-right : ∀ {α} -> Ty {α} Full -> Ty Empty ty-right : Ty Full -> Ty Empty
ty-right = ty-endpt r ty-right = ty-endpt r
CompTyRel : ∀ {α} -> Type CompTyRel : Type
CompTyRel {α} = Σ (Ty {α} Full × Ty Full) CompTyRel = Σ (Ty Full × Ty Full)
λ { (c' , c) -> (ty-left c') ≡ (ty-right c) } λ { (c' , c) -> (ty-left c') ≡ (ty-right c) }
CompTyRel-comp : ∀ {α} -> CompTyRel {α} -> Ty Full CompTyRel-comp : CompTyRel -> Ty Full
CompTyRel-comp ((c' , c) , pf) = comp c' c pf CompTyRel-comp ((c' , c) , pf) = comp c' c pf
CompTyRel-endpt : ∀ {α} -> Interval -> CompTyRel {α} -> Ty Full CompTyRel-endpt : Interval -> CompTyRel -> Ty Full
CompTyRel-endpt l ((c , d) , _) = c CompTyRel-endpt l ((c , d) , _) = c
CompTyRel-endpt r ((c , d) , _) = d CompTyRel-endpt r ((c , d) , _) = d
...@@ -101,69 +91,57 @@ CompTyRel-endpt r ((c , d) , _) = d ...@@ -101,69 +91,57 @@ CompTyRel-endpt r ((c , d) , _) = d
-- Given a "normal" type A, view it as its reflexivity precision derivation c : A ⊑ A. -- Given a "normal" type A, view it as its reflexivity precision derivation c : A ⊑ A.
ty-refl : Ty {α} Empty -> Ty {α} Full ty-refl : Ty Empty -> Ty Full
ty-refl nat = nat ty-refl nat = nat
ty-refl dyn = dyn ty-refl dyn = dyn
ty-refl (Ai ⇀ Ao) = ty-refl Ai ⇀ ty-refl Ao ty-refl (Ai ⇀ Ao) = ty-refl Ai ⇀ ty-refl Ao
ty-refl (▹ A) = ▹ (ty-refl A)
ty-endpt-refl : {A : Ty {α} Empty} -> (p : Interval) -> ty-endpt p (ty-refl A) ≡ A
ty-endpt-refl {_} {nat} p = refl
ty-endpt-refl {_} {dyn} p = refl
ty-endpt-refl {_} {A ⇀ B} p = cong₂ _⇀_ (ty-endpt-refl p) (ty-endpt-refl p)
ty-endpt-refl {_} {▹ A} p = cong ▹ (ty-endpt-refl p)
_⊑_ : Ty {α} Empty -> Ty Empty -> Type
A ⊑ B = Σ[ c ∈ Ty Full ] ((ty-left c ≡ A) × (ty-right c ≡ B))
ty-endpt-refl : {A : Ty Empty} -> (p : Interval) -> ty-endpt p (ty-refl A) ≡ A
ty-endpt-refl {nat} p = refl
ty-endpt-refl {dyn} p = refl
ty-endpt-refl {A ⇀ B} p = cong₂ _⇀_ (ty-endpt-refl p) (ty-endpt-refl p)
-- ############### Contexts ############### -- ############### Contexts ###############
open Ctx
TyCtx : iCtx → Type (ℓ-suc ℓ-zero)
Ctx : ∀ {α : IntExt} -> iCtx -> Type TyCtx Ξ = Ctx (Ty Ξ)
Ctx {α} Ξ = List (Ty {α} Ξ)
-- Endpoints of a full context -- Endpoints of a full context
ctx-endpt : (p : Interval) -> Ctx {α} Full -> Ctx Empty ctx-endpt : (p : Interval) -> TyCtx Full -> TyCtx Empty
ctx-endpt p = map (ty-endpt p) ctx-endpt p = Context.map (ty-endpt p)
CompCtx : (Δ Γ : Ctx {α} Full) -> (pf : ctx-endpt l Δ ≡ ctx-endpt r Γ) ->
Ctx {α} Full
CompCtx Δ Γ pf = {!!}
CompCtx : (Δ Γ : TyCtx Full)
-> (pf : ctx-endpt l Δ ≡ ctx-endpt r Γ)
-> TyCtx Full
CompCtx Δ Γ pf .var = Δ .var
CompCtx Δ Γ pf .isFinSetVar = Δ .isFinSetVar
CompCtx Δ Γ pf .el x = comp (Δ .el x)
(Γ .el (transport (cong var pf) x))
λ i → pf i .el (transport-filler (cong var pf) x i)
-- "Contains" relation stating that a context Γ contains a type T -- -- "Contains" relation stating that a context Γ contains a type T
data _∋_ : ∀ {Ξ} -> Ctx {α} Ξ -> Ty {α} Ξ -> Set where -- data _∋_ : ∀ {Ξ} -> Ctx Ξ -> Ty Ξ -> Set where
vz : ∀ {Ξ Γ S} -> _∋_ {α} {Ξ} (S :: Γ) S -- vz : ∀ {Ξ Γ S} -> _∋_ {Ξ} (S :: Γ) S
vs : ∀ {Ξ Γ S T} (x : _∋_ {α} {Ξ} Γ T) -> (S :: Γ ∋ T) -- vs : ∀ {Ξ Γ S T} (x : _∋_ {Ξ} Γ T) -> (S :: Γ ∋ T)
infix 4 _∋_ -- infix 4 _∋_
∋-ctx-endpt : {Γ : Ctx {α} Full} {c : Ty Full} -> (p : Interval) -> -- ∋-ctx-endpt : {Γ : Ctx Full} {c : Ty Full} -> (p : Interval) ->
(Γ ∋ c) -> ((ctx-endpt p Γ) ∋ (ty-endpt p c)) -- (Γ ∋ c) -> ((ctx-endpt p Γ) ∋ (ty-endpt p c))
∋-ctx-endpt p vz = vz -- ∋-ctx-endpt p vz = vz
∋-ctx-endpt p (vs Γ∋c) = vs (∋-ctx-endpt p Γ∋c) -- ∋-ctx-endpt p (vs Γ∋c) = vs (∋-ctx-endpt p Γ∋c)
-- View a "normal" typing context Γ as a type precision context where the derivation -- View a "normal" typing context Γ as a type precision context where the derivation
-- corresponding to each type A in Γ is just the reflexivity precision derivation A ⊑ A. -- corresponding to each type A in Γ is just the reflexivity precision derivation A ⊑ A.
ctx-refl : Ctx {α} Empty -> Ctx Full ctx-refl : TyCtx Empty -> TyCtx Full
ctx-refl = map ty-refl ctx-refl = Context.map ty-refl
--ctx-refl · = ·
--ctx-refl (A :: Γ) = ty-refl A :: ctx-refl Γ
-- For a given typing context, the endpoints of the corresponding reflexivity precision -- For a given typing context, the endpoints of the corresponding reflexivity precision
-- context are the typing context itself. -- context are the typing context itself.
ctx-endpt-refl : {Γ : Ctx {α} Empty} -> (p : Interval) -> ctx-endpt p (ctx-refl Γ) ≡ Γ ctx-endpt-refl : {Γ : TyCtx Empty} -> (p : Interval) -> ctx-endpt p (ctx-refl Γ) ≡ Γ
ctx-endpt-refl {_} {·} p = refl ctx-endpt-refl {Γ} p = Ctx≡ _ _ refl (funExt λ x → ty-endpt-refl {A = Γ .el x} p)
ctx-endpt-refl {_} {A :: Γ} p = cong₂ _::_ (ty-endpt-refl p) (ctx-endpt-refl p)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment