USE BOOK TYPES AND PROGRAMMING LANGUAGES AS REFERENCE
What is the role of termSubstTop operation (Section 7.2) in the
multi-step evaluation function eval?
7.3 Evaluation As in Chapter 3, the evaluation function depends on an auxiliary predicate isval: let rec isval ctx t = match t with TmAbs (-,-,-) true |- false The single-step evaluation function is a direct transcription of the evaluation rules, except that we pass a context ctx along with the term. This argument is not used in the present evall function, but it is needed by some of the more complex evaluators later on. let rec evall ctx t = match t with TmApp(fi, TmAbs (-,x, t12), v2) when isval ctx v2 – termSubstTop v2 t12 | TmApp(fi,v1, t2) when isval ctx v1 - let t2' = evall ctx t2 in TmApp (fi, vi, t2') | TmApp (fi, t1, t2) let ti' = evall ctx tl in TmApp(fi, ti', t2) 1- raise NoRuleApplies The multi-step evaluation function is the same as before, except for the ctx argument: = let rec eval ctx t = try let t' = evall ctx t in eval ctx t' with NoRuleApplies → t
USE BOOK TYPES AND PROGRAMMING LANGUAGES AS REFERENCE What is the role of termSubstTop operation (Section 7.2) in the mu
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
USE BOOK TYPES AND PROGRAMMING LANGUAGES AS REFERENCE What is the role of termSubstTop operation (Section 7.2) in the mu
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!