SlideShare a Scribd company logo
1 of 26
Formal methods in
software engineering
Lec 2
Elements of Z
Prof Engr Faiz ul haque Zeya
Topics in this lecture
 Sets and types,
 declarations,
 variables,
 expressions,
 operators,
 predicates,
 equations and
 laws.
Sets
Displaying sets
 The obvious way to describe a set is to list or enumerate all of its members or elements. This is
called a set display. In Z we follow the ordinary mathematical convention and write sets with
braces, separating elements by commas. Here is a display of the set of lamps in a traffic light:
 {red, yellow, green]
Naming sets
 To write a program that simulates a dice game, we need a set that contains
the numbers of spots found on the faces of dice: {1,2, 3,4, 5,6). Z does
provide notation for a range of consecutive numbers; we can abbreviate this 1
.. 6 (without braces) pronounced one up to six
Types
 In Z we can only form sets from objects that are similar in some way. We say
that elements of the same set must have the same type; sets in Z are typed
 {2,4, red, yellow, 6} [TYPE ERROR! Elements have different types.]
Type and set
 Types and sets are very closely related. Every type has a carrier set that
contains all of the objects of that type. For example, the carrier set for the
integer type Z is the set with every integer in it: {..., —2, — 1,0, 1, 2,...}. We
usually say that the type is its carrier set . Every type is a set, but not all sets
are types.
 Natural numbers belong to the type integer, Z, because every natural
numberis also an integer.
 Types are very important in Z, even though only one type is built in: the type
integer, appropriately named Z
Declaration
 Declarations introduce variables and tell to which set each variable belongs.
Declaration cont…
 Each name introduced in a declaration names or denotes a single element in
the set that appears to the right of the colon. This element is sometimes
called the name's value. This value may be unknown or undetermined, so the
names introduced in declarations are called variables. In the preceding
declarations, i, d1,d2 and signal are variables
Constraining variables
 In Z we can constraints the value the variable it can take. These are
axiomatic definitions that include a paragraph with contraints. Predicates are
the constraints
Constant
Constant
 . A definition where the types are explicitly spelled out in this way is said to
be normalized.
 . A signature is a declaration that names the type, as we must have in a
normalized definition: e : EVEN is a declaration, but e : Z is a signature.
Defining new types
 Two methods for defining types.
 FREE TYPE definition.
 BASIC TYPE definition.
Free types
 Similar to enumerated types. When there are not enough items.
BASIC types
 When there are too many items in the type and we dobnt; wabnt to say in
advance what the elements are.
 [NAME]
Set variable
Idnetifier
Expressions and operators
 Expressions describe the values that variables might have.
 Expressions enable us to describe values in terms of names and literals we
have already defined. Expressions are formulas where names and literal
values appear together with operators. Expressions are sometimes called
terms
Arithmetic expression
 The Z mathematical tool-kit defines the usual arithmetic operators addition,
subtraction, and multiplication +, —, and *. The tool-kit doesn't provide any
way to represent fractions — it doesn't define real or rational numbers — so
ordinary division is not available. However, the tool-kit does provide integer
division div and remainder or modulus mod
 12 div 5=2
 12 mod 5=2
Set expression
Expression and type
 Every expression has a type: the type of the value it denotes.
 Some operators are generic; they can work with different types as long as
types are combined correctly
 Some operators take operands of one type and denote values of a different
type. For example, the size (or cardinality) operator # counts the elements of
a set. Its operand is a set, but its value is a number:
Erroneous expressions
 Expressions must have the correct appearance or syntax. In Z, as in
traditional mathematics, most binary operators have infix syntax: They
appear between their operands, as in 5 -f 3OTODD U EVEN.Many unary
operators in Z have pre/u syntax: They appear before their operands, as in —
x or #DICE. Using a prefix operator as if it were postfix is an example of a
syntax error.
 DICE# is an error.
Predicates , equations and law
 Three kinds of predicates: equations such as size = 2048, inequalities such as
size > 640, and membership predicates such as e € EVEN.
Equations-
 An equation is a predicate where two expressions are joined by an equal sign:
e1 = e2. means that e1 and e2 both have the same value. Equations are
perhaps the most common predicates
 Size=2048
Law
 They are also used to describe the operators themselves. Predicates used in
this way are called laws

More Related Content

Similar to elementsofZ.pptx

Similar to elementsofZ.pptx (20)

Object Oriented Programming with C++
Object Oriented Programming with C++Object Oriented Programming with C++
Object Oriented Programming with C++
 
03 Ch3 Notes Revised
03 Ch3 Notes Revised03 Ch3 Notes Revised
03 Ch3 Notes Revised
 
component of c language.pptx
component of c language.pptxcomponent of c language.pptx
component of c language.pptx
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
ERD.pptx
ERD.pptxERD.pptx
ERD.pptx
 
Variables & Data Types in R
Variables & Data Types in RVariables & Data Types in R
Variables & Data Types in R
 
structureformal1.ppt
structureformal1.pptstructureformal1.ppt
structureformal1.ppt
 
R Programming
R ProgrammingR Programming
R Programming
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
C++ data types
C++ data typesC++ data types
C++ data types
 
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCA
 
dbms er model
dbms er modeldbms er model
dbms er model
 
Chapter3
Chapter3Chapter3
Chapter3
 
Chapter3
Chapter3Chapter3
Chapter3
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 

More from Faiz Zeya

lec3forma.pptx
lec3forma.pptxlec3forma.pptx
lec3forma.pptxFaiz Zeya
 
FOLBUKCFAIZ.pptx
FOLBUKCFAIZ.pptxFOLBUKCFAIZ.pptx
FOLBUKCFAIZ.pptxFaiz Zeya
 
Word2vec-08032022-012238pm (1).pptx
Word2vec-08032022-012238pm (1).pptxWord2vec-08032022-012238pm (1).pptx
Word2vec-08032022-012238pm (1).pptxFaiz Zeya
 
Code completion using OpenAI APIs.pptx
Code completion using OpenAI APIs.pptxCode completion using OpenAI APIs.pptx
Code completion using OpenAI APIs.pptxFaiz Zeya
 
Types of machine learning.pptx
Types of machine learning.pptxTypes of machine learning.pptx
Types of machine learning.pptxFaiz Zeya
 
Linear algebraweek2
Linear algebraweek2Linear algebraweek2
Linear algebraweek2Faiz Zeya
 
Query expansion for search improvement by faizulhaque
Query expansion for search improvement by faizulhaque Query expansion for search improvement by faizulhaque
Query expansion for search improvement by faizulhaque Faiz Zeya
 
Big data introduction
Big data introductionBig data introduction
Big data introductionFaiz Zeya
 

More from Faiz Zeya (8)

lec3forma.pptx
lec3forma.pptxlec3forma.pptx
lec3forma.pptx
 
FOLBUKCFAIZ.pptx
FOLBUKCFAIZ.pptxFOLBUKCFAIZ.pptx
FOLBUKCFAIZ.pptx
 
Word2vec-08032022-012238pm (1).pptx
Word2vec-08032022-012238pm (1).pptxWord2vec-08032022-012238pm (1).pptx
Word2vec-08032022-012238pm (1).pptx
 
Code completion using OpenAI APIs.pptx
Code completion using OpenAI APIs.pptxCode completion using OpenAI APIs.pptx
Code completion using OpenAI APIs.pptx
 
Types of machine learning.pptx
Types of machine learning.pptxTypes of machine learning.pptx
Types of machine learning.pptx
 
Linear algebraweek2
Linear algebraweek2Linear algebraweek2
Linear algebraweek2
 
Query expansion for search improvement by faizulhaque
Query expansion for search improvement by faizulhaque Query expansion for search improvement by faizulhaque
Query expansion for search improvement by faizulhaque
 
Big data introduction
Big data introductionBig data introduction
Big data introduction
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 

elementsofZ.pptx

  • 1. Formal methods in software engineering Lec 2 Elements of Z Prof Engr Faiz ul haque Zeya
  • 2. Topics in this lecture  Sets and types,  declarations,  variables,  expressions,  operators,  predicates,  equations and  laws.
  • 3. Sets Displaying sets  The obvious way to describe a set is to list or enumerate all of its members or elements. This is called a set display. In Z we follow the ordinary mathematical convention and write sets with braces, separating elements by commas. Here is a display of the set of lamps in a traffic light:  {red, yellow, green]
  • 4. Naming sets  To write a program that simulates a dice game, we need a set that contains the numbers of spots found on the faces of dice: {1,2, 3,4, 5,6). Z does provide notation for a range of consecutive numbers; we can abbreviate this 1 .. 6 (without braces) pronounced one up to six
  • 5. Types  In Z we can only form sets from objects that are similar in some way. We say that elements of the same set must have the same type; sets in Z are typed  {2,4, red, yellow, 6} [TYPE ERROR! Elements have different types.]
  • 6. Type and set  Types and sets are very closely related. Every type has a carrier set that contains all of the objects of that type. For example, the carrier set for the integer type Z is the set with every integer in it: {..., —2, — 1,0, 1, 2,...}. We usually say that the type is its carrier set . Every type is a set, but not all sets are types.  Natural numbers belong to the type integer, Z, because every natural numberis also an integer.  Types are very important in Z, even though only one type is built in: the type integer, appropriately named Z
  • 7. Declaration  Declarations introduce variables and tell to which set each variable belongs.
  • 8. Declaration cont…  Each name introduced in a declaration names or denotes a single element in the set that appears to the right of the colon. This element is sometimes called the name's value. This value may be unknown or undetermined, so the names introduced in declarations are called variables. In the preceding declarations, i, d1,d2 and signal are variables
  • 9. Constraining variables  In Z we can constraints the value the variable it can take. These are axiomatic definitions that include a paragraph with contraints. Predicates are the constraints
  • 10.
  • 13.  . A definition where the types are explicitly spelled out in this way is said to be normalized.  . A signature is a declaration that names the type, as we must have in a normalized definition: e : EVEN is a declaration, but e : Z is a signature.
  • 14. Defining new types  Two methods for defining types.  FREE TYPE definition.  BASIC TYPE definition.
  • 15. Free types  Similar to enumerated types. When there are not enough items.
  • 16. BASIC types  When there are too many items in the type and we dobnt; wabnt to say in advance what the elements are.  [NAME]
  • 19. Expressions and operators  Expressions describe the values that variables might have.  Expressions enable us to describe values in terms of names and literals we have already defined. Expressions are formulas where names and literal values appear together with operators. Expressions are sometimes called terms
  • 20. Arithmetic expression  The Z mathematical tool-kit defines the usual arithmetic operators addition, subtraction, and multiplication +, —, and *. The tool-kit doesn't provide any way to represent fractions — it doesn't define real or rational numbers — so ordinary division is not available. However, the tool-kit does provide integer division div and remainder or modulus mod  12 div 5=2  12 mod 5=2
  • 22. Expression and type  Every expression has a type: the type of the value it denotes.  Some operators are generic; they can work with different types as long as types are combined correctly  Some operators take operands of one type and denote values of a different type. For example, the size (or cardinality) operator # counts the elements of a set. Its operand is a set, but its value is a number:
  • 23. Erroneous expressions  Expressions must have the correct appearance or syntax. In Z, as in traditional mathematics, most binary operators have infix syntax: They appear between their operands, as in 5 -f 3OTODD U EVEN.Many unary operators in Z have pre/u syntax: They appear before their operands, as in — x or #DICE. Using a prefix operator as if it were postfix is an example of a syntax error.  DICE# is an error.
  • 24. Predicates , equations and law  Three kinds of predicates: equations such as size = 2048, inequalities such as size > 640, and membership predicates such as e € EVEN.
  • 25. Equations-  An equation is a predicate where two expressions are joined by an equal sign: e1 = e2. means that e1 and e2 both have the same value. Equations are perhaps the most common predicates  Size=2048
  • 26. Law  They are also used to describe the operators themselves. Predicates used in this way are called laws