Skip to content

Commit

Permalink
[FTheoryTools] Code improvements as suggested by lgoettgens
Browse files Browse the repository at this point in the history
  • Loading branch information
HereAround committed Jan 11, 2025
1 parent 1e3e098 commit 75a0598
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 52 deletions.
8 changes: 4 additions & 4 deletions experimental/FTheoryTools/src/G4Fluxes/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ G4-flux candidate
# Compute the cohomology class corresponding to the hypersurface equation
cy = polynomial(cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m)))))

n = length(gens(cox_ring(base_space(m))))
n = ngens(cox_ring(base_space(m)))
c_ds = [polynomial(cohomology_class(d)) for d in torusinvariant_prime_divisors(ambient_space(m))[1:n]]
zero_sec = zero_section_class(m)

Expand Down Expand Up @@ -243,13 +243,13 @@ G4-flux candidate
cy = polynomial(cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m)))))

# Identify the cohomology classes of all base divisors
n = length(gens(cox_ring(base_space(m))))
n = ngens(cox_ring(base_space(m)))
c_ds = [polynomial(cohomology_class(d)) for d in torusinvariant_prime_divisors(ambient_space(m))[1:n]]

# Identify the cohomology classes of all exceptional divisors
gS = gens(cox_ring(ambient_space(m)))
exceptional_divisor_positions = findall(x -> occursin(r"^e\d+$", x), string.(gS))
exceptional_divisors = [torusinvariant_prime_divisors(ambient_space(m))[k] for k in exceptional_divisor_positions];
exceptional_divisor_positions = findall(x -> occursin(r"^e\d+$", x), string.(symbols(cox_ring(ambient_space(m)))))
exceptional_divisors = torusinvariant_prime_divisors(ambient_space(m))[exceptional_divisor_positions]
c_ei = [polynomial(cohomology_class(d)) for d in exceptional_divisors]

# now execute the checks if any non-Abelian gauge group factor is broken
Expand Down
96 changes: 51 additions & 45 deletions experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ julia> length(g4_amb_list) == 172
true
```
"""
function ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Vector{CohomologyClass}
function ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)

# Entry check
@req base_space(m) isa NormalToricVariety "Base space must be a toric variety for computation of ambient space G4 candidates"
if has_attribute(m, :ambient_space_models_of_g4_fluxes)
return get_attribute(m, :ambient_space_models_of_g4_fluxes)
return get_attribute(m, :ambient_space_models_of_g4_fluxes)::Vector{CohomologyClass}
end

# Execute entry tests in computation of basis_of_h22. If any of these fail, no need to proceed. Hence, do this first.
Expand Down Expand Up @@ -104,7 +104,7 @@ function ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool

set_attribute!(m, :ambient_space_models_of_g4_fluxes, filtered_h22_basis)
set_attribute!(m, :ambient_space_models_of_g4_fluxes_indices, filtered_h22_basis_indices)
return filtered_h22_basis
return filtered_h22_basis::Vector{CohomologyClass}

end

Expand Down Expand Up @@ -195,7 +195,7 @@ julia> passes_elementary_quantization_checks(g4)
true
```
"""
function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Tuple{QQMatrix, QQMatrix}
function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)

# (1) Entry checks
@req base_space(m) isa NormalToricVariety "Computation of well-quantized G4-fluxes only supported for toric base and ambient spaces"
Expand All @@ -205,7 +205,7 @@ function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryMode
@req is_simplicial(ambient_space(m)) "Computation of well-quantized G4-fluxes only supported for simplicial toric ambient space"
end
if has_attribute(m, :well_quantized_ambient_space_models_of_g4_fluxes)
return get_attribute(m, :well_quantized_ambient_space_models_of_g4_fluxes)
return get_attribute(m, :well_quantized_ambient_space_models_of_g4_fluxes)::Tuple{QQMatrix, QQMatrix}

Check warning on line 208 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L208

Added line #L208 was not covered by tests
end


Expand All @@ -226,19 +226,21 @@ function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryMode


# (3) Are intersection numbers known?
inter_dict = Dict{NTuple{4, Int64}, ZZRingElem}()
s_inter_dict = Dict{String, ZZRingElem}()
if has_attribute(m, :inter_dict)
inter_dict = get_attribute(m, :inter_dict)
end
if has_attribute(m, :s_inter_dict)
s_inter_dict = get_attribute(m, :s_inter_dict)
end
inter_dict = if has_attribute(m, :inter_dict)
get_attribute(m, :inter_dict)

Check warning on line 230 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L230

Added line #L230 was not covered by tests
else
Dict{NTuple{4, Int64}, ZZRingElem}()
end::Dict{NTuple{4, Int64}, ZZRingElem}
s_inter_dict = if has_attribute(m, :s_inter_dict)
get_attribute(m, :s_inter_dict)

Check warning on line 235 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L235

Added line #L235 was not covered by tests
else
Dict{String, ZZRingElem}()
end::Dict{String, ZZRingElem}


# (4) Obtain critical information - this may take significant time!
ambient_space_flux_candidates_basis = ambient_space_models_of_g4_fluxes(m, check = check)
ambient_space_flux_candidates_basis_indices = get_attribute(m, :ambient_space_models_of_g4_fluxes_indices)
ambient_space_flux_candidates_basis_indices = get_attribute(m, :ambient_space_models_of_g4_fluxes_indices)::Vector{Tuple{Int64, Int64}}
list_of_divisor_pairs_to_be_considered = Oscar._ambient_space_divisor_pairs_to_be_considered(m)


Expand All @@ -262,7 +264,7 @@ function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryMode

# Cover all other case with generic, but potentially painfully slow methodology.
tds = torusinvariant_prime_divisors(ambient_space(m))
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
cds = [cohomology_class(td) for td in tds]
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
for i in 1:length(ambient_space_flux_candidates_basis)
condition = Vector{ZZRingElem}()
Expand Down Expand Up @@ -328,7 +330,7 @@ function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryMode


# (10) Finally, return the result
return res
return res::Tuple{QQMatrix, QQMatrix}

end

Expand Down Expand Up @@ -435,7 +437,7 @@ julia> passes_verticality_checks(qsm_g4_candidate)
true
```
"""
function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Tuple{QQMatrix, QQMatrix}
function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)

# (1) Entry checks
@req base_space(m) isa NormalToricVariety "Computation of well-quantized G4-fluxes only supported for toric base and ambient spaces"
Expand All @@ -445,7 +447,7 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra
@req is_simplicial(ambient_space(m)) "Computation of well-quantized G4-fluxes only supported for simplicial toric ambient space"
end
if has_attribute(m, :well_quantized_and_vertical_ambient_space_models_of_g4_fluxes)
return get_attribute(m, :well_quantized_and_vertical_ambient_space_models_of_g4_fluxes)
return get_attribute(m, :well_quantized_and_vertical_ambient_space_models_of_g4_fluxes)::Tuple{QQMatrix, QQMatrix}

Check warning on line 450 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L450

Added line #L450 was not covered by tests
end


Expand All @@ -466,20 +468,22 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra


# (3) Are intersection numbers known?
inter_dict = Dict{NTuple{4, Int64}, ZZRingElem}()
s_inter_dict = Dict{String, ZZRingElem}()
if has_attribute(m, :inter_dict)
inter_dict = get_attribute(m, :inter_dict)
end
if has_attribute(m, :s_inter_dict)
s_inter_dict = get_attribute(m, :s_inter_dict)
end
inter_dict = if has_attribute(m, :inter_dict)
get_attribute(m, :inter_dict)
else
Dict{NTuple{4, Int64}, ZZRingElem}()
end::Dict{NTuple{4, Int64}, ZZRingElem}
s_inter_dict = if has_attribute(m, :s_inter_dict)
get_attribute(m, :s_inter_dict)
else
Dict{String, ZZRingElem}()
end::Dict{String, ZZRingElem}


# (4) Obtain critical information - this may take significant time!
ambient_space_flux_candidates_basis = ambient_space_models_of_g4_fluxes(m, check = check)
list_of_base_divisor_pairs_to_be_considered = Oscar._ambient_space_base_divisor_pairs_to_be_considered(m)
ambient_space_flux_candidates_basis_indices = get_attribute(m, :ambient_space_models_of_g4_fluxes_indices)
ambient_space_flux_candidates_basis_indices = get_attribute(m, :ambient_space_models_of_g4_fluxes_indices)::Vector{Tuple{Int64, Int64}}
list_of_divisor_pairs_to_be_considered = Oscar._ambient_space_divisor_pairs_to_be_considered(m)


Expand Down Expand Up @@ -515,7 +519,7 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra

# Cover all other case with generic, but potentially painfully slow methodology.
tds = torusinvariant_prime_divisors(ambient_space(m))
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
cds = [cohomology_class(td) for td in tds]
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
for i in 1:length(ambient_space_flux_candidates_basis)

Expand Down Expand Up @@ -582,7 +586,7 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra

# Cover all other case with generic, but potentially painfully slow methodology.
tds = torusinvariant_prime_divisors(ambient_space(m))
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
cds = [cohomology_class(td) for td in tds]
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
for i in 1:length(ambient_space_flux_candidates_basis)
condition = Vector{ZZRingElem}()
Expand Down Expand Up @@ -637,7 +641,7 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra


# (12) Finally, return the result
return res
return res::Tuple{QQMatrix, QQMatrix}

end

Expand Down Expand Up @@ -752,7 +756,7 @@ julia> breaks_non_abelian_gauge_group(qsm_g4_candidate)
false
```
"""
function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Tuple{QQMatrix, QQMatrix}
function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)

# (1) Entry checks
@req base_space(m) isa NormalToricVariety "Computation of well-quantized G4-fluxes only supported for toric base and ambient spaces"
Expand All @@ -762,7 +766,7 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb
@req is_simplicial(ambient_space(m)) "Computation of well-quantized G4-fluxes only supported for simplicial toric ambient space"

Check warning on line 766 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L765-L766

Added lines #L765 - L766 were not covered by tests
end
if has_attribute(m, :well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes)
return get_attribute(m, :well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes)
return get_attribute(m, :well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes)::Tuple{QQMatrix, QQMatrix}

Check warning on line 769 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L769

Added line #L769 was not covered by tests
end


Expand All @@ -783,25 +787,27 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb


# (3) Are intersection numbers known?
inter_dict = Dict{NTuple{4, Int64}, ZZRingElem}()
s_inter_dict = Dict{String, ZZRingElem}()
if has_attribute(m, :inter_dict)
inter_dict = get_attribute(m, :inter_dict)
end
if has_attribute(m, :s_inter_dict)
s_inter_dict = get_attribute(m, :s_inter_dict)
end
inter_dict = if has_attribute(m, :inter_dict)
get_attribute(m, :inter_dict)

Check warning on line 791 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L791

Added line #L791 was not covered by tests
else
Dict{NTuple{4, Int64}, ZZRingElem}()
end::Dict{NTuple{4, Int64}, ZZRingElem}
s_inter_dict = if has_attribute(m, :s_inter_dict)
get_attribute(m, :s_inter_dict)

Check warning on line 796 in experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl#L796

Added line #L796 was not covered by tests
else
Dict{String, ZZRingElem}()
end::Dict{String, ZZRingElem}


# (4) Obtain critical information - this may take significant time!
ambient_space_flux_candidates_basis = ambient_space_models_of_g4_fluxes(m, check = check)
list_of_base_divisor_pairs_to_be_considered = Oscar._ambient_space_base_divisor_pairs_to_be_considered(m)
ambient_space_flux_candidates_basis_indices = get_attribute(m, :ambient_space_models_of_g4_fluxes_indices)
ambient_space_flux_candidates_basis_indices = get_attribute(m, :ambient_space_models_of_g4_fluxes_indices)::Vector{Tuple{Int64, Int64}}
list_of_divisor_pairs_to_be_considered = Oscar._ambient_space_divisor_pairs_to_be_considered(m)


# (5) The following is fragile, but hopefully is a starting point
exceptional_divisor_positions = findall(x -> occursin(r"^e\d+$", x), string.(gS))
exceptional_divisor_positions = findall(x -> occursin(r"^e\d+$", x), string.(symbols(S)))


# (6) Work out the relevant intersection numbers to tell if a flux is vertical
Expand Down Expand Up @@ -845,7 +851,7 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb

# Cover all other case with generic, but potentially painfully slow methodology.
tds = torusinvariant_prime_divisors(ambient_space(m))
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
cds = [cohomology_class(td) for td in tds]
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
for i in 1:length(ambient_space_flux_candidates_basis)

Expand Down Expand Up @@ -926,7 +932,7 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb

# Cover all other case with generic, but potentially painfully slow methodology.
tds = torusinvariant_prime_divisors(ambient_space(m))
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
cds = [cohomology_class(td) for td in tds]
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
for i in 1:length(ambient_space_flux_candidates_basis)
condition = Vector{ZZRingElem}()
Expand Down Expand Up @@ -981,6 +987,6 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb


# (12) Finally, return the result
return res
return res::Tuple{QQMatrix, QQMatrix}

end
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function tune(h::HypersurfaceModel, input_sections::Dict{String, <:Any}; complet
# 2. Compute the new hypersurface equation
parametrized_hypersurface_equation = hypersurface_equation_parametrization(h)
R = parent(parametrized_hypersurface_equation)
vars = [string(k) for k in symbols(R)]
vars = string.(symbols(R))
S = cox_ring(ambient_space(h))
images = [k in secs_names ? eval_poly(string(explicit_secs[k]), S) : k == "Kbar" ? eval_poly("0", S) : eval_poly(k, S) for k in vars]
map = hom(R, S, images; check=false)
Expand Down
4 changes: 2 additions & 2 deletions experimental/FTheoryTools/src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ function _kodaira_type(id::MPolyIdeal{<:MPolyRingElem}, ords::Tuple{Int64, Int64
d = discriminant(w)

# For now, we explicitly require that the gauge ideal is principal
@req (length(gens(id)) == 1) "Gauge ideal is not principal"
@req (ngens(id) == 1) "Gauge ideal is not principal"

# Over concrete bases, we randomly reduce the polynomials defining the gauge
# divisor to only two variables so that the is_radical check is faster. This
# could give an incorrect result (radical or not), so we actually try this
# five times and see if we get agreement among all of the results
num_gens = length(gens(parent(f)))
num_gens = ngens(parent(f))
gauge2s, f2s, g2s, d2s = [], [], [], []
if rand_seed != nothing
Random.seed!(rand_seed)
Expand Down

0 comments on commit 75a0598

Please sign in to comment.