19 #ifndef SEC_ATP_IMPL_H 20 #define SEC_ATP_IMPL_H 22 #ifndef SHEAF_DLL_SPEC_H 23 #include "SheafSystem/sheaf_dll_spec.h" 26 #ifndef ASSERT_CONTRACT_H 27 #include "SheafSystem/assert_contract.h" 31 #include "SheafSystem/sec_atp.h" 44 template <
typename V0,
typename V1,
typename VR>
46 hook_functor<V0, V1, VR>::
47 operator()(
const V0& x0,
const V1& x1, VR& xresult)
51 require(precondition_of(
hook(x0, x1, xresult)));
55 hook(x0, x1, xresult);
59 ensure(postcondition_of(
hook(x0, x1, xresult)));
67 template <
typename V0,
typename VR>
69 star_functor<V0, VR>::
70 operator()(
const V0& x0, VR& xresult)
74 require(precondition_of(
star(x0, xresult)));
82 ensure(postcondition_of(
star(x0, xresult)));
90 template <
typename V0,
typename V1,
typename VR>
92 wedge_functor<V0, V1, VR>::
93 operator()(
const V0& x0,
const V1& x1, VR& xresult)
97 require(precondition_of(
wedge(x0, x1, xresult)));
101 wedge(x0, x1, xresult);
105 ensure(postcondition_of(
wedge(x0, x1, xresult)));
115 template <
typename S0,
typename S1,
typename SR>
116 void hook(
const S0& x0,
const S1& x1, SR& xresult,
bool xauto_access)
120 require(x0.state_is_auto_read_accessible(xauto_access));
121 require(x1.state_is_auto_read_accessible(xauto_access));
122 require(xresult.state_is_auto_read_accessible(xauto_access));
123 require(x1.dd(xauto_access) == x0.dd(xauto_access));
124 require(x0.is_p_form(xauto_access) == x1.is_p_form(xauto_access));
125 require(xresult.p(xauto_access) == x0.p(xauto_access) - 1);
131 x0.get_read_access();
132 x1.get_read_access();
133 xresult.get_read_write_access(
true);
136 typedef typename S0::fiber_type::volatile_type V0;
137 typedef typename S1::fiber_type::volatile_type V1;
138 typedef typename SR::fiber_type::volatile_type VR;
139 hook_functor<V0, V1, VR> f;
146 xresult.put_variance(
hook(x0.variance(
false)),
false);
153 xresult.release_access();
159 ensure(xresult.variance(xauto_access) ==
hook(x0.variance(xauto_access)));
168 template <
typename S0,
typename SR>
169 void star(
const S0& x0, SR& xresult,
bool xauto_access)
173 require(x0.state_is_auto_read_accessible(xauto_access));
174 require(xresult.state_is_auto_read_write_accessible(xauto_access));
180 x0.get_read_access();
181 xresult.get_read_write_access(
true);
184 typedef typename S0::fiber_type::volatile_type V0;
185 typedef typename SR::fiber_type::volatile_type VR;
186 star_functor<V0, VR> f;
195 define_old_variable(
bool old_xresult_is_p_form = xresult.is_p_form(
false));
199 xresult.put_variance(
star(x0.variance(
false), x0.dd()),
false );
205 xresult.release_access();
210 ensure((x0.p(xauto_access)>0) \
211 ? (xresult.is_p_form(xauto_access) == x0.is_p_form(xauto_access)) :
true);
212 ensure((x0.p(xauto_access)==0) \
213 ? (xresult.is_p_form(xauto_access) == old_xresult_is_p_form):
true );
221 template <
typename S0,
typename S1,
typename SR>
222 void wedge(
const S0& x0,
const S1& x1, SR& xresult,
bool xauto_access)
226 require(x0.state_is_auto_read_accessible(xauto_access));
227 require(x1.state_is_auto_read_accessible(xauto_access));
228 require(xresult.state_is_auto_read_write_accessible(xauto_access));
229 require(x0.dd(xauto_access) >= xresult.dd(xauto_access));
230 require(x1.dd(xauto_access) >= xresult.dd(xauto_access));
231 require(xresult.p(xauto_access) == x0.p(xauto_access) + x1.p(xauto_access));
232 require(x0.is_p_form(xauto_access) == x1.is_p_form(xauto_access));
238 x0.get_read_access();
239 x1.get_read_access();
240 xresult.get_read_write_access(
true);
243 typedef typename S0::fiber_type::volatile_type V0;
244 typedef typename S1::fiber_type::volatile_type V1;
245 typedef typename SR::fiber_type::volatile_type VR;
246 wedge_functor<V0, V1, VR> f;
251 xresult.put_variance(
wedge(x0.variance(
false), x1.variance(
false)),
false);
257 xresult.release_access();
262 ensure(xresult.variance(xauto_access) == \
263 wedge(x0.variance(xauto_access), x1.variance(xauto_access)));
273 #endif // ifndef SEC_ATP_IMPL_H void unary_op(const S0 &x0, SR &xresult, F xfunctor, bool xauto_access)
Unary operator.
void binary_op(const S0 &x0, const S1 &x1, SR &xresult, F xfunctor, bool xauto_access)
Binary operator.
SHEAF_DLL_SPEC tensor_variance hook(const tensor_variance &x0)
The variance of the hook of a tensor with variance x0.
SHEAF_DLL_SPEC tensor_variance wedge(const tensor_variance &x0, const tensor_variance &x1)
The variance of the wedge of a tensor with variance x0 with a tnesor with variance x1...
SHEAF_DLL_SPEC tensor_variance star(const tensor_variance &x0, int xdd)
The variance of the Hodge star of a tensor with variance x0 over a vector space of dimension xdd...
Namespace for the fiber_bundles component of the sheaf system.