Extending a reduction relation

99 Views Asked by At

While taking a look at PLT redex, I wanted to play with simplification rules; so I defined this minimal language for booleans:

(define-language B0
  (b T F (not b)))

I wanted to simplify a chain of (not (not ...)) so I extended the language to deal with contexts and defined a reduction relation to simplify the not:

(define-extended-language B1 B0
  (C (not C) hole)
  (BV T F))

(define red0
  (reduction-relation
   B1
   (--> (in-hole C (not T)) (in-hole C F))
   (--> (in-hole C (not F)) (in-hole C T))))

Now I wanted to extend my language to boolean equations and to allow not-simplification at each side of the equation, so I defined:

(define-extended-language B2 B1
  (E (= C b) (= b C)))

hoping that:

(define red1
  (extend-reduction-relation red0 B2))

will do the thing. But no: red1 can reduce (not (not (not F))))) but not (= (not T) F)))

Am I doing something really silly here?

1

There are 1 best solutions below

0
On

The problem with red1 is that it only contains the rules of red0 which use the limited context C. To make it work as expected you could either add the old rules modified to use E or make somehow the final extended context have the name C. One not very tedious approach could be:

(define-language L)

(define R
  (reduction-relation L
    (--> (not T) F)
    (--> (not F) T)))

(define-language LB
  (b T F (not b))
  (C (compatible-closure-context b)))

(define RB (context-closure R LB C))

(define-extended-language LBE LB
  (e (= b b))
  (C .... (compatible-closure-context e #:wrt b)))

(define RBE (extend-reduction-relation RB LBE))

Note that this doesn't work in some older versions.

Two sources of useful information are this tutorial and of course the redex reference.