| 1 |
|
| 2 |
Set Primitive Projections. |
| 3 |
|
| 4 |
Record R := C { p : nat }. |
| 5 |
(* R is defined |
| 6 |
p is defined *) |
| 7 |
|
| 8 |
Unset Primitive Projections. |
| 9 |
Record R' := C' { p' : nat }. |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
Fail Definition f := fix f (x : R) : nat := p x. |
| 14 |
(** Not allowed to make fixpoint defs on (non-recursive) records |
| 15 |
having eta *) |
| 16 |
|
| 17 |
Fail Definition f := fix f (x : R') : nat := p' x. |
| 18 |
(** Even without eta (R' is not primitive here), as long as they're |
| 19 |
found to be BiFinite (non-recursive), we disallow it *) |
| 20 |
|
| 21 |
(* |
| 22 |
|
| 23 |
(* Subject reduction failure example, if we allowed fixpoints *) |
| 24 |
|
| 25 |
Set Primitive Projections. |
| 26 |
|
| 27 |
Record R := C { p : nat }. |
| 28 |
|
| 29 |
Definition f := fix f (x : R) : nat := p x. |
| 30 |
|
| 31 |
(* eta rule for R *) |
| 32 |
Definition Rtr (P : R -> Type) x (v : P (C (p x))) : P x |
| 33 |
:= v. |
| 34 |
|
| 35 |
Definition goal := forall x, f x = p x. |
| 36 |
|
| 37 |
(* when we compute the Rtr away typechecking will fail *) |
| 38 |
Definition thing : goal := fun x => |
| 39 |
(Rtr (fun x => f x = p x) x (eq_refl _)). |
| 40 |
|
| 41 |
Definition thing' := Eval compute in thing. |
| 42 |
|
| 43 |
Fail Check (thing = thing'). |
| 44 |
(* |
| 45 |
The command has indeed failed with message: |
| 46 |
The term "thing'" has type "forall x : R, (let (p) := x in p) = (let (p) := x in p)" |
| 47 |
while it is expected to have type "goal" (cannot unify "(let (p) := x in p) = (let (p) := x in p)" |
| 48 |
and "f x = p x"). |
| 49 |
*) |
| 50 |
|
| 51 |
Definition thing_refl := eq_refl thing. |
| 52 |
|
| 53 |
Fail Definition thing_refl' := Eval compute in thing_refl. |
| 54 |
(* |
| 55 |
The command has indeed failed with message: |
| 56 |
Illegal application: |
| 57 |
The term "@eq_refl" of type "forall (A : Type) (x : A), x = x" |
| 58 |
cannot be applied to the terms |
| 59 |
"forall x : R, (fix f (x0 : R) : nat := let (p) := x0 in p) x = (let (p) := x in p)" : "Prop" |
| 60 |
"fun x : R => eq_refl" : "forall x : R, (let (p) := x in p) = (let (p) := x in p)" |
| 61 |
The 2nd term has type "forall x : R, (let (p) := x in p) = (let (p) := x in p)" |
| 62 |
which should be coercible to |
| 63 |
"forall x : R, (fix f (x0 : R) : nat := let (p) := x0 in p) x = (let (p) := x in p)". |
| 64 |
*) |
| 65 |
|
| 66 |
Definition more_refls : thing_refl = thing_refl. |
| 67 |
Proof. |
| 68 |
compute. reflexivity. |
| 69 |
Fail Defined. Abort. |
| 70 |
*) |