Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define-extended-judgment-form should replace rules with same name #192

Open
dvanhorn opened this issue Aug 25, 2019 · 1 comment
Open

define-extended-judgment-form should replace rules with same name #192

dvanhorn opened this issue Aug 25, 2019 · 1 comment

Comments

@dvanhorn
Copy link
Member

I was surprised to discover that define-extended-judgment-form does not do something similar to extend-reduction-relation when an extension names a rule the same as the underlying relation, i.e. replace that rule with the new one.

Here is a concrete example:

#lang racket
(require redex/reduction-semantics)

(define-language A
  (v ::= integer))

(define-extended-language B A
  (v ::= .... boolean))

(define-judgment-form A
  #:mode (valA I)
  #:contract (valA v)
  [---- id
   (valA v)])

(define-extended-judgment-form B valA
  #:mode (valB I)
  #:contract (valB v)
  [---- id
   (valB boolean)])

(judgment-holds (valB 4))  ;; should produce #f, id rule replaced
(judgment-holds (valB #t)) ;; should produce #t

Being able to do this is critical when you want to extend "helper" judgments by replacing the original rule with a similar rule that use the helper for the extended language.

For example:

#lang racket
(require redex/reduction-semantics)

(define-language A
  (v ::= integer))

(define-extended-language B A
  (v ::= .... boolean))

(define-judgment-form A
  #:mode (valA I)
  #:contract (valA v)
  [(helpA v)
   ---- id
   (valA v)])

(define-judgment-form A
  #:mode (helpA I)
  #:contract (helpA v)
  [-----
   (helpA v)])

(define-extended-judgment-form B valA
  #:mode (valB I)
  #:contract (valB v)  
  [(helpB boolean)
    ---- id
   (valB boolean)])

;; reinterpret helpA over B
(define-extended-judgment-form B helpA
  #:mode (helpB I)
  #:contract (helpB v))

(judgment-holds (helpB #t)) ;; #t, as expected

;; should produce #t, results in a contract violation
;; because helpA is still being used
(judgment-holds (valB #t)) 

It's also conceptually confusing since using define-extended-judgment-form lets you create two distinct rules with the same name, which is not allowed when you to write out the same judgment form without using extension.

@rfindler
Copy link
Member

rfindler commented Aug 25, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants