Fresh variable

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In formal reasoning, in particular in mathematical logic, computer algebra, and automated theorem proving, a fresh variable is a variable that did not occur in the context considered so far.[1][citation needed] The concept is often used without explanation.[2][citation needed]

Fresh variables may be used to replace other variables, to eliminate variable shadowing or capture. For instance, in alpha-conversion, the processing of terms in the lambda calculus into equivalent terms with renamed variables, replacing variables with fresh variables can be helpful as a way to avoid accidentally capturing variables that should be free.[3] Another use for fresh variables involves the development of loop invariants in formal program verification, where it is sometimes useful to replace constants by newly introduced fresh variables.[4]

Example

[edit | edit source]

For example, in term rewriting, before applying a rule lr to a given term t, each variable in lr should be replaced by a fresh one to avoid clashes with variables occurring in t.[citation needed] Given the rule append(cons(x,y),z)cons(x,append(y,z)) and the term append(cons(x,cons(y,nil)),cons(3,nil)), attempting to find a matching substitution of the rule's left-hand side, append(cons(x,y),z), within append(cons(x,cons(y,nil)),cons(3,nil)) will fail, since y cannot match cons(y,nil). However, if the rule is replaced by a fresh copy[a] append(cons(v1,v2),v3)cons(v1,append(v2,v3)) before, matching will succeed with the answer substitution {v1x,v2cons(y,nil),v3cons(3,nil)}.

Notes

[edit | edit source]
  1. ^ that is, a copy with each variable consistently replaced by a fresh variable

References

[edit | edit source]
  1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). Here: slide 13/26.
  2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). Here: p.4.
  3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).