   let freshName = count(from: 0)
 
   func freshVar(_ type: Type) -> AbstractValue? {
-    switch removeOwnership(type) {
+    switch simplifyType(type) {
     case .namedType("Int"): return .int(.var(IntVar(freshName())))
     case .namedType("Bool"): return .bool(.var(freshBoolVar()))
     case .namedType("TensorShape"): return freshShapeValue()

  }
}

fileprivate func unwrapFunctionType(_ type: Type) -> Type? {
  switch type {
  case let .attributedType(_, t):
    return unwrapFunctionType(t)
  case let .genericType(_, _, t):
    return unwrapFunctionType(t)
  case .functionType(_, _):
    return type
  default:
    return nil
  }
}

func removeOwnership(_ type: Type) -> Type {
  switch type {
  case let .withOwnership(_, subtype): return removeOwnership(subtype)
  default: return type
  }
}

        updates = [.function(name)]

      case let .partialApply(_, _, fn, _, args, fnType):
        guard case let .functionType(allArgTypes, _) = simplifyType(fnType) else {
          fatalError("Expected a function type in .partialApply, got: \(fnType)")
        }
        assert(allArgTypes.count >= args.count)
