module Behaviour where
-open import Data.Nat using (ℕ)
open import Data.String using (String)
-open import Data.Vec using (Vec)
+open import Data.List using (List)
open import Data.Product using (_×_)
open import Variable
open import Expr
par : Behaviour → Behaviour → Behaviour
assign : Variable → Expr → Behaviour
nil : Behaviour
- inputchoice : {n : ℕ} → Vec (Input_ex × Behaviour) n → Behaviour
+ inputchoice : List (Input_ex × Behaviour) → Behaviour
wait : Channel → Operation → Location → Variable → Behaviour
exec : Channel → Operation → Variable → Behaviour → Behaviour
module Typecheck where
-import Data.List as List
+open import Data.List.All using (All; all) renaming ([] to []-All; _∷_ to _∷-All_)
import Data.Vec.Equality as VecEq
open import Relation.Nullary using (¬_)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; subst; refl)
open import Data.Nat using (ℕ; _+_; suc; _≟_)
-open import Data.Vec using (Vec; _∈_; zip; _∷_; here)
+open import Data.List using (List; []; _∷_; foldl)
+open import Data.Vec using (Vec; _∈_; zip; _∷_; here; fromList; toList) renaming ([] to []-Vec)
+open import Data.Product using (_,_; _×_)
open import Function
open import Expr
open import Type
--------------------------
→ Γ ⊢B while e b ▹ Γ₁
- t-choice : {Γ₁ : Ctx m} {k n : ℕ} {η : Input_ex} {inputs : Vec Input_ex n}
- {b : Behaviour} {behaviours : Vec Behaviour n}
- → η ∈ inputs
- → b ∈ behaviours
- → Γ ⊢B seq (input η) b ▹ Γ₁
- ----------------------------------------------
- → Γ ⊢B inputchoice (zip inputs behaviours) ▹ Γ₁
+ t-choice : {Γ₁ : Ctx m} {choices : List (Input_ex × Behaviour)}
+ → All (λ { (η , b) → Γ ⊢B seq (input η) b ▹ Γ₁ }) choices
+ -----------------------------------------------
+ → Γ ⊢B inputchoice choices ▹ Γ₁
t-par : {k k₁ p p₁ : ℕ} {b1 b2 : Behaviour}
{Γ₁ : Ctx k} {Γ₁' : Ctx k₁} {Γ₂ : Ctx p} {Γ₂' : Ctx p₁} {Γ' : Ctx m}
------------------------------------
→ Γ ⊢B (input (reqres o x a b)) ▹ Γ₁
+
+{-# NON_TERMINATING #-}
check-B : {n m : ℕ} {Γ₁ : Ctx m} → (Γ : Ctx n) → (b : Behaviour) → Dec (_⊢B_▹_ {n} {m} Γ b Γ₁)
check-B {n} {m} {Γ₁} Γ nil with Γ CtxEq.≟ Γ₁
... | yes Γ≡Γ₁ = yes (t-nil {n} {m} {Γ} {Γ₁} {Γ≡Γ₁})
-... | no ¬p = no (λ {(t-nil {Γ₁} {Γ≡Γ₁}) → ¬p Γ≡Γ₁})
+... | no ¬p = no (λ {(t-nil {_} {Γ≡Γ₁}) → ¬p Γ≡Γ₁})
check-B {n} {m} {Γ₁} Γ (if e b1 b2) with check-B Γ b1 | check-B Γ b2
... | yes ctx₁ | yes ctx₂ = yes (t-if expr-t ctx₁ ctx₂)
... | yes _ | no ¬p = no (λ {(t-if _ _ c₂) → ¬p c₂})
{ (yes ctx) → yes (t-while {n} {m} {Γ} {Γ₁} {Γ≡Γ₁} expr-t ctx)
; (no ¬p) → no (λ {(t-while _ ctx) → ¬p ctx})
}
-... | no ¬p = no {!!}
+... | no ¬p = no (λ {(t-while {_} {Γ≡Γ₁} _ _) → ¬p Γ≡Γ₁})
+check-B {n} {m} {Γ₁} Γ (inputchoice pairs) with all (λ { (η , b) → check-B {n} {m} {Γ₁} Γ (seq (input η) b) }) pairs
+... | yes checked = yes (t-choice checked)
+... | no ¬p = no (λ { (t-choice checked) → ¬p checked })
check-B Γ b = {!!}