Ctx : ℕ → Set
Ctx = Vec TypeDecl
+
+roots : {n : ℕ} → Ctx n → List Name
+roots xs = go xs
+ where
+ open import Data.List using ([]; _∷_)
+
+ go : {n : ℕ} → Ctx n → List Name
+ go Vec.[] = []
+ go (Vec._∷_ x xs) =
+ case x of λ
+ { (var v t) → (root v) ∷ (roots xs)
+ ; _ → roots xs
+ }
+
+intersect-roots : List Name → List Name → List Name
+intersect-roots xs ys = intersect xs ys
+ where
+ open import Data.List using ([]; _∷_)
+ open import Data.String using (_≟_)
+
+ intersect : List Name → List Name → List Name
+ intersect [] _ = []
+ intersect _ [] = []
+ intersect (x ∷ xs) (y ∷ ys) with x ≟ y
+ ... | yes x≡y = x ∷ intersect xs ys
+ ... | no _ = intersect xs ys
module Typecheck where
+import Data.List as List
import Data.Vec.Equality as VecEq
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_)
open import Data.Nat using (ℕ; _+_)
{Γ₁ : Ctx k} {Γ₁' : Ctx k₁} {Γ₂ : Ctx p} {Γ₂' : Ctx p₁} {Γ' : Ctx m}
→ Γ₁ ⊢ b1 ▹ Γ₁'
→ Γ₂ ⊢ b2 ▹ Γ₂'
- -- TODO: Express that Γ = Γ₁, Γ₂ and Γ' = Γ₁', Γ₂' - disjoint unions
+ → intersect-roots (roots Γ₁') (roots Γ₂') ≡ List.[]
+ -- TODO: maybe it's not enough to express that Γ = Γ₁, Γ₂ and Γ' = Γ₁', Γ₂' - disjoint unions
---------------
→ Γ ⊢ par b1 b2 ▹ Γ'