Functors and natural transformations - functor

If F is a functor linking category C to category D, and G is a functor linking category C to category E,(and assuming that both functors are bijections), does this imply that there is a unique natural transformation from functor F to functor G?

Related

Prolog - Print truth table for first order table

I've some difficults to print a truth table for first order logic.
The tasks is:
Write a Prolog predicate table (F, U) that receives one as input
well-formed formula in propositional logic F e
is satisfied by the rows of the truth table of formula F
which have U value. Formula F is expressed by
the function symbols not / 1, and / 2 and or / 2,
the constants t (for true) and f (for false),
any round brackets and use free variables as symbols
of proposition.
Example
?- table(and(P, or(Q, P)), U)
P=t, Q=f, U=t;
P=t, Q=t, U=t;
P=f, Q=f, U=f;
P=f, Q=t, U=f;

In Maxima, how do I get the elementwise (Hadamard) product of two matrices?

In Maxima, how do I get the elementwise (Hadamard) product of two matrices?
e.g
a b
c d
*
e f
g h
->
a*e b*f
c*e d*h
A*B is the elementwise product, as opposed to the matrix product, A.B

Relational Algebra: Natural Join having the same result as Cartesian product

I am trying to understand what will be the result of performing a natural join
between two relations R and S, where they have no common attributes.
By following the below definition, I thought the answer might be an empty set:
Natural Join definition.
My line of thought was because the condition in the 'Select' symbol is not met, the projection of all of the attributes won't take place.
When I asked my lecturer about this, he said that the output will be the same as doing a cartezian product between R and S.
I can't seem to understand why, would appreciate any help )
Natural join combines a cross product and a selection into one
operation. It performs a selection forcing equality on those
attributes that appear in both relation schemes. Duplicates are
removed as in all relation operations.
There are two special cases:
• If the two relations have no attributes in common, then their
natural join is simply their cross product.
• If the two relations have more than one attribute in common,
then the natural join selects only the rows where all pairs of
matching attributes match.
Notation: r s
Let r and s be relation instances on schema R and S
respectively.
The result is a relation on schema R ∪ S which is
obtained by considering each pair of tuples tr from r and ts from s.
If tr and ts have the same value on each of the attributes in R ∩ S, a
tuple t is added to the result, where
– t has the same value as tr on r
– t has the same value as ts on s
Example:
R = (A, B, C, D)
S = (E, B, D)
Result schema = (A, B, C, D, E)
r s is defined as:
πr.A, r.B, r.C, r.D, s.E (σr.B = s.B r.D = s.D (r x s))
The definition of the natural join you linked is:
It can be broken as:
1.First take the cartezian product.
2.Then select only those row so that attributes of the same name have the same value
3.Now apply projection so that all attributes have distinct names.
If the two tables have no attributes with same name, we will jump to step 3 and therefore the result will indeed be cartezian product.

How does the ISO Prolog standard require the preservation of variable identity when converting from a clause to a term?

I am missing something in my reading of ISO/IEC 13211-1, subclauses 7.6.3 and 7.6.4:
7.6.3 Converting the head of a clause to a term
A head H with predicate indicator P/N can be converted to a term T:
a) If N is zero then T is the atom P.
b) If N is non-zero then T is a renamed copy (7.1.6.2) of TT where TT is the compound term whose principal functor is P/N and the arguments of H and TT are identical.
7.6.4 Converting the body of a clause to a term
A goal G which is a predication with predicate indicator P/N can be converted to a term T:
a) If N is zero then T is the atom P.
b) If N is non-zero then T is a renamed copy (7.1.6.2) of TT where TT is the compound term whose principal functor is P/N and the arguments of G and TT are identical.
c) If G is a control construct which appears in table 9 then T is a term with the corresponding principal functor. If the principal functor of T is call/1 or catch/3 or throw/1 then the arguments of G and T are identical, else if the principal functor of T is (',')/2 or (;)/2 or (->)/2 then each argument of G shall also be converted to a term.
Suppose we have a public (7.5.3) (e.g. dynamic) user-defined predicate a/1, defined by the following single clause:
a(X) :- b(X).
Clearly, the goal
?- clause(a(A), b(B)), A == B.
should succeed. Quoting part of the definition of clause/2 (8.8.1.1):
a) Searches sequentially through each public user-defined procedure in the database and creates a list L of all the terms clause(H, B) such that
1) the database contains a clause whose head can be converted to a term H (7.6.3), and whose body can be converted to a term B (7.6.4), and
2) H unifies with Head, and
3) B unifies with Body.
Converting the head of the above clause to a term, 7.6.3 b) applies, and we create a renamed copy a(A) of a(X). Similarly, converting the body of the clause, 7.6.4 b) applies, and we create a renamed copy b(B) of b(X).
The problem is that a(A) and b(B) are separate renamed copies. How is it required that A and B are identical variables, as we would expect?
The same question could be asked for a clause
p :- q(X), r(X).
When we convert the body of this clause to a term, 7.6.4 c) applies, and the principal functor of the term should be (',')/2, with the two arguments being the goals q(X) and r(X) converted to terms. But these are predications and 7.6.4 b) applies, so again the two resulting terms are separately renamed copies.
What am I missing?

Is it possible to represent a context-free grammar with first-order logic?

Briefly, I have a EBNF grammar and so a parse-tree, but I do not know if there is a procedure to translate it in First Order Logic.
For example:
DR ::= E and P
P ::= B | (and P)* | (or P)*
B ::= L | P (and L P)
L ::= a
Yes, there is. The general pattern for translating a production of the form
A ::= B C ... D
is to paraphrase is declaratively as saying
A sequence of terminals s is an A (or: A generates the sequence s, if you prefer that formulation) if:
s is the concatenation of s_1, s_2, ... s_n, and
s_1 is a B / B generates the sequence s_1, and
s_2 is a C / C generates the sequence s_2, and
...
s_n is a D / D generates the sequence s_n.
Assuming we write these in the obvious way using a generates predicate, and that we can write concatenation using a || operator, your first rule becomes (if I am right to guess that E and P are non-terminals and "and" is a terminal symbol) something like
generates(DR,s) ⊃ generates(E,s1)
∧ generates(and,s2)
∧ generates(P,s3)
∧ s = s1 || s2 || s3
To establish the consequent (i.e. prove that s is an A), prove the antecedents. As long as the grammar does actually generate some sentences, and as long as you have some premises defining the "generates" relation for terminal symbols, the proof will be straightforward.
Prolog definite-clause grammars are a beautiful instantiation of this pattern. It takes some of us a while to understand and appreciate the use of difference lists in DCGs, but they handle the partitioning of s into subsequences and the association of the subsequences with the different parts of the right hand side much more elegantly than the simple translation into logic given above.

Resources