SlideShare a Scribd company logo
FORMAL METHODS
Project Report
The purpose of this report is to demonstrate our end semester project for
“Formal Methods” that Find the index of the last 0 in an array
program.
Submitted by :
Shoaib Haseeb
6/8/2015
1
FORMAL METHODS
Project Report
Title:
Find the index of the last 0 in an array program
Input:
An array of integers.
Expected Output:
Index of the last zero in that array.
Pseudo code:
Summary:
In this project we were asked to find the index of the last zero in
array. The challenge which we faced was that we had the restriction of
passing only the array as an input. We couldn't pass another variable with
that. So for this purpose we made a function named "EXIST_ZERO" in which
an array is passed and we have used a built-in function of "EXISTS" in it
which is checking the existence of zero in the array.
6/8/2015
2
EXIST_ZERO function:
val EXIST_ZERO_DEF= Define
` (EXISTS [] = F) /
( EXISTS (h::t) = if (h=0) then T else EXISTS t)`;
Secondly we have made the function "last_zero" which in turn uses the
"EXIST_ZERO" function and returns the index of the last zero in the array
passed to it.
last_zero function:
val last_zero = Define
`( zero [] = 0 ) /
(zero (h::t) =
if (EXISTS (h::t))
then 1+ zero t
else
0
)`;
Some test cases to verify:
We verified the test cases using "e(RW_TAC
std_ss[last_zero,EXIST_ZERO_DEF]);" after setting goals.
Goals/Test Cases:
1: g`zero[]=0`;
Expected output: 0
Output:
> val it =
6/8/2015
3
Initial goal proved.
|- zero [] = 0 : proof
Status: Passed
2: g`zero[1;2;0;4]=3`;
Expected output: 3
Output:
> val it =
Initial goal proved.
|- zero [1; 2; 0; 4] = 3 : proof
Status: Passed
3: g`zero[0;0]=2`;
Expected output: 2
Output:
> val it =
Initial goal proved.
|- zero [0; 0] = 2 : proof
Status: Passed
4: g`zero[0;0;0;0]=zero[1;2;3;0]`;
Expected output: zero [0; 0; 0; 0] = zero [1; 2; 3; 0]
Output:
> val it =
Initial goal proved.
|- zero [0; 0; 0; 0] = zero [1; 2; 3; 0] : proof
Status: Passed
6/8/2015
4
5: g`zero[1;2;0;4]=2`;
Expected output: F
Output: > val it =
F
Status: Passed

More Related Content

DOCX
Check the output of the following code then recode it to eliminate fu
PDF
Class 6 2ciclo
PPT
Operator Overloading
PPSX
C programming array & shorting
PPTX
function in c
PPTX
Queue Implementation Using Array & Linked List
PDF
Data structure lab manual
PDF
Java -lec-5
Check the output of the following code then recode it to eliminate fu
Class 6 2ciclo
Operator Overloading
C programming array & shorting
function in c
Queue Implementation Using Array & Linked List
Data structure lab manual
Java -lec-5

What's hot (20)

PPTX
Operator overloading
PPTX
Templates
PDF
Introduction to Computer and Programing - Lecture 04
DOCX
Exp 5-1 d-422
DOCX
01 list using array
DOCX
Data Structure Project File
PPTX
BB - Functions (Operations and Piecewise)
PPTX
MCM FUNCTIONS BLACKBOARD COMPATIBILITY
PDF
The Functional Programming Triad of fold, scan and iterate
PPTX
knn classification
PPTX
operator overloading
PPTX
multiple linear regression
PDF
Stack concepts by Divya
PPTX
Expressions using operator in c
PPTX
Decision making and branching
PDF
Understanding storage class using nm
PPTX
CHAPTER 6
PDF
Recursion concepts by Divya
PDF
DIG1108 Lesson 6
PDF
Functions
Operator overloading
Templates
Introduction to Computer and Programing - Lecture 04
Exp 5-1 d-422
01 list using array
Data Structure Project File
BB - Functions (Operations and Piecewise)
MCM FUNCTIONS BLACKBOARD COMPATIBILITY
The Functional Programming Triad of fold, scan and iterate
knn classification
operator overloading
multiple linear regression
Stack concepts by Divya
Expressions using operator in c
Decision making and branching
Understanding storage class using nm
CHAPTER 6
Recursion concepts by Divya
DIG1108 Lesson 6
Functions
Ad

Similar to Formal methods Project Report for the support of slides uploaded (20)

PPTX
Formal methods
PPT
PDF
AI Lesson 18
PDF
Lesson 18
PDF
Please answer the following questions 1 through 30QUESTION 1The .pdf
PDF
062636636366363773737373733+73737733+7.pdf
PDF
C_Dayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 5.pdf
PPTX
Csci101 lect03 algorithms_i
PDF
Yoyak ScalaDays 2015
DOCX
1 Faculty of Computer Studies Information Technology a.docx
DOCX
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
PPTX
Practice exercises of online Judges related to array
PPT
Data structure lecture 4
DOCX
Cpcs 203 -array-problems
PPTX
Formal Methods lecture 01
PPTX
How Data Flow analysis works in a static code analyzer
PDF
C++ How to Program Early Objects Version 9th Edition Deitel Solutions Manual
PDF
SEC5261_SAT_Week07_Spring22.pdf
PPT
Mba admission in india
DOCX
Please Please Please Read the instructions and do everything li.docx
Formal methods
AI Lesson 18
Lesson 18
Please answer the following questions 1 through 30QUESTION 1The .pdf
062636636366363773737373733+73737733+7.pdf
C_Dayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 5.pdf
Csci101 lect03 algorithms_i
Yoyak ScalaDays 2015
1 Faculty of Computer Studies Information Technology a.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
Practice exercises of online Judges related to array
Data structure lecture 4
Cpcs 203 -array-problems
Formal Methods lecture 01
How Data Flow analysis works in a static code analyzer
C++ How to Program Early Objects Version 9th Edition Deitel Solutions Manual
SEC5261_SAT_Week07_Spring22.pdf
Mba admission in india
Please Please Please Read the instructions and do everything li.docx
Ad

Recently uploaded (20)

PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
MCP Security Tutorial - Beginner to Advanced
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
assetexplorer- product-overview - presentation
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Cost to Outsource Software Development in 2025
PPTX
"Secure File Sharing Solutions on AWS".pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Custom Software Development Services.pptx.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
STL Containers in C++ : Sequence Container : Vector
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PPTX
GSA Content Generator Crack (2025 Latest)
Wondershare Recoverit Full Crack New Version (Latest 2025)
Patient Appointment Booking in Odoo with online payment
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
MCP Security Tutorial - Beginner to Advanced
How to Use SharePoint as an ISO-Compliant Document Management System
assetexplorer- product-overview - presentation
iTop VPN Crack Latest Version Full Key 2025
Cost to Outsource Software Development in 2025
"Secure File Sharing Solutions on AWS".pptx
Why Generative AI is the Future of Content, Code & Creativity?
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Oracle Fusion HCM Cloud Demo for Beginners
Digital Systems & Binary Numbers (comprehensive )
Custom Software Development Services.pptx.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
STL Containers in C++ : Sequence Container : Vector
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Weekly report ppt - harsh dattuprasad patel.pptx
GSA Content Generator Crack (2025 Latest)

Formal methods Project Report for the support of slides uploaded

  • 1. FORMAL METHODS Project Report The purpose of this report is to demonstrate our end semester project for “Formal Methods” that Find the index of the last 0 in an array program. Submitted by : Shoaib Haseeb
  • 2. 6/8/2015 1 FORMAL METHODS Project Report Title: Find the index of the last 0 in an array program Input: An array of integers. Expected Output: Index of the last zero in that array. Pseudo code: Summary: In this project we were asked to find the index of the last zero in array. The challenge which we faced was that we had the restriction of passing only the array as an input. We couldn't pass another variable with that. So for this purpose we made a function named "EXIST_ZERO" in which an array is passed and we have used a built-in function of "EXISTS" in it which is checking the existence of zero in the array.
  • 3. 6/8/2015 2 EXIST_ZERO function: val EXIST_ZERO_DEF= Define ` (EXISTS [] = F) / ( EXISTS (h::t) = if (h=0) then T else EXISTS t)`; Secondly we have made the function "last_zero" which in turn uses the "EXIST_ZERO" function and returns the index of the last zero in the array passed to it. last_zero function: val last_zero = Define `( zero [] = 0 ) / (zero (h::t) = if (EXISTS (h::t)) then 1+ zero t else 0 )`; Some test cases to verify: We verified the test cases using "e(RW_TAC std_ss[last_zero,EXIST_ZERO_DEF]);" after setting goals. Goals/Test Cases: 1: g`zero[]=0`; Expected output: 0 Output: > val it =
  • 4. 6/8/2015 3 Initial goal proved. |- zero [] = 0 : proof Status: Passed 2: g`zero[1;2;0;4]=3`; Expected output: 3 Output: > val it = Initial goal proved. |- zero [1; 2; 0; 4] = 3 : proof Status: Passed 3: g`zero[0;0]=2`; Expected output: 2 Output: > val it = Initial goal proved. |- zero [0; 0] = 2 : proof Status: Passed 4: g`zero[0;0;0;0]=zero[1;2;3;0]`; Expected output: zero [0; 0; 0; 0] = zero [1; 2; 3; 0] Output: > val it = Initial goal proved. |- zero [0; 0; 0; 0] = zero [1; 2; 3; 0] : proof Status: Passed
  • 5. 6/8/2015 4 5: g`zero[1;2;0;4]=2`; Expected output: F Output: > val it = F Status: Passed