Pure semantics of GraphSpec DAGs #
This module interprets typed DAG terms and blocks in TorchLean.TensorPack environments and
proves that evaluation respects renaming, substitution, inlining, and block composition.
Typed environment lookup for pure tensors.
Instances For
Looking up a programmatically selected variable agrees with typed-list lookup.
Appending a value does not change the meaning of an existing variable.
Looking up a variable embedded from the left reads the original left environment.
Looking up a variable embedded from the right reads the appended right environment.
Looking up the final variable returns the value most recently appended to an environment.
Spec interpreter #
Evaluate a typed argument list by evaluating each component term under the same environment.
Instances For
Pure evaluation of a DAG term.
This is the “math-first” semantics: we interpret a term as a pure function on tensors. No monads, no mutation, no autograd tape, just the Spec definitions of primitives.
The key runtime discipline is the environment discipline:
varreads fromenv,opevaluates its arguments and feeds them to the primitive’sspecFwd,let1evaluates the bound term once and extendsenvfor the body.
Instances For
Evaluating an operation node first evaluates its typed arguments, then applies the primitive's pure semantics.
Evaluating an output-shape cast transports the value along the same shape equality.
Semantics of variable renaming #
A variable renaming preserves an environment when every renamed lookup has the same value.
Instances For
A sound renaming remains sound when the same value is appended to both environments.
Pure evaluation commutes with a sound renaming of an operation's arguments.
Pure evaluation commutes with any variable renaming that preserves environment lookup.
Renaming arguments into the left side of an appended environment preserves their values.
Renaming arguments into the right side of an appended environment preserves their values.
Renaming a term into the left side of an appended environment preserves its value.
Appending an arbitrary typed environment does not change a weakened term's value.
Renaming a term into the right side of an appended environment preserves its value.
Appending an unrelated value does not change a term's pure meaning.
The final variable in an extended environment denotes the value that was just appended.
A term substitution represents an environment when every assigned term evaluates to the value stored at the corresponding source variable.
Instances For
A sound substitution remains sound across the value introduced by a let binding.
Pure evaluation commutes with a sound substitution of operation arguments.
Pure evaluation commutes with any term substitution representing the source environment.
Evaluating an argument selected by a typed variable agrees with lookup in the evaluated argument environment.
Pure evaluation of an inlined term equals evaluation of the original term under the supplied argument values.
Evaluating concatenated graph arguments concatenates their tensor values in the same order.
Evaluating a statically split argument list agrees with splitting its evaluated values.
Evaluating the left part of a typed argument split returns the corresponding value prefix.
Evaluating the right part of a typed argument split returns the corresponding value suffix.
Prepending an unrelated value does not change a term's pure meaning.
Prepending an unrelated value does not change a typed argument list's pure meaning.
Evaluating all variables of an environment returns that environment in order.
Reinterpret a block's result list along an equality of output shapes.
Instances For
Evaluate a multi-output block, preserving sharing introduced by let1.
Instances For
Casting a block's output shapes casts its evaluated typed result by the same equality.
Substituting terms into a block preserves its pure multi-output semantics whenever the substitution denotes the original environment.
Evaluating an inlined block is the same as evaluating its original body under the supplied typed argument values.
Pure evaluation of block composition is ordinary typed environment extension.
Composing two blocks evaluates the first once and appends its typed outputs for the second.