612 | term_of_dB' _ _ = error "term_of_dB: term not in normal form"; |
612 | term_of_dB' _ _ = error "term_of_dB: term not in normal form"; |
613 |
613 |
614 fun typing_of_term Ts e (Bound i) = |
614 fun typing_of_term Ts e (Bound i) = |
615 Norm.Vara (e, nat_of_int i, dBtype_of_typ (nth Ts i)) |
615 Norm.Vara (e, nat_of_int i, dBtype_of_typ (nth Ts i)) |
616 | typing_of_term Ts e (t $ u) = (case fastype_of1 (Ts, t) of |
616 | typing_of_term Ts e (t $ u) = (case fastype_of1 (Ts, t) of |
617 Type ("fun", [T, U]) => Norm.Appaa (e, dB_of_term t, |
617 Type ("fun", [T, U]) => Norm.Appb (e, dB_of_term t, |
618 dBtype_of_typ T, dBtype_of_typ U, dB_of_term u, |
618 dBtype_of_typ T, dBtype_of_typ U, dB_of_term u, |
619 typing_of_term Ts e t, typing_of_term Ts e u) |
619 typing_of_term Ts e t, typing_of_term Ts e u) |
620 | _ => error "typing_of_term: function type expected") |
620 | _ => error "typing_of_term: function type expected") |
621 | typing_of_term Ts e (Abs (s, T, t)) = |
621 | typing_of_term Ts e (Abs (s, T, t)) = |
622 let val dBT = dBtype_of_typ T |
622 let val dBT = dBtype_of_typ T |
623 in Norm.Absaa (e, dBT, dB_of_term t, |
623 in Norm.Absb (e, dBT, dB_of_term t, |
624 dBtype_of_typ (fastype_of1 (T :: Ts, t)), |
624 dBtype_of_typ (fastype_of1 (T :: Ts, t)), |
625 typing_of_term (T :: Ts) (Norm.shift e Norm.Zero_nat dBT) t) |
625 typing_of_term (T :: Ts) (Norm.shift e Norm.Zero_nat dBT) t) |
626 end |
626 end |
627 | typing_of_term _ _ _ = error "typing_of_term: bad term"; |
627 | typing_of_term _ _ _ = error "typing_of_term: bad term"; |
628 |
628 |