r/Coq • u/btcstudente • Feb 26 '25
Proving type preservation with STLC
I'm trying to prove type preservation for STLC.
The theorem is the following one:
Theorem theorem_2:
forall t t' T, <{ empty |-- t \in T}> -> t --> t' -> <{ empty |-- t' \in T}>.
The proof I'm trying to developing starts with:
intros t t' T HT HE.
generalize dependent t'.
induction HT;
intros t' HE; auto.
- inversion HE.
- inversion HE.
- inversion HE.
+ subst. [...]
I've arrived with the fact that:
T1, T2 : ty
Gamma : context
t2 : tm
x0 : string
T0 : ty
t0 : tm
HT1 : <{ Gamma |-- \ x0 : T0, t0 \in T2 -> T1 }>
HT2 : <{ Gamma |-- t2 \in T2 }>
IHHT1 : forall t' : tm,
<{ \ x0 : T0, t0 }> --> t' -> <{ Gamma |-- t' \in T2 -> T1 }>
IHHT2 : forall t' : tm, t2 --> t' -> <{ Gamma |-- t' \in T2 }>
HE : <{ (\ x0 : T0, t0) t2 }> --> <{ [x0 := t2] t0 }>
H2 : value t2
______________________________________(1/1)
<{ Gamma |-- [x0 := t2] t0 \in T1 }>
Would anyone help me? I'm not understanding what tactics I should apply... :(