Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1.  
  2. open import Function using (_$_) renaming (_∘′_ to _∘_) public
  3. open import Category.Monad public
  4. open import Data.Empty using (⊥) public
  5. open import Data.Unit using (⊤) renaming (tt to •) public
  6. open import Data.Fin using (Fin) renaming (zero to zeroᶠ; suc to sucᶠ) public
  7. open import Data.Product using (_×_) renaming (_,_ to ⟨_,_⟩; proj₁ to π₁; proj₂ to π₂) public
  8. open import Data.Bool using (Bool; true; false; if_then_else_; not) renaming (_∧_ to _and_; _∨_ to _or_) public
  9. open import Data.Maybe using (Maybe; just; nothing) renaming (monad to Mmonad) public
  10. open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst₂; cong₂) public
  11. open import Relation.Nullary using (Dec; yes; no; ¬_) public
  12.  
  13.  
  14. -- Atoms, used as variable identifiers.
  15. open import Data.Nat using (ℕ) renaming (zero to zeroⁿ; suc to sucⁿ)
  16.  
  17. Atom : Set
  18. Atom = ℕ
  19.  
  20. v₀ v₁ v₂ : Atom
  21. v₀ = 0
  22. v₁ = 1
  23. v₂ = 2
  24.  
  25.  
  26. -- Lists, used as contexts.
  27. data List (A : Set) : Set where
  28. ∅ : List A
  29. _,_ : List A → A → List A
  30. infixl 10 _,_
  31.  
  32. [_] : ∀ {A} → A → List A
  33. [ x ] = ∅ , x
  34.  
  35.  
  36. -- List inclusion, or de Bruijn indices.
  37. data _∈_ {A} : A → List A → Set where
  38. zero : ∀ {x xs} → x ∈ xs , x
  39. suc : ∀ {x y xs} → x ∈ xs → x ∈ xs , y
  40. infix 8 _∈_
  41.  
  42.  
  43. -- Context extension.
  44. data _⊆_ {A} : List A → List A → Set where
  45. stop : ∀ {Γ} → Γ ⊆ Γ
  46. skip : ∀ {Γ Γ' A} → Γ ⊆ Γ' → Γ ⊆ Γ' , A
  47. keep : ∀ {Γ Γ' A} → Γ ⊆ Γ' → Γ , A ⊆ Γ' , A
  48. infix 8 _⊆_
  49.  
  50.  
  51.  
  52. -- List concatenation.
  53. _⧺_ : ∀ {A} → List A → List A → List A
  54. Γ ⧺ ∅ = Γ
  55. Γ ⧺ Δ , A = (Γ ⧺ Δ) , A
  56. infixl 9 _⧺_ _⁏_
  57.  
  58. _⁏_ : ∀ {A} → List A → List A → List A
  59. _⁏_ = _⧺_
  60.  
  61. assoc⧺ : ∀ {A} {L₁ L₂ L₃ : List A} → L₁ ⧺ (L₂ ⧺ L₃) ≡ (L₁ ⧺ L₂) ⧺ L₃
  62. assoc⧺ {L₃ = ∅} = refl
  63. assoc⧺ {L₃ = xs , x} = cong₂ _,_ (assoc⧺ {L₃ = xs}) refl
  64.  
  65. unit⧺₁ : ∀ {A} {L : List A} → ∅ ⧺ L ≡ L
  66. unit⧺₁ {L = ∅} = refl
  67. unit⧺₁ {L = xs , x} = cong₂ _,_ (unit⧺₁ {L = xs}) refl
  68.  
  69. unit⧺₂ : ∀ {A} {L₁ L₂ : List A} → ∅ ⧺ L₁ ⧺ L₂ ≡ L₁ ⧺ L₂
  70. unit⧺₂ {L₁ = L₁} {L₂} = trans (sym (assoc⧺ {L₁ = ∅} {L₁} {L₂})) unit⧺₁
  71.  
  72.  
  73. -- Types reused by multiple systems.
  74. data ★ : Set where
  75. ι : ★
  76. _⊳_ : ★ → ★ → ★
  77. infixr 8 _⊳_
  78.  
  79.  
  80. data Form : Set where
  81. var : Atom → Form
  82. _⇒_ : Form → Form → Form
  83. infixr 10 _⇒_
  84.  
  85. Cx : Set
  86. Cx = List Form
  87.  
  88. data _⊢_ : Cx → Form → Set where
  89. ID : ∀ {A} → [ A ] ⊢ A
  90. MP : ∀ {Γ₁ Γ₂ A B} → Γ₁ ⊢ A ⇒ B → Γ₂ ⊢ A → Γ₁ ⁏ Γ₂ ⊢ B
  91. EX : ∀ {Γ₁ Γ₂ A} → Γ₁ ⁏ Γ₂ ⊢ A → Γ₂ ⁏ Γ₁ ⊢ A
  92. AB : ∀ {A B C} → ∅ ⊢ (B ⇒ C) ⇒ (A ⇒ B) ⇒ (A ⇒ C)
  93. AC : ∀ {A B C} → ∅ ⊢ (A ⇒ B ⇒ C) ⇒ B ⇒ A ⇒ C
  94. AI : ∀ {A} → ∅ ⊢ A ⇒ A
  95. infix 5 _⊢_
  96.  
  97.  
  98. ded : ∀ {Γ Δ A B} → Γ ⊢ B → Γ ≡ Δ , A → Δ ⊢ A ⇒ B
  99. ded ID refl = AI
  100. ded (MP {Γ₂ = ∅} t₁ t₂) eq = subst₂ _⊢_ unit⧺₁ refl (MP (MP AC (ded t₁ eq)) t₂)
  101. ded (MP {Γ₁} {xs , A} t₁ t₂) refl = subst₂ _⊢_ (unit⧺₂ {L₁ = Γ₁} {xs}) refl (MP (MP AB t₁) (ded t₂ refl))
  102. ded (EX {∅} t) refl = subst₂ _⊢_ unit⧺₁ refl (ded t refl)
  103. ded (EX {Γ₁ , A} {∅} t) refl = subst₂ _⊢_ (sym unit⧺₁) refl (ded t refl)
  104. ded (EX {Γ₁ , A} {Γ₂ , x} t) refl = {!ded t refl!}
  105. ded AB ()
  106. ded AC ()
  107. ded AI ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement