;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  MDH 25 October 2007 - Cleaned up old code - Created 2006
;;;  This is the implementation for the Double Sum example in the paper
;;;  "Synthesis of moduli of uniform continuity by the Monotone Dialectica 
;;;  Interpretation in the proof-system MinLog" by M.-D. Hernest
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/minlog/init.scm")
(set! COMMENT-FLAG #f)
(libload "nat.scm")
(mload "../modules/diatup.scm")
(mload "../examples/diatup/HeredExtEq/heeq-def.scm")

(set! UNFOLDING-FLAG #t)
(define t0 (pt "[f,k] ((Rec nat=>nat) k 0 ([n,m](f (f n))+m))"))
(define p1 (time (term-to-heeq-proof t0)))

(define vatmp (time (DIA-extract 'monot p1)))
(define untup (tmpair-to-tuple (vatmpair-to-tmpair vatmp)))
(define tmlst (tmtuple-to-tmlist untup))
(length tmlst)
(define raw_et (car tmlst))
(set! COMMENT-FLAG #t)
(size-and-depth raw_et)
;; (pp raw_et)
(define et (mk-term-in-app-form raw_et 
				   (term-to-maj (pt "f1"))
				   (term-to-maj (pt "f2"))))
(set! UNFOLDING-FLAG #t)
(pp (time (nt (mk-term-in-app-form et (pt "9")))))

