#test success % this uses subtyping in multiple places type std = $std. ('e : 1) + ('b0 : $pos. ('b0 : pos) + ('b1 : std)) + ('b1 : std) % either of the next two lines will work % type pos = $pos. ('b0 : pos) + ('b1 : std) type pos = $pos. ('b0 : pos) + ('b1 : $std. ('e : 1) + ('b0 : pos) + ('b1 : std)) decl b0 : pos -> pos (* and pos -> std since pos <: std *) decl b1 : std -> pos (* and pos -> pos since pos <: std *) (* and std -> std since pos <: std *) decl e : 1 -> std defn b0 = \x. fold ('b0 x) defn b1 = \x. fold ('b1 x) defn e = \u. fold ('e u) decl inc : std -> pos defn inc = $inc. \x. case x of ( fold 'b0 y => b1 y | fold 'b1 y => b0 (inc y) | fold 'e u => b1 (e u) ) decl pred : pos -> std fail defn pred = $pred. \x. case x of ( fold 'b0 y => b1 (pred y) | fold 'b1 y => b0 y | fold 'e u => e u ) defn pred = $pred. \x. case x of ( fold 'b0 y => b1 (pred y) | fold 'b1 y => case y of ( fold 'e u => e u | fold 'b0 z => b0 (b0 z) | fold 'b1 z => b0 (b1 z) ) )