exam in discrete math

profileA1Homework_01
FrmlMeth.SoftwareEXLSGroupCASpringSemester2018CO-4262018-738AM1.zip

Overview3.html

This unit will cover how to use predicate calculus to represent program specifications and will outline how sets, relations, and predicate calculus can be combined to produce mathematical specifications.

Learning Objectives: Related course level objectives: 2 and 4 (note 4 is LO2 below)

After completing the tasks of Module 10:

  • The student will be able to determine the truth value of predicates written in predicate calculus.
  • Express natural language design specifications as pre- and post-conditions in predicate calculus.
  • The student will be able to convert natural language specifications into predicate calculus using a comprehensive specification.
  • The student will be able to determine the truth value of predicates expressed using comprehensive specification.
  • The student will be able to identify the elements of relations specified using a comprehensive specification.
  • The student will be able to determine the truth value of predicates expressed using relations and Z operations.

Tasks: To achieve the learning objectives of this module, you must do the following:

  • Read Chapters 5 & 6 in Ince.
  • Finish and Submit the assignment.
  • Read all of the files in the learning module.
  • Participate and lead (start threads and reply to threads) the discussion on Predicate Calculus in the Content Forum of the Discussion Tool.
  • Take the Predicate Calculus Quiz
  • Read the assigned paper on Z to prepare for the next week

RELATIONS.docx

RELATIONS

A relation is a set of ordered pairs.

(x, y) = (p, q) (x = p) Λ (y = q)

EX: {a, b: N | a + b = 4 • (a, b)}

Defines the relation {(0, 4), (1, 3), (2, 2), (3, 1), (4, 0)}

Relations are usually named and can be written a number of ways:

EX: eqless = {a, b: N | a = b Λ a < 4} -- constructive specification

OR eqless = {(0, 0), (1, 1), (2, 2), (3, 3)} -- enumeration

If (x, y) is contained in a relation, then say:

(x, y) R OR R(x, y)

Can say the relation is defined over N x N

Relations describe a relationship between the elements; elements can be ordered pairs whose elements are sets.

EX: files = {new, old, archive, summary, tax}

And users = {Jones, Roberts, Wilson}

The relation CanAccess is a relation over users x P files which describe the files which a particular user can access.

This could contain:

{(Jones, {new}), (Roberts, {new, old, summary}), (Wilson, {tax})}

There are a number of operators defined for relations.

1. Domain operator: dom has one operand; its value is the set whose members are the left-hand elements of the pairs in a relation.

EX: Given CanAccess as defined above, then

dom CanAccess = {Jones, Roberts, Wilson}

2. Range operator: ran has one operand; its value is the set whose members are the right-hand elements of the pairs in a relation.

EX: Given UsesComputer is a relation defined over users x computers and

computers = {VAX780, Sequent, DRS800}

and the current value of UsesComputer is

{(Jones, VAX780), (Roberts, Sequent), (Wilson, VAX780)}

then ran UsesComputer =

{VAX780, Sequent}

3. Inverse operator: written as -1 as superscript; has one operand which is a relation; it reverses the elements of the pairs of the relation it operates on

EX: Given UsesComputer is a relation defined over users x computers and

computers = { VAX780, Sequent, DRS800}

and the current value of UsesComputer is

{(Jones, VAX780), (Roberts, Sequent), (Wilson, VAX780)}

then UsesComputer1 =

{(VAX780, Jones), (Sequent, Roberts), (VAX780, Wilson,)}

Example:

OS users are classified by means of sets NormalUsers and PrivilegedUsers. The association between users and the files they own is modelled by a relation owns over users and files. What expression represents the set of files owned by privileged users?

Answer: We’re looking for a specification that forms the relation which contains privileged users and files. So?

ran{u : users; f : files | u PrivilegedUsers Λ (u, f) owns }

Predicate+Calculus+and+Design+Specification+w+annotations.docx

Predicate Calculus and Design Specification

During system design a functional specification is transformed into a system design. The same drawbacks of using natural language in system specification are true for its use in design specification. We can use Predicate Calculus as an exact notation for describing the function of program units.

Singular Existential quantifier: asserts that only one object in a class holds. Written as:

a: acts • ActuatorState (a, functioning)

This asserts that only ONE actuator is functioning.

a: acts • ActuatorState (a, functioning)

There is a actuator that is functioning.

The second extra facility is known as the counting quantifier. The counting quantifier is not a predicate. It represents the number of objects in a class which have a certain property. The counting quantifier is Ω as is used as:

Ω line : lines . connected (line, reactor12)

This gives the number of communication lines which are connected to reactor 12.

The function of the “update” procedure is to update the value of the global variable SystemState. The system has one integer perimeter temp. If temp is greater than or equal to 200, then SystemState is set to zero; otherwise SystemState is set to a value of one.

SystemState will have a value ranging between zero and five, temp will range from zero to 1000. temp will be unaffected by the procedure.

Pre-condition:

(SystemState >= 0 ^ SystemState <= 5)^(temp >= 0 ^ temp<=1000)

Post-condition:

temp’=temp ^ ((temp>= 200)=> (SystemState’= 0))^ ((temp<200)=>(SystemState’=1))

The procedure NewVal has one integer parameter val. The function of NewVal is to increment the parameter by one.

Pre-condition:

Post-condition:

val’ = val + 1

The procedure “select” has three parameters. The first parameter flag is Boolean; The second and third parameters add and val are integers. If the first parameter is true, then the second parameter is set to the modulus of the third parameter.

Pre:

(flag Boolean )^(add )^(val )

Post:

[(flag’ = true) => (add’ = modulus val)]

The procedure “addup” has three parameters arr1, arr2, arr3. All the paramaters are integer arrays with range 1..50.Fuction of “addup” is to add corresponding element of arr1 and arr2 then put the sum into corresponding element of arr3.On entry to this function, arr3 elements are all zero.