1- From Coq Require Import List Logic.Decidable.
1+ From Coq Require Import List Logic.Decidable ssreflect .
22From MetaCoq.Common Require Import BasicAst Kernames Universes EnvMap.
33From MetaCoq.Erasure Require Import EAst EWellformed.
4- From MetaCoq.Utils Require Import bytestring.
4+ From MetaCoq.Utils Require Import bytestring ReflectEq .
55From Equations Require Import Equations.
66
77Import ListNotations.
88Import EnvMap.
9+ Import Kernames.
910
1011#[global] Obligation Tactic := idtac.
1112#[global] Set Equations Transparent .
@@ -14,10 +15,125 @@ Import EnvMap.
1415Definition inspect {A} (a : A) : {b | a = b} := exist _ a eq_refl.
1516Notation "x 'eqn:' p" := (exist _ x p) (only parsing, at level 20).
1617
18+ (*
1719#[local] Obligation Tactic :=
20+ try simpl;
1821 try intro wf_decls;
1922 try dependent elimination wf_decls;
2023 try auto.
24+ *)
25+
26+ Definition eflags : EEnvFlags := all_env_flags.
27+
28+ Fixpoint check_fresh_global (k : kername) (decls : global_declarations) : bool :=
29+ match decls with
30+ | [] => true
31+ | p::ds => negb (eq_kername (fst p) k) && check_fresh_global k ds
32+ end .
33+
34+ Fixpoint check_wf_glob {efl : EEnvFlags} (decls : global_declarations) : bool :=
35+ match decls with
36+ | [] => true
37+ | p::ds => check_wf_glob ds && check_fresh_global (fst p) ds && wf_global_decl ds (snd p)
38+ end .
39+
40+ Definition check_wf_program {efl : EEnvFlags} (p : program) : bool :=
41+ check_wf_glob (fst p) && wellformed (fst p) 0 (snd p).
42+
43+ (* freshness boolean check coincides with the freshness property *)
44+ Fixpoint check_fresh_globalP (k : kername) (decls : global_declarations)
45+ : reflectProp (fresh_global k decls) (check_fresh_global k decls).
46+ dependent elimination decls; simpl.
47+ Proof .
48+ - apply reflectP.
49+ apply Forall_nil.
50+ - destruct (inspect (fst p == k)).
51+ destruct x.
52+ + rewrite e.
53+ simpl.
54+ apply reflectF.
55+ intro global_ds.
56+ dependent elimination global_ds.
57+ apply n.
58+ apply eqb_eq.
59+ auto.
60+ + rewrite e.
61+ simpl.
62+ destruct (check_fresh_globalP k l).
63+ * apply reflectP.
64+ apply Forall_cons.
65+ destruct (neqb (fst p) k).
66+ apply H0.
67+ rewrite e.
68+ simpl.
69+ auto.
70+ auto.
71+ * apply reflectF.
72+ intro gds.
73+ dependent elimination gds.
74+ auto.
75+ Defined .
76+
77+ (* well-formedness boolean check coincides with the wf property *)
78+ Fixpoint check_wf_globP {efl : EEnvFlags} (decls : global_declarations)
79+ : reflectProp (wf_glob decls) (check_wf_glob decls).
80+ Proof .
81+ dependent elimination decls.
82+ - apply reflectP.
83+ apply wf_glob_nil.
84+ - remember (check_wf_glob l).
85+ pose x := (check_wf_globP efl l).
86+ rewrite <-Heqb in x.
87+ destruct x.
88+ + simpl.
89+ rewrite <-Heqb.
90+ simpl.
91+ remember (check_fresh_global (fst p) l).
92+ pose x := (check_fresh_globalP (fst p) l).
93+ rewrite <-Heqb0 in x.
94+ destruct x.
95+ simpl.
96+ remember (wf_global_decl l (snd p)).
97+ destruct b.
98+ apply reflectP.
99+ destruct p.
100+ apply wf_glob_cons; auto.
101+ apply reflectF.
102+ intro gds.
103+ dependent elimination gds.
104+ simpl in Heqb1.
105+ rewrite <-Heqb1 in i.
106+ discriminate i.
107+ simpl.
108+ apply reflectF.
109+ intro gds.
110+ dependent elimination gds.
111+ auto.
112+ + simpl.
113+ rewrite <- Heqb.
114+ simpl.
115+ apply reflectF.
116+ intro gds.
117+ dependent elimination gds.
118+ auto.
119+ Defined .
120+
121+ (*
122+
123+ check_fresh_globalP k [] := _;
124+ check_fresh_globalP k ((k', _)::ds) with inspect (eq_kername k' k), inspect (check_fresh_global k ds) := {
125+ | false eqn: p | true eqn: q := _;
126+ | _ eqn: p | _ eqn: q := _
127+ }.
128+ - apply ReflectT.
129+ apply Forall_nil.
130+ - rewrite q.
131+ rewrite p.
132+ simpl.
133+ apply ReflectT.
134+ apply Forall_cons.
135+ + .
136+
21137
22138Equations? dec_fresh_global (k : kername) (decls : global_declarations) : decidable (fresh_global k decls) :=
23139dec_fresh_global k [] := or_introl (Forall_nil _);
@@ -62,4 +178,5 @@ dec_wf_program (decls, t) with dec_wf_glob decls := {
62178 discriminate i.
63179Defined.
64180
65- Definition eflags : EEnvFlags := all_env_flags.
181+
182+ *)
0 commit comments