We say three sets $A_1, A_2, A_3$ form a triangle if for each $1 \leq i,j \leq 3$ we have $A_i \cap A_j \neq \emptyset$, and $A_1 \cap A_2 \cap A_3 = \emptyset$. Let $f(n)$ be the smallest positive integer such that any subset of $\{1,2,3,\ldots, n\}$ of the size $f(n)$ has at least one triangle. Find a formula for $f(n)$.
To find the smallest positive integer \( f(n) \) such that any subset of \(\{1, 2, 3, \ldots, n\}\) of size \( f(n) \) has at least one triangle, we need to analyze the conditions given:

1. **Definition of a Triangle**:
   - Three sets \( A_1, A_2, A_3 \) form a triangle if:
     - \( A_i \cap A_j \neq \emptyset \) for all \( 1 \leq i, j \leq 3 \)
     - \( A_1 \cap A_2 \cap A_3 = \emptyset \)

2. **Objective**:
   - Find the smallest \( f(n) \) such that any subset of \(\mathcal{P}(\{1, 2, \ldots, n\})\) of size \( f(n) \) contains a triangle.

3. **Upper Bound**:
   - Consider the power set \(\mathcal{P}(\{1, 2, \ldots, n\})\), which has \( 2^n \) elements.
   - We need to ensure that any subset of size \( f(n) \) contains a triangle.

4. **Lower Bound**:
   - We need \( f(n) > 2^{n-1} + n \) because the set made of all parts containing \( a_n \), together with \(\emptyset\) and the singletons \(\{a_k\}\), \( 1 \leq k \leq n-1 \), contains no triangles.

5. **Detailed Calculation**:
   - Let's consider the Erdős–Ko–Rado theorem, which states that for \( n \geq 2k \), the maximum size of a family of \( k \)-element subsets of \(\{1, 2, \ldots, n\}\) such that every pair of subsets has a non-empty intersection is \(\binom{n-1}{k-1}\).
   - For our problem, we need to ensure that any subset of size \( f(n) \) contains three sets forming a triangle.

6. **Applying the Erdős–Ko–Rado Theorem**:
   - For \( k = 2 \), the theorem implies that the maximum size of a family of 2-element subsets of \(\{1, 2, \ldots, n\}\) such that every pair of subsets has a non-empty intersection is \(\binom{n-1}{1} = n-1\).
   - However, we need to ensure that any subset of size \( f(n) \) contains three sets forming a triangle, which requires a larger bound.

7. **Conclusion**:
   - By considering the intersection properties and the Erdős–Ko–Rado theorem, we can conclude that \( f(n) \) must be at least \( 2^{n-1} + n + 1 \) to ensure that any subset of size \( f(n) \) contains a triangle.

The final answer is \( \boxed{ f(n) = 2^{n-1} + n + 1 } \)