> Definition count_up_def:
count_up m k = if m < k:num then 1 + count_up (m+1) k else 0:num
Termination
WF_REL_TAC ‘measure $ λ(m,k). k - m:num’
End;
Equations stored under "count_up_def".
Induction stored under "count_up_ind".
val count_up_def =
⊢ ∀m k. count_up m k = if m < k then 1 + count_up (m + 1) k else 0: thm
> val cv_count_up_pre = cv_trans_pre_rec count_up_def
(WF_REL_TAC ‘measure $ λ(m,k). cv$c2n k - cv$c2n m’
\\ Cases \\ Cases \\ gvs [] \\ rw [] \\ gvs []);
Equations stored under "cv_count_up_def".
Induction stored under "cv_count_up_ind".
Finished translating count_up, stored in cv_count_up_thm
WARNING: definition of cv_count_up has a precondition.
You can set up the precondition proof as follows:
Theorem count_up_pre[cv_pre]:
∀m k. count_up_pre m k
Proof
ho_match_mp_tac count_up_ind (* for example *)
...
QED
val cv_count_up_pre =
⊢ ∀m k. count_up_pre m k ⇔ m < k ⇒ count_up_pre (m + 1) k: thm
> Theorem count_up_pre[cv_pre]:
∀m k. count_up_pre m k
Proof
ho_match_mp_tac count_up_ind \\ rw []
\\ simp [Once cv_count_up_pre]
QED
val count_up_pre = ⊢ ∀m k. count_up_pre m k: thm
> cv_eval “count_up 5 100”;
val it = ⊢ count_up 5 100 = 95: thm