Ajout du cut, un peu buggé pour l'instant.
This commit is contained in:
parent
ed4471da44
commit
a1276102a7
13
lexer.mll
13
lexer.mll
@ -2,22 +2,21 @@
|
|||||||
open Parser
|
open Parser
|
||||||
}
|
}
|
||||||
|
|
||||||
rule token_ty = parse
|
rule token = parse
|
||||||
| [' ' '\t' '\n'] { token_ty lexbuf }
|
| [' ' '\t' '\n'] { token lexbuf }
|
||||||
| eof { EOF }
|
| eof { EOF }
|
||||||
|
|
||||||
| '(' { LPAREN }
|
| '(' { LPAREN }
|
||||||
| ')' { RPAREN }
|
| ')' { RPAREN }
|
||||||
| "->" { RARROW }
|
| "->" { RARROW }
|
||||||
| '~' { TILDE }
|
| '~' { TILDE }
|
||||||
| "False" { FALSE }
|
|
||||||
| ['A'-'Z']+['0'-'9']* as s { TYPE_NAME s }
|
|
||||||
|
|
||||||
and token_tactic = parse
|
|
||||||
| [' ' '\t' '\n'] { token_tactic lexbuf }
|
|
||||||
| eof { EOF }
|
|
||||||
| "intro" { INTRO }
|
| "intro" { INTRO }
|
||||||
| "assumption" { ASSUMPTION }
|
| "assumption" { ASSUMPTION }
|
||||||
| "apply" { APPLY }
|
| "apply" { APPLY }
|
||||||
|
| "cut" { CUT }
|
||||||
|
| "False" { FALSE }
|
||||||
|
|
||||||
|
| ['A'-'Z']+['0'-'9']* as s { TYPE_NAME s }
|
||||||
| ['a'-'z']+['0'-'9']* as s { VAR_NAME s }
|
| ['a'-'z']+['0'-'9']* as s { VAR_NAME s }
|
||||||
| '.' { DOT }
|
| '.' { DOT }
|
||||||
|
|||||||
10
main.ml
10
main.ml
@ -48,7 +48,7 @@ show "Please type the formula to prove\n";
|
|||||||
let ty =
|
let ty =
|
||||||
try
|
try
|
||||||
let lexbuf = Lexing.from_string (readline ()) in
|
let lexbuf = Lexing.from_string (readline ()) in
|
||||||
Parser.main_type Lexer.token_ty lexbuf
|
Parser.main_type Lexer.token lexbuf
|
||||||
with e -> (
|
with e -> (
|
||||||
Printf.printf "Can't parse type\n";
|
Printf.printf "Can't parse type\n";
|
||||||
raise e
|
raise e
|
||||||
@ -84,7 +84,7 @@ while !subgoals <> [] do
|
|||||||
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 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
|
||||||
@ -132,6 +132,12 @@ while !subgoals <> [] do
|
|||||||
in
|
in
|
||||||
explore hyps;
|
explore hyps;
|
||||||
)
|
)
|
||||||
|
| Cut tint -> (
|
||||||
|
subgoals := (TImpl(tint, ty), hyps)::(tint, hyps)::!subgoals;
|
||||||
|
fill_holes := function
|
||||||
|
| (pf::px::s) -> f ((LApp(pf, px))::s)
|
||||||
|
| _ -> fail ()
|
||||||
|
)
|
||||||
done;
|
done;
|
||||||
|
|
||||||
let finalLam = !fill_holes [] in
|
let finalLam = !fill_holes [] in
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
%token <string> VAR_NAME
|
%token <string> VAR_NAME
|
||||||
%token <string> TYPE_NAME
|
%token <string> TYPE_NAME
|
||||||
|
|
||||||
%token DOT INTRO ASSUMPTION APPLY
|
%token DOT INTRO ASSUMPTION APPLY CUT
|
||||||
|
|
||||||
/* L'ordre de définition définit la priorité */
|
/* L'ordre de définition définit la priorité */
|
||||||
%right RARROW
|
%right RARROW
|
||||||
@ -40,3 +40,4 @@ 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 }
|
| APPLY VAR_NAME DOT { Apply $2 }
|
||||||
|
| CUT ty DOT { Cut $2 }
|
||||||
|
|||||||
@ -16,7 +16,7 @@ let rec string_of_ty (t: ty) : string =
|
|||||||
(* Affiche un λ-terme avec la même syntaxe qu’en entrée *)
|
(* Affiche un λ-terme avec la même syntaxe qu’en entrée *)
|
||||||
let rec string_of_lam (l: lam) : string = match l with
|
let rec string_of_lam (l: lam) : string = match l with
|
||||||
| LFun(v,t,l') -> "λ"^v^":"^(string_of_ty t)^" . "^(string_of_lam l')
|
| LFun(v,t,l') -> "λ"^v^":"^(string_of_ty t)^" . "^(string_of_lam l')
|
||||||
| LApp(l1, l2) -> (string_of_lam l1)^" "^(string_of_lam l2)
|
| LApp(l1, l2) -> "("^(string_of_lam l1)^" "^(string_of_lam l2)^")"
|
||||||
| LVar(v) -> v
|
| LVar(v) -> v
|
||||||
| LExf(l',t) -> "exf("^(string_of_lam l')^" : "^(string_of_ty t)^")"
|
| LExf(l',t) -> "exf("^(string_of_lam l')^" : "^(string_of_ty t)^")"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user