2024-04-16 10:07:09 +02:00
|
|
|
open Lam
|
2024-04-15 12:07:49 +02:00
|
|
|
open Types
|
2024-04-30 11:44:28 +02:00
|
|
|
open Proof
|
2024-05-16 12:38:45 +02:00
|
|
|
open Hlam
|
2024-04-09 11:09:33 +02:00
|
|
|
|
|
|
|
(* fonction d'affichage *)
|
2024-04-15 12:07:49 +02:00
|
|
|
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
|
2024-04-16 10:07:09 +02:00
|
|
|
"(" ^ s1 ^ " -> " ^ s2 ^ ")"
|
|
|
|
| Bot -> "False"
|
2024-05-14 15:23:44 +02:00
|
|
|
| And (t1, t2) ->
|
2024-05-05 20:33:39 +02:00
|
|
|
let s1 = string_of_ty t1 in
|
|
|
|
let s2 = string_of_ty t2 in
|
|
|
|
"(" ^ s1 ^ " /\\ " ^ s2 ^ ")"
|
2024-05-14 15:23:44 +02:00
|
|
|
| Or (t1, t2) ->
|
2024-05-05 20:33:39 +02:00
|
|
|
let s1 = string_of_ty t1 in
|
|
|
|
let s2 = string_of_ty t2 in
|
|
|
|
"(" ^ s1 ^ " \\/ " ^ s2 ^ ")"
|
2024-04-15 12:07:49 +02:00
|
|
|
|
2024-04-09 11:30:52 +02:00
|
|
|
let rec string_of_expr = function
|
2024-04-15 12:07:49 +02:00
|
|
|
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) ->
|
2024-04-16 10:07:09 +02:00
|
|
|
"("^(string_of_expr e1)^" "^(string_of_expr e2)^")"
|
2024-04-09 11:30:52 +02:00
|
|
|
| Var (s) -> s
|
2024-04-16 10:07:09 +02:00
|
|
|
| Exf (e, t) ->
|
|
|
|
let s_e = string_of_expr e in
|
|
|
|
let s_ty = string_of_ty t in
|
|
|
|
"exf (" ^ s_e ^ " : " ^ s_ty ^ ")"
|
2024-05-14 15:23:44 +02:00
|
|
|
| Pair (e1, e2) ->
|
2024-05-16 12:31:06 +02:00
|
|
|
"("^(string_of_expr e1)^", "^(string_of_expr e2)^")"
|
2024-05-17 08:10:26 +02:00
|
|
|
| Left (e, t) ->
|
|
|
|
let s_e = string_of_expr e in
|
|
|
|
let s_ty = string_of_ty t in
|
|
|
|
"l (" ^ s_e ^ " : " ^ s_ty ^ ")"
|
|
|
|
| Right (e, t) ->
|
|
|
|
let s_e = string_of_expr e in
|
|
|
|
let s_ty = string_of_ty t in
|
|
|
|
"r (" ^ s_e ^ " : " ^ s_ty ^ ")"
|
2024-04-09 11:30:52 +02:00
|
|
|
|
2024-05-16 12:31:06 +02:00
|
|
|
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)^")"
|
2024-05-17 08:10:26 +02:00
|
|
|
| HLeft (e, t) ->
|
|
|
|
let s_e = string_of_hlam e in
|
|
|
|
let s_ty = string_of_ty t in
|
|
|
|
"l (" ^ s_e ^ " : " ^ s_ty ^ ")"
|
|
|
|
| HRight (e, t) ->
|
|
|
|
let s_e = string_of_hlam e in
|
|
|
|
let s_ty = string_of_ty t in
|
|
|
|
"r (" ^ s_e ^ " : " ^ s_ty ^ ")"
|
2024-05-16 12:31:06 +02:00
|
|
|
| Ref e ->
|
|
|
|
"{"^(string_of_hlam !e)^"}"
|
|
|
|
| Hole -> "?"
|
2024-04-15 12:07:49 +02:00
|
|
|
|
2024-04-16 10:07:09 +02:00
|
|
|
let print_ty t =
|
|
|
|
print_string (string_of_ty t)
|
|
|
|
|
2024-04-09 11:30:52 +02:00
|
|
|
let print_expr e =
|
|
|
|
print_string (string_of_expr e)
|
2024-04-09 11:09:33 +02:00
|
|
|
|
2024-05-16 12:31:06 +02:00
|
|
|
let print_hlam e =
|
|
|
|
print_string (string_of_hlam e)
|
|
|
|
|
2024-04-30 11:44:28 +02:00
|
|
|
let print_goal ((_, ty, c) : goal) : unit =
|
|
|
|
let rec print_hyps (c : context) : unit = match c with
|
|
|
|
[] -> ()
|
2024-05-06 00:10:23 +02:00
|
|
|
| (hyp_id, _, _, ty)::q ->
|
|
|
|
print_string (hyp_id^" : "^(string_of_ty ty)^"\n");
|
|
|
|
print_hyps q
|
2024-05-01 11:07:40 +02:00
|
|
|
in
|
|
|
|
print_string "\027[1m";
|
|
|
|
print_hyps c;
|
2024-04-30 11:44:28 +02:00
|
|
|
print_ty ty;
|
2024-05-01 11:07:40 +02:00
|
|
|
print_string "\n==========\027[0m\n"
|
2024-04-16 10:07:09 +02:00
|
|
|
|
|
|
|
let affiche_val _ = print_string "TODO"
|
2024-05-01 11:07:40 +02:00
|
|
|
|
|
|
|
let print_error (error_type : string) (details : string) =
|
|
|
|
output_string stderr ("\027[1;31mError:\027[0m \027[34m"^error_type^"\027[0m "^details^"\n");
|
2024-05-06 00:10:23 +02:00
|
|
|
flush stderr
|