• No results found

A cut c in a graph is subset of vertices. The weight of a cut is defined as the number of edges between c and its complement. A maximum cut is a cut with maximal weight, and, hence, the maximum cut problem is the problem of finding a maximum cut. The size of a maximum cut is at least the size of any other cut. As in the previous problems the maximum cut problem is an NP-hard, i.e., there is no polynomial algorithm for computing an optimal solution. The Figure 4.7 shows an example of a maximum cut.

4.4.1

Relational Approximation of Maximum Cuts

Let us assume an undirected loop-free graph G “ pX, Eq. X is the set of non-empty vertices and E is the set of edges between those vertices. As before the graph is given relation- algebraically by symmetric and irreflexive adjacency relation R : X Ñ X. The conjunction

Figure 4.7: A Maximum cut : The vertices {1,5,3}

of following two formulas is the pre-condition PrepRq of the algorithm. R Ď I R “ R˘

We get two disjoint subsets if we apply cut on graph G. With respect to relation R we get a vector s : X Ñ 1 and its complement. In [1], they provide an approximation algorithm for the maximum cut. The relation R [ pc; ¯c˘ \ ¯c; c˘q restrict the graph to those edges that start in c and end in the complement of c or vice versa. Therefore, its cardinality is the weight of the cut c. The approximation bound of the algorithm is 12. This leads to the following post-condition PostpR, sq where a cut is computed in s:

@c : X Ñ 1, |R [ pc; ¯c˘ \ ¯c; c˘q| ď 2 ¨ |R [ ps; ¯s˘ \ ¯s; s˘q|.

With other words, the post-condition says the weight of the computed cut s is less than or equal to twice the weight of any cut. The following relational program is correct with respect to the pre-condition PrepRq and post-condition PostpR, sq.

v, s, t :“ |ù X1, KK, KK while v ,KK do p:“ pointpvq i f |R; p [ s| ă |R; p [ t| then v, s :“ v [ ¯p, s \ p else v, t :“ v [ ¯p, t \ p

The type of v, s, t and p is X Ñ 1 due to the initialisation of v. The program computes a cut s and its complement with respect to the nodes already visited in t. In each iteration

the number of edges between the current node p and the two set s and t are compared. p is added to the set with fewer edges to p. This approach was mentioned in [12], which is specialization of the approximation algorithm for maximum cut problem published in [14].

The conjunction of following three formulas are considered as loop invariant InvpR, v, s, tq for the program.

p1q s [ t “KK p2q s \ t “ ¯v p3q|R [ ps; s˘\ t; t˘q| ď |R [ ps; t˘\ t; s˘q|.

The first two formulas state that s and t are a partition of v, i.e., t is the complement of s with respect to the nodes already visited. Formula (3) says that the number of edges be- tween the set s and t is greater than the number of edges connecting vertices of the set s or t.

The following lemma, stated in [1], shows the termination of the loop.

Lemma 4.4.1. Given v : X Ñ 1 with v ,KK, then for all p : X Ñ 1 with p Ď v, v [ ¯p@ v. Again, the following lemmas [1] verify that the program is correct with respect to PrepRq and InvpR, v, s, tq.

Lemma 4.4.2. If R : X Ñ X satisfies PrepRq, then InvpR, Lx1, KK, KKq holds.

Lemma 4.4.3. For all points p : X Ñ 1 with p Ď v, the following two properties hold if PrepRq and InvpR, v, s, tq are satisfied:

(1) If |R; p [ s| ă |R; p [ t|, then we have InvpR, v [ ¯p, s [ p, tq. (2) If |R; p [ t| ď |R; p [ s|, then we have InvpR, v [ ¯p, s, t [ pq.

Lemma 4.4.4. If R : X Ñ X and v, s, t : X Ñ 1 such that v “KK and InvpR, v, s, tq are satisfied then PostpR, sq holds.

Finally, we give the recursive version of the algorithm for the maximum cut problem. Sim- ilar to the previous two sections, this algorithm is implemented using two functions. We also prove that our defined algorithm is correct.

maxCut1pR, v, s, tq “

i f v “KK then s

else let p:“ pointpsq in

i f |R; p [ s| ă |R; p [ t| then maxCut1 pv [ ¯pq ps \ pq t

else maxCut1

maxCutpRq “ maxCut1 R

KK KK.

Lemma 4.4.5. For a relation R : X Ñ X InvpR, v, s, tq implies InvpR, v, s1, tq where s1

“ maxCut1 R v s t.

Lemma 4.4.6. For a relation R : X Ñ X we have that PrepRq implies PostpR, sq where s “ maxCut R.

The Coq Proof Assistant

Coq[20] is simultaneously a functional programming language and an interactive proof system. It uses a mathematically high level language called Gallina which is based on the calculus of inductive construction – an expressive formal language. It supports higher- order logic and strongly-typed functional programming. Coq allows to specify theories, their implementation and to prove their correctness. It allows translating certified programs to languages such as Haskel, Objective Caml or Scheme. Coq provides interactive proof methods, decision and semi-decision algorithms and a tactic language as a proof devel- opment system. It also provides high-level notations, implicit contents and various other useful tools for the formalization of mathematics or the development of programs.

In this section, we describe some basic feature of Coq that we use frequently. We also give some examples during the discussion. There are lots of other features which are not used and henceforth we did not discuss those features. Details of Coq are available in [20].

5.1

Set, Prop and Type

There are three kinds of types in Coq, and collectively these types are called sorts. These three kinds are S et, Prop and T ype. Prop is the universe of logical propositions. Every theorem is a logical proposition. S et is the universe of specifications and programs. T ype is the combined type of S et and Prop. T ype contain small sets like Boolean, natural num- bers, product types and function types over small sets.

The Coq command Check is used to obtain the type of a term during an interactive ses- sion. Every term has exactly one type.

Check true. true : bool Check True. True : Prop Check 5. 5 : nat Check mult.

mult : nat Ñ nat Ñ nat

We need use a period at the end of the statement to terminate that statement.

Check forall a b, a * b= b * a.

forall a b : nat, a * b= b * a : Prop

As we mention before, every theorem or property P is of type Prop, i.e., P : Prop. A proof of p of the property P has type P, i.e., p : P. The type of a and b in the example above is determined by the type of functions applied to a and b so that we do not have to provide their type in the quantification. However, it is good practice to specify the type of all variables, i.e. instead of f orall a b we should write f orall pa b : natq.

Related documents