Skip to content

Commit 3a5c31e

Browse files
authored
Merge pull request #531 from MetaCoq/primitive-int-float
Primitive integers and floats
2 parents 9831832 + aa097dd commit 3a5c31e

File tree

95 files changed

+1358
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1358
-240
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,5 @@ erasure/src/pCUICErrors.ml
416416
erasure/src/pCUICErrors.mli
417417
erasure/src/pCUICTypeChecker.ml
418418
erasure/src/pCUICTypeChecker.mli
419+
erasure/src/pCUICPrimitive.ml
420+
erasure/src/pCUICPrimitive.mli

checker/theories/Checker.v

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ Inductive type_error :=
447447
| IllFormedFix (m : mfixpoint term) (i : nat)
448448
| UnsatisfiedConstraints (c : ConstraintSet.t)
449449
| UnsatisfiableConstraints (c : ConstraintSet.t)
450-
| NotEnoughFuel (n : nat).
450+
| NotEnoughFuel (n : nat)
451+
| NotSupported (s : string).
451452

452453
Definition string_of_type_error (e : type_error) : string :=
453454
match e with
@@ -468,6 +469,7 @@ Definition string_of_type_error (e : type_error) : string :=
468469
| UnsatisfiedConstraints c => "Unsatisfied constraints"
469470
| UnsatisfiableConstraints c => "Unsatisfiable constraints"
470471
| NotEnoughFuel n => "Not enough fuel"
472+
| NotSupported s => s ^ " are not supported"
471473
end.
472474

473475
Inductive typing_result (A : Type) :=
@@ -769,6 +771,8 @@ Section Typecheck2.
769771
| Some f => ret f.(dtype)
770772
| None => raise (IllFormedFix mfix n)
771773
end
774+
775+
| tInt _ | tFloat _ => raise (NotSupported "primitive types")
772776
end.
773777

774778
Definition check (Γ : context) (t : term) (ty : term) : typing_result unit :=

checker/theories/Retyping.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Section TypeOf.
9999
| Some f => ret f.(dtype)
100100
| None => raise (IllFormedFix mfix n)
101101
end
102+
103+
| tInt _ | tFloat _ => raise (NotSupported "primitive types")
102104
end.
103105

104106
Definition sort_of (Γ : context) (t : term) : typing_result Universe.t :=

configure.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ if command -v coqc >/dev/null 2>&1
1616
then
1717
COQLIB=`coqc -where`
1818

19-
if [ "$1" == "local" ]
20-
then
19+
if [ "$1" = "local" ]; then
2120
echo "Building MetaCoq locally"
2221
CHECKER_DEPS="-R ../template-coq/theories MetaCoq.Template -I ../template-coq/build"
2322
PCUIC_MLDEPS="-I ../checker/src"

erasure/_PluginProject.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ src/kernames.ml
3131
# src/typing0.ml
3232

3333
# From PCUIC
34+
src/pCUICPrimitive.mli
35+
src/pCUICPrimitive.ml
3436
src/pCUICAst.ml
3537
src/pCUICAst.mli
3638
src/pCUICAstUtils.ml

erasure/src/metacoq_erasure_plugin.mlpack

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Classes0
1414
Logic1
1515
Relation
1616
Relation_Properties
17+
PCUICPrimitive
1718
PCUICAst
1819
PCUICAstUtils
1920
PCUICUnivSubst

erasure/theories/EAst.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(* Distributed under the terms of the MIT license. *)
22
From MetaCoq.Template Require Export utils BasicAst Universes.
3-
3+
From MetaCoq.PCUIC Require Import PCUICPrimitive.
44
(** * Extracted terms
55
66
These are the terms produced by extraction: compared to kernel terms,
@@ -37,7 +37,8 @@ Inductive term : Set :=
3737
term (* discriminee *) -> list (nat * term) (* branches *) -> term
3838
| tProj : projection -> term -> term
3939
| tFix : mfixpoint term -> nat -> term
40-
| tCoFix : mfixpoint term -> nat -> term.
40+
| tCoFix : mfixpoint term -> nat -> term
41+
| tPrim : prim_val term -> term.
4142

4243
Fixpoint mkApps t us :=
4344
match us with

erasure/theories/EAstUtils.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(* Distributed under the terms of the MIT license. *)
22
From MetaCoq.Template Require Import utils Kernames.
33
From MetaCoq.Erasure Require Import EAst.
4+
From MetaCoq.PCUIC Require PCUICPrimitive.
45
Require Import ssreflect ssrbool.
56

67

@@ -267,6 +268,7 @@ Fixpoint string_of_term (t : term) : string :=
267268
^ string_of_term c ^ ")"
268269
| tFix l n => "Fix(" ^ (string_of_list (string_of_def string_of_term) l) ^ "," ^ string_of_nat n ^ ")"
269270
| tCoFix l n => "CoFix(" ^ (string_of_list (string_of_def string_of_term) l) ^ "," ^ string_of_nat n ^ ")"
271+
| tPrim p => "Prim(" ^ PCUICPrimitive.string_of_prim string_of_term p ^ ")"
270272
end.
271273

272274
(** Compute all the global environment dependencies of the term *)

erasure/theories/EInduction.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Lemma term_forall_list_ind :
2828
(forall (s : projection) (t : term), P t -> P (tProj s t)) ->
2929
(forall (m : mfixpoint term) (n : nat), All (fun x => P (dbody x)) m -> P (tFix m n)) ->
3030
(forall (m : mfixpoint term) (n : nat), All (fun x => P (dbody x)) m -> P (tCoFix m n)) ->
31+
(forall p, P (tPrim p)) ->
3132
forall t : term, P t.
3233
Proof.
3334
intros until t. revert t.

erasure/theories/ELiftSubst.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Fixpoint lift n k t : term :=
3232
| tVar _ => t
3333
| tConst _ => t
3434
| tConstruct _ _ => t
35+
| tPrim _ => t
3536
end.
3637

37-
3838
Notation lift0 n := (lift n 0).
3939
Definition up := lift 1 0.
4040

0 commit comments

Comments
 (0)