Debian Codegraph @

src/Bedrock/Field/Translation/Proofs/VarnameSet.v

raw
1 From Coq Require Import String.
2 Require Import Crypto.Bedrock.Field.Common.Types.
3 Require Import Crypto.Language.API.
4 Local Open Scope Z_scope.
5
6 Import API.Compilers.
7 Import Types.Notations.
8
9 Section VarnameSet.
10 Context
11 {width BW word mem locals ext_spec varname_gen error}
12 `{parameters_sentinel : @parameters
13 width BW word mem locals ext_spec varname_gen error}.
14 Context {listZ : rep.rep base_listZ}.
15 Existing Instance rep.Z.
16
17 (* Set of variable names used by an ltype *)
18 Fixpoint varname_set_base {t}
19 : base_ltype t -> PropSet.set string :=
20 match t with
21 | base.type.prod a b =>
22 fun x => PropSet.union (varname_set_base (fst x))
23 (varname_set_base (snd x))
24 | base_listZ => rep.varname_set
25 | _ => rep.varname_set
26 end.
27 Fixpoint varname_set_args {t}
28 : type.for_each_lhs_of_arrow ltype t ->
29 PropSet.set string :=
30 match t as t0 return type.for_each_lhs_of_arrow _ t0 -> _ with
31 | type.base b => fun _:unit => PropSet.empty_set
32 | type.arrow (type.base a) b =>
33 fun (x:base_ltype a * _) =>
34 PropSet.union (varname_set_base (fst x))
35 (varname_set_args (snd x))
36 | _ => fun _ => PropSet.empty_set (* garbage; invalid argument *)
37 end.
38 Definition varname_set {t} : ltype t -> PropSet.set string :=
39 match t with
40 | type.base _ => varname_set_base
41 | _ => fun _ => PropSet.empty_set
42 end.
43
44 Fixpoint varname_set_listonly {t}
45 : base_ltype t ->
46 PropSet.set string :=
47 match t with
48 | base.type.prod a b =>
49 fun x => PropSet.union (varname_set_listonly (fst x))
50 (varname_set_listonly (snd x))
51 | base_listZ => rep.varname_set
52 | _ => fun _ => PropSet.empty_set
53 end.
54 Fixpoint varname_set_listexcl {t}
55 : base_ltype t ->
56 PropSet.set string :=
57 match t with
58 | base.type.prod a b =>
59 fun x => PropSet.union (varname_set_listexcl (fst x))
60 (varname_set_listexcl (snd x))
61 | base_listZ => fun _ => PropSet.empty_set
62 | _ => rep.varname_set
63 end.
64 End VarnameSet.