Construction du lambda-terme

This commit is contained in:
Adrien Vannson 2022-05-09 00:15:52 +02:00
parent ec7519ce98
commit 17907e1690
No known key found for this signature in database
GPG Key ID: FE2E66FD978C1A55

33
main.ml
View File

@ -1,6 +1,9 @@
open Structs;; open Structs;;
open Pieuvre;; open Pieuvre;;
let fail () =
failwith "Unknown error";;
(* Parsage des arguments*) (* Parsage des arguments*)
let filename = ref "" in let filename = ref "" in
@ -52,19 +55,30 @@ let ty =
) )
in in
while true do let subgoals: (ty * (var_lambda * ty) list) list ref = ref [(ty, [])] in
(* On donne en paramètre une liste contenant un lambda-terme par trou (ie subgoal),
* et elle renvoie le lambda-terme complet (en remplaçant les trous) *)
let fill_holes = ref (fun holes -> List.hd holes) in
while !subgoals <> [] do
let (ty, hyp) = List.hd !subgoals in
subgoals := List.tl !subgoals;
if is_interactive then ( if is_interactive then (
(* Nettoyage du terminal *) (* Nettoyage du terminal *)
let _ = Sys.command("clear -x") in let _ = Sys.command("clear -x") in
(* Affichage des hypothèses *) (* Affichage des hypothèses *)
Printf.printf "There are %d hypothesis\n" (List.length hyp);
(* Affichage des sous-buts *) (* Affichage des sous-buts *)
Printf.printf "================\n"; Printf.printf "================\n";
Printf.printf "%s\n" (string_of_ty ty); Printf.printf "%s\n" (string_of_ty ty);
(* Lecture d'une tactique *) (* Lecture d'une tactique *)
Printf.printf "What do you want to do?\n"; Printf.printf "What do you want to do?\n"
);
let tactic = let tactic =
let rec read_tactic () = let rec read_tactic () =
@ -81,8 +95,19 @@ while true do
in in
read_tactic () read_tactic ()
in in
()
match tactic with
| Intro var -> (
match ty with
| TImpl (ty1, ty2) -> (
subgoals := (ty2, (var, ty1) :: hyp) :: !subgoals;
let f = !fill_holes in
fill_holes := fun holes -> match holes with
| h :: hs -> f (LFun (var, ty1, h) :: hs)
| _ -> fail ()
)
| _ -> failwith "Can't intro"
) )
done; done;
();; Printf.printf "Final proof :\n%s" (string_of_lam (!fill_holes []));;