Skip to content

Commit

Permalink
Code clean up and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mbelotti committed Feb 10, 2023
1 parent 6680664 commit 5947b2c
Show file tree
Hide file tree
Showing 16 changed files with 3,630 additions and 1,573 deletions.
749 changes: 749 additions & 0 deletions .ipynb_checkpoints/Lemma22-checkpoint.ipynb

Large diffs are not rendered by default.

379 changes: 379 additions & 0 deletions .ipynb_checkpoints/tutorial-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,379 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Quadratic generation (Theorem 4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's first include all of our code in the jupyter notebook"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" ----- ----- ----- - ----- \n",
"| | | | | | | | | | \n",
"| | | | | | | | \n",
"| | ----- | | | |----- \n",
"| | | | |-----| | | \n",
"| | | | | | | | | | \n",
" ----- ----- ----- - - - - \n",
"\n",
"...combining (and extending) ANTIC, GAP, Polymake and Singular\n",
"Version\u001b[32m 0.11.2 \u001b[39m... \n",
" ... which comes with absolutely no warranty whatsoever\n",
"Type: '?Oscar' for more information\n",
"(c) 2019-2022 by The OSCAR Development Team\n"
]
},
{
"data": {
"text/plain": [
"matrix_of_exponents (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"include(\"./is_khovanskii.jl\")\n",
"include(\"./mukai_edge_graph.jl\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(Multivariate Polynomial Ring in 8 variables t, z[1], z[2], z[3], ..., z[7] over Rational Field, fmpq_mpoly[t, z[1], z[2], z[3], z[4], z[5], z[6], z[7]])"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"KS, (t,z...)=PolynomialRing(QQ, [\"t\",[\"z[$i]\" for i in 1:7]...])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4×7 Matrix{fmpq_mpoly}:\n",
" t^59 t^44 t^79 t^20 t^12 t^81 t^36\n",
" t^8 t^72 t^49 t^39 t^58 t^23 t^64\n",
" t^44 t^58 t^12 t^52 t^57 t^49 t^51\n",
" t^25 t^23 t^60 t^72 t^45 t^51 t^6"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"P=[t^59 t^44 t^79 t^20 t^12 t^81 t^36; t^8 t^72 t^49 t^39 t^58 t^23 t^64; t^44 t^58 t^12 t^52 t^57 t^49 t^51; t^25 t^23 t^60 t^72 t^45 t^51 t^6]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is just an example of a matrix for which things work out, but we have others"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#A=[t^136 t^47 t^28 t^101 t^64 t^193 t^83; t^67 t^158 t^46 t^128 t^122 t^133 t^82; t^78 t^183 t^106 t^95 t^78 t^154 t^9; t^98 t^166 t^148 t^35 t^26 t^193 t^95]\n",
"#A=[t^13 t^68 t^70 t^27 t^68 t^90 t^10; t^45 t^32 t^9 t^29 t^15 t^13 t^61; t^45 t^82 t^26 t^22 t^9 t^54 t^45; t^2 t^36 t^32 t^25 t^16 t^87 t^68]\n",
"#A=[t^96 t^77 t^27 t^21 t^20 t^63 t^76; t^35 t^98 t^80 t^81 t^60 t^85 t^53; t^23 t^22 t^76 t^53 t^99 t^31 t^97; t^27 t^84 t^30 t^79 t^56 t^21 t^74]\n",
"#A=[t^58 t^100 t^61 t^11 t^18 t^40 t^100; t^23 t^38 t^40 t^89 t^63 t^56 t^66; t^92 t^25 t^76 t^27 t^67 t^36 t^73; t^18 t^90 t^92 t^73 t^54 t^8 t^18]\n",
"#A=[t^178 t^93 t^185 t^97 t^103 t^22 t^32; t^38 t^84 t^177 t^188 t^150 t^192 t^26; t^127 t^14 t^192 t^134 t^23 t^91 t^132; t^173 t^78 t^18 t^155 t^189 t^161 t^19]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The function ``generalposition_monomeric_check`` produces the polynomials which are the images of $\\phi_{7,3}(t)(G_{7,3})$, where the map $\\phi_{7,3}$ is described in Section $3$ of the paper and the matrix $P$ is exactly the $P$ appearing in the above cell. The output of the function is:\n",
"\n",
"* A boolean ``bool`` which is true if and only if the seven points given by the columns of P are in general position as described in Section 3 of the article and the initial forms are monomeric\n",
"\n",
"\n",
"* If bool is true, a vector of integers ``deg_mon`` which gives the multidegree of the 129 generators\n",
"\n",
"* If bool is true, a vector of monomials in KS which are the initial forms of the images $\\phi_{7,3}(t)(G_{7,3})$ but with the x coordinates evaluated at one and the y called z. This is just a raw version of the initial forms which we will obtained later by calling the function ``initial_forms_of_sections``\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hyperplanes check \n",
"Quad check \n",
"Cub check \n",
"Strange check\n",
"We are doing quartic 1\n",
"We are doing quartic 2\n",
"We are doing quartic 3\n"
]
}
],
"source": [
"bool,deg_mon,equations_mon=generalposition_monomeric_check(P);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The function ``degree_two_check`` takes the vector eq_mon and equations_mon obtained as outputs of the above functions and returns a boolean which is true if and only if the Hilbert function of the algebra generated by the initial forms of $\\phi_{7,3}(t)(G_{7,3})$ is equal to the Hilbert function of the the Cox ring in degree two."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bol_degree2=degree_two_check(deg_mon,equations_mon);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now compute the actual initial forms as monomials in $\\mathbb{C}[x_1,\\dots,x_7,y_1,\\dots,y_7]$ using the function ``initial_forms_of_sections``"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"equations_mon_complete=initial_forms_of_sections(equations_mon)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now want to verify that the relations between the initial forms are actually generated by binomials of degree two, since this is the only missing step in proving that the polynomials $\\phi_{7,3}(t)(G_{7,3})$ are a Khovanskii basis for the algebra they generate. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First, we use the ``matrix_of_exponents`` that takes as an input the vector of monomials of initial forms and compute the $129\\times 14$ matrix of exponents."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"M=matrix_of_exponents(equations_mon_complete)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we use the markov_basis function of of 4ti2 in order to find generators for the ideal of relations between the monomials and we verify that the relations are all quadratic. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"function write_M_m2(M)\n",
" print(\"matrix\\\"\")\n",
" for row in range(1,129)\n",
" for col in range(1,14)\n",
" print(M[row,col])\n",
" if col!=14\n",
" print(\",\")\n",
" end\n",
" end \n",
" print(\";\")\n",
" end\n",
" print(\"\\\"\")\n",
"end"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now just take the output M2 of ``write_M_m2(M)`` and pass it to macaulay2 using the following commands\n",
"\n",
"```\n",
"installPackage \"FourTiTwo\";\n",
"toricMarkov(transpose(M2))\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ehrhart-type formulas (Section 5.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We first introduce the unimodular transformation and apply it to the vectors $(a_1, \\dots, a_7, b_1,b_3, b_5,b_7) \\in \\mathbb{Z}^{11}$ from the rows of $M$. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Unimod_transf = matrix(ZZ,[0 0 0 0 0 0 0 1 1 1 1; 1 0 0 0 0 0 0 1 0 0 0; 0 1 0 0 0 0 0 0 0 0 0; 0 0 1 0 0 0 0 0 1 0 0; 0 0 0 1 0 0 0 0 0 0 0; 0 0 0 0 1 0 0 0 0 1 0; 0 0 0 0 0 1 0 0 0 0 0; 0 0 0 0 0 0 1 0 0 0 1; 0 0 0 0 0 0 0 0 1 0 0; 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 0 0 0 1]);\n",
"M = M[:,[1,2,3,4,5,6,7,8,10,12,14]];"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"M_trans=transpose(Unimod_transf*transpose(M))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We then look at the graph $\\Gamma$ defined by the new vectors"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"C = positive_hull(M_trans)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f_vector(C)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"facets(C)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mukai edge graph (Section 6)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We define the Mukai bilinear form in the case of the blow up of $\\mathbb{P}^3$ in seven points. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"function Mukai_form(i,j)\n",
" E=deg_mon[i]\n",
" D=deg_mon[j]\n",
" return (2*E[1]*D[1]-(E[1]-E[2])*(D[1]-D[2])-(E[1]-E[3])*(D[1]-D[3])-(E[1]-E[4])*(D[1]-D[4])-(E[1]-E[5])*(D[1]-D[5])-(E[1]-E[6])*(D[1]-D[6])-(E[1]-E[7])*(D[1]-D[7])-(E[1]-E[8])*(D[1]-D[8]));\n",
"end"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We check whether the polytope defined by $M$ has Mukai edge graph. The function takes as input the matrix $M$ and the degrees given as one of the outputs `deg_mon` in the function `is_khovanskii`. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"has_Mukai_edge_graph(M,deg_mon)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.7.0",
"language": "julia",
"name": "julia-1.7"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
4 changes: 2 additions & 2 deletions Lemma22.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -733,15 +733,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.7.2",
"display_name": "Julia 1.7.0",
"language": "julia",
"name": "julia-1.7"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.7.2"
"version": "1.7.0"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 5947b2c

Please sign in to comment.