def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) Eq << apply(Equality(A & B, A | B)) Eq << Subset(A, A | B, plausible=True).subs(Eq[0].reversed) Eq << Subset(A & B, B, plausible=True) Eq.subset = Eq[-2].subs(Eq[-1]) Eq << Subset(B, A | B, plausible=True).subs(Eq[0].reversed) Eq << Subset(A & B, A, plausible=True) Eq << Eq[-2].subs(Eq[-1]).subs(Eq.subset).reversed
def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) C = Symbol.C(dtype=dtype.integer) subset = Subset(A, B, evaluate=False) equality = Equality(B & C, S.EmptySet, evaluate=False) Eq << apply(equality, subset) Eq << subset.intersect(C) Eq << Eq[-1].subs(equality) Eq << Supset(*Eq[-1].args, plausible=True) Eq << Eq[-1].subs(Eq[-2])
def apply(given): assert given.is_Equality A_minus_B, emptyset = given.args assert emptyset.is_EmptySet and A_minus_B.is_Complement B, A = A_minus_B.args return Subset(B, A, given=given)
def prove(Eq): n = Symbol.n(integer=True, positive=True) x = Symbol.x(complex=True, shape=(n,)) A = Symbol.A(dtype=dtype.complex * n) B = Symbol.B(dtype=dtype.complex * n) Eq << apply(Contains(x, A), Subset(A, B)) # Eq <<= Eq[0] & Eq[1] Eq <<= Eq[1] & Eq[0]
def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) inequality = Unequality(A, B) subset = Subset(A, B, evaluate=False) Eq << apply(inequality, subset) Eq << ~Eq[-1] Eq << Eq[-1].union(A) Eq << Subset(B, A | B, plausible=True) Eq << Eq[-1].subs(Eq[-2]) Eq << Eq[-1].subs(subset).reversed Eq << Eq[-1].subs(Eq[0])
def apply(given): assert given.is_ForAll assert len(given.limits) == 1 x, A = given.limits[0] assert given.function.is_Contains _x, B = given.function.args assert x == _x return Subset(A, B, given=given)
def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) subset = Subset(A, B, evaluate=False) Eq << apply(subset) Eq << sets.imply.equality.inclusion_exclusion_principle.apply(B - A, B & A) Eq << Eq[-1].subs(Eq[-2]) Eq << subset.intersect(A) Eq << Supset(*Eq[-1].args, plausible=True) Eq << Eq[-1].subs(Eq[-2]) Eq << Eq[-1].abs()
def prove(Eq): n = Symbol.n(domain=Interval(2, oo, integer=True)) S = Symbol.S(dtype=dtype.integer * n) x = Symbol.x(**S.element_symbol().dtype.dict) i = Symbol.i(integer=True) j = Symbol.j(integer=True) given = [ ForAll[j:1:n - 1, x:S](Contains( LAMBDA[i:n](Piecewise((x[0], Equality(i, j)), (x[j], Equality(i, 0)), (x[i], True))), S)), ForAll[x:S](Equality(abs(x.set_comprehension()), n)) ] Eq << apply(given) Eq << discrete.combinatorics.permutation.adjacent.swap2.general.apply( Eq[0]) Eq.permutation = discrete.combinatorics.permutation.adjacent.swapn.permutation.apply( Eq[-1]) Eq << Eq.permutation.limits[0][1].this.definition Eq << discrete.combinatorics.permutation.factorial.definition.apply(n) Eq << Eq[-1].this.lhs.arg.limits_subs(Eq[-1].lhs.arg.variable, Eq[-2].rhs.variable) Eq <<= Eq[-1] & Eq[-2].abs() F = Function.F(nargs=(), dtype=dtype.integer * n) F.eval = lambda e: conditionset(x, Equality(x.set_comprehension(), e), S) e = Symbol.e(dtype=dtype.integer) Eq << Subset(F(e), S, plausible=True) Eq << Eq[-1].this.lhs.definition Eq << sets.subset.forall.imply.forall.apply(Eq[-1], Eq.permutation) Eq.forall_x = ForAll(Contains(Eq[-1].lhs, F(e)), *Eq[-1].limits, plausible=True) Eq << Eq.forall_x.definition.split() P = Eq[-1].limits[0][1] Eq << sets.imply.conditionset.apply(P) Eq << Eq[-1].apply(sets.equality.imply.equality.permutation, x) Eq.equality_e = Eq[-3] & Eq[-1] Eq << sets.imply.conditionset.apply(F(e)).reversed
def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) Eq << apply(Subset(A, B)) Eq << sets.subset.imply.equality.complement.apply(Eq[0]) Eq << ~Eq[1] Eq << Eq[-1] + Eq[-2].reversed
def prove(Eq): A = Symbol.A(dtype=dtype.integer, given=True) B = Symbol.B(dtype=dtype.integer, given=True) C = Symbol.C(dtype=dtype.integer, given=True) Eq << apply(Equality(B & C, S.EmptySet, evaluate=False), Subset(A, B, evaluate=False)) Eq << sets.equality.imply.equality.given.emptyset.subset.apply( Eq[0], Eq[1]) Eq << Eq[-1].union(Eq[-2].lhs).reversed
def prove(Eq): n = Symbol.n(complex=True, positive=True) A = Symbol.A(dtype=dtype.complex * n) B = Symbol.B(dtype=dtype.complex * n) Eq << apply(Subset(B, A)) x = Eq[1].variable Eq << ForAll[x:B](Contains(x, B), plausible=True) Eq << Eq[-1].simplify() Eq << Eq[-1].apply(sets.contains.subset.imply.contains, Eq[0], join=False)
def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) subset = Subset(A, B) Eq << apply(subset) Eq << Eq[0].union(B) Eq << Supset(*Eq[-1].args, plausible=True) Eq << Eq[-1].subs(Eq[-2])
def prove(Eq): n = Symbol.n(integer=True, positive=True) p = Symbol.p(integer=True, shape=(n, )) x = Symbol.x(integer=True, shape=(n, )) Eq << apply( Equality(p.set_comprehension(), Interval(0, n - 1, integer=True)), x) A = Symbol.A(definition=Eq[1].lhs) B = Symbol.B(definition=Eq[1].rhs) Eq.A_definition = A.this.definition i = Eq[1].lhs.variable _i = Symbol.i(domain=Interval(0, n - 1, integer=True)) Eq.A_definition = Eq.A_definition.this.rhs.limits_subs(i, _i) j = Eq[1].rhs.variable _j = Symbol.j(domain=Interval(0, n - 1, integer=True)) Eq.B_definition = B.this.definition Eq.B_definition = Eq.B_definition.this.rhs.limits_subs( Eq.B_definition.rhs.variable, _j) Eq.subset = Subset(Eq.A_definition.rhs, Eq.B_definition.rhs, plausible=True) Eq << Eq.subset.simplify() Eq << Eq[-1].definition Eq << Eq[-1].subs(Eq[-1].variable, p[_i]) Eq.supset = Supset(Eq.subset.lhs, Eq.subset.rhs, plausible=True) Eq << Eq.supset.simplify() Eq.definition = Eq[-1].definition Eq << discrete.combinatorics.permutation.index.equality.apply(Eq[0], _j) index_j = Eq[-1].lhs.indices[0] Eq << Eq.definition.subs(Eq[-1].reversed) Eq << Eq[-1].subs(Eq[-1].variable, index_j) Eq <<= Eq.subset & Eq.supset Eq << Eq[-1].this.lhs.limits_subs(_i, i) Eq << Eq[-1].this.rhs.limits_subs(_j, j)
def prove(Eq): n = Symbol.n(integer=True, positive=True) Eq << apply(n) Q = Eq[0].lhs.base t = Q.definition.variable Eq << Subset(Eq[0].lhs, Eq[2].rhs, plausible=True) Eq.subset_P = sets.subset.imply.subset.apply(Eq[-1], (t, ), simplify=False) Eq.subset_Q = Subset(Eq.subset_P.rhs, Eq.subset_P.lhs, plausible=True) Eq << Eq.subset_Q.definition Eq << Eq[-1].limits_subs(Eq[-1].variable, Eq[0].rhs.variable) Eq << Eq[-1].definition Eq << Eq[-1].definition Eq << sets.imply.conditionset.apply(Eq[2].rhs) Eq <<= Eq.subset_P & Eq.subset_Q
def prove(Eq): A = Symbol.A(dtype=dtype.integer) B = Symbol.B(dtype=dtype.integer) subset = Subset(A, B) Eq << apply(subset) Eq << Eq[0].intersect(A) Eq << Supset(*Eq[-1].args, plausible=True) Eq <<= Eq[-1] & Eq[-2] Eq << Eq[-1].reversed
def prove(Eq): n = Symbol.n(integer=True, positive=True) u = Symbol.u(domain=Interval(0, n, integer=True)) v = Symbol.v(domain=Interval(0, n, integer=True)) Eq << apply(n, u, v) w, i, j = Eq[0].lhs.args Q = Eq[2].lhs.base Eq << sets.imply.conditionset.apply(Q[u]).split() Eq.x_j_equality = Eq[-1].apply( discrete.combinatorics.permutation.index.exists, v) Eq << Eq.x_j_equality.this.function.limits_subs( Eq.x_j_equality.function.variable, j) Eq << algebre.matrix.elementary.swap.invariant.permutation.apply(n + 1, w=w) Eq << Subset(Eq[-2].limits[0][1], Eq[-1].rhs, plausible=True) Eq << sets.subset.forall.imply.forall.apply(Eq[-1], Eq[-2]) Eq << Eq[-1].subs(Eq[-1].rhs.this.definition) Eq << Eq[-1].subs(i, n) k = Eq[-1].function.lhs.function.arg.args[0].indices[-1] Eq << Eq[1][k].set.union_comprehension((k, 0, n)) Eq.x_n1_set_comprehension = Eq[-2].subs(Eq[-1].reversed) Eq << Eq[1][n] Eq << Eq[0].subs(i, n)[n] Eq << Eq[-2].this.rhs.subs(Eq[-1]) Eq << Eq[-1].this.rhs.expand() Eq << Eq[-1].subs(Eq.x_j_equality) Eq << Eq[-1].this.function().function.rhs.args[0].simplify() Eq <<= Eq.x_n1_set_comprehension & Eq[-1] Eq << Eq[3].definition
def prove(Eq): n = Symbol.n(integer=True, positive=True) i = Symbol.i(integer=True) x = Symbol.x(shape=(oo, ), dtype=dtype.complex * n) A = Symbol.A(dtype=dtype.complex * n) m = Symbol.m(integer=True, positive=True) Eq << apply(Subset(x[i], A), (i, 0, m - 1)) Eq << Eq[-1].subs(m, 1) Eq << Eq[0].subs(i, 0) Eq << Eq[1].subs(m, m + 1) Eq << Eq[0].subs(i, m) Eq <<= Eq[-1] & Eq[1]
def prove(Eq): n = Symbol.n(complex=True, positive=True) A = Symbol.A(dtype=dtype.complex * n) B = Symbol.B(dtype=dtype.complex * n) x = Symbol.x(complex=True, shape=(n, )) f = Function.f(nargs=(n, ), complex=True, shape=()) assert f.is_complex assert f.shape == () Eq << apply(Subset(B, A), ForAll[x:A](Equality(f(x), 1))) Eq << Eq[0].definition Eq << Eq[-1].limits_subs(Eq[-1].variable, x) Eq << Eq[-1].apply(sets.contains.forall.imply.condition, Eq[1], join=False)
def prove(Eq): A = Symbol.A(dtype=dtype.integer, given=True) B = Symbol.B(dtype=dtype.integer, given=True) Eq << apply(Subset(A, B), Equality(abs(A), abs(B))) Eq << (B - A).assertion() Eq.union_AB = Eq[-1].subs(Eq[1]) Eq << Eq[0].union(B) Eq << sets.subset.imply.equality.union.apply(Eq[0]) Eq << Eq[-1].abs() Eq << Eq.union_AB.subs(Eq[-1]).reversed Eq << sets.equality.imply.equality.emptyset.apply(Eq[-1]) Eq << sets.equality.imply.subset.complement.apply(Eq[-1]) Eq << Eq[-1].subs(Eq[0]).reversed
def prove(Eq): k = Symbol.k(integer=True, positive=True) n = Symbol.n(integer=True, positive=True) Eq << apply(n, k) s2_quote = Symbol.s_quote_2(definition=Eq[0].rhs.limits[0][1]) Eq << s2_quote.this.definition Eq.s2_definition = Eq[0].subs(Eq[-1].reversed) s1_quote = Eq[2].lhs Eq << s1_quote.assertion() i = Eq[1].lhs.indices[0] x_slice = Eq[-1].limits[0][0] x = x_slice.base Eq.x_abs_positive_s1, Eq.x_abs_sum_s1, Eq.x_union_s1 = Eq[-1].split() j = Symbol.j(domain=Interval(0, k, integer=True)) x_quote = Eq[1].lhs.base Eq.x_quote_set_in_s2 = Subset(image_set(UNION[i:0:k](x_quote[i].set), x_slice, s1_quote), Eq[0].lhs, plausible=True) Eq << Eq.x_quote_set_in_s2.definition Eq << Eq[-1].subs(Eq.s2_definition) Eq << Eq[-1].definition.definition Eq << Eq[-1].this.function.args[0].simplify() Eq << Eq[1].union_comprehension((i, 0, k)) x_quote_union = Eq[-1].subs(Eq.x_union_s1) Eq << x_quote_union Eq << Eq[1].abs() x_quote_abs = Eq[-1] Eq << Eq[-1].sum((i, 0, k)) Eq << sets.imply.less_than.union.apply(*Eq[-1].rhs.args[1].arg.args) Eq << Eq[-2].subs(Eq[-1]) Eq << Eq[-1].subs(Eq.x_abs_sum_s1) Eq << x_quote_union.abs() x_quote_union_abs = Eq[-1] u = Eq[-1].lhs.arg Eq << sets.imply.less_than.union_comprehension.apply(u.function, *u.limits) Eq << Eq[-2].subs(Eq[-1]) Eq << Eq[-4].subs(Eq[-1]) SqueezeTheorem = Eq[-1] Eq << x_quote_abs.as_Or() Eq << Eq[-1].subs(i, j) Eq << Eq[-2].forall((i, Unequality(i, j))) Eq << sets.imply.greater_than.apply(*Eq[-2].rhs.arg.args[::-1]) Eq << Eq[-1].subs(Eq.x_abs_positive_s1.limits_subs(i, j)) Eq << Eq[-4].subs(Eq[-1]) Eq << Eq[-4].subs(Eq.x_abs_positive_s1) Eq << (Eq[-1] & Eq[-2]) Eq << (x_quote_union & SqueezeTheorem & Eq[-1]) Eq.x_quote_definition = Eq[1].reference((i, 0, k)) Eq.subset_A = Subset(Eq[4].lhs, Eq[4].rhs, plausible=True) Eq.supset_A = Supset(Eq[4].lhs, Eq[3].lhs, plausible=True) Eq << Eq.supset_A.subs(Eq[3]) Eq << Eq[-1].definition.definition Eq << Eq[-1].split() notContains = Eq[-1] Eq << ~Eq[-1] Eq << Eq[-1].definition Eq << Eq.x_quote_definition[j] Eq << Eq[-1].intersect(Eq[-2].reversed) Eq << sets.imply.equality.inclusion_exclusion_principle.apply( *Eq[-1].lhs.args) Eq << Eq[-1].subs(Eq[-2]) Eq.set_size_inequality = Eq[-1].subs( StrictLessThan(Eq[-1].function.rhs, Eq[-1].function.rhs + 1, plausible=True)) Eq << x_quote_union.this.function.lhs.bisect({i, j}) Eq << sets.imply.less_than.union.apply(*Eq[-1].lhs.args) Eq << sets.imply.less_than.union_comprehension.apply( *Eq[-2].lhs.args[0].args) Eq << Eq[-2].subs(Eq[-1]) + Eq.set_size_inequality Eq << Eq[-1].this().function.rhs.args[-1].simplify() Eq << Eq[-1].this().function.rhs.args[0].arg.simplify() Eq << Eq[-1].subs(x_quote_union_abs) Eq << Eq[-1].subs(SqueezeTheorem) Eq << Eq.subset_A.subs(Eq[3]) Eq << Eq[-1].definition.definition s2_hat_n = Symbol("\hat{s}_{2, n}", definition=Eq[-1].limits[0][1]) Eq << s2_hat_n.this.definition Eq.s2_hat_n_assertion = Eq[-2].this.limits[0].subs(Eq[-1].reversed) Eq << Eq[-1].this.rhs.as_image_set() s2_quote_n = Symbol("s'_{2, n}", definition=Eq[-1].rhs.limits[0][1]) assert s2_quote_n in s2_quote assert Supset(s2_quote, s2_quote_n) Eq << s2_quote_n.this.definition Eq << Eq[-2].subs(Eq[-1].reversed) Eq.s2_hat_n_hypothesis = Eq.s2_hat_n_assertion.this.limits[0].subs(Eq[-1]) Eq << s2_quote_n.assertion() Eq.n_not_in_x, Eq.x_abs_positive_s2_n, Eq.x_abs_sum_s2_n, Eq.x_union_s2_n = Eq[ -1].split() Eq << Eq.n_not_in_x.definition Eq.x_j_inequality = Eq[-1].limits_subs(i, j) Eq << Eq.x_union_s2_n.func(Contains(n, Eq.x_union_s2_n.lhs), *Eq.x_union_s2_n.limits, plausible=True) Eq << Eq[-1].subs(Eq.x_union_s2_n) Eq << Eq[-1].definition x_hat = Symbol(r"\hat{x}", shape=(oo, ), dtype=dtype.integer, definition=LAMBDA[i](Piecewise( (x_slice[i] - {n}, Equality(i, j)), (x_slice[i], True)))) Eq.x_hat_definition = x_hat.equality_defined() Eq << Eq[-1].this.function.limits_subs(i, j) Eq.x_j_subset = Eq[-1].apply(sets.contains.imply.subset, simplify=False) Eq << Eq.x_j_subset.apply(sets.inequality.subset.imply.inequality, Eq.x_j_inequality, simplify=False) Eq.x_j_abs_positive = Eq[-1].apply( sets.inequality.imply.strict_greater_than) Eq.x_hat_abs = Eq.x_hat_definition.abs() Eq << Eq.x_hat_abs.as_Or() Eq << Eq[-1].subs(i, j) Eq << Eq[-2].forall((i, Unequality(i, j))) Eq << Eq[-1].subs(Eq.x_abs_positive_s2_n) # -1 Eq << Eq[-3].subs(Eq.x_j_abs_positive) Eq.x_hat_abs_positive = Eq[-1] & Eq[-2] Eq.x_hat_union = Eq.x_hat_definition.union_comprehension((i, 0, k)) Eq.x_union_complement = Eq.x_union_s2_n - {n} Eq << Eq.x_union_s2_n.abs().subs(Eq.x_abs_sum_s2_n.reversed).apply( sets.equality.imply.forall_equality.nonoverlapping) Eq << Eq[-1].limits_subs(Eq[-1].variables[1], j).limits_subs( Eq[-1].variable, i) Eq.x_complement_n = Eq[-1].apply(sets.equality.subset.imply.equality, Eq.x_j_subset) Eq << Eq.x_complement_n.this.function.function.union_comprehension( *Eq.x_complement_n.function.function.limits) Eq << Eq.x_hat_union.subs(Eq[-1].reversed) Eq.x_hat_union = Eq[-1].subs(Eq.x_union_complement) Eq << Eq.x_hat_abs.sum((i, 0, k)).subs(Eq.x_abs_sum_s2_n) Eq << Eq.x_j_subset.apply(sets.subset.imply.equality.complement) Eq << Eq[-2].subs(Eq[-1]) Eq << (Eq[-1] & Eq.x_hat_abs_positive & Eq.x_hat_union) function = Contains(x_hat[:k + 1], s1_quote) function = Eq[-1].function.func(function, *Eq[-1].function.limits) Eq.x_hat_in_s1 = Eq[-1].func(function, *Eq[-1].limits, plausible=True) Eq << Eq.x_hat_in_s1.definition Eq << Eq.x_hat_definition.as_Or() Eq << Eq[-1].subs(i, j) Eq << Eq[-2].forall((i, Unequality(i, j))) Eq <<= Eq[-1] & Eq.x_complement_n.reversed Eq << (Eq[-1] & Eq[-3]) Eq << Eq[-1].this.function.function.reference( *Eq[-1].function.function.limits) Eq << Eq.x_hat_in_s1.subs(Eq[-1]) Eq << Eq.s2_hat_n_hypothesis.strip().strip() Eq << Eq[-1].subs(Eq.x_quote_definition) Eq.equation = Eq[-1] - {n} Eq << Eq.x_union_s1.intersect({n}) Eq.nonoverlapping_s1_quote = Eq[-1].apply( sets.equality.imply.equality.given.emptyset.intersect) Eq.xi_complement_n = Eq.nonoverlapping_s1_quote.apply( sets.equality.imply.equality.given.emptyset.complement, reverse=True) Eq << Eq.equation.subs(Eq.xi_complement_n) a = Eq[-1].variable b = Symbol.b(**a.dtype.dict) Eq << Eq[-1].limits_subs(a, b) Eq << Eq[-1].this.function.subs(x[:k + 1], a) Eq << Eq[-1].limits_subs(b, x[:k + 1]) Eq << Eq[-1].this.function.function.reference((i, 0, k)) Eq.supset_A = sets.supset.imply.supset.apply(Eq.supset_A, (j, ), simplify=False) Eq << Eq.supset_A.subs(Eq.subset_A)
def prove(Eq): k = Symbol.k(integer=True, positive=True) n = Symbol.n(integer=True, positive=True) Eq << apply(n, k) s2 = Eq[0].lhs s2_quote = Symbol.s_quote_2(definition=Eq[0].rhs.limits[0][1]) Eq << s2_quote.this.definition Eq.s2_definition = Eq[0].subs(Eq[-1].reversed) s0 = Eq[1].lhs s0_quote = Symbol.s_quote_0(definition=Eq[1].rhs.limits[0][1]) Eq << s0_quote.this.definition Eq << Eq[1].subs(Eq[-1].reversed) s0_definition = Eq[-1] e = Symbol.e(dtype=dtype.integer.set) s0_ = image_set(Union(e, {n.set}), e, s0) plausible0 = Subset(s0_, s2, plausible=True) Eq << plausible0 Eq << Eq[-1].definition Eq << Eq[-1].this.limits[0][1].subs(s0_definition) Eq << Eq[-1].subs(Eq.s2_definition) s0_plausible = Eq[-1] Eq.s2_quote_definition = s2_quote.assertion() Eq << s0_quote.assertion() Eq << Eq[-1].split() x_abs_positive = Eq[-3] x_abs_sum = Eq[-2] x_union_s0 = Eq[-1] i = Eq[-1].lhs.limits[0][0] x = Eq[-1].variable.base Eq << Equality.define(x[k], {n}) x_k_definition = Eq[-1] Eq << Eq[-1].union(Eq[-2]) x_union = Eq[-1] Eq << x_k_definition.set Eq << Eq[-1].union(x[:k].set_comprehension()) Eq << s0_plausible.subs(Eq[-1].reversed) Eq << Eq[-1].definition.definition Eq << x_k_definition.abs() Eq << Eq[-1].subs(StrictGreaterThan(1, 0, plausible=True)) Eq << x_abs_sum + Eq[-2] Eq << (x_abs_positive & Eq[-2]) Eq << (x_union & Eq[-1] & Eq[-2]) j = Symbol.j(domain=Interval(0, k, integer=True)) B = Eq[2].lhs Eq << plausible0.subs(Eq[2].reversed) Eq << s2.this.bisect(conditionset(e, Contains({n}, e), s2)) Eq.subset_B = Subset(Eq[-1].rhs.args[0], Eq[-2].lhs, plausible=True) # unproven Eq.supset_B = Supset(Eq[-1].rhs.args[0], Eq[-2].lhs, plausible=True) # unproven Eq << Eq.supset_B.subs(Eq[2]) Eq << Eq[-1].definition.definition Eq << Eq.subset_B.subs(Eq[2]) Eq << Eq[-1].definition.definition Eq.subset_B_definition = Eq[-1] - {n.set} num_plausibles = len(Eq.plausibles_dict) Eq.plausible_notcontains = ForAll(NotContains({n}, e), (e, s0), plausible=True) Eq << Eq.plausible_notcontains.this.limits[0][1].subs(s0_definition) Eq << ~Eq[-1] Eq << Eq[-1].definition Eq << x_union_s0.union(Eq[-1].reversed).this().function.lhs.simplify() Eq << Eq[-1].subs(x_union_s0) assert num_plausibles == len(Eq.plausibles_dict) Eq << Eq.plausible_notcontains.apply( sets.notcontains.imply.equality.emptyset) Eq.s0_complement_n = Eq[-1].apply( sets.equality.imply.equality.given.emptyset.complement) Eq << Eq.subset_B_definition.subs(Eq.s0_complement_n) s2_n = Symbol('s_{2, n}', definition=Eq[-1].limits[0][1]) Eq.s2_n_definition = s2_n.this.definition Eq << s2_n.assertion() Eq << Eq[-1].subs(Eq.s2_definition).split() Eq.s2_n_assertion = Eq[-2].definition Eq << Eq[-1].subs(Eq.s2_n_assertion) Eq << Eq[-1].definition Eq.x_j_definition = Eq[-1].limits_subs(Eq[-1].variable, j).reversed Eq.x_abs_positive_s2, Eq.x_abs_sum_s2, Eq.x_union_s2 = Eq.s2_quote_definition.split( ) Eq << Eq.x_union_s2 - Eq.x_j_definition Eq << Eq[-1].this.function.lhs.args[0].bisect({j}) x_tilde = Symbol(r"\tilde{x}", shape=(k, ), dtype=dtype.integer, definition=LAMBDA[i:k](Piecewise((x[i], i < j), (x[i + 1], True)))) Eq.x_tilde_definition = x_tilde.equality_defined() Eq << Eq.x_tilde_definition.union_comprehension((i, 0, k - 1)) Eq << Eq[-1].this.rhs.args[1].limits_subs(i, i - 1) Eq.x_tilde_union = Eq[-1].subs(Eq[-3]) Eq.x_tilde_abs = Eq.x_tilde_definition.abs() Eq << Eq.x_tilde_abs.sum((i, 0, k - 1)) Eq << Eq[-1].this.rhs.args[0].limits_subs(i, i - 1) Eq.x_tilde_abs_sum = Eq[-1].subs(Eq.x_abs_sum_s2, Eq.x_j_definition.abs()) Eq << Eq.x_tilde_abs.as_Or() Eq << Eq[-1].forall((i, i < j)) Eq << Eq[-2].forall((i, i >= j)) Eq << Eq[-2].subs(Eq.x_abs_positive_s2) Eq << Eq[-2].subs(Eq.x_abs_positive_s2.limits_subs(i, i + 1)) Eq << (Eq[-1] & Eq[-2]) Eq << (Eq[-1] & Eq.x_tilde_abs_sum & Eq.x_tilde_union) Eq << Eq[-1].func( Contains(x_tilde, s0_quote), *Eq[-1].limits, plausible=True) Eq << Eq[-1].definition Eq << Eq[-1].this.function.args[0].simplify() Eq.x_tilde_set_in_s0 = Eq[-3].func(Contains( UNION.construct_finite_set(x_tilde), s0), *Eq[-3].limits, plausible=True) Eq << Eq.x_tilde_set_in_s0.subs(s0_definition) Eq << Eq[-1].definition Eq << Eq.x_tilde_definition.set.union_comprehension((i, 0, k - 1)) Eq << Eq[-1].subs(Eq.x_j_definition) Eq << Eq[-1].subs(Eq.s2_n_assertion.reversed) Eq << Eq.x_tilde_set_in_s0.subs(Eq[-1]) Eq << Eq[-1].this.limits[0].subs(Eq.s2_n_definition) Eq.subset_B_plausible = Eq.subset_B_definition.union({n.set}) Eq << Eq.subset_B_plausible.limits_assertion() Eq << Eq[-1].definition.split()[1] Eq << Eq[-1].apply(sets.contains.imply.equality.union) Eq << Eq.subset_B_plausible.subs(Eq[-1]) Eq << Eq.supset_B.subs(Eq.subset_B)
def apply(given): assert given.is_Contains e, s = given.args return Subset(e.set, s, given=given)
def apply(given, *limits): assert given.is_Subset fx, A = given.args return Subset(UNION(fx, *limits).simplify(), A, given=given)
def prove(Eq): n = Symbol.n(domain=[2, oo], integer=True) x = Symbol.x(shape=(oo, ), integer=True) k = Symbol.k(integer=True) j = Symbol.j(domain=[0, n - 1], integer=True, given=True) Eq << apply( Equality(x[:n].set_comprehension(k), Interval(0, n - 1, integer=True)), j) Eq << Eq[1].lhs.this.definition Eq <<= Eq[-3].subs(Eq[-1]), Eq[-2].subs(Eq[-1]) Eq << Eq[-1].lhs.indices[0].this.expand() Eq << Eq[-1].rhs.function.args[1].this.as_Piecewise() Eq << Eq[-2].this.rhs.subs(Eq[-1]) Eq << Eq[-1].rhs.subs(1, 0).this.bisect({0}) assert Eq[-1].lhs.limits[0][1].args[-1][-1].step.is_zero == False Eq << Eq[-2].subs(Eq[-1].reversed) assert Eq[-1].rhs.limits[0][1].args[-1][-1].step.is_zero == False sj = Symbol.s_j(definition=Eq[-1].rhs.limits[0][1]) Eq.sj_definition = sj.equality_defined() assert Eq.sj_definition.rhs.limits[0][-1].step.is_zero == False Eq.crossproduct = Eq[-1].subs(Eq.sj_definition.reversed) Eq.sj_definition_reversed = Eq.sj_definition.this.rhs.limits[0][1].reversed assert Eq.sj_definition_reversed.args[-1].args[-1][ -1].step.is_zero == False Eq.sj_definition_reversed = Eq.sj_definition_reversed.reversed assert Eq.sj_definition_reversed.lhs.args[-1][-1].step.is_zero == False Eq << Eq[0].intersect({j}) Eq << Piecewise((x[k].set, Equality(x[k], j)), (EmptySet(), True)).this.simplify() Eq << Eq[-1].reversed.union_comprehension((k, 0, n - 1)) Eq.distribute = Eq[-1].subs(Eq[-3]).reversed Eq << Eq.distribute.this.lhs.function.subs( Eq.distribute.lhs.limits[0][1].args[1][1]) Eq << Eq[-1].as_Or() Eq << Eq[-1].subs(Eq.sj_definition_reversed) Eq.sj_greater_than_1 = greater_than.apply(Eq[-1]) Eq.distribute = Eq.distribute.subs(Eq.sj_definition_reversed) Eq << Eq.sj_greater_than_1.lhs.assertion() Eq.sj_less_than_1, Eq.inequality_ab = Eq[-1].split() (a, *_), (b, *_) = Eq.inequality_ab.limits Eq << sets.equality.imply.forall_equality.nonoverlapping.apply( Eq[0].abs(), excludes=Eq.inequality_ab.variables_set) Eq << Eq[-1].subs(k, a) Eq << Eq[-1].subs(Eq[-1].variable, b) Eq << (Eq.inequality_ab & Eq[-1]) Eq.distribute_ab = Eq[-1].this.function.distribute() Eq.j_equality, _ = sj.assertion().split() Eq.i_domain = ForAll[a:sj](Contains(a, Interval(0, n - 1, integer=True)), plausible=True) Eq << Eq.i_domain.simplify() Eq.sj_element_contains = ForAll[b:sj](Contains( b, Interval(0, n - 1, integer=True)), plausible=True) Eq << Eq.sj_element_contains.simplify() Eq << Eq.i_domain.apply(sets.contains.imply.equality.union) Eq << Eq.distribute_ab.subs(Eq[-1]) Eq << (Eq[-1] & Eq.sj_element_contains) Eq << Eq.j_equality.limits_subs(k, a).reversed Eq << Eq[-2].subs(Eq[-1]) Eq << Eq.j_equality.limits_subs(k, b).reversed Eq << Eq[-1].subs(Eq[-2]) Eq << Eq.sj_less_than_1.subs(Eq.sj_greater_than_1) Eq << sets.equality.imply.contains.apply(Eq[-1], var=k) Eq.index_domain = Eq[-1].subs(Eq.crossproduct.reversed) Eq << Eq.j_equality.subs(k, Eq.index_domain.lhs).split() Eq <<= Eq[-2] & Eq.index_domain Eq << Eq[-1].reversed Eq << Subset(sj, Eq[1].rhs, plausible=True) Eq <<= Eq[-1] & Eq.index_domain
def apply(given): assert given.is_Equality A, B = given.args assert A.is_set and B.is_set return Subset(A, B, given=given)
def prove(Eq): n = Symbol.n(integer=True, positive=True) u = Symbol.u(domain=Interval(0, n, integer=True)) v = Symbol.v(domain=Interval(0, n, integer=True)) Eq << apply(n, u, v) w, i, j = Eq[0].lhs.args Q = Eq[2].lhs.base Eq.x_slice_last, Eq.x_slice_domain = sets.imply.conditionset.apply( Q[u]).split() Eq << Eq.x_slice_domain.apply( discrete.combinatorics.permutation.index.equality, v) Eq.h_domain, Eq.x_h_equality = Eq[-1].split() hv = Eq.x_h_equality.function.lhs.indices[0] Eq << algebre.matrix.elementary.swap.invariant.permutation.apply(n + 1, w=w) Eq << Subset(Eq[-2].limits[0][1], Eq[-1].rhs, plausible=True) Eq << sets.subset.forall.imply.forall.apply(Eq[-1], Eq[-2]) Eq << Eq[-1].subs(Eq[-1].rhs.this.definition) Eq << Eq[-1].subs(i, n) Eq << Eq[-1].subs(j, hv) k = Eq[-1].function.lhs.function.arg.args[0].indices[-1] Eq.Xv_definition = Eq[1].subs(j, v) Eq << Eq.Xv_definition[k].set.union_comprehension((k, 0, n)) Eq.x_n1_set_comprehension = Eq[-2].subs(Eq[-1].reversed) Eq << Eq.Xv_definition[n] Eq << Eq[0].subs(i, n).subs(j, hv)[n] Eq << Eq[-2].this.rhs.subs(Eq[-1]) Eq << Eq[-1].this.rhs.expand() Eq << Eq[-1].subs(Eq.x_h_equality) Eq << Eq[-1].this.function.as_Or() Eq << (Eq[-1] & Eq.h_domain).split() Eq <<= Eq.x_n1_set_comprehension & Eq[-1] Eq.Xv_in_Qv, Eq.x_eq_swap_Xv = Eq[3].split() Eq << Eq.Xv_in_Qv.definition Eq.indexu_eq_indexu = Eq.x_eq_swap_Xv.function.rhs.args[0].indices[ 1].this.subs(Eq.Xv_definition) Eq.indexu_eq_indexv = Eq.x_slice_domain.apply( discrete.combinatorics.permutation.index.swap, u, v, w=w) Eq.indexu_contains, Eq.x_indexu_equality = Eq.x_slice_domain.apply( discrete.combinatorics.permutation.index.equality, u).split() Eq.equality_of_indexu_and_n = Eq.x_indexu_equality + Eq.x_slice_last.reversed i = Symbol.i(domain=Interval(0, n, integer=True)) j = Symbol.j(domain=Interval(0, n, integer=True)) Eq << Eq.x_slice_domain.apply( discrete.combinatorics.permutation.index.kronecker_delta.indexOf, i, j) x = Eq[-1].variable.base Eq << Eq[-1].subs(i, x[n]).split() Eq << Eq[-2].subs(Eq.x_slice_last) m = Symbol.m(domain=Interval(0, n, integer=True)) Eq.indexOf_indexed = Eq.x_slice_domain.apply( discrete.combinatorics.permutation.index.indexOf_indexed, j=m) Eq << Eq.indexOf_indexed.subs(m, n) Eq << Eq[-2].subs(Eq[-1]) Eq << Eq[-1].subs(j, Eq.equality_of_indexu_and_n.function.lhs).split() Eq << Eq[-2].subs(Eq.x_indexu_equality) Eq << Eq.indexOf_indexed.subs( m, Eq.equality_of_indexu_and_n.function.lhs.indices[0]).split() Eq <<= Eq.indexu_contains & Eq[-2] Eq << Eq[-3].subs(Eq[-1]) Eq << Eq[-1].subs(Eq.equality_of_indexu_and_n) Eq << Eq[-1].this.function.lhs.as_Piecewise() Eq << Eq[-1].this.function.as_Or() Eq << Eq.indexu_eq_indexv.subs(Eq[-1].reversed) Eq << Eq.indexu_eq_indexu.subs(Eq[-1]) Eq << Eq.x_eq_swap_Xv.subs(Eq[-1]) Eq << Eq[-1].subs(Eq.Xv_definition) Eq << algebre.matrix.elementary.swap.multiply.left.apply( x[:n + 1], i=n, j=Eq.h_domain.lhs, w=w) Eq << Eq[-2].subs(Eq[-1])