首页 > 其他分享 >CMPT 477 / 777 Formal Verification Programming

CMPT 477 / 777 Formal Verification Programming

时间:2024-10-01 19:27:26浏览次数:10  
标签:777 CMPT color Programming vertices colors file following sat

CMPT 477 / 777 Formal Verification Programming Assignment 1

This assignment is due by 11:59pm PT on Wednesday Oct 2, 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 Oct 2 and 11:59pm PT Oct 3, you get n 10 points.
  • If you submit between 11:59pm PT Oct 3 and 11:59pm PT Oct 4, you get n 20 points.
  • If you submit after 11:59pm PT Oct 4, you get 0 points.

1 Problem Description

(100 points) A solution to a graph coloring problem is an assignment of colors to vertices such that notwo adjacent vertices have the same color. Formally, a finite graph G = (V, E) consists of vertices V ={v1, . . . , vn} and edges E = {(vi1 , wi1 ), . . . ,(vik , wik )}. The finite set of colors is given by C = {c1, . . . , cm}.

A problem instance is given by a graph and a set of colors: the problem is to assign each vertex v V a color(v) C such that for every edge (v, w) E, color(v) = color(w). Clearly, not all instances havesolutions.Please write a Java program with Z3 APIs to solve the graph coloring problem. The input is a file inthe following format

where the first line contains two positive integers: N is the number of vertices, and M is the number of colors(separated by a space). Without loss of generality, we can assume V = {1, . . . , N} and C = {1, . . . , M}.Each of the rest line contains two positive integers vij and wij that are no more than N, which correspondsto an edge (vij , wij ).The output is also a file. If an instance does not have 代 写CMPT 477 / 777 Formal Verification Programming  a solution, write “No Solution” in the output file.Otherwise, write an assignment of colors to vertices in the following format.where vi denotes the vertex and ci denotes its color, i.e., color(vi) = ci , separated by a space.You might want to use the following hints for encoding:

  • Introduce a boolean variable pv,c for color(v) = c.
  • Describe the formula asserting every vertex is colored.1• Describe the formula asserting every vertex has at most one color.
  • Describe the formula asserting that no two connected vertices have the same color.

2 Sample Input and Output

Suppose we have an input file input.txt that contains the following six lineswhich represents the following graph

After running the program, we can get a file with the following lines (not unique)1 1It means the colors of vertices v1, v2, v3, v4 are c1, c2, c2, c3, respectively.

3 Compilation and Execution

Compilation. The provided codebase uses the Maven build system. After you enter the verif-sat directory, the project can be easily compiled with one command

$ mvn packageThen you should be able to see the message “BUILD SUCCESS”. A directory called target will be createdand a jar file called verif-sat-1.0.jar will be generated inside the target.

Execution. In the verif-sat directory, you can execute the program using the following command (use ;instead of : on Windows)

$ java -cp lib/com.microsoft.z3.jar:target/verif-sat-1.0.jar sat.GraphColoring <in-path> <out-path>

where <in-path> is the path to the input file and <out-path> is the path to the output file.

For example, you can run

$ java -cp lib/com.microsoft.z3.jar:target/verif-sat-1.0.jar sat.GraphColoring input.txt output.txtYou will see a runtime exception with message “To be implemented”, because the program is not implemented yet. After you finish the implementation, you should see a file named output.txt with the contentas shown in Section 2.

24 Deliverable A zip file called P1 SFUID.zip (SFUID is replaced with your 9-digit student ID number) that contains the

followings:

  • The verif-sat directory that contains your Java program. You can have multiple source files if youwant, but you need to make sure the project can be built and executed in the way described in Section 3.
  • A short report called P1 SFUID.pdf that describes your encoding and explains the design choices,features, issues (if any), and anything else that you want to explain about your program.

标签:777,CMPT,color,Programming,vertices,colors,file,following,sat
From: https://www.cnblogs.com/comp9021/p/18443027

相关文章

  • The 13th Shandong ICPC Provincial Collegiate Programming Contest
    目录写在前面I签到A签到D二分答案,贪心G排序,贪心L构造,思维B模拟,拓扑排序E数学,结论,模拟M计算几何,单调性J二进制,连通性问题,并查集K贪心orDP,结论,构造F线段树优化DP写在最后写在前面补题地址:https://codeforces.com/gym/104417。以下按个人向难度排序。妈的调休太顶......
  • COMP 218 Fundamentals of Object-Oriented Programming
    ©Maynotbecopiedorduplicatedwithoutthepermissionoftheowner.COMP218FundamentalsofObject-OrientedProgrammingAssignment1Pleasenote:youareNOTallowedtoposttheassignment/solutionanywhereontheInternet.IntellectualPropertyrightsa......
  • COMP3331 9331 HTTP & Socket Programming
    COMP33319331ComputerNetworksandApplicationsLabExercise2:HTTP&SocketProgrammingSpecificationMakeSubmissionCheckSubmissionCollectSubmissionObjectives:GaininsightsintotheoperationofHTTP.Getfamiliarwithbasicsocketprogra......
  • CS1112 Specific programming constructs
    CS1112Fall2024Project2dueWednesday9/25at11pmObjectivesCompletingthisprojectwillsolidifyyourunderstandingoffor-loops,while-loops,andnestedloops.Thecomputationalthemeofthisprojectissimulation,withproblem1usingrandomnessa......
  • UNIQUE VISION Programming Contest 2024 Autumn (AtCoder Beginner Contest 372)
    总结(我的塘人局):单调栈是忘得差不多了 A-delete.题意:输出删除所有'.'的字符串思路:遍历输出不是'.'复杂度:O(n) Code:#include<bits/stdc++.h>usingnamespacestd;usingLL=longlong;usingi64=int64_t;voidsolve(){strings;cin......
  • CSSE2002 Programming in the Large
    Programming in the Large (CSSE2002)Assignment 2 — Semester 2, 2024Overview This assignment provides experience working with an existing software project. You are provided with a small extension to the Farming game application......
  • COSC2391 Further Programming
    COSC2391 FurtherProgramming/COSC1295AdvancedProgrammingAssignment2- Semester 2 20241.IntroductionThisassignmentisdesignedto:•   Evaluateyourabilitytodevelop GUI applications usingJavaFX.•   Evaluateyourskillsin stori......
  • CMPINF 0401 Intermediate Programming
    CMPINF0401IntermediateProgrammingAssignment1Topics:Reviewofexpressions,conditions,loopsandI/OOnline:Wednesday,September4,2024Due:Allsource(.java)filesandacompletedAssignmentInformationSheetzippedintoasinglefileandsubmit......
  • The 17th Heilongjiang Provincial Collegiate Programming Contest A(思维 + 二分)
    题意有\(n\)本类型\(A\)的书题解点击查看代码#include<bits/stdc++.h>usingi64=longlong;voidsolve(){ inta,b,n,m,h; std::cin>>a>>b>>n>>m>>h; i64cnt=i64(n/b)*(h-a); if(cnt>=m-1)......
  • The 2020 ICPC Asia Shenyang Regional Programming Contest
    D-JourneytoUn'Goro记\(p_i\)表示前缀\(i\)中\(\mathrmr\)的个数。则题目要求的是\(p_r-p_{l-1}\)为奇数最多有多少对。显然应该越平均越好。\(p_i\)总共有\(n+1\)个,则奇偶数的数量均不超过\(m=\left\lceil\frac{n+1}{2}\right\rceil\),答案就是\((n+1-m)\time......