3
$\begingroup$

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.

define additionally inverse function,

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!

$\endgroup$
2
  • $\begingroup$ Resolve[ForAll[a, 0 <= a <= 1, g[a, 0] == a], Integers]? $\endgroup$ – kglr Aug 28 '19 at 12:47
  • $\begingroup$ @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. $\endgroup$ – user13892 Aug 28 '19 at 16:03
1
$\begingroup$

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

Original Answer:

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}

$\endgroup$
3
  • $\begingroup$ Thank you for updating the answer to give Point[{{0}, {1}}] but it is failing in the above case (see my updated question). $\endgroup$ – user13892 Sep 28 '19 at 10:31
  • $\begingroup$ See my update.. $\endgroup$ – OkkesDulgerci Sep 28 '19 at 11:35
  • $\begingroup$ 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, π}. $\endgroup$ – user13892 Sep 28 '19 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.