<commit_before># Note this is valid only because this file is technically a top-level file,
# i.e. it isn't included anywhere with `$include'
with(Domain_Type):

local Simplify_DConstrain := (can_simp, do_simp) -> module()
    uses Domain;

    export ModuleApply := proc(vs0 :: DomBound, sh :: DomShape, $)
        local vs := vs0, ctx;
        if _Env_HakaruSolve=false then
           return sh end if;
        vs  := Domain:-Bound:-varsOf(vs,"set");
        ctx := Domain:-Bound:-toConstraints(vs0, 'bound_types');
        subsindets(sh, DomConstrain
                  ,x->do_simpl_constraints(vs0, vs, ctx, x));
    end proc;

    local do_simpl_constraints := proc(vs0, vars, ctx_vs, x, $)
        local ctx1, ctx, ss, td, rest, d, in_vs;
        ss, ctx := selectremove(q->depends(q,indets(vars,Name)), x);
        td, rest := selectremove(can_simp(vs0), ss);
        ctx1 := { op(ctx), op(ctx_vs), op(rest) };
        d := map(x->do_simp(vs0,ctx1,x), td);
        DConstrain(op(d), op(ctx), op(rest));
    end proc;
end module;

try_improve_exp := module()
  export SimplName  := "Try improve exp";
  export SimplOrder := 6 - 2/10;
  export ModuleApply := Simplify_DConstrain(can, `try`);

  local can := proc(vs)
    c -> c::relation and (not(lhs(c) :: Name) and not(rhs(c) :: Name) and has(c,{ln,exp}));
  end proc;

  local `try` := proc(dbnd, ctx1, q0, $)
    local vars, vars_q, q := q0;
    vars := Domain:-Bound:-varsOf(dbnd,"set");
    vars_q := indets(q, name) intersect vars;
    if nops(vars_q)=0 then return q end if;

    vars_q := op(1,vars_q);
    KB:-try_improve_exp(q, vars_q, ctx1);
  end proc;<commit_msg>Name overlaps with the export in KB<commit_after># Note this is valid only because this file is technically a top-level file,
# i.e. it isn't included anywhere with `$include'
with(Domain_Type):

local Simplify_DConstrain := (can_simp, do_simp) -> module()
    uses Domain;

    export ModuleApply := proc(vs0 :: DomBound, sh :: DomShape, $)
        local vs := vs0, ctx;
        if _Env_HakaruSolve=false then
           return sh end if;
        vs  := Domain:-Bound:-varsOf(vs,"set");
        ctx := Domain:-Bound:-toConstraints(vs0, 'bound_types');
        subsindets(sh, DomConstrain
                  ,x->do_simpl_constraints(vs0, vs, ctx, x));
    end proc;

    local do_simpl_constraints := proc(vs0, vars, ctx_vs, x, $)
        local ctx1, ctx, ss, td, rest, d, in_vs;
        ss, ctx := selectremove(q->depends(q,indets(vars,Name)), x);
        td, rest := selectremove(can_simp(vs0), ss);
        ctx1 := { op(ctx), op(ctx_vs), op(rest) };
        d := map(x->do_simp(vs0,ctx1,x), td);
        DConstrain(op(d), op(ctx), op(rest));
    end proc;
end module;

Domain_try_improve_exp := module()
  export SimplName  := "Try improve exp";
  export SimplOrder := 6 - 2/10;
  export ModuleApply := Simplify_DConstrain(can, `try`);

  local can := proc(vs)
    c -> c::relation and (not(lhs(c) :: Name) and not(rhs(c) :: Name) and has(c,{ln,exp}));
  end proc;

  local `try` := proc(dbnd, ctx1, q0, $)
    local vars, vars_q, q := q0;
    vars := Domain:-Bound:-varsOf(dbnd,"set");
    vars_q := indets(q, name) intersect vars;
    if nops(vars_q)=0 then return q end if;

    vars_q := op(1,vars_q);
    KB:-try_improve_exp(q, vars_q, ctx1);
  end proc;
{'fraction_non_alphanumeric': 0.1585180686304282, 'fraction_numerical': 0.012146978439113271, 'mean_word_length': 3.1538461538461537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2539374', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1189, 'n_words': 317}