anchor.diff:                      | _                -> 0
                     in
                     
  -                  let ty_nested_positive_in_d (dlid:lident) (env:env) :bool =
  +                  let ty_nested_positive_in (t:term') (env:env) :bool =
  +                    match t with
  +                    | Tm_app (t, args) ->
  +                      let fv = get_head_fvar_of_app_node t in
  +                      if Ident.lid_equals fv.fv_name.v ilid then true  //TODO: check that the ty does not appear in the indexes, don't understand that though
  +                      else false
  +                    | Tm_arrow (sbs, c) ->
  +                      fst (List.fold_left (fun (r, env) b ->
  +                             if not r then r, env
  +                             else
  +                             match (SS.compress (fst b).sort).n with
  +                             | Tm_app (t, args) ->
  +                               let fv = get_head_fvar_of_app_node t in
  +                               if Ident.lid_equals fv.fv_name.v ilid then true, push_binders env [b]  //TODO: check that the ty does not appear in the indexes
  +                               else (ty_strictly_positive_in (fst b).sort env, push_binders env [b])
  +                             | _ ->  ty_strictly_positive_in (fst b).sort env, push_binders env [b]
  +                           ) (true, env) sbs)  //TODO: also check c, c should be an I ... check ty does not occur in indexes
  +                    | _ -> failwith "Nested positive check, unhandled case"  //TODO: Type typed binders?
  +                  in
  +
  +                  let ty_nested_positive_in_dlid (dlid:lident) (env:env) :bool =
                       let _, dt = lookup_datacon env dlid in
  +                    let dt = N.normalize [N.Beta; N.Eager_unfolding; N.UnfoldUntil Delta_constant; N.Iota; N.Zeta; N.AllowUnboundUniverses] env dt in
                       //apply universe substitution to the datacon type
                       let dt = SS.subst usubst dt in
                       //open the type parameters of the inductive
  
positive.code:           | Sig_inductive_typ (lid, us, bs, _, _, _, _, _) -> lid, us, bs  //TODO: handle type indices
            | _                                           -> failwith "Impossible!"
        in
        let usubst, us = SS.univ_var_opening us in
        //apply usubt to bs
        let bs = SS.subst_binders usubst bs in
  
negative.code:                       let dbs = SS.subst_binders subst dbs in
                        let c = SS.subst_comp subst c in
  
                        ty_nested_positive_in (Tm_arrow (dbs, c)) env
                      | _ -> ty_nested_positive_in (SS.compress dt).n env
                        
                    in
                      
                    List.forall (fun d -> ty_nested_positive_in_dlid d env) idatas
                in
  
                //normalize the sort to unfold any type abbreviations, TODO: what steps?
                let bsort = N.normalize [N.Beta; N.Eager_unfolding; N.UnfoldUntil Delta_constant; N.Iota; N.Zeta; N.AllowUnboundUniverses] env bsort in
                not (ty_occurs_in bsort) ||
                  (match (SS.compress bsort).n with
                   | Tm_app (t, args) ->
                     let fv = get_head_fvar_of_app_node t in
                     if Ident.lid_equals fv.fv_name.v lid then ty_not_in_its_args args
                     else ty_nested_positive_in_ilid fv.fv_name.v args env
                   | Tm_arrow (sbs, c) ->
                     let b1 = List.for_all (fun (b, _) -> not (ty_occurs_in b.sort)) sbs in
                     let b2 = ty_strictly_positive_in (FStar.Syntax.Util.comp_result c) (push_binders env sbs) in //TODO: do we need to compress c, if so how?
                     b1 && b2
                   | Tm_fvar _ -> true  //if it's just a fvar, it should be fine?
                   | _ -> false  //TODO: returning false in all other cases, will see as they come up
                  )
              in
  
  