Commit 913918a6 authored by Frontull Samuel's avatar Frontull Samuel
Browse files

combine nested lambdas

parent 4c24b678
......@@ -5,7 +5,11 @@ type term = Var of string | Lam of string * term | App of term * term
let rec _term_to_string term =
match term with
| Var v -> v
| Lam (v, t) -> "λ" ^ v ^ "." ^ _term_to_string t
| Lam (v, t) -> (
match t with
| Lam (v2, t2) -> _term_to_string (Lam (v ^ " " ^ v2, t2))
| _ -> "λ" ^ v ^ "." ^ _term_to_string t
)
| App (e1, e2) -> (
match (e1, e2) with
| Var _, Var _ -> _term_to_string e1 ^ " " ^ _term_to_string e2
......@@ -188,7 +192,7 @@ let rec trs_term_to_string term =
match (e1, e2) with
| TDes _, TDes _ ->
"(" ^ trs_term_to_string e1 ^ ") (" ^ trs_term_to_string e2 ^ ")"
| TDes _, _ -> " (" ^ trs_term_to_string e1 ^ ") " ^ trs_term_to_string e2
| TDes _, _ -> "(" ^ trs_term_to_string e1 ^ ") " ^ trs_term_to_string e2
| _, TDes _ -> trs_term_to_string e1 ^ " (" ^ trs_term_to_string e2 ^ ")"
| _, _ -> trs_term_to_string e1 ^ " " ^ trs_term_to_string e2 )
| TCon (l, fvs) ->
......@@ -263,16 +267,9 @@ let rec trs_term_to_string_nopos term =
| TDes (e1, e2) -> (
match (e1, e2) with
| TDes _, TDes _ ->
"("
^ trs_term_to_string_nopos e1
^ ") ("
^ trs_term_to_string_nopos e2
^ ")"
"(" ^ trs_term_to_string_nopos e1 ^ ") (" ^ trs_term_to_string_nopos e2 ^ ")"
| TDes _, _ ->
" ("
^ trs_term_to_string_nopos e1
^ ") "
^ trs_term_to_string_nopos e2
"(" ^ trs_term_to_string_nopos e1 ^ ") " ^ trs_term_to_string_nopos e2
| _, TDes _ ->
trs_term_to_string_nopos e1 ^ " (" ^ trs_term_to_string_nopos e2 ^ ")"
| _, _ -> trs_term_to_string_nopos e1 ^ " " ^ trs_term_to_string_nopos e2
......@@ -488,6 +485,6 @@ let print_simulation lterm =
let sim = simulate_lterm_in_trs lterm in
let sim2 = simulate_trs_in_lterm (l_term_to_trs lterm) in
Printf.printf
"%s\n\n++++++++++++++++\n++++++++++++++++\n++++++++++++++++\n\n%s\n"
"\n%s\n\n++++++++++++++++\n++++++++++++++++\n++++++++++++++++\n\n%s\n"
(String.concat "\n\n========================\n\n" sim)
(String.concat "\n\n========================\n\n" sim2)
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