Module("strategy/general/substitution",[Imports([Import("strategy/traversal/simple"),Import("collection/tuple/common"),ImportWildcard("collection/list"),Import("strategy/general/rename")]),Strategies([SDefNoArgs("subs-args",LChoice(Match(NoAnnoList(Tuple([Var("sbs"),Var("t")]))),LRule(RuleNoCond(NoAnnoList(Tuple([Var("xs"),Var("ys"),Var("t")])),NoAnnoList(Tuple([App(Call(SVar("zip"),[Id]),NoAnnoList(Tuple([Var("xs"),Var("ys")]))),Var("t")]))))))]),Rules([RDef("SubsVar",[DefaultVarDec("isvar"),DefaultVarDec("mksbs")],Rule(Var("t"),App(CallNoArgs(SVar("lookup")),NoAnnoList(Tuple([Var("x"),Var("sbs")]))),Seq(AM(BA(CallNoArgs(SVar("isvar")),Var("t")),Var("x")),AM(CallNoArgs(SVar("mksbs")),Var("sbs")))))]),Strategies([SDef("substitute",[DefaultVarDec("isvar"),DefaultVarDec("ren")],Seq(AM(CallNoArgs(SVar("subs-args")),NoAnnoList(Tuple([Var("sbs"),Var("t")]))),Seq(Build(Var("t")),Call(SVar("alltd"),[Seq(Call(SVar("SubsVar"),[CallNoArgs(SVar("isvar")),Build(Var("sbs"))]),CallNoArgs(SVar("ren")))])))),SDef("substitute",[DefaultVarDec("isvar")],Call(SVar("substitute"),[CallNoArgs(SVar("isvar")),Id])),SDef("substitute",[DefaultVarDec("isvar"),VarDec("varshape",FunType([FunType([ConstType(SortVar("name"))],ConstType(SortVar("env"))),ConstType(SortVar("name"))],ConstType(SortVar("term")))),DefaultVarDec("bndvars"),VarDec("boundin",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),ConstType(SortVar("term"))],ConstType(SortVar("term")))),VarDec("paste",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("vars"))),ConstType(SortVar("term"))],ConstType(SortVar("term")))),DefaultVarDec("ren")],Seq(AM(CallNoArgs(SVar("subs-args")),NoAnnoList(Tuple([Var("sbs"),Var("t")]))),Seq(Build(NoAnnoList(Tuple([Var("t"),NoAnnoList(List([]))]))),Rec("x",Call(SVar("env-alltd"),[LChoice(Call(SVar("RnVar"),[CallNoArgs(SVar("varshape"))]),LChoice(Seq(CallNoArgs(SVar("Fst")),Seq(Call(SVar("SubsVar"),[CallNoArgs(SVar("isvar")),Build(Var("sbs"))]),CallNoArgs(SVar("ren")))),Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars")),CallNoArgs(SVar("paste"))]),Call(SVar("DistBinding"),[CallNoArgs(SVar("x")),CallNoArgs(SVar("boundin"))]))))]))))),SDef("substitute",[DefaultVarDec("isvar"),VarDec("varshape",FunType([FunType([ConstType(SortVar("name"))],ConstType(SortVar("env"))),ConstType(SortVar("name"))],ConstType(SortVar("term")))),DefaultVarDec("bndvars"),VarDec("boundin",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),ConstType(SortVar("term"))],ConstType(SortVar("term")))),VarDec("paste",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("vars"))),ConstType(SortVar("term"))],ConstType(SortVar("term"))))],Call(SVar("substitute"),[CallNoArgs(SVar("isvar")),CallNoArgs(SVar("varshape")),CallNoArgs(SVar("bndvars")),CallNoArgs(SVar("boundin")),CallNoArgs(SVar("paste")),Id]))])])
