Construction du lambda-terme
This commit is contained in:
parent
ec7519ce98
commit
17907e1690
63
main.ml
63
main.ml
@ -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,37 +55,59 @@ 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 () =
|
||||||
try
|
try
|
||||||
let lexbuf = Lexing.from_string (readline ()) in
|
let lexbuf = Lexing.from_string (readline ()) in
|
||||||
Parser.main_tactic Lexer.token_tactic lexbuf
|
Parser.main_tactic Lexer.token_tactic lexbuf
|
||||||
with e -> (
|
with e -> (
|
||||||
Printf.printf "Can't parse tactic\n";
|
Printf.printf "Can't parse tactic\n";
|
||||||
if is_interactive then
|
if is_interactive then
|
||||||
read_tactic ()
|
read_tactic ()
|
||||||
else
|
else
|
||||||
raise e
|
raise e
|
||||||
)
|
)
|
||||||
in
|
|
||||||
read_tactic ()
|
|
||||||
in
|
in
|
||||||
()
|
read_tactic ()
|
||||||
)
|
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 []));;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user