forked from microsoft/mcBV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitializationRules.fs
71 lines (57 loc) · 1.79 KB
/
InitializationRules.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module InitializationRules
open System.Collections.Generic
open Microsoft.Z3
open GlobalOptions
open Util
open Literal
open BooleanValuation
open Clause
open Trail
open State
open WatchManager
open VariableDB
open ClauseDB
open TheoryDB
open TheoryRelation
open BitVector
open BitVectorValuation
open RLEBVTheory
open BoundsTheory
let watchNewClause (s:State) (i:int) =
let trail = !s.trail
let bval = !s.bVal
let cDB = !s.clauseDB
let w = !s.watchManager
let pCls = (!s.clauseDB).getClauseRef i
assert(getSize(!pCls) > 1)
let (l, r) = findTwoWatches !pCls (s.bVal)
w.watchBool (!pCls).[1] i
w.watchBool (!pCls).[2] i
match r with
| Clause.Unsat -> s.SetConflict (Some pCls)
| Implication -> s.Push (Imp (pCls, (!pCls).[1]))
| _ -> ()
let pushUnit (s:State) (pCls:Ref<Clause>) =
assert(getSize(!pCls) = 1)
match (!s.bVal).getValueB((!pCls).[1]) with
| False -> s.SetConflict (Some pCls)
| Undefined -> s.Push (Imp (pCls, (!pCls).[1])) |> ignore
| True -> () // Already True, and therefore on the trail.
let pushUnits (s:State) =
dbg <| (lazy "Pushing units: ")
for c in (!s.clauseDB).units do
let l = c.[1]
let v = lit2var l
// CMW: We should not need to do anything with model assignments
// or bounds predicates here. This will all be done automatically
// via pushUnit -> ... -> Trail.push
pushUnit s (ref c)
let mutable i = 0
while s.IsSearch && i < (!s.clauseDB).count do
watchNewClause s i
i <- i + 1
let showWatches (s:State) (l:Literal) =
printfn "(%s): " (l.ToString())
let lwl = ((!s.watchManager).getWatchList l)
for w in lwl do
printfn "| %s" (clauseToString ((!s.clauseDB).getClause w))