feat: Finish Chapter 5
This commit is contained in:
parent
a33c1585d6
commit
d5a19e0d69
6 changed files with 81 additions and 9 deletions
22
trans/prop-desugar.str
Normal file
22
trans/prop-desugar.str
Normal file
|
@ -0,0 +1,22 @@
|
|||
module prop-desugar
|
||||
imports libstrategolib signatures/-
|
||||
|
||||
rules
|
||||
|
||||
DefN : Not(x) -> Impl(x, False())
|
||||
DefI : Impl(x, y) -> Or(Not(x), y)
|
||||
DefE : Eq(x, y) -> And(Impl(x, y), Impl(y, x))
|
||||
DefO1 : Or(x, y) -> Impl(Not(x), y)
|
||||
DefO2 : Or(x, y) -> Not(And(Not(x), Not(y)))
|
||||
DefA1 : And(x, y) -> Not(Or(Not(x), Not(y)))
|
||||
DefA2 : And(x, y) -> Not(Impl(x, Not(y)))
|
||||
|
||||
IDefI : Or(Not(x), y) -> Impl(x, y)
|
||||
|
||||
IDefE : And(Impl(x, y), Impl(y, x)) -> Eq(x, y)
|
||||
|
||||
strategies
|
||||
|
||||
desugar = topdown(try(DefI <+ DefE))
|
||||
|
||||
impl-nf = topdown(repeat(DefN <+ DefA2 <+ DefO1 <+ DefE))
|
|
@ -67,7 +67,7 @@ So, we can just take our `test3` expression above and make it a part of
|
|||
an SPT test suite, which we will call `test/manual-suite.spt`:
|
||||
```SPT
|
||||
{! ../test/manual-suite.spt extract:
|
||||
start: '\*\*/'
|
||||
start: '\*\*[/]'
|
||||
terminate: '(.*run dnf)' !}
|
||||
```
|
||||
|
||||
|
@ -86,7 +86,7 @@ what the transformation actually produced. So we add just a bit to
|
|||
`test/manual-suite.spt`:
|
||||
```SPT
|
||||
{! ../test/manual-suite.spt extract:
|
||||
start: '\*\*/'
|
||||
start: '\*\*[/]'
|
||||
terminate: '(.*run dnf.*)$' !}
|
||||
```
|
||||
|
||||
|
|
27
trans/prop-eval2.str
Normal file
27
trans/prop-eval2.str
Normal file
|
@ -0,0 +1,27 @@
|
|||
module prop-eval2
|
||||
imports libstrategolib signatures/-
|
||||
rules
|
||||
|
||||
Eval : Not(True()) -> False()
|
||||
Eval : Not(False()) -> True()
|
||||
Eval : And(True(), x) -> x
|
||||
Eval : And(x, True()) -> x
|
||||
Eval : And(False(), x) -> False()
|
||||
Eval : And(x, False()) -> False()
|
||||
Eval : Or(True(), x) -> True()
|
||||
Eval : Or(x, True()) -> True()
|
||||
Eval : Or(False(), x) -> x
|
||||
Eval : Or(x, False()) -> x
|
||||
Eval : Impl(True(), x) -> x
|
||||
Eval : Impl(x, True()) -> True()
|
||||
Eval : Impl(False(), x) -> True()
|
||||
Eval : Impl(x, False()) -> Not(x)
|
||||
Eval : Eq(False(), x) -> Not(x)
|
||||
Eval : Eq(x, False()) -> Not(x)
|
||||
Eval : Eq(True(), x) -> x
|
||||
Eval : Eq(x, True()) -> x
|
||||
|
||||
strategies
|
||||
|
||||
eval-up = bottomup(repeat(Eval))
|
||||
eval-down = downup(repeat(Eval))
|
|
@ -19,4 +19,4 @@ rules
|
|||
strategies
|
||||
|
||||
dnf4 = innermost(DefI <+ DefE <+ DAOL <+ DAOR <+ DN <+ DMA <+ DMO)
|
||||
cnf4 = innermost(DefI <+ DefE <+ DOAL <+ DOAR <+ DN <+ DMA <+ DMO)
|
||||
cnf4 = innermost(DefI <+ DefE <+ DOAL <+ DOAR <+ DN <+ DMA <+ DMO)
|
||||
|
|
|
@ -11,6 +11,8 @@ imports
|
|||
prop-dnf3
|
||||
prop-cnf3
|
||||
prop-laws
|
||||
prop-eval2
|
||||
prop-desugar
|
||||
|
||||
rules // Debugging
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue