66(* Copyright 2009-2010: Thomas Braibant, Damien Pous. *)
77(************************************************************************** *)
88
9- (** * Theory file for the aac_rewrite tactic
9+ (** * Theory for AAC Tactics
1010
1111 We define several base classes to package associative and possibly
1212 commutative/idempotent operators, and define a data-type for reified (or
2626 where one occurrence of [+] operates on nat while the other one
2727 operates on positive. *)
2828
29- Require Import Arith NArith.
30- Require Import List.
31- Require Import FMapPositive FMapFacts.
32- Require Import RelationClasses Equality .
33- Require Export Morphisms.
34-
35- From AAC_tactics
36- Require Import Utils Constants.
29+ From Coq Require Import Arith NArith List.
30+ From Coq Require Import FMapPositive FMapFacts RelationClasses Equality .
31+ From Coq Require Export Morphisms.
32+ From AAC_tactics Require Import Utils Constants.
3733
3834Set Implicit Arguments .
3935Set Asymmetric Patterns.
4036
4137Local Open Scope signature_scope.
4238
43- (** * Environments for the reification process: we use positive maps to index elements *)
39+ (** ** Environments for the reification process
40+
41+ We use positive maps to index elements. *)
4442
4543Section sigma.
4644 Definition sigma := PositiveMap.t.
@@ -57,8 +55,7 @@ Section sigma.
5755 Register sigma_empty as aac_tactics.sigma.empty.
5856End sigma.
5957
60-
61- (** * Classes for properties of operators *)
58+ (** ** Classes for properties of operators *)
6259
6360Class Associative (X:Type ) (R:relation X) (dot: X -> X -> X) :=
6461 law_assoc : forall x y z, R (dot x (dot y z)) (dot (dot x y) z).
@@ -75,7 +72,6 @@ Register Commutative as aac_tactics.classes.Commutative.
7572Register Idempotent as aac_tactics.classes.Idempotent.
7673Register Unit as aac_tactics.classes.Unit.
7774
78-
7975(** Class used to find the equivalence relation on which operations
8076 are A or AC, starting from the relation appearing in the goal *)
8177
@@ -88,24 +84,21 @@ Register aac_lift_equivalence as aac_tactics.internal.aac_lift_equivalence.
8884
8985(** simple instances, when we have a subrelation, or an equivalence *)
9086
91- #[global]
92- Instance aac_lift_subrelation {X} {R} {E} {HE: Equivalence E}
93- {HR: @Transitive X R} {HER: subrelation E R}: AAC_lift R E | 3.
87+ #[export] Instance aac_lift_subrelation {X} {R} {E} {HE: Equivalence E}
88+ {HR: @Transitive X R} {HER: subrelation E R} : AAC_lift R E | 3.
9489Proof .
9590 constructor; trivial.
9691 intros ? ? H ? ? H'. split; intro G.
9792 rewrite <- H, G. apply HER, H'.
9893 rewrite H, G. apply HER. symmetry. apply H'.
9994Qed .
10095
101- #[global]
102- Instance aac_lift_proper {X} {R : relation X} {E} {HE: Equivalence E}
103- {HR: Proper (E==>E==>iff) R}: AAC_lift R E | 4 := {}.
104-
96+ #[export] Instance aac_lift_proper {X} {R : relation X} {E}
97+ {HE: Equivalence E} {HR: Proper (E==>E==>iff) R} : AAC_lift R E | 4 := {}.
10598
99+ (** ** Utilities for the evaluation function *)
106100
107101Module Internal.
108- (** * Utilities for the evaluation function *)
109102
110103Section copy.
111104
@@ -132,7 +125,7 @@ Section copy.
132125 Lemma copy_Psucc : forall n x, R (copy (Pos.succ n) x) (plus x (copy n x)).
133126 Proof . intros; unfold copy; rewrite Prect_succ. reflexivity. Qed .
134127
135- Global Instance copy_compat n: Proper (R ==> R) (copy n).
128+ #[export] Instance copy_compat n: Proper (R ==> R) (copy n).
136129 Proof .
137130 unfold copy.
138131 induction n using Pind; intros x y H.
@@ -142,9 +135,9 @@ Section copy.
142135
143136End copy.
144137
145- (** * Packaging structures *)
138+ (** ** Packaging structures *)
146139
147- (** ** free symbols *)
140+ (** *** Free symbols *)
148141
149142Module Sym.
150143 Section t.
@@ -189,7 +182,7 @@ Module Sym.
189182
190183End Sym.
191184
192- (** ** binary operations *)
185+ (** *** Binary operations *)
193186
194187Module Bin.
195188 Section t.
@@ -211,7 +204,7 @@ Module Bin.
211204End Bin.
212205
213206
214- (** * Reification, normalisation, and decision *)
207+ (** ** Reification, normalisation, and decision *)
215208
216209Section s.
217210 Context {X} {R: relation X} {E: @Equivalence X R}.
@@ -247,8 +240,9 @@ Section s.
247240 #[local]
248241 Hint Resolve e_bin e_unit: typeclass_instances.
249242
250- (** ** Almost normalised syntax
251- a term in [T] is in normal form if:
243+ (** *** Almost normalised syntax
244+
245+ A term in [T] is in normal form if:
252246 - sums do not contain sums
253247 - products do not contain products
254248 - there are no unary sums or products
@@ -303,7 +297,7 @@ Section s.
303297
304298
305299
306- (** ** Evaluation from syntax to the abstract domain *)
300+ (** *** Evaluation from syntax to the abstract domain *)
307301
308302 Fixpoint eval u: X :=
309303 match u with
@@ -373,7 +367,7 @@ Section s.
373367 match Bin.idem (e_bin i) with Some _ => true | None => false end .
374368
375369
376- (** ** Normalisation *)
370+ (** *** Normalisation *)
377371
378372 #[universes(template)]
379373 Inductive discr {A} : Type :=
@@ -519,7 +513,7 @@ Section s.
519513 | vcons _ u l => vcons (norm u) (vnorm l)
520514 end .
521515
522- (** ** Correctness *)
516+ (** *** Correctness *)
523517
524518 Lemma is_unit_of_Unit : forall i j : idx,
525519 is_unit_of i j = true -> Unit R (Bin.value (e_bin i)) (eval (unit j)).
@@ -554,17 +548,16 @@ Section s.
554548 Proof .
555549 destruct ((e_bin i)); auto.
556550 Qed .
557- #[local]
558- Hint Resolve Binvalue_Proper Binvalue_Associative Binvalue_Commutative : core.
551+ #[local] Hint Resolve Binvalue_Proper Binvalue_Associative Binvalue_Commutative : core.
559552
560553 (** auxiliary lemmas about sums *)
561554
562- #[local]
563- Hint Resolve is_unit_of_Unit : core.
555+ #[local] Hint Resolve is_unit_of_Unit : core.
564556 Section sum_correctness.
565557 Variable i : idx.
566558 Variable is_unit : idx -> bool.
567- Hypothesis is_unit_sum_Unit : forall j, is_unit j = true-> @Unit X R (Bin.value (e_bin i)) (eval (unit j)).
559+ Hypothesis is_unit_sum_Unit : forall j, is_unit j = true ->
560+ @Unit X R (Bin.value (e_bin i)) (eval (unit j)).
568561
569562 Inductive is_sum_spec_ind : T -> @discr (mset T) -> Prop :=
570563 | is_sum_spec_op : forall j l, j = i -> is_sum_spec_ind (sum j l) (Is_op l)
@@ -974,8 +967,7 @@ Local Ltac internal_normalize :=
974967 compute [Internal.eval Utils.fold_map Internal.copy Prect]; simpl.
975968
976969
977- (** * Lemmas for performing transitivity steps
978- given an instance of AAC_lift *)
970+ (** ** Lemmas for performing transitivity steps given an AAC_lift instance *)
979971
980972Section t.
981973 Context `{AAC_lift}.
0 commit comments