「SF-LC」14 ImpCEvalFun
Step-Indexed Evaluator
…Copied from 12-imp.md:
Chapter
ImpCEvalFunprovide some workarounds to make functional evalution works:
- step-indexed evaluator, i.e. limit the recursion depth. (think about Depth-Limited Search).
- return
optionto tell if it’s a normal or abnormal termination.- use
LETOPT...IN...to reduce the “optional unwrapping” (basicaly Monadic binding>>=!)
this approach oflet-bindingbecame so popular in ML family.
1 | Notation "'LETOPT' x <== e1 'IN' e2" |
Relational vs. Step-Indexed Evaluation
Prove ceval_step is equiv to ceval
->
1 | Theorem ceval_step__ceval: forall c st st', |
The critical part of proof:
destructfor thei.induction i, generalize on allst st' c.i = 0case contradictioni = S i'case;destruct c.destruct (ceval_step ...)for theoptionNonecase contradictionSomecase, use induction hypothesis…
<-
1 | Theorem ceval__ceval_step: forall c st st', |
评论
TwikooValine






