aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to 'etc')
-rw-r--r--etc/utils/hierarchy_test.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/etc/utils/hierarchy_test.py b/etc/utils/hierarchy_test.py
new file mode 100644
index 0000000..bc90c55
--- /dev/null
+++ b/etc/utils/hierarchy_test.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# usage: hiearchy_test.py inputfile
+
+import pygraphviz as pgv
+import sys, argparse
+
+def children(G,n):
+ res = set()
+ new = set([n])
+ while new != set():
+ p = new.pop()
+ res.add(p)
+ new.update(set(G.successors(p)).difference(res))
+ return res
+
+def common_children(G):
+ result = set()
+ for x in G.nodes():
+ for y in G.nodes():
+ if children(G,x).intersection(children(G,y)) != set():
+ result.add((x,y))
+ return result
+
+def print_common_children_coq_check(G):
+ print("(** Generated by etc/utils/hierarchy_test.py *)")
+ print("From mathcomp Require Import all.")
+ for x in G.nodes():
+ if x.rfind("Lmod") >= 0 or x.rfind("Splitting") >= 0 or \
+ x.rfind("lgebra") >= 0 or x.rfind("FieldExt") >= 0 or \
+ x.rfind("Vector") >= 0:
+ print ("Local Notation \"" + x + ".type\" := (" + x + ".type _).")
+ print ("")
+ for (x, y) in common_children(G):
+ if x < y:
+ print ("Check erefl : (_ : " + x + ".type) = (_ : " + y + ".type) :> Type.")
+
+def main():
+ parser = argparse.ArgumentParser(description='Generate a check .v file \
+ for mathcomp structure hiearchies')
+ parser.add_argument('dotfile', metavar='<dotfile>', nargs=1,
+ help='a dotfile representing the hierarchy')
+ args = parser.parse_args()
+ print_common_children_coq_check(pgv.AGraph(args.dotfile[0]))
+
+if __name__ == "__main__":
+ main()