Fresh variable
Find sources: "Fresh variable" – news · newspapers · books · scholar · JSTOR (September 2023) (Learn how and when to remove this message)
Find sources: "Fresh variable" – news · newspapers · books · scholar · JSTOR (September 2023) (Learn how and when to remove this message)
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 ]For example, in term rewriting, before applying a rule {\displaystyle l\to r} to a given term {\displaystyle t}, each variable in {\displaystyle l\to r} should be replaced by a fresh one to avoid clashes with variables occurring in {\displaystyle t}.[citation needed ] Given the rule {\displaystyle \operatorname {append} (\operatorname {cons} (x,y),z)\to \operatorname {cons} (x,\operatorname {append} (y,z))} and the term {\displaystyle \operatorname {append} (\operatorname {cons} (x,\operatorname {cons} (y,\mathrm {nil} )),\operatorname {cons} (3,\mathrm {nil} )),} attempting to find a matching substitution of the rule's left-hand side, {\displaystyle \operatorname {append} (\operatorname {cons} (x,y),z)}, within {\displaystyle \operatorname {append} (\operatorname {cons} (x,\operatorname {cons} (y,\mathrm {nil} )),\operatorname {cons} (3,\mathrm {nil} ))} will fail, since {\displaystyle y} cannot match {\displaystyle \operatorname {cons} (y,\mathrm {nil} )}. However, if the rule is replaced by a fresh copy[a] {\displaystyle \operatorname {append} (\operatorname {cons} (v_{1},v_{2}),v_{3})\to \operatorname {cons} (v_{1},\operatorname {append} (v_{2},v_{3}))} before, matching will succeed with the answer substitution {\displaystyle \{v_{1}\mapsto x,\;v_{2}\mapsto \operatorname {cons} (y,\mathrm {nil} ),\;v_{3}\mapsto \operatorname {cons} (3,\mathrm {nil} )\}.}
Notes
[edit ]- ^ that is, a copy with each variable consistently replaced by a fresh variable
References
[edit ]- ^ Carmen Bruni (2018). Predicate Logic: Natural Deduction (PDF) (Lecture Slides). Univ. of Waterloo. Here: slide 13/26.
- ^ Michael Färber (Feb 2023). Denotational Semantics and a Fast Interpreter for jq (Technical Report). Univ. of Innsbruck. arXiv:2302.10576 . Here: p.4.
- ^ Gordon, Andrew D.; Melham, Thomas F. (1996). "Five axioms of alpha-conversion". In von Wright, Joakim; Grundy, Jim; Harrison, John (eds.). Theorem Proving in Higher Order Logics, 9th International Conference, TPHOLs'96, Turku, Finland, August 26-30, 1996, Proceedings. Lecture Notes in Computer Science. Vol. 1125. Springer. pp. 173–190. doi:10.1007/BFB0105404. ISBN 978-3-540-61587-3.
- ^ Cohen, Edward (1990). "Loops B — On replacing constants by fresh variables". Programming in the 1990s. Monographs in Computer Science. New York: Springer. pp. 149–194. doi:10.1007/978-1-4613-9706-9. ISBN 9781461397069. S2CID 1509875.