library colibrilib.dom_ring — module EnvThe environment of the ring, trusted: the tables of colibri2 (backtrackable, see colibrilib/env.mlw), the product nodes, and the other domains.
module Env17use int.Int18use real.RealInfix19use list.List20use list.Mem21use option.Option22use colibrilib.ring.Atom23use colibrilib.ring.Mono24use colibrilib.stda.StdA as A25use colibrilib.ring.Export as R26use colibrilib.polynome.Lin as L27use colibrilib.env.Env28use colibrilib.spec.Opt29
p is a normal form of the node n in the model of d
predicate is_nf (d:env) (n:Atom.t) (p:R.t) = live d -> d.m n = R.eval d.m p32
The option --lra-no-ring is not given
val use_ring (d:env) : bool35
The option --lra-ring-max-terms
val max_terms (d:env) : int38
Monomial.node: the product node of the monomial m (a node that is not registered, never in the input: its value is the product)
val product_node (m:mono) : Atom.t42ensures { forall d: env. live d -> d.m result = evalm d.m m }43
The node n has the value of the monomial m in every model
predicate is_monomial (n:Atom.t) (m:mono) =46forall d: env. live d -> d.m n = evalm d.m m47
Monomial.monomial: the monomial of a product node
val monomial (n:Atom.t) : option mono50ensures { when_some (is_monomial n) result }51
The normal forms: find_nf d n is the normal form of n
val find_nf (d:env) (n:Atom.t) : option R.t54ensures { when_some (is_nf d n) result }5556val set_nf (d:env) (n:Atom.t) (p:R.t) : unit57writes { d.state }58requires { is_nf d n p }5960val remove_nf (d:env) (n:Atom.t) : unit61writes { d.state }62
The equality of two normal forms (only to avoid useless work)
val same (p q:R.t) : bool65
n uses x in its normal form; the first time, the changes of the linear form of x call Export.changed d x
val add_used (d:env) (x n:Atom.t) : unit69writes { d.state }70
The nodes that use x
val used (d:env) (x:Atom.t) : list Atom.t73
The changes of the linear form of the product node call Export.solve_product d pm
val watch_product (d:env) (pm:Atom.t) : unit77writes { d.state }78
Dom_polynome.assume_equality
val assume_linear (d:env) (n:Atom.t) (l:L.t) : unit81writes { d.state }82requires { live d -> d.m n = L.eval d.m l }83
l is the linear form x itself (only to avoid useless work)
val is_self (l:L.t) (x:Atom.t) : bool86
The ring is used only after the first product: before, the definitions wait
val active (d:env) : bool90val activate (d:env) : unit91writes { d.state }92
The operations of the ring
type op = Add | Sub | Neg | Mul | Div95
The interpretation of the operations (a division by zero is not interpreted)
predicate meaning (m:Atom.t -> real) (o:op) (r:Atom.t) (l:list Atom.t) =99match o, l with100| Add, Cons a (Cons b Nil) -> m r = m a +. m b101| Sub, Cons a (Cons b Nil) -> m r = m a -. m b102| Neg, Cons a Nil -> m r = -. m a103| Mul, Cons a (Cons b Nil) -> m r = m a *. m b104| Div, Cons num (Cons den Nil) -> m den <> 0.0 -> m r *. m den = m num105| _ -> true106end107
A ground term (Ground.t) and its node
type ground110function gnode (g:ground) : Atom.t111112val node (g:ground) : Atom.t113ensures { result = gnode g }114
g has the meaning of the operation and arguments v in every model
predicate interprets (g:ground) (v:(op, list Atom.t)) =117let o, l = v in forall d: env. live d -> meaning d.m o (gnode g) l118
The operation and the arguments of a ground term: a ground term has the value of its interpretation in every model
val view (g:ground) : option (op, list Atom.t)122ensures { when_some (interprets g) result }123
The terms waiting for the activation
val push_waiting (d:env) (g:ground) : unit126writes { d.state }127val waiting (d:env) : list ground128
The differences r = a - b waiting for the activation
val push_sub (d:env) (r a b:Atom.t) : unit131writes { d.state }132requires { live d -> d.m r = d.m a -. d.m b }133val waiting_subs (d:env) : list (Atom.t, Atom.t, Atom.t)134ensures { live d -> forall r a b. mem (r, a, b) result -> d.m r = d.m a -. d.m b }135
n = k * g * q, with g a product of atoms and q the normal form of a node m (up to a constant), is given to Dom_product.
The normal forms already seen
val table_mem (d:env) (p:R.t) : bool143val table_add (d:env) (p:R.t) (n:Atom.t) : unit144writes { d.state }145
v = (n, c): n = c * q in the model of d, with c not zero
predicate is_monic (d:env) (q:R.t) (v:(Atom.t, A.t)) =148let n, c = v in149A.real c <> 0.0 /\ (live d -> d.m n = A.real c *. R.eval d.m q)150
The monic forms: n = c * q
val find_monic (d:env) (q:R.t) : option (Atom.t, A.t)153ensures { when_some (is_monic d q) result }154155val set_monic (d:env) (q:R.t) (n:Atom.t) (c:A.t) : unit156writes { d.state }157requires { A.real c <> 0.0 }158requires { live d -> d.m n = A.real c *. R.eval d.m q }159
The factorizations waiting for a node of normal form q: n = k * g * q
predicate pending_ok (m:Atom.t -> real) (q:R.t) (l:list (Atom.t, A.t, mono)) =163forall n k g. mem (n, k, g) l -> m n = A.real k *. evalm m g *. R.eval m q164165val find_pending (d:env) (q:R.t) : list (Atom.t, A.t, mono)166ensures { live d -> pending_ok d.m q result }167168val set_pending (d:env) (q:R.t) (l:list (Atom.t, A.t, mono)) : unit169writes { d.state }170requires { live d -> pending_ok d.m q l }171172val remove_pending (d:env) (q:R.t) : unit173writes { d.state }174
n = k * g, given to Dom_product (sign and absolute value)
val product (d:env) (n:Atom.t) (k:A.t) (g:mono) : unit177writes { d.state }178requires { live d -> d.m n = A.real k *. evalm d.m g }179end180