Merge remote-tracking branch 'origin/master'

This commit is contained in:
Mysaa 2022-05-17 11:34:04 +02:00
commit b3d949f764
Signed by: Mysaa
GPG Key ID: 7054D5D6A90F084F
7 changed files with 39 additions and 25 deletions

View File

@ -1,11 +1,18 @@
The Pieuvre Proof Prover The Pieuvre Proof Assistant
= ===========================
# Presentation # Utilisation
# Note d'implementation ## Option `typecheck`
L'option `typecheck` peut être testée avec les fichiers tests dans `tests/typecheck`. Pour cela, utiliser les commandes :
```
./pieuvre -typecheck tests/typecheck/right-type
./pieuvre -typecheck tests/typecheck/wrong-type
```
# Répartition du travail ## Note d'implémentation
## Répartition du travail
### Adrien ### Adrien

View File

@ -27,7 +27,7 @@ rule token = parse
| "fun" { FUN } | "fun" { FUN }
| "=>" { MAPS_TO } | "=>" { MAPS_TO }
| ':' { VDOTS } | ':' { COLON }
| "exf" { EXF } | "exf" { EXF }
| "fst" { FST } | "fst" { FST }
| "snd" { SND } | "snd" { SND }

20
main.ml
View File

@ -83,28 +83,27 @@ if !alpha_option then (
exit 0 exit 0
); );
(*if !typecheck_option then ( if !typecheck_option then (
let lexbuf = Lexing.from_channel (match file with let lexbuf = Lexing.from_channel (match file with
| None -> stdin | None -> stdin
| Some file -> file | Some file -> file
) )
in in
let lambda_term = let lambda_term, ty =
try try
Parser.main_lambda Lexer.token lexbuf Parser.main_typed_lambda Lexer.token lexbuf
with e -> ( with e -> (
Printf.printf "Can't read lambda term\n"; Printf.printf "Can't read typed lambda term\n";
raise e raise e
) )
in in
Printf.printf "The type of %s is " (string_of_lam lambda_term); Printf.printf "The type of %s is " (string_of_lam lambda_term);
if typecheck [] lambda_term then ( if not (typecheck [] lambda_term ty) then (
Printf.printf "correct\n" Printf.printf "not "
) else (
Printf.printf "incorrect\n"
); );
Printf.printf "%s.\n" (string_of_ty ty);
exit 0 exit 0
);*) );
(* Show a message only if the input is read from stdin *) (* Show a message only if the input is read from stdin *)
let show s = match file with let show s = match file with
@ -143,7 +142,6 @@ while !subgoals <> [] do
explore hyps explore hyps
in in
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
@ -286,7 +284,7 @@ done;
let finalLam = !fill_holes [] in let finalLam = !fill_holes [] in
if (typecheck [] finalLam ty) then ( if (typecheck [] finalLam ty) then (
Printf.printf "Final proof :\n"; Printf.printf "Final proof :\n";
reduce finalLam reduce finalLam;
) )
else ( else (
Printf.printf "Invalid proof constructed!\n"; Printf.printf "Invalid proof constructed!\n";

View File

@ -11,7 +11,7 @@
%token <string> TYPE_NAME %token <string> TYPE_NAME
%token DOT INTRO ASSUMPTION APPLY ELIM CUT SPLIT LEFT RIGHT FST SND IG ID CASE %token DOT INTRO ASSUMPTION APPLY ELIM CUT SPLIT LEFT RIGHT FST SND IG ID CASE
%token FUN MAPS_TO VDOTS EXF %token FUN MAPS_TO COLON EXF
%token AMPERSAND %token AMPERSAND
@ -33,6 +33,9 @@
%start main_two_lambda %start main_two_lambda
%type <Structs.lam * Structs.lam> main_two_lambda %type <Structs.lam * Structs.lam> main_two_lambda
%start main_typed_lambda
%type <Structs.lam * Structs.ty> main_typed_lambda
%% %%
main_type: main_type:
| ty EOF { $1 } | ty EOF { $1 }
@ -44,7 +47,10 @@ main_lambda:
| lambda EOF { $1 } | lambda EOF { $1 }
main_two_lambda: main_two_lambda:
| lambda AMPERSAND lambda { $1, $3 } | lambda AMPERSAND lambda EOF { $1, $3 }
main_typed_lambda:
| lambda COLON ty EOF { $1, $3 }
/* Types */ /* Types */
ty: ty:
@ -80,7 +86,7 @@ lambda_app:
lambda: lambda:
| lambda_app { $1 } | lambda_app { $1 }
| FUN VAR_NAME VDOTS ty MAPS_TO lambda { LFun ($2, $4, $6) } | FUN VAR_NAME COLON ty MAPS_TO lambda { LFun ($2, $4, $6) }
| FUN LPAREN VAR_NAME VDOTS ty RPAREN MAPS_TO lambda | FUN LPAREN VAR_NAME COLON ty RPAREN MAPS_TO lambda
{ LFun ($3, $5, $8) } { LFun ($3, $5, $8) }
| EXF LPAREN VAR_NAME VDOTS ty RPAREN { LExf (LVar $3, $5) } | EXF LPAREN VAR_NAME COLON ty RPAREN { LExf (LVar $3, $5) }

View File

@ -234,4 +234,5 @@ let rec computeType (env: gam) (l: lam) : ty option =
;; ;;
(* Vérifie que le λ-terme l sous l'environnement env a bien le type t *) (* Vérifie que le λ-terme l sous l'environnement env a bien le type t *)
let typecheck (env: gam) (l: lam) (t: ty) : bool = (computeType env l = Some t); let typecheck (env: gam) (l: lam) (t: ty) : bool =
computeType env l = Some t;;

View File

@ -0,0 +1 @@
fun x: A => fun f: A -> False => f x : A -> ~~A

View File

@ -0,0 +1 @@
(fun x: A -> A => x x) : A -> A