Questions tagged [bound-variable]

A bound variable is a variable that was previously free, but has been bound to a specific value or set of values.

In mathematics, and in other disciplines involving formal languages, including mathematical logic and computer science, a free variable is a notation that specifies places in an expression where substitution may take place. The idea is related to a placeholder (a symbol that will later be replaced by some literal string), or a wildcard character that stands for an unspecified symbol.

In computer programming, the term free variable refers to variables used in a function that are not local variables nor parameters of that function. The term non-local variable is often a synonym in this context.

A bound variable is a variable that was previously free, but has been bound to a specific value or set of values. For example, the variable x becomes a bound variable when we write:

'For all x, (x + 1)2 = x2 + 2x + 1.' or

'There exists x such that x2 = 2.' In either of these propositions, it does not matter logically whether we use x or some other letter. However, it could be confusing to use the same letter again elsewhere in some compound proposition. That is, free variables become bound, and then in a sense retire from being available as stand-in values for other values in the creation of formulae.

The term "dummy variable" is also sometimes used for a bound variable (more often in general mathematics than in computer science), but that use creates an ambiguity with the definition of dummy variables in regression analysis.

13 questions
23
votes
2 answers

What are Free and Bound variables?

I've been programming for a long time (too long, actually), but I'm really struggling to get a handle on the terms "Free Variables" and "Bound Variables". Most of the "explanations" I've found online start by talking about topics like Lambda…
Roddy
  • 66,617
  • 42
  • 165
  • 277
7
votes
3 answers

Is it possible to write a data structure or data structures that represent only closed terms in Haskell or any other language?

Using the De Bruijn notation, it is possible to define lambda terms as: data BTerm = BVar Int | BLam BTerm | BApp BTerm BTerm Or using the usual notation, data Term = Var String | Lam String Term | App Term Term These two datatypes allow…
Edgar
  • 159
  • 5
2
votes
1 answer

Are variables bounded to free variables still free variables?

I am looking at some questions in my textbook about whether or not the variables are free or bound. I am not sure about these two in particular. First off, I want to make sure I understand the concept of free vs. bound. I am fairly sure this x is a…
2
votes
2 answers

Will recursively-called variable be free or bound?

I am trying to have a better understanding about free and bound variables. Here is an example code: (define (what-kind-of-var? guess x) (< (abs (- (square guess) x)) 0.001)) I see that bound variables here would be guess and x, and free…
Isaac
  • 273
  • 3
  • 19
2
votes
1 answer

PT algorithm for ML type inference

For the PT algorithm for ML type inference to work, the input program expression has to have the property that every bound variable is distinct. Can somebody explain it with an example?
1
vote
1 answer

Copy term with variables without variables being bound

With SWI-Prolog. How can a term with variables be copied without the variables being bound? What I have tried I tried copy_term/2 and duplicate_term/2 For example: foo(c). foo(E) :- E = bar(a,b,X), copy_term(E,Ec), …
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
0
votes
3 answers

Error in Getting newly inserted record through trigger-PLSQL

I am trying to create a trigger on EMP table which will audit insertions in EMP_AUDIT table and send mail to respective empno. The thing I am not getting is to get newly inserted record in CSV attachment that is being generated in v_block_query. I…
0
votes
1 answer

Avoiding infinite recursion but still using unbound parameter passing only

I have the following working program: (It can be tested on this site: http://swish.swi-prolog.org, I've removed the direct link to a saved program, because I noticed that anybody can edit it.) It searches for a path between two points in an…
0
votes
1 answer

Difference between "free variable" and "free occurrence of a variable" in context of lambda calculus

Is there any difference between free variable and free occurrence of a variable in context of lambda calculus? If yes, then please explain with an example or two. Actually I was going through the conversion rules for lambda expression where I came…
0
votes
0 answers

Bound variable and sapply

I am used to use apply familiy functions to avoid for loop with R. In this context I was wondering it there is a way to avoid typing a bound variable. For example, say I want to do 100 times an operation do.call(myfun, args). With for I'd write: res…
ClementWalter
  • 4,814
  • 1
  • 32
  • 54
0
votes
1 answer

SQL Bound variables error

I'm getting the error in my code. I'm sure this means there is something wrong with the column=:variable section of my code, but I've gone over it and can't see what's wrong. Fatal error: Uncaught exception 'PDOException' with message…
Mitch8910
  • 185
  • 1
  • 2
  • 15
0
votes
1 answer

How to bind returned function local variable to method parameter?

I would like to get the following PHP code to work. The part that is not working is that the inner variable $greetingCount (the returned function's local variable) is not binding to the outer variable $greetingCount (the method parameter…
-2
votes
1 answer

Is num a bound variable or a free variable?

def function() num = 1 num += 1 return num Is num a bound variable or a free variable? P.S. This code is written in python. There's no former code ahead of this.