anchor.diff:  
   let BETA_CONV tm =
     try BETA tm with Failure _ ->
  -  try let f,arg = dest_comb tm in
  -      let v = bndvar f in
  +  try let f,arg = dest_comb tm
  +      let v = bndvar f
         INST [arg,v] (BETA (mk_comb(f,v)))
  -  with Failure _ -> failwith "BETA_CONV: Not a beta-redex";;
  +  with Failure _ -> failwith "BETA_CONV: Not a beta-redex"
   
   (* ------------------------------------------------------------------------- *)
   (* A few very basic derived equality rules.                                  *)
  
positive.code:     else if is_comb pat then
        COMB2_CONV (PCONV xs (rator pat) conv) (PCONV xs (rand pat) conv)
      else
        ABS_CONV (PCONV xs (body pat) conv) in
    fun pat -> let xs,pbod = strip_abs pat in PCONV xs pbod;;
  
  (* ------------------------------------------------------------------------- *)
  (* Symmetry conversion.                                                      *)
  (* ------------------------------------------------------------------------- *)
  
  let SYM_CONV tm =
    try let th1 = SYM(ASSUME tm) in
        let tm' = concl th1 in
        let th2 = SYM(ASSUME tm') in
        DEDUCT_ANTISYM_RULE th2 th1
    with Failure _ -> failwith "SYM_CONV";;
  
  (* ------------------------------------------------------------------------- *)
  (* Conversion to a rule.                                                     *)
  (* ------------------------------------------------------------------------- *)
  
  let CONV_RULE (conv:conv) th =
    EQ_MP (conv(concl th)) th;;
  
  (* ------------------------------------------------------------------------- *)
  (* Substitution conversion.                                                  *)
  (* ------------------------------------------------------------------------- *)
  
  let SUBS_CONV ths tm =
    try if ths = [] then REFL tm else
        let lefts = map (lhand o concl) ths in
        let gvs = map (genvar o type_of) lefts in
        let pat = subst (zip gvs lefts) tm in
        let abs = list_mk_abs(gvs,pat) in
        let th = rev_itlist
          (fun y x -> CONV_RULE (RAND_CONV BETA_CONV THENC LAND_CONV BETA_CONV)
                                (MK_COMB(x,y))) ths (REFL abs) in
        if rand(concl th) = tm then REFL tm else th
    with Failure _ -> failwith "SUBS_CONV";;
  
  (* ------------------------------------------------------------------------- *)
  (* Get a few rules.                                                          *)
  (* ------------------------------------------------------------------------- *)
  
  let BETA_RULE = CONV_RULE(REDEPTH_CONV BETA_CONV);;
  
  let GSYM = CONV_RULE(ONCE_DEPTH_CONV SYM_CONV);;
  
  let SUBS ths = CONV_RULE (SUBS_CONV ths);;
  
  (* ------------------------------------------------------------------------- *)
  (* A cacher for conversions.                                                 *)
  (* ------------------------------------------------------------------------- *)
  
  let CACHE_CONV =
    let ALPHA_HACK th =
      let tm' = lhand(concl th) in
      fun tm -> if tm' = tm then th else TRANS (ALPHA tm tm') th in
    fun conv ->
      let net = ref empty_net in
      fun tm -> try tryfind (fun f -> f tm) (lookup tm (!net))
                with Failure _ ->
                    let th = conv tm in
                    (net := enter [] (tm,ALPHA_HACK th) (!net); th);;
  
  *)
  
  
negative.code:   (fun c -> TRY_CONV (DEPTH_QCONV c)),
    (fun c -> TRY_CONV (REDEPTH_QCONV c)),
    (fun c -> TRY_CONV (TOP_DEPTH_QCONV c)),
    (fun c -> TRY_CONV (TOP_SWEEP_QCONV c))
  
  (* ------------------------------------------------------------------------- *)
  (* Apply at leaves of op-tree; NB any failures at leaves cause failure.      *)
  