--- /dev/null
+module Behaviour where
+
+open import Data.Maybe using (Maybe)
+open import Data.String using (String)
+open import Data.List using (List)
+open import Data.Product using (_×_)
+open import Variable
+open import Expr
+open import Type
+
+
+data Output_ex : Set where
+ notification : Operation → Location → Expr → Output_ex
+ solicitRes : Operation → Location → Expr → Variable → Output_ex
+
+data Behaviour : Set
+
+data Input_ex : Set where
+ oneway : Operation → Variable → Input_ex
+ reqRes : Operation → Variable → Variable → Behaviour → Input_ex
+
+data Behaviour where
+ input : Input_ex → Behaviour
+ output : Output_ex → Behaviour
+ if : Expr → Behaviour → Maybe Behaviour → Behaviour
+ while : Expr → Behaviour → Behaviour
+ seq : Behaviour → Behaviour → Behaviour
+ par : Behaviour → Behaviour → Behaviour
+ assign : Variable → Expr → Behaviour
+ nil : Behaviour
+ inputchoice : List (Input_ex × Behaviour) → Behaviour
+ wait : Channel → Operation → Location → Variable → Behaviour
+ exec : Channel → Operation → Variable → Behaviour → Behaviour
+
--- /dev/null
+module Expr where
+
+open import Variable
+
+
+data BinOp : Set where
+ plus : BinOp
+ minus : BinOp
+ mult : BinOp
+ div : BinOp
+ power : BinOp
+
+data Expr : Set where
+ var : Variable → Expr
+ binary : BinOp → Variable → Variable → Expr
+ constant : Variable.Value → Expr
--- /dev/null
+module Type where
+
+open import Data.String using (String)
+open import Data.List using (List)
+open import Expr
+open import Variable
+
+
+Operation : Set
+Operation = String
+
+Location : Set
+Location = String
+
+Channel : Set
+Channel = String
+
+data Cardinality : Set where
+ oo : Cardinality
+ oi : Cardinality
+ ii : Cardinality
+
+data BasicType : Set where
+ bool : BasicType
+ int : BasicType
+ double : BasicType
+ long : BasicType
+ string : BasicType
+ raw : BasicType
+ void : BasicType
+
+data TypeTree : Set
+
+data ChildType : Set where
+ child : String → Cardinality → TypeTree → ChildType
+
+data TypeTree where
+ leaf : BasicType → TypeTree
+ node : BasicType → List ChildType → TypeTree
+
+data TypeDecl : Set where
+ outNotify : Operation → Location → TypeTree → TypeDecl
+ outSolRes : Operation → Location → TypeTree → TypeTree → TypeDecl
+ inOneWay : Operation → TypeTree → TypeDecl
+ inReqRes : Operation → TypeTree → TypeTree → TypeDecl
+ var : Variable → TypeTree → TypeDecl
+ empty : TypeDecl
+ pair : TypeDecl → TypeDecl → TypeDecl
+
+Γ : Set
+Γ = List TypeDecl
+
--- /dev/null
+module Typecheck where
+
+open import Data.Maybe using (Maybe; just; nothing)
+open import Function
+open import Expr
+open import Type
+open import Behaviour
+open import Variable
+
+
+typecheck_behaviour : Γ → Behaviour → Maybe Γ
+typecheck_behaviour env nil = just env
+typecheck_behaviour env (if e b1 maybe_b2) =
+ case e of λ
+ {
+ -- If conditional expression is variable
+ (var v) →
+ let ctx1 = typecheck_behaviour env b1 in
+ {!!}
+ ; _ → nothing
+ }
+typecheck_behaviour _ _ = nothing
--- /dev/null
+module Variable where
+
+open import Data.Integer using (ℤ)
+open import Data.String using (String)
+open import Data.Product using (_×_)
+open import Data.Maybe using (Maybe)
+open import Data.List using (List)
+open import Data.Bool using (Bool)
+
+
+Name : Set
+Name = String
+
+data Value : Set where
+ string : String → Value
+ int : ℤ → Value
+ bool : Bool → Value
+ double : ℤ × ℤ → Value
+ long : ℤ → Value
+
+data Variable : Set where
+ leaf : Name → Value → Variable
+ node : Name → Maybe Value → List Variable → Variable
+