# How to define a custom domain?

Is there a way in Wolfram language to define a domain by explicitly listing it as a set.

For example given a function g as follows:

g=Mod[#1+#2,2]&;


The following statement

Resolve[
ForAll[a,g[a,0]==a],
Integers
]


is False for a being an element of Integers.

How do I give it a domain Element[a,{0,1}]?

As pointed out (no pun intended) in the updated answer by OkkesDulgerci that Point[{{0},{1}}] can be used here, but it fails in the following case.

inv=Mod[#1,2]&;


The following statement refuse to resolve

ForAll[a,a∈Point[{{0},{1}}],g[a,inv[a]]==0]//Resolve


but does resolve with

ForAll[a,a∈Integers&&0<=a<=1,g[a,inv[a]]==0]//Resolve


So even though Point[{{0},{1}}] works in some cases but is failing here!

• Resolve[ForAll[a, 0 <= a <= 1, g[a, 0] == a], Integers]? – kglr Aug 28 '19 at 12:47
• @kglr well it is just weird that Wolfram language does not provide a way to define the domain explicitly by listing the elements. Many times it will be not possible or painful to provide a condition to define a subset of the existing domains rather than just listing the values over which to resolve the qualifiers in the statement. – user13892 Aug 28 '19 at 16:03

Update2: For list type of domain your problems are equivalent to these:

dom = {0, 3/2, π};

g = Mod[#1 + #2, 2] &;
inv = Mod[#1, 2] &;
SameQ @@ (g[#1, 0] == #1 & @@@ Cases[Tuples[dom, 2], {_, 0}])


False

SameQ @@ (g[#1, inv[#1]] == 0 & @@@ Tuples[dom, 2])


False

Update: Adding Integers in Resolve solves the problem.

g=Mod[#1+#2,2]&;
inv=Mod[#1,2]&;

Resolve[ForAll[a, a ∈ Point[{{0}, {1}}], g[a, inv[a]] == 0], Integers]


True

Edit:

How do I give it a domain Element[a,{0,1}]?

You can use Point[{{0}, {1}}] to define the domain explicitly by listing the elements.

Resolve[ForAll[a, a ∈ Point[{{0}, {1}}], g[a, 0] == a], Integers]


True

Resolve[ForAll[a, Element[a, Integers] && 0 <= a <= 1, g[a, 0] == a]]


True

Or

Mod[#1 + #2, 2] == #1 & @@@ Cases[Tuples[{0, 1}, 2], {_, 0}]


{True, True}

• Thank you for updating the answer to give Point[{{0}, {1}}] but it is failing in the above case (see my updated question). – user13892 Sep 28 '19 at 10:31
• See my update.. – OkkesDulgerci Sep 28 '19 at 11:35
• Thank you for the updated answer but the whole point of set defined by explicit listing is to not having to use any predefined domains as reference. What if I am interested in resolving over a set say, {0, 3/2, π}. – user13892 Sep 28 '19 at 11:56