library colibrilib.dom_ring — module RunThe rules of the ground terms, mutually recursive. run_subs has a precondition: only activate_all calls it, and Export exposes term.
module Run448use int.Int449use real.RealInfix450use list.List451use option.Option452use colibrilib.ring.Atom453use colibrilib.ring.Export as R454use colibrilib.env.Env455use colibrilib.env.Interval456use Env457use Ring458
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)let rec term (d:env) (g:ground) : unit462diverges463= if use_ring d then begin464let r = node g in465match view g with466| Some (Add, Cons a (Cons b Nil)) ->467if active d then set d r (R.add (atom d a) (atom d b)) else push_waiting d g468| Some (Sub, Cons a (Cons b Nil)) ->469if active d then set d r (R.sub (atom d a) (atom d b)) else push_waiting d g470| Some (Neg, Cons a Nil) ->471if active d then set d r (R.neg (atom d a)) else push_waiting d g472| Some (Mul, Cons a (Cons b Nil)) ->473activate_all d;474set d r (R.mul (atom d a) (atom d b))475| Some (Div, Cons num (Cons den Nil)) ->476if is_not_zero d den then begin477activate_all d;478(* [num = r * den] *)479set d num (R.mul (atom d r) (atom d den))480end481| _ -> ()482end483end484
The first product: the waiting definitions are given to the ring
Valid (35ms) (colibri2)with activate_all (d:env) : unit487diverges488= if not (active d) then begin489activate d;490let subs = waiting_subs d in491run_terms d (waiting d);492run_subs d subs493end494495with run_terms (d:env) (l:list ground) : unit496diverges497= match l with498| Nil -> ()499| Cons g r -> term d g; run_terms d r500end501Valid (121ms) (cvc4)502with run_subs (d:env) (l:list (Atom.t, Atom.t, Atom.t)) : unit503requires { live d -> forall r a b. Mem.mem (r, a, b) l -> d.m r = d.m a -. d.m b }504diverges505= match l with506| Nil -> ()507| Cons (r, a, b) l' -> set d r (R.sub (atom d a) (atom d b)); run_subs d l'508end509end510