Edición de «Práctica 3: Cuantificadores (Algoritmos I)»

De Cuba-Wiki
Advertencia: no has iniciado sesión. Tu dirección IP se hará pública si haces cualquier edición. Si inicias sesión o creas una cuenta, tus ediciones se atribuirán a tu nombre de usuario, además de otros beneficios.

Puedes deshacer la edición. Antes de deshacer la edición, comprueba la siguiente comparación para verificar que realmente es lo que quieres hacer, y entonces publica los cambios para así efectuar la reversión.

Revisión actual Tu texto
Línea 7: Línea 7:
# (<math>\forall j \in [0..|s|)) s_j == x </math>
# (<math>\forall j \in [0..|s|)) s_j == x </math>
# (<math>\exists x \in r, x\ mod\ 2 == 0)(\forall j \in [0..|s|)) s_j == x </math>
# (<math>\exists x \in r, x\ mod\ 2 == 0)(\forall j \in [0..|s|)) s_j == x </math>
# <math> ( |s|>5 \land a < b-1 \land (\forall j \in [a..b)) 2 * s_j == s_{j+1})</math>
# <math> ( |s|>5 \land a<b-1 \land (\forall j \in [a..b)) 2 * s_j == s_{j+1})</math>




Línea 64: Línea 64:
otras formas:  
otras formas:  
-utilizar un aux ultimo que sea algo asi como cabeza(invertir(l:[T]))
-utilizar un aux ultimo que sea algo asi como cabeza(invertir(l:[T]))
-acum(y | s: <math>\mathbb{Z}</math> = Indef, y <math>\leftarrow</math> [1..abs(x)], x mod y == 0);


i) aux mcm<math>(x,y: \mathbb{Z}): \mathbb{Z}</math> = cab([ z | z <math>\leftarrow</math> [0..|x*y|], z \ mod \ x == 0, z \ mod \ y == 0])
i) aux mcm<math>(x,y: \mathbb{Z}): \mathbb{Z}</math> = cab([ z | z <math>\leftarrow</math> [0..|x*y|], z \ mod \ x == 0, z \ mod \ y == 0])
Línea 80: Línea 81:


''esPrefijo''(x,y: [T]): Bool = (<math>\exists</math> i <math>\leftarrow</math> [0..|y|-1]) x==[<math>y_i</math>| j <math>\leftarrow</math> [0..i] ]
''esPrefijo''(x,y: [T]): Bool = (<math>\exists</math> i <math>\leftarrow</math> [0..|y|-1]) x==[<math>y_i</math>| j <math>\leftarrow</math> [0..i] ]
otra forma:
(|b| > |a| <math>\wedge</math> (<math>\forall i \leftarrow</math> [0..|a|) ) <math>a_i==b_i</math>);


3. ''estaOrdenada'', que determina si la secuencia está ordenada de menor a mayor.
3. ''estaOrdenada'', que determina si la secuencia está ordenada de menor a mayor.
Línea 119: Línea 116:


''sinRepetidos''(x: [T]): Bool = (<math>\forall</math> i,j <math>\leftarrow</math> [0..|x|-1], i <math>\neq</math>j) <math>x_i \neq x_j </math>
''sinRepetidos''(x: [T]): Bool = (<math>\forall</math> i,j <math>\leftarrow</math> [0..|x|-1], i <math>\neq</math>j) <math>x_i \neq x_j </math>
otra forma:
(<math>\forall</math> i <math>\leftarrow</math> [0..|x|-1]), <math>x_i \not\in x_{[0..i)}) </math>
otra más:
(<math>\forall</math> e <math>\leftarrow</math> x, cuenta(e, x) == 1)




Línea 152: Línea 145:


===Ejercicio 4===
===Ejercicio 4===
1- "Todos los naturales menores a 10 que cumplen P, cumplen Q":
aux a: Bool (<math>\forall x \in</math> [0..10)) (<math>P(x) \wedge Q(x)</math>)
Esta mal porque no queremos que para todos, todos cumplan P y Q, sino que cuando P sea verdadero, Q tambien lo sea:
aux a: Bool (<math>\forall x \in</math> [0..10))(<math>P(x) \Rightarrow Q(x)</math>)
2- "No hay ningún natural menor a 10 que cumpla P y Q":
aux c: Bool = <math>(\neg ( \exists x \in [0..10) P(x)  \wedge \neg ( \exists x \in [0..10) Q(x))</math>
Pero esto diría que ninguno en s cumple P y ninguno en s cumple Q.
En su lugar deberíamos poner:
aux c: Bool = <math>\neg ( \exists x \in [0..10) ) P(x) \wedge Q(x)</math>;
Ten en cuenta que todas las contribuciones a Cuba-Wiki pueden ser editadas, modificadas o eliminadas por otros colaboradores. Si no deseas que las modifiquen sin limitaciones, no las publiques aquí.
Al mismo tiempo, asumimos que eres el autor de lo que escribiste, o lo copiaste de una fuente en el dominio público o con licencia libre (véase Cuba-Wiki:Derechos de autor para más detalles). ¡No uses textos con copyright sin permiso!

Para editar esta página, responde la pregunta que aparece abajo (más información):

Cancelar Ayuda de edición (se abre en una ventana nueva)