Module("strategy/general/rename",[Imports([Import("strategy/traversal/simple"),Import("collection/tuple/common"),ImportWildcard("collection/list"),Import("strategy/traversal/environment")]),Rules([RDef("RnVar",[VarDec("isvar",FunType([FunType([ConstType(SortVar("name"))],ConstType(SortVar("env"))),ConstType(SortVar("name"))],ConstType(SortVar("term"))))],RuleNoCond(NoAnnoList(Tuple([Var("t"),Var("env")])),App(Call(SVar("isvar"),[Seq(Call(SVar("split"),[Id,Build(Var("env"))]),CallNoArgs(SVar("lookup")))]),Var("t")))),RDef("RnBinding",[DefaultVarDec("bndvrs")],Rule(NoAnnoList(Tuple([Var("t"),Var("env1")])),NoAnnoList(Tuple([Var("t"),Var("env1"),Var("env2")])),Seq(AM(BA(CallNoArgs(SVar("bndvrs")),Var("t")),Var("xs")),Seq(AM(Call(SVar("map"),[CallNoArgs(SVar("new"))]),Var("ys")),AM(BA(CallNoArgs(SVar("conc")),NoAnnoList(Tuple([App(Call(SVar("zip"),[Id]),NoAnnoList(Tuple([Var("xs"),Var("ys")]))),Var("env1")]))),Var("env2")))))),RDef("DistBinding",[DefaultVarDec("s")],RuleNoCond(NoAnnoList(Tuple([Var("t"),Var("env1"),Var("env2")])),App(All(LRule(RuleNoCond(Var("x"),App(CallNoArgs(SVar("s")),NoAnnoList(Tuple([Var("x"),Var("env2")])))))),Var("t"))))]),Strategies([SDef("rename",[VarDec("isvar",FunType([FunType([ConstType(SortVar("name"))],ConstType(SortVar("env"))),ConstType(SortVar("name"))],ConstType(SortVar("term")))),DefaultVarDec("bndvars")],Seq(LRule(RuleNoCond(Var("t"),NoAnnoList(Tuple([Var("t"),NoAnnoList(List([]))])))),Rec("x",Call(SVar("env-alltd"),[LChoice(Call(SVar("RnVar"),[CallNoArgs(SVar("isvar"))]),Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars"))]),Call(SVar("DistBinding"),[CallNoArgs(SVar("x"))])))]))))]),Rules([RDef("DistBinding",[DefaultVarDec("s"),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"))))],RuleNoCond(NoAnnoList(Tuple([Var("t"),Var("env1"),Var("env2")])),App(Call(SVar("boundin"),[LRule(RuleNoCond(Var("x"),App(CallNoArgs(SVar("s")),NoAnnoList(Tuple([Var("x"),Var("env2")]))))),LRule(RuleNoCond(Var("x"),App(CallNoArgs(SVar("s")),NoAnnoList(Tuple([Var("x"),Var("env1")]))))),Id]),Var("t"))))]),Strategies([SDef("rename",[VarDec("isvar",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"))))],Seq(LRule(RuleNoCond(Var("t"),NoAnnoList(Tuple([Var("t"),NoAnnoList(List([]))])))),Rec("x",Call(SVar("env-alltd"),[LChoice(Call(SVar("RnVar"),[CallNoArgs(SVar("isvar"))]),Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars"))]),Call(SVar("DistBinding"),[CallNoArgs(SVar("x")),CallNoArgs(SVar("boundin"))])))]))))]),Rules([RDef("RnBinding",[DefaultVarDec("bndvrs"),VarDec("paste",FunType([FunType([ConstType(SortVar("term"))],ConstType(SortVar("vars"))),ConstType(SortVar("term"))],ConstType(SortVar("term"))))],Rule(NoAnnoList(Tuple([Var("t"),Var("env1")])),NoAnnoList(Tuple([App(Call(SVar("paste"),[Build(Var("ys"))]),Var("t")),Var("env1"),Var("env2")])),Seq(AM(BA(CallNoArgs(SVar("bndvrs")),Var("t")),Var("xs")),Seq(AM(Call(SVar("map"),[CallNoArgs(SVar("new"))]),Var("ys")),AM(BA(CallNoArgs(SVar("conc")),NoAnnoList(Tuple([App(Call(SVar("zip"),[Id]),NoAnnoList(Tuple([Var("xs"),Var("ys")]))),Var("env1")]))),Var("env2"))))))]),Strategies([SDef("rename",[VarDec("isvar",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"))))],Seq(LRule(RuleNoCond(Var("t"),NoAnnoList(Tuple([Var("t"),NoAnnoList(List([]))])))),Rec("x",Call(SVar("env-alltd"),[LChoice(Call(SVar("RnVar"),[CallNoArgs(SVar("isvar"))]),Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars")),CallNoArgs(SVar("paste"))]),Call(SVar("DistBinding"),[CallNoArgs(SVar("x")),CallNoArgs(SVar("boundin"))])))]))))])])
