Diferencia entre revisiones de «Relación 5»
De Razonamiento automático (2014-15)
(Página creada con '<source lang="isar"> header {* R5: Cuantificadores sobre listas *} theory R5 imports Main begin text {* -------------------------------------------------------------------...') |
|||
Línea 1: | Línea 1: | ||
<source lang="isar"> | <source lang="isar"> | ||
header {* R5: Cuantificadores sobre listas *} | header {* R5: Cuantificadores sobre listas *} | ||
− | + | ||
theory R5 | theory R5 | ||
imports Main | imports Main | ||
begin | begin | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 14: | Línea 14: | ||
todos (λx. 1<length x) [[2,1,4],[1,3]] | todos (λx. 1<length x) [[2,1,4],[1,3]] | ||
¬todos (λx. 1<length x) [[2,1,4],[3]] | ¬todos (λx. 1<length x) [[2,1,4],[3]] | ||
− | + | ||
Nota: La función todos es equivalente a la predefinida list_all. | Nota: La función todos es equivalente a la predefinida list_all. | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
+ | --"jeshorcob" | ||
fun todos :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where | fun todos :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where | ||
− | "todos p xs = | + | "todos p [] = True" |
+ | |"todos p (x#xs) = (p x ∧ todos p xs)" | ||
+ | |||
+ | --"jeshorcob" | ||
+ | fun todos2 :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where | ||
+ | "todos2 p xs = foldr (λx. op ∧ (p x)) xs True" | ||
text {* | text {* | ||
Línea 30: | Línea 36: | ||
algunos (λx. 1<length x) [[2,1,4],[3]] | algunos (λx. 1<length x) [[2,1,4],[3]] | ||
¬algunos (λx. 1<length x) [[],[3]]" | ¬algunos (λx. 1<length x) [[],[3]]" | ||
− | + | ||
Nota: La función algunos es equivalente a la predefinida list_ex. | Nota: La función algunos es equivalente a la predefinida list_ex. | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | fun algunos | + | --"jeshorcob" |
− | "algunos p xs = | + | fun algunos :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where |
+ | "algunos p [] = True" | ||
+ | |"algunos p (x#xs) = (p x ∨ todos p xs)" | ||
+ | --"jeshorcob" | ||
+ | fun algunos2 :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where | ||
+ | "algunos2 p xs = foldr (λx. op ∨ (p x)) xs True" | ||
+ | |||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 45: | Línea 57: | ||
*} | *} | ||
+ | --"jeshorcob" | ||
lemma "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)" | lemma "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)" | ||
− | + | by (induct xs) auto | |
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 54: | Línea 67: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
+ | |||
+ | --"jeshorcob" | ||
lemma "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)" | lemma "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)" | ||
− | + | proof (induct xs) | |
− | + | show "todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])" by simp | |
+ | next | ||
+ | fix x xs | ||
+ | assume HI: "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)" | ||
+ | have "todos (λx. P x ∧ Q x) (x#xs) = | ||
+ | ((P x ∧ Q x) ∧ todos (λx. P x ∧ Q x) xs) " by simp | ||
+ | also have "... = (P x∧Q x∧todos P xs∧todos Q xs)" using HI by simp | ||
+ | also have "... = ((P x∧todos P xs)∧(Q x ∧ todos Q xs))" by arith | ||
+ | also have "... = (todos P (x#xs) ∧ (Q x ∧ todos Q xs))" by simp | ||
+ | also have "... = (todos P (x#xs) ∧ todos Q (x#xs))" by simp | ||
+ | finally show "todos (λx. P x ∧ Q x) (x#xs) = | ||
+ | (todos P (x#xs) ∧ todos Q (x#xs))" by simp | ||
+ | qed | ||
+ | |||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 64: | Línea 92: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "todos P (x @ y) = (todos P x ∧ todos P y)" | lemma "todos P (x @ y) = (todos P x ∧ todos P y)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 74: | Línea 102: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma todos_append: | lemma todos_append: | ||
"todos P (x @ y) = (todos P x ∧ todos P y)" | "todos P (x @ y) = (todos P x ∧ todos P y)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 85: | Línea 113: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "todos P (rev xs) = todos P xs" | lemma "todos P (rev xs) = todos P xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 95: | Línea 123: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "todos P (rev xs) = todos P xs" | lemma "todos P (rev xs) = todos P xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 105: | Línea 133: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)" | lemma "algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 115: | Línea 143: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P (map f xs) = algunos (P o f) xs" | lemma "algunos P (map f xs) = algunos (P o f) xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 125: | Línea 153: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P (map f xs) = algunos (P o f) xs" | lemma "algunos P (map f xs) = algunos (P o f) xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 135: | Línea 163: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)" | lemma "algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 145: | Línea 173: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma algunos_append: | lemma algunos_append: | ||
"algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)" | "algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 156: | Línea 184: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P (rev xs) = algunos P xs" | lemma "algunos P (rev xs) = algunos P xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 166: | Línea 194: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P (rev xs) = algunos P xs" | lemma "algunos P (rev xs) = algunos P xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 178: | Línea 206: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 185: | Línea 213: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P xs = (¬ todos (λx. (¬ P x)) xs)" | lemma "algunos P xs = (¬ todos (λx. (¬ P x)) xs)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 195: | Línea 223: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "algunos P xs = (¬ todos (λx. (¬ P x)) xs)" | lemma "algunos P xs = (¬ todos (λx. (¬ P x)) xs)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 209: | Línea 237: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
fun estaEn :: "'a ⇒ 'a list ⇒ bool" where | fun estaEn :: "'a ⇒ 'a list ⇒ bool" where | ||
"estaEn x xs = undefined" | "estaEn x xs = undefined" | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 219: | Línea 247: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 230: | Línea 258: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
fun sinDuplicados :: "'a list ⇒ bool" where | fun sinDuplicados :: "'a list ⇒ bool" where | ||
"sinDuplicados xs = undefined" | "sinDuplicados xs = undefined" | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 241: | Línea 269: | ||
elementos duplicados de la lista xs. Por ejemplo, | elementos duplicados de la lista xs. Por ejemplo, | ||
borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3] | borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3] | ||
− | + | ||
Nota: La función borraDuplicados es equivalente a la predefinida | Nota: La función borraDuplicados es equivalente a la predefinida | ||
remdups. | remdups. | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
fun borraDuplicados :: "'a list ⇒ 'a list" where | fun borraDuplicados :: "'a list ⇒ 'a list" where | ||
"borraDuplicados xs = undefined" | "borraDuplicados xs = undefined" | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 256: | Línea 284: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma length_borraDuplicados: | lemma length_borraDuplicados: | ||
"length (borraDuplicados xs) ≤ length xs" | "length (borraDuplicados xs) ≤ length xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 267: | Línea 295: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma length_borraDuplicados: | lemma length_borraDuplicados: | ||
"length (borraDuplicados xs) ≤ length xs" | "length (borraDuplicados xs) ≤ length xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 278: | Línea 306: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "estaEn a (borraDuplicados xs) = estaEn a xs" | lemma "estaEn a (borraDuplicados xs) = estaEn a xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 288: | Línea 316: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma estaEn_borraDuplicados: | lemma estaEn_borraDuplicados: | ||
"estaEn a (borraDuplicados xs) = estaEn a xs" | "estaEn a (borraDuplicados xs) = estaEn a xs" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 299: | Línea 327: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "sinDuplicados (borraDuplicados xs)" | lemma "sinDuplicados (borraDuplicados xs)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 309: | Línea 337: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma sinDuplicados_borraDuplicados: | lemma sinDuplicados_borraDuplicados: | ||
"sinDuplicados (borraDuplicados xs)" | "sinDuplicados (borraDuplicados xs)" | ||
oops | oops | ||
− | + | ||
text {* | text {* | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
Línea 320: | Línea 348: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
*} | *} | ||
− | + | ||
lemma "borraDuplicados (rev xs) = rev (borraDuplicados xs)" | lemma "borraDuplicados (rev xs) = rev (borraDuplicados xs)" | ||
oops | oops | ||
− | + | ||
end | end | ||
</source> | </source> |
Revisión del 13:39 15 nov 2014
header {* R5: Cuantificadores sobre listas *}
theory R5
imports Main
begin
text {*
---------------------------------------------------------------------
Ejercicio 1. Definir la función
todos :: ('a ⇒ bool) ⇒ 'a list ⇒ bool
tal que (todos p xs) se verifica si todos los elementos de la lista
xs cumplen la propiedad p. Por ejemplo, se verifica
todos (λx. 1<length x) [[2,1,4],[1,3]]
¬todos (λx. 1<length x) [[2,1,4],[3]]
Nota: La función todos es equivalente a la predefinida list_all.
---------------------------------------------------------------------
*}
--"jeshorcob"
fun todos :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where
"todos p [] = True"
|"todos p (x#xs) = (p x ∧ todos p xs)"
--"jeshorcob"
fun todos2 :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where
"todos2 p xs = foldr (λx. op ∧ (p x)) xs True"
text {*
---------------------------------------------------------------------
Ejercicio 2. Definir la función
algunos :: ('a ⇒ bool) ⇒ 'a list ⇒ bool
tal que (algunos p xs) se verifica si algunos elementos de la lista
xs cumplen la propiedad p. Por ejemplo, se verifica
algunos (λx. 1<length x) [[2,1,4],[3]]
¬algunos (λx. 1<length x) [[],[3]]"
Nota: La función algunos es equivalente a la predefinida list_ex.
---------------------------------------------------------------------
*}
--"jeshorcob"
fun algunos :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where
"algunos p [] = True"
|"algunos p (x#xs) = (p x ∨ todos p xs)"
--"jeshorcob"
fun algunos2 :: "('a ⇒ bool) ⇒ 'a list ⇒ bool" where
"algunos2 p xs = foldr (λx. op ∨ (p x)) xs True"
text {*
---------------------------------------------------------------------
Ejercicio 3.1. Demostrar o refutar automáticamente
todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)
---------------------------------------------------------------------
*}
--"jeshorcob"
lemma "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)"
by (induct xs) auto
text {*
---------------------------------------------------------------------
Ejercicio 3.2. Demostrar o refutar detalladamente
todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)
---------------------------------------------------------------------
*}
--"jeshorcob"
lemma "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)"
proof (induct xs)
show "todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])" by simp
next
fix x xs
assume HI: "todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)"
have "todos (λx. P x ∧ Q x) (x#xs) =
((P x ∧ Q x) ∧ todos (λx. P x ∧ Q x) xs) " by simp
also have "... = (P x∧Q x∧todos P xs∧todos Q xs)" using HI by simp
also have "... = ((P x∧todos P xs)∧(Q x ∧ todos Q xs))" by arith
also have "... = (todos P (x#xs) ∧ (Q x ∧ todos Q xs))" by simp
also have "... = (todos P (x#xs) ∧ todos Q (x#xs))" by simp
finally show "todos (λx. P x ∧ Q x) (x#xs) =
(todos P (x#xs) ∧ todos Q (x#xs))" by simp
qed
text {*
---------------------------------------------------------------------
Ejercicio 4.1. Demostrar o refutar automáticamente
todos P (x @ y) = (todos P x ∧ todos P y)
---------------------------------------------------------------------
*}
lemma "todos P (x @ y) = (todos P x ∧ todos P y)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 4.2. Demostrar o refutar detalladamente
todos P (x @ y) = (todos P x ∧ todos P y)
---------------------------------------------------------------------
*}
lemma todos_append:
"todos P (x @ y) = (todos P x ∧ todos P y)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 5.1. Demostrar o refutar automáticamente
todos P (rev xs) = todos P xs
---------------------------------------------------------------------
*}
lemma "todos P (rev xs) = todos P xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 5.2. Demostrar o refutar detalladamente
todos P (rev xs) = todos P xs
---------------------------------------------------------------------
*}
lemma "todos P (rev xs) = todos P xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 6. Demostrar o refutar:
algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)
---------------------------------------------------------------------
*}
lemma "algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 7.1. Demostrar o refutar automáticamente
algunos P (map f xs) = algunos (P ∘ f) xs
---------------------------------------------------------------------
*}
lemma "algunos P (map f xs) = algunos (P o f) xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 7.2. Demostrar o refutar datalladamente
algunos P (map f xs) = algunos (P ∘ f) xs
---------------------------------------------------------------------
*}
lemma "algunos P (map f xs) = algunos (P o f) xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 8.1. Demostrar o refutar automáticamente
algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)
---------------------------------------------------------------------
*}
lemma "algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 8.2. Demostrar o refutar detalladamente
algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)
---------------------------------------------------------------------
*}
lemma algunos_append:
"algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 9.1. Demostrar o refutar automáticamente
algunos P (rev xs) = algunos P xs
---------------------------------------------------------------------
*}
lemma "algunos P (rev xs) = algunos P xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 9.2. Demostrar o refutar detalladamente
algunos P (rev xs) = algunos P xs
---------------------------------------------------------------------
*}
lemma "algunos P (rev xs) = algunos P xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la
siguiente ecuación:
algunos (λx. P x ∨ Q x) xs = Z
y demostrar la equivalencia de forma automática y detallada.
---------------------------------------------------------------------
*}
text {*
---------------------------------------------------------------------
Ejercicio 11.1. Demostrar o refutar automáticamente
algunos P xs = (¬ todos (λx. (¬ P x)) xs)
---------------------------------------------------------------------
*}
lemma "algunos P xs = (¬ todos (λx. (¬ P x)) xs)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 11.2. Demostrar o refutar datalladamente
algunos P xs = (¬ todos (λx. (¬ P x)) xs)
---------------------------------------------------------------------
*}
lemma "algunos P xs = (¬ todos (λx. (¬ P x)) xs)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 12. Definir la funcion primitiva recursiva
estaEn :: 'a ⇒ 'a list ⇒ bool
tal que (estaEn x xs) se verifica si el elemento x está en la lista
xs. Por ejemplo,
estaEn (2::nat) [3,2,4] = True
estaEn (1::nat) [3,2,4] = False
---------------------------------------------------------------------
*}
fun estaEn :: "'a ⇒ 'a list ⇒ bool" where
"estaEn x xs = undefined"
text {*
---------------------------------------------------------------------
Ejercicio 13. Expresar la relación existente entre estaEn y algunos.
Demostrar dicha relación de forma automática y detallada.
---------------------------------------------------------------------
*}
text {*
---------------------------------------------------------------------
Ejercicio 14. Definir la función primitiva recursiva
sinDuplicados :: 'a list ⇒ bool
tal que (sinDuplicados xs) se verifica si la lista xs no contiene
duplicados. Por ejemplo,
sinDuplicados [1::nat,4,2] = True
sinDuplicados [1::nat,4,2,4] = False
---------------------------------------------------------------------
*}
fun sinDuplicados :: "'a list ⇒ bool" where
"sinDuplicados xs = undefined"
text {*
---------------------------------------------------------------------
Ejercicio 15. Definir la función primitiva recursiva
borraDuplicados :: 'a list ⇒ bool
tal que (borraDuplicados xs) es la lista obtenida eliminando los
elementos duplicados de la lista xs. Por ejemplo,
borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]
Nota: La función borraDuplicados es equivalente a la predefinida
remdups.
---------------------------------------------------------------------
*}
fun borraDuplicados :: "'a list ⇒ 'a list" where
"borraDuplicados xs = undefined"
text {*
---------------------------------------------------------------------
Ejercicio 16.1. Demostrar o refutar automáticamente
length (borraDuplicados xs) ≤ length xs
---------------------------------------------------------------------
*}
lemma length_borraDuplicados:
"length (borraDuplicados xs) ≤ length xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 16.2. Demostrar o refutar detalladamente
length (borraDuplicados xs) ≤ length xs
---------------------------------------------------------------------
*}
lemma length_borraDuplicados:
"length (borraDuplicados xs) ≤ length xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 17.1. Demostrar o refutar automáticamente
estaEn a (borraDuplicados xs) = estaEn a xs
---------------------------------------------------------------------
*}
lemma "estaEn a (borraDuplicados xs) = estaEn a xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 17.2. Demostrar o refutar detalladamente
estaEn a (borraDuplicados xs) = estaEn a xs
---------------------------------------------------------------------
*}
lemma estaEn_borraDuplicados:
"estaEn a (borraDuplicados xs) = estaEn a xs"
oops
text {*
---------------------------------------------------------------------
Ejercicio 18.1. Demostrar o refutar automáticamente
sinDuplicados (borraDuplicados xs)
---------------------------------------------------------------------
*}
lemma "sinDuplicados (borraDuplicados xs)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 18.2. Demostrar o refutar detalladamente
sinDuplicados (borraDuplicados xs)
---------------------------------------------------------------------
*}
lemma sinDuplicados_borraDuplicados:
"sinDuplicados (borraDuplicados xs)"
oops
text {*
---------------------------------------------------------------------
Ejercicio 19. Demostrar o refutar:
borraDuplicados (rev xs) = rev (borraDuplicados xs)
---------------------------------------------------------------------
*}
lemma "borraDuplicados (rev xs) = rev (borraDuplicados xs)"
oops
end