summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2012-08-02 09:37:58 +1000
committerJed Barber <jjbarber@y7mail.com>2012-08-02 09:37:58 +1000
commitea042911e5062d7cecf0ead734c039cae5265b6c (patch)
tree1546b933217b41015dde1de07cec13ad99f7262c
parentad0d628b1bf333a99238bd2cefc60ec059df3f81 (diff)
Generates a numbered list of theorems in an article file
-rw-r--r--ListThm.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/ListThm.hs b/ListThm.hs
new file mode 100644
index 0000000..e61aaf9
--- /dev/null
+++ b/ListThm.hs
@@ -0,0 +1,43 @@
+import System( getArgs )
+import Text.Printf
+import Parse
+import ProofGraph
+import WriteProof
+import Semantic
+import Stack
+
+import Data.Maybe
+import Data.Graph.Inductive.Graph( Node, LNode, Edge, LEdge )
+import qualified Data.Graph.Inductive.Graph as Graph
+
+
+
+fst4 :: (a,b,c,d) -> a
+fst4 (a,_,_,_) = a
+
+
+
+toThms :: PGraph -> [Node] -> [String]
+toThms graph nodeList =
+ let hyp = (\g n -> let edge = filter (\x -> (fst . thd3 $ x) == 2) (Graph.out g n)
+ node = snd3 . head $ edge
+ in write g node)
+
+ con = (\g n -> let edge = filter (\x -> (fst . thd3 $ x) == 1) (Graph.out g n)
+ node = snd3 . head $ edge
+ in write g node)
+
+ f = (\x -> (show . fst $ x) ++ ". [" ++ show ((fst4 . fromJust $ (eval (hyp graph (snd x)))) `at` 0) ++
+ "] |- " ++ show ((fst4 . fromJust $ (eval (con graph (snd x)))) `at` 0))
+
+ in map f (zip [1..] nodeList)
+
+
+
+main = do
+ args <- getArgs
+ list <- getLines $ head args
+ let graph = doGraphGen (map (stripReturn) list)
+ initList = filter (\x -> Graph.indeg graph x == 0) (Graph.nodes graph)
+ theorems = toThms graph initList
+ output theorems