Diferencia entre revisiones de «Segundo Parcial 1er Cuat 2016 (Paradigmas)»
De Cuba-Wiki
Sin resumen de edición |
Sin resumen de edición |
||
Línea 39: | Línea 39: | ||
*1) <math>\forall t_1 \forall t_2 subclase(t_1, t_2) \implies subtipo(t_1, t_2)</math> | *1) <math>\forall t_1 \forall t_2 subclase(t_1, t_2) \implies subtipo(t_1, t_2)</math> | ||
*2) <math>\forall t_1 subclase(t_1, t_1)</math> | *2) <math>\forall t_1 subclase(t_1, t_1)</math> | ||
*3) <math>\forall t_1 \forall t_2 (\exists t_3 subclase t_3, t_2 \wedge extiende(t_1, t_3)) \implies subclase(t_1, t_2)</math> | *3) <math>\forall t_1 \forall t_2 (\exists t_3 subclase (t_3, t_2) \wedge extiende(t_1, t_3)) \implies subclase(t_1, t_2)</math> | ||
*4) <math>extiende(perro, animal)</math> | *4) <math>extiende(perro, animal)</math> | ||
*GOAL) <math>\forall x \neg subtipo(perro, x)</math> | *GOAL) <math>\forall x \neg subtipo(perro, x)</math> |
Revisión actual - 20:56 9 jul 2016
Ejercicio 1
a)
Number >> pesos ^Dinero new.
Number >> centavos ^Dinero new.
b)
Number >> pesos ^Dinero withValue: self.
Number >> centavos ^Dinero withValue: self/100.
Dinero >> withValue: aNumber ^(Dinero new) value = aNumber.
Dinero >> = aDinero ^value = aDinero getValue.
Dinero >> + aDinero ^Dinero withValue: value + aDinero getValue.
Dinero >> getValue ^value.
c)
Dinero class >> actualizacion : unDiccionario keysAndValuesDo: [:k :v | number class compile (' k, '^Dinero withValue: ', v asString, '* self')].
Ejercicio 2
a) II) Forma lógica:
- 1)
- 2)
- 3)
- 4)
- GOAL)
Forma clausal ():
1)
2)
3)
4)
GOAL)
b)
asignaciónValida(+declaraciones, ?asignacion) asignaciónValida(d, asig(v1, v2)) :- member(d, decl(v1, t1)), member(d, decl(v2, t2)), v1 \= v2, subtipo(t2, t1).
c)
reemplazar(+programaConVariables, +tipos, +asignacion) reemplazar([], _, []). reemplazar([asig(A, B)|PCVA], T, [asig(A, B)|PCVB]) :- reemplazar(PCVA, T, PCVB). reemplazar([decl(A, TA)|PCVA], T, [decl(B, TB)|PCVB]) :- (var(TA), member(B, TB)); (\+ var(TA), TB == TA), reemplazar(PCVA, T, PCVB).
d)
unicovalido(+programaConVariables, +tipos) unicovalido(PCV, T) :- reemplazar(PCV, T, P), valido(P), not(reemplazar(PCV, T, P2), valido(P2), P1 \= P2).