Recuerden subir los archivos a Cuba-Wiki y no linkearlos de servidores externos, siempre siguiendo la convención de nombres descripta acá.

Diferencia entre revisiones de «Segundo Parcial 1er Cuat 2016 (Paradigmas)»

De Cuba-Wiki
Sin resumen de edición
 
(No se muestra una edición intermedia del mismo usuario)
Línea 1: Línea 1:
{{Back|Paradigmas de Lenguajes de Programación}}
== Ejercicio 1 ==
== Ejercicio 1 ==
a)
a)
Línea 37: 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

Plantilla:Back

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) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall t_1 \forall t_2 subclase(t_1, t_2) \implies subtipo(t_1, t_2)}
  • 2) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall t_1 subclase(t_1, t_1)}
  • 3) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \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)}
  • 4) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle extiende(perro, animal)}
  • GOAL) Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall x \neg subtipo(perro, x)}

Forma clausal (Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle t = t_1, u = t_2, v = t_3} ):

1)

  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall t \forall u \neg subclase(t, u) \vee subtipo(t, u)}
  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \{\neg subclase(t_1, u_1) \vee subtipo(t_1, u_1)\}}

2)

  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \{subclase(t_2, t_2)\}}

3)

  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall t \forall u (\neg \exists v subclase (v, u) \wedge extiende(t, v)) \vee subclase(t, u)}
  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall t \forall u (\forall v \neg subclase (v, u) \vee \neg extiende(t, v)) \vee subclase(t, u)}
  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \forall t \forall u \forall v \neg subclase (v, u) \vee \neg extiende(t, v) \vee subclase(t, u)}
  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \{\neg subclase (v_3, u_3) \vee \neg extiende(t_3, v_3) \vee subclase(t_3, u_3)\}}

4)

  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \{extiende(perro, animal)\}}

GOAL)

  • Error al representar (SVG o PNG como alternativa (MathML puede ser habilitado mediante plugin de navegador): respuesta no válida («Math extension cannot connect to Restbase.») del servidor «https://en.wikipedia.org/api/rest_v1/»:): {\displaystyle \{\neg subtipo(perro, x_g)\}}

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).