Basic Programming Language Theory
Total Programming LanguagePermalink
E.Coli of Total PLs - Godel’s T: It codifies higher order functions and inductive types (nat)
What does it mean for a PL to exist?Permalink
A PL consists of two parts:
- Statics: What are the programs?
- Dynamics: How do we run them?
Basic criterion: Coherence
StaticsPermalink
We will talk about abstract syntax and context-sensitive-conditions on well-formation.
Formal = typing is inductively defined.
We only have information about the types but not the elements themselves.
So we only care about two things, higher order functions, and nat.
So the typing:
is inductively defined by rules, which is the least relation closed under under some rules
Note: can be viewed as a “context”. It could be written as something like
e.g. natural number
Hypothetical Judgement (Structural):
Note: 1 and 2 are indefeasible. 3, 4, 5 is defeasible (Will be different in substructural type systems).
-
Reflexivity
-
Transitivity
-
Weakening
-
Contraction
-
Exchange
DynamicsPermalink
Execute close code (no free variables)
We need to specify:
- States of execution
- Transition
- Initial State and final state
Some rules:
- zero is a value
- successor is a value
- function is a value
- functions can be executed
- Values are stuck/finished
- Determinism/functional language
Note: dynamics doesn’t care about types!
Coherence of Dynamics/Statics/Type Safety():
- Preservation
- Progress
- Termination
Here we proof Termination ( means terminates). According to Godel, if we proof termination, we are proving the consistency of the arithmetic, so we need methods that go beyong the arithmetic (Godel’s incompleteness):
- itself can’t be a variable becasue it is closed
- But for , even by inductive hypothesis, we know and , and , we can only do , but we can’t get any further. We do need more info about !
Therefor we introduct a strong property called hereditary termination:
- Want: implies
- Define: by induction on type [Tait’s Method]
- or with (it is well-defined because it is the strongest predicate satisfying these rules)
- and for every such that (meaning “type goes down”). To write this in another form,
And we have :
If then , and then therefore
So now for inductive hypothesis, we not only know 15 and , but also and . And because we know that is a , we now know that is !
BUT! is only stating about being closed terms, but for : , is an open term, meaning it is a variable, so our theorm doesn’t quite work. We must account for open terms!
[Tait]:
If and , then
So means that if , then (substitution) such that , and means to do the substitution. So we are good now!
Comments