# Can someone confirm these English to predicate logic problems for me?

1. Jan 25, 2010

### Ownaginatious

1. The problem statement, all variables and given/known data

I actually have to problems I would just like someone to confirm for me. I have several other problems similar to these, and I don't want to waste time in case I do not understand the fundamentals. Anyway:

a) Define suitable predicates and functions and then formalize the following sentence : A student receives a grade for every course in which he or she registers:

b) Translate the following English statements into predicate logic : Adding two odd integers yields an even number. Use only addition and multiplication; do not use division, mod, or predicates even(x) and odd(x).

2. Attempt at a solution

Now here is my attempt:

a) I defined the variables:
- c = courses
- s = students

And the functions:
- isReg(s, c)

And then combined them into the following formal statement:

$$(\forall s|: (\forall c | isReg(s,c) : getsGrade(s, c)))$$

b) Now for this I simply derived the following:

$$(\forall x,y:Z|(\exists n:Z|:(2n+1) = x) \wedge (\exists n:Z|:(2n+1) = y):(\exists n:Z|:(2n) = (x + y)))$$

If I've gone wrong, any help at getting back onto the right track would be much appreciated.

Thanks :)

2. Jan 25, 2010

### sylas

(a) is probably right... but English can be ambiguous. When the sentence says "a student..." it could also be taken to mean that "there is a student..." which would be a quite different meaning.

But I suspect you've given what was intended.

I wonder a bit about your syntax for the restricted quantifiers (using "|" to restrict the range of a variable) in part a, where you have the "|" without the preceding domain. Is there a clearly defined syntax you are using?

3. Jan 25, 2010

### Ownaginatious

Ya, I was wondering that exact same thing sylas. My textbook talks a lot about how English is so ambiguous, so I'm going to assume that whether this applies to one student or all students is open to my interpretation ;).

4. Jan 25, 2010

### Ownaginatious

Oh I was led to believe that that's the equivalent to saying "over the whole domain", which is the equivalent to just putting "true" there.

5. Jan 25, 2010

### sylas

It depends on what rules you've been given for syntax. Your syntax uses ":" for two different roles, which is ok. I've seen it done before. I'll use "•" for the start of the statement to which the quantified applies, just for clarity. Here's a possible grammar:
Code (Text):

statement ::= quantifier variable ":" range "•" statement
range ::= setvariable
| setvariable "|" statement

Basically, a grammar like this requires a range for a variable, to be either just named set, or perhaps a named set with an additional constraint or restriction. That's how I have usually seen "|" used. It can be read "such that".

The "•" can be replaced with another ":" without ambiguity, unless the first ":" becomes optional. If the first ":" is optional you might have the following rule as well:
Code (Text):

statement ::= quantifier variable "•" statement

In this case there has to be some understood domain that is being used.

What I have not seen is "|" by itself, without the first ":". It makes sense, if understood has having a ":X" implied before hand, where X is the understood domain.

I'm just asking in case... have you been given a syntax you are expected to use? What you have is still quite comprehensible, but it you have a required syntax you might want to check.

Cheers -- sylas

6. Jan 25, 2010

### Ownaginatious

Well, as given in our book, the syntax they want us to use is the following:

(*x | R : P)

R = Range, P = Body, * = operator/function, x = variable(s). The ':' is also used to represent type (i.e. x : Z = x of type integer).

In class my professor just left out R or made it "true" when he wanted to use the whole domain.

Here is an example he did:

"Some integer is larger than 23" formally is $$(\exists x:Z|:x > 23)$$ or $$(\exists x:Z|true:x > 23)$$

Sorry if I've misunderstood your question. This is all new to me.

7. Jan 25, 2010

### sylas

You've understood fine, and your answers seem fine and consistent with the syntax you've provided. I just wondered about the syntax, and you've explained it well.

Cheers -- sylas

8. Jan 25, 2010

### Ownaginatious

Oh awesome :) Thank you very much for you help!