This is about relations on sets - set

Definition : A relation on set S and T is any subset of the Cartesian product S x T.
Example:
The "larger than" relation for real numbers is the set:
L = {(x, y) | x, y E R, x > y}
Here the part I don't understand it says :
"Here S and T both equal R".
What does it mean?
The elements of set S is equal R and also the elements of set T is eqaul to R.
so S and T is also equal?

The elements of set S is equal R and also the elements of set T is eqaul to R. so S and T is also equal?
Exactly. As both x and y are real numbers, they are taken from the very same set, therefore they are sharing the same domain.

Related

Is there a way to create a type 3 grammar for this language?

I'm trying to find a grammar of the highest type possible for this language:
L={0^2n 1^(n-1)|n>=1}
I only managed to do this:
S->00X
X->00X1|λ
Which is not type 3. I can't seem to figure out how to get it to type 3 (if that's even possible).
You can't do it, because L is not a regular language.
Assume that L is regular. Let w = 0^(2p)1^(p-1) for some integer p>=1, so that |w| > p. Further, consider the strings x, y, and z such that w = xyz with |xy| <= p, which means both x and y are sequences of 0s (since p < 2p). By the pumping lemma, any string of the form xy^nz is also in L, but that means we can increase the number of 0s without increasing the number of 1s found in z. Thus, our assumption that L is regular must be false.

How can I bind the same variables together in prolog

So, I'm relatively new to prolog and was wondering if it is possible to bind 2 variables together in a matrix and would they update simultaneously.
For example, I have this
X = [[_,_], [_,_]].
X = [[_23838, _23844], [_23856, _23862]].
But, I was wondering is it possible to do something like this, almost unifying the diagonal elements in the matrix
X = [[_,_], [_,_]].
X = [[_23838, _23844], [_23856, _23838]].
Assuming the above is possible if _23838 was later bound then would they be the same value?
For example
X = [[5,_], [_,5]].
X = [[5, _23844], [_23856, 5]].
Yes you can.
Just name the variables instead of using the don't care name (aka. "the anonymous variable"), i.e. _:
X = [[A,B], [C,A]].
This expresses the constraint that the value at (1,1) must be the same as the value at (2,2).
You can also start off with "all variables different" and later force them to be equal by unification:
X = [[A,B], [C,D]], A=D
Conversely, you can state that you do not want to see equality in a result (all proofs that can only continue by making A and B equal will fail after dif/2):
X = [[A,B], [C,D]], dif(A,B).
dif/2 is of some interest.

How to set mutually exclusive probabilities in Problog?

A person X can either be inpatient or outpatient.
Given the fact location(X,outpatient) how can Problog infer that the probability of location(X,inpatient) is 0?
For example I want a side effect of:
person(1).
location(1,inpatient).
dependent(1,opioids).
receive(1,clonidine).
query(detoxification(1,opioids,success)).
to be an inference that location(1,outpatient) has zero probability.
If I write location(X,outpatient);location(X,inpatient)., all queries return both with a probability of 1.
If I write P::location(X,outpatient);(1-P)::location(X,inpatient). that gives an error because I haven't specified a value for P. If I specify a value for P, that value is never updated (as expected because Prolog treats variables as algebraic variables and I haven't told Problog to update P.
If I write location(X,outpatient) :- \+ location(X,inpatient). I create a negative cycle, which I have to if I am to specify the inverse goal.
One solution:
P::property(X,location,inpatient);(1-P)::property(X,location, outpatient) :-
inpatient(X),
P is 1.
P::property(X,location,outpatient);(1-P)::property(X,location, inpatient) :-
outpatient(X),
P is 1.
P::inpatient(X);(1-P)::outpatient(X) :-
property(X,location,inpatient),
P is 1.
P::outpatient(X);(1-P)::inpatient(X) :-
property(X,location,outpatient),
P is 1.
This binds inpatient/1 to property/3 for the property of location with value inpatient.

Equation containing a matrix power

I have an equation on the form A^n*b =e= c where A is a matrix and b & c are column vectors.
n is a fixed number for my model determined by a constant. It will most likely be in the hundreds and be changed for different solutions.
A is a matrix of variables, b & c are constants.
How can I formulate A^n*b =e= c in gams?
Optionally: the model that lead me to this is that I have a graph with a connectivity matrix con(x,x2) denoting the connectivity between x and x2 when x and x2 are connected. I would like to calculate the connection between 2 arbitrary nodes, the connectivity between 2 nodes x to x2 is the sum of the connectivity for all paths from x to x2. the connectivity for a path is the product of all connections along the path. Is there a smarter way to formulate this constraint so that I don't have to do matrix exponentiation?
A is not symmetric or invertible but is positive Semidefinite.
You need to define your data in terms of sets and parameters first. Follow this link for more information about the data structure in GAMS: http://www.gams.com/latest/docs/userguides/userguide/_u_g__data_entry.html
Start by defining the sets and parameters of your problem, supposing you have 100 vertices, you can declare x like this for example:
Set x /x1*x100/;
alias(x,x2);
Because you will need to use the same set twice in your matrix, you have to define an alias so that x2 is interpreted by GAMS as the same as x in your model.
Then, declare n and b as parameters, you can do it like this:
Parameter
n /200/
c /100/;
Parameter b(x)
/
x1 3
x2 43
...
x100 23
/;
Note that parameters and variables with more than one value (i.e vectors or matrices) have to be defined over a previously defined set in GAMS. This is why b is defined over set x, think of x like indices of your vectors/matrices.
Declaration of A will have the form:
Variable A(x,x2);
Now you can define your equation using these sets, parameters and variables:
eq(x,x2) .. power(A(x,x2),n) * B(x2) =e= c;
Of course, you will still need to pick a suitable solver (NLP) and define an objective function, but this is how you would model the equation you want and variables for it.

Prolog, check divisibility in Peano arithmetic

I need to check if first given term (for example s(s(nul)) (or 2)) is dividable by the second term, (for example s(nul) (or 1)).
What I want to do is multiply given term by two and then check if that term is smaller or equal to the other term (if it is equal - problem is solved).
So far I got this:
checkingIfDividable(X,X).
checkingIfDividable(X,Y) :-
X > Y,
multiplication(X,Y).
/* multiplication by two should occur here.
I can't figure it out. This solution does not work!*/
multiplication(Y):-
YY is Y * 2,
checkingIfDividable(X,YY).
I can't seem to figure out how to multiply a term by 2. Any ideas?
If a = n*b, n > 0, it is also a = n*b = (1+m)*b = b + m*b, m >= 0.
So if a is dividable by b, and a = b+x, then x is also dividable by b.
In Peano encoding, n = 1+m is written n = s(m).
Take it from here.

Resources