Está en la página 1de 2

1.

Sı́mbolos útiles
Z \ent
R \ float
Bool \bool
True \True
False \False
→ \Then
↔ \ Iff
−→ \implica
∧ $\land$
∨ $\lor$
¬ $\lnot$
∧L $\yLuego$
∨L $\oLuego$
−→L $\implicaLuego$
if condicion then verdadero else f also fi \IfThenElse{condicion}{verdadero}{falso}
[1..10] \rango{1}{10}
(1..10] \rangoac{1}{10}
[1..10) \rangoca{1}{10}
(1..10) \rangoaa{1}{10}
Float \rea
Char \cha
prm(x) \prm{x}
sgd(x) \sgd{x}
mcd $\mcd$
seqhxi \TLista{x}
seqhseqhxii \matriz{x}
[] \lvacia
addFirst(xs) \cons{xs}
indice(xs) \indice{xs}
concat(xs) \conc{xs}
head(xs) \cab{xs}
tail(x) \cola{x}
subseq(xs) \sub{xs}
en(xs) \en{xs}
++ \masmas
acum(expresion|selector, condicion) \acumselec{expresion}{selector}{condicion}
x ← [1..10] \ selector {x}{\rango{1}{10}}

1
2. Definición de Problemas
proc sumar (in a:Z, in b:Z, out c: Z) {
Pre {a 6= 0}
Post {c = a + b}
}

\ b e g i n { p r o c }{ sumar }{\ In a : \ ent , \ In b : \ ent , \Out c : \ e n t }{}


\ p r e {a \ neq 0}
\ p o s t { c = a+b}
\ end { p r o c }

proc dividir (inout a: Z, in b: Z) {


Pre {puedoDividir(b)}
Post divide : {a = a/b}
pred puedoDividir (b: Z) {b = 6 0}
}

\ b e g i n { p r o c }{ d i v i d i r }{\ I n o u t a : \ ent , \ In b : \ e n t }{}


\ pre { puedoDividir (b)}
\ p o s t [ d i v i d e ] { a = a /b}
\ pred { p u e d o D i v i d i r }{b : \ e n t }{b \ neq 0}
\ end { p r o c }

proc potencia (inout b: Z, in e: Z) {


Pre {b = b0 }
Post {b = potencia(b0 , e)}
fun potencia (b:Z,e:Z) : Z = be ;
}

\ b e g i n { p r o c }{ p o t e n c i a }{\ I n o u t b : \ e n t , \ In e : \ e n t }{}
\ p r e {b = b 0 }
\ p o s t {b = p o t e n c i a ( b 0 , e ) }
\ aux { p o t e n c i a }{b : \ ent , e : \ e n t }{\ e n t }{bˆ e }
\ end { p r o c }

2.0.1. Otros comandos útiles (cuando no estamos en environment proc)


proc Sumar (in a:Z, inout b:Z) \encabezadoDeProc{result}{Sumar}{\In a:\ent, \Inout b:\ent}{}
Pre positivo: a > 0 \ preil {positivo}{a>0}
Post divide: res = b/a \ postil {divide}{res = b/a}
fun potencia \auxnom{potencia}

También podría gustarte