I ment to write: If U is n#1, then the power set is (2^n)#1 and the power set of the power set is (2^2^n)#1.
--- Den tirs 12/10/10 skrev Bo Jacoby <[email protected]>: Fra: Bo Jacoby <[email protected]> Emne: Re: [Jprogramming] Sets Til: "Programming forum" <[email protected]> Dato: tirsdag 12. oktober 2010 06.33 If U is n#1, then the power set is (n^2)#1 and the power set of the power set is (n^2^2)#1. --- Den søn 10/10/10 skrev Kip Murray <[email protected]>: Fra: Kip Murray <[email protected]> Emne: Re: [Jprogramming] Sets Til: "Programming forum" <[email protected]> Dato: søndag 10. oktober 2010 23.57 If U is {0,1} the subsets are {} represented by 0 0 {1} represented by 0 1 (0} represented by 1 0 {0,1} represented by 1 1 but there is no way to represent a set like the power set (set of all subsets) { {}, {1}, {0}, {0,1} } -- this set has four elements, and the largest set you can represent has two elements. And it gets worse: you can't represent the power set of the power set ... On 10/10/2010 12:17 PM, Bo Jacoby wrote: > If I understand this correctly, Kip's model only deals with finite sets which > are all subsets of a finite set U, which can be represented by the numbers > i.#U. Any subset of U can be represented by a bit vector, and bit vectors are > manipulated by standard operations such as *. and +. and -. So I fail > to see the purpose of Kip's representation of sets. > > --- Den søn 10/10/10 skrev Marshall Lochbaum<[email protected]>: > > Fra: Marshall Lochbaum<[email protected]> > Emne: Re: [Jprogramming] Sets > Til: "'Programming forum'"<[email protected]> > Dato: søndag 10. oktober 2010 18.51 > > I don't see the usefulness of the a: at the end of the sets. An empty set > should just be represented by 0$a:, and is clearly identifiable because it > gives no output. > > Marshall > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Kip Murray > Sent: Sunday, October 10, 2010 12:02 AM > To: Programming forum > Subject: [Jprogramming] Sets > > Here is my latest attempt to model set theory in J. All sets have distinct > elements and are ordered by /:~ so that match -: determines whether two sets > are the same. Sets must be created by the verb set or by provided > operations. The intention is theoretical not practical! --Kip Murray > > ]A =: set 0;'b';2 NB. elements 0 'b' 2 are put in boxes preceding the >last ┌─┬─┬─┬┐ │0│2│b││ └─┴─┴─┴┘ > ]B =: set 2;'b';'b';0 NB. same elements so same set ┌─┬─┬─┬┐ │0│2│b││ >└─┴─┴─┴┘ > > A -: B > 1 > > ]C =: set 2;'b';'c';'d' > ┌─┬─┬─┬─┬┐ > │2│b│c│d││ > └─┴─┴─┴─┴┘ > > B sand C NB. intersection, "set and" > ┌─┬─┬┐ > │2│b││ > └─┴─┴┘ > B sor C NB. union > ┌─┬─┬─┬─┬─┬┐ > │0│2│b│c│d││ > └─┴─┴─┴─┴─┴┘ > > (A sand B sor C) -: (A sand B) sor (A sand C) NB. distributive law > 1 > > pwrset A NB. A has 3 elements, power set has 2^3, including the empty >set ┌──────┬────────┬────┬──────┬────┬──────┬──┬────┬┐ > │┌─┬─┬┐│┌─┬─┬─┬┐│┌─┬┐│┌─┬─┬┐│┌─┬┐│┌─┬─┬┐│┌┐│┌─┬┐││ > ││0│2││││0│2│b││││0││││0│b││││2││││2│b│││││││b││││ > │└─┴─┴┘│└─┴─┴─┴┘│└─┴┘│└─┴─┴┘│└─┴┘│└─┴─┴┘│└┘│└─┴┘││ > └──────┴────────┴────┴──────┴────┴──────┴──┴────┴┘ > NB. Elements are contained in boxes preceding the last which is always > NB. the Boxed Empty a: (Ace). The use of a: permits a unique and visible > NB. empty set, viz > > (,a:) -: E =: A less A NB. see verb less below > 1 > E > ┌┐ > ││ > └┘ > a: > ┌┐ > ││ > └┘ > E -: a: > 0 > > NB. Definitions > > E =: ,a: NB. empty set > set =: a: ,~ [: /:~ ~. NB. create set from boxed list y > NB. each box of y encloses an element > get =: { }: NB. get boxed elements (from curtail because > NB. elements are inside boxes of curtail) > isin =: e. }: NB. Do boxes in list x contain elements of y? > less =: a: ,~ -.&}: NB. remove elements of y from x > sand =: [ less less NB. intersection, "set and" > sor =: a: ,~ [: /:~ [: ~. ,&}: NB. union, "set or" > diff =: less sor less~ NB. symmetric difference > card =: [: # }: NB. count elements: cardinality > issubs =: [ -: sand NB. Is x a subset of y? > pwrset =: a: ,~ [: /:~ ] (<@#~) 1 (,~"1) 2 (#"1~ {:)@#:@i...@^ #...@}: > NB. pwrset by Raul Miller, adapted > islist =: 1 = #...@$ NB. islist through isunique from validate.ijs > isboxed =: 0< L. > issorted =: -: /:~ > isunique =: -: ~. > isset =: islist *. isboxed *. (a: -: {:) *. issorted@:}: *. isunique@:}: > NB. isset y asks, is array y a set? > iselement =:<@[ isin ] NB. Is array x an element of set y? > > NB. End > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
