anchor.diff:        let r = is_C (fst (List.hd args)) in
         if r then begin
           if not (List.for_all (fun (h, _) -> is_C h) args) then
  -          failwith "not a C (A * C)";
  +          raise_error (Error_UnexpectedDM4FType,
  +                         BU.format1 "Not a C-type (A * C): %s" (Print.term_to_string t))
  +                      t.pos;
           true
         end else begin
           if not (List.for_all (fun (h, _) -> not (is_C h)) args) then
  -          failwith "not a C (C * A)";
  +          raise_error (Error_UnexpectedDM4FType,
  +                         BU.format1 "Not a C-type (C * A): %s" (Print.term_to_string t))
  +                      t.pos;
           false
         end
     | Tm_arrow (binders, comp) ->
         begin match nm_of_comp comp with
         | M t ->
             if (is_C t) then
  -            failwith "not a C (C -> C)";
  +            raise_error (Error_UnexpectedDM4FType,
  +                           BU.format1 "Not a C-type (C -> C): %s" (Print.term_to_string t))
  +                        t.pos;
             true
         | N t ->
             // assert (List.exists is_C binders) ==> is_C comp
  
positive.code:                 (U.mk_app y [ S.as_arg (S.bv_to_name a2) ]))
              in
              mk_forall a1 (mk_forall a2 body)
      | Tm_arrow (binder :: binders, comp) -> //TODO: a bit confusing, since binders may be []
          let t = { t with n = Tm_arrow ([ binder ], S.mk_Total (U.arrow binders comp)) } in
          mk_rel t x y
      | Tm_arrow _ ->
          failwith "unhandled arrow"
      | _ ->
          (* TODO: assert that this is a base type. *)
          (* BU.print2 "base, x=%s, y=%s\n" (Print.term_to_string x) (Print.term_to_string y); *)
  
negative.code:    * context. [gamma] is the series of binders the precede the return type of
     * the context. *)
    let rec collect_binders (t : term) =
      let t = U.unascribe t in
      match (compress t).n with
      | Tm_arrow (bs, comp) ->
          // TODO: dubious, assert no nested arrows
          let rest = match comp.n with
            | Total (t, _) -> t
            | _ -> raise_error (Error_UnexpectedDM4FType,
                                 BU.format1 "wp_a contains non-Tot arrow: %s" (Print.comp_to_string comp))
                      comp.pos
          in
          bs @ (collect_binders rest)
      | Tm_type _ ->
          []
      | _ ->
          raise_error (Error_UnexpectedDM4FType,
                       BU.format1 "wp_a doesn't end in Type0, but rather in %s" (Print.term_to_string t))
                      t.pos
    in
    let mk_lid name : lident = U.dm4f_lid ed name in
  
    let gamma = collect_binders wp_a |> U.name_binders in
  