Pauta Control 2 
===============
*1*
OBS: Usando lambda como \ y primitivas de scheme
(2)1.1

fact =
	fix \f:Nat -> Nat . 
		   \x:Nat . if (= x 0) 
					then 1
					else (* x (f (- x 1)))

(2)1.2.a
fact =
	letrec fact:Nat->Nat =
			 	\x:Nat->Nat .
						if (= x 0)
						then 1
						else (* x (fact (- x 1)))
	in fact												
	
1.2.b

(2)T-letrec:

Gamma,x:T1->T2 |- e1 : T1->T2	Gamma,x:T1->T2 |- e2 : T12	
------------------------------------------------------------
	Gamma |- letrec x:T1->T2 = e1 in e2 : T12	


(2)E-letrec1:

					t1 --> t1'
----------------------------------------------------------
letrec x:T = t1 in t2 --> letrec x:T = t1' in t2

(2)E-letrec2:

letrec x:T1 = \y:T2.t1 in t2 --> [x->\y:T2.[x->letrec x:T1 = \y:T2.t1 in t1]t1]t2

*2*
(\l1: Ref (Nat->Nat) . 
	(\l2 : Ref (Nat->Nat) .
		l1 = \x:Nat . !l2 x) ref \x:Nat . !l1 x)
	ref \x:Nat . x	

---- {l1,l2,l3 son varname, no punteros}

let l1 = ref \x:Nat . x
	in let l2 = ref \x:Nat . !l1 x
		in l1 = \x:Nat . !l2 x	

*3*
3.a 
	ref ref ref 5
3.b
Sigma = {l1:Nat, l2: Ref Nat, l3:Ref Ref Nat}

*4*
No. Por que no podemos construir un tipo para Sigma(l1), ya que divergemos en la expresión
Sigma(l1) = Ref Ref Ref Sigma(l1)

*5*
OBS: T es el tipo de la expr. y v el resultado de su evaluación
5.a 
(2)T : Nat
(2)v : raise 1

(4)5.b
Mal tipeado

(4)5.c
Mal tipeado

*6*
OBS: Escribiendo implicación como >
6.1 
					---------x
					  A ^ B true
----------------f	--------- ^E l		------------x
A > (B > C) true      A true 				A ^ B true
----------------------------- >E 		-------------- ^E r	
		B > C true							B true					
-------------------------------------------------------- >E 
			   C true
		--------------------- >I x
			(A ^ B) > C true
---------------------------------------------- >I f
	(A > (B > C))>((A ^ B) >C) true
	

6.2 (proof terms)

				--------x
				   x:AxB 
----------f		----------			-----------x
f:A->B->C		  fst x:A			   x:AxB
--------------------------		-------------------
		f (fst x):B->C				snd x:B
--------------------------------------------------
			(f (fst x)) (snd x):C
--------------------------------------------------------
		\x:AxB->C . (f (fst x)) (snd x):AxB->C
-----------------------------------------------------------------
\f:A->B->C . \x:AxB->C . (f (fst x)) (snd x) : (A->B->C)->(AxB->C)
	

6.3

(2)uncurry
(2)P = \f:A->B->C . 
		\x:AxB . 
			(f (fst x)) (snd x)
 

*7*
Basta con mostrar un programa donde Sigma(li) cambia en la evaluación.
OBS: Usando sequencia

				 Env		mu				Sigma
x = ref 5 ;  	x->l1		l1->5		l1 -> Ref Nat
y = x ;			y->l1
free y ;		y->nil		l1 is free
z = ref true ;	z->l1		l1->true	l1 -> Ref Bool

succ !x			**ERROR**



