How do we construct an empty set?

7 views
Skip to first unread message

Robert Goldman

unread,
May 29, 2026, 1:34:21 PMMay 29
to ErgoAI and XSB Users Forum
When I try to create an empty set this way, ErgoAI rejects it.

 myset[insert([])].

Times (in seconds): elapsed = 0.000; pure CPU = 0.000

No

Unless I am doing something wrong, this seems problematic, because it means I cannot simply do 

myset[insert(?X)]

Instead I must do something like this

\if ?X = [] \then <create myset as empty set> \else myset[insert(?X)]@\set.

Unfortunately, I do not know how to create a set that is empty, since inserting an empty list fails.

Robert Goldman

unread,
May 29, 2026, 1:50:30 PMMay 29
to ErgoAI and XSB Users Forum, Robert Goldman
I guess what I do is simply not create the set at all, just reference a symbol as if it is a set.  So something like

    \if ?X != [] \then myset[insert(?X)] \else \true

... seems like the right thing.  myset then can be treated as an empty set.  Perhaps a bit of explanation about this could be added to the manual?

Michael Kifer

unread,
Jun 5, 2026, 4:32:57 PM (9 days ago) Jun 5
to ErgoAI-X...@coherentknowledge.com

I am not sure what you are attempting to do  here using your particular syntax. You seem to be assigning some set-related meaning to syntactic constructs like  myset[insert(?X)] and the like.

Where did you see something thing like that?  There are several ways to use or simulate sets.

First, you can use predicates, like p(a), p(b), etc. This is common in LP.

In Ergo, you also have an option to use something like

set(123)[member->{a,b,c,d}].

Finally, there are real, not simulated,set objects, as  described in Section 50.6.

-- michael


gRyBwq5fwes23!#

--
You received this message because you are subscribed to the Google Groups "ErgoAI and XSB Users Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ErgoAI-XSB-for...@coherentknowledge.com.
To view this discussion visit https://groups.google.com/a/coherentknowledge.com/d/msgid/ErgoAI-XSB-forum/e481af7f-f0e7-4332-bf7e-29aac3c906ffn%40coherentknowledge.com.

Robert Goldman

unread,
Jun 5, 2026, 5:10:18 PM (9 days ago) Jun 5
to ErgoAI and XSB Users Forum, Michael Kifer
> You seem to be assigning some set-related meaning to syntactic constructs like  myset[insert(?X)] and the like.

I was trying to use the techniques described in section 50.6, which is where I got that syntax.  For example, on page 332:

    myset123[insert([foo,bar,p(234)])]@\set.

So that's where I got the syntactic construct.

Section 50.6 is where I got the idea of creating a set whose name is myset123 (I'm not sure that "creating" is the right word for this).  The thing I didn't see in the manual was a description of how to make, for example, myset123 be an empty set.  But it appears that if I just address a symbol as if it's a set (i.e., by using methods from \set), then if I haven't inserted anything into that symbol's frame, the set library will treat it as an empty set.

Is that more clear?

I think this exposes a lack of understanding on my part of F-logic.  It seems that any symbol can be treated as if it's a frame.  That makes sense; I just hadn't internalized the lesson.

Michael Kifer

unread,
Jun 6, 2026, 2:40:12 AM (9 days ago) Jun 6
to Robert Goldman, ErgoAI and XSB Users Forum

Ah, this is embarrassing!  I completely forgot how that syntax looks like and started to ask you stupid questions :-(

Yes, an empty set can be created via a query like

?- myEmptySet[insert([])]@\set.

There are some assumptions about the arguments. For example, in union, intersect, minus, all input args must be bound to sets represented by atoms. Then we can do this sort of things:

?- set1[insert([a,b,c])]@\set, set2[insert([c,d,e])]@\set.  // define some sets

?- set1[intersect(set2) -> set3]@\set.   // do the intersect

?- set3[member->?Answer]@\set.   // check the result.

?Answer = c
In other words, this set package does not create set ids on the fly and

?- set1[intersect(set2) -> ?intersection]@\set.  

will get an error.


  

On 6/5/26 17:10, Robert Goldman wrote:
> You seem to be assigning some set-related meaning to syntactic constructs like  myset[insert(?X)] and the like.

I was trying towwww use the techniques described in section 50.6, which is where I got that syntax.  For example, on page 332:
Reply all
Reply to author
Forward
0 new messages