Confused about an intermediate type in Idris -
i'm trying implement toy regular type system ensures few formediness side constraints , allows unfolding mu bindings in it. data type representing these types contains constructors fixed point (mu), replacement nearest enclosing mu-bound term (var), , 0 , 1 argument type operators (nullary , unary, respectively).
to ensure these types well-formed track, 3 bool parameters, whether have mu head constructor, var head constructor, or var anywhere within them.
data : bool -- mu headed? -> bool -- var headed? -> bool -- contains var's? -> type mu : false false _ -> true false false var : false true true nullary : false false false unary : _ _ m -> false false m to implement unfolding mu-headed types need perform substitutions, need implement "mu x. f ====> f[(mu x. f)/x]".
other needing generate proof third type parameter works out, function subst seems straightforward:
total subst : m1 v1 c1 -> m2 v2 c2 -> (c3 ** ((a (m2 || (v2 && m1)) (v2 && v1) c3) ,(c3 = (c2 && c1)))) subst _ nullary = (_ ** (nullary,refl)) subst w (unary a) (subst w a) | (c3** (a',aeq)) = (c3 ** (unary a',aeq)) subst w var = (_ ** (w,refl)) subst w (mu a) = (_ ** (mu a,refl)) i tried , failed write wrapper cleans return type bit.
total subst' : m1 v1 c1 -> m2 v2 c2 -> (m2 || (v2 && m1)) (v2 && v1) (c2 && c1) subst' a1 a2 (subst a2 a2) | (_**(a',aeq)) ?= a' when try solve metavariable, find aeq : x = c2 && delay c2 not aeq : x = c2 && delay c1 expected (recall (&&) lazy in second argument).
am doing wrong? expected behaviour? fwiw, wrote similar wrapper unfold (not shown).
i imagine problem line
subst' a1 a2 (subst a2 a2) don't mean call subst on a1 , a2, or other way around?
Comments
Post a Comment