Toggle navigation
Help
Preferences
Sign up
Log in
Advanced
Ejemplos especificacin en B PowerPoint PPT Presentation
1
/
19
Actions
Remove this presentation
Flag as Inappropriate
I Don't Like This
I like this
Remember as a Favorite
Share
Share
About This Presentation
Transcript and Presenter's Notes
Title: Ejemplos especificacin en B
1
Ejemplos especificación en B
MeFIS
Ramón Brena
2006
2
Sistema de facturación
El sistema manejará las entidades client,
product, invoice, y line
Un cliente tiene allowance categoría (normal,
dubious, friend), cada una tiene un discount
Un producto tiene price, status (available, sold
out), substitute
Una facture tiene client, discount percentage,
max monto permitido
Una linea (de factura) se refiere a un artículo,
cantidad, costo unitario
3
Operaciones
Creación y modificación de clientes
Creación y modificación de producto
Creación y destrucción de factura
Adición de linea a factura
4
Leyes
Un producto agotado no puede entrar en una
factura
Sin embargo, si hay un sustituto, el sistema lo
reemplaza automáticamente en la factura
Dos líneas de la factura no pueden referirse al
mismo artículo
Los clientes dudosos no pueden recibir facturas
El monto (descontado) de la factura no debe
exceder la cantidad permitida
Los amigos tienen 20 de descuento, y nadie más
tiene descuento
5
Combinación de máquinas
La cláusula USES permite utilizar definiciones
previas de otras máquinas
MACHINE
Invoice
USES
Client,
Product
6
Cliente
MACHINE
Client
SETS
CLIENT
CATEGORY friend,
dubious, normal
CONSTANTS
discount
PROPERTIES
discount ? CATEGORY ? (0..100) ?
discount
friend ? 80,
dubious ? 100,
normal ? 100
VARIABLES
client, category, allowance
7
Cliente
INVARIANT
client ? CLIENT ?
category ? client ? CATEGORY ?
allowance ? client ? NAT
INITIALIZATION
client, category, allowance ?, ?, ?
OPERATIONS
c ? create_client(a)
PRE
a ? NAT ?
client ? CLIENT
THEN
END
8
Cliente
modify_category(c,k)
modify_allowance(c,a)
c ? read_client
PRE client ? ? THEN
c ? client
END
END
9
Product
MACHINE
Product
SETS
PRODUCT
STATUS
available, sold_out
VARIABLES
product, price, status, substitute
INVARIANT
product ? PRODUCT ?
price ? product ? NAT ?
status ?
product ? STATUS ?
substitute ? product ?
status-1available
INITIALIZATION
product, price, status, substitute ?, ?, ?, ?
10
Product
OPERATIONS
p ? create_product(c)
PRE
c ? NAT ?
product ? PRODUCT
THEN
END
modify_price
make_unavailable(p)
PRE
p ? product
THEN
status(p) sold_out
substitute substitute ? p
END
11
Product
assign_substitute(p,q)
PRE
p ? product ?
q ? product ?
status(q) available
THEN
substitute(p) q
END
p ? read_product
PRE
product ? ?
THEN
p ? product
END
END
12
Invoice
MACHINE
Invoice
USES
Client, Product
SETS
INVOICE
LINE
VARIABLES
invoice, customer, percentage, allowed, total,
line, origin, article, quantity, unit_cost
13
Invoice
INVARIANT
invoice ? INVOICE ?
customer ? invoice ? client ?
percentage ? invoice (0..100) ?
allowed ? invoice ? NAT ?
total ? invoice ? NAT ?
ran (total ? allowed) ? geq ?
line ? LINE ?
origin ? line ? invoice ?
article ? line ? product ?
quantity ? line ? NAT ?
unit_cost ? line ? NAT ?
origin ? article ? line ? invoice x product
14
Invoice
OPERATIONS
i?create_invoice_header(c)
PRE
c ? client ?
category(c) ? dubious ?
invoice ? INVOICE
THEN
ANY j WHERE
j ? INVOICE - invoice
THEN
invoice invoice ? j
customer(j) c
percentage(j) discount(categorie(c))
allowed(j) allowance(c)
i j
END
END
15
Control de ascensores
Se quieren controlar los elevadores de un
edificio de m pisos.
En cada elevador hay un boton para cada piso, y
se prenden al apretarlos para ir a ese piso se
apagan al llegar al piso.
Los pisos intermedios tienen dos botones para
llamar los elevadores hacia arriba o abajo se
prenden y apagan como los antes mencionados.
16
Control de un ascensor
Cuando no hay llamadas, permanecen donde hayan
quedado, con puertas cerradas.
Todas las llamadas de los pisos deben
eventualmente ser atendidas, y no hay prioridad
de ningún piso.
Todas las llamadas en los elevadores deben ser
eventualmente atendidas, en el sentido de
recorrido del elevador.
Hay un botón de emergencia en cada elevador
17
Lift
MACHINE
Lift
SETS
LIFT
DIRECTION up, dn
CONSTANTS
ground, top
PROPERTIES
ground ? NAT ?
top ? NAT ?
ground lt top
DEFINITIONS
FLOOR ground..top
VARIABLES
moving, floor, dir, in, out
INVARIANT
moving ? LIFT ?
floor ? LIFT ? FLOOR ?
dir ? LIFT ? DIRECTION ?
in ? FLOOR ? DIRECTION ?
out ? LIFT ? FLOOR ?
18
Lift
INVARIANT
(ground,dn) ? ___ ?
(top,up) ? ___ ?
moving ? (out ? floor) ? ?
in ? ran(moving ?(floor ? dir))
? /Explicar/
INITIALIZATION
in,out,moving __, __,__
floor LIFT ? ______
dir LIFT ? ______
OPERATIONS
Request_Floor(l,f)
PRE
l ? LIFT ?
f ? FLOOR ?
(l ? moving ?
floor(l) ? f)
THEN
out out ? (__,__)
END
19
Lift
INVARIANT
(ground,dn) ? in ?
(top,up) ? in ?
moving ? (out ? floor) ? ?
in ? ran(moving ?(floor ? dir))
?
INITIALIZATION
in, out, moving ?, ?, ?
floor LIFT ? ground
dir LIFT ? up
OPERATIONS
Request_Floor(l,f)
PRE
l ? LIFT ?
f ? FLOOR ?
(l ? moving ?
floor(l) ? f)
THEN
out out ? (l,f)
END
Write a Comment
User Comments (
0
)
Cancel
OK
OK
Latest
Latest
Highest Rated
Sort by:
Latest
Highest Rated
Page
of
Recommended
Recommended
Relevance
Latest
Highest Rated
Most Viewed
Sort by:
Recommended
Relevance
Latest
Highest Rated
Most Viewed
Related
More from user
«
/
»
Page
of
«
/
»