├── __init__.py
├── data
├── __init__.py
├── prompts
│ ├── p2_question.md
│ ├── p3_question.md
│ ├── p21_question.md
│ ├── p41_question.md
│ ├── p43_question.md
│ ├── p12_question.md
│ ├── p31_question.md
│ ├── p23_question.md
│ ├── p24_question.md
│ ├── p42_question.md
│ ├── p53_question.md
│ ├── p2_answer.md
│ ├── p34_question.md
│ ├── p22_question.md
│ ├── p32_question.md
│ ├── p52_question.md
│ ├── p13_question.md
│ ├── p1_question.md
│ ├── p11_question.md
│ ├── p4_question.md
│ ├── p14_question.md
│ ├── p44_question.md
│ ├── p51_question.md
│ ├── p33_question.md
│ ├── p54_question.md
│ ├── p43_answer.md
│ ├── p4_answer.md
│ ├── p21_answer.md
│ ├── p22_answer.md
│ ├── p3_answer.md
│ ├── p24_answer.md
│ ├── p13_answer.md
│ ├── p42_answer.md
│ ├── p23_answer.md
│ ├── p33_answer.md
│ ├── p32_answer.md
│ ├── p34_answer.md
│ ├── p51_answer.md
│ ├── p54_answer.md
│ ├── p12_answer.md
│ ├── p44_answer.md
│ ├── p14_answer.md
│ ├── p53_answer.md
│ ├── p31_answer.md
│ ├── p52_answer.md
│ ├── p41_answer.md
│ ├── p11_answer.md
│ └── p1_answer.md
├── .DS_Store
├── problems
│ ├── p2_n_less_than_m_to_the_n.md
│ ├── p28_ramanujans_infinite_nested_roots.md
│ ├── p55_hermitian_matrix_has_real_eigenvalues.md
│ ├── p3_fundamental_theorem_of_algebra.md
│ ├── p41_banach-tarski_paradox.md
│ ├── p21_one_plus_perfect_power_is_not_power_of_two.md
│ ├── p27_power_of_sum_modulo_prime.md
│ ├── p58_real_numbers_form_vector_space.md
│ ├── p43_convex_set_is_contractible.md
│ ├── p50_union_of_topologies_is_not_necessarily_topology.md
│ ├── p25_irrationality_of_logarithm.md
│ ├── p26_lagranges_theorem_number_theory.md
│ ├── p29_tamrefs_last_theorem.md
│ ├── p48_sequence_lemma.md
│ ├── p6_bhaskaras_lemma.md
│ ├── p17_quotient_structure_of_group_is_group.md
│ ├── p8_factorisation_of_z^n+1.md
│ ├── p24_hurwitzs_theorem.md
│ ├── p12_cayleys_representation_theorem_general_case.md
│ ├── p18_schur-zassenhaus_theorem.md
│ ├── p5_real_star_algebra_is_commutative.md
│ ├── p23_eulers_theorem.md
│ ├── p34_hat-check_problem.md
│ ├── p19_self-inverse_elements_commute_iff_product_is_self-inverse.md
│ ├── p42_characterization_of_analytic_basis_by_local_bases.md
│ ├── p15_group_has_latin_square_property.md
│ ├── p53_existence_of_minimal_polynomial_for_square_matrix_over_field.md
│ ├── p20_structure_induced_by_group_operation_is_group.md
│ ├── p32_chebyshevs_inequality.md
│ ├── p60_unique_representation_by_ordered_basis.md
│ ├── p22_chinese_remainder_theorem.md
│ ├── p30_sum_of_reciprocals_of_divisors_equals_abundancy_index.md
│ ├── p40_total_probability_theorem.md
│ ├── p35_markovs_inequality.md
│ ├── p37_mean_number_of_elements_fixed_by_self-map.md
│ ├── p16_invertible_elements_of_monoid_form_subgroup_of_cancellable_elements.md
│ ├── p36_function_of_discrete_random_variable.md
│ ├── p52_condition_for_planes_to_be_parallel.md
│ ├── p57_rank_and_nullity_of_transpose.md
│ ├── p14_existence_of_unique_subgroup_generated_by_subset.md
│ ├── p10_cauchys_mean_theorem.md
│ ├── p13_complement_of_relation_compatible_with_group_is_compatible.md
│ ├── p9_lagranges_identity.md
│ ├── p11_b-algebra_induces_group.md
│ ├── p31_bernoullis_theorem.md
│ ├── p39_weak_law_of_large_numbers.md
│ ├── p1_minkowskis_inequality_for_lebesgue_spaces.md
│ ├── p38_second_borel-cantelli_lemma.md
│ ├── p4_nicomachuss_theorem.md
│ ├── p59_trace_in_terms_of_orthonormal_basis.md
│ ├── p56_invertible_matrix_corresponds_with_change_of_basis.md
│ ├── p7_vector_cross_product_satisfies_jacobi_identity.md
│ ├── p44_existence_and_uniqueness_of_generated_topology.md
│ ├── p51_characterization_of_left_null_space.md
│ ├── p33_conditional_probability_defines_probability_space.md
│ ├── p47_relationship_between_limit_inferior_and_lower_limit.md
│ ├── p46_neighborhood_in_topological_subspace.md
│ ├── p45_filter_on_product_of_hausdorff_spaces_converges_iff_projections_converge.md
│ ├── p54_floquets_theorem.md
│ └── p49_topology_defined_by_closed_sets.md
├── problems_html
│ ├── p55_hermitian_matrix_has_real_eigenvalues.html
│ ├── p58_real_numbers_form_vector_space.html
│ ├── p41_banach-tarski_paradox.html
│ ├── p28_ramanujans_infinite_nested_roots.html
│ ├── p3_fundamental_theorem_of_algebra.html
│ ├── p21_one_plus_perfect_power_is_not_power_of_two.html
│ ├── p2_n_less_than_m_to_the_n.html
│ ├── p27_power_of_sum_modulo_prime.html
│ ├── p34_hat-check_problem.html
│ ├── p29_tamrefs_last_theorem.html
│ ├── p17_quotient_structure_of_group_is_group.html
│ ├── p25_irrationality_of_logarithm.html
│ ├── p50_union_of_topologies_is_not_necessarily_topology.html
│ ├── p43_convex_set_is_contractible.html
│ ├── p24_hurwitzs_theorem.html
│ ├── p8_factorisation_of_z^n+1.html
│ ├── p6_bhaskaras_lemma.html
│ ├── p23_eulers_theorem.html
│ ├── p48_sequence_lemma.html
│ ├── p5_real_star_algebra_is_commutative.html
│ ├── p12_cayleys_representation_theorem_general_case.html
│ ├── p26_lagranges_theorem_number_theory.html
│ ├── p31_bernoullis_theorem.html
│ ├── p19_self-inverse_elements_commute_iff_product_is_self-inverse.html
│ ├── p15_group_has_latin_square_property.html
│ ├── p14_existence_of_unique_subgroup_generated_by_subset.html
│ ├── p30_sum_of_reciprocals_of_divisors_equals_abundancy_index.html
│ ├── p36_function_of_discrete_random_variable.html
│ ├── p20_structure_induced_by_group_operation_is_group.html
│ ├── p60_unique_representation_by_ordered_basis.html
│ ├── p53_existence_of_minimal_polynomial_for_square_matrix_over_field.html
│ ├── p18_schur-zassenhaus_theorem.html
│ ├── p37_mean_number_of_elements_fixed_by_self-map.html
│ ├── p16_invertible_elements_of_monoid_form_subgroup_of_cancellable_elements.html
│ ├── p40_total_probability_theorem.html
│ ├── p42_characterization_of_analytic_basis_by_local_bases.html
│ ├── p10_cauchys_mean_theorem.html
│ ├── p35_markovs_inequality.html
│ ├── p7_vector_cross_product_satisfies_jacobi_identity.html
│ ├── p38_second_borel-cantelli_lemma.html
│ ├── p52_condition_for_planes_to_be_parallel.html
│ ├── p32_chebyshevs_inequality.html
│ ├── p9_lagranges_identity.html
│ ├── p39_weak_law_of_large_numbers.html
│ ├── p57_rank_and_nullity_of_transpose.html
│ ├── p22_chinese_remainder_theorem.html
│ ├── p13_complement_of_relation_compatible_with_group_is_compatible.html
│ ├── p11_b-algebra_induces_group.html
│ ├── p59_trace_in_terms_of_orthonormal_basis.html
│ ├── p51_characterization_of_left_null_space.html
│ ├── p47_relationship_between_limit_inferior_and_lower_limit.html
│ ├── p1_minkowskis_inequality_for_lebesgue_spaces.html
│ ├── p4_nicomachuss_theorem.html
│ ├── p33_conditional_probability_defines_probability_space.html
│ ├── p54_floquets_theorem.html
│ ├── p44_existence_and_uniqueness_of_generated_topology.html
│ ├── p45_filter_on_product_of_hausdorff_spaces_converges_iff_projections_converge.html
│ ├── p56_invertible_matrix_corresponds_with_change_of_basis.html
│ ├── p46_neighborhood_in_topological_subspace.html
│ └── p49_topology_defined_by_closed_sets.html
├── render_md_into_html.py
└── data_utils
│ ├── clean_up_markdown.py
│ ├── load_problems.py
│ └── load_prompts.py
├── .DS_Store
├── interface1.png
├── questions_to_ask.txt
├── LICENSE
├── .gitignore
├── constants.py
├── README.md
└── model_generate.py
/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/collinskatie/checkmate/HEAD/.DS_Store
--------------------------------------------------------------------------------
/data/prompts/p2_question.md:
--------------------------------------------------------------------------------
1 | $\forall m, n \in \mathbb{Z}_{>0}: m > 1 \to n < m^n$
--------------------------------------------------------------------------------
/data/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/collinskatie/checkmate/HEAD/data/.DS_Store
--------------------------------------------------------------------------------
/interface1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/collinskatie/checkmate/HEAD/interface1.png
--------------------------------------------------------------------------------
/data/prompts/p3_question.md:
--------------------------------------------------------------------------------
1 | Every non-constant polynomial with coefficients in $\mathbb{C}$ has a root in $\mathbb{C}$.
--------------------------------------------------------------------------------
/data/problems/p2_n_less_than_m_to_the_n.md:
--------------------------------------------------------------------------------
1 | Show that for non-zero natural numbers $m, n$, if $m > 1$, then $n < m^n$.
2 |
--------------------------------------------------------------------------------
/data/prompts/p21_question.md:
--------------------------------------------------------------------------------
1 | The equation:
2 | $$1 + a^n = 2^m$$
3 |
4 | has no solutions in the integers for $n, m > 1$.
--------------------------------------------------------------------------------
/data/problems/p28_ramanujans_infinite_nested_roots.md:
--------------------------------------------------------------------------------
1 | Show that $3 = \sqrt {1 + 2 \sqrt {1 + 3 \sqrt { 1 + \cdots} } }.$
2 |
--------------------------------------------------------------------------------
/data/prompts/p41_question.md:
--------------------------------------------------------------------------------
1 | The unit ball $\mathbb{D}^3 \subset \mathbb{R}^3$ is equidecomposable to the union of two unit balls.
--------------------------------------------------------------------------------
/data/problems/p55_hermitian_matrix_has_real_eigenvalues.md:
--------------------------------------------------------------------------------
1 | Prove that every Hermitian matrix has eigenvalues which are all real numbers.
--------------------------------------------------------------------------------
/data/problems/p3_fundamental_theorem_of_algebra.md:
--------------------------------------------------------------------------------
1 | Show that every non-constant polynomial with coefficients in $\mathbb{C}$ has a root in $\mathbb{C}$.
2 |
--------------------------------------------------------------------------------
/data/problems/p41_banach-tarski_paradox.md:
--------------------------------------------------------------------------------
1 | Prove that the unit ball $\mathbb{D}^3 \subset \mathbb{R}^3$ is equidecomposable to the union of two unit balls.
--------------------------------------------------------------------------------
/data/problems_html/p55_hermitian_matrix_has_real_eigenvalues.html:
--------------------------------------------------------------------------------
1 |
Prove that every Hermitian matrix has eigenvalues which are all real numbers.
2 |
--------------------------------------------------------------------------------
/data/problems/p21_one_plus_perfect_power_is_not_power_of_two.md:
--------------------------------------------------------------------------------
1 | Show that the equation:
2 | $$1 + a^n = 2^m$$
3 |
4 | has no solutions in the integers for $n, m > 1$.
5 |
--------------------------------------------------------------------------------
/data/problems/p27_power_of_sum_modulo_prime.md:
--------------------------------------------------------------------------------
1 | Let $p$ be a prime number.
2 |
3 | Prove that
4 | $$\left( {a + b}\right)^p \equiv a^p + b^p \ (\mathrm{mod \ } p).$$
5 |
--------------------------------------------------------------------------------
/data/problems/p58_real_numbers_form_vector_space.md:
--------------------------------------------------------------------------------
1 | Show that the set of real numbers $\mathbb{R}$, with the operations of addition and multiplication, forms a vector space.
--------------------------------------------------------------------------------
/data/prompts/p43_question.md:
--------------------------------------------------------------------------------
1 | Let $V$ be a topological vector space over $\mathbb{R}$ or $\mathbb{C}$.
2 |
3 | Let $A\subset V$ be a convex subset.
4 |
5 | Then $A$ is contractible.
--------------------------------------------------------------------------------
/data/problems/p43_convex_set_is_contractible.md:
--------------------------------------------------------------------------------
1 | Let $V$ be a topological vector space over $\mathbb{R}$ or $\mathbb{C}$.
2 |
3 | Let $A\subset V$ be a convex subset.
4 |
5 | Prove that $A$ is contractible.
--------------------------------------------------------------------------------
/data/problems/p50_union_of_topologies_is_not_necessarily_topology.md:
--------------------------------------------------------------------------------
1 | Let $\tau_1$ and $\tau_2$ be topologies on a set $S$.
2 |
3 | Show that $\tau_1 \cup \tau_2$ is not necessarily also a topology on $S$.
--------------------------------------------------------------------------------
/data/problems/p25_irrationality_of_logarithm.md:
--------------------------------------------------------------------------------
1 |
2 | Let $a, b \in \mathbb{N}_{>0}$ such that there exists no $m, n \in \mathbb{N}_{>0}$ such that $a^m = b^n$.
3 |
4 | Prove that $\log_b a$ is irrational.
5 |
--------------------------------------------------------------------------------
/data/problems/p26_lagranges_theorem_number_theory.md:
--------------------------------------------------------------------------------
1 | Let $f$ be a polynomial in one variable of degree $n$ over $\mathbb{Z}_p$ for some prime $p$.
2 |
3 | Prove that $f$ has at most $n$ roots in $\mathbb{Z}_p$.
4 |
--------------------------------------------------------------------------------
/data/prompts/p12_question.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \cdot}\right)$ be a group.
2 |
3 | Then there exists a permutation group $P$ on some set $S$ such that:
4 |
5 | $$G \cong P$$
6 |
7 | That is, such that $G$ is isomorphic to $P$.
--------------------------------------------------------------------------------
/data/prompts/p31_question.md:
--------------------------------------------------------------------------------
1 | Let the probability of the occurrence of an event be $p$.
2 |
3 | Let $n$ independent trials be made, with $k$ successes.
4 |
5 |
6 | Then:
7 | $$\mathrm{} \lim_{n \to \infty} \frac{k}{n} = p$$
--------------------------------------------------------------------------------
/data/problems/p29_tamrefs_last_theorem.md:
--------------------------------------------------------------------------------
1 | Show that the Diophantine equation:
2 | $$n^x + n^y = n^z$$
3 | has exactly one form of solutions in integers, namely:
4 |
5 | $$2^x + 2^x = 2^{x + 1}$$
6 | for all $x \in \mathbb{Z}$.
7 |
--------------------------------------------------------------------------------
/data/prompts/p23_question.md:
--------------------------------------------------------------------------------
1 | Let $a, m \in \mathbb{Z}$ be coprime integers: $a \perp m$.
2 |
3 | Let $\phi \left(m\right)$ be the Euler $\phi$ function of $m$.
4 |
5 |
6 | Then:
7 | $$a^{\phi \left(m\right)} \equiv 1 \mathrm{\ mod \ } m$$
--------------------------------------------------------------------------------
/data/prompts/p24_question.md:
--------------------------------------------------------------------------------
1 | Let $\xi$ be an irrational number.
2 |
3 | Then there are infinitely many relatively prime integers $p, q \in \mathbb{Z}$ such that:
4 |
5 | $$\left| {\xi - \dfrac{p}{q}}\right| < \dfrac {1}{\sqrt{5} \, q^2}$$
--------------------------------------------------------------------------------
/data/problems/p48_sequence_lemma.md:
--------------------------------------------------------------------------------
1 | Let $A$ be a subset of a topological space $X$.
2 |
3 | Show that if there is a sequence of points of $A$ converging to $x$, then $x \in \bar A$.
4 |
5 | Also show that the converse holds if $X$ is first-countable.
--------------------------------------------------------------------------------
/data/problems/p6_bhaskaras_lemma.md:
--------------------------------------------------------------------------------
1 | Let $m \in \mathbb{Z}$ be an integer.
2 |
3 |
4 | For $k \ne 0$ show that if $N x^2 + k = y^2 $, then $N \left( {\dfrac {m x + y} {k}}\right)^2 + \dfrac {m^2 - N}{k} = \left( {\dfrac {m y + N x}{k}}\right)^2$.
5 |
--------------------------------------------------------------------------------
/data/problems/p17_quotient_structure_of_group_is_group.md:
--------------------------------------------------------------------------------
1 | Let $\mathcal{R}$ be a congruence relation on a group $\left( {G, \circ}\right)$.
2 |
3 |
4 | Show that the quotient structure $\left( {G / \mathcal{R}, \circ_\mathcal{R}}\right)$ is a group.
5 |
--------------------------------------------------------------------------------
/data/problems/p8_factorisation_of_z^n+1.md:
--------------------------------------------------------------------------------
1 | Let $n \in \mathbb{Z}_{>0}$ be a (strictly) positive integer.
2 |
3 | Then show that
4 |
5 | $$z^n + 1 = \mathrm{} \prod_{k = 0}^{n - 1} \left( {z - \exp \dfrac {\left( {2 k + 1}\right) i \pi} {n}}\right)$$
6 |
--------------------------------------------------------------------------------
/data/problems/p24_hurwitzs_theorem.md:
--------------------------------------------------------------------------------
1 | Let $\xi$ be an irrational number.
2 |
3 | Then show there are infinitely many relatively prime integers $p, q \in \mathbb{N}_{>0}$ such that:
4 |
5 | $$\left| {\xi - \dfrac{p}{q}}\right| < \dfrac {1}{\sqrt{5} q^2}$$
6 |
--------------------------------------------------------------------------------
/data/problems/p12_cayleys_representation_theorem_general_case.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \cdot}\right)$ be a group.
2 |
3 |
4 | Show that there exists a permutation group $P$ on some set $S$ such that:
5 |
6 | $$G \cong P,$$
7 |
8 | that is, $G$ is isomorphic to $P$.
9 |
--------------------------------------------------------------------------------
/data/problems/p18_schur-zassenhaus_theorem.md:
--------------------------------------------------------------------------------
1 | Let $G$ be a finite group and $N$ be a normal subgroup in $G$.
2 |
3 | Let $N$ also be a Hall subgroup of $G$.
4 |
5 |
6 | Show that a complement $H$ of $N$ exists and that $G$ is the semidirect product of $N$ and $H$.
7 |
--------------------------------------------------------------------------------
/data/problems/p5_real_star_algebra_is_commutative.md:
--------------------------------------------------------------------------------
1 | Let $A = \left(A_F, \oplus\right)$ be a real $*$-algebra whose conjugation is denoted as $*$.
2 |
3 | Prove that $\forall a, b \in A: a \oplus b = b \oplus a$.
4 |
5 | That is, a real $*$-algebra is commutative.
6 |
--------------------------------------------------------------------------------
/data/problems/p23_eulers_theorem.md:
--------------------------------------------------------------------------------
1 | Let $a, m \in \mathbb{Z}$ be coprime integers, denoted as $a \perp m$.
2 |
3 | Let $\phi$ be the Euler totient function.
4 |
5 |
6 | Show that the following equation holds:
7 | $$a^{\phi \left(m\right)} \equiv 1 \mathrm{\ mod \ } m$$
8 |
--------------------------------------------------------------------------------
/data/problems/p34_hat-check_problem.md:
--------------------------------------------------------------------------------
1 | A hat-check girl completely loses track of which of $n$ hats belong to which owners, and hands them back at random to their $n$ owners as the latter leave.
2 |
3 | What is the probability $p_n$ that nobody receives their own hat back?
4 |
--------------------------------------------------------------------------------
/data/prompts/p42_question.md:
--------------------------------------------------------------------------------
1 | Let $T = \left({S, \tau}\right)$ be a topological space.
2 |
3 | Let $P$ be a set of subsets of $S$ such that
4 | $$P \subseteq \tau$$
5 | and
6 | $for all $p \in S$: there exists local basis $B$ at $p: B \subseteq P$
7 |
8 |
9 | Then $P$ is basis of $T$.
--------------------------------------------------------------------------------
/data/problems/p19_self-inverse_elements_commute_iff_product_is_self-inverse.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \circ}\right)$ be a group.
2 |
3 | Let $x, y \in \left( {G, \circ}\right)$, such that $x$ and $y$ are self-inverse.
4 |
5 |
6 | Show that $x$ and $y$ commute iff $x \circ y$ is also self-inverse.
7 |
--------------------------------------------------------------------------------
/data/prompts/p53_question.md:
--------------------------------------------------------------------------------
1 | Let $K$ be a field.
2 |
3 | Let $n$ be a natural number.
4 |
5 | Let $K^{n \times n}$ be the set of $n \times n$ matrices over $K$.
6 |
7 | Let $A \in K^{n \times n}$.
8 |
9 |
10 | Then the minimal polynomial of $A$ exists and has degree at most $n^2$.
--------------------------------------------------------------------------------
/data/prompts/p2_answer.md:
--------------------------------------------------------------------------------
1 | $$ n = \underbrace {1 + 1 + \cdots + 1}_{\text {$n$ times} }$$
2 | $$ < 1 + m + m^2 + \cdots + m^{n - 1} \text{\quad as } m > 1$$
3 | $$ = \frac {m^n - 1} {m - 1} \text{\quad Sum of Geometric Sequence}$$
4 | $$ \leq m^n - 1 \text{\quad as } m - 1 \geq 1$$
5 | $$ < m^n$$
6 |
7 | $\blacksquare$
--------------------------------------------------------------------------------
/data/prompts/p34_question.md:
--------------------------------------------------------------------------------
1 | The traditional wording of the question is as follows.
2 |
3 | A hat-check girl completely loses track of which of $n$ hats belong to which owners, and hands them back at random to their $n$ owners as the latter leave.
4 |
5 | What is the probability $p_n$ that nobody receives their own hat back?
--------------------------------------------------------------------------------
/data/problems/p42_characterization_of_analytic_basis_by_local_bases.md:
--------------------------------------------------------------------------------
1 | Let $T = \left({S, \tau}\right)$ be a topological space.
2 |
3 | Let $P$ be a set of subsets of $S$ such that
4 | $$P \subseteq \tau$$
5 | and
6 |
7 | for all $p \in S$: there exists local basis $B$ at $p: B \subseteq P$.
8 |
9 | Show that $P$ is basis of $T$.
--------------------------------------------------------------------------------
/data/problems_html/p58_real_numbers_form_vector_space.html:
--------------------------------------------------------------------------------
1 | Show that the set of real numbers
, with the operations of addition and multiplication, forms a vector space.
2 |
--------------------------------------------------------------------------------
/data/problems/p15_group_has_latin_square_property.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \circ}\right)$ be a group.
2 |
3 |
4 | Show that $G$ satisfies the Latin square property.
5 |
6 | That is, for all $a, b \in G$, there exists a unique $g \in G$ such that $a \circ g = b$.
7 |
8 | Similarly, there exists a unique $h \in G$ such that $h \circ a = b$.
9 |
--------------------------------------------------------------------------------
/data/problems/p53_existence_of_minimal_polynomial_for_square_matrix_over_field.md:
--------------------------------------------------------------------------------
1 | Let $K$ be a field.
2 |
3 | Let $n$ be a natural number.
4 |
5 | Let $K^{n \times n}$ be the set of $n \times n$ matrices over $K$.
6 |
7 | Let $A \in K^{n \times n}$.
8 |
9 | Prove that the minimal polynomial of $A$ exists and has degree at most $n^2$.
--------------------------------------------------------------------------------
/data/problems/p20_structure_induced_by_group_operation_is_group.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \circ}\right)$ be a group whose identity is $e$.
2 |
3 | Let $S$ be a set.
4 |
5 | Let $\left( {G^S, \oplus}\right)$ be the structure on $G^S$ induced by $\circ$ by pointwise operation.
6 |
7 |
8 | Then show that $\left( {G^S, \oplus}\right)$ is a group.
9 |
--------------------------------------------------------------------------------
/data/problems/p32_chebyshevs_inequality.md:
--------------------------------------------------------------------------------
1 | Let $X$ be a random variable. Assume $\mathsf{E} (X) = \mu$ for some $\mu \in \mathbb{R}$ and $\mathsf{var} (X) = \sigma^2$ for some $\sigma^2 \in \mathbb{R}_{> 0}$.
2 |
3 |
4 | Show that for all $k > 0$:
5 |
6 | $$\Pr \left({\left| {X - \mu}\right| \geq k \sigma}\right) \leq \dfrac {1}{k^2}.$$
7 |
--------------------------------------------------------------------------------
/data/problems/p60_unique_representation_by_ordered_basis.md:
--------------------------------------------------------------------------------
1 | Let $G$ be a unitary $R$-module.
2 |
3 |
4 | Show that $\langle{a_n}\rangle$ is an ordered basis of $G$ if and only if:
5 |
6 | For every $x \in G$ there exists one and only one sequence $\langle {\lambda_n}\rangle$ of scalars such that $\mathrm{} x = \sum_{k = 1}^n \lambda_k a_k$.
--------------------------------------------------------------------------------
/data/prompts/p22_question.md:
--------------------------------------------------------------------------------
1 | Let $a, b \in \mathbb{Z}$.
2 |
3 | Let $r$ and $s$ be coprime integers.
4 |
5 |
6 | Then:
7 |
8 | $a \equiv b \mathrm{\ mod \ } {r s}$ iff $a \equiv b \mathrm{\ mod \ } r$ and $a \equiv b \mathrm{\ mod \ } s$
9 |
10 | where $a \equiv b \mathrm{\ mod \ } r$ denotes that $a$ is congruent modulo $r$ to $b$.
--------------------------------------------------------------------------------
/data/problems/p22_chinese_remainder_theorem.md:
--------------------------------------------------------------------------------
1 | Let $a, b \in \mathbb{Z}$.
2 |
3 | Let $r$ and $s$ be coprime integers.
4 |
5 |
6 | Then show that $a \equiv b \mathrm{\ mod \ } {r s}$ iff $a \equiv b \mathrm{\ mod \ } r$ and $a \equiv b \mathrm{\ mod \ } s$, where $a \equiv b \mathrm{\ mod \ } r$ denotes that $a$ is congruent modulo $r$ to $b$.
7 |
--------------------------------------------------------------------------------
/data/prompts/p32_question.md:
--------------------------------------------------------------------------------
1 | Let $X$ be a random variable.
2 |
3 | Let $\mathsf{E} (X) = \mu$ for some $\mu \in \mathbb{R}$.
4 |
5 | Let $\mathsf{var} (X) = \sigma^2$ for some $\sigma^2 \in \mathbb{R}_{> 0}$.
6 |
7 |
8 | Then, for all $k > 0$:
9 |
10 | $$\Pr \left({\left| {X - \mu}\right| \geq k \sigma}\right) \leq \dfrac {1}{k^2}$$
--------------------------------------------------------------------------------
/data/problems/p30_sum_of_reciprocals_of_divisors_equals_abundancy_index.md:
--------------------------------------------------------------------------------
1 | Let $n$ be a positive integer.
2 |
3 | Let ${\sigma_1} (n)$ denote the divisor sum function of $n$.
4 |
5 |
6 | Show that
7 | $$\mathrm{} \sum_{d \backslash n} \frac {1}{d} = \frac {{\sigma_1} (n)} {n}$$
8 | where $\dfrac {{\sigma_1} (n)} {n}$ is the abundancy index of $n$.
9 |
--------------------------------------------------------------------------------
/data/prompts/p52_question.md:
--------------------------------------------------------------------------------
1 | Let $P: \alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \gamma$ be a plane in $\mathbb{R}^3$.
2 |
3 |
4 | Then the plane $P'$ is parallel to $P$ {{iff}} there is a $\gamma' \in \mathbb{R}$ such that:
5 | $$P' = \left\{\left({x_1, x_2, x_3}\right) \in \mathbb{R}^3 : \alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \gamma' \right\}$$
--------------------------------------------------------------------------------
/data/problems/p40_total_probability_theorem.md:
--------------------------------------------------------------------------------
1 | Let $\left( {\Omega, \Sigma, \Pr}\right)$ be a probability space. Let $\{B_1, B_2, \ldots\}$ be a partition of $\Omega$ such that $\forall i: \Pr \left({B_i}\right) > 0$.
2 |
3 | Show that
4 | $$\mathrm{} \forall A \in \Sigma: \Pr \left(A\right) = \sum_i \Pr \left(A\mid {B_i}\right) \Pr \left({B_i}\right).$$
5 |
--------------------------------------------------------------------------------
/data/problems/p35_markovs_inequality.md:
--------------------------------------------------------------------------------
1 |
2 | Let $\left( {X, \Sigma, \mu}\right)$ be a measure space. Let $A \in \Sigma$.
3 |
4 | Let $f : A \to \overline{\mathbb{R}}$ be an $A$-measurable function.
5 |
6 |
7 | Show that $\mathrm{} \mu \left({ \{x \in A: \mid{f (x)} \mid \geq t\} }\right) \leq \frac {1} {t} \int_A \left| f\right| \mathrm{d} \mu$
8 | for any $t >0$.
9 |
--------------------------------------------------------------------------------
/data/problems/p37_mean_number_of_elements_fixed_by_self-map.md:
--------------------------------------------------------------------------------
1 | Let $n \in \mathbb{N}_{>0}$ be a strictly positive integer. Let $S$ be a finite set of cardinality $n$.
2 |
3 | Let $S^S$ be the set of all mappings from $S$ to itself. Let $\mu (n)$ denote the arithmetic mean of the number of fixed points of all the mappings in $S^S$.
4 |
5 |
6 | Then:
7 | $$\mu (n) = 1$$
8 |
--------------------------------------------------------------------------------
/data/problems_html/p41_banach-tarski_paradox.html:
--------------------------------------------------------------------------------
1 | Prove that the unit ball
is equidecomposable to the union of two unit balls.
2 |
--------------------------------------------------------------------------------
/data/problems/p16_invertible_elements_of_monoid_form_subgroup_of_cancellable_elements.md:
--------------------------------------------------------------------------------
1 | Let $\left( {S, \circ}\right)$ be an monoid whose identity is $e_S$.
2 |
3 | Let $C$ be the set of all cancellable elements of $S$.
4 |
5 | Let $T$ be the set of all invertible elements of $S$.
6 |
7 |
8 | Show that $\left( {T, \circ}\right)$ is a subgroup of $\left( {C, \circ}\right)$.
9 |
--------------------------------------------------------------------------------
/data/problems/p36_function_of_discrete_random_variable.md:
--------------------------------------------------------------------------------
1 | Let $X$ be a discrete random variable on the probability space $\left({\Omega, \Sigma, \Pr}\right)$.
2 |
3 | Let $g: \mathbb{R} \to \mathbb{R}$ be any real function.
4 |
5 | Show that $Y = g (X)$, defined as
6 | $$\forall \omega \in \Omega: Y \left(\omega\right) = g (X \left(\omega\right)),$$
7 | is also a discrete random variable.
8 |
--------------------------------------------------------------------------------
/data/problems/p52_condition_for_planes_to_be_parallel.md:
--------------------------------------------------------------------------------
1 | Let $P: \alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \gamma$ be a plane in $\mathbb{R}^3$.
2 |
3 |
4 | Prove that the plane $P'$ is parallel to $P$ if and only if there is a $\gamma' \in \mathbb{R}$ such that:
5 | $$P' = \left\{\left({x_1, x_2, x_3}\right) \in \mathbb{R}^3 : \alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \gamma' \right\}$$
--------------------------------------------------------------------------------
/data/problems/p57_rank_and_nullity_of_transpose.md:
--------------------------------------------------------------------------------
1 | Let $G$ and $H$ be $n$-dimensional vector spaces over a field.
2 |
3 | Let $\mathcal{L} \left({G, H}\right)$ be the set of all linear transformations from $G$ to $H$.
4 |
5 | Let $u \in \mathcal{L} \left({G, H}\right)$.
6 |
7 | Let $u^t$ be the transpose of $u$.
8 |
9 | Prove that $u$ and $u^t$ have the same rank and nullity.
10 |
--------------------------------------------------------------------------------
/data/problems/p14_existence_of_unique_subgroup_generated_by_subset.md:
--------------------------------------------------------------------------------
1 |
2 | Let $\left( {G, \circ}\right)$ be a group. Let $S \subseteq G$.
3 |
4 |
5 | Show that the subgroup generated by $S$, which is defined to be the intersection of all of the subgroups of $G$ which contain the set $S$:
6 |
7 | $$\mathrm{} \langle S \rangle = \bigcap_i {H_i}: S \subseteq H_i \leq G,$$
8 |
9 | is unique.
10 |
--------------------------------------------------------------------------------
/data/problems_html/p28_ramanujans_infinite_nested_roots.html:
--------------------------------------------------------------------------------
1 | Show that 
2 |
--------------------------------------------------------------------------------
/data/prompts/p13_question.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \circ}\right)$ be a group.
2 |
3 | Let $\mathcal{R}$ be a relation on $G$.
4 |
5 | Let $\mathcal{R}$ be compatible with $\circ$.
6 |
7 | Let $\mathcal{Q} = \complement_{G \times G} \mathcal{R}$, so that:
8 | $$\forall a, b \in G: a \mathcal{Q} b \leftrightarrow \neg \left( {a \mathcal{R} b}\right)$$
9 |
10 | Then $\mathcal{Q}$ is a relation compatible with $\circ$.
11 |
--------------------------------------------------------------------------------
/data/prompts/p1_question.md:
--------------------------------------------------------------------------------
1 | Let $(X, \Sigma, \mu)$ be a measure space.
2 |
3 | Let $p \in [1 \ldots \infty]$.
4 |
5 | Let $f, g: X \to \mathbb{R}$ be $p$-integrable, that is, elements of Lebesgue $p$-space $\mathcal{L}^p(\mu)$.
6 |
7 | Then their pointwise sum $f + g: X \to \mathbb{R}$ is also $p$-integrable, and:
8 |
9 | $\|{f + g}\|_p \leq \|f\|_p + \|g\|_p $
10 |
11 | where $\| {\, \cdot \, }\|_p$ denotes the $p$-seminorm.
--------------------------------------------------------------------------------
/data/problems/p10_cauchys_mean_theorem.md:
--------------------------------------------------------------------------------
1 | Let $x_1, x_2, \ldots, x_n \in \mathbb{R}$ be real numbers which are all positive.
2 |
3 | Let $A_n$ be the arithmetic mean of $x_1, x_2, \ldots, x_n$.
4 |
5 | Let $G_n$ be the geometric mean of $x_1, x_2, \ldots, x_n$.
6 |
7 |
8 | Show that
9 | $$A_n \geq G_n$$
10 | with equality holding iff:
11 | $$\forall i, j \in \{1, 2, \ldots, n\}: x_i = x_j,$$
12 | that is, iff all terms are equal.
13 |
--------------------------------------------------------------------------------
/data/problems/p13_complement_of_relation_compatible_with_group_is_compatible.md:
--------------------------------------------------------------------------------
1 |
2 | Let $\left( {G, \circ}\right)$ be a group. Let $\mathcal{R}$ be a relation on $G$. Let $\mathcal{R}$ be compatible with $\circ$.
3 |
4 | Let $\mathcal{Q}$ be a relation defined such that:
5 | $$\forall a, b \in G: a \mathcal{Q} b \leftrightarrow \neg \left( {a \mathcal{R} b}\right)$$
6 |
7 |
8 | Show that $\mathcal{Q}$ is a relation compatible with $\circ$.
9 |
--------------------------------------------------------------------------------
/data/problems/p9_lagranges_identity.md:
--------------------------------------------------------------------------------
1 | Let $a_k, b_k$ be real or complex numbers. Show that the following identities hold:
2 |
3 | $$ \left( {\sum_{k = 1}^n {a_k}^2}\right) \left( {\sum_{k = 1}^n {b_k}^2}\right) - \left( {\sum_{k = 1}^n a_k b_k}\right)^2 = \sum_{i = 1}^{n - 1} \sum_{j = i + 1}^n \left( {a_i b_j - a_j b_i}\right)^2$$
4 |
5 | $$ = \frac {1} {2} \sum_{i = 1}^n \sum_{1 \leq j \leq n, j \ne i} \left( {a_i b_j - a_j b_i}\right)^2$$
6 |
--------------------------------------------------------------------------------
/data/problems_html/p3_fundamental_theorem_of_algebra.html:
--------------------------------------------------------------------------------
1 | Show that every non-constant polynomial with coefficients in
has a root in
.
2 |
--------------------------------------------------------------------------------
/data/prompts/p11_question.md:
--------------------------------------------------------------------------------
1 | Let $\left( {X, \circ}\right)$ be a $B$-algebra.
2 |
3 | Let $*$ be the binary operation on $X$ defined as:
4 |
5 | $$\forall a, b \in X: a * b := a \circ \left( {0 \circ b}\right)$$
6 |
7 | Then the algebraic structure $\left( {X, *}\right)$ is a group such that:
8 |
9 | $\forall x \in X: 0 \circ x$ is the inverse element of $x$ under $*$.
10 |
11 | That is:
12 | $$\forall a, b \in X: a * b^{-1} := a \circ b$$
--------------------------------------------------------------------------------
/data/prompts/p4_question.md:
--------------------------------------------------------------------------------
1 | $$1^3 = 1$$
2 |
3 | $$2^3 = 3 + 5$$
4 |
5 | $$3^3 = 7 + 9 + 11$$
6 |
7 | $$4^3 = 13 + 15 + 17 + 19 $$
8 |
9 | $$\vdots$$
10 |
11 |
12 | In general:
13 |
14 | $\forall n \in \mathbb{N}_{>0}: n^3 = \left( {n^2 - n + 1} \right) + \left( {n^2 - n + 3} \right) + \cdots + \left( {n^2 + n - 1} \right)$
15 |
16 | In particular, the first term for $\left( {n + 1} \right)^3$ is $2$ greater than the last term for $n^3$.
--------------------------------------------------------------------------------
/data/problems/p11_b-algebra_induces_group.md:
--------------------------------------------------------------------------------
1 |
2 | Let $\left( {X, \circ}\right)$ be a $B$-algebra with identity $0$.
3 |
4 | Let $\star$ be the binary operation on $X$ defined as:
5 |
6 | $$\forall a, b \in X: a \star b := a \circ \left( {0 \circ b}\right).$$
7 |
8 |
9 | Show that the algebraic structure $\left( {X, \star}\right)$ is a group such that for all $x \in X$, the element $0 \circ x$ is the inverse element of $x$ under $\star$.
10 |
--------------------------------------------------------------------------------
/data/problems/p31_bernoullis_theorem.md:
--------------------------------------------------------------------------------
1 | Let the probability of the occurrence of an event be $p$. Let $n$ independent trials be made, with $k_n$ being the random variable that counts the number of successes in these trials.
2 |
3 |
4 | Show that for any $\varepsilon>1$:
5 | $$\lim_{n \to \infty} \mathrm{Pr}(|\frac{k_n}{n}-p|<\varepsilon) = 1,$$
6 |
7 | that is, the mean number of successes lies with high probability close to the probability of the event.
8 |
--------------------------------------------------------------------------------
/data/problems/p39_weak_law_of_large_numbers.md:
--------------------------------------------------------------------------------
1 | Let $P$ be a population. Let $P$ have mean $\mu$ and finite variance. Let $\langle {X_n}\rangle_{n \geq 1}$ be a sequence of random variables forming a random sample from $P$.
2 |
3 | Let:
4 |
5 | $$\mathrm{} {\overline {X}_n} = \frac {1}{n} \sum_{i = 1}^n X_i$$
6 |
7 |
8 | Then show that
9 |
10 | $${\overline {X}_n} \rightarrow^p \mu$$
11 |
12 | where $\rightarrow^p$ denotes convergence in probability.
13 |
--------------------------------------------------------------------------------
/data/prompts/p14_question.md:
--------------------------------------------------------------------------------
1 | Let $\left( {G, \circ}\right)$ be a group.
2 |
3 | Let $\varnothing \subset S \subseteq G$.
4 |
5 | Let $\left( {H, \circ}\right)$ be the subgroup generated by $S$.
6 |
7 | Then $H = \langle S \rangle$ exists and is unique.
8 |
9 |
10 | Also, $\left( {H, \circ}\right)$ is the intersection of all of the subgroups of $G$ which contain the set $S$:
11 |
12 | $$\mathrm{} \langle S \rangle = \bigcap_i {H_i}: S \subseteq H_i \leq G$$
--------------------------------------------------------------------------------
/data/problems/p1_minkowskis_inequality_for_lebesgue_spaces.md:
--------------------------------------------------------------------------------
1 | Let $(X, \Sigma, \mu)$ be a measure space.
2 |
3 | Let $p \in [1, \ldots, \infty]$.
4 |
5 | Let $f, g: X \to \mathbb{R}$ be $p$-integrable, that is, elements of Lebesgue $p$-space $\mathcal{L}^p(\mu)$.
6 |
7 | Prove that their pointwise sum $f + g: X \to \mathbb{R}$ is also $p$-integrable, and:
8 | $$\|{f + g}\|_p \leq \|f\|_p + \|g\|_p $$
9 |
10 | where $\| \cdot \, \cdot \|_p$ denotes the $p$-seminorm.
11 |
--------------------------------------------------------------------------------
/data/problems/p38_second_borel-cantelli_lemma.md:
--------------------------------------------------------------------------------
1 |
2 | Let the events $E_n$ be independent. Let the sum of the probabilities of the $E_n$ diverges to infinity.
3 |
4 |
5 | Show that the probability that infinitely many of them occur is $1$.
6 |
7 | That is, show that if $\mathrm{} \sum_{n = 1}^\infty \Pr \left({E_n}\right) = \infty$ and the events $\mathrm{} \langle {E_n} \rangle ^\infty_{n = 1}$ are independent, then:
8 | $$\mathrm{} \Pr \left({\limsup_{n \to \infty} E_n}\right) = 1$$
9 |
--------------------------------------------------------------------------------
/data/problems_html/p21_one_plus_perfect_power_is_not_power_of_two.html:
--------------------------------------------------------------------------------
1 | Show that the equation:

2 | has no solutions in the integers for
.
3 |
--------------------------------------------------------------------------------
/data/prompts/p44_question.md:
--------------------------------------------------------------------------------
1 | Let $X$ be a set.
2 |
3 | Let $\mathcal{S} \subseteq \mathcal{P}(X)$ be a subset of the power set of $X$.
4 |
5 |
6 | Then there exists a unique topology $\tau \left(\mathcal{S}\right)$ on $X$ such that:
7 |
8 | $(1): \quad\mathcal{S} \subseteq \tau \left(\mathcal{S}\right)$
9 |
10 | $(2): \quad$ For any topology $\mathcal{T}$ on $X$, the implication $\mathcal{S} \subseteq \mathcal{T} \to \tau \left(\mathcal{S}\right) \subseteq \mathcal{T}$ holds.
11 |
--------------------------------------------------------------------------------
/data/problems/p4_nicomachuss_theorem.md:
--------------------------------------------------------------------------------
1 | Consider:
2 |
3 | $$1^3 = 1$$
4 |
5 | $$2^3 = 3 + 5$$
6 |
7 | $$3^3 = 7 + 9 + 11$$
8 |
9 | $$4^3 = 13 + 15 + 17 + 19 $$
10 |
11 | $$\vdots$$
12 |
13 |
14 | Show, in general, that:
15 |
16 | $\forall n \in \mathbb{N}_{>0}: n^3 = \left( {n^2 - n + 1} \right) + \left( {n^2 - n + 3} \right) + \cdots + \left( {n^2 + n - 1} \right)$
17 |
18 | In particular, show that the first term for $\left( {n + 1} \right)^3$ is $2$ greater than the last term for $n^3$.
19 |
--------------------------------------------------------------------------------
/data/prompts/p51_question.md:
--------------------------------------------------------------------------------
1 | Let $\mathbf{A}_{m \times n}$ be a matrix in the matrix space ${\mathcal{M}_{m, n} } \left(\mathbb{R}\right)$.
2 |
3 | Let ${\operatorname {N^{\leftarrow}} } \left({\mathbf{A}}\right)$ be used to denote the left null space of $\mathbf{A}$.
4 |
5 |
6 | Then:
7 | $${\operatorname {N^{\leftarrow}} } \left({\mathbf{A}}\right) = \{\mathbf{x}\in \mathbb{R}^n: \mathbf{x}^\intercal \mathbf{A} = \mathbf 0^\intercal\}$$
8 |
9 | where $\mathbf X^\intercal$ is the transpose of $\mathbf X$.
--------------------------------------------------------------------------------
/data/problems/p59_trace_in_terms_of_orthonormal_basis.md:
--------------------------------------------------------------------------------
1 | Let $\mathbb{K} \subset \mathbb{C}$ be a field.
2 |
3 | Let $\left ({V, \langle \,\cdot\,,\,\cdot\,\rangle }\right)$ be an inner product space over $\mathbb{K}$ of dimension $n$.
4 |
5 | Let $\left({e_1, \ldots, e_n}\right)$ be an orthonormal basis of $V$.
6 |
7 | Let $f: V \to V$ be a linear operator.
8 |
9 | Prove that its trace equals:
10 | $$\mathrm{tr} \left(f\right) = \mathrm{} \sum_{i = 1}^n \langle\, {f \left({e_i}\right) }\,,\, {e_i}\,\rangle$$
--------------------------------------------------------------------------------
/data/problems/p56_invertible_matrix_corresponds_with_change_of_basis.md:
--------------------------------------------------------------------------------
1 | Let $R$ be a commutative ring with unity.
2 |
3 | Let $G$ be an $n$-dimensional unitary $R$-module.
4 |
5 | Let $\langle {a_n}\rangle$ be an ordered basis of $G$.
6 |
7 | Let $\mathbf{P} = [ \alpha_n]$ be a square matrix of order $n$ over $R$.
8 |
9 | Let $\mathrm{} \forall j \in [1 \ldots n]: b_j = \sum_{i = 1}^n \alpha_{i j} a_i$.
10 |
11 | Prove that $\langle{b_n}\rangle$ is an ordered basis of $G$ if and only if $\mathbf{P}$ is invertible.
--------------------------------------------------------------------------------
/data/problems/p7_vector_cross_product_satisfies_jacobi_identity.md:
--------------------------------------------------------------------------------
1 | Let $\mathbf{a}, \mathbf{b}, \mathbf{c}$ be vectors in $3$ dimensional Euclidean space.
2 |
3 | Let $\times$ denotes the cross product.
4 |
5 | Then show that
6 | $\mathbf{a} \times \left( {\mathbf{b} \times \mathbf{c}}\right) + \mathbf{b} \times \left( {\mathbf{c} \times \mathbf{a}}\right) + \mathbf{c} \times \left( {\mathbf{a} \times \mathbf{b}}\right) = \mathbf{0}$.
7 |
8 | That is, show that the cross product operation satisfies the Jacobi identity.
9 |
--------------------------------------------------------------------------------
/data/problems/p44_existence_and_uniqueness_of_generated_topology.md:
--------------------------------------------------------------------------------
1 | Let $X$ be a set.
2 |
3 | Let $\mathcal{S} \subseteq \mathcal{P}(X)$ be a subset of the power set of $X$.
4 |
5 | Show that there exists a unique topology $\tau \left(\mathcal{S}\right)$ on $X$ such that:
6 |
7 | $(1): \quad\mathcal{S} \subseteq \tau \left(\mathcal{S}\right)$
8 |
9 | $(2): \quad$ For any topology $\mathcal{T}$ on $X$, the implication $\mathcal{S} \subseteq \mathcal{T} \to \tau \left(\mathcal{S}\right) \subseteq \mathcal{T}$ holds.
10 |
--------------------------------------------------------------------------------
/data/problems/p51_characterization_of_left_null_space.md:
--------------------------------------------------------------------------------
1 | Let $\mathbf{A}_{m \times n}$ be a matrix in the matrix space ${\mathcal{M}_{m, n} } \left(\mathbb{R}\right)$.
2 |
3 | Let ${\operatorname {N^{\leftarrow}} } \left({\mathbf{A}}\right)$ be used to denote the left null space of $\mathbf{A}$.
4 |
5 | Prove that
6 | $${\operatorname {N^{\leftarrow}} } \left({\mathbf{A}}\right) = \{\mathbf{x}\in \mathbb{R}^n: \mathbf{x}^\intercal \mathbf{A} = \mathbf{0}^\intercal\}$$
7 |
8 | where $\mathbf{X}^\intercal$ is the transpose of $\mathbf{X}$.
--------------------------------------------------------------------------------
/data/problems_html/p2_n_less_than_m_to_the_n.html:
--------------------------------------------------------------------------------
1 | Show that for non-zero natural numbers
, if
, then
.
2 |
--------------------------------------------------------------------------------
/data/prompts/p33_question.md:
--------------------------------------------------------------------------------
1 | Let $\left( {\Omega, \Sigma, \Pr}\right)$ be a measure space.
2 |
3 | Let $B \in \Sigma$ such that $\Pr \left(B\right) > 0$.
4 |
5 |
6 | Let $Q: \Sigma \to \mathbb{R}$ be the real-valued function defined as:
7 |
8 | $$Q \left(A \right) = \Pr \left(A | B\right)$$
9 |
10 | where:
11 |
12 | $$\Pr \left(A | B\right) = \dfrac {\Pr \left(A \cap B\right) }{\Pr \left(B\right)}$$
13 |
14 | is the conditional probability of $A$ given $B$.
15 |
16 |
17 | Then $\left( {\Omega, \Sigma, Q}\right)$ is a probability space.
--------------------------------------------------------------------------------
/data/problems/p33_conditional_probability_defines_probability_space.md:
--------------------------------------------------------------------------------
1 |
2 | Let $\left( {\Omega, \Sigma, \Pr}\right)$ be a measure space. Let $B \in \Sigma$ such that $\Pr \left(B\right) > 0$.
3 |
4 |
5 | Let $Q: \Sigma \to [0,1]$ be defined as:
6 |
7 | $$Q \left(A \right) = \Pr \left(A | B\right)$$
8 |
9 | where:
10 |
11 | $$\Pr \left(A | B\right) = \dfrac {\Pr \left(A \cap B\right) }{\Pr \left(B\right)}$$
12 |
13 | is the conditional probability of $A$ given $B$.
14 |
15 |
16 | Then $\left( {\Omega, \Sigma, Q}\right)$ is a probability space.
17 |
--------------------------------------------------------------------------------
/data/problems/p47_relationship_between_limit_inferior_and_lower_limit.md:
--------------------------------------------------------------------------------
1 | Let $\left( {S, \tau}\right)$ be a topological space.
2 |
3 | Let $f: S \to \mathbb{R} \cup \{-\infty, \infty\}$ be an extended real-valued function.
4 |
5 | Let $\langle {s_n}\rangle_{n \in \mathbb{N}}$ be a convergent sequence in $S$ such that $s_n \to \bar s$.
6 |
7 | Prove that the lower limit of $f$ at $\bar s$ is bounded above by the limit inferior of $\langle {f (s_n) }\rangle$, i.e.:
8 |
9 | $$\mathrm{} \liminf_{s \to \bar s} f (s) \leq \liminf_{n \to \infty} f (s_n)$$
10 |
--------------------------------------------------------------------------------
/data/problems/p46_neighborhood_in_topological_subspace.md:
--------------------------------------------------------------------------------
1 | Let $\left( {X, \tau}\right)$ be a topological space.
2 |
3 | Let $S \subseteq X$ be a subset of $X$.
4 |
5 | Let $\tau_S$ denote the subspace topology on $S$.
6 |
7 | Let $x \in S$ be an arbitrary point of $S$.
8 |
9 | Let $E \subseteq S$.
10 |
11 |
12 | Show that
13 | $E$ is a neighborhood of $x$ in $\left( {S, \tau_S}\right)$
14 | if and only if:
15 |
16 | $\exists D \subseteq X$ such that:
17 |
18 | $D$ is a neighborhood of $x$ in $X$
19 |
20 | $E = D \cap S$.
--------------------------------------------------------------------------------
/data/problems/p45_filter_on_product_of_hausdorff_spaces_converges_iff_projections_converge.md:
--------------------------------------------------------------------------------
1 | Let $\langle {X_i}\rangle_{i \in I}$ be an indexed family of non-empty Hausdorff spaces where $I$ is an arbitrary index set.
2 |
3 | Let $\mathrm{} X := \prod_{i \in I} X_i$ be the corresponding product space.
4 |
5 | Let $\mathrm{pr}_i: X \to X_i$ denote the projection from $X$ onto $X_i$.
6 |
7 | Let $\mathcal{F} \subset \mathcal{P} (X)$ be a filter on $X$.
8 |
9 | Show that $\mathcal{F}$ converges if and only if for each $i \in I$, the image filter $\mathrm{pr}_i \left(\mathcal{F}\right)$ converges.
--------------------------------------------------------------------------------
/data/problems_html/p27_power_of_sum_modulo_prime.html:
--------------------------------------------------------------------------------
1 | Let
be a prime number.
2 | Prove that

3 |
--------------------------------------------------------------------------------
/data/problems/p54_floquets_theorem.md:
--------------------------------------------------------------------------------
1 | Let $\mathbf{A} \left({t}\right)$ be a continuous matrix function with period $T$.
2 |
3 | Let $\Phi \left({t}\right)$ be a fundamental matrix of the Floquet system $\mathbf{x'}= \mathbf{A} \left({t}\right) \mathbf{x}$.
4 |
5 | Prove that $\Phi \left({t + T}\right)$ is also a fundamental matrix.
6 |
7 | Moreover, prove that there exists a nonsingular, continuously differentiable matrix function $\mathbf{P} \left({t}\right)$ with period $T$
8 | A constant (possibly complex) matrix $\mathbf{B}$ such that:
9 | $$\Phi \left({t}\right) = \mathbf{P} \left({t}\right) e^{\mathbf{B}t}$$
--------------------------------------------------------------------------------
/data/prompts/p54_question.md:
--------------------------------------------------------------------------------
1 | Let $\mathbf{A} \left({t}\right)$ be a continuous matrix function with period $T$.
2 |
3 | Let $\Phi \left({t}\right)$ be a fundamental matrix of the Floquet system $\mathbf{x'}= \mathbf{A} \left({t}\right) \mathbf{x}$.
4 |
5 |
6 | Then $\Phi \left({t + T}\right)$ is also a fundamental matrix.
7 |
8 |
9 | Moreover, there exists:
10 | A nonsingular, continuously differentiable matrix function $\mathbf{P} \left({t}\right)$ with period $T$
11 | A constant (possibly complex) matrix $\mathbf{B}$ such that:
12 | $$\Phi \left({t}\right) = \mathbf{P} \left({t}\right) e^{\mathbf{B}t}$$
--------------------------------------------------------------------------------
/data/prompts/p43_answer.md:
--------------------------------------------------------------------------------
1 | Let $x_0 \in A$.
2 |
3 | Define $H : A \times [0\ldots 1] \to A$ by:
4 | $$H \left({x, t}\right) = t x_0 + \left( {1 - t}\right) x$$
5 |
6 | This yields a homotopy between the identity map $I_A$ and the constant map $x_0$.
7 |
8 | Thanks to the assumption of convexity for $A$, $H$ takes values in $A$.
9 |
10 | $H$ is a continuous function, since it is polynomial separately in $x, t$, and:
11 | $$H \left({-, 0}\right) = I_A$$
12 | $$H \left({-, 1}\right) \equiv x_0\quad (\text{the constant function on } x_0)$$
13 |
14 | This proves that $H: I_A \simeq c_{x_0}$.
15 |
16 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems/p49_topology_defined_by_closed_sets.md:
--------------------------------------------------------------------------------
1 | Let $S$ be a set.
2 |
3 | Let $\tau$ be a set of subsets of $S$.
4 |
5 | Show that $\tau$ is a topology on $S$ if and only if:
6 |
7 | $(1): \quad$ Any intersection of arbitrarily many closed sets of $S$ under $\tau$ is a closed set of $S$ under $\tau$
8 |
9 | $(2): \quad$ The union of any finite number of closed sets of $S$ under $\tau$ is a closed set of $S$ under $\tau$
10 |
11 | $(3): \quad S$ and $\varnothing$ are both closed sets of $S$ under $\tau$
12 |
13 | where a closed set $V$ of $S$ under $\tau$ is defined as a subset of $S$ such that $S \backslash V \in \tau$.
--------------------------------------------------------------------------------
/data/problems_html/p34_hat-check_problem.html:
--------------------------------------------------------------------------------
1 | A hat-check girl completely loses track of which of
hats belong to which owners, and hands them back at random to their
owners as the latter leave.
2 | What is the probability
that nobody receives their own hat back?
3 |
--------------------------------------------------------------------------------
/data/prompts/p4_answer.md:
--------------------------------------------------------------------------------
1 | From the definition:
2 | $$\left( {n^2 - n + 1}\right) + \left( {n^2 - n + 3}\right) + \ldots + \left( {n^2 + n - 1}\right)$$
3 |
4 | can be written:
5 | $$\left( {n^2 - n + 1}\right) + \left( {n^2 - n + 3}\right) + \ldots + \left( {n^2 - n + 2 n - 1}\right)$$
6 |
7 | Writing this in sum notation:
8 |
9 | $$\left( {n^2 - n + 1}\right) + \left( {n^2 - n + 3}\right) + \ldots + \left( {n^2 - n + 2 n - 1}\right)$$
10 | $$ = \sum_{k = 1}^n \left( {n^2 - n + 2 k - 1}\right)$$
11 | $$ = n \left( {n^2 - n}\right) + \sum_{k = 1}^n \left( {2 k - 1}\right)$$
12 | $$ = n^3 - n^2 + n^2 \text{\quad Odd Number Theorem}$$
13 | $$ = n^3$$
14 |
15 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p29_tamrefs_last_theorem.html:
--------------------------------------------------------------------------------
1 | Show that the Diophantine equation:

has exactly one form of solutions in integers, namely:
2 |

for all
.
3 |
--------------------------------------------------------------------------------
/data/prompts/p21_answer.md:
--------------------------------------------------------------------------------
1 | Aiming for a contradiction, suppose there is a solution.
2 |
3 | Then:
4 | $$ a^n = 2^m - 1$$
5 | $$ \equiv -1 \mathrm{\ mod \ } 4 \text{\quad as } m > 1$$
6 |
7 | $a$ is immediately seen to be odd.
8 |
9 | By Square Modulo 4, $n$ must also be odd.
10 |
11 |
12 | Now:
13 | $$ 2^m = a^n + 1$$
14 | $$ = \left( {a + 1}\right) \sum_{k = 0}^{n - 1} \left( {-1}\right)^k a^{n - k - 1}\text{\quad Sum of Two Odd Powers}$$
15 |
16 | The latter sum has $n$ powers of $a$, which sums to an odd number.
17 |
18 | The only odd divisor of $2^m$ is $1$.
19 |
20 | However, if the sum is $1$, we have:
21 | $$a^n + 1 = a + 1$$
22 |
23 | giving $n = 1$, contradicting our constraint $n > 1$.
24 |
25 | Hence the result by Proof by Contradiction.
26 |
27 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p17_quotient_structure_of_group_is_group.html:
--------------------------------------------------------------------------------
1 | Let
be a congruence relation on a group
.
2 | Show that the quotient structure
is a group.
3 |
--------------------------------------------------------------------------------
/data/problems_html/p25_irrationality_of_logarithm.html:
--------------------------------------------------------------------------------
1 | Let
such that there exists no
such that
.
2 | Prove that
is irrational.
3 |
--------------------------------------------------------------------------------
/data/problems_html/p50_union_of_topologies_is_not_necessarily_topology.html:
--------------------------------------------------------------------------------
1 | Let
and
be topologies on a set
.
2 | Show that
is not necessarily also a topology on
.
3 |
--------------------------------------------------------------------------------
/data/problems_html/p43_convex_set_is_contractible.html:
--------------------------------------------------------------------------------
1 | Let
be a topological vector space over
or
.
2 | Let
be a convex subset.
3 | Prove that
is contractible.
4 |
--------------------------------------------------------------------------------
/data/prompts/p22_answer.md:
--------------------------------------------------------------------------------
1 | === Necessary Condition ===
2 |
3 | This is proved in Congruence by Divisor of Modulus.
4 |
5 | Note that for this result it is not required that $r \perp s$.
6 |
7 | $\square$
8 |
9 |
10 | === Sufficient Condition ===
11 |
12 | Now suppose that $a \equiv b \mathrm{\ mod \ } r$ and $a \equiv b \mathrm{\ mod \ } s$.
13 |
14 | We have by definition of congruence:
15 | $$a \equiv b \mathrm{\ mod \ } r \to \exists k \in \mathbb{Z}: a - b = k r$$
16 |
17 | From $a \equiv b \mathrm{\ mod \ } s$ we also have that:
18 | $$k r \equiv 0 \mathrm{\ mod \ } s$$
19 |
20 | As $r \perp s$, we have from Common Factor Cancelling in Congruence:
21 | $$k \equiv 0 \mathrm{\ mod \ } s$$
22 |
23 | So:
24 | $$\exists q \in \mathbb{Z}: a - b = q s r$$
25 |
26 | Hence by definition of congruence:
27 | $$a \equiv b \mathrm{\ mod \ } {r s}$$
28 |
29 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p24_hurwitzs_theorem.html:
--------------------------------------------------------------------------------
1 | Let
be an irrational number.
2 | Then show there are infinitely many relatively prime integers
such that:
3 |

4 |
--------------------------------------------------------------------------------
/data/problems_html/p8_factorisation_of_z^n+1.html:
--------------------------------------------------------------------------------
1 | Let
be a (strictly) positive integer.
2 | Then show that
3 |

4 |
--------------------------------------------------------------------------------
/data/prompts/p3_answer.md:
--------------------------------------------------------------------------------
1 | Let $P (z) = a_n z^n + \dots + a_1 z + a_0, \ a_n \ne 0$.
2 |
3 | Aiming for a contradiction, suppose that $P (z)$ is not zero for any $z \in \mathbb{C}$.
4 |
5 | It follows that $1 / P (z)$ must be entire; and is also bounded in the complex plane.
6 |
7 | In order to see that it is indeed bounded, we recall that $\exists R \in \mathbb{R}_{>0}$ such that:
8 |
9 | $$\left| {\dfrac {1}{P (z)} }\right| < \dfrac 2 {\left| {a_n}\right| R^n}, \text{whenever} \ \left| z\right| > R.$$
10 |
11 | Hence, $1 / P (z)$ is bounded in the region outside the disk $\left| z\right| \leq R$.
12 |
13 | However, $1 / P (z)$ is continuous on that closed disk, and thus it is bounded there as well.
14 |
15 | Furthermore, we observe that $1 / P(x)$ must be bounded in the whole plane.
16 |
17 | Through Liouville's Theorem, $1 / P(x)$, and thus $P(x)$, is constant.
18 |
19 | This is a contradiction.
20 |
21 | $\blacksquare$
--------------------------------------------------------------------------------
/data/prompts/p24_answer.md:
--------------------------------------------------------------------------------
1 | === Lemma 1 ===
2 |
3 | Let $\xi$ be an irrational number.
4 |
5 | Let $A \in \mathbb{R}$ be a real number strictly greater than $\sqrt{5}$.
6 |
7 | Then there may exist at most a finite number of relatively prime integers $p, q \in \mathbb{Z}$ such that:
8 |
9 | $$\left| {\xi - \dfrac{p}{q}}\right| < \dfrac {1}{A \, q^2}$$
10 |
11 | === Lemma 2 ===
12 |
13 | Let $\xi$ be an irrational number.
14 |
15 | Let there be $3$ consecutive convergents of the continued fraction to $\xi$.
16 |
17 | Then at least one of them, $\dfrac{p}{q}$ say, satisfies:
18 | $$\left| {\xi - \dfrac{p}{q}}\right| < \dfrac {1}{\sqrt{5} \, q^2}$$
19 |
20 |
21 | There are an infinite number of convergents to $\xi$.
22 |
23 | Taking these in sets of $3$ at a time, it can be seen from Lemma 2 that at least one of them satisfies the given inequality.
24 |
25 | From Lemma 1 it is seen that this inequality is the best possible.
26 |
27 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p6_bhaskaras_lemma.html:
--------------------------------------------------------------------------------
1 | Let
be an integer.
2 | For
show that if $N x^2 + k = y^2 $, then
.
3 |
--------------------------------------------------------------------------------
/data/problems_html/p23_eulers_theorem.html:
--------------------------------------------------------------------------------
1 | Let
be coprime integers, denoted as
.
2 | Let
be the Euler totient function.
3 | Show that the following equation holds:

4 |
--------------------------------------------------------------------------------
/data/problems_html/p48_sequence_lemma.html:
--------------------------------------------------------------------------------
1 | Let
be a subset of a topological space
.
2 | Show that if there is a sequence of points of
converging to
, then
.
3 | Also show that the converse holds if
is first-countable.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p5_real_star_algebra_is_commutative.html:
--------------------------------------------------------------------------------
1 | Let
be a real
-algebra whose conjugation is denoted as
.
2 | Prove that
.
3 | That is, a real
-algebra is commutative.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p12_cayleys_representation_theorem_general_case.html:
--------------------------------------------------------------------------------
1 | Let
be a group.
2 | Show that there exists a permutation group
on some set
such that:
3 |

4 | that is,
is isomorphic to
.
5 |
--------------------------------------------------------------------------------
/data/prompts/p13_answer.md:
--------------------------------------------------------------------------------
1 | Let $x, y, z \in G$.
2 |
3 | Suppose that $\neg \left( {\left( {x \circ z}\right) \mathcal{Q} \left( {y \circ z}\right) }\right)$.
4 |
5 | Then by the definition of $\mathcal{Q}$:
6 | $$\left( {x \circ z}\right) \mathcal{R} \left( {y \circ z}\right)$$
7 |
8 | Because $\mathcal{R}$ is compatible with $\circ$:
9 |
10 | $$\left( {x \circ z}\right) \circ z^{-1} \mathcal{R} \left( {y \circ z}\right) \circ z^{-1}$$
11 |
12 |
13 | By {{GroupAxiom|1}} and the {{GroupAxiom|3}}:
14 |
15 | $$x \mathcal{R} y$$
16 |
17 | so by the definition of $\mathcal{Q}$:
18 |
19 | $$\neg \left( {x \mathcal{Q} y}\right)$$
20 |
21 |
22 | By the Rule of Transposition:
23 | $$\forall x, y, z \in G: x \mathcal{Q} y \to \left( {x \circ z}\right) \mathcal{Q} \left( {y \circ z}\right)$$
24 |
25 | A similar argument shows that:
26 | $$\forall x, y, z \in G: x \mathcal{Q} y \to \left( {z \circ x}\right) \mathcal{Q} \left( {z \circ y}\right)$$
27 |
28 | Thus, by definition, $\mathcal{Q}$ is a relation compatible with $\circ$.
29 |
30 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p26_lagranges_theorem_number_theory.html:
--------------------------------------------------------------------------------
1 | Let
be a polynomial in one variable of degree
over
for some prime
.
2 | Prove that
has at most
roots in
.
3 |
--------------------------------------------------------------------------------
/data/prompts/p42_answer.md:
--------------------------------------------------------------------------------
1 | By assumption:
2 | $$P \subseteq \tau$$
3 |
4 | Let $U$ be an open subset of $S$.
5 |
6 | Define:
7 | $$X := \{V \in P: V \subseteq U\}$$
8 |
9 | By definition of subset:
10 | $$X \subseteq P$$
11 |
12 | We will prove that:
13 | $$\forall u \in S: u \in U \leftrightarrow \exists Z \in X: u \in Z$$
14 |
15 | Let $u \in S$.
16 |
17 | We will prove that:
18 | $$u \in U \to \exists Z \in X: u \in Z$$
19 |
20 | Assume that:
21 | $$u \in U$$
22 |
23 | By assumption:
24 | there exists local basis $B$ at $u: B \subseteq P$.
25 |
26 | By definition of local basis:
27 | $$\exists V \in B: V \subseteq U$$
28 |
29 | Thus by definitions of subset and $X$:
30 | $$V \in X$$
31 |
32 | Thus by definition of local basis:
33 | $$u \in V$$
34 |
35 | $\square$
36 |
37 |
38 | Assume that:
39 | $$\exists Z \in X: u \in Z$$
40 |
41 | By definition of $X$:
42 | $$Z \subseteq U$$
43 |
44 | Thus by definition of subset:
45 | $$u \in U$$
46 |
47 | $\square$
48 |
49 |
50 | Thus by definition of union:
51 | $$U = \bigcup X$$
52 |
53 | Hence $P$ is basis of $L$.
54 |
55 | $\blacksquare$
--------------------------------------------------------------------------------
/questions_to_ask.txt:
--------------------------------------------------------------------------------
1 | Below are some questions that we intend to ask in the data.
2 |
3 | - How do ratings change over the course of the interaction? For instance, does mathematical correctness decrease (or increase) over the interactions? Are only the first steps deemed helpful?
4 | - How many steps does a participant typically spend interacting? When do they stop?
5 | - What kinds of interaction queries are people making? E.g., queries for definitions? Querying to solve the entire problem outright?
6 | - How does level of experience change the magnitude of ratings, and type of queries made during interactions?
7 | - Is GPT-4 consistently preferred, or is there some preference for ChatGPT and/or GPT-3.5?
8 | - Do helpfulness and mathematical correctness seem predictive of the later preference ratings?
9 | - Do the ratings of helpfulness and correctness track together? Or are there clear discrepancies (sometimes very helpful, but incorrect; or vice versa)?
10 | - Does confidence in solving the problem prior to interacting with the AI system change the type of interactions and/or ratings?
11 |
--------------------------------------------------------------------------------
/data/prompts/p23_answer.md:
--------------------------------------------------------------------------------
1 | Let $\llbracket a \rrbracket_m$ denote the residue class modulo $m$ of $a$.
2 |
3 | Since $a \perp m$, it follows by Reduced Residue System under Multiplication forms Abelian Group that $\llbracket a \rrbracket_m$ belongs to the abelian group $\left( {\mathbb{Z}'_m, \times}\right)$.
4 |
5 | Let $k = \mid {\llbracket a \rrbracket_m}\mid$ where $\mid {\, \cdot \,}\mid$ denotes the order of a group element.
6 |
7 | By Order of Element Divides Order of Finite Group:
8 | $$k \backslash \mid {\mathbb{Z}'_m}\mid$$
9 |
10 | By the definition of the Euler $\phi$ function:
11 | $$\mid {\mathbb{Z}'_m}\mid = \phi \left(m\right)$$
12 |
13 |
14 | Thus:
15 |
16 | $$\llbracket a \rrbracket_m^k = \llbracket a \rrbracket_m \text{\quad Definition of Order of Group Element}$$
17 | $$\leadsto \llbracket a \rrbracket_m^{\phi \left(m\right)} = \llbracket {a^{\phi \left(m\right)} }\rrbracket_m \text{\quad Congruence of Powers}$$
18 | $$ = \llbracket 1 \rrbracket_m$$
19 | $$ \leadsto a^{\phi \left(m\right)} \equiv 1 \mathrm{\ mod \ } m \text{\quad Definition of Residue Class}$$
20 |
21 | $\blacksquare$
--------------------------------------------------------------------------------
/data/prompts/p33_answer.md:
--------------------------------------------------------------------------------
1 | It is to be shown that $Q$ is a probability measure on $\left({\Omega, \Sigma}\right)$.
2 |
3 |
4 | As $\Pr$ is a measure, we have that:
5 |
6 | $$\forall A \in \Omega: Q (A) \geq 0$$
7 |
8 | Also, we have that:
9 |
10 | $$ Q \left(\Omega\right) = \Pr \left(\Omega\mid B\right)$$
11 | $$ = \frac {\Pr \left({\Omega \cap B}\right) } {\Pr \left({B}\right)}$$
12 | $$ = \frac {\Pr \left({B}\right)} {\Pr \left({B}\right)}\text{\quad Intersection with Universe}$$
13 | $$ = 1\text{\quad as } \Pr \left({B}\right) > 0$$
14 |
15 |
16 | Now, suppose that $A_1, A_2, \ldots$ are disjoint events in $\Sigma$.
17 |
18 | Then:
19 |
20 | $$Q \left({\bigcup_{i = 1}^\infty A_i}\right)
21 | | r = \frac {1} {\Pr(B)} \Pr \left({\left({\bigcup_{i = 1}^\infty A_i}\right) \cap B}\right)$$
22 | $$ = \frac {1} {\Pr(B)} \Pr \left({\bigcup_{i = 1}^\infty \left({A_i \cap B}\right) }\right)\text{\quad Intersection Distributes over Union}$$
23 | $$ = \sum_{i = 1}^\infty \frac {\Pr\left({A_i \cap B}\right)} {\Pr(B)}\text{\quad as }\Pr \text{ is a measure}$$
24 | $$ = \sum_{i = 1}^\infty Q \left({A_i}\right)$$
25 |
26 | $\blacksquare$
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Katie Collins
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/data/problems_html/p31_bernoullis_theorem.html:
--------------------------------------------------------------------------------
1 | Let the probability of the occurrence of an event be
. Let
independent trials be made, with
being the random variable that counts the number of successes in these trials.
2 | Show that for any
:

3 | that is, the mean number of successes lies with high probability close to the probability of the event.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p19_self-inverse_elements_commute_iff_product_is_self-inverse.html:
--------------------------------------------------------------------------------
1 | Let
be a group.
2 | Let
, such that
and
are self-inverse.
3 | Show that
and
commute iff
is also self-inverse.
4 |
--------------------------------------------------------------------------------
/data/prompts/p32_answer.md:
--------------------------------------------------------------------------------
1 | Let $f$ be the function:
2 |
3 | $$f (x) = \begin{cases} k^2 \sigma^2 & : \mid {x - \mu}\mid \geq k \sigma \\
4 | 0 & : \text{otherwise} \end{cases}$$
5 |
6 | By construction, we see that:
7 | $$f (x)\leq \mid {x - \mu}\mid^2 = \left( {x - \mu}\right)^2$$
8 | for all $x$.
9 |
10 | This means that:
11 | $$\mathrm{E}\left( {f (X)}\right) \leq \mathrm{E}\left( {\left( {X - \mu}\right)^2}\right)$$
12 |
13 | By definition of variance:
14 |
15 | $$\mathrm{E}\left( {\left( {X - \mu}\right)^2}\right) = \mathrm{var}\left(X\right) = \sigma^2$$
16 |
17 | By definition of expectation of discrete random variable, we can show that:
18 |
19 | $$\mathrm{E}\left( {f (X)}\right) = k^2 \sigma^2 \Pr \left({\mid {X - \mu}\mid \geq k \sigma}\right) + 0 \cdot \Pr \left({\mid {X - \mu}\mid \leq k \sigma}\right)$$
20 | $$ = k^2 \sigma^2 \Pr \left({\mid{X - \mu}\mid \geq k \sigma}\right)$$
21 |
22 | Putting this together, we have:
23 |
24 | $$\mathrm{E}\left( {f (X)}\right) \leq \mathrm{E}\left( {\left( {X - \mu}\right)^2}\right)$$
25 | $$ \leadsto k^2 \sigma^2 \Pr \left({\mid {X - \mu}\mid \geq k \sigma}\right) \leq \sigma^2$$
26 |
27 | By dividing both sides by $k^2 \sigma^2$, we get:
28 |
29 | $$\Pr \left({\mid {X - \mu}\mid \geq k \sigma}\right) \leq \dfrac {1}{k^2}$$
30 |
31 | $\blacksquare$
--------------------------------------------------------------------------------
/data/prompts/p34_answer.md:
--------------------------------------------------------------------------------
1 | Put into bald mathematical language, this boils down to:
2 |
3 | For a set $S$ of $n$ elements, what is the number of derangements of $S$ divided by the number of permutations of $S$?
4 |
5 | The answer is: approximately $\dfrac {1}e$, which can be demonstrated as follows.
6 |
7 |
8 | Let $D_n$ be the number of derangements of a set of size $n$.
9 |
10 | We have that:
11 | The Number of Permutations of a set of size $n$ is $n!$.
12 |
13 | The Closed Form for Number of Derangements on Finite Set of size $n$ is:
14 | $$D_n = n! \left( {1 - \dfrac {1}{1!} + \dfrac {1}{2!} - \dfrac {1}{3!} + \cdots + \left( {-1}\right)^n \dfrac {1}{n!} }\right)$$
15 |
16 |
17 | So:
18 |
19 | $$ p_n = \dfrac {D_n} {n!}$$
20 | $$ = \dfrac {!n} {n!}\text{\quad Closed Form for Number of Derangements on Finite Set}$$
21 | $$ = \dfrac {n! \mathrm{} \sum_{k = 0}^n \frac {\left( {-1}\right)^k} {k!} } {n!}\text{\quad Definition of Subfactorial}$$
22 | $$ = \sum_{k = 0}^n \frac {\left( {-1}\right)^k} {k!}$$
23 | $$ = 1 - \dfrac {1}{1!} + \dfrac {1}{2!} - \dfrac {1}{3!} + \cdots + \left( {-1}\right)^n \dfrac {1}{n!}$$
24 |
25 |
26 | Finally:
27 | $$1 - \dfrac {1}{1!} + \dfrac {1}{2!} - \dfrac {1}{3!} + \cdots$$
28 | converges to $\dfrac {1}e$ by Taylor Series Expansion for Exponential Function.
29 |
30 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p15_group_has_latin_square_property.html:
--------------------------------------------------------------------------------
1 | Let
be a group.
2 | Show that
satisfies the Latin square property.
3 | That is, for all
, there exists a unique
such that
.
4 | Similarly, there exists a unique
such that
.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p14_existence_of_unique_subgroup_generated_by_subset.html:
--------------------------------------------------------------------------------
1 | Let
be a group. Let
.
2 | Show that the subgroup generated by
, which is defined to be the intersection of all of the subgroups of
which contain the set
:
3 |

4 | is unique.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p30_sum_of_reciprocals_of_divisors_equals_abundancy_index.html:
--------------------------------------------------------------------------------
1 | Let
be a positive integer.
2 | Let
denote the divisor sum function of
.
3 | Show that

where
is the abundancy index of
.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p36_function_of_discrete_random_variable.html:
--------------------------------------------------------------------------------
1 | Let
be a discrete random variable on the probability space
.
2 | Let
be any real function.
3 | Show that
, defined as

is also a discrete random variable.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p20_structure_induced_by_group_operation_is_group.html:
--------------------------------------------------------------------------------
1 | Let
be a group whose identity is
.
2 | Let
be a set.
3 | Let
be the structure on
induced by
by pointwise operation.
4 | Then show that
is a group.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p60_unique_representation_by_ordered_basis.html:
--------------------------------------------------------------------------------
1 | Let
be a unitary
-module.
2 | Show that
is an ordered basis of
if and only if:
3 | For every
there exists one and only one sequence
of scalars such that
.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p53_existence_of_minimal_polynomial_for_square_matrix_over_field.html:
--------------------------------------------------------------------------------
1 | Let
be a field.
2 | Let
be a natural number.
3 | Let
be the set of
matrices over
.
4 | Let
.
5 | Prove that the minimal polynomial of
exists and has degree at most
.
6 |
--------------------------------------------------------------------------------
/data/prompts/p51_answer.md:
--------------------------------------------------------------------------------
1 | Let $\mathbf{x}= \begin {bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end {bmatrix} \in \mathbb{R}^n$.
2 |
3 | $$ \mathbf{x}\in {\operatorname {N^{\leftarrow}} } \left({\mathbf{A}}\right) \leftrightarrow \mathbf{x}\in {\operatorname N} \left({\mathbf{A}^\intercal}\right) \text{\quad Definition of Left Null Space}$$
4 | $$\leftrightarrow \mathbf{A}^\intercal \mathbf{x}= \mathbf 0 \text{\quad Definition of Null Space}$$
5 | $$ \leftrightarrow \left( {\mathbf{A}^\intercal \mathbf x}\right)^\intercal = \mathbf 0^\intercal\text{\quad taking the transpose of both sides}$$
6 | $$ \leftrightarrow \mathbf{x}^\intercal \left( {\mathbf{A}^\intercal}\right)^\intercal = \mathbf 0^\intercal \text{\quad Transpose of Matrix Product}$$
7 | $$ \leftrightarrow \mathbf{x}^\intercal \mathbf{A} = \mathbf 0^\intercal \text{\quad Transpose of Transpose of Matrix}$$
8 |
9 | We have that $\mathbf{A}^\intercal \mathbf{x}= \mathbf 0$ is equivalent to $\mathbf{x}^\intercal \mathbf{A} = \mathbf 0^\intercal$.
10 |
11 | This implies that $\mathbf{x}\in {\operatorname N} \left({\mathbf{A}^\intercal}\right) \leftrightarrow \mathbf{x}^\intercal \mathbf{A} = \mathbf 0^\intercal$.
12 |
13 | Recall that:
14 | $$\mathbf{x}\in {\operatorname N} \left({\mathbf{A}^\intercal}\right) \leftrightarrow \mathbf{x}\in {\operatorname {N^{\leftarrow}} } \left({\mathbf{A}}\right)$$
15 |
16 | Hence the result, by definition of set equality.
17 |
18 | $\blacksquare$
--------------------------------------------------------------------------------
/data/prompts/p54_answer.md:
--------------------------------------------------------------------------------
1 | We assume the two hypotheses of the theorem.
2 |
3 |
4 | We have that:
5 |
6 | $$ {\frac {\mathrm{d}} {\mathrm{d} t} } \left({\Phi \left({t + T}\right) }\right) = {\Phi'} \left({t + T}\right)$$
7 | $$ = {\mathbf{A}} \left({t + T}\right) \Phi \left({t + T}\right)$$
8 | $$ = {\mathbf{A}} \left(t\right) \Phi \left({t + T}\right)$$
9 |
10 | So the first implication of the theorem holds, that is: that $\Phi \left({t + T}\right)$ is a fundamental matrix.
11 |
12 |
13 | Because $\Phi \left(t\right)$ and $\Phi \left({t + T}\right)$ are both fundamental matrices, there must exist some matrix $\mathbf C$ such that:
14 | $$\Phi \left({t + T}\right) = \Phi \left(t\right) \mathbf C$$
15 |
16 | Hence by the existence of the matrix logarithm, there exists a matrix $\mathbf{B}$ such that:
17 | $$\mathbf C = e^{\mathbf{B}T}$$
18 |
19 |
20 | Defining ${\mathbf{P}} \left(t\right) = \Phi \left(t\right) e^{-\mathbf{B} t}$, it follows that:
21 |
22 | $${\mathbf{P}} \left({t + T}\right) = \Phi \left({t + T}\right) e^{-\mathbf{B} t - \mathbf{B} T}$$
23 | $$ = \Phi \left(t\right) C e^{-\mathbf{B} T} e^{-\mathbf{B} t}$$
24 | $$ = \Phi \left(t\right) e^{-\mathbf{B} t}$$
25 | $$ = {\mathbf{P}} \left(t\right)$$
26 |
27 | and hence ${\mathbf{P}} \left(t\right)$ is periodic with period $T$.
28 |
29 | As $\Phi \left(t\right) = {\mathbf{P}} \left(t\right) e^{\mathbf{B} t}$, the second implication also holds.
30 |
31 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p18_schur-zassenhaus_theorem.html:
--------------------------------------------------------------------------------
1 | Let
be a finite group and
be a normal subgroup in
.
2 | Let
also be a Hall subgroup of
.
3 | Show that a complement
of
exists and that
is the semidirect product of
and
.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p37_mean_number_of_elements_fixed_by_self-map.html:
--------------------------------------------------------------------------------
1 | Let
be a strictly positive integer. Let
be a finite set of cardinality
.
2 | Let
be the set of all mappings from
to itself. Let
denote the arithmetic mean of the number of fixed points of all the mappings in
.
3 | Then:

4 |
--------------------------------------------------------------------------------
/data/prompts/p12_answer.md:
--------------------------------------------------------------------------------
1 | Let $G$ be a group and let $a \in G$.
2 |
3 | Consider the left regular representation $\lambda_a: G \to G$ defined as:
4 |
5 | $${\lambda_a} \left(x\right) = a \cdot x$$
6 |
7 | From Regular Representations in Group are Permutations we have that $\lambda_a$ is a permutation.
8 |
9 | Now let $b \in G$ and consider $\lambda_b: G \to G$ defined as:
10 |
11 | $${\lambda_b} \left(x\right) = b \cdot x$$
12 |
13 | From the Cancellation Laws it follows that $\lambda_a \ne \lambda_b \leftrightarrow a \ne b$.
14 |
15 |
16 | Let $H = \{\lambda_x: x \in G\}$.
17 |
18 | Consider the mapping $\Phi: G \to H$ defined as:
19 | $$\forall a \in G: \Phi \left(b\right) = \lambda_a$$
20 |
21 | From the above we have that $\Phi$ is a bijection.
22 |
23 |
24 | Let $a, b \in G$.
25 |
26 | From Composition of Regular Representations we have that:
27 | $$\lambda_a \circ \lambda_b = \lambda_{a \cdot b}$$
28 | where $\circ$ denotes composition of mappings.
29 |
30 | That is, $\Phi$ has the morphism property.
31 |
32 | Thus $\Phi$ is seen to be a group isomorphism.
33 |
34 |
35 | We also have that:
36 | $$\left({\lambda_a}\right)^{-1} = \lambda_{\left({a^{-1} }\right)}$$
37 | because:
38 | $$\lambda_a \circ \left( {\lambda_a}\right)^{-1} = \lambda_{\left({a \cdot a^{-1} }\right)}$$
39 |
40 |
41 | Hence the set of left regular representations $\{\lambda_x: x \in G\}$ is a group which is isomorphic to $G$.
42 |
43 | $\blacksquare$
--------------------------------------------------------------------------------
/data/prompts/p44_answer.md:
--------------------------------------------------------------------------------
1 | === Existence ===
2 |
3 | Define:
4 | $$\mathbb E = \{\mathcal{T} \subseteq \mathcal{P}(X): \mathcal{S} \subseteq \mathcal{T} \text{ and } \mathcal{T} \text{ is a topology on X}\}$$
5 |
6 |
7 | Since Discrete Topology is Topology, $\mathcal{P}(X)$ is a topology on $X$, it follows that $\mathbb E$ is non-empty.
8 |
9 | Hence, we can define:
10 | $$\mathrm{} \tau \left(\mathcal{S}\right) = \bigcap \mathbb E$$
11 |
12 | It follows that Intersection of Topologies is Topology, $\tau \left(\mathcal{S}\right)$ is a topology on $X$.
13 |
14 |
15 | By Intersection is Largest Subset/General Result and Intersection is Largest Subset, it follows that $\mathcal{S} \subseteq \tau \left(\mathcal{S}\right)$.
16 |
17 |
18 | By Intersection is Subset/General Result and Intersection is Subset, it follows that if $\mathcal{S} \subseteq \mathcal{T}$ and $\mathcal{T}$ is a topology on $X$, then $\tau \left(\mathcal{S}\right) \subseteq \mathcal{T}$.
19 |
20 | $\square$
21 |
22 | === Uniqueness ===
23 |
24 | Suppose that $\mathcal{T}_1$ and $\mathcal{T}_2$ are both topologies on $X$ satisfying conditions $(1)$ and $(2)$.
25 |
26 |
27 | By condition $(1)$, we have $\mathcal{S} \subseteq \mathcal{T}_2$; hence, we can apply condition $(2)$ to conclude that:
28 | $$\mathcal{T}_1 \subseteq \mathcal{T}_2$$
29 |
30 | Similarly:
31 | $$\mathcal{T}_2 \subseteq \mathcal{T}_1$$
32 |
33 |
34 | By definition of set equality:
35 | $$\mathcal{T}_1 = \mathcal{T}_2$$
36 |
37 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p16_invertible_elements_of_monoid_form_subgroup_of_cancellable_elements.html:
--------------------------------------------------------------------------------
1 | Let
be an monoid whose identity is
.
2 | Let
be the set of all cancellable elements of
.
3 | Let
be the set of all invertible elements of
.
4 | Show that
is a subgroup of
.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p40_total_probability_theorem.html:
--------------------------------------------------------------------------------
1 | Let
be a probability space. Let
be a partition of
such that
.
2 | Show that

3 |
--------------------------------------------------------------------------------
/data/problems_html/p42_characterization_of_analytic_basis_by_local_bases.html:
--------------------------------------------------------------------------------
1 | Let
be a topological space.
2 | Let
be a set of subsets of
such that

and
3 | for all
: there exists local basis
at
.
4 | Show that
is basis of
.
5 |
--------------------------------------------------------------------------------
/data/render_md_into_html.py:
--------------------------------------------------------------------------------
1 | import os
2 | from bs4 import BeautifulSoup
3 |
4 |
5 | if __name__ == "__main__":
6 | import argparse
7 | parser = argparse.ArgumentParser()
8 | parser.add_argument("input_dir", help="input markdown directory")
9 | parser.add_argument("output_dir", help="output html directory")
10 | args = parser.parse_args()
11 |
12 | input_dir = args.input_dir
13 | output_dir = args.output_dir
14 |
15 | if not os.path.exists(output_dir):
16 | os.makedirs(output_dir)
17 |
18 | for filename in os.listdir(input_dir):
19 | if filename.endswith(".md"):
20 | input_path = os.path.join(input_dir, filename)
21 | output_path = os.path.join(output_dir, filename.replace(".md", ".html"))
22 | print("Rendering {} to {}".format(input_path, output_path))
23 | os.system("pandoc -f markdown -t html --webtex='https://latex.codecogs.com/svg.latex?' {} -o {}".format(input_path, output_path))
24 |
25 | for filename in os.listdir(output_dir):
26 | file_path = os.path.join(output_dir, filename)
27 |
28 | file_content = open(file_path, "r").read()
29 | file_content = file_content.replace(
30 | '
Let
be real numbers which are all positive.
2 | Let
be the arithmetic mean of
.
3 | Let
be the geometric mean of
.
4 | Show that

with equality holding iff:

that is, iff all terms are equal.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p35_markovs_inequality.html:
--------------------------------------------------------------------------------
1 | Let
be a measure space. Let
.
2 | Let
be an
-measurable function.
3 | Show that
for any
.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p7_vector_cross_product_satisfies_jacobi_identity.html:
--------------------------------------------------------------------------------
1 | Let
be vectors in
dimensional Euclidean space.
2 | Let
denotes the cross product.
3 | Then show that
.
4 | That is, show that the cross product operation satisfies the Jacobi identity.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p38_second_borel-cantelli_lemma.html:
--------------------------------------------------------------------------------
1 | Let the events
be independent. Let the sum of the probabilities of the
diverges to infinity.
2 | Show that the probability that infinitely many of them occur is
.
3 | That is, show that if
and the events
are independent, then:

4 |
--------------------------------------------------------------------------------
/data/problems_html/p52_condition_for_planes_to_be_parallel.html:
--------------------------------------------------------------------------------
1 | Let
be a plane in
.
2 | Prove that the plane
is parallel to
if and only if there is a
such that:

3 |
--------------------------------------------------------------------------------
/data/problems_html/p32_chebyshevs_inequality.html:
--------------------------------------------------------------------------------
1 | Let
be a random variable. Assume
for some
and
for some
.
2 | Show that for all
:
3 |

4 |
--------------------------------------------------------------------------------
/data/prompts/p53_answer.md:
--------------------------------------------------------------------------------
1 | By Matrices over Field form Vector Space:
2 |
3 | $K^{n \times n}$ forms a vector space under usual matrix addition and scalar multiplication.
4 |
5 | By Dimension of Vector Space of Matrices:
6 |
7 | $K^{n \times n}$ has dimension $n^2$.
8 |
9 | Consider the collection of vectors:
10 |
11 | $I, A, A^2, \ldots, A^{n^2}$
12 |
13 | Since this is a collection of $n^2 + 1$ vectors, and $K^{n \times n}$ has dimension $n^2$, we have by [[Size of Linearly Independent Subset is at Most Size of Finite Generator]]:
14 |
15 | $I, A, A^2, \ldots, A^{n^2}$ are linearly dependent.
16 |
17 | That is, there exists $\alpha_0, \alpha_1, \ldots, \alpha_{n^2} \in K$ not all zero such that:
18 |
19 | $$\mathrm{} \sum_{i = 0}^{n^2} \alpha_i A^i = 0$$
20 |
21 | That is, the polynomial:
22 |
23 | $$\mathrm{} \sum_{i = 0}^{n^2} \alpha_i X^i \in K [X]$$
24 |
25 | has $P (A) = 0$, and degree at most $n^2$.
26 |
27 | Let:
28 |
29 | $$S = \{P \in K [X] \backslash \{0\} \mid P (A) = 0\}$$
30 |
31 | $S$ is certainly non-empty since we have found such an element in the computation above.
32 |
33 | Now consider the set:
34 |
35 | $$D = \{\deg P \mid P \in S\}$$
36 |
37 | Since $D$ is a subset of the natural numbers, it contains a least element $N$ by the Well-Ordering Principle.
38 |
39 | Since the polynomial we constructed has degree at most $n^2$, we have $N \leq n^2$.
40 |
41 | Let $Q \in S$ be of degree $N$.
42 |
43 | Let $a_N$ be the coefficient of the $X^N$ term in $Q$.
44 |
45 | Then $\mu = \dfrac {1}{a_N} Q$ is a monic polynomial of minimum degree with $\mu (A) = 0$.
46 |
47 | So $\mu$ is a minimal polynomial for $A$.
48 |
49 | $\blacksquare$
--------------------------------------------------------------------------------
/data/data_utils/clean_up_markdown.py:
--------------------------------------------------------------------------------
1 | import os
2 | import re
3 |
4 | definition_chars = "\[\[Definition:"
5 | starting_chars = "\[\["
6 | ending_chars = "\]\]"
7 |
8 | if __name__ == "__main__":
9 | path_to_clean = "data/prompts"
10 | for filename in os.listdir(path_to_clean):
11 | if filename.endswith(".md"):
12 | with open(os.path.join(path_to_clean, filename), "r") as f:
13 | text = f.read()
14 | indices_to_del = []
15 | for m in re.finditer(definition_chars, text):
16 | start_m = m.start()
17 | first_divisor = text[start_m:].find("|")
18 | first_end = text[start_m:].find("]]")
19 |
20 | indices_to_del.extend(
21 | list(range(start_m, start_m + first_divisor + 1))
22 | )
23 | indices_to_del.extend(
24 | [start_m + first_end, start_m + first_end + 1]
25 | )
26 | altered_text = "".join(
27 | [c for i, c in enumerate(text) if i not in indices_to_del]
28 | )
29 | # print(text)
30 | # print(altered_text)
31 | # print("*" * 100)
32 |
33 | for s in [m.start() for m in re.finditer(starting_chars, text)]:
34 | indices_to_del.extend([s, s + 1])
35 |
36 | for s in [m.start() for m in re.finditer(ending_chars, text)]:
37 | indices_to_del.extend([s, s + 1])
38 |
39 | with open(os.path.join(path_to_clean, filename), "w") as f:
40 | f.write(altered_text)
41 |
--------------------------------------------------------------------------------
/data/problems_html/p9_lagranges_identity.html:
--------------------------------------------------------------------------------
1 | Let
be real or complex numbers. Show that the following identities hold:
2 |

3 |

4 |
--------------------------------------------------------------------------------
/data/problems_html/p39_weak_law_of_large_numbers.html:
--------------------------------------------------------------------------------
1 | Let
be a population. Let
have mean
and finite variance. Let
be a sequence of random variables forming a random sample from
.
2 | Let:
3 |

4 | Then show that
5 |

6 | where
denotes convergence in probability.
7 |
--------------------------------------------------------------------------------
/data/problems_html/p57_rank_and_nullity_of_transpose.html:
--------------------------------------------------------------------------------
1 | Let
and
be
-dimensional vector spaces over a field.
2 | Let
be the set of all linear transformations from
to
.
3 | Let
.
4 | Let
be the transpose of
.
5 | Prove that
and
have the same rank and nullity.
6 |
--------------------------------------------------------------------------------
/data/problems_html/p22_chinese_remainder_theorem.html:
--------------------------------------------------------------------------------
1 | Let
.
2 | Let
and
be coprime integers.
3 | Then show that
iff
and
, where
denotes that
is congruent modulo
to
.
4 |
--------------------------------------------------------------------------------
/data/data_utils/load_problems.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | categories = {}
4 | for i, category in enumerate(
5 | [
6 | "Algebra",
7 | "Group theory",
8 | "Number theory",
9 | "Probability theory",
10 | "Topology",
11 | "Linear algebra",
12 | ]
13 | ):
14 | for j in range(10):
15 | categories[i * 10 + j + 1] = category
16 |
17 |
18 | def load_problem(problem_dir, use_html=False):
19 | """Load a problem from the problem directory."""
20 | if use_html:
21 | problem_file_name = problem_dir.split("/")[-1].rstrip(".html")
22 | else:
23 | problem_file_name = problem_dir.split("/")[-1].rstrip(".md")
24 | problem_file_name_split = problem_file_name.split("_")
25 | print("problem file name: ", problem_file_name_split)
26 | problem_id = int(problem_file_name_split[0][1:]) # remove the starting "p"
27 | problem_name = "_".join(problem_file_name_split[1:])
28 | problem_category = categories[problem_id]
29 | with open(problem_dir, "r") as f:
30 | problem_text = f.read()
31 | return {
32 | "id": problem_id,
33 | "name": problem_name,
34 | "text": problem_text,
35 | "category": problem_category,
36 | }
37 |
38 |
39 | def load_problems(problems_path, use_html=False):
40 | """Load all problems from the problems directory."""
41 | problems = []
42 | for problem_dir in sorted(os.listdir(problems_path)):
43 | problem_id = int(problem_dir.split("_")[0][1:])
44 | problem_dir = os.path.join(problems_path, problem_dir)
45 | assert os.path.isfile(problem_dir)
46 | problem = load_problem(problem_dir, use_html=use_html)
47 | problems.append((problem_id, problem))
48 |
49 | problems = sorted(problems, key=lambda x: x[0])
50 | problems = [problem for _, problem in problems]
51 | return problems
52 |
--------------------------------------------------------------------------------
/data/problems_html/p13_complement_of_relation_compatible_with_group_is_compatible.html:
--------------------------------------------------------------------------------
1 | Let
be a group. Let
be a relation on
. Let
be compatible with
.
2 | Let
be a relation defined such that:

3 | Show that
is a relation compatible with
.
4 |
--------------------------------------------------------------------------------
/data/problems_html/p11_b-algebra_induces_group.html:
--------------------------------------------------------------------------------
1 | Let
be a
-algebra with identity
.
2 | Let
be the binary operation on
defined as:
3 |

4 | Show that the algebraic structure
is a group such that for all
, the element
is the inverse element of
under
.
5 |
--------------------------------------------------------------------------------
/data/prompts/p31_answer.md:
--------------------------------------------------------------------------------
1 | Let the random variable $k$ have the binomial distribution with parameters $n$ and $p$, that is:
2 | $$k \sim \mathrm{B} (n, p)$$
3 | where $k$ denotes the number of successes of the $n$ independent trials of the event with probability $p$.
4 |
5 |
6 | From Expectation of Binomial Distribution:
7 | $$\mathrm{E}(k) = n p \leadsto \dfrac {1}n \mathrm{E}(k) = p$$
8 |
9 | Expectation is Linear gives:
10 | $$ \mathrm{E}\left({\dfrac k n}\right) = p =: \mu$$
11 |
12 |
13 | Similarly, from Variance of Binomial Distribution:
14 | $$\mathrm{var} \left(k\right) = n p \left({1 - p}\right) \leadsto \dfrac {1}{n^2} \mathrm{var} \left(k\right) = \dfrac {p \left({1 - p}\right)} n$$
15 |
16 | From Variance of Linear Combination of Random Variables:
17 | $$\mathrm{var} \left({\dfrac k n}\right) = \dfrac {p \left( {1 - p}\right) } n =: \sigma^2$$
18 |
19 |
20 | By applying Chebyshev's Inequality to $\dfrac {k} {n}$, we have for any $l>0$:
21 | $$\Pr \left({\left| {\dfrac k m - \mu}\right| \geq l \sigma}\right) \leq \dfrac {1}{l^2}$$
22 |
23 | Now, let $\epsilon > 0$ and choose $l = \dfrac \epsilon \sigma$, to get:
24 | $$\Pr \left({\left| {\dfrac k m - \mu}\right| \geq \dfrac \epsilon \sigma \cdot \sigma}\right) \leq \dfrac {\sigma^2} {\epsilon^2}$$
25 |
26 | Simplifying and plugging in the values of $\mu$ and $\sigma^2$ defined above yields:
27 | $$\Pr \left({\left| {\dfrac k n - p}\right| \geq \epsilon}\right) \leq \dfrac {p \left( {1 - p}\right) } {n \epsilon^2}$$
28 |
29 | Scaling both sides by $-1$ and adding $1$ to both sides yields:
30 | $$1- \Pr \left({\left| {\dfrac k n - p}\right| \geq \epsilon}\right) \geq 1 - \dfrac {p \left( {1 - p}\right) } {n \epsilon^2}$$
31 |
32 | Applying Union of Event with Complement is Certainty to the left hand side:
33 | $$\Pr \left({\left|{\dfrac k n - p}\right| \leq \epsilon}\right) \geq 1 - \dfrac {p \left( {1 - p}\right) } {n\epsilon^2}$$
34 |
35 | Taking the limit as $n$ approaches infinity on both sides, we have:
36 | $$\mathrm{} \lim_{n \to \infty} \Pr \left({\left| {\frac{k}{n} - p}\right| < \epsilon}\right) = 1$$
37 |
38 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p59_trace_in_terms_of_orthonormal_basis.html:
--------------------------------------------------------------------------------
1 | Let
be a field.
2 | Let
be an inner product space over
of dimension
.
3 | Let
be an orthonormal basis of
.
4 | Let
be a linear operator.
5 | Prove that its trace equals:

6 |
--------------------------------------------------------------------------------
/data/problems_html/p51_characterization_of_left_null_space.html:
--------------------------------------------------------------------------------
1 | Let
be a matrix in the matrix space
.
2 | Let
be used to denote the left null space of
.
3 | Prove that

4 | where
is the transpose of
.
5 |
--------------------------------------------------------------------------------
/data/problems_html/p47_relationship_between_limit_inferior_and_lower_limit.html:
--------------------------------------------------------------------------------
1 | Let
be a topological space.
2 | Let
be an extended real-valued function.
3 | Let
be a convergent sequence in
such that
.
4 | Prove that the lower limit of
at
is bounded above by the limit inferior of
, i.e.:
5 |

6 |
--------------------------------------------------------------------------------
/data/problems_html/p1_minkowskis_inequality_for_lebesgue_spaces.html:
--------------------------------------------------------------------------------
1 | Let
be a measure space.
2 | Let
.
3 | Let
be
-integrable, that is, elements of Lebesgue
-space
.
4 | Prove that their pointwise sum
is also
-integrable, and:

5 | where
denotes the
-seminorm.
6 |
--------------------------------------------------------------------------------
/data/problems_html/p4_nicomachuss_theorem.html:
--------------------------------------------------------------------------------
1 | Consider:
2 |

3 |

4 |

5 |

6 |

7 | Show, in general, that:
8 | 
9 | In particular, show that the first term for
is
greater than the last term for
.
10 |
--------------------------------------------------------------------------------
/data/problems_html/p33_conditional_probability_defines_probability_space.html:
--------------------------------------------------------------------------------
1 | Let
be a measure space. Let
such that
.
2 | Let
be defined as:
3 |

4 | where:
5 |

6 | is the conditional probability of
given
.
7 | Then
is a probability space.
8 |
--------------------------------------------------------------------------------
/data/problems_html/p54_floquets_theorem.html:
--------------------------------------------------------------------------------
1 | Let
be a continuous matrix function with period
.
2 | Let
be a fundamental matrix of the Floquet system
.
3 | Prove that
is also a fundamental matrix.
4 | Moreover, prove that there exists a nonsingular, continuously differentiable matrix function
with period
A constant (possibly complex) matrix
such that:

5 |
--------------------------------------------------------------------------------
/data/problems_html/p44_existence_and_uniqueness_of_generated_topology.html:
--------------------------------------------------------------------------------
1 | Let
be a set.
2 | Let
be a subset of the power set of
.
3 | Show that there exists a unique topology
on
such that:
4 | 
5 |
For any topology
on
, the implication
holds.
6 |
--------------------------------------------------------------------------------
/data/problems_html/p45_filter_on_product_of_hausdorff_spaces_converges_iff_projections_converge.html:
--------------------------------------------------------------------------------
1 | Let
be an indexed family of non-empty Hausdorff spaces where
is an arbitrary index set.
2 | Let
be the corresponding product space.
3 | Let
denote the projection from
onto
.
4 | Let
be a filter on
.
5 | Show that
converges if and only if for each
, the image filter
converges.
6 |
--------------------------------------------------------------------------------
/data/problems_html/p56_invertible_matrix_corresponds_with_change_of_basis.html:
--------------------------------------------------------------------------------
1 | Let
be a commutative ring with unity.
2 | Let
be an
-dimensional unitary
-module.
3 | Let
be an ordered basis of
.
4 | Let
be a square matrix of order
over
.
5 | Let
.
6 | Prove that
is an ordered basis of
if and only if
is invertible.
7 |
--------------------------------------------------------------------------------
/data/prompts/p52_answer.md:
--------------------------------------------------------------------------------
1 | === Necessary Condition ===
2 |
3 | Let $P'$ be a plan given by the equation:
4 | $$\beta_1 x_1 + \beta_2 x_2 + \beta_3 x_3 = \delta$$
5 |
6 | The Hessian normal vector of $P$ is given by:
7 | $$\mathbf {n_P} = \left({\frac{\alpha_1}{p}, \frac{\alpha_2}{p}, \frac{\alpha_3}{p}}\right), \text{where}$$
8 | $p = \sqrt{\alpha_1^2 + \alpha_2^2 + \alpha_3^2}$. Similarly, the Hessian normal vector of $P'$ is given by:
9 | $$\mathbf {n_{P'}} = \left({\frac{\beta_1}{q}, \frac{\beta_2}{q}, \frac{\beta_3}{q}}\right), \text{where}$$
10 | $q = \sqrt{\beta_1^2 + \beta_2^2 + \beta_3^2}$.
11 |
12 | Since $P$ and $P'$ are parallel, we have that $\mathbf {n_P} \times \mathbf {n_{P'}} = \mathbf 0$.
13 |
14 | We have:
15 | $$\mathbf {n_P} \times \mathbf {n_{P'}} = \left({\frac{\alpha_1}{p}, \frac{\alpha_2}{p}, \frac{\alpha_3}{p}}\right) \times \left({\frac{\beta_1}{q}, \frac{\beta_2}{q}, \frac{\beta_3}{q}}\right)$$
16 | $$ = \frac{1}{pq} \left({\alpha_2 \beta_3 - \alpha_3 \beta_2, \alpha_3 \beta_1 - \alpha_1 \beta_3, \alpha_1 \beta_2 - \alpha_2 \beta_1}\right)$$
17 | $$ = \mathbf 0$$
18 |
19 | Obviously, $pq\ne 0$, so:
20 | $$\alpha_2 \beta_3 - \alpha_3 \beta_2 = 0$$
21 | $$\alpha_3 \beta_1 - \alpha_1 \beta_3 = 0$$
22 | $$\alpha_1 \beta_2 - \alpha_2 \beta_1 = 0$$
23 |
24 | This implies that $\exists t \in \mathbb{R} \backslash \{0\}$ such that: $(\beta_1, \beta_2, \beta_3) = t(\alpha_1, \alpha_2, \alpha_3)$.
25 |
26 | Putting this back into the equation of $P'$, we have:
27 | $$t\alpha_1 x_1 + t\alpha_2 x_2 + t\alpha_3 x_3 = \delta$$
28 | $$\mathbb{R}ightarrow\alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \frac{\delta}{t}$$
29 |
30 | Therefore, setting $\gamma' = \frac{\delta}{t}$, the conclusion follows.
31 |
32 | === Sufficient Condition ===
33 |
34 | Let $P' \ne P$ be a plane given by the equation:
35 |
36 | $$\alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \gamma'$$
37 |
38 | Aiming for contradiction, suppose we have a point:
39 | $$\mathbf{x}= \left({x_1, x_2, x_3}\right) \in P \cap P'$$
40 |
41 | Then, as $\mathbf{x}\in P$, it also satisfies:
42 |
43 | $$\alpha_1 x_1 + \alpha_2 x_2 + \alpha_3 x_3 = \gamma$$
44 |
45 | It follows that $\gamma = \gamma'$, so $P = P'$.
46 |
47 | This contradiction shows that $P \cap P' = \varnothing$, that is, $P$ and $P'$ are parallel.
48 |
49 | The remaining case is when $P' = P$.
50 |
51 | By definition, $P$ is parallel to itself.
52 |
53 | The result follows.
54 |
55 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p46_neighborhood_in_topological_subspace.html:
--------------------------------------------------------------------------------
1 | Let
be a topological space.
2 | Let
be a subset of
.
3 | Let
denote the subspace topology on
.
4 | Let
be an arbitrary point of
.
5 | Let
.
6 | Show that
is a neighborhood of
in
if and only if:
7 |
such that:
8 |
is a neighborhood of
in 
9 |
.
10 |
--------------------------------------------------------------------------------
/data/prompts/p41_answer.md:
--------------------------------------------------------------------------------
1 | Let $\mathbb D^3$ be centered at the origin, and $D^3$ be some other unit ball in $\mathbb{R}^3$ such that $\mathbb D^3 \cap D^3 = \varnothing$.
2 |
3 | Let $\mathbb S^2 = \partial \mathbb D^3$.
4 |
5 | By the Hausdorff Paradox, there exists a decomposition of $ \mathbb S^2$ into four sets $A, B, C, D$ such that $A, B, C$ and $B \cup C$ are congruent, and $D$ is countable.
6 |
7 | For $r \in \mathbb{R}_{>0}$, define a function $r^*: \mathbb{R}^3 \to \mathbb{R}^3$ as ${r^*} \left({\mathbf x}\right) = r \mathbf x$, and define the sets:
8 |
9 | $$ W = \bigcup_{0 < r \leq 1} {r^*} \left(A\right)$$
10 | $$ X = \bigcup_{0 < r \leq 1} {r^*} \left(B\right)$$
11 | $$ Y = \bigcup_{0 < r \leq 1} {r^*} \left(C\right)$$
12 | $$ Z = \bigcup_{0 < r \leq 1} {r^*} \left(D\right)$$
13 |
14 |
15 | Let $T = W \cup Z \cup \{\mathbf 0\}$.
16 |
17 | $W$ and $X \cup Y$ are clearly congruent by the congruency of $A$ with $B \cup C$, hence $W$ and $X \cup Y$ are equidecomposable.
18 |
19 | Since $X$ and $Y$ are congruent, and $W$ and $X$ are congruent, $X \cup Y$ and $W \cup X$ are equidecomposable.
20 |
21 | $W$ and $X \cup Y$ as well as $X$ and $W$ are congruent, so $W \cup X$ and $W \cup X \cup Y$ are equidecomposable.
22 |
23 | Hence $W$ and $W \cup X \cup Y$ are equidecomposable, by Equidecomposability is Equivalence Relation.
24 |
25 | So $T$ and $\mathbb D^3$ are equidecomposable, from Equidecomposability Unaffected by Union.
26 |
27 |
28 | Similarly we find $X$, $Y$, and $W \cup X \cup Y$ are equidecomposable.
29 |
30 |
31 | Since $D$ is only countable, but ${\operatorname {SO} } (3)$ is not, we have:
32 | $$\exists \phi \in {\operatorname {SO} } (3): \phi (D) \subset A \cup B \cup C$$
33 | so that $I = \phi (D) \subset W \cup X \cup Y$.
34 |
35 | Since $X$ and $W \cup X \cup Y$ are equidecomposable, by Subsets of Equidecomposable Subsets are Equidecomposable, $\exists H \subseteq X$ such that $H$ and $I$ are equidecomposable.
36 |
37 |
38 | Finally, let $p \in X - H$ be a point and define $S = Y \cup H \cup \{p\}$.
39 |
40 | Since:
41 |
42 | - $Y$ and $W \cup X \cup Y$
43 |
44 | - $H$ and $Z$
45 |
46 | - $\{0\}$ and $\{p\}$
47 |
48 | are all equidecomposable in pairs, $S$ and $\mathbb B^3$ are equidecomposable by Equidecomposability Unaffected by Union.
49 |
50 | Since $D^3$ and $\mathbb D^3$ are congruent, $D^3$ and $S$ are equidecomposable, from Equidecomposability is Equivalence Relation.
51 |
52 |
53 | By Equidecomposability Unaffected by Union, $T \cup S$ and $\mathbb D^3 \cup D^3$ are equidecomposable.
54 |
55 | Hence $T \cup S \subseteq \mathbb D^3 \subset \mathbb D^3 \cup D^3$ are equidecomposable and so, by the Equidecomposable Nested Sets|chain property of equidecomposability, $\mathbb D^3$ and $\mathbb D^3 \cup D^3$ are equidecomposable.
56 |
57 | $\blacksquare$
--------------------------------------------------------------------------------
/data/data_utils/load_prompts.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 |
4 | ones_digit_to_ones_digit_of_examples = {}
5 | for i in range(10):
6 | ones_digit_to_ones_digit_of_examples[i] = [1]
7 | ones_digit_to_ones_digit_of_examples[1] = [2]
8 | # ones_digit_to_ones_digit_of_examples[2] = [1]
9 | # ones_digit_to_ones_digit_of_examples[3] = [1]
10 |
11 |
12 | def construct_one_example(question, answer):
13 | return f"Question: {question}\nAnswer: {answer}".strip()
14 |
15 |
16 | def get_prompt_examples(prompt_dir):
17 | """
18 | We expect the examples in the prompt directory to be named p{x}_{question|answer}.md
19 | Output of this function:
20 | {
21 | {problem_id}: {
22 | "question": {question},
23 | "answer": {answer}
24 | }
25 | }
26 | """
27 | problem_index_to_info = {}
28 | for file in os.listdir(prompt_dir):
29 | if file.endswith(".md"):
30 | index, question_or_answer = file.rstrip(".md").split("_")
31 | index = int(index.lstrip("p"))
32 | assert question_or_answer in ["question", "answer"]
33 |
34 | file_path = os.path.join(prompt_dir, file)
35 | with open(file_path, "r") as f:
36 | text = f.read().strip()
37 |
38 |
39 | if index not in problem_index_to_info:
40 | problem_index_to_info[index] = {
41 | question_or_answer: text
42 | }
43 | else:
44 | problem_index_to_info[index][question_or_answer] = text
45 |
46 | assert len(problem_index_to_info) == 6 * 4
47 | for value in problem_index_to_info.values():
48 | assert len(value) == 2
49 | return problem_index_to_info
50 |
51 |
52 | def construct_prompt(problem_id, problem_text, prompt_examples):
53 | """
54 | For each of the six domains, we prepare 4 examples in the format of (question, answer)
55 | These correspond to the first 4 problems of each domain, i.e., p1-4, p11-14, p21-24, p31-34, p41-44, p51-54
56 | To construct the prompts, we use 3 examples that are different from the problem at hand
57 | E.g., for p1, we use p2, p3, and p4 as the prompts
58 | for p2, we use p1, p3, and p4 as the prompts
59 | for p3, we use p1, p2, and p4 as the prompts
60 | for p4-10, we use p1, p2, and p3 as the prompts
61 | """
62 | assert 1 <= problem_id <= 60
63 | tens_digit, ones_digit = divmod(problem_id, 10)
64 | ones_digit_of_examples = ones_digit_to_ones_digit_of_examples[ones_digit]
65 | indices_of_examples = [10 * tens_digit + i for i in ones_digit_of_examples]
66 |
67 | total_examples = "\n".join(
68 | construct_one_example(prompt_examples[index]["question"].strip(), prompt_examples[index]["answer"].strip()) for index in indices_of_examples
69 | ).strip()
70 | entire_prompt = total_examples + f"\nQuestion: {problem_text.strip()}\nAnswer:"
71 | return entire_prompt
72 |
--------------------------------------------------------------------------------
/data/prompts/p11_answer.md:
--------------------------------------------------------------------------------
1 | Let $x, y, z \in X$:
2 |
3 | We will show that $\left({X, *}\right)$ satisfies each of the [[Axiom:Group Axioms|group axioms]] in turn:
4 |
5 |
6 | === Group Axiom G0: Closure ===
7 |
8 | By definition of $*$, we have:
9 |
10 | $$x * y = x \circ \left( {0 \circ y}\right)$$
11 |
12 | By Axiom $(AC)$ for $B$-algebras:
13 |
14 | $$x \circ \left( {0 \circ y}\right) \in X$$
15 |
16 |
17 | Whence $x * y \in X$, and so $\left( {X, *}\right)$ is a closed structure.
18 |
19 | $\square$
20 |
21 |
22 | === Group Axiom G1: Associativity ===
23 |
24 | $$\left( {x * y}\right) * z = \left( {x \circ \left( {0 \circ y}\right) }\right) \circ \left( {0 \circ z}\right) \text{\quad Definition of } *$$
25 | $$ = x \circ \left( {\left( {0 \circ z}\right) \circ \left( {0 \circ \left( {0 \circ y}\right) }\right) }\right)\text{\quad Axiom } (A3) \text{ for } B\text{-algebras}$$
26 | $$ = x \circ \left( {\left( {0 \circ z}\right) \circ y}\right) \text{\quad Identity: } 0 \circ \left( {0 \circ x}\right) = x$$
27 | $$ = x \circ \left( {0 \circ \left( {y \circ \left( {0 \circ z}\right) }\right) }\right)\text{\quad Axiom } (A3) \text{ for } B\text{-algebras}$$
28 | $$ = x * \left( {y * z}\right)\text{\quad Definition of }*$$
29 |
30 | Thus it is seen that $*$ is associative.
31 |
32 | $\square$
33 |
34 |
35 | === Group Axiom G2: Existence of Identity Element ===
36 |
37 | Let $e := 0$; we will show that it is an identity element of $\left({X, *}\right)$.
38 |
39 | $$x * e = x \circ \left( {0 \circ 0}\right)\text{\quad Definition of } * \text{ and } e$$
40 | $$ = x \circ 0\text{\quad Axiom } (A1) \text{ for } B\text{-algebras}$$
41 | $$ = x\text{\quad Axiom } (A2) \text{ for } B\text{-algebras}$$
42 |
43 |
44 | $$ e * x = 0 \circ \left( {0 \circ x}\right)\text{\quad Definition of } * \text{ and } e$$
45 | $$ = x\text{\quad Identity: } 0 \circ \left( {0 \circ x}\right) = x$$
46 |
47 |
48 | Hence $0$ is an identity for $*$.
49 |
50 | $\square$
51 |
52 |
53 | === Group Axiom G3: Existence of Inverse Element ===
54 |
55 | Let us prove that for all $x \in X$, $0 \circ x$ is an inverse element to $x$.
56 |
57 | $$ x * \left( {0 \circ x}\right) = x \circ \left( {0 \circ \left( {0 \circ x}\right) }\right)\text{\quad Definition of } *$$
58 | $$ = x \circ x\text{\quad Identity: } 0 \circ \left( {0 \circ x}\right) = x$$
59 | $$ = 0\text{\quad Axiom } (A1) \text{ for } B\text{-algebras}$$
60 |
61 |
62 | $$ \left( {0 \circ x}\right) * x = \left( {0 \circ x}\right) \circ \left( {0 \circ x}\right)\text{\quad Definition of } *$$
63 | $$ = 0\text{\quad Axiom } (A1) \text{ for } B\text{-algebras}$$
64 |
65 |
66 | That is, each $x \in X$ has a unique inverse element $x^{-1}$ under $*$.
67 |
68 | This inverse element is $0 \circ x$.
69 |
70 | $\square$
71 |
72 |
73 | It follows that:
74 |
75 | $$ a * b^{-1} = a \circ \left( {0 \circ b^{-1} }\right)\text{\quad Definition of } *$$
76 | $$ = a \circ \left( {0 \circ \left( {0 \circ b}\right) }\right)\text{\quad Definition of } b^{-1}$$
77 | $$ a \circ b\text{\quad Identity: }0 \circ \left( {0 \circ x}\right) = x$$
78 |
79 | $\square$
80 |
81 |
82 | All the axioms have been shown to hold and the result follows.
83 |
84 | $\blacksquare$
--------------------------------------------------------------------------------
/data/problems_html/p49_topology_defined_by_closed_sets.html:
--------------------------------------------------------------------------------
1 | Let
be a set.
2 | Let
be a set of subsets of
.
3 | Show that
is a topology on
if and only if:
4 |
Any intersection of arbitrarily many closed sets of
under
is a closed set of
under 
5 |
The union of any finite number of closed sets of
under
is a closed set of
under 
6 |
and
are both closed sets of
under 
7 | where a closed set
of
under
is defined as a subset of
such that
.
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | share/python-wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | MANIFEST
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .nox/
43 | .coverage
44 | .coverage.*
45 | .cache
46 | nosetests.xml
47 | coverage.xml
48 | *.cover
49 | *.py,cover
50 | .hypothesis/
51 | .pytest_cache/
52 | cover/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | .pybuilder/
76 | target/
77 |
78 | # Jupyter Notebook
79 | .ipynb_checkpoints
80 |
81 | # IPython
82 | profile_default/
83 | ipython_config.py
84 |
85 | # pyenv
86 | # For a library or package, you might want to ignore these files since the code is
87 | # intended to run in multiple environments; otherwise, check them in:
88 | # .python-version
89 |
90 | # pipenv
91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
94 | # install all needed dependencies.
95 | #Pipfile.lock
96 |
97 | # poetry
98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99 | # This is especially recommended for binary packages to ensure reproducibility, and is more
100 | # commonly ignored for libraries.
101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102 | #poetry.lock
103 |
104 | # pdm
105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106 | #pdm.lock
107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108 | # in version control.
109 | # https://pdm.fming.dev/#use-with-ide
110 | .pdm.toml
111 |
112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113 | __pypackages__/
114 |
115 | # Celery stuff
116 | celerybeat-schedule
117 | celerybeat.pid
118 |
119 | # SageMath parsed files
120 | *.sage.py
121 |
122 | # Environments
123 | .env
124 | .venv
125 | env/
126 | venv/
127 | ENV/
128 | env.bak/
129 | venv.bak/
130 |
131 | # Spyder project settings
132 | .spyderproject
133 | .spyproject
134 |
135 | # Rope project settings
136 | .ropeproject
137 |
138 | # mkdocs documentation
139 | /site
140 |
141 | # mypy
142 | .mypy_cache/
143 | .dmypy.json
144 | dmypy.json
145 |
146 | # Pyre type checker
147 | .pyre/
148 |
149 | # pytype static type analyzer
150 | .pytype/
151 |
152 | # Cython debug symbols
153 | cython_debug/
154 |
155 | # PyCharm
156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158 | # and can be added to the global gitignore or merged into this file. For a more nuclear
159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160 | #.idea/
161 |
--------------------------------------------------------------------------------
/constants.py:
--------------------------------------------------------------------------------
1 | MAX_CONVERSATION_LENGTH = 20
2 | MAX_TOKENS_PER_GENERATION = 512
3 | SAMPLING_TEMPERATURE = 0.
4 |
5 |
6 | plaintxt_instructions = [
7 | ["Welcome to our study!", "In this task, you will be interacting with AI systems to explore how well AI systems can assist in solving mathematical problems.",
8 | "Your responses will inform AI, mathematics, and potentially human-computer interaction research.",
9 | "By participating in this study, you consent to having your responses stored and used for publication.",
10 | "Your email and other identifying information (beyond level of mathematical expertise) will not be stored.",
11 | "Please only continue if you are comfortable with the above."],
12 | ["In this study, you will be posed with mathematical problems (e.g., theorems) and asked to evaluate how good different AI systems are at helping to solve that problem.",
13 | "You may evaluate a maximum of nine problems (three sets of three problems over the three models) You can choose which subtopic of mathematics (e.g., algebra, probability theory) you would like these problems to come from.",
14 | "Note: if you already know how to solve the problem, pretend that you are an undergraduate mathematics student who does not immediately know how to solve the problem. What kind of assistance may be helpful? Are these AIs good assistants?"]]
15 |
16 |
17 | first_rating_instructions = [
18 |
19 | "You have at most " + str(MAX_CONVERSATION_LENGTH) + " interactions to play with the model and explore its ability to help you solve the problem. You do not need to use all interactions.",
20 | "After the interactions, you will rate for each step: 1) how helpful you found the response for helping you solve the problem, or if you already know how to solve the problem, imagine that you are an undergraduate student who does not immediately know how to solve the problem; and 2) how mathematically correct the response was.",
21 | "You can type in Markdown or LaTeX."
22 |
23 | ]
24 |
25 | instruction_pages = ["".join(['' + x + "
" for x in instruction_page]) for instruction_page in plaintxt_instructions]
26 | first_rating_instruct_txt = "".join(['' + x + "
" for x in first_rating_instructions])
27 |
28 | experience_options = ["Current undergraduate studying mathematics",
29 | "Undegraduate degree in mathematics",
30 | "Masters degree in mathematics",
31 | "PhD in mathematics",
32 | "Professor in mathematics",
33 | "Never studied for a math degree / not enrolled in math degree"]
34 |
35 |
36 | ai_experience_options = ["Never",
37 | "A few times total",
38 | "A couple of times a month",
39 | "Weekly",
40 | "Daily"]
41 |
42 |
43 | useful_prompt_txt = "How helpful would this AI generated response be towards helping someone solve this problem? If you already know how to solve the problem, evaluate this as if you were an undergraduate mathematics student encountering this problem for the first time."
44 |
45 | correctness_prompt_txt = "How correct (i.e., mathematically sound) is the generation?"
46 |
47 | usefulness_options = [
48 | "(0) Actively harmful",
49 | "(1) Very harmful",
50 | "(2) Somewhat harmful",
51 | "(3) Unlikely to help, but unlikely to hurt",
52 | "(4) Somewhat helpful",
53 | "(5) Very helpful",
54 | "(6) Definitely helpful"
55 | ]
56 |
57 | correctness_options = [
58 | "(0) N/A - this response does not contain any mathematical information",
59 | "(1) Completely incorrect or nonsensical",
60 | "(2) Multiple critical maths errors",
61 | "(3) At least one critical math error or multiple small errors",
62 | "(4) One or more minor errors, but otherwise mostly correct",
63 | "(5) One or two minor errors, but almost entirely correct",
64 | "(6) Completely correct"
65 | ]
66 |
67 |
68 | solo_solve_options = [
69 | "(0) Definitely could not solve on my own",
70 | "(1) Very unlikely to be able to solve on my own",
71 | "(2) Unlikely to be able to solve on my own",
72 | "(3) May be able to solve on my own",
73 | "(4) Likely be able to solve on my own",
74 | "(5) Very likely to be able to solve on my own",
75 | "(6) Definitely can solve on my own"
76 | ]
77 |
78 | model_options = [
79 | "chatgpt",
80 | "instructgpt",
81 | "chatgpt4"
82 | ]
83 |
84 |
--------------------------------------------------------------------------------
/data/prompts/p1_answer.md:
--------------------------------------------------------------------------------
1 | We split into three cases.
2 |
3 | === Case 1: $p > 1$ ===
4 |
5 | We first show that $f + g \in {\mathcal{L}^p} \left(\mu\right)$.
6 |
7 | Note that from Pointwise Maximum of Measurable Functions is Measurable:
8 |
9 | $x \mapsto \max \{f (x), g (x)\}$ is $\Sigma$-measurable.
10 |
11 | We then have from Measure is Monotone:
12 |
13 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu = \int \mid {2 \max \{f (x), g (x)\} }\mid^p {\mathrm{d} \mu} (x)$$
14 |
15 | We then have:
16 |
17 | $$\int \mid {2 \max \{f (x), g (x)\}}\mid^p {\mathrm{d} \mu} (x)
18 | = \int 2^p \mid {\max \{f (x), g (x)\}}\mid^p {\mathrm{d} \mu} (x)\quad \text{Integral of Positive Measurable Function is Positive Homogeneous}$$
19 | $$= 2^p \int \max \{\mid {f (x)}\mid ^p, \mid {g (x)}\mid ^p\} {\mathrm{d} \mu} (x)$$
20 | $$\leq 2^p \int \left( {\mid f\mid^p + \mid g\mid^p}\right) \mathrm{d} \mu$$
21 |
22 | Since $f, g \in {\mathcal{L}^p} \left(\mu\right)$, we have:
23 |
24 | $$\mathrm{} \int \mid f\mid^p \mathrm{d} \mu < \infty$$
25 |
26 | and:
27 |
28 | $$\mathrm{} \int \mid g\mid^p \mathrm{d} \mu < \infty$$
29 |
30 | so:
31 |
32 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu < \infty$$
33 |
34 | so:
35 |
36 | $$f + g \in {\mathcal{L}^p} \left(\mu\right)$$
37 |
38 | If:
39 |
40 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu = 0$$
41 |
42 | then the desired inequality is immediate.
43 |
44 | So, take:
45 |
46 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu > 0$$
47 |
48 | Write:
49 |
50 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu = \int \mid {f + g}\mid \mid {f + g}\mid^{p - 1} \mathrm{d} \mu$$
51 |
52 | From the Triangle Inequality, Integral of Positive Measurable Function is Monotone and Integral of Positive Measurable Function is Additive, we have:
53 |
54 | $$\mathrm{} \int \mid {f + g}\mid \mid {f + g}\mid^{p - 1} \mathrm{d} \mu \leq \int \mid f\mid \mid {f + g}\mid^{p - 1} \mathrm{d} \mu + \int \mid g\mid \mid {f + g}\mid^{p - 1} \mathrm{d} \mu$$
55 |
56 | From Hölder's Inequality, we have:
57 |
58 | $$\mathrm{} \int \mid f\mid \mid {f + g}\mid^{p - 1} \mathrm{d} \mu + \int \mid g\mid \mid {f + g}\mid^{p - 1} \mathrm{d} \mu \leq \left( {\int {\mid f\mid}^p \mathrm{d} \mu}\right)^{1/p} \left( {\int \mid {f + g}\mid^{q \left( {p - 1}\right) } \mathrm{d} \mu}\right)^{1/q} + \left( {\int {\mid g\mid}^p \mathrm{d} \mu}\right)^{1/p} \left( {\int \mid {f + g}\mid^{q \left( {p - 1}\right) } \mathrm{d} \mu}\right)^{1/q}$$
59 |
60 | where $q$ satisfies:
61 |
62 | $$\mathrm{} \frac {1} p + \frac {1} q = 1$$
63 |
64 | Then we have:
65 |
66 | $$p + q = p q$$
67 |
68 | so:
69 |
70 | $$p = pq - q = q \left( {p - 1}\right)$$
71 |
72 | So we have:
73 |
74 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu \leq \left( {\left( {\int {\mid f\mid}^p \mathrm{d} \mu}\right)^{1/p} + \left( {\int {\mid g\mid}^p \mathrm{d} \mu}\right)^{1/p} }\right) \left( {\int \mid {f + g}\mid^p \mathrm{d} \mu}\right)^{1/q}$$
75 |
76 | From the definition of the $p$-seminorm we have:
77 |
78 | $$\mathrm{} \int \mid {f + g}\mid^p \mathrm{d} \mu \leq \left( {\| f\|_p + \| g\|_p}\right) \left( {\int \mid {f + g}\mid^p \mathrm{d} \mu}\right)^{1/q}$$
79 |
80 | So that:
81 |
82 | $$\mathrm{} \left( {\int \mid {f + g}\mid^p \mathrm{d} \mu}\right)^{1 - 1/q} \leq \| f\|_p + \| g\|_p$$
83 |
84 | That is:
85 |
86 | $$\mathrm{} \left( {\int \mid {f + g}\mid^p \mathrm{d} \mu}\right)^{1/p} \leq \| f\|_p + \| g\|_p$$
87 |
88 | So from the definition of the $p$-seminorm we have:
89 |
90 | $$\| {f + g}\|_p \leq \| f\|_p + \| g\|_p$$
91 |
92 | $\square$
93 |
94 | === Case 2: $p = 1$ ===
95 |
96 | From the Triangle Inequality, we have:
97 |
98 | $$\mid {f + g}\mid \leq \mid f\mid + \mid g\mid$$
99 |
100 | So, from Integral of Positive Measurable Function is Additive and Integral of Positive Measurable Function is Monotone, we have:
101 |
102 | $$\mathrm{} \int \mid {f + g}\mid \mathrm{d} \mu \leq \int \mid f\mid \mathrm{d} \mu + \int \mid g\mid \mathrm{d} \mu$$
103 |
104 | So if $f, g \in {\mathcal{L}^1} \left(\mu\right)$ we have $f + g \in {\mathcal{L}^1} \left(\mu\right)$
105 |
106 | From the definition of the $1$-seminorm, we also have that:
107 |
108 | $$\| {f + g}\|_1 \leq \| f\|_1 + \| g\|_1$$
109 |
110 | immediately.
111 |
112 | $\square$
113 |
114 |
115 | === Case 3: $p = \infty$ ===
116 |
117 | Suppose $f, g \in {\mathcal{L}^\infty} \left(\mu\right)$.
118 |
119 | Then from the definition of the $\mathcal{L}^\infty$-space, there exists $\mu$-null sets $N_1$ and $N_2$ such that:
120 |
121 | $$\mid {f (x)}\mid \leq \| f\|_\infty \text{ for } x \not \in N_1$$
122 |
123 | and:
124 |
125 | $$\mid {g (x)}\mid \leq \| g\|_\infty\text{ for }x \not \in N_2$$
126 |
127 | Then, for $x \not \in N_1 \cup N_2$ we have:
128 |
129 | $$\mid {f (x) + g (x)}\mid \leq \| f\|_\infty + \| g\|_\infty$$
130 |
131 | by the Triangle Inequality.
132 |
133 | From Null Sets Closed under Countable Union, we have:
134 |
135 | $N_1 \cup N_2$ is $\mu$-null.
136 |
137 | So:
138 |
139 | $$\| {f + g}\|_\infty \leq \| f\|_\infty + \| g\|_\infty$$
140 |
141 | as desired.
142 |
143 | $\blacksquare$
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CheckMate: A Prototype Adaptable Platform for Interactive Comparative Evaluation of LLMs
2 |
3 | We include code for our protoype interactive LLM evaluation platform, CheckMate, as introduced in our [PNAS paper](https://www.pnas.org/doi/10.1073/pnas.2318124121).
4 |
5 | If you have any questions or challenges, please feel free to post a GitHub Issue! [NOTE you may need Gradio version 3.24.0]
6 |
7 | 
8 |
9 | We include an overview of how to adapt the platform for your own tasks in the User Guide of our [working paper](https://arxiv.org/abs/2306.01694).
10 |
11 | The data we have already collected, as part of MathConverse, is posted in ``data/mathconverse_parsed_interactions.csv``. Columns are as follows:
12 | * model: name of the model the user was interacting with. note, participants did not know model identity when interacting.
13 | * human_interactions: queries provided by the human during the interaction trace. each entry in the list was an interaction in the same interaction trace.
14 | * model_responses: the model's response associated with each query.
15 | * correctness_ratings: participants' ratings of mathematical correctness for each model response.
16 | * helpfulness_ratings: participants' ratings of perceived helpfulness for each model response.
17 | * solo_solve: the participants' self-declared confidence in their ability to solve the problem on their own in advance. MISSING if the participant did not provide.
18 | * problem_name: name of the problem interacting with (see data/ for all problems).
19 | * selected_topic: topic the participant selected to interact with.
20 | * uid: a unique, randomly generated id to associate with that participant's round of interactions.
21 | * time_taken: time (in sec) spent by the user in total on the model interactions and ratings.
22 | * mth_bkgrd: self-declared level of mathematical experience.
23 | * ai_play_bkgrd: self-declared amount of experience interacting with AI systems prior to participating in the survey.
24 | * interaction_set_idx: order of the set of three interactions that the participant was undertaking (zero-indexed; e.g., if this is 1, then this is the second round of three model ratings the participant is providing).
25 | * final_prefs: user-provided preferences over the models. MISSING if incomplete or not provided.
26 |
27 | NEW!!! We have also uploaded an annotated taxonomy of user queries at ``data/annotated_taxonomy.csv``
28 |
29 | We will provide a further processing script shortly. ``questions_to_ask.txt`` are a set of pre-registered questions that we wanted to ask of the data. Questions were written prior to any data collection; these were last updated on April 6, 2023.
30 |
31 | ## Launching the server
32 | At present, the CheckMate code is seeded with the interface to run our mathematics evaluation. To start the code, you should provide your own API key in ``model_generate.py``. You can launch the survey by running: ``gradio experiment.py`` assuming that you have installed [gradio](https://gradio.app/). We used gradio version 3.19.0 but later versions should also work.
33 |
34 | ## Contact
35 | If you have any questions, please do not hesitate to add as an Issue to our repo, or reach out to kmc61@cam.ac.uk and/or qj213@cam.ac.uk.
36 |
37 | ## Citation
38 | If you use our code and/or data, please consider citing us at:
39 | ```
40 | @article{collinsJiang2023interactiveMathEval,
41 | author = {Katherine M. Collins and Albert Q. Jiang and Simon Frieder and Lionel Wong and Miri Zilka and Umang Bhatt and Thomas Lukasiewicz and Yuhuai Wu and Joshua B. Tenenbaum and William Hart and Timothy Gowers and Wenda Li and Adrian Weller and Mateja Jamnik },
42 | title = {Evaluating language models for mathematics through interactions},
43 | journal = {Proceedings of the National Academy of Sciences},
44 | volume = {121},
45 | number = {24},
46 | pages = {e2318124121},
47 | year = {2024},
48 | doi = {10.1073/pnas.2318124121},
49 | URL = {https://www.pnas.org/doi/abs/10.1073/pnas.2318124121},
50 | eprint = {https://www.pnas.org/doi/pdf/10.1073/pnas.2318124121},
51 | abstract = {There is much excitement about the opportunity to harness the power of large language models (LLMs) when building problem-solving assistants. However, the standard methodology of evaluating LLMs relies on static pairs of inputs and outputs; this is insufficient for making an informed decision about which LLMs are best to use in an interactive setting, and how that varies by setting. Static assessment therefore limits how we understand language model capabilities. We introduce CheckMate, an adaptable prototype platform for humans to interact with and evaluate LLMs. We conduct a study with CheckMate to evaluate three language models (InstructGPT, ChatGPT, and GPT-4) as assistants in proving undergraduate-level mathematics, with a mixed cohort of participants from undergraduate students to professors of mathematics. We release the resulting interaction and rating dataset, MathConverse. By analyzing MathConverse, we derive a taxonomy of human query behaviors and uncover that despite a generally positive correlation, there are notable instances of divergence between correctness and perceived helpfulness in LLM generations, among other findings. Further, we garner a more granular understanding of GPT-4 mathematical problem-solving through a series of case studies, contributed by experienced mathematicians. We conclude with actionable takeaways for ML practitioners and mathematicians: models that communicate uncertainty, respond well to user corrections, and can provide a concise rationale for their recommendations, may constitute better assistants. Humans should inspect LLM output carefully given their current shortcomings and potential for surprising fallibility.}}
52 | ```
53 |
--------------------------------------------------------------------------------
/model_generate.py:
--------------------------------------------------------------------------------
1 | from constants import model_options, MAX_CONVERSATION_LENGTH, MAX_TOKENS_PER_GENERATION, SAMPLING_TEMPERATURE
2 |
3 | import gradio as gr
4 | import openai
5 |
6 | oai_key = "" # ADD YOUR KEY
7 | openai.api_key = oai_key
8 |
9 |
10 | def generate(model, prompt):
11 | assert model in model_options
12 | if model == "codegpt" or model == "textgpt" or model == "instructgpt":
13 | oai_model_name = {
14 | "codegpt": "code-davinci-002",
15 | "textgpt": "text-davinci-003",
16 | "instructgpt": "text-davinci-003"
17 | }
18 | completion = openai.Completion.create(
19 | model=oai_model_name[model],
20 | prompt=prompt,
21 | max_tokens=256,
22 | temperature=0,
23 | stop=["Question:"]
24 | )
25 | return completion.choices[0].text
26 | elif model == "chatgpt" or model == "chatgpt4":
27 | oai_model_name = {
28 | "chatgpt": "gpt-3.5-turbo",
29 | "chatgpt4": "gpt-4"
30 | }
31 | message_string = prompt.replace("Question:", "user:")
32 | message_string = message_string.replace("Answer:", "assistant:")
33 | messages = message_string.split("")
34 | messages = [m.strip() for m in messages]
35 | messages = [m for m in messages if m]
36 | conversation = []
37 | for message in messages:
38 | if message.startswith("user:"):
39 | conversation.append({"role": "user", "content": message[5:]})
40 | elif message.startswith("assistant:"):
41 | conversation.append({"role": "assistant", "content": message[10:]})
42 | else:
43 | raise AssertionError(message)
44 | conversation = [{"role": "system", "content": "You are an assistant to a professional mathematician."}, conversation[-2]]
45 | sentence = openai.ChatCompletion.create(
46 | model=oai_model_name[model],
47 | messages=conversation,
48 | max_tokens=256
49 | )
50 | return sentence.choices[0].message.content
51 | else:
52 | raise NotImplementedError
53 |
54 | def generate_with_chatbot_divisors(model, prompt):
55 | return openai.Completion.create(
56 | model="code-davinci-002",
57 | prompt=prompt,
58 | max_tokens=256,
59 | temperature=0,
60 | stop=["User:", "AI:"]
61 | )["choices"][0]["text"]
62 |
63 |
64 | def legacy_chatbot_generate(user_input, history=[]):
65 | history.append(f"User: {user_input.strip()}")
66 | prompt = "\n".join(history) + f"\nAI:"
67 | response = generate_with_chatbot_divisors(None, prompt)
68 | history.append(f"AI: {response.strip()}")
69 | conversations = [(history[i], history[i+1]) for i in range(0, len(history)-1, 2)]
70 |
71 | # Whether the textbox and the submit button should be hidden
72 | if len(history) >= 2*MAX_CONVERSATION_LENGTH:
73 | return conversations, history, gr.update(visible=False), gr.update(visible=False)
74 | else:
75 | return conversations, history, gr.update(visible=True), gr.update(visible=True)
76 |
77 |
78 | ########################################
79 | # The above should not be used anymore #
80 | ########################################
81 | def query_a_chat_completion(model, messages):
82 | assert model in ["gpt-3.5-turbo", "gpt-4"]
83 | completion = openai.ChatCompletion.create(
84 | model=model,
85 | messages=messages,
86 | max_tokens=MAX_TOKENS_PER_GENERATION,
87 | temperature=SAMPLING_TEMPERATURE
88 | )
89 | return completion.choices[0].message.content
90 |
91 | def pretend_a_chat_completion(model, messages):
92 | assert model == "text-davinci-003"
93 | # Create an instruction prompt
94 | prompt = "Help a professional mathematician solve a problem:\n"
95 | for message in messages:
96 | if message["role"] == "user":
97 | prompt += f"User: {message['content']}\n"
98 | elif message["role"] == "assistant":
99 | prompt += f"AI: {message['content']}\n"
100 | else:
101 | pass
102 | prompt += "AI:"
103 | # print(prompt)
104 | completion = openai.Completion.create(
105 | model=model,
106 | prompt=prompt,
107 | max_tokens=MAX_TOKENS_PER_GENERATION,
108 | temperature=SAMPLING_TEMPERATURE
109 | )
110 | return completion["choices"][0]["text"]
111 |
112 |
113 | def chatbot_generate(user_newest_input, history, model):
114 | """
115 | Generate the next response from the chatbot
116 | :param user_newest_input: The newest input from the user
117 | :param history: The history of the conversation
118 | list[str], where each element starts with "User:" or "AI:"
119 | :return: The chatbot state, the history, the text, the submit button
120 | """
121 | # convert to openai model format
122 | actual_model = {
123 | "chatgpt": "gpt-3.5-turbo",
124 | "chatgpt4": "gpt-4",
125 | "instructgpt": "text-davinci-003"
126 | }[model]
127 |
128 | # Update the history with newest user input
129 | history.append(f"User: {user_newest_input.strip()}")
130 |
131 | # construct chat messages
132 | chat_messages = [{"role": "system", "content": "You are a helpful assistant to a professional mathematician."}]
133 | for hist in history:
134 | if hist.startswith("User:"):
135 | chat_messages.append(
136 | {
137 | "role": "user",
138 | "content": hist[5:].strip()
139 | }
140 | )
141 | elif hist.startswith("AI:"):
142 | chat_messages.append(
143 | {
144 | "role": "assistant",
145 | "content": hist[3:].strip()
146 | }
147 | )
148 | else:
149 | raise NotImplementedError
150 |
151 | # Get the generation from OpenAI
152 | if actual_model in ["gpt-3.5-turbo", "gpt-4"]:
153 | ai_newest_output = query_a_chat_completion(actual_model, chat_messages)
154 | elif actual_model == "text-davinci-003":
155 | ai_newest_output = pretend_a_chat_completion(actual_model, chat_messages)
156 | else:
157 | raise NotImplementedError
158 |
159 | # Update the history with newest AI output
160 | history.append(f"AI: {ai_newest_output.strip()}")
161 | conversations = [(history[i], history[i+1]) for i in range(0, len(history)-1, 2)]
162 |
163 | # Whether the textbox and the submit button should be hidden
164 | if len(history) >= 2*MAX_CONVERSATION_LENGTH:
165 | return conversations, history, gr.update(visible=False), gr.update(visible=False)
166 | else:
167 | return conversations, history, gr.update(visible=True), gr.update(visible=True)
168 |
--------------------------------------------------------------------------------