Skip to content

Commit d2c7128

Browse files
committed
[FTheoryTools] Code improvements as suggested by @lgoettgens
1 parent 7255b9c commit d2c7128

File tree

4 files changed

+58
-52
lines changed

4 files changed

+58
-52
lines changed

experimental/FTheoryTools/src/G4Fluxes/properties.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ G4-flux candidate
122122
# Compute the cohomology class corresponding to the hypersurface equation
123123
cy = polynomial(cohomology_class(toric_divisor_class(ambient_space(m), degree(hypersurface_equation(m)))))
124124

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

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

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

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

255255
# now execute the checks if any non-Abelian gauge group factor is broken

experimental/FTheoryTools/src/G4Fluxes/special_attributes.jl

+51-45
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ julia> length(g4_amb_list) == 172
3838
true
3939
```
4040
"""
41-
function ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Vector{CohomologyClass}
41+
function ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)
4242

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

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

105105
set_attribute!(m, :ambient_space_models_of_g4_fluxes, filtered_h22_basis)
106106
set_attribute!(m, :ambient_space_models_of_g4_fluxes_indices, filtered_h22_basis_indices)
107-
return filtered_h22_basis
107+
return filtered_h22_basis::Vector{CohomologyClass}
108108

109109
end
110110

@@ -195,7 +195,7 @@ julia> passes_elementary_quantization_checks(g4)
195195
true
196196
```
197197
"""
198-
function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Tuple{QQMatrix, QQMatrix}
198+
function well_quantized_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)
199199

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

211211

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

227227

228228
# (3) Are intersection numbers known?
229-
inter_dict = Dict{NTuple{4, Int64}, ZZRingElem}()
230-
s_inter_dict = Dict{String, ZZRingElem}()
231-
if has_attribute(m, :inter_dict)
232-
inter_dict = get_attribute(m, :inter_dict)
233-
end
234-
if has_attribute(m, :s_inter_dict)
235-
s_inter_dict = get_attribute(m, :s_inter_dict)
236-
end
229+
inter_dict = if has_attribute(m, :inter_dict)
230+
get_attribute(m, :inter_dict)
231+
else
232+
Dict{NTuple{4, Int64}, ZZRingElem}()
233+
end::Dict{NTuple{4, Int64}, ZZRingElem}
234+
s_inter_dict = if has_attribute(m, :s_inter_dict)
235+
get_attribute(m, :s_inter_dict)
236+
else
237+
Dict{String, ZZRingElem}()
238+
end::Dict{String, ZZRingElem}
237239

238240

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

244246

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

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

329331

330332
# (10) Finally, return the result
331-
return res
333+
return res::Tuple{QQMatrix, QQMatrix}
332334

333335
end
334336

@@ -435,7 +437,7 @@ julia> passes_verticality_checks(qsm_g4_candidate)
435437
true
436438
```
437439
"""
438-
function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)::Tuple{QQMatrix, QQMatrix}
440+
function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)
439441

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

451453

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

467469

468470
# (3) Are intersection numbers known?
469-
inter_dict = Dict{NTuple{4, Int64}, ZZRingElem}()
470-
s_inter_dict = Dict{String, ZZRingElem}()
471-
if has_attribute(m, :inter_dict)
472-
inter_dict = get_attribute(m, :inter_dict)
473-
end
474-
if has_attribute(m, :s_inter_dict)
475-
s_inter_dict = get_attribute(m, :s_inter_dict)
476-
end
471+
inter_dict = if has_attribute(m, :inter_dict)
472+
get_attribute(m, :inter_dict)
473+
else
474+
Dict{NTuple{4, Int64}, ZZRingElem}()
475+
end::Dict{NTuple{4, Int64}, ZZRingElem}
476+
s_inter_dict = if has_attribute(m, :s_inter_dict)
477+
get_attribute(m, :s_inter_dict)
478+
else
479+
Dict{String, ZZRingElem}()
480+
end::Dict{String, ZZRingElem}
477481

478482

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

485489

@@ -515,7 +519,7 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra
515519

516520
# Cover all other case with generic, but potentially painfully slow methodology.
517521
tds = torusinvariant_prime_divisors(ambient_space(m))
518-
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
522+
cds = [cohomology_class(td) for td in tds]
519523
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
520524
for i in 1:length(ambient_space_flux_candidates_basis)
521525

@@ -582,7 +586,7 @@ function well_quantized_and_vertical_ambient_space_models_of_g4_fluxes(m::Abstra
582586

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

638642

639643
# (12) Finally, return the result
640-
return res
644+
return res::Tuple{QQMatrix, QQMatrix}
641645

642646
end
643647

@@ -752,7 +756,7 @@ julia> breaks_non_abelian_gauge_group(qsm_g4_candidate)
752756
false
753757
```
754758
"""
755-
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}
759+
function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes(m::AbstractFTheoryModel; check::Bool = true)
756760

757761
# (1) Entry checks
758762
@req base_space(m) isa NormalToricVariety "Computation of well-quantized G4-fluxes only supported for toric base and ambient spaces"
@@ -762,7 +766,7 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb
762766
@req is_simplicial(ambient_space(m)) "Computation of well-quantized G4-fluxes only supported for simplicial toric ambient space"
763767
end
764768
if has_attribute(m, :well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes)
765-
return get_attribute(m, :well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes)
769+
return get_attribute(m, :well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_ambient_space_models_of_g4_fluxes)::Tuple{QQMatrix, QQMatrix}
766770
end
767771

768772

@@ -783,25 +787,27 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb
783787

784788

785789
# (3) Are intersection numbers known?
786-
inter_dict = Dict{NTuple{4, Int64}, ZZRingElem}()
787-
s_inter_dict = Dict{String, ZZRingElem}()
788-
if has_attribute(m, :inter_dict)
789-
inter_dict = get_attribute(m, :inter_dict)
790-
end
791-
if has_attribute(m, :s_inter_dict)
792-
s_inter_dict = get_attribute(m, :s_inter_dict)
793-
end
790+
inter_dict = if has_attribute(m, :inter_dict)
791+
get_attribute(m, :inter_dict)
792+
else
793+
Dict{NTuple{4, Int64}, ZZRingElem}()
794+
end::Dict{NTuple{4, Int64}, ZZRingElem}
795+
s_inter_dict = if has_attribute(m, :s_inter_dict)
796+
get_attribute(m, :s_inter_dict)
797+
else
798+
Dict{String, ZZRingElem}()
799+
end::Dict{String, ZZRingElem}
794800

795801

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

802808

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

806812

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

846852
# Cover all other case with generic, but potentially painfully slow methodology.
847853
tds = torusinvariant_prime_divisors(ambient_space(m))
848-
cds = [cohomology_class(tds[i]) for i in 1:length(tds)]
854+
cds = [cohomology_class(td) for td in tds]
849855
pt_class = cohomology_class(anticanonical_divisor_class(ambient_space(m)))
850856
for i in 1:length(ambient_space_flux_candidates_basis)
851857

@@ -926,7 +932,7 @@ function well_quantized_and_vertical_and_no_non_abelian_gauge_group_breaking_amb
926932

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

982988

983989
# (12) Finally, return the result
984-
return res
990+
return res::Tuple{QQMatrix, QQMatrix}
985991

986992
end

experimental/FTheoryTools/src/HypersurfaceModels/methods.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function tune(h::HypersurfaceModel, input_sections::Dict{String, <:Any}; complet
120120
# 2. Compute the new hypersurface equation
121121
parametrized_hypersurface_equation = hypersurface_equation_parametrization(h)
122122
R = parent(parametrized_hypersurface_equation)
123-
vars = [string(k) for k in symbols(R)]
123+
vars = string.(symbols(R))
124124
S = cox_ring(ambient_space(h))
125125
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]
126126
map = hom(R, S, images; check=false)

experimental/FTheoryTools/src/auxiliary.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ function _kodaira_type(id::MPolyIdeal{<:MPolyRingElem}, ords::Tuple{Int64, Int64
225225
d = discriminant(w)
226226

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

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

0 commit comments

Comments
 (0)