From 562da0c4beec2525db4867e56867576aaf6c0bd8 Mon Sep 17 00:00:00 2001 From: Cyril Cohen Date: Tue, 2 Apr 2019 16:40:14 +0200 Subject: identifying missing joins --- etc/utils/hierarchy_test.py | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 etc/utils/hierarchy_test.py (limited to 'etc') 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='', 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() -- cgit v1.2.3