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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
use trilean::SKleene;
use kernel::*;
use model::*;
use logic::{Boolean, NotFormula};
use propagation::*;
use propagation::events::*;
use term::ops::*;
use gcollections::kind::*;
use gcollections::ops::*;
use num::traits::Num;
use std::fmt::{Debug, Formatter, Result};
use concept::*;
pub struct BooleanNeg<VStore> {
b: Boolean<VStore>
}
impl<VStore> BooleanNeg<VStore>
{
pub fn new(b: Boolean<VStore>) -> Self {
BooleanNeg {
b: b
}
}
}
impl<VStore> Debug for BooleanNeg<VStore>
{
fn fmt(&self, fmt: &mut Formatter) -> Result {
fmt.debug_struct("BooleanNeg")
.field("b", &self.b)
.finish()
}
}
impl<VStore> Clone for BooleanNeg<VStore> where
VStore: Collection
{
fn clone(&self) -> Self {
BooleanNeg {
b: self.b.clone()
}
}
}
impl<VStore> DisplayStateful<Model> for BooleanNeg<VStore>
{
fn display(&self, model: &Model) {
print!("not ");
self.b.display(model);
}
}
impl<VStore, Domain, Bound> NotFormula<VStore> for BooleanNeg<VStore> where
VStore: VStoreConcept<Item=Domain> + 'static,
Domain: IntDomain<Item=Bound> + 'static,
Bound: IntBound + 'static,
{
fn not(&self) -> Formula<VStore> {
Box::new(self.b.clone())
}
}
impl<VStore, Dom, Bound> Subsumption<VStore> for BooleanNeg<VStore> where
VStore: Collection<Item=Dom>,
Dom: Bounded<Item=Bound> + IsSingleton,
Bound: Num
{
fn is_subsumed(&self, vstore: &VStore) -> SKleene {
!self.b.is_subsumed(vstore)
}
}
impl<VStore, Dom, Bound> Propagator<VStore> for BooleanNeg<VStore> where
VStore: VStoreConcept<Item=Dom>,
Dom: Collection<Item=Bound> + Singleton,
Bound: Num
{
fn propagate(&mut self, vstore: &mut VStore) -> bool {
self.b.update(vstore, Dom::singleton(Bound::zero()))
}
}
impl<VStore> PropagatorDependencies<FDEvent> for BooleanNeg<VStore>
{
fn dependencies(&self) -> Vec<(usize, FDEvent)> {
PropagatorDependencies::dependencies(&self.b)
}
}