Last active
May 21, 2024 12:59
-
-
Save ncfavier/83d8967700a7f86524b480ac6186c23f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS --cubical #-} | |
open import Cubical.Data.Int | |
open import Cubical.Data.Int.Divisibility | |
open import Cubical.Data.Nat | |
open import Cubical.Foundations.Everything | |
open import Data.List | |
open import Data.List.NonEmpty as List⁺ | |
data Vertex : Type where | |
a b c : Vertex | |
data Triangle : Type where | |
inc : Vertex → Triangle | |
ab : inc a ≡ inc b | |
bc : inc b ≡ inc c | |
ca : inc c ≡ inc a | |
infix 40 _⇒_ | |
_⇒_ : (x y : Vertex) → inc x ≡ inc y | |
a ⇒ a = refl | |
a ⇒ b = ab | |
a ⇒ c = sym ca | |
b ⇒ a = sym ab | |
b ⇒ b = refl | |
b ⇒ c = bc | |
c ⇒ a = ca | |
c ⇒ b = sym bc | |
c ⇒ c = refl | |
walk : (s : List⁺ Vertex) → inc (List⁺.head s) ≡ inc (List⁺.last s) | |
walk s with snocView s | |
... | ys ∷ʳ′ y = go ys | |
where | |
go : (ys : List Vertex) → inc (List⁺.head (ys List⁺.∷ʳ y)) ≡ inc y | |
go [] = refl | |
go (v ∷ vs) = v ⇒ _ ∙ go vs | |
Cover : Triangle → Type | |
Cover (inc _) = ℤ | |
Cover (ab i) = sucPathℤ i | |
Cover (bc i) = sucPathℤ i | |
Cover (ca i) = sucPathℤ i | |
-- Division towards 0 | |
div3 : ℤ → ℤ | |
div3 n@(pos _) = quotRem 3 n (snotz ∘ injPos) .QuotRem.div | |
div3 n@(negsuc _) = - quotRem 3 (- n) (snotz ∘ injPos) .QuotRem.div | |
degree : List⁺ Vertex → ℤ | |
degree s = div3 (subst Cover (walk s) 0) | |
open import Agda.Builtin.Char | |
open import Agda.Builtin.FromString | |
open import Agda.Builtin.String | |
open import Data.Bool | |
open import Data.List.Effectful as List | |
open import Data.Maybe | |
open import Data.Maybe.Effectful as Maybe | |
parse1 : Char → Maybe Vertex | |
parse1 'a' = just a | |
parse1 'b' = just b | |
parse1 'c' = just c | |
parse1 _ = nothing | |
parse : List Char → Maybe (List⁺ Vertex) | |
parse s = mapA parse1 s >>= fromList | |
where open List.TraversableA Maybe.applicative | |
instance | |
IsString-vertices : IsString (List⁺ Vertex) | |
IsString-vertices .IsString.Constraint s = T (is-just (parse (primStringToList s))) | |
IsString-vertices .IsString.fromString s ⦃ j ⦄ = to-witness-T _ j | |
_ : degree "abca" ≡ 1 | |
_ = refl | |
_ : degree "bcab" ≡ 1 | |
_ = refl | |
_ : degree "cabc" ≡ 1 | |
_ = refl | |
_ : degree "accbbbaa" ≡ -1 | |
_ = refl | |
_ : degree "abcacba" ≡ 0 | |
_ = refl | |
_ : degree "abcabcab" ≡ 2 | |
_ = refl | |
_ : degree "abababababababcababababababab" ≡ 1 | |
_ = refl | |
_ : degree "abcbca" ≡ 1 | |
_ = refl | |
_ : degree "abcabcacb" ≡ 1 | |
_ = refl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{pgfplots} | |
\usepackage{xcolor} | |
\pgfplotsset{compat=1.17} | |
\usepgfplotslibrary{colormaps,fillbetween} | |
\definecolor{color1}{HTML}{f700ff} | |
\definecolor{color2}{HTML}{9012ff} | |
\definecolor{color3}{HTML}{12ffe8} | |
\begin{document} | |
\begin{tikzpicture} | |
\begin{axis} | |
[ | |
hide axis, | |
colormap/cool, | |
view={5}{40}, | |
z post scale=4, | |
] | |
\addplot3[ | |
->, | |
color=color1, | |
thick, | |
domain=0:3, | |
samples = 10, | |
samples y=0, | |
] ({sin(deg(x*2*pi))}, {cos(deg(x*2*pi))}, {3*x}); | |
\addplot3[ | |
->, | |
color=color2, | |
thick, | |
domain=0:3, | |
samples = 10, | |
samples y=0, | |
] ({sin(deg(x*2*pi))}, {cos(deg(x*2*pi))}, {3*x+1}); | |
\addplot3[ | |
->, | |
color=color3, | |
thick, | |
domain=0:3, | |
samples = 10, | |
samples y=0, | |
] ({sin(deg(x*2*pi))}, {cos(deg(x*2*pi))}, {3*x+2}); | |
\addplot3[ | |
thick, | |
dashed, | |
domain=0:1, | |
samples = 4, | |
samples y=0, | |
] ({sin(deg(x*2*pi))}, {cos(deg(x*2*pi))}, {5}); | |
\end{axis} | |
\end{tikzpicture} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment