First order logic - position of quantifier - logic

When you have a statement with →, does it matter if you use a quantifier before or after the implication?
ex. the statement "Every man loves a king" (2 different semantic interpretations)
Every man loves a king and these kings may all differ from each other. ∀x IsMan(x) → ∃y (IsKing(y) ∧ Loves(x,y))
There is a single king that every man loves. ∃y, ∀x (IsKing(y) ∧ IsMan(x)) → Loves(x,y)
For #1, would it be equally correct to write it as ∀x, ∃y, (IsMan(x) ∧ IsKing(y)) → Loves(x,y)?
And for #2, what about ∃y IsKing(y) → ∀x (IsMan(x) ∧ Loves(x,y))?

Yes, the order of quantifier matters to decide the satisfiability/validity of a formula.
One way to be sure of it is to know that (A → B) is the same as (not A or B) and that (not (∀x x))is the same as (∃x (not x)).
Thus, when you have (∃x, ∀y x → y) it is the same as (∀x ∃y ((not x) or y)).
Which is different from (∃x, x → ∀y y) which can then be ((∀x (not x) or (∀y y)).

Related

express the following statements as formulas in first-order predicate logic

Let:
• B(x) for “x has bifurcated horns”
• D(x) for “x suffers from dermal asthenia”
• F(x) for “x is female”
• M(x, y) for “x is the mother of y”
• S(x) for “x is Syldavian”
• U(x) for “x is a unicorn”
How do I express
1) "Mother unicorns with dermal asthenia pass the condition on to all their offspring"
2) "Any unicorn whose mother is Syldavian suffers from dermal asthenia"
in first-order predicate logic?
My attempt
1)
there exist a x and for all y,
if x is mother of y
and x is a unicorn
and x has dermal asthenia,
it implies y have dermal asthenia too.
∃x∀y( (M(x,y) ∧ U(x) ∧ D(x) ) -> D(y) )
2)
for all x and y,
if y is a unicorn
and x is mother of y,
and x is Syldavian,
it implies y has dermal asthenia
∀x∀y( ( U(y) ∧ M(x,y) ∧ S(x) ) -> B(y) )
Any help would be appreciated, especially on when to use ∀ and when to use ∃.
Thank you.
"Mother unicorns with dermal asthenia pass the condition on to all their offspring"
∀x∀y((M(x,y) ∧ U(x) ∧ D(x)) -> D(y))
"Any unicorn whose mother is Syldavian suffers from dermal asthenia"
∀x∀y((M(x,y) ∧ U(y) ∧ S(x)) -> D(x))
Here there is no statements "there exists" or "at least one". These statements are about all unicorns so we do not use ∃.

How to write it in skolem form?(Prolog)

Translate the following formula into a horn formula in Skolem form:
∀w¬∀x∃z(H(w)∧(¬G(x,x)∨¬H(z)))
it's translated from german to english, how to write it in horn form and then in skolem form, i didn't find anything on internet...plz help me
I will always use the satisfiability preserving version of skolemization, i.e. the one where those are replaced which would become existential quantifiers when moved to the head of the formula.
To make life a bit simpler, let's push the negations to the atoms. We can also see that w doesn't occur in ¬G(x,x)∨¬H(z) and that x,z don't occur in H(w), allowing us to distribute the quantifiers a bit inside.
Then we obtain the formula ∀w¬H(w) ∨ ∃x∀z (G(x,x)∧ H(z)) .
If we want to refute the formula:
We skolemize ∃x and delete ∀w, ∀z and obtain:
¬H(w) ∨ (G(c,c)∧ H(z))
after CNF transformation, we have:
(¬H(w) ∨ G(c,c)) ∧ (¬H(w) ∨ H(z))
both clauses have exactly one positive literal, so they are horn clauses. Translated to Prolog syntax we get:
g(c,c) :- h(W).
h(Z) :- h(W).
If we want to prove the formula:
We have to negate before we skolemize, leading to:
∃w H(w) ∧ ∀x∃z (¬G(x,x) ∨ ¬H(z))
after skolemizing ∃w and ∃z, deleting ∀x and CNF transformation, we obtain:
H(c) ∧ (¬G(x,x) ∨ ¬H(f(x)))
That could be interpreted as a fact h(c) and a query ?- g(X,X), h(f(X)).
To be honest, both variants don't make much sense - the first does not terminate for any input and in the second version, the query will fail because g/2 is not defined.
does this page help?
6.3 Convert first-order logic expressions to normal form
A horn clause consists of various goals that all have to be satisfied in order for the whole clause to be true.
∀w¬∀x∃z(H(w)∧(¬G(x,x)∨¬H(z)))
First you want to translate the whole statement to human language for clarity. ¬ means NOT, ∧ means AND and ∨ means OR. The () are used to group goals.
∀w¬∀x∃z
For all w, all NOT x, at least 1 Z. If a w is true, x must be false and there must be at least 1 z.
H(w)
Is w a H? There must be a fact that says H(w) is true in your knowledge base.
¬G(x,x)
Is there a fact G(x,x)? If yes, return false.
¬H(z)
Is there a fact H(z)? If yes, return false.
z(H(w)∧(¬G(x,x)∨¬H(z)))
What this says that z is only true if H(w) is true AND either G(x,x) OR H(z) is false.
In Prolog you'd write this as
factCheck(W,X,Z) :- h(W), not(g(X,X);not(checkZ(Z)).
where Z is a list with at least 1 entry in it. If ANY element in list Z is true, fail.
%is the list empty?
checkZ([])
%is h true for the first element of the list?
checkZ([Head|Tail]) :- h(Head), !.
%remove the first element of the list
checkZ([Head|Tail]) :- checkZ(Tail).

can you help me to transform forall FO logical formula to it equivalent not exist formula?

i have this formula
∀x ∀y (A(x,y) V A(y,x) → B(y,c1) ∧ B(x,c2) ∧ c1≠c2)
to the equivalent formula that by using existential quantifier
?
∀x ∀y X is the same as ¬∃(x, y) ¬X
'X → Y' is the same as 'There is no counterexample when X but not Y'
¬(A(x,y) V A(y,x) → B(x,c1) ∧ B(x,c2) ∧ c1≠c2) = (A(x,y) V A(y,x)) ∧ ¬(B(x,c1) ∧ B(x,c2) ∧ c1≠c2)) - our counterexample. If we put negation of the second part in it and collect everything together, we get:
¬∃(x, y) (A(x,y) V A(y,x)) ∧ (¬B(x,c1) v ¬B(x,c2) v c1 = c2)
Update: replaced ¬∃x ¬∃ y with ¬∃(x, y). I suppose that's what you originally meant, right?
When you want to make that change, you basically want to find the opposite of what the inner statement says , because if a statement is true **for every ** x, then it means the opposite of it does not happen, ever; not exist means just that, there is no x such that makes the statement true.

Simplify expressions with nested ∃ and an equality

I came across a proof that I could not easily automate until I threw this lemma into Isabelle’s simplifier set:
lemma ex_ex_eq_hint:
"(∃x. (∃xs ys. x = f xs ys ∧ P xs ys) ∧ Q x) ⟷
(∃xs ys. Q (f xs ys) ∧ P xs ys)"
by auto
Now I am wondering: Is there a good reason why the simplifier or the classical reasoner is not able perform this simplification in general and automatically? Is there a more general form of this lemma that could be added to the default simpset to achieve this?
In Isabelle2015, the simplifier knows a number of rules to eliminate existentially bound variables which are determined by equality. For your case, the relevant ones are simp_thms(36-40):
(∃x. ?P) ⟷ ?P
∃x. x = ?t
∃x. ?t = x
(∃x. x = ?t ∧ ?P x) ⟷ ?P ?t
(∃x. ?t = x ∧ ?P x) ⟷ ?P ?t
Additionally, ex_simps(1-2) push existentials into conjuncts if one side does not mention the bound variable:
(∃x. ?P x ∧ ?Q) ⟷ (∃x. ?P x) ∧ ?Q
(∃x. ?P ∧ ?Q x) ⟷ ?P ∧ (∃x. ?Q x)
In many cases, these rules suffice to eliminate the existential quantifier. In your case, however, there are further existential quantifiers for xs and ys in between. In principle, the above rules and ex_comm, i.e., (∃x y. ?P x y) ⟷ (∃y x. ?P x y) (and associativity of op &, but that's a default simp rule anyway), suffice to prove your lemma by rewriting. However, one would have to pull the existentials out of the conjuncts and then permute the quantifiers such that x is bound innermost. None of these steps is desireable in the general case. Moreover,commutativity is subject to Isabelle's term order, so the simplifier might not even apply it in the indended way.
Thus, this problem cannot be solved in general by a finite set of rewrite rules, because there may be arbitrarily many nestings of quantifiers. It could, however, be solved by a simproc which triggers on existential quantifiers and searches the quantified predicate term for an equality of the bound variable. If the equality appears in a position such that the existential can be eliminated, then it has to produce the appropriate rewrite rule on the spot (conversions might be useful for that).
However, the simproc should make sure that it does not disturb the structure of the goal too much. Some of such disturbance can already be seen in your example. On the left hand side, the predicate Q is not in the scope of the inner quantifiers, but it is on the right-hand side.
This means that it is not clear that this transformation is desirable in all cases. For example, on the left-hand side, the classical reasoner used by auto, fastforce, etc. can go under one existential quantifier and then use classical reasoning to find an instantiation for x by analysing Q. This may lead to further simplifications of the equality x = f xs ys, which can lead to further instantiations. In contrast, on the right-hand side, the reasoner first has to introduce two schematic variables for existential quantifiers before it can even start to look at Q.
So in summary, I recommend that you analyse your setup to see why this form of quantifier nesting has occured at all in a goal state. Maybe you can adjust it such that everything works with the existing set of rules.

Expressing Einstein Puzzle as a Set of Closed Formulas in First Order Logic

I am given the classic Einstein/Zebra puzzle in this form:
Let us assume that there are five houses of different colors next to each other on the same road. In each house lives a man of a different nationality. Every man has his favorite drink, his favorite brand of cigarettes, and keeps pets of a particular kind.
The Englishman lives in the red house.
The Swede keeps dogs.
The Dane drinks tea.
The green house is just to the left of the white one.
The owner of the green house drinks coffee.
The Pall Mall smoker keeps birds.
The owner of the yellow house smokes Dunhills.
The man in the center house drinks milk.
The Norwegian lives in the first house.
The Blend smoker has a neighbor who keeps cats.
The man who smokes Blue Masters drinks bier.
The man who keeps horses lives next to the Dunhill smoker.
The German smokes Prince.
The Norwegian lives next to the blue house.
The Blend smoker has a neighbor who drinks water.
The question to be answered is: Who keeps fish?
The task is to express these statements as a set of closed formulas in first order logic, one for each of the statements, given the assumptions that the five persons in the puzzle are represented by englishman, swede, dane, norwegian, german, and keep(X,Y) means person X keeps pet Y. These will then later be converted to prolog.
My question is if I'm going about converting the statements in the right way. Right now, I have something like:
color(X, red) → lives(englishman, X)
keep(swede, dog)
drinks(dane, tea)
color(X, red) ∧ color(Y, green) → leftof(X, Y)
color(X, green) ∧ lives(Y, X) → drinks(Y, coffee)
smokes(X, pallmall) → keep(X, birds)
color(X, yellow) ∧ lives(Y, X) → smokes(Y, dunhills)
Is this correct, or should it be more like the other way I tried it:
house(X) ∧ color(X, red) → lives(englishman, X)
dog(X) → keep(swede, X)
tea(X) → drinks(dane, X)
house(X) ∧ house(Y) ∧ color(X, green) ∧ color(Y, white) → leftof(X, Y)
house(X) ∧ color(X, green) ∧ lives(Y, X) ∧ coffee(Z) → drinks(Y, Z)
pallmalls(X) ∧ smokes(Y, X) ∧ birds(Z) → keep(Y, Z)
house(X) ∧ color(X, yellow) ∧ lives(Y, X) ∧ dunhills(Z) → smokes(Y, Z)
I also attempted something like:
lives(englishman, redhouse)
keep(swede, dogs)
drinks(dane, tea)
leftof(greenhouse, whitehouse)
lives(X, greenhouse) → drinks(X, coffee)
smokes(X, pallmall) → keep(X, birds)
lives(X, yellowhouse) → smokes(X, dunhills)
I think the first one is most correct, but I'm not sure. I'm also not sure how to represent something like center or neighbor in first order logic. Are any of these close to being correct?
EDIT: I've come up with a solution that I think is possibly correct. I noticed that it said CLOSED formulas, so I did it in this way:
lives(englishman, red)
keep(swede, dogs)
drinks(dane, tea)
leftof(green, white)
∃X lives(X, green) ∧ drinks(X, coffee)
∃X smokes(X, pallmalls) ∧ keep(X, birds)
∃X lives(X, yellow) ∧ smokes(X, dunhills)
∃X position(X, 3) ∧ drinks(X, milk)
position(norwegian, 1)
∃X,Y smokes(X, blend) ∧ neighbor(X, Y) ∧ smokes(Y, dunhill)
∃X smokes(X, bluemasters) ∧ drinks(X, bier)
∃X,Y keep(X, horses) ∧ neighbor(X, Y) ∧ smoke(Y, dunhill)
smokes(german, prince)
∃X neighbor(norwegian, X) ∧ lives(X, blue)
∃X,Y smokes(X, blends) ∧ neighbor(X,Y) ∧ drinks(Y, water)
Is this the correct way to go about it? Any help would be appreciated.

Resources