Let $s \in \Sigma^*$ be a finite string over alphabet $\Sigma$. Find all "compressible" substrings of $s$, that is substrings $t \leqslant s$ (notation) such that $t\alpha t \leqslant s$ for some $\alpha \leqslant s$ and $|t| \geq 2$. It's true that with the usual size of a smallest grammar for $s$ that a length-2 string is not really compressible unless it occurs at least 3 times disjointly in $s$ i.e. $t \alpha t \beta t \leqslant s$, however, we still call it as such. It doesn't matter because you can reduce a smallest grammar with it's length-2 twice occuring substrings and retain its same size. Call the set of compressible substrings $C_s$.
Take $s = ababcababc$ as our example string. Then $C_s = \{ab,ba,bc,aba,abc,bab, abab, babc, ababc\}$. In general since there are $O(|s|^2)$ substrings we can say that $|C_s| = O(|s|^2)$ safely.
Now, assign variables to these substrings:
$$ A \to ab \\ B \to ba \\ C \to bc \\ D \to aba \\ E \to abc \\ F \to bab \\ G \to abab \\ H \to babc \\ I \to ababc \\ $$
Call the set of variables (LHS's) $V$ and the set of expaned rules (RHS's) $R$.
For a single variable $A$ it is clear to me that a left-most packing in $s$ is a sufficient tool to find the maximal number of $A$'s we can pack into $s$ via substring-to-variable substitution:
$$ s \Rightarrow AAcAAc $$ This in particular works if we have long runs of $a$'s : $s' = aaaaabababaabaaaaaaa \Rightarrow A'A'abababA'bA'A'A'a$ and say $A' \to aa$. So it works for all cases. But that's not the proof I'm worried about.
I'm wondering if there exists a polynomial-time algorithm in $|s| = N$ such that given any number $1 \leq k \leq |C_s|$, where $C_s = \{c_1, c_2, \dots c_n\}$, of variables $v_1, \dots, v_k$, we can determine if $r_1$ copies of $v_1$ can be packed into $s$, while simultaneously $r_2$ copies of $v_2$ can be packed in, ..., while simultaneously $r_k$ copies of $v_k$ can be packed in.
Can you state this in terms of a maximal (or less) independent subset of vertices of a graph algorithm, that happens to be solvable in polynomial time?
Because you take take each variable's $i$th occurence, for example $s \Rightarrow A^1A^2cA^3A^4c$ denoted with a superscript that doesn't mean concatenation powering, and label a graph with these variables $A^i$, $B^j$, and so on.. Then two variables conflict if they overlap if you try to pack them both into $s$, so draw an undirected edge between their vertices. This I will call a "conflict graph". Well, we're not exactly looking for a maximal independent subset, so I was wondering if this related or special case were solvable in polynomial time.