Module("rename-dyn",[Imports([Import("simple-traversal"),Import("tuple"),Import("list"),Import("dynamic-rules")]),Rules([SDef("RnBinding",[DefaultVarDec("bndvrs")],Where(Seq(CallNoArgs(SVar("bndvrs")),Call(SVar("map"),[ScopeDefault(Seq(Match(Var("x")),Seq(AM(CallNoArgs(SVar("new")),Var("y")),GenDynRules([SetDynRule(DynRuleId(RDecNoArgs("RenameVar")),RuleNoCond(Var("x"),Var("y")))]))))]))))]),Strategies([SDef("rename",[VarDec("isvar",FunType([ConstType(SortVar("name")),FunType([ConstType(SortVar("name"))],ConstType(SortVar("env")))],ConstType(SortVar("term")))),DefaultVarDec("bndvars")],Rec("x",Call(SVar("alltd"),[LChoice(Call(SVar("isvar"),[CallNoArgs(SVar("RenameVar"))]),DynRuleScope([DynRuleScopeId("RenameVar")],Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars"))]),All(CallNoArgs(SVar("x"))))))])))]),Strategies([SDef("rename",[VarDec("isvar",FunType([ConstType(SortVar("name")),FunType([ConstType(SortVar("name"))],ConstType(SortVar("env")))],ConstType(SortVar("term")))),DefaultVarDec("bndvars"),VarDec("boundin",FunType([ConstType(SortVar("term")),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term")))],ConstType(SortVar("term"))))],Rec("x",Call(SVar("alltd"),[LChoice(Call(SVar("isvar"),[CallNoArgs(SVar("RenameVar"))]),Seq(DynRuleScope([DynRuleScopeId("RenameVar")],Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars"))]),Call(SVar("boundin"),[CallNoArgs(SVar("x")),Id,Id]))),Call(SVar("boundin"),[Id,CallNoArgs(SVar("x")),Id])))])))]),Rules([SDef("RnBinding",[DefaultVarDec("bndvrs"),VarDec("paste",FunType([ConstType(SortVar("term")),FunType([ConstType(SortVar("term"))],ConstType(SortVar("vars")))],ConstType(SortVar("term"))))],Seq(Where(Seq(CallNoArgs(SVar("bndvrs")),AM(Call(SVar("map"),[ScopeDefault(Seq(Match(Var("x")),Seq(AM(CallNoArgs(SVar("new")),Var("y")),GenDynRules([SetDynRule(DynRuleId(RDecNoArgs("RenameVar")),RuleNoCond(Var("x"),Var("y")))]))))]),Var("ys")))),Call(SVar("paste"),[Build(Var("ys"))])))]),Strategies([SDef("rename",[VarDec("isvar",FunType([ConstType(SortVar("name")),FunType([ConstType(SortVar("name"))],ConstType(SortVar("env")))],ConstType(SortVar("term")))),DefaultVarDec("bndvars"),VarDec("boundin",FunType([ConstType(SortVar("term")),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term"))),FunType([ConstType(SortVar("term"))],ConstType(SortVar("term")))],ConstType(SortVar("term")))),VarDec("paste",FunType([ConstType(SortVar("term")),FunType([ConstType(SortVar("term"))],ConstType(SortVar("vars")))],ConstType(SortVar("term"))))],Rec("x",Call(SVar("alltd"),[LChoice(Call(SVar("isvar"),[CallNoArgs(SVar("RenameVar"))]),Seq(DynRuleScope([DynRuleScopeId("RenameVar")],Seq(Call(SVar("RnBinding"),[CallNoArgs(SVar("bndvars")),CallNoArgs(SVar("paste"))]),Call(SVar("boundin"),[CallNoArgs(SVar("x")),Id,Id]))),Call(SVar("boundin"),[Id,CallNoArgs(SVar("x")),Id])))])))])])
