Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7871

Re: How to check whether an infinite set is closed under addition?

From Mobius ReX <aoirex@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to check whether an infinite set is closed under addition?
Date 2012-01-16 11:56 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jf138u$5im$1@smc.vnet.net> (permalink)
References <201201150951.EAA19688@smc.vnet.net> <C9FCBB38-0E20-478B-97BC-BD57313E080F@mimuw.edu.pl>

Show all headers | View raw


Cool! Thanks a lot.

Best,
Renjun


On Sun, Jan 15, 2012 at 4:22 AM, Andrzej Kozlowski <akoz@mimuw.edu.pl> wrote:
>
> On 15 Jan 2012, at 12:00, Andrzej Kozlowski wrote:
>
>> Let
>> On 15 Jan 2012, at 10:51, Rex wrote:
>>
>>> Given k positive numbers a_1<a_2<a_3<...<a_k, and all integers greater
>>> than a_k, we want to check whether this set {a_1, a_2, a_3,...a_k, a_k
>>> + 1, a_k+2, ......} is closed under addition.
>>>
>>> Is there any easy way to do this? any functions that we could use in
>>> Mathematica?
>>>
>>> Your help will be greatly appreciated.
>>>
>>>
>>
>> Lest's call your set {a1,a2,...,a3} "base". Then:
>>
>> closedQ[base_List] :=
>> Complement[Select[Total[Subsets[base, {2}], {2}], # <= Max[base] &],
>>   base] == {}
>>
>> For example:
>>
>> closedQ[{1, 2, 3}]
>>
>> True
>>
>> closedQ[{1, 4, 6, 7}]
>>
>> False
>>
>> Andrzej Kozlowski
>>
>
> The program above does dome unnecessary comparisons since anything added to the largest element of the base will obviously included in the complete set. If the base is ordered, a better program will be:
>
> closedQ[base_List] :=
>  Complement[
>   Select[Total[Subsets[Most[base], {2}], {2}], # <= Last[base] &],
>   base] == {}
>
> If it is not ordered we could use Sort[base] in place of base.
>
> Andrzej Kozlowski

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: How to check whether an infinite set is closed under addition? Mobius ReX <aoirex@gmail.com> - 2012-01-16 11:56 +0000

csiph-web