Common — library colibrilib.dom_ring — module Run

The rules of the ground terms, mutually recursive. run_subs has a precondition: only activate_all calls it, and Export exposes term.

448
module Run
449
use int.Int
450
use real.RealInfix
451
use list.List
452
use option.Option
453
use colibrilib.ring.Atom
454
use colibrilib.ring.Export as R
455
use colibrilib.env.Env
456
use colibrilib.env.Interval
457
use Env
458
use Ring

The normal form of the node of a ground term (+, -, *, and the numerator of a division by a node that is not zero)

  Valid (375ms) (colibri2 5) (split_vc) (depth 1)
462
let rec
term
(d:env) (g:ground) : unit
463
diverges
464
= if use_ring d then begin
465
let r = node g in
466
match view g with
467
| Some (Add, Cons a (Cons b Nil)) ->
468
if active d then set d r (R.add (atom d a) (atom d b)) else push_waiting d g
469
| Some (Sub, Cons a (Cons b Nil)) ->
470
if active d then set d r (R.sub (atom d a) (atom d b)) else push_waiting d g
471
| Some (Neg, Cons a Nil) ->
472
if active d then set d r (R.neg (atom d a)) else push_waiting d g
473
| Some (Mul, Cons a (Cons b Nil)) ->
474
activate_all d;
475
set d r (R.mul (atom d a) (atom d b))
476
| Some (Div, Cons num (Cons den Nil)) ->
477
if is_not_zero d den then begin
478
activate_all d;
479
(* [num = r * den] *)
480
set d num (R.mul (atom d r) (atom d den))
481
end
482
| _ -> ()
483
end
484
end

The first product: the waiting definitions are given to the ring

  Valid (35ms) (colibri2)
487
with
activate_all
(d:env) : unit
488
diverges
489
= if not (active d) then begin
490
activate d;
491
let subs = waiting_subs d in
492
run_terms d (waiting d);
493
run_subs d subs
494
end
495
496
with
run_terms
(d:env) (l:list ground) : unit
497
diverges
498
= match l with
499
| Nil -> ()
500
| Cons g r -> term d g; run_terms d r
501
end
502
Valid (121ms) (cvc4)
503
with
run_subs
(d:env) (l:list (Atom.t, Atom.t, Atom.t)) : unit
504
requires { live d -> forall r a b. Mem.mem (r, a, b) l -> d.m r = d.m a -. d.m b }
505
diverges
506
= match l with
507
| Nil -> ()
508
| Cons (r, a, b) l' -> set d r (R.sub (atom d a) (atom d b)); run_subs d l'
509
end
510
end