Commit 54d0c5ab by POTTIER Francois

Parameters: new functions [occurs], [occurs_shallow], [occurs_deep].

parent a7722410
......@@ -60,6 +60,34 @@ let rec fold f init = function
let identifiers m p =
fold (fun accu x -> StringMap.add x.value x.position accu) m p
let rec occurs (x : symbol) (p : parameter) =
match p with
| ParameterVar y ->
x = y.value
| ParameterApp (y, ps) ->
x = y.value || List.exists (occurs x) ps
| ParameterAnonymous _ ->
assert false
let occurs_shallow (x : symbol) (p : parameter) =
match p with
| ParameterVar y ->
x = y.value
| ParameterApp (y, _) ->
assert (x <> y.value);
false
| ParameterAnonymous _ ->
assert false
let occurs_deep (x : symbol) (p : parameter) =
match p with
| ParameterVar _ ->
false
| ParameterApp (_, ps) ->
List.exists (occurs x) ps
| ParameterAnonymous _ ->
assert false
type t = parameter
let rec equal x y =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment