To solve this optimization problem, we first need to translate the natural language description into a symbolic representation. Let's denote the amount invested in toothpaste company A as $x_1$ and the amount invested in toothpaste company B as $x_2$. The objective is to maximize profit, which can be represented as $0.12x_1 + 0.14x_2$, given that each dollar invested in company A yields a $0.12 profit and each dollar invested in company B yields a $0.14 profit.

The constraints are:
1. The total investment cannot exceed $5000: $x_1 + x_2 \leq 5000$.
2. At least 40% of the total investment must be in toothpaste company A: $x_1 \geq 0.4(x_1 + x_2)$, which simplifies to $x_1 \geq 0.4x_1 + 0.4x_2$ or $0.6x_1 \geq 0.4x_2$.
3. At least $1000 must be invested in toothpaste company B: $x_2 \geq 1000$.

The symbolic representation of the problem is:
```json
{
    'sym_variables': [('x1', 'amount invested in toothpaste company A'), ('x2', 'amount invested in toothpaste company B')],
    'objective_function': '0.12*x1 + 0.14*x2',
    'constraints': ['x1 + x2 <= 5000', '0.6*x1 >= 0.4*x2', 'x2 >= 1000', 'x1 >= 0', 'x2 >= 0']
}
```

Now, let's implement this problem in Gurobi using Python:

```python
from gurobipy import *

# Create a new model
m = Model("Toothpaste_Investment")

# Add variables
x1 = m.addVar(lb=0, name="amount_invested_in_A")
x2 = m.addVar(lb=0, name="amount_invested_in_B")

# Set the objective function
m.setObjective(0.12*x1 + 0.14*x2, GRB.MAXIMIZE)

# Add constraints
m.addConstr(x1 + x2 <= 5000, name="total_investment")
m.addConstr(0.6*x1 >= 0.4*x2, name="percentage_in_A")
m.addConstr(x2 >= 1000, name="minimum_in_B")

# Optimize the model
m.optimize()

# Print the results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Amount invested in A: {x1.x}")
    print(f"Amount invested in B: {x2.x}")
    print(f"Total profit: {0.12*x1.x + 0.14*x2.x}")
else:
    print("No optimal solution found")
```