-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
119 additions
and
140 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
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,110 @@ | ||
(* monae: Monadic equational reasoning in Coq *) | ||
(* Copyright (C) 2023 monae authors, license: LGPL-2.1-or-later *) | ||
Require Import ZArith. | ||
From mathcomp Require Import all_ssreflect. | ||
Require Import monad_model. | ||
From HB Require Import structures. | ||
Require Import preamble hierarchy monad_lib typed_store_lib. | ||
|
||
(******************************************************************************) | ||
(* Typed store universes *) | ||
(* *) | ||
(* Inductive ml_type == generated by coqgen *) | ||
(* *) | ||
(* Module CoqTypeNat *) | ||
(* coq_type_nat == adapted from code generated by coqgen *) | ||
(* *) | ||
(* Module CoqTypeInt63 *) | ||
(* Fixpoint coq_type63 == generated type translation function *) | ||
(******************************************************************************) | ||
|
||
Local Open Scope monae_scope. | ||
|
||
(******************************************************************************) | ||
(* generated by coqgen *) | ||
(******************************************************************************) | ||
Module MLTypes. | ||
Inductive ml_type : Set := | ||
| ml_int | ||
| ml_bool | ||
| ml_unit | ||
| ml_ref (_ : ml_type) | ||
| ml_arrow (_ : ml_type) (_ : ml_type) | ||
| ml_rlist (_ : ml_type). | ||
|
||
Definition ml_type_eq_dec (T1 T2 : ml_type) : {T1=T2}+{T1<>T2}. | ||
revert T2; induction T1; destruct T2; | ||
try (right; intro; discriminate); try (now left); | ||
try (case (IHT1_5 T2_5); [|right; injection; intros; contradiction]); | ||
try (case (IHT1_4 T2_4); [|right; injection; intros; contradiction]); | ||
try (case (IHT1_3 T2_3); [|right; injection; intros; contradiction]); | ||
try (case (IHT1_2 T2_2); [|right; injection; intros; contradiction]); | ||
(case (IHT1 T2) || case (IHT1_1 T2_1)); try (left; now subst); | ||
right; injection; intros; contradiction. | ||
Defined. | ||
|
||
Definition val_nonempty (M : UU0 -> UU0) := tt. | ||
|
||
Notation loc := (@loc _ monad_model.locT_nat). | ||
|
||
Inductive rlist (a : Type) (a_1 : ml_type) := | ||
| Nil | ||
| Cons (_ : a) (_ : loc (ml_rlist a_1)). | ||
|
||
Definition ml_type_eq_mixin := hasDecEq.Build _ (comparePc MLTypes.ml_type_eq_dec). | ||
HB.instance Definition ml_type_eqType := ml_type_eq_mixin. | ||
|
||
End MLTypes. | ||
(******************************************************************************) | ||
|
||
Module CoqTypeNat. | ||
Import MLTypes. | ||
|
||
Section with_monad. | ||
Context [M : Type -> Type]. | ||
|
||
Fixpoint coq_type_nat (T : ml_type) : Type := | ||
match T with | ||
| ml_int => nat | ||
| ml_bool => bool | ||
| ml_unit => unit | ||
| ml_arrow T1 T2 => coq_type_nat T1 -> M (coq_type_nat T2) | ||
| ml_ref T1 => loc T1 | ||
| ml_rlist T1 => rlist (coq_type_nat T1) T1 | ||
end. | ||
End with_monad. | ||
|
||
HB.instance Definition _ := @isML_universe.Build ml_type coq_type_nat ml_unit val_nonempty. | ||
|
||
Definition typedStoreMonad (N : monad) := | ||
typedStoreMonad ml_type N monad_model.locT_nat. | ||
|
||
Definition typedStoreRunMonad (N : monad) := | ||
typedStoreRunMonad ml_type N monad_model.locT_nat. | ||
End CoqTypeNat. | ||
|
||
Require Import PrimInt63. | ||
Require Sint63. | ||
|
||
Module CoqTypeInt63. | ||
Import MLTypes. | ||
|
||
(******************************************************************************) | ||
(* generated by coqgen *) | ||
(******************************************************************************) | ||
Section with_monad. | ||
Context [M : Type -> Type]. | ||
Fixpoint coq_type63 (T : ml_type) : Type := | ||
match T with | ||
| ml_int => int | ||
| ml_bool => bool | ||
| ml_unit => unit | ||
| ml_arrow T1 T2 => coq_type63 T1 -> M (coq_type63 T2) | ||
| ml_ref T1 => loc T1 | ||
| ml_rlist T1 => rlist (coq_type63 T1) T1 | ||
end. | ||
End with_monad. | ||
(******************************************************************************) | ||
|
||
HB.instance Definition _ := @isML_universe.Build ml_type coq_type63 ml_unit val_nonempty. | ||
End CoqTypeInt63. |