Skip to content

Commit 9d1ac81

Browse files
author
Ioana
committed
using replay...
1 parent f27adf6 commit 9d1ac81

File tree

9 files changed

+94
-350
lines changed

9 files changed

+94
-350
lines changed

concret.ml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
let linears s =
22
LinearPoset.linearisations(s)
33

4-
let concretise (s:LinearPoset.t) =
4+
let concretise s sigs =
55
let () = if (!Param.debug_mode) then
66
(Format.printf "concretise linear poset :";
77
List.iter (fun i -> Format.printf "%d " i) s.LinearPoset.seq) in
8-
let (trace,_) =
8+
let init_state = Replay.init_state in
9+
let trace =
910
List.fold_left
10-
(fun (trace,rf) eid ->
11+
(fun trace eid ->
1112
let event = Poset.get_event_by_id eid s.LinearPoset.pos in
1213
let step = Event.get_step event in
13-
let m = Transition.get_rhs (TraceConcret.get_first_transition trace) in
14-
let (trans,new_nodes,new_ports) =
15-
Transition.make m step
16-
trace.TraceConcret.node_names
17-
trace.TraceConcret.port_names in
18-
((TraceConcret.add_transition trace trans new_nodes new_ports),
19-
((eid,trans)::rf)))
20-
(TraceConcret.empty,[]) s.LinearPoset.seq in
21-
trace
14+
let lhs_state =
15+
try Transition.get_rhs_state
16+
(TraceConcret.get_first_transition trace)
17+
with Failure s -> init_state in
18+
let (rhs_state,_) = Replay.do_step sigs lhs_state step in
19+
let trans = Transition.make lhs_state rhs_state in
2220

21+
TraceConcret.add_transition trace trans)
22+
TraceConcret.empty s.LinearPoset.seq in
23+
trace
2324

24-
let concret (s:Poset.t) = concretise (linears s)
25+
let concret s sigs = concretise (linears s) sigs

concret.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
val concret : Poset.t -> TraceConcret.t
2+
val concret : Poset.t -> Signature.s -> TraceConcret.s

formulas.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,13 @@ let obs = function
243243
Domain.Pos p -> p
244244
| _ -> raise (ExceptDefn.Malformed_Args("obs"))
245245

246-
let negative_influence = function
246+
let negative_influence env = function
247247
(Domain.Pos p1, Domain.Pos p2) ->
248-
let t = Concret.concret p1 in
249-
let () = if (!Param.debug_mode) then TraceConcret.print t in
248+
let sigs = Model.signatures env in
249+
let t = Concret.concret p1 sigs in
250+
let pre_env = Pattern.minimal_env sigs contact_map in
251+
let pattern_trace = TraceConcret.pattern_trace contact_map sigs pre_env t in
252+
(* let () = if (!Param.debug_mode) then TraceConcret.print t sigs in*)
250253
true
251254
| _ -> raise(ExceptDefn.Malformed_Args("negative_influence"))
252255

@@ -260,7 +263,7 @@ let check_pred p =
260263
(String.equal is_label "label")
261264
else false
262265

263-
let interpretation t =
266+
let interpretation env t =
264267
let domain = (List.map (fun p -> Domain.Pos(p)) (Domain.get_posets(t)))@
265268
(List.map (fun e -> Domain.Ev(e)) (Domain.get_events(t))) in
266269
let func f args =
@@ -284,6 +287,6 @@ let interpretation t =
284287
| ("equal_events", [e1;e2]) -> equal_events (e1,e2)
285288
| ("sub_posets", [p1;p2]) -> sub_poset (p1,p2)
286289
| ("negative_influence", [p1;p2]) ->
287-
negative_influence (p1,p2)
290+
negative_influence env (p1,p2)
288291
| _ -> raise (ExceptDefn.Uninterpreted_Predicate(p)) in
289292
(func,pred,domain)

formulas.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ val holds : (string -> Domain.domain list -> Domain.domain) *
2121
(Domain.domain list) ->
2222
(string -> Domain.domain) -> Domain.domain fol formula -> bool
2323

24-
val interpretation : Domain.t ->
24+
val interpretation : Model.t -> Domain.t ->
2525
(string -> Domain.domain list -> Domain.domain) *
2626
(string -> Domain.domain list -> bool) *
2727
Domain.domain list

main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ let () =
9191
[Formulas.Var "s1";
9292
Formulas.Var "s2"]))) in
9393

94-
let m = Formulas.interpretation posets in
94+
let m = Formulas.interpretation env posets in
9595
let () = Format.printf "\n evaluate formula\n" in
9696
(evaluate fm_neg m empty_valuation)
9797

traceConcret.ml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11

2-
type t = {
3-
transitions : Transition.t list;
4-
node_names : Maps.node_map;
5-
port_names : Maps.port_map;
6-
}
2+
type s = Transition.s list
73

8-
let empty = {transitions = [];node_names=[];port_names=[]}
4+
type t = Transition.t list
95

10-
let print t = List.iter (fun trans -> Transition.print trans) t.transitions
6+
let empty = []
117

12-
let get_first_transition t =
13-
try
14-
List.hd t.transitions
15-
with Failure s -> Transition.empty
8+
(*
9+
let print t sigs = List.iter (fun trans -> Transition.print trans sigs) t
10+
*)
1611

17-
let get_last_transition t =
18-
List.nth t.transitions ((List.length t.transitions)-1)
12+
let get_first_transition t = List.hd t
13+
let get_last_transition t = List.nth t ((List.length t)-1)
14+
let add_transition trace trans = trans::trace
1915

20-
let add_transition trace trans new_nodes new_ports =
21-
{transitions=trans::trace.transitions;
22-
node_names=new_nodes;
23-
port_names=new_ports;}
16+
let pattern_trace contact_map sigs pre_env trace =
17+
List.map (fun trans ->
18+
Transition.pattern_transition contact_map sigs pre_env trans) trace

traceConcret.mli

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
type s = Transition.s list
2+
type t = Transition.t list
13

2-
type t = {
3-
transitions : Transition.t list;
4-
node_names : Maps.node_map;
5-
port_names : Maps.port_map;
6-
}
74

8-
val empty: t
9-
val print: t -> unit
5+
val empty: s
6+
(*val print: t -> Signature.s -> unit*)
107

11-
val get_last_transition: t -> Transition.t
12-
val get_first_transition: t -> Transition.t
13-
val add_transition: t -> Transition.t -> Maps.node_map ->
14-
Maps.port_map ->t
8+
val get_last_transition: s -> Transition.s
9+
val get_first_transition: s -> Transition.s
10+
val add_transition: s -> Transition.s -> s
11+
val pattern_trace:
12+
(int list * (int * int) list) array array -> Signature.s ->
13+
Pattern.PreEnv.t -> s -> t

0 commit comments

Comments
 (0)