R/specifications.R

Defines functions tree_code partition_spec small_subset_partition_spec inner_model_spec norm_spec scale_spec game_spec difference_hierarchy_spec borel_hierarchy_spec pointclass_spec forcing_spec iteration_spec ultrapower_spec extender_spec measure_spec ideal_spec filter_spec embedding_spec validate_specification closure_requirements critical_point_spec .spec cardinal_iteration_spec mahlo_iteration_spec mahlo_property variants cardinal_property .record .flag .ordinal .symbol

Documented in borel_hierarchy_spec cardinal_iteration_spec cardinal_property closure_requirements critical_point_spec difference_hierarchy_spec embedding_spec extender_spec filter_spec forcing_spec game_spec ideal_spec inner_model_spec iteration_spec mahlo_iteration_spec mahlo_property measure_spec norm_spec partition_spec pointclass_spec scale_spec small_subset_partition_spec tree_code ultrapower_spec validate_specification variants

# Validated descriptions of infinite mathematical objects.
.symbol <- function(value) {
  .require(.scalar_string(value) && nzchar(value) && nchar(value)<=500L,"Expected a nonempty symbolic label"); value
}
.ordinal <- function(value) {
  if(is.list(value)) {
    .require(identical(value$type,"ordinal_term"),"Expected an ordinal term"); return(validate_record(value))
  }
  if(is.numeric(value) || (.scalar_string(value) && grepl("^[0-9]+$",value))) return(ordinal_term("finite",value))
  ordinal_term("symbol",.name(value))
}
.flag <- function(value) {
  .require(is.null(value) || (is.logical(value) && length(value)==1L && !is.na(value)),"Expected a Boolean hypothesis or NULL for unspecified"); value
}
.record <- function(family,concept,parameters,context=NULL,obligations=list()) {
  list(type="specification",schema_version="1.0",family=family,concept=concept,parameters=.plain(parameters),
    context=.context(context),status="SYMBOLIC",existence="NOT_ASSERTED",obligations=.array(obligations))
}
cardinal_property <- function(concept, kappa="kappa", context=NULL, ...) {
  record <- definition(concept); parameters <- list(...)
  .require(record$kind=="cardinal_property","Expected a cardinal-property definition")
  specs <- record$parameters
  .require(setequal(names(parameters),setdiff(names(specs),"kappa")) && !anyDuplicated(names(parameters)),"Missing or unexpected cardinal parameters")
  values <- list(kappa=.name(kappa))
  for(key in names(parameters)) {
    value <- parameters[[key]]
    if(specs[[key]]$kind=="positive_integer") {
      values[[key]] <- .natural(value); .require(values[[key]]!="0","Expected a positive integer")
    } else if(concept=="indescribable" && key=="level") {
      .require(.fields(value,c("polarity","order","alternations")),"Indescribability level needs polarity, order and alternations")
      .require(.scalar_string(value$polarity) && value$polarity %in% c("Pi","Sigma"),"Invalid complexity polarity")
      values[[key]] <- list(polarity=value$polarity,order=.natural(value$order),alternations=.natural(value$alternations))
    } else {
      values[[key]] <- .ordinal(value)
      if(key=="eta") .require(!identical(serialize(values[[key]]),serialize(ordinal_term("finite",0))),"Eta must be positive")
      if((concept=="erdos" && key=="alpha") || (concept=="nu_rowbottom" && key=="nu") ||
         (concept %in% c("lambda_supercompact","lambda_strong","lambda_compact","i0","i1","i2","i3") && key=="lambda"))
        .require(values[[key]]$kind!="finite","This parameter must be infinite")
    }
  }
  .record("cardinal",concept,values,context,c(paste0("Definition requirements: ",paste(unlist(record$requirements),collapse=", ")),
    "Existence and satisfaction of the property require separate mathematical evidence."))
}
variants <- function(concept) {
  definition(concept)
  groups <- list(c("inaccessible","weakly_inaccessible","alpha_inaccessible","alpha_weakly_inaccessible"),
    c("mahlo","weakly_mahlo","alpha_mahlo","alpha_weakly_mahlo"),c("strong","lambda_strong"),
    c("supercompact","lambda_supercompact"),c("huge","almost_huge","superhuge","n_huge"),c("rowbottom","nu_rowbottom"))
  for(g in groups) if(concept %in% g) return(sort(g,method="radix"))
  concept
}
mahlo_property <- function(kappa="kappa", weak=FALSE, context=NULL) {
  .require(is.logical(weak) && length(weak)==1L && !is.na(weak),"weak must be Boolean")
  cardinal_property(if(weak) "weakly_mahlo" else "mahlo",kappa,context)
}
mahlo_iteration_spec <- function(index, weak=FALSE, context=NULL) {
  .require(is.logical(weak) && length(weak)==1L && !is.na(weak),"weak must be Boolean")
  .record("mahlo_iteration","mahlo_operation",list(index=.ordinal(index),weak=weak,
    initial_class=if(weak) "weakly_inaccessible" else "inaccessible",successor="base_intersect_stationary_trace",limit="intersection"),context,
    c("Stationarity is relative to the specified model.","This recursion is symbolic; no transfinite enumeration is performed."))
}
cardinal_iteration_spec <- function(operator,index,initial_class="inaccessible",context=NULL) {
  .spec("cardinal_iteration",list(operator=operator,index=index,initial_class=initial_class,
    successor="previous_intersect_operator",limit="intersection"),context)
}
.spec <- function(family,parameters,context=NULL) {
  expected <- unlist(.catalogue()$specification_parameters[[family]],use.names=FALSE)
  .require(.fields(parameters,expected),"Missing or unexpected specification parameters")
  flags <- c("normal","fine","nonprincipal","zero_singletons","two_valued","well_founded","coherent","iterability","limit_property","effective","ultrafilter","weakly_amenable","externally_countably_complete","proper","contains_bounded")
  ordinal_keys <- c("completeness","additivity","length","height","rank_bound","saturation","color_bound","index")
  values <- list()
  for(key in names(parameters)) {
    value <- parameters[[key]]
    result <- if(key %in% flags && !(key=="ultrafilter" && family=="ultrapower")) .flag(value)
      else if(key %in% ordinal_keys) { if(is.null(value)) NULL else .ordinal(value) }
      else if(key=="level") .natural(value)
      else if(key %in% c("norms","axioms","parameters")) {
        .require((is.list(value) || is.character(value)) && all(vapply(as.list(value),function(x) .scalar_string(x) && nzchar(x),logical(1))),"Expected symbolic labels")
        .array(value)
      } else if(key=="arity") {
        if(identical(value,"finite_subsets")) value
        else if(family=="partition" && (is.list(value) || (.scalar_string(value) && !grepl("^[0-9]+$",value)))) {
          term <- .ordinal(value)
          if(term$kind=="finite") term$args[[1L]] else term
        } else .natural(value)
      }
      else if(key=="colors") .ordinal(value)
      else { if(is.null(value)) NULL else .symbol(value) }
    values[key] <- list(result)
  }
  if(family=="cardinal_iteration") {
    .require(values$operator %in% c("limit_points","stationary_trace"),"Unknown cardinal iteration operator")
    .require(values$initial_class %in% c("regular","weakly_inaccessible","inaccessible"),"Unknown initial cardinal class")
    .require(!is.null(values$index),"An ordinal index is required")
    .require(identical(values$successor,"previous_intersect_operator") && identical(values$limit,"intersection"),"Unknown cardinal iteration convention")
  }
  if(family=="pointclass") {
    .require(values$family %in% c("borel","projective","arithmetic","analytic_hierarchy","third_order_arithmetic"),"Unknown pointclass family")
    .require(values$polarity %in% c("Sigma","Pi","Delta"),"Invalid pointclass polarity")
    .require(!is.null(values$effective),"Effective/boldface convention must be explicit")
    if(values$family %in% c("borel","projective","third_order_arithmetic")) .require(values$level!="0","This hierarchy starts at level one")
    if(values$family=="third_order_arithmetic") .require(!values$effective,"No effective third-order convention is implemented")
  }
  if(family=="borel_hierarchy") {
    .require(!is.null(values$index) && !identical(serialize(values$index),serialize(ordinal_term("finite",0))),"Borel ranks must be positive")
    .require(values$polarity %in% c("Sigma","Pi","Delta"),"Invalid Borel polarity")
    .require(!is.null(values$effective),"Effective convention must be explicit")
    .require(identical(!is.null(values$ordinal_code),values$effective),"Specify an ordinal code exactly for an effective hierarchy")
  }
  if(family=="difference_hierarchy") {
    .require(!is.null(values$base_pointclass) && !is.null(values$index),"Base pointclass and length are required")
    .require(!is.null(values$effective),"Effective convention must be explicit")
    .require(!values$effective || !is.null(values$sequence_code),"Effective differences require a joint sequence code")
    .require(identical(values$convention,"decreasing_first_exit_odd") && identical(values$exhaustion,"use_length"),"Unknown difference convention")
  }
  if(family=="partition") {
    .require(values$variant %in% c("ordinary","square_bracket"),"Unknown partition variant")
    .require(values$variant=="square_bracket" || is.null(values$color_bound),"A color bound requires the square-bracket variant")
  }
  if(family=="small_subset_partition") {
    .require(all(vapply(values[c("kappa","gamma","coloring_model","witness_model")],function(x) !is.null(x),logical(1))),"Cardinal and model labels are required")
    .require(values$chain_order %in% c("proper_inclusion","size_separated"),"Unknown chain order")
    .require(values$homogeneous_requirement %in% c("unbounded","stationary","filter_member"),"Unknown homogeneous requirement")
    .require(!values$arity %in% c("finite_subsets","0"),"Chain length must be a positive finite integer")
    .require(identical(!is.null(values$filter_name),values$homogeneous_requirement=="filter_member"),"Specify a filter exactly for filter-member homogeneity")
    .require(!identical(serialize(values$colors),serialize(ordinal_term("finite",0))),"At least one color is required")
  }
  if(family=="inner_model") .require(values$construction %in% c("L","L[A]","L(A)","L(R)","HOD","L[U]","extender_model"),"Unknown inner-model construction")
  concepts <- c(embedding="elementary_embedding",iteration="iteration_system",forcing="forcing_poset",pointclass="projective_pointclass",game="infinite_game",scale="scale",norm="pointclass_norm",partition="partition_relation",tree_code="suslin_representation")
  concept <- if(family %in% names(concepts)) concepts[[family]] else family
  if(family=="pointclass") concept <- if(values$family=="third_order_arithmetic") "third_order_pointclass" else if(values$family=="arithmetic") "arithmetic_pointclass" else if(values$family=="analytic_hierarchy") "analytical_pointclass" else if(values$effective) "effective_pointclass" else if(values$family=="borel") "borel_pointclass" else "projective_pointclass"
  obligations <- c("All structural attributes are hypotheses, not verified properties of infinite objects.",
    "Well-foundedness, elementarity, genericity and iterability require independent evidence when relevant.")
  if(family=="borel_hierarchy") {
    concept <- if(values$effective) "effective_pointclass" else "borel_pointclass"
    obligations <- c(obligations,
      "The index must be a positive countable ordinal in the stated model.",
      "Sigma at rank one means open; higher Sigma ranks use countable unions of lower-rank Pi sets. Pi is dual and Delta is their intersection.")
    if(values$effective) obligations <- c(obligations,
      "The named ordinal code must provide a recursive presentation of the index relative to the listed real parameters, including effective limit-stage instructions.",
      "Neither validity of the ordinal notation nor membership of any set in the pointclass is verified.")
  }
  .record(family,concept,values,context,obligations)
}
critical_point_spec <- function(embedding) {
  validate_specification(embedding); .require(embedding$family=="embedding","Expected an embedding specification")
  list(symbol=embedding$parameters$critical_point,source=embedding$parameters$source,target=embedding$parameters$target,status="DECLARED",existence="NOT_ASSERTED")
}
closure_requirements <- function(embedding) {
  validate_specification(embedding); .require(embedding$family=="embedding","Expected an embedding specification")
  list(closure=embedding$parameters$closure,status="DECLARED",verified=FALSE)
}
validate_specification <- function(value) {
  .require(is.list(value) && identical(value$type,"specification"),"Expected a specification")
  family <- value$family; params <- value$parameters
  .require(is.list(params) && !is.null(names(params)),"Expected named specification parameters")
  if(identical(family,"cardinal")) expected <- do.call(cardinal_property,c(list(concept=value$concept,context=value$context),params))
  else if(identical(family,"mahlo_iteration")) {
    .require(.fields(params,c("index","weak","initial_class","successor","limit")),"Invalid iteration fields")
    expected <- mahlo_iteration_spec(params$index,params$weak,value$context)
  } else {
    .require(.scalar_string(family) && family %in% names(.catalogue()$specification_parameters),"Unknown specification family")
    expected <- .spec(family,params,value$context)
  }
  .require(identical(serialize(value),serialize(expected)),"Noncanonical or altered specification"); expected
}

# Declare source, target, critical point, language fragment and closure.
embedding_spec <- function(source="V",target="M",critical_point="kappa",elementarity="full_first_order",closure=NULL,context=NULL) {
  .spec("embedding",list(source=source,target=target,critical_point=critical_point,elementarity=elementarity,closure=closure),context)
}

# Describe a filter with separate completeness, normality and fineness hypotheses.
filter_spec <- function(carrier="kappa",completeness=NULL,normal=NULL,fine=NULL,nonprincipal=NULL,ultrafilter=NULL,weakly_amenable=NULL,externally_countably_complete=NULL,relative_model=NULL,context=NULL) {
  ctx <- .context(context)
  .spec("filter",list(carrier=carrier,completeness=completeness,normal=normal,fine=fine,nonprincipal=nonprincipal,
    ultrafilter=ultrafilter,weakly_amenable=weakly_amenable,externally_countably_complete=externally_countably_complete,
    relative_model=if(is.null(relative_model)) ctx$model else relative_model),ctx)
}

# Describe an ideal; saturation and completeness are distinct parameters.
ideal_spec <- function(carrier="kappa",completeness=NULL,saturation=NULL,normal=NULL,proper=NULL,contains_bounded=NULL,relative_model=NULL,context=NULL) {
  ctx <- .context(context)
  .spec("ideal",list(carrier=carrier,completeness=completeness,saturation=saturation,normal=normal,
    proper=proper,contains_bounded=contains_bounded,relative_model=if(is.null(relative_model)) ctx$model else relative_model),ctx)
}

# Describe a full-carrier measure without conflating real and two-valued measures.
measure_spec <- function(carrier="kappa",additivity=NULL,zero_singletons=NULL,two_valued=NULL,context=NULL) {
  .spec("measure",list(carrier=carrier,additivity=additivity,zero_singletons=zero_singletons,two_valued=two_valued),context)
}

# Describe extender support length and independent coherence/well-foundedness obligations.
extender_spec <- function(critical_point="kappa",length="lambda",source_model="V",well_founded=NULL,coherent=NULL,context=NULL) {
  .spec("extender",list(critical_point=critical_point,length=length,source_model=source_model,well_founded=well_founded,coherent=coherent),context)
}

# Describe an ultrapower without assuming its well-foundedness.
ultrapower_spec <- function(model="V",ultrafilter="U",well_founded=NULL,context=NULL) {
  .spec("ultrapower",list(model=model,ultrafilter=ultrafilter,well_founded=well_founded),context)
}

# Describe iteration rules, ordinal length and a separate iterability hypothesis.
iteration_spec <- function(model="M",length="alpha",successor_rule="ultrapower",limit_rule="direct_limit",iterability=NULL,context=NULL) {
  .spec("iteration",list(model=model,length=length,successor_rule=successor_rule,limit_rule=limit_rule,iterability=iterability),context)
}

# Describe a forcing configuration; no generic filter is constructed.
forcing_spec <- function(poset="P",ground_model="M",generic_filter="G",closure=NULL,chain_condition=NULL,context=NULL) {
  .spec("forcing",list(poset=poset,ground_model=ground_model,generic_filter=generic_filter,closure=closure,chain_condition=chain_condition),context)
}

# Describe a hierarchy level with explicit effective/boldface convention.
pointclass_spec <- function(family="projective",level=1,polarity="Sigma",effective=FALSE,parameters=list(),context=NULL) {
  .spec("pointclass",list(family=family,level=level,polarity=polarity,effective=effective,parameters=parameters),context)
}

borel_hierarchy_spec <- function(index=1,polarity="Sigma",effective=FALSE,ordinal_code=NULL,parameters=list(),context=NULL) {
  .spec("borel_hierarchy",list(index=index,polarity=polarity,effective=effective,
    ordinal_code=ordinal_code,parameters=parameters),context)
}

difference_hierarchy_spec <- function(base_pointclass="coanalytic",index=1,effective=FALSE,sequence_code=NULL,context=NULL) {
  .spec("difference_hierarchy",list(base_pointclass=base_pointclass,index=index,effective=effective,sequence_code=sequence_code,
    convention="decreasing_first_exit_odd",exhaustion="use_length"),context)
}

# Describe an infinite game; solving finite games is a separate operation.
game_spec <- function(moves="naturals",length=NULL,payoff="A",pointclass="arbitrary",context=NULL) {
  .spec("game",list(moves=moves,length=if(is.null(length)) ordinal_term("omega") else length,payoff=payoff,pointclass=pointclass),context)
}

# Describe a scale with named norms and an explicit limit-property obligation.
scale_spec <- function(domain="A",pointclass="Gamma",norms=list(),limit_property=NULL,context=NULL) {
  .spec("scale",list(domain=domain,pointclass=pointclass,norms=norms,limit_property=limit_property),context)
}

# Describe an ordinal-valued norm and its pointclass/rank obligations.
norm_spec <- function(domain="A",pointclass="Gamma",rank_bound=NULL,context=NULL) {
  .spec("norm",list(domain=domain,pointclass=pointclass,rank_bound=rank_bound),context)
}

# Distinguish L[A], L(A), L(R) and other inner-model constructions.
inner_model_spec <- function(construction="L",predicate=NULL,ambient_model="V",axioms=list("ZF"),context=NULL) {
  .spec("inner_model",list(construction=construction,predicate=predicate,ambient_model=ambient_model,axioms=axioms),context)
}

# Describe an infinite partition assertion; finite enumeration has its own API.
small_subset_partition_spec <- function(kappa="kappa",gamma="gamma",arity=2,colors=2,chain_order="proper_inclusion",homogeneous_requirement="stationary",filter_name=NULL,coloring_model=NULL,witness_model=NULL,context=NULL) {
  ctx <- .context(context)
  .spec("small_subset_partition",list(kappa=kappa,gamma=gamma,arity=arity,colors=colors,
    chain_order=chain_order,homogeneous_requirement=homogeneous_requirement,filter_name=filter_name,
    coloring_model=if(is.null(coloring_model)) ctx$model else coloring_model,
    witness_model=if(is.null(witness_model)) ctx$model else witness_model),ctx)
}
partition_spec <- function(source="kappa",target="kappa",arity=2,colors=2,variant="ordinary",color_bound=NULL,coloring_model=NULL,witness_model=NULL,context=NULL) {
  ctx <- .context(context)
  .spec("partition",list(source=source,target=target,arity=arity,colors=colors,variant=variant,color_bound=color_bound,
    coloring_model=if(is.null(coloring_model)) ctx$model else coloring_model,
    witness_model=if(is.null(witness_model)) ctx$model else witness_model),ctx)
}

# Describe a tree representation without asserting membership of its projection.
tree_code <- function(alphabet="naturals",height=NULL,projection=NULL,well_founded=NULL,context=NULL) {
  .spec("tree_code",list(alphabet=alphabet,height=if(is.null(height)) ordinal_term("omega") else height,projection=projection,well_founded=well_founded),context)
}

Try the largecardinals package in your browser

Any scripts or data that you put into this service are public.

largecardinals documentation built on Nov. 25, 2026, 5:09 p.m.