This commit is contained in:
Adrien Vannson 2022-05-10 11:11:03 +02:00
parent b9d507b650
commit 5af07fff8d
No known key found for this signature in database
GPG Key ID: FE2E66FD978C1A55
4 changed files with 18 additions and 2 deletions

View File

@ -18,5 +18,6 @@ and token_tactic = parse
| eof { EOF } | eof { EOF }
| "intro" { INTRO } | "intro" { INTRO }
| "assumption" { ASSUMPTION } | "assumption" { ASSUMPTION }
| "apply" { APPLY }
| ['a'-'z']+['0'-'9']* as s { VAR_NAME s } | ['a'-'z']+['0'-'9']* as s { VAR_NAME s }
| '.' { DOT } | '.' { DOT }

13
main.ml
View File

@ -119,6 +119,19 @@ while !subgoals <> [] do
in in
explore hyps explore hyps
) )
| Apply var -> (
let rec explore = function
| (var_hyp, TImpl (t1, t2)) :: _ when var_hyp = var && t2 = ty -> (
subgoals := (t1, hyps) :: !subgoals;
fill_holes := function
| hole :: holes -> f ((LApp (LVar var_hyp, hole)) :: holes)
| [] -> fail ()
)
| [] -> failwith ("Hypothesis " ^ var ^ " not found or unusable")
| _ :: hyps -> explore hyps
in
explore hyps;
)
done; done;
Printf.printf "Final proof :\n%s\n" (string_of_lam (!fill_holes []));; Printf.printf "Final proof :\n%s\n" (string_of_lam (!fill_holes []));;

View File

@ -10,7 +10,7 @@
%token <string> VAR_NAME %token <string> VAR_NAME
%token <string> TYPE_NAME %token <string> TYPE_NAME
%token DOT INTRO ASSUMPTION %token DOT INTRO ASSUMPTION APPLY
/* L'ordre de définition définit la priorité */ /* L'ordre de définition définit la priorité */
%right RARROW %right RARROW
@ -39,3 +39,4 @@ main_tactic:
tactic: tactic:
| INTRO VAR_NAME DOT { Intro $2 } | INTRO VAR_NAME DOT { Intro $2 }
| ASSUMPTION DOT { Assumption } | ASSUMPTION DOT { Assumption }
| APPLY VAR_NAME DOT { Apply $2 }

View File

@ -2,4 +2,5 @@ open Structs;;
type tactic = type tactic =
| Intro of var_lambda | Intro of var_lambda
| Assumption;; | Assumption
| Apply of var_lambda;;