CMPT 477/777 Formal Verification

CMPT 477/777 Formal Verification

Programming Assignment 3

This assignment is due by 11:59pm PT on Friday Nov 15, 2024. Please submit it to Canvas.

Late policy:

Suppose you can get n (out of 100) points based on your code and report

• If you submit before the deadline, you can get all n points.

• If you submit between 11:59pm PT Nov 15 and 11:59pm PT Nov 16, you get n − 10 points.

• If you submit between 11:59pm PT Nov 16 and 11:59pm PT Nov 17, you get n − 20 points.

• If you submit after 11:59pm PT Nov 17, you get 0 points.

1. (20 points) Verify the program in Algorithm 1. Note that you cannot change the existing implementation.

Algorithm 1 Find an element in the array

method Find(a : array〈int〉, v : int) returns (index : int)

ensures index ≥ 0 → index < a.Length ∧ a[index] = v

ensures index < 0 → ∀k. 0 ≤ k < a.Length → a[k] = v

1: var i : int := 0;

2: while i < a.Length do

3: if a[i] = v then

4: return i;

5: i := i + 1;

6: return −1;

2. (20 points) Verify the program in Algorithm 2. Note that you cannot change the existing implementation.

Algorithm 2 Sum of 10n + 10(n − 1) + . . . + 10

method Sum(n : int) returns (sum : int)

requires n > 0

ensures sum = 5n × (n + 1)

1: sum := 0;

2: var i : int := n;

3: while i > 0 do

4: var k : int := 0;

5: var j : int := i;

6: while j > 0 do

7: k := k + 10;

8: j := j − 1;

9: sum := sum + k;

10: i := i − 1;

1

3. (30 points) Given a non-empty array of integers, write a method called ArrayMin that finds the minimum

value min in the array. Verify the method can ensure

• min is less than or equal to all elements in the array

• min is equal to some element in the array

4. (30 points) Given an array of coins showing either Front or Back side on top, write a program with a

SortCoins method that sorts the coins. Verify it can ensure

• All coins showing the Front side occur before those showing Back

• The sorted array is a permutation of the original array

Deliverable

A zip file called P3 SFUID.zip that contains at least the followings:

• A file called P3 SFUID.dfy that contains Dafny programs for the above four questions.

• A report called P3 SFUID.pdf that explains the design choices, features, issues (if any), and anything

else that you want to explain about your programs.

================ building error ================ .llt/src_llt/sd8062/hidsp0/testcase/CMakeFiles/src_llt-sd8062-hidsp0-testcase.dir/llt_ecs_msa.cpp.obj: In function `GetTempLogFileLen': D:/newcode/src/component/log_cmpt/log_cmpt_adapt.c:195: multiple definition of `GetTempLogFileLen' .sdk/component/log_cmpt/CMakeFiles/component-log_cmpt.dir/log_cmpt_adapt.c.obj:D:/newcode/src/component/log_cmpt/log_cmpt_adapt.c:195: first defined here .llt/src_llt/sd8062/hidsp0/testcase/CMakeFiles/src_llt-sd8062-hidsp0-testcase.dir/llt_ecs_msa.cpp.obj: In function `ClrLogFileInfo': D:/newcode/src/component/log_cmpt/log_cmpt_adapt.c:206: multiple definition of `ClrLogFileInfo' .sdk/component/log_cmpt/CMakeFiles/component-log_cmpt.dir/log_cmpt_adapt.c.obj:D:/newcode/src/component/log_cmpt/log_cmpt_adapt.c:206: first defined here .llt/src_llt/sd8062/hidsp0/testcase/CMakeFiles/src_llt-sd8062-hidsp0-testcase.dir/llt_ecs_msa.cpp.obj:llt_ecs_msa.cpp:(.data+0x0): multiple definition of `g_logTypeMap' .sdk/component/log_cmpt/CMakeFiles/component-log_cmpt.dir/log_cmpt_adapt.c.obj:log_cmpt_adapt.c:(.data+0x0): first defined here .llt/src_llt/sd8062/hidsp0/testcase/CMakeFiles/src_llt-sd8062-hidsp0-testcase.dir/llt_ecs_msa.cpp.obj:llt_ecs_msa.cpp:(.data+0x58): multiple definition of `g_logTypeMapNum' .sdk/component/log_cmpt/CMakeFiles/component-log_cmpt.dir/log_cmpt_adapt.c.obj:log_cmpt_adapt.c:(.data+0x58): first defined here collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. [build] make build end. For more detailed information, please check ./BUILD.LOG. Build Fail! 什么意思
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值