Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sgdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gradual-typing
sgdt
Commits
f4b0666a
Commit
f4b0666a
authored
2 years ago
by
Eric Giovannini
Browse files
Options
Downloads
Patches
Plain Diff
denotational semantics
parent
0a8d2b96
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
formalizations/guarded-cubical/Interpretation.agda
+91
-0
91 additions, 0 deletions
formalizations/guarded-cubical/Interpretation.agda
with
91 additions
and
0 deletions
formalizations/guarded-cubical/Interpretation.agda
0 → 100644
+
91
−
0
View file @
f4b0666a
{-# OPTIONS --cubical --rewriting --guarded #-}
-- Define the interpretation of the syntax
open import Later
module Interpretation (k : Clock) where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Transport
open import Cubical.Data.Unit
open import Cubical.Data.Nat hiding (_^_)
open import Cubical.Data.Prod
open import Cubical.Data.Empty
open import Cubical.Relation.Binary.Poset
open import ErrorDomains k
open import GradualSTLC
private
variable
l : Level
A B : Set l
private
▹_ : Set l → Set l
▹_ A = ▹_,_ k A
-- Denotational semantics
⟦_⟧ty : Ty -> Type
⟦ nat ⟧ty = ℕ
⟦ dyn ⟧ty = Dyn
⟦ A => B ⟧ty = ⟦ A ⟧ty -> L℧ ⟦ B ⟧ty
⟦_⟧ctx : Ctx -> Type
⟦ · ⟧ctx = Unit
⟦ Γ :: A ⟧ctx = ⟦ Γ ⟧ctx × ⟦ A ⟧ty
-- Agda can infer that the context is not empty, so
-- ⟦ Γ ⟧ctx must be a product
-- Make A implicit
look : {Γ : Ctx} -> (env : ⟦ Γ ⟧ctx) -> (A : Ty) -> (x : Γ ∋ A) -> ⟦ A ⟧ty
look env A vz = proj₂ env
look env A (vs {Γ} {S} {T} x) = look (proj₁ env) A x
{-
lookup : (Γ : Ctx) -> (A : Ty) -> (x : Γ ∋ A) -> ⟦ A ⟧ty
lookup (Γ :: A) A vz = proj₂ {!!}
lookup Γ A (vs y) = {!!}
-}
⟦_⟧lt : {A B : Ty} -> A ⊑ B -> EP ⟦ A ⟧ty ⟦ B ⟧ty
⟦ dyn ⟧lt = EP-id Dyn
⟦ A⊑A' => B⊑B' ⟧lt = EP-lift ⟦ A⊑A' ⟧lt ⟦ B⊑B' ⟧lt
⟦ nat ⟧lt = EP-id ℕ
⟦ inj-nat ⟧lt = EP-nat
⟦ inj-arrow (A-dyn => B-dyn) ⟧lt =
EP-comp (EP-lift ⟦ A-dyn ⟧lt ⟦ B-dyn ⟧lt) EP-fun
⟦_⟧tm : {Γ : Ctx} {A : Ty} -> Tm Γ A -> (⟦ Γ ⟧ctx -> L℧ ⟦ A ⟧ty)
⟦ var x ⟧tm = λ ⟦Γ⟧ -> ret (look ⟦Γ⟧ _ x)
⟦ lda M ⟧tm = λ ⟦Γ⟧ -> ret ( λ N -> ⟦ M ⟧tm (⟦Γ⟧ , N) )
⟦ app M1 M2 ⟧tm =
-- λ Γ -> bind (⟦ M1 ⟧tm Γ) λ f -> bind (⟦ M2 ⟧tm Γ) f
λ Γ -> bind (⟦ M1 ⟧tm Γ) (bind (⟦ M2 ⟧tm Γ))
⟦ err ⟧tm ⟦Γ⟧ = ℧
⟦ up {Γ = Γ2} {A = A} {B = B} A⊑B M ⟧tm =
λ ⟦Γ⟧ -> mapL (EP.emb ⟦ A⊑B ⟧lt) (⟦ M ⟧tm ⟦Γ⟧)
-- Equivalently:
-- EP.emb (EP-L ⟦ A⊑B ⟧lt) (⟦ M ⟧tm ⟦Γ⟧)
⟦ dn {A = A} {B = B} A⊑B M ⟧tm =
λ ⟦Γ⟧ -> bind (⟦ M ⟧tm ⟦Γ⟧) (EP.proj ⟦ A⊑B ⟧lt)
mapL-emb : {A A' : Type} -> (epAA' : EP A A') (a : L℧ A) ->
mapL (EP.emb epAA') a ≡ EP.emb (EP-L epAA') a
mapL-emb epAA' a = refl
--------------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment