Can a function contain a variable?

63 Views Asked by At

For example:

f is function
x is a variable
john is a constant

Would $ f(x, john) $ be well formed? Or can a function only map constants to an object in a domain?

3

There are 3 best solutions below

1
On BEST ANSWER

Yes, function terms can contain variables. The definition of well-formed expressions of predicate logic reads

...
If $x$ is a variable, then $x$ is a term.
...
If $f$ is an $n$-ary function symbol and $t_1, \ldots, t_n$ are terms, then $f(t_1, \ldots, t_n)$ is a term.
...

Since function symbols operate on terms, and variables are terms, this is permitted.

BTW, careful about terminology: "valid" has a specialized meaning in logic, meaning that a formula is true in all interpretations; to say that an expression is "grammatical", better say "well-formed" to avoid misunderstandings.

0
On

Sure. Let's say $f$ is a function that takes two inputs, $x$ and $y$, and gives us some output $z$, i.e. $z = f(x,y)$. Then if you fix $y = \text{john}$ then you can think of $z = f(x,\text{john})$ as a function itself with one input, $x$, made by looking at a the graph of $z = f(x,y)$ along the plane $y = \text{john}$. If you wanted to you could give this new function it's own name, say $g(x) = f(x,\text{john})$.

0
On

Technically, a function doesn't "contain" a variable. A function can, however, be defined by an expression that contains a variable, and its arguments can include a variable. Your question is rather odd: if a function is defined by an expression that doesn't contain any variables, then it's a constant valued function, which technically is a function, but isn't what people generally mean by a "function". For instance, "True" can be considered a function, in that something that sends all inputs to True is a function, but it would normally be considered a constant.

The arguments of a function being variables is what's normal, and them being constants is what's unusual. Often, if a function is defined in terms of a constant, it is treated as a parameter/subscript/index: $f_{John}(x)$.