-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstitch.ml
87 lines (76 loc) · 2.82 KB
/
stitch.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
open Function
open Sourcepos
open Name
open Formula
open Location
open Order
open Node
(* This file is part of Arsenic, a proofchecker for New Lace logic.
Copyright (c) 2015 Richard Bornat.
Licensed under the MIT license (sic): see LICENCE.txt or
https://opensource.org/licenses/MIT
*)
type stitch = { stitchpos : sourcepos;
stitchorder : order;
stitchsource : node;
(* stitchlocopt : location option; (* for a reservation-dependent constraint *)
stitchspopt : spost option;
*)
stitchspopt : formula option; (* postcondition of source: optional *)
stitchembroidery : formula
}
(* and spost =
| SpostSimple of formula
| SpostRes of formula
| SpostDouble of formula * formula
let string_of_spost = function
| SpostSimple f -> "{" ^ string_of_formula f ^ "}"
| SpostRes f -> "{ ?" ^ string_of_formula f ^ "}"
| SpostDouble (f1,f2) -> "{" ^ string_of_formula f1 ^ "; ?" ^ string_of_formula f2 ^ "}"
*)
let string_of_stitch { stitchorder = order;
stitchsource = source;
(* stitchlocopt = locopt;
*)
stitchspopt = spopt;
stitchembroidery = assertion
} =
Printf.sprintf "%s %s%s: %s"
(string_of_order order)
(string_of_node source)
(* (match locopt with
| None -> ""
| Some (loc) -> Printf.sprintf "?%s" (string_of_location loc)
)
*)
(match spopt with
| None -> ""
| Some f -> Printf.sprintf " {%s}" (string_of_formula f)
)
(string_of_formula assertion)
let stitchadorn spos order source (* locopt *) spopt assertion =
{ stitchpos = spos;
stitchorder = order;
stitchsource = source;
(* stitchlocopt = locopt;
*)
stitchspopt = spopt;
stitchembroidery = assertion
}
let pos_of_stitch s = s.stitchpos
let order_of_stitch s = s.stitchorder
let source_of_stitch s = s.stitchsource
(* let locopt_of_stitch s = s.stitchlocopt
*)
let spopt_of_stitch s = s.stitchspopt
let assertion_of_stitch s = s.stitchembroidery
let is_go = Order.is_go <.> order_of_stitch
(* let is_reserved_stitch s = match locopt_of_stitch s with Some _ -> true | _ -> false *)
let fostitch frees {stitchspopt = spopt; stitchembroidery = embroidery} =
let spfrees =
match spopt with
| Some f -> Formula.fof frees f
| None -> frees
in
Formula.fof spfrees embroidery
let frees = fostitch NameSet.empty