Pauta: [escribiendo lambda como \]

1.

or = \b . \c . b tru c

not = \b . b fls tru
pow = \b . \e . e b
pow = \m . \n . m n
pow = \m . \n . m (times n) c1     -- (?)

2.

a) [ii] (\x . x x) (\x . x x)
b) [v] En forma normal
c) [iii] (\z . \x . x z) (\x. x x)


3.
(a)
	Progreso: Cierto
	Preservacion: Falso, por
	      pred (succ 0) : Bool --> 0 :Nat 
	Unicidad: Falso, por la derivacion de tipos a pred (succ 0) obtengo Nat
	o Bool

(b)
	Progreso: Cierto
	Preservacion: Falso, por
	      if true else 0 then 0 : Int --> true : Bool
	Unicidad: Cierto

(c)
	Progreso: Cierto
	Preservacion: Falso, por
	      pred 0 : Foo --> 0 : Nat	      	      
	Unicidad: Falso, por la derivacion de tipos a pred 0 obtengo Nat
	o Foo

4.
(a)
if (if true then true else 0) then false else 0 : False + Bool


(b) Lemma [Inversion]
* Si true: T, entonces
     T=True or T = Bool


* Si if t1 then t2 else t3 : T, entonces
     si t1:True entonces T=T2 donde t2 :T2, para cualquier t3 :T3
     si t1:False entonces T=T3 donde t3:T3, para cualquier t2 : T2
     si t1:Bool entonces t2:T2 y t3:T3 y T=T2 y T=T3

5. 
El STLC no es turing completo, ya que no acepta terminos divergentes (ej. omega) y operadores
recursivos como Y/fix. Por tanto el Halting Problem no aplica.

6.
 f in {f:Nat->Nat}				     g in {g:Nat}	
--------------------				  ---------------
f:Nat->Natf:Nat->Nat    |-0:Nat			    g:Nat|-g:Nat
--------------------------------                -------------------------
    f:Nat->Nat|-f 0:Nat			          g:Nat|- pred g: Nat
------------------------------------	     ------------------------------- 	
.|-(\f:Nat->Nat. f 0):(Nat->Nat)->Nat           .|-(\g: Nat . pred g) : Nat -> Nat
---------------------------------------------------------------------------
.|- (\f:Nat->Nat. f 0) (\g: Nat . pred g) : Nat


--t-var --t-zero       	    	--t-var
--------t-app	       	     ---------t-pred
------------t-abs      	    ---------------t-abs
----------------------------------------------t-app


7.  (TAPL 9.3.8, pag. 106/7)
Case t-var: 
     	    t = z
     	    with z:T in (Gamma,x:S)

si x != z entonces [x->s]z = z y Gamma,x:S |- z:T 
si x = z entonces [x->s]z = s y Gamma|-s:S  

Case t-abs: 
     	    t = \y:T2 . t1	T=T2->T1
	    Gamma, x:S, y:T2 |- t1 :T1

(1) Gamma, y:T2,x:S |- t1 : T1 por permutacion.
(2) Gamma, y:T2 |- s : S por weakening
(3) Gamma, y:T2 |- [x->s]t1 :T1 por HI, (1) y (2)
(4) [x->s]\y:T2 . t1 = \y:T2 . [x->s]t1 por def. de subtitucion. 
(5) Gamma |- \y:T2. [x->s]t1 : T2 -> T1 por t-abs, (4) y (5)

       
Case t-succ:
	    t = succ t1		T:Nat
	    Gamma,x:S |- t1 : Nat

(1) [x->s]succ t1 = succ [x->s]t1 por def. de subtitucion
(2) Gamma |- [x->s]t1 : Nat por HI
(3) Gamma |- succ [x->s]t1 : Nat por t-succ, (1) y (2)	
