- #1
CGandC
- 326
- 34
Hello, I have a few questions and I'd appreciate if you can please help me.
1. If I want to say "for every ## i \in \Bbb N ## and ## 0 \leq j \leq i ## define ## A_{i,j} := i ## and ## B_{i,j} := i \cdot j ## ",
then is the logical formula used for this is as such?:
## \forall i \in \Bbb N. \forall ~ 0 \leq j \leq i. ~ \exists A_{i,j}. \exists B_{i,j}.( A_{i,j} = i ~\land ~ B_{i,j} = i \cdot j ) ##
2. Suppose we have the function ## f: \Bbb Q \to \Bbb N ## defined as follows: for every ## q \in \Bbb Q ## there exist ## a \in \Bbb Z ## and ## b \in \Bbb N^+ ## s.t. ## q = \frac{a}{b} ## and ## q ## is a rational in its reduced form; then ## f(q) = f(\frac{a}{b}) = |a| + |b| ##.
Can this whole sentence be written as the following logical formula?:
## \exists f: \Bbb Q \to \Bbb N . \forall q \in \Bbb Q. \exists a \in \Bbb Z. \exists b \in \Bbb N^+ . ( q = \frac{a}{b} ~ \land ~ \text{ q is in reduced form } ). f(q) = f(\frac{a}{b}) = |a| + |b| ##
3. Would the following pseudo-code be correct for describing both logical formulas above?
Thanks in advance for any help!
1. If I want to say "for every ## i \in \Bbb N ## and ## 0 \leq j \leq i ## define ## A_{i,j} := i ## and ## B_{i,j} := i \cdot j ## ",
then is the logical formula used for this is as such?:
## \forall i \in \Bbb N. \forall ~ 0 \leq j \leq i. ~ \exists A_{i,j}. \exists B_{i,j}.( A_{i,j} = i ~\land ~ B_{i,j} = i \cdot j ) ##
2. Suppose we have the function ## f: \Bbb Q \to \Bbb N ## defined as follows: for every ## q \in \Bbb Q ## there exist ## a \in \Bbb Z ## and ## b \in \Bbb N^+ ## s.t. ## q = \frac{a}{b} ## and ## q ## is a rational in its reduced form; then ## f(q) = f(\frac{a}{b}) = |a| + |b| ##.
Can this whole sentence be written as the following logical formula?:
## \exists f: \Bbb Q \to \Bbb N . \forall q \in \Bbb Q. \exists a \in \Bbb Z. \exists b \in \Bbb N^+ . ( q = \frac{a}{b} ~ \land ~ \text{ q is in reduced form } ). f(q) = f(\frac{a}{b}) = |a| + |b| ##
3. Would the following pseudo-code be correct for describing both logical formulas above?
define logical_formula(i,j):
if j <= i:
A_ij = i
B_ij = i*j
return A_ij , B_ij
else:
return True ## returning "True" because the formula is vacuously true in this case.
#######################################################################################
define f(q):
if is_rational(q) == True :
a,b = find_reduced_form(q)
return (|a| + |b|)
else:
return True ## returning "True" because the logical formula of the function definition
## is vacuously true in this case.
Thanks in advance for any help!
Last edited: