Rootwise resource potential
DefinitionMoserSchneckenreither_RootPotentialA constructor-like root contributes its charge and the sum of its children’s potentials at their input annotations. Variables and unsupported roots have potential zero. The context potential sums the rootwise potentials of the assigned terms at the context annotations.
import Definitions.Def_MoserSchneckenreither_Annotations
noncomputable section
namespace MoserSchneckenreither
variable {sig : Signature} {P : Problem sig}
/-- A rootwise variant of Definition 3. A constructor-like root contributes its charge
and the potentials of its children. A variable or unsupported root contributes zero. -/
def rootPotential (F : AnnotatedSignature P) : Term sig → Annotation → ℚ≥0
| .var _, _ => 0
| .app f ts, q => by
classical
exact if ConstructorLike P f then
F.cost f q + (List.ofFn fun i ↦ rootPotential F (ts i) (F.input f q i)).sum
else 0
/-- The sum of the rootwise potentials of the substitution images at the context annotations. -/
def rootContextPotential (F : AnnotatedSignature P) (σ : ℕ → Term sig) (Γ : Context) :
ℚ≥0 := (Γ.map fun a ↦ rootPotential F (σ a.1) a.2).sum
end MoserSchneckenreither
Read-back
What the Lean code literally says, in plain math · GPT-6 (Codex)
rootPotential
A signature has symbols indexed by the integers from through for some , a natural-number arity for each symbol , a nonempty subset of constructor symbols, and at least one symbol of arity zero. A term is a variable labelled by a natural number or an application . A problem has a strict list and a weak list of rewrite rules. Each rule has left-hand side with outside the constructor subset, and every variable on its right-hand side occurs on its left-hand side. Call a symbol constructor-like for if it is in the constructor subset or occurs anywhere in a left-hand-side argument of some rule in either list. An annotation is a finitely supported sequence of nonnegative rationals indexed by , with pointwise addition and scalar multiplication. An annotated signature for gives each symbol a nonempty set of allowed declarations, each with one input annotation per argument, a nonnegative rational cost, and an output annotation. It also gives functions and on output annotations and, for , argument indices , returning an annotation and a nonnegative rational, respectively. For each constructor-like and each , the declaration with output , inputs and cost is allowed. Every allowed declaration of such an with output has precisely those inputs and cost. For these symbols and each applicable , the functions and preserve annotation addition and multiplication by every nonnegative rational. Define for every term and annotation , with values in the nonnegative rationals. It is zero on variables and on applications whose head is outside the constructor-like symbols. At an application with a constructor-like head, it is . An empty sum contributes zero, and the same recursion applies independently in each argument.
rootContextPotential
A signature has symbols indexed by the integers from through for some , a natural-number arity for each symbol , a nonempty subset of constructor symbols, and at least one symbol of arity zero. A term is a variable labelled by a natural number or an application . A problem has a strict list and a weak list of rewrite rules. Each rule has left-hand side with outside the constructor subset, and every variable on its right-hand side occurs on its left-hand side. Call a symbol constructor-like for if it is in the constructor subset or occurs anywhere in a left-hand-side argument of some rule in either list. An annotation is a finitely supported sequence of nonnegative rationals indexed by , with pointwise addition and scalar multiplication. An annotated signature for gives each symbol a nonempty set of allowed declarations, each with one input annotation per argument, a nonnegative rational cost, and an output annotation. It also gives functions and on output annotations and, for , argument indices , returning an annotation and a nonnegative rational, respectively. For each constructor-like and each , the declaration with output , inputs and cost is allowed. Every allowed declaration of such an with output has precisely those inputs and cost. For these symbols and each applicable , the functions and preserve annotation addition and multiplication by every nonnegative rational. Define for every term and annotation , with values in the nonnegative rationals. It is zero on variables and on applications whose head is outside the constructor-like symbols. At an application with a constructor-like head, it is . An empty sum contributes zero, and the same recursion applies independently in each argument. For any total assignment from natural-number variable names to terms and any list of name–annotation pairs, the root context potential is , summed over the entries of the list. An empty list has sum zero, and every occurrence of a repeated pair contributes a summand. The assignment can take any term as a value, including one containing variables.