change stlc-sub's 'check' function to not assume
its input is well-typed
This commit is contained in:
parent
dea6e7c6e9
commit
1ecd4c0563
|
@ -5,7 +5,7 @@
|
|||
racket/list
|
||||
racket/match
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
(define the-error "the order of the variable clauses is swapped")
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -269,19 +269,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -268,19 +268,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
racket/list
|
||||
racket/match
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
(define the-error "substitutes rator into rand in application")
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -269,19 +269,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -268,19 +268,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -145,8 +145,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -266,19 +266,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -268,19 +268,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
racket/list
|
||||
racket/match
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
(define the-error "swaps to/from expressions when recurring inside a constant")
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -269,19 +269,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -268,19 +268,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -268,19 +268,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
racket/match
|
||||
racket/list
|
||||
racket/contract
|
||||
math/base)
|
||||
racket/bool)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
|
||||
(define x? (redex-match stlc x))
|
||||
|
||||
(define v? (redex-match stlc v))
|
||||
(define τ? (redex-match stlc τ))
|
||||
(define v? (redex-match? stlc v))
|
||||
(define τ? (redex-match? stlc τ))
|
||||
(define/contract (type-check M)
|
||||
(-> M? (or/c τ? #f))
|
||||
(define M-t (judgment-holds (typeof • ,M τ) τ))
|
||||
|
@ -268,19 +268,19 @@
|
|||
M]
|
||||
[#f #f]))))
|
||||
|
||||
;; check : (or/c #f term) -> boolean[#f = counterexample found!]
|
||||
(define (check term)
|
||||
(or (not term)
|
||||
(v? term)
|
||||
(let ([red-res (apply-reduction-relation red term)]
|
||||
[t-type (type-check term)])
|
||||
;; xxx should this also be t-type IMPLIES?
|
||||
(and
|
||||
(= (length red-res) 1)
|
||||
(let ([t-type (type-check term)])
|
||||
(implies
|
||||
t-type
|
||||
(let ([red-res (apply-reduction-relation red term)])
|
||||
(and (= (length red-res) 1)
|
||||
(let ([red-t (car red-res)])
|
||||
(or
|
||||
(equal? red-t "error")
|
||||
(or (equal? red-t "error")
|
||||
(let ([red-type (type-check red-t)])
|
||||
(equal? t-type red-type))))))))
|
||||
(equal? t-type red-type))))))))))
|
||||
|
||||
(define (generate-enum-term)
|
||||
(generate-term stlc M #:i-th (pick-an-index 0.0001)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user