
;(libload "minpr_gen.scm")
(libload "nat.scm")

(add-pvar-name "uQ" (make-arity (py "nat")))

(aga "unboundedQ" (pf "all n excl m. n < m ! uQ m"))
; Q is unbounded

(add-var-name "f" (py "nat=>nat"))

;(add-rewrite-rule (pt "n<Succ n") (pt "True"))
;(add-rewrite-rule (pt "Succ n<0") (pt "False"))

;(add-pvar-name "uQf" (make-arity (py "nat")))
;the set of left f-minima; a subset of Q

; Lemma 6.1.

(set-goal 
 (pf "all f, n excl m.
       n < m ! 
       uQ(m) ! 
       (all m1. uQ(m1) -> m < m1 -> f(m1) < f(m) -> bot)"))

(assume "f")
(assume "n")

(by-assume-minimal-wrt
 (pf "excl m. n < m ! uQ(m)") "n1" (pt "f") "minH1" "min_P1_1" "min_P1_2")
(use "unboundedQ")
(exc-intro (pt "n1"))
(use "min_P1_1")
(use "min_P1_2")
(strip)
(use "minH1" (pt "m1"))
(use 6)
(use "NatLtTrans" (pt "n1"))
(use "min_P1_1")
(use 5)
(use 4)
(save "Lemma1")

(set! UNFOLDING-FLAG #f)
(define lemma1
  (expand-theorems
       (theorem-name-to-proof "Lemma1")))
;(np lemma1)
;(dp lemma1)
(define reduced-lemma1 (reduce-efq-and-stab lemma1))
;(define ggn-reduced-lemma1 (proof-to-goedel-gentzen-translation reduced-lemma1))

(mload "../modules/atr.scm")

;ToDo

 (define term
   (atr-min-excl-proof-to-structured-extracted-term reduced-lemma1))

; Error:

; min-excl-proof?
; goal formulas expected
; n<m
; uQ m
; all m1.uQ m1 -> m<m1 -> f m1<f m -> bot
; ABORT: Minlog "sorry"

; explanation: the formula to be proven seems 
; not to be a "goal" formula 
; (as in the formulation from "a-tr")


; (define nterm (nt term))
; (pp nterm)



