package lutin

  1. Overview
  2. Docs
Lutin: modeling stochastic reactive systems

Install

Dune Dependency

Authors

Maintainers

Sources

lutin.2.71.10.tgz
md5=4d07d1263dbc90ab18cbaec55a57dcfe
sha512=2e899aee5e44826827b3626771f7ce01241b1745d48f30b60404cc5cbaa44ac608920e9af3bf171275c429a8b823b3cee7542199b7c4c32919b6bb37e33bf8de

doc/src/lutin/constraint.ml.html

Source file constraint.ml

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
(*-----------------------------------------------------------------------
** Copyright (C) - Verimag.
** This file may only be copied under the terms of the CeCill
** Public License
**-----------------------------------------------------------------------
**
** File: constraint.ml
** Main author: erwan.jahier@univ-grenoble-alpes.fr
*)


(* exported *)
type ineq =
  | GZ      of Ne.t (** expr >  0 *)
  | GeqZ    of Ne.t (** expr >= 0 *)

(* exported *)
type t =
  | Bv      of Exp.var (** Booleans  *)
  | EqZ     of Ne.t   (** expr  = 0 *)
  | Ineq    of ineq   (** > or >= *)

(* exported *)
let (ineq_to_string : ineq -> string) =
  fun f ->
    match f with
      | GZ(ne)   -> ((Ne.to_string ne)  ^ " >  0 ")
      | GeqZ(ne) -> ((Ne.to_string ne)  ^ " >= 0 ")

(* exported *)
let (to_string : t -> string) =
  fun f ->
    match f with
      | Bv(var)  -> (Var.name var)
      | Ineq(ineq) -> ineq_to_string ineq
      | EqZ(ne)  -> ((Ne.to_string ne) ^  " = 0 ")

let (to_string_verbose : t -> string) =
  fun f ->
    match f with
      | Bv(var)  -> (Var.to_string var)
      | Ineq(ineq) -> ineq_to_string ineq
      | EqZ(ne)  -> ((Ne.to_string ne) ^  " = 0 ")

let (print : t -> unit) =
  fun cstr ->
    Format.print_string (to_string cstr)

let (print_ineq : ineq -> unit) =
  fun ineq ->
    Format.print_string (ineq_to_string ineq)


(* exported *)
let (dimension_ineq : ineq -> int) =
  fun cstr ->
    match cstr with
	GZ(ne) -> Ne.dimension ne
      | GeqZ(ne) -> Ne.dimension ne

(* exported *)
let (dimension : t -> int) =
  fun cstr ->
    match cstr with
	Bv(_) -> 1
      | Ineq(ineq) -> dimension_ineq ineq
      | EqZ(ne) -> Ne.dimension ne


(* exported *)
let (neg_ineq : ineq -> ineq) =
  fun cstr ->
    match cstr with
	GZ(ne) -> GeqZ(Ne.neg_nexpr ne)
      | GeqZ(ne) -> GZ(Ne.neg_nexpr ne)

(* exported *)
let (opp_ineq : ineq -> ineq) =
  fun cstr ->
    match cstr with
	GZ(ne) -> GZ(Ne.neg_nexpr ne)
      | GeqZ(ne) -> GeqZ(Ne.neg_nexpr ne)


(* exported *)
let (apply_subst_ineq : Ne.subst -> ineq -> ineq) =
  fun s cstr ->
    match cstr with
	GZ(ne)   -> GZ(Ne.apply_subst ne s)
      | GeqZ(ne) -> GeqZ(Ne.apply_subst ne s)

(* exported *)
let (apply_subst : Ne.subst -> t -> t) =
  fun s cstr ->
    match cstr with
	Bv(_)    -> cstr
      | Ineq(ineq)   -> Ineq(apply_subst_ineq s ineq)
      | EqZ(ne)  -> EqZ(Ne.apply_subst ne s)

(* exported *)
let (apply_substl_ineq : Ne.subst list -> ineq -> ineq) =
  fun s cstr ->
      match cstr with
	  GZ(ne)   -> GZ(Ne.apply_substl s ne)
	| GeqZ(ne) -> GeqZ(Ne.apply_substl s ne)

(* exported *)
let (apply_substl : Ne.subst list -> t -> t) =
  fun s cstr ->
    match cstr with
	Bv(_)    -> cstr
      | Ineq(ineq)   -> Ineq(apply_substl_ineq s ineq)
      | EqZ(ne)  -> EqZ(Ne.apply_substl s ne)


(* exported *)
let (eval_ineq : Var.num_subst list -> ineq ->  bool) =
  fun s ineq ->
    match ineq with
	GZ(ne)   -> Value.num_sup_zero(Ne.eval ne s)
      | GeqZ(ne) -> Value.num_supeq_zero(Ne.eval ne s)



(* exported *)
let (get_vars_ineq : ineq -> string list) =
  fun ineq ->
    match ineq with
	GZ(ne)   -> Ne.get_vars ne
      | GeqZ(ne) -> Ne.get_vars ne

(* exported *)
let (get_vars : t -> string list) =
  fun cstr ->
    match cstr with
	Bv var -> [(Var.name var)]
      | EqZ ne -> Ne.get_vars ne
      | Ineq ineq   -> get_vars_ineq ineq

OCaml

Innovation. Community. Security.