module A201607.BasicIPC.Metatheory.Hilbert-KripkeConcreteGluedImplicit where
open import A201607.BasicIPC.Syntax.Hilbert public
open import A201607.BasicIPC.Semantics.KripkeConcreteGluedImplicit public
open ImplicitSyntax (_⊢_) (mono⊢) public
module _ {{_ : Model}} where
reify : ∀ {A w} → w ⊩ A → unwrap w ⊢ A
reify {α P} s = syn s
reify {A ▻ B} s = syn s
reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s))
reify {⊤} s = unit
reify⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → unwrap w ⊢⋆ Ξ
reify⋆ {∅} ∙ = ∙
reify⋆ {Ξ , A} (ts , t) = reify⋆ ts , reify t
module _ {{_ : Model}} where
⟪K⟫ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A
⟪K⟫ {A} a = app ck (reify a) ⅋ λ ξ →
K (mono⊩ {A} ξ a)
⟪S⟫′ : ∀ {A B C w} → w ⊩ A ▻ B ▻ C → w ⊩ (A ▻ B) ▻ A ▻ C
⟪S⟫′ {A} {B} {C} s₁ = app cs (syn s₁) ⅋ λ ξ s₂ →
app (app cs (mono⊢ (unwrap≤ ξ) (syn s₁))) (syn s₂) ⅋ λ ξ′ →
⟪S⟫ (mono⊩ {A ▻ B ▻ C} (trans≤ ξ ξ′) s₁) (mono⊩ {A ▻ B} ξ′ s₂)
_⟪,⟫′_ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A ∧ B
_⟪,⟫′_ {A} a = app cpair (reify a) ⅋ λ ξ →
_,_ (mono⊩ {A} ξ a)
eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A
eval (var i) γ = lookup i γ
eval (app t u) γ = eval t γ ⟪$⟫ eval u γ
eval ci γ = ci ⅋ K I
eval ck γ = ck ⅋ K ⟪K⟫
eval cs γ = cs ⅋ K ⟪S⟫′
eval cpair γ = cpair ⅋ K _⟪,⟫′_
eval cfst γ = cfst ⅋ K π₁
eval csnd γ = csnd ⅋ K π₂
eval unit γ = ∙
private
instance
canon : Model
canon = record
{ _⊩ᵅ_ = λ w P → unwrap w ⊢ α P
; mono⊩ᵅ = λ ξ t → mono⊢ (unwrap≤ ξ) t
}
reflectᶜ : ∀ {A w} → unwrap w ⊢ A → w ⊩ A
reflectᶜ {α P} t = t ⅋ t
reflectᶜ {A ▻ B} t = t ⅋ λ ξ a → reflectᶜ (app (mono⊢ (unwrap≤ ξ) t) (reify a))
reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t)
reflectᶜ {⊤} t = ∙
reflectᶜ⋆ : ∀ {Ξ w} → unwrap w ⊢⋆ Ξ → w ⊩⋆ Ξ
reflectᶜ⋆ {∅} ∙ = ∙
reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t
refl⊩⋆ : ∀ {w} → w ⊩⋆ unwrap w
refl⊩⋆ = reflectᶜ⋆ refl⊢⋆
trans⊩⋆ : ∀ {w w′ w″} → w ⊩⋆ unwrap w′ → w′ ⊩⋆ unwrap w″ → w ⊩⋆ unwrap w″
trans⊩⋆ ts us = reflectᶜ⋆ (trans⊢⋆ (reify⋆ ts) (reify⋆ us))
quot : ∀ {A Γ} → Γ ⊨ A → Γ ⊢ A
quot s = reify (s refl⊩⋆)
norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A
norm = quot ∘ eval