diff options
| author | Cyril Cohen | 2019-04-03 13:44:32 +0200 |
|---|---|---|
| committer | GitHub | 2019-04-03 13:44:32 +0200 |
| commit | 6bfadd75cc6dbcc1b6a29b2607e413f87c418c90 (patch) | |
| tree | c3699bf13ef3119e011f3168f98644718b882d26 /etc/utils | |
| parent | 9209c4414b22ead6b5a70d6f2bfb460b1ad26728 (diff) | |
| parent | 7ab5c99ab4c2ecfd55702a4279392f067652e357 (diff) | |
Merge pull request #291 from pi8027/finalg-hierarchy
Fix inheritances from countalg to finalg
Diffstat (limited to 'etc/utils')
| -rw-r--r-- | etc/utils/hierarchy_test.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/etc/utils/hierarchy_test.py b/etc/utils/hierarchy_test.py new file mode 100644 index 0000000..30de3e6 --- /dev/null +++ b/etc/utils/hierarchy_test.py @@ -0,0 +1,45 @@ +#!/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 x < y and 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): + 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() |
