「SF-LC」14 ImpCEvalFun
Step-Indexed Evaluator
…Copied from 12-imp.md
:
Chapter
ImpCEvalFun
provide some workarounds to make functional evalution works:
- step-indexed evaluator, i.e. limit the recursion depth. (think about Depth-Limited Search).
- return
option
to tell if it’s a normal or abnormal termination.- use
LETOPT...IN...
to reduce the “optional unwrapping” (basicaly Monadic binding>>=
!)
this approach oflet-binding
became 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:
destruct
for thei
.induction i
, generalize on allst st' c
.i = 0
case contradictioni = S i'
case;destruct c
.destruct (ceval_step ...)
for theoption
None
case contradictionSome
case, use induction hypothesis…
<-
1 | Theorem ceval__ceval_step: forall c st st', |