# Confusion with Tuple Relation Calculus Operations

I came upon a question like,

Given the following relational schemas

Student (studId, name, age, sex, deptNo, advisor)
Department (deptId, DName, hod, phoneNo)

Which of the following will be the tuple relational calculus query to obtain the department names that do not have any girl students?

{d.Dname | department(d) ∧ ~ ((∃(s)) student(s) ∧ s.sex = ‘F’ ∧ s.deptNo = d.deptId)}

My interpretation to it is the for every department, the inner logic is trying to find at least one student who is from the same department and is a female. Now if it fails to find one, it return FALSE and the negation will make it TRUE and thus that Dname will be printed. This is perfectly fine.

But if I negate the logic, i.e flow the negate sign then the inner logic becomes,

((∀s ∈ student) s.sex ≠ ‘F’ ∨ s.deptNo ≠ d.deptId)

How does this mean the same as above? I cannot imagine it.

Any help is appreciated. Thanks in advance.

∃s (student(s) ∧ s.sex = ‘F’ ∧ s.deptNo = d.deptId)

For some s, s is a student & s is female & s is in d's department.

~∃s (student(s) ∧ s.sex = ‘F’ ∧ s.deptNo = d.deptId)

For no s, s is a student & s is female & s is in d's department.

~∃x P is ∀x ~P. So ~∃x (Q ∧ R) is ∀x (~Q V ~R) is ∀x (Q → ~R). We get:

∀s (student(s) → (s.sex ≠ ‘F’ ∨ s.deptNo ≠ d.deptId))

For all s, if s is a student then either they are not female or their department is not d's.

For all students, either they are not female or their department is not d's.

For some reason you changed notation (but not meaning) & wrote that as:

∀s ∈ student(s) (s.sex ≠ ‘F’ ∨ s.deptNo ≠ d.deptId))

You don't explain what you think this means so it's not clear why you think it couldn't mean the same as the negated existential. But they mean the same thing.

When all the students are either non-female or not in d's department, the forall is true. But the negated existential is also true. Otherwise some student is female & in d's department, and the forall is false. But the negated existential is also false. (That "otherwise" clearly is the existential.)

Now if it fails to find one, it returns FALSE and the negation will make it TRUE

You don't explain your notion of universal quantification failure & success. Your "fails to find one returns false" is for the existential. (Ie "finds one returns true".) But "fails to find all returns false" is for the universal. (Ie "finds all returns true".) (Not "fails to find one returns true" or "finds one returns false".)

When the existential fails to find a student that is female & in d's department--false, negated to true--the universal finds all students are either non-female or not in d's department--true. Otherwise, both expressions return false. They always return the same result.