From 6b0d09c7d92e8dcb48532ce9db552c6318924f2e Mon Sep 17 00:00:00 2001 From: "William J. Bowman" Date: Fri, 20 Feb 2015 18:22:04 -0500 Subject: [PATCH] Redex 1.6 enables caching of judgment forms! * Judgment form caching enables running test suite in seconds instead of days. * Fixed numerous bugs after properly exercising the oll/stlc examples. --- README.md | 3 ++- oll.rkt | 7 ++++--- redex-curnel.rkt | 2 +- stlc.rkt | 13 +++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ea70ba9..2bb701a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ cur (plural curs) Getting started =============== -Don't actually try to run anything. The type-checker may be exponential, +Requires redex-lib version 1.6 if you want answer in a reasonable amount +of time. Otherwise, the type-checker may require exponential time or worse. Open up `stlc.rkt` to see an example of what advanced meta-programming can let you do. diff --git a/oll.rkt b/oll.rkt index b80f6a0..89366bd 100644 --- a/oll.rkt +++ b/oll.rkt @@ -54,10 +54,11 @@ (with-output-to-file (syntax->datum #'latex-file) (thunk (format "\\fbox{$~a$}$~n$\\begin{mathpar}~n~a~n\end{mathpar}$$" + (syntax->datum #'(n types* ...)) (string-trim (for/fold ([str ""]) - ([rule (syntax->datum #'(rules.latex ...))]) - (format "~a~a\\and~n" rule)) + ([rule (attribute rules.latex)]) + (format "~a~a\\and~n" str rule)) "\\and" #:left? #f))) #:exists 'append)) @@ -311,7 +312,7 @@ (begin (coq-lift-top-level (format "Inductive ~a : ~a :=~a." - (syntax-e #'n) + (sanitize-id (format "~a" (syntax-e #'n))) (output-coq #'t) (for/fold ([strs ""]) ([clause (syntax->list #'((x* : t*) ...))]) diff --git a/redex-curnel.rkt b/redex-curnel.rkt index 6ba7c2d..da1e3e4 100644 --- a/redex-curnel.rkt +++ b/redex-curnel.rkt @@ -47,7 +47,7 @@ (check-true (t? (term (λ (x_0 : (Unv 0)) x_0))))) ;; 'A' - ;; Universes + ;; (Unv 0)s of Universes ;; Replace with sub-typing (define-judgment-form cicL #:mode (unv-ok I O) diff --git a/stlc.rkt b/stlc.rkt index 6117061..9616a33 100644 --- a/stlc.rkt +++ b/stlc.rkt @@ -15,17 +15,16 @@ ;; TODO: Abstract this over stlc-type, and provide from in OLL (data gamma : Type (emp-gamma : gamma) - (ext-gamma : (->* gamma var stlc-type gamma))) + (extend-gamma : (->* gamma var stlc-type gamma))) (define-rec (lookup-gamma (g : gamma) (x : var) : (maybe stlc-type)) (case* g [emp-gamma (none stlc-type)] - [(ext-gamma (g1 : gamma) (v1 : var) (t1 : stlc-type)) + [(extend-gamma (g1 : gamma) (v1 : var) (t1 : stlc-type)) (if (var-equal? v1 x) (some stlc-type t1) (lookup-gamma g1 x))])) - (define-relation (has-type gamma stlc-term stlc-type) #:output-coq "stlc.v" #:output-latex "stlc.tex" @@ -41,7 +40,7 @@ ------------------------ T-False (has-type g (stlc-val-->-stlc-term stlc-false) stlc-boolty)] - [(g : gamma) (x : var) (t : style-type) + [(g : gamma) (x : var) (t : stlc-type) (== (maybe stlc-type) (lookup-gamma g x) (some stlc-type t)) ------------------------ T-Var (has-type g (var-->-stlc-term x) t)] @@ -55,9 +54,11 @@ [(g : gamma) (e1 : stlc-term) (e2 : stlc-term) (t1 : stlc-type) (t2 : stlc-type) + (t : stlc-type) + (x : var) (y : var) (has-type g e1 (stlc-* t1 t2)) - (has-type (extend-gamma (extend-gamma g x t1) t y2) e2 t) - ---------------------- T-Pair + (has-type (extend-gamma (extend-gamma g x t1) y t2) e2 t) + ---------------------- T-Let (has-type g (stlc-let x y e1 e2) t)] [(g : gamma) (e1 : stlc-term) (t1 : stlc-type) (t2 : stlc-type) (x : var)