Skip to content

Instantly share code, notes, and snippets.

View righ1113's full-sized avatar
🏠
Working from home

righ1113

🏠
Working from home
View GitHub Profile
@righ1113
righ1113 / Isort.idr
Created January 26, 2019 12:40
挿入ソートの証明
module Isort
-- > idris -p base
import Syntax.PreorderReasoning
%default total
%hide sorted
sorted : List Nat -> Bool
@righ1113
righ1113 / CoInductive.idr
Created February 3, 2019 04:30
余帰納?
module CoInductive
%default total
-- 性質Q
codata Q : Stream Nat -> Type where
Qcons : (x:Nat) -> Q xs -> Q (x::xs)
isQ : (xs:Stream Nat) -> Q xs
@righ1113
righ1113 / judgeFiniteUnfoldr.md
Last active April 16, 2019 00:29
unfoldrが有限項か判定したい

judge finite unfoldr by Idris

unfoldrが有限項か判定したい

原理的に無理なのか

/libs/contrib/Data/CoList.idr
CoListunfoldrは以下のように実装されている。

@righ1113
righ1113 / rev_rev_id.lean
Last active July 5, 2023 19:58
リストを2回逆順にすると元に戻る in Lean
open list (hiding reverse)
#check 1
#reduce head [0, 1, 2, 3]
variable {T : Type}
def snoc : list T → T → list T
@righ1113
righ1113 / multiOf3.lean
Last active July 5, 2023 19:59
各桁の和が3の倍数なら、元の数も3の倍数 in Lean
open nat
#check succ
-- isMm3 y x : -3y + x
inductive Mm3 (y : ℕ)
| isMm3 : ℕ → Mm3
open Mm3
#check isMm3 3 5
@righ1113
righ1113 / MultiOf3.idr
Last active July 5, 2023 19:59
各桁の和が3の倍数な整数は3の倍数 in Idris
module MultiOf3
%default total
-- isMm3 y x : -3y + x
data Mm3 : (y : Nat) -> Type where
isMm3 : (y : Nat) -> Nat -> Mm3 y
-- 3の倍数か判定する
@righ1113
righ1113 / CosineFormula.idr
Last active July 5, 2023 19:59
ベクトルを用いた余弦定理の証明 in Idris, Lean
module CosineFormula
-- > idris -p base
import Syntax.PreorderReasoning
%default total
%hide Language.Reflection.P
%hide cos
@righ1113
righ1113 / zdk.egi
Last active November 17, 2023 01:47
『ズンドコキヨシ with パターンマッチ指向言語Egison』をnew syntaxで
--
-- zundoko kiyoshi
--
-- $ egison 4.1.3
-- > loadFile "zdk.egi"
-- > zdk
--
-- Codes
@righ1113
righ1113 / MagicSquare.hs
Last active September 26, 2019 14:38
3*3魔方陣は1種類しか存在しない
module MagicSquare where
import Data.List (permutations)
{--
3*3 Magic square
a b c
d e f
@righ1113
righ1113 / EightPuzzle.hs
Last active July 5, 2023 19:58
8パズルは181440通り in Egison, Haskell
module EightPuzzle where
import Data.List (permutations)
-- 参考記事:https://mathtrain.jp/8puzzle
{--
8 puzzle
1 2 3