ubst :: Integer -> Term -> Term -> Term
subst j s t = case t of
  arg@(Arg n) -> if n==j then s else arg
  Abs t -> subst (j+1) (shift 1 0 s) t
  App t1 t2 -> App (subst j s t1) (subst j s t2)

subst :: Integer -> Term -> Term -> Term
subst j s t = case t of
  arg@(Arg n) -> if n==j then s else arg
  Abs t -> subst (j+1) (shift 1 0 s) t
  App t1 t2 -> App (subst j s t1) (subst j s t2)
subst j s t = case t of
  arg@(Arg n) -> if n==j then s else arg
  Abs t -> subst (j+1) (shift 1 0 s) t
  App t1 t2 -> App (subst j s t1) (subst j s t2)