Skip to content

Instantly share code, notes, and snippets.

@zitterbewegung
Last active September 18, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zitterbewegung/4152b322eef5ecccdcf3502e8220844b to your computer and use it in GitHub Desktop.
Save zitterbewegung/4152b322eef5ecccdcf3502e8220844b to your computer and use it in GitHub Desktop.
Partial prototype of a knot theory POW.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env racket
#lang typed/racket #:with-refinements
;(require graph)
;raco pkg install graph
(require typed/racket/date)
(require racket/sequence)
(require typed/racket/date)
(require math/array)
(require math/matrix)
(require typed/racket/unit)
(require pfds/queue/hood-melville)
(define trefoil (array #[#[00 02 01 00]
#[02 10 09 01]
#[03 09 04 06]
#[00 03 05 04]] : Integer))
(define simple-unknot (array #[#[02 01 ]
#[03 04]] : Integer))
;TODO It must have a dimention of N by M
;TODO It must be ambiend isotopic to the knot $K$ that we send
;TODO It must have a set of operations $O$ of cardinality $O_n$
;DONE It must have a crossing number $C$
;TODO use a queue (set? ) and a set of mosaic moves to implement the checking of validity of a set of moves.
;source is optional
; Knot table
;KNOTS are specified as a $N * M$ matrix corresponding to $0-18$ that maps to the set of mosaic tiles $T_0$ to $T_n$
;(define culprit (matrix-graph [[0 3 8 #f -4]
; [#f 0 #f 1 7]
; [#f 4 0 #f #f]
; [2 #f -5 0 #f]
; [#f #f #f 6 0]]))
; https://docs.racket-lang.org/math/matrix_types.html#%28form._%28%28lib._math%2Fmatrix..rkt%29._.Matrix%29%29
(struct braidcoin ([source_knot : (Matrix Integer)]
[target_knot : (Matrix Integer)]
[crossing_number : (Refine [n : Integer] (> n 0))]
[dimention : (Refine [n : Integer] (> n 0))]
[timestamp : date])
#:prefab)
(define unknot-trefoil (braidcoin trefoil simple-unknot 3 4 (current-date)))
(define unknot-unknot (braidcoin simple-unknot simple-unknot 3 4 (current-date)))
;* Header X-braidcoin: 0:SOURCE_KNOT:DESTINATION_KNOT:CROSSING_NUMBER:DIMENTION:OPERATION_COUNTER:DATE
;KNOTS are specified as a $N * M$ matrix corresponding to $0-18$ that maps to the set of mosaic tiles $T_0$ to $T_n$
(struct knot-operations ([queue : braidcoin]))
(: crossing-number (-> (Array Integer) Integer))
(define (crossing-number array)
;09 and 10 correspond to over and under crossing
(array-count (λ: ([x : Integer]) (or (equal? x 10) (equal? x 09))) array))
(: crossing-number-test (-> braidcoin Boolean))
(define (crossing-number-test bc)
;DONE It must have a crossing number $C$
(if (equal? (crossing-number (braidcoin-source_knot bc))
(crossing-number (braidcoin-target_knot bc)))
#t
#f))
;(struct knot-operations braidcoin)
;(define (expansion move braidcoin)
; #t)
;(define (reidmeister-1 braidcoin)
; #t)
(define-type Tree (U leaf node))
(struct leaf ([source_knot : (Matrix Integer)]
[target_knot : (Matrix Integer)]
[crossing_number : (Refine [n : Integer] (> n 0))]
[dimention : (Refine [n : Integer] (> n 0))]
[timestamp : date])
#:prefab)
(struct node ([left : Tree] [right : Tree]))
(: tree-height (-> Tree Integer))
(define (tree-height t)
(cond [(leaf? t) 1]
[else (max (+ 1 (tree-height (node-left t)))
(+ 1 (tree-height (node-right t))))]))
(define unknot-trefoil-leaf (leaf trefoil simple-unknot 3 4 (current-date)))
(define unknot-unknot-leaf (leaf simple-unknot simple-unknot 3 4 (current-date)))
(tree-height (node unknot-unknot-leaf unknot-trefoil-leaf))
(node unknot-unknot-leaf unknot-trefoil-leaf)
(tree-height (node unknot-unknot-leaf unknot-trefoil-leaf))
;(: test-fail (-> Tree Boolean))
;(define (tree-height t)
; (cond [eqv? (crossing-number (node-left t)) (node-right t) #f]
; [else (max (+ 1 (tree-height (node-left t)))
; (+ 1 (tree-height (node-right t))))]))
;(struct queue)
;(struct chain)
;(struct current_transactions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment