use super::*;
pub fn std() -> Vec<Knowledge> {
vec![
Def(False1, Ret(Bool(false))),
Def(Not, _if(false, true)),
Def(Idb, _if(true, false)),
Def(True1, Ret(Bool(true))),
Def(And, _if(_if(true, false), false)),
Def(Or, _if(true, _if(true, false))),
Def(Eqb, _if(_if(true, false), _if(false, true))),
Def(Xor, _if(_if(false, true), _if(true, false))),
Def(Nand, _if(_if(false, true), true)),
Def(Nor, _if(false, _if(false, true))),
Def(Exc, _if(_if(false, true), false)),
Def(Imply, _if(_if(true, false), true)),
Def(Fstb, _if(true, false)),
Def(Sndb, _if(_if(true, false), _if(true, false))),
Red(app("x", head_tail_tup("y", "z")), app2("x", "y", "z")),
Red(constr("x", head_tail_tup("y", "z")), constr(constr("x", "y"), "z")),
Red(app2(constr(constr("x", "y"), "z"), "a", "b"),
app(constr(app(constr("x", "y"), "a"), "z"), "b")),
Red(app(("g", "f"), head_tail_tup("y", "z")),
(app2("g", "y", "z"), app2("f", "y", "z")).into()),
Red(app(_if("x", Any), true), "x".into()),
Red(app(_if(Any, "x"), false), "x".into()),
Red(constr(app(_if("x", Any), Any), true), "x".into()),
Red(constr(app(_if(Any, "x"), Any), false), "x".into()),
Red(Tup(vec!["x".into()]), "x".into()),
Red(app(ret_var("x"), Any), "x".into()),
Red(app(Ex, ret_var("x")), app(Eq, "x")),
Red(app(Ex, constr("f", "f")), Idb.into()),
Red(app("x", Tup(vec![])), "x".into()),
Red(path("f", ("g", "g")), path("f", "g")),
Red(path("f", ("g", "g", "g")), path("f", "g")),
Red(app(Triv, constr2(arity_var("f", 2), "g0", "g1")), ("g0", "g1").into()),
Red(app(Triv, constr(arity_var("f", 1), "g")), "g".into()),
Red(app(Triv, no_constr("f")), true.into()),
Red(Imag2.into(), quat(0.0, 0.0, 1.0, 0.0)),
Red(Imag3.into(), quat(0.0, 0.0, 0.0, 1.0)),
Red(app2(Mul, Imag, typ("x", QuatType)),
typ(app2(Mul, vec4(0.0, 1.0, 0.0, 0.0), "x"), QuatType)),
Red(app2(Mul, typ("x", QuatType), Imag),
typ(app2(Mul, "x", vec4(0.0, 1.0, 0.0, 0.0)), QuatType)),
Red(app2(Mul, app2(Mul, "x", Imag), typ("y", QuatType)),
app2(Mul, "x", app2(Mul, Imag, typ("y", QuatType)))),
Red(app(Neg, quat("x", "y", "z", "w")),
quat(app(Neg, "x"), app(Neg, "y"), app(Neg, "z"), app(Neg, "w"))),
Red(app2(Mul, typ("x", QuatType), Imag), app2(Mul, typ("x", QuatType), typ(Imag, QuatType))),
Red(app2(Add, Imag, typ("x", QuatType)),
typ(app2(Add, vec4(0.0, 1.0, 0.0, 0.0), "x"), QuatType)),
Red(app2(Add, typ("x", QuatType), Imag),
typ(app2(Add, "x", vec4(0.0, 1.0, 0.0, 0.0)), QuatType)),
Red(app2(Add, "s", quat("x", "y", "z", "w")),
quat(app2(Add, "s", "x"), app2(Add, "s", "y"),
app2(Add, "s", "z"), app2(Add, "s", "w"))),
Red(app2(Mul, "s", quat("x", "y", "z", "w")),
quat(app2(Mul, "s", "x"), app2(Mul, "s", "y"),
app2(Mul, "s", "z"), app2(Mul, "s", "w"))),
Red(app2(Mul, quat("x", "y", "z", "w"), "s"),
quat(app2(Mul, "x", "s"), app2(Mul, "y", "s"),
app2(Mul, "z", "s"), app2(Mul, "w", "s"))),
Red(app2(Add, typ("x", QuatType), app2(Mul, "y", Imag)),
typ(app2(Add, "x", vec4(0.0, "y", 0.0, 0.0)), QuatType)),
Red(app2(Add, app2(Mul, "x", Imag), typ("y", QuatType)),
typ(app2(Add, quat(0.0, "x", 0.0, 0.0), "y"), QuatType)),
Red(app2(Mul, typ("x", QuatType), typ("y", QuatType)), typ(app2(Mul, "x", "y"), QuatType)),
Red(typ(app2(Mul, vec4("x0", "y0", "z0", "w0"), vec4("x1", "y1", "z1", "w1")), QuatType),
{
let x0: Expr = "x0".into();
let y0: Expr = "y0".into();
let z0: Expr = "z0".into();
let w0: Expr = "w0".into();
let x1: Expr = "x1".into();
let y1: Expr = "y1".into();
let z1: Expr = "z1".into();
let w1: Expr = "w1".into();
quat(
x0.clone() * x1.clone() -
y0.clone() * y1.clone() -
z0.clone() * z1.clone() -
w0.clone() * w1.clone(),
x0.clone() * y1.clone() +
y0.clone() * x1.clone() +
z0.clone() * w1.clone() -
w0.clone() * z1.clone(),
x0.clone() * z1.clone() +
z0.clone() * x1.clone() -
y0.clone() * w1.clone() +
w0.clone() * y1.clone(),
x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1,
)
}),
Red(app2(Add, typ("x", QuatType), typ("y", QuatType)), typ(app2(Add, "x", "y"), QuatType)),
Red(typ(app2(Add, vec4("x0", "y0", "z0", "w0"), vec4("x1", "y1", "z1", "w1")), QuatType),
quat(app2(Add, "x0", "x1"), app2(Add, "y0", "y1"),
app2(Add, "z0", "z1"), app2(Add, "w0", "w1"))),
Red(app2(Add, "x", typ("y", QuatType)), typ(app2(Add, "x", "y"), QuatType)),
Red(quat("x", "y", Imag, "z"), app2(Add, app2(Mul, Imag, Imag2), quat("x", "y", 0.0, "z"))),
Red(quat("x", "y", "z", Imag), app2(Add, app2(Mul, Imag, Imag3), quat("x", "y", "z", 0.0))),
Red(app(TypeOf, true), BoolType.into()),
Red(app(TypeOf, false), BoolType.into()),
Red(app(TypeOf, ret_var("x")), unop_ret_var("x", TypeOf)),
Red(app(TypeOf, list_var("x")), VecType.into()),
Red(app(path(False1, TypeOf), BoolType), BoolType.into()),
Red(app(path(Not, TypeOf), BoolType), BoolType.into()),
Red(app(path(Idb, TypeOf), BoolType), BoolType.into()),
Red(app(path(True1, TypeOf), BoolType), BoolType.into()),
Red(app2(path(False2, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(True2, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(And, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Or, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Eqb, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Xor, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Nand, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Nor, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Exc, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Imply, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Fstb, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Sndb, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app(path(Sqrt, TypeOf), F64Type), F64Type.into()),
Red(app(path(Ln, TypeOf), F64Type), F64Type.into()),
Red(app(path(Log2, TypeOf), F64Type), F64Type.into()),
Red(app(path(Log10, TypeOf), F64Type), F64Type.into()),
Red(app(path(Exp, TypeOf), F64Type), F64Type.into()),
Red(app2(path(Eq, TypeOf), BoolType, BoolType), BoolType.into()),
Red(app2(path(Add, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app2(path(Sub, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app2(path(Mul, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app2(path(Div, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app2(path(Rem, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app2(path(Pow, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app2(path(Rpow, TypeOf), F64Type, F64Type), F64Type.into()),
Red(app(path(Len, TypeOf), VecType), F64Type.into()),
Red(app2(path(Concat, TypeOf), VecType, VecType), VecType.into()),
Red(comp(Not, Not), Idb.into()),
Red(path(Not, Not), Not.into()),
Red(comp("x", Id), "x".into()),
Red(comp(Id, "x"), "x".into()),
Red(path("x", Id), "x".into()),
Red(path(Id, "x"), Id.into()),
Red((Fst, Snd).into(), Id.into()),
Red(path(And, Not), Or.into()),
Red(path(Or, Not), And.into()),
Red(path(Xor, Not), Eqb.into()),
Red(path(Eqb, Not), Xor.into()),
Red(path(Nand, Not), Nor.into()),
Red(path(Nor, Not), Nand.into()),
Red(path(Nand, (Not, Not, Id)), path(And, Not)),
Red(comp(Not, app(Rge, "x")), app(Rlt, "x")),
Red(comp(Not, app(Rgt, "x")), app(Rle, "x")),
Red(comp(Not, app(Rle, "x")), app(Rgt, "x")),
Red(comp(Not, app(Rlt, "x")), app(Rge, "x")),
Red(path(Add, Even), Eqb.into()),
Red(path(Add, Odd), Xor.into()),
Red(path(Add, Sqrt),
comp(Sqrt, comp(Add, (comp(app(Rpow, 2.0), Fst), comp(app(Rpow, 2.0), Snd))))),
Red(path(Mul, Even), Or.into()),
Red(path(Mul, Odd), And.into()),
Red(comp(Not, Even), Odd.into()),
Red(comp(Not, Odd), Even.into()),
Red(path(constr(constr(Mul, app(Rge, 0.0)), app(Rge, 0.0)),
app(constr(Rpow, app(Rge, 0.0)), Any)), Mul.into()),
Red(path(Add, Exp), Mul.into()),
Red(path(Mul, Ln), Add.into()),
Red(comp(Exp, Ln), Id.into()),
Red(comp(Ln, Exp), Id.into()),
Red(comp(Neg, Neg), Id.into()),
Red(comp(Conj, Conj), Id.into()),
Red(comp(Sqrt, Sqnorm), Norm.into()),
Red(comp(app(Rpow, 2.0), Norm), Sqnorm.into()),
Red(comp(Sqrt, app(Rpow, 2.0)), Abs.into()),
Red(app(False1, Any), false.into()),
Red(app(True1, Any), true.into()),
Red(app(Not, false), true.into()),
Red(app(Not, true), false.into()),
Red(app(Id, "x"), "x".into()),
Red(app(And, true), Idb.into()),
Red(app(And, false), False1.into()),
Red(app(Or, true), True1.into()),
Red(app(Or, false), Idb.into()),
Red(app2(Fstb, "x", "y"), "x".into()),
Red(app2(Fst, "x", "y"), "x".into()),
Red(app2(Sndb, "x", "y"), "y".into()),
Red(app2(Snd, "x", "y"), "y".into()),
Red(app(Eqb, false), Not.into()),
Red(app(Eqb, true), Idb.into()),
Red(app(Sin, app2(Mul, ret_int_var("x"), Tau)), app(Sin, Tau)),
Red(app(Cos, app2(Mul, ret_int_var("x"), Tau)), app(Cos, Tau)),
Red(app(Tan, app2(Mul, ret_int_var("x"), Tau)), app(Tan, Tau)),
Red(app2(Pow, Eps, 2.0), 0.0.into()),
Red(app2(Add, Imag, Imag), app2(Mul, 2.0, Imag)),
Red(app2(Add, app2(Mul, "x", Imag), Imag), app2(Mul, app2(Add, "x", 1.0), Imag)),
Red(app2(Add, Imag, app2(Mul, "x", Imag)), app2(Mul, app2(Add, 1.0, "x"), Imag)),
Red(app2(Mul, Imag, Imag), app2(Pow, Imag, 2.0)),
Red(app2(Mul, Eps, Eps), app2(Pow, Eps, 2.0)),
Red(app2(Pow, Imag, 2.0), (-1.0).into()),
Red(app2(Lt, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Lt)),
Red(app2(Le, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Le)),
Red(app2(Gt, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Gt)),
Red(app2(Ge, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Ge)),
Red(app(Neg, ret_var("x")), unop_ret_var("x", Neg)),
Red(app(Neg, app2(Add, ret_var("a"), app2(Mul, ret_var("b"), "x"))),
app2(Add, app(Neg, "a"), app2(Mul, app(Neg, "b"), "x"))),
Red(app(Reci, ret_var("x")), unop_ret_var("x", Reci)),
Red(app(Reci, app2(Add, ret_var("x"), app2(Mul, ret_var("y"), Imag))),
app2(Add, app2(Div, "x", app2(Add, app2(Pow, "x", 2.0), app2(Pow, "y", 2.0))),
app2(Mul, app2(Div, app(Neg, "y"), app2(Add, app2(Pow, "x", 2.0),
app2(Pow, "y", 2.0))), Imag))),
Red(app(Abs, ret_var("x")), unop_ret_var("x", Abs)),
Red(app2(Add, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Add)),
Red(app2(Add, ret_var("x"), app2(Add, ret_var("y"), "z")),
app2(Add, binop_ret_var("x", "y", Add), "z")),
Red(app2(Sub, ret_var("a"), app2(Mul, ret_var("b"), "x")),
app2(Add, "a", app2(Mul, app(Neg, "b"), "x"))),
Red(app2(Sub, app2(Add, ret_var("a"), app2(Mul, ret_var("b"), "x")),
app2(Add, ret_var("c"), app2(Mul, ret_var("d"), "x"))),
app2(Add, app2(Sub, "a", "c"), app2(Mul, app2(Sub, "b", "d"), "x"))),
Red(app2(Add, app2(Add, ret_var("a"), app2(Mul, ret_var("b"), "x")),
app2(Mul, ret_var("c"), "x")),
app2(Add, "a", app2(Mul, app2(Add, "b", "c"), "x"))),
Red(app2(Add, app2(Mul, ret_var("a"), "x"), app2(Mul, ret_var("b"), "x")),
app2(Mul, app2(Add, "a", "b"), "x")),
Red(app2(Sub, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Sub)),
Red(app2(Mul, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Mul)),
Red(app2(Mul, ret_var("x"), app2(Mul, ret_var("y"), "z")),
app2(Mul, binop_ret_var("x", "y", Mul), "z")),
Red(app2(Mul, ret_var("a"), app2(Add, ret_var("b"), app2(Mul, ret_var("c"), "x"))),
app2(Add, app2(Mul, "a", "b"), app2(Mul, app2(Mul, "a", "c"), "x"))),
Red(app2(Mul, app2(Add, ret_var("a"), app2(Mul, ret_var("b"), "x")),
app2(Mul, ret_var("c"), "x")),
app2(Mul, app2(Mul, "c", "x"), app2(Add, "a", app2(Mul, "b", "x")))),
Red(app2(Mul, app2(Mul, ret_var("a"), "x"), app2(Add, ret_var("b"),
app2(Mul, ret_var("c"), "x"))),
app2(Add, app2(Mul, app2(Mul, "a", "c"), app2(Pow, "x", 2.0)),
app2(Mul, app2(Mul, "a", "b"), "x"))),
Red(app2(Mul, app2(Add, ret_var("a"), app2(Mul, ret_var("b"), "x")),
app2(Add, ret_var("c"), app2(Mul, ret_var("d"), "x"))),
app2(Add, app2(Add, app2(Mul, "a", "c"), app2(Mul, app2(Mul, "b", "d"),
app2(Pow, "x", 2.0))),
app2(Mul, app2(Add, app2(Mul, "a", "d"), app2(Mul, "b", "c")), "x"))),
Red(app2(Mul, app2(Mul, ret_var("a"), "x"), app2(Mul, ret_var("b"), "x")),
app2(Mul, app2(Mul, "a", "b"), app2(Pow, "x", 2.0))),
Red(app2(Div, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Div)),
Red(app2(Div, app2(Add, ret_var("a"), app2(Mul, ret_var("b"), Eps)),
app2(Add, ret_var("c"), app2(Mul, ret_var("d"), Eps))),
app2(Add, app2(Div, "a", "c"), app2(Mul, app2(Div, app2(Sub, app2(Mul, "b", "c"),
app2(Mul, "a", "d")), app2(Pow, "c", 2.0)), Eps))),
Red(app2(Div, "x", app2(Add, ret_var("a"), app2(Mul, ret_var("b"), Imag))),
app2(Mul, "x", app(Reci, app2(Add, "a", app2(Mul, "b", Imag))))),
Red(app2(Rem, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Rem)),
Red(app2(Pow, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Pow)),
Red(app2(Rpow, ret_var("x"), ret_var("y")), binop_ret_var("y", "x", Pow)),
Red(app2(Eq, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Eq)),
Red(app2(Push, list_var("x"), "y"), binop_ret_var("x", "y", Push)),
Red(app2(PushFront, list_var("x"), "y"), binop_ret_var("x", "y", PushFront)),
Red(app(constr(app(constr(Concat, app(Rty, VecType)), "x"), app(Rty, VecType)),
"y"), binop_ret_var("x", "y", Concat)),
Red(app(Len, "x"), unop_ret_var("x", Len)),
Red(app(constr(Sum, app(Rty, VecType)), head_tail_list("x", "y")),
app2(Add, "x", app(constr(Sum, app(Rty, VecType)), "y"))),
Red(app(constr(Sum, app(Rty, VecType)), singleton("x")), "x".into()),
Red(app(constr(Max, app(Rty, VecType)), head_tail_list("x", "y")),
app2(Max2, "x", app(constr(Max, app(Rty, VecType)), "y"))),
Red(app(constr(Max, app(Rty, VecType)), singleton("x")), "x".into()),
Red(app(constr(Min, app(Rty, VecType)), head_tail_list("x", "y")),
app2(Min2, "x", app(constr(Min, app(Rty, VecType)), "y"))),
Red(app(constr(Min, app(Rty, VecType)), singleton("x")), "x".into()),
Red(app2(Max2, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Max2)),
Red(app2(Min2, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Min2)),
Red(app3(Range, ret_var("x"), ret_var("y"), ret_var("z")),
ternop_ret_var("x", "y", "z", Range)),
Red(app3(Rangel, ret_var("x"), ret_var("y"), ret_var("z")),
ternop_ret_var("x", "y", "z", Rangel)),
Red(app3(Ranger, ret_var("x"), ret_var("y"), ret_var("z")),
ternop_ret_var("x", "y", "z", Ranger)),
Red(app3(Rangem, ret_var("x"), ret_var("y"), ret_var("z")),
ternop_ret_var("x", "y", "z", Rangem)),
Red(app(Prob, ret_var("x")), unop_ret_var("x", Prob)),
Red(app(Probl, ret_var("x")), unop_ret_var("x", Probl)),
Red(app(Probr, ret_var("x")), unop_ret_var("x", Probr)),
Red(app(Probm, ret_var("x")), unop_ret_var("x", Probm)),
Red(app2(Item, ret_var("x"), list_var("y")), binop_ret_var("x", "y", Item)),
Red(app3(El, "x", "y", "z"), app2(Item, "y", app2(Item, "x", "z"))),
Red(app(constr(Re, app(Rty, VecType)), "x"), app2(Item, 0.0, "x")),
Red(app(Re, app2(Add, "a", app2(Mul, Any, Imag))), "a".into()),
Red(app(constr(Im, app(Rty, VecType)), "x"), app2(Item, 1.0, "x")),
Red(app(Im, app2(Add, Any, app2(Mul, "a", Imag))), "a".into()),
Red(app2(Mulc, vec2("x0", "y0"), vec2("x1", "y1")),
vec2(app2(Sub, app2(Mul, "x0", "x1"), app2(Mul, "y0", "y1")),
app2(Add, app2(Mul, "x0", "y1"), app2(Mul, "x1", "y0")))),
Red(app(Conj, vec2("x", "y")), vec2("x", app(Neg, "y"))),
Red(app(Conj, app2(Add, "a", app2(Mul, "b", Imag))),
app2(Add, "a", app2(Mul, app(Neg, "b"), Imag))),
Red(app(constr(Sqnorm, app(Rty, VecType)), "x"), app(Sum, app3(VecOp, Mul, "x", "x"))),
Red(app(Norm, "x"), app(Sqrt, app(Sqnorm, "x"))),
Red(app(constr(IsSquareMat, app(Rty, VecType)), "x"), unop_ret_var("x", IsSquareMat)),
Red(app2(Base, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Base)),
Red(app(Arity, "x"), unop_ret_var("x", Arity)),
Red(path(Mul, Neg), comp(Neg, Mul)),
Red(comp(app(Mul, "x"), app(Mul, "y")), app(Mul, app2(Mul, "x", "y"))),
Red(comp(app(Mul, "x"), comp(Mul, ("g", comp(app(Mul, "y"), Snd)))),
comp(app(Mul, "x"), comp(app(Mul, "y"), comp(Mul, ("g", Snd))))),
Red(comp(app(Mul, "x"), comp(Mul, (comp(app(Mul, "y"), Fst), "g"))),
comp(app(Mul, "x"), comp(app(Mul, "y"), comp(Mul, (Fst, "g"))))),
Red(comp(app(Mul, "x"), comp(app(Mul, "y"), "z")),
comp(comp(app(Mul, "x"), app(Mul, "y")), "z")),
Red(app(Neg, app(Neg, "x")), "x".into()),
Red(app(Sqrt, 1.0), 1.0.into()),
Red(app(Sqrt, -1.0), Imag.into()),
Red(app2(Add, 0.0, "x"), "x".into()),
Red(app2(Add, "x", 0.0), "x".into()),
Red(app2(Sub, 0.0, "x"), app(Neg, "x")),
Red(app2(Sub, "x", 0.0), "x".into()),
Red(app2(Mul, 1.0, "x"), "x".into()),
Red(app2(Mul, "x", 1.0), "x".into()),
Red(app(Mul, 0.0), 0.0.into()),
Red(app(Mul, -1.0), Neg.into()),
Red(app2(Mul, Any, 0.0), 0.0.into()),
Red(app2(Div, ret_var("x"), Inf), 0.0.into()),
Red(app2(Pow, "x", 1.0), "x".into()),
Red(app2(Pow, "x", 0.0), 1.0.into()),
Red(app2(Pow, app(Sqrt, "x"), 2.0), "x".into()),
Red(app(Sin, Tau), 0.0.into()),
Red(app(Cos, Tau), 1.0.into()),
Red(app(Tan, Tau), 0.0.into()),
Red(app2(Add, "x", app(Neg, "y")), app2(Sub, "x", "y")),
Red(app2(Mul, "x", app(Neg, "y")), app(Neg, app2(Mul, "x", "y"))),
concrete_op(Add),
concrete_op(Sub),
concrete_op(Mul),
concrete_op(Div),
concrete_op(Rem),
concrete_op(Pow),
concrete_op(Rpow),
vec_op(Add),
vec_op(Sub),
vec_op(Mul),
vec_op(Div),
vec_op(Rem),
vec_op(Pow),
vec_op(Rpow),
Red(app2(app(VecOp, "f"), head_tail_list("x0", "y0"), head_tail_list("x1", "y1")),
app2(Concat, List(vec![app2("f", "x0", "x1")]), app2(app(VecOp, "f"), "y0", "y1"))),
Red(app2(app(VecOp, "f"), singleton("x"), singleton("y")), List(vec![app2("f", "x", "y")])),
Red(app2(VecUop, "f", head_tail_list("x", "y")), app2(Concat, List(vec![app("f", "x")]),
app2(VecUop, "f", "y"))),
Red(app2(VecUop, "f", singleton("x")), List(vec![app("f", "x")])),
Red(app(constr(app(constr(Dot, app(Rty, VecType)), vec2("x0", "y0")), app(Rty, VecType)), vec2("x1", "y1")),
app2(Add, app2(Mul, "x0", "x1"), app2(Mul, "y0", "y1"))),
Red(path(Concat, Len), Add.into()),
Red(path(Concat, Sum), Add.into()),
Red(path(Concat, Min), Min2.into()),
Red(path(Concat, Max), Max2.into()),
Red(path(Concat, Sqnorm), Add.into()),
Red(path(MulMat, Det), Mul.into()),
Red(path(MulMat, (comp(Fst, Dim), comp(Snd, Dim), Dim)), Id.into()),
Red(path(_if("a", "b"), (Not, Id)), _if("b", "a")),
Red(path("f", (Id, "g")), comp("g", "f")),
Red(path("f", (Id, Id, "g")), comp("g", "f")),
Red(comp(Not, comp(Not, "x")), "x".into()),
Red(comp(And, (Le, Ge)), Eq.into()),
Red(comp(And, ("f", "f")), "f".into()),
Red(comp(And, (app(Rge, ret_var("x")), app(Rge, ret_var("y")))),
app(Rge, app2(Max2, "x", "y"))),
Red(comp(And, (app(Rgt, ret_var("x")), app(Rgt, ret_var("y")))),
app(Rgt, app2(Max2, "x", "y"))),
Red(comp(And, (app(Rle, ret_var("x")), app(Rle, ret_var("y")))),
app(Rle, app2(Min2, "x", "y"))),
Red(comp(And, (app(Rlt, ret_var("x")), app(Rlt, ret_var("y")))),
app(Rlt, app2(Min2, "x", "y"))),
Red(comp(And, (app(Rlt, "x"), app(Rle, "x"))), app(Rlt, "x")),
Red(comp(And, (app(Rle, "x"), app(Rlt, "y"))), comp(And, (app(Rlt, "y"), app(Rle, "x")))),
Red(comp(And, (app(Rlt, "x"), app(Rgt, "x"))), false.into()),
Red(comp(And, (app(Rgt, "x"), app(Rlt, "y"))), comp(And, (app(Rlt, "y"), app(Rgt, "x")))),
Red(comp(And, (app(Rgt, "x"), app(Rle, "y"))), comp(And, (app(Rle, "y"), app(Rgt, "x")))),
Red(comp(And, (app(Rle, "x"), app(Rge, "x"))), app(Eq, "x")),
Red(comp(And, (app(Rgt, "x"), app(Rge, "x"))), app(Rgt, "x")),
Red(comp(And, (app(Rge, "x"), app(Rgt, "y"))), comp(And, (app(Rgt, "y"), app(Rge, "x")))),
Red(comp(And, (app(Rge, "x"), app(Rlt, "y"))), comp(And, (app(Rlt, "y"), app(Rge, "x")))),
Red(comp(And, (app(Rge, "x"), app(Rle, "y"))), comp(And, (app(Rle, "y"), app(Rge, "x")))),
Red(comp(And, (app(Rlt, ret_var("x")), app(Rgt, ret_var("y")))),
app(_if(false, app2(Rangem, app2(Min2, "x", "y"), app2(Max2, "x", "y"))),
app2(Le, "x", "y"))),
Red(comp(And, (app(Rlt, ret_var("x")), app(Rge, ret_var("y")))),
app(_if(false, app2(Rangel, app2(Min2, "x", "y"), app2(Max2, "x", "y"))),
app2(Le, "x", "y"))),
Red(comp(And, (app(Rle, ret_var("x")), app(Rgt, ret_var("y")))),
app(_if(false, app2(Ranger, app2(Min2, "x", "y"), app2(Max2, "x", "y"))),
app2(Le, "x", "y"))),
Red(comp(And, (app(Rle, ret_var("x")), app(Rge, ret_var("y")))),
app(_if(false, app2(Range, app2(Min2, "x", "y"), app2(Max2, "x", "y"))),
app2(Lt, "x", "y"))),
Red(comp(And, (app(Rlt, ret_var("x")), app(Rle, ret_var("y")))),
app(_if(app(Rlt, "x"), app(Rle, "y")), app2(Le, "x", "y"))),
Red(comp(And, (app(Rgt, ret_var("x")), app(Rge, ret_var("y")))),
app(_if(app(Rgt, "x"), app(Rge, "y")), app2(Ge, "x", "y"))),
Red(comp(Or, (app(Rlt, "x"), app(Rle, "x"))), app(Rle, "x")),
Red(comp(Or, (app(Rle, "x"), app(Rlt, "y"))), comp(Or, (app(Rlt, "y"), app(Rle, "x")))),
Red(comp(Or, (app(Rlt, "x"), app(Eq, "x"))), app(Rle, "x")),
Red(comp(Or, (app(Eq, "x"), app(Rgt, "x"))), app(Rge, "x")),
Red(comp(Or, (app(Rlt, "x"), app(Rge, "x"))), true.into()),
Red(comp(Or, (app(Rle, "x"), app(Rgt, "x"))), true.into()),
Red(comp(Or, (app(Rle, "x"), app(Rge, "x"))), true.into()),
Red(comp(Or, (app(Rge, "x"), app(Rlt, "y"))), comp(Or, (app(Rlt, "y"), app(Rge, "x")))),
Red(comp(Or, (app(Rgt, "x"), app(Rle, "y"))), comp(Or, (app(Rle, "y"), app(Rgt, "x")))),
Red(comp(Or, (app(Rge, "x"), app(Rle, "y"))), comp(Or, (app(Rle, "y"), app(Rge, "x")))),
Red(comp(Or, (app(Eq, "y"), app(Rlt, "x"))), comp(Or, (app(Rlt, "x"), app(Eq, "y")))),
Red(comp(Or, (app(Rgt, "x"), app(Eq, "y"))), comp(Or, (app(Eq, "y"), app(Rgt, "x")))),
Red(comp(Or, (app(Eq, "x"), app(Rge, "x"))), app(Rge, "x")),
Red(comp(Or, (app(Rle, "x"), app(Eq, "x"))), app(Rle, "x")),
Red(comp(Or, (app(Rge, "x"), app(Eq, "y"))), comp(Or, (app(Eq, "y"), app(Rge, "x")))),
Red(comp(Or, (app(Eq, "x"), app(Rle, "y"))), comp(Or, (app(Rle, "y"), app(Eq, "x")))),
Red(comp(Or, (app(Rgt, "x"), app(Rge, "x"))), app(Rge, "x")),
Red(comp(Or, (app(Rge, "x"), app(Rgt, "y"))), comp(Or, (app(Rgt, "y"), app(Rge, "x")))),
Red(comp(Or, (app(Rlt, ret_var("x")), app(Rle, ret_var("y")))),
app(_if(app(Rle, "y"), app(Rlt, "x")), app2(Le, "x", "y"))),
Red(comp(Or, (app(Rgt, ret_var("x")), app(Rge, ret_var("y")))),
app(_if(app(Rge, "y"), app(Gt, "x")), app2(Ge, "x", "y"))),
Red(comp(Or, ("f", "f")), "f".into()),
Red(app2(D, not_ret_var("x"), "x"), 1.0.into()),
Red(app2(D, not_ret_var("x"), ret_var("y")), 0.0.into()),
Red(app2(D, not_ret_var("x"), app2(Mul, ret_var("k"), "y")), app2(Mul, "k", app2(D, "x", "y"))),
Red(app2(D, not_ret_var("x"), app2(Mul, Pi, "y")), app2(Mul, Pi, app2(D, "x", "y"))),
Red(app2(D, not_ret_var("x"), app2(Mul, Tau, "y")), app2(Mul, Tau, app2(D, "x", "y"))),
Red(app2(D, not_ret_var("x"), app2(Pow, "x", ret_var("k"))),
app2(Mul, "k", app2(Pow, "x", app2(Sub, "k", 1.0)))),
Red(app2(D, not_ret_var("x"), app(Sin, "x")), app(Cos, "x")),
Red(app2(D, not_ret_var("x"), app(Cos, "x")), app(Neg, app(Sin, "x"))),
Red(app2(D, not_ret_var("x"), app(Sin, app2(Mul, ret_var("k"), "x"))),
app2(Mul, "k", app(Cos, app2(Mul, "k", "x")))),
Red(app2(D, not_ret_var("x"), app(Cos, app2(Mul, ret_var("k"), "x"))),
app2(Mul, app(Neg, "k"), app(Sin, app2(Mul, "k", "x")))),
Red(app3(Integ, not_ret_var("x"), "c", "x"),
app2(Add, "c", app2(Mul, 0.5, app2(Pow, "x", 2.0)))),
Red(constr(And, Eq), Fstb.into()),
Red(constr(Or, Eq), Fstb.into()),
Red(constr(Eq, Eq), true.into()),
Red(constr(Sub, Eq), 0.0.into()),
Red(app2(constr(Add, Eq), "x", Any), app2(Mul, 2.0, "x")),
Red(app2(constr(Mul, Eq), "x", Any), app2(Pow, "x", 2.0)),
Red(app(constr(ret_var("x"), Eq), Any), "x".into()),
Red(constr("f", True2), "f".into()),
Red(constr("f", True1), "f".into()),
Red(app2(Mul, app2(Pow, "x", ret_var("k")), "x"),
app2(Pow, "x", unop_ret_var("k", Inc))),
Red(app2(Mul, "x", app2(Pow, "x", ret_var("k"))),
app2(Pow, "x", unop_ret_var("k", Inc))),
Red(app2(Mul, app2(Pow, "x", ret_var("a")), app2(Pow, "x", ret_var("b"))),
app2(Pow, "x", binop_ret_var("a", "b", Add))),
Red(app(Ex, False1), Not.into()),
Red(app(Ex, Not), True1.into()),
Red(app(Ex, Idb), True1.into()),
Red(app(Ex, True1), Idb.into()),
Red(app(Ex, And), True1.into()),
Red(app(Ex, Or), True1.into()),
Red(app(Ex, Nand), True1.into()),
Red(app(Ex, Nor), True1.into()),
Red(app(Ex, Xor), True1.into()),
Red(app(Ex, Eqb), True1.into()),
Red(app(Ex, Exc), True1.into()),
Red(app(Ex, Imply), True1.into()),
Red(app(Ex, Fstb), True1.into()),
Red(app(Ex, Sndb), True1.into()),
Red(app(Ex, Id), true.into()),
Red(app(Ex, constr(constr(Add, app(Rge, "x")), app(Rge, "y"))),
app(Rge, app2(Add, "x", "y"))),
Red(app(Ex, constr(constr(Add, app(Rgt, "x")), app(Rgt, "y"))),
app(Rgt, app2(Add, "x", "y"))),
Red(app(Ex, constr(constr(Add, app(Rle, "x")), app(Rle, "y"))),
app(Rle, app2(Add, "x", "y"))),
Red(app(Ex, constr(constr(Add, app(Rlt, "x")), app(Rlt, "y"))),
app(Rlt, app2(Add, "x", "y"))),
Red(Idb.into(), Id.into()),
Red(Fstb.into(), Fst.into()),
Red(Sndb.into(), Snd.into()),
Red(Eqb.into(), Eq.into()),
Red(comp(Len, Concat), comp(path(Concat, Len), (comp(Len, Fst), comp(Len, Snd)))),
Red(comp(Sum, Concat), comp(path(Concat, Sum), (comp(Sum, Fst), comp(Sum, Snd)))),
Red(comp(Max, Concat), comp(path(Concat, Max), (comp(Max, Fst), comp(Max, Snd)))),
Red(comp(Min, Concat), comp(path(Concat, Min), (comp(Min, Fst), comp(Min, Snd)))),
Red(comp(Sqnorm, Concat),
comp(path(Concat, Sqnorm), (comp(Sqnorm, Fst), comp(Sqnorm, Snd)))),
Red(comp(Norm, Concat), comp(Sqrt, comp(Sqnorm, Concat))),
Red(comp(Len, app(Base, "x")), "x".into()),
Red(app(constr(app(constr(comp("f", Fst), "x"), "a"), Any), Any),
app(constr("f", "x"), "a")),
Red(app2(comp("f", Fst), "a", Any), app("f", "a")),
Red(app(constr(app(constr(comp("f", Snd), Any), Any), "x"), "a"),
app(constr("f", "x"), "a")),
Red(app2(comp("f", Snd), Any, "a"), app("f", "a")),
Red(app2(constr(comp("f", Fst), Any), "a", Any), app("f", "a")),
Red(app2(constr(comp("f", Snd), Any), Any, "a"), app("f", "a")),
Red(comp(comp("f", Fst), ("x", Any)), comp("f", "x")),
Red(comp(comp("f", Snd), (Any, "x")), comp("f", "x")),
Red(comp(("x", "y"), ("a", "b")), (comp("x", ("a", "b")), comp("y", ("a", "b"))).into()),
Red(comp(("x", "y", "z"), ("a", "b", "c")),
(comp("x", "a"), comp("y", "b"), comp("z", "c")).into()),
Red(comp("h", path("f", ("g", Id))), path("f", ("g", "h"))),
Red(comp("h", path("f", ("g0", "g1", Id))), path("f", ("g0", "g1", "h"))),
Red(app2(Add, app2(Pow, app(Cos, "x"), 2.0),
app2(Pow, app(Sin, "x"), 2.0)), 1.0.into()),
Red(app(no_constr("f"), list_var("x")), app(constr("f", app(Rty, VecType)), "x")),
Red(app2(Add, not_ret_var("a"), ret_var("b")), app2(Add, "b", "a")),
Red(app2(Add, not_ret_var("a"), app2(Add, ret_var("b"), "c")),
app2(Add, "b", app2(Add, "a", "c"))),
Red(app2(Sub, app2(Add, ret_var("a"), not_ret_var("b")), not_ret_var("c")),
app2(Add, "a", app2(Sub, "b", "c"))),
Red(app2(Mul, not_ret_var("a"), ret_var("b")), app2(Mul, "b", "a")),
EqvEval(app(Sqrt, ret_pos_var("x")), unop_ret_var("x", Sqrt)),
EqvEval(app(Sqrt, ret_neg_var("x")), app2(Mul, app(Sqrt, "x"), Imag)),
EqvEval(app(Ln, ret_var("x")), unop_ret_var("x", Ln)),
EqvEval(app(Log2, ret_var("x")), unop_ret_var("x", Log2)),
EqvEval(app(Log10, ret_var("x")), unop_ret_var("x", Log10)),
EqvEval(app(Exp, ret_var("x")), unop_ret_var("x", Exp)),
EqvEval(app(Sin, ret_var("x")), unop_ret_var("x", Sin)),
EqvEval(app(Asin, ret_var("x")), unop_ret_var("x", Asin)),
EqvEval(app(Cos, ret_var("x")), unop_ret_var("x", Cos)),
EqvEval(app(Acos, ret_var("x")), unop_ret_var("x", Acos)),
EqvEval(app(Tan, ret_var("x")), unop_ret_var("x", Tan)),
EqvEval(app(Atan, ret_var("x")), unop_ret_var("x", Atan)),
EqvEval(app2(Atan2, ret_var("x"), ret_var("y")), binop_ret_var("x", "y", Atan2)),
Eqv(app2(Mul, 2.0, Pi), Tau.into()),
EqvEval(Pi.into(), 3.141592653589793.into()),
EqvEval(Tau.into(), 6.283185307179586.into()),
Eqv(app2(Pow, "x", 2.0), app2(Mul, "x", "x")),
Eqv(comp(Not, Nand), And.into()),
Eqv(comp(Not, Nor), Or.into()),
Eqv(comp(Not, And), Nand.into()),
Eqv(comp(Not, Or), Nor.into()),
Eqv(comp(Not, Eqb), Xor.into()),
Eqv(comp(Not, Xor), Eqb.into()),
Eqv(app(Rge, "x"), app(Le, "x")),
Eqv(app(Rgt, "x"), app(Lt, "x")),
Eqv(app(Rle, "x"), app(Ge, "x")),
Eqv(app(Rlt, "x"), app(Gt, "x")),
Eqv(app2(Range, 0.0, 1.0), Prob.into()),
Eqv(app2(Rangel, 0.0, 1.0), Probl.into()),
Eqv(app2(Ranger, 0.0, 1.0), Probr.into()),
Eqv(app2(Rangem, 0.0, 1.0), Probm.into()),
Eqv(app2(El, "x", "y"), comp(app(Item, "x"), app(Item, "y"))),
commutative(And),
commutative(Or),
commutative(Nand),
commutative(Nor),
commutative(Xor),
commutative(Eq),
commutative(Add),
commutative(Mul),
associative(Add),
Eqv(app2(Sub, "a", app2(Sub, "b", "c")), app2(Add, app2(Sub, "a", "b"), "c")),
Eqv(app2(Sub, app2(Sub, "a", "b"), "c"), app2(Sub, "a", app2(Add, "b", "c"))),
associative(Mul),
distributive(Mul, Add),
distributive(Mul, Sub),
Eqv(app2(Mul, app2(Sub, "a", "b"), "c"),
app2(Sub, app2(Mul, "a", "c"), app2(Mul, "b", "c"))),
Eqv(app2(Mul, app2(Add, "a", "b"), "c"),
app2(Add, app2(Mul, "a", "c"), app2(Mul, "b", "c"))),
Eqv(app2(Sub, app2(Add, "a", "b"), "c"), app2(Add, "a", app2(Sub, "b", "c"))),
Eqv(app2(Pow, app2(Add, "a", "b"), 2.0), app2(Add, app2(Add, app2(Pow, "a", 2.0),
app2(Mul, app2(Mul, 2.0, "a"), "b")), app2(Pow, "b", 2.0))),
Eqv(app2(Pow, app2(Sub, "a", "b"), 2.0), app2(Add, app2(Sub, app2(Pow, "a", 2.0),
app2(Mul, app2(Mul, 2.0, "a"), "b")), app2(Pow, "b", 2.0))),
Eqv(app2(Mul, app2(Add, "a", "b"), app2(Sub, "a", "b")),
app2(Sub, app2(Pow, "a", 2.0), app2(Pow, "b", 2.0))),
Eqv(app2(Pow, app2(Mul, "a", "b"), 2.0), app2(Mul, app2(Pow, "a", 2.0), app2(Pow, "b", 2.0))),
Eqv(app2(Rpow, "a", "b"), app2(Pow, "b", "a")),
Eqv(app2(no_constr("f"), "a", "a"), app2(constr("f", Eq), "a", "a")),
Eqv(path(path("f", "g"), "h"), path("f", comp("h", "g"))),
Eqv(path(path("f", ("g0", "g1", "g2")), ("h0", "h1", "h2")),
path("f", (comp("h0", "g0"), comp("h1", "g1"), comp("h2", "g2")))),
Eqv(comp("f", comp("g", ("h0", "h1"))), comp(comp("f", "g"), ("h0", "h1"))),
Eqv(comp(comp("f", ("g0", "g1")), ("h0", "h1")),
comp("f", comp(("g0", "g1"), ("h0", "h1")))),
Eqv(comp("f", comp("g", "h")), comp(comp("f", "g"), "h")),
Eqv(path(arity_var("f", 1), "g"), path(path(arity_var("f", 1), ("g", Id)), (Id, "g"))),
Eqv(app(constr(app(constr(comp("f", ("g0", "g1")), "x"), "a"), "y"), "b"),
app2("f", app(constr(app(constr("g0", "x"), "a"), "y"), "b"),
app(constr(app(constr("g1", "x"), "a"), "y"), "b"))),
Eqv(app2(comp("f", ("g0", "g1")), "a", "b"),
app2("f", app2("g0", "a", "b"), app2("g1", "a", "b"))),
Eqv(app(comp("f", ("g0", "g1")), "a"), app2("f", app("g0", "a"), app("g1", "a"))),
Eqv(app(comp("f", (app("g0", "a"), app("g1", "b"))), "c"),
app3(comp("f", (comp("g0", Fst), comp("g1", Snd))), "a", "b", "c")),
Eqv(app2(comp("f", "g"), "a", "b"), app("f", app2("g", "a", "b"))),
Eqv(app(constr(app(constr(comp("f", "g"), "x"), "a"), "y"), "b"),
app("f", app(constr(app(constr("g", "x"), "a"), "y"), "b"))),
Eqv(app(comp("f", "g"), "a"), app("f", app("g", "a"))),
Eqv(app(constr(app(constr(comp("f", "g"), "x"), "a"), "y"), "b"),
app2(comp("f", constr(constr("g", "x"), "y")), "a", "b")),
Eqv(app(constr(comp("f", arity_var("g", 1)), "x"), "a"), app("f", app(constr("g", "x"), "a"))),
Eqv(app(constr(app(constr(comp("g", arity_var("f", 2)), Any), "a"), Any), "b"),
app(app(path(arity_var("f", 2), "g"), app("g", "a")), app("g", "b"))),
Eqv(app(constr(comp("g", arity_var("f", 1)), Any), "a"),
app(path(arity_var("f", 1), "g"), app("g", "a"))),
Eqv(app(app(comp("g", arity_var("f", 2)), "a"), "b"),
app2(path(arity_var("f", 2), "g"), app("g", "a"), app("g", "b"))),
Eqv(comp("g", arity_var("f", 2)),
comp(path(arity_var("f", 2), "g"), (comp("g", Fst), comp("g", Snd)))),
Eqv(app(comp("g", arity_var("f", 1)), "a"), app(path(arity_var("f", 1), "g"), app("g", "a"))),
Eqv(app(("g", "f"), "a"), (app("g", "a"), app("f", "a")).into()),
Eqv(comp("f", app(("g0", "g1"), "a")), app(comp("f", ("g0", "g1")), "a")),
Eqv(constr(comp("g", "f"), "h"), comp("g", constr("f", "h"))),
Eqv(comp(path("f", ("g0", "g1", "g2")), (comp("g0", Fst), comp("g1", Snd))),
comp("g2", "f")),
Eqv(comp(path("f", ("g0", "g1")), "g0"), comp("g1", "f")),
Eqv(comp(path("f", (Id, "g0", "g1")), (Fst, comp("g0", Snd))), comp("g1", "f")),
Eqv(comp(path("f", ("g0", Id, "g1")), (comp("g0", Fst), Snd)), comp("g1", "f")),
]
}