<commit_before>#lang racket
(require redex)

(reduction-steps-cutoff 100)

(define-language threads
  (p ((store (x v) ...) (threads e ...)))
  (e (set! x e)
     (let ((x e)) e)
     (e e)
     x
     v
     (+ e e))
  (v (lambda (x) e)
     number)
  (x variable)
  (pc ((store (x v) ...) tc))
  (tc (threads e ... ec e ...))
  (ec (ec e) (v ec) (set! variable ec) (let ((x ec)) e) (+ ec e) (+ v ec) hole))

(define reductions
  (reduction-relation
   threads
   (--> (in-hole pc_1 (+ number_1 number_2))
        (in-hole pc_1 ,(+ (term number_1) (term number_2)))
        sum)
   
   (--> ((store
             (name befores (x v)) ...
           (x_i v_i)
           (name afters (x v)) ...)
         (in-hole tc_1 x_i))
        ((store 
             befores ... 
           (x_i v_i)
           afters ...)
         (in-hole tc_1 v_i))
        deref)
   
   (--> ((store (x_1 v_1) ... (x_i v) (x_2 v_2) ...)
         (in-hole tc_1 (set! x_i v_new)))
        ((store (x_1 v_1) ... (x_i v_new) (x_2 v_2) ...)
         (in-hole tc_1 v_new))
        set!)
   
   (--> (in-hole pc_1 ((lambda (x_1) e_1) v_1))
        (in-hole pc_1 ,(substitute (term x_1) (term v_1) (term e_1)))
        app)
   
   (--> ((store (name the-store any) ...)
         (in-hole tc_1 (let ((x_1 v_1)) e_1)))
        (term-let ((new-x (variable-not-in (term (the-store ...)) (term x_1))))
          (term 
           ((store the-store ... (new-x v_1))
            (in-hole tc_1 ,(substitute (term x_1) (term new-x) (term e_1))))))
        let)))

(define (substitute . x) (error 'substitute "~s" x))

(define (run es) (traces threads reductions `((store) (threads ,@es))))
(provide run)

(define (count x) 
  (match x
    [`(set! ,x ,e) (+ 1 (count e))]<commit_msg>Fixes a bug in the deref rule<commit_after>#lang racket
(require redex)

(reduction-steps-cutoff 100)

(define-language threads
  (p ((store (x v) ...) (threads e ...)))
  (e (set! x e)
     (let ((x e)) e)
     (e e)
     x
     v
     (+ e e))
  (v (lambda (x) e)
     number)
  (x variable)
  (pc ((store (x v) ...) tc))
  (tc (threads e ... ec e ...))
  (ec (ec e) (v ec) (set! variable ec) (let ((x ec)) e) (+ ec e) (+ v ec) hole))

(define reductions
  (reduction-relation
   threads
   (--> (in-hole pc_1 (+ number_1 number_2))
        (in-hole pc_1 ,(+ (term number_1) (term number_2)))
        sum)
   
   (--> ((store
          (name befores (x_0 v_0)) ...
          (x_i v_i)
          (name afters (x_i+1 v_i+1)) ...)
         (in-hole tc_1 x_i))
        ((store 
          befores ... 
          (x_i v_i)
          afters ...)
         (in-hole tc_1 v_i))
        deref)
   
   (--> ((store (x_1 v_1) ... (x_i v) (x_2 v_2) ...)
         (in-hole tc_1 (set! x_i v_new)))
        ((store (x_1 v_1) ... (x_i v_new) (x_2 v_2) ...)
         (in-hole tc_1 v_new))
        set!)
   
   (--> (in-hole pc_1 ((lambda (x_1) e_1) v_1))
        (in-hole pc_1 ,(substitute (term x_1) (term v_1) (term e_1)))
        app)
   
   (--> ((store (name the-store any) ...)
         (in-hole tc_1 (let ((x_1 v_1)) e_1)))
        (term-let ((new-x (variable-not-in (term (the-store ...)) (term x_1))))
          (term 
           ((store the-store ... (new-x v_1))
            (in-hole tc_1 ,(substitute (term x_1) (term new-x) (term e_1))))))
        let)))

(define (substitute . x) (error 'substitute "~s" x))

(define (run es) (traces threads reductions `((store) (threads ,@es))))
(provide run)

(define (count x) 
  (match x
    [`(set! ,x ,e) (+ 1 (count e))]
{'fraction_non_alphanumeric': 0.2035448827901658, 'fraction_numerical': 0.023441966838193252, 'mean_word_length': 1.770387965162312, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7230405', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1419, 'n_words': 405}