Files
vanity/README.md
T

40 lines
2.5 KiB
Markdown

# vanity
executable artefact about parametricity failure under specialisation and inlining with representation lowering
this project models a small typed source calculus and then lowers it into an explicit representation calculus and audits whether the source observation and target observation remain related. the surface is semantic rather than structural as its about abstraction theorems, representation relations, strictness shifts, and the proof obligations that an optimiser assumes when it rewrites polymorphic code
the target language makes representation explicit and forces each transition to be spelled out in the term. values are either boxed or unboxed and can be projected from products or injected into sums as well as unpacked when needed and moved across worker wrapper boundaries as part of calling convention shifts
the target calculus is intentionally lower level than the source and trades abstraction for control over layout and calling. it has tuple and sum representations and uses explicit box and unbox operations to mediate between them. equality on integers and booleans is primitive rather than encoded as well as recursive binding being built in rather than derived
the audit path records pass boundary observations and each corpus case is checked against relation preservation, target arity and shape validation, termination class preservation and effect trace preservation. unsafe profiles intentionally refute the invariants so that optimiser bugs show up as small source target deltas rather than vague failures
the source calculus also has an explicit `tick` effect which is enough to expose unsound dce style rewrites. eliminating a dead binding is only valid when the eliminated term is effect free
## example(s)
a representation exposure witness starts from a polymorphic constant false term
```ocaml
forall a. function a function a bool
```
under a safe profile instantiating this preserves the baseline relation. under an unsafe inline profile instantiating can expose integer equality and refute the abstraction theorem
a strictness witness places a divergent recursive computation
```ocaml
roll mu a. int loop
```
the source observation can keep the recursive payload latent and a strict lowering path can force it during construction and change termination
a worker wrapper witness uses the explicit source type representation
```ocaml
TArrow (TPair (TInt, TBool), TPair (TInt, TBool))
```
the target worker receives `RInt` and `RBool` while the wrapper preserves the boxed source interface IRs