In the attached picture there's a symbol I don't understand. To understand additive functional dependency I need to know what the symbol means. Please advice?
It's the symbol where it says: "Suppose that X ⊇ Y and that..."
⊇ = ?
Thanks!
This symbol is used in set theory to say that X is a superset of Y, ie. All elements of Y are contained within X. Note that X could be equal to Y in this meaning. Without the underlining on the symbol Y would be a strict subset of X meaning they cannot be equal
It means "X is a superset of Y". The subset symbol is the same but flipped horizontally.
A ⊇ B -> Superset: A has the same elements as B, or more
A ⊃ B -> Proper Superset: A has B's elements and more
for example:
A ⊇ B -> {1, 2, 3} ⊇ {1, 2, 3}
A ⊃ B -> {1, 2, 3, 4} ⊃ {1, 2, 3}
Related
Initializing a defstruct using new or without new, seems to do the same, is there any difference?
(%i1) defstruct(foo(a,b));
(%o1) [foo(a, b)]
(%i2) f: foo(1,2);
(%o2) foo(a = 1, b = 2)
(%i3) f#a;
(%o3) 1
(%i4) f_new: new(foo(1,2));
(%o4) foo(a = 1, b = 2)
(%i5) f_new#a;
(%o5) 1
(%i6)
Without using new, the code seems a bit shorter and easier, but I'm not sure if some code will break if I use this pattern.
I think both ways are OK. The only difference so far as I know is that new(foo(...)) will ensure that there are the correct number of initial values. For example new(foo(1)) and new(foo(1, 2, 3)) will give errors, with foo as defined above. Just writing foo(1) or foo(1, 2, 3) doesn't trigger an error (maybe it should).
How can i transform a term like: 3 * y * w * t^3 in a list made of: List = [3, *, y,...], without using the following predicate:
t2l(Term, List) :-
t2l_(Term, List-X),
X = [].
t2l_(Term, [F|X]-X) :-
Term =.. [F],
!.
t2l_(Term, L1-L4) :-
Term =.. [F, A1, A2],
t2l_(A1, L1-L2),
L2 = [F|L3],
t2l_(A2, L3-L4).
Is there a simple way?
In Prolog, everything that can be expressed by pattern matching should be expressed by pattern matching.
In your case, this is difficult, because you cannot collectively distinguish the integers from other arising terms by pattern matching with the defaulty representation you are using.
In the following, I am not solving the task completely for you, but I am showing how you can solve it once you have a clean representation.
As always when describing a list in Prolog, consider using dcg notation:
term_to_list(y) --> [y].
term_to_list(w) --> [w].
term_to_list(t) --> [t].
term_to_list(i(I)) --> [I].
term_to_list(A * B) -->
term_to_list(A),
[*],
term_to_list(B).
term_to_list(A^B) -->
term_to_list(A),
[^],
term_to_list(B).
In this example, I am using i(I) to symbolically represent the integer I.
Sample query and result:
?- phrase(term_to_list(i(3)*y*w*t^i(3)), Ls).
Ls = [3, *, y, *, w, *, t, ^, 3].
I leave converting the defaulty representation to a clean one as an easy exercise.
Thanks mat for answering, i forgot to close the question. However i have created a new predicate that solve the problem:
term_string(Term, X),
string_codes(X, AList),
ascii_to_list(AList, Y).
ascii_to_list([X | Xs], [Y | Out]) :-
X >= 48,
X =< 57,
!,
number_codes(Y, [X]),
ascii_to_list(Xs, Out).
ascii_to_list([X | Xs], [Y | Out]) :-
char_code(Y, X),
ascii_to_list(Xs, Out).
ascii_to_list([], []).
This problem is similar to the "Exact Hitting Set" problem (http://en.wikipedia.org/wiki/Exact_cover#Exact_hitting_set) but with slightly different constraints.
I am looking for libraries, implementations, or papers that solve the following.
Say I have a set of sets S, and is initialized as follows:
S = {N, O, P, E};
N = {1, 2, 5}
O = {4, 5}
P = {1, 6, 7}
E = {2, 3, 8}};
S has n sets, and each subset set is of unknown size. In this example n = 4
Now I have another set X of size n, which is initialized to:
X = {1, 2, 4, 6}
What I need to do, is match each element in X to one and only one set in S.
So S should be completely satisfied with all of it's sets mapped to X and vice versa.
X[0] --> N
X[1] --> E
X[2] --> O
X[3] --> P
The main problem I am having is how to deal with the duplicated data with in the sets of S. How do I deal with these collisions? And How to implement the algorithm in such a way that is relatively scalable?
If you have any information that could point me in the right direction to solve this will be very much appreciated.
You could create a bipartite graph in the following manner:
For each element in the set X create a node in the U disjoint set of the graph
For each subset in the set S create a node in the V disjoint set of the graph
If element of X in subset of S then create an edge between the corresponding nodes in U and V
Then having the bipartite graph you can solve the problem using hopcroft karp algorithm to produce the maximum cardinality matching.(O(|E|sqrt(V)))
I have probably a very simple question.
What returns in Maxima function chebyshev_t(n, t)? I mean the exact mathematical formula.
Best Regards
When n is a literal integer (e.g. 2, 3, 5, etc) then chebyshev_t evaluates to a polynomial.
When n is a symbol declared an integer (via declare(n, integer) then chebyshev_t evaluates to a summation.
(%i1) display2d : false $
(%i2) chebyshev_t (5, u);
(%o2) -25*(1-u)-16*(1-u)^5+80*(1-u)^4-140*(1-u)^3+100*(1-u)^2+1
(%i3) declare (m, integer);
(%o3) done
(%i4) chebyshev_t (m, u);
(%o4) 'sum(pochhammer(-m,i1)*pochhammer(m,i1)*(1-u)^i1
/(pochhammer(1/2,i1)*2^i1*i1!),i1,0,m)
Below I have a Definite Clause Grammar that should accept the string aabccc, however when I tested the grammar, the only string I was able to get accepted was abc.
I'm pretty sure I've gotten rid of left-hand recursion, so I'm not sure what's going wrong.
s --> x, y, z.
x --> [a], x.
x --> [a].
y --> [b], y.
y --> [b].
z --> [c], z.
z --> [c].
Also, would I be able to define the above grammar as...
s --> x, y, z.
x --> [a], x; [a].
y --> [b], y; [b].
z --> [c], z; [c].
Both version of your grammar work as expected:
?- phrase(s, [a,a,b,b,c,c,c], R).
R = [] .
?- phrase(s, [a,a,b,b,c,c,c]).
true .
Maybe the issue was that you're trying to call it not with e.g. a [a,a,b,b,c,c,c] list of tokens but with a aabccc atom? If that's the case, you can use the standard atom_chars/2 built-in predicate to convert an atom into a list of characters:
?- atom_chars(aabccc, Tokens).
Tokens = [a, a, b, c, c, c].