aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-05-15 22:37:02 -0400
committerGravatar Jason Gross <jgross@mit.edu>2017-05-15 22:37:02 -0400
commit9480dccb77f9e9312c9159a4c7fca8814bc73433 (patch)
treee97a61ecca3f2654a881575baf2a0c850790dc74
parentd3054c8ba755bea855cbcecd12b1e54529d15693 (diff)
Add Named.ExprInversion
-rw-r--r--_CoqProject1
-rw-r--r--src/Compilers/Named/ExprInversion.v21
2 files changed, 22 insertions, 0 deletions
diff --git a/_CoqProject b/_CoqProject
index 8d289a6fb..0a151d30d 100644
--- a/_CoqProject
+++ b/_CoqProject
@@ -84,6 +84,7 @@ src/Compilers/Named/CountLets.v
src/Compilers/Named/DeadCodeElimination.v
src/Compilers/Named/DeadCodeEliminationInterp.v
src/Compilers/Named/EstablishLiveness.v
+src/Compilers/Named/ExprInversion.v
src/Compilers/Named/FMapContext.v
src/Compilers/Named/GetNames.v
src/Compilers/Named/IdContext.v
diff --git a/src/Compilers/Named/ExprInversion.v b/src/Compilers/Named/ExprInversion.v
new file mode 100644
index 000000000..783341f26
--- /dev/null
+++ b/src/Compilers/Named/ExprInversion.v
@@ -0,0 +1,21 @@
+Require Import Crypto.Compilers.TypeInversion.
+Require Import Crypto.Compilers.Syntax.
+Require Import Crypto.Compilers.Named.Syntax.
+
+Module Export Named.
+ Ltac invert_one_expr e :=
+ preinvert_one_type e;
+ intros ? e;
+ destruct e;
+ try exact I.
+
+ Ltac invert_expr_step :=
+ match goal with
+ | [ e : Named.exprf _ _ _ (Tbase _) |- _ ] => invert_one_expr e
+ | [ e : Named.exprf _ _ _ (Prod _ _) |- _ ] => invert_one_expr e
+ | [ e : Named.exprf _ _ _ Unit |- _ ] => invert_one_expr e
+ | [ e : Named.expr _ _ _ (Arrow _ _) |- _ ] => invert_one_expr e
+ end.
+
+ Ltac invert_expr := repeat invert_expr_step.
+End Named.