1. Trang chủ
  2. » Luận Văn - Báo Cáo

Lecture Formal methods in software engineering: Partial operator - TRƯỜNG CÁN BỘ QUẢN LÝ GIÁO DỤC THÀNH PHỐ HỒ CHÍ MINH

10 10 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 609,7 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The type   set of X is the class of all possible finite sets of values drawn from the type   X .  For example:. set of nat1 sets of non-zero Natural numbers[r]

Trang 1

Lecture 21

Trang 2

Qaisar Javaid, Assistant Professor

Trang 3

An operator

op : T1 * * Tn -> R

is said to be total if, for any a1:T1, an:Tn, the expression

op(a1, ., an)

is defined. 

If there exists some b1:T1, .,bn:Tn for which

op(b1, .,bn)

is undefined, op is said to be a partial operator. 

We avoid applying partial operators to values on which they are 

undefined!

Trang 4

Type Symbol

nat

nat1

int

real

char

Bool

Values

Natural numbers

nat excluding

0 Integers Real Numbers Characters Booleans

Example Values

0, 1, 2, …

1, 2, 3, …

…,-1,0,1,2,…

-23.334

‘g’, ‘@’

true, false

<Red>, <Bio>

Operators

+,-,*,/,… +,-,*,/,… +,-,*,/,… +,-,*,/,…

=, <>

and, or, …

=, <>

Trang 5

Type Constructors

[_] Optional types :: Record types set of _ Finite sets seq of _ Finite sequences map _ to _ Finite mappings

Trang 6

The finite set type constructor is: set of _

What are the types of the following expressions?

{1, -3, 12}

Trang 7

The set type constructor

The type set of X is the class of all possible finite sets of values drawn from the type X. For example:

set of nat1 sets of non-zero Natural numbers

set of Student sets of student records

set of (seq of char) sets of sequences of

characters (e.g sets of names)

set of (set of int) sets of sets of integers, e.g. 

{ {3,56,2},{-2},{},{-33,5} }

Trang 8

(1) Enumeration:

(2) Subrange (integers only): {integer1, ,integer2}

e.g {12, ,20} =

{12, ,12} =

{9, ,3} =

(0) Empty Set: {}

Trang 9

Defining sets 

(3) Comprehension

{ expression | binding & predicate }

The set of values of the expression under each assignment of values to bound variables  satisfying the predicate. 

Consider all the values that can be taken by the variables in the binding. 

Restrict this to just those combinations of values which satisfy the predicate. 

Evaluate the expression for each combination. This gives you the values in the set. 

e.g.  { x**2 | x:nat & x < 5 }

Trang 10

Examples of Comprehensions:

{x | x:nat & x < 5}

{y | y:nat & y < 0}

{x+y | x,y:nat & x<3 and y<4}

Ngày đăng: 01/04/2021, 16:00

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w