Back to work.
In private correspondence Brian Schott has exposed an error:
M =: pwrSet 0;1
N =: pwrSet 1;0
]K =: M ; N ; < M u N
+----------------+----------------+----------------------+
|++---+---+-----+|++---+---+-----+|+-----++---+---+-----+|
|||+-+|+-+|+-+-+||||+-+|+-+|+-+-+|||+-+-+||+-+|+-+|+-+-+||
||||1|||0|||0|1||||||0|||1|||1|0|||||0|1||||0|||1|||1|0|||
|||+-+|+-+|+-+-+||||+-+|+-+|+-+-+|||+-+-+||+-+|+-+|+-+-+||
|++---+---+-----+|++---+---+-----+|+-----++---+---+-----+|
+----------------+----------------+----------------------+
#&.>K
+-+-+-+
|4|4|5|
+-+-+-+
M equalset N NB. no set distinction between 0;1 and 1;0
1
NB. but (as we already know from the counts)
M equalset M u N
0
----------------------------------------------------------------------
If M equalset N we should have M equalset M u N and N equalset M u N .
----------------------------------------------------------------------
Kip
The error is somewhere in
NB. "Real sets" 12 August 2009
NB. A "set" is 0$<1 or a non-empty list of boxes with no duplicates.
NB. An "element" is the open of a box. As 0$<1 has no box it has no element.
NB. M =: set element;element;...;element creates a set with those elements.
NB. Use M =: set element;...;element;<element if the rightmost element is boxed.
NB. If you are CAREFUL TO HAVE NO DUPLICATES you can use
NB. M =: element;element;...;element when rightmost element is open
NB. M =: element;...;element;<element when rightmost element is boxed
NB. Verb set =: ~. is defined below.
load 'validate'
set =: ~. NB. creates a non-empty set when used as shown above
isset =: -:&(0$<1) +. isboxed *. isvector *. (-: ~.)
NB. 0$<1 or boxed non-empty list without duplicates
isrealset =: -: realset NB. see verb realset below
Empty =: 0$<1 NB. empty set
E =: Empty
sortset =: ( ] : [: )`( /:~ : [: )@.( (isset f.) *. -.@((0$<1) -: ]) )
NB. If argument is a set but not 0$<1 , sortset sorts the argument;
NB. returns 0$<1 and nonsets unchanged.
realset =: 3 : 0 NB. recursive sortset; almost Fraser's sortSet
s =. y
for_k. i. >: L. y do. s =. sortset L:k s end.
)
NB. usage realset set produces an equivalent "real set":
NB. recursively "sortsetted" for easy comparison with other "real sets".
NB. This program of Fraser's is a real break-through.
sortSet =: 3 : 0 NB. Fraser's; the source of realset
s =. y
for_k. i. >: L. y do. s =. Set L:k s end.
)
equalset =: -:&realset NB. i.e., equal as sets
eqs =: equalset
iselementof =: <@[ e. ]
in =: iselementof
u =: -. , ] NB. union, R. E. Boss and Oleg Kobchenko
less =: -. NB. difference
n =: [ -. -. NB. intersection, R. E. Boss and Oleg Kobchenko
issubsetof =: [ equalset n
part =: issubsetof
NB. pwrSet below is Raul's powSet without the sort
pwrSet =: (<@#~) 2 (#"1~ {:)@#:@i...@^ #
NB. This program of Raul's is another mile-stone.
NB. powSet=: /:~@:(<@#~) 2 (#"1~ {:)@#:@i...@^ # NB. Raul's; the source of
pwrSet
NB. Commented out to avoid confusion with pwrSet
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm