;; (load "~/git/minlog/init.scm")
(set! COMMENT-FLAG #f)
(libload "nat.scm")
(libload "list.scm")
(libload "pos.scm")
(libload "int.scm")
(libload "rat.scm")
(libload "rea.scm")
(load "/Users/Dominik/Downloads/lub_lemma-1.scm")
(set! COMMENT-FLAG #t)

(add-pvar-name "S" (make-arity (py "rea")))

;;Init
(set-goal
 "all x,b(Real x -> S^ x -> all y(Real y -> S^ y -> y<<=b) ->
	       exd c exl d(c<d andi 
			       all y(Real y -> S^ y -> y<<=d) andi
			       exnc y(Real y andnc S^ y andnc c<<=y)))")
(cases)
(assume "as" "M" "b" "Rx" "Sx" "bBd")
(intro 0 (pt "as(M 1)-1"))
(intro 0 (pt "b"))
(assert "RealLt(as(M 1)-1)(RealConstr as M)1")
 (ng #t)
 (simp "RatPlusComm")
 (use "RatLePlusR")
 (simp "<-" "RatLeUMinus")
 (ng #t)
 (simp "RatPlusComm")
 (use "RatLeTrans" (pt "abs(as(M 1)+ ~(as(M 3)))"))
 (ng #t)
 (use "Truth")
 (simp (pf "(1#2)=(1#2**1)"))
 (use "CauchyElim" (pt "M"))
 (use "RealConstrToCauchy")
 (use "Rx")
 (ng #t)
 (use "Truth")
 (use "MonElim")
 (use "RealConstrToMon" (pt "as")) 
 (use "Rx")
 (ng #t)
 (use "Truth")
 (ng #t)
 (use "Truth")
(assume "c<x")
(split)
(use "RealToRatLt" (pt "PosS(PosS(PosS(PosS(PosS 1))))"))
(use "RealLtLeTrans" (pt "RealConstr as M"))
(use "RealRat")
(use "Rx")
(use "RealRat")
(use "c<x")
(use "bBd")
(use "Rx")
(use "Sx")
(split)
(use "bBd")
(intro 0 (pt "RealConstr as M"))
(split)
(use "Rx")
(split)
(use "Sx")
(use "RealLtToLe" (pt "1"))
(use "RealRat")
(use "Rx")
(use "c<x")
;;(cdp)
;;ok
(save "Init")

(define eterm (proof-to-extracted-term))
(pp eterm)
(define neterm (rename-variables (nt eterm)))
(ppc neterm)

;[x,a][if x ([as,M]as(M 1)+IntN 1 pair a)]
(define sproof (proof-to-soundness-proof))
;(cdp sproof)
;(cdp (np sproof))
(animate "Init")
(animate "Rht")
(add-theorem "InitSound" sproof)


;; For the proof in LuB, we use another version of soundness, avoiding Ex:
(set-goal "all x,b(Real x -> S^ x -> all y(Real y -> S^ y -> y<<=b) -> 
			lft (cInit x b)<rht (cInit x b) andnc 
			all y(Real y -> S^ y -> y<<= rht (cInit x b)) andnc 
			exnc y(Real y andnc S^ y andnc lft (cInit x b)<<=y))")
(cases)
(assume "as" "M" "b1" "Rx1" "Sx1" "b1Bd")
(use-with "ExLTMRElim" 
     (py "rat")
     (make-cterm (pv "d") 
		 (pf "lft(cInit (RealConstr as M) b1)<d andnc 
		     all y(Real y -> S^ y -> y<<=d) andnc 
		     exnc y(Real y andnc S^ y andnc lft(cInit (RealConstr as M) b1)<<=y)"))
     (pt "b1")
     "?")
(use-with "ExDTMRElim"
	  (py "rat")
	  (py "rat")
	  (make-cterm (pv "c") (pv "a^") 
		      (pf "(ExLTMR (cterm (d) c<d andnc 
					  all y(Real y -> S^ y -> y<<=d) andnc
					  exnc y(Real y andnc S^ y andnc c<<=y)))a^"))
	  (pt "[if (RealConstr as M) ([as,M,b0]as(M 1)-1 pair([a^]a^)b0)]b1")
	  "?")
;(pp (nt (pt "[if (RealConstr as M) ([as,M,b0]as(M 1)-1 pair([a^]a^)b0)]b1")))
(use "InitSound")
(auto)
(save "InitReal")
(deanimate "Init")


(pp "InitSound")
(pp "InitReal")


;;StepAux
(set-goal "all c,d(c<d -> all x(Real x -> S^ x -> x<<=d) ori
		          exnc x(Real x andnc S^ x andnc c <<=x)) -> 
	   all c,d(c<d -> all x(Real x -> S^ x -> x<<=d) ->
		       exnc x(Real x andnc S^ x andnc c<<=x) ->
		       exd c1 exl d1(all x(Real x -> S^ x -> x<<=d1) andi
					 exnc x(Real x andnc S^ x andnc c1<<=x) andi
					 c<=c1 andi d1<=d andi d1-c1==(2#3)*(d-c) andi c1<d1))")
(assume "OLA" "c" "d" "c<d" "S<=d" "c<=S")
;; Abbreviations for (1#3)*(2*c+d) and (1#3)*(c+2*d)
(assert "exl c1 c1=(1#3)*(2*c+d)")
 (intro 0 (pt "(1#3)*(2*c+d)"))
 (use "Truth")
(assume "ExHypLft")
(by-assume "ExHypLft" "c1" "c1Def")
(assert "exl d1 d1=(1#3)*(c+2*d)")
 (intro 0 (pt "(1#3)*(c+2*d)"))
 (use "Truth")
(assume "ExHypRht")
(by-assume "ExHypRht" "d1" "d1Def")
(assert "c1<d1")
 (simp "c1Def")
 (simp "d1Def")
 (use "RatLtMonTimes")
 (use "Truth")
 (use "RatLeLtTrans" (pt "c+c+d"))
 (simprat (pf "2*c==c+c"))
 (use "Truth")
 (simprat (pf "c==1*c"))
 (simprat "<-" "RatTimesPlusDistrLeft")
 (use "Truth")
 (use "Truth")
 (use "RatLtLeTrans" (pt "c+d+d"))
 (simp "<-" "RatPlusAssoc")
 (simp "<-" "RatPlusAssoc")
 (use "RatLtMonPlus")
 (use "Truth")
 (simp "RatPlusComm")
 (use "RatLtMonPlus")
 (use "Truth")
 (use "c<d")
 (simprat (pf "2*d==d+d"))
 (use "Truth")
 (simprat (pf "d==1*d"))
 (simprat "<-" "RatTimesPlusDistrLeft")
 (use "Truth")
 (use "Truth")
(assume "c1<d1")
(inst-with-to "OLA" (pt "c1") (pt "d1") "c1<d1" "Disj")
(drop "OLA")
(elim "Disj")
;; 25,26
(drop "Disj")
;; Case Lft
(assume "LftCase")
(intro 0 (pt "c"))
(intro 0 (pt "d1"))
(split)
(use "LftCase")
(split)
(use "c<=S")
(split)
(use "Truth")
(split)
(simp "d1Def")
(use "RatLeTrans" (pt "(1#3)*(d+2*d)"))
(simp "RatTimesComm")
(simp "<-" "RatLeUMinus")
(simp "RatTimesComm")
(simp "RatLeUMinus")
(use "RatLeMonTimes")
(use "Truth")
(use "RatLeMonPlus")
(use "RatLtToLe")
(use "c<d")
(use "Truth")
(simprat (pf "d+2*d==3*d"))
(simp "RatTimesAssoc")
(use "Truth")
(simprat (pf "d==1*d"))
(simp "RatTimesAssoc")
(simprat "<-" "RatTimesPlusDistrLeft")
(use "Truth")
(use "Truth")
(split)
(simp "d1Def")
(simprat (pf "(1#3)*(c+2*d)-c==(1#3)*(c+2*d)+ ~c"))
(simprat (pf "~c==(1#3)*(~3*c)"))
(simprat "<-" "RatTimesPlusDistr")
(simp "RatPlusComm")
(simp "RatPlusAssoc")
(simprat (pf "c==1*c"))
(simp "RatTimesAssoc")
(simprat "<-" "RatTimesPlusDistrLeft")
(simprat (pf "(RatTimes~3 1+1)*c== 2* ~c"))
(simp "RatPlusComm")
(simprat "<-" "RatTimesPlusDistr")
(simp "RatTimesAssoc")
(use "Truth")
(ng #t)
(use "Truth")
(ng #t)
(use "Truth")
(use "Truth")
(use "Truth")
(simp "d1Def")
(use "RatLeLtTrans" (pt "c1"))
(simp "c1Def")
(simp "RatTimesComm")
(simprat (pf "c==(c*(3#1))*(1#3)"))
(use "RatLeMonTimes")
(use "Truth")
(ng #t)
(simp "<-" "RatTimesAssoc")
(simprat (pf "(3#1)*(1#3)==1"))
(ng #t)
(simprat (pf "c*(3#1)==2*c+c"))
(use "RatLtToLe")
(use "RatLtMonPlus")
(use "Truth")
(use "c<d")
(simprat (pf "2*c+c==2*c+1*c"))
(simprat "<-" "RatTimesPlusDistrLeft")
(ng #t)
(simp "RatTimesComm")
(use "Truth")
(ng #t)
(use "Truth")
(ng #t)
(use "Truth")
(simp "<-" "RatTimesAssoc")
(ng #t)
(use "Truth")
(simp "<-" "d1Def")
(use "c1<d1")
(drop "Disj")
;; Case Rht
(assume "RhtCase")
(intro 0 (pt "c1"))
(intro 0 (pt "d"))
(split)
(use "S<=d")
(split)
(use "RhtCase")
(split)
(simp "c1Def")
(use "RatLeTrans" (pt "(1#3)*(c+2*c)"))
(simprat (pf "c==1*c"))
(simp "RatTimesAssoc")
(simprat "<-" "RatTimesPlusDistrLeft")
(use "Truth")
(use "Truth")
(simp "RatTimesComm")
(simp "<-" "RatLeUMinus")
(simp "RatTimesComm")
(simp "RatLeUMinus")
(use "RatLeMonTimes")
(use "Truth")
(simp "RatPlusComm")
(use "RatLeMonPlus")
(use "Truth")
(use "RatLtToLe")
(use "c<d")
(split)
(use "Truth")
;(split)
;(use "Truth")
(split)
(simp "c1Def")
(simprat (pf "d-(1#3)*(2*c+d)==(1#3)*(3*d)+ (1#3)*(~d+ ~(2*c))"))
(simprat "<-" "RatTimesPlusDistr")
(simp "RatPlusAssoc")
(simprat (pf "3*d+ ~d==2*d"))
(simprat (pf "~(2*c)==2* ~c"))
(simprat "<-" "RatTimesPlusDistr")
(simp "RatTimesAssoc")
(use "Truth")
(use "Truth")
(simprat (pf "~d== IntN 1*d"))
(simprat "<-" "RatTimesPlusDistrLeft")
(use "Truth")
(simprat (pf "d==d*1"))
;(simp "<-" "RatTimesIdIntUMinus")
(ng)
;(simp "RatTimesComm")
(use "Truth")
(use "Truth")
;(use "RatPlusCompat")
;(use "Truth")
(simprat (pf "d-(1#3)*(2*c+d)==d+ ~((1#3)*(2*c+d))"))
(use "RatPlusCompat")
(ng)
(use "Truth")
(simprat (pf "~d+ ~(2*c)== (IntN 1#1)*(d+2*c)"))
(simp "RatTimesAssoc")
(simp-with "RatTimesComm" (pt "(1#3)") (pt "(IntN 1#1)"))
(ng #t)
(simp "RatPlusComm")
(use "Truth")
(ng #t)
(use "Truth")
(ng #t)
(use "Truth")
(use "RatLtLeTrans" (pt "d1"))
(use "c1<d1")
(simp "d1Def")
(simp "RatTimesComm")
(simprat (pf "d==(3*d)*(1#3)"))
(use "RatLeMonTimes")
(use "Truth")
(ng #t)
(simp "RatTimesComm")
(simp "RatTimesAssoc")
(ng #t)
(simprat (pf "3*d==1*d+2*d"))
(ng #t)
(use "RatLtToLe")
(use "c<d")
(simprat "<-" "RatTimesPlusDistrLeft")
(ng #t)
(use "Truth")
(simp "RatTimesComm")
(simp "RatTimesAssoc")
(ng #t)
(use "Truth")
;; Proof finished.
(save "StepAux")

;(define eterm (proof-to-extracted-term (theorem-name-to-proof "StepAux")))
(add-var-name "ola" (py "rat=>rat=>boole"))
;(define neterm (rename-variables (nt eterm)))
;(ppc neterm)

;; [ola,a,a0]
;;  [case (ola((1#3)*(2*a+a0))((1#3)*(a+2*a0)))
;;    (True -> a pair(1#3)*(a+2*a0))
;;    (False -> (1#3)*(2*a+a0)pair a0)]

(define sproof (proof-to-soundness-proof (theorem-name-to-proof "StepAux")))
;(cdp sproof)
;(cdp (np sproof))
;(animate "StepAux")
(add-theorem "StepAuxSound" sproof)

(add-var-name "cd" (py "rat yprod rat"))



;;Step
(set-goal "all c,d(c<d -> all x(Real x -> S^ x -> x<<=d) oru
			  exnc x(Real x andnc S^ x andnc c <<=x)) ->
	   all cd(lft cd<rht cd -> all x(Real x -> S^ x -> x<<=rht cd) ->
		      exnc x(Real x andnc S^ x andnc lft cd<<=x) ->
		      exl cd1(all x(Real x -> S^ x -> x<<=rht cd1) andi
			      exnc x(Real x andnc S^ x andnc lft cd1<<=x) andi
			      lft cd<=lft cd1 andi
			      rht cd1<=rht cd andi 
			      rht cd1-lft cd1==(2#3)*(rht cd-lft cd) andnc 
			      lft cd1 < rht cd1))")
(assume "OLA" "cd" "c<d" "S<=d" "c<=S")
(inst-with-to "StepAux" "OLA" 
	      (pt "lft cd") 
	      (pt "rht cd") 
	      "c<d" "S<=d" "c<=S" "NextInst")
(drop "OLA")
(by-assume "NextInst" "c1" "c1Prop")
(by-assume "c1Prop" "d1" "c1d1Prop")
(intro 0 (pt "c1 pair d1"))
(ng)
(use "c1d1Prop")
;; Proof finished.
(save "Step")

;(define eterm (proof-to-extracted-term (theorem-name-to-proof "NextPair")))
;(define neterm (rename-variables (nt eterm)))
;(ppc neterm)
;; [ola,cd]cNext ola lft cd rht cd

(define sproof (proof-to-soundness-proof(theorem-name-to-proof "Step")))
;(animate "Next")
;(cdp sproof)
;(cdp (np sproof))
;ok
;(deanimate "Next")
;(pp (proof-to-formula sproof))
(animate "Step")
(save "StepSound" sproof)

(add-var-name "cds" (py "nat=>rat yprod rat"))

;;As for Init we prove n own soundness version: 
(set-goal "all ola(all c,d(c<d -> (OrUMR 
				    (cterm () all x(Real x -> S^ x -> x<<=d))
				    (cterm () exnc x(Real x andnc S^ x andnc c<<=x)))(ola c d)) -> 
		   all cd(lft cd<rht cd -> all x(Real x -> S^ x -> x<<=rht cd) -> 
			      exnc x(Real x andnc S^ x andnc lft cd<<=x) -> 
			      all x(Real x -> S^ x -> x<<=rht (cStep ola cd)) andnc  
			      exnc x(Real x andnc S^ x andnc lft (cStep ola cd)<<=x) andnc 
			      lft cd<=lft (cStep ola cd) andnc rht (cStep ola cd)<=rht cd andnc 
			      rht (cStep ola cd)-lft (cStep ola cd)==(2#3)*(rht cd-lft cd) andnc 
			      lft (cStep ola cd)< rht (cStep ola cd)))")
 (assume "ola1" "OLAMR" "cd" "c<d" "S<=d" "c<=S")
 (use-with "ExLTMRElim"
	  (py "rat yprod rat")
	  (make-cterm (pv "cd0") 
		      (pf "all x(Real x -> S^ x -> x<<=rht cd0) andnc 
			  exnc x(Real x andnc S^ x andnc lft cd0<<=x) andnc 
			  lft cd<=lft cd0 andnc rht cd0<=rht cd andnc 
			  rht cd0-lft cd0==(2#3)*(rht cd-lft cd) andnc 
			  lft cd0 < rht cd0"))
	  (pt "cStep ola1 cd")
	  "?")
 (use "StepSound")
 (use "OLAMR")
 (auto)
(save "StepReal")
(deanimate "Step")

(pp "StepSound")
(pp "StepReal")


;;c_n,d_n are real numbers & equal
;;SeqProps
(set-goal
 "all cs,ds,m(all n(cs n<ds n andnc 
		       cs n<=cs(Succ n) andnc 
		       ds(Succ n)<=ds n andnc 
		       ds(Succ n)-cs(Succ n)==(2#3)*(ds n-cs n)) -> 
 ds Zero-cs Zero<=2**m -> 
 Real(RealConstr cs([q]2*(m+(PosToNat q)))) andnc 
 Real(RealConstr ds([q]2*(m+(PosToNat q)))) andnc 
 RealConstr cs([q]2*(m+(PosToNat q)))===
 RealConstr ds([q]2*(m+(PosToNat q))))")
(assume "cs" "ds" "m0" "SeqProp" "InitBound")
; Left Increasing
(assert "all n,m(n<=m -> cs n<=cs m)")
 (assume "n")
 (ind)
  (assume "Hyp")
  (simp (pf "n=Zero"))
  (use "Truth")
  (use "Hyp")
  (assume "m" "IH" "Hyp")
  (assert "n<=m oru n=Succ m")
   (casedist (pt "n<=m"))
   (assume "n<=m")
   (intro 0)
   (use "Truth")
   (assume "m<n")
   (intro 1)
   (simp (pf "n=n max Succ m"))
;   (assume "Succ m<=n")
   (simp (pf "Succ m=n max Succ m"))
   (use "Truth")
   (use "NatEqSym")
   (use "NatMaxEq2")
   (use "Hyp")
   (use "NatEqSym")
   (use "NatMaxEq1")
   (use "NatNotLtToLe")
   (assume "n<Succ m")
   (use "m<n")
   (use "NatLtSuccToLe")
   (use "n<Succ m")
  (assume "Disj")
  (elim "Disj")
  (assume "Case1")
   (use "RatLeTrans" (pt "cs m"))
   (use "IH")
   (use "Case1")
   (use "SeqProp")
  (assume "Case2")
   (simp "Case2")
   (use "Truth")
(assume "LeftIncr")
; Right decreasing
(assert "all n,m(n<=m -> ds m<=ds n)")
 (assume "n")
 (ind)
  (assume "Hyp")
  (simp (pf "n=Zero"))
  (use "Truth")
  (use "Hyp")
  (assume "m" "IH" "Hyp")
  (assert "n<=m oru n=Succ m")
   (casedist (pt "n<=m"))
   (assume "n<=m")
   (intro 0)
   (use "Truth")
   (assume "m<n")
   (intro 1)
   (simp (pf "n=n max Succ m"))
;   (assume "Succ m<=n")
   (simp (pf "Succ m=n max Succ m"))
   (use "Truth")
   (use "NatEqSym")
   (use "NatMaxEq2")
   (use "Hyp")
   (use "NatEqSym")
   (use "NatMaxEq1")
   (use "NatNotLtToLe")
   (assume "n<Succ m")
   (use "m<n")
   (use "NatLtSuccToLe")
   (use "n<Succ m")
  (assume "Disj")
  (elim "Disj")
  (assume "Case1")
   (use "RatLeTrans" (pt "ds m"))
   (use "SeqProp")
   (use "IH")
   (use "Case1")
  (assume "Case2")
   (simp "Case2")
   (use "Truth")
(assume "RightDecr")
; AbsBoundLeft
(assert "all n,m(n<=m -> abs(cs m-cs n)<=ds n-cs n)")
 (assume "n" "m" "n<=m")
 (use "RatLeTrans" (pt "cs m-cs n"))
 (simp "RatAbsId")
 (use "Truth")
 (simp (pf "cs m-cs n=cs m+ ~(cs n)"))
 (use "RatLePlusR")
 (ng)
 (use "LeftIncr")
 (use "n<=m")
 (use "Truth")
 (simp (pf "cs m-cs n=cs m+ ~(cs n)"))
 (simp (pf "ds n-cs n=ds n+ ~(cs n)"))
 (use "RatLeMonPlus")
 (use "RatLeTrans" (pt "ds m"))
 (use "RatLtToLe")
 (use "SeqProp")
 (use "RightDecr")
 (use "n<=m")
 (use "Truth")
 (use "Truth")
 (use "Truth")
(assume "AbsBoundLeft")
; AbsBoundRight
(assert "all n,m(n<=m -> abs(ds m-ds n)<=ds n-cs n)")
 (assume "n" "m" "n<=m")
 (use "RatLeTrans" (pt "ds n-ds m"))
 (use "RatLeAbs")
 (simp (pf "ds m-ds n=ds m+ ~(ds n)"))
 (simp "RatPlusComm")
 (use "RatLePlusRInv")
 (simp (pf "ds n-ds m=ds n+ ~(ds m)"))
 (simp "RatPlusAssoc")
 (simp "RatPlusComm")
 (use "RatLePlusR")
 (ng #t)
 (use "RatLeMonPlus")
 (use "RightDecr")
 (use "n<=m")
 (use "RightDecr")
 (use "n<=m")
 (use "Truth")
 (use "Truth")
 (ng #t)
 (simp "RatPlusComm")
 (use "Truth")
 (simp (pf "ds n-ds m=ds n+ ~(ds m)"))
 (simp (pf "ds n-cs n=ds n+ ~(cs n)"))
 (use "RatLeMonPlus")
 (use "Truth")
 (ng)
 (use "RatLeTrans" (pt "cs m"))
 (use "LeftIncr")
 (use "n<=m")
 (use "RatLtToLe")
 (use "SeqProp")
 (use "Truth")
 (use "Truth")
(assume "AbsBoundRight")
; Diff
(assert "all n(ds n-cs n==(2#3)**n*(ds Zero-cs Zero))")
 (ind)
  (use "Truth")
  (assume "n" "IH")
  (simprat (pf "(2#3)**Succ n*(ds Zero -cs Zero)==(2#3)*(ds n-cs n)"))
  (use "SeqProp") 
  (simprat "IH")
  (simp "RatTimesAssoc")
  (simprat (pf "(2#3)**Succ n==(2#3)*(2#3)**n"))
  (use "Truth") 
  (simprat "RatExpSucc")
  (simp "RatTimesComm")
  (use "Truth")
(assume "Diff")
; Real Left
(assert "Real(RealConstr cs([q]2*(m0+(PosToNat q))))")
 (use "RealIntro")
 (use "CauchyIntro")
 (ng #t)
 (assume "p0" "n" "m" "nHyp" "mHyp")
 (use "NatLeLin" (pt "n") (pt "m"))
 (assume "Case1")
  (use "RatLeTrans" (pt "ds n-cs n"))
  (simprat (pf "abs(cs n+ ~(cs m))==abs(~(cs n+ ~(cs m)))"))
  (ng #t)
  (simp "RatPlusComm")
  (use "AbsBoundLeft")
  (use "Case1")
  (simp "RatAbsMax")
  (simp "RatAbsMax")
  (ng #t)
  (use "RatMaxComm")
  (simprat "Diff")
  (use "RatLeTrans" (pt "2**m0*(2#3)**n"))
  (simp "RatTimesComm")
  (use "RatLeMonTimes")
  (use "RatLeExpMon")
  (ng #t)
  (use "Truth")
  (use "InitBound")
  ; ?_175:2**p*(2#3)**n<=(1#2**p0)
  (use "RatLeTimesCancelR" (pt "2**p0#1")) 
  (ng #t)
  (use "Truth")
  (ng #t)
  (simprat (pf "(2**p0#2**p0)==1"))
  (simp "<-" "RatTimesAssoc")
  (simp-with "RatTimesComm" (pt "(2#3)**n") (pt "(2**p0#1)"))
  (simp "RatTimesAssoc")
  (use "RatLeTimesCancelR" (pt "3**n#1")) 
  (use "Truth")
  (ng #t)
  (simp (pf "2**m0*2**p0=2**(m0+p0)"))
  (simp "<-" "RatTimesAssoc")
  (simprat (pf "((2#3)**n*3**n)==2**n"))
  (ng #t)
  (simp (pf "2**(m0+p0)*2**n=2**(m0+p0+n)"))
  (simp "NatPlusComm")
  (use "Lemma2" (pt "m0+(PosToNat p0)") (pt "n"))
  (ng #t)
  (use "nHyp")
  (use "PosExpTwoNatPlus")
  ; ?_205:(2#3)**n*3**n==2**n
  (simprat (pf "3**n==RatExp 3 n"))
  (simprat "Lemma3")
  (use "Truth")
  (use "PosExpRatExp")
  (use "Lemma6")
  (ng #t)
  (use "Truth")
 (assume "Case2")
  (use "RatLeTrans" (pt "ds m-cs m"))
  (use "AbsBoundLeft")
  (use "Case2")
  (simprat (pf "ds m-cs m==(2#3)**m*(ds Zero-cs Zero)"))
  ;(use "Diff")
  (use "RatLeTrans" (pt "2**m0*(2#3)**m"))
  (simp "RatTimesComm")
  (use "RatLeMonTimes")
  (use "RatLeExpMon")
  (ng #t)
  (use "Truth")
  (use "InitBound")
  ; ?_216:2**p*(2#3)**m<=(1#2**p0)
  (use "RatLeTimesCancelR" (pt "2**p0#1")) 
  (ng #t)
  (use "Truth")
  (ng #t)
  (simprat (pf "(2**p0#2**p0)==1"))
  (simp "<-" "RatTimesAssoc")
  (simp-with "RatTimesComm" (pt "(2#3)**m") (pt "(2**p0#1)"))
  (simp "RatTimesAssoc")
  (use "RatLeTimesCancelR" (pt "3**m#1")) 
  (use "Truth")
  (ng #t)
  (simp (pf "2**m0*2**p0=2**(m0+p0)"))
  (simp "<-" "RatTimesAssoc")
  (simprat (pf "((2#3)**m*3**m)==2**m"))
  (ng #t)
  (simp (pf "2**(m0+p0)*2**m=2**(m0+p0+m)"))
  (simp "NatPlusComm")
  (use "Lemma2" (pt "m0+p0") (pt "m"))
  (ng #t)
  (use "mHyp")
  (use "PosExpTwoNatPlus")
  ; ?_238:(2#3)**m*3**m==2**m
  (simprat (pf "3**m==RatExp 3 m"))
  (simprat "Lemma3")
  (use "Truth")
  (use "PosExpRatExp")
  (ng #t)
  (use "Lemma6")
  (ng #t)
  (use "Truth")
  (use "Diff")
 ;?_156:Mon((RealConstr cs([q]2*(m0+q)))mod)
 (ng #t)
 (use "MonIntro")
 (assume "p1" "p2" "p1<=p2")
 (ng #t)
 (use "NatLeMonPlus")
 (use "NatLeMonPlus")
 (use "NatLeMonPlus")
 (use "Truth")
 (simp "PosToNatLe")
 (use "p1<=p2")
 (use "Truth")
 (simp "PosToNatLe")
 (use "p1<=p2")
(assume "RealLeft")
; Real Right
(assert "Real(RealConstr ds([q]2*(m0+q)))")
 (use "RealIntro")
 (use "CauchyIntro")
 (ng #t)
 (assume "p0" "n" "m" "nHyp" "mHyp")
 (use "NatLeLin" (pt "n") (pt "m"))
 (assume "Case1")
  (use "RatLeTrans" (pt "ds n-cs n"))
  (simprat (pf "abs(ds n+ ~(ds m))==abs(~(ds n+ ~(ds m)))"))
  (ng #t)
  (simp "RatPlusComm")
  (use "AbsBoundRight")
  (use "Case1")
  (simp "RatAbsMax")
  (simp "RatAbsMax")
  (ng #t)
  (use "RatMaxComm")
  (simprat "Diff")
  (use "RatLeTrans" (pt "2**m0*(2#3)**n"))
  (simp "RatTimesComm")
  (use "RatLeMonTimes")
  (use "RatLeExpMon")
  (ng #t)
  (use "Truth")
  (use "InitBound")
  ;
  (use "RatLeTimesCancelR" (pt "2**p0#1")) 
  (ng #t)
  (use "Truth")
  (ng #t)
  (simprat (pf "(2**p0#2**p0)==1"))
  (simp "<-" "RatTimesAssoc")
  (simp-with "RatTimesComm" (pt "(2#3)**n") (pt "(2**p0#1)"))
  (simp "RatTimesAssoc")
  (use "RatLeTimesCancelR" (pt "3**n#1")) 
  (use "Truth")
  (ng #t)
  (simp (pf "2**m0*2**p0=2**(m0+p0)"))
  (simp "<-" "RatTimesAssoc")
  (simprat (pf "((2#3)**n*3**n)==2**n"))
  (ng #t)
  (simp (pf "2**(m0+p0)*2**n=2**(m0+p0+n)"))
  (simp "NatPlusComm")
  (use "Lemma2" (pt "m0+p0") (pt "n"))
  (ng #t)
  (use "nHyp")
  (use "PosExpTwoNatPlus")
  ;  
  (simprat (pf "3**n==RatExp 3 n"))
  (simprat "Lemma3")
  (use "Truth")
  (use "PosExpRatExp")
  (ng #t)
  (use "Lemma6")
  (ng #t)
  (use "Truth")
 (assume "Case2")
  (use "RatLeTrans" (pt "ds m-cs m"))
  (use "AbsBoundRight")
  (use "Case2")
  (simprat (pf "ds m-cs m==(2#3)**m*(ds Zero-cs Zero)"))
  ;(use "Diff")
  (use "RatLeTrans" (pt "2**m0*(2#3)**m"))
  (simp "RatTimesComm")
  (use "RatLeMonTimes")
  (use "RatLeExpMon")
  (ng #t)
  (use "Truth")
  (use "InitBound")
  ; ?_216:2**p*(2#3)**m<=(1#2**p0)
  (use "RatLeTimesCancelR" (pt "2**p0#1")) 
  (ng #t)
  (use "Truth")
  (ng #t)
  (simprat (pf "(2**p0#2**p0)==1"))
  (simp "<-" "RatTimesAssoc")
  (simp-with "RatTimesComm" (pt "(2#3)**m") (pt "(2**p0#1)"))
  (simp "RatTimesAssoc")
  (use "RatLeTimesCancelR" (pt "3**m#1")) 
  (use "Truth")
  (ng #t)
  (simp (pf "2**m0*2**p0=2**(m0+p0)"))
  (simp "<-" "RatTimesAssoc")
  (simprat (pf "((2#3)**m*3**m)==2**m"))
  (ng #t)
  (simp (pf "2**(m0+p0)*2**m=2**(m0+p0+m)"))
  (simp "NatPlusComm")
  (use "Lemma2" (pt "m0+p0") (pt "m"))
  (ng #t)
  (use "mHyp")
  (use "PosExpTwoNatPlus")
  ; ?_238:(2#3)**m*3**m==2**m
  (simprat (pf "3**m==RatExp 3 m"))
  (simprat "Lemma3")
  (use "Truth")
  (use "PosExpRatExp")
  (ng #t)
  (use "Lemma6")
  (ng #t)
  (use "Truth")
  (use "Diff")
 ;Mon
 (ng #t)
 (use "MonIntro")
 (assume "p1" "p2" "p1<=p2")
 (ng #t)
 (use "NatLeMonPlus")
 (use "NatLeMonPlus")
 (use "NatLeMonPlus")
 (use "Truth")
 (simp "PosToNatLe")
 (use "p1<=p2")
 (use "Truth")
 (simp "PosToNatLe")
 (use "p1<=p2")
(assume "RealRight")
       


(msplit)
 (use "RealEqIntro")
 (use "RealLeft")
 (use "RealRight")
 (assume "p1")
 (ng #t)
 (simprat (pf "abs(cs(m0+PosS p1+m0+PosS p1)+ ~(ds(m0+PosS p1+m0+PosS p1)))==
	      abs(~(cs(m0+PosS p1+m0+PosS p1))+ ds(m0+PosS p1+m0+PosS p1))"))
 (simp "RatAbsId")
 (ng #t)
 (simp "RatPlusComm")
 (simprat "Diff")
 (use "RatLeTrans" (pt "(2#3)**NatPlus(m0+PosS p1)(m0+PosS p1)*2**m0"))
 (simp "RatTimesComm")
 (simp-with "RatTimesComm" (pt"(2#3)**(m0+PosS p1+(m0+PosS p1))") (pt "2**m0#1"))
 (use "RatLeMonTimes")
 (use "RatLeExpMon")
 (use "Truth")
 (use "InitBound")
 (simp (pf "m0+PosS p1+(m0+PosS p1)=2*(m0+PosS p1)"))
 (simprat "<-" "RatExpExp")
 (ng #t)
 (use "RatLeTrans" (pt "(1#2)**(m0+PosS p1)*2**m0"))
 (use "RatLeMonTimes")
 (use "Truth")
 (use-with "RatLeMonExpNat" (pt "(4#9)") (pt "(1#2)") (pt "m0+PosS p1") "?" "?") 
 (use "Truth")
 (use "Truth")
 ; ?_401:(1#2)**PosS(p+p1)*2**p<=(1#2**p1)
 (simp (pf "m0+PosS p1=Succ(m0+p1)"))
 (simprat "RatExpSucc")
 (simprat "RatExpDistrPlus")
 (simp "<-" "RatTimesAssoc")
 (simp "<-" "RatTimesAssoc")
 (simp "RatTimesComm")
 (simp "<-" "RatTimesAssoc")
 (simp "<-" "RatTimesAssoc")
 (simprat "PosExpRatExp")
 (simp-with "RatTimesComm" (pt "RatExp 2 m0") (pt "(1#2)**m0"))
 (simprat "Lemma3")
 (simp "PosExpOne")
 (ng #t)
 (simp "RatTimesComm")
 (simprat (pf "(1#2**p1)==(1#1)*(1#2)**(PosToNat p1)"))
 (simp-with "<-" "RatTimesAssoc" (pt "(1#2)**m0") (pt "(1#2)**(PosToNat p1)") (pt "RatExp 2 m0"))
 (simp-with "RatTimesComm" (pt "(1#2)**(PosToNat p1)") (pt "RatExp 2 m0"))
 (simp "RatTimesAssoc")
 (simp "RatTimesAssoc")
 (use "RatLeMonTimes")
 (use "RatLeExpMon")
 (use "Truth")
 (simp "<-" "RatTimesAssoc")
 (simprat (pf "(1#2)**m0*RatExp 2 m0==1"))
 (ng #t)
 (use "Truth")
 (ind (pt "m0"))
 (ng #t)
 (use "Truth")
 (assume "n" "IH")
 (ng #t)
 (simprat "RatExpSucc")
 (simprat "RatExpSucc")
 (simp-with "RatTimesComm" (pt "(2#1)") (pt "RatExp 2 n"))
 (ng #t)
 (simp-with "RatTimesComm" (pt "(1#2)*(1#2)**n*RatExp 2 n") (pt "(2#1)"))
 (ng #t)
 (use "IH")
 (simp "PosToNatToIntId")
 (ng #t)
 (use "Truth")
 (simp "PosSSucc")
 (ng #t)
 (use "Truth")
 (ng #t)
 (use "Truth")
 (use "RatLePlusR")
 (ng #t)
 (use "RatLtToLe")
 (use-with "SeqProp" (pt "m0+PosS p1+m0+PosS p1") 'left)
 (simp "RatAbsMax")
 (simp "RatAbsMax")
 (use "RatMaxComm")
 (use "RealRight")
 (use "RealLeft")
;;done
(save "SeqProps")



;;types of cInit & cStep, for rational sequence of LuB
(pp (term-to-type (pt "cInit")))
(pp (term-to-type (pt "cStep")))
;;type of OLA:
(pp (formula-to-et-type (pf "all c,d(c<d -> all x(Real x -> S^ x -> x<<=d) oru
exnc x(Real x andnc S^ x andnc c<<=x))")))


;;somit: cInit x b and cStep ola cd haben Eigenschaft (1)-(3)
;;definiere Folge über:
;; [n](Rec nat=>rat yprod rat)n(cInit x b)([n](cStep ola))

;;Lub
(set-goal "all b,x(Real x -> S^ x -> all y(Real y -> S^ y -> y<<=b) -> 
                        exl ola all c,d(c<d -> (OrUMR 
				   (cterm () all x(Real x -> S^ x -> x<<=d))
				   (cterm () exnc x(Real x andnc S^ x andnc c<<=x)))(ola c d)) -> 
			exl x(Real x andi 
			      all y(Real y -> S^ y -> y<<=x) andi 
			      all a,p(RealLt a x p -> exnc x(S^ x andi a<<=x))))")

(assume "b" "x" "Rx" "Sx" "bSup" "ExOlaMRTotal")
(by-assume "ExOlaMRTotal" "ola" "OlaMRTotal")

;;we assert the existence of the rational sequences
(assert "exl cds(
		 (cds Zero) eqd cInit x b andnc 
		 all n(all x(Real x -> S^ x -> x<<=rht (cds (Succ n))) andnc 
			   exnc x(Real x andnc S^ x andnc lft (cds (Succ n))<<=x) andnc 
			   lft (cds n)<=lft (cds (Succ n)) andnc 
			   rht (cds (Succ n))<=rht (cds n) andnc 
			   rht (cds (Succ n))-lft (cds (Succ n))==(2#3)*(rht (cds n)-lft (cds n)) andnc 
			   lft (cds (Succ n))<rht (cds (Succ n))))")
(intro 0 (pt "[n](Rec nat=>rat yprod rat)n(cInit x b)([n](cStep ola))"))

;;we use InitReal StepReal to prove that the desired properties hold
(split)
(ng #t)
(use "InitEqD")
;;


(ind)
;;case Zero
(use "StepReal")
(use "OlaMRTotal")
(use "InitReal")
(use "Rx")
(use "Sx")
(use "bSup")
(use "InitReal")
(use "Rx")
(use "Sx")
(use "bSup")
(use "InitReal")
(use "Rx")
(use "Sx")
(use "bSup")
;;case Succ
(assume "n" "IH")
(use "StepReal")
(use "OlaMRTotal")
(use "IH")
(use "IH")
(use "IH")
(assume "exlseq")
;;existence of seqs done

(by-assume "exlseq" "cds" "seqprops")
(cut "all m(m=cRatLeAbsBound(rht(cInit x b)-lft(cInit x b)) -> 
		exl x(Real x andnc all y(Real y -> S^ y -> y<<=x) andi 
		all a,p(RealLt a x p -> exnc x0(S^ x0 andnc a<<=x0))))")
(assume "AllHyp")
(use "AllHyp" (pt "cRatLeAbsBound(rht(cInit x b)-lft(cInit x b))"))
(use "Truth")
(assume "m" "mDef")
(intro 0 (pt "RealConstr ([n](lft(cds n)))([p]2*(m+p))"))
(assert "Real(RealConstr([n]lft(cds n))([p]2*(m+p))) andnc 
	Real(RealConstr([n]rht(cds n))([p]2*(m+p))) andnc 
	RealConstr([n]lft(cds n))([p]2*(m+p))===RealConstr([n]rht(cds n))([p]2*(m+p))")
 (use "SeqProps")
 (assume "n")
 (msplit)
 (use "seqprops")
 (use "seqprops")
 (use "seqprops")
 (ng #t)
 (use "RatLeLtTrans" (pt "lft(cds (Succ n))"))
 (use "seqprops")
 (use "RatLtLeTrans" (pt "rht(cds (Succ n))"))
 (use "seqprops")
 (use "seqprops")
 (ng #t)
 (simp "seqprops")
 (ng #t)
 (simp "mDef")
 (use "RatLeTrans" (pt "abs(rht(cInit x b)-lft(cInit x b))"))
 (ng #t)
 (use "Truth")
 (use "RatLeAbsBoundExFree")
(assume "Realprops")
(split)
(use "Realprops")
(split)
;?_106:all y(Real y -> S y -> y<<=RealConstr([n]lft(cds n))([p]2*(m+p)))
(cases)
(assume "as" "M" "Ry" "Sy")
(simpreal (pf "RealConstr([n]lft(cds n))([q]2*(m+q))===RealConstr([n]rht(cds n))([q]2*(m+q))"))
(use "RealLeSeqLeReal")
(use "Realprops")
(use "Ry")
(assume "n")
(ng #t)
(use "RealLeTrans" (pt "RealConstr ([m]rht(cds (Succ n)))([p]Zero)"))
(use "seqprops")
(use "Ry")
(use "Sy")
(use "RatLeToRealLe")
(use "seqprops")
(use "Realprops")
(assume "c" "p" "a<x")
(assert "exnc y(Real y andnc S^ y andnc lft(cds(2*(PosS(PosS p)+m)))<<=y)")
 (simp (pf "PosS(PosS p)+m=Succ(Succ(p+m))"))
 (use "seqprops")
 (simp "PosSSucc")
 (simp "PosSSucc")
 (ng #t)
 (use "Truth")
(assume "exHyp")
(by-assume "exHyp" "y" "Hyp")
(intro 0 (pt "y"))
(split)
(use "Hyp")
(use "RealLeTrans" (pt "RealConstr([n]lft(cds(2*(m+(PosS(PosS p))))))([p]Zero)"))
(use "RealLeIntro")
(use "RealRat")
(use "RealRat")
(use "RealPosToNNeg" (pt "p"))
(realproof)
(ng)
(use "a<x")
(simp "NatPlusComm")
(use "Hyp")
;;(cdp)
;;ok
(save "LUB")

(define sproof (proof-to-soundness-proof))
(add-theorem "LUBSound" sproof)
;(define eterm (proof-to-extracted-term (theorem-name-to-proof "LUB")))
;(deanimate "RatLeAbsBound")
;(pp (rename-variables (nt eterm)))
;[a,x,ola]
; RealConstr
; ([n]
;   lft((Rec nat=>rat yprod rat)n(cInit x a)
;       ([n0]cStep([a0,a1][if (a0<a1) (ola a0 a1) False]))))
; ([p]
;   cRatLeAbsBound(rht(cInit x a)+ ~lft(cInit x a))+p+
;   cRatLeAbsBound(rht(cInit x a)+ ~lft(cInit x a))+
;   p)

;(pp "LUBSound")

;; -------------------------------------------------------------------------


;;Nils Köpp
;;LUB with Dependant Choice(DC)

(add-var-name "xx" (py "alpha"))
(add-var-name "xxs" (py "nat=>alpha"))
(add-pvar-name "SS" (make-arity (py "nat") (py "alpha")))
(add-pvar-name "RR" (make-arity (py "nat") (py "alpha") (py "alpha")))

(add-global-assumption "DC" "all xx0(SS^ Zero xx0 -> all n,xx(SS^ n xx -> exl xx1(SS^ (Succ n) xx1 andi RR^ n xx xx1)) -> exl xxs((xxs Zero) eqd xx0 andi all n (SS^ n (xxs n) andi RR^ n (xxs n) (xxs (Succ n)))))")

(set-goal "all b,x(Real x -> S^ x -> all y(Real y -> S^ y -> y<<=b) -> 
			all c,d(c<d -> all x(Real x -> S^ x -> x<<=d) oru 
				       exnc x(Real x andnc S^ x andnc c<<=x)) -> 
			exl x(Real x andi 
			      all y(Real y -> S^ y -> y<<=x) andi 
			      all a,p(RealLt a x p -> exnc x(S^ x andi a<<=x))))") 
(assume "b" "x" "Rx" "Sx" "bSup" "OLA")
(inst-with-to "Init" (pt "x") (pt "b") "Rx" "Sx" "bSup" "Inst")
(by-assume "Inst" "c" "cProp")
(by-assume "cProp" "d" "cdProp")
;;we assert the existence of the rational sequences
(assert "exl cds(
         cds Zero eqd (c pair d) andnc 
         all n(
          (lft(cds n)<rht(cds n) andnc 
           all x(Real x -> S^ x -> x<<=rht(cds n)) andnc 
           exnc x(Real x andnc S^ x andnc lft(cds n)<<=x)) andnc 
          lft(cds n)<=lft(cds(Succ n)) andnc 
          rht(cds(Succ n))<=rht(cds n) andnc 
          rht(cds(Succ n))-lft(cds(Succ n))==(2#3)*(rht(cds n)-lft(cds n)) andnc 
          lft(cds(Succ n))<rht(cds(Succ n))))")
(use-with "DC"
	  (py "rat yprod rat")
	  (make-cterm (pv "n") (pv "cd") (pf "lft cd<rht cd andnc all x(Real x -> S^ x -> x<<=rht cd) andnc exnc x(Real x andnc S^ x andnc lft cd<<=x)"))
	  (make-cterm (pv "n") (pv "cd") (pv "cd0") (pf "lft cd<=lft cd0 andnc rht cd0<=rht cd andnc rht cd0-lft cd0==(2#3)*(rht cd-lft cd) andnc lft cd0<rht cd0")) (pt "c pair d") "?" "?")
(ng #t)
(split)
(use "cdProp")
(use "cdProp")
(assume "n" "cd1" "Hyp")
(elim "Hyp")
(assume "c1<d1" "Conj")
(elim "Conj")
(assume "d1Bd" "c1NBd")
(inst-with-to "Step" "OLA" (pt "cd1") "c1<d1" "d1Bd" "c1NBd" "StepInst")
(by-assume "StepInst" "cd2" "cd2Prop")
(intro 0 (pt "cd2"))
(msplit)
(use "cd2Prop")
(use "cd2Prop")
(use "cd2Prop")
(use "cd2Prop")
(split)
(use "cd2Prop")
(split)
(use "cd2Prop")
(use "cd2Prop")
(assume "ExHypSeq")

(by-assume "ExHypSeq" "cds" "seqprops")
(cut "all m(m=cRatLeAbsBound(rht(c pair d)-lft(c pair d)) -> 
		exl x(Real x andnc all y(Real y -> S^ y -> y<<=x) andi 
		all a,p(RealLt a x p -> exnc x0(S^ x0 andnc a<<=x0))))")
(assume "AllHyp")
(use "AllHyp" (pt "cRatLeAbsBound(rht(c pair d)-lft(c pair d))"))
(use "Truth")
(assume "m" "mDef")
(intro 0 (pt "RealConstr ([n](lft(cds n)))([p]2*(m+p))"))
;?_79:Real(RealConstr([n]lft(cds n))([p]p+m)) andr 
;     all y(Real y -> S y -> y<<=RealConstr([n]lft(cds n))([p]p+m)) andr 
;     all a,p(
;      RealLt a(RealConstr([n]lft(cds n))([p0]p0+m))p -> 
;      exd x(S x andl a<<=x))
(assert "Real(RealConstr([n]lft(cds n))([p]2*(m+p))) andnc 
	Real(RealConstr([n]rht(cds n))([p]2*(m+p))) andnc 
	RealConstr([n]lft(cds n))([p]2*(m+p))===RealConstr([n]rht(cds n))([p]2*(m+p))")
 (use "SeqProps")
 (assume "n")
 (msplit)
 (use "seqprops")
 (use "seqprops")
 (use "seqprops")
 (ng #t)
 (use "RatLeLtTrans" (pt "lft(cds (Succ n))"))
 (use "seqprops")
 (use "RatLtLeTrans" (pt "rht(cds (Succ n))"))
 (use "seqprops")
 (use "seqprops")
 (ng #t)
 (simp "seqprops")
 (ng #t)
 (simp "mDef")
 (use "RatLeTrans" (pt "abs(rht((c pair d))-lft(c pair d))"))
 (ng #t)
 (use "Truth")
 (use "RatLeAbsBoundExFree")
(assume "Realprops")
(split)
(use "Realprops")
(split)
;?_106:all y(Real y -> S y -> y<<=RealConstr([n]lft(cds n))([p]2*(m+p)))
(cases)
(assume "as" "M" "Ry" "Sy")
(simpreal (pf "RealConstr([n]lft(cds n))([q]2*(m+q))===RealConstr([n]rht(cds n))([q]2*(m+q))"))
(use "RealLeSeqLeReal")
(use "Realprops")
(use "Ry")
(assume "n")
(ng #t)
(use "RealLeTrans" (pt "RealConstr ([m]rht(cds (Succ n)))([p]Zero)"))
(use "seqprops")
(use "Ry")
(use "Sy")
(use "RatLeToRealLe")
(use "seqprops")
(use "Realprops")
(assume "c0" "p" "a<x")
(assert "exnc y(Real y andnc S^ y andnc lft(cds(2*(PosS(PosS p)+m)))<<=y)")
 (simp (pf "PosS(PosS p)+m=Succ(Succ(p+m))"))
 (use "seqprops")
 (simp "PosSSucc")
 (simp "PosSSucc")
 (ng #t)
 (use "Truth")
(assume "exHyp")
(by-assume "exHyp" "y" "Hyp")
(intro 0 (pt "y"))
(split)
(use "Hyp")
(use "RealLeTrans" (pt "RealConstr([n]lft(cds(2*(m+(PosS(PosS p))))))([p]Zero)"))
(use "RealLeIntro")
(use "RealRat")
(use "RealRat")
(use "RealPosToNNeg" (pt "p"))
(realproof)
(ng)
(use "a<x")
(simp "NatPlusComm")
(use "Hyp")
(save "LUBDC")
;;(cdp)
;;ok

(define eterm (proof-to-extracted-term))
(pp (nt eterm))
