How to specify a set of equivalent Functional Dependencies for a given relation - relational-algebra

We've been told that the FD are:
A->B
B->C
C->A
But with the transitive rule, since A->B and B->C this also means:
A->C
I worked out that:
A->BC is true, since A->B and A->C are FD. I can split A->BC to A->B, A->C with the splitting rule
C->AB is true, since C->A and due to transit rule: C->B is true (where C->A, A->B means C->B)
Can someone tell me the correct answer and why my answer is wrong. I can't get my head round the given answer.

The discussion of why your answer is wrong can be found in the comments.
The correct answer is #4: only in this answer A, B and C are superkeys as in the original set of functional dependencies. In #1 A is not a superkey (e.g., A -> B does not hold), in #3 C is not a superkey (e.g., C -> B does not hold).

Related

how to do a proof for subset in Isabelle

I'm trying to do some proofs manually in Isabelle but I'm struggling with the following proof:
lemma "(A ∩ B) ∪ C ⊆ A ∪ C "
I'm trying to transform it Propositional Logic then prove it.
So here's what I tried:
lemma "(A ∩ B) ∪ C ⊆ A ∪ C "
apply (subst subset_iff)+
apply(rule allI)
apply (rule impI)
(*here normally we should try to get rid of Union and Inter*)
apply(subst Un_iff)+
apply(subst (asm) Un_iff)+
apply(subst Inter_iff) (*not working*)
I'm stuck at the last step, could someone please help me finish this proof and explain how should one find the right theorems till the end?
I use find_theorems, but it takes a lot of time + the only useful (and understandable) ressource I found so far is this link:
https://www.inf.ed.ac.uk/teaching/courses/ar/isabelle/FormalCheatSheet.pdf
and some very few random lecture notes containing almost the same content as the link above...
Other resources I found are 100+ pages and do not look like a place to start for a beginner...
Thanks in advance
First writing such kind of proofs manually is not useful as it can be solved by blast. It is mostly reserved for advanced users. The only documentation I know is the old tutorial, Section 5.
Anyway, you have the wrong intersection theorems: you want to use Int_iff. Here is the full proof:
lemma "(A ∩ B) ∪ C ⊆ A ∪ C "
apply (subst subset_iff)+
apply(rule allI)
apply (rule impI)
(*here normally we should try to get rid of Union and Inter*)
apply(subst Un_iff)+
apply(subst (asm) Un_iff)
apply(subst (asm) Int_iff)
apply (elim disjE)
apply (elim conjE)
apply (rule disjI1)
apply assumption
apply (rule disjI2)
apply assumption
done
How did would I find such proof? I know by heart the low-level theorems on implication, conjunction, and disjunction (allI, impI, conjI, conjE, disjE, disjI1,...). There is a consistent naming convention (I: intro rule, E: elimination rule, D: destruction rule), so it is not so hard to remember.
For the rest, searching with find_theorems (or the query panel) is the way to go.
Here is the proof I would write (but the other one is nicer for teaching: conjE is way more important than IntE):
lemma "(A ∩ B) ∪ C ⊆ A ∪ C "
apply (rule subset_iff[THEN iffD2])
apply(intro allI impI)
apply (elim UnE)
apply (elim IntE)
apply (rule UnI1)
apply assumption
apply (rule UnI2)
apply assumption
done

Knights and Knives Logical Proposition

I have a question regarding Knights and Knaves and logical proposition. If I want to solve the puzzle and I assume I have two kinds of citizens: Knights, who always tell the truth, and knaves, who always tell lies. On the basis of utterances from some citizens, I must decide what kind they are.
There are three kinds of citizens: a, b and c, who are talking about themselves:
a says: ”All of us are knaves.”
b says: ”Exactly one of us is a knight.”
To solve the puzzle I should determine: What kinds of citizens are a, b and c? I should solve the puzzle by modelling the two utterances above using propositional logic, and I assume that I can use p to describe a knight and ¬p to describe a knave. How would I go about doing that? Any hint for someone who hasn't done any noticeable discrete mathematics in college?
A and C are Knaves. B is a Knight.
If A is a Knight, "All of us are knaves" is true. So, A would also be a Knave. This is a contradiction. Hence, A is a Knave.
If B is a Knave, then "Exactly one of us is a knight." is false. Meaning that 2 or more are Knights. But neither A nor B is a Knight. How can possibly be 2 or more Knights (since C is the only one with a possibility of being a Knight). This is also a contradiction. So, B is a Knight.
We just showed that B is a Knight. So, he himself is the only Knight he is talking about. So, C is a Knave.
Now, I don't think you can model this argument in the Propositional Logic. For one, notice the universal and existential quantifiers ("All" and "Exactly One") in the statements "All of us are knaves" and "Exactly one of us is a knight.". For another one, notice that A and B are talking about themselves. Modeling situations like this is one of the hardest problems in the history (not kidding!). Look at the following links for more info:
https://en.wikipedia.org/wiki/Liar_paradox
https://en.wikipedia.org/wiki/Self-reference
you can create a Truth table,
by first look at it i can say A must be knave, and B is a knight. because if A is a knight he can't say he's a knave(lie), also he can't be right about that all are knaves (can't say the truth) so B is a knight(if B Knave he can't say the truth that makes A a liar and he must be one) and then C is a Knave.

Deterministic Finite Automata pattern

I'm trying to solve this problem using Deterministic Finite Automata :
inputs: {a,b}
conditions:
a. must have exactly 2 a
b. have more than 2 b
so a correct input should be like this abbba or bbbaa or babab
now my question is, "is there a pattern to solve this things?"
Yes there is a pattern. You can take each statement and deduct pre-states from them. Then you take the cross-product of those pre-states, which will comprise the final states. In this example:
a. will yield states: 0a, 1a, 2a, 2+a (you've seen 0 a, 1 a, 2 as or more than 2 as)
b. will yield states: 0b, 1b, 2b, 2+b (you've seen 0 b, 1 b, 2 bs or more than 2 bs)
The cross product of these states result in 4x4=16 states. You'll start from {0a,0b} states. The inputs can be 3 types: a, b or something else.
From that you should be able to go. Do you need more help?
(Are we solving homework?)
Always draw such things first.
Feel free to give states any meanings. What you need here is states like: q2: (1 b, 2 a's). Draw states like this, until the accept state and connect them with lines. The accept state is qx: 2 a's 3 b's.
After reaching the accept state, if input is "b" that line goes to itself, the accept state. If the input is "a", draw a new state, that will get into an endless loop and goes into itself no matter what the input is.
(are we helping for an exam here?)

Simple Prolog implement about multi-agent argumentation

New to logic programming (Prolog). Come across a simple question but dont know how to code it in prolog.
Question is like you have several arguements: argument(a),argument(b)..., and several attack relations like attack(a,b) which means argument a attacks argument b. So given an argument I want to find out if it is a grounded one. "Grounded" for an argument a means if b attacks a, then there exists another argument, say c attacks b. If no argument attacks c then we say a and c are grounded.
Can you give an example how to implement this grounded/1 program to achieve this goal.
Not sure I make it clear....But welcome to give any advice (or code)!!
What I've understand from your explanation, an argument is grounded when there are no other grounded arguments attacking it.
You can define a procedure grounded/1 which obeys this rule straightforward in prolog:
grounded(A):-
argument(A), % A is an argument
\+ % for which there does not exist
(
attack(B, A), % an attacker
grounded(B) % which is grounded
).
[Edit after comment by OP]:
If you have to deal with cycles, then you will probably need to keep a list of visited "attacks", no forbid cycles:
grounded(A):-
grounded(A, []).
grounded(A, L):-
argument(A),
\+
(
attack(B, A),
\+ member(B, L), % Here we forbid cycles
grounded(B, [A|L]) % We add the current argument to the list of forbidden arguments
).
I don't know how to write in Prolog but the grounded semantics are computed starting from arguments that weren't attacked, given the argument tree.
(Hope it guides #gusbro to find a proper answer to this thread.)
To explain how it's computed, I'll introduce the following function F(x) = {x defends y}, where:
If one defended argument is attacked by other deffended argument, then the attacked argument will be removed from the set.
And so on, until the function cannot be more extended with more arguments, which it reached the minimal fix point in F.
(Exemple 1) given the following argumentation graph, the grounded extension is Eg = {c, e, f, a}.
So, the first function begins with:
Now let consider computing of grounded extension with cycles.
(Example 2) In the given argumentation graph bellow, e defends b and d, but b is attacked by d, then it can't be included in the grounded semantics. From this point we have a conflict-free set {e, d}. From {e, d} we can apply agin the function F({e, d}) = {e, d, a}, where d defends a from b. Applying again the function F({e, d, a}) = {e, d, a}, showing that {e, d, a} is the minimal fix point in F. Therefore, {e, d, a} is the grounded extension.
(Example 3) In the argumentation tree below, the grounded extension , since There aren't arguments that weren't attacked. Otherwise, If the argument e did not attack itself, the grounded extension should be , which is not the case.
In this last example, the cycle rises to different preferred extensions, where you can use as support the equivalent concept of argument labeling defined elsewhere by Martin Caminada.

Algorithm for 2-Satisfiability problem

Can anyone explain the algorithm for 2-satisfiability problem or provide me the links for the same? I could not find good links to understand it.
If you have n variables and m clauses:
Create a graph with 2n vertices: intuitively, each vertex resembles a true or not true literal for each variable. For each clause (a v b), where a and b are literals, create an edge from !a to b and from !b to a. These edges mean that if a is not true, then b must be true and vica-versa.
Once this digraph is created, go through the graph and see if there is a cycle that contains both a and !a for some variable a. If there is, then the 2SAT is not satisfiable (because a implies !a and vica-versa). Otherwise, it is satisfiable, and this can even give you a satisfying assumption (pick some literal a so that a doesn't imply !a, force all implications from there, repeat). You can do this part with any of your standard graph algorithms, ala Breadth-First Search , Floyd-Warshall, or any algorithm like these, depending on how sensitive you are to the time complexity of your algorithm.
You can solve it with greedy approach.
Or using Graph theory, here is link which explains the solution using graph theory.
http://www.cs.tau.ac.il/~safra/Complexity/2SAT.ppt
Here is the Wikipedia page on the subject, which describes a polynomial time algorithm. (The brute force algorithm of just trying all the different truth assignments is exponential time.) Maybe a bit of further explanation will help.
The expression "if P then Q" is only false when P is true and Q is false. So the expression has the same truth table values as "Q or not P". It is also equivalent to its contrapositive, "if not Q then not P", and that in turn is equivalent to "not P or Q" (the same as the other one).
So the algorithm involves replacing every expression of the form "A or B", with the two expressions, "if not A then B" and "if not B then A". (Putting it another way, A and B can't both be false.)
Next, construct a graph representing these implications. Create nodes for each "A" and "not A", and add links for each of the implications obtained above.
The last step is to make sure that none of the variables is equivalent to its own negation. That is, for each variable A (or not A), follow the links to discover all the nodes that can be reached from it, taking care to detect loops.
If one of the variables, A, can reach "not A", and "not A" can also reach A, then the original expression is not satisfiable. (It is a paradox.) If none of the variables do this, then it is satisfiable.
(It's okay if A implies "not A", but not the other way around. That just means that A must be negated to satisfy the expression.)
2 satisfiabilty:
if x & !x is strongly connected
then from !x we can reach to x
from x we can reach to !x
so in our operation,
in case of x,
we have 2 options only,
1.taking x (x) that leads to !x
2.rejecting x (!x) that leads to x
and both the choices are leading to the paradox of taking and rejecting a choice at the same time
so the satisfiability is impossible :D

Resources