Turning statement into predicate logic

221 Views Asked by At

Hey so I had to turn this into predicate logic. A list $l$ is in ascending order. So what i did is

$\forall x.((number(x) \leq length(l)-1) \to elem(l,x) \leq elem(l,x+1))$

so my question is do i have to specify that l is a list? something like

$\exists l.((list(l))\to(\forall x.((number(x) \leq length(l)-1) \to elem(l,x)\leq elem(l,x+1))) $

1

There are 1 best solutions below

2
On BEST ANSWER

The $number(x)$ part is weird ... is $number$ supposed to be a predicate? But that can't be right, since you say $number(x) \le length(l)-1$, which would only work if $number(x)$ is an object, and thus $number$ must be a function. But what function? Your $elem(l,x)$ expression is of course a function that returns the $x$-th element from the list, so you use $x$ as an index ... So then what does $number(x)$ do? Indeed, isn't it just the index $x$ itself that ranges from $1$ to $length(l)-1$? In other words, you should just get rid of that $number$ function, (and also introduce a lower bound to the index), so you get:

$\forall x ((1 \le x \land x \le length(l)-1) \rightarrow elem(l,x) \le elem(l,x+1))$

If you explicitly need to say that $l$ is a list (I really can't answer that question for you), then put $List(l) \land$ in front of that (don't use a quantifier for $l$, and certainly do not use a $\rightarrow$ in combination with a $\exists$)