open Lam open Types open Proof open Hlam (* fonction d'affichage *) let rec string_of_ty = function TVar s -> s | Arr(t1, t2) -> let s1 = string_of_ty t1 in let s2 = string_of_ty t2 in "(" ^ s1 ^ " -> " ^ s2 ^ ")" | Bot -> "False" | And (t1, t2) -> let s1 = string_of_ty t1 in let s2 = string_of_ty t2 in "(" ^ s1 ^ " /\\ " ^ s2 ^ ")" | Or (t1, t2) -> let s1 = string_of_ty t1 in let s2 = string_of_ty t2 in "(" ^ s1 ^ " \\/ " ^ s2 ^ ")" | Unknown -> "Unknown" let rec string_of_expr = function Fun ((s, t), e) -> let s_ty = string_of_ty t in let s_e = string_of_expr e in "fun (" ^ s ^ " : " ^ s_ty ^ ") => (" ^ s_e ^ ")" | App (e1, e2) -> "("^(string_of_expr e1)^" "^(string_of_expr e2)^")" | Var (s) -> s | Exf (e, t) -> let s_e = string_of_expr e in let s_ty = string_of_ty t in "exf (" ^ s_e ^ " : " ^ s_ty ^ ")" | Pair (e1, e2) -> "("^(string_of_expr e1)^", "^(string_of_expr e2)^")" | Left e -> "l("^(string_of_expr e)^")" | Right e -> "r("^(string_of_expr e)^")" let rec string_of_hlam = function HFun ((s, t), e) -> let s_ty = string_of_ty t in let s_e = string_of_hlam e in "fun (" ^ s ^ " : " ^ s_ty ^ ") => (" ^ s_e ^ ")" | HApp (e1, e2) -> "("^(string_of_hlam e1)^" "^(string_of_hlam e2)^")" | HVar (s) -> s | HExf (e, t) -> let s_e = string_of_hlam e in let s_ty = string_of_ty t in "exf (" ^ s_e ^ " : " ^ s_ty ^ ")" | HPair (e1, e2) -> "("^(string_of_hlam e1)^", "^(string_of_hlam e2)^")" | HLeft e -> "l("^(string_of_hlam e)^")" | HRight e -> "r("^(string_of_hlam e)^")" | Ref e -> "{"^(string_of_hlam !e)^"}" | Hole -> "?" let print_ty t = print_string (string_of_ty t) let print_expr e = print_string (string_of_expr e) let print_hlam e = print_string (string_of_hlam e) let print_goal ((_, ty, c) : goal) : unit = let rec print_hyps (c : context) : unit = match c with [] -> () | (hyp_id, _, _, ty)::q -> print_string (hyp_id^" : "^(string_of_ty ty)^"\n"); print_hyps q in print_string "\027[1m"; print_hyps c; print_ty ty; print_string "\n==========\027[0m\n" let affiche_val _ = print_string "TODO" let print_error (error_type : string) (details : string) = output_string stderr ("\027[1;31mError:\027[0m \027[34m"^error_type^"\027[0m "^details^"\n"); flush stderr