use "depDelphin.d"; (* ADVANCED SECTION OF DISSERTATION.. *) (* These next two relations allow us to state that terms/exps are equal (identical). *) sig exp -> type> ; sig term N -> type> ; (* It is useful to have an empty type to argue about something being impossible. *) sig ; (* Standard less-than relation (we will use it to talk about context extensions) *) sig nat -> type> lt M (s N)> ; (* * ********************************************* * ********************************************* * We now show that (equiv P E T) is deterministic. * Which allows us to conclude: * * PART A: toHOAS (toDebruijn E) = E * This is shown by proving * -> -> (as fun detA-closed) * * PART B: toDebruijn(toHOAS T) = T * This is shown by proving * -> -> (as fun detB-closed) * ********************************************** * ********************************************** *) (* * ********************************************* * (PART A) *********************************************** *) (* The scope of params applies to all fun declarations until * the next params. *) params = , , , ; fun equalApp : -> -> = fn => ; fun equalLam : <{x:exp} eqexp (E1 x) (E1' x)> -> = fn <[x] eqexpid> => ; fun lessProp2 : -> = fn => | => let val

= lessProp2 in end; fun lessProp1 : -> = fn => | => lessProp2 ; fun lessContra2 : -> -> = fn => lessContra2 (lessProp1 ); fun lessContra : -> = fn => lessContra2 <_> ; fun lessProp : -> -> = fn => @ (lessProp1 ); type detA-World = -> -> ; fun extend : ( -> -> -> <(equiv (s P') E (var' one))#> -> ) -> detA-World -> {}{} detA-World = fn C => fn W => fn {}{} ( => ) | {}{} ( => let val = C

<_> in {}{} (fn .) (* (fn .) is a total function of * type -> ... *) end \x \d) | {}{} ( => let val = C

<_> in {}{} (fn .) (* (fn .) is a total function of * type -> ... *) end \x \d) | {}{} ( => let val = W in {}{} end \x \d); fun detA-Var : detA-World -> -> -> = fn W => W | W => detA-Var W ; fun detA : ( -> -> -> <(equiv (s P') E (var' one))#> -> ) -> detA-World -> -> -> = fn C W => let val = detA C W val = detA C W in equalApp end | C W => let val Cnew : ( -> -> -> <(equiv (s P') E (var' one))#> -> ) = fn => C (lessProp ) in (case {}{} detA (Cnew with

=> lessContra ) ((extend C W) \x \d) of {}{} => equalLam <[x] EQ x>) end | C W => detA-Var W ; (* Putting it all together *) params = .; fun detA-closed : -> -> = fn => detA (fn .) (fn .) ; (* * ********************************************* * (PART B) *********************************************** *) params = , , , ; fun equalApp : -> -> = fn => ; fun equalLam : -> = fn => ; fun equalBvar : -> = fn => ; type detB-World = -> -> ; type detB-Contradiction = -> -> -> ; fun detB-Var : -> -> * * = fn => (<_>, , ) | => let val (, , ) = detB-Var in (, , ) end; fun contraApp : -> -> = fn => contraApp

; fun contraLam : -> -> = fn => contraLam

; fun detB : detB-Contradiction -> detB-World -> -> -> = fn C W => let val = detB C W val = detB C W in equalApp end | C W => (case {}{} detB (C with => lessContra ) (W with => ) of {}{} => equalLam ) | C W => W | C W => equalBvar (detB C W ) | C W => let val (, , ) = detB-Var val = C in (fn .) (* (fn .) is a total function of * type -> ... *) end | C W => let val (, , ) = detB-Var val = C in (fn .) (* (fn .) is a total function of * type -> ... *) end (* The next four cases handle impossible cases * We prove these cases are impossible by using contraApp and contraLam * which return an object of type empty, of which there are none. * * Given an E : , we can conclude anything, which * is why we just do: (fn .) E * The type of (fn .) will be -> T. *) | C W <_> => (fn .) (contraApp

) | C W <_> => (fn .) (contraApp

) | C W <_> => (fn .) (contraLam

) | C W <_> => (fn .) (contraLam

); (* Putting it all together *) params = .; fun detB-closed : -> -> = fn => detB (fn .) (fn .) ;