Skip to content

Commit f9595d4

Browse files
committed
Fix bitrotting in manual
1 parent 9de65da commit f9595d4

8 files changed

+103
-107
lines changed

Filter.hs

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
#!/usr/bin/runhaskell
2-
31
{-# LANGUAGE RecordWildCards #-}
42
import Text.Pandoc.JSON
53
import Text.Pandoc
64
import Tip.Core
75
import Tip.Parser
8-
import Tip.Passes
6+
import Tip.Passes hiding (Mode)
97
import qualified Tip.Pretty.SMT as SMT
108
import qualified Tip.Pretty.Why3 as Why3
119
import Control.Monad
@@ -28,7 +26,6 @@ tipBlock name classes attrs expr =
2826
(modes, passes) = go classes [] []
2927
go [] modes passes = (reverse modes, reverse passes)
3028
go ("no-datatypes":xs) modes passes = go xs (NoData:modes) passes
31-
go ("no-check-sat":xs) modes passes = go xs (NoCheckSat:modes) passes
3229
go ("no-functions":xs) modes passes = go xs (NoFuns:modes) passes
3330
go ("no-properties":xs) modes passes = go xs (NoProp:modes) passes
3431
go ("why3":xs) modes passes = go xs (Why3:modes) passes
@@ -37,20 +34,19 @@ tipBlock name classes attrs expr =
3734
[(pass, "")] -> go xs modes (pass:passes)
3835
_ -> error ("Unknown pass " ++ x)
3936

40-
data Mode = NoData | NoProp | NoFuns | NoCheckSat | Why3 deriving (Show, Eq)
37+
data Mode = NoData | NoProp | NoFuns | Why3 deriving (Show, Eq)
4138

4239
pass :: StandardPass -> Theory Id -> Theory Id
43-
pass p = freshPass (runPass p)
40+
pass p thy =
41+
case freshPass (runPass p) thy of
42+
[thy'] -> thy'
4443

4544
mode :: [Mode] -> Theory Id -> String
4645
mode ms thy@Theory{..}
4746
| Why3 `elem` ms = show . Why3.ppTheory $ thy'
48-
| NoCheckSat `elem` ms = out' thy'
4947
| otherwise = out thy'
5048
where
51-
out = show . SMT.ppTheory
52-
out' = dropRev (length "(check-sat)") . show . SMT.ppTheory
53-
dropRev n = reverse . drop n . reverse
49+
out = show . SMT.ppTheory (SMT.smtQuoted ++ SMT.tipKeywords ++ SMT.smtKeywords)
5450
thy' =
5551
thy {
5652
thy_datatypes = checking NoData thy_datatypes,

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ clean:
88

99
.PHONY: all clean
1010

11-
%.html: %.md
12-
pandoc $< -o $@ --standalone --filter ./Filter.hs --bibliography=bibfile.bib --template ./template.html
11+
%.html: %.md Filter
12+
pandoc $< -o $@ --standalone --filter ./Filter --bibliography=bibfile.bib --template ./template.html
1313

14+
Filter: Filter.hs
15+
ghc --make -O $<

bnf.html

-3
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ <h1>TIP BNF</h1>
114114
terminator FunDec &quot;&quot;;
115115

116116
position token Symbol (letter|[&quot;~!@$%^&amp;*_+=&lt;&gt;.?/&quot;])(letter|digit|[&quot;~!@$%^&amp;*_-+=&lt;&gt;.?/&quot;])*;</code></pre>
117-
<div class="references">
118-
119-
</div>
120117
</div>
121118
</body>
122119
</html>

format.html

+56-55
Large diffs are not rendered by default.

list.smt2

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
(declare-datatypes (a)
2-
((list (nil) (cons (head a) (tail (list a))))))
3-
(define-funs-rec
4-
((par (a) (append ((xs (list a)) (ys (list a))) (list a))))
5-
((match xs
6-
(case nil (as nil (list a)))
7-
(case (cons x xs) (cons x (as (append xs ys) (list a)))))))
8-
(assert-not
1+
(declare-datatype
2+
list
93
(par (a)
10-
(forall ((xs (list a))) (= (append xs (as nil (list a))) xs))))
11-
(check-sat)
4+
((nil) (cons (head a) (tail (list a))))))
5+
(define-fun-rec
6+
append (par (a) (((xs (list a)) (ys (list a))) (list a)))
7+
(match xs
8+
((nil (_ nil a))
9+
((cons x xs) (cons x (append xs ys))))))
10+
(prove
11+
(par (a)
12+
(forall ((xs (list a))) (= (append xs (_ nil a)) xs))))

map.smt2

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
(declare-datatypes (a)
2-
((list (nil) (cons (head a) (tail (list a))))))
3-
(define-funs-rec
4-
((par (a b) (map2 ((f (=> a b)) (xs (list a))) (list b))))
5-
((match xs
6-
(case nil (as nil (list b)))
7-
(case (cons y ys) (cons (@ f y) (as (map2 f ys) (list b)))))))
8-
(assert-not
1+
(declare-datatype
2+
list
3+
(par (a)
4+
((nil) (cons (head a) (tail (list a))))))
5+
(define-fun-rec
6+
map (par (a b) (((f (=> a b)) (xs (list a))) (list b)))
7+
(match xs
8+
((nil (_ nil b))
9+
((cons y ys) (cons (@ f y) (map f ys))))))
10+
(prove
911
(par (a b c)
1012
(forall ((f (=> b c)) (g (=> a b)) (xs (list a)))
11-
(= (map2 (lambda ((x a)) (@ f (@ g x))) xs)
12-
(map2 f (map2 g xs))))))
13-
(check-sat)
13+
(= (map (lambda ((x a)) (@ f (@ g x))) xs)
14+
(map f (map g xs))))))

nat-default.smt2

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
(declare-datatypes () ((Nat (Zero) (Succ (pred Nat)))))
2-
(define-funs-rec
3-
((plus ((x Nat) (y Nat)) Nat))
4-
((match x
5-
(case Zero y)
6-
(case default (Succ (plus (pred x) y))))))
7-
(assert-not (forall ((n Nat) (m Nat)) (= (plus n m) (plus m n))))
8-
(check-sat)
1+
(declare-datatype Nat ((Zero) (Succ (pred Nat))))
2+
(define-fun-rec
3+
plus ((x Nat) (y Nat)) Nat
4+
(match x
5+
((Zero y)
6+
(default (Succ (plus (pred x) y))))))
7+
(prove (forall ((n Nat) (m Nat)) (= (plus n m) (plus m n))))

nat.smt2

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
(declare-datatypes () ((Nat (Zero) (Succ (pred Nat)))))
2-
(define-funs-rec
3-
((plus ((x Nat) (y Nat)) Nat))
4-
((match x
5-
(case Zero y)
6-
(case (Succ n) (Succ (plus n y))))))
7-
(assert-not (forall ((n Nat) (m Nat)) (= (plus n m) (plus m n))))
8-
(check-sat)
1+
(declare-datatype Nat ((Zero) (Succ (pred Nat))))
2+
(define-fun-rec
3+
plus ((x Nat) (y Nat)) Nat
4+
(match x
5+
((Zero y)
6+
((Succ n) (Succ (plus n y))))))
7+
(prove (forall ((n Nat) (m Nat)) (= (plus n m) (plus m n))))

0 commit comments

Comments
 (0)