-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example of transfer of nat_rec to an abtract type + bugfix
- Loading branch information
1 parent
4d2d532
commit 8452607
Showing
7 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ examples/summable.v | |
examples/trocq_setoid_rewrite.v | ||
examples/Vector_tuple.v | ||
examples/misc.v | ||
exmaples/nat_ind.v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
(*****************************************************************************) | ||
(* * Trocq *) | ||
(* _______ * Copyright (C) 2023 Inria & MERCE *) | ||
(* |__ __| * (Mitsubishi Electric R&D Centre Europe) *) | ||
(* | |_ __ ___ ___ __ _ * Cyril Cohen <[email protected]> *) | ||
(* | | '__/ _ \ / __/ _` | * Enzo Crance <[email protected]> *) | ||
(* | | | | (_) | (_| (_| | * Assia Mahboubi <[email protected]> *) | ||
(* |_|_| \___/ \___\__, | ************************************************) | ||
(* | | * This file is distributed under the terms of *) | ||
(* |_| * GNU Lesser General Public License Version 3 *) | ||
(* * see LICENSE file for the text of the license *) | ||
(*****************************************************************************) | ||
|
||
From Coq Require Import ssreflect. | ||
From HoTT Require Import HoTT. | ||
From Trocq Require Import Trocq. | ||
|
||
Set Universe Polymorphism. | ||
|
||
Section IndType. | ||
Variables (I : Type) (I0 : I) (IS : I -> I). | ||
Variables (to_nat : I -> nat) (of_nat : nat -> I). | ||
|
||
Hypothesis to_natK : forall x, of_nat (to_nat x) = x. | ||
Hypothesis of_nat0 : of_nat O = I0. | ||
Hypothesis of_natS : forall x n, of_nat n = x -> of_nat (S n) = IS x. | ||
|
||
(* We only need/ (2a,3) which is morally that Nmap is a split injection *) | ||
Definition RI : Param2a3.Rel I nat := | ||
SplitSurj.toParamSym (SplitSurj.Build to_natK). | ||
|
||
Definition RI0 : RI I0 O. Proof. exact of_nat0. Qed. | ||
Definition RIS m n : RI m n -> RI (IS m) (S n). Proof. exact: of_natS. Qed. | ||
|
||
Trocq Use RI. | ||
Trocq Use RI0. | ||
Trocq Use RIS. | ||
|
||
Lemma I_Srec : forall (P : I -> Type), P I0 -> | ||
(forall n, P n -> P (IS n)) -> forall n, P n. | ||
Proof. | ||
trocq. | ||
(* the output sort of P' is (1,1) because of the covariant and contravariant occurrences of P in | ||
the input goal; this annotation was made to be definitionally equal to Type: from there, | ||
the induction principle of nat can be applied directly *) | ||
exact nat_rect. | ||
Defined. | ||
|
||
End IndType. | ||
|
||
Check I_Srec. | ||
Print I_Srec. | ||
Print Assumptions I_Srec. |