anchor.diff:    | (x, y) :: t ->
       let m = unify m t in
       unify_one m x y in
  -
  -let bnd_equal b1 b2 =
  -  match (b1, b2) with 
  -  | (Int i1, Int i2) -> i1 = i2
  -  | (NegInf, NegInf) -> true
  -  | (Inf, Inf) -> true
  -  | _ -> false
  -
  -let rec typ_equal t1 t2 = 
  -  match (t1, t2) with
  -  | (TName (Id x), TName (Id y)) -> x = y
  -  | (TApp (t1, ts1), TApp (t2, ts2)) ->
  -    (typ_equal t1 t2) && List.fold2 (fun b t1 t2 -> b && typ_equal t2 t2) true ts1 ts2
  -  | (TVar _, TVar _) -> internalErr "type variable should be resolved already"
  -  | (TInt (l1, h1), TInt(l2, h2)) ->
  -    (bnd_equal l1 l2) && (bnd_equal h1 h2)
  -  | (TArrow (xs, y), TArrow (us, v)) ->
  -    List.fold2 (fun b t1 t2 -> b&& typ_equal t1 t2) true xs us && (typ_equal y v)
  -  | _ -> internalErr "type mismatch"
   
   let insert_cast (e:exp) (t:typ) (et:typ) : exp =
     // cast from type 't' to 'et'
  
positive.code:   | XGhost -> GhostLocal ((if isRet then Mutable else Immutable), Some t)
      
  let push_rets (env:env) (rets:pformal list):env =
    {env with scope_mods = List.fold (fun s (x, t, g, io, a) -> Local(x, t, (param_info true (x, t, g, io, a))):: s) env.scope_mods rets}
  
  let push_params_without_rets (env:env) (args:pformal list) (rets:pformal list):env =
    let arg_in_rets arg l = List.exists (fun elem -> elem = arg) l in
  
negative.code:     | None -> err ("Identifier not found " + (err_id id))
      | Some r -> ()
  
  let rec kind_equal k1 k2 =
    match (k1, k2) with
    | (TYPE i1, TYPE i2) -> i1=i2
    | (KApp (ks1, k1), KApp(ks2, k2)) ->
      (List.fold2 (fun b k1 k2 -> b && (kind_equal k1 k2)) true ks1 ks2) && (kind_equal k1 k2)
    
  let rec resolve_type env t:kind =
    match t with 
    | TName id -> lookup_type env id
    | TApp (t, ts) -> 
        let k = resolve_type env t in
        tc_kind env k ts
    | TArrow (ts, t) -> err ("not implemented")
    | _ -> err ("not implemented")
  and tc_kind env k ts = 
    let check env k t = 
      if kind_equal k (resolve_type env t) then ()
      else err ("kind of types not matching") in
    match k with
    | KApp (ks, k) ->
      if (List.length ks <> List.length ts) then err ("number of parameters not match in type construct")
      else List.iter2 (fun k t -> check env k t) ks ts;
      k
    | _ -> err ("wrong kind for the type")
  and resolve_types env ts = List.map (resolve_type env) ts;
  
  let rec tc_stmt (env:env) (s:stmt):stmt =
    match s with
  