Calculate $sum_{|cup S|=k}(-1)^{|S|+1}$ where $S$ is a non-empty subset of...












3












$begingroup$


Let $x_i={a_i,a_{i+1}} (1 leq i leq n)$ and $X={x_1, cdots, x_n}$. Given $k$, I'd like to ask how to calculate $sum_{|cup S|=k}(-1)^{|S|+1}$ where $S$ is a non-empty subset of $X$?



The problem can be transformed into $sum_{t}sum_{substack{|cup S|=k\|S|=t}}(-1)^{|S|+1}=sum_{t}(-1)^{t}sum_{substack{|cup S|=k\|S|=t}}1$. The last summation can be interpreted as counting how many length-$n$ binary strings with $t$ ones such that the number of consecutive "11" substrings is $2t-k$. But it's still hard to perform calculation.










share|cite|improve this question











$endgroup$












  • $begingroup$
    Are $a_1,a_2,ldots,a_{n+1}$ pairwise distinct?
    $endgroup$
    – user614671
    Dec 2 '18 at 12:05










  • $begingroup$
    Yes. All $a_1, a_2, cdots, a_{n+1} $ are distinct.
    $endgroup$
    – Hang Wu
    Dec 2 '18 at 12:06












  • $begingroup$
    In the second-to-last sentence, I think you mean "[...] length-$color{red}{(n+1)}$ binary strings with $color{red}{k}$ ones such that [...] is $color{red}{2t+1-k}$."
    $endgroup$
    – Batominovski
    Dec 2 '18 at 21:30












  • $begingroup$
    No. There are $2^n$ possibilities for the choice of $S$, and each consecutive "11" substring will reduce the size of $cup S$ by one.
    $endgroup$
    – Hang Wu
    Dec 3 '18 at 3:38












  • $begingroup$
    I just left a lengthy possible solution, but maybe I should have first asked: what kind of answer are you looking for?
    $endgroup$
    – Badam Baplan
    Dec 3 '18 at 8:00


















3












$begingroup$


Let $x_i={a_i,a_{i+1}} (1 leq i leq n)$ and $X={x_1, cdots, x_n}$. Given $k$, I'd like to ask how to calculate $sum_{|cup S|=k}(-1)^{|S|+1}$ where $S$ is a non-empty subset of $X$?



The problem can be transformed into $sum_{t}sum_{substack{|cup S|=k\|S|=t}}(-1)^{|S|+1}=sum_{t}(-1)^{t}sum_{substack{|cup S|=k\|S|=t}}1$. The last summation can be interpreted as counting how many length-$n$ binary strings with $t$ ones such that the number of consecutive "11" substrings is $2t-k$. But it's still hard to perform calculation.










share|cite|improve this question











$endgroup$












  • $begingroup$
    Are $a_1,a_2,ldots,a_{n+1}$ pairwise distinct?
    $endgroup$
    – user614671
    Dec 2 '18 at 12:05










  • $begingroup$
    Yes. All $a_1, a_2, cdots, a_{n+1} $ are distinct.
    $endgroup$
    – Hang Wu
    Dec 2 '18 at 12:06












  • $begingroup$
    In the second-to-last sentence, I think you mean "[...] length-$color{red}{(n+1)}$ binary strings with $color{red}{k}$ ones such that [...] is $color{red}{2t+1-k}$."
    $endgroup$
    – Batominovski
    Dec 2 '18 at 21:30












  • $begingroup$
    No. There are $2^n$ possibilities for the choice of $S$, and each consecutive "11" substring will reduce the size of $cup S$ by one.
    $endgroup$
    – Hang Wu
    Dec 3 '18 at 3:38












  • $begingroup$
    I just left a lengthy possible solution, but maybe I should have first asked: what kind of answer are you looking for?
    $endgroup$
    – Badam Baplan
    Dec 3 '18 at 8:00
















3












3








3


1



$begingroup$


Let $x_i={a_i,a_{i+1}} (1 leq i leq n)$ and $X={x_1, cdots, x_n}$. Given $k$, I'd like to ask how to calculate $sum_{|cup S|=k}(-1)^{|S|+1}$ where $S$ is a non-empty subset of $X$?



The problem can be transformed into $sum_{t}sum_{substack{|cup S|=k\|S|=t}}(-1)^{|S|+1}=sum_{t}(-1)^{t}sum_{substack{|cup S|=k\|S|=t}}1$. The last summation can be interpreted as counting how many length-$n$ binary strings with $t$ ones such that the number of consecutive "11" substrings is $2t-k$. But it's still hard to perform calculation.










share|cite|improve this question











$endgroup$




Let $x_i={a_i,a_{i+1}} (1 leq i leq n)$ and $X={x_1, cdots, x_n}$. Given $k$, I'd like to ask how to calculate $sum_{|cup S|=k}(-1)^{|S|+1}$ where $S$ is a non-empty subset of $X$?



The problem can be transformed into $sum_{t}sum_{substack{|cup S|=k\|S|=t}}(-1)^{|S|+1}=sum_{t}(-1)^{t}sum_{substack{|cup S|=k\|S|=t}}1$. The last summation can be interpreted as counting how many length-$n$ binary strings with $t$ ones such that the number of consecutive "11" substrings is $2t-k$. But it's still hard to perform calculation.







combinatorics elementary-set-theory






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 3 '18 at 3:35







Hang Wu

















asked Dec 2 '18 at 11:56









Hang WuHang Wu

416310




416310












  • $begingroup$
    Are $a_1,a_2,ldots,a_{n+1}$ pairwise distinct?
    $endgroup$
    – user614671
    Dec 2 '18 at 12:05










  • $begingroup$
    Yes. All $a_1, a_2, cdots, a_{n+1} $ are distinct.
    $endgroup$
    – Hang Wu
    Dec 2 '18 at 12:06












  • $begingroup$
    In the second-to-last sentence, I think you mean "[...] length-$color{red}{(n+1)}$ binary strings with $color{red}{k}$ ones such that [...] is $color{red}{2t+1-k}$."
    $endgroup$
    – Batominovski
    Dec 2 '18 at 21:30












  • $begingroup$
    No. There are $2^n$ possibilities for the choice of $S$, and each consecutive "11" substring will reduce the size of $cup S$ by one.
    $endgroup$
    – Hang Wu
    Dec 3 '18 at 3:38












  • $begingroup$
    I just left a lengthy possible solution, but maybe I should have first asked: what kind of answer are you looking for?
    $endgroup$
    – Badam Baplan
    Dec 3 '18 at 8:00




















  • $begingroup$
    Are $a_1,a_2,ldots,a_{n+1}$ pairwise distinct?
    $endgroup$
    – user614671
    Dec 2 '18 at 12:05










  • $begingroup$
    Yes. All $a_1, a_2, cdots, a_{n+1} $ are distinct.
    $endgroup$
    – Hang Wu
    Dec 2 '18 at 12:06












  • $begingroup$
    In the second-to-last sentence, I think you mean "[...] length-$color{red}{(n+1)}$ binary strings with $color{red}{k}$ ones such that [...] is $color{red}{2t+1-k}$."
    $endgroup$
    – Batominovski
    Dec 2 '18 at 21:30












  • $begingroup$
    No. There are $2^n$ possibilities for the choice of $S$, and each consecutive "11" substring will reduce the size of $cup S$ by one.
    $endgroup$
    – Hang Wu
    Dec 3 '18 at 3:38












  • $begingroup$
    I just left a lengthy possible solution, but maybe I should have first asked: what kind of answer are you looking for?
    $endgroup$
    – Badam Baplan
    Dec 3 '18 at 8:00


















$begingroup$
Are $a_1,a_2,ldots,a_{n+1}$ pairwise distinct?
$endgroup$
– user614671
Dec 2 '18 at 12:05




$begingroup$
Are $a_1,a_2,ldots,a_{n+1}$ pairwise distinct?
$endgroup$
– user614671
Dec 2 '18 at 12:05












$begingroup$
Yes. All $a_1, a_2, cdots, a_{n+1} $ are distinct.
$endgroup$
– Hang Wu
Dec 2 '18 at 12:06






$begingroup$
Yes. All $a_1, a_2, cdots, a_{n+1} $ are distinct.
$endgroup$
– Hang Wu
Dec 2 '18 at 12:06














$begingroup$
In the second-to-last sentence, I think you mean "[...] length-$color{red}{(n+1)}$ binary strings with $color{red}{k}$ ones such that [...] is $color{red}{2t+1-k}$."
$endgroup$
– Batominovski
Dec 2 '18 at 21:30






$begingroup$
In the second-to-last sentence, I think you mean "[...] length-$color{red}{(n+1)}$ binary strings with $color{red}{k}$ ones such that [...] is $color{red}{2t+1-k}$."
$endgroup$
– Batominovski
Dec 2 '18 at 21:30














$begingroup$
No. There are $2^n$ possibilities for the choice of $S$, and each consecutive "11" substring will reduce the size of $cup S$ by one.
$endgroup$
– Hang Wu
Dec 3 '18 at 3:38






$begingroup$
No. There are $2^n$ possibilities for the choice of $S$, and each consecutive "11" substring will reduce the size of $cup S$ by one.
$endgroup$
– Hang Wu
Dec 3 '18 at 3:38














$begingroup$
I just left a lengthy possible solution, but maybe I should have first asked: what kind of answer are you looking for?
$endgroup$
– Badam Baplan
Dec 3 '18 at 8:00






$begingroup$
I just left a lengthy possible solution, but maybe I should have first asked: what kind of answer are you looking for?
$endgroup$
– Badam Baplan
Dec 3 '18 at 8:00












1 Answer
1






active

oldest

votes


















2












$begingroup$

There is a nice algebraic way to do this by constructing a regular language (or equivalently an appropriate finite automaton) and extracting a generating function from it. Such problems are inherently linear, so we know that we'll come out with a rational generating function and it will be routine to find explicit expressions for its coefficients or analyze its growth.



We're working towards getting a trivariate generating function $P(u,x,y)$ where the coefficient of $u^a x^b y^c$ encodes the number of ways to divide the $n$ sets into $b$ sets that form exactly $c$ contiguous blocks. $P(u,x,y)$ will contain more than enough information to answer your question. Indeed, observe that the number of elements covered by a choice of $b$ sets forming $c$ contiguous blocks is always $b + c$. Thus, setting $Q(u,z) = -P(u,-z,z)$, we see that the $u^nz^k$ coefficient of $Q$ encodes precisely the sign-weighted sum of ways to cover $k$ elements in the problem of size $n$, i.e. the coefficients of $Q$ will be precisely what you are asking about.



To get this power series we first construct a finite automaton that steps through the sets one at a time, at step either selecting or skipping the next set. We want the automaton to be able to keep track of three pieces of information: how many steps it has taken ($u$), how many sets it has chosen ($x$), and how many contiguous blocks it has formed ($y$). The automaton needs $2$ states, so that it knows whether the next set it chooses is being added to a previous block or is the beginning of a new block.



Here is a diagram of the automaton. As an example, suppose $n = 5$ and the automaton was choosing the arrangement ${a_2, a_3}, {a_3, a_4}, {a_5, a_6}$. The automaton would reach this by the sequence NO YES YES NO YES, and the variable encoding would progress as $u, u^2xy, u^3x^2y, u^4x^2y,u^5x^3y^2$.



enter image description here



Let's call the right state the $F$ state ($F$ for free) and the left state the $B$ state ($B$ for block). Let $L_F(u,x,y)$ be the trivariate generating function whose coefficient $u^a x^b y^c$ is the number of ways that the automaton can produce that variable encoding by starting at the $F$ state (by construction, these are the numbers we're interested in). Define $L_B(u,x,y)$ similarly, but instead counting the number of ways starting at the $B$ state.



Algebraically, we can read off a system of equations relating the two generating functions. The first equation intuitively says that when we are in the $F$ state, we can encode $uxy$ and go to the $B$ state, or we can encode $u$ and remain in the $F$ state, or we can stop. Similarly for the second equation.



$$L_F(u,x,y) = uxyL_B(u,x,y) + uL_F(u,x,y) + 1$$
$$L_B(u,x,y) = uxL_B(u,x,y) + uL_F(u,x,y) + 1$$



(Note: If our problem had, for example, the additional restriction that we always had to choose the $n$th set, then we could easily incorporate that into our method; it would translate to saying that the automaton cannot stop on the $B$ state, and thus to removing the '$+1$' from the $L_B$ defining equation.)



We can solve for $L_F$! After some arithmetic manipulations you come out with



$$L_F(u,x,y) = frac{1+uxy-ux}{1 -ux - u - u^2xy + u^2x}$$



Finally, as said above, we can specify / forget about information to get $$Q(u,z) = -L_F(u,-z,z) = -frac{1 - uz^2 + uz}{1+uz - u+ u^2z^2 - u^2z}$$



As a sanity check, note that we do have $Q(u,1) = -1$, which is a relief because in theory we should have $Q(u,1) =sum_ksum_{|cup S|=k}(-1)^{|S|+1} = sum_k {n choose k } (-1)^{k+1}$.



With $Q(u,z)$ in hand it becomes easy to analyze these numbers any which way.



For example, letting $a_{k,n}$ be the coefficient of $z^k u^n$, we immediately get the recurrence relation
$$a_{k,n} = a_{k, n-1} - a_{k-1,n-1} + a_{k-1,n-2} - a_{k-2,n-2}$$
with the initial conditions $$a_{0,n} = -1, a_{1,n} = 0, a_{2,n} = n$$ (and of course $a_{k,n} = 0$ if $k > n+1$)






share|cite|improve this answer











$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3022548%2fcalculate-sum-cup-s-k-1s1-where-s-is-a-non-empty-subset-of-x%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2












    $begingroup$

    There is a nice algebraic way to do this by constructing a regular language (or equivalently an appropriate finite automaton) and extracting a generating function from it. Such problems are inherently linear, so we know that we'll come out with a rational generating function and it will be routine to find explicit expressions for its coefficients or analyze its growth.



    We're working towards getting a trivariate generating function $P(u,x,y)$ where the coefficient of $u^a x^b y^c$ encodes the number of ways to divide the $n$ sets into $b$ sets that form exactly $c$ contiguous blocks. $P(u,x,y)$ will contain more than enough information to answer your question. Indeed, observe that the number of elements covered by a choice of $b$ sets forming $c$ contiguous blocks is always $b + c$. Thus, setting $Q(u,z) = -P(u,-z,z)$, we see that the $u^nz^k$ coefficient of $Q$ encodes precisely the sign-weighted sum of ways to cover $k$ elements in the problem of size $n$, i.e. the coefficients of $Q$ will be precisely what you are asking about.



    To get this power series we first construct a finite automaton that steps through the sets one at a time, at step either selecting or skipping the next set. We want the automaton to be able to keep track of three pieces of information: how many steps it has taken ($u$), how many sets it has chosen ($x$), and how many contiguous blocks it has formed ($y$). The automaton needs $2$ states, so that it knows whether the next set it chooses is being added to a previous block or is the beginning of a new block.



    Here is a diagram of the automaton. As an example, suppose $n = 5$ and the automaton was choosing the arrangement ${a_2, a_3}, {a_3, a_4}, {a_5, a_6}$. The automaton would reach this by the sequence NO YES YES NO YES, and the variable encoding would progress as $u, u^2xy, u^3x^2y, u^4x^2y,u^5x^3y^2$.



    enter image description here



    Let's call the right state the $F$ state ($F$ for free) and the left state the $B$ state ($B$ for block). Let $L_F(u,x,y)$ be the trivariate generating function whose coefficient $u^a x^b y^c$ is the number of ways that the automaton can produce that variable encoding by starting at the $F$ state (by construction, these are the numbers we're interested in). Define $L_B(u,x,y)$ similarly, but instead counting the number of ways starting at the $B$ state.



    Algebraically, we can read off a system of equations relating the two generating functions. The first equation intuitively says that when we are in the $F$ state, we can encode $uxy$ and go to the $B$ state, or we can encode $u$ and remain in the $F$ state, or we can stop. Similarly for the second equation.



    $$L_F(u,x,y) = uxyL_B(u,x,y) + uL_F(u,x,y) + 1$$
    $$L_B(u,x,y) = uxL_B(u,x,y) + uL_F(u,x,y) + 1$$



    (Note: If our problem had, for example, the additional restriction that we always had to choose the $n$th set, then we could easily incorporate that into our method; it would translate to saying that the automaton cannot stop on the $B$ state, and thus to removing the '$+1$' from the $L_B$ defining equation.)



    We can solve for $L_F$! After some arithmetic manipulations you come out with



    $$L_F(u,x,y) = frac{1+uxy-ux}{1 -ux - u - u^2xy + u^2x}$$



    Finally, as said above, we can specify / forget about information to get $$Q(u,z) = -L_F(u,-z,z) = -frac{1 - uz^2 + uz}{1+uz - u+ u^2z^2 - u^2z}$$



    As a sanity check, note that we do have $Q(u,1) = -1$, which is a relief because in theory we should have $Q(u,1) =sum_ksum_{|cup S|=k}(-1)^{|S|+1} = sum_k {n choose k } (-1)^{k+1}$.



    With $Q(u,z)$ in hand it becomes easy to analyze these numbers any which way.



    For example, letting $a_{k,n}$ be the coefficient of $z^k u^n$, we immediately get the recurrence relation
    $$a_{k,n} = a_{k, n-1} - a_{k-1,n-1} + a_{k-1,n-2} - a_{k-2,n-2}$$
    with the initial conditions $$a_{0,n} = -1, a_{1,n} = 0, a_{2,n} = n$$ (and of course $a_{k,n} = 0$ if $k > n+1$)






    share|cite|improve this answer











    $endgroup$


















      2












      $begingroup$

      There is a nice algebraic way to do this by constructing a regular language (or equivalently an appropriate finite automaton) and extracting a generating function from it. Such problems are inherently linear, so we know that we'll come out with a rational generating function and it will be routine to find explicit expressions for its coefficients or analyze its growth.



      We're working towards getting a trivariate generating function $P(u,x,y)$ where the coefficient of $u^a x^b y^c$ encodes the number of ways to divide the $n$ sets into $b$ sets that form exactly $c$ contiguous blocks. $P(u,x,y)$ will contain more than enough information to answer your question. Indeed, observe that the number of elements covered by a choice of $b$ sets forming $c$ contiguous blocks is always $b + c$. Thus, setting $Q(u,z) = -P(u,-z,z)$, we see that the $u^nz^k$ coefficient of $Q$ encodes precisely the sign-weighted sum of ways to cover $k$ elements in the problem of size $n$, i.e. the coefficients of $Q$ will be precisely what you are asking about.



      To get this power series we first construct a finite automaton that steps through the sets one at a time, at step either selecting or skipping the next set. We want the automaton to be able to keep track of three pieces of information: how many steps it has taken ($u$), how many sets it has chosen ($x$), and how many contiguous blocks it has formed ($y$). The automaton needs $2$ states, so that it knows whether the next set it chooses is being added to a previous block or is the beginning of a new block.



      Here is a diagram of the automaton. As an example, suppose $n = 5$ and the automaton was choosing the arrangement ${a_2, a_3}, {a_3, a_4}, {a_5, a_6}$. The automaton would reach this by the sequence NO YES YES NO YES, and the variable encoding would progress as $u, u^2xy, u^3x^2y, u^4x^2y,u^5x^3y^2$.



      enter image description here



      Let's call the right state the $F$ state ($F$ for free) and the left state the $B$ state ($B$ for block). Let $L_F(u,x,y)$ be the trivariate generating function whose coefficient $u^a x^b y^c$ is the number of ways that the automaton can produce that variable encoding by starting at the $F$ state (by construction, these are the numbers we're interested in). Define $L_B(u,x,y)$ similarly, but instead counting the number of ways starting at the $B$ state.



      Algebraically, we can read off a system of equations relating the two generating functions. The first equation intuitively says that when we are in the $F$ state, we can encode $uxy$ and go to the $B$ state, or we can encode $u$ and remain in the $F$ state, or we can stop. Similarly for the second equation.



      $$L_F(u,x,y) = uxyL_B(u,x,y) + uL_F(u,x,y) + 1$$
      $$L_B(u,x,y) = uxL_B(u,x,y) + uL_F(u,x,y) + 1$$



      (Note: If our problem had, for example, the additional restriction that we always had to choose the $n$th set, then we could easily incorporate that into our method; it would translate to saying that the automaton cannot stop on the $B$ state, and thus to removing the '$+1$' from the $L_B$ defining equation.)



      We can solve for $L_F$! After some arithmetic manipulations you come out with



      $$L_F(u,x,y) = frac{1+uxy-ux}{1 -ux - u - u^2xy + u^2x}$$



      Finally, as said above, we can specify / forget about information to get $$Q(u,z) = -L_F(u,-z,z) = -frac{1 - uz^2 + uz}{1+uz - u+ u^2z^2 - u^2z}$$



      As a sanity check, note that we do have $Q(u,1) = -1$, which is a relief because in theory we should have $Q(u,1) =sum_ksum_{|cup S|=k}(-1)^{|S|+1} = sum_k {n choose k } (-1)^{k+1}$.



      With $Q(u,z)$ in hand it becomes easy to analyze these numbers any which way.



      For example, letting $a_{k,n}$ be the coefficient of $z^k u^n$, we immediately get the recurrence relation
      $$a_{k,n} = a_{k, n-1} - a_{k-1,n-1} + a_{k-1,n-2} - a_{k-2,n-2}$$
      with the initial conditions $$a_{0,n} = -1, a_{1,n} = 0, a_{2,n} = n$$ (and of course $a_{k,n} = 0$ if $k > n+1$)






      share|cite|improve this answer











      $endgroup$
















        2












        2








        2





        $begingroup$

        There is a nice algebraic way to do this by constructing a regular language (or equivalently an appropriate finite automaton) and extracting a generating function from it. Such problems are inherently linear, so we know that we'll come out with a rational generating function and it will be routine to find explicit expressions for its coefficients or analyze its growth.



        We're working towards getting a trivariate generating function $P(u,x,y)$ where the coefficient of $u^a x^b y^c$ encodes the number of ways to divide the $n$ sets into $b$ sets that form exactly $c$ contiguous blocks. $P(u,x,y)$ will contain more than enough information to answer your question. Indeed, observe that the number of elements covered by a choice of $b$ sets forming $c$ contiguous blocks is always $b + c$. Thus, setting $Q(u,z) = -P(u,-z,z)$, we see that the $u^nz^k$ coefficient of $Q$ encodes precisely the sign-weighted sum of ways to cover $k$ elements in the problem of size $n$, i.e. the coefficients of $Q$ will be precisely what you are asking about.



        To get this power series we first construct a finite automaton that steps through the sets one at a time, at step either selecting or skipping the next set. We want the automaton to be able to keep track of three pieces of information: how many steps it has taken ($u$), how many sets it has chosen ($x$), and how many contiguous blocks it has formed ($y$). The automaton needs $2$ states, so that it knows whether the next set it chooses is being added to a previous block or is the beginning of a new block.



        Here is a diagram of the automaton. As an example, suppose $n = 5$ and the automaton was choosing the arrangement ${a_2, a_3}, {a_3, a_4}, {a_5, a_6}$. The automaton would reach this by the sequence NO YES YES NO YES, and the variable encoding would progress as $u, u^2xy, u^3x^2y, u^4x^2y,u^5x^3y^2$.



        enter image description here



        Let's call the right state the $F$ state ($F$ for free) and the left state the $B$ state ($B$ for block). Let $L_F(u,x,y)$ be the trivariate generating function whose coefficient $u^a x^b y^c$ is the number of ways that the automaton can produce that variable encoding by starting at the $F$ state (by construction, these are the numbers we're interested in). Define $L_B(u,x,y)$ similarly, but instead counting the number of ways starting at the $B$ state.



        Algebraically, we can read off a system of equations relating the two generating functions. The first equation intuitively says that when we are in the $F$ state, we can encode $uxy$ and go to the $B$ state, or we can encode $u$ and remain in the $F$ state, or we can stop. Similarly for the second equation.



        $$L_F(u,x,y) = uxyL_B(u,x,y) + uL_F(u,x,y) + 1$$
        $$L_B(u,x,y) = uxL_B(u,x,y) + uL_F(u,x,y) + 1$$



        (Note: If our problem had, for example, the additional restriction that we always had to choose the $n$th set, then we could easily incorporate that into our method; it would translate to saying that the automaton cannot stop on the $B$ state, and thus to removing the '$+1$' from the $L_B$ defining equation.)



        We can solve for $L_F$! After some arithmetic manipulations you come out with



        $$L_F(u,x,y) = frac{1+uxy-ux}{1 -ux - u - u^2xy + u^2x}$$



        Finally, as said above, we can specify / forget about information to get $$Q(u,z) = -L_F(u,-z,z) = -frac{1 - uz^2 + uz}{1+uz - u+ u^2z^2 - u^2z}$$



        As a sanity check, note that we do have $Q(u,1) = -1$, which is a relief because in theory we should have $Q(u,1) =sum_ksum_{|cup S|=k}(-1)^{|S|+1} = sum_k {n choose k } (-1)^{k+1}$.



        With $Q(u,z)$ in hand it becomes easy to analyze these numbers any which way.



        For example, letting $a_{k,n}$ be the coefficient of $z^k u^n$, we immediately get the recurrence relation
        $$a_{k,n} = a_{k, n-1} - a_{k-1,n-1} + a_{k-1,n-2} - a_{k-2,n-2}$$
        with the initial conditions $$a_{0,n} = -1, a_{1,n} = 0, a_{2,n} = n$$ (and of course $a_{k,n} = 0$ if $k > n+1$)






        share|cite|improve this answer











        $endgroup$



        There is a nice algebraic way to do this by constructing a regular language (or equivalently an appropriate finite automaton) and extracting a generating function from it. Such problems are inherently linear, so we know that we'll come out with a rational generating function and it will be routine to find explicit expressions for its coefficients or analyze its growth.



        We're working towards getting a trivariate generating function $P(u,x,y)$ where the coefficient of $u^a x^b y^c$ encodes the number of ways to divide the $n$ sets into $b$ sets that form exactly $c$ contiguous blocks. $P(u,x,y)$ will contain more than enough information to answer your question. Indeed, observe that the number of elements covered by a choice of $b$ sets forming $c$ contiguous blocks is always $b + c$. Thus, setting $Q(u,z) = -P(u,-z,z)$, we see that the $u^nz^k$ coefficient of $Q$ encodes precisely the sign-weighted sum of ways to cover $k$ elements in the problem of size $n$, i.e. the coefficients of $Q$ will be precisely what you are asking about.



        To get this power series we first construct a finite automaton that steps through the sets one at a time, at step either selecting or skipping the next set. We want the automaton to be able to keep track of three pieces of information: how many steps it has taken ($u$), how many sets it has chosen ($x$), and how many contiguous blocks it has formed ($y$). The automaton needs $2$ states, so that it knows whether the next set it chooses is being added to a previous block or is the beginning of a new block.



        Here is a diagram of the automaton. As an example, suppose $n = 5$ and the automaton was choosing the arrangement ${a_2, a_3}, {a_3, a_4}, {a_5, a_6}$. The automaton would reach this by the sequence NO YES YES NO YES, and the variable encoding would progress as $u, u^2xy, u^3x^2y, u^4x^2y,u^5x^3y^2$.



        enter image description here



        Let's call the right state the $F$ state ($F$ for free) and the left state the $B$ state ($B$ for block). Let $L_F(u,x,y)$ be the trivariate generating function whose coefficient $u^a x^b y^c$ is the number of ways that the automaton can produce that variable encoding by starting at the $F$ state (by construction, these are the numbers we're interested in). Define $L_B(u,x,y)$ similarly, but instead counting the number of ways starting at the $B$ state.



        Algebraically, we can read off a system of equations relating the two generating functions. The first equation intuitively says that when we are in the $F$ state, we can encode $uxy$ and go to the $B$ state, or we can encode $u$ and remain in the $F$ state, or we can stop. Similarly for the second equation.



        $$L_F(u,x,y) = uxyL_B(u,x,y) + uL_F(u,x,y) + 1$$
        $$L_B(u,x,y) = uxL_B(u,x,y) + uL_F(u,x,y) + 1$$



        (Note: If our problem had, for example, the additional restriction that we always had to choose the $n$th set, then we could easily incorporate that into our method; it would translate to saying that the automaton cannot stop on the $B$ state, and thus to removing the '$+1$' from the $L_B$ defining equation.)



        We can solve for $L_F$! After some arithmetic manipulations you come out with



        $$L_F(u,x,y) = frac{1+uxy-ux}{1 -ux - u - u^2xy + u^2x}$$



        Finally, as said above, we can specify / forget about information to get $$Q(u,z) = -L_F(u,-z,z) = -frac{1 - uz^2 + uz}{1+uz - u+ u^2z^2 - u^2z}$$



        As a sanity check, note that we do have $Q(u,1) = -1$, which is a relief because in theory we should have $Q(u,1) =sum_ksum_{|cup S|=k}(-1)^{|S|+1} = sum_k {n choose k } (-1)^{k+1}$.



        With $Q(u,z)$ in hand it becomes easy to analyze these numbers any which way.



        For example, letting $a_{k,n}$ be the coefficient of $z^k u^n$, we immediately get the recurrence relation
        $$a_{k,n} = a_{k, n-1} - a_{k-1,n-1} + a_{k-1,n-2} - a_{k-2,n-2}$$
        with the initial conditions $$a_{0,n} = -1, a_{1,n} = 0, a_{2,n} = n$$ (and of course $a_{k,n} = 0$ if $k > n+1$)







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Dec 3 '18 at 17:57

























        answered Dec 3 '18 at 7:56









        Badam BaplanBadam Baplan

        4,476722




        4,476722






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3022548%2fcalculate-sum-cup-s-k-1s1-where-s-is-a-non-empty-subset-of-x%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Probability when a professor distributes a quiz and homework assignment to a class of n students.

            Aardman Animations

            Are they similar matrix