Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Michael Thomas Barz
/
BKK-verifier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
32e57312
authored
Jan 17, 2022
by
Michael Barz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add BKK checker to a public repo
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
0 deletions
BKKchecker.ipynb
BKKchecker.ipynb
0 → 100644
View file @
32e57312
{
"cells": [
{
"cell_type": "markdown",
"id": "pressing-loading",
"metadata": {},
"source": [
"Starting with a set $ A \\subseteq \\mathbb{Z}^d, $ we figure out a set of equations defining $ X^A, $ and then compute the degree of $ X^A. $"
]
},
{
"cell_type": "code",
"execution_count": 155,
"id": "disabled-forth",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 155,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = [ [1,0], [0,1], [2,0], [1,1], [1,2] ]\n",
"# Warning: Do not input [0,...,0] as a vector in A;\n",
"# it is automatically added to homogenize throughout\n",
"# the code execution.\n",
"\n",
"parameters = [ \"t\" + str(i+1) for i in range(len(A[0])) ]\n",
"variables = [ \"x\" + str(i+1) for i in range(len(A)) ]\n",
"\n",
"R = PolynomialRing(CC, parameters + variables)\n",
"\n",
"def make_term(i, exponent):\n",
" term = \"x\" + str(i+1) + \" - \"\n",
" second = \"1\"\n",
" for j in range(len(exponent)):\n",
" e = exponent[j]\n",
" if e > 0:\n",
" second = second + \" * \" + \"t\" + str(j+1) + \"^(\" + str(e) + \")\"\n",
" return (term + second)\n",
"\n",
"# this ideal is the affine variety; now we homogenize\n",
"I = R.ideal([make_term(i, A[i]) for i in range(len(variables))])\n",
"\n",
"S = PolynomialRing(CC, variables)\n",
"\n",
"# By elimination theory, if we take a Groebner basis of I, \n",
"# and then remove all the terms containing a 'ti' parameter,\n",
"# we get an equation for our affine variety.\n",
"def filter_basis(basis):\n",
" filtered_basis = []\n",
" for poly in basis:\n",
" poly_str = str(poly)\n",
" if not ('t' in poly_str):\n",
" filtered_basis.append(poly_str)\n",
" return filtered_basis\n",
"\n",
"# So, take the ideal of our affine variety,\n",
"# and then homogenize with a new variable x0.\n",
"J = S.ideal(filter_basis(I.groebner_basis()))\n",
"\n",
"K = J.homogenize(\"x0\")\n",
"\n",
"# now, we can compute deg(X^A), since\n",
"# the Hilbert polynomial of X^A is\n",
"# deg(X^A) * t^d/d! + O(t^{d-1})\n",
"hilbert_poly = K.hilbert_polynomial()\n",
"\n",
"# output degree!\n",
"\n",
"dimension = hilbert_poly.degree()\n",
"factorial(dimension) * hilbert_poly.coefficients()[-1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "disabled-uncle",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 9.2",
"language": "sage",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment