{"text": "test3ok : Nat\ntest3ok = case (the Nat 1, the Nat 2) of\n (x, y) => x + y\n\ntest3ok' : Nat\ntest3ok' = case (1, 2) of\n (x, y) => x + y\n", "meta": {"hexsha": "ed44f6e8b1955016784cd953b696cde101aded1d", "size": 157, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/basic017/CaseInf.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/basic017/CaseInf.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/basic017/CaseInf.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 19.625, "max_line_length": 40, "alphanum_fraction": 0.4458598726, "num_tokens": 67, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.5495595844788906}} {"text": "> module FastSimpleProb.BasicOperations\n\n> import Data.List\n> import Data.So\n> import Syntax.PreorderReasoning\n\n> import FastSimpleProb.SimpleProb\n> import Double.Predicates\n> import NonNegDouble.NonNegDouble\n> import NonNegDouble.Constants\n> import NonNegDouble.BasicOperations\n> import NonNegDouble.Operations\n> import NonNegDouble.Properties\n> import NonNegDouble.Postulates\n> import List.Operations\n> import List.Properties\n> import Fun.Operations\n> import Pairs.Operations\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n> using implementation NumNonNegDouble\n> |||\n> mkSimpleProb : {A : Type} -> \n> (aps : List (A, NonNegDouble)) -> \n> {auto prf : Positive (toDouble (sumMapSnd aps))} ->\n> SimpleProb A\n> mkSimpleProb aps {prf} = MkSimpleProb aps prf\n\n\n> |||\n> toList : {A : Type} -> SimpleProb A -> List (A, NonNegDouble)\n> toList (MkSimpleProb aps _) = aps\n\n\n> |||\n> support : {A : Type} -> SimpleProb A -> List A\n> support = (map fst) . toList\n\n\n> using implementation NumNonNegDouble\n> |||\n> rescale : {A : Type} -> \n> (p : NonNegDouble) -> Positive (toDouble p) -> SimpleProb A -> SimpleProb A\n> rescale {A} p pp (MkSimpleProb aps psum) = MkSimpleProb aps' psum' where\n> aps' : List (A, NonNegDouble)\n> aps' = mapIdRightMult (aps, p)\n> psum' : Positive (toDouble (sumMapSnd aps'))\n> psum' = mapIdRightMultPreservesPositivity aps psum p pp\n\n\n> using implementation NumNonNegDouble\n> using implementation FractionalNonNegDouble\n> |||\n> normalize : {A : Type} -> \n> SimpleProb A -> SimpleProb A\n> normalize (MkSimpleProb aps psum) = \n> let p : NonNegDouble\n> = one / (sumMapSnd aps) in\n> let pp : Positive (toDouble p)\n> = divPreservesPositivity positiveOne psum in \n> rescale p pp (MkSimpleProb aps psum) \n\n\n> |||\n> weights : {A : Type} -> SimpleProb A -> List NonNegDouble\n> weights = (map snd) . toList\n\n\n> using implementation NumNonNegDouble\n> ||| 'weight sp a' is the weight of 'a' according to 'sp'\n> weight : {A : Type} -> (Eq A) => SimpleProb A -> A -> NonNegDouble\n> weight sp a = foldr f (fromInteger 0) (toList sp) where\n> f : (A, NonNegDouble) -> NonNegDouble -> NonNegDouble\n> f (a', w') w = if (a == a') then w + w' else w\n\n\n> using implementation FractionalNonNegDouble\n> ||| 'prob sp a' is the probability of 'a' according to 'sp'\n> prob : {A : Type} -> (Eq A) => SimpleProb A -> A -> NonNegDouble\n> prob sp a = (weight sp a) / (sum (weights sp))\n\n> {-\n> ||| 'prob sp a' is the probability of 'a' according to 'sp'\n> prob : {A : Type} -> (Eq A) => SimpleProb A -> A -> Double\n> prob sp a = fst pq / snd pq where\n> f : (A, Double) -> (Double, Double) -> (Double, Double)\n> f (a', p') (p, q) = if (a == a') then (p + p', q + p') else (p, q + p')\n> pq : (Double, Double)\n> pq = foldr f (0.0, 0.0) (toList sp)\n> -}\n\n\n> using implementation NumNonNegDouble\n> ||| Make a SimpleProb in which all elements of a list have the same \n> ||| probablility. If the list has no duplicates, this results in a\n> ||| uniform probability distribution\n> mkFlatSimpleProb : {A : Type} -> (as : List A) -> List.Operations.NonEmpty as -> SimpleProb A\n> mkFlatSimpleProb Nil prf = absurd prf\n> mkFlatSimpleProb {A} (a :: Nil) _ = MkSimpleProb [(a, one)] positiveOne\n> mkFlatSimpleProb {A} (a :: (a' :: as)) _ = MkSimpleProb aps prf where\n> ps' : SimpleProb A\n> ps' = assert_total (mkFlatSimpleProb (a' :: as) ())\n> aps : List (A, NonNegDouble)\n> aps = (a, one) :: (toList ps')\n> prf : Positive (toDouble (sumMapSnd aps))\n> prf = sumMapSndConsLemma1 a 1.0 positiveOne (MkLTE Oh) (toList ps')\n\n\n> using implementation NumNonNegDouble\n> using implementation EqNonNegDouble\n> |||\n> trim : {A : Type} -> (Eq A) => \n> SimpleProb A -> SimpleProb A\n> trim {A} (MkSimpleProb aps psum) = MkSimpleProb aps' psum' where\n> aps' : List (A, NonNegDouble)\n> aps' = discardBySndZeroEq aps\n> psum' : Positive (toDouble (sumMapSnd aps'))\n> psum' = replace {P = \\ X => Positive (toDouble X)} (sym (discardBySndZeroLemmaEq aps)) psum\n\n\n> using implementation ShowNonNegDouble\n> ||| \n> showlong : {A : Type} -> Show A => SimpleProb A -> String\n> showlong sp = showlong (toList sp) \n\n\n> {-\n\n> ---} \n\n\n\n\n", "meta": {"hexsha": "77c0e19d98298a4d8b4ef0140bd6453718fac45f", "size": 4421, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "FastSimpleProb/BasicOperations.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FastSimpleProb/BasicOperations.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FastSimpleProb/BasicOperations.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.0362318841, "max_line_length": 99, "alphanum_fraction": 0.6172811581, "num_tokens": 1405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6926419831347362, "lm_q1q2_score": 0.5493384788641246}} {"text": "import Data.Vect\n\nMkBig : Nat -> Type\nMkBig Z = Int\nMkBig (S k) = ((n ** Vect n Int), MkBig k)\n\nbigEx : (n : Nat) -> MkBig n\nbigEx Z = 94\nbigEx (S k) = ((2 ** [0,0]), bigEx k)\n\ndata VWrap : Type -> Type where\n MkVWrap : (0 n : Nat) -> Vect n a -> VWrap a\n\nexport\nMkBig' : Nat -> Type\nMkBig' Z = Int\nMkBig' (S k) = (VWrap Int, MkBig' k)\n\nnamespace Foo\n public\n export\n bigEx' : (n : Nat) -> MkBig' n\n bigEx' Z = 94\n bigEx' (S k) = (MkVWrap 1 [0], bigEx' k)\n\neqBigs : bigEx 1000000 = bigEx 1000000\neqBigs = Refl\n\neqBigs' : bigEx' 800000 = bigEx' 800000\neqBigs' = Refl\n\n", "meta": {"hexsha": "b5167bbc4ab0c8b6e90e2c47f1ccd0656b5a7011", "size": 576, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/perf004/bigdpair.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/idris2/perf004/bigdpair.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/idris2/perf004/bigdpair.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.0, "max_line_length": 49, "alphanum_fraction": 0.5850694444, "num_tokens": 255, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.54930694810406}} {"text": "data Vect : Nat -> Type -> Type where\n Nil : Vect Z a\n (::) : a -> Vect k a -> Vect (S k) a\n\n%name Vect xs, ys, zs\n\nappend : Vect n a -> Vect m a -> Vect (n + m) a\nappend xs ys\n = case xs of\n foo => ?bar\n\ndata Foo a = MkFoo a | MkBar (a -> a)\n\nFunctor Foo where\n map f thing = ?baz\n", "meta": {"hexsha": "8e79c60833493c95e5c12d9287e74d51fef409e3", "size": 304, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/interactive003/IEdit.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/interactive003/IEdit.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/interactive003/IEdit.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 19.0, "max_line_length": 47, "alphanum_fraction": 0.5197368421, "num_tokens": 105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.5491304921593335}} {"text": "||| [specification](https://csrc.nist.gov/csrc/media/publications/fips/46/3/archive/1999-10-25/documents/fips46-3.pdf)\nmodule Data.Crypto.Encryption.Block.DEA\n\n-- import Control.Isomorphism\nimport Data.Bits\nimport Data.Fin\nimport Data.Vect\n\nimport Data.Crypto.Encryption\nimport Data.Crypto.Encryption.Block\nimport Data.Crypto.Util\n\n%default total\n%access private\n\n-- utility functions\n\ntrim : Bits (1 + n) -> Bits n\ntrim b = truncate (shiftRightLogical (intToBits 1) b)\n\n-- Plenty of places in the 3DES spec use 1-based indexes, where we would like\n-- 0-based indexes. So we embed the same numbers from the spec (for easy\n-- eyeball-checking), then use this to correct the difference.\noffByOne : Fin (S (S n)) -> Fin (S n)\noffByOne FZ = FZ\noffByOne (FS y) = y\n\nselectBits : Vect m (Fin n) -> Bits n -> Bits m\nselectBits positions input = foldl (\\acc, b => shiftLeft acc (intToBits 1) `and` b)\n (intToBits 0)\n (map (\\x => intToBits (if getBit x input then 1 else 0)) positions)\n\n||| The initial permutation\nIP : Bits 64 -> Bits 64\nIP = selectBits (map offByOne [58, 50, 42, 34, 26, 18, 10, 2,\n 60, 52, 44, 36, 28, 20, 12, 4,\n 62, 54, 46, 38, 30, 22, 14, 6,\n 64, 56, 48, 40, 32, 24, 16, 8,\n 57, 49, 41, 33, 25, 17, 9, 1,\n 59, 51, 43, 35, 27, 19, 11, 3,\n 61, 53, 45, 37, 29, 21, 13, 5,\n 63, 55, 47, 39, 31, 23, 15, 7])\n\ninverseIP : Bits 64 -> Bits 64\ninverseIP = selectBits (map offByOne [40, 8, 48, 16, 56, 24, 64, 32,\n 39, 7, 47, 15, 55, 23, 63, 31,\n 38, 6, 46, 14, 54, 22, 62, 30,\n 37, 5, 45, 13, 53, 21, 61, 29,\n 36, 4, 44, 12, 52, 20, 60, 28,\n 35, 3, 43, 11, 51, 19, 59, 27,\n 34, 2, 42, 10, 50, 18, 58, 26,\n 33, 1, 41, 9, 49, 17, 57, 25])\n\n-- TODO: prove this\n-- permutation : Iso (Bits 64) (Bits 64)\n-- permutation = MkIso IP IP'\n\nE : Bits 32 -> Bits 48\nE = selectBits (map offByOne [32, 1, 2, 3, 4, 5,\n 4, 5, 6, 7, 8, 9,\n 8, 9, 10, 11, 12, 13,\n 12, 13, 14, 15, 16, 17,\n 16, 17, 18, 19, 20, 21,\n 20, 21, 22, 23, 24, 25,\n 24, 25, 26, 27, 28, 29,\n 28, 29, 30, 31, 32, 1])\n\nP : Bits 32 -> Bits 32\nP = selectBits (map offByOne [16, 7, 20, 21,\n 29, 12, 28, 17,\n 1, 15, 23, 26,\n 5, 18, 31, 10,\n 2, 8, 24, 14,\n 32, 27, 3, 9,\n 19, 13, 30, 6,\n 22, 11, 4, 25])\n\n-- TODO: Generalize from `16 in `Fin 16` and `nextPow2 16` to `n`.\nselect : Vect 4 (Vect 16 (Fin 16)) -> Bits 6 -> Bits (nextPow2 16)\nselect table bits =\n let row = bitsToFin (truncate {m=4} (or (shiftRightLogical (cast 5) (and bits (intToBits 32))) (and bits (intToBits 1))))\n col = bitsToFin (truncate {m=2} (shiftRightLogical (cast 1) (and bits (intToBits 30))))\n in finToBits (index col (index row table))\n\nS : Vect 8 (Bits 6 -> Bits 4)\nS = map select\n -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n [[[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7],\n [ 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8],\n [ 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0],\n [15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]],\n [[15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10],\n [ 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5],\n [ 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15],\n [13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9]],\n [[10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8],\n [13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1],\n [13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7],\n [ 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12]],\n [[ 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15],\n [13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9],\n [10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4],\n [ 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14]],\n [[ 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9],\n [14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6],\n [ 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14],\n [11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3]],\n [[12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11],\n [10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8],\n [ 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6],\n [ 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13]],\n [[ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1],\n [13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6],\n [ 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2],\n [ 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12]],\n [[13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7],\n [ 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2],\n [ 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8],\n [ 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11]]]\n\nf : Bits 32 -> Bits 48 -> Bits 32\nf R K = P (concat (zipWith apply S (partition (E R `xor` K))))\n\niteration : (Bits 32, Bits 32) -> Bits 48 -> (Bits 32, Bits 32)\niteration (L, R) K = (R, L `xor` f R K)\n\ncentralDEA : Bits 64 -> Vect 16 (Bits 48) -> Bits 64\ncentralDEA input keys =\n let [L, R] = the (Vect 2 (Bits 32)) (partition (IP input))\n in inverseIP (uncurry (flip append) (foldl iteration (L, R) keys))\n\n||| permuted choice\nPC1 : Bits 64 -> Bits 56\nPC1 = selectBits (map offByOne [57, 49, 41, 33, 25, 17, 9,\n 1, 58, 50, 42, 34, 26, 18,\n 10, 2, 59, 51, 43, 35, 27,\n 19, 11, 3, 60, 52, 44, 36,\n 63, 55, 47, 39, 31, 23, 15,\n 7, 62, 54, 46, 38, 30, 22,\n 14, 6, 61, 53, 45, 37, 29,\n 21, 13, 5, 28, 20, 12, 4])\n\n||| permuted choice\nPC2 : Bits 56 -> Bits 48\nPC2 = selectBits (map offByOne [14, 17, 11, 24, 1, 5,\n 3, 28, 15, 6, 21, 10,\n 23, 19, 12, 4, 26, 8,\n 16, 7, 27, 20, 13, 2,\n 41, 52, 31, 37, 47, 55,\n 30, 40, 51, 45, 33, 48,\n 44, 49, 39, 56, 34, 53,\n 46, 42, 50, 36, 29, 32])\n\npublic export\nDEAKey : Type\nDEAKey = Bits 64\n\n||| INSECURE!\npublic export\ndata DataEncryptionAlgorithm : Type where\n DEA : DEAKey -> DataEncryptionAlgorithm\n\n\n||| key schedule\nKS : DEAKey -> Vect 16 (Bits 48)\nKS key = map PC2\n (tail (scanl (\\prevKey, shift =>\n concat (map (rotateLeft shift)\n (partition {m=28} {n=2} prevKey)))\n (PC1 key)\n [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]))\n\n\nimplementation BlockCipher DataEncryptionAlgorithm 64 0 where\n encryptBlock (DEA key) block = centralDEA block (KS key)\n decryptBlock (DEA key) block = centralDEA block (reverse (KS key))\n", "meta": {"hexsha": "318b20747e4cde2ea0c09c0b4b4576151def1721", "size": 8266, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Crypto/Encryption/Block/DEA.idr", "max_stars_repo_name": "idris-hackers/idris-crypto", "max_stars_repo_head_hexsha": "0fb69b76e399f2fa72f338e410504323751843e7", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 79, "max_stars_repo_stars_event_min_datetime": "2015-01-11T20:37:05.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T07:41:27.000Z", "max_issues_repo_path": "src/Data/Crypto/Encryption/Block/DEA.idr", "max_issues_repo_name": "idris-hackers/idris-crypto", "max_issues_repo_head_hexsha": "0fb69b76e399f2fa72f338e410504323751843e7", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-09-10T20:32:40.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-18T16:27:23.000Z", "max_forks_repo_path": "src/Data/Crypto/Encryption/Block/DEA.idr", "max_forks_repo_name": "idris-hackers/idris-crypto", "max_forks_repo_head_hexsha": "0fb69b76e399f2fa72f338e410504323751843e7", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2015-04-23T23:09:48.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-10T22:30:23.000Z", "avg_line_length": 46.7005649718, "max_line_length": 123, "alphanum_fraction": 0.3998306315, "num_tokens": 3964, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.851952809486198, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5488493894126077}} {"text": "module Main\n\ndata Ty = TyInt | TyBool | TyFun Ty Ty\n\ninterpTy : Ty -> Type\ninterpTy TyInt = Int\ninterpTy TyBool = Bool\ninterpTy (TyFun s t) = interpTy s -> interpTy t\n\nusing (G : Vect n Ty)\n\n data Env : Vect n Ty -> Type where\n Nil : Env Nil\n (::) : interpTy a -> Env G -> Env (a :: G)\n\n data HasType : (i : Fin n) -> Vect n Ty -> Ty -> Type where\n stop : HasType fZ (t :: G) t\n pop : HasType k G t -> HasType (fS k) (u :: G) t\n\n lookup : HasType i G t -> Env G -> interpTy t\n lookup stop (x :: xs) = x\n lookup (pop k) (x :: xs) = lookup k xs\n\n data Expr : Vect n Ty -> Ty -> Type where\n Var : HasType i G t -> Expr G t\n Val : (x : Int) -> Expr G TyInt\n Lam : Expr (a :: G) t -> Expr G (TyFun a t)\n App : Expr G (TyFun a t) -> Expr G a -> Expr G t\n Op : (interpTy a -> interpTy b -> interpTy c) -> Expr G a -> Expr G b ->\n Expr G c\n If : Expr G TyBool -> Expr G a -> Expr G a -> Expr G a\n Bind : Expr G a -> (interpTy a -> Expr G b) -> Expr G b\n\n dsl expr\n lambda = Lam\n variable = Var\n index_first = stop\n index_next = pop\n\n (<$>) : |(f : Expr G (TyFun a t)) -> Expr G a -> Expr G t\n (<$>) = \\f, a => App f a\n\n pure : Expr G a -> Expr G a\n pure = id\n\n syntax IF [x] THEN [t] ELSE [e] = If x t e\n\n (==) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool\n (==) = Op (==)\n\n (<) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool\n (<) = Op (<)\n\n instance Num (Expr G TyInt) where\n (+) x y = Op (+) x y\n (-) x y = Op (-) x y\n (*) x y = Op (*) x y\n\n abs x = IF (x < 0) THEN (-x) ELSE x\n\n fromInteger = Val . fromInteger\n\n interp : Env G -> {static} Expr G t -> interpTy t\n interp env (Var i) = lookup i env\n interp env (Val x) = x\n interp env (Lam sc) = \\x => interp (x :: env) sc\n interp env (App f s) = (interp env f) (interp env s)\n interp env (Op op x y) = op (interp env x) (interp env y)\n interp env (If x t e) = if (interp env x) then (interp env t) else (interp env e)\n interp env (Bind v f) = interp env (f (interp env v))\n\n eId : Expr G (TyFun TyInt TyInt)\n eId = expr (\\x => x)\n\n eTEST : Expr G (TyFun TyInt (TyFun TyInt TyInt))\n eTEST = expr (\\x, y => y)\n\n eAdd : Expr G (TyFun TyInt (TyFun TyInt TyInt))\n eAdd = expr (\\x, y => Op (+) x y)\n\n eDouble : Expr G (TyFun TyInt TyInt)\n eDouble = expr (\\x => App (App eAdd x) (Var stop))\n\n eFac : Expr G (TyFun TyInt TyInt)\n eFac = expr (\\x => IF x == 0 THEN 1 ELSE [| eFac (x - 1) |] * x)\n\ntestFac : Int\ntestFac = interp [] eFac 4\n\nmain : IO ()\nmain = print testFac\n\n\n", "meta": {"hexsha": "f0e96d884fd7cb6ebed6a555b8f9873418a514db", "size": 2591, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "vendor/bundle/ruby/2.0.0/gems/pygments.rb-0.6.1/vendor/pygments-main/tests/examplefiles/test.idr", "max_stars_repo_name": "agent010101/agent010101.github.io", "max_stars_repo_head_hexsha": "b8bf8ef1bc30999223deb95506b0685b4ec8449a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 23, "max_stars_repo_stars_event_min_datetime": "2015-02-17T18:34:15.000Z", "max_stars_repo_stars_event_max_datetime": "2017-08-25T17:11:52.000Z", "max_issues_repo_path": "vendor/bundle/ruby/2.0.0/gems/pygments.rb-0.6.1/vendor/pygments-main/tests/examplefiles/test.idr", "max_issues_repo_name": "agent010101/agent010101.github.io", "max_issues_repo_head_hexsha": "b8bf8ef1bc30999223deb95506b0685b4ec8449a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 34, "max_issues_repo_issues_event_min_datetime": "2015-05-12T17:54:27.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-28T14:30:46.000Z", "max_forks_repo_path": "vendor/bundle/ruby/2.0.0/gems/pygments.rb-0.6.1/vendor/pygments-main/tests/examplefiles/test.idr", "max_forks_repo_name": "agent010101/agent010101.github.io", "max_forks_repo_head_hexsha": "b8bf8ef1bc30999223deb95506b0685b4ec8449a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 16, "max_forks_repo_forks_event_min_datetime": "2015-02-06T20:43:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-14T10:05:12.000Z", "avg_line_length": 27.5638297872, "max_line_length": 84, "alphanum_fraction": 0.5283674257, "num_tokens": 932, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.5488220494418664}} {"text": "module Void\n\nimport Basic\n\n%default total\n\npublic export\ndata Void : Type where\n\npublic export\nVoidInduction : (0 p : Void -> Type) -> (0 x : Void) -> p x\nVoidInduction _ x impossible\n\npublic export\nVoidRecursion : (0 p : Type) -> (0 x : Void) -> p\nVoidRecursion p = VoidInduction (const p)\n\npublic export\nVoidInitial : (0 p : Type) -> (0 x : Void) -> p\nVoidInitial = VoidRecursion\n\npublic export\nIsEmpty : Type -> Type\nIsEmpty a = a -> Void\n\npublic export\nNeg : Type -> Type\nNeg = IsEmpty\n\n", "meta": {"hexsha": "a8826e5437e2acaf5598aeecc251e72ffb23b460", "size": 491, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Void.idr", "max_stars_repo_name": "Russoul/Idris2-HoTT", "max_stars_repo_head_hexsha": "0c11569ca8205caecd92e4cdb85fb7f10ca80454", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2021-01-17T05:44:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T09:36:13.000Z", "max_issues_repo_path": "src/Void.idr", "max_issues_repo_name": "Russoul/Idris2-HoTT", "max_issues_repo_head_hexsha": "0c11569ca8205caecd92e4cdb85fb7f10ca80454", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Void.idr", "max_forks_repo_name": "Russoul/Idris2-HoTT", "max_forks_repo_head_hexsha": "0c11569ca8205caecd92e4cdb85fb7f10ca80454", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.3666666667, "max_line_length": 59, "alphanum_fraction": 0.6802443992, "num_tokens": 146, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.548693554313276}} {"text": "{--\nCopyright 2021 Joel Berkeley\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n--}\n||| This module contains common library types.\nmodule Types\n\nimport public Data.Nat\nimport public Data.Vect\n\n||| Describes the shape of a `Tensor`. For example, a `Tensor` of `Double`s with contents\n||| `[[0, 1, 2], [3, 4, 5]]` has two elements in its outer-most axis, and each of those elements\n||| has three `Double`s in it, so this has shape [2, 3]. A `Tensor` can have axes of zero length,\n||| though the shape cannot be unambiguously inferred by visualising it. For example, `[[], []]`\n||| can have shape [2, 0], [2, 0, 5] or etc. A scalar `Tensor` has shape `[]`.\n|||\n||| The rank is the number of elements in the shape, or equivalently the number of axes.\npublic export 0\nShape : {0 rank: Nat} -> Type\nShape = Vect rank Nat\n\n||| An `Array shape` is either:\n||| \n||| * a single value of an implicitly inferred type `dtype` (for `shape` `[]`), or\n||| * an arbitrarily nested array of `Vect`s of such values (for any other `shape`)\n|||\n||| @shape The shape of this array.\npublic export 0\nArray : {0 dtype : Type} -> (0 shape : Shape) -> Type\nArray {dtype} [] = dtype\nArray {dtype} (d :: ds) = Vect d (Array ds {dtype=dtype})\n", "meta": {"hexsha": "4f046495cefc80d84e1c94644c8faee3874b0075", "size": 1691, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Types.idr", "max_stars_repo_name": "joelberkeley/spidr", "max_stars_repo_head_hexsha": "98cffe059ac5162a46942027658b6fe1dba5074d", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 18, "max_stars_repo_stars_event_min_datetime": "2020-11-21T00:57:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-09T18:18:43.000Z", "max_issues_repo_path": "src/Types.idr", "max_issues_repo_name": "joelberkeley/spidr", "max_issues_repo_head_hexsha": "98cffe059ac5162a46942027658b6fe1dba5074d", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 55, "max_issues_repo_issues_event_min_datetime": "2021-04-22T18:52:38.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T17:09:55.000Z", "max_forks_repo_path": "src/Types.idr", "max_forks_repo_name": "joelberkeley/spidr", "max_forks_repo_head_hexsha": "98cffe059ac5162a46942027658b6fe1dba5074d", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2021-08-11T10:43:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T04:00:23.000Z", "avg_line_length": 39.3255813953, "max_line_length": 97, "alphanum_fraction": 0.7031342401, "num_tokens": 461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.5486066114390677}} {"text": "module TypeIndexedTypeChecker\n\n-- Based on https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.pdf\n\nimport Data.Fin\nimport Data.List\nimport Data.Vect\nimport Control.Catchable\n\ndata Ty : Type where\n TyInt : Ty\n TyFun : Ty -> Ty -> Ty\n\n-- lemmas\nnotIntFun : TyInt = TyFun x y -> Void\nnotIntFun Refl impossible\nnotFunInt : (TyFun x y) = TyInt -> Void\nnotFunInt Refl impossible\nxEqyNeq : (x = x') -> ((y = y') -> Void) -> TyFun x y = TyFun x' y' -> Void\nxEqyNeq Refl contra Refl = contra Refl\nxNeqyEq : (y = y') -> ((x = x') -> Void) -> TyFun x y = TyFun x' y' -> Void\nxNeqyEq Refl contra Refl = contra Refl\nxNeqyNEq : ((x = x') -> Void) -> ((y = y') -> Void) -> TyFun x y = TyFun x' y' -> Void\nxNeqyNEq contra contra' Refl = contra Refl\n\nimplementation DecEq Ty where\n decEq TyInt TyInt = Yes Refl\n decEq TyInt (TyFun x y) = No notIntFun\n decEq (TyFun x y) TyInt = No notFunInt\n decEq (TyFun x y) (TyFun x' y') with (decEq x x')\n decEq (TyFun x'' y) (TyFun x'' y') | (Yes Refl) with (decEq y y')\n decEq (TyFun x'' y'') (TyFun x'' y'') | (Yes Refl) | (Yes Refl) = Yes Refl\n decEq (TyFun x'' y) (TyFun x'' y') | (Yes Refl) | (No contra) = No (\\eq => xEqyNeq Refl contra eq)\n decEq (TyFun x y) (TyFun x' y') | (No contra) with (decEq y y')\n decEq (TyFun x y'') (TyFun x' y'') | (No contra) | (Yes Refl) = No (\\eq => xNeqyEq Refl contra eq)\n decEq (TyFun x y) (TyFun x' y') | (No contra) | (No contra') = No (\\eq => xNeqyNEq contra contra' eq)\n\ndata UExp : Nat -> Type where\n UVar : Fin n -> UExp n\n ULam : Ty -> UExp (S n) -> UExp n\n UApp : UExp n -> UExp n -> UExp n\n UPlus : UExp n -> UExp n -> UExp n\n UIntE : Int -> UExp n\n\n\ndata Expr : Vect n Ty -> Ty -> Type where\n Val : Int -> Expr ctx TyInt\n Plus : Expr ctx TyInt -> Expr ctx TyInt -> Expr ctx TyInt\n Var : Elem t ctx -> Expr ctx t\n Lam : Expr (a :: ctx) b -> Expr ctx (TyFun a b)\n App : Expr ctx (TyFun a b) -> Expr ctx a -> Expr ctx b\n\n\ninterpTy : Ty -> Type\ninterpTy TyInt = Int\ninterpTy (TyFun arg res) = interpTy arg -> interpTy res\n\ninterpCtx : Vect n Ty -> Type\ninterpCtx [] = ()\ninterpCtx (t :: ts) = (interpTy t, interpCtx ts)\n\nlookup : Elem t ctx -> interpCtx ctx -> interpTy t\nlookup Here (t, _) = t\nlookup (There x) (_, ts) = lookup x ts\n\nshow : (t : Ty) -> interpTy t -> String\nshow TyInt v = show v\nshow (TyFun x y) v = \"Fun\"\n\neval : interpCtx ctx -> Expr ctx t -> interpTy t\neval ctx (Val x) = x\neval ctx (Var x) = lookup x ctx\neval ctx (Lam body) = \\x => eval (x, ctx) body\neval ctx (App f x) = (eval ctx f) (eval ctx x)\neval ctx (Plus e1 e2) = (eval ctx e1) + (eval ctx e2)\n\ncheck : (Catchable m String) => UExp Z -> ((t : Ty) -> Expr [] t -> m r) -> m r\ncheck uexp k = go [] uexp k\n where\n go : (Catchable m String) => (ctx : Vect n Ty) -> UExp n -> ((t : Ty) -> Expr ctx t -> m r) -> m r\n go ctx (UVar n) k = checkVar n ctx $ \\ty, elem => k ty (Var elem)\n where\n checkVar : (Catchable m String) => {n : Nat} -> Fin n -> (ctx : Vect n Ty) -> ((t : Ty) -> Elem t ctx -> m r) -> m r\n checkVar FZ (ty :: _) k = k ty Here\n checkVar (FS n') (_ :: ctx') k = checkVar n' ctx' $ \\ty, elem => k ty (There elem)\n\n go ctx (ULam ty body) k = go (ty :: ctx) body $ \\resTy, body' => k (TyFun ty resTy) (Lam body')\n go ctx (UApp e1 e2) k = go ctx e1 $ \\funTy, e1' =>\n go ctx e2 $ \\argTy, e2' => checkApp funTy argTy e1' e2' k\n where\n checkApp : (Catchable m String) => (funTy : Ty) -> (argTy : Ty) -> Expr ctx funTy -> Expr ctx argTy -> ((t : Ty) -> Expr ctx t -> m r) -> m r\n checkApp (TyFun argTy' resTy) argTy e1' e2' k with (decEq argTy' argTy)\n checkApp (TyFun argTy resTy) argTy e1' e2' k | (Yes Refl) = k resTy (App e1' e2')\n checkApp (TyFun argTy' refTy) argTy e1' e2' k | (No contra) = throw \"TypeError\"\n checkApp _ _ e1' e2' k = throw \"TypeError\"\n go ctx (UPlus e1 e2) k = go ctx e1 $ \\ty1, e1' =>\n go ctx e2 $ \\ty2, e2' => checkPlus ty1 ty2 e1' e2' k\n where\n checkPlus : (Catchable m String) => (ty1 : Ty) -> (ty2 : Ty) -> Expr ctx ty1 -> Expr ctx ty2 -> ((t : Ty) -> Expr ctx t -> m r) -> m r\n checkPlus TyInt TyInt e1' e2' k = k TyInt (Plus e1' e2')\n checkPlus _ _ e1' e2' k = throw \"TypeError\"\n go ctx (UIntE x) k = k TyInt (Val x)\n\n\nexample : UExp Z\nexample = UApp (ULam TyInt (UPlus (UVar FZ) (UIntE 1))) (UIntE 5)\n\ntest : Either String String\ntest = check example (\\ty, expr => Right $ show ty $ eval () expr)\n", "meta": {"hexsha": "8d88fee3fc5a326f8753e6036b2c6082744c0432", "size": 4498, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/TypeIndexedTypeChecker.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/TypeIndexedTypeChecker.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/TypeIndexedTypeChecker.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 40.8909090909, "max_line_length": 149, "alphanum_fraction": 0.5751445087, "num_tokens": 1667, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619436290698, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.548605693516593}} {"text": "import Common\n\neitherBool : Iso (Either a a) (a, Bool)\neitherBool = MkIso to from tf ft\n where\n to : (Either a a) -> (a, Bool)\n to (Left x) = (x, False)\n to (Right x) = (x, True)\n from : (a, Bool) -> (Either a a)\n from (x, False) = Left x\n from (x, True) = Right x\n tf (a, False) = Refl\n tf (a, True) = Refl\n ft (Left x) = Refl\n ft (Right x) = Refl\n\n\ndec : (pc: a -> Type) -> (f : (x: a) -> Dec (pc x)) -> Iso (Sigma a (\\x => Dec (pc x))) a\ndec pc f = MkIso to from tf ft\n where\n to : (Sigma a (\\x => Dec (pc x))) -> a\n to (MkSigma x p) = x\n from : a -> (Sigma a (\\x => Dec (pc x)))\n from x = MkSigma x (f x)\n tf x = Refl\n ft (MkSigma x (Yes prf)) with (f x)\n | Yes prf = cong {f=\\r => MkSigma x (Yes r)} $ believe_me ()\n | No contra = void $ contra prf\n ft (MkSigma x (No contra)) with (f x)\n | Yes prf = void $ contra prf\n | No contra = cong {f=\\r => MkSigma x (No r)} $ believe_me ()\n\n\neitherDec : (pc: a -> Type) -> Iso (Sigma a (\\x => Dec (pc x))) (Sigma a (\\x => (Either (pc x -> Void) (pc x))))\neitherDec pc = MkIso to from tf ft\n where\n to : (Sigma a (\\x => Dec (pc x))) -> (Sigma a (\\x => (Either (pc x -> Void) (pc x))))\n to (MkSigma x (No contra)) = (x ** Left contra)\n to (MkSigma x (Yes prf)) = (x ** Right prf)\n from : (Sigma a (\\x => (Either (pc x -> Void) (pc x)))) -> (Sigma a (\\x => Dec (pc x)))\n from (MkSigma x (Left contra)) = (x ** No contra)\n from (MkSigma x (Right prf)) = (x ** Yes prf)\n tf (MkSigma x (Left contra)) = Refl\n tf (MkSigma x (Right prf)) = Refl\n ft (MkSigma x (No contra)) = Refl\n ft (MkSigma x (Yes prf)) = Refl\n\n\neitherSigmaDistribLeft : Iso (Sigma a (\\x => (Either pa pb)))\n (Either (Sigma a (\\x => pa)) (Sigma a (\\x => pb)))\neitherSigmaDistribLeft = MkIso to from tf ft\n where\n to : (Sigma a (\\x => (Either pa pb))) -> (Either (Sigma a (\\x => pa)) (Sigma a (\\x => pb)))\n to (MkSigma x (Left pa)) = Left (MkSigma x pa)\n to (MkSigma x (Right pb)) = Right (MkSigma x pb)\n from : (Either (Sigma a (\\x => pa)) (Sigma a (\\x => pb))) -> (Sigma a (\\x => (Either pa pb)))\n from (Left (MkSigma x pa)) = MkSigma x (Left pa)\n from (Right (MkSigma x pb)) = MkSigma x (Right pb)\n tf (Left (MkSigma x p)) = Refl\n tf (Right (MkSigma x p)) = Refl\n ft (MkSigma x (Left pa)) = Refl\n ft (MkSigma x (Right pb)) = Refl\n\n-- use a to find whether it's b or c next to it\nbranch : (pc: a -> Type) ->\n ((x: a) -> Dec (pc x)) ->\n Iso b d ->\n Iso c d ->\n Iso (Sigma a (\\x => (Either (pc x -> Void, b) (pc x, c)))) (a, d)\nbranch pc\n f\n (MkIso bdto bdfrom bdtf bdft)\n (MkIso cdto cdfrom cdtf cdft)\n = MkIso to from tf ft\n where\n to : (Sigma a (\\x => (Either (pc x -> Void, b) (pc x, c)))) -> (a, d)\n to (MkSigma x (Left (p, y))) = (x, bdto y)\n to (MkSigma x (Right (p, y))) = (x, cdto y)\n from : (a, d) -> (Sigma a (\\x => (Either (pc x -> Void, b) (pc x, c))))\n from (x, y) = case (appIso (eitherDec pc) (unappIso (dec pc f) x)) of\n (MkSigma z (Left p)) => MkSigma z $ Left (p, bdfrom y)\n (MkSigma z (Right p)) => MkSigma z $ Right (p, cdfrom y)\n tf (x, y) with (f x)\n | Yes prf = rewrite (cdtf y) in Refl\n | No contra = rewrite (bdtf y) in Refl\n ft (MkSigma x (Left (p, y))) with (f x)\n | Yes prf = void $ p prf\n | No contra = rewrite (bdft y) in cong {f=\\r => MkSigma x (Left (r, y))} $ believe_me ()\n ft (MkSigma x (Right (p, y))) with (f x)\n | Yes prf = rewrite (cdft y) in cong {f=\\r => MkSigma x (Right (r, y))} $ believe_me ()\n | No contra = void $ contra p\n", "meta": {"hexsha": "f604c0b30e78550fb604806df91bdb97ccff5aae", "size": 3653, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Either.idr", "max_stars_repo_name": "defanor/morphisms", "max_stars_repo_head_hexsha": "57ec23fc955dc69300d6fbd394cb9ac3209ff76b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-06-10T20:58:11.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-10T20:58:11.000Z", "max_issues_repo_path": "src/Either.idr", "max_issues_repo_name": "defanor/morphisms", "max_issues_repo_head_hexsha": "57ec23fc955dc69300d6fbd394cb9ac3209ff76b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Either.idr", "max_forks_repo_name": "defanor/morphisms", "max_forks_repo_head_hexsha": "57ec23fc955dc69300d6fbd394cb9ac3209ff76b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 39.7065217391, "max_line_length": 112, "alphanum_fraction": 0.5149192445, "num_tokens": 1358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.78793120560257, "lm_q2_score": 0.6959583376458152, "lm_q1q2_score": 0.5483672920304277}} {"text": "module Control.Function\n\npublic export\ninterface Injective (f : a -> b) where\n constructor MkInjective\n injective : {x, y : a} -> f x = f y -> x = y\n\npublic export\ninj : (0 f : a -> b) -> {auto 0 _ : Injective f} -> {0 x, y : a} -> (0 _ : f x = f y) -> x = y\ninj _ eq = irrelevantEq (injective eq)\n", "meta": {"hexsha": "5b2c488806e9aca835c35ebc88708fa9027fd70e", "size": 300, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Control/Function.idr", "max_stars_repo_name": "chrrasmussen/Idris2-Erlang", "max_stars_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "idris2/libs/base/Control/Function.idr", "max_issues_repo_name": "chrrasmussen/Idris2-Erlang", "max_issues_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "idris2/libs/base/Control/Function.idr", "max_forks_repo_name": "chrrasmussen/Idris2-Erlang", "max_forks_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 27.2727272727, "max_line_length": 94, "alphanum_fraction": 0.5833333333, "num_tokens": 109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.78793120560257, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.5483672721550792}} {"text": "module Toolkit.Data.List.View.PairWise\n\nimport Data.List\n\n%default total\n\npublic export\ndata PairWise : List a -> Type where\n Empty : PairWise Nil\n One : (x:a) -> PairWise [x]\n Two : (x,y : a) -> PairWise [x,y]\n N : (x,y : a)\n -> PairWise (y::xs)\n -> PairWise (x::y::xs)\n\n\nexport\npairwise : (xs : List a) -> PairWise xs\npairwise [] = Empty\npairwise (x :: []) = One x\npairwise (x :: (y :: xs)) with (pairwise (y::xs))\n pairwise (x :: (y :: [])) | (One y) = Two x y\n pairwise (x :: (y :: [w])) | (Two y w) = N x y (Two y w)\n pairwise (x :: (y :: (w :: xs))) | (N y w v) = N x y (N y w v)\n\nunSafeToList : {xs : List a} -> PairWise xs -> Maybe (List (a,a))\nunSafeToList Empty = Just Nil\nunSafeToList (One x) = Nothing\nunSafeToList (Two x y) = Just [(x,y)]\nunSafeToList (N x y z)\n = do rest <- unSafeToList z\n pure (MkPair x y :: rest)\n\n||| Returns a list of pairs if `xs` has even number of elements, Nothing if odd.\nexport\nunSafePairUp : (xs : List a) -> Maybe (List (a,a))\nunSafePairUp xs = (unSafeToList (pairwise xs))\n\n\n-- [ EOF ]\n", "meta": {"hexsha": "1d98c6ef6e46a6574d2af7af284dfd295306bf5e", "size": 1065, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/List/View/PairWise.idr", "max_stars_repo_name": "border-patrol/lightclick", "max_stars_repo_head_hexsha": "1f52fc27674f244c399e5e579403e8075f982a37", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2020-11-03T11:33:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T17:11:38.000Z", "max_issues_repo_path": "src/Toolkit/Data/List/View/PairWise.idr", "max_issues_repo_name": "border-patrol/lightclick", "max_issues_repo_head_hexsha": "1f52fc27674f244c399e5e579403e8075f982a37", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Toolkit/Data/List/View/PairWise.idr", "max_forks_repo_name": "border-patrol/lightclick", "max_forks_repo_head_hexsha": "1f52fc27674f244c399e5e579403e8075f982a37", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-09T19:49:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T19:49:11.000Z", "avg_line_length": 25.9756097561, "max_line_length": 80, "alphanum_fraction": 0.5774647887, "num_tokens": 379, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.5478323551705266}} {"text": "\nmodule Applicative\n\n\n-- Attempt to write applicative from memory\ninterface Functor s => MyApplicative (s : Type -> Type) where\n myPure : a -> s a\n myApply : s (a -> b) -> s a -> s b\n\n", "meta": {"hexsha": "825ff3334b55436b6ee12f8e81d3b5628c4ce7a7", "size": 202, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter7/Applicative.idr", "max_stars_repo_name": "robkorn/idris-type-driven-development-exercises", "max_stars_repo_head_hexsha": "d3dcf7e0e0707c991a20c020e671e6e0aa21cf84", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-12-18T12:54:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-28T09:54:21.000Z", "max_issues_repo_path": "Chapter7/Applicative.idr", "max_issues_repo_name": "robkorn/idris-type-driven-development-exercises", "max_issues_repo_head_hexsha": "d3dcf7e0e0707c991a20c020e671e6e0aa21cf84", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter7/Applicative.idr", "max_forks_repo_name": "robkorn/idris-type-driven-development-exercises", "max_forks_repo_head_hexsha": "d3dcf7e0e0707c991a20c020e671e6e0aa21cf84", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-12-18T12:54:05.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-18T12:54:05.000Z", "avg_line_length": 20.2, "max_line_length": 61, "alphanum_fraction": 0.5891089109, "num_tokens": 55, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8596637577007393, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.5476322865540937}} {"text": "module MiniForth\n\ndata IxList : {i : Type} -> (rel : i -> i -> Type) -> i -> i -> Type where\n Nil : IxList rel i i\n (::) : rel i j -> IxList rel j k -> IxList rel i k\n\ndata Instr : Nat -> Nat -> Type where\n Lit : Int -> Instr n (S n)\n Dup : Instr (S n) (S (S n))\n Swap : Instr (S (S n)) (S (S n))\n Drop : Instr (S n) n\n Over : Instr (S (S n)) (S (S (S n)))\n Op : (Int -> Int -> Int) -> Instr (S (S n)) (S n)\n\ndata Val : Nat -> Nat -> Type where\n ValC : Int -> Val (S n) n\n\nrun : IxList Instr i j -> IxList Val i 0 -> IxList Val j 0\nrun [] st = st\nrun ((Lit x) :: xs) st = run xs (ValC x :: st)\nrun (Dup :: xs) ((ValC x) :: st) = run xs (ValC x :: ValC x :: st)\nrun (Swap :: _) ((ValC _) :: []) impossible\nrun (Swap :: xs) ((ValC x) :: ((ValC y) :: st)) = run xs (ValC y :: ValC x :: st)\nrun (Drop :: xs) ((ValC x) :: st) = run xs st\nrun (Over :: _) ((ValC _) :: []) impossible\nrun (Over :: xs) ((ValC x) :: (ValC y) :: st) = run xs ((ValC y) :: (ValC x) :: (ValC y) :: st)\nrun (Op _ :: _) ((ValC _) :: []) impossible\nrun (Op f :: xs) ((ValC x) :: ((ValC y) :: st)) = run xs (ValC (f x y) :: st)\n\nsquare : IxList Instr (S n) (S n)\nsquare = Dup :: Op (*) :: Nil\n\nprg : IxList Instr 0 1\nprg = Lit 5 :: square\n\ntest : run MiniForth.prg [] = [ValC 25]\ntest = Refl\n", "meta": {"hexsha": "359df15a419f7f984ed298c890d4b1ab04cea685", "size": 1269, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/MiniForth.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/MiniForth.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MiniForth.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 33.3947368421, "max_line_length": 95, "alphanum_fraction": 0.5074862096, "num_tokens": 514, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711680567799, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.547572766251723}} {"text": "module Data.Verified.Fufunctor\n\nimport Data.Fufunctor\n\n%default total\n%access public export\n\n||| Verified Fufunctor\n||| A Fufunctor for which identity and composition laws are verified\ninterface Fufunctor t => VerifiedFufunctor (t : Type -> Type -> Type -> Type) where\n fufunctorIdentity : {a : Type} -> {b : Type} -> {c : Type} ->\n (x : t a b c) ->\n fumap Basics.id Basics.id Basics.id x = x\n fufunctorComposition : {a : Type} -> {b : Type} -> {c : Type} ->\n {a1 : Type} -> {b1 : Type} -> {c1 : Type} ->\n (x : t a b c) ->\n (fa1 : a1 -> a) -> (fb1 : b1 -> b) -> (fc1 : c -> c1) ->\n (fa2 : a2 -> a1) -> (fb2 : b2 -> b1) -> (fc2 : c1 -> c2) ->\n (fumap (fa1 . fa2) (fb1 . fb2) (fc2 . fc1) x) =\n (fumap fa2 fb2 fc2 . fumap fa1 fb1 fc1) x\n", "meta": {"hexsha": "f1aac9223908fd3a40bffd59d5c4a75c21c51c1e", "size": 922, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Verified/Fufunctor.idr", "max_stars_repo_name": "lemastero/Idris-Trifunctors", "max_stars_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Verified/Fufunctor.idr", "max_issues_repo_name": "lemastero/Idris-Trifunctors", "max_issues_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-13T21:31:36.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-13T21:31:36.000Z", "max_forks_repo_path": "src/Data/Verified/Fufunctor.idr", "max_forks_repo_name": "lemastero/Idris-Trifunctors", "max_forks_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-19T04:35:47.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-19T04:35:47.000Z", "avg_line_length": 43.9047619048, "max_line_length": 84, "alphanum_fraction": 0.4598698482, "num_tokens": 298, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8267118068790619, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.547219451195033}} {"text": "> module EscadoOliva.Quantifier\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n> ||| Quantifier\n> K : Type -> Type -> Type\n> K R X = (X -> R) -> R\n\n\n", "meta": {"hexsha": "c110b2ee7ce281c920c35274eb5f708851fe80c1", "size": 168, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "EscardoOliva/Quantifier.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "EscardoOliva/Quantifier.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "EscardoOliva/Quantifier.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 12.9230769231, "max_line_length": 31, "alphanum_fraction": 0.6130952381, "num_tokens": 57, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.5469647882773}} {"text": "import Common\n\nlist : Iso a b -> Iso (List a) (List b)\nlist (MkIso abto abfrom abtf abft) = MkIso to from tf ft\n where\n to : List a -> List b\n to [] = []\n to (x :: xs) = abto x :: to xs\n from : List b -> List a\n from [] = []\n from (x :: xs) = abfrom x :: from xs\n tf [] = Refl\n tf (x :: xs) = rewrite (abtf x) in cong (tf xs)\n ft [] = Refl\n ft (x :: xs) = rewrite (abft x) in cong (ft xs)\n\n\ndep_to : Iso b c -> a -> b -> (a, c)\ndep_to (MkIso to' from' tf' ft') x y = (x, (to' y))\n\ndep_from : Iso b c -> a -> c -> (a, b)\ndep_from (MkIso to' from' tf' ft') x y = (x, (from' y))\n\ndep : (a -> Iso b c) -> Iso (a, b) (a, c)\ndep f = MkIso to from tf ft\n where\n to : (a, b) -> (a, c)\n to (x, y) = dep_to (f x) x y\n from : (a, c) -> (a, b)\n from (x, y) = dep_from (f x) x y\n tf (x, y) = case (inspect $ f x) of\n (match (MkIso to' from' tf' ft') {eq=fx}) => rewrite fx in\n case (dep_from (MkIso to' from' tf' ft') x y) of\n (x', y') => rewrite fx in\n case (dep_to (MkIso to' from' tf' ft') x (from' y)) of\n (x'', y'') => rewrite (tf' y) in Refl\n ft (x, y) = case (inspect $ f x) of\n (match (MkIso to' from' tf' ft') {eq=fx}) => rewrite fx in\n case (dep_to (MkIso to' from' tf' ft') x y) of\n (x', y') => rewrite fx in\n case (dep_from (MkIso to' from' tf' ft') x (to' y)) of\n (x'', y'') => rewrite (ft' y) in Refl\n", "meta": {"hexsha": "298ca43f0432fc7f765a4dca099688f099dc1069", "size": 1442, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Misc.idr", "max_stars_repo_name": "defanor/morphisms", "max_stars_repo_head_hexsha": "57ec23fc955dc69300d6fbd394cb9ac3209ff76b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-06-10T20:58:11.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-10T20:58:11.000Z", "max_issues_repo_path": "src/Misc.idr", "max_issues_repo_name": "defanor/morphisms", "max_issues_repo_head_hexsha": "57ec23fc955dc69300d6fbd394cb9ac3209ff76b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Misc.idr", "max_forks_repo_name": "defanor/morphisms", "max_forks_repo_head_hexsha": "57ec23fc955dc69300d6fbd394cb9ac3209ff76b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.5348837209, "max_line_length": 66, "alphanum_fraction": 0.4750346741, "num_tokens": 569, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391595913457, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.5468810984247741}} {"text": "> module Data.List.TypeEnumeration\n> import Data.List\n> import Data.List.DecIn\n> import Functions\n> %access public export\n\nThis module contains utilities for \"enumerating a type\" by placing all elements\nof that type into a list. It contains two basic quantifiers on a type `t` and a \nlist `xs : List t`:\n\n- `All {t} xs`, proofs that `xs` contains every element of `t`\n- `NoDupes {t} xs`, proofs that `xs` contains no duplicate elements of `t`\n\nFirst we start with `All {t} xs`: how can we determine if `xs` contains every \nelement of `t`? If this were the case, we would be able to construct a\nfunction $f_{xs} : (x:t) \\rightarrow \\texttt{Elem} x xs$.\n\n> ||| Proofs that a given list contains all possible elements of a given type.\n> All : {t : Type} -> List t -> Type \n> All xs {t} = (x:t) -> Elem x xs\n\nThere are some boilerplate and uninhabited trivialities to get out of the way. \n\n> ||| Given a type t and a proof of t, it is a contradiction to have a proof that\n> ||| the empty list contains all elements of t.\n> allNotEmpty : All {t} [] -> t -> Void\n> allNotEmpty f x = absurd (f x)\n\n> ||| If a type `t` is uninhabited, then the empty list contains all elements \n> ||| of that type.\n> voidEmptyAll : Uninhabited t => All {t} []\n> voidEmptyAll = \\c => absurd c\n\nProofs that a list contains some elements of $t$ with no duplicates are defined by\n\n> ||| Proofs that a list contains no duplicates.\n> NoDupes : {t:Type} -> List t -> Type\n> NoDupes {t} xs = (x:t) -> Prop (Elem x xs)\n\nWith this we can start working on proving if a given list uniquely contains all\nelements of a given type. We start with some trivial helper lemmas:\n\n> ||| If we know $x$ belongs to a list $xs$ then $x :: xs$ obviously contains\n> ||| duplicate values (namely, $x$).\n> noDupesInHeadLemma : Elem x xs -> NoDupes (x :: xs) -> Void\n> noDupesInHeadLemma {x = x} {xs = []} _ _ impossible\n> noDupesInHeadLemma {x} a b = hereIsNotThere (b x Here (There a))\n\nIf a type has decidable equality, then All and NoDupes are decidable.\nWe need a (somewhat metamathematical) lemma to start stating that any two\nvoid values of the same type are equal (there are in fact zero of them - this\nis just a wrapper for \"void can prove anything\")\n\n> ||| Any two contradictions of the same type are identical.\n> voidsAreEquivalent : {t: Type} -> (t -> Void) -> (a:t) -> (b:t) -> (a=b)\n> voidsAreEquivalent f a b = void (f a)\n\n> ||| Equivalent to `There` being an injective function.\n> thereLemma2 : {a: Elem x xs} -> {b : Elem x xs} -> (There a = There b) -> a = b\n> thereLemma2 {a = Here} {b = Here} pf = Refl\n> thereLemma2 {a = Here} {b = (There _)} Refl impossible\n> thereLemma2 {a = (There _)} {b = Here} Refl impossible\n> thereLemma2 {a = (There x)} {b = (There x)} Refl = Refl\n\n> ||| For fixed $y$, `There` is an injective function from `Elem x xs` to \n> ||| `Elem x (y :: xs)`.\n> thereInjective : Injective There\n> thereInjective x y = thereLemma2 {a=x} {b=y}\n\n\n> ||| Given a list `xs` without duplicates, and an element `x` known not to be\n> ||| contained in `xs`, then `x :: xs` also contains no duplicates.\n> consNoDupes : DecEq t => {x : t} -> NoDupes {t} xs -> (Not (Elem x xs)) -> NoDupes (x :: xs)\n> consNoDupes {x = x} noDupesSublist notIn y pf1 pf2 with (decEq x y)\n> consNoDupes {x = y} noDupesSublist notIn y Here Here | Yes pf = Refl\n> consNoDupes {x = y} noDupesSublist notIn y Here (There later) | Yes pf = \n> absurd (notIn later)\n> consNoDupes {x = y} noDupesSublist notIn y (There later) Here | Yes pf = \n> absurd (notIn later)\n> consNoDupes {x = x} noDupesSublist notIn y (There later) (There z) | Yes pf = \n> absurd (notIn (rewrite pf in later)) \n> consNoDupes {x = y} noDupesSublist notIn y Here Here | No contra = Refl\n> consNoDupes {x = y} noDupesSublist notIn y Here (There later) | No contra = \n> absurd (notIn later)\n> consNoDupes {x = y} noDupesSublist notIn y (There later) Here | No contra = \n> absurd (notIn later)\n> consNoDupes {x = x} noDupesSublist notIn y (There later) (There z) | No contra = \n> let ndupes = (noDupesSublist y later z) in cong ndupes\n\n\n> ||| If a nonempty list contains no duplicates, then its tail has no duplicates.\n> dupeCons : NoDupes (x :: xs) -> NoDupes xs\n> dupeCons dupeBiglist item pf1 pf2 = thereLemma2 (dupeBiglist item (There pf1) (There pf2))\n\n> ||| If a type `t` has decidable equality, then `List t` has a decision \n> ||| procedure for determining if it contains any duplicates.\n> deqEqToDupe : DecEq t => (xs:List t) -> Dec (NoDupes xs)\n> deqEqToDupe [] = Yes (\\a => (\\b => (\\c => (voidsAreEquivalent uninhabited b c))))\n> deqEqToDupe (x :: xs) with (isElem x xs)\n> deqEqToDupe (x :: xs) | Yes pf = No (noDupesInHeadLemma pf)\n> deqEqToDupe (x :: xs) | No contra = case deqEqToDupe xs of\n> Yes noDupes => Yes (consNoDupes noDupes contra)\n> No areDupes => No (\\c => areDupes (dupeCons c))\n\nDecidable list membership allows us to remove duplicates from a list:\n\n> ||| Given an input list `xs`, return a list `ys` satisfying the following:\n> ||| - `Elem y ys` has at most one element up to equality (`NoDupes ys`)\n> ||| - Given a proof `Elem x xs` (resp `Elem x ys`) we have a proof `Elem x ys`\n> ||| (resp `Elem x xs`) (`ElementPreservingCorrespondence xs ys`)\n> remDup : DecIn t => (xs : List t) -> (ys ** (NoDupes ys, ElementPreservingCorrespondence xs ys))", "meta": {"hexsha": "95b9e94473c21680525b0981b6670fc101cbaa82", "size": 5404, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/Data/List/TypeEnumeration.lidr", "max_stars_repo_name": "nicklecompte/idris-finite-sets", "max_stars_repo_head_hexsha": "de247371fb125f84b32b50f805095e677d30c93b", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/List/TypeEnumeration.lidr", "max_issues_repo_name": "nicklecompte/idris-finite-sets", "max_issues_repo_head_hexsha": "de247371fb125f84b32b50f805095e677d30c93b", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/List/TypeEnumeration.lidr", "max_forks_repo_name": "nicklecompte/idris-finite-sets", "max_forks_repo_head_hexsha": "de247371fb125f84b32b50f805095e677d30c93b", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 48.6846846847, "max_line_length": 98, "alphanum_fraction": 0.6600666173, "num_tokens": 1716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959545, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5465313196442996}} {"text": "||| N-ary congruence for reasoning\nmodule Data.Telescope.Congruence\n\nimport Data.Telescope.Telescope\nimport Data.Telescope.Segment\nimport Data.Telescope.SimpleFun\nimport Data.Telescope.Fun\n\npublic export\ncongType : (delta : Segment n gamma)\n -> (env1 : Left.Environment gamma) -> (sy1 : SimpleFun env1 delta Type) -> (lhs : Fun env1 delta sy1)\n -> (env2 : Left.Environment gamma) -> (sy2 : SimpleFun env2 delta Type) -> (rhs : Fun env2 delta sy2)\n -> Type\ncongType [] env1 sy1 lhs env2 sy2 rhs = lhs ~=~ rhs\ncongType (ty :: delta) env1 sy1 lhs env2 sy2 rhs =\n {x1 : ty env1} -> {x2 : ty env2}\n -> x1 ~=~ x2\n -> congType delta\n (env1 ** x1) (sy1 x1) (lhs x1)\n (env2 ** x2) (sy2 x2) (rhs x2)\n\npublic export\ncongSegment : {n : Nat} -> (0 delta : Segment n gamma)\n ->(0 env1 : Left.Environment gamma)-> (0 sy1 : SimpleFun env1 delta Type) -> (0 lhs : Fun env1 delta sy1)\n ->(0 env2 : Left.Environment gamma)-> (0 sy2 : SimpleFun env2 delta Type) -> (0 rhs : Fun env2 delta sy2)\n ->(0 _ : env1 ~=~ env2) -> (0 _ : sy1 ~=~ sy2) -> (0 _ : lhs ~=~ rhs)\n -> congType delta env1 sy1 lhs\n env2 sy2 rhs\ncongSegment {n = 0 } [] env sy context env sy context Refl Refl Refl = Refl\ncongSegment {n = S n} (ty :: delta) env sy context env sy context Refl Refl Refl = recursiveCall\n where\n recursiveCall : {x1 : ty env} -> {x2 : ty env} -> x1 ~=~ x2\n -> congType delta (env ** x1) (sy x1) (context x1)\n (env ** x2) (sy x2) (context x2)\n recursiveCall {x1=x} {x2=x} Refl = congSegment delta\n (env ** x) (sy x) (context x)\n (env ** x) (sy x) (context x)\n Refl Refl Refl\n\npublic export\ncong : {n : Nat} -> {0 delta : Segment n []} -> {0 sy : SimpleFun () delta Type}\n -> (context : Fun () delta sy)\n -> congType delta () sy context\n () sy context\ncong {n} {delta} {sy} context = congSegment delta () sy context\n () sy context\n Refl Refl Refl\n", "meta": {"hexsha": "942e3f7b4c29977590aba974b09aed084617f8e5", "size": 2362, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/contrib/Data/Telescope/Congruence.idr", "max_stars_repo_name": "chrrasmussen/Idris2-Erlang", "max_stars_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "idris2/libs/contrib/Data/Telescope/Congruence.idr", "max_issues_repo_name": "chrrasmussen/Idris2-Erlang", "max_issues_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "idris2/libs/contrib/Data/Telescope/Congruence.idr", "max_forks_repo_name": "chrrasmussen/Idris2-Erlang", "max_forks_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 49.2083333333, "max_line_length": 107, "alphanum_fraction": 0.4957662997, "num_tokens": 668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.5457789998642152}} {"text": "import Data.Vect\n\ndata WordState : (guesses_remaining : Nat) -> (letters : Nat) -> Type where\n MkWordState : (word : String) ->\n (missing : Vect letters Char) ->\n WordState guesses_remaining letters\n\ndata Finished : Type where\n Lost : (game : WordState 0 (S letters)) -> Finished\n Won : (game : WordState (S guesses) 0) -> Finished\n\ntotal\nremoveElem : (value: a) -> (xs : Vect (S n) a) ->\n {auto prf : Elem value xs} ->\n Vect n a\nremoveElem value (value :: ys) {prf = Here} = ys\nremoveElem {n = Z} value (y :: []) {prf = There later} = absurd later\nremoveElem {n = (S k)} value (y :: ys) {prf = There later}\n = y :: removeElem value ys\n\n\ndata ValidInput : List Char -> Type where\n Letter : (c : Char) -> ValidInput [c]\n\nnilFailure : (s : String) -> ValidInput [] -> Void\nnilFailure _ (Letter _) impossible\n\ntwoFailure : (s : String) -> ValidInput (x :: (y :: xs)) -> Void\ntwoFailure _ (Letter _) impossible\n\nisValidString : (s : String) -> Dec (ValidInput (unpack s))\nisValidString s = isValidInput (unpack s) where\n isValidInput : (cs : List Char) -> Dec (ValidInput cs)\n isValidInput [] = No (nilFailure s)\n isValidInput (x :: []) = Yes (Letter x)\n isValidInput (x :: (y :: xs)) = No (twoFailure s)\n\nreadGuess : IO (x ** ValidInput x)\nreadGuess = do putStr \"Guess:\"\n x <- getLine\n case isValidString (toUpper x) of\n Yes prf => pure (_ ** prf)\n No contra => do putStr \"Invalid guess\"\n readGuess\n\nprocessGuess : (letter : Char) ->\n WordState (S guesses) (S letters) ->\n Either (WordState guesses (S letters))\n (WordState (S guesses) letters)\nprocessGuess letter (MkWordState word missing) = case isElem letter missing of\n (Yes prf) => Right (MkWordState word (removeElem letter missing))\n (No contra) => Left (MkWordState word missing) \n\n\ngame : WordState (S guesses) (S letters) -> IO Finished\ngame {guesses} {letters} st\n = do (_ ** Letter letter) <- readGuess\n case processGuess letter st of\n Left l => do putStrLn \"Wrong!\"\n case guesses of\n Z => pure (Lost l)\n S k => game l\n Right r => do putStrLn \"Right!\"\n case letters of \n Z => pure (Won r)\n S k => game r\n\nmain : IO ()\nmain = do result <- game {guesses = 2}\n (MkWordState \"Test\" ['T','E', 'S'])\n case result of\n Lost (MkWordState word missing) =>\n putStrLn (\"You lose. The word was \" ++ word)\n Won game =>\n putStrLn \"You win!\"\n\n \n", "meta": {"hexsha": "76f55d549f9409a4bb4517ab814e8f0ccd1b0893", "size": 2974, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp9/Hangman.idr", "max_stars_repo_name": "Ryxai/idris_book_notes", "max_stars_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "type_driven_book/chp9/Hangman.idr", "max_issues_repo_name": "Ryxai/idris_book_notes", "max_issues_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "type_driven_book/chp9/Hangman.idr", "max_forks_repo_name": "Ryxai/idris_book_notes", "max_forks_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.1282051282, "max_line_length": 119, "alphanum_fraction": 0.5047074647, "num_tokens": 706, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.5457302148345015}} {"text": "%default total\n\n-- Let's try to replicate the dependent example with simple algebraic data types\ndata PetrolVehicle = Car' Nat | Bus' Nat\ndata PedalVehicle = Bike'\ndata Vehicle' = Petrol' PetrolVehicle | Pedal' PedalVehicle\n\nwheels' : Vehicle' -> Nat\nwheels' (Petrol' (Car' _)) = 4\nwheels' (Petrol' (Bus' _)) = 4\nwheels' (Pedal' _) = 2\n\nrefuel' : PetrolVehicle -> PetrolVehicle\nrefuel' (Car' k) = Car' 100\nrefuel' (Bus' k) = Bus' 200\n\ndata Power = Petrol | Pedal | Electric\ndata Vehicle : Power -> Type where\n Bycicle : Vehicle Pedal\n Car : (fuel : Nat) -> Vehicle Petrol\n Bus : (fuel : Nat) -> Vehicle Petrol\n -- Extra\n Unicycle : Vehicle Pedal\n Motorcycle : (fuel : Nat) -> Vehicle Petrol\n ElectricCar : (energy : Nat) -> Vehicle Electric\n\nwheels : Vehicle _ -> Nat\nwheels Bycicle = 2\nwheels (Car fuel) = 4\nwheels (Bus fuel) = 4\nwheels Unicycle = 1\nwheels (Motorcycle fuel) = 2\nwheels (ElectricCar energy) = 4\n\nrefuel : Vehicle Petrol -> Vehicle Petrol\nrefuel (Car fuel) = Car 100\nrefuel (Bus fuel) = Bus 200\nrefuel (Motorcycle fuel) = Motorcycle 50\n\n\n", "meta": {"hexsha": "9878fa275173e117c89be5bf3daa9b43d744522a", "size": 1061, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "vehicles.idr", "max_stars_repo_name": "GustavoMF31/TDDwithIdrisExercises", "max_stars_repo_head_hexsha": "22b7c2802e1d8fd102a5b9b70d024205b3f35a74", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "vehicles.idr", "max_issues_repo_name": "GustavoMF31/TDDwithIdrisExercises", "max_issues_repo_head_hexsha": "22b7c2802e1d8fd102a5b9b70d024205b3f35a74", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "vehicles.idr", "max_forks_repo_name": "GustavoMF31/TDDwithIdrisExercises", "max_forks_repo_head_hexsha": "22b7c2802e1d8fd102a5b9b70d024205b3f35a74", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8780487805, "max_line_length": 80, "alphanum_fraction": 0.6870876532, "num_tokens": 355, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045937171068, "lm_q2_score": 0.615087848460224, "lm_q1q2_score": 0.5457087646934824}} {"text": "> module Nat.CoprimeProperties\n\n> import Nat.Coprime\n> import Nat.GCD\n> import Nat.GCDOperations\n> import Nat.GCDProperties\n> import Nat.Divisor\n> import Nat.DivisorOperations\n> import Nat.DivisorProperties\n> import Nat.OperationsProperties\n> import Nat.GCDAlgorithm\n> import Nat.GCDEuclid\n> import Pairs.Operations\n> import Sigma.Sigma\n\n> %default total\n> %auto_implicits on\n> %access export\n> -- %access public export\n\n\n> ||| Coprime is decidable\n> decCoprime : (m : Nat) -> (n : Nat) -> Dec (Coprime m n)\n> decCoprime m n with (decEq (gcdAlg m n) (S Z))\n> | (Yes p) = Yes (MkCoprime p)\n> | (No contra) = No contra' where\n> contra' : Coprime m n -> Void\n> contra' (MkCoprime p) = contra p\n> %freeze decCoprime\n\n\n> ||| Coprime is symmetric\n> symmetricCoprime : Coprime m n -> Coprime n m\n> symmetricCoprime {m} {n} (MkCoprime prf) = MkCoprime (trans (gcdAlgCommutative n m) prf)\n> %freeze symmetricCoprime\n\n\n> ||| Any number is coprime with one\n> anyCoprimeOne : Coprime m (S Z)\n> anyCoprimeOne {m} = MkCoprime s3 where\n> s1 : (gcdAlg m (S Z)) `Divisor` (S Z)\n> s1 = gcdDivisorSnd (gcdAlgLemma m (S Z))\n> s2 : (S Z ) `Divisor` (gcdAlg m (S Z))\n> s2 = oneDivisorAny (gcdAlg m (S Z))\n> s3 : gcdAlg m (S Z) = S Z\n> s3 = divisorAntisymmetric (gcdAlg m (S Z)) (S Z) s1 s2\n> %freeze anyCoprimeOne\n\n\n> ||| Division by gcd yields coprime numbers\n> gcdCoprimeLemma : (d : Nat) -> (m : Nat) -> (n : Nat) -> \n> (dDm : d `Divisor` m) -> (dDn : d `Divisor` n) -> \n> Z `LT` d -> GCD d m n -> Coprime (quotient m d dDm) (quotient n d dDn)\n> gcdCoprimeLemma d m n dDm dDn zLTd dGCDmn =\n> let m' : Nat\n> = quotient m d dDm in\n> let n' : Nat\n> = quotient n d dDn in\n> let d' : Nat\n> = gcdAlg m' n' in\n> let d'GCDm'n' : (GCD d' m' n')\n> = gcdAlgLemma m' n' in\n> let d'Dm' : (d' `Divisor` m')\n> = gcdDivisorFst d'GCDm'n' in\n> let d'Dn' : (d' `Divisor` n')\n> = gcdDivisorSnd d'GCDm'n' in\n> let oneDd' : ((S Z) `Divisor` d')\n> = oneDivisorAny d' in\n> let d'Done : (d' `Divisor` (S Z))\n> = gcdLemma'' d m n dDm dDn dGCDmn zLTd d' d'Dm' d'Dn' in\n> let d'EQone : (d' = (S Z)) \n> = divisorAntisymmetric d' (S Z) d'Done oneDd' in\n> MkCoprime d'EQone\n> %freeze gcdCoprimeLemma\n\n\n> {-\n\n> ||| Division by gcd yields coprime numbers\n> gcdCoprimeLemma : (v : GCD (S d) m n) -> Coprime (quotient m (S d) (gcdDivisorFst v))\n> (quotient n (S d) (gcdDivisorSnd v))\n> gcdCoprimeLemma {d} {m} {n} v = MkCoprime (MkGCD d'Dm' d'Dn' d'G) Refl where\n> dDm : (S d) `Divisor` m\n> dDm = gcdDivisorFst v\n> dDn : (S d) `Divisor` n\n> dDn = gcdDivisorSnd v\n> m' : Nat\n> m' = quotient m (S d) dDm\n> n' : Nat\n> n' = quotient n (S d) dDn\n> d'Dm' : S Z `Divisor` m'\n> d'Dm' = oneDivisorAny m'\n> d'Dn' : S Z `Divisor` n'\n> d'Dn' = oneDivisorAny n'\n> d'G : (d'' : Nat) -> d'' `Divisor` m' -> d'' `Divisor` n' -> d'' `Divisor` (S Z)\n> d'G d'' = gcdLemma v\n> %freeze gcdCoprimeLemma\n\n> ||| Division by gcd yields coprime numbers\n> gcdCoprimeLemma' : (v : GCD d m n) -> Not (d = Z) -> Coprime (quotient m d (gcdDivisorFst v))\n> (quotient n d (gcdDivisorSnd v))\n> gcdCoprimeLemma' {d} {m} {n} v dNotZ = MkCoprime (MkGCD d'Dm' d'Dn' d'G) Refl where\n> dDm : d `Divisor` m\n> dDm = gcdDivisorFst v\n> dDn : d `Divisor` n\n> dDn = gcdDivisorSnd v\n> m' : Nat\n> m' = quotient m d dDm\n> n' : Nat\n> n' = quotient n d dDn\n> d'Dm' : S Z `Divisor` m'\n> d'Dm' = oneDivisorAny m'\n> d'Dn' : S Z `Divisor` n'\n> d'Dn' = oneDivisorAny n'\n> d'G : (d'' : Nat) -> d'' `Divisor` m' -> d'' `Divisor` n' -> d'' `Divisor` (S Z)\n> d'G d'' = gcdLemma' v dNotZ\n> %freeze gcdCoprimeLemma'\n\n> ||| Division by gcd yields coprime numbers\n> gcdCoprimeLemma'' : (v : GCD d m n) -> Z `LT` d -> Coprime (quotient m d (gcdDivisorFst v))\n> (quotient n d (gcdDivisorSnd v))\n> gcdCoprimeLemma'' {d} {m} {n} v zLTd = MkCoprime (MkGCD d'Dm' d'Dn' d'G) Refl where\n> dDm : d `Divisor` m\n> dDm = gcdDivisorFst v\n> dDn : d `Divisor` n\n> dDn = gcdDivisorSnd v\n> m' : Nat\n> m' = quotient m d dDm\n> n' : Nat\n> n' = quotient n d dDn\n> d'Dm' : S Z `Divisor` m'\n> d'Dm' = oneDivisorAny m'\n> d'Dn' : S Z `Divisor` n'\n> d'Dn' = oneDivisorAny n'\n> dNotZ : Not (d = Z)\n> dNotZ = gtZisnotZ zLTd\n> d'G : (d'' : Nat) -> d'' `Divisor` m' -> d'' `Divisor` n' -> d'' `Divisor` (S Z)\n> d'G d'' = gcdLemma' v dNotZ\n> %freeze gcdCoprimeLemma''\n\n\nGCD / Coprime properties:\n\n> |||\n> gcdOneCoprimeLemma1 : (alg : (a : Nat) -> (b : Nat) -> (d : Nat ** GCD d a b)) ->\n> (m : Nat) -> (n : Nat) ->\n> gcd (alg m n) = S Z -> Coprime m n\n> gcdOneCoprimeLemma1 alg m n prf = MkCoprime (getProof (alg m n)) prf\n> %freeze gcdOneCoprimeLemma1\n\n> |||\n> gcdOneCoprimeLemma2 : (m : Nat) -> (n : Nat) ->\n> (alg : (a : Nat) -> (b : Nat) -> (d : Nat ** GCD d a b)) ->\n> Coprime m n -> gcd (alg m n) = S Z\n> gcdOneCoprimeLemma2 m n alg (MkCoprime {d} v prf) = s3 where\n> s1 : d = S Z\n> s1 = prf\n> s2 : gcd (alg m n) = d\n> s2 = gcdUnique (gcd (alg m n)) d (getProof (alg m n)) v\n> s3 : gcd (alg m n) = S Z\n> s3 = trans s2 s1\n> %freeze gcdOneCoprimeLemma2\n\n> |||\n> gcdAnyOneOne : (alg : (a : Nat) -> (b : Nat) -> (d : Nat ** GCD d a b)) ->\n> (m : Nat) ->\n> gcd (alg m (S Z)) = S Z\n> gcdAnyOneOne alg m = gcdOneCoprimeLemma2 m (S Z) alg anyCoprimeOne\n> %freeze gcdAnyOneOne\n\n> ---}\n", "meta": {"hexsha": "2a04a20f1d35e2d3a4caabcdf231ce0f483449c1", "size": 5973, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Nat/CoprimeProperties.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Nat/CoprimeProperties.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Nat/CoprimeProperties.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.726744186, "max_line_length": 95, "alphanum_fraction": 0.5163234555, "num_tokens": 2400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.5457071563281937}} {"text": "module BadRefl\n\nimport IdrisPrelude\n\nplus : Nat -> Nat -> Nat\nplus =\n natElim\n ( \\ _ => (Nat -> Nat) ) -- motive\n ( \\ n => n ) -- case for Zero\n ( \\ p, rec, n => Succ (rec n) ) -- case for Succ\n\n-- the other direction requires induction on N:\npostulate pNPlus0isN : (n : Nat) -> Eq Nat (plus n Zero) n\n\n\n-- the other direction requires induction on N:\nsuccPlus : (n : Nat) -> Eq Nat (Succ n) (plus (Succ n) Zero)\nsuccPlus =\n (\\n => pNPlus0isN (Succ n))\n", "meta": {"hexsha": "ad518c10965750a90d66a454b86c4ab3244ca620", "size": 496, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "thesisExamples/BadRefl.idr", "max_stars_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_stars_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-03-16T11:14:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-05T20:21:46.000Z", "max_issues_repo_path": "thesisExamples/BadRefl.idr", "max_issues_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_issues_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thesisExamples/BadRefl.idr", "max_forks_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_forks_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8, "max_line_length": 61, "alphanum_fraction": 0.5564516129, "num_tokens": 161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.5457071444042465}} {"text": "> module SequentialDecisionProblems.examples.Main\n\n> import Decidable.Order\n\n> import Data.List\n> import Data.List.Quantifiers\n> import Effects\n> import Effect.Exception\n> import Effect.StdIO\n\n> import SequentialDecisionProblems.CoreTheory\n> import SequentialDecisionProblems.FullTheory\n> import SequentialDecisionProblems.TabBackwardsInduction\n> import SequentialDecisionProblems.Utils\n> import SequentialDecisionProblems.NonDeterministicDefaults\n> import SequentialDecisionProblems.CoreTheoryOptDefaults\n> import SequentialDecisionProblems.FullTheoryOptDefaults\n> import SequentialDecisionProblems.TabBackwardsInductionOptDefaults\n\n> import SequentialDecisionProblems.examples.LeftAheadRight\n\n> import List.Operations\n> import List.Properties\n> import BoundedNat.BoundedNat\n> import BoundedNat.Operations\n> import BoundedNat.Properties\n> import Sigma.Sigma\n> import Sigma.Operations\n> import Nat.OperationsProperties\n> import Nat.LTEProperties\n> import Nat.LTProperties\n> import Unit.Properties\n> import Void.Properties\n> import LocalEffect.Exception\n> import LocalEffect.StdIO\n\n> -- %default total\n> %auto_implicits off\n\n> -- %logging 5\n\nLike \"Example2.lidr\", but now |step t x y| is empty in states\ncorresponding to |maxColumn|, no matter which |y| is selected! Thus,\nsuch states are not viable for more than zero steps. Attemps at making\nmore than zero decision steps starting from |maxColumn| should be\ndetected and rejected.\n\n* The decision process:\n\n> maxColumn : Nat\n> maxColumn = 10\n\n> nColumns : Nat\n> nColumns = S maxColumn\n\n** States:\n\n> SequentialDecisionProblems.CoreTheory.State t = LTB nColumns\n\n** Controls:\n\n> SequentialDecisionProblems.CoreTheory.Ctrl t x = LeftAheadRight\n\n** Transition function:\n\n> SequentialDecisionProblems.CoreTheory.nexts t (MkSigma Z prf) Left =\n> [MkSigma maxColumn (ltIdS maxColumn)]\n> SequentialDecisionProblems.CoreTheory.nexts t (MkSigma (S n) prf) Left with (decLT (S n) maxColumn)\n> | (Yes p) = [MkSigma n (ltLemma1 n nColumns prf)]\n> | (No contra) = []\n> SequentialDecisionProblems.CoreTheory.nexts t (MkSigma n prf) Ahead with (decLT n maxColumn)\n> | (Yes p) = [MkSigma n prf]\n> | (No contra) = []\n> SequentialDecisionProblems.CoreTheory.nexts t (MkSigma n prf) Right with (decLT n maxColumn)\n> | (Yes p) = [MkSigma (S n) (LTESucc p)]\n> | (No contra) = []\n\n** |Val| and |LTE|:\n\n> SequentialDecisionProblems.CoreTheory.Val = \n> Nat\n\n> SequentialDecisionProblems.CoreTheory.plus = \n> Prelude.Nat.plus\n\n> SequentialDecisionProblems.CoreTheory.zero = \n> Z\n\n> SequentialDecisionProblems.CoreTheory.LTE = \n> Prelude.Nat.LTE\n\n> SequentialDecisionProblems.FullTheory.reflexiveLTE = \n> Nat.LTEProperties.reflexiveLTE\n\n> SequentialDecisionProblems.FullTheory.transitiveLTE = \n> Nat.LTEProperties.transitiveLTE\n\n> SequentialDecisionProblems.FullTheory.monotonePlusLTE = \n> Nat.LTEProperties.monotoneNatPlusLTE\n\n> SequentialDecisionProblems.CoreTheoryOptDefaults.totalPreorderLTE = \n> Nat.LTEProperties.totalPreorderLTE \n\n** Reward function:\n\n> SequentialDecisionProblems.CoreTheory.reward t x y (MkSigma c _) =\n> if c == Z\n> then (S Z)\n> else if (S c) == nColumns\n> then (S (S Z))\n> else Z\n\n** Measure:\n\n> SequentialDecisionProblems.CoreTheory.meas = sum\n> SequentialDecisionProblems.FullTheory.measMon = sumMon\n\n** |State| is finite:\n\n> SequentialDecisionProblems.TabBackwardsInduction.finiteState t = \n> finiteLTB nColumns\n\n** |Ctrl| is finite:\n\n> SequentialDecisionProblems.Utils.finiteCtrl _ = \n> finiteLeftAheadRight\n\n** Reachability:\n\n> SequentialDecisionProblems.CoreTheory.Reachable x' = Unit\n> SequentialDecisionProblems.CoreTheory.reachableSpec1 {t} x r y = all (nexts t x y) where\n> all : (xs : List (State (S t))) -> SequentialDecisionProblems.CoreTheory.All (Reachable {t' = S t}) xs\n> all Nil = Nil\n> all (x :: xs) = () :: (all xs)\n> SequentialDecisionProblems.TabBackwardsInduction.decidableReachable x = decidableUnit\n\n** Viability:\n\n> nextsLemma0 : {t : Nat} -> \n> (x : State t) -> (outl x `LT` maxColumn) -> nexts t x Ahead = [x]\n> nextsLemma0 {t} (MkSigma i prf) p with (decLT i maxColumn)\n> | (Yes _) = Refl\n> | (No contra) = void (contra p)\n\n> nextsLemma1 : {t : Nat} -> \n> (x : State t) -> (outl x `LT` maxColumn) -> \n> SequentialDecisionProblems.CoreTheory.NotEmpty (nexts t x Ahead)\n> nextsLemma1 {t} x prf with (decLT (outl x) maxColumn)\n> | (Yes p) = s3 where\n> s1 : SequentialDecisionProblems.CoreTheory.NotEmpty [x] \n> s1 = SequentialDecisionProblems.CoreTheory.elemNotEmptySpec0 x [x] Here\n> s2 : [x] = nexts t x Ahead\n> s2 = sym (nextsLemma0 x p)\n> s3 : SequentialDecisionProblems.CoreTheory.NotEmpty (nexts t x Ahead)\n> s3 = replace s2 s1\n> | (No contra) = void (contra prf)\n\n> SequentialDecisionProblems.CoreTheory.Viable Z _ = Unit\n> SequentialDecisionProblems.CoreTheory.Viable (S n) x with (decLT (outl x) maxColumn)\n> | (Yes _) = Unit\n> | (No _) = Void\n\n> viableLemma0 : {t : Nat} -> {x : State t} -> Viable Z x = Unit\n> viableLemma0 = Refl\n\n> viableLemma1 : {t : Nat} -> {n : Nat} -> {x : State t} -> \n> (outl x) `Prelude.Nat.LT` maxColumn -> Viable (S n) x = Unit\n> viableLemma1 {t} {n} {x} prf with (decLT (outl x) maxColumn)\n> | (Yes _) = Refl\n> | (No contra) = void (contra prf)\n\n> viableLemma2 : {t : Nat} -> {n : Nat} -> {x : State t} -> \n> Not ((outl x) `Prelude.Nat.LT` maxColumn) -> Viable (S n) x = Void\n> viableLemma2 {t} {n} {x} prf with (decLT (outl x) maxColumn)\n> | (Yes p) = void (prf p)\n> | (No _) = Refl\n\n> viableLemma : {t : Nat} -> {n : Nat} ->\n> (x : State t) -> \n> SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} n) (nexts t x Ahead)\n> viableLemma {t} {n = Z} (MkSigma i prf) with (decLT i maxColumn)\n> | (Yes p) = res where\n> res : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} Z) [MkSigma i prf]\n> res = v :: Nil where\n> v : Viable {t = S t} Z (MkSigma i prf)\n> v with (decLT i maxColumn)\n> | (Yes _) = MkUnit\n> | (No contra) = void (contra p)\n> | (No _) = Nil\n> viableLemma {t} {n = S m} (MkSigma i prf) with (decLT i maxColumn)\n> | (Yes p) = res where\n> res : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} (S m)) [MkSigma i prf]\n> res = v :: Nil where\n> v : Viable {t = S t} (S m) (MkSigma i prf)\n> v with (decLT i maxColumn)\n> | (Yes _) = MkUnit\n> | (No contra) = void (contra p)\n> | (No _) = Nil\n\n> SequentialDecisionProblems.CoreTheory.viableSpec1 {t} {n} x v with (decLT (outl x) maxColumn)\n> | (Yes prf) = MkSigma Ahead (ne, av) where\n> ne : NotEmpty (nexts t x Ahead)\n> ne = nextsLemma1 x prf\n> av : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} n) (nexts t x Ahead)\n> av = viableLemma x \n> | (No _) = void v\n\n> SequentialDecisionProblems.Utils.finiteViable Z _ = finiteUnit\n> SequentialDecisionProblems.Utils.finiteViable (S m) x with (decLT (outl x) maxColumn)\n> | (Yes p) = finiteUnit\n> | (No c) = finiteVoid\n\n> SequentialDecisionProblems.Utils.decidableViable Z _ = decidableUnit\n> SequentialDecisionProblems.Utils.decidableViable (S m) x with (decLT (outl x) maxColumn)\n> | (Yes _) = decidableUnit\n> | (No _) = decidableVoid\n\n\n* The computation:\n\n> SequentialDecisionProblems.Utils.showState = show @{ShowLTB}\n> SequentialDecisionProblems.Utils.showCtrl = show\n\n> computation : { [STDIO] } Eff ()\n> computation =\n> do putStr (\"enter number of steps:\\n\")\n> nSteps <- getNat\n> putStr (\"enter initial column:\\n\")\n> x0 <- getLTB nColumns\n> case (decidableViable {t = Z} nSteps x0) of\n> (Yes v0) => do putStrLn (\"computing optimal policies ...\")\n> ps <- pure (tabTailRecursiveBackwardsInduction Z nSteps)\n> putStrLn (\"computing optimal controls ...\")\n> mxys <- pure (possibleStateCtrlSeqs x0 () v0 ps)\n> putStrLn (show mxys)\n> putStrLn (\"done!\") \n> (No _) => putStrLn (\"initial column non viable for \" ++ cast {from = Int} (cast nSteps) ++ \" steps\")\n\n> main : IO ()\n> main = run computation\n\n\n> {-\n\n> ---}\n\n-- Local Variables:\n-- idris-packages: (\"effects\")\n-- End:\n", "meta": {"hexsha": "b4269a33775515a13402fddedbc4fd9cbf9dc328", "size": 8346, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionProblems/examples/Example3.NoViabilityDefaults.Tab.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SequentialDecisionProblems/examples/Example3.NoViabilityDefaults.Tab.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SequentialDecisionProblems/examples/Example3.NoViabilityDefaults.Tab.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.384, "max_line_length": 111, "alphanum_fraction": 0.6665468488, "num_tokens": 2507, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5454985394370738}} {"text": "module Sub06Apply36x9\r\n\r\nimport ProofColDivSeqBase\r\nimport ProofColDivSeqPostulate\r\n\r\n%default total\r\n-- %language ElabReflection\r\n\r\n\r\n-- 3(12x+3) --E[2,-4]--> 3x\r\ne36x9To3x :\r\n (l:Nat) -> P (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))))) 2 -> P l 2\r\ne36x9To3x l prf =\r\n let prf2 = lvDown (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))))) 2 prf in e36x9To3x' l prf2\r\n\r\nexport\r\napply36x9 : P (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))))) 2\r\n -> (m : Nat ** (LTE (S m) (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))))), P m 2))\r\napply36x9 {l} col = let col2 = e36x9To3x l col in (l ** (lte36x9 l, col2)) where\r\n lte36x9 : (l:Nat) -> LTE (S l) (S (S (S (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l))))))\r\n lte36x9 Z = (lteSuccRight . lteSuccRight . LTESucc) LTEZero\r\n lte36x9 (S l) = let lemma = lte36x9 l in\r\n rewrite (sym (plusSuccRightSucc l l)) in\r\n rewrite (sym (plusSuccRightSucc (plus l l) (S (plus l l)))) in\r\n rewrite (sym (plusSuccRightSucc (plus l l) (plus l l))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus l l) (plus l l)) (S (S (S (plus (plus l l) (plus l l))))))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus l l) (plus l l)) (S (S (plus (plus l l) (plus l l)))))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus l l) (plus l l)) (S (plus (plus l l) (plus l l))))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l)))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (S (S (S (plus (plus l l) (plus l l))))))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (S (S (plus (plus l l) (plus l l)))))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (S (plus (plus l l) (plus l l))))) in\r\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))) in\r\n (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc) lemma\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "meta": {"hexsha": "dfa6cac8af67d4b9cc376a4b20bdb2f096e5aebb", "size": 2502, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program/Sub06Apply36x9.idr", "max_stars_repo_name": "righ1113/collatzProof_DivSeq", "max_stars_repo_head_hexsha": "eef9da457fe77f0b58fb4407ab128d38ada9071e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "program/Sub06Apply36x9.idr", "max_issues_repo_name": "righ1113/collatzProof_DivSeq", "max_issues_repo_head_hexsha": "eef9da457fe77f0b58fb4407ab128d38ada9071e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-26T12:59:21.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-19T07:02:00.000Z", "max_forks_repo_path": "program/Sub06Apply36x9.idr", "max_forks_repo_name": "righ1113/collatzProof_DivSeq", "max_forks_repo_head_hexsha": "eef9da457fe77f0b58fb4407ab128d38ada9071e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 61.0243902439, "max_line_length": 187, "alphanum_fraction": 0.5935251799, "num_tokens": 1013, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110396870288, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.545237193249364}} {"text": "module Prelude.Basics\n\nimport Builtin\n\n%default total\n\npublic export\nNot : Type -> Type\nNot x = x -> Void\n\n-----------------------\n-- UTILITY FUNCTIONS --\n-----------------------\n\n||| Manually assign a type to an expression.\n||| @ a the type to assign\n||| @ x the element to get the type\npublic export %inline\nthe : (0 a : Type) -> (1 x : a) -> a\nthe _ x = x\n\n||| Identity function.\npublic export %inline\nid : (1 x : a) -> a -- Hopefully linearity annotation won't\n -- break equality proofs involving id\nid x = x\n\n||| Function that duplicates its input\npublic export\ndup : a -> (a, a)\ndup x = (x, x)\n\n||| Constant function. Ignores its second argument.\npublic export %inline\nconst : a -> b -> a\nconst x = \\value => x\n\n||| Function composition.\npublic export %inline\n(.) : (b -> c) -> (a -> b) -> a -> c\n(.) f g = \\x => f (g x)\n\n||| Takes in the first two arguments in reverse order.\n||| @ f the function to flip\npublic export\nflip : (f : a -> b -> c) -> b -> a -> c\nflip f x y = f y x\n\n||| Function application.\npublic export\napply : (a -> b) -> a -> b\napply f a = f a\n\npublic export\ncurry : ((a, b) -> c) -> a -> b -> c\ncurry f a b = f (a, b)\n\npublic export\nuncurry : (a -> b -> c) -> (a, b) -> c\nuncurry f (a, b) = f a b\n\n-- $ is compiled specially to shortcut any tricky unification issues, but if\n-- it did have a type this is what it would be, and it might be useful to\n-- use directly sometimes (e.g. in higher order functions)\npublic export\n($) : forall a, b . ((x : a) -> b x) -> (x : a) -> b x\n($) f a = f a\n\n-------------------\n-- PROOF HELPERS --\n-------------------\n\n||| Equality is a congruence.\npublic export\ncong : (0 f : t -> u) -> (1 p : a = b) -> f a = f b\ncong f Refl = Refl\n\n||| Two-holed congruence.\nexport\n-- These are natural in equational reasoning.\ncong2 : (0 f : t1 -> t2 -> u) -> (1 p1 : a = b) -> (1 p2 : c = d) -> f a c = f b d\ncong2 f Refl Refl = Refl\n\n--------------\n-- BOOLEANS --\n--------------\n\n||| Boolean Data Type.\npublic export\ndata Bool = True | False\n\n||| Boolean NOT.\npublic export\nnot : (1 b : Bool) -> Bool\nnot True = False\nnot False = True\n\n||| Boolean AND only evaluates the second argument if the first is `True`.\npublic export\n(&&) : (1 b : Bool) -> Lazy Bool -> Bool\n(&&) True x = x\n(&&) False x = False\n\n||| Boolean OR only evaluates the second argument if the first is `False`.\npublic export\n(||) : (1 b : Bool) -> Lazy Bool -> Bool\n(||) True x = True\n(||) False x = x\n\n%inline\npublic export\nintToBool : Int -> Bool\nintToBool 0 = False\nintToBool x = True\n", "meta": {"hexsha": "106354b7023306d6868631dd174d2558da989a46", "size": 2545, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/prelude/Prelude/Basics.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/libs/prelude/Prelude/Basics.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/libs/prelude/Prelude/Basics.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1304347826, "max_line_length": 82, "alphanum_fraction": 0.5693516699, "num_tokens": 786, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.5451115660584112}} {"text": "import Data.List\n\n\n\n\ndata Color = White | Yellow | Orange | Red | Green | Blue\ndata Piece = Up | Down | Left | Right | Front | Back -- только для наглядности\n | UpFL | UpFR | UpBL | UpBR | DownFL | DownFR | DownBL | DownBR\n | LeftFU | LeftFD | LeftBU | LeftBD | RightFU | RightFD | RightBU | RightBD\n | FrontUL | FrontUR | FrontDL | FrontDR | BackUL | BackUR | BackDL | BackDR\n\nrecord Cube where\n constructor MkCube\n stickers : List Color\n pieces : List Piece\n groups : List ( -- список возможных поворотов\n List ( -- список групп перемещений наклеек\n List Piece)) -- группа перемещений наклеек\n blocks : List (List Piece)\n\n \ncube1x1x1 : Cube\ncube1x1x1 = MkCube [White, Yellow, Orange, Red, Green, Blue]\n [Up, Down, Left, Right, Front, Back]\n [ [ [Up, Back, Down, Front] ], -- x\n [ [Up, Right, Down, Left] ], -- y\n [ [Front, Right, Back, Left] ] ] -- z\n []\n \ncube2x2x2 : Cube\ncube2x2x2 = MkCube [White, White, White, White, Yellow, Yellow, Yellow, Yellow,\n Orange, Orange, Orange, Orange, Red, Red, Red, Red,\n Green, Green, Green, Green, Blue, Blue, Blue, Blue]\n [UpFL, UpFR, UpBL, UpBR, DownFL, DownFR, DownBL, DownBR,\n LeftFU, LeftFD, LeftBU, LeftBD, RightFU, RightFD, RightBU, RightBD,\n FrontUL, FrontUR, FrontDL, FrontDR, BackUL, BackUR, BackDL, BackDR]\n [ [ [UpFL, BackUL, DownBL, FrontDL],\n [UpFR, BackUR, DownBR, FrontDR],\n [UpBL, BackDL, DownFL, FrontUL],\n [UpBR, BackDR, DownFR, FrontUR],\n [LeftFU, LeftBU, LeftBD, LeftFD],\n [RightFU, RightBU, RightBD, RightFD] ], -- x\n [ [UpFL, RightFU, DownFR, LeftFD],\n [UpFR, RightFD, DownFL, LeftFU],\n [UpBL, RightBU, DownBR, LeftBD],\n [UpBR, RightBD, DownBL, LeftBU],\n [FrontUL, FrontUR, FrontDR, FrontDL],\n [BackUL, BackUR, BackDR, BackDL] ], -- y\n [ [UpFL, BackUL, DownBL, FrontDL],\n [UpBL, BackDL, DownFL, FrontUL],\n [LeftFU, LeftBU, LeftBD, LeftFD] ] ] -- L\n []\n \ncube1x2x2 : Cube\ncube1x2x2 = ?hole122\n-- cube1x2x2 = record {blocks = []} cube2x2x2\n \n \n\n\ntoNat : Piece -> Nat\ntoNat Up = 0\ntoNat Down = 1\ntoNat Left = 2\ntoNat Right = 3\ntoNat Front = 4\ntoNat Back = 5\ntoNat UpFL = 0 -- zn as indexation list\ntoNat UpFR = 1\ntoNat UpBL = 2\ntoNat UpBR = 3\ntoNat DownFL = 4\ntoNat DownFR = 5\ntoNat DownBL = 6\ntoNat DownBR = 7\ntoNat LeftFU = 8\ntoNat LeftFD = 9\ntoNat LeftBU = 10\ntoNat LeftBD = 11\ntoNat RightFU = 12\ntoNat RightFD = 13\ntoNat RightBU = 14\ntoNat RightBD = 15\ntoNat FrontUL = 16\ntoNat FrontUR = 17\ntoNat FrontDL = 18\ntoNat FrontDR = 19\ntoNat BackUL = 20\ntoNat BackUR = 21\ntoNat BackDL = 22\ntoNat BackDR = 23\n \nCast Piece Nat where\n cast piece = toNat piece\n \nEq Piece where\n x == y = (toNat x) == (toNat y)\n\nCast (List Piece) (List Nat) where\n cast [] = []\n cast (x :: xs) = cast x :: cast xs\n \nCast (List (List Piece)) (List (List Nat)) where\n cast [] = []\n cast (x :: xs) = cast x :: cast xs\n \nEq (Nat, Color) where\n (n1,_) == (n2,_) = n1 == n2\n\nOrd (Nat, Color) where\n compare (n1,_) (n2,_) = compare n1 n2\n \nShow Color where\n show White = \"White\"\n show Yellow = \"Yellow\"\n show Orange = \"Orange\"\n show Red = \"Red\"\n show Green = \"Green\"\n show Blue = \"Blue\"\n \nShow Cube where\n show cube = show (stickers cube)\n\n\nrotate : Nat -> Cube -> Maybe Cube\nrotate n cube = \n let group = indexT n (groups cube) in\n case checkBlocked group (blocks cube) of\n True => Nothing\n False => Just (record {stickers = multiperm (cast group) (stickers cube)} cube) where\n \n -- TODO stdlib\n indexT : Nat -> List (List a) -> List a\n indexT _ [] = []\n indexT Z (x :: xs) = x\n indexT (S k) (_ :: xs) = indexT k xs\n \n checkBlocked : List (List Piece) -> List (List Piece) -> Bool\n checkBlocked xs ys = alienElem (flat xs) (flat ys) where\n \n -- TODO stdlib\n flat : List (List a) -> List a\n flat [] = []\n flat ([] :: xxs) = flat xxs\n flat (l@(x :: xs) :: xxs) = l ++ flat xxs \n \n -- TODO stdlib\n isElem : Eq a => a -> List a -> Bool\n isElem _ [] = False\n isElem x (y :: ys) =\n if x == y\n then True\n else isElem x ys\n \n alienElem : Eq a => (checked : List a) -> (checker : List a) -> Bool\n alienElem [] _ = True -- not alien in first list\n alienElem _ [] = False -- find alien in first list\n alienElem (x :: xs) ys =\n if isElem x ys\n then alienElem xs ys\n else False\n \n\n multiperm : List (List Nat) -> List Color -> List Color\n multiperm [] xs = xs\n multiperm (i :: is) xs = multiperm is (perm i xs) where\n\n perm : List Nat -> List Color -> List Color\n perm is xs = new 0 xs . sort . get 0 xs . sort $ zip is (shift is) where\n \n new : (index : Nat) -> (elems : List Color) -> (saved : List (Nat, Color)) -> List Color\n new _ elems [] = elems\n new n (elem :: elems) saved@((i, savedElem) :: saveds) =\n if n == i\n then savedElem :: new (n+1) elems saveds\n else elem :: new (n+1) elems saved\n new _ _ _ = []\n \n get : (index : Nat) -> (elems : List Color) -> (indexs : List (Nat, Nat)) -> List (Nat, Color)\n get i (elem :: elems) indexs@((indexFrom, indexDest) :: indexsFromDest) =\n if i == indexFrom\n then (indexDest, elem) :: get (i + 1) elems indexsFromDest\n else get (i + 1) elems indexs\n get _ _ _ = []\n \n -- TODO stdlib\n shift : List Nat -> List Nat \n shift [] = []\n shift (x :: xs) = xs ++ [x]\n\nmain : IO ()\nmain = putStrLn . show . rotate 1 $ cube2x2x2\n", "meta": {"hexsha": "07015af7a3ac7338d504f719343cf3d5806ff335", "size": 6390, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "cube.idr", "max_stars_repo_name": "mjdtdw/rubik", "max_stars_repo_head_hexsha": "bd15aa5a23a670be9f05594dfd9453b1672fb90b", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "cube.idr", "max_issues_repo_name": "mjdtdw/rubik", "max_issues_repo_head_hexsha": "bd15aa5a23a670be9f05594dfd9453b1672fb90b", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cube.idr", "max_forks_repo_name": "mjdtdw/rubik", "max_forks_repo_head_hexsha": "bd15aa5a23a670be9f05594dfd9453b1672fb90b", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1088082902, "max_line_length": 106, "alphanum_fraction": 0.50657277, "num_tokens": 1865, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5449773567564169}} {"text": "data Input = Answer Int\n | QuitCmd\n\ndata Command : Type -> Type where\n PutStr : String -> Command ()\n GetLine : Command String\n Pure : ty -> Command ty\n Bind : Command a -> (a -> Command b) -> Command b\n\ndata ConsoleIO : Type -> Type where\n Quit : a -> ConsoleIO a\n Do : Command a -> (a -> Inf (ConsoleIO b)) -> ConsoleIO b\n\nrunCommand : Command a -> IO a\nrunCommand (PutStr x) = putStr x\nrunCommand GetLine = getLine\nrunCommand (Pure val) = pure val\nrunCommand (Bind c f) = do res <- runCommand c\n runCommand (f res)\n\n\nnamespace CommandDo\n (>>=) : Command a -> (a -> Command b) -> Command b\n (>>=) = Bind\n\nnamespace ConsoleDo\n (>>=) : Command a -> (a -> Inf (ConsoleIO b)) -> ConsoleIO b\n (>>=) = Do\n\nreadInput : (prompt : String) -> Command Input\nreadInput prompt = do PutStr prompt\n answer <- GetLine\n if toLower answer == \"quit\"\n then Pure QuitCmd\n else Pure (Answer (cast answer))\n\n\nmutual\n correct : Stream Int -> (score : Nat) -> (questions : Nat) -> ConsoleIO Nat\n correct nums score questions\n = do PutStr \"Correct!\\n\"\n quiz nums (score + 1) (questions + 1)\n\n wrong : Stream Int -> Int -> (score : Nat) -> (questions : Nat)\n -> ConsoleIO Nat\n wrong nums ans score questions\n = do PutStr (\"Wrong the answer is \" ++ show ans ++ \"\\n\")\n quiz nums score (questions + 1)\n\n quiz : Stream Int -> (score : Nat) -> (questions : Nat) -> ConsoleIO Nat\n quiz (num1 :: num2 :: nums) score questions\n = do PutStr (\"Score so far: \" ++ show score ++ \"\\n\")\n input <- readInput (show num1 ++ \" * \" ++ show num2 ++ \"? \") \n case input of\n Answer answer => if answer == num1 * num2\n then correct nums score questions\n else wrong nums (num1 * num2) score questions\n QuitCmd => Quit score\n", "meta": {"hexsha": "36031749a3bfb92b1edebcd6d2413cd3390ca502", "size": 1952, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp11/ArithCmdDo.idr", "max_stars_repo_name": "Ryxai/idris_book_notes", "max_stars_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "type_driven_book/chp11/ArithCmdDo.idr", "max_issues_repo_name": "Ryxai/idris_book_notes", "max_issues_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "type_driven_book/chp11/ArithCmdDo.idr", "max_forks_repo_name": "Ryxai/idris_book_notes", "max_forks_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0847457627, "max_line_length": 79, "alphanum_fraction": 0.5527663934, "num_tokens": 511, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.5449169888981954}} {"text": "import Data.Vect\n\nreadVect : IO (len ** Vect len String)\nreadVect = do x <- getLine\n if (x == \"\")\n then pure (_ ** [])\n else do (_ ** xs) <- readVect\n pure (_ ** x :: xs)\n\nzipInputs : IO ()\nzipInputs = do putStrLn \"Enter first vector (blank line to end):\"\n (len1 ** vec1) <- readVect\n putStrLn \"Enter second vector (blank line to end):\"\n (len2 ** vec2) <-readVect\n (case exactLength len1 vec2 of\n Nothing => putStrLn \"Vectors are of different lengths\"\n (Just vec2') => printLn (zip vec1 vec2'))\n", "meta": {"hexsha": "749df96f1ccb2fd3490ca53a6054d701ad9adb42", "size": 669, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp5/zipvect.idr", "max_stars_repo_name": "Ryxai/idris_book_notes", "max_stars_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "type_driven_book/chp5/zipvect.idr", "max_issues_repo_name": "Ryxai/idris_book_notes", "max_issues_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "type_driven_book/chp5/zipvect.idr", "max_forks_repo_name": "Ryxai/idris_book_notes", "max_forks_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.1666666667, "max_line_length": 75, "alphanum_fraction": 0.4783258595, "num_tokens": 152, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.7981867753392728, "lm_q1q2_score": 0.5448213280018582}} {"text": "module ExampleDetectableErrors\n\nimport Data.Nat\nimport Data.Vect\nimport Data.List\nimport LinearTypes\nimport Control.Linear.LIO\nimport Unitary\nimport QStateT\nimport System.Random\nimport Injection\nimport Complex\nimport QuantumOp\nimport Examples\n\n-------------------------------------- Impossible Unitaries ---------------------------------------\n-- In this example, we try to apply a Hadamard gate on a non-existing wire (index 4 on a gate of size 3)\n\nbrokenH : Unitary 3\n--brokenH = H 4 toffoli\n\n-- Error: While processing right hand side of brokenH. Can't find an implementation for == (compare 4 3) LT = True.\n\n\n\n\n-- In this example, we try to apply the control and the target of a CNOT on the same wire\n\nbrokenCNOT : Unitary 2\n--brokenCNOT = CNOT 1 1 IdGate\n\n-- Error: While processing right hand side of brokenCNOT. Can't find an implementation for not (== 1 1) = True.\n\n\n\n\n-- In this example, we try to apply a circuit on a non existing wire (index 4 on a gate of size 3)\n\nbrokenApply1 : Unitary 3\n--brokenApply1 = apply toBellBasis toffoli [1,4]\n\n-- Error: While processing right hand side of brokenApply1. Can't find an implementation for allSmaller [1, 4] 3 && Delay (allDifferent [1, 4]) = True.\n\n\n\n\n-- In this example, we try to apply a circuit twice on the same wire\n\nbrokenApply2 : Unitary 3\n--brokenApply2 = apply toffoli IdGate [1,2,1]\n\n-- Error: While processing right hand side of brokenApply2. Can't find an implementation for allSmaller [1, 2, 1] 3 && Delay (allDifferent [1, 2,1]) = True.\n\n\n--------------------------------- BROKEN QUANTUM STATE OPERATIONS ---------------------------------\n\n-- In this example, wew try to reuse a qubit that has be measured\n\nbrokenOp1 : IO (Vect 4 Bool)\n{-brokenOp1 = \n run (do\n [q1,q2,q3,q4] <- newQubits {t = SimulatedOp} 4\n [b3] <- measure [q3]\n [r4,r3,r1] <- applyUnitary [q4,q3,q1] (X 0 IdGate) --trying to reuse q3\n [b1,b4,b2] <- measure [r1,r4,q2]\n pure ([b1,b2,b3,b4])\n )\n -} \n-- Error: While processing right hand side of brokenOp1. q3 is not accessible in this context.\n\n\n\n-- In this example, we try to copy a qubit\n\nbrokenOp2 : IO (Vect 5 Bool)\n{-brokenOp2 = \n run (do\n [q1,q2,q3,q4] <- newQubits {t = SimulatedOp} 4\n [b3] <- measure [q3]\n [q4,q1,q5] <- applyUnitary [q4,q1,q4] (X 0 IdGate) --trying to copy q4\n [b1,b2,b5] <- measure [q1,q2,q5]\n pure [b1,b2,b3,b5,b5]\n )\n -}\n--Error : While processing right hand side of brokenOp2. There are 2 uses of linear name q4. \n\n\n\n-- In this example, we try to reuse a pointer to an old state of a qubit (the state of the qubit has been modified)\n\nbrokenOp3 : IO (Vect 4 Bool)\n{-brokenOp3 = \n run (do\n [q1,q2,q3,q4] <- newQubits {t = SimulatedOp} 4\n [b3] <- measure [q3]\n [r4,r2,r1] <- applyUnitary [q4,q2,q1] (X 0 IdGate) \n [b1,b4,b2] <- measure [r1,r4,q2] --trying to reuse the name q2\n pure ([b1,b2,b3,b4])\n )\n -}\n--Error: While processing right hand side of brokenOp2. q2 is not accessible in this context.\n\n", "meta": {"hexsha": "756ee1864291642e23a48862c61c7b975175c494", "size": 3026, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ExampleDetectableErrors.idr", "max_stars_repo_name": "zamdzhiev/Qimaera", "max_stars_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2021-08-24T14:36:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T00:36:11.000Z", "max_issues_repo_path": "ExampleDetectableErrors.idr", "max_issues_repo_name": "zamdzhiev/Qimaera", "max_issues_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ExampleDetectableErrors.idr", "max_forks_repo_name": "zamdzhiev/Qimaera", "max_forks_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.3786407767, "max_line_length": 156, "alphanum_fraction": 0.641440846, "num_tokens": 948, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.5448213244862414}} {"text": "module Linear\n\npublic export\ndata Usage = Once | Many\n\npublic export\ndata Use : Usage -> (Type -> Type) -> Type -> Type where\n Pure : (1 x : a) -> Use t m a\n BindOnce : (1 act : Use Once m a) -> (1 k : (1 x : a) -> Use t m b) -> Use t m b\n BindMany : (1 act : Use Many m a) -> (1 k : (x : a) -> Use t m b) -> Use t m b\n\npublic export\ncontType : (Type -> Type) -> Usage -> Usage -> Type -> Type -> Type\ncontType m Once q a b = ((1 x : a) -> Use q m b)\ncontType m Many q a b = ((x : a) -> Use q m b)\n\npublic export\n(>>=) : {p : _} -> (1 f : Use p m a) -> (1 k : contType m p q a b) -> Use q m b\n(>>=) {p = Once} = BindOnce\n(>>=) {p = Many} = BindMany\n\npublic export\npure : (1 x : a) -> Use t m a\npure = Pure\n\npublic export\nOne : (Type -> Type) -> Type -> Type\nOne = Use Once\n\npublic export\nAny : (Type -> Type) -> Type -> Type\nAny = Use Many\n", "meta": {"hexsha": "e93d70f138c74f0fb71621224d853a5c6a1ca17f", "size": 852, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/linear005/Linear.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/linear005/Linear.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/linear005/Linear.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 25.8181818182, "max_line_length": 85, "alphanum_fraction": 0.5363849765, "num_tokens": 308, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583695, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.5445220272395427}} {"text": "module Main\n\nrep : (n : Nat) -> a -> List a\nrep Z x = []\nrep (S k) x = x :: rep k x\n\ndata RLE : List Char -> Type where\n REnd : RLE []\n RChar : (n : Nat) -> (c : Char) -> (rs : RLE xs) ->\n RLE (rep n c ++ xs)\n\n------------\n\nrle : (xs : List Char) -> RLE xs\nrle [] = REnd\nrle (x :: xs) with (rle xs)\n rle (x :: []) | REnd = RChar 1 x REnd\n rle (x :: (rep n c ++ ys)) | (RChar n c rs) with (decEq x c)\n rle (x :: (rep n x ++ ys)) | (RChar n x rs) | (Yes refl) \n = RChar (S n) x rs\n rle (x :: (rep n c ++ ys)) | (RChar n c rs) | (No f) \n = RChar 1 x (RChar n c rs)\n\ncompress : List Char -> String\ncompress xs with (rle xs)\n compress [] | REnd = \"\" \n compress (rep n c ++ ys) | (RChar n c rs) \n = show n ++ strCons c (compress ys)\n\ncompressString : String -> String\ncompressString xs = compress (unpack xs)\n\nmain : IO ()\nmain = putStrLn (compressString \"foooobaaaarbaaaz\")\n", "meta": {"hexsha": "9de8bdba2c9933c9b4754ceaa3d89efa6fd05e53", "size": 932, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "RLE/rle.idr", "max_stars_repo_name": "silky/idris-demos", "max_stars_repo_head_hexsha": "1cda10e07d9c8205b9dd56048b1c2cc96f8e3e04", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-06-27T11:33:51.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-27T11:33:51.000Z", "max_issues_repo_path": "RLE/rle.idr", "max_issues_repo_name": "silky/idris-demos", "max_issues_repo_head_hexsha": "1cda10e07d9c8205b9dd56048b1c2cc96f8e3e04", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "RLE/rle.idr", "max_forks_repo_name": "silky/idris-demos", "max_forks_repo_head_hexsha": "1cda10e07d9c8205b9dd56048b1c2cc96f8e3e04", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 26.6285714286, "max_line_length": 62, "alphanum_fraction": 0.508583691, "num_tokens": 338, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680904463334, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.5433191123440495}} {"text": "import Data.Vect\n\ndvec : (n : Nat) -> {default (replicate n 1) xs : Vect n Nat} -> Nat\ndvec n = foldr (+) Z xs\n\n", "meta": {"hexsha": "c84a21872984b0c8d5638c8f3c4b2c4f47f8c04f", "size": 112, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/basic036/defimp.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/idris2/basic036/defimp.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/idris2/basic036/defimp.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.6666666667, "max_line_length": 68, "alphanum_fraction": 0.5892857143, "num_tokens": 43, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289388252252041, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.5428676673383597}} {"text": "module Main\n\ndata Identity a = Id a\n\nrunIdentity : Identity a -> a\nrunIdentity (Id a) = a\n\ninstance Functor Identity where\n map f (Id x) = Id (f x)\n\ninstance Applicative Identity where\n pure = Id\n (Id f) <$> (Id x) = Id (f x)\n\ninstance Monad Identity where\n (Id m) >>= f = f m\n\ndata Source : {r : Type} -> (m : Type -> Type) -> (a : Type) -> Type where\n Src : (r -> (r -> a -> m r) -> m r) -> Source {r} m a\n\nrunSource : {r : Type} -> Source {r} m a -> r -> (r -> a -> m r) -> m r\nrunSource (Src await) = await\n\nConduit : {r : Type} -> Type -> (Type -> Type) -> Type -> Type\nConduit {r} a m b = Source {r} m a -> Source {r} m b\n\nSink : {r : Type} -> Type -> (Type -> Type) -> Type -> Type\nSink {r} a m s = Source {r} m a -> m s\n\ninstance Functor (Source {r} m) where\n map f (Src await) = Src $ \\z, yield => await z (\\r => yield r . f)\n\nfoldM : Monad m => (r -> a -> m r) -> r -> List a -> m r\nfoldM f z [] = return z\nfoldM f z (x :: xs) = f z x >>= flip (foldM f) xs\n\nsource : {r : Type} -> (r -> (r -> a -> m r) -> m r) -> Source {r} m a\nsource = Src\n\nsourceList : Monad m => List a -> Source m a\nsourceList xs = source $ \\z, yield => foldM yield z xs\n\nmapC : Monad m => {r : Type} -> (a -> b) -> Conduit {r} a m b\nmapC = map\n\nsinkList : Monad m => Sink {r = List a} a m (List a)\nsinkList (Src await) = await Prelude.List.Nil (\\xs, x => return (x :: xs))\n\nmain : IO ()\nmain = print $ runIdentity $ sinkList $ mapC (+1) $ sourceList [1..10]\n", "meta": {"hexsha": "2ff05c1310ab0529bd83762ab3b8af8210fa45e7", "size": 1456, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Conduit/Simple.idr", "max_stars_repo_name": "jwiegley/simple-conduit", "max_stars_repo_head_hexsha": "a4c7e9d447b3321e91c0a5aa7872ec8d4c1bc283", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 13, "max_stars_repo_stars_event_min_datetime": "2015-01-27T23:13:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-28T13:21:32.000Z", "max_issues_repo_path": "Conduit/Simple.idr", "max_issues_repo_name": "jwiegley/simple-conduit", "max_issues_repo_head_hexsha": "a4c7e9d447b3321e91c0a5aa7872ec8d4c1bc283", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-02-15T19:32:12.000Z", "max_issues_repo_issues_event_max_datetime": "2015-02-16T22:35:26.000Z", "max_forks_repo_path": "Conduit/Simple.idr", "max_forks_repo_name": "jwiegley/simple-conduit", "max_forks_repo_head_hexsha": "a4c7e9d447b3321e91c0a5aa7872ec8d4c1bc283", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-05-27T15:25:38.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-28T13:21:44.000Z", "avg_line_length": 28.5490196078, "max_line_length": 74, "alphanum_fraction": 0.5432692308, "num_tokens": 517, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388167733099, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5428676618032586}} {"text": "module Prelude.Num\n\nimport Builtin\nimport Prelude.Basics\nimport Prelude.EqOrd\nimport Prelude.Ops\n\n%default total\n\n------------------------\n-- NUMERIC INTERFACES --\n------------------------\n\n%integerLit fromInteger\n\n||| The Num interface defines basic numerical arithmetic.\npublic export\ninterface Num ty where\n constructor MkNum\n (+) : ty -> ty -> ty\n (*) : ty -> ty -> ty\n ||| Conversion from Integer.\n fromInteger : Integer -> ty\n\n%allow_overloads fromInteger\n\n||| The `Neg` interface defines operations on numbers which can be negative.\npublic export\ninterface Num ty => Neg ty where\n constructor MkNeg\n ||| The underlying of unary minus. `-5` desugars to `negate (fromInteger 5)`.\n negate : ty -> ty\n (-) : ty -> ty -> ty\n\n||| Numbers for which the absolute value is defined should implement `Abs`.\npublic export\ninterface Num ty => Abs ty where\n constructor MkAbs\n ||| Absolute value.\n abs : ty -> ty\n\npublic export\ninterface Num ty => Fractional ty where\n constructor MkFractional\n partial\n (/) : ty -> ty -> ty\n partial\n recip : ty -> ty\n\n recip x = 1 / x\n\npublic export\ninterface Num ty => Integral ty where\n constructor MkIntegral\n partial\n div : ty -> ty -> ty\n partial\n mod : ty -> ty -> ty\n\n----- Instances for primitives\n\n-- Integer\n\n%inline\npublic export\nNum Integer where\n (+) = prim__add_Integer\n (*) = prim__mul_Integer\n fromInteger = id\n\n%inline\npublic export\nNeg Integer where\n negate x = prim__sub_Integer 0 x\n (-) = prim__sub_Integer\n\npublic export\nAbs Integer where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Integer where\n div x y\n = case y == 0 of\n False => prim__div_Integer x y\n mod x y\n = case y == 0 of\n False => prim__mod_Integer x y\n\n-- This allows us to pick integer as a default at the end of elaboration if\n-- all other possibilities fail. I don't plan to provide a nicer syntax for\n-- this...\n%defaulthint\n%inline\npublic export\ndefaultInteger : Num Integer\ndefaultInteger = %search\n\n-- Int\n\n%inline\npublic export\nNum Int where\n (+) = prim__add_Int\n (*) = prim__mul_Int\n fromInteger = prim__cast_IntegerInt\n\n%inline\npublic export\nNeg Int where\n negate x = prim__sub_Int 0 x\n (-) = prim__sub_Int\n\npublic export\nAbs Int where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Int where\n div x y\n = case y == 0 of\n False => prim__div_Int x y\n mod x y\n = case y == 0 of\n False => prim__mod_Int x y\n\n-- Int8\n\n%inline\npublic export\nNum Int8 where\n (+) = prim__add_Int8\n (*) = prim__mul_Int8\n fromInteger = prim__cast_IntegerInt8\n\n%inline\npublic export\nNeg Int8 where\n negate x = prim__sub_Int8 0 x\n (-) = prim__sub_Int8\n\npublic export\nAbs Int8 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Int8 where\n div x y\n = case y == 0 of\n False => prim__div_Int8 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Int8 x y\n\n-- Int16\n\n%inline\npublic export\nNum Int16 where\n (+) = prim__add_Int16\n (*) = prim__mul_Int16\n fromInteger = prim__cast_IntegerInt16\n\n%inline\npublic export\nNeg Int16 where\n negate x = prim__sub_Int16 0 x\n (-) = prim__sub_Int16\n\npublic export\nAbs Int16 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Int16 where\n div x y\n = case y == 0 of\n False => prim__div_Int16 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Int16 x y\n\n-- Int32\n\n%inline\npublic export\nNum Int32 where\n (+) = prim__add_Int32\n (*) = prim__mul_Int32\n fromInteger = prim__cast_IntegerInt32\n\n%inline\npublic export\nNeg Int32 where\n negate x = prim__sub_Int32 0 x\n (-) = prim__sub_Int32\n\npublic export\nAbs Int32 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Int32 where\n div x y\n = case y == 0 of\n False => prim__div_Int32 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Int32 x y\n\n-- Int64\n\n%inline\npublic export\nNum Int64 where\n (+) = prim__add_Int64\n (*) = prim__mul_Int64\n fromInteger = prim__cast_IntegerInt64\n\n%inline\npublic export\nNeg Int64 where\n negate x = prim__sub_Int64 0 x\n (-) = prim__sub_Int64\n\npublic export\nAbs Int64 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Int64 where\n div x y\n = case y == 0 of\n False => prim__div_Int64 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Int64 x y\n\n-- Bits8\n\n%inline\npublic export\nNum Bits8 where\n (+) = prim__add_Bits8\n (*) = prim__mul_Bits8\n fromInteger = prim__cast_IntegerBits8\n\n%inline\npublic export\nNeg Bits8 where\n negate x = prim__sub_Bits8 0 x\n (-) = prim__sub_Bits8\n\npublic export\nAbs Bits8 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Bits8 where\n div x y\n = case y == 0 of\n False => prim__div_Bits8 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Bits8 x y\n\n-- Bits16\n\n%inline\npublic export\nNum Bits16 where\n (+) = prim__add_Bits16\n (*) = prim__mul_Bits16\n fromInteger = prim__cast_IntegerBits16\n\n%inline\npublic export\nNeg Bits16 where\n negate x = prim__sub_Bits16 0 x\n (-) = prim__sub_Bits16\n\npublic export\nAbs Bits16 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Bits16 where\n div x y\n = case y == 0 of\n False => prim__div_Bits16 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Bits16 x y\n\n-- Bits32\n\n%inline\npublic export\nNum Bits32 where\n (+) = prim__add_Bits32\n (*) = prim__mul_Bits32\n fromInteger = prim__cast_IntegerBits32\n\n%inline\npublic export\nNeg Bits32 where\n negate x = prim__sub_Bits32 0 x\n (-) = prim__sub_Bits32\n\npublic export\nAbs Bits32 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Bits32 where\n div x y\n = case y == 0 of\n False => prim__div_Bits32 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Bits32 x y\n\n-- Bits64\n\n%inline\npublic export\nNum Bits64 where\n (+) = prim__add_Bits64\n (*) = prim__mul_Bits64\n fromInteger = prim__cast_IntegerBits64\n\n%inline\npublic export\nNeg Bits64 where\n negate x = prim__sub_Bits64 0 x\n (-) = prim__sub_Bits64\n\npublic export\nAbs Bits64 where\n abs x = if x < 0 then -x else x\n\npublic export\nIntegral Bits64 where\n div x y\n = case y == 0 of\n False => prim__div_Bits64 x y\n mod x y\n = case y == 0 of\n False => prim__mod_Bits64 x y\n\n-- Double\n\npublic export\nNum Double where\n (+) = prim__add_Double\n (*) = prim__mul_Double\n fromInteger = prim__cast_IntegerDouble\n\n%inline\npublic export\nNeg Double where\n negate x = prim__negate_Double x\n (-) = prim__sub_Double\n\npublic export\nAbs Double where\n abs x = if x < 0 then -x else x\n\npublic export\nFractional Double where\n (/) = prim__div_Double\n", "meta": {"hexsha": "7ef56a19f42b206100ae542482e0b766165a31da", "size": 6715, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/prelude/Prelude/Num.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "libs/prelude/Prelude/Num.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/prelude/Prelude/Num.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.0510752688, "max_line_length": 79, "alphanum_fraction": 0.6589724497, "num_tokens": 2087, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503206, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.542840155193458}} {"text": "module Ch03.Exercise_3_5_14\n\nimport Ch03.Arith\n\n%default total\n\nnumValueProofIs : {t : Term} ->\n (pf : IsNumValue t) ->\n (nv : NumValue ** (t = nv2t nv, pf = ConvertedFrom nv))\nnumValueProofIs {t = (v2t (Right nv))} (ConvertedFrom nv) = (nv ** (Refl, Refl))\n\nzeroNotSucc : {t : Term} ->\n (Zero = Succ t) -> Void\nzeroNotSucc Refl impossible\n\nsucc_inj : {t1, t2 : Term} ->\n (Succ t1 = Succ t2) ->\n (t1 = t2)\nsucc_inj Refl = Refl\n\nnv2t_inj : {nv1, nv2 : NumValue} ->\n (nv2t nv1 = nv2t nv2) ->\n (nv1 = nv2)\nnv2t_inj {nv1=Zero} {nv2=Zero} prf = Refl\nnv2t_inj {nv1=Zero} {nv2=Succ x} prf = absurd (zeroNotSucc prf)\nnv2t_inj {nv1=Succ x} {nv2=Zero} prf = absurd (zeroNotSucc (sym prf))\nnv2t_inj {nv1=Succ x} {nv2=Succ y} prf = cong (nv2t_inj (succ_inj prf))\n\nnumValueProofsUnique : {t : Term} ->\n (pf1 : IsNumValue t) ->\n (pf2 : IsNumValue t) ->\n (pf1 = pf2)\nnumValueProofsUnique pf1 pf2 with (numValueProofIs pf1)\n numValueProofsUnique pf1 pf2 | (nv ** (pf_t, pf_pf)) with (numValueProofIs pf2)\n numValueProofsUnique pf1 pf2 | (nv ** (pf_t, pf_pf)) | (nv' ** (pf_t', pf_pf')) = case nv2t_inj {nv1=nv} {nv2=nv'} (trans (sym pf_t) pf_t') of\n Refl => trans pf_pf (sym pf_pf')\nuniqueEval : (t : Term) ->\n (r : EvalsTo t t') ->\n (r' : EvalsTo t t'') ->\n (r = r') \nuniqueEval True EIfTrue _ impossible\nuniqueEval True EIfFalse _ impossible\nuniqueEval True (EIf _) _ impossible\nuniqueEval True (ESucc _) _ impossible\nuniqueEval True EPredZero _ impossible\nuniqueEval True EPredSucc _ impossible\nuniqueEval True (EPred _) _ impossible\nuniqueEval True EIsZeroZero _ impossible\nuniqueEval True EIsZeroSucc _ impossible\nuniqueEval True (EIsZero _) _ impossible\nuniqueEval False EIfTrue _ impossible\nuniqueEval False EIfFalse _ impossible\nuniqueEval False (EIf _) _ impossible\nuniqueEval False (ESucc _) _ impossible\nuniqueEval False EPredZero _ impossible\nuniqueEval False EPredSucc _ impossible\nuniqueEval False (EPred _) _ impossible\nuniqueEval False EIsZeroZero _ impossible\nuniqueEval False EIsZeroSucc _ impossible\nuniqueEval False (EIsZero _) _ impossible\nuniqueEval (IfThenElse True y z) EIfTrue EIfTrue = Refl\nuniqueEval (IfThenElse True y z) EIfTrue (EIf x) impossible\nuniqueEval (IfThenElse False y z) EIfFalse EIfFalse = Refl\nuniqueEval (IfThenElse False y z) EIfFalse (EIf x) impossible\nuniqueEval (IfThenElse True y z) (EIf w) EIfTrue impossible\nuniqueEval (IfThenElse False y z) (EIf w) EIfFalse impossible\nuniqueEval (IfThenElse x y z) (EIf w) (EIf s) = case uniqueEval x w s of\n Refl => Refl\nuniqueEval Zero EIfTrue _ impossible\nuniqueEval Zero EIfFalse _ impossible\nuniqueEval Zero (EIf _) _ impossible\nuniqueEval Zero (ESucc _) _ impossible\nuniqueEval Zero EPredZero _ impossible\nuniqueEval Zero EPredSucc _ impossible\nuniqueEval Zero (EPred _) _ impossible\nuniqueEval Zero EIsZeroZero _ impossible\nuniqueEval Zero EIsZeroSucc _ impossible\nuniqueEval Zero (EIsZero _) _ impossible\nuniqueEval (Succ x) (ESucc y) (ESucc z) = case uniqueEval x y z of\n Refl => Refl\nuniqueEval (Pred Zero) EPredZero EPredZero = Refl\nuniqueEval (Pred Zero) EPredZero (EPred x) impossible\nuniqueEval (Pred (Succ t')) (EPredSucc {pf=pf1}) (EPredSucc {pf=pf2}) = case numValueProofsUnique pf1 pf2 of\n Refl => Refl\nuniqueEval (Pred (Succ t')) (EPredSucc {pf}) (EPred x) = absurd (valuesDontEvaluate {pf=(numValueIsValue (succNumValueIsNumValue pf))} x)\nuniqueEval (Pred Zero) (EPred y) EPredZero = absurd (valuesDontEvaluate {pf=IsValue.ConvertedFrom (Right Zero)} y)\nuniqueEval (Pred (Succ t')) (EPred y) (EPredSucc {pf}) = absurd (valuesDontEvaluate {pf=(numValueIsValue (succNumValueIsNumValue pf))} y)\n\nuniqueEval (Pred x) (EPred y) (EPred z) = case uniqueEval x y z of\n Refl => Refl\nuniqueEval (IsZero Zero) EIsZeroZero EIsZeroZero = Refl\nuniqueEval (IsZero Zero) EIsZeroZero (EIsZero x) impossible\nuniqueEval (IsZero (Succ nv1)) (EIsZeroSucc {pf=pf1}) (EIsZeroSucc {pf=pf2}) = case numValueProofsUnique pf1 pf2 of\n Refl => Refl\nuniqueEval (IsZero (Succ nv1)) (EIsZeroSucc {pf}) (EIsZero x) = absurd (valuesDontEvaluate {pf=(numValueIsValue (succNumValueIsNumValue pf))} x)\nuniqueEval (IsZero Zero) (EIsZero y) EIsZeroZero impossible\nuniqueEval (IsZero (Succ nv1)) (EIsZero y) (EIsZeroSucc {pf}) = absurd (valuesDontEvaluate {pf=(numValueIsValue (succNumValueIsNumValue pf))} y)\nuniqueEval (IsZero x) (EIsZero y) (EIsZero z) = case uniqueEval x y z of\n Refl => Refl\n\n||| Proof that the one-step evaluation rules of the arithmetic language are deterministic (Ex. 3.5.14).\ndetVal : {t,t',t'' : Term} ->\n EvalsTo t t' ->\n EvalsTo t t'' ->\n (t' = t'')\ndetVal {t} pf pf' = case uniqueEval t pf pf' of\n Refl => Refl\n", "meta": {"hexsha": "0073d90e44a1ca009eb6b466c99420426ca9bec2", "size": 5276, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Ch03/Exercise_3_5_14.idr", "max_stars_repo_name": "mr-infty/tapl", "max_stars_repo_head_hexsha": "3934bfe42b93f84c1bf35b7b34cf30b3a7fd7399", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2020-02-27T13:52:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-15T11:38:28.000Z", "max_issues_repo_path": "Ch03/Exercise_3_5_14.idr", "max_issues_repo_name": "mr-infty/tapl", "max_issues_repo_head_hexsha": "3934bfe42b93f84c1bf35b7b34cf30b3a7fd7399", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ch03/Exercise_3_5_14.idr", "max_forks_repo_name": "mr-infty/tapl", "max_forks_repo_head_hexsha": "3934bfe42b93f84c1bf35b7b34cf30b3a7fd7399", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2021-03-13T04:56:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T07:08:45.000Z", "avg_line_length": 48.8518518519, "max_line_length": 146, "alphanum_fraction": 0.6408263836, "num_tokens": 1606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503206, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.5428401496673714}} {"text": "> module SequentialDecisionProblems.applications.Main\n\n> import Data.Fin\n> import Data.List\n> import Data.List.Quantifiers\n> import Data.So\n> import Effects\n> import Effect.Exception\n> import Effect.StdIO\n\n> import SequentialDecisionProblems.CoreTheory\n> import SequentialDecisionProblems.FullTheory\n> import SequentialDecisionProblems.TabBackwardsInduction\n> import SequentialDecisionProblems.Utils\n> import SequentialDecisionProblems.FastStochasticDefaults\n> import SequentialDecisionProblems.CoreTheoryOptDefaults\n> import SequentialDecisionProblems.FullTheoryOptDefaults\n> import SequentialDecisionProblems.TabBackwardsInductionOptDefaults\n\n> import SequentialDecisionProblems.applications.FreezeOrIncrease\n> import SequentialDecisionProblems.applications.GoodOrBad\n\n> import FastSimpleProb.SimpleProb\n> import FastSimpleProb.BasicOperations\n> import FastSimpleProb.BasicProperties\n> import FastSimpleProb.MonadicOperations\n> import FastSimpleProb.MonadicProperties\n> import FastSimpleProb.Measures\n> import FastSimpleProb.MeasuresProperties\n> import Sigma.Sigma\n> import Double.Predicates\n> import Double.Postulates\n> import Double.Operations\n> import Double.Properties\n> import NonNegDouble.NonNegDouble\n> import NonNegDouble.Constants\n> import NonNegDouble.BasicOperations\n> import NonNegDouble.Operations\n> import NonNegDouble.Properties\n> import NonNegDouble.Predicates\n> import NonNegDouble.LTEProperties\n> import Finite.Predicates\n> import Finite.Operations\n> import Finite.Properties\n> import Decidable.Predicates\n> import Decidable.Properties\n> import LocalEffect.Exception\n> import LocalEffect.StdIO\n> import Fin.Operations\n> import List.Operations\n> import Unit.Properties\n\n> -- %default total\n> %auto_implicits off\n\n> -- %logging 5\n\n\n* Introduction\n\nWe specify a first emissions game as a stochastic sequential decision\nproblem with a single decision maker.\n\n\n* Controls\n\nAt each decision step, the decision maker has two options: freezing\nemissions or increasing emissions:\n\n> SequentialDecisionProblems.CoreTheory.Ctrl _ _ = FreezeOrIncrease\n\n\n* States\n\nAt each decision step, the decision maker has to choose an option on the\nbases of two data: the amount of cumulated emissions and the state of\nthe world. The latter can be either good or bad:\n\n> SequentialDecisionProblems.CoreTheory.State t = (Fin (S t), GoodOrBad)\n\nThe idea is that the game starts with zero cumulated emissions and with\nthe world in the good state. In these conditions, the probability to\nturn to the bad state is low. But if the cumulated emissions increase\nbeyond a critical threshold, the probability that the state of the world\nturns bad increases. If the world is the bad state, there is no chance\nto come back to the good state. As for controls, it is useful to show\nthat |State| is finite:\n\n\n* Transition function\n\n> -- The critical threshold\n> cr : Double\n> cr = 0.0\n\n> -- The probability of staying in a good world when the cumulated\n> -- emissions are below the critical threshold\n> p1 : NonNegDouble\n> p1 = cast 0.65\n\n> -- The probabilities of staying in a good world when the cumulated\n> -- emissions are above the critical threshold\n> p2 : NonNegDouble\n> p2 = cast 0.1\n\n> -- The transition function: good world, freezing emissions\n> SequentialDecisionProblems.CoreTheory.nexts t (e, Good) Freeze =\n> let goodState = (weaken e, Good) in\n> let badState = (weaken e, Bad) in\n> if (fromFin e <= cr)\n> then mkSimpleProb [(goodState, p1), (badState, one - p1)]\n> else mkSimpleProb [(goodState, p2), (badState, one - p2)]\n\n> -- The transition function: good world, increasing emissions\n> SequentialDecisionProblems.CoreTheory.nexts t (e, Good) Increase =\n> let goodState = (FS e, Good) in\n> let badState = (FS e, Bad) in\n> if (fromFin e <= cr) then mkSimpleProb [(goodState, p1), (badState, one - p1)]\n> else mkSimpleProb [(goodState, p2), (badState, one - p2)]\n\n> -- The transition function: bad world, freezing emissions\n> SequentialDecisionProblems.CoreTheory.nexts t (e, Bad) Freeze =\n> let badState = (weaken e, Bad) in mkSimpleProb [(badState, one)]\n\n> -- The transition function: bad world, increasing emissions\n> SequentialDecisionProblems.CoreTheory.nexts t (e, Bad) Increase =\n> let badState = (FS e, Bad) in mkSimpleProb [(badState, one)]\n\n* |Val| and |LTE|:\n\n> SequentialDecisionProblems.CoreTheory.Val =\n> NonNegDouble.NonNegDouble\n \n> SequentialDecisionProblems.CoreTheory.plus =\n> NonNegDouble.Operations.plus\n\n> SequentialDecisionProblems.CoreTheory.zero =\n> fromInteger @{NumNonNegDouble} 0\n\n> SequentialDecisionProblems.CoreTheory.LTE =\n> NonNegDouble.Predicates.LTE\n\n> SequentialDecisionProblems.FullTheory.reflexiveLTE =\n> NonNegDouble.LTEProperties.reflexiveLTE\n\n> SequentialDecisionProblems.FullTheory.transitiveLTE =\n> NonNegDouble.LTEProperties.transitiveLTE\n \n> SequentialDecisionProblems.FullTheory.monotonePlusLTE =\n> NonNegDouble.LTEProperties.monotonePlusLTE\n\n> SequentialDecisionProblems.CoreTheoryOptDefaults.totalPreorderLTE =\n> NonNegDouble.LTEProperties.totalPreorderLTE\n\n\n* Reward function\n\nThe idea is that being in a good world yields one unit of benefits per\nstep and being in a bad world yield less benefits:\n\n> -- Ratio of the benefits in a bad world and the benefits in a good world\n> badOverGood : NonNegDouble\n> badOverGood = cast 0.5\n\n> -- Sanity check\n> badOverGoodLTEone : badOverGood `NonNegDouble.Predicates.LTE` one\n> badOverGoodLTEone = MkLTE Oh\n\nEmitting greenhouse gases also brings benefits. These are a fraction of\nthe step benefits in a good world and freezing emissions brings less\nbenefits than increasing emissions:\n\n> -- Ratio between freezing emissions benefits and step benefits (in a good world)\n> freezeOverGood : NonNegDouble\n> freezeOverGood = cast 0.1\n\n> -- Ratio between increasing emissions benefits and step benefits (in a good world)\n> increaseOverGood : NonNegDouble\n> increaseOverGood = cast 0.3\n\n> -- Sanity check\n> freezeOverGoodLTEone : freezeOverGood `NonNegDouble.Predicates.LTE` one\n> freezeOverGoodLTEone = MkLTE Oh\n\n> -- Sanity check\n> increaseOverGoodLTEone : increaseOverGood `NonNegDouble.Predicates.LTE` one\n> increaseOverGoodLTEone = MkLTE Oh\n\n> -- Sanity check\n> freezeLTEincrease : freezeOverGood `NonNegDouble.Predicates.LTE` increaseOverGood\n> freezeLTEincrease = MkLTE Oh\n\n> -- Reward function:\n> \n> using implementation NumNonNegDouble\n> \n> SequentialDecisionProblems.CoreTheory.reward _ _ Freeze (_, Good) =\n> one + one * freezeOverGood\n> SequentialDecisionProblems.CoreTheory.reward _ _ Increase (_, Good) =\n> one + one * increaseOverGood\n> SequentialDecisionProblems.CoreTheory.reward _ _ Freeze (_, Bad) =\n> one * badOverGood + one * freezeOverGood\n> SequentialDecisionProblems.CoreTheory.reward _ _ Increase (_, Bad) =\n> one * badOverGood + one * increaseOverGood\n\n\n* Completing the problem specification\n\nTo be able to apply the verified, generic backwards induction algorithm\nof |CoreTheory| to compute optimal policies for our problem, we have to\nexplain how the decision maker accounts for uncertainties on rewards\ninduced by uncertainties in the transition function. We first assume\nthat the decision maker measures uncertain rewards by their expected\nvalue:\n\n> SequentialDecisionProblems.CoreTheory.meas = expectedValue\n> SequentialDecisionProblems.FullTheory.measMon = monotoneExpectedValue\n\nFurther on, we have to implement the notions of viability and\nreachability. We start by positing that all states are viable for any\nnumber of steps:\n\n> -- Viable : (n : Nat) -> State t -> Type\n> SequentialDecisionProblems.CoreTheory.Viable n x = Unit\n\nFrom this definition, it trivially follows that all elements of an\narbitrary list of states are viable for an arbitrary number of steps:\n\n> viableLemma : {t, n : Nat} -> (xs : List (State t)) -> All (Viable n) xs\n> viableLemma Nil = Nil\n> viableLemma {t} {n} (x :: xs) = () :: (viableLemma {t} {n} xs)\n\nThis fact and the (less trivial) result that simple probability\ndistributions are never empty, see |nonEmptyLemma| in\n|MonadicProperties| in |SimpleProb|, allows us to show that the above\ndefinition of |Viable| fulfills |viableSpec1|:\n\n> -- viableSpec1 : (x : State t) -> Viable (S n) x -> GoodCtrl t x\n> SequentialDecisionProblems.CoreTheory.viableSpec1 {t} {n} s v =\n> MkSigma Freeze (ne, av) where\n> ne : SequentialDecisionProblems.CoreTheory.NotEmpty (nexts t s Freeze)\n> ne = nonEmptyLemma (nexts t s Freeze)\n> av : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} n) (nexts t s Freeze)\n> av = viableLemma {t = S t} (support (nexts t s Freeze))\n\n> SequentialDecisionProblems.Utils.finiteViable n x = finiteUnit\n\n> SequentialDecisionProblems.Utils.decidableViable n x = decidableUnit\n\nFor reachability, we proceed in a similar way. We say that all states\nare reachable\n\n> -- Reachable : State t' -> Type\n> SequentialDecisionProblems.CoreTheory.Reachable x' = Unit\n\nwhich immediately implies |reachableSpec1|:\n\n> -- reachableSpec1 : (x : State t) -> Reachable {t' = t} x -> (y : Ctrl t x) -> All (Reachable {t' = S t}) (nexts t x y)\n> SequentialDecisionProblems.CoreTheory.reachableSpec1 {t} x r y = all (nexts t x y) where\n> all : (sp : SimpleProb (State (S t))) -> SequentialDecisionProblems.CoreTheory.All (Reachable {t' = S t}) sp\n> all sp = all' (support sp) where\n> all' : (xs : List (State (S t))) -> Data.List.Quantifiers.All (Reachable {t' = S t}) xs\n> all' Nil = Nil\n> all' (x :: xs) = () :: (all' xs)\n\nand decidability of |Reachable|:\n\n> SequentialDecisionProblems.TabBackwardsInduction.decidableReachable x = decidableUnit\n\nFinally, we have to show that controls are finite\n\n> -- finiteCtrl : {t : Nat} -> (x : State t) -> Finite (Ctrl t x)\n> SequentialDecisionProblems.Utils.finiteCtrl _ = finiteFreezeOrIncrease\n\nand, in order to use the fast, tail-recursive tabulated version of\nbackwards induction, that states are finite:\n\n> SequentialDecisionProblems.TabBackwardsInduction.finiteState t =\n> finitePair (finiteFin) (finiteGoodOrBad)\n\n\n* Optimal policies, optimal decisions, ...\n\nWe can now apply the results of our |CoreTheory| and of the |FullTheory|\nto compute verified optimal policies, possible state-control sequences,\netc. To this end, we need to be able to show the outcome of the decision\nprocess. This means implemeting functions to print states and controls:\n\n> -- showState : {t : Nat} -> State t -> String\n> SequentialDecisionProblems.Utils.showState {t} (e, Good) =\n> \"(\" ++ show (finToNat e) ++ \",Good)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, Bad) =\n> \"(\" ++ show (finToNat e) ++ \",Bad)\"\n\n> -- showControl : {t : Nat} -> {x : State t} -> Ctrl t x -> String\n> SequentialDecisionProblems.Utils.showCtrl {t} {x} Freeze = \"Freeze\"\n> SequentialDecisionProblems.Utils.showCtrl {t} {x} Increase = \"Increase\"\n\n>\n> using implementation ShowNonNegDouble\n> \n> computation : { [STDIO] } Eff ()\n> computation =\n> do putStr (\"enter number of steps:\\n\")\n> nSteps <- getNat\n> case (decidableViable {t = Z} nSteps (FZ, Good)) of\n> (Yes v) => do putStrLn (\"computing optimal policies ...\")\n> -- ps <- pure (backwardsInduction Z nSteps)\n> ps <- pure (tabTailRecursiveBackwardsInduction Z nSteps)\n> putStrLn (\"computing optimal controls ...\")\n> mxys <- pure (possibleStateCtrlSeqs (FZ, Good) () v ps)\n> putStrLn \"possible state-control sequences:\"\n> putStr \" \"\n> putStrLn (showlong mxys)\n> mvs <- pure (possibleRewards' mxys)\n> putStrLn \"possible rewards:\"\n> putStr \" \"\n> putStrLn (show mvs)\n> putStrLn (\"done!\")\n> (No _) => putStrLn (\"initial state non viable for \" ++ cast {from = Int} (cast nSteps) ++ \" steps\")\n\n> main : IO ()\n> main = run computation\n\n\n> {-\n\n> ---}\n\n\n-- Local Variables:\n-- idris-packages: (\"effects\")\n-- End:\n", "meta": {"hexsha": "40609989d3565e9b11437093a8c07ecb408cb2a8", "size": 12136, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionProblems/applications/EmissionsGame1.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SequentialDecisionProblems/applications/EmissionsGame1.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SequentialDecisionProblems/applications/EmissionsGame1.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.3353293413, "max_line_length": 121, "alphanum_fraction": 0.7268457482, "num_tokens": 3090, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5427564200440753}} {"text": "> module NonNegDouble.Properties\n\n> import Data.So\n> import Syntax.PreorderReasoning\n\n> import Double.Predicates\n> import Double.Postulates\n> import Double.Properties\n> import NonNegDouble.NonNegDouble\n> import NonNegDouble.Constants\n> import NonNegDouble.BasicOperations\n> import NonNegDouble.Operations\n> import List.Operations\n> import Subset.Properties\n> import Pairs.Operations\n> import Unique.Predicates\n\n> %default total\n> %access public export\n\n\n* Positivity of constants\n\n> ||| zero is not positive\n> notPositiveZero : Not (Positive (toDouble NonNegDouble.Constants.zero))\n> notPositiveZero = s3 where\n> s0 : toDouble (Element 0.0 (MkLTE Oh)) = 0.0\n> s0 = Refl\n> s1 : Element 0.0 (MkLTE Oh) = NonNegDouble.Constants.zero\n> s1 = Refl\n> s2 : toDouble NonNegDouble.Constants.zero = 0.0\n> s2 = replace {P = \\ X => toDouble X = 0.0} s1 s0 \n> s3 : Not (Positive (toDouble NonNegDouble.Constants.zero))\n> s3 = replace {P = \\ X => Not (Positive X)} (sym s2) Double.Properties.notPositiveZero \n\n> ||| one is positive\n> positiveOne : Positive (toDouble NonNegDouble.Constants.one)\n> positiveOne = MkLT Oh\n\n\n* Implementations:\n\n> ||| NonNegDouble is an implementation of Show\n> -- implementation [ShowNonNegDouble] Show NonNegDouble where\n> implementation [ShowNonNegDouble] Show NonNegDouble where\n> show = show . toDouble \n\n> ||| NonNegDouble is an implementation of Num\n> implementation [NumNonNegDouble] Num NonNegDouble where\n> (+) = plus\n> (*) = mult\n> fromInteger = fromNat . fromIntegerNat\n\n> using implementation NumNonNegDouble\n> ||| NonNegDouble is an implementation of Fractional\n> implementation [FractionalNonNegDouble] Fractional NonNegDouble where\n> (/) = div\n\n> ||| NonNegDouble is an implementation of Eq\n> implementation [EqNonNegDouble] Eq NonNegDouble where\n> (==) x y = (toDouble x) == (toDouble y)\n\n> using implementation NumNonNegDouble\n> using implementation EqNonNegDouble\n> ||| NonNegDouble is an implementation of Ord\n> implementation [OrdNonNegDouble] Ord NonNegDouble where\n> compare x y = compare (toDouble x) (toDouble y)\n\n\n* Properties of |toDouble|:\n\n> using implementation NumNonNegDouble\n> ||| \n> toDoublePlusLemma : (x : NonNegDouble) -> (y : NonNegDouble) -> toDouble (x + y) = (toDouble x) + (toDouble y)\n> toDoublePlusLemma (Element x px) (Element y py) = \n> ( toDouble ((Element x px) + (Element y py)) )\n> ={ Refl }=\n> ( toDouble (plus (Element x px) (Element y py)) )\n> ={ Refl }=\n> ( toDouble (Element (x + y) (plusPreservesNonNegativity px py)) )\n> ={ Refl }=\n> ( x + y )\n> ={ Refl }=\n> ( (toDouble (Element x px)) + (toDouble (Element y py)) )\n> QED\n\n> using implementation NumNonNegDouble\n> ||| \n> toDoubleMultLemma : (x : NonNegDouble) -> (y : NonNegDouble) -> toDouble (x * y) = (toDouble x) * (toDouble y)\n> toDoubleMultLemma (Element x px) (Element y py) = \n> ( toDouble ((Element x px) * (Element y py)) )\n> ={ Refl }=\n> ( toDouble (mult (Element x px) (Element y py)) )\n> ={ Refl }=\n> ( toDouble (Element (x * y) (multPreservesNonNegativity px py)) )\n> ={ Refl }=\n> ( x * y )\n> ={ Refl }=\n> ( (toDouble (Element x px)) * (toDouble (Element y py)) )\n> QED\n\n> using implementation FractionalNonNegDouble\n> ||| \n> toDoubleDivLemma : (x : NonNegDouble) -> (y : NonNegDouble) -> toDouble (x / y) = (toDouble x) / (toDouble y)\n> toDoubleDivLemma (Element x px) (Element y py) = \n> ( toDouble ((Element x px) / (Element y py)) )\n> ={ Refl }=\n> ( toDouble (div (Element x px) (Element y py)) )\n> ={ Refl }=\n> ( toDouble (Element (x / y) (divPreservesNonNegativity px py)) )\n> ={ Refl }=\n> ( x / y )\n> ={ Refl }=\n> ( (toDouble (Element x px)) / (toDouble (Element y py)) )\n> QED\n\n\n* Properties entailed by postulates and properties of |Double|s:\n\n> using implementation FractionalNonNegDouble\n> |||\n> divPreservesPositivity : {x, y : NonNegDouble} -> \n> Positive (toDouble x) -> Positive (toDouble y) -> Positive (toDouble (x / y))\n> divPreservesPositivity {x} {y} pdx pdy = replace s1 s2 where\n> s1 : (toDouble x) / (toDouble y) = toDouble (x / y)\n> s1 = sym (toDoubleDivLemma x y)\n> s2 : Positive ((toDouble x) / (toDouble y))\n> s2 = Double.Postulates.divPreservesPositivity pdx pdy\n\n> using implementation NumNonNegDouble\n> |||\n> plusAssociative : (x : NonNegDouble) -> (y : NonNegDouble) -> (z : NonNegDouble) -> \n> x + (y + z) = (x + y) + z\n> plusAssociative (Element x px) (Element y py) (Element z pz) =\n> ( Element x px + ((Element y py) + (Element z pz)) )\n> ={ Refl }=\n> ( Element x px + Element (y + z) (plusPreservesNonNegativity py pz) ) \n> ={ Refl }=\n> ( Element (x + (y + z)) (plusPreservesNonNegativity px (plusPreservesNonNegativity py pz)) ) \n> ={ subsetEqLemma1 (Element (x + (y + z)) (plusPreservesNonNegativity px (plusPreservesNonNegativity py pz))) \n> (Element ((x + y) + z) (plusPreservesNonNegativity (plusPreservesNonNegativity px py) pz)) \n> (plusAssociative x y z) uniqueLTE }=\n> ( Element ((x + y) + z) (plusPreservesNonNegativity (plusPreservesNonNegativity px py) pz) )\n> ={ Refl }=\n> ( Element (x + y) (plusPreservesNonNegativity px py) + Element z pz )\n> ={ Refl }=\n> ( ((Element x px) + (Element y py)) + Element z pz )\n> QED \n\n> {-\n\n> ---}\n\n\n\n\n\n", "meta": {"hexsha": "a2cfc6538d3c0c7286dd99d7de3d4a2be50c82cd", "size": 5542, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "NonNegDouble/Properties.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "NonNegDouble/Properties.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NonNegDouble/Properties.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 35.0759493671, "max_line_length": 115, "alphanum_fraction": 0.6250451101, "num_tokens": 1668, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527906914787, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.5427201631139723}} {"text": "module Algebra.Monoid\n\nimport Data.List\n\n%default total\n\n||| This interface is a witness that for a\n||| type `a` the axioms of a monoid hold: `(<+>)` is associative\n||| with `neutral` being the neutral element.\npublic export\ninterface Monoid a => LMonoid a where\n 0 appendAssociative : {x,y,z : a} -> x <+> (y <+> z) === (x <+> y) <+> z\n\n 0 appendLeftNeutral : {x : a} -> Prelude.neutral <+> x === x\n\n 0 appendRightNeutral : {x : a} -> x <+> Prelude.neutral === x\n\nexport\nLMonoid (List a) where\n appendAssociative = Data.List.appendAssociative _ _ _\n appendRightNeutral = appendNilRightNeutral _\n appendLeftNeutral = Refl\n\nunsafeRefl : a === b\nunsafeRefl = believe_me (Refl {x = a})\n\nexport\nLMonoid String where\n appendAssociative = unsafeRefl\n appendRightNeutral = unsafeRefl\n appendLeftNeutral = unsafeRefl\n\n||| This interface is a witness that for a\n||| type `a` the axioms of a commutative monoid hold:\n||| `(<+>)` is commutative.\npublic export\ninterface LMonoid a => CommutativeMonoid a where\n 0 appendCommutative : {x,y : a} -> x <+> y === y <+> x\n", "meta": {"hexsha": "42cb88128dfe482c7277cb2609d39da3394f574e", "size": 1064, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Algebra/Monoid.idr", "max_stars_repo_name": "stefan-hoeck/idris2-prim", "max_stars_repo_head_hexsha": "d342072f3b30f7930221bab620a836e0e67c2374", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2022-03-13T22:37:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:22:30.000Z", "max_issues_repo_path": "src/Algebra/Monoid.idr", "max_issues_repo_name": "stefan-hoeck/idris2-prim", "max_issues_repo_head_hexsha": "d342072f3b30f7930221bab620a836e0e67c2374", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra/Monoid.idr", "max_forks_repo_name": "stefan-hoeck/idris2-prim", "max_forks_repo_head_hexsha": "d342072f3b30f7930221bab620a836e0e67c2374", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.2820512821, "max_line_length": 74, "alphanum_fraction": 0.6795112782, "num_tokens": 333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199552262967, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5426087143167215}} {"text": "-- ----------------------------------------------------------- [ Chapter11.idr ]\n-- Module : Exercises.Chapter11\n-- Description : Solutions to the Chapter 11 exercises in Edwin Brady's\n-- book, \"Type-Driven Development with Idris.\"\n-- --------------------------------------------------------------------- [ EOH ]\nmodule Exercises.Chapter11\n\nimport Data.Primitives.Views\nimport Test\n\n%access export\n%default total\n\n-- ------------------------------------------------------- [ Exercise 11.1.7.1 ]\n\neveryOther : Stream a -> Stream a\neveryOther (_ :: x :: xs) = x :: everyOther xs\n\n-- ------------------------------------------------------ [ Exercises 11.1.7.2 ]\n\n||| Generic infinite lists\ndata InfList : (elem : Type) -> Type where\n ||| An infinite list, consisting of a head element and an infinite list.\n (::) : (x : elem) -> (xs : Inf (InfList elem)) -> InfList elem\n\n%name InfList xs, ys, zs\n\ncountFrom : Integer -> InfList Integer\ncountFrom x = x :: countFrom (x + 1)\n\ngetPrefix : (count : Nat) -> InfList a -> List a\ngetPrefix Z _ = []\ngetPrefix (S k) (x :: xs) = x :: getPrefix k xs\n\nimplementation Functor InfList where\n map f (x :: xs) = f x :: map f xs -- FIXME: Delay is implicit, right?\n\n-- ------------------------------------------------------- [ Exercise 11.1.7.3 ]\n\nrandoms : Int -> Stream Int\nrandoms seed = let seed' = 1664525 * seed + 1013904223 in\n (seed' `shiftR` 2) :: randoms seed'\n\n{-\nmutual\n even : Nat -> Bool\n even Z = True\n even (S k) = odd k\n\n odd : Nat -> Bool\n odd Z = False\n odd (S k) = even k\n-}\n\n||| The faces of a coin, heads or tails.\ndata Face = Heads | Tails\n\nimplementation Eq Face where\n (==) Heads Heads = True\n (==) Tails Tails = True\n (==) _ _ = False\n\nsyntax [test] \"?\" [t] \":\" [e] = if test then t else e;\n\nprivate\ngetFace : Int -> Face\ngetFace x with (divides x 2)\n getFace (_ + rem) | (DivBy _) = (rem == 1) ? Tails : Heads\n\ncoinFlips : (count : Nat) -> Stream Int -> List Face\ncoinFlips Z _ = []\ncoinFlips (S k) (x :: xs) = getFace x :: coinFlips k xs\n\n-- ------------------------------------------------------- [ Exercise 11.1.7.4 ]\n\nprivate\nsquareRootApprox : (number, approx : Double) -> Stream Double\nsquareRootApprox number approx =\n let next = (approx + (number / approx)) / 2\n in approx :: squareRootApprox number next\n\n-- ------------------------------------------------------- [ Exercise 11.1.7.5 ]\n\nsquareRootBound : (max : Nat) -> (number, bound : Double)\n -> (approxs : Stream Double)\n -> Double\nsquareRootBound Z _ _ (x :: _) = x\nsquareRootBound (S k) number bound (x :: xs) =\n if bound > abs (x * x)\n then x\n else squareRootBound k number bound xs\n\nsquareRoot : (number : Double) -> Double\nsquareRoot number = squareRootBound 100 number 0.00000000001\n (squareRootApprox number number)\n\n-- ------------------------------------------------------------------- [ InfIO ]\n\nnamespace InfIO\n data InfIO : Type where\n Do : IO a -> (a -> Inf InfIO) -> InfIO\n\n (>>=) : IO a -> (a -> Inf InfIO) -> InfIO\n (>>=) = Do\n\ndata Fuel = Dry | More (Lazy Fuel)\n\ntank : Nat -> Fuel\ntank Z = Dry\ntank (S k) = More (tank k)\n\npartial\nforever : Fuel\nforever = More forever\n\nrun : Fuel -> InfIO -> IO ()\nrun Dry _ = putStrLn \"Out of fuel\"\nrun (More fuel) (Do c f) = do res <- c\n run fuel (f res)\n\n-- --------------------------------------------------------- [ Exercise 11.2.7 ]\n\ntotalREPL : (prompt : String) -> (action : String -> String) -> InfIO\ntotalREPL prompt action\n = do putStr prompt\n input <- getLine\n putStr (action input)\n totalREPL prompt action\n\n-- ------------------------------------------ [ 11.3.2 Domain Specific Comands ]\n\ndata Command : Type -> Type where\n PutStr : String -> Command ()\n PutStrLn : String -> Command ()\n GetLine : Command String\n\n Pure : ty -> Command ty\n Bind : Command a -> (a -> Command b) -> Command b\n\n-- ------------------------------------------------------- [ Exercise 11.3.4.2 ]\n ReadFile : (filepath : String) -> Command (Either FileError String)\n WriteFile : (filepath, contents : String) -> Command (Either FileError ())\n\nnamespace CommandDo\n (>>=) : Command a -> (a -> Command b) -> Command b\n (>>=) = Bind\n\nrunCommand : Command a -> IO a\nrunCommand (PutStr str) = putStr str\nrunCommand (PutStrLn str) = putStrLn str\nrunCommand GetLine = getLine\nrunCommand (Pure val) = pure val\nrunCommand (Bind c f) = runCommand c >>= runCommand . f\nrunCommand (ReadFile filepath) = readFile filepath\nrunCommand (WriteFile filepath contents) = writeFile filepath contents\n\ndata ConsoleIO : Type -> Type where\n Quit : a -> ConsoleIO a\n Do : Command a -> (a -> Inf (ConsoleIO b)) -> ConsoleIO b\n\nnamespace ConsoleDo\n (>>=) : Command a -> (a -> Inf (ConsoleIO b)) -> ConsoleIO b\n (>>=) = Do\n\n run : Fuel -> ConsoleIO a -> IO (Maybe a)\n run fuel (Quit val) = do pure (Just val)\n run (More fuel) (Do c f) = do res <- runCommand c\n run fuel (f res)\n run Dry p = pure Nothing\n\n run_ : Fuel -> ConsoleIO a -> IO ()\n run_ fuel (Quit val) = pure ()\n run_ (More fuel) (Do c f) = do res <- runCommand c\n run_ fuel (f res)\n run_ Dry p = pure ()\n\n partial\n runForever : ConsoleIO a -> IO (Maybe a)\n runForever = run forever\n\n partial\n runForever_ : ConsoleIO a -> IO ()\n runForever_ = run_ forever\n\n-- ---------------------------------------------- [ 11.3.3 Sequencing Commands ]\n\ndata Input = Answer Int\n | QuitCmd\n\nreadInput : (prompt : String) -> Command Input\nreadInput prompt = do PutStr prompt\n answer <- GetLine\n if toLower answer == \"quit\"\n then Pure QuitCmd\n else Pure (Answer (cast answer))\n\n-- ------------------------------------------------------- [ Exercise 11.3.4.1 ]\n\nrecord QuizState where\n constructor MkQuizState\n score, attempts : Nat\n\nimplementation Show QuizState where\n show (MkQuizState score attempts)\n = show score ++ \" / \" ++ show attempts\n\nprivate\narithInputs : (seed : Int) -> Stream Int\narithInputs seed = map bound (randoms seed)\n where\n bound : Int -> Int\n bound num with (divides num 12)\n bound ((12 * div) + rem) | (DivBy prf) = abs rem + 1\n\nmutual\n correct : Stream Int -> QuizState -> ConsoleIO QuizState\n correct nums state\n = do PutStrLn \"Correct!\"\n quiz nums (record { score $= (+ 1) } state)\n\n wrong : Stream Int -> Int -> QuizState -> ConsoleIO QuizState\n wrong nums answer state\n = do PutStrLn $ \"Wrong, the answer is: \" ++ show answer\n quiz nums state\n\n quiz : Stream Int -> QuizState -> ConsoleIO QuizState\n quiz (num1 :: num2 :: nums) state\n = do PutStrLn $ \"Score so far: \" ++ show state\n input <- readInput $ show num1 ++ \" * \" ++ show num2 ++ \"? \"\n case input of\n Answer answer =>\n let newState = record { attempts $= (+ 1) } state\n correctAnswer = num1 * num2 in\n if answer == correctAnswer\n then correct nums newState\n else wrong nums correctAnswer newState\n QuitCmd =>\n Quit state\n\n-- ------------------------------------------------------- [ Exercise 11.3.4.3 ]\n\nmutual\n ||| Read the contents of a file and print it to stdout with a trailing\n ||| newline. Print an error message if filename is not a normal file.\n cat : (filename : String) -> ConsoleIO ()\n cat filename\n = do Right contents <- ReadFile filename\n | Left err => do PutStrLn (show err)\n shell\n PutStrLn contents\n shell\n\n ||| Read the contents of a source file and write it to a destination file.\n ||| Print an error message if anything goes wrong.\n ||| @ source a source filepath, must be a normal file\n ||| @ destination a destination filepath, must be writable\n copy : (source, destination : String) -> ConsoleIO ()\n copy source destination\n = do Right contents <- ReadFile source\n | Left err => do PutStrLn (show err)\n shell\n Right () <- WriteFile destination contents\n | Left err => do PutStrLn (show err)\n shell\n shell\n\n ||| Print a warning about an invalid command.\n ||| @ command a string that represents an invalid command\n invalidCommand : (command : String) -> ConsoleIO ()\n invalidCommand command\n = do PutStrLn (\"Invalid command: \" ++ command)\n shell\n\n ||| Quit the shell.\n exit : ConsoleIO ()\n exit = Quit ()\n\n ||| Run a limited, interactive shell.\n ||| Supported commands:\n ||| - cat [filename]\n ||| - copy [source] [destination]\n ||| - exit\n shell : ConsoleIO ()\n shell = do PutStr \"> \"\n input <- GetLine\n case words input of\n [\"exit\"] => exit\n [\"cat\", filepath] => cat filepath\n [\"copy\", source, destination] => copy source destination\n _ => invalidCommand input\n\n-- ------------------------------------------------------------------- [ Tests ]\n\ntestEveryOther : IO ()\ntestEveryOther = assertEq [2,4..20] $ take 10 (everyOther [1..])\n\ntestInfListFunctor : IO ()\ntestInfListFunctor = assertEq [2,4..20] $ getPrefix 10 (map (*2) (countFrom 1))\n\ntestCoinFlips : IO ()\ntestCoinFlips = assertEq [Tails,Heads,Tails,Tails,Heads,Tails] $\n coinFlips 6 (randoms 12345)\n\ntestSquareRootApprox1 : IO ()\ntestSquareRootApprox1 = assertEq [10.0,5.5,3.659090909090909] $\n take 3 (squareRootApprox 10 10)\n\ntestSquareRootApprox2 : IO ()\ntestSquareRootApprox2 = assertEq [25.0,14.5,10.698275862068964] $\n take 3 (squareRootApprox 100 25)\n\ntestSquareRoot1 : IO ()\ntestSquareRoot1 = assertEq 2.449489742783178 (squareRoot 6)\n\ntestSquareRoot2 : IO ()\ntestSquareRoot2 = assertEq 50.0 (squareRoot 2500)\n\ntestSquareRoot3 : IO ()\ntestSquareRoot3 = assertEq 50.009999000199954 (squareRoot 2501)\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "567979ce8467328efb00ae6b96b1d71f5d1ac28c", "size": 10357, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Exercises/Chapter11.idr", "max_stars_repo_name": "yurrriq/tdd-with-idris", "max_stars_repo_head_hexsha": "873c6c719706d06179527c5d93982bb7c184da90", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-15T01:29:36.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-15T01:29:36.000Z", "max_issues_repo_path": "src/Exercises/Chapter11.idr", "max_issues_repo_name": "yurrriq/tdd-with-idris", "max_issues_repo_head_hexsha": "873c6c719706d06179527c5d93982bb7c184da90", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2016-11-21T23:42:45.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-01T05:43:10.000Z", "max_forks_repo_path": "src/Exercises/Chapter11.idr", "max_forks_repo_name": "yurrriq/tdd-with-idris", "max_forks_repo_head_hexsha": "873c6c719706d06179527c5d93982bb7c184da90", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1645962733, "max_line_length": 80, "alphanum_fraction": 0.5368349908, "num_tokens": 2657, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.760650658103136, "lm_q1q2_score": 0.541759879663589}} {"text": "||| Prime, coprime, compositie types for `Nat`\n||| Extremely slow, but it totally works.\nmodule Extra.Nat.Prime\n\nimport Data.Fin\nimport Data.Nat\nimport Data.Nat.Factor\nimport Data.Nat.Order\nimport Data.Nat.Order.Properties\nimport Decidable.Decidable\n\n||| A witness of two numbers being relatively prime\npublic export\ndata Coprime : Nat -> Nat -> Type where\n MkCoprime : GCD 1 a b -> Coprime a b\n\n||| A witness of two numbers not being relatively prime\npublic export\ndata NotCoprime : Nat -> Nat -> Type where\n MkNotCoprime0 : GCD 0 a b -> NotCoprime a b\n MkNotCoprime2 : GCD (S (S n)) a b -> NotCoprime a b\n\n||| Coprimality of two `Nat`s\npublic export\ndata Coprimality : Nat -> Nat -> Type where\n TheyAreCoprime : Coprime a b -> Coprimality a b\n TheyArentCoprime : NotCoprime a b -> Coprimality a b\n\n||| Calculate the coprimality of two `Nat`s\npublic export\ncoprimality : (a : Nat) -> (b : Nat) -> {auto ok: NotBothZero a b} -> Coprimality a b\ncoprimality a b with (Data.Nat.Factor.gcd a b)\n coprimality a b | (0 ** gcd_a_b) = TheyArentCoprime (MkNotCoprime0 gcd_a_b)\n coprimality a b | (1 ** gcd_a_b) = TheyAreCoprime (MkCoprime gcd_a_b)\n coprimality a b | ((S (S n)) ** gcd_a_b) = TheyArentCoprime (MkNotCoprime2 gcd_a_b)\n\n||| Check are two numbers coprime to each other\npublic export\nisCoprime : (a : Nat) -> (b : Nat) -> {auto ok: NotBothZero a b} -> Bool\nisCoprime a b =\n case coprimality a b {ok = ok} of\n TheyAreCoprime _ => True\n _ => False\n\n||| A witness of a `Nat` being a compositie number\npublic export\ndata Composite : Nat -> Type where\n MkComposite : (x : Nat) -> LTE 2 x -> LT x n -> Factor x n -> Composite n\n\n||| A witness of a `Nat` being a prime number\npublic export\ndata Prime : Nat -> Type where\n MkPrime : ((x : Nat) -> LTE 2 x -> LT x n -> NotFactor x n) -> Prime n\n\n||| Primality of a `Nat`\npublic export\ndata Primality : Nat -> Type where\n ItIsPrime : Prime n -> Primality n\n ItIsComposite : Composite n -> Primality n\n\n||| This module's pseudo prime\ndata PseudoPrime : Nat -> Nat -> Type where\n MkPseudoPrime : LTE 2 l -> LT l n -> ((x : Nat) -> LTE l x -> LT x n -> NotFactor x n) -> PseudoPrime l n\n\n||| Constructs a trivial pseudo prime of a `Nat`\ntrivial : (n : Nat) -> LTE 2 n -> PseudoPrime n (S n)\ntrivial 0 lte_2_n = void $ absurd lte_2_n\ntrivial 1 lte_2_n = void $ absurd lte_2_n\ntrivial (S (S n)) lte_2_n = MkPseudoPrime lte_2_n lteRefl lemma\n where\n gamma : (k : Nat) -> S k = plus (mult k 1) 1\n gamma k =\n rewrite multOneRightNeutral k in\n rewrite plusCommutative k 1 in\n Refl\n lemma : (x : Nat) -> LTE (S (S n)) x -> LTE (S x) (S (S (S n))) -> NotFactor x (S (S (S n)))\n lemma x lte lte' =\n let ccc = LTEIsAntisymmetric (S (S n)) x lte (fromLteSucc lte') in\n rewrite sym ccc in\n ProperRemExists 1 0 (gamma (S (S n)))\n\n||| Realize that a `PseudoPrime` is an actual `Prime`\nrealize : PseudoPrime 2 n -> Prime n\nrealize (MkPseudoPrime _ _ prf) = MkPrime prf\n\n||| Strengthen a `PseudoPrime`, used to prove some other stuff\nstrengthen : {l : Nat} -> LTE 2 l -> PseudoPrime (S l) n -> NotFactor l n -> PseudoPrime l n\nstrengthen lte (MkPseudoPrime _ lt_l_n prf) notfactor_l_n = MkPseudoPrime lte (lteSuccLeft lt_l_n) lemma\n where\n lemma : (x : Nat) -> LTE l x -> LT x n -> NotFactor x n\n lemma x lte_l_x lt_x_n = case isLTE (S l) x of\n Yes lte_Sl_x => prf x lte_Sl_x lt_x_n\n No contra => rewrite (LTEIsAntisymmetric x l (fromLteSucc $ notlteIsLT (S l) x $ notLteIsnotlte (S l) x contra) lte_l_x) in notfactor_l_n\n\n||| The prime number 2, proved manually\npublic export\nprime2 : Prime 2\nprime2 = MkPrime lemma\n where\n lemma : (x : Nat) -> LTE 2 x -> LT x 2 -> NotFactor x 2\n lemma 0 lte_2_0 _ = void $ absurd lte_2_0\n lemma 1 lte_2_1 _ = void $ absurd lte_2_1\n lemma (S (S n)) _ lt_2_n = void $ absurd lt_2_n\n\n||| Calculates a `Nat`'s primality\npublic export\nprimality : (n : Nat) -> LTE 2 n -> Primality n\nprimality 0 lte_2_0 = void $ absurd lte_2_0\nprimality 1 lte_2_1 = void $ absurd lte_2_1\nprimality 2 lte_2_2 = ItIsPrime prime2\nprimality n@(S (S (S k))) lte_2_n = lemma (trivial (S (S k)) (LTESucc $ LTESucc $ LTEZero))\n where\n lemma : {x : Nat} -> PseudoPrime (S (S x)) (S (S (S k))) -> Primality (S (S (S k)))\n lemma {x = 0} p = ItIsPrime (realize p)\n lemma {x = (S y)} p@(MkPseudoPrime lte_2_x lte_x_n prf) =\n case decFactor (S (S (S k))) (S (S y)) of\n ItIsFactor factor => ItIsComposite $ MkComposite (S (S y)) (lteAddRight {m = y} 2) (lteSuccLeft lte_x_n) factor\n ItIsNotFactor not_factor => lemma (strengthen (lteAddRight {m = y} 2) p not_factor)\n\n||| Check if a `Nat` is a prime number\npublic export\nisPrime : (n : Nat) -> {auto okay : LTE 2 n} -> Bool\nisPrime 1 = void $ absurd okay\nisPrime (S (S n)) = case primality (S (S n)) okay of\n ItIsPrime _ => True\n ItIsComposite _ => False\n", "meta": {"hexsha": "aff4233dba49550d6d3d1971adad7d4638ae01d6", "size": 4802, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Extra/Nat/Prime.idr", "max_stars_repo_name": "tensorknower69/idris2-extra", "max_stars_repo_head_hexsha": "b856915276987758da8c38865b4b336079bc1e9a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Extra/Nat/Prime.idr", "max_issues_repo_name": "tensorknower69/idris2-extra", "max_issues_repo_head_hexsha": "b856915276987758da8c38865b4b336079bc1e9a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Extra/Nat/Prime.idr", "max_forks_repo_name": "tensorknower69/idris2-extra", "max_forks_repo_head_hexsha": "b856915276987758da8c38865b4b336079bc1e9a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.811023622, "max_line_length": 141, "alphanum_fraction": 0.6686797168, "num_tokens": 1748, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.865224072151174, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.541737710293776}} {"text": "module Data.Verified.Trifunctor\n\nimport Data.Trifunctor\n\n%default total\n%access public export\n\n||| Verified Trifunctor\n||| A Trifunctor for which identity and composition laws are verified\ninterface Trifunctor t => VerifiedTrifunctor (t : Type -> Type -> Type -> Type) where\n trifunctorIdentity : {a : Type} -> {b : Type} -> {c : Type} ->\n (x : t a b c) ->\n timap Basics.id Basics.id Basics.id x = x\n trifunctorComposition : {a : Type} -> {b : Type} -> {c : Type} ->\n {a1 : Type} -> {b1 : Type} -> {c1 : Type} ->\n (x : t a b c) ->\n (fa1 : a -> a1) -> (fb1 : b -> b1) -> (fc1 : c -> c1) ->\n (fa2 : a1 -> a2) -> (fb2 : b1 -> b2) -> (fc2 : c1 -> c2) ->\n (timap (fa2 . fa1) (fb2 . fb1) (fc2 . fc1) x) =\n (timap fa2 fb2 fc2 . timap fa1 fb1 fc1) x\n", "meta": {"hexsha": "655d13039fe1b7e04fec6f5673916f3f47fbcafe", "size": 938, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Verified/Trifunctor.idr", "max_stars_repo_name": "lemastero/Idris-Trifunctors", "max_stars_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Verified/Trifunctor.idr", "max_issues_repo_name": "lemastero/Idris-Trifunctors", "max_issues_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-13T21:31:36.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-13T21:31:36.000Z", "max_forks_repo_path": "src/Data/Verified/Trifunctor.idr", "max_forks_repo_name": "lemastero/Idris-Trifunctors", "max_forks_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-19T04:35:47.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-19T04:35:47.000Z", "avg_line_length": 44.6666666667, "max_line_length": 85, "alphanum_fraction": 0.460554371, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744939732855, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.5411712548198387}} {"text": "-- exercises in \"Type-Driven Development with Idris\"\n-- chapter 4\n\n-- check that all functions are total\n%default total\n\n||| Powersources for vehicles\ndata PowerSource = Petrol | Pedal | Electric\n\n||| Vehicles\ndata Vehicle : PowerSource -> Type where\n Unicycle : Vehicle Pedal\n Bicycle : Vehicle Pedal\n Motorcycle : (fuel : Nat) -> Vehicle Petrol\n Car : (fuel : Nat) -> Vehicle Petrol\n Bus : (fuel : Nat) -> Vehicle Petrol\n Tram : Vehicle Electric\n ElectricCar : Vehicle Electric\n\nwheels : Vehicle power -> Nat\nwheels Unicycle = 1\nwheels Bicycle = 2\nwheels (Motorcycle fuel) = 2\nwheels (Car fuel) = 4\nwheels (Bus fuel) = 4\nwheels Tram = 10\nwheels ElectricCar = 4\n\nrefuel : Vehicle Petrol -> Vehicle Petrol\nrefuel (Motorcycle fuel) = Motorcycle 50\nrefuel (Car fuel) = Car 100\nrefuel (Bus fuel) = Bus 200\nrefuel Unicycle impossible\nrefuel Bicycle impossible\nrefuel Tram impossible\nrefuel ElectricCar impossible\n", "meta": {"hexsha": "eb7a9ec9e2386bc669936aaa738d1b8d42d9c0b2", "size": 916, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter4/Vehicle.idr", "max_stars_repo_name": "pascalpoizat/idris-book", "max_stars_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-08-16T00:58:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T01:07:37.000Z", "max_issues_repo_path": "chapter4/Vehicle.idr", "max_issues_repo_name": "pascalpoizat/idris-book", "max_issues_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter4/Vehicle.idr", "max_forks_repo_name": "pascalpoizat/idris-book", "max_forks_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-23T03:15:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-23T03:15:39.000Z", "avg_line_length": 24.7567567568, "max_line_length": 52, "alphanum_fraction": 0.7325327511, "num_tokens": 269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.812867299704166, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.540890484083163}} {"text": "{-data SnocList ty = Empty | Snoc (SnocList ty) ty\n\nreverseSnoc : SnocList ty -> List ty\nreverseSnoc Empty = [] \nreverseSnoc (Snoc xs x) = x :: reverseSnoc xs-}\n\ndata SnocList : List a -> Type where\n Empty : SnocList []\n Snoc : (rec : SnocList xs) -> SnocList (xs ++ [x])\n\nsnocListHelp : (snoc : SnocList input) -> (rest : List a) ->\n SnocList (input ++ rest)\nsnocListHelp {input} snoc [] = rewrite appendNilRightNeutral input in snoc\nsnocListHelp {input} snoc (x :: xs) = rewrite appendAssociative input [x] xs in\n snocListHelp (Snoc snoc {x}) xs\n\nsnocList : (xs : List a) -> SnocList xs\nsnocList xs = snocListHelp Empty xs\n\nmyReverseHelper : (input : List a) -> SnocList input -> List a\nmyReverseHelper [] Empty = []\nmyReverseHelper (xs ++ [x]) (Snoc rec) = x :: myReverseHelper xs rec\n\n{-myReverse : List a -> List a\nmyReverse xs = myReverseHelper xs (snocList xs)-}\n\nmyReverse : List a -> List a\nmyReverse input with (snocList input)\n myReverse [] | Empty = []\n myReverse (xs ++ [x]) | (Snoc rec) = x :: myReverse xs | rec\n\nisSuffix : Eq a => List a -> List a -> Bool\nisSuffix input1 input2 with (snocList input1)\n isSuffix [] input2 | Empty = True\n isSuffix (xs ++ [x]) input2 | (Snoc xsrec) with (snocList input2)\n isSuffix (xs ++ [x]) [] | (Snoc xsrec) | Empty = False\n isSuffix (xs ++ [x]) (ys ++ [y]) | (Snoc xsrec) | (Snoc ysrec)\n = if x == y then isSuffix xs ys | xsrec | ysrec\n else False\n\ndata SplitRec : List a -> Type where\n SplitRecNil : SplitRec []\n SplitRecOne : SplitRec [x]\n SplitRecPair : (lrec : Lazy (SplitRec lefts)) ->\n (rrec : Lazy (SplitRec rights)) ->\n SplitRec (lefts ++ rights)\n\ntotal splitRec : (xs : List a) -> SplitRec xs\n", "meta": {"hexsha": "b109b88c89bcae3b807eb2368789348ded1162eb", "size": 1775, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp10/Snoc.idr", "max_stars_repo_name": "Ryxai/idris_book_notes", "max_stars_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "type_driven_book/chp10/Snoc.idr", "max_issues_repo_name": "Ryxai/idris_book_notes", "max_issues_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "type_driven_book/chp10/Snoc.idr", "max_forks_repo_name": "Ryxai/idris_book_notes", "max_forks_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.2244897959, "max_line_length": 79, "alphanum_fraction": 0.6146478873, "num_tokens": 561, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.5408539823792332}} {"text": "module Data.List.Fixes\n\n%default total\n%access export\n\npublic export\ndata PrefixOfBy : (holdsFor : type -> type -> Type)\n -> (pref : List type)\n -> (input : List type)\n -> Type where\n Empty : PrefixOfBy p Nil xs\n Extend : (prf : p x y)\n -> PrefixOfBy p xs ys\n -> PrefixOfBy p (x::xs) (y::ys)\n\nrightIsEmpty : PrefixOfBy p (x :: xs) [] -> Void\nrightIsEmpty Empty impossible\nrightIsEmpty (Extend _ _) impossible\n\nnotPrefix : (contra : p x y -> Void)\n -> PrefixOfBy p (x :: xs) (y :: ys)\n -> Void\nnotPrefix contra (Extend prf x) = contra prf\n\nrestNotPrefix : (contra : PrefixOfBy p xs ys -> Void)\n -> PrefixOfBy p (x :: xs) (y :: ys)\n -> Void\nrestNotPrefix contra (Extend x y) = contra y\n\n\nisPrefixOfBy : (test : (x,y : type) -> Dec (p x y))\n -> (pref, input : List type)\n -> (Dec $ PrefixOfBy p pref input)\nisPrefixOfBy test [] input = Yes Empty\nisPrefixOfBy test (x :: xs) [] = No rightIsEmpty\nisPrefixOfBy test (x :: xs) (y :: ys) with (test x y)\n isPrefixOfBy test (x :: xs) (y :: ys) | (Yes prf) with (isPrefixOfBy test xs ys)\n isPrefixOfBy test (x :: xs) (y :: ys) | (Yes prf) | (Yes z) = Yes (Extend prf z)\n isPrefixOfBy test (x :: xs) (y :: ys) | (Yes prf) | (No contra) =\n No (restNotPrefix contra)\n\n isPrefixOfBy test (x :: xs) (y :: ys) | (No contra) =\n No (notPrefix contra)\n\n\nisPrefixOf : DecEq type\n => (pref, input : List type)\n -> Dec $ PrefixOfBy (=) pref input\nisPrefixOf = isPrefixOfBy decEq\n\npublic export\nSuffixOfBy : (holdsFor : type -> type -> Type)\n -> (pref : List type)\n -> (input : List type)\n -> Type\nSuffixOfBy holdsFor pref input =\n PrefixOfBy holdsFor (reverse pref) (reverse input)\n\nisSuffixOfBy : (test : (x,y : type) -> Dec (p x y))\n -> (pref, input : List type)\n -> (Dec $ SuffixOfBy p pref input)\nisSuffixOfBy test pref input =\n isPrefixOfBy test (reverse pref) (reverse input)\n\n\n\nisSuffixOf : DecEq type\n => (suf, input : List type)\n -> (Dec $ SuffixOfBy (=) suf input)\nisSuffixOf suf input =\n isSuffixOfBy decEq suf input\n", "meta": {"hexsha": "d6fa2ec802524872a836471cfb3530c649eec3d8", "size": 2189, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/List/Fixes.idr", "max_stars_repo_name": "witt3rd/idris-containers", "max_stars_repo_head_hexsha": "6f4e06a0e85ee6336e493cee800fff42215da2ac", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 99, "max_stars_repo_stars_event_min_datetime": "2015-03-01T20:22:37.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-01T02:17:39.000Z", "max_issues_repo_path": "Data/List/Fixes.idr", "max_issues_repo_name": "witt3rd/idris-containers", "max_issues_repo_head_hexsha": "6f4e06a0e85ee6336e493cee800fff42215da2ac", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 30, "max_issues_repo_issues_event_min_datetime": "2015-03-23T19:17:35.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-01T13:05:44.000Z", "max_forks_repo_path": "Data/List/Fixes.idr", "max_forks_repo_name": "witt3rd/idris-containers", "max_forks_repo_head_hexsha": "6f4e06a0e85ee6336e493cee800fff42215da2ac", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 26, "max_forks_repo_forks_event_min_datetime": "2015-06-02T17:20:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-13T14:51:07.000Z", "avg_line_length": 30.4027777778, "max_line_length": 84, "alphanum_fraction": 0.576975788, "num_tokens": 665, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.72487026428967, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.5408539608912076}} {"text": "module Q\nimport ZZ\nimport GCDZZ\nimport Divisors\nimport Monoid\nimport Rationals\nimport ZZUtils\nimport TwoVarDiophEq\nimport NatUtils\n\n\n\n|||data type for rationals\ndata Q : Type where\n PbySq : (p: ZZ) -> (q: Nat) -> Q\n\nZQ : Q\nZQ = PbySq (Pos Z) Z\n\nOneQ : Q\nOneQ = PbySq (Pos (S Z)) Z\n\n|||data type which has the simplified form of a Rational number, a transversal group\ndata SimpQ : Type where\n SimplifiedQ : (p:ZZ) -> (q:ZZ) -> .(IsPositive q) -> .(GCDZ p q 1) -> SimpQ\n\n\n--Auxillary conversions to convert Q into a SimpQ\nQtoZZPair : Q -> ZZPair\nQtoZZPair (PbySq p q) = (p, Pos(S q))\n\nSimplifyToZZPair : (x:Q)-> (y: ZZPair ** (GCDZ (fst y) (snd y) 1))\nSimplifyToZZPair (PbySq p q)= simplifyWithProof (QtoZZPair (PbySq p q)) (PositiveZ{k=q})\n\nZZPairtoQ : ZZPair -> Q\nZZPairtoQ (p, Pos(S q)) = PbySq p q\n\n--auxillary functions for conversion of data types\n\nblah: {b:ZZ}-> {d:ZZ}-> (IsPositive b) -> (IsPositive d) -> (x: IsDivisibleZ b d) -> (IsPositive (fst x))\nblah Positive Positive ((Pos Z) ** pf) = void (posIsNotPosTimesZero pf)\nblah Positive Positive ((NegS l)** pf) = void(PosTimesNegIsNotPos pf)\nblah Positive Positive ((Pos (S l))**pf) = Positive\n\ndDivsb: (GCDZ a b d) -> (IsDivisibleZ b d)\ndDivsb dgcdab = (snd (fst (snd dgcdab)))\n-- aux end\n\nZZtoSimpQ : (p:ZZ) ->(q:ZZ) -> (pf: IsPositive q) -> (d : ZZ ** GCDZ p q d) -> SimpQ\nZZtoSimpQ p q pf (d**dgcdab) = SimplifiedQ (aByd dgcdab) (fst (dDivsb dgcdab)) (blah pf (fst dgcdab) (dDivsb dgcdab)) (divideByGcdThenGcdOne dgcdab)\n\n|||Simplifies a rational number to its coprime form\nQtoSimpQ : Q -> SimpQ\nQtoSimpQ (PbySq p q) = ZZtoSimpQ p (Pos(S q)) Positive (gcdZZ p (Pos (S q)) RightPositive)\n\n|||addition over rational number\naddQ: Q -> Q -> Q\naddQ (PbySq p1 q1) (PbySq p2 q2) =\n let\n num : ZZ = (p1 * (Pos(S q2))) + (p2 * (Pos (S q1)))\n denom: Nat = q1 * q2 + q1 + q2\n in\n PbySq num denom\n\n|||addition over the transversal group\naddSimpQ : SimpQ -> SimpQ -> SimpQ\naddSimpQ (SimplifiedQ p1 (Pos(S q1)) Positive gcd1) (SimplifiedQ p2 (Pos(S q2)) Positive gcd2) =\n QtoSimpQ (addQ (PbySq p1 q1) (PbySq p2 q2))\n\n||| multiplication over Rationals\nmultQ: Q-> Q -> Q\nmultQ (PbySq p1 q1) (PbySq p2 q2) = PbySq (p1 * p2) (q1 * q2 + q1 + q2)\n\n|||Multiplication over the transversal group\nmultSimpQ : SimpQ -> SimpQ -> SimpQ\nmultSimpQ (SimplifiedQ p1 (Pos(S q1)) Positive gcd1) (SimplifiedQ p2 (Pos(S q2)) Positive gcd2) =\n QtoSimpQ (multQ (PbySq p1 q1) (PbySq p2 q2))\n\n\n--Conversions from integers to aforementioned types\nZZtoQ : ZZ -> Q\nZZtoQ x = PbySq x Z\n\nIntegertoQ : Integer -> Q\nIntegertoQ x = ZZtoQ(fromInt x)\n\nIntegertoSimpQ : Integer -> SimpQ\nIntegertoSimpQ x = QtoSimpQ (IntegertoQ x)\n\n--defining the + and * signs for Q and SimpQ\nimplementation Num Q where\n (+) = addQ\n (*) = multQ\n fromInteger = IntegertoQ\n\nimplementation Num SimpQ where\n (+) = addSimpQ\n (*) = multSimpQ\n fromInteger = IntegertoSimpQ\n\n|||Proves that addition over Q is commutative\naddQIsComm : (x:Q)->(y: Q)-> (x+y=y+x)\naddQIsComm (PbySq p1 q1) (PbySq p2 q2) =\n rewrite plusCommutativeZ (p1 * (Pos(S q2))) (p2 * (Pos (S q1))) in\n rewrite multCommutative q1 q2 in\n rewrite plusCommutative (q2*q1 + q1) q2 in\n rewrite plusAssociative q2 (q2 * q1) q1 in\n rewrite plusCommutative q2 (q2 * q1) in\n Refl\n--auxillary function\napYX : (x: Type)->(y: Type) -> (f: y -> x) -> (n: y) -> (m: y) -> n = m -> f n = f m\napYX x y f m m Refl = Refl\n\n{-\naddSimpQisComm : (x: SimpQ) -> (y: SimpQ) ->(x+y = y+x)\naddSimpQisComm (SimplifiedQ p1 (Pos(S q1)) Positive gcd1) (SimplifiedQ p2 (Pos(S q2)) Positive gcd2) =\n let\n sum :Q = ( (PbySq p1 q1)+(PbySq p2 q2))\n in\n rewrite addQIsComm (PbySq p1 q1) (PbySq p2 q2) in\n Refl\n-}\n\n|||proves that multiplication over Q is commutative\nmultQisComm : (x:Q)-> (y: Q) -> (x*y = y*x)\nmultQisComm (PbySq p1 q1) (PbySq p2 q2) =\n rewrite multCommutativeZ p1 p2 in\n rewrite multCommutative q1 q2 in\n rewrite plusCommutative (q2*q1 + q1) q2 in\n rewrite plusAssociative q2 (q2 * q1) q1 in\n rewrite plusCommutative q2 (q2 * q1) in\n Refl\n\n|||Functions to give the IsIdentity type for Q over *\nleftMultId : (r : Q) -> (OneQ * r = r)\nleftMultId (PbySq p q) = rewrite multOneLeftNeutralZ p in Refl\n\nRightMultId : (r: Q)-> (r * OneQ = r)\nRightMultId r = trans (multQisComm r OneQ) (leftMultId r)\n\nOneIsQMultId : (a: Q) -> (a*OneQ =a, OneQ * a = a)\nOneIsQMultId a = (RightMultId a, leftMultId a)\n\n|||functions to give the IsIdentity type for Q over +\nleftAddId : (r : Q) -> (ZQ + r = r)\nleftAddId (PbySq p q) =\n rewrite multOneRightNeutralZ p in\n rewrite plusZeroLeftNeutralZ p in\n Refl\n\nrightAddId : (r: Q) -> (r + ZQ = r)\nrightAddId r = trans (addQIsComm r ZQ) (leftAddId r)\n\nZIsQAddId : (a:Q)->((a+ZQ)=a, (ZQ+a)=a)\nZIsQAddId a = (rightAddId a, leftAddId a)\n\n\n|||Auxillary functions\nmultZero : (n: Nat) -> mult n Z = Z\nmultZero Z = Refl\nmultZero (S k) = multZero k\n\n\n\nAux1 : (n: Nat) -> (q : Nat) -> Nat -> Q\nAux1 n q m = PbySq (Pos (plus m n)) q\n\nAux2: (n: Nat) -> (q: Nat) -> Nat -> Q\nAux2 n q m = PbySq (plusZ (plusZ (Pos 0) (negNat m)) (NegS n)) q\n{-\n||| The IdentityExists type for Q over +\nQAddIdExists : Type\nQAddIdExists = (ZQ ** (ZIsQAddId))\n-}\n", "meta": {"hexsha": "48f3b90edfafda6ced6504f627484acc20ae8e00", "size": 5209, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Code/Q.idr", "max_stars_repo_name": "anotherArka/LTS2019", "max_stars_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-01-16T18:03:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-13T16:28:41.000Z", "max_issues_repo_path": "Code/Q.idr", "max_issues_repo_name": "anotherArka/LTS2019", "max_issues_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 58, "max_issues_repo_issues_event_min_datetime": "2019-01-08T11:22:38.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-21T10:26:10.000Z", "max_forks_repo_path": "Code/Q.idr", "max_forks_repo_name": "anotherArka/LTS2019", "max_forks_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 22, "max_forks_repo_forks_event_min_datetime": "2019-01-08T05:56:23.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-31T03:58:00.000Z", "avg_line_length": 29.7657142857, "max_line_length": 148, "alphanum_fraction": 0.6463812632, "num_tokens": 2081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267694452331, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.5408093298391476}} {"text": "module Main\n\nimport Data.Nat\nimport Data.Vect\nimport Data.List\nimport LinearTypes\nimport Control.Linear.LIO\nimport Unitary\nimport QStateT\nimport Teleportation\nimport System.Random\nimport Injection\nimport QFT\nimport Grover\nimport AlterningBitsOracle\nimport VQE\nimport Complex\nimport QuantumOp\nimport CoinToss\nimport QAOA\nimport Graph\nimport Examples\nimport RUS\n\n-- %default total\n \n\n||| Perform 1000 fair coin tosses and count the number of heads\n||| (via simulating the quantum dynamics).\ntestCoins : IO ()\ntestCoins = do\n let f = coin {t = SimulatedOp}\n s <- sequence (Data.List.replicate 1000 f)\n let heads = filter (== True) s\n putStrLn $ \"Number of heads: \" ++ (show (length heads))\n\n\n||| Call the drawTeleportation function (using the SimulatedOp implementation)\n||| then execute the runTeleportation function 1000 times and report on the\n||| observed measurement results on the third qubit\n||| (which is in state |+> at the end of the teleportation protocol).\nexport\ntestTeleport : IO ()\ntestTeleport = do\n drawTeleportation {t = SimulatedOp}\n l <- sequence (Data.List.replicate 1000 (runTeleportation {t = SimulatedOp}))\n let nbT = length $ filter (\\x => (last x) == True) l\n putStrLn \"\\n\\nFor 1000 measurements\"\n putStrLn (\"Number of True measurements : \" ++ show nbT) \n\n||| Test graph for the QAOA problem\nexport\ngraph1 : Graph 5\ngraph1 = AddVertex (AddVertex (AddVertex (AddVertex (AddVertex Empty []) [True]) [True, True]) [False, True, False]) [False, False, True, True]\n\n||| Execute QAOA with 100 samples on the previous graph to solve the MAXCUT problem\nexport\ntestQAOA : IO (Cut 5)\ntestQAOA = do\n QAOA {t = SimulatedOp} 100 1 graph1\n\n\n||| Small test for the VQE algorithm\nexport\ntestVQE : IO Double\ntestVQE = do\n putStrLn \"Test VQE\"\n let hamiltonian = [(2, [PauliX, PauliY]),(3,[PauliZ, PauliI])]\n VQE {t = SimulatedOp} 2 hamiltonian 5 10 5\n\n\nexport\nmain : IO ()\nmain = do\n\n -- Execute the example file and draw the circuit examples\n drawExamples\n\n -- Draw the Quantum Fourier Transform for n = 3\n-- putStrLn \"\\n\\n\\nQuantum Fourier Transform for n = 3\"\n-- draw (qft 3)\n\n\n -- Execute the coin toss example\n putStrLn \"\\nTest coin toss by performing 1000 coin tosses.\"\n testCoins\n\n -- Teleportation protocol\n-- putStrLn \"\\nTest Teleportation protocol\"\n-- testTeleport\n\n -- Repeat until success\n putStrLn \"\\nTest 'Repeat Until Success'. Probability to measure '1' is 2/3 for this example.\"\n testMultipleRUS 10000\n\n -- VQE\n-- putStrLn \"\\nSmall test with VQE\"\n-- r <- testVQE\n-- putStrLn $ \"result from VQE : \" ++ show r\n\n -- QAOA\n-- putStrLn \"\\nSmall test with QAOA\"\n-- cut <- testQAOA\n-- putStrLn $ \"result from QAOA : \" ++ show cut\n\n pure ()\n\n\n \n\n\n", "meta": {"hexsha": "d28d2a3a66516658e514947569686a2fcf513943", "size": 2698, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Main.idr", "max_stars_repo_name": "zamdzhiev/Qimaera", "max_stars_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2021-08-24T14:36:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T00:36:11.000Z", "max_issues_repo_path": "Main.idr", "max_issues_repo_name": "zamdzhiev/Qimaera", "max_issues_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Main.idr", "max_forks_repo_name": "zamdzhiev/Qimaera", "max_forks_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0892857143, "max_line_length": 143, "alphanum_fraction": 0.7120088955, "num_tokens": 801, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5403940385560839}} {"text": "module Data.List\n\nimport Data.Nat\nimport Data.List1\n\npublic export\nisNil : List a -> Bool\nisNil [] = True\nisNil _ = False\n\npublic export\nisCons : List a -> Bool\nisCons [] = False\nisCons _ = True\n\npublic export\nsnoc : List a -> a -> List a\nsnoc xs x = xs ++ [x]\n\npublic export\ntake : Nat -> List a -> List a\ntake (S k) (x :: xs) = x :: take k xs\ntake _ _ = []\n\npublic export\ndrop : (n : Nat) -> (xs : List a) -> List a\ndrop Z xs = xs\ndrop (S n) [] = []\ndrop (S n) (_::xs) = drop n xs\n\n||| Satisfiable if `k` is a valid index into `xs`\n|||\n||| @ k the potential index\n||| @ xs the list into which k may be an index\npublic export\ndata InBounds : (k : Nat) -> (xs : List a) -> Type where\n ||| Z is a valid index into any cons cell\n InFirst : InBounds Z (x :: xs)\n ||| Valid indices can be extended\n InLater : InBounds k xs -> InBounds (S k) (x :: xs)\n\npublic export\nUninhabited (InBounds k []) where\n uninhabited InFirst impossible\n uninhabited (InLater _) impossible\n\n||| Decide whether `k` is a valid index into `xs`\npublic export\ninBounds : (k : Nat) -> (xs : List a) -> Dec (InBounds k xs)\ninBounds _ [] = No uninhabited\ninBounds Z (_ :: _) = Yes InFirst\ninBounds (S k) (x :: xs) with (inBounds k xs)\n inBounds (S k) (x :: xs) | (Yes prf) = Yes (InLater prf)\n inBounds (S k) (x :: xs) | (No contra)\n = No $ \\(InLater y) => contra y\n\n||| Find a particular element of a list.\n|||\n||| @ ok a proof that the index is within bounds\npublic export\nindex : (n : Nat) -> (xs : List a) -> {auto ok : InBounds n xs} -> a\nindex Z (x :: xs) {ok = InFirst} = x\nindex (S k) (_ :: xs) {ok = InLater _} = index k xs\n\n||| Generate a list by repeatedly applying a partial function until exhausted.\n||| @ f the function to iterate\n||| @ x the initial value that will be the head of the list\npublic export\niterate : (f : a -> Maybe a) -> (x : a) -> List a\niterate f x = x :: case f x of\n Nothing => []\n Just y => iterate f y\n\npublic export\ntakeWhile : (p : a -> Bool) -> List a -> List a\ntakeWhile p [] = []\ntakeWhile p (x::xs) = if p x then x :: takeWhile p xs else []\n\npublic export\ndropWhile : (p : a -> Bool) -> List a -> List a\ndropWhile p [] = []\ndropWhile p (x::xs) = if p x then dropWhile p xs else x::xs\n\npublic export\nfilter : (p : a -> Bool) -> List a -> List a\nfilter p [] = []\nfilter p (x :: xs)\n = if p x\n then x :: filter p xs\n else filter p xs\n\n||| Find the first element of the list that satisfies the predicate.\npublic export\nfind : (p : a -> Bool) -> (xs : List a) -> Maybe a\nfind p [] = Nothing\nfind p (x::xs) = if p x then Just x else find p xs\n\n||| Find associated information in a list using a custom comparison.\npublic export\nlookupBy : (a -> a -> Bool) -> a -> List (a, b) -> Maybe b\nlookupBy p e [] = Nothing\nlookupBy p e ((l, r) :: xs) =\n if p e l then\n Just r\n else\n lookupBy p e xs\n\n||| Find associated information in a list using Boolean equality.\npublic export\nlookup : Eq a => a -> List (a, b) -> Maybe b\nlookup = lookupBy (==)\n\n||| Check if something is a member of a list using a custom comparison.\npublic export\nelemBy : (a -> a -> Bool) -> a -> List a -> Bool\nelemBy p e [] = False\nelemBy p e (x::xs) = p e x || elemBy p e xs\n\npublic export\nnubBy : (a -> a -> Bool) -> List a -> List a\nnubBy = nubBy' []\n where\n nubBy' : List a -> (a -> a -> Bool) -> List a -> List a\n nubBy' acc p [] = []\n nubBy' acc p (x::xs) =\n if elemBy p x acc then\n nubBy' acc p xs\n else\n x :: nubBy' (x::acc) p xs\n\n||| O(n^2). The nub function removes duplicate elements from a list. In\n||| particular, it keeps only the first occurrence of each element. It is a\n||| special case of nubBy, which allows the programmer to supply their own\n||| equality test.\n|||\n||| ```idris example\n||| nub (the (List _) [1,2,1,3])\n||| ```\npublic export\nnub : Eq a => List a -> List a\nnub = nubBy (==)\n\n||| The deleteBy function behaves like delete, but takes a user-supplied equality predicate.\npublic export\ndeleteBy : (a -> a -> Bool) -> a -> List a -> List a\ndeleteBy _ _ [] = []\ndeleteBy eq x (y::ys) = if x `eq` y then ys else y :: deleteBy eq x ys\n\n||| `delete x` removes the first occurrence of `x` from its list argument. For\n||| example,\n|||\n|||````idris example\n|||delete 'a' ['b', 'a', 'n', 'a', 'n', 'a']\n|||````\n|||\n||| It is a special case of deleteBy, which allows the programmer to supply\n||| their own equality test.\npublic export\ndelete : Eq a => a -> List a -> List a\ndelete = deleteBy (==)\n\n||| The unionBy function returns the union of two lists by user-supplied equality predicate.\npublic export\nunionBy : (a -> a -> Bool) -> List a -> List a -> List a\nunionBy eq xs ys = xs ++ foldl (flip (deleteBy eq)) (nubBy eq ys) xs\n\n||| Compute the union of two lists according to their `Eq` implementation.\n|||\n||| ```idris example\n||| union ['d', 'o', 'g'] ['c', 'o', 'w']\n||| ```\n|||\npublic export\nunion : Eq a => List a -> List a -> List a\nunion = unionBy (==)\n\npublic export\nspan : (a -> Bool) -> List a -> (List a, List a)\nspan p [] = ([], [])\nspan p (x::xs) =\n if p x then\n let (ys, zs) = span p xs in\n (x::ys, zs)\n else\n ([], x::xs)\n\npublic export\nbreak : (a -> Bool) -> List a -> (List a, List a)\nbreak p xs = span (not . p) xs\n\npublic export\nsplit : (a -> Bool) -> List a -> List1 (List a)\nsplit p xs =\n case break p xs of\n (chunk, []) => singleton chunk\n (chunk, (c :: rest)) => cons chunk (split p (assert_smaller xs rest))\n\npublic export\nsplitAt : (n : Nat) -> (xs : List a) -> (List a, List a)\nsplitAt Z xs = ([], xs)\nsplitAt (S k) [] = ([], [])\nsplitAt (S k) (x :: xs)\n = let (tk, dr) = splitAt k xs in\n (x :: tk, dr)\n\npublic export\npartition : (a -> Bool) -> List a -> (List a, List a)\npartition p [] = ([], [])\npartition p (x::xs) =\n let (lefts, rights) = partition p xs in\n if p x then\n (x::lefts, rights)\n else\n (lefts, x::rights)\n\n||| The inits function returns all initial segments of the argument, shortest\n||| first. For example,\n|||\n||| ```idris example\n||| inits [1,2,3]\n||| ```\npublic export\ninits : List a -> List (List a)\ninits xs = [] :: case xs of\n [] => []\n x :: xs' => map (x ::) (inits xs')\n\n||| The tails function returns all final segments of the argument, longest\n||| first. For example,\n|||\n||| ```idris example\n||| tails [1,2,3] == [[1,2,3], [2,3], [3], []]\n|||```\npublic export\ntails : List a -> List (List a)\ntails xs = xs :: case xs of\n [] => []\n _ :: xs' => tails xs'\n\n||| Split on the given element.\n|||\n||| ```idris example\n||| splitOn 0 [1,0,2,0,0,3]\n||| ```\n|||\npublic export\nsplitOn : Eq a => a -> List a -> List1 (List a)\nsplitOn a = split (== a)\n\n||| Replaces all occurences of the first argument with the second argument in a list.\n|||\n||| ```idris example\n||| replaceOn '-' ',' ['1', '-', '2', '-', '3']\n||| ```\n|||\npublic export\nreplaceOn : Eq a => a -> a -> List a -> List a\nreplaceOn a b l = map (\\c => if c == a then b else c) l\n\npublic export\nreverseOnto : List a -> List a -> List a\nreverseOnto acc [] = acc\nreverseOnto acc (x::xs) = reverseOnto (x::acc) xs\n\npublic export\nreverse : List a -> List a\nreverse = reverseOnto []\n\n||| Construct a list with `n` copies of `x`.\n||| @ n how many copies\n||| @ x the element to replicate\npublic export\nreplicate : (n : Nat) -> (x : a) -> List a\nreplicate Z _ = []\nreplicate (S n) x = x :: replicate n x\n\n||| Compute the intersect of two lists by user-supplied equality predicate.\nexport\nintersectBy : (a -> a -> Bool) -> List a -> List a -> List a\nintersectBy eq xs ys = [x | x <- xs, any (eq x) ys]\n\n||| Compute the intersect of two lists according to the `Eq` implementation for the elements.\nexport\nintersect : Eq a => List a -> List a -> List a\nintersect = intersectBy (==)\n\nexport\nintersectAllBy : (a -> a -> Bool) -> List (List a) -> List a\nintersectAllBy eq [] = []\nintersectAllBy eq (xs :: xss) = filter (\\x => all (elemBy eq x) xss) xs\n\nexport\nintersectAll : Eq a => List (List a) -> List a\nintersectAll = intersectAllBy (==)\n\n||| Combine two lists elementwise using some function.\n|||\n||| If the lists are different lengths, the result is truncated to the\n||| length of the shortest list.\nexport\nzipWith : (a -> b -> c) -> List a -> List b -> List c\nzipWith _ [] _ = []\nzipWith _ _ [] = []\nzipWith f (x::xs) (y::ys) = f x y :: zipWith f xs ys\n\n||| Combine two lists elementwise into pairs.\n|||\n||| If the lists are different lengths, the result is truncated to the\n||| length of the shortest list.\nexport\nzip : List a -> List b -> List (a, b)\nzip = zipWith \\x, y => (x, y)\n\nexport\nzipWith3 : (a -> b -> c -> d) -> List a -> List b -> List c -> List d\nzipWith3 _ [] _ _ = []\nzipWith3 _ _ [] _ = []\nzipWith3 _ _ _ [] = []\nzipWith3 f (x::xs) (y::ys) (z::zs) = f x y z :: zipWith3 f xs ys zs\n\n||| Combine three lists elementwise into tuples.\n|||\n||| If the lists are different lengths, the result is truncated to the\n||| length of the shortest list.\nexport\nzip3 : List a -> List b -> List c -> List (a, b, c)\nzip3 = zipWith3 \\x, y, z => (x, y, z)\n\npublic export\ndata NonEmpty : (xs : List a) -> Type where\n IsNonEmpty : NonEmpty (x :: xs)\n\nexport\nUninhabited (NonEmpty []) where\n uninhabited IsNonEmpty impossible\n\n||| Get the head of a non-empty list.\n||| @ ok proof the list is non-empty\npublic export\nhead : (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nhead [] impossible\nhead (x :: _) = x\n\n||| Get the tail of a non-empty list.\n||| @ ok proof the list is non-empty\npublic export\ntail : (l : List a) -> {auto 0 ok : NonEmpty l} -> List a\ntail [] impossible\ntail (_ :: xs) = xs\n\n||| Retrieve the last element of a non-empty list.\n||| @ ok proof that the list is non-empty\npublic export\nlast : (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nlast [] impossible\nlast [x] = x\nlast (_::x::xs) = List.last (x::xs)\n\n||| Return all but the last element of a non-empty list.\n||| @ ok proof the list is non-empty\npublic export\ninit : (l : List a) -> {auto 0 ok : NonEmpty l} -> List a\ninit [] impossible\ninit [_] = []\ninit (x::y::ys) = x :: init (y::ys)\n\n||| Attempt to get the head of a list. If the list is empty, return `Nothing`.\npublic export\nhead' : List a -> Maybe a\nhead' [] = Nothing\nhead' (x::_) = Just x\n\n||| Attempt to get the tail of a list. If the list is empty, return `Nothing`.\nexport\ntail' : List a -> Maybe (List a)\ntail' [] = Nothing\ntail' (_::xs) = Just xs\n\n||| Attempt to retrieve the last element of a non-empty list.\n|||\n||| If the list is empty, return `Nothing`.\nexport\nlast' : List a -> Maybe a\nlast' [] = Nothing\nlast' xs@(_::_) = Just (last xs)\n\n||| Attempt to return all but the last element of a non-empty list.\n|||\n||| If the list is empty, return `Nothing`.\nexport\ninit' : List a -> Maybe (List a)\ninit' [] = Nothing\ninit' xs@(_::_) = Just (init xs)\n\n||| Convert any Foldable structure to a list.\nexport\ntoList : Foldable t => t a -> List a\ntoList = foldr (::) []\n\n||| Prefix every element in the list with the given element\n|||\n||| ```idris example\n||| with List (mergeReplicate '>' ['a', 'b', 'c', 'd', 'e'])\n||| ```\n|||\nexport\nmergeReplicate : a -> List a -> List a\nmergeReplicate sep [] = []\nmergeReplicate sep (y::ys) = sep :: y :: mergeReplicate sep ys\n\n\n||| Insert some separator between the elements of a list.\n|||\n||| ````idris example\n||| with List (intersperse ',' ['a', 'b', 'c', 'd', 'e'])\n||| ````\n|||\nexport\nintersperse : a -> List a -> List a\nintersperse sep [] = []\nintersperse sep (x::xs) = x :: mergeReplicate sep xs\n\n||| Given a separator list and some more lists, produce a new list by\n||| placing the separator between each of the lists.\n|||\n||| @ sep the separator\n||| @ xss the lists between which the separator will be placed\n|||\n||| ```idris example\n||| intercalate [0, 0, 0] [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]\n||| ```\nexport\nintercalate : (sep : List a) -> (xss : List (List a)) -> List a\nintercalate sep xss = concat $ intersperse sep xss\n\n||| Apply a partial function to the elements of a list, keeping the ones at which\n||| it is defined.\npublic export\nmapMaybe : (a -> Maybe b) -> List a -> List b\nmapMaybe f [] = []\nmapMaybe f (x::xs) =\n case f x of\n Nothing => mapMaybe f xs\n Just j => j :: mapMaybe f xs\n\n--------------------------------------------------------------------------------\n-- Special folds\n--------------------------------------------------------------------------------\n\n||| Foldl a non-empty list without seeding the accumulator.\n||| @ ok proof that the list is non-empty\npublic export\nfoldl1 : (a -> a -> a) -> (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nfoldl1 f [] impossible\nfoldl1 f (x::xs) = foldl f x xs\n\n||| Foldr a non-empty list without seeding the accumulator.\n||| @ ok proof that the list is non-empty\npublic export\nfoldr1 : (a -> a -> a) -> (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nfoldr1 f [] impossible\nfoldr1 f [x] = x\nfoldr1 f (x::y::ys) = f x (List.foldr1 f (y::ys))\n\n||| Foldl without seeding the accumulator. If the list is empty, return `Nothing`.\npublic export\nfoldl1' : (a -> a -> a) -> List a -> Maybe a\nfoldl1' f [] = Nothing\nfoldl1' f xs@(_::_) = Just (List.foldl1 f xs)\n\n||| Foldr without seeding the accumulator. If the list is empty, return `Nothing`.\npublic export\nfoldr1' : (a -> a -> a) -> List a -> Maybe a\nfoldr1' f [] = Nothing\nfoldr1' f xs@(_::_) = Just (List.foldr1 f xs)\n\n--------------------------------------------------------------------------------\n-- Sorting\n--------------------------------------------------------------------------------\n\n||| Check whether a list is sorted with respect to the default ordering for the type of its elements.\nexport\nsorted : Ord a => List a -> Bool\nsorted (x :: xs @ (y :: _)) = x <= y && sorted xs\nsorted _ = True\n\n||| Merge two sorted lists using an arbitrary comparison\n||| predicate. Note that the lists must have been sorted using this\n||| predicate already.\nexport\nmergeBy : (a -> a -> Ordering) -> List a -> List a -> List a\nmergeBy order [] right = right\nmergeBy order left [] = left\nmergeBy order (x::xs) (y::ys) =\n -- The code below will emit `y` before `x` whenever `x == y`.\n -- If you change this, `sortBy` will stop being stable, unless you fix `sortBy`, too.\n case order x y of\n LT => x :: mergeBy order xs (y::ys)\n _ => y :: mergeBy order (x::xs) ys\n\n||| Merge two sorted lists using the default ordering for the type of their elements.\nexport\nmerge : Ord a => List a -> List a -> List a\nmerge left right = mergeBy compare left right\n\n||| Sort a list using some arbitrary comparison predicate.\n|||\n||| @ cmp how to compare elements\n||| @ xs the list to sort\nexport\nsortBy : (cmp : a -> a -> Ordering) -> (xs : List a) -> List a\nsortBy cmp [] = []\nsortBy cmp [x] = [x]\nsortBy cmp xs = let (x, y) = split xs in\n mergeBy cmp\n (sortBy cmp (assert_smaller xs x))\n (sortBy cmp (assert_smaller xs y)) -- not structurally smaller, hence assert\n where\n splitRec : List b -> List a -> (List a -> List a) -> (List a, List a)\n splitRec (_::_::xs) (y::ys) zs = splitRec xs ys (zs . ((::) y))\n splitRec _ ys zs = (ys, zs [])\n -- In the above base-case clause, we put `ys` on the LHS to get a stable sort.\n -- This is because `mergeBy` prefers taking elements from its RHS operand\n -- if both heads are equal, and all elements in `zs []` precede all elements of `ys`\n -- in the original list.\n\n split : List a -> (List a, List a)\n split xs = splitRec xs xs id\n\n||| Sort a list using the default ordering for the type of its elements.\nexport\nsort : Ord a => List a -> List a\nsort = sortBy compare\n\nexport\nisPrefixOfBy : (eq : a -> a -> Bool) -> (left, right : List a) -> Bool\nisPrefixOfBy p [] _ = True\nisPrefixOfBy p _ [] = False\nisPrefixOfBy p (x::xs) (y::ys) = p x y && isPrefixOfBy p xs ys\n\n||| The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.\nexport\nisPrefixOf : Eq a => List a -> List a -> Bool\nisPrefixOf = isPrefixOfBy (==)\n\nexport\nisSuffixOfBy : (a -> a -> Bool) -> List a -> List a -> Bool\nisSuffixOfBy p left right = isPrefixOfBy p (reverse left) (reverse right)\n\n||| The isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second.\nexport\nisSuffixOf : Eq a => List a -> List a -> Bool\nisSuffixOf = isSuffixOfBy (==)\n\n||| The isInfixOf function takes two lists and returns True iff the first list\n||| is contained, wholly and intact, anywhere within the second.\n|||\n||| ```idris example\n||| isInfixOf ['b','c'] ['a', 'b', 'c', 'd']\n||| ```\n||| ```idris example\n||| isInfixOf ['b','d'] ['a', 'b', 'c', 'd']\n||| ```\n|||\nexport\nisInfixOf : Eq a => List a -> List a -> Bool\nisInfixOf n h = any (isPrefixOf n) (tails h)\n\n||| Transposes rows and columns of a list of lists.\n|||\n||| ```idris example\n||| with List transpose [[1, 2], [3, 4]]\n||| ```\n|||\n||| This also works for non square scenarios, thus\n||| involution does not always hold:\n|||\n||| transpose [[], [1, 2]] = [[1], [2]]\n||| transpose (transpose [[], [1, 2]]) = [[1, 2]]\nexport\ntranspose : List (List a) -> List (List a)\ntranspose [] = []\ntranspose (heads :: tails) = spreadHeads heads (transpose tails) where\n spreadHeads : List a -> List (List a) -> List (List a)\n spreadHeads [] tails = tails\n spreadHeads (head :: heads) [] = [head] :: spreadHeads heads []\n spreadHeads (head :: heads) (tail :: tails) = (head :: tail) :: spreadHeads heads tails\n\n--------------------------------------------------------------------------------\n-- Properties\n--------------------------------------------------------------------------------\n\nexport\nUninhabited ([] = Prelude.(::) x xs) where\n uninhabited Refl impossible\n\nexport\nUninhabited (Prelude.(::) x xs = []) where\n uninhabited Refl impossible\n\n||| (::) is injective\nexport\nconsInjective : forall x, xs, y, ys .\n the (List a) (x :: xs) = the (List b) (y :: ys) -> (x = y, xs = ys)\nconsInjective Refl = (Refl, Refl)\n\n||| The empty list is a right identity for append.\nexport\nappendNilRightNeutral : (l : List a) -> l ++ [] = l\nappendNilRightNeutral [] = Refl\nappendNilRightNeutral (_::xs) = rewrite appendNilRightNeutral xs in Refl\n\n||| Appending lists is associative.\nexport\nappendAssociative : (l, c, r : List a) -> l ++ (c ++ r) = (l ++ c) ++ r\nappendAssociative [] c r = Refl\nappendAssociative (_::xs) c r = rewrite appendAssociative xs c r in Refl\n\nrevOnto : (xs, vs : List a) -> reverseOnto xs vs = reverse vs ++ xs\nrevOnto _ [] = Refl\nrevOnto xs (v :: vs)\n = rewrite revOnto (v :: xs) vs in\n rewrite appendAssociative (reverse vs) [v] xs in\n rewrite revOnto [v] vs in Refl\n\nexport\nrevAppend : (vs, ns : List a) -> reverse ns ++ reverse vs = reverse (vs ++ ns)\nrevAppend [] ns = rewrite appendNilRightNeutral (reverse ns) in Refl\nrevAppend (v :: vs) ns\n = rewrite revOnto [v] vs in\n rewrite revOnto [v] (vs ++ ns) in\n rewrite sym (revAppend vs ns) in\n rewrite appendAssociative (reverse ns) (reverse vs) [v] in\n Refl\n\nexport\ndropFusion : (n, m : Nat) -> (l : List t) -> drop n (drop m l) = drop (n+m) l\ndropFusion Z m l = Refl\ndropFusion (S n) Z l = rewrite plusZeroRightNeutral n in Refl\ndropFusion (S n) (S m) [] = Refl\ndropFusion (S n) (S m) (x::l) = rewrite plusAssociative n 1 m in\n rewrite plusCommutative n 1 in\n dropFusion (S n) m l\n\nexport\nlengthMap : (xs : List a) -> length (map f xs) = length xs\nlengthMap [] = Refl\nlengthMap (x :: xs) = cong S (lengthMap xs)\n", "meta": {"hexsha": "e8c77e801a0c7c652d8eabc46f9410cdbdee9f8d", "size": 19662, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Data/List.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/libs/base/Data/List.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/libs/base/Data/List.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2958397535, "max_line_length": 106, "alphanum_fraction": 0.5888007324, "num_tokens": 6065, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7799928900257126, "lm_q1q2_score": 0.5402558221784037}} {"text": "||| There are different flavours of induction-recursion. This is the one\n||| introduced in Dybjer and Setzer's paper:\n||| Indexed induction-recursion\n\nmodule Data.InductionRecursion.DybjerSetzer\n\npublic export\ndata Code : (input : sort -> Type) -> (output : Type) -> Type where\n Yield : output -> Code input output\n Store : (payload : Type) -> (payload -> Code input output) -> Code input output\n Branch : (label : Type) -> (toSort : label -> sort) ->\n (((l : label) -> input (toSort l)) -> Code input output) ->\n Code input output\n\npublic export\nDecodeType\n : Code input output -> (x : sort -> Type) ->\n (f : {s : sort} -> x s -> input s) ->\n Type\nDecodeType (Yield _) x f = ()\nDecodeType (Store payload k) x f = (v : payload ** DecodeType (k v) x f)\nDecodeType (Branch label toSort k) x f\n = (r : ((l : label) -> x (toSort l)) ** DecodeType (k (\\ l => f (r l))) x f)\n\npublic export\nDecodeOutput\n : (c : Code input output) -> (x : Lazy (sort -> Type)) ->\n (f : {s : sort} -> x s -> input s) ->\n DecodeType c x f -> output\nDecodeOutput (Yield o) x f _ = o\nDecodeOutput (Store p k) x f (v ** d) = DecodeOutput (k v) x f d\nDecodeOutput (Branch l s k) x f (r ** d) = DecodeOutput (k (\\ l => f (r l))) x f d\n\nmutual\n\n public export\n data Mu : (f : (s : sort) -> Code input (input s)) -> (s : sort) -> Type where\n MkMu : {f : (s : sort) -> Code input (input s)} -> {s : sort} ->\n DecodeType (f s) (Mu f) Decode -> Mu {input} f s\n\n public export\n Decode : {f : (s : sort) -> Code input (input s)} ->\n {s : sort} -> Mu {input} f s -> input s\n Decode (MkMu d) = DecodeOutput (f s) (Mu f) (\\ d => assert_total (Decode d)) d\n\npublic export\nbind : Code i o -> (o -> Code i o') -> Code i o'\nbind (Yield v) f = f v\nbind (Store p k) f = Store p (\\ v => bind (k v) f)\nbind (Branch l s k) f = Branch l s (\\ r => bind (k r) f)\n\npublic export\nFunctor (Code i) where\n map f v = bind v (Yield . f)\n\npublic export\nApplicative (Code i) where\n pure = Yield\n cf <*> co = bind cf (\\ f => map (f $) co)\n\npublic export\nMonad (Code i) where\n (>>=) = bind\n", "meta": {"hexsha": "33db914be47d06d2c811abf62d3750fa50257464", "size": 2099, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/InductionRecursion/DybjerSetzer.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "libs/contrib/Data/InductionRecursion/DybjerSetzer.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "libs/contrib/Data/InductionRecursion/DybjerSetzer.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 32.796875, "max_line_length": 82, "alphanum_fraction": 0.5783706527, "num_tokens": 688, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.5401815680215684}} {"text": "Ty : Type\nTy = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty : Ty\nempty = \\ _, empty, _ => empty\n\narr : Ty -> Ty -> Ty\narr = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon : Type\nCon = (Con : Type)\n ->(nil : Con)\n ->(snoc : Con -> Ty -> Con)\n -> Con\n\nnil : Con\nnil = \\ con, nil, snoc => nil\n\nsnoc : Con -> Ty -> Con\nsnoc = \\ g, a, con, nil, snoc => snoc (g con nil snoc) a\n\nVar : Con -> Ty -> Type\nVar = \\ g, a =>\n (Var : Con -> Ty -> Type)\n -> (vz : (g : _)-> (a : _) -> Var (snoc g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var g a -> Var (snoc g b) a)\n -> Var g a\n\nvz : {g : _}-> {a : _} -> Var (snoc g a) a\nvz = \\ var, vz, vs => vz _ _\n\nvs : {g : _} -> {B : _} -> {a : _} -> Var g a -> Var (snoc g B) a\nvs = \\ x, var, vz, vs => vs _ _ _ (x var vz vs)\n\nTm : Con -> Ty -> Type\nTm = \\ g, a =>\n (Tm : Con -> Ty -> Type)\n -> (var : (g : _) -> (a : _) -> Var g a -> Tm g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm (snoc g a) B -> Tm g (arr a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm g (arr a B) -> Tm g a -> Tm g B)\n -> Tm g a\n\nvar : {g : _} -> {a : _} -> Var g a -> Tm g a\nvar = \\ x, tm, var, lam, app => var _ _ x\n\nlam : {g : _} -> {a : _} -> {B : _} -> Tm (snoc g a) B -> Tm g (arr a B)\nlam = \\ t, tm, var, lam, app => lam _ _ _ (t tm var lam app)\n\napp : {g:_}->{a:_}->{B:_} -> Tm g (arr a B) -> Tm g a -> Tm g B\napp = \\ t, u, tm, var, lam, app => app _ _ _ (t tm var lam app) (u tm var lam app)\n\nv0 : {g:_}->{a:_} -> Tm (snoc g a) a\nv0 = var vz\n\nv1 : {g:_}->{a:_}-> {B:_}-> Tm (snoc (snoc g a) B) a\nv1 = var (vs vz)\n\nv2 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm (snoc (snoc (snoc g a) B) C) a\nv2 = var (vs (vs vz))\n\nv3 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm (snoc (snoc (snoc (snoc g a) B) C) D) a\nv3 = var (vs (vs (vs vz)))\n\nv4 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm (snoc (snoc (snoc (snoc (snoc g a) B) C) D) E) a\nv4 = var (vs (vs (vs (vs vz))))\n\ntest : {g:_}-> {a:_} -> Tm g (arr (arr a a) (arr a a))\ntest = lam (lam (app v1 (app v1 (app v1 (app v1 (app v1 (app v1 v0)))))))\nTy1 : Type\nTy1 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty1 : Ty1\nempty1 = \\ _, empty, _ => empty\n\narr1 : Ty1 -> Ty1 -> Ty1\narr1 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon1 : Type\nCon1 = (Con1 : Type)\n ->(nil : Con1)\n ->(snoc : Con1 -> Ty1 -> Con1)\n -> Con1\n\nnil1 : Con1\nnil1 = \\ con, nil1, snoc => nil1\n\nsnoc1 : Con1 -> Ty1 -> Con1\nsnoc1 = \\ g, a, con, nil1, snoc1 => snoc1 (g con nil1 snoc1) a\n\nVar1 : Con1 -> Ty1 -> Type\nVar1 = \\ g, a =>\n (Var1 : Con1 -> Ty1 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var1 (snoc1 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var1 g a -> Var1 (snoc1 g b) a)\n -> Var1 g a\n\nvz1 : {g : _}-> {a : _} -> Var1 (snoc1 g a) a\nvz1 = \\ var, vz1, vs => vz1 _ _\n\nvs1 : {g : _} -> {B : _} -> {a : _} -> Var1 g a -> Var1 (snoc1 g B) a\nvs1 = \\ x, var, vz1, vs1 => vs1 _ _ _ (x var vz1 vs1)\n\nTm1 : Con1 -> Ty1 -> Type\nTm1 = \\ g, a =>\n (Tm1 : Con1 -> Ty1 -> Type)\n -> (var : (g : _) -> (a : _) -> Var1 g a -> Tm1 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm1 (snoc1 g a) B -> Tm1 g (arr1 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm1 g (arr1 a B) -> Tm1 g a -> Tm1 g B)\n -> Tm1 g a\n\nvar1 : {g : _} -> {a : _} -> Var1 g a -> Tm1 g a\nvar1 = \\ x, tm, var1, lam, app => var1 _ _ x\n\nlam1 : {g : _} -> {a : _} -> {B : _} -> Tm1 (snoc1 g a) B -> Tm1 g (arr1 a B)\nlam1 = \\ t, tm, var1, lam1, app => lam1 _ _ _ (t tm var1 lam1 app)\n\napp1 : {g:_}->{a:_}->{B:_} -> Tm1 g (arr1 a B) -> Tm1 g a -> Tm1 g B\napp1 = \\ t, u, tm, var1, lam1, app1 => app1 _ _ _ (t tm var1 lam1 app1) (u tm var1 lam1 app1)\n\nv01 : {g:_}->{a:_} -> Tm1 (snoc1 g a) a\nv01 = var1 vz1\n\nv11 : {g:_}->{a:_}-> {B:_}-> Tm1 (snoc1 (snoc1 g a) B) a\nv11 = var1 (vs1 vz1)\n\nv21 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm1 (snoc1 (snoc1 (snoc1 g a) B) C) a\nv21 = var1 (vs1 (vs1 vz1))\n\nv31 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm1 (snoc1 (snoc1 (snoc1 (snoc1 g a) B) C) D) a\nv31 = var1 (vs1 (vs1 (vs1 vz1)))\n\nv41 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm1 (snoc1 (snoc1 (snoc1 (snoc1 (snoc1 g a) B) C) D) E) a\nv41 = var1 (vs1 (vs1 (vs1 (vs1 vz1))))\n\ntest1 : {g:_}-> {a:_} -> Tm1 g (arr1 (arr1 a a) (arr1 a a))\ntest1 = lam1 (lam1 (app1 v11 (app1 v11 (app1 v11 (app1 v11 (app1 v11 (app1 v11 v01)))))))\nTy2 : Type\nTy2 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty2 : Ty2\nempty2 = \\ _, empty, _ => empty\n\narr2 : Ty2 -> Ty2 -> Ty2\narr2 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon2 : Type\nCon2 = (Con2 : Type)\n ->(nil : Con2)\n ->(snoc : Con2 -> Ty2 -> Con2)\n -> Con2\n\nnil2 : Con2\nnil2 = \\ con, nil2, snoc => nil2\n\nsnoc2 : Con2 -> Ty2 -> Con2\nsnoc2 = \\ g, a, con, nil2, snoc2 => snoc2 (g con nil2 snoc2) a\n\nVar2 : Con2 -> Ty2 -> Type\nVar2 = \\ g, a =>\n (Var2 : Con2 -> Ty2 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var2 (snoc2 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var2 g a -> Var2 (snoc2 g b) a)\n -> Var2 g a\n\nvz2 : {g : _}-> {a : _} -> Var2 (snoc2 g a) a\nvz2 = \\ var, vz2, vs => vz2 _ _\n\nvs2 : {g : _} -> {B : _} -> {a : _} -> Var2 g a -> Var2 (snoc2 g B) a\nvs2 = \\ x, var, vz2, vs2 => vs2 _ _ _ (x var vz2 vs2)\n\nTm2 : Con2 -> Ty2 -> Type\nTm2 = \\ g, a =>\n (Tm2 : Con2 -> Ty2 -> Type)\n -> (var : (g : _) -> (a : _) -> Var2 g a -> Tm2 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm2 (snoc2 g a) B -> Tm2 g (arr2 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm2 g (arr2 a B) -> Tm2 g a -> Tm2 g B)\n -> Tm2 g a\n\nvar2 : {g : _} -> {a : _} -> Var2 g a -> Tm2 g a\nvar2 = \\ x, tm, var2, lam, app => var2 _ _ x\n\nlam2 : {g : _} -> {a : _} -> {B : _} -> Tm2 (snoc2 g a) B -> Tm2 g (arr2 a B)\nlam2 = \\ t, tm, var2, lam2, app => lam2 _ _ _ (t tm var2 lam2 app)\n\napp2 : {g:_}->{a:_}->{B:_} -> Tm2 g (arr2 a B) -> Tm2 g a -> Tm2 g B\napp2 = \\ t, u, tm, var2, lam2, app2 => app2 _ _ _ (t tm var2 lam2 app2) (u tm var2 lam2 app2)\n\nv02 : {g:_}->{a:_} -> Tm2 (snoc2 g a) a\nv02 = var2 vz2\n\nv12 : {g:_}->{a:_}-> {B:_}-> Tm2 (snoc2 (snoc2 g a) B) a\nv12 = var2 (vs2 vz2)\n\nv22 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm2 (snoc2 (snoc2 (snoc2 g a) B) C) a\nv22 = var2 (vs2 (vs2 vz2))\n\nv32 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm2 (snoc2 (snoc2 (snoc2 (snoc2 g a) B) C) D) a\nv32 = var2 (vs2 (vs2 (vs2 vz2)))\n\nv42 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm2 (snoc2 (snoc2 (snoc2 (snoc2 (snoc2 g a) B) C) D) E) a\nv42 = var2 (vs2 (vs2 (vs2 (vs2 vz2))))\n\ntest2 : {g:_}-> {a:_} -> Tm2 g (arr2 (arr2 a a) (arr2 a a))\ntest2 = lam2 (lam2 (app2 v12 (app2 v12 (app2 v12 (app2 v12 (app2 v12 (app2 v12 v02)))))))\nTy3 : Type\nTy3 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty3 : Ty3\nempty3 = \\ _, empty, _ => empty\n\narr3 : Ty3 -> Ty3 -> Ty3\narr3 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon3 : Type\nCon3 = (Con3 : Type)\n ->(nil : Con3)\n ->(snoc : Con3 -> Ty3 -> Con3)\n -> Con3\n\nnil3 : Con3\nnil3 = \\ con, nil3, snoc => nil3\n\nsnoc3 : Con3 -> Ty3 -> Con3\nsnoc3 = \\ g, a, con, nil3, snoc3 => snoc3 (g con nil3 snoc3) a\n\nVar3 : Con3 -> Ty3 -> Type\nVar3 = \\ g, a =>\n (Var3 : Con3 -> Ty3 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var3 (snoc3 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var3 g a -> Var3 (snoc3 g b) a)\n -> Var3 g a\n\nvz3 : {g : _}-> {a : _} -> Var3 (snoc3 g a) a\nvz3 = \\ var, vz3, vs => vz3 _ _\n\nvs3 : {g : _} -> {B : _} -> {a : _} -> Var3 g a -> Var3 (snoc3 g B) a\nvs3 = \\ x, var, vz3, vs3 => vs3 _ _ _ (x var vz3 vs3)\n\nTm3 : Con3 -> Ty3 -> Type\nTm3 = \\ g, a =>\n (Tm3 : Con3 -> Ty3 -> Type)\n -> (var : (g : _) -> (a : _) -> Var3 g a -> Tm3 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm3 (snoc3 g a) B -> Tm3 g (arr3 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm3 g (arr3 a B) -> Tm3 g a -> Tm3 g B)\n -> Tm3 g a\n\nvar3 : {g : _} -> {a : _} -> Var3 g a -> Tm3 g a\nvar3 = \\ x, tm, var3, lam, app => var3 _ _ x\n\nlam3 : {g : _} -> {a : _} -> {B : _} -> Tm3 (snoc3 g a) B -> Tm3 g (arr3 a B)\nlam3 = \\ t, tm, var3, lam3, app => lam3 _ _ _ (t tm var3 lam3 app)\n\napp3 : {g:_}->{a:_}->{B:_} -> Tm3 g (arr3 a B) -> Tm3 g a -> Tm3 g B\napp3 = \\ t, u, tm, var3, lam3, app3 => app3 _ _ _ (t tm var3 lam3 app3) (u tm var3 lam3 app3)\n\nv03 : {g:_}->{a:_} -> Tm3 (snoc3 g a) a\nv03 = var3 vz3\n\nv13 : {g:_}->{a:_}-> {B:_}-> Tm3 (snoc3 (snoc3 g a) B) a\nv13 = var3 (vs3 vz3)\n\nv23 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm3 (snoc3 (snoc3 (snoc3 g a) B) C) a\nv23 = var3 (vs3 (vs3 vz3))\n\nv33 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm3 (snoc3 (snoc3 (snoc3 (snoc3 g a) B) C) D) a\nv33 = var3 (vs3 (vs3 (vs3 vz3)))\n\nv43 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm3 (snoc3 (snoc3 (snoc3 (snoc3 (snoc3 g a) B) C) D) E) a\nv43 = var3 (vs3 (vs3 (vs3 (vs3 vz3))))\n\ntest3 : {g:_}-> {a:_} -> Tm3 g (arr3 (arr3 a a) (arr3 a a))\ntest3 = lam3 (lam3 (app3 v13 (app3 v13 (app3 v13 (app3 v13 (app3 v13 (app3 v13 v03)))))))\nTy4 : Type\nTy4 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty4 : Ty4\nempty4 = \\ _, empty, _ => empty\n\narr4 : Ty4 -> Ty4 -> Ty4\narr4 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon4 : Type\nCon4 = (Con4 : Type)\n ->(nil : Con4)\n ->(snoc : Con4 -> Ty4 -> Con4)\n -> Con4\n\nnil4 : Con4\nnil4 = \\ con, nil4, snoc => nil4\n\nsnoc4 : Con4 -> Ty4 -> Con4\nsnoc4 = \\ g, a, con, nil4, snoc4 => snoc4 (g con nil4 snoc4) a\n\nVar4 : Con4 -> Ty4 -> Type\nVar4 = \\ g, a =>\n (Var4 : Con4 -> Ty4 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var4 (snoc4 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var4 g a -> Var4 (snoc4 g b) a)\n -> Var4 g a\n\nvz4 : {g : _}-> {a : _} -> Var4 (snoc4 g a) a\nvz4 = \\ var, vz4, vs => vz4 _ _\n\nvs4 : {g : _} -> {B : _} -> {a : _} -> Var4 g a -> Var4 (snoc4 g B) a\nvs4 = \\ x, var, vz4, vs4 => vs4 _ _ _ (x var vz4 vs4)\n\nTm4 : Con4 -> Ty4 -> Type\nTm4 = \\ g, a =>\n (Tm4 : Con4 -> Ty4 -> Type)\n -> (var : (g : _) -> (a : _) -> Var4 g a -> Tm4 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm4 (snoc4 g a) B -> Tm4 g (arr4 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm4 g (arr4 a B) -> Tm4 g a -> Tm4 g B)\n -> Tm4 g a\n\nvar4 : {g : _} -> {a : _} -> Var4 g a -> Tm4 g a\nvar4 = \\ x, tm, var4, lam, app => var4 _ _ x\n\nlam4 : {g : _} -> {a : _} -> {B : _} -> Tm4 (snoc4 g a) B -> Tm4 g (arr4 a B)\nlam4 = \\ t, tm, var4, lam4, app => lam4 _ _ _ (t tm var4 lam4 app)\n\napp4 : {g:_}->{a:_}->{B:_} -> Tm4 g (arr4 a B) -> Tm4 g a -> Tm4 g B\napp4 = \\ t, u, tm, var4, lam4, app4 => app4 _ _ _ (t tm var4 lam4 app4) (u tm var4 lam4 app4)\n\nv04 : {g:_}->{a:_} -> Tm4 (snoc4 g a) a\nv04 = var4 vz4\n\nv14 : {g:_}->{a:_}-> {B:_}-> Tm4 (snoc4 (snoc4 g a) B) a\nv14 = var4 (vs4 vz4)\n\nv24 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm4 (snoc4 (snoc4 (snoc4 g a) B) C) a\nv24 = var4 (vs4 (vs4 vz4))\n\nv34 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm4 (snoc4 (snoc4 (snoc4 (snoc4 g a) B) C) D) a\nv34 = var4 (vs4 (vs4 (vs4 vz4)))\n\nv44 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm4 (snoc4 (snoc4 (snoc4 (snoc4 (snoc4 g a) B) C) D) E) a\nv44 = var4 (vs4 (vs4 (vs4 (vs4 vz4))))\n\ntest4 : {g:_}-> {a:_} -> Tm4 g (arr4 (arr4 a a) (arr4 a a))\ntest4 = lam4 (lam4 (app4 v14 (app4 v14 (app4 v14 (app4 v14 (app4 v14 (app4 v14 v04)))))))\nTy5 : Type\nTy5 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty5 : Ty5\nempty5 = \\ _, empty, _ => empty\n\narr5 : Ty5 -> Ty5 -> Ty5\narr5 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon5 : Type\nCon5 = (Con5 : Type)\n ->(nil : Con5)\n ->(snoc : Con5 -> Ty5 -> Con5)\n -> Con5\n\nnil5 : Con5\nnil5 = \\ con, nil5, snoc => nil5\n\nsnoc5 : Con5 -> Ty5 -> Con5\nsnoc5 = \\ g, a, con, nil5, snoc5 => snoc5 (g con nil5 snoc5) a\n\nVar5 : Con5 -> Ty5 -> Type\nVar5 = \\ g, a =>\n (Var5 : Con5 -> Ty5 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var5 (snoc5 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var5 g a -> Var5 (snoc5 g b) a)\n -> Var5 g a\n\nvz5 : {g : _}-> {a : _} -> Var5 (snoc5 g a) a\nvz5 = \\ var, vz5, vs => vz5 _ _\n\nvs5 : {g : _} -> {B : _} -> {a : _} -> Var5 g a -> Var5 (snoc5 g B) a\nvs5 = \\ x, var, vz5, vs5 => vs5 _ _ _ (x var vz5 vs5)\n\nTm5 : Con5 -> Ty5 -> Type\nTm5 = \\ g, a =>\n (Tm5 : Con5 -> Ty5 -> Type)\n -> (var : (g : _) -> (a : _) -> Var5 g a -> Tm5 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm5 (snoc5 g a) B -> Tm5 g (arr5 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm5 g (arr5 a B) -> Tm5 g a -> Tm5 g B)\n -> Tm5 g a\n\nvar5 : {g : _} -> {a : _} -> Var5 g a -> Tm5 g a\nvar5 = \\ x, tm, var5, lam, app => var5 _ _ x\n\nlam5 : {g : _} -> {a : _} -> {B : _} -> Tm5 (snoc5 g a) B -> Tm5 g (arr5 a B)\nlam5 = \\ t, tm, var5, lam5, app => lam5 _ _ _ (t tm var5 lam5 app)\n\napp5 : {g:_}->{a:_}->{B:_} -> Tm5 g (arr5 a B) -> Tm5 g a -> Tm5 g B\napp5 = \\ t, u, tm, var5, lam5, app5 => app5 _ _ _ (t tm var5 lam5 app5) (u tm var5 lam5 app5)\n\nv05 : {g:_}->{a:_} -> Tm5 (snoc5 g a) a\nv05 = var5 vz5\n\nv15 : {g:_}->{a:_}-> {B:_}-> Tm5 (snoc5 (snoc5 g a) B) a\nv15 = var5 (vs5 vz5)\n\nv25 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm5 (snoc5 (snoc5 (snoc5 g a) B) C) a\nv25 = var5 (vs5 (vs5 vz5))\n\nv35 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm5 (snoc5 (snoc5 (snoc5 (snoc5 g a) B) C) D) a\nv35 = var5 (vs5 (vs5 (vs5 vz5)))\n\nv45 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm5 (snoc5 (snoc5 (snoc5 (snoc5 (snoc5 g a) B) C) D) E) a\nv45 = var5 (vs5 (vs5 (vs5 (vs5 vz5))))\n\ntest5 : {g:_}-> {a:_} -> Tm5 g (arr5 (arr5 a a) (arr5 a a))\ntest5 = lam5 (lam5 (app5 v15 (app5 v15 (app5 v15 (app5 v15 (app5 v15 (app5 v15 v05)))))))\nTy6 : Type\nTy6 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty6 : Ty6\nempty6 = \\ _, empty, _ => empty\n\narr6 : Ty6 -> Ty6 -> Ty6\narr6 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon6 : Type\nCon6 = (Con6 : Type)\n ->(nil : Con6)\n ->(snoc : Con6 -> Ty6 -> Con6)\n -> Con6\n\nnil6 : Con6\nnil6 = \\ con, nil6, snoc => nil6\n\nsnoc6 : Con6 -> Ty6 -> Con6\nsnoc6 = \\ g, a, con, nil6, snoc6 => snoc6 (g con nil6 snoc6) a\n\nVar6 : Con6 -> Ty6 -> Type\nVar6 = \\ g, a =>\n (Var6 : Con6 -> Ty6 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var6 (snoc6 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var6 g a -> Var6 (snoc6 g b) a)\n -> Var6 g a\n\nvz6 : {g : _}-> {a : _} -> Var6 (snoc6 g a) a\nvz6 = \\ var, vz6, vs => vz6 _ _\n\nvs6 : {g : _} -> {B : _} -> {a : _} -> Var6 g a -> Var6 (snoc6 g B) a\nvs6 = \\ x, var, vz6, vs6 => vs6 _ _ _ (x var vz6 vs6)\n\nTm6 : Con6 -> Ty6 -> Type\nTm6 = \\ g, a =>\n (Tm6 : Con6 -> Ty6 -> Type)\n -> (var : (g : _) -> (a : _) -> Var6 g a -> Tm6 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm6 (snoc6 g a) B -> Tm6 g (arr6 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm6 g (arr6 a B) -> Tm6 g a -> Tm6 g B)\n -> Tm6 g a\n\nvar6 : {g : _} -> {a : _} -> Var6 g a -> Tm6 g a\nvar6 = \\ x, tm, var6, lam, app => var6 _ _ x\n\nlam6 : {g : _} -> {a : _} -> {B : _} -> Tm6 (snoc6 g a) B -> Tm6 g (arr6 a B)\nlam6 = \\ t, tm, var6, lam6, app => lam6 _ _ _ (t tm var6 lam6 app)\n\napp6 : {g:_}->{a:_}->{B:_} -> Tm6 g (arr6 a B) -> Tm6 g a -> Tm6 g B\napp6 = \\ t, u, tm, var6, lam6, app6 => app6 _ _ _ (t tm var6 lam6 app6) (u tm var6 lam6 app6)\n\nv06 : {g:_}->{a:_} -> Tm6 (snoc6 g a) a\nv06 = var6 vz6\n\nv16 : {g:_}->{a:_}-> {B:_}-> Tm6 (snoc6 (snoc6 g a) B) a\nv16 = var6 (vs6 vz6)\n\nv26 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm6 (snoc6 (snoc6 (snoc6 g a) B) C) a\nv26 = var6 (vs6 (vs6 vz6))\n\nv36 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm6 (snoc6 (snoc6 (snoc6 (snoc6 g a) B) C) D) a\nv36 = var6 (vs6 (vs6 (vs6 vz6)))\n\nv46 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm6 (snoc6 (snoc6 (snoc6 (snoc6 (snoc6 g a) B) C) D) E) a\nv46 = var6 (vs6 (vs6 (vs6 (vs6 vz6))))\n\ntest6 : {g:_}-> {a:_} -> Tm6 g (arr6 (arr6 a a) (arr6 a a))\ntest6 = lam6 (lam6 (app6 v16 (app6 v16 (app6 v16 (app6 v16 (app6 v16 (app6 v16 v06)))))))\nTy7 : Type\nTy7 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty7 : Ty7\nempty7 = \\ _, empty, _ => empty\n\narr7 : Ty7 -> Ty7 -> Ty7\narr7 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon7 : Type\nCon7 = (Con7 : Type)\n ->(nil : Con7)\n ->(snoc : Con7 -> Ty7 -> Con7)\n -> Con7\n\nnil7 : Con7\nnil7 = \\ con, nil7, snoc => nil7\n\nsnoc7 : Con7 -> Ty7 -> Con7\nsnoc7 = \\ g, a, con, nil7, snoc7 => snoc7 (g con nil7 snoc7) a\n\nVar7 : Con7 -> Ty7 -> Type\nVar7 = \\ g, a =>\n (Var7 : Con7 -> Ty7 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var7 (snoc7 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var7 g a -> Var7 (snoc7 g b) a)\n -> Var7 g a\n\nvz7 : {g : _}-> {a : _} -> Var7 (snoc7 g a) a\nvz7 = \\ var, vz7, vs => vz7 _ _\n\nvs7 : {g : _} -> {B : _} -> {a : _} -> Var7 g a -> Var7 (snoc7 g B) a\nvs7 = \\ x, var, vz7, vs7 => vs7 _ _ _ (x var vz7 vs7)\n\nTm7 : Con7 -> Ty7 -> Type\nTm7 = \\ g, a =>\n (Tm7 : Con7 -> Ty7 -> Type)\n -> (var : (g : _) -> (a : _) -> Var7 g a -> Tm7 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm7 (snoc7 g a) B -> Tm7 g (arr7 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm7 g (arr7 a B) -> Tm7 g a -> Tm7 g B)\n -> Tm7 g a\n\nvar7 : {g : _} -> {a : _} -> Var7 g a -> Tm7 g a\nvar7 = \\ x, tm, var7, lam, app => var7 _ _ x\n\nlam7 : {g : _} -> {a : _} -> {B : _} -> Tm7 (snoc7 g a) B -> Tm7 g (arr7 a B)\nlam7 = \\ t, tm, var7, lam7, app => lam7 _ _ _ (t tm var7 lam7 app)\n\napp7 : {g:_}->{a:_}->{B:_} -> Tm7 g (arr7 a B) -> Tm7 g a -> Tm7 g B\napp7 = \\ t, u, tm, var7, lam7, app7 => app7 _ _ _ (t tm var7 lam7 app7) (u tm var7 lam7 app7)\n\nv07 : {g:_}->{a:_} -> Tm7 (snoc7 g a) a\nv07 = var7 vz7\n\nv17 : {g:_}->{a:_}-> {B:_}-> Tm7 (snoc7 (snoc7 g a) B) a\nv17 = var7 (vs7 vz7)\n\nv27 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm7 (snoc7 (snoc7 (snoc7 g a) B) C) a\nv27 = var7 (vs7 (vs7 vz7))\n\nv37 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm7 (snoc7 (snoc7 (snoc7 (snoc7 g a) B) C) D) a\nv37 = var7 (vs7 (vs7 (vs7 vz7)))\n\nv47 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm7 (snoc7 (snoc7 (snoc7 (snoc7 (snoc7 g a) B) C) D) E) a\nv47 = var7 (vs7 (vs7 (vs7 (vs7 vz7))))\n\ntest7 : {g:_}-> {a:_} -> Tm7 g (arr7 (arr7 a a) (arr7 a a))\ntest7 = lam7 (lam7 (app7 v17 (app7 v17 (app7 v17 (app7 v17 (app7 v17 (app7 v17 v07)))))))\nTy8 : Type\nTy8 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty8 : Ty8\nempty8 = \\ _, empty, _ => empty\n\narr8 : Ty8 -> Ty8 -> Ty8\narr8 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon8 : Type\nCon8 = (Con8 : Type)\n ->(nil : Con8)\n ->(snoc : Con8 -> Ty8 -> Con8)\n -> Con8\n\nnil8 : Con8\nnil8 = \\ con, nil8, snoc => nil8\n\nsnoc8 : Con8 -> Ty8 -> Con8\nsnoc8 = \\ g, a, con, nil8, snoc8 => snoc8 (g con nil8 snoc8) a\n\nVar8 : Con8 -> Ty8 -> Type\nVar8 = \\ g, a =>\n (Var8 : Con8 -> Ty8 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var8 (snoc8 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var8 g a -> Var8 (snoc8 g b) a)\n -> Var8 g a\n\nvz8 : {g : _}-> {a : _} -> Var8 (snoc8 g a) a\nvz8 = \\ var, vz8, vs => vz8 _ _\n\nvs8 : {g : _} -> {B : _} -> {a : _} -> Var8 g a -> Var8 (snoc8 g B) a\nvs8 = \\ x, var, vz8, vs8 => vs8 _ _ _ (x var vz8 vs8)\n\nTm8 : Con8 -> Ty8 -> Type\nTm8 = \\ g, a =>\n (Tm8 : Con8 -> Ty8 -> Type)\n -> (var : (g : _) -> (a : _) -> Var8 g a -> Tm8 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm8 (snoc8 g a) B -> Tm8 g (arr8 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm8 g (arr8 a B) -> Tm8 g a -> Tm8 g B)\n -> Tm8 g a\n\nvar8 : {g : _} -> {a : _} -> Var8 g a -> Tm8 g a\nvar8 = \\ x, tm, var8, lam, app => var8 _ _ x\n\nlam8 : {g : _} -> {a : _} -> {B : _} -> Tm8 (snoc8 g a) B -> Tm8 g (arr8 a B)\nlam8 = \\ t, tm, var8, lam8, app => lam8 _ _ _ (t tm var8 lam8 app)\n\napp8 : {g:_}->{a:_}->{B:_} -> Tm8 g (arr8 a B) -> Tm8 g a -> Tm8 g B\napp8 = \\ t, u, tm, var8, lam8, app8 => app8 _ _ _ (t tm var8 lam8 app8) (u tm var8 lam8 app8)\n\nv08 : {g:_}->{a:_} -> Tm8 (snoc8 g a) a\nv08 = var8 vz8\n\nv18 : {g:_}->{a:_}-> {B:_}-> Tm8 (snoc8 (snoc8 g a) B) a\nv18 = var8 (vs8 vz8)\n\nv28 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm8 (snoc8 (snoc8 (snoc8 g a) B) C) a\nv28 = var8 (vs8 (vs8 vz8))\n\nv38 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm8 (snoc8 (snoc8 (snoc8 (snoc8 g a) B) C) D) a\nv38 = var8 (vs8 (vs8 (vs8 vz8)))\n\nv48 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm8 (snoc8 (snoc8 (snoc8 (snoc8 (snoc8 g a) B) C) D) E) a\nv48 = var8 (vs8 (vs8 (vs8 (vs8 vz8))))\n\ntest8 : {g:_}-> {a:_} -> Tm8 g (arr8 (arr8 a a) (arr8 a a))\ntest8 = lam8 (lam8 (app8 v18 (app8 v18 (app8 v18 (app8 v18 (app8 v18 (app8 v18 v08)))))))\nTy9 : Type\nTy9 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty9 : Ty9\nempty9 = \\ _, empty, _ => empty\n\narr9 : Ty9 -> Ty9 -> Ty9\narr9 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon9 : Type\nCon9 = (Con9 : Type)\n ->(nil : Con9)\n ->(snoc : Con9 -> Ty9 -> Con9)\n -> Con9\n\nnil9 : Con9\nnil9 = \\ con, nil9, snoc => nil9\n\nsnoc9 : Con9 -> Ty9 -> Con9\nsnoc9 = \\ g, a, con, nil9, snoc9 => snoc9 (g con nil9 snoc9) a\n\nVar9 : Con9 -> Ty9 -> Type\nVar9 = \\ g, a =>\n (Var9 : Con9 -> Ty9 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var9 (snoc9 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var9 g a -> Var9 (snoc9 g b) a)\n -> Var9 g a\n\nvz9 : {g : _}-> {a : _} -> Var9 (snoc9 g a) a\nvz9 = \\ var, vz9, vs => vz9 _ _\n\nvs9 : {g : _} -> {B : _} -> {a : _} -> Var9 g a -> Var9 (snoc9 g B) a\nvs9 = \\ x, var, vz9, vs9 => vs9 _ _ _ (x var vz9 vs9)\n\nTm9 : Con9 -> Ty9 -> Type\nTm9 = \\ g, a =>\n (Tm9 : Con9 -> Ty9 -> Type)\n -> (var : (g : _) -> (a : _) -> Var9 g a -> Tm9 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm9 (snoc9 g a) B -> Tm9 g (arr9 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm9 g (arr9 a B) -> Tm9 g a -> Tm9 g B)\n -> Tm9 g a\n\nvar9 : {g : _} -> {a : _} -> Var9 g a -> Tm9 g a\nvar9 = \\ x, tm, var9, lam, app => var9 _ _ x\n\nlam9 : {g : _} -> {a : _} -> {B : _} -> Tm9 (snoc9 g a) B -> Tm9 g (arr9 a B)\nlam9 = \\ t, tm, var9, lam9, app => lam9 _ _ _ (t tm var9 lam9 app)\n\napp9 : {g:_}->{a:_}->{B:_} -> Tm9 g (arr9 a B) -> Tm9 g a -> Tm9 g B\napp9 = \\ t, u, tm, var9, lam9, app9 => app9 _ _ _ (t tm var9 lam9 app9) (u tm var9 lam9 app9)\n\nv09 : {g:_}->{a:_} -> Tm9 (snoc9 g a) a\nv09 = var9 vz9\n\nv19 : {g:_}->{a:_}-> {B:_}-> Tm9 (snoc9 (snoc9 g a) B) a\nv19 = var9 (vs9 vz9)\n\nv29 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm9 (snoc9 (snoc9 (snoc9 g a) B) C) a\nv29 = var9 (vs9 (vs9 vz9))\n\nv39 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm9 (snoc9 (snoc9 (snoc9 (snoc9 g a) B) C) D) a\nv39 = var9 (vs9 (vs9 (vs9 vz9)))\n\nv49 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm9 (snoc9 (snoc9 (snoc9 (snoc9 (snoc9 g a) B) C) D) E) a\nv49 = var9 (vs9 (vs9 (vs9 (vs9 vz9))))\n\ntest9 : {g:_}-> {a:_} -> Tm9 g (arr9 (arr9 a a) (arr9 a a))\ntest9 = lam9 (lam9 (app9 v19 (app9 v19 (app9 v19 (app9 v19 (app9 v19 (app9 v19 v09)))))))\nTy10 : Type\nTy10 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty10 : Ty10\nempty10 = \\ _, empty, _ => empty\n\narr10 : Ty10 -> Ty10 -> Ty10\narr10 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon10 : Type\nCon10 = (Con10 : Type)\n ->(nil : Con10)\n ->(snoc : Con10 -> Ty10 -> Con10)\n -> Con10\n\nnil10 : Con10\nnil10 = \\ con, nil10, snoc => nil10\n\nsnoc10 : Con10 -> Ty10 -> Con10\nsnoc10 = \\ g, a, con, nil10, snoc10 => snoc10 (g con nil10 snoc10) a\n\nVar10 : Con10 -> Ty10 -> Type\nVar10 = \\ g, a =>\n (Var10 : Con10 -> Ty10 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var10 (snoc10 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var10 g a -> Var10 (snoc10 g b) a)\n -> Var10 g a\n\nvz10 : {g : _}-> {a : _} -> Var10 (snoc10 g a) a\nvz10 = \\ var, vz10, vs => vz10 _ _\n\nvs10 : {g : _} -> {B : _} -> {a : _} -> Var10 g a -> Var10 (snoc10 g B) a\nvs10 = \\ x, var, vz10, vs10 => vs10 _ _ _ (x var vz10 vs10)\n\nTm10 : Con10 -> Ty10 -> Type\nTm10 = \\ g, a =>\n (Tm10 : Con10 -> Ty10 -> Type)\n -> (var : (g : _) -> (a : _) -> Var10 g a -> Tm10 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm10 (snoc10 g a) B -> Tm10 g (arr10 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm10 g (arr10 a B) -> Tm10 g a -> Tm10 g B)\n -> Tm10 g a\n\nvar10 : {g : _} -> {a : _} -> Var10 g a -> Tm10 g a\nvar10 = \\ x, tm, var10, lam, app => var10 _ _ x\n\nlam10 : {g : _} -> {a : _} -> {B : _} -> Tm10 (snoc10 g a) B -> Tm10 g (arr10 a B)\nlam10 = \\ t, tm, var10, lam10, app => lam10 _ _ _ (t tm var10 lam10 app)\n\napp10 : {g:_}->{a:_}->{B:_} -> Tm10 g (arr10 a B) -> Tm10 g a -> Tm10 g B\napp10 = \\ t, u, tm, var10, lam10, app10 => app10 _ _ _ (t tm var10 lam10 app10) (u tm var10 lam10 app10)\n\nv010 : {g:_}->{a:_} -> Tm10 (snoc10 g a) a\nv010 = var10 vz10\n\nv110 : {g:_}->{a:_}-> {B:_}-> Tm10 (snoc10 (snoc10 g a) B) a\nv110 = var10 (vs10 vz10)\n\nv210 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm10 (snoc10 (snoc10 (snoc10 g a) B) C) a\nv210 = var10 (vs10 (vs10 vz10))\n\nv310 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm10 (snoc10 (snoc10 (snoc10 (snoc10 g a) B) C) D) a\nv310 = var10 (vs10 (vs10 (vs10 vz10)))\n\nv410 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm10 (snoc10 (snoc10 (snoc10 (snoc10 (snoc10 g a) B) C) D) E) a\nv410 = var10 (vs10 (vs10 (vs10 (vs10 vz10))))\n\ntest10 : {g:_}-> {a:_} -> Tm10 g (arr10 (arr10 a a) (arr10 a a))\ntest10 = lam10 (lam10 (app10 v110 (app10 v110 (app10 v110 (app10 v110 (app10 v110 (app10 v110 v010)))))))\nTy11 : Type\nTy11 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty11 : Ty11\nempty11 = \\ _, empty, _ => empty\n\narr11 : Ty11 -> Ty11 -> Ty11\narr11 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon11 : Type\nCon11 = (Con11 : Type)\n ->(nil : Con11)\n ->(snoc : Con11 -> Ty11 -> Con11)\n -> Con11\n\nnil11 : Con11\nnil11 = \\ con, nil11, snoc => nil11\n\nsnoc11 : Con11 -> Ty11 -> Con11\nsnoc11 = \\ g, a, con, nil11, snoc11 => snoc11 (g con nil11 snoc11) a\n\nVar11 : Con11 -> Ty11 -> Type\nVar11 = \\ g, a =>\n (Var11 : Con11 -> Ty11 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var11 (snoc11 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var11 g a -> Var11 (snoc11 g b) a)\n -> Var11 g a\n\nvz11 : {g : _}-> {a : _} -> Var11 (snoc11 g a) a\nvz11 = \\ var, vz11, vs => vz11 _ _\n\nvs11 : {g : _} -> {B : _} -> {a : _} -> Var11 g a -> Var11 (snoc11 g B) a\nvs11 = \\ x, var, vz11, vs11 => vs11 _ _ _ (x var vz11 vs11)\n\nTm11 : Con11 -> Ty11 -> Type\nTm11 = \\ g, a =>\n (Tm11 : Con11 -> Ty11 -> Type)\n -> (var : (g : _) -> (a : _) -> Var11 g a -> Tm11 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm11 (snoc11 g a) B -> Tm11 g (arr11 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm11 g (arr11 a B) -> Tm11 g a -> Tm11 g B)\n -> Tm11 g a\n\nvar11 : {g : _} -> {a : _} -> Var11 g a -> Tm11 g a\nvar11 = \\ x, tm, var11, lam, app => var11 _ _ x\n\nlam11 : {g : _} -> {a : _} -> {B : _} -> Tm11 (snoc11 g a) B -> Tm11 g (arr11 a B)\nlam11 = \\ t, tm, var11, lam11, app => lam11 _ _ _ (t tm var11 lam11 app)\n\napp11 : {g:_}->{a:_}->{B:_} -> Tm11 g (arr11 a B) -> Tm11 g a -> Tm11 g B\napp11 = \\ t, u, tm, var11, lam11, app11 => app11 _ _ _ (t tm var11 lam11 app11) (u tm var11 lam11 app11)\n\nv011 : {g:_}->{a:_} -> Tm11 (snoc11 g a) a\nv011 = var11 vz11\n\nv111 : {g:_}->{a:_}-> {B:_}-> Tm11 (snoc11 (snoc11 g a) B) a\nv111 = var11 (vs11 vz11)\n\nv211 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm11 (snoc11 (snoc11 (snoc11 g a) B) C) a\nv211 = var11 (vs11 (vs11 vz11))\n\nv311 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm11 (snoc11 (snoc11 (snoc11 (snoc11 g a) B) C) D) a\nv311 = var11 (vs11 (vs11 (vs11 vz11)))\n\nv411 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm11 (snoc11 (snoc11 (snoc11 (snoc11 (snoc11 g a) B) C) D) E) a\nv411 = var11 (vs11 (vs11 (vs11 (vs11 vz11))))\n\ntest11 : {g:_}-> {a:_} -> Tm11 g (arr11 (arr11 a a) (arr11 a a))\ntest11 = lam11 (lam11 (app11 v111 (app11 v111 (app11 v111 (app11 v111 (app11 v111 (app11 v111 v011)))))))\nTy12 : Type\nTy12 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty12 : Ty12\nempty12 = \\ _, empty, _ => empty\n\narr12 : Ty12 -> Ty12 -> Ty12\narr12 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon12 : Type\nCon12 = (Con12 : Type)\n ->(nil : Con12)\n ->(snoc : Con12 -> Ty12 -> Con12)\n -> Con12\n\nnil12 : Con12\nnil12 = \\ con, nil12, snoc => nil12\n\nsnoc12 : Con12 -> Ty12 -> Con12\nsnoc12 = \\ g, a, con, nil12, snoc12 => snoc12 (g con nil12 snoc12) a\n\nVar12 : Con12 -> Ty12 -> Type\nVar12 = \\ g, a =>\n (Var12 : Con12 -> Ty12 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var12 (snoc12 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var12 g a -> Var12 (snoc12 g b) a)\n -> Var12 g a\n\nvz12 : {g : _}-> {a : _} -> Var12 (snoc12 g a) a\nvz12 = \\ var, vz12, vs => vz12 _ _\n\nvs12 : {g : _} -> {B : _} -> {a : _} -> Var12 g a -> Var12 (snoc12 g B) a\nvs12 = \\ x, var, vz12, vs12 => vs12 _ _ _ (x var vz12 vs12)\n\nTm12 : Con12 -> Ty12 -> Type\nTm12 = \\ g, a =>\n (Tm12 : Con12 -> Ty12 -> Type)\n -> (var : (g : _) -> (a : _) -> Var12 g a -> Tm12 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm12 (snoc12 g a) B -> Tm12 g (arr12 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm12 g (arr12 a B) -> Tm12 g a -> Tm12 g B)\n -> Tm12 g a\n\nvar12 : {g : _} -> {a : _} -> Var12 g a -> Tm12 g a\nvar12 = \\ x, tm, var12, lam, app => var12 _ _ x\n\nlam12 : {g : _} -> {a : _} -> {B : _} -> Tm12 (snoc12 g a) B -> Tm12 g (arr12 a B)\nlam12 = \\ t, tm, var12, lam12, app => lam12 _ _ _ (t tm var12 lam12 app)\n\napp12 : {g:_}->{a:_}->{B:_} -> Tm12 g (arr12 a B) -> Tm12 g a -> Tm12 g B\napp12 = \\ t, u, tm, var12, lam12, app12 => app12 _ _ _ (t tm var12 lam12 app12) (u tm var12 lam12 app12)\n\nv012 : {g:_}->{a:_} -> Tm12 (snoc12 g a) a\nv012 = var12 vz12\n\nv112 : {g:_}->{a:_}-> {B:_}-> Tm12 (snoc12 (snoc12 g a) B) a\nv112 = var12 (vs12 vz12)\n\nv212 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm12 (snoc12 (snoc12 (snoc12 g a) B) C) a\nv212 = var12 (vs12 (vs12 vz12))\n\nv312 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm12 (snoc12 (snoc12 (snoc12 (snoc12 g a) B) C) D) a\nv312 = var12 (vs12 (vs12 (vs12 vz12)))\n\nv412 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm12 (snoc12 (snoc12 (snoc12 (snoc12 (snoc12 g a) B) C) D) E) a\nv412 = var12 (vs12 (vs12 (vs12 (vs12 vz12))))\n\ntest12 : {g:_}-> {a:_} -> Tm12 g (arr12 (arr12 a a) (arr12 a a))\ntest12 = lam12 (lam12 (app12 v112 (app12 v112 (app12 v112 (app12 v112 (app12 v112 (app12 v112 v012)))))))\nTy13 : Type\nTy13 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty13 : Ty13\nempty13 = \\ _, empty, _ => empty\n\narr13 : Ty13 -> Ty13 -> Ty13\narr13 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon13 : Type\nCon13 = (Con13 : Type)\n ->(nil : Con13)\n ->(snoc : Con13 -> Ty13 -> Con13)\n -> Con13\n\nnil13 : Con13\nnil13 = \\ con, nil13, snoc => nil13\n\nsnoc13 : Con13 -> Ty13 -> Con13\nsnoc13 = \\ g, a, con, nil13, snoc13 => snoc13 (g con nil13 snoc13) a\n\nVar13 : Con13 -> Ty13 -> Type\nVar13 = \\ g, a =>\n (Var13 : Con13 -> Ty13 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var13 (snoc13 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var13 g a -> Var13 (snoc13 g b) a)\n -> Var13 g a\n\nvz13 : {g : _}-> {a : _} -> Var13 (snoc13 g a) a\nvz13 = \\ var, vz13, vs => vz13 _ _\n\nvs13 : {g : _} -> {B : _} -> {a : _} -> Var13 g a -> Var13 (snoc13 g B) a\nvs13 = \\ x, var, vz13, vs13 => vs13 _ _ _ (x var vz13 vs13)\n\nTm13 : Con13 -> Ty13 -> Type\nTm13 = \\ g, a =>\n (Tm13 : Con13 -> Ty13 -> Type)\n -> (var : (g : _) -> (a : _) -> Var13 g a -> Tm13 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm13 (snoc13 g a) B -> Tm13 g (arr13 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm13 g (arr13 a B) -> Tm13 g a -> Tm13 g B)\n -> Tm13 g a\n\nvar13 : {g : _} -> {a : _} -> Var13 g a -> Tm13 g a\nvar13 = \\ x, tm, var13, lam, app => var13 _ _ x\n\nlam13 : {g : _} -> {a : _} -> {B : _} -> Tm13 (snoc13 g a) B -> Tm13 g (arr13 a B)\nlam13 = \\ t, tm, var13, lam13, app => lam13 _ _ _ (t tm var13 lam13 app)\n\napp13 : {g:_}->{a:_}->{B:_} -> Tm13 g (arr13 a B) -> Tm13 g a -> Tm13 g B\napp13 = \\ t, u, tm, var13, lam13, app13 => app13 _ _ _ (t tm var13 lam13 app13) (u tm var13 lam13 app13)\n\nv013 : {g:_}->{a:_} -> Tm13 (snoc13 g a) a\nv013 = var13 vz13\n\nv113 : {g:_}->{a:_}-> {B:_}-> Tm13 (snoc13 (snoc13 g a) B) a\nv113 = var13 (vs13 vz13)\n\nv213 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm13 (snoc13 (snoc13 (snoc13 g a) B) C) a\nv213 = var13 (vs13 (vs13 vz13))\n\nv313 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm13 (snoc13 (snoc13 (snoc13 (snoc13 g a) B) C) D) a\nv313 = var13 (vs13 (vs13 (vs13 vz13)))\n\nv413 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm13 (snoc13 (snoc13 (snoc13 (snoc13 (snoc13 g a) B) C) D) E) a\nv413 = var13 (vs13 (vs13 (vs13 (vs13 vz13))))\n\ntest13 : {g:_}-> {a:_} -> Tm13 g (arr13 (arr13 a a) (arr13 a a))\ntest13 = lam13 (lam13 (app13 v113 (app13 v113 (app13 v113 (app13 v113 (app13 v113 (app13 v113 v013)))))))\nTy14 : Type\nTy14 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty14 : Ty14\nempty14 = \\ _, empty, _ => empty\n\narr14 : Ty14 -> Ty14 -> Ty14\narr14 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon14 : Type\nCon14 = (Con14 : Type)\n ->(nil : Con14)\n ->(snoc : Con14 -> Ty14 -> Con14)\n -> Con14\n\nnil14 : Con14\nnil14 = \\ con, nil14, snoc => nil14\n\nsnoc14 : Con14 -> Ty14 -> Con14\nsnoc14 = \\ g, a, con, nil14, snoc14 => snoc14 (g con nil14 snoc14) a\n\nVar14 : Con14 -> Ty14 -> Type\nVar14 = \\ g, a =>\n (Var14 : Con14 -> Ty14 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var14 (snoc14 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var14 g a -> Var14 (snoc14 g b) a)\n -> Var14 g a\n\nvz14 : {g : _}-> {a : _} -> Var14 (snoc14 g a) a\nvz14 = \\ var, vz14, vs => vz14 _ _\n\nvs14 : {g : _} -> {B : _} -> {a : _} -> Var14 g a -> Var14 (snoc14 g B) a\nvs14 = \\ x, var, vz14, vs14 => vs14 _ _ _ (x var vz14 vs14)\n\nTm14 : Con14 -> Ty14 -> Type\nTm14 = \\ g, a =>\n (Tm14 : Con14 -> Ty14 -> Type)\n -> (var : (g : _) -> (a : _) -> Var14 g a -> Tm14 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm14 (snoc14 g a) B -> Tm14 g (arr14 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm14 g (arr14 a B) -> Tm14 g a -> Tm14 g B)\n -> Tm14 g a\n\nvar14 : {g : _} -> {a : _} -> Var14 g a -> Tm14 g a\nvar14 = \\ x, tm, var14, lam, app => var14 _ _ x\n\nlam14 : {g : _} -> {a : _} -> {B : _} -> Tm14 (snoc14 g a) B -> Tm14 g (arr14 a B)\nlam14 = \\ t, tm, var14, lam14, app => lam14 _ _ _ (t tm var14 lam14 app)\n\napp14 : {g:_}->{a:_}->{B:_} -> Tm14 g (arr14 a B) -> Tm14 g a -> Tm14 g B\napp14 = \\ t, u, tm, var14, lam14, app14 => app14 _ _ _ (t tm var14 lam14 app14) (u tm var14 lam14 app14)\n\nv014 : {g:_}->{a:_} -> Tm14 (snoc14 g a) a\nv014 = var14 vz14\n\nv114 : {g:_}->{a:_}-> {B:_}-> Tm14 (snoc14 (snoc14 g a) B) a\nv114 = var14 (vs14 vz14)\n\nv214 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm14 (snoc14 (snoc14 (snoc14 g a) B) C) a\nv214 = var14 (vs14 (vs14 vz14))\n\nv314 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm14 (snoc14 (snoc14 (snoc14 (snoc14 g a) B) C) D) a\nv314 = var14 (vs14 (vs14 (vs14 vz14)))\n\nv414 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm14 (snoc14 (snoc14 (snoc14 (snoc14 (snoc14 g a) B) C) D) E) a\nv414 = var14 (vs14 (vs14 (vs14 (vs14 vz14))))\n\ntest14 : {g:_}-> {a:_} -> Tm14 g (arr14 (arr14 a a) (arr14 a a))\ntest14 = lam14 (lam14 (app14 v114 (app14 v114 (app14 v114 (app14 v114 (app14 v114 (app14 v114 v014)))))))\nTy15 : Type\nTy15 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty15 : Ty15\nempty15 = \\ _, empty, _ => empty\n\narr15 : Ty15 -> Ty15 -> Ty15\narr15 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon15 : Type\nCon15 = (Con15 : Type)\n ->(nil : Con15)\n ->(snoc : Con15 -> Ty15 -> Con15)\n -> Con15\n\nnil15 : Con15\nnil15 = \\ con, nil15, snoc => nil15\n\nsnoc15 : Con15 -> Ty15 -> Con15\nsnoc15 = \\ g, a, con, nil15, snoc15 => snoc15 (g con nil15 snoc15) a\n\nVar15 : Con15 -> Ty15 -> Type\nVar15 = \\ g, a =>\n (Var15 : Con15 -> Ty15 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var15 (snoc15 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var15 g a -> Var15 (snoc15 g b) a)\n -> Var15 g a\n\nvz15 : {g : _}-> {a : _} -> Var15 (snoc15 g a) a\nvz15 = \\ var, vz15, vs => vz15 _ _\n\nvs15 : {g : _} -> {B : _} -> {a : _} -> Var15 g a -> Var15 (snoc15 g B) a\nvs15 = \\ x, var, vz15, vs15 => vs15 _ _ _ (x var vz15 vs15)\n\nTm15 : Con15 -> Ty15 -> Type\nTm15 = \\ g, a =>\n (Tm15 : Con15 -> Ty15 -> Type)\n -> (var : (g : _) -> (a : _) -> Var15 g a -> Tm15 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm15 (snoc15 g a) B -> Tm15 g (arr15 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm15 g (arr15 a B) -> Tm15 g a -> Tm15 g B)\n -> Tm15 g a\n\nvar15 : {g : _} -> {a : _} -> Var15 g a -> Tm15 g a\nvar15 = \\ x, tm, var15, lam, app => var15 _ _ x\n\nlam15 : {g : _} -> {a : _} -> {B : _} -> Tm15 (snoc15 g a) B -> Tm15 g (arr15 a B)\nlam15 = \\ t, tm, var15, lam15, app => lam15 _ _ _ (t tm var15 lam15 app)\n\napp15 : {g:_}->{a:_}->{B:_} -> Tm15 g (arr15 a B) -> Tm15 g a -> Tm15 g B\napp15 = \\ t, u, tm, var15, lam15, app15 => app15 _ _ _ (t tm var15 lam15 app15) (u tm var15 lam15 app15)\n\nv015 : {g:_}->{a:_} -> Tm15 (snoc15 g a) a\nv015 = var15 vz15\n\nv115 : {g:_}->{a:_}-> {B:_}-> Tm15 (snoc15 (snoc15 g a) B) a\nv115 = var15 (vs15 vz15)\n\nv215 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm15 (snoc15 (snoc15 (snoc15 g a) B) C) a\nv215 = var15 (vs15 (vs15 vz15))\n\nv315 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm15 (snoc15 (snoc15 (snoc15 (snoc15 g a) B) C) D) a\nv315 = var15 (vs15 (vs15 (vs15 vz15)))\n\nv415 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm15 (snoc15 (snoc15 (snoc15 (snoc15 (snoc15 g a) B) C) D) E) a\nv415 = var15 (vs15 (vs15 (vs15 (vs15 vz15))))\n\ntest15 : {g:_}-> {a:_} -> Tm15 g (arr15 (arr15 a a) (arr15 a a))\ntest15 = lam15 (lam15 (app15 v115 (app15 v115 (app15 v115 (app15 v115 (app15 v115 (app15 v115 v015)))))))\nTy16 : Type\nTy16 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty16 : Ty16\nempty16 = \\ _, empty, _ => empty\n\narr16 : Ty16 -> Ty16 -> Ty16\narr16 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon16 : Type\nCon16 = (Con16 : Type)\n ->(nil : Con16)\n ->(snoc : Con16 -> Ty16 -> Con16)\n -> Con16\n\nnil16 : Con16\nnil16 = \\ con, nil16, snoc => nil16\n\nsnoc16 : Con16 -> Ty16 -> Con16\nsnoc16 = \\ g, a, con, nil16, snoc16 => snoc16 (g con nil16 snoc16) a\n\nVar16 : Con16 -> Ty16 -> Type\nVar16 = \\ g, a =>\n (Var16 : Con16 -> Ty16 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var16 (snoc16 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var16 g a -> Var16 (snoc16 g b) a)\n -> Var16 g a\n\nvz16 : {g : _}-> {a : _} -> Var16 (snoc16 g a) a\nvz16 = \\ var, vz16, vs => vz16 _ _\n\nvs16 : {g : _} -> {B : _} -> {a : _} -> Var16 g a -> Var16 (snoc16 g B) a\nvs16 = \\ x, var, vz16, vs16 => vs16 _ _ _ (x var vz16 vs16)\n\nTm16 : Con16 -> Ty16 -> Type\nTm16 = \\ g, a =>\n (Tm16 : Con16 -> Ty16 -> Type)\n -> (var : (g : _) -> (a : _) -> Var16 g a -> Tm16 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm16 (snoc16 g a) B -> Tm16 g (arr16 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm16 g (arr16 a B) -> Tm16 g a -> Tm16 g B)\n -> Tm16 g a\n\nvar16 : {g : _} -> {a : _} -> Var16 g a -> Tm16 g a\nvar16 = \\ x, tm, var16, lam, app => var16 _ _ x\n\nlam16 : {g : _} -> {a : _} -> {B : _} -> Tm16 (snoc16 g a) B -> Tm16 g (arr16 a B)\nlam16 = \\ t, tm, var16, lam16, app => lam16 _ _ _ (t tm var16 lam16 app)\n\napp16 : {g:_}->{a:_}->{B:_} -> Tm16 g (arr16 a B) -> Tm16 g a -> Tm16 g B\napp16 = \\ t, u, tm, var16, lam16, app16 => app16 _ _ _ (t tm var16 lam16 app16) (u tm var16 lam16 app16)\n\nv016 : {g:_}->{a:_} -> Tm16 (snoc16 g a) a\nv016 = var16 vz16\n\nv116 : {g:_}->{a:_}-> {B:_}-> Tm16 (snoc16 (snoc16 g a) B) a\nv116 = var16 (vs16 vz16)\n\nv216 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm16 (snoc16 (snoc16 (snoc16 g a) B) C) a\nv216 = var16 (vs16 (vs16 vz16))\n\nv316 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm16 (snoc16 (snoc16 (snoc16 (snoc16 g a) B) C) D) a\nv316 = var16 (vs16 (vs16 (vs16 vz16)))\n\nv416 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm16 (snoc16 (snoc16 (snoc16 (snoc16 (snoc16 g a) B) C) D) E) a\nv416 = var16 (vs16 (vs16 (vs16 (vs16 vz16))))\n\ntest16 : {g:_}-> {a:_} -> Tm16 g (arr16 (arr16 a a) (arr16 a a))\ntest16 = lam16 (lam16 (app16 v116 (app16 v116 (app16 v116 (app16 v116 (app16 v116 (app16 v116 v016)))))))\nTy17 : Type\nTy17 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty17 : Ty17\nempty17 = \\ _, empty, _ => empty\n\narr17 : Ty17 -> Ty17 -> Ty17\narr17 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon17 : Type\nCon17 = (Con17 : Type)\n ->(nil : Con17)\n ->(snoc : Con17 -> Ty17 -> Con17)\n -> Con17\n\nnil17 : Con17\nnil17 = \\ con, nil17, snoc => nil17\n\nsnoc17 : Con17 -> Ty17 -> Con17\nsnoc17 = \\ g, a, con, nil17, snoc17 => snoc17 (g con nil17 snoc17) a\n\nVar17 : Con17 -> Ty17 -> Type\nVar17 = \\ g, a =>\n (Var17 : Con17 -> Ty17 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var17 (snoc17 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var17 g a -> Var17 (snoc17 g b) a)\n -> Var17 g a\n\nvz17 : {g : _}-> {a : _} -> Var17 (snoc17 g a) a\nvz17 = \\ var, vz17, vs => vz17 _ _\n\nvs17 : {g : _} -> {B : _} -> {a : _} -> Var17 g a -> Var17 (snoc17 g B) a\nvs17 = \\ x, var, vz17, vs17 => vs17 _ _ _ (x var vz17 vs17)\n\nTm17 : Con17 -> Ty17 -> Type\nTm17 = \\ g, a =>\n (Tm17 : Con17 -> Ty17 -> Type)\n -> (var : (g : _) -> (a : _) -> Var17 g a -> Tm17 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm17 (snoc17 g a) B -> Tm17 g (arr17 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm17 g (arr17 a B) -> Tm17 g a -> Tm17 g B)\n -> Tm17 g a\n\nvar17 : {g : _} -> {a : _} -> Var17 g a -> Tm17 g a\nvar17 = \\ x, tm, var17, lam, app => var17 _ _ x\n\nlam17 : {g : _} -> {a : _} -> {B : _} -> Tm17 (snoc17 g a) B -> Tm17 g (arr17 a B)\nlam17 = \\ t, tm, var17, lam17, app => lam17 _ _ _ (t tm var17 lam17 app)\n\napp17 : {g:_}->{a:_}->{B:_} -> Tm17 g (arr17 a B) -> Tm17 g a -> Tm17 g B\napp17 = \\ t, u, tm, var17, lam17, app17 => app17 _ _ _ (t tm var17 lam17 app17) (u tm var17 lam17 app17)\n\nv017 : {g:_}->{a:_} -> Tm17 (snoc17 g a) a\nv017 = var17 vz17\n\nv117 : {g:_}->{a:_}-> {B:_}-> Tm17 (snoc17 (snoc17 g a) B) a\nv117 = var17 (vs17 vz17)\n\nv217 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm17 (snoc17 (snoc17 (snoc17 g a) B) C) a\nv217 = var17 (vs17 (vs17 vz17))\n\nv317 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm17 (snoc17 (snoc17 (snoc17 (snoc17 g a) B) C) D) a\nv317 = var17 (vs17 (vs17 (vs17 vz17)))\n\nv417 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm17 (snoc17 (snoc17 (snoc17 (snoc17 (snoc17 g a) B) C) D) E) a\nv417 = var17 (vs17 (vs17 (vs17 (vs17 vz17))))\n\ntest17 : {g:_}-> {a:_} -> Tm17 g (arr17 (arr17 a a) (arr17 a a))\ntest17 = lam17 (lam17 (app17 v117 (app17 v117 (app17 v117 (app17 v117 (app17 v117 (app17 v117 v017)))))))\nTy18 : Type\nTy18 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty18 : Ty18\nempty18 = \\ _, empty, _ => empty\n\narr18 : Ty18 -> Ty18 -> Ty18\narr18 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon18 : Type\nCon18 = (Con18 : Type)\n ->(nil : Con18)\n ->(snoc : Con18 -> Ty18 -> Con18)\n -> Con18\n\nnil18 : Con18\nnil18 = \\ con, nil18, snoc => nil18\n\nsnoc18 : Con18 -> Ty18 -> Con18\nsnoc18 = \\ g, a, con, nil18, snoc18 => snoc18 (g con nil18 snoc18) a\n\nVar18 : Con18 -> Ty18 -> Type\nVar18 = \\ g, a =>\n (Var18 : Con18 -> Ty18 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var18 (snoc18 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var18 g a -> Var18 (snoc18 g b) a)\n -> Var18 g a\n\nvz18 : {g : _}-> {a : _} -> Var18 (snoc18 g a) a\nvz18 = \\ var, vz18, vs => vz18 _ _\n\nvs18 : {g : _} -> {B : _} -> {a : _} -> Var18 g a -> Var18 (snoc18 g B) a\nvs18 = \\ x, var, vz18, vs18 => vs18 _ _ _ (x var vz18 vs18)\n\nTm18 : Con18 -> Ty18 -> Type\nTm18 = \\ g, a =>\n (Tm18 : Con18 -> Ty18 -> Type)\n -> (var : (g : _) -> (a : _) -> Var18 g a -> Tm18 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm18 (snoc18 g a) B -> Tm18 g (arr18 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm18 g (arr18 a B) -> Tm18 g a -> Tm18 g B)\n -> Tm18 g a\n\nvar18 : {g : _} -> {a : _} -> Var18 g a -> Tm18 g a\nvar18 = \\ x, tm, var18, lam, app => var18 _ _ x\n\nlam18 : {g : _} -> {a : _} -> {B : _} -> Tm18 (snoc18 g a) B -> Tm18 g (arr18 a B)\nlam18 = \\ t, tm, var18, lam18, app => lam18 _ _ _ (t tm var18 lam18 app)\n\napp18 : {g:_}->{a:_}->{B:_} -> Tm18 g (arr18 a B) -> Tm18 g a -> Tm18 g B\napp18 = \\ t, u, tm, var18, lam18, app18 => app18 _ _ _ (t tm var18 lam18 app18) (u tm var18 lam18 app18)\n\nv018 : {g:_}->{a:_} -> Tm18 (snoc18 g a) a\nv018 = var18 vz18\n\nv118 : {g:_}->{a:_}-> {B:_}-> Tm18 (snoc18 (snoc18 g a) B) a\nv118 = var18 (vs18 vz18)\n\nv218 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm18 (snoc18 (snoc18 (snoc18 g a) B) C) a\nv218 = var18 (vs18 (vs18 vz18))\n\nv318 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm18 (snoc18 (snoc18 (snoc18 (snoc18 g a) B) C) D) a\nv318 = var18 (vs18 (vs18 (vs18 vz18)))\n\nv418 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm18 (snoc18 (snoc18 (snoc18 (snoc18 (snoc18 g a) B) C) D) E) a\nv418 = var18 (vs18 (vs18 (vs18 (vs18 vz18))))\n\ntest18 : {g:_}-> {a:_} -> Tm18 g (arr18 (arr18 a a) (arr18 a a))\ntest18 = lam18 (lam18 (app18 v118 (app18 v118 (app18 v118 (app18 v118 (app18 v118 (app18 v118 v018)))))))\nTy19 : Type\nTy19 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty19 : Ty19\nempty19 = \\ _, empty, _ => empty\n\narr19 : Ty19 -> Ty19 -> Ty19\narr19 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon19 : Type\nCon19 = (Con19 : Type)\n ->(nil : Con19)\n ->(snoc : Con19 -> Ty19 -> Con19)\n -> Con19\n\nnil19 : Con19\nnil19 = \\ con, nil19, snoc => nil19\n\nsnoc19 : Con19 -> Ty19 -> Con19\nsnoc19 = \\ g, a, con, nil19, snoc19 => snoc19 (g con nil19 snoc19) a\n\nVar19 : Con19 -> Ty19 -> Type\nVar19 = \\ g, a =>\n (Var19 : Con19 -> Ty19 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var19 (snoc19 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var19 g a -> Var19 (snoc19 g b) a)\n -> Var19 g a\n\nvz19 : {g : _}-> {a : _} -> Var19 (snoc19 g a) a\nvz19 = \\ var, vz19, vs => vz19 _ _\n\nvs19 : {g : _} -> {B : _} -> {a : _} -> Var19 g a -> Var19 (snoc19 g B) a\nvs19 = \\ x, var, vz19, vs19 => vs19 _ _ _ (x var vz19 vs19)\n\nTm19 : Con19 -> Ty19 -> Type\nTm19 = \\ g, a =>\n (Tm19 : Con19 -> Ty19 -> Type)\n -> (var : (g : _) -> (a : _) -> Var19 g a -> Tm19 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm19 (snoc19 g a) B -> Tm19 g (arr19 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm19 g (arr19 a B) -> Tm19 g a -> Tm19 g B)\n -> Tm19 g a\n\nvar19 : {g : _} -> {a : _} -> Var19 g a -> Tm19 g a\nvar19 = \\ x, tm, var19, lam, app => var19 _ _ x\n\nlam19 : {g : _} -> {a : _} -> {B : _} -> Tm19 (snoc19 g a) B -> Tm19 g (arr19 a B)\nlam19 = \\ t, tm, var19, lam19, app => lam19 _ _ _ (t tm var19 lam19 app)\n\napp19 : {g:_}->{a:_}->{B:_} -> Tm19 g (arr19 a B) -> Tm19 g a -> Tm19 g B\napp19 = \\ t, u, tm, var19, lam19, app19 => app19 _ _ _ (t tm var19 lam19 app19) (u tm var19 lam19 app19)\n\nv019 : {g:_}->{a:_} -> Tm19 (snoc19 g a) a\nv019 = var19 vz19\n\nv119 : {g:_}->{a:_}-> {B:_}-> Tm19 (snoc19 (snoc19 g a) B) a\nv119 = var19 (vs19 vz19)\n\nv219 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm19 (snoc19 (snoc19 (snoc19 g a) B) C) a\nv219 = var19 (vs19 (vs19 vz19))\n\nv319 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm19 (snoc19 (snoc19 (snoc19 (snoc19 g a) B) C) D) a\nv319 = var19 (vs19 (vs19 (vs19 vz19)))\n\nv419 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm19 (snoc19 (snoc19 (snoc19 (snoc19 (snoc19 g a) B) C) D) E) a\nv419 = var19 (vs19 (vs19 (vs19 (vs19 vz19))))\n\ntest19 : {g:_}-> {a:_} -> Tm19 g (arr19 (arr19 a a) (arr19 a a))\ntest19 = lam19 (lam19 (app19 v119 (app19 v119 (app19 v119 (app19 v119 (app19 v119 (app19 v119 v019)))))))\nTy20 : Type\nTy20 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty20 : Ty20\nempty20 = \\ _, empty, _ => empty\n\narr20 : Ty20 -> Ty20 -> Ty20\narr20 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon20 : Type\nCon20 = (Con20 : Type)\n ->(nil : Con20)\n ->(snoc : Con20 -> Ty20 -> Con20)\n -> Con20\n\nnil20 : Con20\nnil20 = \\ con, nil20, snoc => nil20\n\nsnoc20 : Con20 -> Ty20 -> Con20\nsnoc20 = \\ g, a, con, nil20, snoc20 => snoc20 (g con nil20 snoc20) a\n\nVar20 : Con20 -> Ty20 -> Type\nVar20 = \\ g, a =>\n (Var20 : Con20 -> Ty20 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var20 (snoc20 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var20 g a -> Var20 (snoc20 g b) a)\n -> Var20 g a\n\nvz20 : {g : _}-> {a : _} -> Var20 (snoc20 g a) a\nvz20 = \\ var, vz20, vs => vz20 _ _\n\nvs20 : {g : _} -> {B : _} -> {a : _} -> Var20 g a -> Var20 (snoc20 g B) a\nvs20 = \\ x, var, vz20, vs20 => vs20 _ _ _ (x var vz20 vs20)\n\nTm20 : Con20 -> Ty20 -> Type\nTm20 = \\ g, a =>\n (Tm20 : Con20 -> Ty20 -> Type)\n -> (var : (g : _) -> (a : _) -> Var20 g a -> Tm20 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm20 (snoc20 g a) B -> Tm20 g (arr20 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm20 g (arr20 a B) -> Tm20 g a -> Tm20 g B)\n -> Tm20 g a\n\nvar20 : {g : _} -> {a : _} -> Var20 g a -> Tm20 g a\nvar20 = \\ x, tm, var20, lam, app => var20 _ _ x\n\nlam20 : {g : _} -> {a : _} -> {B : _} -> Tm20 (snoc20 g a) B -> Tm20 g (arr20 a B)\nlam20 = \\ t, tm, var20, lam20, app => lam20 _ _ _ (t tm var20 lam20 app)\n\napp20 : {g:_}->{a:_}->{B:_} -> Tm20 g (arr20 a B) -> Tm20 g a -> Tm20 g B\napp20 = \\ t, u, tm, var20, lam20, app20 => app20 _ _ _ (t tm var20 lam20 app20) (u tm var20 lam20 app20)\n\nv020 : {g:_}->{a:_} -> Tm20 (snoc20 g a) a\nv020 = var20 vz20\n\nv120 : {g:_}->{a:_}-> {B:_}-> Tm20 (snoc20 (snoc20 g a) B) a\nv120 = var20 (vs20 vz20)\n\nv220 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm20 (snoc20 (snoc20 (snoc20 g a) B) C) a\nv220 = var20 (vs20 (vs20 vz20))\n\nv320 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm20 (snoc20 (snoc20 (snoc20 (snoc20 g a) B) C) D) a\nv320 = var20 (vs20 (vs20 (vs20 vz20)))\n\nv420 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm20 (snoc20 (snoc20 (snoc20 (snoc20 (snoc20 g a) B) C) D) E) a\nv420 = var20 (vs20 (vs20 (vs20 (vs20 vz20))))\n\ntest20 : {g:_}-> {a:_} -> Tm20 g (arr20 (arr20 a a) (arr20 a a))\ntest20 = lam20 (lam20 (app20 v120 (app20 v120 (app20 v120 (app20 v120 (app20 v120 (app20 v120 v020)))))))\nTy21 : Type\nTy21 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty21 : Ty21\nempty21 = \\ _, empty, _ => empty\n\narr21 : Ty21 -> Ty21 -> Ty21\narr21 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon21 : Type\nCon21 = (Con21 : Type)\n ->(nil : Con21)\n ->(snoc : Con21 -> Ty21 -> Con21)\n -> Con21\n\nnil21 : Con21\nnil21 = \\ con, nil21, snoc => nil21\n\nsnoc21 : Con21 -> Ty21 -> Con21\nsnoc21 = \\ g, a, con, nil21, snoc21 => snoc21 (g con nil21 snoc21) a\n\nVar21 : Con21 -> Ty21 -> Type\nVar21 = \\ g, a =>\n (Var21 : Con21 -> Ty21 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var21 (snoc21 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var21 g a -> Var21 (snoc21 g b) a)\n -> Var21 g a\n\nvz21 : {g : _}-> {a : _} -> Var21 (snoc21 g a) a\nvz21 = \\ var, vz21, vs => vz21 _ _\n\nvs21 : {g : _} -> {B : _} -> {a : _} -> Var21 g a -> Var21 (snoc21 g B) a\nvs21 = \\ x, var, vz21, vs21 => vs21 _ _ _ (x var vz21 vs21)\n\nTm21 : Con21 -> Ty21 -> Type\nTm21 = \\ g, a =>\n (Tm21 : Con21 -> Ty21 -> Type)\n -> (var : (g : _) -> (a : _) -> Var21 g a -> Tm21 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm21 (snoc21 g a) B -> Tm21 g (arr21 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm21 g (arr21 a B) -> Tm21 g a -> Tm21 g B)\n -> Tm21 g a\n\nvar21 : {g : _} -> {a : _} -> Var21 g a -> Tm21 g a\nvar21 = \\ x, tm, var21, lam, app => var21 _ _ x\n\nlam21 : {g : _} -> {a : _} -> {B : _} -> Tm21 (snoc21 g a) B -> Tm21 g (arr21 a B)\nlam21 = \\ t, tm, var21, lam21, app => lam21 _ _ _ (t tm var21 lam21 app)\n\napp21 : {g:_}->{a:_}->{B:_} -> Tm21 g (arr21 a B) -> Tm21 g a -> Tm21 g B\napp21 = \\ t, u, tm, var21, lam21, app21 => app21 _ _ _ (t tm var21 lam21 app21) (u tm var21 lam21 app21)\n\nv021 : {g:_}->{a:_} -> Tm21 (snoc21 g a) a\nv021 = var21 vz21\n\nv121 : {g:_}->{a:_}-> {B:_}-> Tm21 (snoc21 (snoc21 g a) B) a\nv121 = var21 (vs21 vz21)\n\nv221 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm21 (snoc21 (snoc21 (snoc21 g a) B) C) a\nv221 = var21 (vs21 (vs21 vz21))\n\nv321 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm21 (snoc21 (snoc21 (snoc21 (snoc21 g a) B) C) D) a\nv321 = var21 (vs21 (vs21 (vs21 vz21)))\n\nv421 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm21 (snoc21 (snoc21 (snoc21 (snoc21 (snoc21 g a) B) C) D) E) a\nv421 = var21 (vs21 (vs21 (vs21 (vs21 vz21))))\n\ntest21 : {g:_}-> {a:_} -> Tm21 g (arr21 (arr21 a a) (arr21 a a))\ntest21 = lam21 (lam21 (app21 v121 (app21 v121 (app21 v121 (app21 v121 (app21 v121 (app21 v121 v021)))))))\nTy22 : Type\nTy22 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty22 : Ty22\nempty22 = \\ _, empty, _ => empty\n\narr22 : Ty22 -> Ty22 -> Ty22\narr22 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon22 : Type\nCon22 = (Con22 : Type)\n ->(nil : Con22)\n ->(snoc : Con22 -> Ty22 -> Con22)\n -> Con22\n\nnil22 : Con22\nnil22 = \\ con, nil22, snoc => nil22\n\nsnoc22 : Con22 -> Ty22 -> Con22\nsnoc22 = \\ g, a, con, nil22, snoc22 => snoc22 (g con nil22 snoc22) a\n\nVar22 : Con22 -> Ty22 -> Type\nVar22 = \\ g, a =>\n (Var22 : Con22 -> Ty22 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var22 (snoc22 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var22 g a -> Var22 (snoc22 g b) a)\n -> Var22 g a\n\nvz22 : {g : _}-> {a : _} -> Var22 (snoc22 g a) a\nvz22 = \\ var, vz22, vs => vz22 _ _\n\nvs22 : {g : _} -> {B : _} -> {a : _} -> Var22 g a -> Var22 (snoc22 g B) a\nvs22 = \\ x, var, vz22, vs22 => vs22 _ _ _ (x var vz22 vs22)\n\nTm22 : Con22 -> Ty22 -> Type\nTm22 = \\ g, a =>\n (Tm22 : Con22 -> Ty22 -> Type)\n -> (var : (g : _) -> (a : _) -> Var22 g a -> Tm22 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm22 (snoc22 g a) B -> Tm22 g (arr22 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm22 g (arr22 a B) -> Tm22 g a -> Tm22 g B)\n -> Tm22 g a\n\nvar22 : {g : _} -> {a : _} -> Var22 g a -> Tm22 g a\nvar22 = \\ x, tm, var22, lam, app => var22 _ _ x\n\nlam22 : {g : _} -> {a : _} -> {B : _} -> Tm22 (snoc22 g a) B -> Tm22 g (arr22 a B)\nlam22 = \\ t, tm, var22, lam22, app => lam22 _ _ _ (t tm var22 lam22 app)\n\napp22 : {g:_}->{a:_}->{B:_} -> Tm22 g (arr22 a B) -> Tm22 g a -> Tm22 g B\napp22 = \\ t, u, tm, var22, lam22, app22 => app22 _ _ _ (t tm var22 lam22 app22) (u tm var22 lam22 app22)\n\nv022 : {g:_}->{a:_} -> Tm22 (snoc22 g a) a\nv022 = var22 vz22\n\nv122 : {g:_}->{a:_}-> {B:_}-> Tm22 (snoc22 (snoc22 g a) B) a\nv122 = var22 (vs22 vz22)\n\nv222 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm22 (snoc22 (snoc22 (snoc22 g a) B) C) a\nv222 = var22 (vs22 (vs22 vz22))\n\nv322 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm22 (snoc22 (snoc22 (snoc22 (snoc22 g a) B) C) D) a\nv322 = var22 (vs22 (vs22 (vs22 vz22)))\n\nv422 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm22 (snoc22 (snoc22 (snoc22 (snoc22 (snoc22 g a) B) C) D) E) a\nv422 = var22 (vs22 (vs22 (vs22 (vs22 vz22))))\n\ntest22 : {g:_}-> {a:_} -> Tm22 g (arr22 (arr22 a a) (arr22 a a))\ntest22 = lam22 (lam22 (app22 v122 (app22 v122 (app22 v122 (app22 v122 (app22 v122 (app22 v122 v022)))))))\nTy23 : Type\nTy23 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty23 : Ty23\nempty23 = \\ _, empty, _ => empty\n\narr23 : Ty23 -> Ty23 -> Ty23\narr23 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon23 : Type\nCon23 = (Con23 : Type)\n ->(nil : Con23)\n ->(snoc : Con23 -> Ty23 -> Con23)\n -> Con23\n\nnil23 : Con23\nnil23 = \\ con, nil23, snoc => nil23\n\nsnoc23 : Con23 -> Ty23 -> Con23\nsnoc23 = \\ g, a, con, nil23, snoc23 => snoc23 (g con nil23 snoc23) a\n\nVar23 : Con23 -> Ty23 -> Type\nVar23 = \\ g, a =>\n (Var23 : Con23 -> Ty23 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var23 (snoc23 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var23 g a -> Var23 (snoc23 g b) a)\n -> Var23 g a\n\nvz23 : {g : _}-> {a : _} -> Var23 (snoc23 g a) a\nvz23 = \\ var, vz23, vs => vz23 _ _\n\nvs23 : {g : _} -> {B : _} -> {a : _} -> Var23 g a -> Var23 (snoc23 g B) a\nvs23 = \\ x, var, vz23, vs23 => vs23 _ _ _ (x var vz23 vs23)\n\nTm23 : Con23 -> Ty23 -> Type\nTm23 = \\ g, a =>\n (Tm23 : Con23 -> Ty23 -> Type)\n -> (var : (g : _) -> (a : _) -> Var23 g a -> Tm23 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm23 (snoc23 g a) B -> Tm23 g (arr23 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm23 g (arr23 a B) -> Tm23 g a -> Tm23 g B)\n -> Tm23 g a\n\nvar23 : {g : _} -> {a : _} -> Var23 g a -> Tm23 g a\nvar23 = \\ x, tm, var23, lam, app => var23 _ _ x\n\nlam23 : {g : _} -> {a : _} -> {B : _} -> Tm23 (snoc23 g a) B -> Tm23 g (arr23 a B)\nlam23 = \\ t, tm, var23, lam23, app => lam23 _ _ _ (t tm var23 lam23 app)\n\napp23 : {g:_}->{a:_}->{B:_} -> Tm23 g (arr23 a B) -> Tm23 g a -> Tm23 g B\napp23 = \\ t, u, tm, var23, lam23, app23 => app23 _ _ _ (t tm var23 lam23 app23) (u tm var23 lam23 app23)\n\nv023 : {g:_}->{a:_} -> Tm23 (snoc23 g a) a\nv023 = var23 vz23\n\nv123 : {g:_}->{a:_}-> {B:_}-> Tm23 (snoc23 (snoc23 g a) B) a\nv123 = var23 (vs23 vz23)\n\nv223 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm23 (snoc23 (snoc23 (snoc23 g a) B) C) a\nv223 = var23 (vs23 (vs23 vz23))\n\nv323 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm23 (snoc23 (snoc23 (snoc23 (snoc23 g a) B) C) D) a\nv323 = var23 (vs23 (vs23 (vs23 vz23)))\n\nv423 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm23 (snoc23 (snoc23 (snoc23 (snoc23 (snoc23 g a) B) C) D) E) a\nv423 = var23 (vs23 (vs23 (vs23 (vs23 vz23))))\n\ntest23 : {g:_}-> {a:_} -> Tm23 g (arr23 (arr23 a a) (arr23 a a))\ntest23 = lam23 (lam23 (app23 v123 (app23 v123 (app23 v123 (app23 v123 (app23 v123 (app23 v123 v023)))))))\nTy24 : Type\nTy24 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty24 : Ty24\nempty24 = \\ _, empty, _ => empty\n\narr24 : Ty24 -> Ty24 -> Ty24\narr24 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon24 : Type\nCon24 = (Con24 : Type)\n ->(nil : Con24)\n ->(snoc : Con24 -> Ty24 -> Con24)\n -> Con24\n\nnil24 : Con24\nnil24 = \\ con, nil24, snoc => nil24\n\nsnoc24 : Con24 -> Ty24 -> Con24\nsnoc24 = \\ g, a, con, nil24, snoc24 => snoc24 (g con nil24 snoc24) a\n\nVar24 : Con24 -> Ty24 -> Type\nVar24 = \\ g, a =>\n (Var24 : Con24 -> Ty24 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var24 (snoc24 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var24 g a -> Var24 (snoc24 g b) a)\n -> Var24 g a\n\nvz24 : {g : _}-> {a : _} -> Var24 (snoc24 g a) a\nvz24 = \\ var, vz24, vs => vz24 _ _\n\nvs24 : {g : _} -> {B : _} -> {a : _} -> Var24 g a -> Var24 (snoc24 g B) a\nvs24 = \\ x, var, vz24, vs24 => vs24 _ _ _ (x var vz24 vs24)\n\nTm24 : Con24 -> Ty24 -> Type\nTm24 = \\ g, a =>\n (Tm24 : Con24 -> Ty24 -> Type)\n -> (var : (g : _) -> (a : _) -> Var24 g a -> Tm24 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm24 (snoc24 g a) B -> Tm24 g (arr24 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm24 g (arr24 a B) -> Tm24 g a -> Tm24 g B)\n -> Tm24 g a\n\nvar24 : {g : _} -> {a : _} -> Var24 g a -> Tm24 g a\nvar24 = \\ x, tm, var24, lam, app => var24 _ _ x\n\nlam24 : {g : _} -> {a : _} -> {B : _} -> Tm24 (snoc24 g a) B -> Tm24 g (arr24 a B)\nlam24 = \\ t, tm, var24, lam24, app => lam24 _ _ _ (t tm var24 lam24 app)\n\napp24 : {g:_}->{a:_}->{B:_} -> Tm24 g (arr24 a B) -> Tm24 g a -> Tm24 g B\napp24 = \\ t, u, tm, var24, lam24, app24 => app24 _ _ _ (t tm var24 lam24 app24) (u tm var24 lam24 app24)\n\nv024 : {g:_}->{a:_} -> Tm24 (snoc24 g a) a\nv024 = var24 vz24\n\nv124 : {g:_}->{a:_}-> {B:_}-> Tm24 (snoc24 (snoc24 g a) B) a\nv124 = var24 (vs24 vz24)\n\nv224 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm24 (snoc24 (snoc24 (snoc24 g a) B) C) a\nv224 = var24 (vs24 (vs24 vz24))\n\nv324 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm24 (snoc24 (snoc24 (snoc24 (snoc24 g a) B) C) D) a\nv324 = var24 (vs24 (vs24 (vs24 vz24)))\n\nv424 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm24 (snoc24 (snoc24 (snoc24 (snoc24 (snoc24 g a) B) C) D) E) a\nv424 = var24 (vs24 (vs24 (vs24 (vs24 vz24))))\n\ntest24 : {g:_}-> {a:_} -> Tm24 g (arr24 (arr24 a a) (arr24 a a))\ntest24 = lam24 (lam24 (app24 v124 (app24 v124 (app24 v124 (app24 v124 (app24 v124 (app24 v124 v024)))))))\nTy25 : Type\nTy25 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty25 : Ty25\nempty25 = \\ _, empty, _ => empty\n\narr25 : Ty25 -> Ty25 -> Ty25\narr25 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon25 : Type\nCon25 = (Con25 : Type)\n ->(nil : Con25)\n ->(snoc : Con25 -> Ty25 -> Con25)\n -> Con25\n\nnil25 : Con25\nnil25 = \\ con, nil25, snoc => nil25\n\nsnoc25 : Con25 -> Ty25 -> Con25\nsnoc25 = \\ g, a, con, nil25, snoc25 => snoc25 (g con nil25 snoc25) a\n\nVar25 : Con25 -> Ty25 -> Type\nVar25 = \\ g, a =>\n (Var25 : Con25 -> Ty25 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var25 (snoc25 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var25 g a -> Var25 (snoc25 g b) a)\n -> Var25 g a\n\nvz25 : {g : _}-> {a : _} -> Var25 (snoc25 g a) a\nvz25 = \\ var, vz25, vs => vz25 _ _\n\nvs25 : {g : _} -> {B : _} -> {a : _} -> Var25 g a -> Var25 (snoc25 g B) a\nvs25 = \\ x, var, vz25, vs25 => vs25 _ _ _ (x var vz25 vs25)\n\nTm25 : Con25 -> Ty25 -> Type\nTm25 = \\ g, a =>\n (Tm25 : Con25 -> Ty25 -> Type)\n -> (var : (g : _) -> (a : _) -> Var25 g a -> Tm25 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm25 (snoc25 g a) B -> Tm25 g (arr25 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm25 g (arr25 a B) -> Tm25 g a -> Tm25 g B)\n -> Tm25 g a\n\nvar25 : {g : _} -> {a : _} -> Var25 g a -> Tm25 g a\nvar25 = \\ x, tm, var25, lam, app => var25 _ _ x\n\nlam25 : {g : _} -> {a : _} -> {B : _} -> Tm25 (snoc25 g a) B -> Tm25 g (arr25 a B)\nlam25 = \\ t, tm, var25, lam25, app => lam25 _ _ _ (t tm var25 lam25 app)\n\napp25 : {g:_}->{a:_}->{B:_} -> Tm25 g (arr25 a B) -> Tm25 g a -> Tm25 g B\napp25 = \\ t, u, tm, var25, lam25, app25 => app25 _ _ _ (t tm var25 lam25 app25) (u tm var25 lam25 app25)\n\nv025 : {g:_}->{a:_} -> Tm25 (snoc25 g a) a\nv025 = var25 vz25\n\nv125 : {g:_}->{a:_}-> {B:_}-> Tm25 (snoc25 (snoc25 g a) B) a\nv125 = var25 (vs25 vz25)\n\nv225 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm25 (snoc25 (snoc25 (snoc25 g a) B) C) a\nv225 = var25 (vs25 (vs25 vz25))\n\nv325 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm25 (snoc25 (snoc25 (snoc25 (snoc25 g a) B) C) D) a\nv325 = var25 (vs25 (vs25 (vs25 vz25)))\n\nv425 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm25 (snoc25 (snoc25 (snoc25 (snoc25 (snoc25 g a) B) C) D) E) a\nv425 = var25 (vs25 (vs25 (vs25 (vs25 vz25))))\n\ntest25 : {g:_}-> {a:_} -> Tm25 g (arr25 (arr25 a a) (arr25 a a))\ntest25 = lam25 (lam25 (app25 v125 (app25 v125 (app25 v125 (app25 v125 (app25 v125 (app25 v125 v025)))))))\nTy26 : Type\nTy26 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty26 : Ty26\nempty26 = \\ _, empty, _ => empty\n\narr26 : Ty26 -> Ty26 -> Ty26\narr26 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon26 : Type\nCon26 = (Con26 : Type)\n ->(nil : Con26)\n ->(snoc : Con26 -> Ty26 -> Con26)\n -> Con26\n\nnil26 : Con26\nnil26 = \\ con, nil26, snoc => nil26\n\nsnoc26 : Con26 -> Ty26 -> Con26\nsnoc26 = \\ g, a, con, nil26, snoc26 => snoc26 (g con nil26 snoc26) a\n\nVar26 : Con26 -> Ty26 -> Type\nVar26 = \\ g, a =>\n (Var26 : Con26 -> Ty26 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var26 (snoc26 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var26 g a -> Var26 (snoc26 g b) a)\n -> Var26 g a\n\nvz26 : {g : _}-> {a : _} -> Var26 (snoc26 g a) a\nvz26 = \\ var, vz26, vs => vz26 _ _\n\nvs26 : {g : _} -> {B : _} -> {a : _} -> Var26 g a -> Var26 (snoc26 g B) a\nvs26 = \\ x, var, vz26, vs26 => vs26 _ _ _ (x var vz26 vs26)\n\nTm26 : Con26 -> Ty26 -> Type\nTm26 = \\ g, a =>\n (Tm26 : Con26 -> Ty26 -> Type)\n -> (var : (g : _) -> (a : _) -> Var26 g a -> Tm26 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm26 (snoc26 g a) B -> Tm26 g (arr26 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm26 g (arr26 a B) -> Tm26 g a -> Tm26 g B)\n -> Tm26 g a\n\nvar26 : {g : _} -> {a : _} -> Var26 g a -> Tm26 g a\nvar26 = \\ x, tm, var26, lam, app => var26 _ _ x\n\nlam26 : {g : _} -> {a : _} -> {B : _} -> Tm26 (snoc26 g a) B -> Tm26 g (arr26 a B)\nlam26 = \\ t, tm, var26, lam26, app => lam26 _ _ _ (t tm var26 lam26 app)\n\napp26 : {g:_}->{a:_}->{B:_} -> Tm26 g (arr26 a B) -> Tm26 g a -> Tm26 g B\napp26 = \\ t, u, tm, var26, lam26, app26 => app26 _ _ _ (t tm var26 lam26 app26) (u tm var26 lam26 app26)\n\nv026 : {g:_}->{a:_} -> Tm26 (snoc26 g a) a\nv026 = var26 vz26\n\nv126 : {g:_}->{a:_}-> {B:_}-> Tm26 (snoc26 (snoc26 g a) B) a\nv126 = var26 (vs26 vz26)\n\nv226 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm26 (snoc26 (snoc26 (snoc26 g a) B) C) a\nv226 = var26 (vs26 (vs26 vz26))\n\nv326 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm26 (snoc26 (snoc26 (snoc26 (snoc26 g a) B) C) D) a\nv326 = var26 (vs26 (vs26 (vs26 vz26)))\n\nv426 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm26 (snoc26 (snoc26 (snoc26 (snoc26 (snoc26 g a) B) C) D) E) a\nv426 = var26 (vs26 (vs26 (vs26 (vs26 vz26))))\n\ntest26 : {g:_}-> {a:_} -> Tm26 g (arr26 (arr26 a a) (arr26 a a))\ntest26 = lam26 (lam26 (app26 v126 (app26 v126 (app26 v126 (app26 v126 (app26 v126 (app26 v126 v026)))))))\nTy27 : Type\nTy27 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty27 : Ty27\nempty27 = \\ _, empty, _ => empty\n\narr27 : Ty27 -> Ty27 -> Ty27\narr27 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon27 : Type\nCon27 = (Con27 : Type)\n ->(nil : Con27)\n ->(snoc : Con27 -> Ty27 -> Con27)\n -> Con27\n\nnil27 : Con27\nnil27 = \\ con, nil27, snoc => nil27\n\nsnoc27 : Con27 -> Ty27 -> Con27\nsnoc27 = \\ g, a, con, nil27, snoc27 => snoc27 (g con nil27 snoc27) a\n\nVar27 : Con27 -> Ty27 -> Type\nVar27 = \\ g, a =>\n (Var27 : Con27 -> Ty27 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var27 (snoc27 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var27 g a -> Var27 (snoc27 g b) a)\n -> Var27 g a\n\nvz27 : {g : _}-> {a : _} -> Var27 (snoc27 g a) a\nvz27 = \\ var, vz27, vs => vz27 _ _\n\nvs27 : {g : _} -> {B : _} -> {a : _} -> Var27 g a -> Var27 (snoc27 g B) a\nvs27 = \\ x, var, vz27, vs27 => vs27 _ _ _ (x var vz27 vs27)\n\nTm27 : Con27 -> Ty27 -> Type\nTm27 = \\ g, a =>\n (Tm27 : Con27 -> Ty27 -> Type)\n -> (var : (g : _) -> (a : _) -> Var27 g a -> Tm27 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm27 (snoc27 g a) B -> Tm27 g (arr27 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm27 g (arr27 a B) -> Tm27 g a -> Tm27 g B)\n -> Tm27 g a\n\nvar27 : {g : _} -> {a : _} -> Var27 g a -> Tm27 g a\nvar27 = \\ x, tm, var27, lam, app => var27 _ _ x\n\nlam27 : {g : _} -> {a : _} -> {B : _} -> Tm27 (snoc27 g a) B -> Tm27 g (arr27 a B)\nlam27 = \\ t, tm, var27, lam27, app => lam27 _ _ _ (t tm var27 lam27 app)\n\napp27 : {g:_}->{a:_}->{B:_} -> Tm27 g (arr27 a B) -> Tm27 g a -> Tm27 g B\napp27 = \\ t, u, tm, var27, lam27, app27 => app27 _ _ _ (t tm var27 lam27 app27) (u tm var27 lam27 app27)\n\nv027 : {g:_}->{a:_} -> Tm27 (snoc27 g a) a\nv027 = var27 vz27\n\nv127 : {g:_}->{a:_}-> {B:_}-> Tm27 (snoc27 (snoc27 g a) B) a\nv127 = var27 (vs27 vz27)\n\nv227 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm27 (snoc27 (snoc27 (snoc27 g a) B) C) a\nv227 = var27 (vs27 (vs27 vz27))\n\nv327 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm27 (snoc27 (snoc27 (snoc27 (snoc27 g a) B) C) D) a\nv327 = var27 (vs27 (vs27 (vs27 vz27)))\n\nv427 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm27 (snoc27 (snoc27 (snoc27 (snoc27 (snoc27 g a) B) C) D) E) a\nv427 = var27 (vs27 (vs27 (vs27 (vs27 vz27))))\n\ntest27 : {g:_}-> {a:_} -> Tm27 g (arr27 (arr27 a a) (arr27 a a))\ntest27 = lam27 (lam27 (app27 v127 (app27 v127 (app27 v127 (app27 v127 (app27 v127 (app27 v127 v027)))))))\nTy28 : Type\nTy28 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty28 : Ty28\nempty28 = \\ _, empty, _ => empty\n\narr28 : Ty28 -> Ty28 -> Ty28\narr28 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon28 : Type\nCon28 = (Con28 : Type)\n ->(nil : Con28)\n ->(snoc : Con28 -> Ty28 -> Con28)\n -> Con28\n\nnil28 : Con28\nnil28 = \\ con, nil28, snoc => nil28\n\nsnoc28 : Con28 -> Ty28 -> Con28\nsnoc28 = \\ g, a, con, nil28, snoc28 => snoc28 (g con nil28 snoc28) a\n\nVar28 : Con28 -> Ty28 -> Type\nVar28 = \\ g, a =>\n (Var28 : Con28 -> Ty28 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var28 (snoc28 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var28 g a -> Var28 (snoc28 g b) a)\n -> Var28 g a\n\nvz28 : {g : _}-> {a : _} -> Var28 (snoc28 g a) a\nvz28 = \\ var, vz28, vs => vz28 _ _\n\nvs28 : {g : _} -> {B : _} -> {a : _} -> Var28 g a -> Var28 (snoc28 g B) a\nvs28 = \\ x, var, vz28, vs28 => vs28 _ _ _ (x var vz28 vs28)\n\nTm28 : Con28 -> Ty28 -> Type\nTm28 = \\ g, a =>\n (Tm28 : Con28 -> Ty28 -> Type)\n -> (var : (g : _) -> (a : _) -> Var28 g a -> Tm28 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm28 (snoc28 g a) B -> Tm28 g (arr28 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm28 g (arr28 a B) -> Tm28 g a -> Tm28 g B)\n -> Tm28 g a\n\nvar28 : {g : _} -> {a : _} -> Var28 g a -> Tm28 g a\nvar28 = \\ x, tm, var28, lam, app => var28 _ _ x\n\nlam28 : {g : _} -> {a : _} -> {B : _} -> Tm28 (snoc28 g a) B -> Tm28 g (arr28 a B)\nlam28 = \\ t, tm, var28, lam28, app => lam28 _ _ _ (t tm var28 lam28 app)\n\napp28 : {g:_}->{a:_}->{B:_} -> Tm28 g (arr28 a B) -> Tm28 g a -> Tm28 g B\napp28 = \\ t, u, tm, var28, lam28, app28 => app28 _ _ _ (t tm var28 lam28 app28) (u tm var28 lam28 app28)\n\nv028 : {g:_}->{a:_} -> Tm28 (snoc28 g a) a\nv028 = var28 vz28\n\nv128 : {g:_}->{a:_}-> {B:_}-> Tm28 (snoc28 (snoc28 g a) B) a\nv128 = var28 (vs28 vz28)\n\nv228 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm28 (snoc28 (snoc28 (snoc28 g a) B) C) a\nv228 = var28 (vs28 (vs28 vz28))\n\nv328 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm28 (snoc28 (snoc28 (snoc28 (snoc28 g a) B) C) D) a\nv328 = var28 (vs28 (vs28 (vs28 vz28)))\n\nv428 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm28 (snoc28 (snoc28 (snoc28 (snoc28 (snoc28 g a) B) C) D) E) a\nv428 = var28 (vs28 (vs28 (vs28 (vs28 vz28))))\n\ntest28 : {g:_}-> {a:_} -> Tm28 g (arr28 (arr28 a a) (arr28 a a))\ntest28 = lam28 (lam28 (app28 v128 (app28 v128 (app28 v128 (app28 v128 (app28 v128 (app28 v128 v028)))))))\nTy29 : Type\nTy29 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty29 : Ty29\nempty29 = \\ _, empty, _ => empty\n\narr29 : Ty29 -> Ty29 -> Ty29\narr29 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon29 : Type\nCon29 = (Con29 : Type)\n ->(nil : Con29)\n ->(snoc : Con29 -> Ty29 -> Con29)\n -> Con29\n\nnil29 : Con29\nnil29 = \\ con, nil29, snoc => nil29\n\nsnoc29 : Con29 -> Ty29 -> Con29\nsnoc29 = \\ g, a, con, nil29, snoc29 => snoc29 (g con nil29 snoc29) a\n\nVar29 : Con29 -> Ty29 -> Type\nVar29 = \\ g, a =>\n (Var29 : Con29 -> Ty29 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var29 (snoc29 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var29 g a -> Var29 (snoc29 g b) a)\n -> Var29 g a\n\nvz29 : {g : _}-> {a : _} -> Var29 (snoc29 g a) a\nvz29 = \\ var, vz29, vs => vz29 _ _\n\nvs29 : {g : _} -> {B : _} -> {a : _} -> Var29 g a -> Var29 (snoc29 g B) a\nvs29 = \\ x, var, vz29, vs29 => vs29 _ _ _ (x var vz29 vs29)\n\nTm29 : Con29 -> Ty29 -> Type\nTm29 = \\ g, a =>\n (Tm29 : Con29 -> Ty29 -> Type)\n -> (var : (g : _) -> (a : _) -> Var29 g a -> Tm29 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm29 (snoc29 g a) B -> Tm29 g (arr29 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm29 g (arr29 a B) -> Tm29 g a -> Tm29 g B)\n -> Tm29 g a\n\nvar29 : {g : _} -> {a : _} -> Var29 g a -> Tm29 g a\nvar29 = \\ x, tm, var29, lam, app => var29 _ _ x\n\nlam29 : {g : _} -> {a : _} -> {B : _} -> Tm29 (snoc29 g a) B -> Tm29 g (arr29 a B)\nlam29 = \\ t, tm, var29, lam29, app => lam29 _ _ _ (t tm var29 lam29 app)\n\napp29 : {g:_}->{a:_}->{B:_} -> Tm29 g (arr29 a B) -> Tm29 g a -> Tm29 g B\napp29 = \\ t, u, tm, var29, lam29, app29 => app29 _ _ _ (t tm var29 lam29 app29) (u tm var29 lam29 app29)\n\nv029 : {g:_}->{a:_} -> Tm29 (snoc29 g a) a\nv029 = var29 vz29\n\nv129 : {g:_}->{a:_}-> {B:_}-> Tm29 (snoc29 (snoc29 g a) B) a\nv129 = var29 (vs29 vz29)\n\nv229 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm29 (snoc29 (snoc29 (snoc29 g a) B) C) a\nv229 = var29 (vs29 (vs29 vz29))\n\nv329 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm29 (snoc29 (snoc29 (snoc29 (snoc29 g a) B) C) D) a\nv329 = var29 (vs29 (vs29 (vs29 vz29)))\n\nv429 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm29 (snoc29 (snoc29 (snoc29 (snoc29 (snoc29 g a) B) C) D) E) a\nv429 = var29 (vs29 (vs29 (vs29 (vs29 vz29))))\n\ntest29 : {g:_}-> {a:_} -> Tm29 g (arr29 (arr29 a a) (arr29 a a))\ntest29 = lam29 (lam29 (app29 v129 (app29 v129 (app29 v129 (app29 v129 (app29 v129 (app29 v129 v029)))))))\nTy30 : Type\nTy30 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty30 : Ty30\nempty30 = \\ _, empty, _ => empty\n\narr30 : Ty30 -> Ty30 -> Ty30\narr30 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon30 : Type\nCon30 = (Con30 : Type)\n ->(nil : Con30)\n ->(snoc : Con30 -> Ty30 -> Con30)\n -> Con30\n\nnil30 : Con30\nnil30 = \\ con, nil30, snoc => nil30\n\nsnoc30 : Con30 -> Ty30 -> Con30\nsnoc30 = \\ g, a, con, nil30, snoc30 => snoc30 (g con nil30 snoc30) a\n\nVar30 : Con30 -> Ty30 -> Type\nVar30 = \\ g, a =>\n (Var30 : Con30 -> Ty30 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var30 (snoc30 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var30 g a -> Var30 (snoc30 g b) a)\n -> Var30 g a\n\nvz30 : {g : _}-> {a : _} -> Var30 (snoc30 g a) a\nvz30 = \\ var, vz30, vs => vz30 _ _\n\nvs30 : {g : _} -> {B : _} -> {a : _} -> Var30 g a -> Var30 (snoc30 g B) a\nvs30 = \\ x, var, vz30, vs30 => vs30 _ _ _ (x var vz30 vs30)\n\nTm30 : Con30 -> Ty30 -> Type\nTm30 = \\ g, a =>\n (Tm30 : Con30 -> Ty30 -> Type)\n -> (var : (g : _) -> (a : _) -> Var30 g a -> Tm30 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm30 (snoc30 g a) B -> Tm30 g (arr30 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm30 g (arr30 a B) -> Tm30 g a -> Tm30 g B)\n -> Tm30 g a\n\nvar30 : {g : _} -> {a : _} -> Var30 g a -> Tm30 g a\nvar30 = \\ x, tm, var30, lam, app => var30 _ _ x\n\nlam30 : {g : _} -> {a : _} -> {B : _} -> Tm30 (snoc30 g a) B -> Tm30 g (arr30 a B)\nlam30 = \\ t, tm, var30, lam30, app => lam30 _ _ _ (t tm var30 lam30 app)\n\napp30 : {g:_}->{a:_}->{B:_} -> Tm30 g (arr30 a B) -> Tm30 g a -> Tm30 g B\napp30 = \\ t, u, tm, var30, lam30, app30 => app30 _ _ _ (t tm var30 lam30 app30) (u tm var30 lam30 app30)\n\nv030 : {g:_}->{a:_} -> Tm30 (snoc30 g a) a\nv030 = var30 vz30\n\nv130 : {g:_}->{a:_}-> {B:_}-> Tm30 (snoc30 (snoc30 g a) B) a\nv130 = var30 (vs30 vz30)\n\nv230 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm30 (snoc30 (snoc30 (snoc30 g a) B) C) a\nv230 = var30 (vs30 (vs30 vz30))\n\nv330 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm30 (snoc30 (snoc30 (snoc30 (snoc30 g a) B) C) D) a\nv330 = var30 (vs30 (vs30 (vs30 vz30)))\n\nv430 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm30 (snoc30 (snoc30 (snoc30 (snoc30 (snoc30 g a) B) C) D) E) a\nv430 = var30 (vs30 (vs30 (vs30 (vs30 vz30))))\n\ntest30 : {g:_}-> {a:_} -> Tm30 g (arr30 (arr30 a a) (arr30 a a))\ntest30 = lam30 (lam30 (app30 v130 (app30 v130 (app30 v130 (app30 v130 (app30 v130 (app30 v130 v030)))))))\nTy31 : Type\nTy31 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty31 : Ty31\nempty31 = \\ _, empty, _ => empty\n\narr31 : Ty31 -> Ty31 -> Ty31\narr31 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon31 : Type\nCon31 = (Con31 : Type)\n ->(nil : Con31)\n ->(snoc : Con31 -> Ty31 -> Con31)\n -> Con31\n\nnil31 : Con31\nnil31 = \\ con, nil31, snoc => nil31\n\nsnoc31 : Con31 -> Ty31 -> Con31\nsnoc31 = \\ g, a, con, nil31, snoc31 => snoc31 (g con nil31 snoc31) a\n\nVar31 : Con31 -> Ty31 -> Type\nVar31 = \\ g, a =>\n (Var31 : Con31 -> Ty31 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var31 (snoc31 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var31 g a -> Var31 (snoc31 g b) a)\n -> Var31 g a\n\nvz31 : {g : _}-> {a : _} -> Var31 (snoc31 g a) a\nvz31 = \\ var, vz31, vs => vz31 _ _\n\nvs31 : {g : _} -> {B : _} -> {a : _} -> Var31 g a -> Var31 (snoc31 g B) a\nvs31 = \\ x, var, vz31, vs31 => vs31 _ _ _ (x var vz31 vs31)\n\nTm31 : Con31 -> Ty31 -> Type\nTm31 = \\ g, a =>\n (Tm31 : Con31 -> Ty31 -> Type)\n -> (var : (g : _) -> (a : _) -> Var31 g a -> Tm31 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm31 (snoc31 g a) B -> Tm31 g (arr31 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm31 g (arr31 a B) -> Tm31 g a -> Tm31 g B)\n -> Tm31 g a\n\nvar31 : {g : _} -> {a : _} -> Var31 g a -> Tm31 g a\nvar31 = \\ x, tm, var31, lam, app => var31 _ _ x\n\nlam31 : {g : _} -> {a : _} -> {B : _} -> Tm31 (snoc31 g a) B -> Tm31 g (arr31 a B)\nlam31 = \\ t, tm, var31, lam31, app => lam31 _ _ _ (t tm var31 lam31 app)\n\napp31 : {g:_}->{a:_}->{B:_} -> Tm31 g (arr31 a B) -> Tm31 g a -> Tm31 g B\napp31 = \\ t, u, tm, var31, lam31, app31 => app31 _ _ _ (t tm var31 lam31 app31) (u tm var31 lam31 app31)\n\nv031 : {g:_}->{a:_} -> Tm31 (snoc31 g a) a\nv031 = var31 vz31\n\nv131 : {g:_}->{a:_}-> {B:_}-> Tm31 (snoc31 (snoc31 g a) B) a\nv131 = var31 (vs31 vz31)\n\nv231 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm31 (snoc31 (snoc31 (snoc31 g a) B) C) a\nv231 = var31 (vs31 (vs31 vz31))\n\nv331 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm31 (snoc31 (snoc31 (snoc31 (snoc31 g a) B) C) D) a\nv331 = var31 (vs31 (vs31 (vs31 vz31)))\n\nv431 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm31 (snoc31 (snoc31 (snoc31 (snoc31 (snoc31 g a) B) C) D) E) a\nv431 = var31 (vs31 (vs31 (vs31 (vs31 vz31))))\n\ntest31 : {g:_}-> {a:_} -> Tm31 g (arr31 (arr31 a a) (arr31 a a))\ntest31 = lam31 (lam31 (app31 v131 (app31 v131 (app31 v131 (app31 v131 (app31 v131 (app31 v131 v031)))))))\nTy32 : Type\nTy32 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty32 : Ty32\nempty32 = \\ _, empty, _ => empty\n\narr32 : Ty32 -> Ty32 -> Ty32\narr32 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon32 : Type\nCon32 = (Con32 : Type)\n ->(nil : Con32)\n ->(snoc : Con32 -> Ty32 -> Con32)\n -> Con32\n\nnil32 : Con32\nnil32 = \\ con, nil32, snoc => nil32\n\nsnoc32 : Con32 -> Ty32 -> Con32\nsnoc32 = \\ g, a, con, nil32, snoc32 => snoc32 (g con nil32 snoc32) a\n\nVar32 : Con32 -> Ty32 -> Type\nVar32 = \\ g, a =>\n (Var32 : Con32 -> Ty32 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var32 (snoc32 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var32 g a -> Var32 (snoc32 g b) a)\n -> Var32 g a\n\nvz32 : {g : _}-> {a : _} -> Var32 (snoc32 g a) a\nvz32 = \\ var, vz32, vs => vz32 _ _\n\nvs32 : {g : _} -> {B : _} -> {a : _} -> Var32 g a -> Var32 (snoc32 g B) a\nvs32 = \\ x, var, vz32, vs32 => vs32 _ _ _ (x var vz32 vs32)\n\nTm32 : Con32 -> Ty32 -> Type\nTm32 = \\ g, a =>\n (Tm32 : Con32 -> Ty32 -> Type)\n -> (var : (g : _) -> (a : _) -> Var32 g a -> Tm32 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm32 (snoc32 g a) B -> Tm32 g (arr32 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm32 g (arr32 a B) -> Tm32 g a -> Tm32 g B)\n -> Tm32 g a\n\nvar32 : {g : _} -> {a : _} -> Var32 g a -> Tm32 g a\nvar32 = \\ x, tm, var32, lam, app => var32 _ _ x\n\nlam32 : {g : _} -> {a : _} -> {B : _} -> Tm32 (snoc32 g a) B -> Tm32 g (arr32 a B)\nlam32 = \\ t, tm, var32, lam32, app => lam32 _ _ _ (t tm var32 lam32 app)\n\napp32 : {g:_}->{a:_}->{B:_} -> Tm32 g (arr32 a B) -> Tm32 g a -> Tm32 g B\napp32 = \\ t, u, tm, var32, lam32, app32 => app32 _ _ _ (t tm var32 lam32 app32) (u tm var32 lam32 app32)\n\nv032 : {g:_}->{a:_} -> Tm32 (snoc32 g a) a\nv032 = var32 vz32\n\nv132 : {g:_}->{a:_}-> {B:_}-> Tm32 (snoc32 (snoc32 g a) B) a\nv132 = var32 (vs32 vz32)\n\nv232 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm32 (snoc32 (snoc32 (snoc32 g a) B) C) a\nv232 = var32 (vs32 (vs32 vz32))\n\nv332 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm32 (snoc32 (snoc32 (snoc32 (snoc32 g a) B) C) D) a\nv332 = var32 (vs32 (vs32 (vs32 vz32)))\n\nv432 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm32 (snoc32 (snoc32 (snoc32 (snoc32 (snoc32 g a) B) C) D) E) a\nv432 = var32 (vs32 (vs32 (vs32 (vs32 vz32))))\n\ntest32 : {g:_}-> {a:_} -> Tm32 g (arr32 (arr32 a a) (arr32 a a))\ntest32 = lam32 (lam32 (app32 v132 (app32 v132 (app32 v132 (app32 v132 (app32 v132 (app32 v132 v032)))))))\nTy33 : Type\nTy33 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty33 : Ty33\nempty33 = \\ _, empty, _ => empty\n\narr33 : Ty33 -> Ty33 -> Ty33\narr33 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon33 : Type\nCon33 = (Con33 : Type)\n ->(nil : Con33)\n ->(snoc : Con33 -> Ty33 -> Con33)\n -> Con33\n\nnil33 : Con33\nnil33 = \\ con, nil33, snoc => nil33\n\nsnoc33 : Con33 -> Ty33 -> Con33\nsnoc33 = \\ g, a, con, nil33, snoc33 => snoc33 (g con nil33 snoc33) a\n\nVar33 : Con33 -> Ty33 -> Type\nVar33 = \\ g, a =>\n (Var33 : Con33 -> Ty33 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var33 (snoc33 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var33 g a -> Var33 (snoc33 g b) a)\n -> Var33 g a\n\nvz33 : {g : _}-> {a : _} -> Var33 (snoc33 g a) a\nvz33 = \\ var, vz33, vs => vz33 _ _\n\nvs33 : {g : _} -> {B : _} -> {a : _} -> Var33 g a -> Var33 (snoc33 g B) a\nvs33 = \\ x, var, vz33, vs33 => vs33 _ _ _ (x var vz33 vs33)\n\nTm33 : Con33 -> Ty33 -> Type\nTm33 = \\ g, a =>\n (Tm33 : Con33 -> Ty33 -> Type)\n -> (var : (g : _) -> (a : _) -> Var33 g a -> Tm33 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm33 (snoc33 g a) B -> Tm33 g (arr33 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm33 g (arr33 a B) -> Tm33 g a -> Tm33 g B)\n -> Tm33 g a\n\nvar33 : {g : _} -> {a : _} -> Var33 g a -> Tm33 g a\nvar33 = \\ x, tm, var33, lam, app => var33 _ _ x\n\nlam33 : {g : _} -> {a : _} -> {B : _} -> Tm33 (snoc33 g a) B -> Tm33 g (arr33 a B)\nlam33 = \\ t, tm, var33, lam33, app => lam33 _ _ _ (t tm var33 lam33 app)\n\napp33 : {g:_}->{a:_}->{B:_} -> Tm33 g (arr33 a B) -> Tm33 g a -> Tm33 g B\napp33 = \\ t, u, tm, var33, lam33, app33 => app33 _ _ _ (t tm var33 lam33 app33) (u tm var33 lam33 app33)\n\nv033 : {g:_}->{a:_} -> Tm33 (snoc33 g a) a\nv033 = var33 vz33\n\nv133 : {g:_}->{a:_}-> {B:_}-> Tm33 (snoc33 (snoc33 g a) B) a\nv133 = var33 (vs33 vz33)\n\nv233 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm33 (snoc33 (snoc33 (snoc33 g a) B) C) a\nv233 = var33 (vs33 (vs33 vz33))\n\nv333 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm33 (snoc33 (snoc33 (snoc33 (snoc33 g a) B) C) D) a\nv333 = var33 (vs33 (vs33 (vs33 vz33)))\n\nv433 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm33 (snoc33 (snoc33 (snoc33 (snoc33 (snoc33 g a) B) C) D) E) a\nv433 = var33 (vs33 (vs33 (vs33 (vs33 vz33))))\n\ntest33 : {g:_}-> {a:_} -> Tm33 g (arr33 (arr33 a a) (arr33 a a))\ntest33 = lam33 (lam33 (app33 v133 (app33 v133 (app33 v133 (app33 v133 (app33 v133 (app33 v133 v033)))))))\nTy34 : Type\nTy34 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty34 : Ty34\nempty34 = \\ _, empty, _ => empty\n\narr34 : Ty34 -> Ty34 -> Ty34\narr34 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon34 : Type\nCon34 = (Con34 : Type)\n ->(nil : Con34)\n ->(snoc : Con34 -> Ty34 -> Con34)\n -> Con34\n\nnil34 : Con34\nnil34 = \\ con, nil34, snoc => nil34\n\nsnoc34 : Con34 -> Ty34 -> Con34\nsnoc34 = \\ g, a, con, nil34, snoc34 => snoc34 (g con nil34 snoc34) a\n\nVar34 : Con34 -> Ty34 -> Type\nVar34 = \\ g, a =>\n (Var34 : Con34 -> Ty34 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var34 (snoc34 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var34 g a -> Var34 (snoc34 g b) a)\n -> Var34 g a\n\nvz34 : {g : _}-> {a : _} -> Var34 (snoc34 g a) a\nvz34 = \\ var, vz34, vs => vz34 _ _\n\nvs34 : {g : _} -> {B : _} -> {a : _} -> Var34 g a -> Var34 (snoc34 g B) a\nvs34 = \\ x, var, vz34, vs34 => vs34 _ _ _ (x var vz34 vs34)\n\nTm34 : Con34 -> Ty34 -> Type\nTm34 = \\ g, a =>\n (Tm34 : Con34 -> Ty34 -> Type)\n -> (var : (g : _) -> (a : _) -> Var34 g a -> Tm34 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm34 (snoc34 g a) B -> Tm34 g (arr34 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm34 g (arr34 a B) -> Tm34 g a -> Tm34 g B)\n -> Tm34 g a\n\nvar34 : {g : _} -> {a : _} -> Var34 g a -> Tm34 g a\nvar34 = \\ x, tm, var34, lam, app => var34 _ _ x\n\nlam34 : {g : _} -> {a : _} -> {B : _} -> Tm34 (snoc34 g a) B -> Tm34 g (arr34 a B)\nlam34 = \\ t, tm, var34, lam34, app => lam34 _ _ _ (t tm var34 lam34 app)\n\napp34 : {g:_}->{a:_}->{B:_} -> Tm34 g (arr34 a B) -> Tm34 g a -> Tm34 g B\napp34 = \\ t, u, tm, var34, lam34, app34 => app34 _ _ _ (t tm var34 lam34 app34) (u tm var34 lam34 app34)\n\nv034 : {g:_}->{a:_} -> Tm34 (snoc34 g a) a\nv034 = var34 vz34\n\nv134 : {g:_}->{a:_}-> {B:_}-> Tm34 (snoc34 (snoc34 g a) B) a\nv134 = var34 (vs34 vz34)\n\nv234 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm34 (snoc34 (snoc34 (snoc34 g a) B) C) a\nv234 = var34 (vs34 (vs34 vz34))\n\nv334 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm34 (snoc34 (snoc34 (snoc34 (snoc34 g a) B) C) D) a\nv334 = var34 (vs34 (vs34 (vs34 vz34)))\n\nv434 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm34 (snoc34 (snoc34 (snoc34 (snoc34 (snoc34 g a) B) C) D) E) a\nv434 = var34 (vs34 (vs34 (vs34 (vs34 vz34))))\n\ntest34 : {g:_}-> {a:_} -> Tm34 g (arr34 (arr34 a a) (arr34 a a))\ntest34 = lam34 (lam34 (app34 v134 (app34 v134 (app34 v134 (app34 v134 (app34 v134 (app34 v134 v034)))))))\nTy35 : Type\nTy35 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty35 : Ty35\nempty35 = \\ _, empty, _ => empty\n\narr35 : Ty35 -> Ty35 -> Ty35\narr35 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon35 : Type\nCon35 = (Con35 : Type)\n ->(nil : Con35)\n ->(snoc : Con35 -> Ty35 -> Con35)\n -> Con35\n\nnil35 : Con35\nnil35 = \\ con, nil35, snoc => nil35\n\nsnoc35 : Con35 -> Ty35 -> Con35\nsnoc35 = \\ g, a, con, nil35, snoc35 => snoc35 (g con nil35 snoc35) a\n\nVar35 : Con35 -> Ty35 -> Type\nVar35 = \\ g, a =>\n (Var35 : Con35 -> Ty35 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var35 (snoc35 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var35 g a -> Var35 (snoc35 g b) a)\n -> Var35 g a\n\nvz35 : {g : _}-> {a : _} -> Var35 (snoc35 g a) a\nvz35 = \\ var, vz35, vs => vz35 _ _\n\nvs35 : {g : _} -> {B : _} -> {a : _} -> Var35 g a -> Var35 (snoc35 g B) a\nvs35 = \\ x, var, vz35, vs35 => vs35 _ _ _ (x var vz35 vs35)\n\nTm35 : Con35 -> Ty35 -> Type\nTm35 = \\ g, a =>\n (Tm35 : Con35 -> Ty35 -> Type)\n -> (var : (g : _) -> (a : _) -> Var35 g a -> Tm35 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm35 (snoc35 g a) B -> Tm35 g (arr35 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm35 g (arr35 a B) -> Tm35 g a -> Tm35 g B)\n -> Tm35 g a\n\nvar35 : {g : _} -> {a : _} -> Var35 g a -> Tm35 g a\nvar35 = \\ x, tm, var35, lam, app => var35 _ _ x\n\nlam35 : {g : _} -> {a : _} -> {B : _} -> Tm35 (snoc35 g a) B -> Tm35 g (arr35 a B)\nlam35 = \\ t, tm, var35, lam35, app => lam35 _ _ _ (t tm var35 lam35 app)\n\napp35 : {g:_}->{a:_}->{B:_} -> Tm35 g (arr35 a B) -> Tm35 g a -> Tm35 g B\napp35 = \\ t, u, tm, var35, lam35, app35 => app35 _ _ _ (t tm var35 lam35 app35) (u tm var35 lam35 app35)\n\nv035 : {g:_}->{a:_} -> Tm35 (snoc35 g a) a\nv035 = var35 vz35\n\nv135 : {g:_}->{a:_}-> {B:_}-> Tm35 (snoc35 (snoc35 g a) B) a\nv135 = var35 (vs35 vz35)\n\nv235 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm35 (snoc35 (snoc35 (snoc35 g a) B) C) a\nv235 = var35 (vs35 (vs35 vz35))\n\nv335 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm35 (snoc35 (snoc35 (snoc35 (snoc35 g a) B) C) D) a\nv335 = var35 (vs35 (vs35 (vs35 vz35)))\n\nv435 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm35 (snoc35 (snoc35 (snoc35 (snoc35 (snoc35 g a) B) C) D) E) a\nv435 = var35 (vs35 (vs35 (vs35 (vs35 vz35))))\n\ntest35 : {g:_}-> {a:_} -> Tm35 g (arr35 (arr35 a a) (arr35 a a))\ntest35 = lam35 (lam35 (app35 v135 (app35 v135 (app35 v135 (app35 v135 (app35 v135 (app35 v135 v035)))))))\nTy36 : Type\nTy36 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty36 : Ty36\nempty36 = \\ _, empty, _ => empty\n\narr36 : Ty36 -> Ty36 -> Ty36\narr36 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon36 : Type\nCon36 = (Con36 : Type)\n ->(nil : Con36)\n ->(snoc : Con36 -> Ty36 -> Con36)\n -> Con36\n\nnil36 : Con36\nnil36 = \\ con, nil36, snoc => nil36\n\nsnoc36 : Con36 -> Ty36 -> Con36\nsnoc36 = \\ g, a, con, nil36, snoc36 => snoc36 (g con nil36 snoc36) a\n\nVar36 : Con36 -> Ty36 -> Type\nVar36 = \\ g, a =>\n (Var36 : Con36 -> Ty36 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var36 (snoc36 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var36 g a -> Var36 (snoc36 g b) a)\n -> Var36 g a\n\nvz36 : {g : _}-> {a : _} -> Var36 (snoc36 g a) a\nvz36 = \\ var, vz36, vs => vz36 _ _\n\nvs36 : {g : _} -> {B : _} -> {a : _} -> Var36 g a -> Var36 (snoc36 g B) a\nvs36 = \\ x, var, vz36, vs36 => vs36 _ _ _ (x var vz36 vs36)\n\nTm36 : Con36 -> Ty36 -> Type\nTm36 = \\ g, a =>\n (Tm36 : Con36 -> Ty36 -> Type)\n -> (var : (g : _) -> (a : _) -> Var36 g a -> Tm36 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm36 (snoc36 g a) B -> Tm36 g (arr36 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm36 g (arr36 a B) -> Tm36 g a -> Tm36 g B)\n -> Tm36 g a\n\nvar36 : {g : _} -> {a : _} -> Var36 g a -> Tm36 g a\nvar36 = \\ x, tm, var36, lam, app => var36 _ _ x\n\nlam36 : {g : _} -> {a : _} -> {B : _} -> Tm36 (snoc36 g a) B -> Tm36 g (arr36 a B)\nlam36 = \\ t, tm, var36, lam36, app => lam36 _ _ _ (t tm var36 lam36 app)\n\napp36 : {g:_}->{a:_}->{B:_} -> Tm36 g (arr36 a B) -> Tm36 g a -> Tm36 g B\napp36 = \\ t, u, tm, var36, lam36, app36 => app36 _ _ _ (t tm var36 lam36 app36) (u tm var36 lam36 app36)\n\nv036 : {g:_}->{a:_} -> Tm36 (snoc36 g a) a\nv036 = var36 vz36\n\nv136 : {g:_}->{a:_}-> {B:_}-> Tm36 (snoc36 (snoc36 g a) B) a\nv136 = var36 (vs36 vz36)\n\nv236 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm36 (snoc36 (snoc36 (snoc36 g a) B) C) a\nv236 = var36 (vs36 (vs36 vz36))\n\nv336 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm36 (snoc36 (snoc36 (snoc36 (snoc36 g a) B) C) D) a\nv336 = var36 (vs36 (vs36 (vs36 vz36)))\n\nv436 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm36 (snoc36 (snoc36 (snoc36 (snoc36 (snoc36 g a) B) C) D) E) a\nv436 = var36 (vs36 (vs36 (vs36 (vs36 vz36))))\n\ntest36 : {g:_}-> {a:_} -> Tm36 g (arr36 (arr36 a a) (arr36 a a))\ntest36 = lam36 (lam36 (app36 v136 (app36 v136 (app36 v136 (app36 v136 (app36 v136 (app36 v136 v036)))))))\nTy37 : Type\nTy37 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty37 : Ty37\nempty37 = \\ _, empty, _ => empty\n\narr37 : Ty37 -> Ty37 -> Ty37\narr37 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon37 : Type\nCon37 = (Con37 : Type)\n ->(nil : Con37)\n ->(snoc : Con37 -> Ty37 -> Con37)\n -> Con37\n\nnil37 : Con37\nnil37 = \\ con, nil37, snoc => nil37\n\nsnoc37 : Con37 -> Ty37 -> Con37\nsnoc37 = \\ g, a, con, nil37, snoc37 => snoc37 (g con nil37 snoc37) a\n\nVar37 : Con37 -> Ty37 -> Type\nVar37 = \\ g, a =>\n (Var37 : Con37 -> Ty37 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var37 (snoc37 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var37 g a -> Var37 (snoc37 g b) a)\n -> Var37 g a\n\nvz37 : {g : _}-> {a : _} -> Var37 (snoc37 g a) a\nvz37 = \\ var, vz37, vs => vz37 _ _\n\nvs37 : {g : _} -> {B : _} -> {a : _} -> Var37 g a -> Var37 (snoc37 g B) a\nvs37 = \\ x, var, vz37, vs37 => vs37 _ _ _ (x var vz37 vs37)\n\nTm37 : Con37 -> Ty37 -> Type\nTm37 = \\ g, a =>\n (Tm37 : Con37 -> Ty37 -> Type)\n -> (var : (g : _) -> (a : _) -> Var37 g a -> Tm37 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm37 (snoc37 g a) B -> Tm37 g (arr37 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm37 g (arr37 a B) -> Tm37 g a -> Tm37 g B)\n -> Tm37 g a\n\nvar37 : {g : _} -> {a : _} -> Var37 g a -> Tm37 g a\nvar37 = \\ x, tm, var37, lam, app => var37 _ _ x\n\nlam37 : {g : _} -> {a : _} -> {B : _} -> Tm37 (snoc37 g a) B -> Tm37 g (arr37 a B)\nlam37 = \\ t, tm, var37, lam37, app => lam37 _ _ _ (t tm var37 lam37 app)\n\napp37 : {g:_}->{a:_}->{B:_} -> Tm37 g (arr37 a B) -> Tm37 g a -> Tm37 g B\napp37 = \\ t, u, tm, var37, lam37, app37 => app37 _ _ _ (t tm var37 lam37 app37) (u tm var37 lam37 app37)\n\nv037 : {g:_}->{a:_} -> Tm37 (snoc37 g a) a\nv037 = var37 vz37\n\nv137 : {g:_}->{a:_}-> {B:_}-> Tm37 (snoc37 (snoc37 g a) B) a\nv137 = var37 (vs37 vz37)\n\nv237 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm37 (snoc37 (snoc37 (snoc37 g a) B) C) a\nv237 = var37 (vs37 (vs37 vz37))\n\nv337 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm37 (snoc37 (snoc37 (snoc37 (snoc37 g a) B) C) D) a\nv337 = var37 (vs37 (vs37 (vs37 vz37)))\n\nv437 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm37 (snoc37 (snoc37 (snoc37 (snoc37 (snoc37 g a) B) C) D) E) a\nv437 = var37 (vs37 (vs37 (vs37 (vs37 vz37))))\n\ntest37 : {g:_}-> {a:_} -> Tm37 g (arr37 (arr37 a a) (arr37 a a))\ntest37 = lam37 (lam37 (app37 v137 (app37 v137 (app37 v137 (app37 v137 (app37 v137 (app37 v137 v037)))))))\n", "meta": {"hexsha": "1d24c2f34d1224d185991bc4ff1024d18f694627", "size": 91608, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "bench/stlc_small2k.idr", "max_stars_repo_name": "Kha/smalltt", "max_stars_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 377, "max_stars_repo_stars_event_min_datetime": "2017-11-26T16:57:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T21:31:01.000Z", "max_issues_repo_path": "bench/stlc_small2k.idr", "max_issues_repo_name": "Kha/smalltt", "max_issues_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-03-16T09:14:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:51:10.000Z", "max_forks_repo_path": "bench/stlc_small2k.idr", "max_forks_repo_name": "Kha/smalltt", "max_forks_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2018-12-05T21:11:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T19:46:54.000Z", "avg_line_length": 33.9414597999, "max_line_length": 118, "alphanum_fraction": 0.4984935813, "num_tokens": 42469, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503206, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.539935764230649}} {"text": "module Verified.Applicative\n\nimport Verified.Functor\n\n%default total\n\nclass (Applicative f, VerifiedFunctor f) => VerifiedApplicative (f : Type -> Type) where\n applicativeMap : (x : f a) -> (g : a -> b) ->\n map g x = pure g <*> x\n applicativeIdentity : (x : f a) -> pure id <*> x = x\n applicativeComposition : (x : f a) -> (g1 : f (a -> b)) -> (g2 : f (b -> c)) ->\n ((pure (.) <*> g2) <*> g1) <*> x = g2 <*> (g1 <*> x)\n applicativeHomomorphism : (x : a) -> (g : a -> b) ->\n (<*>) {f} (pure g) (pure x) = pure {f} (g x)\n applicativeInterchange : (x : a) -> (g : f (a -> b)) ->\n g <*> pure x = pure (\\g' : a -> b => g' x) <*> g\n", "meta": {"hexsha": "dcdfc54fd0a045a310bb5d04ea925d59894d8835", "size": 728, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Verified/Applicative.idr", "max_stars_repo_name": "yurrriq/idris-verified", "max_stars_repo_head_hexsha": "10dd99e43824421be94138b5547fed5a294c9cd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Verified/Applicative.idr", "max_issues_repo_name": "yurrriq/idris-verified", "max_issues_repo_head_hexsha": "10dd99e43824421be94138b5547fed5a294c9cd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Verified/Applicative.idr", "max_forks_repo_name": "yurrriq/idris-verified", "max_forks_repo_head_hexsha": "10dd99e43824421be94138b5547fed5a294c9cd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.8235294118, "max_line_length": 88, "alphanum_fraction": 0.4450549451, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473879530491, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.5397914950929024}} {"text": "> module SequentialDecisionProblems.CoreTheory\n\n> import Sigma.Sigma\n> import Sigma.Operations\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n* Preliminaries\n\nIn a nutshell, the core theory introduces the notion of policy, policy\nsequence, optimality of policy sequences and implements a generic\nbackwards induction algorithm |backwardsInduction| for computing optimal\npolicy sequences.\n\nHowever, the core theory does not implement a machine checkable proof\nthat |backwardsInduction| is correct that is, that its result is an\noptimal policy sequence.\n\nThis is done in the full theory presented in |FullTheory|. Both here and\nin |FullTheory|, the assumptions are implemented as holes\n(metavariables, forward declarations, partial definitions, etc.). The\nidea is that users that wish to apply the theory (typically, for\ncomputing optimal solutions for a specific decision problem) will\nfill-in the holes by providing problem-specific implementations.\n\n\n* Sequential decision processes\n\nA sequential decision problem (SDP) is specified in terms of, among\nothers, its underlying decision process.\n\nIn a decision process, a decision maker is required to perform a number\nof decision steps. At each step, the decision maker is in (observes) a\nstate and is required to select a control (action, option). The idea is\nthat, upon selecting a control in a given state, the decision maker will\nenter (observe) a new state. In a deterministic decision process, such\nnew state is uniquely defined in terms of the current decision step,\nstate and selected control. But in decision processes under uncertainty,\nthe decision maker only knows which new states are \"possible\" (again,\nfor a given decision step, \"current\" state and selected control) and,\nperhaps, their probabilities. But it does not know which one will\nactually occur.\n\nThus, in order to specify a decision process, one has to first specify\nwhat are the possible states at each decision step:\n\n> State : (t : Nat) -> Type\n\nThen, one has to explain which controls can be selected at a given step\nand for a given state:\n\n> Ctrl : (t : Nat) -> (x : State t) -> Type\n\nFinally, one has to explain which \"next\" states are possible at a given\ndecision step, in a given state and for a selected control. In the\ndeterministic case, one could provide such explanation by defining a\nstepping function\n\n< next : (t : Nat) -> (x : State t) -> (y : Ctrl t x) -> State (S t)\n\nBut what if the decision process has uncertain outcomes? In this case,\nwe follow an approach originally proposed by Ionescu [1] and generalize\n|next| to a monadic transition function:\n\n> M : Type -> Type\n\n> nexts : (t : Nat) -> (x : State t) -> (y : Ctrl t x) -> M (State (S t))\n\nFor reasons that will become clear in the sequel, |M| is is required\nto be a functor:\n\n> fmap : {A, B : Type} -> \n> (A -> B) -> M A -> M B\n> postulate functorSpec1 : fmap . id = id\n> postulate functorSpec2 : {A, B, C : Type} -> {f : B -> C} -> {g : A -> B} ->\n> fmap (f . g) = (fmap f) . (fmap g)\n\nIn the above specification and throughout this file, we use postulates\nto denote assumptions that we consider to be conceptually relevant but\nthat are not necessary for the theory. Thus, strictly speaking, |M| is\nnot required to be a functor, just to implement |fmap|.\n\nIn specific decision processes, we expect |M| to be |Id| (deterministic\nSDP), |List| (non-deterministic SDP) or |Prob| (stochastic SDP). But our\nassumptions are general enough to specify other kinds of decision\nprocesses.\n\n\n* Sequential decision problems\n\nIn order to obtain a problem from a decision process, we introduce the\nadditional assumption that, with each transition from the current state\nto a new state, the decision maker receives a certain reward (payoff,\netc.)\n\n> Val : Type\n\n> reward : (t : Nat) -> (x : State t) -> (y : Ctrl t x) -> (x' : State (S t)) -> Val\n\nSince the original work of Bellman [1957], this has turned out to be a\nuseful abstraction. The idea is that the decision maker seeks controls\nthat maximize the sum of the rewards obtained in a decision\nprocess. Thus, values of type |Val| have to be \"addable\"\n\n> plus : Val -> Val -> Val\n\nWe will also need |Val| to be equipped with a \"zero\"\n\n> zero : Val\n\nand with a binary \"comparison\" relation\n\n> LTE : Val -> Val -> Type\n\nIn a deterministic case, implementing the above assumptions completely\ndefines a sequential decision problem. But whenever a decision step has\nan uncertain outcome, uncertainties about \"next\" states naturally yield\nuncertainties about rewards. In these cases, the decision makes faces a\nnumber of possible rewards (one for each possible next state) and has to\nexplain how it measures such chances. In stochastic decision problems,\npossible next states (and, therefore possible rewards) are labelled with\nprobabilities. In these cases, possible rewards are often measured in\nterms of their expected value. Here, again, we follow the approach\nproposed by Ionescu in [2] and introduce a measure\n\n> meas : M Val -> Val\n\nthat characterizes how the decision maker values uncertainties about\nrewards in a single decision step. It is possible that a decision maker\nvalues uncertainties according to different measures at different\ndecision steps. This could be easily formalized by generalising\n\n< meas : M Val -> Val\n\nto\n\n< meas : (t : Nat) -> (x : State t) -> (M Val -> Val)\n\n\n* Solving sequential decision problems\n\nImplementing the above holes defines a specific SDP unambiguously. But\nin order to compute controls that maximize the sum of the rewards over\nan arbitrary number of decision steps, we need to be able to assess that\nall \"next\" states in an |M|-structure satisfy certain properties. This\nrequires |M| to be a \"container\":\n\n> Elem : {A : Type} -> A -> M A -> Type\n> NotEmpty : {A : Type} -> M A -> Type\n> All : {A : Type} -> (P : A -> Type) -> M A -> Type\n> tagElem : {A : Type} -> (ma : M A) -> M (Sigma A (\\ a => a `Elem` ma))\n\n> allElemSpec0 : {A : Type} -> {P : A -> Type} ->\n> (a : A) -> (ma : M A) -> All P ma -> a `Elem` ma -> P a\n\n> postulate elemNotEmptySpec0 : {A : Type} -> \n> (a : A) -> (ma : M A) -> a `Elem` ma -> NotEmpty ma\n\n> postulate elemNotEmptySpec1 : {A : Type} -> \n> (ma : M A) -> NotEmpty ma -> Sigma A (\\ a => a `Elem` ma)\n\n\n> postulate tagElemSpec : {A : Type} -> (ma : M A) -> fmap outl (tagElem ma) = ma\n\nThe theory presented here relies on two further notions: viability and\nreachability.\n\n\n* Viability\n\nIntuitively, a state |x : State t| is viable for |n| steps if, in spite\nof the uncertainties of the decision process, one can make |n| decision\nsteps starting from |x| without bumping into a dead end. Here, dead ends\nare states for which no controls are available. In concrete decision\nproblems, they could represent exceptional outcomes: aborting a\ncomputation, running out of fuel, being shot dead.\n\n> Viable : {t : Nat} -> (n : Nat) -> State t -> Type\n\nThus, every state is viable for zero steps\n\n> postulate viableSpec0 : {t : Nat} ->\n> (x : State t) -> Viable Z x\n\nand a state is viable for |S n| steps iff there exists a control that\nleads to a non-empty |M|-structure of next states which are viable for\n|n| steps. We call such controls \"good\" controls:\n\n> Good : (t : Nat) -> (x : State t) -> (n : Nat) -> (Ctrl t x) -> Type\n> Good t x n y = (NotEmpty (nexts t x y), All (Viable {t = S t} n) (nexts t x y))\n\n> GoodCtrl : (t : Nat) -> (x : State t) -> (n : Nat) -> Type\n> GoodCtrl t x n = Sigma (Ctrl t x) (Good t x n)\n> -- GoodCtrl t x n = Sigma (Ctrl t x) (\\ y => (NotEmpty (nexts t x y), All (Viable {t = S t} n) (nexts t x y)))\n\n> viableSpec1 : {t : Nat} -> {n : Nat} ->\n> (x : State t) -> Viable (S n) x -> GoodCtrl t x n\n\n> postulate viableSpec2 : {t : Nat} -> {n : Nat} ->\n> (x : State t) -> GoodCtrl t x n -> Viable (S n) x\n\nAuxiliary functions:\n\n> |||\n> ctrl : {t, n : Nat} -> {x : State t} -> GoodCtrl t x n -> Ctrl t x\n> ctrl (MkSigma y _) = y\n\n> |||\n> -- good : {t, n : Nat} -> {x : State t} -> (y : GoodCtrl t x n) -> Good t x n (ctrl y)\n> -- good (MkSigma _ p) = p\n\n> |||\n> allViable : {t, n : Nat} -> {x : State t} -> (y : GoodCtrl t x n) -> All (Viable n) (nexts t x (ctrl y)) \n> allViable (MkSigma _ p) = snd p\n\n\n* Reachability\n\nViability is, strictly speaking, all what is needed to formalize the\nnotion of policies as functions that associate \"good\" controls to\nviable states.\n\nBut in a decision problem, not all viable states are actually\nreachable. Thus, we would like to further restrict the domain of\npolicies to states that can actually be reached. Intuitively, a state is\nreachable if there are controls that allow for a path from some initial\nstate to that state. Thus, tautologically, every initial state is\nreachable:\n\n> Reachable : {t' : Nat} -> State t' -> Type\n\n> postulate reachableSpec0 : (x : State Z) -> Reachable x\n\nMoreover, if |x| is reachable and admits a control |y|, then all states\nthat can be obtained by selecting |y| in |x| are also reachable:\n\n> reachableSpec1 : {t : Nat} -> (x : State t) -> Reachable x -> (y : Ctrl t x) -> All Reachable (nexts t x y)\n\nAnd the other way round:\n\n> Pred : {t : Nat} -> State t -> State (S t) -> Type\n> Pred {t} x x' = Sigma (Ctrl t x) (\\ y => x' `Elem` nexts t x y)\n\n> ReachablePred : {t : Nat} -> State t -> State (S t) -> Type\n> ReachablePred x x' = (Reachable x, x `Pred` x')\n\n> postulate reachableSpec2 : {t : Nat} -> (x' : State (S t)) -> Reachable x' -> Sigma (State t) (\\ x => x `ReachablePred` x')\n\n\n* Policies and policy sequences\n\nPolicies are functions that associate to every state |x| at decision\nstep |t| which is reachable and viable for |S m| steps (from which |S\nm| more decision steps are doable) a good control:\n\n> Policy : (t : Nat) -> (n : Nat) -> Type\n> Policy t Z = Unit\n> Policy t (S m) = (x : State t) -> Reachable x -> Viable (S m) x -> GoodCtrl t x m\n\nA policy sequence for making |n| decision steps starting from some\n(reachable, viable for |n| steps) state at decision step |t| is a list\nof policies of length |n|, one for each decision step:\n\n> data PolicySeq : (t : Nat) -> (n : Nat) -> Type where\n> Nil : {t : Nat} -> \n> PolicySeq t Z\n> (::) : {t, n : Nat} -> \n> Policy t (S n) -> PolicySeq (S t) n -> PolicySeq t (S n)\n\nFold for |PolicySeq|:\n\n> foldPolicySeq : {X : (t : Nat) -> (n : Nat) -> Type} ->\n> ((t : Nat) -> X t Z) ->\n> ((t : Nat) -> (n : Nat) -> Policy t (S n) -> X (S t) n -> X t (S n)) ->\n> (t : Nat) -> (n : Nat) -> PolicySeq t n -> X t n\n> foldPolicySeq e f t Z Nil = e t\n> foldPolicySeq e f t (S n) (p :: ps) = f t n p (foldPolicySeq e f (S t) n ps)\n\n* The value of policy sequences\n\nAs mentioned before, the idea of a decision problem is that the\ndecision maker seeks controls that maximize the sum of the rewards\nobtained in a decision process.\n\nThus, in order to meaningfully define a notion of optimality for policy\nsequences, we have to compute the value (in terms of possible sums of\nrewards) of making decisions according to a given policy sequence.\n\nSpecifically, for a policy sequence |ps : PolicySeq tn| and a reachable,\nviable for |n| steps state |x : State t|, we have to compute the value\n(in terms of possible sums of rewards) of making |n| decision steps with\n|ps| starting from |x|:\n\n< val : {t : Nat} -> {n : Nat} -> \n< (x : State t) -> Reachable x -> Viable n x -> PolicySeq t n -> Val\n\nThe case |n = Z| (and |ps = Nil|) is trivial. Here, we are not making\nany decision step. Thus, we do not collect any reward and the value is\njust zero:\n\n< val {t} {n = Z} x r v ps = zero\n\nIf |n = S m| and |ps| consists of a policy |p : Policy t (S m)| and of a\npolicy sequence |ps : PolicySeq (S t) m|, things are more complicated:\n\n< val {t} {n = S m} x r v (p :: ps) = ?\n\nHere, we first have to compute the rewards obtained by selecting the\ncontrol |y = ctrl (p x r v)| in the first decision step. We get one\npossible reward for each state in |nexts t x y|. Thus, if |x' `Elem`\n(nexts t x y)|, its corresponding reward is\n\n< reward t x y x'\n\nNext, we have to add to all these rewards (one for every |x'|) the\nvalues of making |m| further decision steps with |ps| starting from\n|x'|:\n\n< val x' r' v' ps\n\nTo do so, we have to provide reachability and viability evidences |r'|\nand |v'| for |x'|. Finally, we have to reduce all possible values to a\nsingle aggregated value. Here is where the measure |meas| comes into\nplace.\n\nIt is useful to introduce the notion of those possible states that can\nbe obtained by selecting the control |y : Ctrl t x| in |x : State t|:\n\n> PossibleNextState : {t : Nat} -> \n> (x : State t) -> (y : Ctrl t x) -> Type\n> PossibleNextState {t} x y = Sigma (State (S t)) (\\ x' => x' `Elem` (nexts t x y))\n\nWith this notion in place and assuming \n\n< val : {t : Nat} -> {n : Nat} -> \n< (x : State t) -> Reachable x -> Viable n x -> PolicySeq t n -> Val\n\nto be available, we can implement\n\n> mutual\n\n> sval : {t, m : Nat} -> \n> (x : State t) -> (r : Reachable x) -> (v : Viable (S m) x) ->\n> (gy : GoodCtrl t x m) -> (ps : PolicySeq (S t) m) ->\n> PossibleNextState x (ctrl gy) -> Val\n> {- \n> sval {t} {m} x r v gy ps (MkSigma x' x'emx') = reward t x y x' `plus` val x' r' v' ps where\n> y : Ctrl t x\n> y = ctrl gy\n> mx' : M (State (S t))\n> mx' = nexts t x y\n> ar' : All Reachable mx'\n> ar' = reachableSpec1 x r y\n> av' : All (Viable m) mx'\n> av' = allViable gy\n> r' : Reachable x'\n> r' = allElemSpec0 x' mx' ar' x'emx'\n> v' : Viable m x'\n> v' = allElemSpec0 x' mx' av' x'emx'\n> -}\n> sval {t} {m} x r v gy ps (MkSigma x' x'emx') = \n> let y : Ctrl t x \n> = ctrl gy in\n> let mx' : M (State (S t))\n> = nexts t x y in\n> let ar' : All Reachable mx'\n> = reachableSpec1 x r y in\n> let av' : All (Viable m) mx'\n> = allViable gy in\n> let r' : Reachable x'\n> = allElemSpec0 x' mx' ar' x'emx' in\n> let v' : Viable m x'\n> = allElemSpec0 x' mx' av' x'emx' in\n> reward t x y x' `plus` val x' r' v' ps\n\nAnd finally\n\n> val : {t, n : Nat} -> \n> (x : State t) -> (r : Reachable x) -> (v : Viable n x) -> PolicySeq t n -> Val\n> val {t} {n = Z} x r v ps = zero\n> val {t} {n = S m} x r v (p :: ps) = meas (fmap (sval x r v gy ps) (tagElem mx')) where\n> gy : GoodCtrl t x m\n> gy = p x r v\n> y : Ctrl t x\n> y = ctrl gy\n> mx' : M (State (S t))\n> mx' = nexts t x y\n\n\n* Optimality of policy sequences\n\nWith a function for computing the value (in terms of \"possible\" sums\nof rewards) of making |n| decision steps with a policy sequence\nstarting from some specific state, we can formalise what it means for\none such sequence to be optimal.\n\nInformally, we say that a policy sequence |ps| for making |n| decision\nsteps starting from states in |State t| which are reachable and viable\nfor |n| steps is optimal if its value is at least as good as the value\nof any other policy sequence for making |n| decision steps starting\nfrom states in |State t|. Formally:\n\n> |||\n> OptPolicySeq : {t, n : Nat} -> \n> PolicySeq t n -> Type\n> \n> {-\n> OptPolicySeq {t} {n} ps = (ps' : PolicySeq t n) ->\n> (x : State t) -> (r : Reachable x) -> (v : Viable n x) ->\n> val x r v ps' `LTE` val x r v ps\n> -}\n> OptPolicySeq {t} {n} ps = (x : State t) -> (r : Reachable x) -> (v : Viable n x) ->\n> (ps' : PolicySeq t n) ->\n> val x r v ps' `LTE` val x r v ps\n\nNotice that the above notion of optimality is very strong. It entails a\nquantification over all (viable and reachable) states of |Stete t| to\nwhich the first policy of the sequence can be applied. \n\nThus, if we manage to compute an optimal policy sequence of length |n|\nfor making |n| decisions starting from step |t|, we have the guarantee\nthat, no matter which state we will happen to be at decision step |t|,\nthere is no better way to make |n| decision steps than that encoded by\nour policy.\n\nIn other words, we have |n| rules for making ``best'' (in terms of\n``possible'' sums of rewards) decisions.\n\nThus, an obvious question is whether it is at all possible to compute\nsequences of policies that are optimal in the above sense. As we shall\nsee in |FullTheory|, if the assumptions put forward here and in\n|ExtraAssumptions| are fulfilled, the answer to this question is\npositive.\n\nIn the rest of this file, we implement a generic backwards induction\nalgorithm for computing optimal policy sequences for an arbitrary number\nof decision steps.\n\n\n* Optimal extensions of policy sequences\n\nThe computation at the core of backwards induction is the computation\nof an optimal extension of a policy sequence. An extension of a policy\nsequence for making |m| decision steps starting from states at\ndecision step |S t| is just a policy for taking decisions at step |t|,\nthat is, a policy that is put *in front* of the list of policies that\nwill deal with any resulting future states.\n\nInformally, a policy |p| is an optimal extension of a policy sequence\n|ps| if there is no better way than |p :: ps| to make |S m| decision\nsteps at step |t|. Formally:\n\n> |||\n> OptExt : {t, m : Nat} -> \n> PolicySeq (S t) m -> Policy t (S m) -> Type\n> {- \n> OptExt {t} {m} ps p = (p' : Policy t (S m)) ->\n> (x : State t) -> (r : Reachable x) -> (v : Viable (S m) x) ->\n> val x r v (p' :: ps) `LTE` val x r v (p :: ps)\n> -}\n> OptExt {t} {m} ps p = (x : State t) -> (r : Reachable x) -> (v : Viable (S m) x) ->\n> (p' : Policy t (S m)) ->\n> val x r v (p' :: ps) `LTE` val x r v (p :: ps) \n\nThe idea behind the notion of optimal extension is that if |p| is an\noptimal extension of |ps| and |ps| is optimal, then |p :: ps| is\noptimal. This is Bellman's principle of optimality [1] which we will\nimplement in |FullTheory|.\n\nThe strong requirement of optimality implies that |p| is optimal for\nevery state, therefore, the control obtained by applying |p| to a given\nstate |x| must be optimal, i.e., it must maximise the function |cval x r\nv ps|:\n\n> ||| \n> cval : {t, n : Nat} -> \n> (x : State t) -> (r : Reachable x) -> (v : Viable (S n) x) ->\n> (ps : PolicySeq (S t) n) -> GoodCtrl t x n -> Val\n> cval {t} x r v ps gy = meas (fmap (sval x r v gy ps) (tagElem mx')) where\n> y : Ctrl t x\n> y = ctrl gy\n> mx' : M (State (S t))\n> mx' = nexts t x y\n\nLet |cvalargmax| be a function that delivers the control that leads to\nthe maximal value of |cval x r v ps|:\n\n> cvalargmax : {t, n : Nat} -> \n> (x : State t) -> (r : Reachable x) -> (v : Viable (S n) x) ->\n> (ps : PolicySeq (S t) n) -> GoodCtrl t x n\n\nThe controls obtained by maximising |cval x r v ps| for each of the\nstates |x : State t| will deliver a policy which is an optimal extension\nof |ps|. Thus, the problem of maximising |val| has been reduced to the\nmaximisation of |cval| for the states at time |t|. Therefore, the\nfunction that computes this optimal extension is:\n\n> ||| \n> optExt : {t, n : Nat} -> \n> PolicySeq (S t) n -> Policy t (S n)\n> optExt {t} {n} ps = p where\n> p : Policy t (S n)\n> p x r v = cvalargmax x r v ps\n\n\n* Generic machine checkable backwards induction\n\nIf |LTE| is reflexive, it is straightforward to show that empty policy\nsequences (that is, sequences for performing zero decision steps) are\noptimal. Therefore, we have a starting point for the recursive process\nof extending optimal policy sequences. This suggests the following\nimplementations of backwards induction:\n\n> backwardsInduction : (t : Nat) -> (n : Nat) -> PolicySeq t n\n> backwardsInduction t Z = Nil\n> {-\n> backwardsInduction t (S n) = optExt ps :: ps where\n> ps : PolicySeq (S t) n\n> ps = backwardsInduction (S t) n\n> -}\n> backwardsInduction t (S n) = let ps = backwardsInduction (S t) n in\n> optExt ps :: ps\n\n> {-\n\n> take : {t : Nat} -> (n : Nat) -> (m : Nat) -> PolicySeq t n -> Sigma Nat (\\ m' => PolicySeq t m')\n> take {t} Z m ps = MkSigma Z Nil\n> take {t} (S n) Z ps = MkSigma Z Nil\n> take {t} (S n) (S m) (p :: ps) = MkSigma (S m') (p' :: ps') where\n> mps' : Sigma Nat (\\ m' => PolicySeq (S t) m')\n> mps' = take n m ps \n> m' : Nat\n> m' = outl mps'\n> ps' : PolicySeq (S t) m'\n> ps' = outr mps'\n> p' : Policy t (S m')\n> p' = ?this_might_work -- p\n\n> bi : (t : Nat) -> (n : Nat) -> (m : Nat) -> PolicySeq t n\n> bi t Z m = Nil\n> bi t (S n) m = p :: ps where\n> ps : PolicySeq (S t) n\n> ps = bi (S t) n m\n> m' : Nat \n> m' = outl (take n m ps)\n> ps' : PolicySeq (S t) m'\n> ps' = outr (take n m ps)\n> p : Policy t (S n)\n> p = ?this_will_not_work -- optExt ps'\n\n> -}\n\nThis file contains all the *computational* elements that the user must\nspecify in order to be able to run |backwardsInduction|. The results\nare going to fulfill the condition of optimality only if several\nassumptions hold, some of which we have introduced only informally (and\nothers not at all). For example, we have not formalised the requirement\nthat |cvalargmax| delivers an optimal control, or that |LTE| is\nreflexive (and we haven't even mentioned its transitivity, which is also\nrequired).\n\nThese additional assumptions are formulated in the file |FullTheory|,\nwhere we also implement a machine-checked proof of the correctness of\n|backwardsInduction| under these assumptions.\n\nThis separation has been introduced in order to enable users that do not\nwant to deal with formal proofs to use the framework for computing\noptimal policies. Of course, the optimality of the results will, in\nthis case, not be machine-checked.\n\n\n> {-\n\n> ---}\n\n\n[1] Bellman, Richard; \"Dynamic Programming\", Princeton University Press,\n 1957\n\n[2] Ionescu, Cezar; \"Vulnerability Modelling and Monadic Dynamical\n Systems\", Freie Universitaet Berlin, 2009\n \n", "meta": {"hexsha": "7e4af250b27a96a163a07c9b0ecf86d2905ff9ee", "size": 22398, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionProblems/CoreTheory.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SequentialDecisionProblems/CoreTheory.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SequentialDecisionProblems/CoreTheory.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.2218430034, "max_line_length": 127, "alphanum_fraction": 0.6378694526, "num_tokens": 6600, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6757646010190477, "lm_q1q2_score": 0.5393863693978944}} {"text": "{-\n$ cd collatzProof_DivSeq/program3\n$ chcp 65001\n$ idris\n> :l ProofColDivSeqMain\n-}\nmodule ProofColDivSeqMain\n\nimport ProofColDivSeqBase as B\nimport ProofColDivSeqPostulate\nimport Sub02LTE72t45\nimport Sub03LTE216t81\nimport Sub04LTE216t153\nimport Sub05LTE216t225\nimport Sub06LTE108t27\nimport Sub07LTE108t63\nimport Sub08LTE108t99\nimport Sub09LTE18t15\nimport Sub11LTE36t21\nimport Sub12LTE108t39\nimport Sub13LTE108t75\nimport Sub14LTE108t111\n\n%default total\n\n\n-- 示すのに、整礎帰納法を使っている\nmakeLimitedDivSeq :\n ((z : Nat) -> ((FirstLimited . B.allDivSeq) z -> (AllLimited . B.allDivSeq) z))\n -> (n : Nat) -> (FirstLimited . B.allDivSeq) n\nmakeLimitedDivSeq firstToAll n = wfInd {P=(\\z=>(FirstLimited . B.allDivSeq) z)} {rel=LT'} (step firstToAll) n where\n step : ((z : Nat) -> ((FirstLimited . B.allDivSeq) z -> (AllLimited . B.allDivSeq) z))\n -> (x : Nat) -> ((y : Nat) -> LT' y x -> (FirstLimited . B.allDivSeq) y)\n -> (FirstLimited . B.allDivSeq) x\n step _ Z _ = IsFirstLimited10 -- 6*<0>+3 = 3\n step firstToAll (S x) rs with (mod3 x)\n -- 0 mod 9\n step firstToAll (S (j + j + j)) rs | ThreeZero with (parity j)\n step firstToAll (S ((Z+Z) + (Z+Z) + (Z+Z))) rs | ThreeZero | Even = IsFirstLimited01 -- 6*<1>+3 = 9\n step firstToAll (S (((S k)+(S k)) + ((S k)+(S k)) + ((S k)+(S k)))) rs | ThreeZero | Even with (parity k)\n step firstToAll (S (((S (l+l))+(S (l+l))) + ((S (l+l))+(S (l+l))) + ((S (l+l))+(S (l+l))))) rs | ThreeZero | Even | Even\n = (IsFirstLimited02 l . firstToAll l) (rs l $ lteToLt' $ lte72t45 l)\n step firstToAll (S (((S (S (l+l)))+(S (S (l+l)))) + ((S (S (l+l)))+(S (S (l+l)))) + ((S (S (l+l)))+(S (S (l+l)))))) rs | ThreeZero | Even | Odd with (mod3 l)\n step firstToAll (S (((S (S ((m+m+m)+(m+m+m))))+(S (S ((m+m+m)+(m+m+m))))) + ((S (S ((m+m+m)+(m+m+m))))+(S (S ((m+m+m)+(m+m+m))))) + ((S (S ((m+m+m)+(m+m+m))))+(S (S ((m+m+m)+(m+m+m))))))) rs | ThreeZero | Even | Odd | ThreeZero\n = (IsFirstLimited03 m . firstToAll (m+m)) (rs (m+m) $ lteToLt' $ lte216t81 m)\n step firstToAll (S (((S (S ((S (m+m+m))+(S (m+m+m)))))+(S (S ((S (m+m+m))+(S (m+m+m)))))) + ((S (S ((S (m+m+m))+(S (m+m+m)))))+(S (S ((S (m+m+m))+(S (m+m+m)))))) + ((S (S ((S (m+m+m))+(S (m+m+m)))))+(S (S ((S (m+m+m))+(S (m+m+m)))))))) rs | ThreeZero | Even | Odd | ThreeOne\n = (IsFirstLimited04 m . firstToAll (S ((m+m)+(m+m)))) (rs (S ((m+m)+(m+m))) $ lteToLt' $ lte216t153 m)\n step firstToAll (S (((S (S ((S (S (m+m+m)))+(S (S (m+m+m))))))+(S (S ((S (S (m+m+m)))+(S (S (m+m+m))))))) + ((S (S ((S (S (m+m+m)))+(S (S (m+m+m))))))+(S (S ((S (S (m+m+m)))+(S (S (m+m+m))))))) + ((S (S ((S (S (m+m+m)))+(S (S (m+m+m))))))+(S (S ((S (S (m+m+m)))+(S (S (m+m+m))))))))) rs | ThreeZero | Even | Odd | ThreeTwo\n = (IsFirstLimited05 m . firstToAll (S (S (S (S (S (S (S (m+m+m+m)+(m+m+m+m))))))))) (rs (S (S (S (S (S (S (S (m+m+m+m)+(m+m+m+m)))))))) $ lteToLt' $ lte216t225 m)\n step firstToAll (S ((S (k+k)) + (S (k+k)) + (S (k+k)))) rs | ThreeZero | Odd with (mod3 k)\n step firstToAll (S ((S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l))))) rs | ThreeZero | Odd | ThreeZero\n = (IsFirstLimited06 l . firstToAll (S (S (S (l+l+l+l)+(l+l+l+l)+(l+l+l+l)+(l+l+l+l))))) (rs (S (S (S (l+l+l+l)+(l+l+l+l)+(l+l+l+l)+(l+l+l+l)))) $ lteToLt' $ lte108t27 l)\n step firstToAll (S ((S ((S (l+l+l))+(S (l+l+l)))) + (S ((S (l+l+l))+(S (l+l+l)))) + (S ((S (l+l+l))+(S (l+l+l)))))) rs | ThreeZero | Odd | ThreeOne\n = (IsFirstLimited07 l . firstToAll (S (S (S (S (l+l+l+l)+(l+l+l+l)))))) (rs (S (S (S (S (l+l+l+l)+(l+l+l+l))))) $ lteToLt' $ lte108t63 l)\n step firstToAll (S ((S ((S (S (l+l+l)))+(S (S (l+l+l))))) + (S ((S (S (l+l+l)))+(S (S (l+l+l))))) + (S ((S (S (l+l+l)))+(S (S (l+l+l))))))) rs | ThreeZero | Odd | ThreeTwo\n = (IsFirstLimited08 l . firstToAll (S (S (S ((l+l)+(l+l)))))) (rs (S (S (S ((l+l)+(l+l))))) $ lteToLt' $ lte108t99 l)\n -- 6 mod 9\n step firstToAll (S (S (j + j + j))) rs | ThreeOne\n = (IsFirstLimited09 j . firstToAll j) (rs j $ lteToLt' $ lte18t15 j)\n -- 3 mod 9\n step firstToAll (S (S (S (j + j + j)))) rs | ThreeTwo with (parity j)\n step firstToAll (S (S (S ( (k+k) + (k+k) + (k+k))))) rs | ThreeTwo | Even\n = (IsFirstLimited11 k . firstToAll k) (rs k $ lteToLt' $ lte36t21 k)\n step firstToAll (S (S (S ((S (k+k)) + (S (k+k)) + (S (k+k)))))) rs | ThreeTwo | Odd with (mod3 k)\n step firstToAll (S (S (S ((S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l))))))) rs | ThreeTwo | Odd | ThreeZero\n = (IsFirstLimited12 l . firstToAll (l+l)) (rs (l+l) $ lteToLt' $ lte108t39 l)\n step firstToAll (S (S (S ((S ((S (l+l+l))+(S (l+l+l)))) + (S ((S (l+l+l))+(S (l+l+l)))) + (S ((S (l+l+l))+(S (l+l+l)))))))) rs | ThreeTwo | Odd | ThreeOne\n = (IsFirstLimited13 l . firstToAll (S ((l+l)+(l+l)))) (rs (S ((l+l)+(l+l))) $ lteToLt' $ lte108t75 l)\n step firstToAll (S (S (S ((S ((S (S (l+l+l)))+(S (S (l+l+l))))) + (S ((S (S (l+l+l)))+(S (S (l+l+l))))) + (S ((S (S (l+l+l)))+(S (S (l+l+l))))))))) rs | ThreeTwo | Odd | ThreeTwo\n = (IsFirstLimited14 l . firstToAll (S (S (S (S (S (S (S (l+l+l+l)+(l+l+l+l))))))))) (rs (S (S (S (S (S (S (S (l+l+l+l)+(l+l+l+l)))))))) $ lteToLt' $ lte108t111 l)\n\n-- 十分条件\nfirstToAll :\n (z : Nat) -> ((FirstLimited . B.allDivSeq) z -> (AllLimited . B.allDivSeq) z)\nfirstToAll z first =\n let\n suff2_1 = IsFirstLimitedSuff2_1 z first\n suff2_2 = IsFirstLimitedSuff2_2 z first\n suff2_3 = IsFirstLimitedSuff2_3 z first\n suff2_4 = IsFirstLimitedSuff2_4 z first\n suff2_5 = IsFirstLimitedSuff2_5 z first\n suff2_6 = IsFirstLimitedSuff2_6 z first\n all2 = IsAllLimited02 z suff2_1 suff2_2 suff2_3 suff2_4 suff2_5 suff2_6\n suff3_1 = IsFirstLimitedSuff3_1 z first\n suff3_2 = IsFirstLimitedSuff3_2 z first\n suff3_3 = IsFirstLimitedSuff3_3 z first\n suff3_4 = IsFirstLimitedSuff3_4 z first\n suff3_5 = IsFirstLimitedSuff3_5 z first\n suff3_6 = IsFirstLimitedSuff3_6 z first\n all3 = IsAllLimited03 z suff3_1 suff3_2 suff3_3 suff3_4 suff3_5 suff3_6\n suff4_1 = IsFirstLimitedSuff4_1 z first\n suff4_2 = IsFirstLimitedSuff4_2 z first\n suff4_3 = IsFirstLimitedSuff4_3 z first\n suff4_4 = IsFirstLimitedSuff4_4 z first\n suff4_5 = IsFirstLimitedSuff4_5 z first\n all4 = IsAllLimited04 z suff4_1 suff4_2 suff4_3 suff4_4 suff4_5\n suff5_1 = IsFirstLimitedSuff5_1 z first\n suff5_2 = IsFirstLimitedSuff5_2 z first\n suff5_3 = IsFirstLimitedSuff5_3 z first\n suff5_4 = IsFirstLimitedSuff5_4 z first\n suff5_5 = IsFirstLimitedSuff5_5 z first\n suff5_6 = IsFirstLimitedSuff5_6 z first\n all5 = IsAllLimited05 z suff5_1 suff5_2 suff5_3 suff5_4 suff5_5 suff5_6\n suff6_1 = IsFirstLimitedSuff6_1 z first\n suff6_2 = IsFirstLimitedSuff6_2 z first\n suff6_3 = IsFirstLimitedSuff6_3 z first\n suff6_4 = IsFirstLimitedSuff6_4 z first\n suff6_5 = IsFirstLimitedSuff6_5 z first\n suff6_6 = IsFirstLimitedSuff6_6 z first\n all6 = IsAllLimited06 z suff6_1 suff6_2 suff6_3 suff6_4 suff6_5 suff6_6\n suff7_1 = IsFirstLimitedSuff7_1 z first\n suff7_2 = IsFirstLimitedSuff7_2 z first\n suff7_3 = IsFirstLimitedSuff7_3 z first\n suff7_4 = IsFirstLimitedSuff7_4 z first\n suff7_5 = IsFirstLimitedSuff7_5 z first\n suff7_6 = IsFirstLimitedSuff7_6 z first\n suff7_7 = IsFirstLimitedSuff7_7 z first\n all7 = IsAllLimited07 z suff7_1 suff7_2 suff7_3 suff7_4 suff7_5 suff7_6 suff7_7\n suff8_1 = IsFirstLimitedSuff8_1 z first\n suff8_2 = IsFirstLimitedSuff8_2 z first\n suff8_3 = IsFirstLimitedSuff8_3 z first\n suff8_4 = IsFirstLimitedSuff8_4 z first\n suff8_5 = IsFirstLimitedSuff8_5 z first\n suff8_6 = IsFirstLimitedSuff8_6 z first\n all8 = IsAllLimited08 z suff8_1 suff8_2 suff8_3 suff8_4 suff8_5 suff8_6\n in IsAllLimited01 z IsAllLimited00 all2 all3 all4 all5 all6 all7 all8\n\n-- 最終的な定理\nlimitedDivSeq : (n : Nat) -> (FirstLimited . B.allDivSeq) n\nlimitedDivSeq = makeLimitedDivSeq firstToAll\n\n\n\n", "meta": {"hexsha": "27879d2f5407f6cbae4bdbcde9027e2edccf4303", "size": 8478, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program3/ProofColDivSeqMain.idr", "max_stars_repo_name": "righ1113/collatzProof_DivSeq", "max_stars_repo_head_hexsha": "eef9da457fe77f0b58fb4407ab128d38ada9071e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "program3/ProofColDivSeqMain.idr", "max_issues_repo_name": "righ1113/collatzProof_DivSeq", "max_issues_repo_head_hexsha": "eef9da457fe77f0b58fb4407ab128d38ada9071e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2019-01-26T12:59:21.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-19T07:02:00.000Z", "max_forks_repo_path": "program3/ProofColDivSeqMain.idr", "max_forks_repo_name": "righ1113/collatzProof_DivSeq", "max_forks_repo_head_hexsha": "eef9da457fe77f0b58fb4407ab128d38ada9071e", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 63.2686567164, "max_line_length": 333, "alphanum_fraction": 0.5576786978, "num_tokens": 3356, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424256566558, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.5388913755007219}} {"text": "import Effects\nimport Effect.StdIO\nimport Effect.State\n\n-- Local Variables:\n-- idris-load-packages: (\"contrib\" \"prelude\" \"effects\" \"base\")\n-- End:\n\n-- this is mostly code from the tutorial on effects\nhello : Eff () [STDIO]\nhello = putStrLn \"hello world!\"\n\n\ndata BTree a = Leaf\n | Node (BTree a) a (BTree a)\n\ntestTree : BTree String\ntestTree = Node (Node Leaf \"Jim\" Leaf)\n \"Fred\"\n (Node (Node Leaf \"Alice\" Leaf)\n \"Sheila\"\n (Node Leaf \"Bob\" Leaf))\n\n\ntreeTagAux : BTree a -> Eff (BTree (Int,a)) [STATE Int]\ntreeTagAux Leaf = pure Leaf\ntreeTagAux (Node b1 x b2) = do\n b1' <- treeTagAux b1\n i <- get\n put (i + 1)\n b2' <- treeTagAux b2\n pure (Node b1' (i,x) b2')\n\n-- So one of the things that I find super fascinating are the dependent effects\n-- obviously such things are needed for the purpose of having things like state that\n-- contain dependent types, but it's also just really neat and makes, at least to me,\n-- more sense than the simple-type-theory style monadic approach to semantics\n-- The way I think I see effects in Idris is that you're essentially creating an internal\n-- language of an effect and then you need to give a semantics of the effect in terms of\n-- the types that support the operation and *that* is what the handlers are. \n\n-- Let's try making a reader effect, one that has an ask and local operation\n\ndata Reader : Effect where\n Ask : Reader a a (\\x => a)\n Local : (a -> b) -> Reader c b f -> Reader c a (\\x => a)\n \n-- I think that's the right signature, it type checks at least. It's a little more complicated\n-- than a normal reader because there could be some kind of dependent type in the reader state\n-- such as, I don't know, an environment that's indexed by its length?\n\n-- so what we're trying to do here is \n-- run the \"local\" effect with the resource (f r)\n-- get back the value, in this case of type 't' from the local effect action\n-- then restore the original state by passing that to the original continuation\n-- now where I'm getting stuck, I think, is that, to me, this should clearly be something\n-- kinda like\n-- handle (f r) loc (\\t _ => k t r)\n\n rhs : (m : Type -> Type) -> (r : res) -> (act : Reader t res resk) -> (k : (x : t) -> resk x -> m a) -> m a\n rhs m r Ask k = k r r\n rhs m r (Local f loc) k = rhs m (f r) loc (\\ t,_ => k t r) -- Why did this work but recursion in handle didn't???\n\n READER : Type -> EFFECT\n READER t = MkEff t Reader -- yeah this part is just like state aren't I clever \n\ninstance Handler Reader m where\n handle r act k = rhs m r act k\n\n{- \ninstance Handler Reader m where\n handle r Ask k = k r r\n handle r (Local f loc) k = handle (f r) loc ?f\n-}\n", "meta": {"hexsha": "ab09d7c318f7ca5229faa155037f635d9b244cad", "size": 2804, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "effectful.idr", "max_stars_repo_name": "clarissalittler/idris-practice", "max_stars_repo_head_hexsha": "e307a93fa4ab7bce9f6cf7fef9973c398b3d65ea", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "effectful.idr", "max_issues_repo_name": "clarissalittler/idris-practice", "max_issues_repo_head_hexsha": "e307a93fa4ab7bce9f6cf7fef9973c398b3d65ea", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "effectful.idr", "max_forks_repo_name": "clarissalittler/idris-practice", "max_forks_repo_head_hexsha": "e307a93fa4ab7bce9f6cf7fef9973c398b3d65ea", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.3866666667, "max_line_length": 114, "alphanum_fraction": 0.6394436519, "num_tokens": 749, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5388554169097682}} {"text": "plus_commutes : (n, m : Nat) -> plus n m = plus m n\nplus_assoc : (n, m, p : Nat) -> plus n (plus m p) = plus (plus n m) p\n\n\n", "meta": {"hexsha": "6b588f9d3729160de92645b7289519092d48b7d6", "size": 124, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/samples/proofs/plusprops.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/samples/proofs/plusprops.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/samples/proofs/plusprops.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8, "max_line_length": 69, "alphanum_fraction": 0.5483870968, "num_tokens": 49, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8757869851639066, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.5386859385933485}} {"text": "> module SimpleProb.MonadicOperations\n\n> import Data.List\n> import Data.List.Quantifiers\n> import Syntax.PreorderReasoning\n\n> import SimpleProb.SimpleProb\n> import SimpleProb.BasicOperations\n> import SimpleProb.BasicProperties\n> import NonNegRational.NonNegRational\n> import NonNegRational.BasicOperations\n> import NonNegRational.BasicProperties\n> import Nat.Positive\n> import Fraction.Normal\n> import Num.Refinements\n> import Fun.Operations\n> import List.Operations\n> import List.Properties\n> import Sigma.Sigma\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n* |SimpleProb| is a functor:\n\n> |||\n> fmap : {A, B : Type} -> (A -> B) -> SimpleProb A -> SimpleProb B\n> fmap f (MkSimpleProb aps s1p) = MkSimpleProb aps' s1p' where\n> aps' : List (B, NonNegRational)\n> aps' = map (cross f id) aps\n> s1p' : sumMapSnd aps' = 1\n> s1p' = trans s1 (trans s2 s3) where\n> s1 : sumMapSnd aps' = sum (map snd aps')\n> s1 = Refl\n> s2 : sum (map snd aps') = sum (map snd aps)\n> s2 = cong (mapSndMapCrossAnyIdLemma f aps)\n> s3 : sum (map snd aps) = 1\n> s3 = s1p\n> \n> {- \n> s1p' = ( sumMapSnd aps' )\n> ={ Refl }=\n> ( sum (map snd aps') )\n> ={ cong (mapSndMapCrossAnyIdLemma f aps) }=\n> ( sum (map snd aps) )\n> ={ Refl }=\n> ( sumMapSnd aps )\n> ={ s1p }=\n> ( 1 )\n> QED\n> -}\n\n* |SimpleProb| is a monad:\n\n> |||\n> ret : {A : Type} -> A -> SimpleProb A\n> ret {A} a = MkSimpleProb [(a, 1)] (sumMapSndSingletonLemma a 1)\n\n> |||\n> bind : {A, B : Type} -> SimpleProb A -> (A -> SimpleProb B) -> SimpleProb B\n> bind {A} {B} (MkSimpleProb aps s1p) f = MkSimpleProb bps' s1p' where\n> f' : A -> List (B, NonNegRational)\n> f' a = toList (f a)\n> s1ps' : (a : A) -> sumMapSnd (f' a) = 1\n> s1ps' a = toListLemma (f a)\n> bps' : List (B, NonNegRational)\n> bps' = mvMult aps f' \n> s1p' : sumMapSnd bps' = 1\n> s1p' = ( sumMapSnd bps' )\n> ={ Refl }=\n> ( sumMapSnd (mvMult aps f') )\n> ={ mvMultLemma aps f' s1ps' }=\n> ( sumMapSnd aps )\n> ={ s1p }=\n> ( 1 )\n> QED\n\n\n* |SimpleProb| is a container monad:\n\n> |||\n> Elem : {A : Type} -> A -> SimpleProb A -> Type\n> Elem a sp = Elem a (support sp)\n\n> |||\n> NonEmpty : {A : Type} -> SimpleProb A -> Type\n> NonEmpty sp = List.Operations.NonEmpty (support sp) \n\n> |||\n> All : {A : Type} -> (P : A -> Type) -> SimpleProb A -> Type\n> All P sp = All P (support sp) \n\n> ||| Tagging\n> tagElem : {A : Type} -> (sp : SimpleProb A) -> SimpleProb (Sigma A (\\ a => a `Elem` sp))\n> tagElem sp = MkSimpleProb aps' s1p' where\n> ssp : List A\n> ssp = support sp\n> psp : List NonNegRational\n> psp = probs sp\n> as' : List (Sigma A (\\ a => a `Elem` sp))\n> as' = List.Operations.tagElem ssp\n> aps' : List (Sigma A (\\ a => a `Elem` sp), NonNegRational)\n> aps' = zip as' psp\n> s1p' : sumMapSnd aps' = 1\n> s1p' = trans s1 (trans s7 s8) where\n> s1 : sumMapSnd aps' = sum (snd (unzip aps'))\n> s1 = sumMapSndUnzipLemma aps'\n> s2 : length as' = length ssp\n> s2 = tagElemPreservesLength ssp\n> s3 : length ssp = length psp\n> s3 = lengthSupportProbsLemma sp\n> s4 : length as' = length psp\n> s4 = trans s2 s3\n> s5 : unzip (zip as' psp) = (as', psp)\n> s5 = unzipZipLemma as' psp s4\n> s6 : snd (unzip aps') = psp\n> s6 = cong {f = snd} s5\n> s7 : sum (snd (unzip aps')) = sum psp\n> s7 = cong {f = sum} s6\n> s8 : sum psp = 1\n> s8 = sumProbsLemma sp\n\n\n> {-\n\n> ---}\n", "meta": {"hexsha": "4e54fd382940a5c4193633650ecd11d79f071e5c", "size": 3569, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SimpleProb/MonadicOperations.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SimpleProb/MonadicOperations.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SimpleProb/MonadicOperations.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.6666666667, "max_line_length": 92, "alphanum_fraction": 0.5589801065, "num_tokens": 1340, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5386819880314554}} {"text": "= The First Tale\n\n> module WhoStoleTheTarts.TheFirstTale\n>\n> %access export\n> %default total\n>\n> %hide Prelude.Pairs.DPair.fst\n\n\nSomeone stole the jam. Our job is to figure out who the thief was.\n\n== Suspects\n\nWe know it was one of the\n\n- March Hare,\n\n> data MarchHare\n\n- Mad Hatter, or\n\n> data MadHatter\n\n- Dormouse\n\n> data Dormouse\n\n... and that they worked alone.\n\n> SomeoneStoleTheJam : Type\n> SomeoneStoleTheJam = Either ( MarchHare, Not MadHatter, Not Dormouse)\n> $ Either (Not MarchHare, MadHatter, Not Dormouse)\n> (Not MarchHare, Not MadHatter, Dormouse)\n\n\n== Statements\n\nThe March Hare claims,\n
\nI never stole the jam!\n
\n\n> MarchHareStatement : (truth : Bool) -> Type\n> MarchHareStatement False = MarchHare\n> MarchHareStatement True = Not MarchHare\n\nAccording to the Mad Hatter,\n
\nOne of us stole it, but it wasn't me!\n
\n\n> MadHatterStatement : (truth : Bool) -> Type\n> MadHatterStatement False = ( MadHatter, Not MarchHare, Not Dormouse)\n> MadHatterStatement True = (Not MadHatter, Either MarchHare Dormouse)\n\nAs per the Dormouse,\n
\nAt least one of them (spoke the truth).\n
\n\n> DormouseStatement : (truth : Bool) -> Type\n> DormouseStatement False = (MarchHareStatement False, MadHatterStatement False)\n> DormouseStatement True = Not (MarchHareStatement False, MadHatterStatement False)\n\n\n== Revelation\n\nWe're also given a revelation:\n\n> Revelation : Type\n\nThe March Hare and the Dormouse were not both speaking the truth, i.e. either\n\n- ... the March Hare spoke the truth and the Dormouse did not\n\n> Revelation = Either (MarchHareStatement True, DormouseStatement False)\n\n- ... or the March Hare did not speak the truth and the Dormouse did.\n\n> (MarchHareStatement False, DormouseStatement True)\n\n\n== Conclusion\n\nGiven the [statements](#statements) above and the [revelation](#revelation),\n\n> Thief : SomeoneStoleTheJam -> Revelation\n\n... we can conclude the March Hare stole the jam.\n\n> -> (MarchHare, Not MadHatter, Not Dormouse)\n\nThe first clause is a simple pattern match.\n\n> Thief (Left marchHare) _ = marchHare\n\nFrom the revelation it follows that if the March Hare spoke the truth,\nthen the Dormouse lied. If the March Hare spoke the truth, then they\ndidn't steal the jam. But if the Dormouse lied, then so did the March Hare\nand is guilty *BWOC*.\n\n> Thief _ (Left (itWas,(them,_))) = absurd (itWas them)\n\nIf the March Hare lied, then they stole the jam.\n\n> Thief (Left (_,did,it)) (Right (marchHare,_)) = (marchHare,did,it)\n\nIf we assume the Mad Hatter stole jam and the March Hare lied,\nthen the March Hare did it *BWOC*.\n\n> Thief (Right (Left (itWas,_))) (Right (them,_)) = absurd (itWas them)\n\nAssume the Dormouse did it and lied. If the Dormouse lied,\nthen the March Hare lied, and therefore stole the jam.\n\n> Thief (Right (Right (itWas,_))) (Left (_,(them,_))) = absurd (itWas them)\n\nAssume the Dormouse did it and the March Hare lied.\nIf the March Hare lied then they are guilty.\n\n> Thief (Right (Right (itWas,_))) (Right (them,_)) = absurd (itWas them)\n\n∎\n", "meta": {"hexsha": "2d4f4ab681e851c9640755632f6712a132dcbca8", "size": 3247, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/WhoStoleTheTarts/TheFirstTale.lidr", "max_stars_repo_name": "yurrriq/alice-in-puzzleland", "max_stars_repo_head_hexsha": "c7f7c056c3de1f3ba5046bf62806f124f5bcb620", "max_stars_repo_licenses": ["WTFPL"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-25T00:05:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-25T00:05:29.000Z", "max_issues_repo_path": "src/WhoStoleTheTarts/TheFirstTale.lidr", "max_issues_repo_name": "yurrriq/alice-in-puzzleland", "max_issues_repo_head_hexsha": "c7f7c056c3de1f3ba5046bf62806f124f5bcb620", "max_issues_repo_licenses": ["WTFPL"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/WhoStoleTheTarts/TheFirstTale.lidr", "max_forks_repo_name": "yurrriq/alice-in-puzzleland", "max_forks_repo_head_hexsha": "c7f7c056c3de1f3ba5046bf62806f124f5bcb620", "max_forks_repo_licenses": ["WTFPL"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-09-25T00:05:31.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-25T00:05:31.000Z", "avg_line_length": 25.976, "max_line_length": 84, "alphanum_fraction": 0.6870957807, "num_tokens": 878, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.5383905151194651}} {"text": "module RegExp.Types\n\nimport Data.List\nimport Decidable.Equality\n\n||| A regular expression specification.\npublic export\ndata RegExp : (0 a : Type) -> Type where\n ||| Denotes the empty set\n Null : RegExp a\n ||| Denotes the empty string\n Empty : RegExp a\n ||| Denotes a single literal character\n Lit : a -> RegExp a\n ||| Denotes concatenation\n Cat : RegExp a -> RegExp a -> RegExp a\n ||| Denotes disjunction (OR)\n Disj : RegExp a -> RegExp a -> RegExp a\n ||| Denotes conjunction (AND)\n Conj : RegExp a -> RegExp a -> RegExp a\n ||| Denotes the Kleene star\n Star : RegExp a -> RegExp a\n\n||| The property of a regular expression matching an input string.\npublic export\ndata Matches: RegExp a -> List a -> Type where\n ||| Rule: `[]` is in `Empty`\n InEmpty : Matches Empty []\n ||| Rule: `[x]` is in `Lit x`\n InLit : {x : a} -> Matches (Lit x) [x]\n ||| Rule: If `xs` is in regular expressions `r` and `ys` is in regular expression `s`, then\n ||| `xs ++ ys` is in `Cat r s`\n InCat : {xs : List a} ->\n {ys : List a} ->\n {zs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n (p : zs = xs ++ ys) ->\n Matches r xs ->\n Matches s ys ->\n Matches (Cat r s) zs\n ||| Rule: If `xs` is in regular expression `r`, then `xs` is in `Disj r _` (i.e. left side)\n InDisjL : {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches r xs ->\n Matches (Disj r s) xs\n ||| Rule: If `xs` is in regular expression `s`, then `xs` is in `Disj _ s` (i.e. right side)\n InDisjR : {xs : List a} ->\n {r : RegExp a} ->\n {s: RegExp a} ->\n Matches s xs ->\n Matches (Disj r s) xs\n ||| Rule: If `xs` is in regular expressions `r` and `s`, then `xs` is in `Conj r s`\n InConj : {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches r xs ->\n Matches s xs ->\n Matches (Conj r s) xs\n ||| Rule: For all regular expression `r`, the empty string is in `Star r`.\n InStarZ : {r: RegExp a} ->\n Matches (Star r) []\n ||| Rule: If `xs` is in regular expression `r` and `ys` is in `Star r`, then `xs ++ ys` is also\n ||| in `Star r`.\n InStarS : {xs : List a} ->\n {ys : List a} ->\n {zs : List a} ->\n {r : RegExp a} ->\n (p : zs = xs ++ ys) ->\n Matches r xs ->\n Matches (Star r) ys ->\n Matches (Star r) (xs ++ ys)\n\nexport\nUninhabited (Matches Null xs) where\n uninhabited _ impossible\n\nexport\nUninhabited (Matches Empty (x::xs)) where\n uninhabited _ impossible\n\nexport\nUninhabited (Matches (Lit x) []) where\n uninhabited _ impossible\n\n----------------------------------------------------------------------------------------------------\n-- Interface Implementations --\n----------------------------------------------------------------------------------------------------\n\nexport\nDecEq a => DecEq (RegExp a) where\n decEq Null Null = Yes Refl\n decEq (Lit x) (Lit y) with (decEq x y)\n decEq (Lit x) (Lit x) | (Yes Refl) = Yes Refl\n decEq (Lit x) (Lit y) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n decEq (Cat r s) (Cat t u) with (decEq r t)\n decEq (Cat r s) (Cat r u) | (Yes Refl) with (decEq s u)\n decEq (Cat r s) (Cat r s) | (Yes Refl) | (Yes Refl) = Yes Refl\n decEq (Cat r s) (Cat r u) | (Yes Refl) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n decEq (Cat r s) (Cat t u) | (No contra) = No \\p => case p of\n Refl => contra Refl\n decEq (Disj r s) (Disj t u) with (decEq r t)\n decEq (Disj r s) (Disj r u) | (Yes Refl) with (decEq s u)\n decEq (Disj r s) (Disj r s) | (Yes Refl) | (Yes Refl) = Yes Refl\n decEq (Disj r s) (Disj r u) | (Yes Refl) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n decEq (Disj r s) (Disj t u) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n decEq (Conj r s) (Conj t u) with (decEq r t)\n decEq (Conj r s) (Conj r u) | (Yes Refl) with (decEq s u)\n decEq (Conj r s) (Conj r s) | (Yes Refl) | (Yes Refl) = Yes Refl\n decEq (Conj r s) (Conj r u) | (Yes Refl) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n decEq (Conj r s) (Conj t u) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n decEq (Star r) (Star s) with (decEq r s)\n decEq (Star r) (Star r) | (Yes Refl) = Yes Refl\n decEq (Star r) (Star s) | (No contra) = No $ \\p => case p of\n Refl => contra Refl\n -- This is plain old structural equality, so I figure it's better to use a `believe_me` catch-all\n -- than to write out a million trivial `No` cases.\n decEq _ _ = No believe_me\n\n----------------------------------------------------------------------------------------------------\n-- Proofs --\n----------------------------------------------------------------------------------------------------\n\n||| Proof that if the result of a concatenation is empty, then both inputs are empty\nappendOutputNil : {xs : List a} ->\n {ys : List a} ->\n xs ++ ys = [] ->\n (xs = [], ys = [])\nappendOutputNil {xs=[]} {ys=[]} p = (Refl, Refl)\nappendOutputNil {xs=[]} {ys=y::ys} p = absurd p\nappendOutputNil {xs=(x::xs)} {ys} p = absurd p\n\n||| Proof that if an `Empty` regular expression matches a string, then the string is empty.\nexport\nemptyMatch_implies_emptyList : Matches Empty xs -> xs = []\nemptyMatch_implies_emptyList InEmpty = Refl\n\n||| Proof that for all `Lit x` matches, `x` is equal to the head of the string.\nexport\nlitMatches_implies_headEqual : DecEq a =>\n {x : a} ->\n {y : a} ->\n {ys : List a} ->\n Matches (Lit x) (y::ys) ->\n x = y\nlitMatches_implies_headEqual {x} {y=x} {ys=[]} InLit = Refl\n\n||| Proof that if `Lit` matches `x::xs`, then `xs = []`\nexport\nlitMatchesCons_implies_restEmpty : Matches (Lit x) (x::xs) -> xs = []\nlitMatchesCons_implies_restEmpty InLit = Refl\n\n||| Proof that if the `Cat r s` matches empty, then both `r` and `s` also match empty\nexport\ncatNotEmpty : {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (Cat r s) [] ->\n (Matches r [], Matches s [])\ncatNotEmpty (InCat p r s) with (appendOutputNil $ sym p)\n catNotEmpty (InCat p r s) | (Refl, Refl) = (r, s)\n\n||| Proof that if `Disj r s` matches empty, then at least one of `r` and `s` matches empty\nexport\ndisjNotEmpty : {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (Disj r s) [] ->\n Either (Matches r []) (Matches s [])\ndisjNotEmpty (InDisjL r) = Left r\ndisjNotEmpty (InDisjR r) = Right r\n\n||| Proof that if the `Conj r s` matches empty, then both `r` and `s` also match empty\nexport\nconjNotEmpty : {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (Conj r s) [] ->\n (Matches r [], Matches s [])\nconjNotEmpty (InConj r s) = (r, s)\n", "meta": {"hexsha": "725e922237231f5cae699b20e8feea681090f219", "size": 7708, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/RegExp/Types.idr", "max_stars_repo_name": "polendri/idris-regex", "max_stars_repo_head_hexsha": "72d5f1c05d34f3119b8be808a3e27b93a526e07a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-01T04:46:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T04:46:44.000Z", "max_issues_repo_path": "src/RegExp/Types.idr", "max_issues_repo_name": "polendri/idris-regex", "max_issues_repo_head_hexsha": "72d5f1c05d34f3119b8be808a3e27b93a526e07a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-06T13:44:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T01:16:42.000Z", "max_forks_repo_path": "src/RegExp/Types.idr", "max_forks_repo_name": "polendri/idris-regexp", "max_forks_repo_head_hexsha": "72d5f1c05d34f3119b8be808a3e27b93a526e07a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.6648648649, "max_line_length": 100, "alphanum_fraction": 0.4692527244, "num_tokens": 2151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.5372906916330557}} {"text": "Ty : Type\nTy = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty : Ty\nempty = \\ _, empty, _ => empty\n\narr : Ty -> Ty -> Ty\narr = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon : Type\nCon = (Con : Type)\n ->(nil : Con)\n ->(snoc : Con -> Ty -> Con)\n -> Con\n\nnil : Con\nnil = \\ con, nil, snoc => nil\n\nsnoc : Con -> Ty -> Con\nsnoc = \\ g, a, con, nil, snoc => snoc (g con nil snoc) a\n\nVar : Con -> Ty -> Type\nVar = \\ g, a =>\n (Var : Con -> Ty -> Type)\n -> (vz : (g : _)-> (a : _) -> Var (snoc g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var g a -> Var (snoc g b) a)\n -> Var g a\n\nvz : {g : _}-> {a : _} -> Var (snoc g a) a\nvz = \\ var, vz, vs => vz _ _\n\nvs : {g : _} -> {B : _} -> {a : _} -> Var g a -> Var (snoc g B) a\nvs = \\ x, var, vz, vs => vs _ _ _ (x var vz vs)\n\nTm : Con -> Ty -> Type\nTm = \\ g, a =>\n (Tm : Con -> Ty -> Type)\n -> (var : (g : _) -> (a : _) -> Var g a -> Tm g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm (snoc g a) B -> Tm g (arr a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm g (arr a B) -> Tm g a -> Tm g B)\n -> Tm g a\n\nvar : {g : _} -> {a : _} -> Var g a -> Tm g a\nvar = \\ x, tm, var, lam, app => var _ _ x\n\nlam : {g : _} -> {a : _} -> {B : _} -> Tm (snoc g a) B -> Tm g (arr a B)\nlam = \\ t, tm, var, lam, app => lam _ _ _ (t tm var lam app)\n\napp : {g:_}->{a:_}->{B:_} -> Tm g (arr a B) -> Tm g a -> Tm g B\napp = \\ t, u, tm, var, lam, app => app _ _ _ (t tm var lam app) (u tm var lam app)\n\nv0 : {g:_}->{a:_} -> Tm (snoc g a) a\nv0 = var vz\n\nv1 : {g:_}->{a:_}-> {B:_}-> Tm (snoc (snoc g a) B) a\nv1 = var (vs vz)\n\nv2 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm (snoc (snoc (snoc g a) B) C) a\nv2 = var (vs (vs vz))\n\nv3 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm (snoc (snoc (snoc (snoc g a) B) C) D) a\nv3 = var (vs (vs (vs vz)))\n\nv4 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm (snoc (snoc (snoc (snoc (snoc g a) B) C) D) E) a\nv4 = var (vs (vs (vs (vs vz))))\n\ntest : {g:_}-> {a:_} -> Tm g (arr (arr a a) (arr a a))\ntest = lam (lam (app v1 (app v1 (app v1 (app v1 (app v1 (app v1 v0)))))))\nTy1 : Type\nTy1 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty1 : Ty1\nempty1 = \\ _, empty, _ => empty\n\narr1 : Ty1 -> Ty1 -> Ty1\narr1 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon1 : Type\nCon1 = (Con1 : Type)\n ->(nil : Con1)\n ->(snoc : Con1 -> Ty1 -> Con1)\n -> Con1\n\nnil1 : Con1\nnil1 = \\ con, nil1, snoc => nil1\n\nsnoc1 : Con1 -> Ty1 -> Con1\nsnoc1 = \\ g, a, con, nil1, snoc1 => snoc1 (g con nil1 snoc1) a\n\nVar1 : Con1 -> Ty1 -> Type\nVar1 = \\ g, a =>\n (Var1 : Con1 -> Ty1 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var1 (snoc1 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var1 g a -> Var1 (snoc1 g b) a)\n -> Var1 g a\n\nvz1 : {g : _}-> {a : _} -> Var1 (snoc1 g a) a\nvz1 = \\ var, vz1, vs => vz1 _ _\n\nvs1 : {g : _} -> {B : _} -> {a : _} -> Var1 g a -> Var1 (snoc1 g B) a\nvs1 = \\ x, var, vz1, vs1 => vs1 _ _ _ (x var vz1 vs1)\n\nTm1 : Con1 -> Ty1 -> Type\nTm1 = \\ g, a =>\n (Tm1 : Con1 -> Ty1 -> Type)\n -> (var : (g : _) -> (a : _) -> Var1 g a -> Tm1 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm1 (snoc1 g a) B -> Tm1 g (arr1 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm1 g (arr1 a B) -> Tm1 g a -> Tm1 g B)\n -> Tm1 g a\n\nvar1 : {g : _} -> {a : _} -> Var1 g a -> Tm1 g a\nvar1 = \\ x, tm, var1, lam, app => var1 _ _ x\n\nlam1 : {g : _} -> {a : _} -> {B : _} -> Tm1 (snoc1 g a) B -> Tm1 g (arr1 a B)\nlam1 = \\ t, tm, var1, lam1, app => lam1 _ _ _ (t tm var1 lam1 app)\n\napp1 : {g:_}->{a:_}->{B:_} -> Tm1 g (arr1 a B) -> Tm1 g a -> Tm1 g B\napp1 = \\ t, u, tm, var1, lam1, app1 => app1 _ _ _ (t tm var1 lam1 app1) (u tm var1 lam1 app1)\n\nv01 : {g:_}->{a:_} -> Tm1 (snoc1 g a) a\nv01 = var1 vz1\n\nv11 : {g:_}->{a:_}-> {B:_}-> Tm1 (snoc1 (snoc1 g a) B) a\nv11 = var1 (vs1 vz1)\n\nv21 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm1 (snoc1 (snoc1 (snoc1 g a) B) C) a\nv21 = var1 (vs1 (vs1 vz1))\n\nv31 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm1 (snoc1 (snoc1 (snoc1 (snoc1 g a) B) C) D) a\nv31 = var1 (vs1 (vs1 (vs1 vz1)))\n\nv41 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm1 (snoc1 (snoc1 (snoc1 (snoc1 (snoc1 g a) B) C) D) E) a\nv41 = var1 (vs1 (vs1 (vs1 (vs1 vz1))))\n\ntest1 : {g:_}-> {a:_} -> Tm1 g (arr1 (arr1 a a) (arr1 a a))\ntest1 = lam1 (lam1 (app1 v11 (app1 v11 (app1 v11 (app1 v11 (app1 v11 (app1 v11 v01)))))))\nTy2 : Type\nTy2 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty2 : Ty2\nempty2 = \\ _, empty, _ => empty\n\narr2 : Ty2 -> Ty2 -> Ty2\narr2 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon2 : Type\nCon2 = (Con2 : Type)\n ->(nil : Con2)\n ->(snoc : Con2 -> Ty2 -> Con2)\n -> Con2\n\nnil2 : Con2\nnil2 = \\ con, nil2, snoc => nil2\n\nsnoc2 : Con2 -> Ty2 -> Con2\nsnoc2 = \\ g, a, con, nil2, snoc2 => snoc2 (g con nil2 snoc2) a\n\nVar2 : Con2 -> Ty2 -> Type\nVar2 = \\ g, a =>\n (Var2 : Con2 -> Ty2 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var2 (snoc2 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var2 g a -> Var2 (snoc2 g b) a)\n -> Var2 g a\n\nvz2 : {g : _}-> {a : _} -> Var2 (snoc2 g a) a\nvz2 = \\ var, vz2, vs => vz2 _ _\n\nvs2 : {g : _} -> {B : _} -> {a : _} -> Var2 g a -> Var2 (snoc2 g B) a\nvs2 = \\ x, var, vz2, vs2 => vs2 _ _ _ (x var vz2 vs2)\n\nTm2 : Con2 -> Ty2 -> Type\nTm2 = \\ g, a =>\n (Tm2 : Con2 -> Ty2 -> Type)\n -> (var : (g : _) -> (a : _) -> Var2 g a -> Tm2 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm2 (snoc2 g a) B -> Tm2 g (arr2 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm2 g (arr2 a B) -> Tm2 g a -> Tm2 g B)\n -> Tm2 g a\n\nvar2 : {g : _} -> {a : _} -> Var2 g a -> Tm2 g a\nvar2 = \\ x, tm, var2, lam, app => var2 _ _ x\n\nlam2 : {g : _} -> {a : _} -> {B : _} -> Tm2 (snoc2 g a) B -> Tm2 g (arr2 a B)\nlam2 = \\ t, tm, var2, lam2, app => lam2 _ _ _ (t tm var2 lam2 app)\n\napp2 : {g:_}->{a:_}->{B:_} -> Tm2 g (arr2 a B) -> Tm2 g a -> Tm2 g B\napp2 = \\ t, u, tm, var2, lam2, app2 => app2 _ _ _ (t tm var2 lam2 app2) (u tm var2 lam2 app2)\n\nv02 : {g:_}->{a:_} -> Tm2 (snoc2 g a) a\nv02 = var2 vz2\n\nv12 : {g:_}->{a:_}-> {B:_}-> Tm2 (snoc2 (snoc2 g a) B) a\nv12 = var2 (vs2 vz2)\n\nv22 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm2 (snoc2 (snoc2 (snoc2 g a) B) C) a\nv22 = var2 (vs2 (vs2 vz2))\n\nv32 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm2 (snoc2 (snoc2 (snoc2 (snoc2 g a) B) C) D) a\nv32 = var2 (vs2 (vs2 (vs2 vz2)))\n\nv42 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm2 (snoc2 (snoc2 (snoc2 (snoc2 (snoc2 g a) B) C) D) E) a\nv42 = var2 (vs2 (vs2 (vs2 (vs2 vz2))))\n\ntest2 : {g:_}-> {a:_} -> Tm2 g (arr2 (arr2 a a) (arr2 a a))\ntest2 = lam2 (lam2 (app2 v12 (app2 v12 (app2 v12 (app2 v12 (app2 v12 (app2 v12 v02)))))))\nTy3 : Type\nTy3 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty3 : Ty3\nempty3 = \\ _, empty, _ => empty\n\narr3 : Ty3 -> Ty3 -> Ty3\narr3 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon3 : Type\nCon3 = (Con3 : Type)\n ->(nil : Con3)\n ->(snoc : Con3 -> Ty3 -> Con3)\n -> Con3\n\nnil3 : Con3\nnil3 = \\ con, nil3, snoc => nil3\n\nsnoc3 : Con3 -> Ty3 -> Con3\nsnoc3 = \\ g, a, con, nil3, snoc3 => snoc3 (g con nil3 snoc3) a\n\nVar3 : Con3 -> Ty3 -> Type\nVar3 = \\ g, a =>\n (Var3 : Con3 -> Ty3 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var3 (snoc3 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var3 g a -> Var3 (snoc3 g b) a)\n -> Var3 g a\n\nvz3 : {g : _}-> {a : _} -> Var3 (snoc3 g a) a\nvz3 = \\ var, vz3, vs => vz3 _ _\n\nvs3 : {g : _} -> {B : _} -> {a : _} -> Var3 g a -> Var3 (snoc3 g B) a\nvs3 = \\ x, var, vz3, vs3 => vs3 _ _ _ (x var vz3 vs3)\n\nTm3 : Con3 -> Ty3 -> Type\nTm3 = \\ g, a =>\n (Tm3 : Con3 -> Ty3 -> Type)\n -> (var : (g : _) -> (a : _) -> Var3 g a -> Tm3 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm3 (snoc3 g a) B -> Tm3 g (arr3 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm3 g (arr3 a B) -> Tm3 g a -> Tm3 g B)\n -> Tm3 g a\n\nvar3 : {g : _} -> {a : _} -> Var3 g a -> Tm3 g a\nvar3 = \\ x, tm, var3, lam, app => var3 _ _ x\n\nlam3 : {g : _} -> {a : _} -> {B : _} -> Tm3 (snoc3 g a) B -> Tm3 g (arr3 a B)\nlam3 = \\ t, tm, var3, lam3, app => lam3 _ _ _ (t tm var3 lam3 app)\n\napp3 : {g:_}->{a:_}->{B:_} -> Tm3 g (arr3 a B) -> Tm3 g a -> Tm3 g B\napp3 = \\ t, u, tm, var3, lam3, app3 => app3 _ _ _ (t tm var3 lam3 app3) (u tm var3 lam3 app3)\n\nv03 : {g:_}->{a:_} -> Tm3 (snoc3 g a) a\nv03 = var3 vz3\n\nv13 : {g:_}->{a:_}-> {B:_}-> Tm3 (snoc3 (snoc3 g a) B) a\nv13 = var3 (vs3 vz3)\n\nv23 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm3 (snoc3 (snoc3 (snoc3 g a) B) C) a\nv23 = var3 (vs3 (vs3 vz3))\n\nv33 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm3 (snoc3 (snoc3 (snoc3 (snoc3 g a) B) C) D) a\nv33 = var3 (vs3 (vs3 (vs3 vz3)))\n\nv43 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm3 (snoc3 (snoc3 (snoc3 (snoc3 (snoc3 g a) B) C) D) E) a\nv43 = var3 (vs3 (vs3 (vs3 (vs3 vz3))))\n\ntest3 : {g:_}-> {a:_} -> Tm3 g (arr3 (arr3 a a) (arr3 a a))\ntest3 = lam3 (lam3 (app3 v13 (app3 v13 (app3 v13 (app3 v13 (app3 v13 (app3 v13 v03)))))))\nTy4 : Type\nTy4 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty4 : Ty4\nempty4 = \\ _, empty, _ => empty\n\narr4 : Ty4 -> Ty4 -> Ty4\narr4 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon4 : Type\nCon4 = (Con4 : Type)\n ->(nil : Con4)\n ->(snoc : Con4 -> Ty4 -> Con4)\n -> Con4\n\nnil4 : Con4\nnil4 = \\ con, nil4, snoc => nil4\n\nsnoc4 : Con4 -> Ty4 -> Con4\nsnoc4 = \\ g, a, con, nil4, snoc4 => snoc4 (g con nil4 snoc4) a\n\nVar4 : Con4 -> Ty4 -> Type\nVar4 = \\ g, a =>\n (Var4 : Con4 -> Ty4 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var4 (snoc4 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var4 g a -> Var4 (snoc4 g b) a)\n -> Var4 g a\n\nvz4 : {g : _}-> {a : _} -> Var4 (snoc4 g a) a\nvz4 = \\ var, vz4, vs => vz4 _ _\n\nvs4 : {g : _} -> {B : _} -> {a : _} -> Var4 g a -> Var4 (snoc4 g B) a\nvs4 = \\ x, var, vz4, vs4 => vs4 _ _ _ (x var vz4 vs4)\n\nTm4 : Con4 -> Ty4 -> Type\nTm4 = \\ g, a =>\n (Tm4 : Con4 -> Ty4 -> Type)\n -> (var : (g : _) -> (a : _) -> Var4 g a -> Tm4 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm4 (snoc4 g a) B -> Tm4 g (arr4 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm4 g (arr4 a B) -> Tm4 g a -> Tm4 g B)\n -> Tm4 g a\n\nvar4 : {g : _} -> {a : _} -> Var4 g a -> Tm4 g a\nvar4 = \\ x, tm, var4, lam, app => var4 _ _ x\n\nlam4 : {g : _} -> {a : _} -> {B : _} -> Tm4 (snoc4 g a) B -> Tm4 g (arr4 a B)\nlam4 = \\ t, tm, var4, lam4, app => lam4 _ _ _ (t tm var4 lam4 app)\n\napp4 : {g:_}->{a:_}->{B:_} -> Tm4 g (arr4 a B) -> Tm4 g a -> Tm4 g B\napp4 = \\ t, u, tm, var4, lam4, app4 => app4 _ _ _ (t tm var4 lam4 app4) (u tm var4 lam4 app4)\n\nv04 : {g:_}->{a:_} -> Tm4 (snoc4 g a) a\nv04 = var4 vz4\n\nv14 : {g:_}->{a:_}-> {B:_}-> Tm4 (snoc4 (snoc4 g a) B) a\nv14 = var4 (vs4 vz4)\n\nv24 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm4 (snoc4 (snoc4 (snoc4 g a) B) C) a\nv24 = var4 (vs4 (vs4 vz4))\n\nv34 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm4 (snoc4 (snoc4 (snoc4 (snoc4 g a) B) C) D) a\nv34 = var4 (vs4 (vs4 (vs4 vz4)))\n\nv44 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm4 (snoc4 (snoc4 (snoc4 (snoc4 (snoc4 g a) B) C) D) E) a\nv44 = var4 (vs4 (vs4 (vs4 (vs4 vz4))))\n\ntest4 : {g:_}-> {a:_} -> Tm4 g (arr4 (arr4 a a) (arr4 a a))\ntest4 = lam4 (lam4 (app4 v14 (app4 v14 (app4 v14 (app4 v14 (app4 v14 (app4 v14 v04)))))))\nTy5 : Type\nTy5 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty5 : Ty5\nempty5 = \\ _, empty, _ => empty\n\narr5 : Ty5 -> Ty5 -> Ty5\narr5 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon5 : Type\nCon5 = (Con5 : Type)\n ->(nil : Con5)\n ->(snoc : Con5 -> Ty5 -> Con5)\n -> Con5\n\nnil5 : Con5\nnil5 = \\ con, nil5, snoc => nil5\n\nsnoc5 : Con5 -> Ty5 -> Con5\nsnoc5 = \\ g, a, con, nil5, snoc5 => snoc5 (g con nil5 snoc5) a\n\nVar5 : Con5 -> Ty5 -> Type\nVar5 = \\ g, a =>\n (Var5 : Con5 -> Ty5 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var5 (snoc5 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var5 g a -> Var5 (snoc5 g b) a)\n -> Var5 g a\n\nvz5 : {g : _}-> {a : _} -> Var5 (snoc5 g a) a\nvz5 = \\ var, vz5, vs => vz5 _ _\n\nvs5 : {g : _} -> {B : _} -> {a : _} -> Var5 g a -> Var5 (snoc5 g B) a\nvs5 = \\ x, var, vz5, vs5 => vs5 _ _ _ (x var vz5 vs5)\n\nTm5 : Con5 -> Ty5 -> Type\nTm5 = \\ g, a =>\n (Tm5 : Con5 -> Ty5 -> Type)\n -> (var : (g : _) -> (a : _) -> Var5 g a -> Tm5 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm5 (snoc5 g a) B -> Tm5 g (arr5 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm5 g (arr5 a B) -> Tm5 g a -> Tm5 g B)\n -> Tm5 g a\n\nvar5 : {g : _} -> {a : _} -> Var5 g a -> Tm5 g a\nvar5 = \\ x, tm, var5, lam, app => var5 _ _ x\n\nlam5 : {g : _} -> {a : _} -> {B : _} -> Tm5 (snoc5 g a) B -> Tm5 g (arr5 a B)\nlam5 = \\ t, tm, var5, lam5, app => lam5 _ _ _ (t tm var5 lam5 app)\n\napp5 : {g:_}->{a:_}->{B:_} -> Tm5 g (arr5 a B) -> Tm5 g a -> Tm5 g B\napp5 = \\ t, u, tm, var5, lam5, app5 => app5 _ _ _ (t tm var5 lam5 app5) (u tm var5 lam5 app5)\n\nv05 : {g:_}->{a:_} -> Tm5 (snoc5 g a) a\nv05 = var5 vz5\n\nv15 : {g:_}->{a:_}-> {B:_}-> Tm5 (snoc5 (snoc5 g a) B) a\nv15 = var5 (vs5 vz5)\n\nv25 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm5 (snoc5 (snoc5 (snoc5 g a) B) C) a\nv25 = var5 (vs5 (vs5 vz5))\n\nv35 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm5 (snoc5 (snoc5 (snoc5 (snoc5 g a) B) C) D) a\nv35 = var5 (vs5 (vs5 (vs5 vz5)))\n\nv45 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm5 (snoc5 (snoc5 (snoc5 (snoc5 (snoc5 g a) B) C) D) E) a\nv45 = var5 (vs5 (vs5 (vs5 (vs5 vz5))))\n\ntest5 : {g:_}-> {a:_} -> Tm5 g (arr5 (arr5 a a) (arr5 a a))\ntest5 = lam5 (lam5 (app5 v15 (app5 v15 (app5 v15 (app5 v15 (app5 v15 (app5 v15 v05)))))))\nTy6 : Type\nTy6 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty6 : Ty6\nempty6 = \\ _, empty, _ => empty\n\narr6 : Ty6 -> Ty6 -> Ty6\narr6 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon6 : Type\nCon6 = (Con6 : Type)\n ->(nil : Con6)\n ->(snoc : Con6 -> Ty6 -> Con6)\n -> Con6\n\nnil6 : Con6\nnil6 = \\ con, nil6, snoc => nil6\n\nsnoc6 : Con6 -> Ty6 -> Con6\nsnoc6 = \\ g, a, con, nil6, snoc6 => snoc6 (g con nil6 snoc6) a\n\nVar6 : Con6 -> Ty6 -> Type\nVar6 = \\ g, a =>\n (Var6 : Con6 -> Ty6 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var6 (snoc6 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var6 g a -> Var6 (snoc6 g b) a)\n -> Var6 g a\n\nvz6 : {g : _}-> {a : _} -> Var6 (snoc6 g a) a\nvz6 = \\ var, vz6, vs => vz6 _ _\n\nvs6 : {g : _} -> {B : _} -> {a : _} -> Var6 g a -> Var6 (snoc6 g B) a\nvs6 = \\ x, var, vz6, vs6 => vs6 _ _ _ (x var vz6 vs6)\n\nTm6 : Con6 -> Ty6 -> Type\nTm6 = \\ g, a =>\n (Tm6 : Con6 -> Ty6 -> Type)\n -> (var : (g : _) -> (a : _) -> Var6 g a -> Tm6 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm6 (snoc6 g a) B -> Tm6 g (arr6 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm6 g (arr6 a B) -> Tm6 g a -> Tm6 g B)\n -> Tm6 g a\n\nvar6 : {g : _} -> {a : _} -> Var6 g a -> Tm6 g a\nvar6 = \\ x, tm, var6, lam, app => var6 _ _ x\n\nlam6 : {g : _} -> {a : _} -> {B : _} -> Tm6 (snoc6 g a) B -> Tm6 g (arr6 a B)\nlam6 = \\ t, tm, var6, lam6, app => lam6 _ _ _ (t tm var6 lam6 app)\n\napp6 : {g:_}->{a:_}->{B:_} -> Tm6 g (arr6 a B) -> Tm6 g a -> Tm6 g B\napp6 = \\ t, u, tm, var6, lam6, app6 => app6 _ _ _ (t tm var6 lam6 app6) (u tm var6 lam6 app6)\n\nv06 : {g:_}->{a:_} -> Tm6 (snoc6 g a) a\nv06 = var6 vz6\n\nv16 : {g:_}->{a:_}-> {B:_}-> Tm6 (snoc6 (snoc6 g a) B) a\nv16 = var6 (vs6 vz6)\n\nv26 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm6 (snoc6 (snoc6 (snoc6 g a) B) C) a\nv26 = var6 (vs6 (vs6 vz6))\n\nv36 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm6 (snoc6 (snoc6 (snoc6 (snoc6 g a) B) C) D) a\nv36 = var6 (vs6 (vs6 (vs6 vz6)))\n\nv46 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm6 (snoc6 (snoc6 (snoc6 (snoc6 (snoc6 g a) B) C) D) E) a\nv46 = var6 (vs6 (vs6 (vs6 (vs6 vz6))))\n\ntest6 : {g:_}-> {a:_} -> Tm6 g (arr6 (arr6 a a) (arr6 a a))\ntest6 = lam6 (lam6 (app6 v16 (app6 v16 (app6 v16 (app6 v16 (app6 v16 (app6 v16 v06)))))))\nTy7 : Type\nTy7 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty7 : Ty7\nempty7 = \\ _, empty, _ => empty\n\narr7 : Ty7 -> Ty7 -> Ty7\narr7 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon7 : Type\nCon7 = (Con7 : Type)\n ->(nil : Con7)\n ->(snoc : Con7 -> Ty7 -> Con7)\n -> Con7\n\nnil7 : Con7\nnil7 = \\ con, nil7, snoc => nil7\n\nsnoc7 : Con7 -> Ty7 -> Con7\nsnoc7 = \\ g, a, con, nil7, snoc7 => snoc7 (g con nil7 snoc7) a\n\nVar7 : Con7 -> Ty7 -> Type\nVar7 = \\ g, a =>\n (Var7 : Con7 -> Ty7 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var7 (snoc7 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var7 g a -> Var7 (snoc7 g b) a)\n -> Var7 g a\n\nvz7 : {g : _}-> {a : _} -> Var7 (snoc7 g a) a\nvz7 = \\ var, vz7, vs => vz7 _ _\n\nvs7 : {g : _} -> {B : _} -> {a : _} -> Var7 g a -> Var7 (snoc7 g B) a\nvs7 = \\ x, var, vz7, vs7 => vs7 _ _ _ (x var vz7 vs7)\n\nTm7 : Con7 -> Ty7 -> Type\nTm7 = \\ g, a =>\n (Tm7 : Con7 -> Ty7 -> Type)\n -> (var : (g : _) -> (a : _) -> Var7 g a -> Tm7 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm7 (snoc7 g a) B -> Tm7 g (arr7 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm7 g (arr7 a B) -> Tm7 g a -> Tm7 g B)\n -> Tm7 g a\n\nvar7 : {g : _} -> {a : _} -> Var7 g a -> Tm7 g a\nvar7 = \\ x, tm, var7, lam, app => var7 _ _ x\n\nlam7 : {g : _} -> {a : _} -> {B : _} -> Tm7 (snoc7 g a) B -> Tm7 g (arr7 a B)\nlam7 = \\ t, tm, var7, lam7, app => lam7 _ _ _ (t tm var7 lam7 app)\n\napp7 : {g:_}->{a:_}->{B:_} -> Tm7 g (arr7 a B) -> Tm7 g a -> Tm7 g B\napp7 = \\ t, u, tm, var7, lam7, app7 => app7 _ _ _ (t tm var7 lam7 app7) (u tm var7 lam7 app7)\n\nv07 : {g:_}->{a:_} -> Tm7 (snoc7 g a) a\nv07 = var7 vz7\n\nv17 : {g:_}->{a:_}-> {B:_}-> Tm7 (snoc7 (snoc7 g a) B) a\nv17 = var7 (vs7 vz7)\n\nv27 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm7 (snoc7 (snoc7 (snoc7 g a) B) C) a\nv27 = var7 (vs7 (vs7 vz7))\n\nv37 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm7 (snoc7 (snoc7 (snoc7 (snoc7 g a) B) C) D) a\nv37 = var7 (vs7 (vs7 (vs7 vz7)))\n\nv47 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm7 (snoc7 (snoc7 (snoc7 (snoc7 (snoc7 g a) B) C) D) E) a\nv47 = var7 (vs7 (vs7 (vs7 (vs7 vz7))))\n\ntest7 : {g:_}-> {a:_} -> Tm7 g (arr7 (arr7 a a) (arr7 a a))\ntest7 = lam7 (lam7 (app7 v17 (app7 v17 (app7 v17 (app7 v17 (app7 v17 (app7 v17 v07)))))))\nTy8 : Type\nTy8 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty8 : Ty8\nempty8 = \\ _, empty, _ => empty\n\narr8 : Ty8 -> Ty8 -> Ty8\narr8 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon8 : Type\nCon8 = (Con8 : Type)\n ->(nil : Con8)\n ->(snoc : Con8 -> Ty8 -> Con8)\n -> Con8\n\nnil8 : Con8\nnil8 = \\ con, nil8, snoc => nil8\n\nsnoc8 : Con8 -> Ty8 -> Con8\nsnoc8 = \\ g, a, con, nil8, snoc8 => snoc8 (g con nil8 snoc8) a\n\nVar8 : Con8 -> Ty8 -> Type\nVar8 = \\ g, a =>\n (Var8 : Con8 -> Ty8 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var8 (snoc8 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var8 g a -> Var8 (snoc8 g b) a)\n -> Var8 g a\n\nvz8 : {g : _}-> {a : _} -> Var8 (snoc8 g a) a\nvz8 = \\ var, vz8, vs => vz8 _ _\n\nvs8 : {g : _} -> {B : _} -> {a : _} -> Var8 g a -> Var8 (snoc8 g B) a\nvs8 = \\ x, var, vz8, vs8 => vs8 _ _ _ (x var vz8 vs8)\n\nTm8 : Con8 -> Ty8 -> Type\nTm8 = \\ g, a =>\n (Tm8 : Con8 -> Ty8 -> Type)\n -> (var : (g : _) -> (a : _) -> Var8 g a -> Tm8 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm8 (snoc8 g a) B -> Tm8 g (arr8 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm8 g (arr8 a B) -> Tm8 g a -> Tm8 g B)\n -> Tm8 g a\n\nvar8 : {g : _} -> {a : _} -> Var8 g a -> Tm8 g a\nvar8 = \\ x, tm, var8, lam, app => var8 _ _ x\n\nlam8 : {g : _} -> {a : _} -> {B : _} -> Tm8 (snoc8 g a) B -> Tm8 g (arr8 a B)\nlam8 = \\ t, tm, var8, lam8, app => lam8 _ _ _ (t tm var8 lam8 app)\n\napp8 : {g:_}->{a:_}->{B:_} -> Tm8 g (arr8 a B) -> Tm8 g a -> Tm8 g B\napp8 = \\ t, u, tm, var8, lam8, app8 => app8 _ _ _ (t tm var8 lam8 app8) (u tm var8 lam8 app8)\n\nv08 : {g:_}->{a:_} -> Tm8 (snoc8 g a) a\nv08 = var8 vz8\n\nv18 : {g:_}->{a:_}-> {B:_}-> Tm8 (snoc8 (snoc8 g a) B) a\nv18 = var8 (vs8 vz8)\n\nv28 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm8 (snoc8 (snoc8 (snoc8 g a) B) C) a\nv28 = var8 (vs8 (vs8 vz8))\n\nv38 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm8 (snoc8 (snoc8 (snoc8 (snoc8 g a) B) C) D) a\nv38 = var8 (vs8 (vs8 (vs8 vz8)))\n\nv48 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm8 (snoc8 (snoc8 (snoc8 (snoc8 (snoc8 g a) B) C) D) E) a\nv48 = var8 (vs8 (vs8 (vs8 (vs8 vz8))))\n\ntest8 : {g:_}-> {a:_} -> Tm8 g (arr8 (arr8 a a) (arr8 a a))\ntest8 = lam8 (lam8 (app8 v18 (app8 v18 (app8 v18 (app8 v18 (app8 v18 (app8 v18 v08)))))))\nTy9 : Type\nTy9 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty9 : Ty9\nempty9 = \\ _, empty, _ => empty\n\narr9 : Ty9 -> Ty9 -> Ty9\narr9 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon9 : Type\nCon9 = (Con9 : Type)\n ->(nil : Con9)\n ->(snoc : Con9 -> Ty9 -> Con9)\n -> Con9\n\nnil9 : Con9\nnil9 = \\ con, nil9, snoc => nil9\n\nsnoc9 : Con9 -> Ty9 -> Con9\nsnoc9 = \\ g, a, con, nil9, snoc9 => snoc9 (g con nil9 snoc9) a\n\nVar9 : Con9 -> Ty9 -> Type\nVar9 = \\ g, a =>\n (Var9 : Con9 -> Ty9 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var9 (snoc9 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var9 g a -> Var9 (snoc9 g b) a)\n -> Var9 g a\n\nvz9 : {g : _}-> {a : _} -> Var9 (snoc9 g a) a\nvz9 = \\ var, vz9, vs => vz9 _ _\n\nvs9 : {g : _} -> {B : _} -> {a : _} -> Var9 g a -> Var9 (snoc9 g B) a\nvs9 = \\ x, var, vz9, vs9 => vs9 _ _ _ (x var vz9 vs9)\n\nTm9 : Con9 -> Ty9 -> Type\nTm9 = \\ g, a =>\n (Tm9 : Con9 -> Ty9 -> Type)\n -> (var : (g : _) -> (a : _) -> Var9 g a -> Tm9 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm9 (snoc9 g a) B -> Tm9 g (arr9 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm9 g (arr9 a B) -> Tm9 g a -> Tm9 g B)\n -> Tm9 g a\n\nvar9 : {g : _} -> {a : _} -> Var9 g a -> Tm9 g a\nvar9 = \\ x, tm, var9, lam, app => var9 _ _ x\n\nlam9 : {g : _} -> {a : _} -> {B : _} -> Tm9 (snoc9 g a) B -> Tm9 g (arr9 a B)\nlam9 = \\ t, tm, var9, lam9, app => lam9 _ _ _ (t tm var9 lam9 app)\n\napp9 : {g:_}->{a:_}->{B:_} -> Tm9 g (arr9 a B) -> Tm9 g a -> Tm9 g B\napp9 = \\ t, u, tm, var9, lam9, app9 => app9 _ _ _ (t tm var9 lam9 app9) (u tm var9 lam9 app9)\n\nv09 : {g:_}->{a:_} -> Tm9 (snoc9 g a) a\nv09 = var9 vz9\n\nv19 : {g:_}->{a:_}-> {B:_}-> Tm9 (snoc9 (snoc9 g a) B) a\nv19 = var9 (vs9 vz9)\n\nv29 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm9 (snoc9 (snoc9 (snoc9 g a) B) C) a\nv29 = var9 (vs9 (vs9 vz9))\n\nv39 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm9 (snoc9 (snoc9 (snoc9 (snoc9 g a) B) C) D) a\nv39 = var9 (vs9 (vs9 (vs9 vz9)))\n\nv49 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm9 (snoc9 (snoc9 (snoc9 (snoc9 (snoc9 g a) B) C) D) E) a\nv49 = var9 (vs9 (vs9 (vs9 (vs9 vz9))))\n\ntest9 : {g:_}-> {a:_} -> Tm9 g (arr9 (arr9 a a) (arr9 a a))\ntest9 = lam9 (lam9 (app9 v19 (app9 v19 (app9 v19 (app9 v19 (app9 v19 (app9 v19 v09)))))))\nTy10 : Type\nTy10 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty10 : Ty10\nempty10 = \\ _, empty, _ => empty\n\narr10 : Ty10 -> Ty10 -> Ty10\narr10 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon10 : Type\nCon10 = (Con10 : Type)\n ->(nil : Con10)\n ->(snoc : Con10 -> Ty10 -> Con10)\n -> Con10\n\nnil10 : Con10\nnil10 = \\ con, nil10, snoc => nil10\n\nsnoc10 : Con10 -> Ty10 -> Con10\nsnoc10 = \\ g, a, con, nil10, snoc10 => snoc10 (g con nil10 snoc10) a\n\nVar10 : Con10 -> Ty10 -> Type\nVar10 = \\ g, a =>\n (Var10 : Con10 -> Ty10 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var10 (snoc10 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var10 g a -> Var10 (snoc10 g b) a)\n -> Var10 g a\n\nvz10 : {g : _}-> {a : _} -> Var10 (snoc10 g a) a\nvz10 = \\ var, vz10, vs => vz10 _ _\n\nvs10 : {g : _} -> {B : _} -> {a : _} -> Var10 g a -> Var10 (snoc10 g B) a\nvs10 = \\ x, var, vz10, vs10 => vs10 _ _ _ (x var vz10 vs10)\n\nTm10 : Con10 -> Ty10 -> Type\nTm10 = \\ g, a =>\n (Tm10 : Con10 -> Ty10 -> Type)\n -> (var : (g : _) -> (a : _) -> Var10 g a -> Tm10 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm10 (snoc10 g a) B -> Tm10 g (arr10 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm10 g (arr10 a B) -> Tm10 g a -> Tm10 g B)\n -> Tm10 g a\n\nvar10 : {g : _} -> {a : _} -> Var10 g a -> Tm10 g a\nvar10 = \\ x, tm, var10, lam, app => var10 _ _ x\n\nlam10 : {g : _} -> {a : _} -> {B : _} -> Tm10 (snoc10 g a) B -> Tm10 g (arr10 a B)\nlam10 = \\ t, tm, var10, lam10, app => lam10 _ _ _ (t tm var10 lam10 app)\n\napp10 : {g:_}->{a:_}->{B:_} -> Tm10 g (arr10 a B) -> Tm10 g a -> Tm10 g B\napp10 = \\ t, u, tm, var10, lam10, app10 => app10 _ _ _ (t tm var10 lam10 app10) (u tm var10 lam10 app10)\n\nv010 : {g:_}->{a:_} -> Tm10 (snoc10 g a) a\nv010 = var10 vz10\n\nv110 : {g:_}->{a:_}-> {B:_}-> Tm10 (snoc10 (snoc10 g a) B) a\nv110 = var10 (vs10 vz10)\n\nv210 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm10 (snoc10 (snoc10 (snoc10 g a) B) C) a\nv210 = var10 (vs10 (vs10 vz10))\n\nv310 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm10 (snoc10 (snoc10 (snoc10 (snoc10 g a) B) C) D) a\nv310 = var10 (vs10 (vs10 (vs10 vz10)))\n\nv410 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm10 (snoc10 (snoc10 (snoc10 (snoc10 (snoc10 g a) B) C) D) E) a\nv410 = var10 (vs10 (vs10 (vs10 (vs10 vz10))))\n\ntest10 : {g:_}-> {a:_} -> Tm10 g (arr10 (arr10 a a) (arr10 a a))\ntest10 = lam10 (lam10 (app10 v110 (app10 v110 (app10 v110 (app10 v110 (app10 v110 (app10 v110 v010)))))))\nTy11 : Type\nTy11 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty11 : Ty11\nempty11 = \\ _, empty, _ => empty\n\narr11 : Ty11 -> Ty11 -> Ty11\narr11 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon11 : Type\nCon11 = (Con11 : Type)\n ->(nil : Con11)\n ->(snoc : Con11 -> Ty11 -> Con11)\n -> Con11\n\nnil11 : Con11\nnil11 = \\ con, nil11, snoc => nil11\n\nsnoc11 : Con11 -> Ty11 -> Con11\nsnoc11 = \\ g, a, con, nil11, snoc11 => snoc11 (g con nil11 snoc11) a\n\nVar11 : Con11 -> Ty11 -> Type\nVar11 = \\ g, a =>\n (Var11 : Con11 -> Ty11 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var11 (snoc11 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var11 g a -> Var11 (snoc11 g b) a)\n -> Var11 g a\n\nvz11 : {g : _}-> {a : _} -> Var11 (snoc11 g a) a\nvz11 = \\ var, vz11, vs => vz11 _ _\n\nvs11 : {g : _} -> {B : _} -> {a : _} -> Var11 g a -> Var11 (snoc11 g B) a\nvs11 = \\ x, var, vz11, vs11 => vs11 _ _ _ (x var vz11 vs11)\n\nTm11 : Con11 -> Ty11 -> Type\nTm11 = \\ g, a =>\n (Tm11 : Con11 -> Ty11 -> Type)\n -> (var : (g : _) -> (a : _) -> Var11 g a -> Tm11 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm11 (snoc11 g a) B -> Tm11 g (arr11 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm11 g (arr11 a B) -> Tm11 g a -> Tm11 g B)\n -> Tm11 g a\n\nvar11 : {g : _} -> {a : _} -> Var11 g a -> Tm11 g a\nvar11 = \\ x, tm, var11, lam, app => var11 _ _ x\n\nlam11 : {g : _} -> {a : _} -> {B : _} -> Tm11 (snoc11 g a) B -> Tm11 g (arr11 a B)\nlam11 = \\ t, tm, var11, lam11, app => lam11 _ _ _ (t tm var11 lam11 app)\n\napp11 : {g:_}->{a:_}->{B:_} -> Tm11 g (arr11 a B) -> Tm11 g a -> Tm11 g B\napp11 = \\ t, u, tm, var11, lam11, app11 => app11 _ _ _ (t tm var11 lam11 app11) (u tm var11 lam11 app11)\n\nv011 : {g:_}->{a:_} -> Tm11 (snoc11 g a) a\nv011 = var11 vz11\n\nv111 : {g:_}->{a:_}-> {B:_}-> Tm11 (snoc11 (snoc11 g a) B) a\nv111 = var11 (vs11 vz11)\n\nv211 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm11 (snoc11 (snoc11 (snoc11 g a) B) C) a\nv211 = var11 (vs11 (vs11 vz11))\n\nv311 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm11 (snoc11 (snoc11 (snoc11 (snoc11 g a) B) C) D) a\nv311 = var11 (vs11 (vs11 (vs11 vz11)))\n\nv411 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm11 (snoc11 (snoc11 (snoc11 (snoc11 (snoc11 g a) B) C) D) E) a\nv411 = var11 (vs11 (vs11 (vs11 (vs11 vz11))))\n\ntest11 : {g:_}-> {a:_} -> Tm11 g (arr11 (arr11 a a) (arr11 a a))\ntest11 = lam11 (lam11 (app11 v111 (app11 v111 (app11 v111 (app11 v111 (app11 v111 (app11 v111 v011)))))))\nTy12 : Type\nTy12 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty12 : Ty12\nempty12 = \\ _, empty, _ => empty\n\narr12 : Ty12 -> Ty12 -> Ty12\narr12 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon12 : Type\nCon12 = (Con12 : Type)\n ->(nil : Con12)\n ->(snoc : Con12 -> Ty12 -> Con12)\n -> Con12\n\nnil12 : Con12\nnil12 = \\ con, nil12, snoc => nil12\n\nsnoc12 : Con12 -> Ty12 -> Con12\nsnoc12 = \\ g, a, con, nil12, snoc12 => snoc12 (g con nil12 snoc12) a\n\nVar12 : Con12 -> Ty12 -> Type\nVar12 = \\ g, a =>\n (Var12 : Con12 -> Ty12 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var12 (snoc12 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var12 g a -> Var12 (snoc12 g b) a)\n -> Var12 g a\n\nvz12 : {g : _}-> {a : _} -> Var12 (snoc12 g a) a\nvz12 = \\ var, vz12, vs => vz12 _ _\n\nvs12 : {g : _} -> {B : _} -> {a : _} -> Var12 g a -> Var12 (snoc12 g B) a\nvs12 = \\ x, var, vz12, vs12 => vs12 _ _ _ (x var vz12 vs12)\n\nTm12 : Con12 -> Ty12 -> Type\nTm12 = \\ g, a =>\n (Tm12 : Con12 -> Ty12 -> Type)\n -> (var : (g : _) -> (a : _) -> Var12 g a -> Tm12 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm12 (snoc12 g a) B -> Tm12 g (arr12 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm12 g (arr12 a B) -> Tm12 g a -> Tm12 g B)\n -> Tm12 g a\n\nvar12 : {g : _} -> {a : _} -> Var12 g a -> Tm12 g a\nvar12 = \\ x, tm, var12, lam, app => var12 _ _ x\n\nlam12 : {g : _} -> {a : _} -> {B : _} -> Tm12 (snoc12 g a) B -> Tm12 g (arr12 a B)\nlam12 = \\ t, tm, var12, lam12, app => lam12 _ _ _ (t tm var12 lam12 app)\n\napp12 : {g:_}->{a:_}->{B:_} -> Tm12 g (arr12 a B) -> Tm12 g a -> Tm12 g B\napp12 = \\ t, u, tm, var12, lam12, app12 => app12 _ _ _ (t tm var12 lam12 app12) (u tm var12 lam12 app12)\n\nv012 : {g:_}->{a:_} -> Tm12 (snoc12 g a) a\nv012 = var12 vz12\n\nv112 : {g:_}->{a:_}-> {B:_}-> Tm12 (snoc12 (snoc12 g a) B) a\nv112 = var12 (vs12 vz12)\n\nv212 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm12 (snoc12 (snoc12 (snoc12 g a) B) C) a\nv212 = var12 (vs12 (vs12 vz12))\n\nv312 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm12 (snoc12 (snoc12 (snoc12 (snoc12 g a) B) C) D) a\nv312 = var12 (vs12 (vs12 (vs12 vz12)))\n\nv412 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm12 (snoc12 (snoc12 (snoc12 (snoc12 (snoc12 g a) B) C) D) E) a\nv412 = var12 (vs12 (vs12 (vs12 (vs12 vz12))))\n\ntest12 : {g:_}-> {a:_} -> Tm12 g (arr12 (arr12 a a) (arr12 a a))\ntest12 = lam12 (lam12 (app12 v112 (app12 v112 (app12 v112 (app12 v112 (app12 v112 (app12 v112 v012)))))))\nTy13 : Type\nTy13 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty13 : Ty13\nempty13 = \\ _, empty, _ => empty\n\narr13 : Ty13 -> Ty13 -> Ty13\narr13 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon13 : Type\nCon13 = (Con13 : Type)\n ->(nil : Con13)\n ->(snoc : Con13 -> Ty13 -> Con13)\n -> Con13\n\nnil13 : Con13\nnil13 = \\ con, nil13, snoc => nil13\n\nsnoc13 : Con13 -> Ty13 -> Con13\nsnoc13 = \\ g, a, con, nil13, snoc13 => snoc13 (g con nil13 snoc13) a\n\nVar13 : Con13 -> Ty13 -> Type\nVar13 = \\ g, a =>\n (Var13 : Con13 -> Ty13 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var13 (snoc13 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var13 g a -> Var13 (snoc13 g b) a)\n -> Var13 g a\n\nvz13 : {g : _}-> {a : _} -> Var13 (snoc13 g a) a\nvz13 = \\ var, vz13, vs => vz13 _ _\n\nvs13 : {g : _} -> {B : _} -> {a : _} -> Var13 g a -> Var13 (snoc13 g B) a\nvs13 = \\ x, var, vz13, vs13 => vs13 _ _ _ (x var vz13 vs13)\n\nTm13 : Con13 -> Ty13 -> Type\nTm13 = \\ g, a =>\n (Tm13 : Con13 -> Ty13 -> Type)\n -> (var : (g : _) -> (a : _) -> Var13 g a -> Tm13 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm13 (snoc13 g a) B -> Tm13 g (arr13 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm13 g (arr13 a B) -> Tm13 g a -> Tm13 g B)\n -> Tm13 g a\n\nvar13 : {g : _} -> {a : _} -> Var13 g a -> Tm13 g a\nvar13 = \\ x, tm, var13, lam, app => var13 _ _ x\n\nlam13 : {g : _} -> {a : _} -> {B : _} -> Tm13 (snoc13 g a) B -> Tm13 g (arr13 a B)\nlam13 = \\ t, tm, var13, lam13, app => lam13 _ _ _ (t tm var13 lam13 app)\n\napp13 : {g:_}->{a:_}->{B:_} -> Tm13 g (arr13 a B) -> Tm13 g a -> Tm13 g B\napp13 = \\ t, u, tm, var13, lam13, app13 => app13 _ _ _ (t tm var13 lam13 app13) (u tm var13 lam13 app13)\n\nv013 : {g:_}->{a:_} -> Tm13 (snoc13 g a) a\nv013 = var13 vz13\n\nv113 : {g:_}->{a:_}-> {B:_}-> Tm13 (snoc13 (snoc13 g a) B) a\nv113 = var13 (vs13 vz13)\n\nv213 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm13 (snoc13 (snoc13 (snoc13 g a) B) C) a\nv213 = var13 (vs13 (vs13 vz13))\n\nv313 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm13 (snoc13 (snoc13 (snoc13 (snoc13 g a) B) C) D) a\nv313 = var13 (vs13 (vs13 (vs13 vz13)))\n\nv413 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm13 (snoc13 (snoc13 (snoc13 (snoc13 (snoc13 g a) B) C) D) E) a\nv413 = var13 (vs13 (vs13 (vs13 (vs13 vz13))))\n\ntest13 : {g:_}-> {a:_} -> Tm13 g (arr13 (arr13 a a) (arr13 a a))\ntest13 = lam13 (lam13 (app13 v113 (app13 v113 (app13 v113 (app13 v113 (app13 v113 (app13 v113 v013)))))))\nTy14 : Type\nTy14 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty14 : Ty14\nempty14 = \\ _, empty, _ => empty\n\narr14 : Ty14 -> Ty14 -> Ty14\narr14 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon14 : Type\nCon14 = (Con14 : Type)\n ->(nil : Con14)\n ->(snoc : Con14 -> Ty14 -> Con14)\n -> Con14\n\nnil14 : Con14\nnil14 = \\ con, nil14, snoc => nil14\n\nsnoc14 : Con14 -> Ty14 -> Con14\nsnoc14 = \\ g, a, con, nil14, snoc14 => snoc14 (g con nil14 snoc14) a\n\nVar14 : Con14 -> Ty14 -> Type\nVar14 = \\ g, a =>\n (Var14 : Con14 -> Ty14 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var14 (snoc14 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var14 g a -> Var14 (snoc14 g b) a)\n -> Var14 g a\n\nvz14 : {g : _}-> {a : _} -> Var14 (snoc14 g a) a\nvz14 = \\ var, vz14, vs => vz14 _ _\n\nvs14 : {g : _} -> {B : _} -> {a : _} -> Var14 g a -> Var14 (snoc14 g B) a\nvs14 = \\ x, var, vz14, vs14 => vs14 _ _ _ (x var vz14 vs14)\n\nTm14 : Con14 -> Ty14 -> Type\nTm14 = \\ g, a =>\n (Tm14 : Con14 -> Ty14 -> Type)\n -> (var : (g : _) -> (a : _) -> Var14 g a -> Tm14 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm14 (snoc14 g a) B -> Tm14 g (arr14 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm14 g (arr14 a B) -> Tm14 g a -> Tm14 g B)\n -> Tm14 g a\n\nvar14 : {g : _} -> {a : _} -> Var14 g a -> Tm14 g a\nvar14 = \\ x, tm, var14, lam, app => var14 _ _ x\n\nlam14 : {g : _} -> {a : _} -> {B : _} -> Tm14 (snoc14 g a) B -> Tm14 g (arr14 a B)\nlam14 = \\ t, tm, var14, lam14, app => lam14 _ _ _ (t tm var14 lam14 app)\n\napp14 : {g:_}->{a:_}->{B:_} -> Tm14 g (arr14 a B) -> Tm14 g a -> Tm14 g B\napp14 = \\ t, u, tm, var14, lam14, app14 => app14 _ _ _ (t tm var14 lam14 app14) (u tm var14 lam14 app14)\n\nv014 : {g:_}->{a:_} -> Tm14 (snoc14 g a) a\nv014 = var14 vz14\n\nv114 : {g:_}->{a:_}-> {B:_}-> Tm14 (snoc14 (snoc14 g a) B) a\nv114 = var14 (vs14 vz14)\n\nv214 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm14 (snoc14 (snoc14 (snoc14 g a) B) C) a\nv214 = var14 (vs14 (vs14 vz14))\n\nv314 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm14 (snoc14 (snoc14 (snoc14 (snoc14 g a) B) C) D) a\nv314 = var14 (vs14 (vs14 (vs14 vz14)))\n\nv414 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm14 (snoc14 (snoc14 (snoc14 (snoc14 (snoc14 g a) B) C) D) E) a\nv414 = var14 (vs14 (vs14 (vs14 (vs14 vz14))))\n\ntest14 : {g:_}-> {a:_} -> Tm14 g (arr14 (arr14 a a) (arr14 a a))\ntest14 = lam14 (lam14 (app14 v114 (app14 v114 (app14 v114 (app14 v114 (app14 v114 (app14 v114 v014)))))))\nTy15 : Type\nTy15 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty15 : Ty15\nempty15 = \\ _, empty, _ => empty\n\narr15 : Ty15 -> Ty15 -> Ty15\narr15 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon15 : Type\nCon15 = (Con15 : Type)\n ->(nil : Con15)\n ->(snoc : Con15 -> Ty15 -> Con15)\n -> Con15\n\nnil15 : Con15\nnil15 = \\ con, nil15, snoc => nil15\n\nsnoc15 : Con15 -> Ty15 -> Con15\nsnoc15 = \\ g, a, con, nil15, snoc15 => snoc15 (g con nil15 snoc15) a\n\nVar15 : Con15 -> Ty15 -> Type\nVar15 = \\ g, a =>\n (Var15 : Con15 -> Ty15 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var15 (snoc15 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var15 g a -> Var15 (snoc15 g b) a)\n -> Var15 g a\n\nvz15 : {g : _}-> {a : _} -> Var15 (snoc15 g a) a\nvz15 = \\ var, vz15, vs => vz15 _ _\n\nvs15 : {g : _} -> {B : _} -> {a : _} -> Var15 g a -> Var15 (snoc15 g B) a\nvs15 = \\ x, var, vz15, vs15 => vs15 _ _ _ (x var vz15 vs15)\n\nTm15 : Con15 -> Ty15 -> Type\nTm15 = \\ g, a =>\n (Tm15 : Con15 -> Ty15 -> Type)\n -> (var : (g : _) -> (a : _) -> Var15 g a -> Tm15 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm15 (snoc15 g a) B -> Tm15 g (arr15 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm15 g (arr15 a B) -> Tm15 g a -> Tm15 g B)\n -> Tm15 g a\n\nvar15 : {g : _} -> {a : _} -> Var15 g a -> Tm15 g a\nvar15 = \\ x, tm, var15, lam, app => var15 _ _ x\n\nlam15 : {g : _} -> {a : _} -> {B : _} -> Tm15 (snoc15 g a) B -> Tm15 g (arr15 a B)\nlam15 = \\ t, tm, var15, lam15, app => lam15 _ _ _ (t tm var15 lam15 app)\n\napp15 : {g:_}->{a:_}->{B:_} -> Tm15 g (arr15 a B) -> Tm15 g a -> Tm15 g B\napp15 = \\ t, u, tm, var15, lam15, app15 => app15 _ _ _ (t tm var15 lam15 app15) (u tm var15 lam15 app15)\n\nv015 : {g:_}->{a:_} -> Tm15 (snoc15 g a) a\nv015 = var15 vz15\n\nv115 : {g:_}->{a:_}-> {B:_}-> Tm15 (snoc15 (snoc15 g a) B) a\nv115 = var15 (vs15 vz15)\n\nv215 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm15 (snoc15 (snoc15 (snoc15 g a) B) C) a\nv215 = var15 (vs15 (vs15 vz15))\n\nv315 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm15 (snoc15 (snoc15 (snoc15 (snoc15 g a) B) C) D) a\nv315 = var15 (vs15 (vs15 (vs15 vz15)))\n\nv415 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm15 (snoc15 (snoc15 (snoc15 (snoc15 (snoc15 g a) B) C) D) E) a\nv415 = var15 (vs15 (vs15 (vs15 (vs15 vz15))))\n\ntest15 : {g:_}-> {a:_} -> Tm15 g (arr15 (arr15 a a) (arr15 a a))\ntest15 = lam15 (lam15 (app15 v115 (app15 v115 (app15 v115 (app15 v115 (app15 v115 (app15 v115 v015)))))))\nTy16 : Type\nTy16 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty16 : Ty16\nempty16 = \\ _, empty, _ => empty\n\narr16 : Ty16 -> Ty16 -> Ty16\narr16 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon16 : Type\nCon16 = (Con16 : Type)\n ->(nil : Con16)\n ->(snoc : Con16 -> Ty16 -> Con16)\n -> Con16\n\nnil16 : Con16\nnil16 = \\ con, nil16, snoc => nil16\n\nsnoc16 : Con16 -> Ty16 -> Con16\nsnoc16 = \\ g, a, con, nil16, snoc16 => snoc16 (g con nil16 snoc16) a\n\nVar16 : Con16 -> Ty16 -> Type\nVar16 = \\ g, a =>\n (Var16 : Con16 -> Ty16 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var16 (snoc16 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var16 g a -> Var16 (snoc16 g b) a)\n -> Var16 g a\n\nvz16 : {g : _}-> {a : _} -> Var16 (snoc16 g a) a\nvz16 = \\ var, vz16, vs => vz16 _ _\n\nvs16 : {g : _} -> {B : _} -> {a : _} -> Var16 g a -> Var16 (snoc16 g B) a\nvs16 = \\ x, var, vz16, vs16 => vs16 _ _ _ (x var vz16 vs16)\n\nTm16 : Con16 -> Ty16 -> Type\nTm16 = \\ g, a =>\n (Tm16 : Con16 -> Ty16 -> Type)\n -> (var : (g : _) -> (a : _) -> Var16 g a -> Tm16 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm16 (snoc16 g a) B -> Tm16 g (arr16 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm16 g (arr16 a B) -> Tm16 g a -> Tm16 g B)\n -> Tm16 g a\n\nvar16 : {g : _} -> {a : _} -> Var16 g a -> Tm16 g a\nvar16 = \\ x, tm, var16, lam, app => var16 _ _ x\n\nlam16 : {g : _} -> {a : _} -> {B : _} -> Tm16 (snoc16 g a) B -> Tm16 g (arr16 a B)\nlam16 = \\ t, tm, var16, lam16, app => lam16 _ _ _ (t tm var16 lam16 app)\n\napp16 : {g:_}->{a:_}->{B:_} -> Tm16 g (arr16 a B) -> Tm16 g a -> Tm16 g B\napp16 = \\ t, u, tm, var16, lam16, app16 => app16 _ _ _ (t tm var16 lam16 app16) (u tm var16 lam16 app16)\n\nv016 : {g:_}->{a:_} -> Tm16 (snoc16 g a) a\nv016 = var16 vz16\n\nv116 : {g:_}->{a:_}-> {B:_}-> Tm16 (snoc16 (snoc16 g a) B) a\nv116 = var16 (vs16 vz16)\n\nv216 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm16 (snoc16 (snoc16 (snoc16 g a) B) C) a\nv216 = var16 (vs16 (vs16 vz16))\n\nv316 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm16 (snoc16 (snoc16 (snoc16 (snoc16 g a) B) C) D) a\nv316 = var16 (vs16 (vs16 (vs16 vz16)))\n\nv416 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm16 (snoc16 (snoc16 (snoc16 (snoc16 (snoc16 g a) B) C) D) E) a\nv416 = var16 (vs16 (vs16 (vs16 (vs16 vz16))))\n\ntest16 : {g:_}-> {a:_} -> Tm16 g (arr16 (arr16 a a) (arr16 a a))\ntest16 = lam16 (lam16 (app16 v116 (app16 v116 (app16 v116 (app16 v116 (app16 v116 (app16 v116 v016)))))))\nTy17 : Type\nTy17 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty17 : Ty17\nempty17 = \\ _, empty, _ => empty\n\narr17 : Ty17 -> Ty17 -> Ty17\narr17 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon17 : Type\nCon17 = (Con17 : Type)\n ->(nil : Con17)\n ->(snoc : Con17 -> Ty17 -> Con17)\n -> Con17\n\nnil17 : Con17\nnil17 = \\ con, nil17, snoc => nil17\n\nsnoc17 : Con17 -> Ty17 -> Con17\nsnoc17 = \\ g, a, con, nil17, snoc17 => snoc17 (g con nil17 snoc17) a\n\nVar17 : Con17 -> Ty17 -> Type\nVar17 = \\ g, a =>\n (Var17 : Con17 -> Ty17 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var17 (snoc17 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var17 g a -> Var17 (snoc17 g b) a)\n -> Var17 g a\n\nvz17 : {g : _}-> {a : _} -> Var17 (snoc17 g a) a\nvz17 = \\ var, vz17, vs => vz17 _ _\n\nvs17 : {g : _} -> {B : _} -> {a : _} -> Var17 g a -> Var17 (snoc17 g B) a\nvs17 = \\ x, var, vz17, vs17 => vs17 _ _ _ (x var vz17 vs17)\n\nTm17 : Con17 -> Ty17 -> Type\nTm17 = \\ g, a =>\n (Tm17 : Con17 -> Ty17 -> Type)\n -> (var : (g : _) -> (a : _) -> Var17 g a -> Tm17 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm17 (snoc17 g a) B -> Tm17 g (arr17 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm17 g (arr17 a B) -> Tm17 g a -> Tm17 g B)\n -> Tm17 g a\n\nvar17 : {g : _} -> {a : _} -> Var17 g a -> Tm17 g a\nvar17 = \\ x, tm, var17, lam, app => var17 _ _ x\n\nlam17 : {g : _} -> {a : _} -> {B : _} -> Tm17 (snoc17 g a) B -> Tm17 g (arr17 a B)\nlam17 = \\ t, tm, var17, lam17, app => lam17 _ _ _ (t tm var17 lam17 app)\n\napp17 : {g:_}->{a:_}->{B:_} -> Tm17 g (arr17 a B) -> Tm17 g a -> Tm17 g B\napp17 = \\ t, u, tm, var17, lam17, app17 => app17 _ _ _ (t tm var17 lam17 app17) (u tm var17 lam17 app17)\n\nv017 : {g:_}->{a:_} -> Tm17 (snoc17 g a) a\nv017 = var17 vz17\n\nv117 : {g:_}->{a:_}-> {B:_}-> Tm17 (snoc17 (snoc17 g a) B) a\nv117 = var17 (vs17 vz17)\n\nv217 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm17 (snoc17 (snoc17 (snoc17 g a) B) C) a\nv217 = var17 (vs17 (vs17 vz17))\n\nv317 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm17 (snoc17 (snoc17 (snoc17 (snoc17 g a) B) C) D) a\nv317 = var17 (vs17 (vs17 (vs17 vz17)))\n\nv417 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm17 (snoc17 (snoc17 (snoc17 (snoc17 (snoc17 g a) B) C) D) E) a\nv417 = var17 (vs17 (vs17 (vs17 (vs17 vz17))))\n\ntest17 : {g:_}-> {a:_} -> Tm17 g (arr17 (arr17 a a) (arr17 a a))\ntest17 = lam17 (lam17 (app17 v117 (app17 v117 (app17 v117 (app17 v117 (app17 v117 (app17 v117 v017)))))))\nTy18 : Type\nTy18 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty18 : Ty18\nempty18 = \\ _, empty, _ => empty\n\narr18 : Ty18 -> Ty18 -> Ty18\narr18 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon18 : Type\nCon18 = (Con18 : Type)\n ->(nil : Con18)\n ->(snoc : Con18 -> Ty18 -> Con18)\n -> Con18\n\nnil18 : Con18\nnil18 = \\ con, nil18, snoc => nil18\n\nsnoc18 : Con18 -> Ty18 -> Con18\nsnoc18 = \\ g, a, con, nil18, snoc18 => snoc18 (g con nil18 snoc18) a\n\nVar18 : Con18 -> Ty18 -> Type\nVar18 = \\ g, a =>\n (Var18 : Con18 -> Ty18 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var18 (snoc18 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var18 g a -> Var18 (snoc18 g b) a)\n -> Var18 g a\n\nvz18 : {g : _}-> {a : _} -> Var18 (snoc18 g a) a\nvz18 = \\ var, vz18, vs => vz18 _ _\n\nvs18 : {g : _} -> {B : _} -> {a : _} -> Var18 g a -> Var18 (snoc18 g B) a\nvs18 = \\ x, var, vz18, vs18 => vs18 _ _ _ (x var vz18 vs18)\n\nTm18 : Con18 -> Ty18 -> Type\nTm18 = \\ g, a =>\n (Tm18 : Con18 -> Ty18 -> Type)\n -> (var : (g : _) -> (a : _) -> Var18 g a -> Tm18 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm18 (snoc18 g a) B -> Tm18 g (arr18 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm18 g (arr18 a B) -> Tm18 g a -> Tm18 g B)\n -> Tm18 g a\n\nvar18 : {g : _} -> {a : _} -> Var18 g a -> Tm18 g a\nvar18 = \\ x, tm, var18, lam, app => var18 _ _ x\n\nlam18 : {g : _} -> {a : _} -> {B : _} -> Tm18 (snoc18 g a) B -> Tm18 g (arr18 a B)\nlam18 = \\ t, tm, var18, lam18, app => lam18 _ _ _ (t tm var18 lam18 app)\n\napp18 : {g:_}->{a:_}->{B:_} -> Tm18 g (arr18 a B) -> Tm18 g a -> Tm18 g B\napp18 = \\ t, u, tm, var18, lam18, app18 => app18 _ _ _ (t tm var18 lam18 app18) (u tm var18 lam18 app18)\n\nv018 : {g:_}->{a:_} -> Tm18 (snoc18 g a) a\nv018 = var18 vz18\n\nv118 : {g:_}->{a:_}-> {B:_}-> Tm18 (snoc18 (snoc18 g a) B) a\nv118 = var18 (vs18 vz18)\n\nv218 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm18 (snoc18 (snoc18 (snoc18 g a) B) C) a\nv218 = var18 (vs18 (vs18 vz18))\n\nv318 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm18 (snoc18 (snoc18 (snoc18 (snoc18 g a) B) C) D) a\nv318 = var18 (vs18 (vs18 (vs18 vz18)))\n\nv418 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm18 (snoc18 (snoc18 (snoc18 (snoc18 (snoc18 g a) B) C) D) E) a\nv418 = var18 (vs18 (vs18 (vs18 (vs18 vz18))))\n\ntest18 : {g:_}-> {a:_} -> Tm18 g (arr18 (arr18 a a) (arr18 a a))\ntest18 = lam18 (lam18 (app18 v118 (app18 v118 (app18 v118 (app18 v118 (app18 v118 (app18 v118 v018)))))))\nTy19 : Type\nTy19 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty19 : Ty19\nempty19 = \\ _, empty, _ => empty\n\narr19 : Ty19 -> Ty19 -> Ty19\narr19 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon19 : Type\nCon19 = (Con19 : Type)\n ->(nil : Con19)\n ->(snoc : Con19 -> Ty19 -> Con19)\n -> Con19\n\nnil19 : Con19\nnil19 = \\ con, nil19, snoc => nil19\n\nsnoc19 : Con19 -> Ty19 -> Con19\nsnoc19 = \\ g, a, con, nil19, snoc19 => snoc19 (g con nil19 snoc19) a\n\nVar19 : Con19 -> Ty19 -> Type\nVar19 = \\ g, a =>\n (Var19 : Con19 -> Ty19 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var19 (snoc19 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var19 g a -> Var19 (snoc19 g b) a)\n -> Var19 g a\n\nvz19 : {g : _}-> {a : _} -> Var19 (snoc19 g a) a\nvz19 = \\ var, vz19, vs => vz19 _ _\n\nvs19 : {g : _} -> {B : _} -> {a : _} -> Var19 g a -> Var19 (snoc19 g B) a\nvs19 = \\ x, var, vz19, vs19 => vs19 _ _ _ (x var vz19 vs19)\n\nTm19 : Con19 -> Ty19 -> Type\nTm19 = \\ g, a =>\n (Tm19 : Con19 -> Ty19 -> Type)\n -> (var : (g : _) -> (a : _) -> Var19 g a -> Tm19 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm19 (snoc19 g a) B -> Tm19 g (arr19 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm19 g (arr19 a B) -> Tm19 g a -> Tm19 g B)\n -> Tm19 g a\n\nvar19 : {g : _} -> {a : _} -> Var19 g a -> Tm19 g a\nvar19 = \\ x, tm, var19, lam, app => var19 _ _ x\n\nlam19 : {g : _} -> {a : _} -> {B : _} -> Tm19 (snoc19 g a) B -> Tm19 g (arr19 a B)\nlam19 = \\ t, tm, var19, lam19, app => lam19 _ _ _ (t tm var19 lam19 app)\n\napp19 : {g:_}->{a:_}->{B:_} -> Tm19 g (arr19 a B) -> Tm19 g a -> Tm19 g B\napp19 = \\ t, u, tm, var19, lam19, app19 => app19 _ _ _ (t tm var19 lam19 app19) (u tm var19 lam19 app19)\n\nv019 : {g:_}->{a:_} -> Tm19 (snoc19 g a) a\nv019 = var19 vz19\n\nv119 : {g:_}->{a:_}-> {B:_}-> Tm19 (snoc19 (snoc19 g a) B) a\nv119 = var19 (vs19 vz19)\n\nv219 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm19 (snoc19 (snoc19 (snoc19 g a) B) C) a\nv219 = var19 (vs19 (vs19 vz19))\n\nv319 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm19 (snoc19 (snoc19 (snoc19 (snoc19 g a) B) C) D) a\nv319 = var19 (vs19 (vs19 (vs19 vz19)))\n\nv419 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm19 (snoc19 (snoc19 (snoc19 (snoc19 (snoc19 g a) B) C) D) E) a\nv419 = var19 (vs19 (vs19 (vs19 (vs19 vz19))))\n\ntest19 : {g:_}-> {a:_} -> Tm19 g (arr19 (arr19 a a) (arr19 a a))\ntest19 = lam19 (lam19 (app19 v119 (app19 v119 (app19 v119 (app19 v119 (app19 v119 (app19 v119 v019)))))))\nTy20 : Type\nTy20 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty20 : Ty20\nempty20 = \\ _, empty, _ => empty\n\narr20 : Ty20 -> Ty20 -> Ty20\narr20 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon20 : Type\nCon20 = (Con20 : Type)\n ->(nil : Con20)\n ->(snoc : Con20 -> Ty20 -> Con20)\n -> Con20\n\nnil20 : Con20\nnil20 = \\ con, nil20, snoc => nil20\n\nsnoc20 : Con20 -> Ty20 -> Con20\nsnoc20 = \\ g, a, con, nil20, snoc20 => snoc20 (g con nil20 snoc20) a\n\nVar20 : Con20 -> Ty20 -> Type\nVar20 = \\ g, a =>\n (Var20 : Con20 -> Ty20 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var20 (snoc20 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var20 g a -> Var20 (snoc20 g b) a)\n -> Var20 g a\n\nvz20 : {g : _}-> {a : _} -> Var20 (snoc20 g a) a\nvz20 = \\ var, vz20, vs => vz20 _ _\n\nvs20 : {g : _} -> {B : _} -> {a : _} -> Var20 g a -> Var20 (snoc20 g B) a\nvs20 = \\ x, var, vz20, vs20 => vs20 _ _ _ (x var vz20 vs20)\n\nTm20 : Con20 -> Ty20 -> Type\nTm20 = \\ g, a =>\n (Tm20 : Con20 -> Ty20 -> Type)\n -> (var : (g : _) -> (a : _) -> Var20 g a -> Tm20 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm20 (snoc20 g a) B -> Tm20 g (arr20 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm20 g (arr20 a B) -> Tm20 g a -> Tm20 g B)\n -> Tm20 g a\n\nvar20 : {g : _} -> {a : _} -> Var20 g a -> Tm20 g a\nvar20 = \\ x, tm, var20, lam, app => var20 _ _ x\n\nlam20 : {g : _} -> {a : _} -> {B : _} -> Tm20 (snoc20 g a) B -> Tm20 g (arr20 a B)\nlam20 = \\ t, tm, var20, lam20, app => lam20 _ _ _ (t tm var20 lam20 app)\n\napp20 : {g:_}->{a:_}->{B:_} -> Tm20 g (arr20 a B) -> Tm20 g a -> Tm20 g B\napp20 = \\ t, u, tm, var20, lam20, app20 => app20 _ _ _ (t tm var20 lam20 app20) (u tm var20 lam20 app20)\n\nv020 : {g:_}->{a:_} -> Tm20 (snoc20 g a) a\nv020 = var20 vz20\n\nv120 : {g:_}->{a:_}-> {B:_}-> Tm20 (snoc20 (snoc20 g a) B) a\nv120 = var20 (vs20 vz20)\n\nv220 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm20 (snoc20 (snoc20 (snoc20 g a) B) C) a\nv220 = var20 (vs20 (vs20 vz20))\n\nv320 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm20 (snoc20 (snoc20 (snoc20 (snoc20 g a) B) C) D) a\nv320 = var20 (vs20 (vs20 (vs20 vz20)))\n\nv420 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm20 (snoc20 (snoc20 (snoc20 (snoc20 (snoc20 g a) B) C) D) E) a\nv420 = var20 (vs20 (vs20 (vs20 (vs20 vz20))))\n\ntest20 : {g:_}-> {a:_} -> Tm20 g (arr20 (arr20 a a) (arr20 a a))\ntest20 = lam20 (lam20 (app20 v120 (app20 v120 (app20 v120 (app20 v120 (app20 v120 (app20 v120 v020)))))))\nTy21 : Type\nTy21 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty21 : Ty21\nempty21 = \\ _, empty, _ => empty\n\narr21 : Ty21 -> Ty21 -> Ty21\narr21 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon21 : Type\nCon21 = (Con21 : Type)\n ->(nil : Con21)\n ->(snoc : Con21 -> Ty21 -> Con21)\n -> Con21\n\nnil21 : Con21\nnil21 = \\ con, nil21, snoc => nil21\n\nsnoc21 : Con21 -> Ty21 -> Con21\nsnoc21 = \\ g, a, con, nil21, snoc21 => snoc21 (g con nil21 snoc21) a\n\nVar21 : Con21 -> Ty21 -> Type\nVar21 = \\ g, a =>\n (Var21 : Con21 -> Ty21 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var21 (snoc21 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var21 g a -> Var21 (snoc21 g b) a)\n -> Var21 g a\n\nvz21 : {g : _}-> {a : _} -> Var21 (snoc21 g a) a\nvz21 = \\ var, vz21, vs => vz21 _ _\n\nvs21 : {g : _} -> {B : _} -> {a : _} -> Var21 g a -> Var21 (snoc21 g B) a\nvs21 = \\ x, var, vz21, vs21 => vs21 _ _ _ (x var vz21 vs21)\n\nTm21 : Con21 -> Ty21 -> Type\nTm21 = \\ g, a =>\n (Tm21 : Con21 -> Ty21 -> Type)\n -> (var : (g : _) -> (a : _) -> Var21 g a -> Tm21 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm21 (snoc21 g a) B -> Tm21 g (arr21 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm21 g (arr21 a B) -> Tm21 g a -> Tm21 g B)\n -> Tm21 g a\n\nvar21 : {g : _} -> {a : _} -> Var21 g a -> Tm21 g a\nvar21 = \\ x, tm, var21, lam, app => var21 _ _ x\n\nlam21 : {g : _} -> {a : _} -> {B : _} -> Tm21 (snoc21 g a) B -> Tm21 g (arr21 a B)\nlam21 = \\ t, tm, var21, lam21, app => lam21 _ _ _ (t tm var21 lam21 app)\n\napp21 : {g:_}->{a:_}->{B:_} -> Tm21 g (arr21 a B) -> Tm21 g a -> Tm21 g B\napp21 = \\ t, u, tm, var21, lam21, app21 => app21 _ _ _ (t tm var21 lam21 app21) (u tm var21 lam21 app21)\n\nv021 : {g:_}->{a:_} -> Tm21 (snoc21 g a) a\nv021 = var21 vz21\n\nv121 : {g:_}->{a:_}-> {B:_}-> Tm21 (snoc21 (snoc21 g a) B) a\nv121 = var21 (vs21 vz21)\n\nv221 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm21 (snoc21 (snoc21 (snoc21 g a) B) C) a\nv221 = var21 (vs21 (vs21 vz21))\n\nv321 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm21 (snoc21 (snoc21 (snoc21 (snoc21 g a) B) C) D) a\nv321 = var21 (vs21 (vs21 (vs21 vz21)))\n\nv421 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm21 (snoc21 (snoc21 (snoc21 (snoc21 (snoc21 g a) B) C) D) E) a\nv421 = var21 (vs21 (vs21 (vs21 (vs21 vz21))))\n\ntest21 : {g:_}-> {a:_} -> Tm21 g (arr21 (arr21 a a) (arr21 a a))\ntest21 = lam21 (lam21 (app21 v121 (app21 v121 (app21 v121 (app21 v121 (app21 v121 (app21 v121 v021)))))))\nTy22 : Type\nTy22 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty22 : Ty22\nempty22 = \\ _, empty, _ => empty\n\narr22 : Ty22 -> Ty22 -> Ty22\narr22 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon22 : Type\nCon22 = (Con22 : Type)\n ->(nil : Con22)\n ->(snoc : Con22 -> Ty22 -> Con22)\n -> Con22\n\nnil22 : Con22\nnil22 = \\ con, nil22, snoc => nil22\n\nsnoc22 : Con22 -> Ty22 -> Con22\nsnoc22 = \\ g, a, con, nil22, snoc22 => snoc22 (g con nil22 snoc22) a\n\nVar22 : Con22 -> Ty22 -> Type\nVar22 = \\ g, a =>\n (Var22 : Con22 -> Ty22 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var22 (snoc22 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var22 g a -> Var22 (snoc22 g b) a)\n -> Var22 g a\n\nvz22 : {g : _}-> {a : _} -> Var22 (snoc22 g a) a\nvz22 = \\ var, vz22, vs => vz22 _ _\n\nvs22 : {g : _} -> {B : _} -> {a : _} -> Var22 g a -> Var22 (snoc22 g B) a\nvs22 = \\ x, var, vz22, vs22 => vs22 _ _ _ (x var vz22 vs22)\n\nTm22 : Con22 -> Ty22 -> Type\nTm22 = \\ g, a =>\n (Tm22 : Con22 -> Ty22 -> Type)\n -> (var : (g : _) -> (a : _) -> Var22 g a -> Tm22 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm22 (snoc22 g a) B -> Tm22 g (arr22 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm22 g (arr22 a B) -> Tm22 g a -> Tm22 g B)\n -> Tm22 g a\n\nvar22 : {g : _} -> {a : _} -> Var22 g a -> Tm22 g a\nvar22 = \\ x, tm, var22, lam, app => var22 _ _ x\n\nlam22 : {g : _} -> {a : _} -> {B : _} -> Tm22 (snoc22 g a) B -> Tm22 g (arr22 a B)\nlam22 = \\ t, tm, var22, lam22, app => lam22 _ _ _ (t tm var22 lam22 app)\n\napp22 : {g:_}->{a:_}->{B:_} -> Tm22 g (arr22 a B) -> Tm22 g a -> Tm22 g B\napp22 = \\ t, u, tm, var22, lam22, app22 => app22 _ _ _ (t tm var22 lam22 app22) (u tm var22 lam22 app22)\n\nv022 : {g:_}->{a:_} -> Tm22 (snoc22 g a) a\nv022 = var22 vz22\n\nv122 : {g:_}->{a:_}-> {B:_}-> Tm22 (snoc22 (snoc22 g a) B) a\nv122 = var22 (vs22 vz22)\n\nv222 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm22 (snoc22 (snoc22 (snoc22 g a) B) C) a\nv222 = var22 (vs22 (vs22 vz22))\n\nv322 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm22 (snoc22 (snoc22 (snoc22 (snoc22 g a) B) C) D) a\nv322 = var22 (vs22 (vs22 (vs22 vz22)))\n\nv422 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm22 (snoc22 (snoc22 (snoc22 (snoc22 (snoc22 g a) B) C) D) E) a\nv422 = var22 (vs22 (vs22 (vs22 (vs22 vz22))))\n\ntest22 : {g:_}-> {a:_} -> Tm22 g (arr22 (arr22 a a) (arr22 a a))\ntest22 = lam22 (lam22 (app22 v122 (app22 v122 (app22 v122 (app22 v122 (app22 v122 (app22 v122 v022)))))))\nTy23 : Type\nTy23 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty23 : Ty23\nempty23 = \\ _, empty, _ => empty\n\narr23 : Ty23 -> Ty23 -> Ty23\narr23 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon23 : Type\nCon23 = (Con23 : Type)\n ->(nil : Con23)\n ->(snoc : Con23 -> Ty23 -> Con23)\n -> Con23\n\nnil23 : Con23\nnil23 = \\ con, nil23, snoc => nil23\n\nsnoc23 : Con23 -> Ty23 -> Con23\nsnoc23 = \\ g, a, con, nil23, snoc23 => snoc23 (g con nil23 snoc23) a\n\nVar23 : Con23 -> Ty23 -> Type\nVar23 = \\ g, a =>\n (Var23 : Con23 -> Ty23 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var23 (snoc23 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var23 g a -> Var23 (snoc23 g b) a)\n -> Var23 g a\n\nvz23 : {g : _}-> {a : _} -> Var23 (snoc23 g a) a\nvz23 = \\ var, vz23, vs => vz23 _ _\n\nvs23 : {g : _} -> {B : _} -> {a : _} -> Var23 g a -> Var23 (snoc23 g B) a\nvs23 = \\ x, var, vz23, vs23 => vs23 _ _ _ (x var vz23 vs23)\n\nTm23 : Con23 -> Ty23 -> Type\nTm23 = \\ g, a =>\n (Tm23 : Con23 -> Ty23 -> Type)\n -> (var : (g : _) -> (a : _) -> Var23 g a -> Tm23 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm23 (snoc23 g a) B -> Tm23 g (arr23 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm23 g (arr23 a B) -> Tm23 g a -> Tm23 g B)\n -> Tm23 g a\n\nvar23 : {g : _} -> {a : _} -> Var23 g a -> Tm23 g a\nvar23 = \\ x, tm, var23, lam, app => var23 _ _ x\n\nlam23 : {g : _} -> {a : _} -> {B : _} -> Tm23 (snoc23 g a) B -> Tm23 g (arr23 a B)\nlam23 = \\ t, tm, var23, lam23, app => lam23 _ _ _ (t tm var23 lam23 app)\n\napp23 : {g:_}->{a:_}->{B:_} -> Tm23 g (arr23 a B) -> Tm23 g a -> Tm23 g B\napp23 = \\ t, u, tm, var23, lam23, app23 => app23 _ _ _ (t tm var23 lam23 app23) (u tm var23 lam23 app23)\n\nv023 : {g:_}->{a:_} -> Tm23 (snoc23 g a) a\nv023 = var23 vz23\n\nv123 : {g:_}->{a:_}-> {B:_}-> Tm23 (snoc23 (snoc23 g a) B) a\nv123 = var23 (vs23 vz23)\n\nv223 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm23 (snoc23 (snoc23 (snoc23 g a) B) C) a\nv223 = var23 (vs23 (vs23 vz23))\n\nv323 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm23 (snoc23 (snoc23 (snoc23 (snoc23 g a) B) C) D) a\nv323 = var23 (vs23 (vs23 (vs23 vz23)))\n\nv423 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm23 (snoc23 (snoc23 (snoc23 (snoc23 (snoc23 g a) B) C) D) E) a\nv423 = var23 (vs23 (vs23 (vs23 (vs23 vz23))))\n\ntest23 : {g:_}-> {a:_} -> Tm23 g (arr23 (arr23 a a) (arr23 a a))\ntest23 = lam23 (lam23 (app23 v123 (app23 v123 (app23 v123 (app23 v123 (app23 v123 (app23 v123 v023)))))))\nTy24 : Type\nTy24 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty24 : Ty24\nempty24 = \\ _, empty, _ => empty\n\narr24 : Ty24 -> Ty24 -> Ty24\narr24 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon24 : Type\nCon24 = (Con24 : Type)\n ->(nil : Con24)\n ->(snoc : Con24 -> Ty24 -> Con24)\n -> Con24\n\nnil24 : Con24\nnil24 = \\ con, nil24, snoc => nil24\n\nsnoc24 : Con24 -> Ty24 -> Con24\nsnoc24 = \\ g, a, con, nil24, snoc24 => snoc24 (g con nil24 snoc24) a\n\nVar24 : Con24 -> Ty24 -> Type\nVar24 = \\ g, a =>\n (Var24 : Con24 -> Ty24 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var24 (snoc24 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var24 g a -> Var24 (snoc24 g b) a)\n -> Var24 g a\n\nvz24 : {g : _}-> {a : _} -> Var24 (snoc24 g a) a\nvz24 = \\ var, vz24, vs => vz24 _ _\n\nvs24 : {g : _} -> {B : _} -> {a : _} -> Var24 g a -> Var24 (snoc24 g B) a\nvs24 = \\ x, var, vz24, vs24 => vs24 _ _ _ (x var vz24 vs24)\n\nTm24 : Con24 -> Ty24 -> Type\nTm24 = \\ g, a =>\n (Tm24 : Con24 -> Ty24 -> Type)\n -> (var : (g : _) -> (a : _) -> Var24 g a -> Tm24 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm24 (snoc24 g a) B -> Tm24 g (arr24 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm24 g (arr24 a B) -> Tm24 g a -> Tm24 g B)\n -> Tm24 g a\n\nvar24 : {g : _} -> {a : _} -> Var24 g a -> Tm24 g a\nvar24 = \\ x, tm, var24, lam, app => var24 _ _ x\n\nlam24 : {g : _} -> {a : _} -> {B : _} -> Tm24 (snoc24 g a) B -> Tm24 g (arr24 a B)\nlam24 = \\ t, tm, var24, lam24, app => lam24 _ _ _ (t tm var24 lam24 app)\n\napp24 : {g:_}->{a:_}->{B:_} -> Tm24 g (arr24 a B) -> Tm24 g a -> Tm24 g B\napp24 = \\ t, u, tm, var24, lam24, app24 => app24 _ _ _ (t tm var24 lam24 app24) (u tm var24 lam24 app24)\n\nv024 : {g:_}->{a:_} -> Tm24 (snoc24 g a) a\nv024 = var24 vz24\n\nv124 : {g:_}->{a:_}-> {B:_}-> Tm24 (snoc24 (snoc24 g a) B) a\nv124 = var24 (vs24 vz24)\n\nv224 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm24 (snoc24 (snoc24 (snoc24 g a) B) C) a\nv224 = var24 (vs24 (vs24 vz24))\n\nv324 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm24 (snoc24 (snoc24 (snoc24 (snoc24 g a) B) C) D) a\nv324 = var24 (vs24 (vs24 (vs24 vz24)))\n\nv424 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm24 (snoc24 (snoc24 (snoc24 (snoc24 (snoc24 g a) B) C) D) E) a\nv424 = var24 (vs24 (vs24 (vs24 (vs24 vz24))))\n\ntest24 : {g:_}-> {a:_} -> Tm24 g (arr24 (arr24 a a) (arr24 a a))\ntest24 = lam24 (lam24 (app24 v124 (app24 v124 (app24 v124 (app24 v124 (app24 v124 (app24 v124 v024)))))))\nTy25 : Type\nTy25 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty25 : Ty25\nempty25 = \\ _, empty, _ => empty\n\narr25 : Ty25 -> Ty25 -> Ty25\narr25 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon25 : Type\nCon25 = (Con25 : Type)\n ->(nil : Con25)\n ->(snoc : Con25 -> Ty25 -> Con25)\n -> Con25\n\nnil25 : Con25\nnil25 = \\ con, nil25, snoc => nil25\n\nsnoc25 : Con25 -> Ty25 -> Con25\nsnoc25 = \\ g, a, con, nil25, snoc25 => snoc25 (g con nil25 snoc25) a\n\nVar25 : Con25 -> Ty25 -> Type\nVar25 = \\ g, a =>\n (Var25 : Con25 -> Ty25 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var25 (snoc25 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var25 g a -> Var25 (snoc25 g b) a)\n -> Var25 g a\n\nvz25 : {g : _}-> {a : _} -> Var25 (snoc25 g a) a\nvz25 = \\ var, vz25, vs => vz25 _ _\n\nvs25 : {g : _} -> {B : _} -> {a : _} -> Var25 g a -> Var25 (snoc25 g B) a\nvs25 = \\ x, var, vz25, vs25 => vs25 _ _ _ (x var vz25 vs25)\n\nTm25 : Con25 -> Ty25 -> Type\nTm25 = \\ g, a =>\n (Tm25 : Con25 -> Ty25 -> Type)\n -> (var : (g : _) -> (a : _) -> Var25 g a -> Tm25 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm25 (snoc25 g a) B -> Tm25 g (arr25 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm25 g (arr25 a B) -> Tm25 g a -> Tm25 g B)\n -> Tm25 g a\n\nvar25 : {g : _} -> {a : _} -> Var25 g a -> Tm25 g a\nvar25 = \\ x, tm, var25, lam, app => var25 _ _ x\n\nlam25 : {g : _} -> {a : _} -> {B : _} -> Tm25 (snoc25 g a) B -> Tm25 g (arr25 a B)\nlam25 = \\ t, tm, var25, lam25, app => lam25 _ _ _ (t tm var25 lam25 app)\n\napp25 : {g:_}->{a:_}->{B:_} -> Tm25 g (arr25 a B) -> Tm25 g a -> Tm25 g B\napp25 = \\ t, u, tm, var25, lam25, app25 => app25 _ _ _ (t tm var25 lam25 app25) (u tm var25 lam25 app25)\n\nv025 : {g:_}->{a:_} -> Tm25 (snoc25 g a) a\nv025 = var25 vz25\n\nv125 : {g:_}->{a:_}-> {B:_}-> Tm25 (snoc25 (snoc25 g a) B) a\nv125 = var25 (vs25 vz25)\n\nv225 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm25 (snoc25 (snoc25 (snoc25 g a) B) C) a\nv225 = var25 (vs25 (vs25 vz25))\n\nv325 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm25 (snoc25 (snoc25 (snoc25 (snoc25 g a) B) C) D) a\nv325 = var25 (vs25 (vs25 (vs25 vz25)))\n\nv425 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm25 (snoc25 (snoc25 (snoc25 (snoc25 (snoc25 g a) B) C) D) E) a\nv425 = var25 (vs25 (vs25 (vs25 (vs25 vz25))))\n\ntest25 : {g:_}-> {a:_} -> Tm25 g (arr25 (arr25 a a) (arr25 a a))\ntest25 = lam25 (lam25 (app25 v125 (app25 v125 (app25 v125 (app25 v125 (app25 v125 (app25 v125 v025)))))))\nTy26 : Type\nTy26 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty26 : Ty26\nempty26 = \\ _, empty, _ => empty\n\narr26 : Ty26 -> Ty26 -> Ty26\narr26 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon26 : Type\nCon26 = (Con26 : Type)\n ->(nil : Con26)\n ->(snoc : Con26 -> Ty26 -> Con26)\n -> Con26\n\nnil26 : Con26\nnil26 = \\ con, nil26, snoc => nil26\n\nsnoc26 : Con26 -> Ty26 -> Con26\nsnoc26 = \\ g, a, con, nil26, snoc26 => snoc26 (g con nil26 snoc26) a\n\nVar26 : Con26 -> Ty26 -> Type\nVar26 = \\ g, a =>\n (Var26 : Con26 -> Ty26 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var26 (snoc26 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var26 g a -> Var26 (snoc26 g b) a)\n -> Var26 g a\n\nvz26 : {g : _}-> {a : _} -> Var26 (snoc26 g a) a\nvz26 = \\ var, vz26, vs => vz26 _ _\n\nvs26 : {g : _} -> {B : _} -> {a : _} -> Var26 g a -> Var26 (snoc26 g B) a\nvs26 = \\ x, var, vz26, vs26 => vs26 _ _ _ (x var vz26 vs26)\n\nTm26 : Con26 -> Ty26 -> Type\nTm26 = \\ g, a =>\n (Tm26 : Con26 -> Ty26 -> Type)\n -> (var : (g : _) -> (a : _) -> Var26 g a -> Tm26 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm26 (snoc26 g a) B -> Tm26 g (arr26 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm26 g (arr26 a B) -> Tm26 g a -> Tm26 g B)\n -> Tm26 g a\n\nvar26 : {g : _} -> {a : _} -> Var26 g a -> Tm26 g a\nvar26 = \\ x, tm, var26, lam, app => var26 _ _ x\n\nlam26 : {g : _} -> {a : _} -> {B : _} -> Tm26 (snoc26 g a) B -> Tm26 g (arr26 a B)\nlam26 = \\ t, tm, var26, lam26, app => lam26 _ _ _ (t tm var26 lam26 app)\n\napp26 : {g:_}->{a:_}->{B:_} -> Tm26 g (arr26 a B) -> Tm26 g a -> Tm26 g B\napp26 = \\ t, u, tm, var26, lam26, app26 => app26 _ _ _ (t tm var26 lam26 app26) (u tm var26 lam26 app26)\n\nv026 : {g:_}->{a:_} -> Tm26 (snoc26 g a) a\nv026 = var26 vz26\n\nv126 : {g:_}->{a:_}-> {B:_}-> Tm26 (snoc26 (snoc26 g a) B) a\nv126 = var26 (vs26 vz26)\n\nv226 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm26 (snoc26 (snoc26 (snoc26 g a) B) C) a\nv226 = var26 (vs26 (vs26 vz26))\n\nv326 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm26 (snoc26 (snoc26 (snoc26 (snoc26 g a) B) C) D) a\nv326 = var26 (vs26 (vs26 (vs26 vz26)))\n\nv426 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm26 (snoc26 (snoc26 (snoc26 (snoc26 (snoc26 g a) B) C) D) E) a\nv426 = var26 (vs26 (vs26 (vs26 (vs26 vz26))))\n\ntest26 : {g:_}-> {a:_} -> Tm26 g (arr26 (arr26 a a) (arr26 a a))\ntest26 = lam26 (lam26 (app26 v126 (app26 v126 (app26 v126 (app26 v126 (app26 v126 (app26 v126 v026)))))))\nTy27 : Type\nTy27 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty27 : Ty27\nempty27 = \\ _, empty, _ => empty\n\narr27 : Ty27 -> Ty27 -> Ty27\narr27 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon27 : Type\nCon27 = (Con27 : Type)\n ->(nil : Con27)\n ->(snoc : Con27 -> Ty27 -> Con27)\n -> Con27\n\nnil27 : Con27\nnil27 = \\ con, nil27, snoc => nil27\n\nsnoc27 : Con27 -> Ty27 -> Con27\nsnoc27 = \\ g, a, con, nil27, snoc27 => snoc27 (g con nil27 snoc27) a\n\nVar27 : Con27 -> Ty27 -> Type\nVar27 = \\ g, a =>\n (Var27 : Con27 -> Ty27 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var27 (snoc27 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var27 g a -> Var27 (snoc27 g b) a)\n -> Var27 g a\n\nvz27 : {g : _}-> {a : _} -> Var27 (snoc27 g a) a\nvz27 = \\ var, vz27, vs => vz27 _ _\n\nvs27 : {g : _} -> {B : _} -> {a : _} -> Var27 g a -> Var27 (snoc27 g B) a\nvs27 = \\ x, var, vz27, vs27 => vs27 _ _ _ (x var vz27 vs27)\n\nTm27 : Con27 -> Ty27 -> Type\nTm27 = \\ g, a =>\n (Tm27 : Con27 -> Ty27 -> Type)\n -> (var : (g : _) -> (a : _) -> Var27 g a -> Tm27 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm27 (snoc27 g a) B -> Tm27 g (arr27 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm27 g (arr27 a B) -> Tm27 g a -> Tm27 g B)\n -> Tm27 g a\n\nvar27 : {g : _} -> {a : _} -> Var27 g a -> Tm27 g a\nvar27 = \\ x, tm, var27, lam, app => var27 _ _ x\n\nlam27 : {g : _} -> {a : _} -> {B : _} -> Tm27 (snoc27 g a) B -> Tm27 g (arr27 a B)\nlam27 = \\ t, tm, var27, lam27, app => lam27 _ _ _ (t tm var27 lam27 app)\n\napp27 : {g:_}->{a:_}->{B:_} -> Tm27 g (arr27 a B) -> Tm27 g a -> Tm27 g B\napp27 = \\ t, u, tm, var27, lam27, app27 => app27 _ _ _ (t tm var27 lam27 app27) (u tm var27 lam27 app27)\n\nv027 : {g:_}->{a:_} -> Tm27 (snoc27 g a) a\nv027 = var27 vz27\n\nv127 : {g:_}->{a:_}-> {B:_}-> Tm27 (snoc27 (snoc27 g a) B) a\nv127 = var27 (vs27 vz27)\n\nv227 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm27 (snoc27 (snoc27 (snoc27 g a) B) C) a\nv227 = var27 (vs27 (vs27 vz27))\n\nv327 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm27 (snoc27 (snoc27 (snoc27 (snoc27 g a) B) C) D) a\nv327 = var27 (vs27 (vs27 (vs27 vz27)))\n\nv427 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm27 (snoc27 (snoc27 (snoc27 (snoc27 (snoc27 g a) B) C) D) E) a\nv427 = var27 (vs27 (vs27 (vs27 (vs27 vz27))))\n\ntest27 : {g:_}-> {a:_} -> Tm27 g (arr27 (arr27 a a) (arr27 a a))\ntest27 = lam27 (lam27 (app27 v127 (app27 v127 (app27 v127 (app27 v127 (app27 v127 (app27 v127 v027)))))))\nTy28 : Type\nTy28 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty28 : Ty28\nempty28 = \\ _, empty, _ => empty\n\narr28 : Ty28 -> Ty28 -> Ty28\narr28 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon28 : Type\nCon28 = (Con28 : Type)\n ->(nil : Con28)\n ->(snoc : Con28 -> Ty28 -> Con28)\n -> Con28\n\nnil28 : Con28\nnil28 = \\ con, nil28, snoc => nil28\n\nsnoc28 : Con28 -> Ty28 -> Con28\nsnoc28 = \\ g, a, con, nil28, snoc28 => snoc28 (g con nil28 snoc28) a\n\nVar28 : Con28 -> Ty28 -> Type\nVar28 = \\ g, a =>\n (Var28 : Con28 -> Ty28 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var28 (snoc28 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var28 g a -> Var28 (snoc28 g b) a)\n -> Var28 g a\n\nvz28 : {g : _}-> {a : _} -> Var28 (snoc28 g a) a\nvz28 = \\ var, vz28, vs => vz28 _ _\n\nvs28 : {g : _} -> {B : _} -> {a : _} -> Var28 g a -> Var28 (snoc28 g B) a\nvs28 = \\ x, var, vz28, vs28 => vs28 _ _ _ (x var vz28 vs28)\n\nTm28 : Con28 -> Ty28 -> Type\nTm28 = \\ g, a =>\n (Tm28 : Con28 -> Ty28 -> Type)\n -> (var : (g : _) -> (a : _) -> Var28 g a -> Tm28 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm28 (snoc28 g a) B -> Tm28 g (arr28 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm28 g (arr28 a B) -> Tm28 g a -> Tm28 g B)\n -> Tm28 g a\n\nvar28 : {g : _} -> {a : _} -> Var28 g a -> Tm28 g a\nvar28 = \\ x, tm, var28, lam, app => var28 _ _ x\n\nlam28 : {g : _} -> {a : _} -> {B : _} -> Tm28 (snoc28 g a) B -> Tm28 g (arr28 a B)\nlam28 = \\ t, tm, var28, lam28, app => lam28 _ _ _ (t tm var28 lam28 app)\n\napp28 : {g:_}->{a:_}->{B:_} -> Tm28 g (arr28 a B) -> Tm28 g a -> Tm28 g B\napp28 = \\ t, u, tm, var28, lam28, app28 => app28 _ _ _ (t tm var28 lam28 app28) (u tm var28 lam28 app28)\n\nv028 : {g:_}->{a:_} -> Tm28 (snoc28 g a) a\nv028 = var28 vz28\n\nv128 : {g:_}->{a:_}-> {B:_}-> Tm28 (snoc28 (snoc28 g a) B) a\nv128 = var28 (vs28 vz28)\n\nv228 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm28 (snoc28 (snoc28 (snoc28 g a) B) C) a\nv228 = var28 (vs28 (vs28 vz28))\n\nv328 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm28 (snoc28 (snoc28 (snoc28 (snoc28 g a) B) C) D) a\nv328 = var28 (vs28 (vs28 (vs28 vz28)))\n\nv428 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm28 (snoc28 (snoc28 (snoc28 (snoc28 (snoc28 g a) B) C) D) E) a\nv428 = var28 (vs28 (vs28 (vs28 (vs28 vz28))))\n\ntest28 : {g:_}-> {a:_} -> Tm28 g (arr28 (arr28 a a) (arr28 a a))\ntest28 = lam28 (lam28 (app28 v128 (app28 v128 (app28 v128 (app28 v128 (app28 v128 (app28 v128 v028)))))))\nTy29 : Type\nTy29 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty29 : Ty29\nempty29 = \\ _, empty, _ => empty\n\narr29 : Ty29 -> Ty29 -> Ty29\narr29 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon29 : Type\nCon29 = (Con29 : Type)\n ->(nil : Con29)\n ->(snoc : Con29 -> Ty29 -> Con29)\n -> Con29\n\nnil29 : Con29\nnil29 = \\ con, nil29, snoc => nil29\n\nsnoc29 : Con29 -> Ty29 -> Con29\nsnoc29 = \\ g, a, con, nil29, snoc29 => snoc29 (g con nil29 snoc29) a\n\nVar29 : Con29 -> Ty29 -> Type\nVar29 = \\ g, a =>\n (Var29 : Con29 -> Ty29 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var29 (snoc29 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var29 g a -> Var29 (snoc29 g b) a)\n -> Var29 g a\n\nvz29 : {g : _}-> {a : _} -> Var29 (snoc29 g a) a\nvz29 = \\ var, vz29, vs => vz29 _ _\n\nvs29 : {g : _} -> {B : _} -> {a : _} -> Var29 g a -> Var29 (snoc29 g B) a\nvs29 = \\ x, var, vz29, vs29 => vs29 _ _ _ (x var vz29 vs29)\n\nTm29 : Con29 -> Ty29 -> Type\nTm29 = \\ g, a =>\n (Tm29 : Con29 -> Ty29 -> Type)\n -> (var : (g : _) -> (a : _) -> Var29 g a -> Tm29 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm29 (snoc29 g a) B -> Tm29 g (arr29 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm29 g (arr29 a B) -> Tm29 g a -> Tm29 g B)\n -> Tm29 g a\n\nvar29 : {g : _} -> {a : _} -> Var29 g a -> Tm29 g a\nvar29 = \\ x, tm, var29, lam, app => var29 _ _ x\n\nlam29 : {g : _} -> {a : _} -> {B : _} -> Tm29 (snoc29 g a) B -> Tm29 g (arr29 a B)\nlam29 = \\ t, tm, var29, lam29, app => lam29 _ _ _ (t tm var29 lam29 app)\n\napp29 : {g:_}->{a:_}->{B:_} -> Tm29 g (arr29 a B) -> Tm29 g a -> Tm29 g B\napp29 = \\ t, u, tm, var29, lam29, app29 => app29 _ _ _ (t tm var29 lam29 app29) (u tm var29 lam29 app29)\n\nv029 : {g:_}->{a:_} -> Tm29 (snoc29 g a) a\nv029 = var29 vz29\n\nv129 : {g:_}->{a:_}-> {B:_}-> Tm29 (snoc29 (snoc29 g a) B) a\nv129 = var29 (vs29 vz29)\n\nv229 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm29 (snoc29 (snoc29 (snoc29 g a) B) C) a\nv229 = var29 (vs29 (vs29 vz29))\n\nv329 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm29 (snoc29 (snoc29 (snoc29 (snoc29 g a) B) C) D) a\nv329 = var29 (vs29 (vs29 (vs29 vz29)))\n\nv429 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm29 (snoc29 (snoc29 (snoc29 (snoc29 (snoc29 g a) B) C) D) E) a\nv429 = var29 (vs29 (vs29 (vs29 (vs29 vz29))))\n\ntest29 : {g:_}-> {a:_} -> Tm29 g (arr29 (arr29 a a) (arr29 a a))\ntest29 = lam29 (lam29 (app29 v129 (app29 v129 (app29 v129 (app29 v129 (app29 v129 (app29 v129 v029)))))))\nTy30 : Type\nTy30 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty30 : Ty30\nempty30 = \\ _, empty, _ => empty\n\narr30 : Ty30 -> Ty30 -> Ty30\narr30 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon30 : Type\nCon30 = (Con30 : Type)\n ->(nil : Con30)\n ->(snoc : Con30 -> Ty30 -> Con30)\n -> Con30\n\nnil30 : Con30\nnil30 = \\ con, nil30, snoc => nil30\n\nsnoc30 : Con30 -> Ty30 -> Con30\nsnoc30 = \\ g, a, con, nil30, snoc30 => snoc30 (g con nil30 snoc30) a\n\nVar30 : Con30 -> Ty30 -> Type\nVar30 = \\ g, a =>\n (Var30 : Con30 -> Ty30 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var30 (snoc30 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var30 g a -> Var30 (snoc30 g b) a)\n -> Var30 g a\n\nvz30 : {g : _}-> {a : _} -> Var30 (snoc30 g a) a\nvz30 = \\ var, vz30, vs => vz30 _ _\n\nvs30 : {g : _} -> {B : _} -> {a : _} -> Var30 g a -> Var30 (snoc30 g B) a\nvs30 = \\ x, var, vz30, vs30 => vs30 _ _ _ (x var vz30 vs30)\n\nTm30 : Con30 -> Ty30 -> Type\nTm30 = \\ g, a =>\n (Tm30 : Con30 -> Ty30 -> Type)\n -> (var : (g : _) -> (a : _) -> Var30 g a -> Tm30 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm30 (snoc30 g a) B -> Tm30 g (arr30 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm30 g (arr30 a B) -> Tm30 g a -> Tm30 g B)\n -> Tm30 g a\n\nvar30 : {g : _} -> {a : _} -> Var30 g a -> Tm30 g a\nvar30 = \\ x, tm, var30, lam, app => var30 _ _ x\n\nlam30 : {g : _} -> {a : _} -> {B : _} -> Tm30 (snoc30 g a) B -> Tm30 g (arr30 a B)\nlam30 = \\ t, tm, var30, lam30, app => lam30 _ _ _ (t tm var30 lam30 app)\n\napp30 : {g:_}->{a:_}->{B:_} -> Tm30 g (arr30 a B) -> Tm30 g a -> Tm30 g B\napp30 = \\ t, u, tm, var30, lam30, app30 => app30 _ _ _ (t tm var30 lam30 app30) (u tm var30 lam30 app30)\n\nv030 : {g:_}->{a:_} -> Tm30 (snoc30 g a) a\nv030 = var30 vz30\n\nv130 : {g:_}->{a:_}-> {B:_}-> Tm30 (snoc30 (snoc30 g a) B) a\nv130 = var30 (vs30 vz30)\n\nv230 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm30 (snoc30 (snoc30 (snoc30 g a) B) C) a\nv230 = var30 (vs30 (vs30 vz30))\n\nv330 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm30 (snoc30 (snoc30 (snoc30 (snoc30 g a) B) C) D) a\nv330 = var30 (vs30 (vs30 (vs30 vz30)))\n\nv430 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm30 (snoc30 (snoc30 (snoc30 (snoc30 (snoc30 g a) B) C) D) E) a\nv430 = var30 (vs30 (vs30 (vs30 (vs30 vz30))))\n\ntest30 : {g:_}-> {a:_} -> Tm30 g (arr30 (arr30 a a) (arr30 a a))\ntest30 = lam30 (lam30 (app30 v130 (app30 v130 (app30 v130 (app30 v130 (app30 v130 (app30 v130 v030)))))))\nTy31 : Type\nTy31 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty31 : Ty31\nempty31 = \\ _, empty, _ => empty\n\narr31 : Ty31 -> Ty31 -> Ty31\narr31 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon31 : Type\nCon31 = (Con31 : Type)\n ->(nil : Con31)\n ->(snoc : Con31 -> Ty31 -> Con31)\n -> Con31\n\nnil31 : Con31\nnil31 = \\ con, nil31, snoc => nil31\n\nsnoc31 : Con31 -> Ty31 -> Con31\nsnoc31 = \\ g, a, con, nil31, snoc31 => snoc31 (g con nil31 snoc31) a\n\nVar31 : Con31 -> Ty31 -> Type\nVar31 = \\ g, a =>\n (Var31 : Con31 -> Ty31 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var31 (snoc31 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var31 g a -> Var31 (snoc31 g b) a)\n -> Var31 g a\n\nvz31 : {g : _}-> {a : _} -> Var31 (snoc31 g a) a\nvz31 = \\ var, vz31, vs => vz31 _ _\n\nvs31 : {g : _} -> {B : _} -> {a : _} -> Var31 g a -> Var31 (snoc31 g B) a\nvs31 = \\ x, var, vz31, vs31 => vs31 _ _ _ (x var vz31 vs31)\n\nTm31 : Con31 -> Ty31 -> Type\nTm31 = \\ g, a =>\n (Tm31 : Con31 -> Ty31 -> Type)\n -> (var : (g : _) -> (a : _) -> Var31 g a -> Tm31 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm31 (snoc31 g a) B -> Tm31 g (arr31 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm31 g (arr31 a B) -> Tm31 g a -> Tm31 g B)\n -> Tm31 g a\n\nvar31 : {g : _} -> {a : _} -> Var31 g a -> Tm31 g a\nvar31 = \\ x, tm, var31, lam, app => var31 _ _ x\n\nlam31 : {g : _} -> {a : _} -> {B : _} -> Tm31 (snoc31 g a) B -> Tm31 g (arr31 a B)\nlam31 = \\ t, tm, var31, lam31, app => lam31 _ _ _ (t tm var31 lam31 app)\n\napp31 : {g:_}->{a:_}->{B:_} -> Tm31 g (arr31 a B) -> Tm31 g a -> Tm31 g B\napp31 = \\ t, u, tm, var31, lam31, app31 => app31 _ _ _ (t tm var31 lam31 app31) (u tm var31 lam31 app31)\n\nv031 : {g:_}->{a:_} -> Tm31 (snoc31 g a) a\nv031 = var31 vz31\n\nv131 : {g:_}->{a:_}-> {B:_}-> Tm31 (snoc31 (snoc31 g a) B) a\nv131 = var31 (vs31 vz31)\n\nv231 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm31 (snoc31 (snoc31 (snoc31 g a) B) C) a\nv231 = var31 (vs31 (vs31 vz31))\n\nv331 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm31 (snoc31 (snoc31 (snoc31 (snoc31 g a) B) C) D) a\nv331 = var31 (vs31 (vs31 (vs31 vz31)))\n\nv431 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm31 (snoc31 (snoc31 (snoc31 (snoc31 (snoc31 g a) B) C) D) E) a\nv431 = var31 (vs31 (vs31 (vs31 (vs31 vz31))))\n\ntest31 : {g:_}-> {a:_} -> Tm31 g (arr31 (arr31 a a) (arr31 a a))\ntest31 = lam31 (lam31 (app31 v131 (app31 v131 (app31 v131 (app31 v131 (app31 v131 (app31 v131 v031)))))))\nTy32 : Type\nTy32 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty32 : Ty32\nempty32 = \\ _, empty, _ => empty\n\narr32 : Ty32 -> Ty32 -> Ty32\narr32 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon32 : Type\nCon32 = (Con32 : Type)\n ->(nil : Con32)\n ->(snoc : Con32 -> Ty32 -> Con32)\n -> Con32\n\nnil32 : Con32\nnil32 = \\ con, nil32, snoc => nil32\n\nsnoc32 : Con32 -> Ty32 -> Con32\nsnoc32 = \\ g, a, con, nil32, snoc32 => snoc32 (g con nil32 snoc32) a\n\nVar32 : Con32 -> Ty32 -> Type\nVar32 = \\ g, a =>\n (Var32 : Con32 -> Ty32 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var32 (snoc32 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var32 g a -> Var32 (snoc32 g b) a)\n -> Var32 g a\n\nvz32 : {g : _}-> {a : _} -> Var32 (snoc32 g a) a\nvz32 = \\ var, vz32, vs => vz32 _ _\n\nvs32 : {g : _} -> {B : _} -> {a : _} -> Var32 g a -> Var32 (snoc32 g B) a\nvs32 = \\ x, var, vz32, vs32 => vs32 _ _ _ (x var vz32 vs32)\n\nTm32 : Con32 -> Ty32 -> Type\nTm32 = \\ g, a =>\n (Tm32 : Con32 -> Ty32 -> Type)\n -> (var : (g : _) -> (a : _) -> Var32 g a -> Tm32 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm32 (snoc32 g a) B -> Tm32 g (arr32 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm32 g (arr32 a B) -> Tm32 g a -> Tm32 g B)\n -> Tm32 g a\n\nvar32 : {g : _} -> {a : _} -> Var32 g a -> Tm32 g a\nvar32 = \\ x, tm, var32, lam, app => var32 _ _ x\n\nlam32 : {g : _} -> {a : _} -> {B : _} -> Tm32 (snoc32 g a) B -> Tm32 g (arr32 a B)\nlam32 = \\ t, tm, var32, lam32, app => lam32 _ _ _ (t tm var32 lam32 app)\n\napp32 : {g:_}->{a:_}->{B:_} -> Tm32 g (arr32 a B) -> Tm32 g a -> Tm32 g B\napp32 = \\ t, u, tm, var32, lam32, app32 => app32 _ _ _ (t tm var32 lam32 app32) (u tm var32 lam32 app32)\n\nv032 : {g:_}->{a:_} -> Tm32 (snoc32 g a) a\nv032 = var32 vz32\n\nv132 : {g:_}->{a:_}-> {B:_}-> Tm32 (snoc32 (snoc32 g a) B) a\nv132 = var32 (vs32 vz32)\n\nv232 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm32 (snoc32 (snoc32 (snoc32 g a) B) C) a\nv232 = var32 (vs32 (vs32 vz32))\n\nv332 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm32 (snoc32 (snoc32 (snoc32 (snoc32 g a) B) C) D) a\nv332 = var32 (vs32 (vs32 (vs32 vz32)))\n\nv432 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm32 (snoc32 (snoc32 (snoc32 (snoc32 (snoc32 g a) B) C) D) E) a\nv432 = var32 (vs32 (vs32 (vs32 (vs32 vz32))))\n\ntest32 : {g:_}-> {a:_} -> Tm32 g (arr32 (arr32 a a) (arr32 a a))\ntest32 = lam32 (lam32 (app32 v132 (app32 v132 (app32 v132 (app32 v132 (app32 v132 (app32 v132 v032)))))))\nTy33 : Type\nTy33 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty33 : Ty33\nempty33 = \\ _, empty, _ => empty\n\narr33 : Ty33 -> Ty33 -> Ty33\narr33 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon33 : Type\nCon33 = (Con33 : Type)\n ->(nil : Con33)\n ->(snoc : Con33 -> Ty33 -> Con33)\n -> Con33\n\nnil33 : Con33\nnil33 = \\ con, nil33, snoc => nil33\n\nsnoc33 : Con33 -> Ty33 -> Con33\nsnoc33 = \\ g, a, con, nil33, snoc33 => snoc33 (g con nil33 snoc33) a\n\nVar33 : Con33 -> Ty33 -> Type\nVar33 = \\ g, a =>\n (Var33 : Con33 -> Ty33 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var33 (snoc33 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var33 g a -> Var33 (snoc33 g b) a)\n -> Var33 g a\n\nvz33 : {g : _}-> {a : _} -> Var33 (snoc33 g a) a\nvz33 = \\ var, vz33, vs => vz33 _ _\n\nvs33 : {g : _} -> {B : _} -> {a : _} -> Var33 g a -> Var33 (snoc33 g B) a\nvs33 = \\ x, var, vz33, vs33 => vs33 _ _ _ (x var vz33 vs33)\n\nTm33 : Con33 -> Ty33 -> Type\nTm33 = \\ g, a =>\n (Tm33 : Con33 -> Ty33 -> Type)\n -> (var : (g : _) -> (a : _) -> Var33 g a -> Tm33 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm33 (snoc33 g a) B -> Tm33 g (arr33 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm33 g (arr33 a B) -> Tm33 g a -> Tm33 g B)\n -> Tm33 g a\n\nvar33 : {g : _} -> {a : _} -> Var33 g a -> Tm33 g a\nvar33 = \\ x, tm, var33, lam, app => var33 _ _ x\n\nlam33 : {g : _} -> {a : _} -> {B : _} -> Tm33 (snoc33 g a) B -> Tm33 g (arr33 a B)\nlam33 = \\ t, tm, var33, lam33, app => lam33 _ _ _ (t tm var33 lam33 app)\n\napp33 : {g:_}->{a:_}->{B:_} -> Tm33 g (arr33 a B) -> Tm33 g a -> Tm33 g B\napp33 = \\ t, u, tm, var33, lam33, app33 => app33 _ _ _ (t tm var33 lam33 app33) (u tm var33 lam33 app33)\n\nv033 : {g:_}->{a:_} -> Tm33 (snoc33 g a) a\nv033 = var33 vz33\n\nv133 : {g:_}->{a:_}-> {B:_}-> Tm33 (snoc33 (snoc33 g a) B) a\nv133 = var33 (vs33 vz33)\n\nv233 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm33 (snoc33 (snoc33 (snoc33 g a) B) C) a\nv233 = var33 (vs33 (vs33 vz33))\n\nv333 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm33 (snoc33 (snoc33 (snoc33 (snoc33 g a) B) C) D) a\nv333 = var33 (vs33 (vs33 (vs33 vz33)))\n\nv433 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm33 (snoc33 (snoc33 (snoc33 (snoc33 (snoc33 g a) B) C) D) E) a\nv433 = var33 (vs33 (vs33 (vs33 (vs33 vz33))))\n\ntest33 : {g:_}-> {a:_} -> Tm33 g (arr33 (arr33 a a) (arr33 a a))\ntest33 = lam33 (lam33 (app33 v133 (app33 v133 (app33 v133 (app33 v133 (app33 v133 (app33 v133 v033)))))))\nTy34 : Type\nTy34 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty34 : Ty34\nempty34 = \\ _, empty, _ => empty\n\narr34 : Ty34 -> Ty34 -> Ty34\narr34 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon34 : Type\nCon34 = (Con34 : Type)\n ->(nil : Con34)\n ->(snoc : Con34 -> Ty34 -> Con34)\n -> Con34\n\nnil34 : Con34\nnil34 = \\ con, nil34, snoc => nil34\n\nsnoc34 : Con34 -> Ty34 -> Con34\nsnoc34 = \\ g, a, con, nil34, snoc34 => snoc34 (g con nil34 snoc34) a\n\nVar34 : Con34 -> Ty34 -> Type\nVar34 = \\ g, a =>\n (Var34 : Con34 -> Ty34 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var34 (snoc34 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var34 g a -> Var34 (snoc34 g b) a)\n -> Var34 g a\n\nvz34 : {g : _}-> {a : _} -> Var34 (snoc34 g a) a\nvz34 = \\ var, vz34, vs => vz34 _ _\n\nvs34 : {g : _} -> {B : _} -> {a : _} -> Var34 g a -> Var34 (snoc34 g B) a\nvs34 = \\ x, var, vz34, vs34 => vs34 _ _ _ (x var vz34 vs34)\n\nTm34 : Con34 -> Ty34 -> Type\nTm34 = \\ g, a =>\n (Tm34 : Con34 -> Ty34 -> Type)\n -> (var : (g : _) -> (a : _) -> Var34 g a -> Tm34 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm34 (snoc34 g a) B -> Tm34 g (arr34 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm34 g (arr34 a B) -> Tm34 g a -> Tm34 g B)\n -> Tm34 g a\n\nvar34 : {g : _} -> {a : _} -> Var34 g a -> Tm34 g a\nvar34 = \\ x, tm, var34, lam, app => var34 _ _ x\n\nlam34 : {g : _} -> {a : _} -> {B : _} -> Tm34 (snoc34 g a) B -> Tm34 g (arr34 a B)\nlam34 = \\ t, tm, var34, lam34, app => lam34 _ _ _ (t tm var34 lam34 app)\n\napp34 : {g:_}->{a:_}->{B:_} -> Tm34 g (arr34 a B) -> Tm34 g a -> Tm34 g B\napp34 = \\ t, u, tm, var34, lam34, app34 => app34 _ _ _ (t tm var34 lam34 app34) (u tm var34 lam34 app34)\n\nv034 : {g:_}->{a:_} -> Tm34 (snoc34 g a) a\nv034 = var34 vz34\n\nv134 : {g:_}->{a:_}-> {B:_}-> Tm34 (snoc34 (snoc34 g a) B) a\nv134 = var34 (vs34 vz34)\n\nv234 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm34 (snoc34 (snoc34 (snoc34 g a) B) C) a\nv234 = var34 (vs34 (vs34 vz34))\n\nv334 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm34 (snoc34 (snoc34 (snoc34 (snoc34 g a) B) C) D) a\nv334 = var34 (vs34 (vs34 (vs34 vz34)))\n\nv434 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm34 (snoc34 (snoc34 (snoc34 (snoc34 (snoc34 g a) B) C) D) E) a\nv434 = var34 (vs34 (vs34 (vs34 (vs34 vz34))))\n\ntest34 : {g:_}-> {a:_} -> Tm34 g (arr34 (arr34 a a) (arr34 a a))\ntest34 = lam34 (lam34 (app34 v134 (app34 v134 (app34 v134 (app34 v134 (app34 v134 (app34 v134 v034)))))))\nTy35 : Type\nTy35 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty35 : Ty35\nempty35 = \\ _, empty, _ => empty\n\narr35 : Ty35 -> Ty35 -> Ty35\narr35 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon35 : Type\nCon35 = (Con35 : Type)\n ->(nil : Con35)\n ->(snoc : Con35 -> Ty35 -> Con35)\n -> Con35\n\nnil35 : Con35\nnil35 = \\ con, nil35, snoc => nil35\n\nsnoc35 : Con35 -> Ty35 -> Con35\nsnoc35 = \\ g, a, con, nil35, snoc35 => snoc35 (g con nil35 snoc35) a\n\nVar35 : Con35 -> Ty35 -> Type\nVar35 = \\ g, a =>\n (Var35 : Con35 -> Ty35 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var35 (snoc35 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var35 g a -> Var35 (snoc35 g b) a)\n -> Var35 g a\n\nvz35 : {g : _}-> {a : _} -> Var35 (snoc35 g a) a\nvz35 = \\ var, vz35, vs => vz35 _ _\n\nvs35 : {g : _} -> {B : _} -> {a : _} -> Var35 g a -> Var35 (snoc35 g B) a\nvs35 = \\ x, var, vz35, vs35 => vs35 _ _ _ (x var vz35 vs35)\n\nTm35 : Con35 -> Ty35 -> Type\nTm35 = \\ g, a =>\n (Tm35 : Con35 -> Ty35 -> Type)\n -> (var : (g : _) -> (a : _) -> Var35 g a -> Tm35 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm35 (snoc35 g a) B -> Tm35 g (arr35 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm35 g (arr35 a B) -> Tm35 g a -> Tm35 g B)\n -> Tm35 g a\n\nvar35 : {g : _} -> {a : _} -> Var35 g a -> Tm35 g a\nvar35 = \\ x, tm, var35, lam, app => var35 _ _ x\n\nlam35 : {g : _} -> {a : _} -> {B : _} -> Tm35 (snoc35 g a) B -> Tm35 g (arr35 a B)\nlam35 = \\ t, tm, var35, lam35, app => lam35 _ _ _ (t tm var35 lam35 app)\n\napp35 : {g:_}->{a:_}->{B:_} -> Tm35 g (arr35 a B) -> Tm35 g a -> Tm35 g B\napp35 = \\ t, u, tm, var35, lam35, app35 => app35 _ _ _ (t tm var35 lam35 app35) (u tm var35 lam35 app35)\n\nv035 : {g:_}->{a:_} -> Tm35 (snoc35 g a) a\nv035 = var35 vz35\n\nv135 : {g:_}->{a:_}-> {B:_}-> Tm35 (snoc35 (snoc35 g a) B) a\nv135 = var35 (vs35 vz35)\n\nv235 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm35 (snoc35 (snoc35 (snoc35 g a) B) C) a\nv235 = var35 (vs35 (vs35 vz35))\n\nv335 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm35 (snoc35 (snoc35 (snoc35 (snoc35 g a) B) C) D) a\nv335 = var35 (vs35 (vs35 (vs35 vz35)))\n\nv435 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm35 (snoc35 (snoc35 (snoc35 (snoc35 (snoc35 g a) B) C) D) E) a\nv435 = var35 (vs35 (vs35 (vs35 (vs35 vz35))))\n\ntest35 : {g:_}-> {a:_} -> Tm35 g (arr35 (arr35 a a) (arr35 a a))\ntest35 = lam35 (lam35 (app35 v135 (app35 v135 (app35 v135 (app35 v135 (app35 v135 (app35 v135 v035)))))))\nTy36 : Type\nTy36 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty36 : Ty36\nempty36 = \\ _, empty, _ => empty\n\narr36 : Ty36 -> Ty36 -> Ty36\narr36 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon36 : Type\nCon36 = (Con36 : Type)\n ->(nil : Con36)\n ->(snoc : Con36 -> Ty36 -> Con36)\n -> Con36\n\nnil36 : Con36\nnil36 = \\ con, nil36, snoc => nil36\n\nsnoc36 : Con36 -> Ty36 -> Con36\nsnoc36 = \\ g, a, con, nil36, snoc36 => snoc36 (g con nil36 snoc36) a\n\nVar36 : Con36 -> Ty36 -> Type\nVar36 = \\ g, a =>\n (Var36 : Con36 -> Ty36 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var36 (snoc36 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var36 g a -> Var36 (snoc36 g b) a)\n -> Var36 g a\n\nvz36 : {g : _}-> {a : _} -> Var36 (snoc36 g a) a\nvz36 = \\ var, vz36, vs => vz36 _ _\n\nvs36 : {g : _} -> {B : _} -> {a : _} -> Var36 g a -> Var36 (snoc36 g B) a\nvs36 = \\ x, var, vz36, vs36 => vs36 _ _ _ (x var vz36 vs36)\n\nTm36 : Con36 -> Ty36 -> Type\nTm36 = \\ g, a =>\n (Tm36 : Con36 -> Ty36 -> Type)\n -> (var : (g : _) -> (a : _) -> Var36 g a -> Tm36 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm36 (snoc36 g a) B -> Tm36 g (arr36 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm36 g (arr36 a B) -> Tm36 g a -> Tm36 g B)\n -> Tm36 g a\n\nvar36 : {g : _} -> {a : _} -> Var36 g a -> Tm36 g a\nvar36 = \\ x, tm, var36, lam, app => var36 _ _ x\n\nlam36 : {g : _} -> {a : _} -> {B : _} -> Tm36 (snoc36 g a) B -> Tm36 g (arr36 a B)\nlam36 = \\ t, tm, var36, lam36, app => lam36 _ _ _ (t tm var36 lam36 app)\n\napp36 : {g:_}->{a:_}->{B:_} -> Tm36 g (arr36 a B) -> Tm36 g a -> Tm36 g B\napp36 = \\ t, u, tm, var36, lam36, app36 => app36 _ _ _ (t tm var36 lam36 app36) (u tm var36 lam36 app36)\n\nv036 : {g:_}->{a:_} -> Tm36 (snoc36 g a) a\nv036 = var36 vz36\n\nv136 : {g:_}->{a:_}-> {B:_}-> Tm36 (snoc36 (snoc36 g a) B) a\nv136 = var36 (vs36 vz36)\n\nv236 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm36 (snoc36 (snoc36 (snoc36 g a) B) C) a\nv236 = var36 (vs36 (vs36 vz36))\n\nv336 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm36 (snoc36 (snoc36 (snoc36 (snoc36 g a) B) C) D) a\nv336 = var36 (vs36 (vs36 (vs36 vz36)))\n\nv436 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm36 (snoc36 (snoc36 (snoc36 (snoc36 (snoc36 g a) B) C) D) E) a\nv436 = var36 (vs36 (vs36 (vs36 (vs36 vz36))))\n\ntest36 : {g:_}-> {a:_} -> Tm36 g (arr36 (arr36 a a) (arr36 a a))\ntest36 = lam36 (lam36 (app36 v136 (app36 v136 (app36 v136 (app36 v136 (app36 v136 (app36 v136 v036)))))))\nTy37 : Type\nTy37 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty37 : Ty37\nempty37 = \\ _, empty, _ => empty\n\narr37 : Ty37 -> Ty37 -> Ty37\narr37 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon37 : Type\nCon37 = (Con37 : Type)\n ->(nil : Con37)\n ->(snoc : Con37 -> Ty37 -> Con37)\n -> Con37\n\nnil37 : Con37\nnil37 = \\ con, nil37, snoc => nil37\n\nsnoc37 : Con37 -> Ty37 -> Con37\nsnoc37 = \\ g, a, con, nil37, snoc37 => snoc37 (g con nil37 snoc37) a\n\nVar37 : Con37 -> Ty37 -> Type\nVar37 = \\ g, a =>\n (Var37 : Con37 -> Ty37 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var37 (snoc37 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var37 g a -> Var37 (snoc37 g b) a)\n -> Var37 g a\n\nvz37 : {g : _}-> {a : _} -> Var37 (snoc37 g a) a\nvz37 = \\ var, vz37, vs => vz37 _ _\n\nvs37 : {g : _} -> {B : _} -> {a : _} -> Var37 g a -> Var37 (snoc37 g B) a\nvs37 = \\ x, var, vz37, vs37 => vs37 _ _ _ (x var vz37 vs37)\n\nTm37 : Con37 -> Ty37 -> Type\nTm37 = \\ g, a =>\n (Tm37 : Con37 -> Ty37 -> Type)\n -> (var : (g : _) -> (a : _) -> Var37 g a -> Tm37 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm37 (snoc37 g a) B -> Tm37 g (arr37 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm37 g (arr37 a B) -> Tm37 g a -> Tm37 g B)\n -> Tm37 g a\n\nvar37 : {g : _} -> {a : _} -> Var37 g a -> Tm37 g a\nvar37 = \\ x, tm, var37, lam, app => var37 _ _ x\n\nlam37 : {g : _} -> {a : _} -> {B : _} -> Tm37 (snoc37 g a) B -> Tm37 g (arr37 a B)\nlam37 = \\ t, tm, var37, lam37, app => lam37 _ _ _ (t tm var37 lam37 app)\n\napp37 : {g:_}->{a:_}->{B:_} -> Tm37 g (arr37 a B) -> Tm37 g a -> Tm37 g B\napp37 = \\ t, u, tm, var37, lam37, app37 => app37 _ _ _ (t tm var37 lam37 app37) (u tm var37 lam37 app37)\n\nv037 : {g:_}->{a:_} -> Tm37 (snoc37 g a) a\nv037 = var37 vz37\n\nv137 : {g:_}->{a:_}-> {B:_}-> Tm37 (snoc37 (snoc37 g a) B) a\nv137 = var37 (vs37 vz37)\n\nv237 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm37 (snoc37 (snoc37 (snoc37 g a) B) C) a\nv237 = var37 (vs37 (vs37 vz37))\n\nv337 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm37 (snoc37 (snoc37 (snoc37 (snoc37 g a) B) C) D) a\nv337 = var37 (vs37 (vs37 (vs37 vz37)))\n\nv437 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm37 (snoc37 (snoc37 (snoc37 (snoc37 (snoc37 g a) B) C) D) E) a\nv437 = var37 (vs37 (vs37 (vs37 (vs37 vz37))))\n\ntest37 : {g:_}-> {a:_} -> Tm37 g (arr37 (arr37 a a) (arr37 a a))\ntest37 = lam37 (lam37 (app37 v137 (app37 v137 (app37 v137 (app37 v137 (app37 v137 (app37 v137 v037)))))))\nTy38 : Type\nTy38 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty38 : Ty38\nempty38 = \\ _, empty, _ => empty\n\narr38 : Ty38 -> Ty38 -> Ty38\narr38 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon38 : Type\nCon38 = (Con38 : Type)\n ->(nil : Con38)\n ->(snoc : Con38 -> Ty38 -> Con38)\n -> Con38\n\nnil38 : Con38\nnil38 = \\ con, nil38, snoc => nil38\n\nsnoc38 : Con38 -> Ty38 -> Con38\nsnoc38 = \\ g, a, con, nil38, snoc38 => snoc38 (g con nil38 snoc38) a\n\nVar38 : Con38 -> Ty38 -> Type\nVar38 = \\ g, a =>\n (Var38 : Con38 -> Ty38 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var38 (snoc38 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var38 g a -> Var38 (snoc38 g b) a)\n -> Var38 g a\n\nvz38 : {g : _}-> {a : _} -> Var38 (snoc38 g a) a\nvz38 = \\ var, vz38, vs => vz38 _ _\n\nvs38 : {g : _} -> {B : _} -> {a : _} -> Var38 g a -> Var38 (snoc38 g B) a\nvs38 = \\ x, var, vz38, vs38 => vs38 _ _ _ (x var vz38 vs38)\n\nTm38 : Con38 -> Ty38 -> Type\nTm38 = \\ g, a =>\n (Tm38 : Con38 -> Ty38 -> Type)\n -> (var : (g : _) -> (a : _) -> Var38 g a -> Tm38 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm38 (snoc38 g a) B -> Tm38 g (arr38 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm38 g (arr38 a B) -> Tm38 g a -> Tm38 g B)\n -> Tm38 g a\n\nvar38 : {g : _} -> {a : _} -> Var38 g a -> Tm38 g a\nvar38 = \\ x, tm, var38, lam, app => var38 _ _ x\n\nlam38 : {g : _} -> {a : _} -> {B : _} -> Tm38 (snoc38 g a) B -> Tm38 g (arr38 a B)\nlam38 = \\ t, tm, var38, lam38, app => lam38 _ _ _ (t tm var38 lam38 app)\n\napp38 : {g:_}->{a:_}->{B:_} -> Tm38 g (arr38 a B) -> Tm38 g a -> Tm38 g B\napp38 = \\ t, u, tm, var38, lam38, app38 => app38 _ _ _ (t tm var38 lam38 app38) (u tm var38 lam38 app38)\n\nv038 : {g:_}->{a:_} -> Tm38 (snoc38 g a) a\nv038 = var38 vz38\n\nv138 : {g:_}->{a:_}-> {B:_}-> Tm38 (snoc38 (snoc38 g a) B) a\nv138 = var38 (vs38 vz38)\n\nv238 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm38 (snoc38 (snoc38 (snoc38 g a) B) C) a\nv238 = var38 (vs38 (vs38 vz38))\n\nv338 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm38 (snoc38 (snoc38 (snoc38 (snoc38 g a) B) C) D) a\nv338 = var38 (vs38 (vs38 (vs38 vz38)))\n\nv438 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm38 (snoc38 (snoc38 (snoc38 (snoc38 (snoc38 g a) B) C) D) E) a\nv438 = var38 (vs38 (vs38 (vs38 (vs38 vz38))))\n\ntest38 : {g:_}-> {a:_} -> Tm38 g (arr38 (arr38 a a) (arr38 a a))\ntest38 = lam38 (lam38 (app38 v138 (app38 v138 (app38 v138 (app38 v138 (app38 v138 (app38 v138 v038)))))))\nTy39 : Type\nTy39 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty39 : Ty39\nempty39 = \\ _, empty, _ => empty\n\narr39 : Ty39 -> Ty39 -> Ty39\narr39 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon39 : Type\nCon39 = (Con39 : Type)\n ->(nil : Con39)\n ->(snoc : Con39 -> Ty39 -> Con39)\n -> Con39\n\nnil39 : Con39\nnil39 = \\ con, nil39, snoc => nil39\n\nsnoc39 : Con39 -> Ty39 -> Con39\nsnoc39 = \\ g, a, con, nil39, snoc39 => snoc39 (g con nil39 snoc39) a\n\nVar39 : Con39 -> Ty39 -> Type\nVar39 = \\ g, a =>\n (Var39 : Con39 -> Ty39 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var39 (snoc39 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var39 g a -> Var39 (snoc39 g b) a)\n -> Var39 g a\n\nvz39 : {g : _}-> {a : _} -> Var39 (snoc39 g a) a\nvz39 = \\ var, vz39, vs => vz39 _ _\n\nvs39 : {g : _} -> {B : _} -> {a : _} -> Var39 g a -> Var39 (snoc39 g B) a\nvs39 = \\ x, var, vz39, vs39 => vs39 _ _ _ (x var vz39 vs39)\n\nTm39 : Con39 -> Ty39 -> Type\nTm39 = \\ g, a =>\n (Tm39 : Con39 -> Ty39 -> Type)\n -> (var : (g : _) -> (a : _) -> Var39 g a -> Tm39 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm39 (snoc39 g a) B -> Tm39 g (arr39 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm39 g (arr39 a B) -> Tm39 g a -> Tm39 g B)\n -> Tm39 g a\n\nvar39 : {g : _} -> {a : _} -> Var39 g a -> Tm39 g a\nvar39 = \\ x, tm, var39, lam, app => var39 _ _ x\n\nlam39 : {g : _} -> {a : _} -> {B : _} -> Tm39 (snoc39 g a) B -> Tm39 g (arr39 a B)\nlam39 = \\ t, tm, var39, lam39, app => lam39 _ _ _ (t tm var39 lam39 app)\n\napp39 : {g:_}->{a:_}->{B:_} -> Tm39 g (arr39 a B) -> Tm39 g a -> Tm39 g B\napp39 = \\ t, u, tm, var39, lam39, app39 => app39 _ _ _ (t tm var39 lam39 app39) (u tm var39 lam39 app39)\n\nv039 : {g:_}->{a:_} -> Tm39 (snoc39 g a) a\nv039 = var39 vz39\n\nv139 : {g:_}->{a:_}-> {B:_}-> Tm39 (snoc39 (snoc39 g a) B) a\nv139 = var39 (vs39 vz39)\n\nv239 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm39 (snoc39 (snoc39 (snoc39 g a) B) C) a\nv239 = var39 (vs39 (vs39 vz39))\n\nv339 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm39 (snoc39 (snoc39 (snoc39 (snoc39 g a) B) C) D) a\nv339 = var39 (vs39 (vs39 (vs39 vz39)))\n\nv439 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm39 (snoc39 (snoc39 (snoc39 (snoc39 (snoc39 g a) B) C) D) E) a\nv439 = var39 (vs39 (vs39 (vs39 (vs39 vz39))))\n\ntest39 : {g:_}-> {a:_} -> Tm39 g (arr39 (arr39 a a) (arr39 a a))\ntest39 = lam39 (lam39 (app39 v139 (app39 v139 (app39 v139 (app39 v139 (app39 v139 (app39 v139 v039)))))))\nTy40 : Type\nTy40 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty40 : Ty40\nempty40 = \\ _, empty, _ => empty\n\narr40 : Ty40 -> Ty40 -> Ty40\narr40 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon40 : Type\nCon40 = (Con40 : Type)\n ->(nil : Con40)\n ->(snoc : Con40 -> Ty40 -> Con40)\n -> Con40\n\nnil40 : Con40\nnil40 = \\ con, nil40, snoc => nil40\n\nsnoc40 : Con40 -> Ty40 -> Con40\nsnoc40 = \\ g, a, con, nil40, snoc40 => snoc40 (g con nil40 snoc40) a\n\nVar40 : Con40 -> Ty40 -> Type\nVar40 = \\ g, a =>\n (Var40 : Con40 -> Ty40 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var40 (snoc40 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var40 g a -> Var40 (snoc40 g b) a)\n -> Var40 g a\n\nvz40 : {g : _}-> {a : _} -> Var40 (snoc40 g a) a\nvz40 = \\ var, vz40, vs => vz40 _ _\n\nvs40 : {g : _} -> {B : _} -> {a : _} -> Var40 g a -> Var40 (snoc40 g B) a\nvs40 = \\ x, var, vz40, vs40 => vs40 _ _ _ (x var vz40 vs40)\n\nTm40 : Con40 -> Ty40 -> Type\nTm40 = \\ g, a =>\n (Tm40 : Con40 -> Ty40 -> Type)\n -> (var : (g : _) -> (a : _) -> Var40 g a -> Tm40 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm40 (snoc40 g a) B -> Tm40 g (arr40 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm40 g (arr40 a B) -> Tm40 g a -> Tm40 g B)\n -> Tm40 g a\n\nvar40 : {g : _} -> {a : _} -> Var40 g a -> Tm40 g a\nvar40 = \\ x, tm, var40, lam, app => var40 _ _ x\n\nlam40 : {g : _} -> {a : _} -> {B : _} -> Tm40 (snoc40 g a) B -> Tm40 g (arr40 a B)\nlam40 = \\ t, tm, var40, lam40, app => lam40 _ _ _ (t tm var40 lam40 app)\n\napp40 : {g:_}->{a:_}->{B:_} -> Tm40 g (arr40 a B) -> Tm40 g a -> Tm40 g B\napp40 = \\ t, u, tm, var40, lam40, app40 => app40 _ _ _ (t tm var40 lam40 app40) (u tm var40 lam40 app40)\n\nv040 : {g:_}->{a:_} -> Tm40 (snoc40 g a) a\nv040 = var40 vz40\n\nv140 : {g:_}->{a:_}-> {B:_}-> Tm40 (snoc40 (snoc40 g a) B) a\nv140 = var40 (vs40 vz40)\n\nv240 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm40 (snoc40 (snoc40 (snoc40 g a) B) C) a\nv240 = var40 (vs40 (vs40 vz40))\n\nv340 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm40 (snoc40 (snoc40 (snoc40 (snoc40 g a) B) C) D) a\nv340 = var40 (vs40 (vs40 (vs40 vz40)))\n\nv440 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm40 (snoc40 (snoc40 (snoc40 (snoc40 (snoc40 g a) B) C) D) E) a\nv440 = var40 (vs40 (vs40 (vs40 (vs40 vz40))))\n\ntest40 : {g:_}-> {a:_} -> Tm40 g (arr40 (arr40 a a) (arr40 a a))\ntest40 = lam40 (lam40 (app40 v140 (app40 v140 (app40 v140 (app40 v140 (app40 v140 (app40 v140 v040)))))))\nTy41 : Type\nTy41 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty41 : Ty41\nempty41 = \\ _, empty, _ => empty\n\narr41 : Ty41 -> Ty41 -> Ty41\narr41 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon41 : Type\nCon41 = (Con41 : Type)\n ->(nil : Con41)\n ->(snoc : Con41 -> Ty41 -> Con41)\n -> Con41\n\nnil41 : Con41\nnil41 = \\ con, nil41, snoc => nil41\n\nsnoc41 : Con41 -> Ty41 -> Con41\nsnoc41 = \\ g, a, con, nil41, snoc41 => snoc41 (g con nil41 snoc41) a\n\nVar41 : Con41 -> Ty41 -> Type\nVar41 = \\ g, a =>\n (Var41 : Con41 -> Ty41 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var41 (snoc41 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var41 g a -> Var41 (snoc41 g b) a)\n -> Var41 g a\n\nvz41 : {g : _}-> {a : _} -> Var41 (snoc41 g a) a\nvz41 = \\ var, vz41, vs => vz41 _ _\n\nvs41 : {g : _} -> {B : _} -> {a : _} -> Var41 g a -> Var41 (snoc41 g B) a\nvs41 = \\ x, var, vz41, vs41 => vs41 _ _ _ (x var vz41 vs41)\n\nTm41 : Con41 -> Ty41 -> Type\nTm41 = \\ g, a =>\n (Tm41 : Con41 -> Ty41 -> Type)\n -> (var : (g : _) -> (a : _) -> Var41 g a -> Tm41 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm41 (snoc41 g a) B -> Tm41 g (arr41 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm41 g (arr41 a B) -> Tm41 g a -> Tm41 g B)\n -> Tm41 g a\n\nvar41 : {g : _} -> {a : _} -> Var41 g a -> Tm41 g a\nvar41 = \\ x, tm, var41, lam, app => var41 _ _ x\n\nlam41 : {g : _} -> {a : _} -> {B : _} -> Tm41 (snoc41 g a) B -> Tm41 g (arr41 a B)\nlam41 = \\ t, tm, var41, lam41, app => lam41 _ _ _ (t tm var41 lam41 app)\n\napp41 : {g:_}->{a:_}->{B:_} -> Tm41 g (arr41 a B) -> Tm41 g a -> Tm41 g B\napp41 = \\ t, u, tm, var41, lam41, app41 => app41 _ _ _ (t tm var41 lam41 app41) (u tm var41 lam41 app41)\n\nv041 : {g:_}->{a:_} -> Tm41 (snoc41 g a) a\nv041 = var41 vz41\n\nv141 : {g:_}->{a:_}-> {B:_}-> Tm41 (snoc41 (snoc41 g a) B) a\nv141 = var41 (vs41 vz41)\n\nv241 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm41 (snoc41 (snoc41 (snoc41 g a) B) C) a\nv241 = var41 (vs41 (vs41 vz41))\n\nv341 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm41 (snoc41 (snoc41 (snoc41 (snoc41 g a) B) C) D) a\nv341 = var41 (vs41 (vs41 (vs41 vz41)))\n\nv441 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm41 (snoc41 (snoc41 (snoc41 (snoc41 (snoc41 g a) B) C) D) E) a\nv441 = var41 (vs41 (vs41 (vs41 (vs41 vz41))))\n\ntest41 : {g:_}-> {a:_} -> Tm41 g (arr41 (arr41 a a) (arr41 a a))\ntest41 = lam41 (lam41 (app41 v141 (app41 v141 (app41 v141 (app41 v141 (app41 v141 (app41 v141 v041)))))))\nTy42 : Type\nTy42 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty42 : Ty42\nempty42 = \\ _, empty, _ => empty\n\narr42 : Ty42 -> Ty42 -> Ty42\narr42 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon42 : Type\nCon42 = (Con42 : Type)\n ->(nil : Con42)\n ->(snoc : Con42 -> Ty42 -> Con42)\n -> Con42\n\nnil42 : Con42\nnil42 = \\ con, nil42, snoc => nil42\n\nsnoc42 : Con42 -> Ty42 -> Con42\nsnoc42 = \\ g, a, con, nil42, snoc42 => snoc42 (g con nil42 snoc42) a\n\nVar42 : Con42 -> Ty42 -> Type\nVar42 = \\ g, a =>\n (Var42 : Con42 -> Ty42 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var42 (snoc42 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var42 g a -> Var42 (snoc42 g b) a)\n -> Var42 g a\n\nvz42 : {g : _}-> {a : _} -> Var42 (snoc42 g a) a\nvz42 = \\ var, vz42, vs => vz42 _ _\n\nvs42 : {g : _} -> {B : _} -> {a : _} -> Var42 g a -> Var42 (snoc42 g B) a\nvs42 = \\ x, var, vz42, vs42 => vs42 _ _ _ (x var vz42 vs42)\n\nTm42 : Con42 -> Ty42 -> Type\nTm42 = \\ g, a =>\n (Tm42 : Con42 -> Ty42 -> Type)\n -> (var : (g : _) -> (a : _) -> Var42 g a -> Tm42 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm42 (snoc42 g a) B -> Tm42 g (arr42 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm42 g (arr42 a B) -> Tm42 g a -> Tm42 g B)\n -> Tm42 g a\n\nvar42 : {g : _} -> {a : _} -> Var42 g a -> Tm42 g a\nvar42 = \\ x, tm, var42, lam, app => var42 _ _ x\n\nlam42 : {g : _} -> {a : _} -> {B : _} -> Tm42 (snoc42 g a) B -> Tm42 g (arr42 a B)\nlam42 = \\ t, tm, var42, lam42, app => lam42 _ _ _ (t tm var42 lam42 app)\n\napp42 : {g:_}->{a:_}->{B:_} -> Tm42 g (arr42 a B) -> Tm42 g a -> Tm42 g B\napp42 = \\ t, u, tm, var42, lam42, app42 => app42 _ _ _ (t tm var42 lam42 app42) (u tm var42 lam42 app42)\n\nv042 : {g:_}->{a:_} -> Tm42 (snoc42 g a) a\nv042 = var42 vz42\n\nv142 : {g:_}->{a:_}-> {B:_}-> Tm42 (snoc42 (snoc42 g a) B) a\nv142 = var42 (vs42 vz42)\n\nv242 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm42 (snoc42 (snoc42 (snoc42 g a) B) C) a\nv242 = var42 (vs42 (vs42 vz42))\n\nv342 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm42 (snoc42 (snoc42 (snoc42 (snoc42 g a) B) C) D) a\nv342 = var42 (vs42 (vs42 (vs42 vz42)))\n\nv442 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm42 (snoc42 (snoc42 (snoc42 (snoc42 (snoc42 g a) B) C) D) E) a\nv442 = var42 (vs42 (vs42 (vs42 (vs42 vz42))))\n\ntest42 : {g:_}-> {a:_} -> Tm42 g (arr42 (arr42 a a) (arr42 a a))\ntest42 = lam42 (lam42 (app42 v142 (app42 v142 (app42 v142 (app42 v142 (app42 v142 (app42 v142 v042)))))))\nTy43 : Type\nTy43 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty43 : Ty43\nempty43 = \\ _, empty, _ => empty\n\narr43 : Ty43 -> Ty43 -> Ty43\narr43 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon43 : Type\nCon43 = (Con43 : Type)\n ->(nil : Con43)\n ->(snoc : Con43 -> Ty43 -> Con43)\n -> Con43\n\nnil43 : Con43\nnil43 = \\ con, nil43, snoc => nil43\n\nsnoc43 : Con43 -> Ty43 -> Con43\nsnoc43 = \\ g, a, con, nil43, snoc43 => snoc43 (g con nil43 snoc43) a\n\nVar43 : Con43 -> Ty43 -> Type\nVar43 = \\ g, a =>\n (Var43 : Con43 -> Ty43 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var43 (snoc43 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var43 g a -> Var43 (snoc43 g b) a)\n -> Var43 g a\n\nvz43 : {g : _}-> {a : _} -> Var43 (snoc43 g a) a\nvz43 = \\ var, vz43, vs => vz43 _ _\n\nvs43 : {g : _} -> {B : _} -> {a : _} -> Var43 g a -> Var43 (snoc43 g B) a\nvs43 = \\ x, var, vz43, vs43 => vs43 _ _ _ (x var vz43 vs43)\n\nTm43 : Con43 -> Ty43 -> Type\nTm43 = \\ g, a =>\n (Tm43 : Con43 -> Ty43 -> Type)\n -> (var : (g : _) -> (a : _) -> Var43 g a -> Tm43 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm43 (snoc43 g a) B -> Tm43 g (arr43 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm43 g (arr43 a B) -> Tm43 g a -> Tm43 g B)\n -> Tm43 g a\n\nvar43 : {g : _} -> {a : _} -> Var43 g a -> Tm43 g a\nvar43 = \\ x, tm, var43, lam, app => var43 _ _ x\n\nlam43 : {g : _} -> {a : _} -> {B : _} -> Tm43 (snoc43 g a) B -> Tm43 g (arr43 a B)\nlam43 = \\ t, tm, var43, lam43, app => lam43 _ _ _ (t tm var43 lam43 app)\n\napp43 : {g:_}->{a:_}->{B:_} -> Tm43 g (arr43 a B) -> Tm43 g a -> Tm43 g B\napp43 = \\ t, u, tm, var43, lam43, app43 => app43 _ _ _ (t tm var43 lam43 app43) (u tm var43 lam43 app43)\n\nv043 : {g:_}->{a:_} -> Tm43 (snoc43 g a) a\nv043 = var43 vz43\n\nv143 : {g:_}->{a:_}-> {B:_}-> Tm43 (snoc43 (snoc43 g a) B) a\nv143 = var43 (vs43 vz43)\n\nv243 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm43 (snoc43 (snoc43 (snoc43 g a) B) C) a\nv243 = var43 (vs43 (vs43 vz43))\n\nv343 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm43 (snoc43 (snoc43 (snoc43 (snoc43 g a) B) C) D) a\nv343 = var43 (vs43 (vs43 (vs43 vz43)))\n\nv443 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm43 (snoc43 (snoc43 (snoc43 (snoc43 (snoc43 g a) B) C) D) E) a\nv443 = var43 (vs43 (vs43 (vs43 (vs43 vz43))))\n\ntest43 : {g:_}-> {a:_} -> Tm43 g (arr43 (arr43 a a) (arr43 a a))\ntest43 = lam43 (lam43 (app43 v143 (app43 v143 (app43 v143 (app43 v143 (app43 v143 (app43 v143 v043)))))))\nTy44 : Type\nTy44 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty44 : Ty44\nempty44 = \\ _, empty, _ => empty\n\narr44 : Ty44 -> Ty44 -> Ty44\narr44 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon44 : Type\nCon44 = (Con44 : Type)\n ->(nil : Con44)\n ->(snoc : Con44 -> Ty44 -> Con44)\n -> Con44\n\nnil44 : Con44\nnil44 = \\ con, nil44, snoc => nil44\n\nsnoc44 : Con44 -> Ty44 -> Con44\nsnoc44 = \\ g, a, con, nil44, snoc44 => snoc44 (g con nil44 snoc44) a\n\nVar44 : Con44 -> Ty44 -> Type\nVar44 = \\ g, a =>\n (Var44 : Con44 -> Ty44 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var44 (snoc44 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var44 g a -> Var44 (snoc44 g b) a)\n -> Var44 g a\n\nvz44 : {g : _}-> {a : _} -> Var44 (snoc44 g a) a\nvz44 = \\ var, vz44, vs => vz44 _ _\n\nvs44 : {g : _} -> {B : _} -> {a : _} -> Var44 g a -> Var44 (snoc44 g B) a\nvs44 = \\ x, var, vz44, vs44 => vs44 _ _ _ (x var vz44 vs44)\n\nTm44 : Con44 -> Ty44 -> Type\nTm44 = \\ g, a =>\n (Tm44 : Con44 -> Ty44 -> Type)\n -> (var : (g : _) -> (a : _) -> Var44 g a -> Tm44 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm44 (snoc44 g a) B -> Tm44 g (arr44 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm44 g (arr44 a B) -> Tm44 g a -> Tm44 g B)\n -> Tm44 g a\n\nvar44 : {g : _} -> {a : _} -> Var44 g a -> Tm44 g a\nvar44 = \\ x, tm, var44, lam, app => var44 _ _ x\n\nlam44 : {g : _} -> {a : _} -> {B : _} -> Tm44 (snoc44 g a) B -> Tm44 g (arr44 a B)\nlam44 = \\ t, tm, var44, lam44, app => lam44 _ _ _ (t tm var44 lam44 app)\n\napp44 : {g:_}->{a:_}->{B:_} -> Tm44 g (arr44 a B) -> Tm44 g a -> Tm44 g B\napp44 = \\ t, u, tm, var44, lam44, app44 => app44 _ _ _ (t tm var44 lam44 app44) (u tm var44 lam44 app44)\n\nv044 : {g:_}->{a:_} -> Tm44 (snoc44 g a) a\nv044 = var44 vz44\n\nv144 : {g:_}->{a:_}-> {B:_}-> Tm44 (snoc44 (snoc44 g a) B) a\nv144 = var44 (vs44 vz44)\n\nv244 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm44 (snoc44 (snoc44 (snoc44 g a) B) C) a\nv244 = var44 (vs44 (vs44 vz44))\n\nv344 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm44 (snoc44 (snoc44 (snoc44 (snoc44 g a) B) C) D) a\nv344 = var44 (vs44 (vs44 (vs44 vz44)))\n\nv444 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm44 (snoc44 (snoc44 (snoc44 (snoc44 (snoc44 g a) B) C) D) E) a\nv444 = var44 (vs44 (vs44 (vs44 (vs44 vz44))))\n\ntest44 : {g:_}-> {a:_} -> Tm44 g (arr44 (arr44 a a) (arr44 a a))\ntest44 = lam44 (lam44 (app44 v144 (app44 v144 (app44 v144 (app44 v144 (app44 v144 (app44 v144 v044)))))))\nTy45 : Type\nTy45 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty45 : Ty45\nempty45 = \\ _, empty, _ => empty\n\narr45 : Ty45 -> Ty45 -> Ty45\narr45 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon45 : Type\nCon45 = (Con45 : Type)\n ->(nil : Con45)\n ->(snoc : Con45 -> Ty45 -> Con45)\n -> Con45\n\nnil45 : Con45\nnil45 = \\ con, nil45, snoc => nil45\n\nsnoc45 : Con45 -> Ty45 -> Con45\nsnoc45 = \\ g, a, con, nil45, snoc45 => snoc45 (g con nil45 snoc45) a\n\nVar45 : Con45 -> Ty45 -> Type\nVar45 = \\ g, a =>\n (Var45 : Con45 -> Ty45 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var45 (snoc45 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var45 g a -> Var45 (snoc45 g b) a)\n -> Var45 g a\n\nvz45 : {g : _}-> {a : _} -> Var45 (snoc45 g a) a\nvz45 = \\ var, vz45, vs => vz45 _ _\n\nvs45 : {g : _} -> {B : _} -> {a : _} -> Var45 g a -> Var45 (snoc45 g B) a\nvs45 = \\ x, var, vz45, vs45 => vs45 _ _ _ (x var vz45 vs45)\n\nTm45 : Con45 -> Ty45 -> Type\nTm45 = \\ g, a =>\n (Tm45 : Con45 -> Ty45 -> Type)\n -> (var : (g : _) -> (a : _) -> Var45 g a -> Tm45 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm45 (snoc45 g a) B -> Tm45 g (arr45 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm45 g (arr45 a B) -> Tm45 g a -> Tm45 g B)\n -> Tm45 g a\n\nvar45 : {g : _} -> {a : _} -> Var45 g a -> Tm45 g a\nvar45 = \\ x, tm, var45, lam, app => var45 _ _ x\n\nlam45 : {g : _} -> {a : _} -> {B : _} -> Tm45 (snoc45 g a) B -> Tm45 g (arr45 a B)\nlam45 = \\ t, tm, var45, lam45, app => lam45 _ _ _ (t tm var45 lam45 app)\n\napp45 : {g:_}->{a:_}->{B:_} -> Tm45 g (arr45 a B) -> Tm45 g a -> Tm45 g B\napp45 = \\ t, u, tm, var45, lam45, app45 => app45 _ _ _ (t tm var45 lam45 app45) (u tm var45 lam45 app45)\n\nv045 : {g:_}->{a:_} -> Tm45 (snoc45 g a) a\nv045 = var45 vz45\n\nv145 : {g:_}->{a:_}-> {B:_}-> Tm45 (snoc45 (snoc45 g a) B) a\nv145 = var45 (vs45 vz45)\n\nv245 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm45 (snoc45 (snoc45 (snoc45 g a) B) C) a\nv245 = var45 (vs45 (vs45 vz45))\n\nv345 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm45 (snoc45 (snoc45 (snoc45 (snoc45 g a) B) C) D) a\nv345 = var45 (vs45 (vs45 (vs45 vz45)))\n\nv445 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm45 (snoc45 (snoc45 (snoc45 (snoc45 (snoc45 g a) B) C) D) E) a\nv445 = var45 (vs45 (vs45 (vs45 (vs45 vz45))))\n\ntest45 : {g:_}-> {a:_} -> Tm45 g (arr45 (arr45 a a) (arr45 a a))\ntest45 = lam45 (lam45 (app45 v145 (app45 v145 (app45 v145 (app45 v145 (app45 v145 (app45 v145 v045)))))))\nTy46 : Type\nTy46 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty46 : Ty46\nempty46 = \\ _, empty, _ => empty\n\narr46 : Ty46 -> Ty46 -> Ty46\narr46 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon46 : Type\nCon46 = (Con46 : Type)\n ->(nil : Con46)\n ->(snoc : Con46 -> Ty46 -> Con46)\n -> Con46\n\nnil46 : Con46\nnil46 = \\ con, nil46, snoc => nil46\n\nsnoc46 : Con46 -> Ty46 -> Con46\nsnoc46 = \\ g, a, con, nil46, snoc46 => snoc46 (g con nil46 snoc46) a\n\nVar46 : Con46 -> Ty46 -> Type\nVar46 = \\ g, a =>\n (Var46 : Con46 -> Ty46 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var46 (snoc46 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var46 g a -> Var46 (snoc46 g b) a)\n -> Var46 g a\n\nvz46 : {g : _}-> {a : _} -> Var46 (snoc46 g a) a\nvz46 = \\ var, vz46, vs => vz46 _ _\n\nvs46 : {g : _} -> {B : _} -> {a : _} -> Var46 g a -> Var46 (snoc46 g B) a\nvs46 = \\ x, var, vz46, vs46 => vs46 _ _ _ (x var vz46 vs46)\n\nTm46 : Con46 -> Ty46 -> Type\nTm46 = \\ g, a =>\n (Tm46 : Con46 -> Ty46 -> Type)\n -> (var : (g : _) -> (a : _) -> Var46 g a -> Tm46 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm46 (snoc46 g a) B -> Tm46 g (arr46 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm46 g (arr46 a B) -> Tm46 g a -> Tm46 g B)\n -> Tm46 g a\n\nvar46 : {g : _} -> {a : _} -> Var46 g a -> Tm46 g a\nvar46 = \\ x, tm, var46, lam, app => var46 _ _ x\n\nlam46 : {g : _} -> {a : _} -> {B : _} -> Tm46 (snoc46 g a) B -> Tm46 g (arr46 a B)\nlam46 = \\ t, tm, var46, lam46, app => lam46 _ _ _ (t tm var46 lam46 app)\n\napp46 : {g:_}->{a:_}->{B:_} -> Tm46 g (arr46 a B) -> Tm46 g a -> Tm46 g B\napp46 = \\ t, u, tm, var46, lam46, app46 => app46 _ _ _ (t tm var46 lam46 app46) (u tm var46 lam46 app46)\n\nv046 : {g:_}->{a:_} -> Tm46 (snoc46 g a) a\nv046 = var46 vz46\n\nv146 : {g:_}->{a:_}-> {B:_}-> Tm46 (snoc46 (snoc46 g a) B) a\nv146 = var46 (vs46 vz46)\n\nv246 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm46 (snoc46 (snoc46 (snoc46 g a) B) C) a\nv246 = var46 (vs46 (vs46 vz46))\n\nv346 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm46 (snoc46 (snoc46 (snoc46 (snoc46 g a) B) C) D) a\nv346 = var46 (vs46 (vs46 (vs46 vz46)))\n\nv446 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm46 (snoc46 (snoc46 (snoc46 (snoc46 (snoc46 g a) B) C) D) E) a\nv446 = var46 (vs46 (vs46 (vs46 (vs46 vz46))))\n\ntest46 : {g:_}-> {a:_} -> Tm46 g (arr46 (arr46 a a) (arr46 a a))\ntest46 = lam46 (lam46 (app46 v146 (app46 v146 (app46 v146 (app46 v146 (app46 v146 (app46 v146 v046)))))))\nTy47 : Type\nTy47 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty47 : Ty47\nempty47 = \\ _, empty, _ => empty\n\narr47 : Ty47 -> Ty47 -> Ty47\narr47 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon47 : Type\nCon47 = (Con47 : Type)\n ->(nil : Con47)\n ->(snoc : Con47 -> Ty47 -> Con47)\n -> Con47\n\nnil47 : Con47\nnil47 = \\ con, nil47, snoc => nil47\n\nsnoc47 : Con47 -> Ty47 -> Con47\nsnoc47 = \\ g, a, con, nil47, snoc47 => snoc47 (g con nil47 snoc47) a\n\nVar47 : Con47 -> Ty47 -> Type\nVar47 = \\ g, a =>\n (Var47 : Con47 -> Ty47 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var47 (snoc47 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var47 g a -> Var47 (snoc47 g b) a)\n -> Var47 g a\n\nvz47 : {g : _}-> {a : _} -> Var47 (snoc47 g a) a\nvz47 = \\ var, vz47, vs => vz47 _ _\n\nvs47 : {g : _} -> {B : _} -> {a : _} -> Var47 g a -> Var47 (snoc47 g B) a\nvs47 = \\ x, var, vz47, vs47 => vs47 _ _ _ (x var vz47 vs47)\n\nTm47 : Con47 -> Ty47 -> Type\nTm47 = \\ g, a =>\n (Tm47 : Con47 -> Ty47 -> Type)\n -> (var : (g : _) -> (a : _) -> Var47 g a -> Tm47 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm47 (snoc47 g a) B -> Tm47 g (arr47 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm47 g (arr47 a B) -> Tm47 g a -> Tm47 g B)\n -> Tm47 g a\n\nvar47 : {g : _} -> {a : _} -> Var47 g a -> Tm47 g a\nvar47 = \\ x, tm, var47, lam, app => var47 _ _ x\n\nlam47 : {g : _} -> {a : _} -> {B : _} -> Tm47 (snoc47 g a) B -> Tm47 g (arr47 a B)\nlam47 = \\ t, tm, var47, lam47, app => lam47 _ _ _ (t tm var47 lam47 app)\n\napp47 : {g:_}->{a:_}->{B:_} -> Tm47 g (arr47 a B) -> Tm47 g a -> Tm47 g B\napp47 = \\ t, u, tm, var47, lam47, app47 => app47 _ _ _ (t tm var47 lam47 app47) (u tm var47 lam47 app47)\n\nv047 : {g:_}->{a:_} -> Tm47 (snoc47 g a) a\nv047 = var47 vz47\n\nv147 : {g:_}->{a:_}-> {B:_}-> Tm47 (snoc47 (snoc47 g a) B) a\nv147 = var47 (vs47 vz47)\n\nv247 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm47 (snoc47 (snoc47 (snoc47 g a) B) C) a\nv247 = var47 (vs47 (vs47 vz47))\n\nv347 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm47 (snoc47 (snoc47 (snoc47 (snoc47 g a) B) C) D) a\nv347 = var47 (vs47 (vs47 (vs47 vz47)))\n\nv447 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm47 (snoc47 (snoc47 (snoc47 (snoc47 (snoc47 g a) B) C) D) E) a\nv447 = var47 (vs47 (vs47 (vs47 (vs47 vz47))))\n\ntest47 : {g:_}-> {a:_} -> Tm47 g (arr47 (arr47 a a) (arr47 a a))\ntest47 = lam47 (lam47 (app47 v147 (app47 v147 (app47 v147 (app47 v147 (app47 v147 (app47 v147 v047)))))))\nTy48 : Type\nTy48 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty48 : Ty48\nempty48 = \\ _, empty, _ => empty\n\narr48 : Ty48 -> Ty48 -> Ty48\narr48 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon48 : Type\nCon48 = (Con48 : Type)\n ->(nil : Con48)\n ->(snoc : Con48 -> Ty48 -> Con48)\n -> Con48\n\nnil48 : Con48\nnil48 = \\ con, nil48, snoc => nil48\n\nsnoc48 : Con48 -> Ty48 -> Con48\nsnoc48 = \\ g, a, con, nil48, snoc48 => snoc48 (g con nil48 snoc48) a\n\nVar48 : Con48 -> Ty48 -> Type\nVar48 = \\ g, a =>\n (Var48 : Con48 -> Ty48 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var48 (snoc48 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var48 g a -> Var48 (snoc48 g b) a)\n -> Var48 g a\n\nvz48 : {g : _}-> {a : _} -> Var48 (snoc48 g a) a\nvz48 = \\ var, vz48, vs => vz48 _ _\n\nvs48 : {g : _} -> {B : _} -> {a : _} -> Var48 g a -> Var48 (snoc48 g B) a\nvs48 = \\ x, var, vz48, vs48 => vs48 _ _ _ (x var vz48 vs48)\n\nTm48 : Con48 -> Ty48 -> Type\nTm48 = \\ g, a =>\n (Tm48 : Con48 -> Ty48 -> Type)\n -> (var : (g : _) -> (a : _) -> Var48 g a -> Tm48 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm48 (snoc48 g a) B -> Tm48 g (arr48 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm48 g (arr48 a B) -> Tm48 g a -> Tm48 g B)\n -> Tm48 g a\n\nvar48 : {g : _} -> {a : _} -> Var48 g a -> Tm48 g a\nvar48 = \\ x, tm, var48, lam, app => var48 _ _ x\n\nlam48 : {g : _} -> {a : _} -> {B : _} -> Tm48 (snoc48 g a) B -> Tm48 g (arr48 a B)\nlam48 = \\ t, tm, var48, lam48, app => lam48 _ _ _ (t tm var48 lam48 app)\n\napp48 : {g:_}->{a:_}->{B:_} -> Tm48 g (arr48 a B) -> Tm48 g a -> Tm48 g B\napp48 = \\ t, u, tm, var48, lam48, app48 => app48 _ _ _ (t tm var48 lam48 app48) (u tm var48 lam48 app48)\n\nv048 : {g:_}->{a:_} -> Tm48 (snoc48 g a) a\nv048 = var48 vz48\n\nv148 : {g:_}->{a:_}-> {B:_}-> Tm48 (snoc48 (snoc48 g a) B) a\nv148 = var48 (vs48 vz48)\n\nv248 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm48 (snoc48 (snoc48 (snoc48 g a) B) C) a\nv248 = var48 (vs48 (vs48 vz48))\n\nv348 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm48 (snoc48 (snoc48 (snoc48 (snoc48 g a) B) C) D) a\nv348 = var48 (vs48 (vs48 (vs48 vz48)))\n\nv448 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm48 (snoc48 (snoc48 (snoc48 (snoc48 (snoc48 g a) B) C) D) E) a\nv448 = var48 (vs48 (vs48 (vs48 (vs48 vz48))))\n\ntest48 : {g:_}-> {a:_} -> Tm48 g (arr48 (arr48 a a) (arr48 a a))\ntest48 = lam48 (lam48 (app48 v148 (app48 v148 (app48 v148 (app48 v148 (app48 v148 (app48 v148 v048)))))))\nTy49 : Type\nTy49 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty49 : Ty49\nempty49 = \\ _, empty, _ => empty\n\narr49 : Ty49 -> Ty49 -> Ty49\narr49 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon49 : Type\nCon49 = (Con49 : Type)\n ->(nil : Con49)\n ->(snoc : Con49 -> Ty49 -> Con49)\n -> Con49\n\nnil49 : Con49\nnil49 = \\ con, nil49, snoc => nil49\n\nsnoc49 : Con49 -> Ty49 -> Con49\nsnoc49 = \\ g, a, con, nil49, snoc49 => snoc49 (g con nil49 snoc49) a\n\nVar49 : Con49 -> Ty49 -> Type\nVar49 = \\ g, a =>\n (Var49 : Con49 -> Ty49 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var49 (snoc49 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var49 g a -> Var49 (snoc49 g b) a)\n -> Var49 g a\n\nvz49 : {g : _}-> {a : _} -> Var49 (snoc49 g a) a\nvz49 = \\ var, vz49, vs => vz49 _ _\n\nvs49 : {g : _} -> {B : _} -> {a : _} -> Var49 g a -> Var49 (snoc49 g B) a\nvs49 = \\ x, var, vz49, vs49 => vs49 _ _ _ (x var vz49 vs49)\n\nTm49 : Con49 -> Ty49 -> Type\nTm49 = \\ g, a =>\n (Tm49 : Con49 -> Ty49 -> Type)\n -> (var : (g : _) -> (a : _) -> Var49 g a -> Tm49 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm49 (snoc49 g a) B -> Tm49 g (arr49 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm49 g (arr49 a B) -> Tm49 g a -> Tm49 g B)\n -> Tm49 g a\n\nvar49 : {g : _} -> {a : _} -> Var49 g a -> Tm49 g a\nvar49 = \\ x, tm, var49, lam, app => var49 _ _ x\n\nlam49 : {g : _} -> {a : _} -> {B : _} -> Tm49 (snoc49 g a) B -> Tm49 g (arr49 a B)\nlam49 = \\ t, tm, var49, lam49, app => lam49 _ _ _ (t tm var49 lam49 app)\n\napp49 : {g:_}->{a:_}->{B:_} -> Tm49 g (arr49 a B) -> Tm49 g a -> Tm49 g B\napp49 = \\ t, u, tm, var49, lam49, app49 => app49 _ _ _ (t tm var49 lam49 app49) (u tm var49 lam49 app49)\n\nv049 : {g:_}->{a:_} -> Tm49 (snoc49 g a) a\nv049 = var49 vz49\n\nv149 : {g:_}->{a:_}-> {B:_}-> Tm49 (snoc49 (snoc49 g a) B) a\nv149 = var49 (vs49 vz49)\n\nv249 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm49 (snoc49 (snoc49 (snoc49 g a) B) C) a\nv249 = var49 (vs49 (vs49 vz49))\n\nv349 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm49 (snoc49 (snoc49 (snoc49 (snoc49 g a) B) C) D) a\nv349 = var49 (vs49 (vs49 (vs49 vz49)))\n\nv449 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm49 (snoc49 (snoc49 (snoc49 (snoc49 (snoc49 g a) B) C) D) E) a\nv449 = var49 (vs49 (vs49 (vs49 (vs49 vz49))))\n\ntest49 : {g:_}-> {a:_} -> Tm49 g (arr49 (arr49 a a) (arr49 a a))\ntest49 = lam49 (lam49 (app49 v149 (app49 v149 (app49 v149 (app49 v149 (app49 v149 (app49 v149 v049)))))))\nTy50 : Type\nTy50 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty50 : Ty50\nempty50 = \\ _, empty, _ => empty\n\narr50 : Ty50 -> Ty50 -> Ty50\narr50 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon50 : Type\nCon50 = (Con50 : Type)\n ->(nil : Con50)\n ->(snoc : Con50 -> Ty50 -> Con50)\n -> Con50\n\nnil50 : Con50\nnil50 = \\ con, nil50, snoc => nil50\n\nsnoc50 : Con50 -> Ty50 -> Con50\nsnoc50 = \\ g, a, con, nil50, snoc50 => snoc50 (g con nil50 snoc50) a\n\nVar50 : Con50 -> Ty50 -> Type\nVar50 = \\ g, a =>\n (Var50 : Con50 -> Ty50 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var50 (snoc50 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var50 g a -> Var50 (snoc50 g b) a)\n -> Var50 g a\n\nvz50 : {g : _}-> {a : _} -> Var50 (snoc50 g a) a\nvz50 = \\ var, vz50, vs => vz50 _ _\n\nvs50 : {g : _} -> {B : _} -> {a : _} -> Var50 g a -> Var50 (snoc50 g B) a\nvs50 = \\ x, var, vz50, vs50 => vs50 _ _ _ (x var vz50 vs50)\n\nTm50 : Con50 -> Ty50 -> Type\nTm50 = \\ g, a =>\n (Tm50 : Con50 -> Ty50 -> Type)\n -> (var : (g : _) -> (a : _) -> Var50 g a -> Tm50 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm50 (snoc50 g a) B -> Tm50 g (arr50 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm50 g (arr50 a B) -> Tm50 g a -> Tm50 g B)\n -> Tm50 g a\n\nvar50 : {g : _} -> {a : _} -> Var50 g a -> Tm50 g a\nvar50 = \\ x, tm, var50, lam, app => var50 _ _ x\n\nlam50 : {g : _} -> {a : _} -> {B : _} -> Tm50 (snoc50 g a) B -> Tm50 g (arr50 a B)\nlam50 = \\ t, tm, var50, lam50, app => lam50 _ _ _ (t tm var50 lam50 app)\n\napp50 : {g:_}->{a:_}->{B:_} -> Tm50 g (arr50 a B) -> Tm50 g a -> Tm50 g B\napp50 = \\ t, u, tm, var50, lam50, app50 => app50 _ _ _ (t tm var50 lam50 app50) (u tm var50 lam50 app50)\n\nv050 : {g:_}->{a:_} -> Tm50 (snoc50 g a) a\nv050 = var50 vz50\n\nv150 : {g:_}->{a:_}-> {B:_}-> Tm50 (snoc50 (snoc50 g a) B) a\nv150 = var50 (vs50 vz50)\n\nv250 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm50 (snoc50 (snoc50 (snoc50 g a) B) C) a\nv250 = var50 (vs50 (vs50 vz50))\n\nv350 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm50 (snoc50 (snoc50 (snoc50 (snoc50 g a) B) C) D) a\nv350 = var50 (vs50 (vs50 (vs50 vz50)))\n\nv450 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm50 (snoc50 (snoc50 (snoc50 (snoc50 (snoc50 g a) B) C) D) E) a\nv450 = var50 (vs50 (vs50 (vs50 (vs50 vz50))))\n\ntest50 : {g:_}-> {a:_} -> Tm50 g (arr50 (arr50 a a) (arr50 a a))\ntest50 = lam50 (lam50 (app50 v150 (app50 v150 (app50 v150 (app50 v150 (app50 v150 (app50 v150 v050)))))))\nTy51 : Type\nTy51 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty51 : Ty51\nempty51 = \\ _, empty, _ => empty\n\narr51 : Ty51 -> Ty51 -> Ty51\narr51 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon51 : Type\nCon51 = (Con51 : Type)\n ->(nil : Con51)\n ->(snoc : Con51 -> Ty51 -> Con51)\n -> Con51\n\nnil51 : Con51\nnil51 = \\ con, nil51, snoc => nil51\n\nsnoc51 : Con51 -> Ty51 -> Con51\nsnoc51 = \\ g, a, con, nil51, snoc51 => snoc51 (g con nil51 snoc51) a\n\nVar51 : Con51 -> Ty51 -> Type\nVar51 = \\ g, a =>\n (Var51 : Con51 -> Ty51 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var51 (snoc51 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var51 g a -> Var51 (snoc51 g b) a)\n -> Var51 g a\n\nvz51 : {g : _}-> {a : _} -> Var51 (snoc51 g a) a\nvz51 = \\ var, vz51, vs => vz51 _ _\n\nvs51 : {g : _} -> {B : _} -> {a : _} -> Var51 g a -> Var51 (snoc51 g B) a\nvs51 = \\ x, var, vz51, vs51 => vs51 _ _ _ (x var vz51 vs51)\n\nTm51 : Con51 -> Ty51 -> Type\nTm51 = \\ g, a =>\n (Tm51 : Con51 -> Ty51 -> Type)\n -> (var : (g : _) -> (a : _) -> Var51 g a -> Tm51 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm51 (snoc51 g a) B -> Tm51 g (arr51 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm51 g (arr51 a B) -> Tm51 g a -> Tm51 g B)\n -> Tm51 g a\n\nvar51 : {g : _} -> {a : _} -> Var51 g a -> Tm51 g a\nvar51 = \\ x, tm, var51, lam, app => var51 _ _ x\n\nlam51 : {g : _} -> {a : _} -> {B : _} -> Tm51 (snoc51 g a) B -> Tm51 g (arr51 a B)\nlam51 = \\ t, tm, var51, lam51, app => lam51 _ _ _ (t tm var51 lam51 app)\n\napp51 : {g:_}->{a:_}->{B:_} -> Tm51 g (arr51 a B) -> Tm51 g a -> Tm51 g B\napp51 = \\ t, u, tm, var51, lam51, app51 => app51 _ _ _ (t tm var51 lam51 app51) (u tm var51 lam51 app51)\n\nv051 : {g:_}->{a:_} -> Tm51 (snoc51 g a) a\nv051 = var51 vz51\n\nv151 : {g:_}->{a:_}-> {B:_}-> Tm51 (snoc51 (snoc51 g a) B) a\nv151 = var51 (vs51 vz51)\n\nv251 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm51 (snoc51 (snoc51 (snoc51 g a) B) C) a\nv251 = var51 (vs51 (vs51 vz51))\n\nv351 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm51 (snoc51 (snoc51 (snoc51 (snoc51 g a) B) C) D) a\nv351 = var51 (vs51 (vs51 (vs51 vz51)))\n\nv451 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm51 (snoc51 (snoc51 (snoc51 (snoc51 (snoc51 g a) B) C) D) E) a\nv451 = var51 (vs51 (vs51 (vs51 (vs51 vz51))))\n\ntest51 : {g:_}-> {a:_} -> Tm51 g (arr51 (arr51 a a) (arr51 a a))\ntest51 = lam51 (lam51 (app51 v151 (app51 v151 (app51 v151 (app51 v151 (app51 v151 (app51 v151 v051)))))))\nTy52 : Type\nTy52 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty52 : Ty52\nempty52 = \\ _, empty, _ => empty\n\narr52 : Ty52 -> Ty52 -> Ty52\narr52 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon52 : Type\nCon52 = (Con52 : Type)\n ->(nil : Con52)\n ->(snoc : Con52 -> Ty52 -> Con52)\n -> Con52\n\nnil52 : Con52\nnil52 = \\ con, nil52, snoc => nil52\n\nsnoc52 : Con52 -> Ty52 -> Con52\nsnoc52 = \\ g, a, con, nil52, snoc52 => snoc52 (g con nil52 snoc52) a\n\nVar52 : Con52 -> Ty52 -> Type\nVar52 = \\ g, a =>\n (Var52 : Con52 -> Ty52 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var52 (snoc52 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var52 g a -> Var52 (snoc52 g b) a)\n -> Var52 g a\n\nvz52 : {g : _}-> {a : _} -> Var52 (snoc52 g a) a\nvz52 = \\ var, vz52, vs => vz52 _ _\n\nvs52 : {g : _} -> {B : _} -> {a : _} -> Var52 g a -> Var52 (snoc52 g B) a\nvs52 = \\ x, var, vz52, vs52 => vs52 _ _ _ (x var vz52 vs52)\n\nTm52 : Con52 -> Ty52 -> Type\nTm52 = \\ g, a =>\n (Tm52 : Con52 -> Ty52 -> Type)\n -> (var : (g : _) -> (a : _) -> Var52 g a -> Tm52 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm52 (snoc52 g a) B -> Tm52 g (arr52 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm52 g (arr52 a B) -> Tm52 g a -> Tm52 g B)\n -> Tm52 g a\n\nvar52 : {g : _} -> {a : _} -> Var52 g a -> Tm52 g a\nvar52 = \\ x, tm, var52, lam, app => var52 _ _ x\n\nlam52 : {g : _} -> {a : _} -> {B : _} -> Tm52 (snoc52 g a) B -> Tm52 g (arr52 a B)\nlam52 = \\ t, tm, var52, lam52, app => lam52 _ _ _ (t tm var52 lam52 app)\n\napp52 : {g:_}->{a:_}->{B:_} -> Tm52 g (arr52 a B) -> Tm52 g a -> Tm52 g B\napp52 = \\ t, u, tm, var52, lam52, app52 => app52 _ _ _ (t tm var52 lam52 app52) (u tm var52 lam52 app52)\n\nv052 : {g:_}->{a:_} -> Tm52 (snoc52 g a) a\nv052 = var52 vz52\n\nv152 : {g:_}->{a:_}-> {B:_}-> Tm52 (snoc52 (snoc52 g a) B) a\nv152 = var52 (vs52 vz52)\n\nv252 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm52 (snoc52 (snoc52 (snoc52 g a) B) C) a\nv252 = var52 (vs52 (vs52 vz52))\n\nv352 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm52 (snoc52 (snoc52 (snoc52 (snoc52 g a) B) C) D) a\nv352 = var52 (vs52 (vs52 (vs52 vz52)))\n\nv452 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm52 (snoc52 (snoc52 (snoc52 (snoc52 (snoc52 g a) B) C) D) E) a\nv452 = var52 (vs52 (vs52 (vs52 (vs52 vz52))))\n\ntest52 : {g:_}-> {a:_} -> Tm52 g (arr52 (arr52 a a) (arr52 a a))\ntest52 = lam52 (lam52 (app52 v152 (app52 v152 (app52 v152 (app52 v152 (app52 v152 (app52 v152 v052)))))))\nTy53 : Type\nTy53 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty53 : Ty53\nempty53 = \\ _, empty, _ => empty\n\narr53 : Ty53 -> Ty53 -> Ty53\narr53 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon53 : Type\nCon53 = (Con53 : Type)\n ->(nil : Con53)\n ->(snoc : Con53 -> Ty53 -> Con53)\n -> Con53\n\nnil53 : Con53\nnil53 = \\ con, nil53, snoc => nil53\n\nsnoc53 : Con53 -> Ty53 -> Con53\nsnoc53 = \\ g, a, con, nil53, snoc53 => snoc53 (g con nil53 snoc53) a\n\nVar53 : Con53 -> Ty53 -> Type\nVar53 = \\ g, a =>\n (Var53 : Con53 -> Ty53 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var53 (snoc53 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var53 g a -> Var53 (snoc53 g b) a)\n -> Var53 g a\n\nvz53 : {g : _}-> {a : _} -> Var53 (snoc53 g a) a\nvz53 = \\ var, vz53, vs => vz53 _ _\n\nvs53 : {g : _} -> {B : _} -> {a : _} -> Var53 g a -> Var53 (snoc53 g B) a\nvs53 = \\ x, var, vz53, vs53 => vs53 _ _ _ (x var vz53 vs53)\n\nTm53 : Con53 -> Ty53 -> Type\nTm53 = \\ g, a =>\n (Tm53 : Con53 -> Ty53 -> Type)\n -> (var : (g : _) -> (a : _) -> Var53 g a -> Tm53 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm53 (snoc53 g a) B -> Tm53 g (arr53 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm53 g (arr53 a B) -> Tm53 g a -> Tm53 g B)\n -> Tm53 g a\n\nvar53 : {g : _} -> {a : _} -> Var53 g a -> Tm53 g a\nvar53 = \\ x, tm, var53, lam, app => var53 _ _ x\n\nlam53 : {g : _} -> {a : _} -> {B : _} -> Tm53 (snoc53 g a) B -> Tm53 g (arr53 a B)\nlam53 = \\ t, tm, var53, lam53, app => lam53 _ _ _ (t tm var53 lam53 app)\n\napp53 : {g:_}->{a:_}->{B:_} -> Tm53 g (arr53 a B) -> Tm53 g a -> Tm53 g B\napp53 = \\ t, u, tm, var53, lam53, app53 => app53 _ _ _ (t tm var53 lam53 app53) (u tm var53 lam53 app53)\n\nv053 : {g:_}->{a:_} -> Tm53 (snoc53 g a) a\nv053 = var53 vz53\n\nv153 : {g:_}->{a:_}-> {B:_}-> Tm53 (snoc53 (snoc53 g a) B) a\nv153 = var53 (vs53 vz53)\n\nv253 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm53 (snoc53 (snoc53 (snoc53 g a) B) C) a\nv253 = var53 (vs53 (vs53 vz53))\n\nv353 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm53 (snoc53 (snoc53 (snoc53 (snoc53 g a) B) C) D) a\nv353 = var53 (vs53 (vs53 (vs53 vz53)))\n\nv453 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm53 (snoc53 (snoc53 (snoc53 (snoc53 (snoc53 g a) B) C) D) E) a\nv453 = var53 (vs53 (vs53 (vs53 (vs53 vz53))))\n\ntest53 : {g:_}-> {a:_} -> Tm53 g (arr53 (arr53 a a) (arr53 a a))\ntest53 = lam53 (lam53 (app53 v153 (app53 v153 (app53 v153 (app53 v153 (app53 v153 (app53 v153 v053)))))))\nTy54 : Type\nTy54 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty54 : Ty54\nempty54 = \\ _, empty, _ => empty\n\narr54 : Ty54 -> Ty54 -> Ty54\narr54 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon54 : Type\nCon54 = (Con54 : Type)\n ->(nil : Con54)\n ->(snoc : Con54 -> Ty54 -> Con54)\n -> Con54\n\nnil54 : Con54\nnil54 = \\ con, nil54, snoc => nil54\n\nsnoc54 : Con54 -> Ty54 -> Con54\nsnoc54 = \\ g, a, con, nil54, snoc54 => snoc54 (g con nil54 snoc54) a\n\nVar54 : Con54 -> Ty54 -> Type\nVar54 = \\ g, a =>\n (Var54 : Con54 -> Ty54 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var54 (snoc54 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var54 g a -> Var54 (snoc54 g b) a)\n -> Var54 g a\n\nvz54 : {g : _}-> {a : _} -> Var54 (snoc54 g a) a\nvz54 = \\ var, vz54, vs => vz54 _ _\n\nvs54 : {g : _} -> {B : _} -> {a : _} -> Var54 g a -> Var54 (snoc54 g B) a\nvs54 = \\ x, var, vz54, vs54 => vs54 _ _ _ (x var vz54 vs54)\n\nTm54 : Con54 -> Ty54 -> Type\nTm54 = \\ g, a =>\n (Tm54 : Con54 -> Ty54 -> Type)\n -> (var : (g : _) -> (a : _) -> Var54 g a -> Tm54 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm54 (snoc54 g a) B -> Tm54 g (arr54 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm54 g (arr54 a B) -> Tm54 g a -> Tm54 g B)\n -> Tm54 g a\n\nvar54 : {g : _} -> {a : _} -> Var54 g a -> Tm54 g a\nvar54 = \\ x, tm, var54, lam, app => var54 _ _ x\n\nlam54 : {g : _} -> {a : _} -> {B : _} -> Tm54 (snoc54 g a) B -> Tm54 g (arr54 a B)\nlam54 = \\ t, tm, var54, lam54, app => lam54 _ _ _ (t tm var54 lam54 app)\n\napp54 : {g:_}->{a:_}->{B:_} -> Tm54 g (arr54 a B) -> Tm54 g a -> Tm54 g B\napp54 = \\ t, u, tm, var54, lam54, app54 => app54 _ _ _ (t tm var54 lam54 app54) (u tm var54 lam54 app54)\n\nv054 : {g:_}->{a:_} -> Tm54 (snoc54 g a) a\nv054 = var54 vz54\n\nv154 : {g:_}->{a:_}-> {B:_}-> Tm54 (snoc54 (snoc54 g a) B) a\nv154 = var54 (vs54 vz54)\n\nv254 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm54 (snoc54 (snoc54 (snoc54 g a) B) C) a\nv254 = var54 (vs54 (vs54 vz54))\n\nv354 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm54 (snoc54 (snoc54 (snoc54 (snoc54 g a) B) C) D) a\nv354 = var54 (vs54 (vs54 (vs54 vz54)))\n\nv454 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm54 (snoc54 (snoc54 (snoc54 (snoc54 (snoc54 g a) B) C) D) E) a\nv454 = var54 (vs54 (vs54 (vs54 (vs54 vz54))))\n\ntest54 : {g:_}-> {a:_} -> Tm54 g (arr54 (arr54 a a) (arr54 a a))\ntest54 = lam54 (lam54 (app54 v154 (app54 v154 (app54 v154 (app54 v154 (app54 v154 (app54 v154 v054)))))))\nTy55 : Type\nTy55 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty55 : Ty55\nempty55 = \\ _, empty, _ => empty\n\narr55 : Ty55 -> Ty55 -> Ty55\narr55 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon55 : Type\nCon55 = (Con55 : Type)\n ->(nil : Con55)\n ->(snoc : Con55 -> Ty55 -> Con55)\n -> Con55\n\nnil55 : Con55\nnil55 = \\ con, nil55, snoc => nil55\n\nsnoc55 : Con55 -> Ty55 -> Con55\nsnoc55 = \\ g, a, con, nil55, snoc55 => snoc55 (g con nil55 snoc55) a\n\nVar55 : Con55 -> Ty55 -> Type\nVar55 = \\ g, a =>\n (Var55 : Con55 -> Ty55 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var55 (snoc55 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var55 g a -> Var55 (snoc55 g b) a)\n -> Var55 g a\n\nvz55 : {g : _}-> {a : _} -> Var55 (snoc55 g a) a\nvz55 = \\ var, vz55, vs => vz55 _ _\n\nvs55 : {g : _} -> {B : _} -> {a : _} -> Var55 g a -> Var55 (snoc55 g B) a\nvs55 = \\ x, var, vz55, vs55 => vs55 _ _ _ (x var vz55 vs55)\n\nTm55 : Con55 -> Ty55 -> Type\nTm55 = \\ g, a =>\n (Tm55 : Con55 -> Ty55 -> Type)\n -> (var : (g : _) -> (a : _) -> Var55 g a -> Tm55 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm55 (snoc55 g a) B -> Tm55 g (arr55 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm55 g (arr55 a B) -> Tm55 g a -> Tm55 g B)\n -> Tm55 g a\n\nvar55 : {g : _} -> {a : _} -> Var55 g a -> Tm55 g a\nvar55 = \\ x, tm, var55, lam, app => var55 _ _ x\n\nlam55 : {g : _} -> {a : _} -> {B : _} -> Tm55 (snoc55 g a) B -> Tm55 g (arr55 a B)\nlam55 = \\ t, tm, var55, lam55, app => lam55 _ _ _ (t tm var55 lam55 app)\n\napp55 : {g:_}->{a:_}->{B:_} -> Tm55 g (arr55 a B) -> Tm55 g a -> Tm55 g B\napp55 = \\ t, u, tm, var55, lam55, app55 => app55 _ _ _ (t tm var55 lam55 app55) (u tm var55 lam55 app55)\n\nv055 : {g:_}->{a:_} -> Tm55 (snoc55 g a) a\nv055 = var55 vz55\n\nv155 : {g:_}->{a:_}-> {B:_}-> Tm55 (snoc55 (snoc55 g a) B) a\nv155 = var55 (vs55 vz55)\n\nv255 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm55 (snoc55 (snoc55 (snoc55 g a) B) C) a\nv255 = var55 (vs55 (vs55 vz55))\n\nv355 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm55 (snoc55 (snoc55 (snoc55 (snoc55 g a) B) C) D) a\nv355 = var55 (vs55 (vs55 (vs55 vz55)))\n\nv455 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm55 (snoc55 (snoc55 (snoc55 (snoc55 (snoc55 g a) B) C) D) E) a\nv455 = var55 (vs55 (vs55 (vs55 (vs55 vz55))))\n\ntest55 : {g:_}-> {a:_} -> Tm55 g (arr55 (arr55 a a) (arr55 a a))\ntest55 = lam55 (lam55 (app55 v155 (app55 v155 (app55 v155 (app55 v155 (app55 v155 (app55 v155 v055)))))))\nTy56 : Type\nTy56 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty56 : Ty56\nempty56 = \\ _, empty, _ => empty\n\narr56 : Ty56 -> Ty56 -> Ty56\narr56 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon56 : Type\nCon56 = (Con56 : Type)\n ->(nil : Con56)\n ->(snoc : Con56 -> Ty56 -> Con56)\n -> Con56\n\nnil56 : Con56\nnil56 = \\ con, nil56, snoc => nil56\n\nsnoc56 : Con56 -> Ty56 -> Con56\nsnoc56 = \\ g, a, con, nil56, snoc56 => snoc56 (g con nil56 snoc56) a\n\nVar56 : Con56 -> Ty56 -> Type\nVar56 = \\ g, a =>\n (Var56 : Con56 -> Ty56 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var56 (snoc56 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var56 g a -> Var56 (snoc56 g b) a)\n -> Var56 g a\n\nvz56 : {g : _}-> {a : _} -> Var56 (snoc56 g a) a\nvz56 = \\ var, vz56, vs => vz56 _ _\n\nvs56 : {g : _} -> {B : _} -> {a : _} -> Var56 g a -> Var56 (snoc56 g B) a\nvs56 = \\ x, var, vz56, vs56 => vs56 _ _ _ (x var vz56 vs56)\n\nTm56 : Con56 -> Ty56 -> Type\nTm56 = \\ g, a =>\n (Tm56 : Con56 -> Ty56 -> Type)\n -> (var : (g : _) -> (a : _) -> Var56 g a -> Tm56 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm56 (snoc56 g a) B -> Tm56 g (arr56 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm56 g (arr56 a B) -> Tm56 g a -> Tm56 g B)\n -> Tm56 g a\n\nvar56 : {g : _} -> {a : _} -> Var56 g a -> Tm56 g a\nvar56 = \\ x, tm, var56, lam, app => var56 _ _ x\n\nlam56 : {g : _} -> {a : _} -> {B : _} -> Tm56 (snoc56 g a) B -> Tm56 g (arr56 a B)\nlam56 = \\ t, tm, var56, lam56, app => lam56 _ _ _ (t tm var56 lam56 app)\n\napp56 : {g:_}->{a:_}->{B:_} -> Tm56 g (arr56 a B) -> Tm56 g a -> Tm56 g B\napp56 = \\ t, u, tm, var56, lam56, app56 => app56 _ _ _ (t tm var56 lam56 app56) (u tm var56 lam56 app56)\n\nv056 : {g:_}->{a:_} -> Tm56 (snoc56 g a) a\nv056 = var56 vz56\n\nv156 : {g:_}->{a:_}-> {B:_}-> Tm56 (snoc56 (snoc56 g a) B) a\nv156 = var56 (vs56 vz56)\n\nv256 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm56 (snoc56 (snoc56 (snoc56 g a) B) C) a\nv256 = var56 (vs56 (vs56 vz56))\n\nv356 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm56 (snoc56 (snoc56 (snoc56 (snoc56 g a) B) C) D) a\nv356 = var56 (vs56 (vs56 (vs56 vz56)))\n\nv456 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm56 (snoc56 (snoc56 (snoc56 (snoc56 (snoc56 g a) B) C) D) E) a\nv456 = var56 (vs56 (vs56 (vs56 (vs56 vz56))))\n\ntest56 : {g:_}-> {a:_} -> Tm56 g (arr56 (arr56 a a) (arr56 a a))\ntest56 = lam56 (lam56 (app56 v156 (app56 v156 (app56 v156 (app56 v156 (app56 v156 (app56 v156 v056)))))))\nTy57 : Type\nTy57 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty57 : Ty57\nempty57 = \\ _, empty, _ => empty\n\narr57 : Ty57 -> Ty57 -> Ty57\narr57 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon57 : Type\nCon57 = (Con57 : Type)\n ->(nil : Con57)\n ->(snoc : Con57 -> Ty57 -> Con57)\n -> Con57\n\nnil57 : Con57\nnil57 = \\ con, nil57, snoc => nil57\n\nsnoc57 : Con57 -> Ty57 -> Con57\nsnoc57 = \\ g, a, con, nil57, snoc57 => snoc57 (g con nil57 snoc57) a\n\nVar57 : Con57 -> Ty57 -> Type\nVar57 = \\ g, a =>\n (Var57 : Con57 -> Ty57 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var57 (snoc57 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var57 g a -> Var57 (snoc57 g b) a)\n -> Var57 g a\n\nvz57 : {g : _}-> {a : _} -> Var57 (snoc57 g a) a\nvz57 = \\ var, vz57, vs => vz57 _ _\n\nvs57 : {g : _} -> {B : _} -> {a : _} -> Var57 g a -> Var57 (snoc57 g B) a\nvs57 = \\ x, var, vz57, vs57 => vs57 _ _ _ (x var vz57 vs57)\n\nTm57 : Con57 -> Ty57 -> Type\nTm57 = \\ g, a =>\n (Tm57 : Con57 -> Ty57 -> Type)\n -> (var : (g : _) -> (a : _) -> Var57 g a -> Tm57 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm57 (snoc57 g a) B -> Tm57 g (arr57 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm57 g (arr57 a B) -> Tm57 g a -> Tm57 g B)\n -> Tm57 g a\n\nvar57 : {g : _} -> {a : _} -> Var57 g a -> Tm57 g a\nvar57 = \\ x, tm, var57, lam, app => var57 _ _ x\n\nlam57 : {g : _} -> {a : _} -> {B : _} -> Tm57 (snoc57 g a) B -> Tm57 g (arr57 a B)\nlam57 = \\ t, tm, var57, lam57, app => lam57 _ _ _ (t tm var57 lam57 app)\n\napp57 : {g:_}->{a:_}->{B:_} -> Tm57 g (arr57 a B) -> Tm57 g a -> Tm57 g B\napp57 = \\ t, u, tm, var57, lam57, app57 => app57 _ _ _ (t tm var57 lam57 app57) (u tm var57 lam57 app57)\n\nv057 : {g:_}->{a:_} -> Tm57 (snoc57 g a) a\nv057 = var57 vz57\n\nv157 : {g:_}->{a:_}-> {B:_}-> Tm57 (snoc57 (snoc57 g a) B) a\nv157 = var57 (vs57 vz57)\n\nv257 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm57 (snoc57 (snoc57 (snoc57 g a) B) C) a\nv257 = var57 (vs57 (vs57 vz57))\n\nv357 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm57 (snoc57 (snoc57 (snoc57 (snoc57 g a) B) C) D) a\nv357 = var57 (vs57 (vs57 (vs57 vz57)))\n\nv457 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm57 (snoc57 (snoc57 (snoc57 (snoc57 (snoc57 g a) B) C) D) E) a\nv457 = var57 (vs57 (vs57 (vs57 (vs57 vz57))))\n\ntest57 : {g:_}-> {a:_} -> Tm57 g (arr57 (arr57 a a) (arr57 a a))\ntest57 = lam57 (lam57 (app57 v157 (app57 v157 (app57 v157 (app57 v157 (app57 v157 (app57 v157 v057)))))))\nTy58 : Type\nTy58 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty58 : Ty58\nempty58 = \\ _, empty, _ => empty\n\narr58 : Ty58 -> Ty58 -> Ty58\narr58 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon58 : Type\nCon58 = (Con58 : Type)\n ->(nil : Con58)\n ->(snoc : Con58 -> Ty58 -> Con58)\n -> Con58\n\nnil58 : Con58\nnil58 = \\ con, nil58, snoc => nil58\n\nsnoc58 : Con58 -> Ty58 -> Con58\nsnoc58 = \\ g, a, con, nil58, snoc58 => snoc58 (g con nil58 snoc58) a\n\nVar58 : Con58 -> Ty58 -> Type\nVar58 = \\ g, a =>\n (Var58 : Con58 -> Ty58 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var58 (snoc58 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var58 g a -> Var58 (snoc58 g b) a)\n -> Var58 g a\n\nvz58 : {g : _}-> {a : _} -> Var58 (snoc58 g a) a\nvz58 = \\ var, vz58, vs => vz58 _ _\n\nvs58 : {g : _} -> {B : _} -> {a : _} -> Var58 g a -> Var58 (snoc58 g B) a\nvs58 = \\ x, var, vz58, vs58 => vs58 _ _ _ (x var vz58 vs58)\n\nTm58 : Con58 -> Ty58 -> Type\nTm58 = \\ g, a =>\n (Tm58 : Con58 -> Ty58 -> Type)\n -> (var : (g : _) -> (a : _) -> Var58 g a -> Tm58 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm58 (snoc58 g a) B -> Tm58 g (arr58 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm58 g (arr58 a B) -> Tm58 g a -> Tm58 g B)\n -> Tm58 g a\n\nvar58 : {g : _} -> {a : _} -> Var58 g a -> Tm58 g a\nvar58 = \\ x, tm, var58, lam, app => var58 _ _ x\n\nlam58 : {g : _} -> {a : _} -> {B : _} -> Tm58 (snoc58 g a) B -> Tm58 g (arr58 a B)\nlam58 = \\ t, tm, var58, lam58, app => lam58 _ _ _ (t tm var58 lam58 app)\n\napp58 : {g:_}->{a:_}->{B:_} -> Tm58 g (arr58 a B) -> Tm58 g a -> Tm58 g B\napp58 = \\ t, u, tm, var58, lam58, app58 => app58 _ _ _ (t tm var58 lam58 app58) (u tm var58 lam58 app58)\n\nv058 : {g:_}->{a:_} -> Tm58 (snoc58 g a) a\nv058 = var58 vz58\n\nv158 : {g:_}->{a:_}-> {B:_}-> Tm58 (snoc58 (snoc58 g a) B) a\nv158 = var58 (vs58 vz58)\n\nv258 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm58 (snoc58 (snoc58 (snoc58 g a) B) C) a\nv258 = var58 (vs58 (vs58 vz58))\n\nv358 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm58 (snoc58 (snoc58 (snoc58 (snoc58 g a) B) C) D) a\nv358 = var58 (vs58 (vs58 (vs58 vz58)))\n\nv458 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm58 (snoc58 (snoc58 (snoc58 (snoc58 (snoc58 g a) B) C) D) E) a\nv458 = var58 (vs58 (vs58 (vs58 (vs58 vz58))))\n\ntest58 : {g:_}-> {a:_} -> Tm58 g (arr58 (arr58 a a) (arr58 a a))\ntest58 = lam58 (lam58 (app58 v158 (app58 v158 (app58 v158 (app58 v158 (app58 v158 (app58 v158 v058)))))))\nTy59 : Type\nTy59 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty59 : Ty59\nempty59 = \\ _, empty, _ => empty\n\narr59 : Ty59 -> Ty59 -> Ty59\narr59 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon59 : Type\nCon59 = (Con59 : Type)\n ->(nil : Con59)\n ->(snoc : Con59 -> Ty59 -> Con59)\n -> Con59\n\nnil59 : Con59\nnil59 = \\ con, nil59, snoc => nil59\n\nsnoc59 : Con59 -> Ty59 -> Con59\nsnoc59 = \\ g, a, con, nil59, snoc59 => snoc59 (g con nil59 snoc59) a\n\nVar59 : Con59 -> Ty59 -> Type\nVar59 = \\ g, a =>\n (Var59 : Con59 -> Ty59 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var59 (snoc59 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var59 g a -> Var59 (snoc59 g b) a)\n -> Var59 g a\n\nvz59 : {g : _}-> {a : _} -> Var59 (snoc59 g a) a\nvz59 = \\ var, vz59, vs => vz59 _ _\n\nvs59 : {g : _} -> {B : _} -> {a : _} -> Var59 g a -> Var59 (snoc59 g B) a\nvs59 = \\ x, var, vz59, vs59 => vs59 _ _ _ (x var vz59 vs59)\n\nTm59 : Con59 -> Ty59 -> Type\nTm59 = \\ g, a =>\n (Tm59 : Con59 -> Ty59 -> Type)\n -> (var : (g : _) -> (a : _) -> Var59 g a -> Tm59 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm59 (snoc59 g a) B -> Tm59 g (arr59 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm59 g (arr59 a B) -> Tm59 g a -> Tm59 g B)\n -> Tm59 g a\n\nvar59 : {g : _} -> {a : _} -> Var59 g a -> Tm59 g a\nvar59 = \\ x, tm, var59, lam, app => var59 _ _ x\n\nlam59 : {g : _} -> {a : _} -> {B : _} -> Tm59 (snoc59 g a) B -> Tm59 g (arr59 a B)\nlam59 = \\ t, tm, var59, lam59, app => lam59 _ _ _ (t tm var59 lam59 app)\n\napp59 : {g:_}->{a:_}->{B:_} -> Tm59 g (arr59 a B) -> Tm59 g a -> Tm59 g B\napp59 = \\ t, u, tm, var59, lam59, app59 => app59 _ _ _ (t tm var59 lam59 app59) (u tm var59 lam59 app59)\n\nv059 : {g:_}->{a:_} -> Tm59 (snoc59 g a) a\nv059 = var59 vz59\n\nv159 : {g:_}->{a:_}-> {B:_}-> Tm59 (snoc59 (snoc59 g a) B) a\nv159 = var59 (vs59 vz59)\n\nv259 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm59 (snoc59 (snoc59 (snoc59 g a) B) C) a\nv259 = var59 (vs59 (vs59 vz59))\n\nv359 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm59 (snoc59 (snoc59 (snoc59 (snoc59 g a) B) C) D) a\nv359 = var59 (vs59 (vs59 (vs59 vz59)))\n\nv459 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm59 (snoc59 (snoc59 (snoc59 (snoc59 (snoc59 g a) B) C) D) E) a\nv459 = var59 (vs59 (vs59 (vs59 (vs59 vz59))))\n\ntest59 : {g:_}-> {a:_} -> Tm59 g (arr59 (arr59 a a) (arr59 a a))\ntest59 = lam59 (lam59 (app59 v159 (app59 v159 (app59 v159 (app59 v159 (app59 v159 (app59 v159 v059)))))))\nTy60 : Type\nTy60 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty60 : Ty60\nempty60 = \\ _, empty, _ => empty\n\narr60 : Ty60 -> Ty60 -> Ty60\narr60 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon60 : Type\nCon60 = (Con60 : Type)\n ->(nil : Con60)\n ->(snoc : Con60 -> Ty60 -> Con60)\n -> Con60\n\nnil60 : Con60\nnil60 = \\ con, nil60, snoc => nil60\n\nsnoc60 : Con60 -> Ty60 -> Con60\nsnoc60 = \\ g, a, con, nil60, snoc60 => snoc60 (g con nil60 snoc60) a\n\nVar60 : Con60 -> Ty60 -> Type\nVar60 = \\ g, a =>\n (Var60 : Con60 -> Ty60 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var60 (snoc60 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var60 g a -> Var60 (snoc60 g b) a)\n -> Var60 g a\n\nvz60 : {g : _}-> {a : _} -> Var60 (snoc60 g a) a\nvz60 = \\ var, vz60, vs => vz60 _ _\n\nvs60 : {g : _} -> {B : _} -> {a : _} -> Var60 g a -> Var60 (snoc60 g B) a\nvs60 = \\ x, var, vz60, vs60 => vs60 _ _ _ (x var vz60 vs60)\n\nTm60 : Con60 -> Ty60 -> Type\nTm60 = \\ g, a =>\n (Tm60 : Con60 -> Ty60 -> Type)\n -> (var : (g : _) -> (a : _) -> Var60 g a -> Tm60 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm60 (snoc60 g a) B -> Tm60 g (arr60 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm60 g (arr60 a B) -> Tm60 g a -> Tm60 g B)\n -> Tm60 g a\n\nvar60 : {g : _} -> {a : _} -> Var60 g a -> Tm60 g a\nvar60 = \\ x, tm, var60, lam, app => var60 _ _ x\n\nlam60 : {g : _} -> {a : _} -> {B : _} -> Tm60 (snoc60 g a) B -> Tm60 g (arr60 a B)\nlam60 = \\ t, tm, var60, lam60, app => lam60 _ _ _ (t tm var60 lam60 app)\n\napp60 : {g:_}->{a:_}->{B:_} -> Tm60 g (arr60 a B) -> Tm60 g a -> Tm60 g B\napp60 = \\ t, u, tm, var60, lam60, app60 => app60 _ _ _ (t tm var60 lam60 app60) (u tm var60 lam60 app60)\n\nv060 : {g:_}->{a:_} -> Tm60 (snoc60 g a) a\nv060 = var60 vz60\n\nv160 : {g:_}->{a:_}-> {B:_}-> Tm60 (snoc60 (snoc60 g a) B) a\nv160 = var60 (vs60 vz60)\n\nv260 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm60 (snoc60 (snoc60 (snoc60 g a) B) C) a\nv260 = var60 (vs60 (vs60 vz60))\n\nv360 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm60 (snoc60 (snoc60 (snoc60 (snoc60 g a) B) C) D) a\nv360 = var60 (vs60 (vs60 (vs60 vz60)))\n\nv460 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm60 (snoc60 (snoc60 (snoc60 (snoc60 (snoc60 g a) B) C) D) E) a\nv460 = var60 (vs60 (vs60 (vs60 (vs60 vz60))))\n\ntest60 : {g:_}-> {a:_} -> Tm60 g (arr60 (arr60 a a) (arr60 a a))\ntest60 = lam60 (lam60 (app60 v160 (app60 v160 (app60 v160 (app60 v160 (app60 v160 (app60 v160 v060)))))))\nTy61 : Type\nTy61 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty61 : Ty61\nempty61 = \\ _, empty, _ => empty\n\narr61 : Ty61 -> Ty61 -> Ty61\narr61 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon61 : Type\nCon61 = (Con61 : Type)\n ->(nil : Con61)\n ->(snoc : Con61 -> Ty61 -> Con61)\n -> Con61\n\nnil61 : Con61\nnil61 = \\ con, nil61, snoc => nil61\n\nsnoc61 : Con61 -> Ty61 -> Con61\nsnoc61 = \\ g, a, con, nil61, snoc61 => snoc61 (g con nil61 snoc61) a\n\nVar61 : Con61 -> Ty61 -> Type\nVar61 = \\ g, a =>\n (Var61 : Con61 -> Ty61 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var61 (snoc61 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var61 g a -> Var61 (snoc61 g b) a)\n -> Var61 g a\n\nvz61 : {g : _}-> {a : _} -> Var61 (snoc61 g a) a\nvz61 = \\ var, vz61, vs => vz61 _ _\n\nvs61 : {g : _} -> {B : _} -> {a : _} -> Var61 g a -> Var61 (snoc61 g B) a\nvs61 = \\ x, var, vz61, vs61 => vs61 _ _ _ (x var vz61 vs61)\n\nTm61 : Con61 -> Ty61 -> Type\nTm61 = \\ g, a =>\n (Tm61 : Con61 -> Ty61 -> Type)\n -> (var : (g : _) -> (a : _) -> Var61 g a -> Tm61 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm61 (snoc61 g a) B -> Tm61 g (arr61 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm61 g (arr61 a B) -> Tm61 g a -> Tm61 g B)\n -> Tm61 g a\n\nvar61 : {g : _} -> {a : _} -> Var61 g a -> Tm61 g a\nvar61 = \\ x, tm, var61, lam, app => var61 _ _ x\n\nlam61 : {g : _} -> {a : _} -> {B : _} -> Tm61 (snoc61 g a) B -> Tm61 g (arr61 a B)\nlam61 = \\ t, tm, var61, lam61, app => lam61 _ _ _ (t tm var61 lam61 app)\n\napp61 : {g:_}->{a:_}->{B:_} -> Tm61 g (arr61 a B) -> Tm61 g a -> Tm61 g B\napp61 = \\ t, u, tm, var61, lam61, app61 => app61 _ _ _ (t tm var61 lam61 app61) (u tm var61 lam61 app61)\n\nv061 : {g:_}->{a:_} -> Tm61 (snoc61 g a) a\nv061 = var61 vz61\n\nv161 : {g:_}->{a:_}-> {B:_}-> Tm61 (snoc61 (snoc61 g a) B) a\nv161 = var61 (vs61 vz61)\n\nv261 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm61 (snoc61 (snoc61 (snoc61 g a) B) C) a\nv261 = var61 (vs61 (vs61 vz61))\n\nv361 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm61 (snoc61 (snoc61 (snoc61 (snoc61 g a) B) C) D) a\nv361 = var61 (vs61 (vs61 (vs61 vz61)))\n\nv461 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm61 (snoc61 (snoc61 (snoc61 (snoc61 (snoc61 g a) B) C) D) E) a\nv461 = var61 (vs61 (vs61 (vs61 (vs61 vz61))))\n\ntest61 : {g:_}-> {a:_} -> Tm61 g (arr61 (arr61 a a) (arr61 a a))\ntest61 = lam61 (lam61 (app61 v161 (app61 v161 (app61 v161 (app61 v161 (app61 v161 (app61 v161 v061)))))))\nTy62 : Type\nTy62 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty62 : Ty62\nempty62 = \\ _, empty, _ => empty\n\narr62 : Ty62 -> Ty62 -> Ty62\narr62 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon62 : Type\nCon62 = (Con62 : Type)\n ->(nil : Con62)\n ->(snoc : Con62 -> Ty62 -> Con62)\n -> Con62\n\nnil62 : Con62\nnil62 = \\ con, nil62, snoc => nil62\n\nsnoc62 : Con62 -> Ty62 -> Con62\nsnoc62 = \\ g, a, con, nil62, snoc62 => snoc62 (g con nil62 snoc62) a\n\nVar62 : Con62 -> Ty62 -> Type\nVar62 = \\ g, a =>\n (Var62 : Con62 -> Ty62 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var62 (snoc62 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var62 g a -> Var62 (snoc62 g b) a)\n -> Var62 g a\n\nvz62 : {g : _}-> {a : _} -> Var62 (snoc62 g a) a\nvz62 = \\ var, vz62, vs => vz62 _ _\n\nvs62 : {g : _} -> {B : _} -> {a : _} -> Var62 g a -> Var62 (snoc62 g B) a\nvs62 = \\ x, var, vz62, vs62 => vs62 _ _ _ (x var vz62 vs62)\n\nTm62 : Con62 -> Ty62 -> Type\nTm62 = \\ g, a =>\n (Tm62 : Con62 -> Ty62 -> Type)\n -> (var : (g : _) -> (a : _) -> Var62 g a -> Tm62 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm62 (snoc62 g a) B -> Tm62 g (arr62 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm62 g (arr62 a B) -> Tm62 g a -> Tm62 g B)\n -> Tm62 g a\n\nvar62 : {g : _} -> {a : _} -> Var62 g a -> Tm62 g a\nvar62 = \\ x, tm, var62, lam, app => var62 _ _ x\n\nlam62 : {g : _} -> {a : _} -> {B : _} -> Tm62 (snoc62 g a) B -> Tm62 g (arr62 a B)\nlam62 = \\ t, tm, var62, lam62, app => lam62 _ _ _ (t tm var62 lam62 app)\n\napp62 : {g:_}->{a:_}->{B:_} -> Tm62 g (arr62 a B) -> Tm62 g a -> Tm62 g B\napp62 = \\ t, u, tm, var62, lam62, app62 => app62 _ _ _ (t tm var62 lam62 app62) (u tm var62 lam62 app62)\n\nv062 : {g:_}->{a:_} -> Tm62 (snoc62 g a) a\nv062 = var62 vz62\n\nv162 : {g:_}->{a:_}-> {B:_}-> Tm62 (snoc62 (snoc62 g a) B) a\nv162 = var62 (vs62 vz62)\n\nv262 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm62 (snoc62 (snoc62 (snoc62 g a) B) C) a\nv262 = var62 (vs62 (vs62 vz62))\n\nv362 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm62 (snoc62 (snoc62 (snoc62 (snoc62 g a) B) C) D) a\nv362 = var62 (vs62 (vs62 (vs62 vz62)))\n\nv462 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm62 (snoc62 (snoc62 (snoc62 (snoc62 (snoc62 g a) B) C) D) E) a\nv462 = var62 (vs62 (vs62 (vs62 (vs62 vz62))))\n\ntest62 : {g:_}-> {a:_} -> Tm62 g (arr62 (arr62 a a) (arr62 a a))\ntest62 = lam62 (lam62 (app62 v162 (app62 v162 (app62 v162 (app62 v162 (app62 v162 (app62 v162 v062)))))))\nTy63 : Type\nTy63 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty63 : Ty63\nempty63 = \\ _, empty, _ => empty\n\narr63 : Ty63 -> Ty63 -> Ty63\narr63 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon63 : Type\nCon63 = (Con63 : Type)\n ->(nil : Con63)\n ->(snoc : Con63 -> Ty63 -> Con63)\n -> Con63\n\nnil63 : Con63\nnil63 = \\ con, nil63, snoc => nil63\n\nsnoc63 : Con63 -> Ty63 -> Con63\nsnoc63 = \\ g, a, con, nil63, snoc63 => snoc63 (g con nil63 snoc63) a\n\nVar63 : Con63 -> Ty63 -> Type\nVar63 = \\ g, a =>\n (Var63 : Con63 -> Ty63 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var63 (snoc63 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var63 g a -> Var63 (snoc63 g b) a)\n -> Var63 g a\n\nvz63 : {g : _}-> {a : _} -> Var63 (snoc63 g a) a\nvz63 = \\ var, vz63, vs => vz63 _ _\n\nvs63 : {g : _} -> {B : _} -> {a : _} -> Var63 g a -> Var63 (snoc63 g B) a\nvs63 = \\ x, var, vz63, vs63 => vs63 _ _ _ (x var vz63 vs63)\n\nTm63 : Con63 -> Ty63 -> Type\nTm63 = \\ g, a =>\n (Tm63 : Con63 -> Ty63 -> Type)\n -> (var : (g : _) -> (a : _) -> Var63 g a -> Tm63 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm63 (snoc63 g a) B -> Tm63 g (arr63 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm63 g (arr63 a B) -> Tm63 g a -> Tm63 g B)\n -> Tm63 g a\n\nvar63 : {g : _} -> {a : _} -> Var63 g a -> Tm63 g a\nvar63 = \\ x, tm, var63, lam, app => var63 _ _ x\n\nlam63 : {g : _} -> {a : _} -> {B : _} -> Tm63 (snoc63 g a) B -> Tm63 g (arr63 a B)\nlam63 = \\ t, tm, var63, lam63, app => lam63 _ _ _ (t tm var63 lam63 app)\n\napp63 : {g:_}->{a:_}->{B:_} -> Tm63 g (arr63 a B) -> Tm63 g a -> Tm63 g B\napp63 = \\ t, u, tm, var63, lam63, app63 => app63 _ _ _ (t tm var63 lam63 app63) (u tm var63 lam63 app63)\n\nv063 : {g:_}->{a:_} -> Tm63 (snoc63 g a) a\nv063 = var63 vz63\n\nv163 : {g:_}->{a:_}-> {B:_}-> Tm63 (snoc63 (snoc63 g a) B) a\nv163 = var63 (vs63 vz63)\n\nv263 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm63 (snoc63 (snoc63 (snoc63 g a) B) C) a\nv263 = var63 (vs63 (vs63 vz63))\n\nv363 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm63 (snoc63 (snoc63 (snoc63 (snoc63 g a) B) C) D) a\nv363 = var63 (vs63 (vs63 (vs63 vz63)))\n\nv463 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm63 (snoc63 (snoc63 (snoc63 (snoc63 (snoc63 g a) B) C) D) E) a\nv463 = var63 (vs63 (vs63 (vs63 (vs63 vz63))))\n\ntest63 : {g:_}-> {a:_} -> Tm63 g (arr63 (arr63 a a) (arr63 a a))\ntest63 = lam63 (lam63 (app63 v163 (app63 v163 (app63 v163 (app63 v163 (app63 v163 (app63 v163 v063)))))))\nTy64 : Type\nTy64 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty64 : Ty64\nempty64 = \\ _, empty, _ => empty\n\narr64 : Ty64 -> Ty64 -> Ty64\narr64 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon64 : Type\nCon64 = (Con64 : Type)\n ->(nil : Con64)\n ->(snoc : Con64 -> Ty64 -> Con64)\n -> Con64\n\nnil64 : Con64\nnil64 = \\ con, nil64, snoc => nil64\n\nsnoc64 : Con64 -> Ty64 -> Con64\nsnoc64 = \\ g, a, con, nil64, snoc64 => snoc64 (g con nil64 snoc64) a\n\nVar64 : Con64 -> Ty64 -> Type\nVar64 = \\ g, a =>\n (Var64 : Con64 -> Ty64 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var64 (snoc64 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var64 g a -> Var64 (snoc64 g b) a)\n -> Var64 g a\n\nvz64 : {g : _}-> {a : _} -> Var64 (snoc64 g a) a\nvz64 = \\ var, vz64, vs => vz64 _ _\n\nvs64 : {g : _} -> {B : _} -> {a : _} -> Var64 g a -> Var64 (snoc64 g B) a\nvs64 = \\ x, var, vz64, vs64 => vs64 _ _ _ (x var vz64 vs64)\n\nTm64 : Con64 -> Ty64 -> Type\nTm64 = \\ g, a =>\n (Tm64 : Con64 -> Ty64 -> Type)\n -> (var : (g : _) -> (a : _) -> Var64 g a -> Tm64 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm64 (snoc64 g a) B -> Tm64 g (arr64 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm64 g (arr64 a B) -> Tm64 g a -> Tm64 g B)\n -> Tm64 g a\n\nvar64 : {g : _} -> {a : _} -> Var64 g a -> Tm64 g a\nvar64 = \\ x, tm, var64, lam, app => var64 _ _ x\n\nlam64 : {g : _} -> {a : _} -> {B : _} -> Tm64 (snoc64 g a) B -> Tm64 g (arr64 a B)\nlam64 = \\ t, tm, var64, lam64, app => lam64 _ _ _ (t tm var64 lam64 app)\n\napp64 : {g:_}->{a:_}->{B:_} -> Tm64 g (arr64 a B) -> Tm64 g a -> Tm64 g B\napp64 = \\ t, u, tm, var64, lam64, app64 => app64 _ _ _ (t tm var64 lam64 app64) (u tm var64 lam64 app64)\n\nv064 : {g:_}->{a:_} -> Tm64 (snoc64 g a) a\nv064 = var64 vz64\n\nv164 : {g:_}->{a:_}-> {B:_}-> Tm64 (snoc64 (snoc64 g a) B) a\nv164 = var64 (vs64 vz64)\n\nv264 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm64 (snoc64 (snoc64 (snoc64 g a) B) C) a\nv264 = var64 (vs64 (vs64 vz64))\n\nv364 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm64 (snoc64 (snoc64 (snoc64 (snoc64 g a) B) C) D) a\nv364 = var64 (vs64 (vs64 (vs64 vz64)))\n\nv464 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm64 (snoc64 (snoc64 (snoc64 (snoc64 (snoc64 g a) B) C) D) E) a\nv464 = var64 (vs64 (vs64 (vs64 (vs64 vz64))))\n\ntest64 : {g:_}-> {a:_} -> Tm64 g (arr64 (arr64 a a) (arr64 a a))\ntest64 = lam64 (lam64 (app64 v164 (app64 v164 (app64 v164 (app64 v164 (app64 v164 (app64 v164 v064)))))))\nTy65 : Type\nTy65 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty65 : Ty65\nempty65 = \\ _, empty, _ => empty\n\narr65 : Ty65 -> Ty65 -> Ty65\narr65 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon65 : Type\nCon65 = (Con65 : Type)\n ->(nil : Con65)\n ->(snoc : Con65 -> Ty65 -> Con65)\n -> Con65\n\nnil65 : Con65\nnil65 = \\ con, nil65, snoc => nil65\n\nsnoc65 : Con65 -> Ty65 -> Con65\nsnoc65 = \\ g, a, con, nil65, snoc65 => snoc65 (g con nil65 snoc65) a\n\nVar65 : Con65 -> Ty65 -> Type\nVar65 = \\ g, a =>\n (Var65 : Con65 -> Ty65 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var65 (snoc65 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var65 g a -> Var65 (snoc65 g b) a)\n -> Var65 g a\n\nvz65 : {g : _}-> {a : _} -> Var65 (snoc65 g a) a\nvz65 = \\ var, vz65, vs => vz65 _ _\n\nvs65 : {g : _} -> {B : _} -> {a : _} -> Var65 g a -> Var65 (snoc65 g B) a\nvs65 = \\ x, var, vz65, vs65 => vs65 _ _ _ (x var vz65 vs65)\n\nTm65 : Con65 -> Ty65 -> Type\nTm65 = \\ g, a =>\n (Tm65 : Con65 -> Ty65 -> Type)\n -> (var : (g : _) -> (a : _) -> Var65 g a -> Tm65 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm65 (snoc65 g a) B -> Tm65 g (arr65 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm65 g (arr65 a B) -> Tm65 g a -> Tm65 g B)\n -> Tm65 g a\n\nvar65 : {g : _} -> {a : _} -> Var65 g a -> Tm65 g a\nvar65 = \\ x, tm, var65, lam, app => var65 _ _ x\n\nlam65 : {g : _} -> {a : _} -> {B : _} -> Tm65 (snoc65 g a) B -> Tm65 g (arr65 a B)\nlam65 = \\ t, tm, var65, lam65, app => lam65 _ _ _ (t tm var65 lam65 app)\n\napp65 : {g:_}->{a:_}->{B:_} -> Tm65 g (arr65 a B) -> Tm65 g a -> Tm65 g B\napp65 = \\ t, u, tm, var65, lam65, app65 => app65 _ _ _ (t tm var65 lam65 app65) (u tm var65 lam65 app65)\n\nv065 : {g:_}->{a:_} -> Tm65 (snoc65 g a) a\nv065 = var65 vz65\n\nv165 : {g:_}->{a:_}-> {B:_}-> Tm65 (snoc65 (snoc65 g a) B) a\nv165 = var65 (vs65 vz65)\n\nv265 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm65 (snoc65 (snoc65 (snoc65 g a) B) C) a\nv265 = var65 (vs65 (vs65 vz65))\n\nv365 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm65 (snoc65 (snoc65 (snoc65 (snoc65 g a) B) C) D) a\nv365 = var65 (vs65 (vs65 (vs65 vz65)))\n\nv465 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm65 (snoc65 (snoc65 (snoc65 (snoc65 (snoc65 g a) B) C) D) E) a\nv465 = var65 (vs65 (vs65 (vs65 (vs65 vz65))))\n\ntest65 : {g:_}-> {a:_} -> Tm65 g (arr65 (arr65 a a) (arr65 a a))\ntest65 = lam65 (lam65 (app65 v165 (app65 v165 (app65 v165 (app65 v165 (app65 v165 (app65 v165 v065)))))))\nTy66 : Type\nTy66 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty66 : Ty66\nempty66 = \\ _, empty, _ => empty\n\narr66 : Ty66 -> Ty66 -> Ty66\narr66 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon66 : Type\nCon66 = (Con66 : Type)\n ->(nil : Con66)\n ->(snoc : Con66 -> Ty66 -> Con66)\n -> Con66\n\nnil66 : Con66\nnil66 = \\ con, nil66, snoc => nil66\n\nsnoc66 : Con66 -> Ty66 -> Con66\nsnoc66 = \\ g, a, con, nil66, snoc66 => snoc66 (g con nil66 snoc66) a\n\nVar66 : Con66 -> Ty66 -> Type\nVar66 = \\ g, a =>\n (Var66 : Con66 -> Ty66 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var66 (snoc66 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var66 g a -> Var66 (snoc66 g b) a)\n -> Var66 g a\n\nvz66 : {g : _}-> {a : _} -> Var66 (snoc66 g a) a\nvz66 = \\ var, vz66, vs => vz66 _ _\n\nvs66 : {g : _} -> {B : _} -> {a : _} -> Var66 g a -> Var66 (snoc66 g B) a\nvs66 = \\ x, var, vz66, vs66 => vs66 _ _ _ (x var vz66 vs66)\n\nTm66 : Con66 -> Ty66 -> Type\nTm66 = \\ g, a =>\n (Tm66 : Con66 -> Ty66 -> Type)\n -> (var : (g : _) -> (a : _) -> Var66 g a -> Tm66 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm66 (snoc66 g a) B -> Tm66 g (arr66 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm66 g (arr66 a B) -> Tm66 g a -> Tm66 g B)\n -> Tm66 g a\n\nvar66 : {g : _} -> {a : _} -> Var66 g a -> Tm66 g a\nvar66 = \\ x, tm, var66, lam, app => var66 _ _ x\n\nlam66 : {g : _} -> {a : _} -> {B : _} -> Tm66 (snoc66 g a) B -> Tm66 g (arr66 a B)\nlam66 = \\ t, tm, var66, lam66, app => lam66 _ _ _ (t tm var66 lam66 app)\n\napp66 : {g:_}->{a:_}->{B:_} -> Tm66 g (arr66 a B) -> Tm66 g a -> Tm66 g B\napp66 = \\ t, u, tm, var66, lam66, app66 => app66 _ _ _ (t tm var66 lam66 app66) (u tm var66 lam66 app66)\n\nv066 : {g:_}->{a:_} -> Tm66 (snoc66 g a) a\nv066 = var66 vz66\n\nv166 : {g:_}->{a:_}-> {B:_}-> Tm66 (snoc66 (snoc66 g a) B) a\nv166 = var66 (vs66 vz66)\n\nv266 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm66 (snoc66 (snoc66 (snoc66 g a) B) C) a\nv266 = var66 (vs66 (vs66 vz66))\n\nv366 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm66 (snoc66 (snoc66 (snoc66 (snoc66 g a) B) C) D) a\nv366 = var66 (vs66 (vs66 (vs66 vz66)))\n\nv466 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm66 (snoc66 (snoc66 (snoc66 (snoc66 (snoc66 g a) B) C) D) E) a\nv466 = var66 (vs66 (vs66 (vs66 (vs66 vz66))))\n\ntest66 : {g:_}-> {a:_} -> Tm66 g (arr66 (arr66 a a) (arr66 a a))\ntest66 = lam66 (lam66 (app66 v166 (app66 v166 (app66 v166 (app66 v166 (app66 v166 (app66 v166 v066)))))))\nTy67 : Type\nTy67 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty67 : Ty67\nempty67 = \\ _, empty, _ => empty\n\narr67 : Ty67 -> Ty67 -> Ty67\narr67 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon67 : Type\nCon67 = (Con67 : Type)\n ->(nil : Con67)\n ->(snoc : Con67 -> Ty67 -> Con67)\n -> Con67\n\nnil67 : Con67\nnil67 = \\ con, nil67, snoc => nil67\n\nsnoc67 : Con67 -> Ty67 -> Con67\nsnoc67 = \\ g, a, con, nil67, snoc67 => snoc67 (g con nil67 snoc67) a\n\nVar67 : Con67 -> Ty67 -> Type\nVar67 = \\ g, a =>\n (Var67 : Con67 -> Ty67 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var67 (snoc67 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var67 g a -> Var67 (snoc67 g b) a)\n -> Var67 g a\n\nvz67 : {g : _}-> {a : _} -> Var67 (snoc67 g a) a\nvz67 = \\ var, vz67, vs => vz67 _ _\n\nvs67 : {g : _} -> {B : _} -> {a : _} -> Var67 g a -> Var67 (snoc67 g B) a\nvs67 = \\ x, var, vz67, vs67 => vs67 _ _ _ (x var vz67 vs67)\n\nTm67 : Con67 -> Ty67 -> Type\nTm67 = \\ g, a =>\n (Tm67 : Con67 -> Ty67 -> Type)\n -> (var : (g : _) -> (a : _) -> Var67 g a -> Tm67 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm67 (snoc67 g a) B -> Tm67 g (arr67 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm67 g (arr67 a B) -> Tm67 g a -> Tm67 g B)\n -> Tm67 g a\n\nvar67 : {g : _} -> {a : _} -> Var67 g a -> Tm67 g a\nvar67 = \\ x, tm, var67, lam, app => var67 _ _ x\n\nlam67 : {g : _} -> {a : _} -> {B : _} -> Tm67 (snoc67 g a) B -> Tm67 g (arr67 a B)\nlam67 = \\ t, tm, var67, lam67, app => lam67 _ _ _ (t tm var67 lam67 app)\n\napp67 : {g:_}->{a:_}->{B:_} -> Tm67 g (arr67 a B) -> Tm67 g a -> Tm67 g B\napp67 = \\ t, u, tm, var67, lam67, app67 => app67 _ _ _ (t tm var67 lam67 app67) (u tm var67 lam67 app67)\n\nv067 : {g:_}->{a:_} -> Tm67 (snoc67 g a) a\nv067 = var67 vz67\n\nv167 : {g:_}->{a:_}-> {B:_}-> Tm67 (snoc67 (snoc67 g a) B) a\nv167 = var67 (vs67 vz67)\n\nv267 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm67 (snoc67 (snoc67 (snoc67 g a) B) C) a\nv267 = var67 (vs67 (vs67 vz67))\n\nv367 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm67 (snoc67 (snoc67 (snoc67 (snoc67 g a) B) C) D) a\nv367 = var67 (vs67 (vs67 (vs67 vz67)))\n\nv467 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm67 (snoc67 (snoc67 (snoc67 (snoc67 (snoc67 g a) B) C) D) E) a\nv467 = var67 (vs67 (vs67 (vs67 (vs67 vz67))))\n\ntest67 : {g:_}-> {a:_} -> Tm67 g (arr67 (arr67 a a) (arr67 a a))\ntest67 = lam67 (lam67 (app67 v167 (app67 v167 (app67 v167 (app67 v167 (app67 v167 (app67 v167 v067)))))))\nTy68 : Type\nTy68 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty68 : Ty68\nempty68 = \\ _, empty, _ => empty\n\narr68 : Ty68 -> Ty68 -> Ty68\narr68 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon68 : Type\nCon68 = (Con68 : Type)\n ->(nil : Con68)\n ->(snoc : Con68 -> Ty68 -> Con68)\n -> Con68\n\nnil68 : Con68\nnil68 = \\ con, nil68, snoc => nil68\n\nsnoc68 : Con68 -> Ty68 -> Con68\nsnoc68 = \\ g, a, con, nil68, snoc68 => snoc68 (g con nil68 snoc68) a\n\nVar68 : Con68 -> Ty68 -> Type\nVar68 = \\ g, a =>\n (Var68 : Con68 -> Ty68 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var68 (snoc68 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var68 g a -> Var68 (snoc68 g b) a)\n -> Var68 g a\n\nvz68 : {g : _}-> {a : _} -> Var68 (snoc68 g a) a\nvz68 = \\ var, vz68, vs => vz68 _ _\n\nvs68 : {g : _} -> {B : _} -> {a : _} -> Var68 g a -> Var68 (snoc68 g B) a\nvs68 = \\ x, var, vz68, vs68 => vs68 _ _ _ (x var vz68 vs68)\n\nTm68 : Con68 -> Ty68 -> Type\nTm68 = \\ g, a =>\n (Tm68 : Con68 -> Ty68 -> Type)\n -> (var : (g : _) -> (a : _) -> Var68 g a -> Tm68 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm68 (snoc68 g a) B -> Tm68 g (arr68 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm68 g (arr68 a B) -> Tm68 g a -> Tm68 g B)\n -> Tm68 g a\n\nvar68 : {g : _} -> {a : _} -> Var68 g a -> Tm68 g a\nvar68 = \\ x, tm, var68, lam, app => var68 _ _ x\n\nlam68 : {g : _} -> {a : _} -> {B : _} -> Tm68 (snoc68 g a) B -> Tm68 g (arr68 a B)\nlam68 = \\ t, tm, var68, lam68, app => lam68 _ _ _ (t tm var68 lam68 app)\n\napp68 : {g:_}->{a:_}->{B:_} -> Tm68 g (arr68 a B) -> Tm68 g a -> Tm68 g B\napp68 = \\ t, u, tm, var68, lam68, app68 => app68 _ _ _ (t tm var68 lam68 app68) (u tm var68 lam68 app68)\n\nv068 : {g:_}->{a:_} -> Tm68 (snoc68 g a) a\nv068 = var68 vz68\n\nv168 : {g:_}->{a:_}-> {B:_}-> Tm68 (snoc68 (snoc68 g a) B) a\nv168 = var68 (vs68 vz68)\n\nv268 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm68 (snoc68 (snoc68 (snoc68 g a) B) C) a\nv268 = var68 (vs68 (vs68 vz68))\n\nv368 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm68 (snoc68 (snoc68 (snoc68 (snoc68 g a) B) C) D) a\nv368 = var68 (vs68 (vs68 (vs68 vz68)))\n\nv468 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm68 (snoc68 (snoc68 (snoc68 (snoc68 (snoc68 g a) B) C) D) E) a\nv468 = var68 (vs68 (vs68 (vs68 (vs68 vz68))))\n\ntest68 : {g:_}-> {a:_} -> Tm68 g (arr68 (arr68 a a) (arr68 a a))\ntest68 = lam68 (lam68 (app68 v168 (app68 v168 (app68 v168 (app68 v168 (app68 v168 (app68 v168 v068)))))))\nTy69 : Type\nTy69 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty69 : Ty69\nempty69 = \\ _, empty, _ => empty\n\narr69 : Ty69 -> Ty69 -> Ty69\narr69 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon69 : Type\nCon69 = (Con69 : Type)\n ->(nil : Con69)\n ->(snoc : Con69 -> Ty69 -> Con69)\n -> Con69\n\nnil69 : Con69\nnil69 = \\ con, nil69, snoc => nil69\n\nsnoc69 : Con69 -> Ty69 -> Con69\nsnoc69 = \\ g, a, con, nil69, snoc69 => snoc69 (g con nil69 snoc69) a\n\nVar69 : Con69 -> Ty69 -> Type\nVar69 = \\ g, a =>\n (Var69 : Con69 -> Ty69 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var69 (snoc69 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var69 g a -> Var69 (snoc69 g b) a)\n -> Var69 g a\n\nvz69 : {g : _}-> {a : _} -> Var69 (snoc69 g a) a\nvz69 = \\ var, vz69, vs => vz69 _ _\n\nvs69 : {g : _} -> {B : _} -> {a : _} -> Var69 g a -> Var69 (snoc69 g B) a\nvs69 = \\ x, var, vz69, vs69 => vs69 _ _ _ (x var vz69 vs69)\n\nTm69 : Con69 -> Ty69 -> Type\nTm69 = \\ g, a =>\n (Tm69 : Con69 -> Ty69 -> Type)\n -> (var : (g : _) -> (a : _) -> Var69 g a -> Tm69 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm69 (snoc69 g a) B -> Tm69 g (arr69 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm69 g (arr69 a B) -> Tm69 g a -> Tm69 g B)\n -> Tm69 g a\n\nvar69 : {g : _} -> {a : _} -> Var69 g a -> Tm69 g a\nvar69 = \\ x, tm, var69, lam, app => var69 _ _ x\n\nlam69 : {g : _} -> {a : _} -> {B : _} -> Tm69 (snoc69 g a) B -> Tm69 g (arr69 a B)\nlam69 = \\ t, tm, var69, lam69, app => lam69 _ _ _ (t tm var69 lam69 app)\n\napp69 : {g:_}->{a:_}->{B:_} -> Tm69 g (arr69 a B) -> Tm69 g a -> Tm69 g B\napp69 = \\ t, u, tm, var69, lam69, app69 => app69 _ _ _ (t tm var69 lam69 app69) (u tm var69 lam69 app69)\n\nv069 : {g:_}->{a:_} -> Tm69 (snoc69 g a) a\nv069 = var69 vz69\n\nv169 : {g:_}->{a:_}-> {B:_}-> Tm69 (snoc69 (snoc69 g a) B) a\nv169 = var69 (vs69 vz69)\n\nv269 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm69 (snoc69 (snoc69 (snoc69 g a) B) C) a\nv269 = var69 (vs69 (vs69 vz69))\n\nv369 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm69 (snoc69 (snoc69 (snoc69 (snoc69 g a) B) C) D) a\nv369 = var69 (vs69 (vs69 (vs69 vz69)))\n\nv469 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm69 (snoc69 (snoc69 (snoc69 (snoc69 (snoc69 g a) B) C) D) E) a\nv469 = var69 (vs69 (vs69 (vs69 (vs69 vz69))))\n\ntest69 : {g:_}-> {a:_} -> Tm69 g (arr69 (arr69 a a) (arr69 a a))\ntest69 = lam69 (lam69 (app69 v169 (app69 v169 (app69 v169 (app69 v169 (app69 v169 (app69 v169 v069)))))))\nTy70 : Type\nTy70 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty70 : Ty70\nempty70 = \\ _, empty, _ => empty\n\narr70 : Ty70 -> Ty70 -> Ty70\narr70 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon70 : Type\nCon70 = (Con70 : Type)\n ->(nil : Con70)\n ->(snoc : Con70 -> Ty70 -> Con70)\n -> Con70\n\nnil70 : Con70\nnil70 = \\ con, nil70, snoc => nil70\n\nsnoc70 : Con70 -> Ty70 -> Con70\nsnoc70 = \\ g, a, con, nil70, snoc70 => snoc70 (g con nil70 snoc70) a\n\nVar70 : Con70 -> Ty70 -> Type\nVar70 = \\ g, a =>\n (Var70 : Con70 -> Ty70 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var70 (snoc70 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var70 g a -> Var70 (snoc70 g b) a)\n -> Var70 g a\n\nvz70 : {g : _}-> {a : _} -> Var70 (snoc70 g a) a\nvz70 = \\ var, vz70, vs => vz70 _ _\n\nvs70 : {g : _} -> {B : _} -> {a : _} -> Var70 g a -> Var70 (snoc70 g B) a\nvs70 = \\ x, var, vz70, vs70 => vs70 _ _ _ (x var vz70 vs70)\n\nTm70 : Con70 -> Ty70 -> Type\nTm70 = \\ g, a =>\n (Tm70 : Con70 -> Ty70 -> Type)\n -> (var : (g : _) -> (a : _) -> Var70 g a -> Tm70 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm70 (snoc70 g a) B -> Tm70 g (arr70 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm70 g (arr70 a B) -> Tm70 g a -> Tm70 g B)\n -> Tm70 g a\n\nvar70 : {g : _} -> {a : _} -> Var70 g a -> Tm70 g a\nvar70 = \\ x, tm, var70, lam, app => var70 _ _ x\n\nlam70 : {g : _} -> {a : _} -> {B : _} -> Tm70 (snoc70 g a) B -> Tm70 g (arr70 a B)\nlam70 = \\ t, tm, var70, lam70, app => lam70 _ _ _ (t tm var70 lam70 app)\n\napp70 : {g:_}->{a:_}->{B:_} -> Tm70 g (arr70 a B) -> Tm70 g a -> Tm70 g B\napp70 = \\ t, u, tm, var70, lam70, app70 => app70 _ _ _ (t tm var70 lam70 app70) (u tm var70 lam70 app70)\n\nv070 : {g:_}->{a:_} -> Tm70 (snoc70 g a) a\nv070 = var70 vz70\n\nv170 : {g:_}->{a:_}-> {B:_}-> Tm70 (snoc70 (snoc70 g a) B) a\nv170 = var70 (vs70 vz70)\n\nv270 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm70 (snoc70 (snoc70 (snoc70 g a) B) C) a\nv270 = var70 (vs70 (vs70 vz70))\n\nv370 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm70 (snoc70 (snoc70 (snoc70 (snoc70 g a) B) C) D) a\nv370 = var70 (vs70 (vs70 (vs70 vz70)))\n\nv470 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm70 (snoc70 (snoc70 (snoc70 (snoc70 (snoc70 g a) B) C) D) E) a\nv470 = var70 (vs70 (vs70 (vs70 (vs70 vz70))))\n\ntest70 : {g:_}-> {a:_} -> Tm70 g (arr70 (arr70 a a) (arr70 a a))\ntest70 = lam70 (lam70 (app70 v170 (app70 v170 (app70 v170 (app70 v170 (app70 v170 (app70 v170 v070)))))))\nTy71 : Type\nTy71 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty71 : Ty71\nempty71 = \\ _, empty, _ => empty\n\narr71 : Ty71 -> Ty71 -> Ty71\narr71 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon71 : Type\nCon71 = (Con71 : Type)\n ->(nil : Con71)\n ->(snoc : Con71 -> Ty71 -> Con71)\n -> Con71\n\nnil71 : Con71\nnil71 = \\ con, nil71, snoc => nil71\n\nsnoc71 : Con71 -> Ty71 -> Con71\nsnoc71 = \\ g, a, con, nil71, snoc71 => snoc71 (g con nil71 snoc71) a\n\nVar71 : Con71 -> Ty71 -> Type\nVar71 = \\ g, a =>\n (Var71 : Con71 -> Ty71 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var71 (snoc71 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var71 g a -> Var71 (snoc71 g b) a)\n -> Var71 g a\n\nvz71 : {g : _}-> {a : _} -> Var71 (snoc71 g a) a\nvz71 = \\ var, vz71, vs => vz71 _ _\n\nvs71 : {g : _} -> {B : _} -> {a : _} -> Var71 g a -> Var71 (snoc71 g B) a\nvs71 = \\ x, var, vz71, vs71 => vs71 _ _ _ (x var vz71 vs71)\n\nTm71 : Con71 -> Ty71 -> Type\nTm71 = \\ g, a =>\n (Tm71 : Con71 -> Ty71 -> Type)\n -> (var : (g : _) -> (a : _) -> Var71 g a -> Tm71 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm71 (snoc71 g a) B -> Tm71 g (arr71 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm71 g (arr71 a B) -> Tm71 g a -> Tm71 g B)\n -> Tm71 g a\n\nvar71 : {g : _} -> {a : _} -> Var71 g a -> Tm71 g a\nvar71 = \\ x, tm, var71, lam, app => var71 _ _ x\n\nlam71 : {g : _} -> {a : _} -> {B : _} -> Tm71 (snoc71 g a) B -> Tm71 g (arr71 a B)\nlam71 = \\ t, tm, var71, lam71, app => lam71 _ _ _ (t tm var71 lam71 app)\n\napp71 : {g:_}->{a:_}->{B:_} -> Tm71 g (arr71 a B) -> Tm71 g a -> Tm71 g B\napp71 = \\ t, u, tm, var71, lam71, app71 => app71 _ _ _ (t tm var71 lam71 app71) (u tm var71 lam71 app71)\n\nv071 : {g:_}->{a:_} -> Tm71 (snoc71 g a) a\nv071 = var71 vz71\n\nv171 : {g:_}->{a:_}-> {B:_}-> Tm71 (snoc71 (snoc71 g a) B) a\nv171 = var71 (vs71 vz71)\n\nv271 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm71 (snoc71 (snoc71 (snoc71 g a) B) C) a\nv271 = var71 (vs71 (vs71 vz71))\n\nv371 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm71 (snoc71 (snoc71 (snoc71 (snoc71 g a) B) C) D) a\nv371 = var71 (vs71 (vs71 (vs71 vz71)))\n\nv471 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm71 (snoc71 (snoc71 (snoc71 (snoc71 (snoc71 g a) B) C) D) E) a\nv471 = var71 (vs71 (vs71 (vs71 (vs71 vz71))))\n\ntest71 : {g:_}-> {a:_} -> Tm71 g (arr71 (arr71 a a) (arr71 a a))\ntest71 = lam71 (lam71 (app71 v171 (app71 v171 (app71 v171 (app71 v171 (app71 v171 (app71 v171 v071)))))))\nTy72 : Type\nTy72 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty72 : Ty72\nempty72 = \\ _, empty, _ => empty\n\narr72 : Ty72 -> Ty72 -> Ty72\narr72 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon72 : Type\nCon72 = (Con72 : Type)\n ->(nil : Con72)\n ->(snoc : Con72 -> Ty72 -> Con72)\n -> Con72\n\nnil72 : Con72\nnil72 = \\ con, nil72, snoc => nil72\n\nsnoc72 : Con72 -> Ty72 -> Con72\nsnoc72 = \\ g, a, con, nil72, snoc72 => snoc72 (g con nil72 snoc72) a\n\nVar72 : Con72 -> Ty72 -> Type\nVar72 = \\ g, a =>\n (Var72 : Con72 -> Ty72 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var72 (snoc72 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var72 g a -> Var72 (snoc72 g b) a)\n -> Var72 g a\n\nvz72 : {g : _}-> {a : _} -> Var72 (snoc72 g a) a\nvz72 = \\ var, vz72, vs => vz72 _ _\n\nvs72 : {g : _} -> {B : _} -> {a : _} -> Var72 g a -> Var72 (snoc72 g B) a\nvs72 = \\ x, var, vz72, vs72 => vs72 _ _ _ (x var vz72 vs72)\n\nTm72 : Con72 -> Ty72 -> Type\nTm72 = \\ g, a =>\n (Tm72 : Con72 -> Ty72 -> Type)\n -> (var : (g : _) -> (a : _) -> Var72 g a -> Tm72 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm72 (snoc72 g a) B -> Tm72 g (arr72 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm72 g (arr72 a B) -> Tm72 g a -> Tm72 g B)\n -> Tm72 g a\n\nvar72 : {g : _} -> {a : _} -> Var72 g a -> Tm72 g a\nvar72 = \\ x, tm, var72, lam, app => var72 _ _ x\n\nlam72 : {g : _} -> {a : _} -> {B : _} -> Tm72 (snoc72 g a) B -> Tm72 g (arr72 a B)\nlam72 = \\ t, tm, var72, lam72, app => lam72 _ _ _ (t tm var72 lam72 app)\n\napp72 : {g:_}->{a:_}->{B:_} -> Tm72 g (arr72 a B) -> Tm72 g a -> Tm72 g B\napp72 = \\ t, u, tm, var72, lam72, app72 => app72 _ _ _ (t tm var72 lam72 app72) (u tm var72 lam72 app72)\n\nv072 : {g:_}->{a:_} -> Tm72 (snoc72 g a) a\nv072 = var72 vz72\n\nv172 : {g:_}->{a:_}-> {B:_}-> Tm72 (snoc72 (snoc72 g a) B) a\nv172 = var72 (vs72 vz72)\n\nv272 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm72 (snoc72 (snoc72 (snoc72 g a) B) C) a\nv272 = var72 (vs72 (vs72 vz72))\n\nv372 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm72 (snoc72 (snoc72 (snoc72 (snoc72 g a) B) C) D) a\nv372 = var72 (vs72 (vs72 (vs72 vz72)))\n\nv472 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm72 (snoc72 (snoc72 (snoc72 (snoc72 (snoc72 g a) B) C) D) E) a\nv472 = var72 (vs72 (vs72 (vs72 (vs72 vz72))))\n\ntest72 : {g:_}-> {a:_} -> Tm72 g (arr72 (arr72 a a) (arr72 a a))\ntest72 = lam72 (lam72 (app72 v172 (app72 v172 (app72 v172 (app72 v172 (app72 v172 (app72 v172 v072)))))))\nTy73 : Type\nTy73 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty73 : Ty73\nempty73 = \\ _, empty, _ => empty\n\narr73 : Ty73 -> Ty73 -> Ty73\narr73 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon73 : Type\nCon73 = (Con73 : Type)\n ->(nil : Con73)\n ->(snoc : Con73 -> Ty73 -> Con73)\n -> Con73\n\nnil73 : Con73\nnil73 = \\ con, nil73, snoc => nil73\n\nsnoc73 : Con73 -> Ty73 -> Con73\nsnoc73 = \\ g, a, con, nil73, snoc73 => snoc73 (g con nil73 snoc73) a\n\nVar73 : Con73 -> Ty73 -> Type\nVar73 = \\ g, a =>\n (Var73 : Con73 -> Ty73 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var73 (snoc73 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var73 g a -> Var73 (snoc73 g b) a)\n -> Var73 g a\n\nvz73 : {g : _}-> {a : _} -> Var73 (snoc73 g a) a\nvz73 = \\ var, vz73, vs => vz73 _ _\n\nvs73 : {g : _} -> {B : _} -> {a : _} -> Var73 g a -> Var73 (snoc73 g B) a\nvs73 = \\ x, var, vz73, vs73 => vs73 _ _ _ (x var vz73 vs73)\n\nTm73 : Con73 -> Ty73 -> Type\nTm73 = \\ g, a =>\n (Tm73 : Con73 -> Ty73 -> Type)\n -> (var : (g : _) -> (a : _) -> Var73 g a -> Tm73 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm73 (snoc73 g a) B -> Tm73 g (arr73 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm73 g (arr73 a B) -> Tm73 g a -> Tm73 g B)\n -> Tm73 g a\n\nvar73 : {g : _} -> {a : _} -> Var73 g a -> Tm73 g a\nvar73 = \\ x, tm, var73, lam, app => var73 _ _ x\n\nlam73 : {g : _} -> {a : _} -> {B : _} -> Tm73 (snoc73 g a) B -> Tm73 g (arr73 a B)\nlam73 = \\ t, tm, var73, lam73, app => lam73 _ _ _ (t tm var73 lam73 app)\n\napp73 : {g:_}->{a:_}->{B:_} -> Tm73 g (arr73 a B) -> Tm73 g a -> Tm73 g B\napp73 = \\ t, u, tm, var73, lam73, app73 => app73 _ _ _ (t tm var73 lam73 app73) (u tm var73 lam73 app73)\n\nv073 : {g:_}->{a:_} -> Tm73 (snoc73 g a) a\nv073 = var73 vz73\n\nv173 : {g:_}->{a:_}-> {B:_}-> Tm73 (snoc73 (snoc73 g a) B) a\nv173 = var73 (vs73 vz73)\n\nv273 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm73 (snoc73 (snoc73 (snoc73 g a) B) C) a\nv273 = var73 (vs73 (vs73 vz73))\n\nv373 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm73 (snoc73 (snoc73 (snoc73 (snoc73 g a) B) C) D) a\nv373 = var73 (vs73 (vs73 (vs73 vz73)))\n\nv473 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm73 (snoc73 (snoc73 (snoc73 (snoc73 (snoc73 g a) B) C) D) E) a\nv473 = var73 (vs73 (vs73 (vs73 (vs73 vz73))))\n\ntest73 : {g:_}-> {a:_} -> Tm73 g (arr73 (arr73 a a) (arr73 a a))\ntest73 = lam73 (lam73 (app73 v173 (app73 v173 (app73 v173 (app73 v173 (app73 v173 (app73 v173 v073)))))))\nTy74 : Type\nTy74 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty74 : Ty74\nempty74 = \\ _, empty, _ => empty\n\narr74 : Ty74 -> Ty74 -> Ty74\narr74 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon74 : Type\nCon74 = (Con74 : Type)\n ->(nil : Con74)\n ->(snoc : Con74 -> Ty74 -> Con74)\n -> Con74\n\nnil74 : Con74\nnil74 = \\ con, nil74, snoc => nil74\n\nsnoc74 : Con74 -> Ty74 -> Con74\nsnoc74 = \\ g, a, con, nil74, snoc74 => snoc74 (g con nil74 snoc74) a\n\nVar74 : Con74 -> Ty74 -> Type\nVar74 = \\ g, a =>\n (Var74 : Con74 -> Ty74 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var74 (snoc74 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var74 g a -> Var74 (snoc74 g b) a)\n -> Var74 g a\n\nvz74 : {g : _}-> {a : _} -> Var74 (snoc74 g a) a\nvz74 = \\ var, vz74, vs => vz74 _ _\n\nvs74 : {g : _} -> {B : _} -> {a : _} -> Var74 g a -> Var74 (snoc74 g B) a\nvs74 = \\ x, var, vz74, vs74 => vs74 _ _ _ (x var vz74 vs74)\n\nTm74 : Con74 -> Ty74 -> Type\nTm74 = \\ g, a =>\n (Tm74 : Con74 -> Ty74 -> Type)\n -> (var : (g : _) -> (a : _) -> Var74 g a -> Tm74 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm74 (snoc74 g a) B -> Tm74 g (arr74 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm74 g (arr74 a B) -> Tm74 g a -> Tm74 g B)\n -> Tm74 g a\n\nvar74 : {g : _} -> {a : _} -> Var74 g a -> Tm74 g a\nvar74 = \\ x, tm, var74, lam, app => var74 _ _ x\n\nlam74 : {g : _} -> {a : _} -> {B : _} -> Tm74 (snoc74 g a) B -> Tm74 g (arr74 a B)\nlam74 = \\ t, tm, var74, lam74, app => lam74 _ _ _ (t tm var74 lam74 app)\n\napp74 : {g:_}->{a:_}->{B:_} -> Tm74 g (arr74 a B) -> Tm74 g a -> Tm74 g B\napp74 = \\ t, u, tm, var74, lam74, app74 => app74 _ _ _ (t tm var74 lam74 app74) (u tm var74 lam74 app74)\n\nv074 : {g:_}->{a:_} -> Tm74 (snoc74 g a) a\nv074 = var74 vz74\n\nv174 : {g:_}->{a:_}-> {B:_}-> Tm74 (snoc74 (snoc74 g a) B) a\nv174 = var74 (vs74 vz74)\n\nv274 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm74 (snoc74 (snoc74 (snoc74 g a) B) C) a\nv274 = var74 (vs74 (vs74 vz74))\n\nv374 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm74 (snoc74 (snoc74 (snoc74 (snoc74 g a) B) C) D) a\nv374 = var74 (vs74 (vs74 (vs74 vz74)))\n\nv474 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm74 (snoc74 (snoc74 (snoc74 (snoc74 (snoc74 g a) B) C) D) E) a\nv474 = var74 (vs74 (vs74 (vs74 (vs74 vz74))))\n\ntest74 : {g:_}-> {a:_} -> Tm74 g (arr74 (arr74 a a) (arr74 a a))\ntest74 = lam74 (lam74 (app74 v174 (app74 v174 (app74 v174 (app74 v174 (app74 v174 (app74 v174 v074)))))))\nTy75 : Type\nTy75 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty75 : Ty75\nempty75 = \\ _, empty, _ => empty\n\narr75 : Ty75 -> Ty75 -> Ty75\narr75 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon75 : Type\nCon75 = (Con75 : Type)\n ->(nil : Con75)\n ->(snoc : Con75 -> Ty75 -> Con75)\n -> Con75\n\nnil75 : Con75\nnil75 = \\ con, nil75, snoc => nil75\n\nsnoc75 : Con75 -> Ty75 -> Con75\nsnoc75 = \\ g, a, con, nil75, snoc75 => snoc75 (g con nil75 snoc75) a\n\nVar75 : Con75 -> Ty75 -> Type\nVar75 = \\ g, a =>\n (Var75 : Con75 -> Ty75 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var75 (snoc75 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var75 g a -> Var75 (snoc75 g b) a)\n -> Var75 g a\n\nvz75 : {g : _}-> {a : _} -> Var75 (snoc75 g a) a\nvz75 = \\ var, vz75, vs => vz75 _ _\n\nvs75 : {g : _} -> {B : _} -> {a : _} -> Var75 g a -> Var75 (snoc75 g B) a\nvs75 = \\ x, var, vz75, vs75 => vs75 _ _ _ (x var vz75 vs75)\n\nTm75 : Con75 -> Ty75 -> Type\nTm75 = \\ g, a =>\n (Tm75 : Con75 -> Ty75 -> Type)\n -> (var : (g : _) -> (a : _) -> Var75 g a -> Tm75 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm75 (snoc75 g a) B -> Tm75 g (arr75 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm75 g (arr75 a B) -> Tm75 g a -> Tm75 g B)\n -> Tm75 g a\n\nvar75 : {g : _} -> {a : _} -> Var75 g a -> Tm75 g a\nvar75 = \\ x, tm, var75, lam, app => var75 _ _ x\n\nlam75 : {g : _} -> {a : _} -> {B : _} -> Tm75 (snoc75 g a) B -> Tm75 g (arr75 a B)\nlam75 = \\ t, tm, var75, lam75, app => lam75 _ _ _ (t tm var75 lam75 app)\n\napp75 : {g:_}->{a:_}->{B:_} -> Tm75 g (arr75 a B) -> Tm75 g a -> Tm75 g B\napp75 = \\ t, u, tm, var75, lam75, app75 => app75 _ _ _ (t tm var75 lam75 app75) (u tm var75 lam75 app75)\n\nv075 : {g:_}->{a:_} -> Tm75 (snoc75 g a) a\nv075 = var75 vz75\n\nv175 : {g:_}->{a:_}-> {B:_}-> Tm75 (snoc75 (snoc75 g a) B) a\nv175 = var75 (vs75 vz75)\n\nv275 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm75 (snoc75 (snoc75 (snoc75 g a) B) C) a\nv275 = var75 (vs75 (vs75 vz75))\n\nv375 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm75 (snoc75 (snoc75 (snoc75 (snoc75 g a) B) C) D) a\nv375 = var75 (vs75 (vs75 (vs75 vz75)))\n\nv475 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm75 (snoc75 (snoc75 (snoc75 (snoc75 (snoc75 g a) B) C) D) E) a\nv475 = var75 (vs75 (vs75 (vs75 (vs75 vz75))))\n\ntest75 : {g:_}-> {a:_} -> Tm75 g (arr75 (arr75 a a) (arr75 a a))\ntest75 = lam75 (lam75 (app75 v175 (app75 v175 (app75 v175 (app75 v175 (app75 v175 (app75 v175 v075)))))))\nTy76 : Type\nTy76 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty76 : Ty76\nempty76 = \\ _, empty, _ => empty\n\narr76 : Ty76 -> Ty76 -> Ty76\narr76 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon76 : Type\nCon76 = (Con76 : Type)\n ->(nil : Con76)\n ->(snoc : Con76 -> Ty76 -> Con76)\n -> Con76\n\nnil76 : Con76\nnil76 = \\ con, nil76, snoc => nil76\n\nsnoc76 : Con76 -> Ty76 -> Con76\nsnoc76 = \\ g, a, con, nil76, snoc76 => snoc76 (g con nil76 snoc76) a\n\nVar76 : Con76 -> Ty76 -> Type\nVar76 = \\ g, a =>\n (Var76 : Con76 -> Ty76 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var76 (snoc76 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var76 g a -> Var76 (snoc76 g b) a)\n -> Var76 g a\n\nvz76 : {g : _}-> {a : _} -> Var76 (snoc76 g a) a\nvz76 = \\ var, vz76, vs => vz76 _ _\n\nvs76 : {g : _} -> {B : _} -> {a : _} -> Var76 g a -> Var76 (snoc76 g B) a\nvs76 = \\ x, var, vz76, vs76 => vs76 _ _ _ (x var vz76 vs76)\n\nTm76 : Con76 -> Ty76 -> Type\nTm76 = \\ g, a =>\n (Tm76 : Con76 -> Ty76 -> Type)\n -> (var : (g : _) -> (a : _) -> Var76 g a -> Tm76 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm76 (snoc76 g a) B -> Tm76 g (arr76 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm76 g (arr76 a B) -> Tm76 g a -> Tm76 g B)\n -> Tm76 g a\n\nvar76 : {g : _} -> {a : _} -> Var76 g a -> Tm76 g a\nvar76 = \\ x, tm, var76, lam, app => var76 _ _ x\n\nlam76 : {g : _} -> {a : _} -> {B : _} -> Tm76 (snoc76 g a) B -> Tm76 g (arr76 a B)\nlam76 = \\ t, tm, var76, lam76, app => lam76 _ _ _ (t tm var76 lam76 app)\n\napp76 : {g:_}->{a:_}->{B:_} -> Tm76 g (arr76 a B) -> Tm76 g a -> Tm76 g B\napp76 = \\ t, u, tm, var76, lam76, app76 => app76 _ _ _ (t tm var76 lam76 app76) (u tm var76 lam76 app76)\n\nv076 : {g:_}->{a:_} -> Tm76 (snoc76 g a) a\nv076 = var76 vz76\n\nv176 : {g:_}->{a:_}-> {B:_}-> Tm76 (snoc76 (snoc76 g a) B) a\nv176 = var76 (vs76 vz76)\n\nv276 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm76 (snoc76 (snoc76 (snoc76 g a) B) C) a\nv276 = var76 (vs76 (vs76 vz76))\n\nv376 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm76 (snoc76 (snoc76 (snoc76 (snoc76 g a) B) C) D) a\nv376 = var76 (vs76 (vs76 (vs76 vz76)))\n\nv476 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm76 (snoc76 (snoc76 (snoc76 (snoc76 (snoc76 g a) B) C) D) E) a\nv476 = var76 (vs76 (vs76 (vs76 (vs76 vz76))))\n\ntest76 : {g:_}-> {a:_} -> Tm76 g (arr76 (arr76 a a) (arr76 a a))\ntest76 = lam76 (lam76 (app76 v176 (app76 v176 (app76 v176 (app76 v176 (app76 v176 (app76 v176 v076)))))))\nTy77 : Type\nTy77 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty77 : Ty77\nempty77 = \\ _, empty, _ => empty\n\narr77 : Ty77 -> Ty77 -> Ty77\narr77 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon77 : Type\nCon77 = (Con77 : Type)\n ->(nil : Con77)\n ->(snoc : Con77 -> Ty77 -> Con77)\n -> Con77\n\nnil77 : Con77\nnil77 = \\ con, nil77, snoc => nil77\n\nsnoc77 : Con77 -> Ty77 -> Con77\nsnoc77 = \\ g, a, con, nil77, snoc77 => snoc77 (g con nil77 snoc77) a\n\nVar77 : Con77 -> Ty77 -> Type\nVar77 = \\ g, a =>\n (Var77 : Con77 -> Ty77 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var77 (snoc77 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var77 g a -> Var77 (snoc77 g b) a)\n -> Var77 g a\n\nvz77 : {g : _}-> {a : _} -> Var77 (snoc77 g a) a\nvz77 = \\ var, vz77, vs => vz77 _ _\n\nvs77 : {g : _} -> {B : _} -> {a : _} -> Var77 g a -> Var77 (snoc77 g B) a\nvs77 = \\ x, var, vz77, vs77 => vs77 _ _ _ (x var vz77 vs77)\n\nTm77 : Con77 -> Ty77 -> Type\nTm77 = \\ g, a =>\n (Tm77 : Con77 -> Ty77 -> Type)\n -> (var : (g : _) -> (a : _) -> Var77 g a -> Tm77 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm77 (snoc77 g a) B -> Tm77 g (arr77 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm77 g (arr77 a B) -> Tm77 g a -> Tm77 g B)\n -> Tm77 g a\n\nvar77 : {g : _} -> {a : _} -> Var77 g a -> Tm77 g a\nvar77 = \\ x, tm, var77, lam, app => var77 _ _ x\n\nlam77 : {g : _} -> {a : _} -> {B : _} -> Tm77 (snoc77 g a) B -> Tm77 g (arr77 a B)\nlam77 = \\ t, tm, var77, lam77, app => lam77 _ _ _ (t tm var77 lam77 app)\n\napp77 : {g:_}->{a:_}->{B:_} -> Tm77 g (arr77 a B) -> Tm77 g a -> Tm77 g B\napp77 = \\ t, u, tm, var77, lam77, app77 => app77 _ _ _ (t tm var77 lam77 app77) (u tm var77 lam77 app77)\n\nv077 : {g:_}->{a:_} -> Tm77 (snoc77 g a) a\nv077 = var77 vz77\n\nv177 : {g:_}->{a:_}-> {B:_}-> Tm77 (snoc77 (snoc77 g a) B) a\nv177 = var77 (vs77 vz77)\n\nv277 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm77 (snoc77 (snoc77 (snoc77 g a) B) C) a\nv277 = var77 (vs77 (vs77 vz77))\n\nv377 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm77 (snoc77 (snoc77 (snoc77 (snoc77 g a) B) C) D) a\nv377 = var77 (vs77 (vs77 (vs77 vz77)))\n\nv477 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm77 (snoc77 (snoc77 (snoc77 (snoc77 (snoc77 g a) B) C) D) E) a\nv477 = var77 (vs77 (vs77 (vs77 (vs77 vz77))))\n\ntest77 : {g:_}-> {a:_} -> Tm77 g (arr77 (arr77 a a) (arr77 a a))\ntest77 = lam77 (lam77 (app77 v177 (app77 v177 (app77 v177 (app77 v177 (app77 v177 (app77 v177 v077)))))))\nTy78 : Type\nTy78 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty78 : Ty78\nempty78 = \\ _, empty, _ => empty\n\narr78 : Ty78 -> Ty78 -> Ty78\narr78 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon78 : Type\nCon78 = (Con78 : Type)\n ->(nil : Con78)\n ->(snoc : Con78 -> Ty78 -> Con78)\n -> Con78\n\nnil78 : Con78\nnil78 = \\ con, nil78, snoc => nil78\n\nsnoc78 : Con78 -> Ty78 -> Con78\nsnoc78 = \\ g, a, con, nil78, snoc78 => snoc78 (g con nil78 snoc78) a\n\nVar78 : Con78 -> Ty78 -> Type\nVar78 = \\ g, a =>\n (Var78 : Con78 -> Ty78 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var78 (snoc78 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var78 g a -> Var78 (snoc78 g b) a)\n -> Var78 g a\n\nvz78 : {g : _}-> {a : _} -> Var78 (snoc78 g a) a\nvz78 = \\ var, vz78, vs => vz78 _ _\n\nvs78 : {g : _} -> {B : _} -> {a : _} -> Var78 g a -> Var78 (snoc78 g B) a\nvs78 = \\ x, var, vz78, vs78 => vs78 _ _ _ (x var vz78 vs78)\n\nTm78 : Con78 -> Ty78 -> Type\nTm78 = \\ g, a =>\n (Tm78 : Con78 -> Ty78 -> Type)\n -> (var : (g : _) -> (a : _) -> Var78 g a -> Tm78 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm78 (snoc78 g a) B -> Tm78 g (arr78 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm78 g (arr78 a B) -> Tm78 g a -> Tm78 g B)\n -> Tm78 g a\n\nvar78 : {g : _} -> {a : _} -> Var78 g a -> Tm78 g a\nvar78 = \\ x, tm, var78, lam, app => var78 _ _ x\n\nlam78 : {g : _} -> {a : _} -> {B : _} -> Tm78 (snoc78 g a) B -> Tm78 g (arr78 a B)\nlam78 = \\ t, tm, var78, lam78, app => lam78 _ _ _ (t tm var78 lam78 app)\n\napp78 : {g:_}->{a:_}->{B:_} -> Tm78 g (arr78 a B) -> Tm78 g a -> Tm78 g B\napp78 = \\ t, u, tm, var78, lam78, app78 => app78 _ _ _ (t tm var78 lam78 app78) (u tm var78 lam78 app78)\n\nv078 : {g:_}->{a:_} -> Tm78 (snoc78 g a) a\nv078 = var78 vz78\n\nv178 : {g:_}->{a:_}-> {B:_}-> Tm78 (snoc78 (snoc78 g a) B) a\nv178 = var78 (vs78 vz78)\n\nv278 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm78 (snoc78 (snoc78 (snoc78 g a) B) C) a\nv278 = var78 (vs78 (vs78 vz78))\n\nv378 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm78 (snoc78 (snoc78 (snoc78 (snoc78 g a) B) C) D) a\nv378 = var78 (vs78 (vs78 (vs78 vz78)))\n\nv478 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm78 (snoc78 (snoc78 (snoc78 (snoc78 (snoc78 g a) B) C) D) E) a\nv478 = var78 (vs78 (vs78 (vs78 (vs78 vz78))))\n\ntest78 : {g:_}-> {a:_} -> Tm78 g (arr78 (arr78 a a) (arr78 a a))\ntest78 = lam78 (lam78 (app78 v178 (app78 v178 (app78 v178 (app78 v178 (app78 v178 (app78 v178 v078)))))))\nTy79 : Type\nTy79 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty79 : Ty79\nempty79 = \\ _, empty, _ => empty\n\narr79 : Ty79 -> Ty79 -> Ty79\narr79 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon79 : Type\nCon79 = (Con79 : Type)\n ->(nil : Con79)\n ->(snoc : Con79 -> Ty79 -> Con79)\n -> Con79\n\nnil79 : Con79\nnil79 = \\ con, nil79, snoc => nil79\n\nsnoc79 : Con79 -> Ty79 -> Con79\nsnoc79 = \\ g, a, con, nil79, snoc79 => snoc79 (g con nil79 snoc79) a\n\nVar79 : Con79 -> Ty79 -> Type\nVar79 = \\ g, a =>\n (Var79 : Con79 -> Ty79 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var79 (snoc79 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var79 g a -> Var79 (snoc79 g b) a)\n -> Var79 g a\n\nvz79 : {g : _}-> {a : _} -> Var79 (snoc79 g a) a\nvz79 = \\ var, vz79, vs => vz79 _ _\n\nvs79 : {g : _} -> {B : _} -> {a : _} -> Var79 g a -> Var79 (snoc79 g B) a\nvs79 = \\ x, var, vz79, vs79 => vs79 _ _ _ (x var vz79 vs79)\n\nTm79 : Con79 -> Ty79 -> Type\nTm79 = \\ g, a =>\n (Tm79 : Con79 -> Ty79 -> Type)\n -> (var : (g : _) -> (a : _) -> Var79 g a -> Tm79 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm79 (snoc79 g a) B -> Tm79 g (arr79 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm79 g (arr79 a B) -> Tm79 g a -> Tm79 g B)\n -> Tm79 g a\n\nvar79 : {g : _} -> {a : _} -> Var79 g a -> Tm79 g a\nvar79 = \\ x, tm, var79, lam, app => var79 _ _ x\n\nlam79 : {g : _} -> {a : _} -> {B : _} -> Tm79 (snoc79 g a) B -> Tm79 g (arr79 a B)\nlam79 = \\ t, tm, var79, lam79, app => lam79 _ _ _ (t tm var79 lam79 app)\n\napp79 : {g:_}->{a:_}->{B:_} -> Tm79 g (arr79 a B) -> Tm79 g a -> Tm79 g B\napp79 = \\ t, u, tm, var79, lam79, app79 => app79 _ _ _ (t tm var79 lam79 app79) (u tm var79 lam79 app79)\n\nv079 : {g:_}->{a:_} -> Tm79 (snoc79 g a) a\nv079 = var79 vz79\n\nv179 : {g:_}->{a:_}-> {B:_}-> Tm79 (snoc79 (snoc79 g a) B) a\nv179 = var79 (vs79 vz79)\n\nv279 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm79 (snoc79 (snoc79 (snoc79 g a) B) C) a\nv279 = var79 (vs79 (vs79 vz79))\n\nv379 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm79 (snoc79 (snoc79 (snoc79 (snoc79 g a) B) C) D) a\nv379 = var79 (vs79 (vs79 (vs79 vz79)))\n\nv479 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm79 (snoc79 (snoc79 (snoc79 (snoc79 (snoc79 g a) B) C) D) E) a\nv479 = var79 (vs79 (vs79 (vs79 (vs79 vz79))))\n\ntest79 : {g:_}-> {a:_} -> Tm79 g (arr79 (arr79 a a) (arr79 a a))\ntest79 = lam79 (lam79 (app79 v179 (app79 v179 (app79 v179 (app79 v179 (app79 v179 (app79 v179 v079)))))))\nTy80 : Type\nTy80 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty80 : Ty80\nempty80 = \\ _, empty, _ => empty\n\narr80 : Ty80 -> Ty80 -> Ty80\narr80 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon80 : Type\nCon80 = (Con80 : Type)\n ->(nil : Con80)\n ->(snoc : Con80 -> Ty80 -> Con80)\n -> Con80\n\nnil80 : Con80\nnil80 = \\ con, nil80, snoc => nil80\n\nsnoc80 : Con80 -> Ty80 -> Con80\nsnoc80 = \\ g, a, con, nil80, snoc80 => snoc80 (g con nil80 snoc80) a\n\nVar80 : Con80 -> Ty80 -> Type\nVar80 = \\ g, a =>\n (Var80 : Con80 -> Ty80 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var80 (snoc80 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var80 g a -> Var80 (snoc80 g b) a)\n -> Var80 g a\n\nvz80 : {g : _}-> {a : _} -> Var80 (snoc80 g a) a\nvz80 = \\ var, vz80, vs => vz80 _ _\n\nvs80 : {g : _} -> {B : _} -> {a : _} -> Var80 g a -> Var80 (snoc80 g B) a\nvs80 = \\ x, var, vz80, vs80 => vs80 _ _ _ (x var vz80 vs80)\n\nTm80 : Con80 -> Ty80 -> Type\nTm80 = \\ g, a =>\n (Tm80 : Con80 -> Ty80 -> Type)\n -> (var : (g : _) -> (a : _) -> Var80 g a -> Tm80 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm80 (snoc80 g a) B -> Tm80 g (arr80 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm80 g (arr80 a B) -> Tm80 g a -> Tm80 g B)\n -> Tm80 g a\n\nvar80 : {g : _} -> {a : _} -> Var80 g a -> Tm80 g a\nvar80 = \\ x, tm, var80, lam, app => var80 _ _ x\n\nlam80 : {g : _} -> {a : _} -> {B : _} -> Tm80 (snoc80 g a) B -> Tm80 g (arr80 a B)\nlam80 = \\ t, tm, var80, lam80, app => lam80 _ _ _ (t tm var80 lam80 app)\n\napp80 : {g:_}->{a:_}->{B:_} -> Tm80 g (arr80 a B) -> Tm80 g a -> Tm80 g B\napp80 = \\ t, u, tm, var80, lam80, app80 => app80 _ _ _ (t tm var80 lam80 app80) (u tm var80 lam80 app80)\n\nv080 : {g:_}->{a:_} -> Tm80 (snoc80 g a) a\nv080 = var80 vz80\n\nv180 : {g:_}->{a:_}-> {B:_}-> Tm80 (snoc80 (snoc80 g a) B) a\nv180 = var80 (vs80 vz80)\n\nv280 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm80 (snoc80 (snoc80 (snoc80 g a) B) C) a\nv280 = var80 (vs80 (vs80 vz80))\n\nv380 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm80 (snoc80 (snoc80 (snoc80 (snoc80 g a) B) C) D) a\nv380 = var80 (vs80 (vs80 (vs80 vz80)))\n\nv480 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm80 (snoc80 (snoc80 (snoc80 (snoc80 (snoc80 g a) B) C) D) E) a\nv480 = var80 (vs80 (vs80 (vs80 (vs80 vz80))))\n\ntest80 : {g:_}-> {a:_} -> Tm80 g (arr80 (arr80 a a) (arr80 a a))\ntest80 = lam80 (lam80 (app80 v180 (app80 v180 (app80 v180 (app80 v180 (app80 v180 (app80 v180 v080)))))))\nTy81 : Type\nTy81 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty81 : Ty81\nempty81 = \\ _, empty, _ => empty\n\narr81 : Ty81 -> Ty81 -> Ty81\narr81 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon81 : Type\nCon81 = (Con81 : Type)\n ->(nil : Con81)\n ->(snoc : Con81 -> Ty81 -> Con81)\n -> Con81\n\nnil81 : Con81\nnil81 = \\ con, nil81, snoc => nil81\n\nsnoc81 : Con81 -> Ty81 -> Con81\nsnoc81 = \\ g, a, con, nil81, snoc81 => snoc81 (g con nil81 snoc81) a\n\nVar81 : Con81 -> Ty81 -> Type\nVar81 = \\ g, a =>\n (Var81 : Con81 -> Ty81 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var81 (snoc81 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var81 g a -> Var81 (snoc81 g b) a)\n -> Var81 g a\n\nvz81 : {g : _}-> {a : _} -> Var81 (snoc81 g a) a\nvz81 = \\ var, vz81, vs => vz81 _ _\n\nvs81 : {g : _} -> {B : _} -> {a : _} -> Var81 g a -> Var81 (snoc81 g B) a\nvs81 = \\ x, var, vz81, vs81 => vs81 _ _ _ (x var vz81 vs81)\n\nTm81 : Con81 -> Ty81 -> Type\nTm81 = \\ g, a =>\n (Tm81 : Con81 -> Ty81 -> Type)\n -> (var : (g : _) -> (a : _) -> Var81 g a -> Tm81 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm81 (snoc81 g a) B -> Tm81 g (arr81 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm81 g (arr81 a B) -> Tm81 g a -> Tm81 g B)\n -> Tm81 g a\n\nvar81 : {g : _} -> {a : _} -> Var81 g a -> Tm81 g a\nvar81 = \\ x, tm, var81, lam, app => var81 _ _ x\n\nlam81 : {g : _} -> {a : _} -> {B : _} -> Tm81 (snoc81 g a) B -> Tm81 g (arr81 a B)\nlam81 = \\ t, tm, var81, lam81, app => lam81 _ _ _ (t tm var81 lam81 app)\n\napp81 : {g:_}->{a:_}->{B:_} -> Tm81 g (arr81 a B) -> Tm81 g a -> Tm81 g B\napp81 = \\ t, u, tm, var81, lam81, app81 => app81 _ _ _ (t tm var81 lam81 app81) (u tm var81 lam81 app81)\n\nv081 : {g:_}->{a:_} -> Tm81 (snoc81 g a) a\nv081 = var81 vz81\n\nv181 : {g:_}->{a:_}-> {B:_}-> Tm81 (snoc81 (snoc81 g a) B) a\nv181 = var81 (vs81 vz81)\n\nv281 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm81 (snoc81 (snoc81 (snoc81 g a) B) C) a\nv281 = var81 (vs81 (vs81 vz81))\n\nv381 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm81 (snoc81 (snoc81 (snoc81 (snoc81 g a) B) C) D) a\nv381 = var81 (vs81 (vs81 (vs81 vz81)))\n\nv481 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm81 (snoc81 (snoc81 (snoc81 (snoc81 (snoc81 g a) B) C) D) E) a\nv481 = var81 (vs81 (vs81 (vs81 (vs81 vz81))))\n\ntest81 : {g:_}-> {a:_} -> Tm81 g (arr81 (arr81 a a) (arr81 a a))\ntest81 = lam81 (lam81 (app81 v181 (app81 v181 (app81 v181 (app81 v181 (app81 v181 (app81 v181 v081)))))))\nTy82 : Type\nTy82 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty82 : Ty82\nempty82 = \\ _, empty, _ => empty\n\narr82 : Ty82 -> Ty82 -> Ty82\narr82 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon82 : Type\nCon82 = (Con82 : Type)\n ->(nil : Con82)\n ->(snoc : Con82 -> Ty82 -> Con82)\n -> Con82\n\nnil82 : Con82\nnil82 = \\ con, nil82, snoc => nil82\n\nsnoc82 : Con82 -> Ty82 -> Con82\nsnoc82 = \\ g, a, con, nil82, snoc82 => snoc82 (g con nil82 snoc82) a\n\nVar82 : Con82 -> Ty82 -> Type\nVar82 = \\ g, a =>\n (Var82 : Con82 -> Ty82 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var82 (snoc82 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var82 g a -> Var82 (snoc82 g b) a)\n -> Var82 g a\n\nvz82 : {g : _}-> {a : _} -> Var82 (snoc82 g a) a\nvz82 = \\ var, vz82, vs => vz82 _ _\n\nvs82 : {g : _} -> {B : _} -> {a : _} -> Var82 g a -> Var82 (snoc82 g B) a\nvs82 = \\ x, var, vz82, vs82 => vs82 _ _ _ (x var vz82 vs82)\n\nTm82 : Con82 -> Ty82 -> Type\nTm82 = \\ g, a =>\n (Tm82 : Con82 -> Ty82 -> Type)\n -> (var : (g : _) -> (a : _) -> Var82 g a -> Tm82 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm82 (snoc82 g a) B -> Tm82 g (arr82 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm82 g (arr82 a B) -> Tm82 g a -> Tm82 g B)\n -> Tm82 g a\n\nvar82 : {g : _} -> {a : _} -> Var82 g a -> Tm82 g a\nvar82 = \\ x, tm, var82, lam, app => var82 _ _ x\n\nlam82 : {g : _} -> {a : _} -> {B : _} -> Tm82 (snoc82 g a) B -> Tm82 g (arr82 a B)\nlam82 = \\ t, tm, var82, lam82, app => lam82 _ _ _ (t tm var82 lam82 app)\n\napp82 : {g:_}->{a:_}->{B:_} -> Tm82 g (arr82 a B) -> Tm82 g a -> Tm82 g B\napp82 = \\ t, u, tm, var82, lam82, app82 => app82 _ _ _ (t tm var82 lam82 app82) (u tm var82 lam82 app82)\n\nv082 : {g:_}->{a:_} -> Tm82 (snoc82 g a) a\nv082 = var82 vz82\n\nv182 : {g:_}->{a:_}-> {B:_}-> Tm82 (snoc82 (snoc82 g a) B) a\nv182 = var82 (vs82 vz82)\n\nv282 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm82 (snoc82 (snoc82 (snoc82 g a) B) C) a\nv282 = var82 (vs82 (vs82 vz82))\n\nv382 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm82 (snoc82 (snoc82 (snoc82 (snoc82 g a) B) C) D) a\nv382 = var82 (vs82 (vs82 (vs82 vz82)))\n\nv482 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm82 (snoc82 (snoc82 (snoc82 (snoc82 (snoc82 g a) B) C) D) E) a\nv482 = var82 (vs82 (vs82 (vs82 (vs82 vz82))))\n\ntest82 : {g:_}-> {a:_} -> Tm82 g (arr82 (arr82 a a) (arr82 a a))\ntest82 = lam82 (lam82 (app82 v182 (app82 v182 (app82 v182 (app82 v182 (app82 v182 (app82 v182 v082)))))))\nTy83 : Type\nTy83 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty83 : Ty83\nempty83 = \\ _, empty, _ => empty\n\narr83 : Ty83 -> Ty83 -> Ty83\narr83 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon83 : Type\nCon83 = (Con83 : Type)\n ->(nil : Con83)\n ->(snoc : Con83 -> Ty83 -> Con83)\n -> Con83\n\nnil83 : Con83\nnil83 = \\ con, nil83, snoc => nil83\n\nsnoc83 : Con83 -> Ty83 -> Con83\nsnoc83 = \\ g, a, con, nil83, snoc83 => snoc83 (g con nil83 snoc83) a\n\nVar83 : Con83 -> Ty83 -> Type\nVar83 = \\ g, a =>\n (Var83 : Con83 -> Ty83 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var83 (snoc83 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var83 g a -> Var83 (snoc83 g b) a)\n -> Var83 g a\n\nvz83 : {g : _}-> {a : _} -> Var83 (snoc83 g a) a\nvz83 = \\ var, vz83, vs => vz83 _ _\n\nvs83 : {g : _} -> {B : _} -> {a : _} -> Var83 g a -> Var83 (snoc83 g B) a\nvs83 = \\ x, var, vz83, vs83 => vs83 _ _ _ (x var vz83 vs83)\n\nTm83 : Con83 -> Ty83 -> Type\nTm83 = \\ g, a =>\n (Tm83 : Con83 -> Ty83 -> Type)\n -> (var : (g : _) -> (a : _) -> Var83 g a -> Tm83 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm83 (snoc83 g a) B -> Tm83 g (arr83 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm83 g (arr83 a B) -> Tm83 g a -> Tm83 g B)\n -> Tm83 g a\n\nvar83 : {g : _} -> {a : _} -> Var83 g a -> Tm83 g a\nvar83 = \\ x, tm, var83, lam, app => var83 _ _ x\n\nlam83 : {g : _} -> {a : _} -> {B : _} -> Tm83 (snoc83 g a) B -> Tm83 g (arr83 a B)\nlam83 = \\ t, tm, var83, lam83, app => lam83 _ _ _ (t tm var83 lam83 app)\n\napp83 : {g:_}->{a:_}->{B:_} -> Tm83 g (arr83 a B) -> Tm83 g a -> Tm83 g B\napp83 = \\ t, u, tm, var83, lam83, app83 => app83 _ _ _ (t tm var83 lam83 app83) (u tm var83 lam83 app83)\n\nv083 : {g:_}->{a:_} -> Tm83 (snoc83 g a) a\nv083 = var83 vz83\n\nv183 : {g:_}->{a:_}-> {B:_}-> Tm83 (snoc83 (snoc83 g a) B) a\nv183 = var83 (vs83 vz83)\n\nv283 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm83 (snoc83 (snoc83 (snoc83 g a) B) C) a\nv283 = var83 (vs83 (vs83 vz83))\n\nv383 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm83 (snoc83 (snoc83 (snoc83 (snoc83 g a) B) C) D) a\nv383 = var83 (vs83 (vs83 (vs83 vz83)))\n\nv483 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm83 (snoc83 (snoc83 (snoc83 (snoc83 (snoc83 g a) B) C) D) E) a\nv483 = var83 (vs83 (vs83 (vs83 (vs83 vz83))))\n\ntest83 : {g:_}-> {a:_} -> Tm83 g (arr83 (arr83 a a) (arr83 a a))\ntest83 = lam83 (lam83 (app83 v183 (app83 v183 (app83 v183 (app83 v183 (app83 v183 (app83 v183 v083)))))))\nTy84 : Type\nTy84 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty84 : Ty84\nempty84 = \\ _, empty, _ => empty\n\narr84 : Ty84 -> Ty84 -> Ty84\narr84 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon84 : Type\nCon84 = (Con84 : Type)\n ->(nil : Con84)\n ->(snoc : Con84 -> Ty84 -> Con84)\n -> Con84\n\nnil84 : Con84\nnil84 = \\ con, nil84, snoc => nil84\n\nsnoc84 : Con84 -> Ty84 -> Con84\nsnoc84 = \\ g, a, con, nil84, snoc84 => snoc84 (g con nil84 snoc84) a\n\nVar84 : Con84 -> Ty84 -> Type\nVar84 = \\ g, a =>\n (Var84 : Con84 -> Ty84 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var84 (snoc84 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var84 g a -> Var84 (snoc84 g b) a)\n -> Var84 g a\n\nvz84 : {g : _}-> {a : _} -> Var84 (snoc84 g a) a\nvz84 = \\ var, vz84, vs => vz84 _ _\n\nvs84 : {g : _} -> {B : _} -> {a : _} -> Var84 g a -> Var84 (snoc84 g B) a\nvs84 = \\ x, var, vz84, vs84 => vs84 _ _ _ (x var vz84 vs84)\n\nTm84 : Con84 -> Ty84 -> Type\nTm84 = \\ g, a =>\n (Tm84 : Con84 -> Ty84 -> Type)\n -> (var : (g : _) -> (a : _) -> Var84 g a -> Tm84 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm84 (snoc84 g a) B -> Tm84 g (arr84 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm84 g (arr84 a B) -> Tm84 g a -> Tm84 g B)\n -> Tm84 g a\n\nvar84 : {g : _} -> {a : _} -> Var84 g a -> Tm84 g a\nvar84 = \\ x, tm, var84, lam, app => var84 _ _ x\n\nlam84 : {g : _} -> {a : _} -> {B : _} -> Tm84 (snoc84 g a) B -> Tm84 g (arr84 a B)\nlam84 = \\ t, tm, var84, lam84, app => lam84 _ _ _ (t tm var84 lam84 app)\n\napp84 : {g:_}->{a:_}->{B:_} -> Tm84 g (arr84 a B) -> Tm84 g a -> Tm84 g B\napp84 = \\ t, u, tm, var84, lam84, app84 => app84 _ _ _ (t tm var84 lam84 app84) (u tm var84 lam84 app84)\n\nv084 : {g:_}->{a:_} -> Tm84 (snoc84 g a) a\nv084 = var84 vz84\n\nv184 : {g:_}->{a:_}-> {B:_}-> Tm84 (snoc84 (snoc84 g a) B) a\nv184 = var84 (vs84 vz84)\n\nv284 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm84 (snoc84 (snoc84 (snoc84 g a) B) C) a\nv284 = var84 (vs84 (vs84 vz84))\n\nv384 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm84 (snoc84 (snoc84 (snoc84 (snoc84 g a) B) C) D) a\nv384 = var84 (vs84 (vs84 (vs84 vz84)))\n\nv484 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm84 (snoc84 (snoc84 (snoc84 (snoc84 (snoc84 g a) B) C) D) E) a\nv484 = var84 (vs84 (vs84 (vs84 (vs84 vz84))))\n\ntest84 : {g:_}-> {a:_} -> Tm84 g (arr84 (arr84 a a) (arr84 a a))\ntest84 = lam84 (lam84 (app84 v184 (app84 v184 (app84 v184 (app84 v184 (app84 v184 (app84 v184 v084)))))))\nTy85 : Type\nTy85 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty85 : Ty85\nempty85 = \\ _, empty, _ => empty\n\narr85 : Ty85 -> Ty85 -> Ty85\narr85 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon85 : Type\nCon85 = (Con85 : Type)\n ->(nil : Con85)\n ->(snoc : Con85 -> Ty85 -> Con85)\n -> Con85\n\nnil85 : Con85\nnil85 = \\ con, nil85, snoc => nil85\n\nsnoc85 : Con85 -> Ty85 -> Con85\nsnoc85 = \\ g, a, con, nil85, snoc85 => snoc85 (g con nil85 snoc85) a\n\nVar85 : Con85 -> Ty85 -> Type\nVar85 = \\ g, a =>\n (Var85 : Con85 -> Ty85 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var85 (snoc85 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var85 g a -> Var85 (snoc85 g b) a)\n -> Var85 g a\n\nvz85 : {g : _}-> {a : _} -> Var85 (snoc85 g a) a\nvz85 = \\ var, vz85, vs => vz85 _ _\n\nvs85 : {g : _} -> {B : _} -> {a : _} -> Var85 g a -> Var85 (snoc85 g B) a\nvs85 = \\ x, var, vz85, vs85 => vs85 _ _ _ (x var vz85 vs85)\n\nTm85 : Con85 -> Ty85 -> Type\nTm85 = \\ g, a =>\n (Tm85 : Con85 -> Ty85 -> Type)\n -> (var : (g : _) -> (a : _) -> Var85 g a -> Tm85 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm85 (snoc85 g a) B -> Tm85 g (arr85 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm85 g (arr85 a B) -> Tm85 g a -> Tm85 g B)\n -> Tm85 g a\n\nvar85 : {g : _} -> {a : _} -> Var85 g a -> Tm85 g a\nvar85 = \\ x, tm, var85, lam, app => var85 _ _ x\n\nlam85 : {g : _} -> {a : _} -> {B : _} -> Tm85 (snoc85 g a) B -> Tm85 g (arr85 a B)\nlam85 = \\ t, tm, var85, lam85, app => lam85 _ _ _ (t tm var85 lam85 app)\n\napp85 : {g:_}->{a:_}->{B:_} -> Tm85 g (arr85 a B) -> Tm85 g a -> Tm85 g B\napp85 = \\ t, u, tm, var85, lam85, app85 => app85 _ _ _ (t tm var85 lam85 app85) (u tm var85 lam85 app85)\n\nv085 : {g:_}->{a:_} -> Tm85 (snoc85 g a) a\nv085 = var85 vz85\n\nv185 : {g:_}->{a:_}-> {B:_}-> Tm85 (snoc85 (snoc85 g a) B) a\nv185 = var85 (vs85 vz85)\n\nv285 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm85 (snoc85 (snoc85 (snoc85 g a) B) C) a\nv285 = var85 (vs85 (vs85 vz85))\n\nv385 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm85 (snoc85 (snoc85 (snoc85 (snoc85 g a) B) C) D) a\nv385 = var85 (vs85 (vs85 (vs85 vz85)))\n\nv485 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm85 (snoc85 (snoc85 (snoc85 (snoc85 (snoc85 g a) B) C) D) E) a\nv485 = var85 (vs85 (vs85 (vs85 (vs85 vz85))))\n\ntest85 : {g:_}-> {a:_} -> Tm85 g (arr85 (arr85 a a) (arr85 a a))\ntest85 = lam85 (lam85 (app85 v185 (app85 v185 (app85 v185 (app85 v185 (app85 v185 (app85 v185 v085)))))))\nTy86 : Type\nTy86 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty86 : Ty86\nempty86 = \\ _, empty, _ => empty\n\narr86 : Ty86 -> Ty86 -> Ty86\narr86 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon86 : Type\nCon86 = (Con86 : Type)\n ->(nil : Con86)\n ->(snoc : Con86 -> Ty86 -> Con86)\n -> Con86\n\nnil86 : Con86\nnil86 = \\ con, nil86, snoc => nil86\n\nsnoc86 : Con86 -> Ty86 -> Con86\nsnoc86 = \\ g, a, con, nil86, snoc86 => snoc86 (g con nil86 snoc86) a\n\nVar86 : Con86 -> Ty86 -> Type\nVar86 = \\ g, a =>\n (Var86 : Con86 -> Ty86 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var86 (snoc86 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var86 g a -> Var86 (snoc86 g b) a)\n -> Var86 g a\n\nvz86 : {g : _}-> {a : _} -> Var86 (snoc86 g a) a\nvz86 = \\ var, vz86, vs => vz86 _ _\n\nvs86 : {g : _} -> {B : _} -> {a : _} -> Var86 g a -> Var86 (snoc86 g B) a\nvs86 = \\ x, var, vz86, vs86 => vs86 _ _ _ (x var vz86 vs86)\n\nTm86 : Con86 -> Ty86 -> Type\nTm86 = \\ g, a =>\n (Tm86 : Con86 -> Ty86 -> Type)\n -> (var : (g : _) -> (a : _) -> Var86 g a -> Tm86 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm86 (snoc86 g a) B -> Tm86 g (arr86 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm86 g (arr86 a B) -> Tm86 g a -> Tm86 g B)\n -> Tm86 g a\n\nvar86 : {g : _} -> {a : _} -> Var86 g a -> Tm86 g a\nvar86 = \\ x, tm, var86, lam, app => var86 _ _ x\n\nlam86 : {g : _} -> {a : _} -> {B : _} -> Tm86 (snoc86 g a) B -> Tm86 g (arr86 a B)\nlam86 = \\ t, tm, var86, lam86, app => lam86 _ _ _ (t tm var86 lam86 app)\n\napp86 : {g:_}->{a:_}->{B:_} -> Tm86 g (arr86 a B) -> Tm86 g a -> Tm86 g B\napp86 = \\ t, u, tm, var86, lam86, app86 => app86 _ _ _ (t tm var86 lam86 app86) (u tm var86 lam86 app86)\n\nv086 : {g:_}->{a:_} -> Tm86 (snoc86 g a) a\nv086 = var86 vz86\n\nv186 : {g:_}->{a:_}-> {B:_}-> Tm86 (snoc86 (snoc86 g a) B) a\nv186 = var86 (vs86 vz86)\n\nv286 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm86 (snoc86 (snoc86 (snoc86 g a) B) C) a\nv286 = var86 (vs86 (vs86 vz86))\n\nv386 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm86 (snoc86 (snoc86 (snoc86 (snoc86 g a) B) C) D) a\nv386 = var86 (vs86 (vs86 (vs86 vz86)))\n\nv486 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm86 (snoc86 (snoc86 (snoc86 (snoc86 (snoc86 g a) B) C) D) E) a\nv486 = var86 (vs86 (vs86 (vs86 (vs86 vz86))))\n\ntest86 : {g:_}-> {a:_} -> Tm86 g (arr86 (arr86 a a) (arr86 a a))\ntest86 = lam86 (lam86 (app86 v186 (app86 v186 (app86 v186 (app86 v186 (app86 v186 (app86 v186 v086)))))))\nTy87 : Type\nTy87 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty87 : Ty87\nempty87 = \\ _, empty, _ => empty\n\narr87 : Ty87 -> Ty87 -> Ty87\narr87 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon87 : Type\nCon87 = (Con87 : Type)\n ->(nil : Con87)\n ->(snoc : Con87 -> Ty87 -> Con87)\n -> Con87\n\nnil87 : Con87\nnil87 = \\ con, nil87, snoc => nil87\n\nsnoc87 : Con87 -> Ty87 -> Con87\nsnoc87 = \\ g, a, con, nil87, snoc87 => snoc87 (g con nil87 snoc87) a\n\nVar87 : Con87 -> Ty87 -> Type\nVar87 = \\ g, a =>\n (Var87 : Con87 -> Ty87 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var87 (snoc87 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var87 g a -> Var87 (snoc87 g b) a)\n -> Var87 g a\n\nvz87 : {g : _}-> {a : _} -> Var87 (snoc87 g a) a\nvz87 = \\ var, vz87, vs => vz87 _ _\n\nvs87 : {g : _} -> {B : _} -> {a : _} -> Var87 g a -> Var87 (snoc87 g B) a\nvs87 = \\ x, var, vz87, vs87 => vs87 _ _ _ (x var vz87 vs87)\n\nTm87 : Con87 -> Ty87 -> Type\nTm87 = \\ g, a =>\n (Tm87 : Con87 -> Ty87 -> Type)\n -> (var : (g : _) -> (a : _) -> Var87 g a -> Tm87 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm87 (snoc87 g a) B -> Tm87 g (arr87 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm87 g (arr87 a B) -> Tm87 g a -> Tm87 g B)\n -> Tm87 g a\n\nvar87 : {g : _} -> {a : _} -> Var87 g a -> Tm87 g a\nvar87 = \\ x, tm, var87, lam, app => var87 _ _ x\n\nlam87 : {g : _} -> {a : _} -> {B : _} -> Tm87 (snoc87 g a) B -> Tm87 g (arr87 a B)\nlam87 = \\ t, tm, var87, lam87, app => lam87 _ _ _ (t tm var87 lam87 app)\n\napp87 : {g:_}->{a:_}->{B:_} -> Tm87 g (arr87 a B) -> Tm87 g a -> Tm87 g B\napp87 = \\ t, u, tm, var87, lam87, app87 => app87 _ _ _ (t tm var87 lam87 app87) (u tm var87 lam87 app87)\n\nv087 : {g:_}->{a:_} -> Tm87 (snoc87 g a) a\nv087 = var87 vz87\n\nv187 : {g:_}->{a:_}-> {B:_}-> Tm87 (snoc87 (snoc87 g a) B) a\nv187 = var87 (vs87 vz87)\n\nv287 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm87 (snoc87 (snoc87 (snoc87 g a) B) C) a\nv287 = var87 (vs87 (vs87 vz87))\n\nv387 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm87 (snoc87 (snoc87 (snoc87 (snoc87 g a) B) C) D) a\nv387 = var87 (vs87 (vs87 (vs87 vz87)))\n\nv487 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm87 (snoc87 (snoc87 (snoc87 (snoc87 (snoc87 g a) B) C) D) E) a\nv487 = var87 (vs87 (vs87 (vs87 (vs87 vz87))))\n\ntest87 : {g:_}-> {a:_} -> Tm87 g (arr87 (arr87 a a) (arr87 a a))\ntest87 = lam87 (lam87 (app87 v187 (app87 v187 (app87 v187 (app87 v187 (app87 v187 (app87 v187 v087)))))))\nTy88 : Type\nTy88 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty88 : Ty88\nempty88 = \\ _, empty, _ => empty\n\narr88 : Ty88 -> Ty88 -> Ty88\narr88 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon88 : Type\nCon88 = (Con88 : Type)\n ->(nil : Con88)\n ->(snoc : Con88 -> Ty88 -> Con88)\n -> Con88\n\nnil88 : Con88\nnil88 = \\ con, nil88, snoc => nil88\n\nsnoc88 : Con88 -> Ty88 -> Con88\nsnoc88 = \\ g, a, con, nil88, snoc88 => snoc88 (g con nil88 snoc88) a\n\nVar88 : Con88 -> Ty88 -> Type\nVar88 = \\ g, a =>\n (Var88 : Con88 -> Ty88 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var88 (snoc88 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var88 g a -> Var88 (snoc88 g b) a)\n -> Var88 g a\n\nvz88 : {g : _}-> {a : _} -> Var88 (snoc88 g a) a\nvz88 = \\ var, vz88, vs => vz88 _ _\n\nvs88 : {g : _} -> {B : _} -> {a : _} -> Var88 g a -> Var88 (snoc88 g B) a\nvs88 = \\ x, var, vz88, vs88 => vs88 _ _ _ (x var vz88 vs88)\n\nTm88 : Con88 -> Ty88 -> Type\nTm88 = \\ g, a =>\n (Tm88 : Con88 -> Ty88 -> Type)\n -> (var : (g : _) -> (a : _) -> Var88 g a -> Tm88 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm88 (snoc88 g a) B -> Tm88 g (arr88 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm88 g (arr88 a B) -> Tm88 g a -> Tm88 g B)\n -> Tm88 g a\n\nvar88 : {g : _} -> {a : _} -> Var88 g a -> Tm88 g a\nvar88 = \\ x, tm, var88, lam, app => var88 _ _ x\n\nlam88 : {g : _} -> {a : _} -> {B : _} -> Tm88 (snoc88 g a) B -> Tm88 g (arr88 a B)\nlam88 = \\ t, tm, var88, lam88, app => lam88 _ _ _ (t tm var88 lam88 app)\n\napp88 : {g:_}->{a:_}->{B:_} -> Tm88 g (arr88 a B) -> Tm88 g a -> Tm88 g B\napp88 = \\ t, u, tm, var88, lam88, app88 => app88 _ _ _ (t tm var88 lam88 app88) (u tm var88 lam88 app88)\n\nv088 : {g:_}->{a:_} -> Tm88 (snoc88 g a) a\nv088 = var88 vz88\n\nv188 : {g:_}->{a:_}-> {B:_}-> Tm88 (snoc88 (snoc88 g a) B) a\nv188 = var88 (vs88 vz88)\n\nv288 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm88 (snoc88 (snoc88 (snoc88 g a) B) C) a\nv288 = var88 (vs88 (vs88 vz88))\n\nv388 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm88 (snoc88 (snoc88 (snoc88 (snoc88 g a) B) C) D) a\nv388 = var88 (vs88 (vs88 (vs88 vz88)))\n\nv488 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm88 (snoc88 (snoc88 (snoc88 (snoc88 (snoc88 g a) B) C) D) E) a\nv488 = var88 (vs88 (vs88 (vs88 (vs88 vz88))))\n\ntest88 : {g:_}-> {a:_} -> Tm88 g (arr88 (arr88 a a) (arr88 a a))\ntest88 = lam88 (lam88 (app88 v188 (app88 v188 (app88 v188 (app88 v188 (app88 v188 (app88 v188 v088)))))))\nTy89 : Type\nTy89 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty89 : Ty89\nempty89 = \\ _, empty, _ => empty\n\narr89 : Ty89 -> Ty89 -> Ty89\narr89 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon89 : Type\nCon89 = (Con89 : Type)\n ->(nil : Con89)\n ->(snoc : Con89 -> Ty89 -> Con89)\n -> Con89\n\nnil89 : Con89\nnil89 = \\ con, nil89, snoc => nil89\n\nsnoc89 : Con89 -> Ty89 -> Con89\nsnoc89 = \\ g, a, con, nil89, snoc89 => snoc89 (g con nil89 snoc89) a\n\nVar89 : Con89 -> Ty89 -> Type\nVar89 = \\ g, a =>\n (Var89 : Con89 -> Ty89 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var89 (snoc89 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var89 g a -> Var89 (snoc89 g b) a)\n -> Var89 g a\n\nvz89 : {g : _}-> {a : _} -> Var89 (snoc89 g a) a\nvz89 = \\ var, vz89, vs => vz89 _ _\n\nvs89 : {g : _} -> {B : _} -> {a : _} -> Var89 g a -> Var89 (snoc89 g B) a\nvs89 = \\ x, var, vz89, vs89 => vs89 _ _ _ (x var vz89 vs89)\n\nTm89 : Con89 -> Ty89 -> Type\nTm89 = \\ g, a =>\n (Tm89 : Con89 -> Ty89 -> Type)\n -> (var : (g : _) -> (a : _) -> Var89 g a -> Tm89 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm89 (snoc89 g a) B -> Tm89 g (arr89 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm89 g (arr89 a B) -> Tm89 g a -> Tm89 g B)\n -> Tm89 g a\n\nvar89 : {g : _} -> {a : _} -> Var89 g a -> Tm89 g a\nvar89 = \\ x, tm, var89, lam, app => var89 _ _ x\n\nlam89 : {g : _} -> {a : _} -> {B : _} -> Tm89 (snoc89 g a) B -> Tm89 g (arr89 a B)\nlam89 = \\ t, tm, var89, lam89, app => lam89 _ _ _ (t tm var89 lam89 app)\n\napp89 : {g:_}->{a:_}->{B:_} -> Tm89 g (arr89 a B) -> Tm89 g a -> Tm89 g B\napp89 = \\ t, u, tm, var89, lam89, app89 => app89 _ _ _ (t tm var89 lam89 app89) (u tm var89 lam89 app89)\n\nv089 : {g:_}->{a:_} -> Tm89 (snoc89 g a) a\nv089 = var89 vz89\n\nv189 : {g:_}->{a:_}-> {B:_}-> Tm89 (snoc89 (snoc89 g a) B) a\nv189 = var89 (vs89 vz89)\n\nv289 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm89 (snoc89 (snoc89 (snoc89 g a) B) C) a\nv289 = var89 (vs89 (vs89 vz89))\n\nv389 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm89 (snoc89 (snoc89 (snoc89 (snoc89 g a) B) C) D) a\nv389 = var89 (vs89 (vs89 (vs89 vz89)))\n\nv489 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm89 (snoc89 (snoc89 (snoc89 (snoc89 (snoc89 g a) B) C) D) E) a\nv489 = var89 (vs89 (vs89 (vs89 (vs89 vz89))))\n\ntest89 : {g:_}-> {a:_} -> Tm89 g (arr89 (arr89 a a) (arr89 a a))\ntest89 = lam89 (lam89 (app89 v189 (app89 v189 (app89 v189 (app89 v189 (app89 v189 (app89 v189 v089)))))))\nTy90 : Type\nTy90 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty90 : Ty90\nempty90 = \\ _, empty, _ => empty\n\narr90 : Ty90 -> Ty90 -> Ty90\narr90 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon90 : Type\nCon90 = (Con90 : Type)\n ->(nil : Con90)\n ->(snoc : Con90 -> Ty90 -> Con90)\n -> Con90\n\nnil90 : Con90\nnil90 = \\ con, nil90, snoc => nil90\n\nsnoc90 : Con90 -> Ty90 -> Con90\nsnoc90 = \\ g, a, con, nil90, snoc90 => snoc90 (g con nil90 snoc90) a\n\nVar90 : Con90 -> Ty90 -> Type\nVar90 = \\ g, a =>\n (Var90 : Con90 -> Ty90 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var90 (snoc90 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var90 g a -> Var90 (snoc90 g b) a)\n -> Var90 g a\n\nvz90 : {g : _}-> {a : _} -> Var90 (snoc90 g a) a\nvz90 = \\ var, vz90, vs => vz90 _ _\n\nvs90 : {g : _} -> {B : _} -> {a : _} -> Var90 g a -> Var90 (snoc90 g B) a\nvs90 = \\ x, var, vz90, vs90 => vs90 _ _ _ (x var vz90 vs90)\n\nTm90 : Con90 -> Ty90 -> Type\nTm90 = \\ g, a =>\n (Tm90 : Con90 -> Ty90 -> Type)\n -> (var : (g : _) -> (a : _) -> Var90 g a -> Tm90 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm90 (snoc90 g a) B -> Tm90 g (arr90 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm90 g (arr90 a B) -> Tm90 g a -> Tm90 g B)\n -> Tm90 g a\n\nvar90 : {g : _} -> {a : _} -> Var90 g a -> Tm90 g a\nvar90 = \\ x, tm, var90, lam, app => var90 _ _ x\n\nlam90 : {g : _} -> {a : _} -> {B : _} -> Tm90 (snoc90 g a) B -> Tm90 g (arr90 a B)\nlam90 = \\ t, tm, var90, lam90, app => lam90 _ _ _ (t tm var90 lam90 app)\n\napp90 : {g:_}->{a:_}->{B:_} -> Tm90 g (arr90 a B) -> Tm90 g a -> Tm90 g B\napp90 = \\ t, u, tm, var90, lam90, app90 => app90 _ _ _ (t tm var90 lam90 app90) (u tm var90 lam90 app90)\n\nv090 : {g:_}->{a:_} -> Tm90 (snoc90 g a) a\nv090 = var90 vz90\n\nv190 : {g:_}->{a:_}-> {B:_}-> Tm90 (snoc90 (snoc90 g a) B) a\nv190 = var90 (vs90 vz90)\n\nv290 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm90 (snoc90 (snoc90 (snoc90 g a) B) C) a\nv290 = var90 (vs90 (vs90 vz90))\n\nv390 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm90 (snoc90 (snoc90 (snoc90 (snoc90 g a) B) C) D) a\nv390 = var90 (vs90 (vs90 (vs90 vz90)))\n\nv490 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm90 (snoc90 (snoc90 (snoc90 (snoc90 (snoc90 g a) B) C) D) E) a\nv490 = var90 (vs90 (vs90 (vs90 (vs90 vz90))))\n\ntest90 : {g:_}-> {a:_} -> Tm90 g (arr90 (arr90 a a) (arr90 a a))\ntest90 = lam90 (lam90 (app90 v190 (app90 v190 (app90 v190 (app90 v190 (app90 v190 (app90 v190 v090)))))))\nTy91 : Type\nTy91 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty91 : Ty91\nempty91 = \\ _, empty, _ => empty\n\narr91 : Ty91 -> Ty91 -> Ty91\narr91 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon91 : Type\nCon91 = (Con91 : Type)\n ->(nil : Con91)\n ->(snoc : Con91 -> Ty91 -> Con91)\n -> Con91\n\nnil91 : Con91\nnil91 = \\ con, nil91, snoc => nil91\n\nsnoc91 : Con91 -> Ty91 -> Con91\nsnoc91 = \\ g, a, con, nil91, snoc91 => snoc91 (g con nil91 snoc91) a\n\nVar91 : Con91 -> Ty91 -> Type\nVar91 = \\ g, a =>\n (Var91 : Con91 -> Ty91 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var91 (snoc91 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var91 g a -> Var91 (snoc91 g b) a)\n -> Var91 g a\n\nvz91 : {g : _}-> {a : _} -> Var91 (snoc91 g a) a\nvz91 = \\ var, vz91, vs => vz91 _ _\n\nvs91 : {g : _} -> {B : _} -> {a : _} -> Var91 g a -> Var91 (snoc91 g B) a\nvs91 = \\ x, var, vz91, vs91 => vs91 _ _ _ (x var vz91 vs91)\n\nTm91 : Con91 -> Ty91 -> Type\nTm91 = \\ g, a =>\n (Tm91 : Con91 -> Ty91 -> Type)\n -> (var : (g : _) -> (a : _) -> Var91 g a -> Tm91 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm91 (snoc91 g a) B -> Tm91 g (arr91 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm91 g (arr91 a B) -> Tm91 g a -> Tm91 g B)\n -> Tm91 g a\n\nvar91 : {g : _} -> {a : _} -> Var91 g a -> Tm91 g a\nvar91 = \\ x, tm, var91, lam, app => var91 _ _ x\n\nlam91 : {g : _} -> {a : _} -> {B : _} -> Tm91 (snoc91 g a) B -> Tm91 g (arr91 a B)\nlam91 = \\ t, tm, var91, lam91, app => lam91 _ _ _ (t tm var91 lam91 app)\n\napp91 : {g:_}->{a:_}->{B:_} -> Tm91 g (arr91 a B) -> Tm91 g a -> Tm91 g B\napp91 = \\ t, u, tm, var91, lam91, app91 => app91 _ _ _ (t tm var91 lam91 app91) (u tm var91 lam91 app91)\n\nv091 : {g:_}->{a:_} -> Tm91 (snoc91 g a) a\nv091 = var91 vz91\n\nv191 : {g:_}->{a:_}-> {B:_}-> Tm91 (snoc91 (snoc91 g a) B) a\nv191 = var91 (vs91 vz91)\n\nv291 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm91 (snoc91 (snoc91 (snoc91 g a) B) C) a\nv291 = var91 (vs91 (vs91 vz91))\n\nv391 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm91 (snoc91 (snoc91 (snoc91 (snoc91 g a) B) C) D) a\nv391 = var91 (vs91 (vs91 (vs91 vz91)))\n\nv491 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm91 (snoc91 (snoc91 (snoc91 (snoc91 (snoc91 g a) B) C) D) E) a\nv491 = var91 (vs91 (vs91 (vs91 (vs91 vz91))))\n\ntest91 : {g:_}-> {a:_} -> Tm91 g (arr91 (arr91 a a) (arr91 a a))\ntest91 = lam91 (lam91 (app91 v191 (app91 v191 (app91 v191 (app91 v191 (app91 v191 (app91 v191 v091)))))))\nTy92 : Type\nTy92 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty92 : Ty92\nempty92 = \\ _, empty, _ => empty\n\narr92 : Ty92 -> Ty92 -> Ty92\narr92 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon92 : Type\nCon92 = (Con92 : Type)\n ->(nil : Con92)\n ->(snoc : Con92 -> Ty92 -> Con92)\n -> Con92\n\nnil92 : Con92\nnil92 = \\ con, nil92, snoc => nil92\n\nsnoc92 : Con92 -> Ty92 -> Con92\nsnoc92 = \\ g, a, con, nil92, snoc92 => snoc92 (g con nil92 snoc92) a\n\nVar92 : Con92 -> Ty92 -> Type\nVar92 = \\ g, a =>\n (Var92 : Con92 -> Ty92 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var92 (snoc92 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var92 g a -> Var92 (snoc92 g b) a)\n -> Var92 g a\n\nvz92 : {g : _}-> {a : _} -> Var92 (snoc92 g a) a\nvz92 = \\ var, vz92, vs => vz92 _ _\n\nvs92 : {g : _} -> {B : _} -> {a : _} -> Var92 g a -> Var92 (snoc92 g B) a\nvs92 = \\ x, var, vz92, vs92 => vs92 _ _ _ (x var vz92 vs92)\n\nTm92 : Con92 -> Ty92 -> Type\nTm92 = \\ g, a =>\n (Tm92 : Con92 -> Ty92 -> Type)\n -> (var : (g : _) -> (a : _) -> Var92 g a -> Tm92 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm92 (snoc92 g a) B -> Tm92 g (arr92 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm92 g (arr92 a B) -> Tm92 g a -> Tm92 g B)\n -> Tm92 g a\n\nvar92 : {g : _} -> {a : _} -> Var92 g a -> Tm92 g a\nvar92 = \\ x, tm, var92, lam, app => var92 _ _ x\n\nlam92 : {g : _} -> {a : _} -> {B : _} -> Tm92 (snoc92 g a) B -> Tm92 g (arr92 a B)\nlam92 = \\ t, tm, var92, lam92, app => lam92 _ _ _ (t tm var92 lam92 app)\n\napp92 : {g:_}->{a:_}->{B:_} -> Tm92 g (arr92 a B) -> Tm92 g a -> Tm92 g B\napp92 = \\ t, u, tm, var92, lam92, app92 => app92 _ _ _ (t tm var92 lam92 app92) (u tm var92 lam92 app92)\n\nv092 : {g:_}->{a:_} -> Tm92 (snoc92 g a) a\nv092 = var92 vz92\n\nv192 : {g:_}->{a:_}-> {B:_}-> Tm92 (snoc92 (snoc92 g a) B) a\nv192 = var92 (vs92 vz92)\n\nv292 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm92 (snoc92 (snoc92 (snoc92 g a) B) C) a\nv292 = var92 (vs92 (vs92 vz92))\n\nv392 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm92 (snoc92 (snoc92 (snoc92 (snoc92 g a) B) C) D) a\nv392 = var92 (vs92 (vs92 (vs92 vz92)))\n\nv492 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm92 (snoc92 (snoc92 (snoc92 (snoc92 (snoc92 g a) B) C) D) E) a\nv492 = var92 (vs92 (vs92 (vs92 (vs92 vz92))))\n\ntest92 : {g:_}-> {a:_} -> Tm92 g (arr92 (arr92 a a) (arr92 a a))\ntest92 = lam92 (lam92 (app92 v192 (app92 v192 (app92 v192 (app92 v192 (app92 v192 (app92 v192 v092)))))))\nTy93 : Type\nTy93 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty93 : Ty93\nempty93 = \\ _, empty, _ => empty\n\narr93 : Ty93 -> Ty93 -> Ty93\narr93 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon93 : Type\nCon93 = (Con93 : Type)\n ->(nil : Con93)\n ->(snoc : Con93 -> Ty93 -> Con93)\n -> Con93\n\nnil93 : Con93\nnil93 = \\ con, nil93, snoc => nil93\n\nsnoc93 : Con93 -> Ty93 -> Con93\nsnoc93 = \\ g, a, con, nil93, snoc93 => snoc93 (g con nil93 snoc93) a\n\nVar93 : Con93 -> Ty93 -> Type\nVar93 = \\ g, a =>\n (Var93 : Con93 -> Ty93 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var93 (snoc93 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var93 g a -> Var93 (snoc93 g b) a)\n -> Var93 g a\n\nvz93 : {g : _}-> {a : _} -> Var93 (snoc93 g a) a\nvz93 = \\ var, vz93, vs => vz93 _ _\n\nvs93 : {g : _} -> {B : _} -> {a : _} -> Var93 g a -> Var93 (snoc93 g B) a\nvs93 = \\ x, var, vz93, vs93 => vs93 _ _ _ (x var vz93 vs93)\n\nTm93 : Con93 -> Ty93 -> Type\nTm93 = \\ g, a =>\n (Tm93 : Con93 -> Ty93 -> Type)\n -> (var : (g : _) -> (a : _) -> Var93 g a -> Tm93 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm93 (snoc93 g a) B -> Tm93 g (arr93 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm93 g (arr93 a B) -> Tm93 g a -> Tm93 g B)\n -> Tm93 g a\n\nvar93 : {g : _} -> {a : _} -> Var93 g a -> Tm93 g a\nvar93 = \\ x, tm, var93, lam, app => var93 _ _ x\n\nlam93 : {g : _} -> {a : _} -> {B : _} -> Tm93 (snoc93 g a) B -> Tm93 g (arr93 a B)\nlam93 = \\ t, tm, var93, lam93, app => lam93 _ _ _ (t tm var93 lam93 app)\n\napp93 : {g:_}->{a:_}->{B:_} -> Tm93 g (arr93 a B) -> Tm93 g a -> Tm93 g B\napp93 = \\ t, u, tm, var93, lam93, app93 => app93 _ _ _ (t tm var93 lam93 app93) (u tm var93 lam93 app93)\n\nv093 : {g:_}->{a:_} -> Tm93 (snoc93 g a) a\nv093 = var93 vz93\n\nv193 : {g:_}->{a:_}-> {B:_}-> Tm93 (snoc93 (snoc93 g a) B) a\nv193 = var93 (vs93 vz93)\n\nv293 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm93 (snoc93 (snoc93 (snoc93 g a) B) C) a\nv293 = var93 (vs93 (vs93 vz93))\n\nv393 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm93 (snoc93 (snoc93 (snoc93 (snoc93 g a) B) C) D) a\nv393 = var93 (vs93 (vs93 (vs93 vz93)))\n\nv493 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm93 (snoc93 (snoc93 (snoc93 (snoc93 (snoc93 g a) B) C) D) E) a\nv493 = var93 (vs93 (vs93 (vs93 (vs93 vz93))))\n\ntest93 : {g:_}-> {a:_} -> Tm93 g (arr93 (arr93 a a) (arr93 a a))\ntest93 = lam93 (lam93 (app93 v193 (app93 v193 (app93 v193 (app93 v193 (app93 v193 (app93 v193 v093)))))))\nTy94 : Type\nTy94 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty94 : Ty94\nempty94 = \\ _, empty, _ => empty\n\narr94 : Ty94 -> Ty94 -> Ty94\narr94 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon94 : Type\nCon94 = (Con94 : Type)\n ->(nil : Con94)\n ->(snoc : Con94 -> Ty94 -> Con94)\n -> Con94\n\nnil94 : Con94\nnil94 = \\ con, nil94, snoc => nil94\n\nsnoc94 : Con94 -> Ty94 -> Con94\nsnoc94 = \\ g, a, con, nil94, snoc94 => snoc94 (g con nil94 snoc94) a\n\nVar94 : Con94 -> Ty94 -> Type\nVar94 = \\ g, a =>\n (Var94 : Con94 -> Ty94 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var94 (snoc94 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var94 g a -> Var94 (snoc94 g b) a)\n -> Var94 g a\n\nvz94 : {g : _}-> {a : _} -> Var94 (snoc94 g a) a\nvz94 = \\ var, vz94, vs => vz94 _ _\n\nvs94 : {g : _} -> {B : _} -> {a : _} -> Var94 g a -> Var94 (snoc94 g B) a\nvs94 = \\ x, var, vz94, vs94 => vs94 _ _ _ (x var vz94 vs94)\n\nTm94 : Con94 -> Ty94 -> Type\nTm94 = \\ g, a =>\n (Tm94 : Con94 -> Ty94 -> Type)\n -> (var : (g : _) -> (a : _) -> Var94 g a -> Tm94 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm94 (snoc94 g a) B -> Tm94 g (arr94 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm94 g (arr94 a B) -> Tm94 g a -> Tm94 g B)\n -> Tm94 g a\n\nvar94 : {g : _} -> {a : _} -> Var94 g a -> Tm94 g a\nvar94 = \\ x, tm, var94, lam, app => var94 _ _ x\n\nlam94 : {g : _} -> {a : _} -> {B : _} -> Tm94 (snoc94 g a) B -> Tm94 g (arr94 a B)\nlam94 = \\ t, tm, var94, lam94, app => lam94 _ _ _ (t tm var94 lam94 app)\n\napp94 : {g:_}->{a:_}->{B:_} -> Tm94 g (arr94 a B) -> Tm94 g a -> Tm94 g B\napp94 = \\ t, u, tm, var94, lam94, app94 => app94 _ _ _ (t tm var94 lam94 app94) (u tm var94 lam94 app94)\n\nv094 : {g:_}->{a:_} -> Tm94 (snoc94 g a) a\nv094 = var94 vz94\n\nv194 : {g:_}->{a:_}-> {B:_}-> Tm94 (snoc94 (snoc94 g a) B) a\nv194 = var94 (vs94 vz94)\n\nv294 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm94 (snoc94 (snoc94 (snoc94 g a) B) C) a\nv294 = var94 (vs94 (vs94 vz94))\n\nv394 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm94 (snoc94 (snoc94 (snoc94 (snoc94 g a) B) C) D) a\nv394 = var94 (vs94 (vs94 (vs94 vz94)))\n\nv494 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm94 (snoc94 (snoc94 (snoc94 (snoc94 (snoc94 g a) B) C) D) E) a\nv494 = var94 (vs94 (vs94 (vs94 (vs94 vz94))))\n\ntest94 : {g:_}-> {a:_} -> Tm94 g (arr94 (arr94 a a) (arr94 a a))\ntest94 = lam94 (lam94 (app94 v194 (app94 v194 (app94 v194 (app94 v194 (app94 v194 (app94 v194 v094)))))))\nTy95 : Type\nTy95 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty95 : Ty95\nempty95 = \\ _, empty, _ => empty\n\narr95 : Ty95 -> Ty95 -> Ty95\narr95 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon95 : Type\nCon95 = (Con95 : Type)\n ->(nil : Con95)\n ->(snoc : Con95 -> Ty95 -> Con95)\n -> Con95\n\nnil95 : Con95\nnil95 = \\ con, nil95, snoc => nil95\n\nsnoc95 : Con95 -> Ty95 -> Con95\nsnoc95 = \\ g, a, con, nil95, snoc95 => snoc95 (g con nil95 snoc95) a\n\nVar95 : Con95 -> Ty95 -> Type\nVar95 = \\ g, a =>\n (Var95 : Con95 -> Ty95 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var95 (snoc95 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var95 g a -> Var95 (snoc95 g b) a)\n -> Var95 g a\n\nvz95 : {g : _}-> {a : _} -> Var95 (snoc95 g a) a\nvz95 = \\ var, vz95, vs => vz95 _ _\n\nvs95 : {g : _} -> {B : _} -> {a : _} -> Var95 g a -> Var95 (snoc95 g B) a\nvs95 = \\ x, var, vz95, vs95 => vs95 _ _ _ (x var vz95 vs95)\n\nTm95 : Con95 -> Ty95 -> Type\nTm95 = \\ g, a =>\n (Tm95 : Con95 -> Ty95 -> Type)\n -> (var : (g : _) -> (a : _) -> Var95 g a -> Tm95 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm95 (snoc95 g a) B -> Tm95 g (arr95 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm95 g (arr95 a B) -> Tm95 g a -> Tm95 g B)\n -> Tm95 g a\n\nvar95 : {g : _} -> {a : _} -> Var95 g a -> Tm95 g a\nvar95 = \\ x, tm, var95, lam, app => var95 _ _ x\n\nlam95 : {g : _} -> {a : _} -> {B : _} -> Tm95 (snoc95 g a) B -> Tm95 g (arr95 a B)\nlam95 = \\ t, tm, var95, lam95, app => lam95 _ _ _ (t tm var95 lam95 app)\n\napp95 : {g:_}->{a:_}->{B:_} -> Tm95 g (arr95 a B) -> Tm95 g a -> Tm95 g B\napp95 = \\ t, u, tm, var95, lam95, app95 => app95 _ _ _ (t tm var95 lam95 app95) (u tm var95 lam95 app95)\n\nv095 : {g:_}->{a:_} -> Tm95 (snoc95 g a) a\nv095 = var95 vz95\n\nv195 : {g:_}->{a:_}-> {B:_}-> Tm95 (snoc95 (snoc95 g a) B) a\nv195 = var95 (vs95 vz95)\n\nv295 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm95 (snoc95 (snoc95 (snoc95 g a) B) C) a\nv295 = var95 (vs95 (vs95 vz95))\n\nv395 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm95 (snoc95 (snoc95 (snoc95 (snoc95 g a) B) C) D) a\nv395 = var95 (vs95 (vs95 (vs95 vz95)))\n\nv495 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm95 (snoc95 (snoc95 (snoc95 (snoc95 (snoc95 g a) B) C) D) E) a\nv495 = var95 (vs95 (vs95 (vs95 (vs95 vz95))))\n\ntest95 : {g:_}-> {a:_} -> Tm95 g (arr95 (arr95 a a) (arr95 a a))\ntest95 = lam95 (lam95 (app95 v195 (app95 v195 (app95 v195 (app95 v195 (app95 v195 (app95 v195 v095)))))))\n", "meta": {"hexsha": "1e2b2818e87f19d22ade727dd09392c0835ecf6e", "size": 234520, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "bench/stlc_small5k.idr", "max_stars_repo_name": "Kha/smalltt", "max_stars_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 377, "max_stars_repo_stars_event_min_datetime": "2017-11-26T16:57:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T21:31:01.000Z", "max_issues_repo_path": "bench/stlc_small5k.idr", "max_issues_repo_name": "Kha/smalltt", "max_issues_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-03-16T09:14:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:51:10.000Z", "max_forks_repo_path": "bench/stlc_small5k.idr", "max_forks_repo_name": "Kha/smalltt", "max_forks_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2018-12-05T21:11:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T19:46:54.000Z", "avg_line_length": 34.4022297198, "max_line_length": 118, "alphanum_fraction": 0.5050997783, "num_tokens": 107545, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388167733099, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5369850882970811}} {"text": "module QPF\n\nimport Linear.Types\nimport Linear.Equality\nimport FunExt\n\n{-\n This file implements quantitative polynomial functors as a type\n Desc with interpretation qpf, and shows that initiality implies\n induction for them.\n-}\n\n\n-- Grammar of polynomial functors\n\npublic export\ndata Desc : Type where\n Id' : Desc\n Const' : Type -> Desc\n Prod' : Desc -> Desc -> Desc\n Sum' : Desc -> Desc -> Desc\n With' : Desc -> Desc -> Desc\n Arr' : Type -> Desc -> Desc\n\n-- Interpretation\n\npublic export\n0 qpf : Desc -> Type -> Type\nqpf Id' x = x\nqpf (Const' a) _ = a\nqpf (Prod' f g) x = LPair (qpf f x) (qpf g x)\nqpf (Sum' f g) x = Sum (qpf f x) (qpf g x)\nqpf (With' f g) x = With (qpf f x) (qpf g x)\nqpf (Arr' a f) x = a -<> qpf f x\n\npublic export\nfmap : (d : Desc) -> (f : a -<> b) -> qpf d a -<> qpf d b\nfmap Id' f x = f x\nfmap (Const' _) _ x = x\nfmap (Prod' c d) f x = bimap (fmap c f) (fmap d f) x\nfmap (Sum' c d) f x = bimap (fmap c f) (fmap d f) x\nfmap (With' c d) f x = bimap (fmap c f) (fmap d f) x\nfmap (Arr' a c) f x = \\ y => fmap c f (x y)\n\n-- Functor laws\n0 fmap_id : {d : Desc} -> (1 x : qpf d a) -> x = fmap {b = a} d (\\1 x => x) x\nfmap_id {d = Id'} x = Refl\nfmap_id {d = (Const' _)} _ = Refl\nfmap_id {d = (Prod' c d)} (x # y) = lcong2 (#) (fmap_id x) (fmap_id y)\nfmap_id {d = (Sum' c d)} (Inl x) = lcong Inl (fmap_id x)\nfmap_id {d = (Sum' c d)} (Inr y) = lcong Inr (fmap_id y)\nfmap_id {d = (With' c d)} x = funext (\\b => if b then fmap_id (x True) else fmap_id (x False))\nfmap_id {d = (Arr' a c)} g = funext (\\ y => fmap_id (g y))\n\n0 fmap_comp : (d : Desc) -> {f : a -<> b} -> {g : b -<> c} ->\n (1 x : qpf d a) -> fmap d g (fmap d f x) = fmap d (\\ x => g (f x)) x\nfmap_comp Id' x = Refl\nfmap_comp (Const' a) _ = Refl\nfmap_comp (Prod' c d) (x # y) = lcong2 (#) (fmap_comp c {f} {g} x) (fmap_comp d {f} {g} y)\nfmap_comp (Sum' c d) (Inl x) = lcong Inl (fmap_comp c x)\nfmap_comp (Sum' c d) (Inr y) = lcong Inr (fmap_comp d y)\nfmap_comp (With' c d) x = funext (\\b => if b then fmap_comp c (x True) else fmap_comp d (x False))\nfmap_comp (Arr' a c) g = funext (\\ y => fmap_comp c (g y))\n\n-- Predicate lifting\n\npublic export\n0 lift : (d : Desc) -> (p : x -> Type) -> qpf d x -> Type\nlift Id' p f = p f\nlift (Const' a) p x = Sigma1 a (\\ y => x = y)\nlift (Prod' c d) p z = LPair (lift c p (LPair.fst z)) (lift d p (LPair.snd z))\nlift (Sum' c d) p z = Sum (Sigma0 (qpf c x) (\\ z1 => LPair (z = Inl z1) (lift c p z1))) (Sigma0 (qpf d x) (\\ z2 => LPair (z = Inr z2) (lift d p z2)))\nlift (With' c d) p f = With (lift c p (f True)) (lift d p (f False))\nlift (Arr' a c) p f = (1 y : a) -> lift c p (f y)\n\n-- Lifting fuses with fmap (we only provide the useful direction)\n\n0 liftcomp : (d : Desc) -> (p : x -> Type) -> (g : x' -<> x) ->\n (y : qpf d x') -> lift d p (fmap d g y) -> lift d (\\ w => p (g w)) y\nliftcomp Id' p g y z = z\nliftcomp (Const' a) p g y z = z\nliftcomp (Prod' c d) p g (x # y) (z1 # z2) = (liftcomp c p g x z1) # (liftcomp d p g y z2)\nliftcomp (Sum' c d) p g (Inl y) (Inl (_ # (Refl # z))) = Inl (y # (Refl # liftcomp c p g y z))\nliftcomp (Sum' c d) p g (Inl y) (Inr (_ # (leqr # z))) = absurd leqr\nliftcomp (Sum' c d) p g (Inr y) (Inl (_ # (leqr # z))) = absurd (sym leqr)\nliftcomp (Sum' c d) p g (Inr y) (Inr (_ # (Refl # z))) = Inr (y # (Refl # liftcomp d p g y z))\nliftcomp (With' c d) p g y z = \\ b => if b then liftcomp c p g (y True) (z True) else liftcomp d p g (y False) (z False)\nliftcomp (Arr' a c) p g f z = \\ y => liftcomp c p g (f y) (z y)\n\nliftfmap : (d : Desc) -> {p : x -> Type} ->\n ((1 y : x) -> p y) -> (1 z : qpf d x) -> lift d p z\nliftfmap Id' f z = f z\nliftfmap (Const' a) f z = z # Refl\nliftfmap (Prod' c d) f (z1 # z2) = liftfmap c f z1 # liftfmap d f z2\nliftfmap (Sum' c d) f (Inl z) = Inl (z # (Refl # liftfmap c f z))\nliftfmap (Sum' c d) f (Inr z) = Inr (z # (Refl # liftfmap d f z))\nliftfmap (With' c d) f z = \\ b => if b then liftfmap c f (z True) else liftfmap d f (z False)\nliftfmap (Arr' a c) f z = \\ y => liftfmap c f (z y)\n\n0 liftfmap_comp : {x : Type} -> {x' : Type} -> (d : Desc) -> {p : x -> Type} ->\n (f : (1 y : x) -> p y) -> (g : x' -<> x) ->\n (1 z : qpf d x') ->\n liftcomp d p g z (liftfmap d {p} f (fmap d g z)) = liftfmap d {p = \\ w => p (g w)} (\\ x => f (g x)) z\n\nliftfmap_comp Id' f g y = Refl\nliftfmap_comp (Const' a) f g y = Refl\nliftfmap_comp (Prod' c d) f g (x # y) = lcong2 (#) (liftfmap_comp c f g x) (liftfmap_comp d f g y)\nliftfmap_comp (Sum' c d) f g (Inl y) = lcong (\\ z => Inl (y # (Refl # z))) (liftfmap_comp c f g y)\nliftfmap_comp (Sum' c d) f g (Inr y) = lcong (\\ z => Inr (y # (Refl # z))) (liftfmap_comp d f g y)\nliftfmap_comp (With' c d) f g y = funext (\\ b => if b then liftfmap_comp c f g (y True) else liftfmap_comp d f g (y False))\nliftfmap_comp (Arr' a c) f g h = funext (\\ y => liftfmap_comp c f g (h y))\n\n\n\n-- qpf d distributes over Sigma0\n\npublic export\ndist : {0 x : Type} -> {0 y : x -> Type} ->\n (d : Desc) -> qpf d (Sigma0 x y) -<> Sigma0 (qpf d x) (lift d y)\ndist Id' (x # y) = x # y\ndist (Const' _) x = x # (x # Refl)\ndist (Prod' c d) (x # y) =\n let (f # lf) = dist c x\n (g # lg) = dist d y\n in (f # g) # (lf # lg)\ndist (Sum' c d) (Inl f) =\n let (f # lf) = dist c f\n in (Inl f) # (Inl (f # (Refl # lf)))\ndist (Sum' c d) (Inr g) =\n let (g # lg) = dist d g\n in (Inr g) # (Inr (g # (Refl # lg)))\ndist (With' c d) w =\n (h w) # (j w) where\n 0 h : With (qpf c (Sigma0 x y)) (qpf d (Sigma0 x y)) -> With (qpf c x) (qpf d x)\n h u True = fst (dist c (u True))\n h u False = fst (dist d (u False))\n\n j : (1 u : With (qpf c (Sigma0 x y)) (qpf d (Sigma0 x y))) ->\n With (lift c y (h u True)) (lift d y (h u False))\n j u True = snd (dist c (u True))\n j u False = snd (dist d (u False))\ndist (Arr' a c) w =\n (h w) # (j w) where\n 0 h : (a -<> qpf c (Sigma0 x y)) -> (a -<> qpf c x)\n h g z = fst (dist c (g z))\n\n j : (1 g : a -<> qpf c (Sigma0 x y)) ->\n ((1 z : a) -> (lift c y (h g z)))\n j g z = snd (dist c (g z))\n\n-- The first projection of dist is fmap fst\n0 distfst : (d : Desc) -> {0 x : Type} -> {0 p : x -> Type} ->\n (y : qpf d (Sigma0 x p)) -> fst {b = lift d p} (dist {y = p} d y) = fmap {b = x} d (fst {b = p}) y\ndistfst Id' (x # y) = Refl\ndistfst (Const' a) y = Refl\ndistfst (Prod' c d) (x # y) with (distfst c x)\n distfst (Prod' c d) (x # y) | r with (distfst d y)\n distfst (Prod' c d) (x # y) | r | q with (dist c x)\n distfst (Prod' c d) (x # y) | r | q | (f # lf) with (dist d y)\n distfst (Prod' c d) (x # y) | r | q | (f # lf) | (g # lg) = lcong2 (#) r q\ndistfst (Sum' c d) (Inl y) with (distfst c y)\n distfst (Sum' c d) (Inl y) | q with (dist c y)\n distfst (Sum' c d) (Inl y) | q | (f # lf) = lcong Inl q\ndistfst (Sum' c d) (Inr y) with (distfst d y)\n distfst (Sum' c d) (Inr y) | q with (dist d y)\n distfst (Sum' c d) (Inr y) | q | (f # lf) = lcong Inr q\ndistfst (With' c d) y = funext (\\ b => if b then distfst c (y True) else distfst d (y False))\ndistfst (Arr' a c) y = funext (\\ z => distfst c (y z))\n\n\n-- Algebra\n\npublic export\ndata W : (0 u : Desc) -> Type where\n Con : qpf u (W u) -<> W u\n -- Note: we only use pattern matching on Con to define fold and prove its properties\n\n-- The notion of algebra morphism\n\n0 morphism : (d : Desc) -> (alg1 : qpf d a -<> a) -> (alg2 : qpf d b -<> b) ->\n a -<> b -> Type\nmorphism d alg1 alg2 f = (1 y : qpf d a) -> f (alg1 y) = alg2 (fmap d f y)\n\n0 morphism_id : (alg : qpf d a -<> a) -> morphism d alg alg (\\ x => x)\nmorphism_id alg y = lcong alg (fmap_id y)\n\n0 morphism_comp : {d : Desc} ->\n (alg1 : qpf d a -<> a) ->\n (alg2 : qpf d b -<> b) ->\n (alg3 : qpf d c -<> c) ->\n {f : a -<> b} -> {g : b -<> c} ->\n morphism d alg1 alg2 f ->\n morphism d alg2 alg3 g ->\n morphism d alg1 alg3 (\\ x => g (f x))\nmorphism_comp {d} alg1 alg2 alg3 {f} {g} m12 m23 y =\n trans (lcong g (m12 y)) (trans (m23 (fmap d f y)) (lcong alg3 (fmap_comp d y)))\n\n-- Unique mediating morphism\n\nmutual\n fold_h : {c : Desc} -> (d : Desc) -> (qpf c x -<> x) -> qpf d (W c) -<> qpf d x\n fold_h Id' alg (Con w) = alg (fold_h c alg w)\n fold_h (Const' y) alg w = w\n fold_h (Prod' c d) alg w = bimap (fold_h c alg) (fold_h d alg) w\n fold_h (Sum' c d) alg w = bimap (fold_h c alg) (fold_h d alg) w\n fold_h (With' c d) alg w = with With.bimap (bimap (fold_h c alg) (fold_h d alg) w)\n fold_h (Arr' a c) alg w = \\ y => fold_h c alg (w y)\n\n fold : (d : Desc) -> (qpf d x -<> x) -> W d -<> x\n fold d alg (Con w) = alg (fold_h d alg w)\n\nmutual\n 0 uniq_h : {c : Desc} -> (d : Desc) ->\n (h : W c -<> x) ->\n (alg : qpf c x -<> x) ->\n morphism c Con alg h ->\n (w : qpf d (W c)) -> fmap d h w = fold_h {c = c} d alg w\n uniq_h Id' h alg commutes (Con y) = trans (commutes y) (lcong alg (uniq_h c h alg commutes y))\n uniq_h (Const' y) h calg commutes z = Refl\n uniq_h (Prod' c' d') h calg commutes (f' # g') =\n let uc' = uniq_h c' h calg commutes f'\n ud' = uniq_h d' h calg commutes g'\n in lcong2 (#) uc' ud'\n uniq_h (Sum' c' d') h calg commutes (Inl f') = lcong Inl (uniq_h c' h calg commutes f')\n uniq_h (Sum' c' d') h calg commutes (Inr g') = lcong Inr (uniq_h d' h calg commutes g')\n uniq_h (With' c' d') h calg commutes z =\n funext (\\x => if x then uniq_h c' h calg commutes (z True)\n else uniq_h d' h calg commutes (z False))\n uniq_h (Arr' a c') h calg commutes z = funext (\\ y => uniq_h c' h calg commutes (z y))\n\n 0 uniq : {d : Desc} ->\n (alg : qpf d x -<> x) ->\n (h : W d -<> x) ->\n ((1 y : qpf d (W d)) -> h (Con y) = alg (fmap d h y)) ->\n (w : W d) -> h w = fold d alg w\n uniq alg h commutes (Con y) =\n trans (commutes y) (lcong alg (uniq_h d h alg commutes y))\n\n0 foldCon_id : (1 w : W d) -> w = fold d Con w\nfoldCon_id w = uniq Con (\\x => x) (\\y => lcong Con (fmap_id y)) w\n\n0 foldCommutes : (d : Desc) -> (alg : qpf d x -<> x) ->\n morphism d Con alg (fold d alg)\nfoldCommutes Id' alg (Con x) = Refl\nfoldCommutes (Const' _) alg x = Refl\nfoldCommutes (Prod' c d) alg (x # y) =\n let commutesC = uniq_h c (fold (Prod' c d) alg) alg (foldCommutes (Prod' c d) alg) x\n commutesD = uniq_h d (fold (Prod' c d) alg) alg (foldCommutes (Prod' c d) alg) y\n in lcong alg (lcong2 (#) (sym commutesC) (sym commutesD))\n\nfoldCommutes (Sum' c d) alg (Inl x) =\n let commutesC = uniq_h c (fold (Sum' c d) alg) alg (foldCommutes (Sum' c d) alg) x\n in lcong alg (lcong Inl (sym commutesC))\n\nfoldCommutes (Sum' c d) alg (Inr y) =\n let commutesD = uniq_h d (fold (Sum' c d) alg) alg (foldCommutes (Sum' c d) alg) y\n in lcong alg (lcong Inr (sym commutesD))\n\nfoldCommutes (With' c d) alg x =\n lcong alg (funext (\\b => if b then sym (uniq_h c (fold (With' c d) alg) alg (foldCommutes (With' c d) alg) (x True))\n else sym (uniq_h d (fold (With' c d) alg) alg (foldCommutes (With' c d) alg) (x False))\n ))\nfoldCommutes (Arr' a c) alg g =\n lcong alg (funext (\\ y => sym (uniq_h c (fold (Arr' a c) alg) alg (foldCommutes (Arr' a c) alg) (g y))))\n\n-- Induction from initiality\n\npAlg : {d : Desc} -> {0 p : x -> Type} -> (alg : qpf d x -<> x) ->\n (step : (1 w : Sigma0 (qpf d x) (lift d p)) -> p (alg (fst w))) ->\n qpf d (Sigma0 x p) -<> Sigma0 x p\npAlg alg step y = let z = dist d y in alg (fst z) # step z\n\n0 fstCommutes : (d : Desc) -> {0 p : x -> Type} -> {alg : qpf d x -<> x} ->\n {step : (1 w : Sigma0 (qpf d x) (lift d p)) -> p (alg (fst w))} ->\n morphism d (pAlg {d} {p} alg step) alg Sigma0.fst\nfstCommutes d z = lcong alg (distfst d z)\n\npublic export\ninduction : {d : Desc} -> {0 p : W d -> Type} ->\n (step : (1 w : Sigma0 (qpf d (W d)) (lift d p)) -> p (Con (fst w))) ->\n (1 w : W d) -> p w\ninduction step w =\n let\n h : W d -<> Sigma0 (W d) p\n h = fold d (pAlg Con step)\n 0 eq : (w : W d) -> fst (h w) = w\n eq w = trans (uniq Con (\\w => fst (h w)) (\\ y => morphism_comp Con (pAlg Con step) Con (foldCommutes d (pAlg Con step)) (fstCommutes {alg = Con} {step} d) y) w) (sym (foldCon_id w))\n in replace {x = fst (h w)} {p = p} (eq w) (snd (h w))\n", "meta": {"hexsha": "58cccfe1bd8430ba382500af44ac67729a05ecae", "size": 12317, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "QPF.idr", "max_stars_repo_name": "g-nakov/quantitative-poly", "max_stars_repo_head_hexsha": "7602304f9e85b2a4abf1db08328d3ea302c854da", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "QPF.idr", "max_issues_repo_name": "g-nakov/quantitative-poly", "max_issues_repo_head_hexsha": "7602304f9e85b2a4abf1db08328d3ea302c854da", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "QPF.idr", "max_forks_repo_name": "g-nakov/quantitative-poly", "max_forks_repo_head_hexsha": "7602304f9e85b2a4abf1db08328d3ea302c854da", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6193771626, "max_line_length": 185, "alphanum_fraction": 0.5307298855, "num_tokens": 4984, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.5369113432257235}} {"text": "---\npandoc-minted:\n language: idris\n---\n\n= Bathroom Security\n\n[Link](https://adventofcode.com/2016/day/2)\n\nYou arrive at *Easter Bunny Headquarters* under cover of darkness. However, you\nleft in such a rush that you forgot to use the bathroom! Fancy office buildings\nlike this one usually have keypad locks on their bathrooms, so you search the\nfront desk for the code.\n\n\"In order to improve security,\" the document you find says, \"bathroom codes will\nno longer be written down. Instead, please memorize and follow the procedure\nbelow to access the bathrooms.\"\n\nThe document goes on to explain that each button to be pressed can be found by\nstarting on the previous button and moving to adjacent buttons on the keypad:\n`U` moves up, `D` moves down, `L` moves left, and `R` moves right. Each line of\ninstructions corresponds to one button, starting at the previous button (or, for\nthe first line, *the \"5\" button*); press whatever button you're on at the end of\neach line. If a move doesn't lead to a button, ignore it.\n\nYou can't hold it much longer, so you decide to figure out the code as you walk\nto the bathroom. You picture a keypad like this:\n\n```text\n1 2 3\n4 5 6\n7 8 9\n```\n\nSuppose your instructions are:\n\n```text\nULL\nRRDDD\nLURDL\nUUUUD\n```\n\n- You start at \"5\" and move up (to \"2\"), left (to \"1\"), and left (you can't, and\n stay on \"1\"), so the first button is `1`.\n- Starting from the previous button (\"1\"), you move right twice (to \"3\") and\n then down three times (stopping at \"9\" after two moves and ignoring the\n third), ending up with `9`.\n- Continuing from \"9\", you move left, up, right, down, and left, ending with\n `8`.\n- Finally, you move up four times (stopping at \"2\"), then down once, ending with\n `5`.\n\nSo, in this example, the bathroom code is `1985`.\n\nYour puzzle input is the instructions from the document you found at the front\ndesk.\n\n\n== Module Declaration and Imports\n\n> ||| Day 2: Bathroom Security\n> module Data.Advent.Day02\n>\n> import public Data.Advent.Day\n> import public Data.Ix\n>\n> import Data.Vect\n>\n> import public Lightyear\n> import public Lightyear.Char\n> import public Lightyear.Strings\n\n\n== Data Types\n\n> %access public export\n>\n> ||| Up, down, left or right.\n> data Instruction = ||| Up\n> U\n> | ||| Down\n> D\n> | ||| Left\n> L\n> | ||| Right\n> R\n>\n> ||| A single digit, i.e. a number strictly less than ten.\n> Digit : Type\n> Digit = Fin 10\n>\n> implementation Show Digit where\n> show = show . finToInteger\n>\n> implementation [showDigits] Show (List Digit) where\n> show = concatMap show\n>\n> ||| A pair of coordinates on the keypad, `(x, y)`.\n> Coordinates : Type\n> Coordinates = (Fin 3, Fin 3)\n\n\\newpage\n\n\n== Parsers\n\n> %access export\n>\n> up : Parser Instruction\n> up = char 'U' *> pure U \"up\"\n>\n> down : Parser Instruction\n> down = char 'D' *> pure D \"down\"\n>\n> left : Parser Instruction\n> left = char 'L' *> pure L \"left\"\n>\n> right : Parser Instruction\n> right = char 'R' *> pure R \"right\"\n>\n> instruction : Parser Instruction\n> instruction = up <|> down <|> left <|> right \"up, down, left or right\"\n>\n> partial instructions : Parser (List Instruction)\n> instructions = some instruction <* (skip endOfLine <|> eof)\n\n\n== Part One\n\n\\begin{quote}\n What is the bathroom code?\n\\end{quote}\n\n> namespace PartOne\n>\n> ||| A keypad like this:\n> |||\n> ||| ```\n> ||| 1 2 3\n> ||| 4 5 6\n> ||| 7 8 9\n> ||| ```\n> keypad : Vect 3 (Vect 3 Digit)\n> keypad = [ [1, 2, 3],\n> [4, 5, 6],\n> [7, 8, 9] ]\n>\n> move : Coordinates -> Instruction -> Coordinates\n> move (x, y) U = (x, pred y)\n> move (x, y) D = (x, succ y)\n> move (x, y) L = (pred x, y)\n> move (x, y) R = (succ x, y)\n\n\\newpage\n\n> button : Coordinates -> List Instruction -> (Coordinates, Digit)\n> button loc@(x, y) [] = (loc, index x (index y keypad))\n> button loc (i :: is) = button (move loc i) is\n>\n> partial partOne : List (List Instruction) -> String\n> partOne = show @{showDigits} . go ((1,1), [])\n> where\n> go : (Coordinates, List Digit) -> List (List Instruction) -> List Digit\n> go (_, ds) [] = reverse ds\n> go (loc, ds) (is :: iis) = let (loc', d) = PartOne.button loc is in\n> go (loc', d :: ds) iis\n>\n> namespace PartOne\n>\n> ||| ```idris example\n> ||| example\n> ||| ```\n> partial example : String\n> example = fromEither $ partOne <$>\n> parse (some instructions) \"ULL\\nRRDDD\\nLURDL\\nUUUUD\"\n\n\n== Part Two\n\nYou finally arrive at the bathroom (it's a several minute walk from the lobby so\nvisitors can behold the many fancy conference rooms and water coolers on this\nfloor) and go to punch in the code. Much to your bladder's dismay, the keypad is\nnot at all like you imagined it. Instead, you are confronted with the result of\nhundreds of man-hours of bathroom-keypad-design meetings:\n\n```text\n 1\n 2 3 4\n5 6 7 8 9\n A B C\n D\n```\n\nYou still start at \"5\" and stop when you're at an edge, but given the same\ninstructions as above, the outcome is very different:\n\n- You start at \"5\" and don't move at all (up and left are both edges), ending at\n `5`.\n- Continuing from \"5\", you move right twice and down three times (through \"6\",\n \"7\", \"B\", \"D\", \"D\"), ending at `D`.\n- Then, from \"D\", you move five more times (through \"D\", \"B\", \"C\", \"C\", \"B\"),\n ending at `B`.\n- Finally, after five more moves, you end at `3`.\n\n\\newpage\n\nSo, given the actual keypad layout, the code would be `5DB3`.\n\n\\begin{quote}\n Using the same instructions in your puzzle input, what is the correct\n \\textit{bathroom code}?\n\\end{quote}\n\n> namespace PartTwo\n>\n> keypad : Vect 5 (n ** Vect n Char)\n> keypad = [ (1 ** ['1'])\n> , (3 ** ['2', '3', '4'])\n> , (5 ** ['5', '6', '7', '8', '9'])\n> , (3 ** ['A', 'B', 'C'])\n> , (1 ** ['D'])\n> ]\n>\n> -- NOTE: This will wrap at the bounds, which might be unexpected.\n> partial convert : (n : Nat) -> Fin m -> Fin n\n> convert (S j) fm {m} =\n> let delta = half $ if S j > m\n> then S j `minus` m\n> else m `minus` S j in\n> the (Fin (S j)) $ fromNat $ finToNat fm `f` delta\n> where\n> f : Nat -> Nat -> Nat\n> f = if S j > m then plus else minus\n> partial half : Nat -> Nat\n> half = flip div 2\n>\n> canMoveVertically : (Fin (S k), Fin 5) -> Instruction -> Bool\n> canMoveVertically (x, y) i with ((finToNat x, finToNat y))\n> canMoveVertically (x, y) U | (col, row) =\n> case row of\n> Z => False\n> S Z => col == 1\n> S (S Z) => inRange (1,3) col\n> _ => True\n> canMoveVertically (x, y) D | (col, row) =\n> case row of\n> S (S Z) => inRange (1,3) col\n> S (S (S Z)) => col == 1\n> S (S (S (S Z))) => False\n> _ => True\n> canMoveVertically _ _ | _ = True\n\n\\newpage\n\n> partial move : (Fin (S k), Fin 5) -> Instruction ->\n> ((n ** Fin n), Fin 5)\n> move (x, y) U = if canMoveVertically (x, y) U\n> then let n = fst (index (pred y) keypad) in\n> ((n ** convert n x), pred y)\n> else ((_ ** x), y)\n> move (x, y) D = if canMoveVertically (x, y) D\n> then let n = fst (index (succ y) keypad) in\n> ((n ** convert n x), succ y)\n> else ((_ ** x), y)\n> move (x, y) L = let n = fst (index y keypad) in\n> ((n ** convert n (pred x)), y)\n> move (x, y) R = let n = fst (index y keypad) in\n> ((n ** convert n (succ x)), y)\n>\n> partial button : (Fin (S k), Fin 5) -> List Instruction ->\n> (((n ** Fin n), Fin 5), Char)\n> button loc@(x, y) [] =\n> let (n ** row) = index y PartTwo.keypad\n> xx = convert n x in\n> (((n ** xx), y), index xx row)\n> button loc (i :: is) =\n> let ((S _ ** x), y) = move loc i in\n> button (x, y) is\n>\n> partial partTwo : List (List Instruction) -> String\n> partTwo = go (((5 ** 0),2), [])\n> where\n> partial go : (((n ** Fin n), Fin 5), List Char) ->\n> List (List Instruction) -> String\n> go (_, cs) [] = pack $ reverse cs\n> go (loc, cs) (is :: iis) =\n> let ((S k ** xx), y) = loc\n> (loc', c) = PartTwo.button (xx, y) {k=k} is in\n> go (loc', c :: cs) iis\n>\n> namespace PartTwo\n>\n> ||| ```idris example\n> ||| PartTwo.example\n> ||| ```\n> partial example : String\n> example = fromEither $ partTwo <$>\n> parse (some instructions) \"ULL\\nRRDDD\\nLURDL\\nUUUUD\"\n\n\n== Main\n\n> namespace Main\n>\n> partial main : IO ()\n> main = runDay $ MkDay 2 (some instructions)\n> (pure . partOne)\n> (pure . partTwo)\n", "meta": {"hexsha": "a2a315b258e5b285f0400eb632c49860f722198c", "size": 9065, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/Data/Advent/Day02.lidr", "max_stars_repo_name": "yurrriq/advent-of-code", "max_stars_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-11-04T10:32:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-05T07:36:22.000Z", "max_issues_repo_path": "src/Data/Advent/Day02.lidr", "max_issues_repo_name": "yurrriq/aoc19", "max_issues_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Advent/Day02.lidr", "max_forks_repo_name": "yurrriq/aoc19", "max_forks_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-26T19:27:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-26T19:27:21.000Z", "avg_line_length": 29.2419354839, "max_line_length": 80, "alphanum_fraction": 0.5503585218, "num_tokens": 2714, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.5368558391224239}} {"text": "module Prelude.Interfaces\n\nimport Builtin\nimport Prelude.Basics\nimport Prelude.EqOrd\nimport Prelude.Num\nimport Prelude.Ops\n\n%default total\n\n-------------\n-- ALGEBRA --\n-------------\n\n||| Sets equipped with a single binary operation that is associative. Must\n||| satisfy the following laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\npublic export\ninterface Semigroup ty where\n (<+>) : ty -> ty -> ty\n\n||| Sets equipped with a single binary operation that is associative, along with\n||| a neutral element for that binary operation. Must satisfy the following\n||| laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\n||| + Neutral for `<+>`:\n||| forall a, a <+> neutral == a\n||| forall a, neutral <+> a == a\npublic export\ninterface Semigroup ty => Monoid ty where\n neutral : ty\n\npublic export\nSemigroup () where\n _ <+> _ = ()\n\npublic export\nMonoid () where\n neutral = ()\n\npublic export\nSemigroup Ordering where\n LT <+> _ = LT\n GT <+> _ = GT\n EQ <+> o = o\n\npublic export\nMonoid Ordering where\n neutral = EQ\n\npublic export\nSemigroup b => Semigroup (a -> b) where\n (f <+> g) x = f x <+> g x\n\npublic export\nMonoid b => Monoid (a -> b) where\n neutral _ = neutral\n\n\nexport\nshiftL : Int -> Int -> Int\nshiftL = prim__shl_Int\n\nexport\nshiftR : Int -> Int -> Int\nshiftR = prim__shr_Int\n\n----------------------------------------------\n-- FUNCTOR, APPLICATIVE, ALTERNATIVE, MONAD --\n----------------------------------------------\n\n||| Functors allow a uniform action over a parameterised type.\n||| @ f a parameterised type\npublic export\ninterface Functor f where\n ||| Apply a function across everything of type 'a' in a parameterised type\n ||| @ f the parameterised type\n ||| @ func the function to apply\n map : (func : a -> b) -> f a -> f b\n\n||| An infix alias for `map`, applying a function across everything of type 'a'\n||| in a parameterised type.\n||| @ f the parameterised type\n||| @ func the function to apply\npublic export\n(<$>) : Functor f => (func : a -> b) -> f a -> f b\n(<$>) func x = map func x\n\n||| Run something for effects, replacing the return value with a given parameter.\npublic export\n(<$) : Functor f => b -> f a -> f b\n(<$) b = map (const b)\n\n||| Flipped version of `<$`.\npublic export\n($>) : Functor f => f a -> b -> f b\n($>) fa b = map (const b) fa\n\n||| Run something for effects, throwing away the return value.\npublic export\nignore : Functor f => f a -> f ()\nignore = map (const ())\n\npublic export\ninterface Functor f => Applicative f where\n pure : a -> f a\n (<*>) : f (a -> b) -> f a -> f b\n\npublic export\n(<*) : Applicative f => f a -> f b -> f a\na <* b = map const a <*> b\n\npublic export\n(*>) : Applicative f => f a -> f b -> f b\na *> b = map (const id) a <*> b\n\n%allow_overloads pure\n%allow_overloads (<*)\n%allow_overloads (*>)\n\npublic export\ninterface Applicative f => Alternative f where\n empty : f a\n (<|>) : f a -> f a -> f a\n\npublic export\ninterface Applicative m => Monad m where\n ||| Also called `bind`.\n (>>=) : m a -> (a -> m b) -> m b\n\n ||| Also called `flatten` or mu.\n join : m (m a) -> m a\n\n -- default implementations\n (>>=) x f = join (f <$> x)\n join x = x >>= id\n\n%allow_overloads (>>=)\n\n||| `guard a` is `pure ()` if `a` is `True` and `empty` if `a` is `False`.\npublic export\nguard : Alternative f => Bool -> f ()\nguard x = if x then pure () else empty\n\n||| Conditionally execute an applicative expression.\npublic export\nwhen : Applicative f => Bool -> Lazy (f ()) -> f ()\nwhen True f = f\nwhen False f = pure ()\n\n---------------------------\n-- FOLDABLE, TRAVERSABLE --\n---------------------------\n\n||| The `Foldable` interface describes how you can iterate over the elements in\n||| a parameterised type and combine the elements together, using a provided\n||| function, into a single result.\n||| @ t The type of the 'Foldable' parameterised type.\npublic export\ninterface Foldable (t : Type -> Type) where\n ||| Successively combine the elements in a parameterised type using the\n ||| provided function, starting with the element that is in the final position\n ||| i.e. the right-most position.\n ||| @ func The function used to 'fold' an element into the accumulated result\n ||| @ init The starting value the results are being combined into\n ||| @ input The parameterised type\n foldr : (func : elem -> acc -> acc) -> (init : acc) -> (input : t elem) -> acc\n\n ||| The same as `foldr` but begins the folding from the element at the initial\n ||| position in the data structure i.e. the left-most position.\n ||| @ func The function used to 'fold' an element into the accumulated result\n ||| @ init The starting value the results are being combined into\n ||| @ input The parameterised type\n foldl : (func : acc -> elem -> acc) -> (init : acc) -> (input : t elem) -> acc\n foldl f z t = foldr (flip (.) . flip f) id t z\n\n||| Similar to `foldl`, but uses a function wrapping its result in a `Monad`.\n||| Consequently, the final value is wrapped in the same `Monad`.\npublic export\nfoldlM : (Foldable t, Monad m) => (funcM: a -> b -> m a) -> (init: a) -> (input: t b) -> m a\nfoldlM fm a0 = foldl (\\ma,b => ma >>= flip fm b) (pure a0)\n\n||| Combine each element of a structure into a monoid.\npublic export\nconcat : (Foldable t, Monoid a) => t a -> a\nconcat = foldr (<+>) neutral\n\n||| Combine into a monoid the collective results of applying a function to each\n||| element of a structure.\npublic export\nconcatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m\nconcatMap f = foldr ((<+>) . f) neutral\n\n||| The conjunction of all elements of a structure containing lazy boolean\n||| values. `and` short-circuits from left to right, evaluating until either an\n||| element is `False` or no elements remain.\npublic export\nand : Foldable t => t (Lazy Bool) -> Bool\nand = foldl (&&) True\n\n||| The disjunction of all elements of a structure containing lazy boolean\n||| values. `or` short-circuits from left to right, evaluating either until an\n||| element is `True` or no elements remain.\npublic export\nor : Foldable t => t (Lazy Bool) -> Bool\nor = foldl (||) False\n\n||| The disjunction of the collective results of applying a predicate to all\n||| elements of a structure. `any` short-circuits from left to right.\npublic export\nany : Foldable t => (a -> Bool) -> t a -> Bool\nany p = foldl (\\x,y => x || p y) False\n\n||| The disjunction of the collective results of applying a predicate to all\n||| elements of a structure. `all` short-circuits from left to right.\npublic export\nall : Foldable t => (a -> Bool) -> t a -> Bool\nall p = foldl (\\x,y => x && p y) True\n\n||| Add together all the elements of a structure.\npublic export\nsum : (Foldable t, Num a) => t a -> a\nsum = foldr (+) 0\n\n||| Add together all the elements of a structure.\n||| Same as `sum` but tail recursive.\nexport\nsum' : (Foldable t, Num a) => t a -> a\nsum' = foldl (+) 0\n\n||| Multiply together all elements of a structure.\npublic export\nproduct : (Foldable t, Num a) => t a -> a\nproduct = foldr (*) 1\n\n||| Multiply together all elements of a structure.\n||| Same as `product` but tail recursive.\nexport\nproduct' : (Foldable t, Num a) => t a -> a\nproduct' = foldl (*) 1\n\n||| Map each element of a structure to a computation, evaluate those\n||| computations and discard the results.\npublic export\ntraverse_ : (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()\ntraverse_ f = foldr ((*>) . f) (pure ())\n\n||| Evaluate each computation in a structure and discard the results.\npublic export\nsequence_ : (Foldable t, Applicative f) => t (f a) -> f ()\nsequence_ = foldr (*>) (pure ())\n\n||| Like `traverse_` but with the arguments flipped.\npublic export\nfor_ : (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()\nfor_ = flip traverse_\n\n||| Fold using Alternative.\n|||\n||| If you have a left-biased alternative operator `<|>`, then `choice` performs\n||| left-biased choice from a list of alternatives, which means that it\n||| evaluates to the left-most non-`empty` alternative.\n|||\n||| If the list is empty, or all values in it are `empty`, then it evaluates to\n||| `empty`.\n|||\n||| Example:\n|||\n||| ```\n||| -- given a parser expression like:\n||| expr = literal <|> keyword <|> funcall\n|||\n||| -- choice lets you write this as:\n||| expr = choice [literal, keyword, funcall]\n||| ```\n|||\n||| Note: In Haskell, `choice` is called `asum`.\npublic export\nchoice : (Foldable t, Alternative f) => t (f a) -> f a\nchoice = foldr (<|>) empty\n\n||| A fused version of `choice` and `map`.\npublic export\nchoiceMap : (Foldable t, Alternative f) => (a -> f b) -> t a -> f b\nchoiceMap f = foldr (\\e, a => f e <|> a) empty\n\npublic export\ninterface (Functor t, Foldable t) => Traversable (t : Type -> Type) where\n ||| Map each element of a structure to a computation, evaluate those\n ||| computations and combine the results.\n traverse : Applicative f => (a -> f b) -> t a -> f (t b)\n\n||| Evaluate each computation in a structure and collect the results.\npublic export\nsequence : (Traversable t, Applicative f) => t (f a) -> f (t a)\nsequence = traverse id\n\n||| Like `traverse` but with the arguments flipped.\npublic export\nfor : (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)\nfor = flip traverse\n\n", "meta": {"hexsha": "22a1107d2fae3d5c9aba807595d51448360dd3c7", "size": 9219, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/prelude/Prelude/Interfaces.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/libs/prelude/Prelude/Interfaces.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/libs/prelude/Prelude/Interfaces.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.0293159609, "max_line_length": 92, "alphanum_fraction": 0.6322811585, "num_tokens": 2672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.7057850154599563, "lm_q1q2_score": 0.5368558326594658}} {"text": "data Vect : Nat -> Type -> Type where\n Nil : Vect Z a\n (::) : a -> Vect k a -> Vect (S k) a\n\n%name Vect xs, ys, zs\n\nzipWith : (a -> b -> c) -> Vect n a -> Vect n b -> Vect n c\n", "meta": {"hexsha": "39c3860281816dd73f5ca44c1c52e5356166915f", "size": 183, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "examples/type-driven-development/idris/vectors.idr", "max_stars_repo_name": "bemayr/talk.developer-confidence", "max_stars_repo_head_hexsha": "af300fb7c1ea695020fcd0ddece5ec2a34b471b7", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-02-12T09:28:28.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-12T09:28:28.000Z", "max_issues_repo_path": "examples/type-driven-development/idris/vectors.idr", "max_issues_repo_name": "bemayr/talk.developer-confidence", "max_issues_repo_head_hexsha": "af300fb7c1ea695020fcd0ddece5ec2a34b471b7", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/type-driven-development/idris/vectors.idr", "max_forks_repo_name": "bemayr/talk.developer-confidence", "max_forks_repo_head_hexsha": "af300fb7c1ea695020fcd0ddece5ec2a34b471b7", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.875, "max_line_length": 59, "alphanum_fraction": 0.4863387978, "num_tokens": 67, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8519527869325346, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.5365382319175328}} {"text": "\nmodule Determinism\n\n\n\nimport BigStep\nimport Progress\nimport Step\nimport Subst\nimport Term\nimport Equivalence\n\n\n%default total\n%access export\n\n\n------------------------------------------------------------------------------\n-- Begin: DETERMINISM OF INDUCTIVELY DEFINED SMALL-STEP AND BIG-STEP SEMANTICS\n\nstepDeterministic : (Step e1 e2) -> (Step e1 e3) ->\n e2 = e3\n-- case split in the following order: (Step e1 e2), (Step e1 e3)\nstepDeterministic {e1 = TApp _ e11} (StApp1 x) (StApp1 y) = \n cong {f = \\e => TApp e e11} $ stepDeterministic x y\n--\nstepDeterministic (StApp1 x) (StApp2 y z) = absurd $ valueIrreducible _ y x\n-- \nstepDeterministic (StApp1 x) (StBeta y) = absurd $ valueIrreducible _ VAbs x\n--\nstepDeterministic (StApp2 x z) (StApp1 y) = absurd $ valueIrreducible _ x y\n--\nstepDeterministic {e1 = TApp e11 _} (StApp2 x z) (StApp2 y w) = \n cong {f = \\e => TApp e11 e} $ stepDeterministic z w\n-- \nstepDeterministic (StApp2 x z) (StBeta y) = absurd $ valueIrreducible _ y z\n--\nstepDeterministic (StBeta x) (StApp2 y z) = absurd $ valueIrreducible _ x z\n--\nstepDeterministic (StBeta x) (StBeta y) = Refl\n--\nstepDeterministic (StFix x) (StFix y) = cong $ stepDeterministic x y\n--\nstepDeterministic (StFix x) StFixBeta = absurd $ valueIrreducible _ VAbs x\n--\nstepDeterministic StFixBeta StFixBeta = Refl\n--\nstepDeterministic (StSucc x) (StSucc y) = cong $ stepDeterministic x y\n--\nstepDeterministic (StPred x) (StPred y) = cong $ stepDeterministic x y\n--\nstepDeterministic (StPred x) StPredZero = absurd $ valueIrreducible _ VZero x\n--\nstepDeterministic (StPred x) (StPredSucc y) = absurd $ valueIrreducible _ (VSucc y) x\n--\nstepDeterministic StPredZero (StPred x) = absurd $ valueIrreducible _ VZero x\n--\nstepDeterministic StPredZero StPredZero = Refl\n--\nstepDeterministic (StPredSucc x) (StPred y) = absurd $ valueIrreducible _ (VSucc x) y\n--\nstepDeterministic (StPredSucc x) (StPredSucc y) = Refl\n--\nstepDeterministic {e1 = TIfz _ e12 e13} (StIfz x) (StIfz y) = \n cong {f = \\e => TIfz e e12 e13} $ stepDeterministic x y\n-- \nstepDeterministic (StIfz x) StIfzZero = absurd $ valueIrreducible _ VZero x\n--\nstepDeterministic (StIfz x) (StIfzSucc y) = absurd $ valueIrreducible _ (VSucc y) x\n--\nstepDeterministic StIfzZero (StIfz x) = absurd $ valueIrreducible _ VZero x\n--\nstepDeterministic StIfzZero StIfzZero = Refl\n--\nstepDeterministic (StIfzSucc x) (StIfz y) = absurd $ valueIrreducible _ (VSucc x) y\n--\nstepDeterministic (StIfzSucc x) (StIfzSucc y) = Refl\n\n\n\ntransStepDeterministic : (v2 : Value e2) -> (TransStep e1 e2) ->\n (v3 : Value e3) -> (TransStep e1 e3) ->\n e2 = e3\ntransStepDeterministic v2 (TStRefl e3) v3 (TStRefl e3) = Refl\n--\ntransStepDeterministic v2 (TStRefl e2) v3 (TStTrans x y) = \n absurd $ valueIrreducible e2 v2 x\n--\ntransStepDeterministic v2 (TStTrans x z) v3 (TStRefl e3) = \n absurd $ valueIrreducible e3 v3 x\n--\ntransStepDeterministic {e2 = e2} v2 (TStTrans x z) v3 (TStTrans y w) =\n let eq = stepDeterministic x y\n z' = replace {P = \\x => x} (cong {f = \\e => TransStep e e2} eq) z\n in transStepDeterministic v2 z' v3 w\n\n\n\n-- The following proof of the determinism of 'BigStep'\n-- relies on the equivalence of 'Step' and 'BigStep'.\nbigStepDeterministic' : (BigStep e1 e2) ->\n (BigStep e1 e3) ->\n e2 = e3\nbigStepDeterministic' x y = \n let (tst2, v2) = bigStepToTransStep x\n (tst3, v3) = bigStepToTransStep y\n in transStepDeterministic v2 tst2 v3 tst3\n\n\n\ninjectiveAbs : (TAbs e1 = TAbs e2) -> e1 = e2\ninjectiveAbs Refl = Refl\n\n\ninjectiveSucc : (TSucc e1 = TSucc e2) -> e1 = e2\ninjectiveSucc Refl = Refl\n\n\nzeroNotSucc : (TZero = TSucc _) -> Void\nzeroNotSucc Refl impossible\n\n\npairEq : a = b -> c = d -> (a, c) = (b, d)\npairEq Refl Refl = Refl\n\n\nvalueBigStepEq : Value e1 -> BigStep e1 e2 -> e1 = e2\nvalueBigStepEq VZero (BStValue _) = Refl\nvalueBigStepEq (VSucc x) (BStValue _) = Refl\nvalueBigStepEq (VSucc x) (BStSucc y) = cong $ valueBigStepEq x y\nvalueBigStepEq VAbs (BStValue _) = Refl\n\n\nbigStepDeterministic : (BigStep e1 e2) -> (BigStep e1 e3) ->\n e2 = e3\n-- case split in the following order: (BigStep e1 e2), (BigStep e1 e3)\nbigStepDeterministic (BStValue _) (BStValue _) = Refl\n--\nbigStepDeterministic (BStValue _) (BStApp z w t) impossible\n--\nbigStepDeterministic (BStValue _) (BStFix y z) impossible\n--\nbigStepDeterministic (BStValue v2) (BStSucc x) = case v2 of\n VAbs impossible\n VZero impossible\n VSucc v2' => cong $ valueBigStepEq v2' x\n-- \nbigStepDeterministic (BStValue _) (BStPredZero y) impossible\n--\nbigStepDeterministic (BStValue _) (BStPredSucc x) impossible\n--\nbigStepDeterministic (BStValue _) (BStIfzZero z w) impossible\n--\nbigStepDeterministic (BStValue _) (BStIfzSucc w s) impossible\n--\nbigStepDeterministic (BStApp w t u) (BStValue _) impossible\n--\nbigStepDeterministic {e2 = e2} (BStApp w t u) (BStApp z s v) = \n let ih1 = injectiveAbs $ bigStepDeterministic w z\n ih2 = bigStepDeterministic t s\n peq = pairEq ih1 ih2\n u' = replace {P = \\x => BigStep (subst (snd x) First (fst x)) e2} peq u\n in bigStepDeterministic u' v\n--\nbigStepDeterministic (BStFix z w) (BStValue v3) impossible\n--\nbigStepDeterministic {e2 = e2} (BStFix z w) (BStFix y s) = \n let ih = injectiveAbs $ bigStepDeterministic z y\n w' = replace {P = \\x => BigStep (subst (TFix (TAbs x)) First x) e2} ih w\n in bigStepDeterministic w' s\n--\nbigStepDeterministic (BStSucc x) (BStValue v3) = case v3 of\n VAbs impossible\n VZero impossible\n VSucc v3' => cong . sym $ valueBigStepEq v3' x\n--\nbigStepDeterministic (BStSucc x) (BStSucc y) = cong $ bigStepDeterministic x y\n--\nbigStepDeterministic (BStPredZero z) (BStValue _) impossible\n--\nbigStepDeterministic (BStPredZero z) (BStPredZero y) = Refl\n--\nbigStepDeterministic (BStPredZero z) (BStPredSucc x) = \n let ih = bigStepDeterministic z x\n in absurd $ zeroNotSucc ih\n--\nbigStepDeterministic (BStPredSucc x) (BStValue _) impossible\n--\nbigStepDeterministic (BStPredSucc x) (BStPredZero z) = \n let ih = bigStepDeterministic x z\n in absurd . zeroNotSucc $ sym ih\n--\nbigStepDeterministic (BStPredSucc x) (BStPredSucc y) = \n injectiveSucc $ bigStepDeterministic x y\n--\nbigStepDeterministic (BStIfzZero w s) (BStValue _) impossible\n--\nbigStepDeterministic (BStIfzZero w s) (BStIfzZero y z) = bigStepDeterministic s z\n--\nbigStepDeterministic (BStIfzZero w s) (BStIfzSucc z t) = \n let ih = bigStepDeterministic w z\n in absurd $ zeroNotSucc ih\n--\nbigStepDeterministic (BStIfzSucc s t) (BStValue _) impossible\n--\nbigStepDeterministic (BStIfzSucc s t) (BStIfzZero y z) = \n let ih = bigStepDeterministic s y\n in absurd . zeroNotSucc $ sym ih\n--\nbigStepDeterministic (BStIfzSucc s t) (BStIfzSucc z w) = bigStepDeterministic t w\n\n-- End: DETERMINISM OF INDUCTIVELY DEFINED SMALL-STEP AND BIG-STEP SEMANTICS\n----------------------------------------------------------------------------\n\n\n\n----------------------------------------------------------------------------------\n-- Begin: VERY RESTRICTED FROM OF DETERMINISM FOR CO-INDUCTIVELY DEFINED SEMANTICS\n\n-- The coinductive relation 'CoBigStep' is not deterministic as, for example,\n-- the term 'omega' can evaluate to anything. However, the following form of\n-- determinism holds for terminating terms:\n-- (cf. Lemma 35 in \"Coinductive big-step operational semantics\" by \n-- X. Leroy and H. Grall)\ncoBigStepDeterministic' : BigStep e1 e2 -> CoBigStep e1 e3 -> e2 = e3\n--\ncoBigStepDeterministic' (BStValue v) cbst = coBigStepValueIrreducible cbst v\n--\ncoBigStepDeterministic' (BStApp bst1 bst2 bst3) cbst = case cbst of\n (CoBStValue v) impossible\n (CoBStApp cbst1 cbst2 cbst3) =>\n case coBigStepDeterministic' bst1 cbst1 of\n Refl => case coBigStepDeterministic' bst2 cbst2 of\n Refl => case coBigStepDeterministic' bst3 cbst3 of\n Refl => Refl\n--\ncoBigStepDeterministic' (BStFix bst1 bst2) cbst = case cbst of\n (CoBStValue v) impossible\n (CoBStFix cbst1 cbst2) => \n case coBigStepDeterministic' bst1 cbst1 of\n Refl => case coBigStepDeterministic' bst2 cbst2 of\n Refl => Refl\n--\ncoBigStepDeterministic' (BStSucc bst) cbst = case cbst of\n (CoBStValue (VSucc v)) => cong . sym $ bigStepValueIrreducible bst v\n (CoBStSucc cbst) => case coBigStepDeterministic' bst cbst of\n Refl => Refl\n--\ncoBigStepDeterministic' (BStPredZero bst) cbst = case cbst of \n (CoBStValue v) impossible\n (CoBStPredZero cbst) => case coBigStepDeterministic' bst cbst of\n Refl => Refl\n (CoBStPredSucc cbst) => case coBigStepDeterministic' bst cbst of\n Refl impossible\n--\ncoBigStepDeterministic' (BStPredSucc bst) cbst = case cbst of\n (CoBStValue v) impossible\n (CoBStPredZero cbst) => case coBigStepDeterministic' bst cbst of\n Refl impossible\n (CoBStPredSucc cbst) => case coBigStepDeterministic' bst cbst of\n Refl => Refl\n--\ncoBigStepDeterministic' (BStIfzZero bst1 bst2) cbst = case cbst of\n (CoBStValue v) impossible\n (CoBStIfzZero cbst1 cbst2) => coBigStepDeterministic' bst2 cbst2\n (CoBStIfzSucc cbst1 cbst2) => case coBigStepDeterministic' bst1 cbst1 of\n Refl impossible\n--\ncoBigStepDeterministic' (BStIfzSucc bst1 bst2) cbst = case cbst of\n (CoBStValue v) impossible\n (CoBStIfzZero cbst1 cbst2) => case coBigStepDeterministic' bst1 cbst1 of\n Refl impossible\n (CoBStIfzSucc cbst1 cbst2) => coBigStepDeterministic' bst2 cbst2\n\n\n-- An analogous statement holds for terminating terms and the coinductive \n-- relation 'CoTransStep', which is generally not deterministic either:\ncoTransStepDeterministic' : Value e2 -> TransStep e1 e2 -> \n Value e3 -> CoTransStep e1 e3 -> \n e2 = e3\ncoTransStepDeterministic' v2 (TStRefl e1) v3 (CoTStRefl e1) = Refl\ncoTransStepDeterministic' v2 (TStRefl e1) v3 (CoTStTrans st _) = \n absurd $ valueIrreducible _ v2 st\ncoTransStepDeterministic' v2 (TStTrans st tst) v3 (CoTStRefl e1) = \n absurd $ valueIrreducible _ v3 st\ncoTransStepDeterministic' v2 (TStTrans st1 tst) v3 (CoTStTrans st2 ctst) =\n case stepDeterministic st1 st2 of\n Refl => coTransStepDeterministic' v2 tst v3 ctst\n\n\n-- The following statement can also be seen as a restricted\n-- from of determinism of the 'CoTransStep' relation given\n-- that 'TransStep' terminates:\ncoTransStepExtends : TransStep e1 e2 -> Value e2 -> \n CoTransStep e1 e3 -> CoTransStep e3 e2\ncoTransStepExtends (TStRefl e2) v (CoTStRefl e2) = CoTStRefl e2\ncoTransStepExtends (TStRefl e2) v (CoTStTrans st ctst) = \n absurd $ valueIrreducible _ v st\ncoTransStepExtends (TStTrans st tst) v (CoTStRefl e1) =\n CoTStTrans st $ transToCoTrans tst\ncoTransStepExtends (TStTrans st1 tst) v (CoTStTrans st2 ctst) = \n case stepDeterministic st1 st2 of\n Refl => coTransStepExtends tst v ctst\n\n\ncoTransStepExtends' : TransStep e1 e2 -> Value e2 -> \n CoTransStep e1 e3 -> CoTransStep e1 e2\ncoTransStepExtends' tst v ctst = coTransStepTransitive ctst $ coTransStepExtends tst v ctst\n\n\n-- Another result that relies on \n-- (a) irreducibility of values and\n-- (b) determinism of the 'Step' relation:\ncoTransStepInterpolates : CoTransStep e1 e3 -> Value e3 -> Step e1 e2 -> CoTransStep e2 e3\ncoTransStepInterpolates (CoTStRefl e1) v st = absurd $ valueIrreducible _ v st\ncoTransStepInterpolates (CoTStTrans st' ctst) v st = \n let eq = stepDeterministic st st'\n in rewrite eq in ctst\n\n-- End: VERY RESTRICTED FROM OF DETERMINISM FOR CO-INDUCTIVELY DEFINED SEMANTICS\n--------------------------------------------------------------------------------\n\n\n\n-----------------------------------------------------------\n-- Begin: DIVERGENCE OF TERM 'Subst.omega' UNDER SMALL-STEP\n\n-- Term 'omega' steps to itself in one step:\nstepOmega : Step Subst.omega Subst.omega\nstepOmega = StFixBeta\n\n\n-- That 'omega' steps to itself under the reflexive,\n-- transitive closure of 'Step' is trivial:\ntransStepOmega : TransStep Subst.omega Subst.omega\ntransStepOmega = TStRefl _\n\n\n-- By determinism of 'Step', the term 'omega' steps to nothing but itself:\nstepOmegaOnly : Step Subst.omega e -> e = Subst.omega \nstepOmegaOnly st = stepDeterministic st stepOmega\n\n\n-- To extend the previous result 'stepOmegaOnly' to the transitive closure\n-- of the 'Step' relation, an indexed version of 'TransStep' is needed:\ndata TransStepN : Nat -> Term [] t -> Term [] t -> Type where\n TStNRefl : (e : Term [] t) -> TransStepN Z e e\n TStNTrans : {e : Term [] t} -> {e' : Term [] t} -> {e'' : Term [] t} ->\n Step e e' -> TransStepN n e' e'' -> TransStepN (S n) e e''\n\n\ntransStepFromN : TransStepN n e1 e2 -> TransStep e1 e2\ntransStepFromN (TStNRefl e1) = TStRefl e1\ntransStepFromN (TStNTrans st tstn) = TStTrans st (transStepFromN tstn)\n\n\ntransStepToN : TransStep e1 e2 -> (n : Nat ** TransStepN n e1 e2)\ntransStepToN (TStRefl e1) = (Z ** TStNRefl e1)\ntransStepToN (TStTrans st tst) = let (m ** tstn) = transStepToN tst\n in ((S m) ** TStNTrans st tstn)\n\n\ntransStepNOmegaOnly : (n : Nat) -> TransStepN n Subst.omega e -> e = Subst.omega\ntransStepNOmegaOnly Z (TStNRefl _) = Refl\ntransStepNOmegaOnly {e} (S k) (TStNTrans st tstk) = \n let eq = stepOmegaOnly st \n tstk' = replace {P = \\x => TransStepN k x e} eq tstk\n in transStepNOmegaOnly k tstk'\n\n\n-- Finally, the fact that 'omega' only steps to itself is proven\n-- by appealing to the indexed version of the transitive closure:\n-- (An induction argument analogous to the one in 'transStepNOmegaOnly'\n-- is not accepted by Idris' totality checker. Induction would proceed on\n-- the structure of the 'TransStep omega e' argument, and the induction\n-- hypothesis would be applied to the second argument of the 'TStTrans'\n-- constructor, which would again have the type 'TransStep omega e' but\n-- only after rewriting with the equation obtained from 'stepOmegaOnly'.)\ntransStepOmegaOnly : TransStep Subst.omega e -> e = Subst.omega\ntransStepOmegaOnly tst = let (n ** tstn) = transStepToN tst\n in transStepNOmegaOnly n tstn\n\n\ntransStepDivergenceOmega : TransStep Subst.omega e -> (Value e -> Void)\ntransStepDivergenceOmega tst v = let eq = transStepOmegaOnly tst\n in case (replace {P = \\x => Value x} eq v) of\n VZero impossible\n (VSucc _) impossible\n VAbs impossible\n\n\n-- Instead of diverging, the term 'omega' can evaluate to anything\n-- under the coinductive relation 'CoTransStep'. Hence evaluation\n-- under 'CoTransStep' is not deterministic:\ncoTransStepOmegaAny : CoTransStep Subst.omega e\ncoTransStepOmegaAny = CoTStTrans StFixBeta (coTransStepOmegaAny)\n\n-- End: DIVERGENCE OF TERM 'Subst.omega' UNDER SMALL-STEP\n---------------------------------------------------------\n\n\n\n---------------------------------------------------------\n-- Begin: DIVERGENCE OF TERM 'Subst.omega' UNDER BIG-STEP\n\n-- The following straightforward approach to proving\n-- that 'omega' diverges does not pass Idris' totality\n-- checker because of the rewriting of 'bst' in the\n-- induction step:\n--\n-- divergenceOmega : BigStep Subst.omega e -> Void\n-- divergenceOmega {e = _} (BStValue v) = case v of\n-- VZero impossible\n-- (VSucc _) impossible\n-- VAbs impossible\n-- divergenceOmega {e = e} (BStFix (BStValue v) bst) =\n-- let bst' = replace {P = \\x => BigStep x e} substOmega bst\n-- in divergenceOmega bst'\n\n\n-- To prove that 'omega' diverges under big-step semantics,\n-- an indexed version of the 'BigStep' relation is introduced:\ndata BigStepN : Nat -> Term [] t -> (y: Term [] t) -> Type where\n BStValueN : (v : Value e) -> BigStepN Z e e\n --\n BStAppN : BigStepN k e1 (TAbs e1') ->\n BigStepN m e2 e2' ->\n BigStepN n (subst e2' First e1') e ->\n BigStepN (S $ k+m+n) (TApp e1 e2) e\n -- \n BStFixN : BigStepN m e (TAbs e') ->\n BigStepN n (subst (TFix (TAbs e')) First e') e'' ->\n BigStepN (S $ m+n) (TFix e) e''\n -- \n BStSuccN : BigStepN n e e' ->\n BigStepN (S n) (TSucc e) (TSucc e')\n -- \n BStPredZeroN : BigStepN n e TZero ->\n BigStepN (S n) (TPred e) TZero\n -- \n BStPredSuccN : BigStepN n e (TSucc e') ->\n BigStepN (S n) (TPred e) e'\n -- \n BStIfzZeroN : BigStepN m e1 TZero ->\n BigStepN n e2 e ->\n BigStepN (S $ m+n) (TIfz e1 e2 _) e\n -- \n BStIfzSuccN : BigStepN m e1 (TSucc _) ->\n BigStepN n e3 e ->\n BigStepN (S $ m+n) (TIfz e1 _ e3) e\n\n\nbigStepToN : BigStep e1 e2 -> (n : Nat ** BigStepN n e1 e2)\nbigStepToN (BStValue v) = (Z ** BStValueN v)\n--\nbigStepToN (BStApp bst1 bst2 bst3) = let (n1 ** bstn1) = bigStepToN bst1\n (n2 ** bstn2) = bigStepToN bst2\n (n3 ** bstn3) = bigStepToN bst3\n in ((S $ n1+n2+n3) ** BStAppN bstn1 bstn2 bstn3)\n-- \nbigStepToN (BStFix bst1 bst2) = let (n1 ** bstn1) = bigStepToN bst1\n (n2 ** bstn2) = bigStepToN bst2\n in ((S $ n1+n2) ** BStFixN bstn1 bstn2) \n-- \nbigStepToN (BStSucc bst) = let (n ** bstn) = bigStepToN bst\n in ((S n) ** BStSuccN bstn)\n-- \nbigStepToN (BStPredZero bst) = let (n ** bstn) = bigStepToN bst\n in ((S n) ** BStPredZeroN bstn)\n-- \nbigStepToN (BStPredSucc bst) = let (n ** bstn) = bigStepToN bst\n in ((S n) ** BStPredSuccN bstn)\n--\nbigStepToN (BStIfzZero bst1 bst2) = let (n1 ** bstn1) = bigStepToN bst1\n (n2 ** bstn2) = bigStepToN bst2\n in ((S $ n1+n2) ** BStIfzZeroN bstn1 bstn2) \n-- \nbigStepToN (BStIfzSucc bst1 bst2) = let (n1 ** bstn1) = bigStepToN bst1\n (n2 ** bstn2) = bigStepToN bst2\n in ((S $ n1+n2) ** BStIfzSuccN bstn1 bstn2) \n\n\nbigStepFromN : BigStepN n e1 e2 -> BigStep e1 e2\nbigStepFromN (BStValueN v) = BStValue v\n--\nbigStepFromN (BStAppN bstn1 bstn2 bstn3) = let bst1 = bigStepFromN bstn1\n bst2 = bigStepFromN bstn2\n bst3 = bigStepFromN bstn3\n in BStApp bst1 bst2 bst3\n-- \nbigStepFromN (BStFixN bstn1 bstn2) = let bst1 = bigStepFromN bstn1\n bst2 = bigStepFromN bstn2\n in BStFix bst1 bst2\n-- \nbigStepFromN (BStSuccN bstn) = let bst = bigStepFromN bstn\n in BStSucc bst\n--\nbigStepFromN (BStPredZeroN bstn) = let bst = bigStepFromN bstn\n in BStPredZero bst\n--\nbigStepFromN (BStPredSuccN bstn) = let bst = bigStepFromN bstn\n in BStPredSucc bst\n--\nbigStepFromN (BStIfzZeroN bstn1 bstn2) = let bst1 = bigStepFromN bstn1\n bst2 = bigStepFromN bstn2\n in BStIfzZero bst1 bst2\n--\nbigStepFromN (BStIfzSuccN bstn1 bstn2) = let bst1 = bigStepFromN bstn1\n bst2 = bigStepFromN bstn2\n in BStIfzSucc bst1 bst2\n\n\n-- Divergence of 'omega' under the indexed version of big-step semantics:\nbigStepDivergenceOmega' : (n : Nat) -> BigStepN n Subst.omega e -> Void\nbigStepDivergenceOmega' Z (BStValueN v) = case v of\n VZero impossible\n (VSucc _) impossible\n VAbs impossible\nbigStepDivergenceOmega' {e} (S n) bstn = case bstn of\n (BStFixN (BStValueN v) bstn2) => let bstn2' = replace {P = \\x => BigStepN n x e}\n substOmega bstn2\n in bigStepDivergenceOmega' n bstn2'\n\n\nbigStepDivergenceOmega : BigStep Subst.omega e -> Void\nbigStepDivergenceOmega bst = let (n ** bstn) = bigStepToN bst\n in bigStepDivergenceOmega' n bstn\n\n\n-- Instead of diverging, the term 'omega' can evaluate to anything\n-- under the coinductive relation 'CoBigStep'. Hence, evaluation\n-- under 'CoBigStep' is non-deterministic:\ncoBigStepOmegaAny : CoBigStep Subst.omega e\ncoBigStepOmegaAny = CoBStFix (CoBStValue VAbs) Determinism.coBigStepOmegaAny \n\n-- End: DIVERGENCE OF TERM 'Subst.omega' UNDER BIG-STEP\n-------------------------------------------------------\n", "meta": {"hexsha": "c515cf9781609f72da07b451d03c20a2b0a67420", "size": 21589, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "codata/src/Determinism.idr", "max_stars_repo_name": "normanrink/PCF", "max_stars_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "codata/src/Determinism.idr", "max_issues_repo_name": "normanrink/PCF", "max_issues_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "codata/src/Determinism.idr", "max_forks_repo_name": "normanrink/PCF", "max_forks_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.1282527881, "max_line_length": 91, "alphanum_fraction": 0.6102644865, "num_tokens": 6632, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5360310089340967}} {"text": "||| An expression language with mechanical proof of type-safety.\n|||\n||| `Recorded` is an expression language supporting Let-bindings, and\n||| Records i.e. Named Tuples. Standard constructions are used to\n||| represent the language as an EDSL, together with proof of progress\n||| taken from PLFA Part 2.\n|||\n||| This module represents Section 3 of the Functional Pearl.\n|||\nmodule Razor.Recorded\n\nimport Razor.Common\n\n%default total\n\nnamespace Types\n\n public export\n data Ty = TyInt\n | TyChar\n | TyRecord (Vect (S n) Ty)\n\nnamespace Terms\n\n mutual\n ||| Field in a record.\n public export\n data Field : (g : List Ty)\n -> (type : Ty)\n -> Type\n where\n MkField : (value : Recorded g type)\n -> Field g type\n\n ||| Record Fields.\n public export\n data Fields : (g : List Ty)\n -> (types : Vect (S n) Ty)\n -> Type\n where\n Singleton : (first : Field g ty)\n -> Fields g (ty::Nil)\n\n Extend : (next : Field g ty)\n -> (rest : Fields g tys)\n -> Fields g (ty::tys)\n\n public export\n data Recorded : List Ty -> Ty -> Type where\n -- Let-Bindings & Variables\n Var : Elem ty g -> Recorded g ty\n\n Let : {expr, body : Ty}\n -> (this : Recorded g expr)\n -> (beInThis : Recorded (expr::g) body)\n -> Recorded g body\n\n -- Base Values\n I : Int -> Recorded g TyInt\n C : Char -> Recorded g TyChar\n\n -- Records & Accessors\n MkRecord : {types : Vect (S n) Ty}\n -> (values : Fields g types)\n -> Recorded g (TyRecord types)\n\n Proj : {type : Ty}\n -> {types : Vect (S n) Ty}\n -> (rec : Recorded g (TyRecord types))\n -> (idx : Elem type types)\n -> Recorded g type\n\n public export\n index : (idx : Elem type types)\n -> (fields : Fields g types)\n -> Recorded g type\n index Here (Singleton (MkField value)) = value\n index Here (Extend (MkField value) rest) = value\n index (There later) (Extend next rest) = index later rest\n\nnamespace Renaming\n\n public export\n weaken : (Contains old type -> Contains new type)\n -> (Contains (old += type') type -> Contains (new += type') type)\n\n weaken func Here = Here\n weaken func (There rest) = There (func rest)\n\n mutual\n namespace Fields\n public export\n rename : (forall type . Contains old type -> Contains new type)\n -> (forall types . Fields old types -> Fields new types)\n rename f (Singleton (MkField first))\n = Singleton (MkField (rename f first))\n rename f (Extend (MkField next) rest)\n = Extend (MkField (rename f next)) (rename f rest)\n\n public export\n rename : (forall type . Contains old type -> Contains new type)\n -> (forall type . Recorded old type -> Recorded new type)\n -- Let-Bindings & Variables\n rename f (Var x) = Var (f x)\n rename f (Let this beInThis)\n = Let (rename f this)\n (rename (weaken f) beInThis)\n\n -- Base Values\n rename f (I x) = I x\n rename f (C x) = C x\n\n -- Records & Accessors\n rename f (MkRecord values) = MkRecord (rename f values)\n rename f (Proj rec idx) = Proj (rename f rec) idx\n\nnamespace Substitution\n public export\n weakens : (forall type . Contains old type\n -> Recorded new type)\n -> (forall type . Contains (old += type') type\n -> Recorded (new += type') type)\n weakens f Here = Var Here\n weakens f (There rest) = rename There (f rest)\n\n namespace General\n mutual\n namespace Fields\n public export\n subst : (f : forall type . Contains old type -> Recorded new type)\n -> (forall types . Fields old types -> Fields new types)\n subst f (Singleton (MkField first))\n = Singleton (MkField (subst f first))\n subst f (Extend (MkField next) rest)\n = Extend (MkField (subst f next)) (subst f rest)\n\n public export\n subst : (forall type . Contains old type -> Recorded new type)\n -> (forall type . Recorded old type -> Recorded new type)\n -- Let-Bindings & Variables\n subst f (Var x) = f x\n subst f (Let this beInThis)\n = Let (subst f this)\n (subst (weakens f) beInThis)\n\n -- Base Values\n subst f (I x) = I x\n subst f (C x) = C x\n\n -- Records & Accesors\n subst f (MkRecord values) = MkRecord (subst f values)\n subst f (Proj rec idx) = Proj (subst f rec) idx\n\n namespace Single\n public export\n apply : (this : Recorded ctxt typeB)\n -> (idx : Contains (ctxt += typeB) typeA)\n -> Recorded ctxt typeA\n apply this Here = this\n apply this (There rest) = Var rest\n\n public export\n subst : (this : Recorded ctxt typeB)\n -> (inThis : Recorded (ctxt += typeB) typeA)\n -> Recorded ctxt typeA\n subst {ctxt} {typeA} {typeB} this inThis\n = General.subst (apply this) inThis\n\n\nnamespace Values\n mutual\n namespace Field\n public export\n data Value : (field : Field g type) -> Type\n where\n MkField : (prf : Value v)\n -> Value (MkField v)\n\n namespace Fields\n public export\n data Value : (fields : Fields g types) -> Type\n where\n Singleton : (field : Value value)\n -> Value (Singleton value)\n\n Extend : {value : Field g type}\n -> {values : Fields g types}\n -> (next : Value value)\n -> (rest : Value values)\n -> Value (Extend value values)\n\n public export\n data Value : Recorded ctxt type -> Type where\n -- Base Values\n I : Value (I i)\n C : Value (C c)\n\n -- Records\n MkRecord : Value fields -> Value (MkRecord fields)\n\n\nnamespace Reduction\n\n mutual\n namespace Field\n public export\n data Redux : (this, that : Field ctxt type) -> Type\n where\n SimplifyField : {this, that : Recorded g type}\n -> (prf : Redux this that)\n -> Redux (MkField this)\n (MkField that)\n\n namespace Fields\n public export\n data Redux : (this, that : Terms.Fields g types) -> Type\n where\n SimplifySingleton : (prf : Redux this that)\n -> Redux (Singleton this)\n (Singleton that)\n\n SimplifyExtend : {this, that : Field g type}\n -> {rest : Fields g types}\n -> (prf : Redux this that)\n -> Redux (Extend this rest)\n (Extend that rest)\n\n SimplifyExtendV : {this, that : Fields ctxt types}\n -> {v : Field ctxt type}\n -> (value : Value v)\n -> (rest : Redux this that)\n -> Redux (Extend v this)\n (Extend v that)\n\n\n public export\n data Redux : (this, that : Recorded ctxt type) -> Type where\n -- Let Bindings\n SimplifyLetValue : Redux this that\n -> Redux (Let this body)\n (Let that body)\n ReduceLetBody : Value value\n -> Redux (Let value body)\n (subst value body)\n\n SimplifyRecord : Redux this that\n -> Redux (MkRecord this) (MkRecord that)\n\n\n -- Accessors\n SimplifyProj : {type : Ty}\n -> {labels : Vect (S n) Ty}\n -> {this, that : Recorded g (TyRecord labels)}\n -> {idx : Elem type labels}\n -> Redux this that\n -> Redux (Proj this idx) (Proj that idx)\n\n ReduceProj : {type : Ty}\n -> {types : Vect (S n) Ty}\n -> {fields : Fields g types}\n -> {idx : Elem type types}\n -> (values : Value fields)\n -> Redux (Proj (MkRecord fields) idx)\n (index idx fields)\n\nnamespace Progress\n\n public export\n data Progress : (term : Recorded Nil type)\n -> Type\n where\n Done : {term : Recorded Nil type} -> Value term -> Progress term\n Step : {type : Ty}\n -> {this, that : Recorded Nil type}\n -> (step : Redux this that)\n -> Progress this\n\n namespace Field\n public export\n data Progress : (field : Field Nil type) -> Type where\n Done : Value field -> Progress field\n Step : {this, that : Field Nil type}\n -> (step : Redux this that)\n -> Progress this\n\n namespace Fields\n public export\n data Progress : (fields : Fields Nil types) -> Type where\n Done : (value : Value fields) -> Progress fields\n\n Step : {this, that : Fields Nil types}\n -> (step : Redux this that)\n -> Progress this\n\n\n mutual\n namespace Field\n public export\n progress : (field : Field Nil type)\n -> Progress field\n progress (MkField value) with (progress value)\n progress(MkField value) | (Done v)\n = Done (MkField v)\n progress(MkField value) | (Step step)\n = Step (SimplifyField step)\n\n namespace Fields\n public export\n progress : (fields : Fields Nil types)\n -> Progress fields\n progress (Singleton first) with (Field.progress first)\n progress (Singleton first) | (Done x)\n = Done (Singleton x)\n progress (Singleton first) | (Step prf)\n = Step (SimplifySingleton prf)\n\n\n progress (Extend next rest) with (progress next)\n progress (Extend next rest) | (Done x) with (progress rest)\n progress (Extend next rest) | (Done x) | (Done xs)\n = Done (Extend x xs)\n progress (Extend next rest) | (Done x) | (Step prf)\n = Step (SimplifyExtendV x prf)\n\n progress (Extend next rest) | (Step prf)\n = Step (SimplifyExtend prf)\n\n public export\n progress : forall type . (term : Recorded Nil type) -> Progress term\n -- Let-Bindings & Variables\n progress (Var _) impossible\n progress (Let this beInThis) with (progress this)\n progress (Let this beInThis) | (Done x)\n = Step (ReduceLetBody x)\n progress (Let this beInThis) | (Step prf)\n = Step (SimplifyLetValue prf)\n\n -- Base Values\n progress (I x) = Done I\n progress (C x) = Done C\n\n -- Records & Accessors\n progress (MkRecord values) with (progress values)\n progress (MkRecord values) | (Done v) = Done (MkRecord v)\n progress (MkRecord values) | (Step prf) = Step (SimplifyRecord prf)\n\n progress (Proj rec idx) with (progress rec)\n progress (Proj (MkRecord fields) idx) | (Done (MkRecord fieldsV))\n = Step (ReduceProj fieldsV)\n progress (Proj rec idx) | (Step prf)\n = Step (SimplifyProj prf)\n\nnamespace Evaluation\n\n public export\n data Reduces : (this : Recorded ctxt type)\n -> (that : Recorded ctxt type)\n -> Type\n where\n Refl : {this : Recorded ctxt type}\n -> Reduces this this\n Trans : {this, that, end : Recorded ctxt type}\n -> Redux this that\n -> Reduces that end\n -> Reduces this end\n\n public export\n data Finished : (term : Recorded ctxt type)\n -> Type\n where\n Normalised : {term : Recorded ctxt type} -> Value term -> Finished term\n OOF : Finished term\n\n public export\n data Evaluate : (term : Recorded Nil type) -> Type where\n RunEval : {this, that : Recorded Nil type}\n -> (steps : Inf (Reduces this that))\n -> (result : Finished that)\n -> Evaluate this\n\n public export\n data Fuel = Empty | More (Lazy Fuel)\n\n public export\n covering\n forever : Fuel\n forever = More forever\n\n public export\n compute : (fuel : Fuel)\n -> (term : Recorded Nil type)\n -> Evaluate term\n compute Empty term = RunEval Refl OOF\n compute (More fuel) term with (progress term)\n compute (More fuel) term | (Done value) = RunEval Refl (Normalised value)\n compute (More fuel) term | (Step step {that}) with (compute fuel that)\n compute (More fuel) term | (Step step {that = that}) | (RunEval steps result)\n = RunEval (Trans step steps) result\n\npublic export\ncovering\nrun : (this : Recorded Nil type)\n -> Maybe (Subset (Recorded Nil type) (Reduces this))\nrun this with (compute forever this)\n run this | (RunEval steps (Normalised {term} x))\n = Just (Element term steps)\n run this | (RunEval steps OOF) = Nothing\n\n\nnamespace Examples\n\n public export\n pairIC : Recorded Nil (TyRecord [TyInt, (TyChar)])\n pairIC = MkRecord (Extend (MkField (I 1))\n (Singleton (MkField (C 'c'))))\n\n public export\n i : Recorded Nil TyInt\n i = Proj pairIC Here\n\n public export\n c : Recorded Nil TyChar\n c = Proj pairIC (There Here)\n", "meta": {"hexsha": "8fe34ebc50b51befb458bc7885fc27b9087a5824", "size": 13715, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Razor/Recorded.idr", "max_stars_repo_name": "border-patrol/pearly-razors", "max_stars_repo_head_hexsha": "bc2677dda9171f8043e6cfb62ef4153e92c15714", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-09-29T16:07:47.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-22T09:12:24.000Z", "max_issues_repo_path": "Razor/Recorded.idr", "max_issues_repo_name": "border-patrol/pearly-razors", "max_issues_repo_head_hexsha": "bc2677dda9171f8043e6cfb62ef4153e92c15714", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Razor/Recorded.idr", "max_forks_repo_name": "border-patrol/pearly-razors", "max_forks_repo_head_hexsha": "bc2677dda9171f8043e6cfb62ef4153e92c15714", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3466981132, "max_line_length": 83, "alphanum_fraction": 0.5258476121, "num_tokens": 3257, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.535425220565411}} {"text": "module Main\n\nimport Data.Vect\n\n%flag C \"-g3\"\n%flag C \"-ggdb\"\n%flag C \"-O0\"\n\nrep : (n : Nat) -> Char -> Vect n Char\nrep Z x = []\nrep (S k) x = x :: rep k x\n\ndata RLE : Vect n Char -> Type where\n REnd : RLE []\n RChar : .{k : Nat}\n -> {xs : Vect k Char}\n -> (n : Nat)\n -> (x : Char)\n -> RLE xs\n -> RLE (rep (S n) x ++ xs)\n\neq : (x : Char) -> (y : Char) -> Maybe (x = y)\neq x y = if x == y then Just (believe_me (Refl {x})) else Nothing\n\n------------\n\nrle : (xs : Vect n Char) -> RLE xs\nrle [] = REnd\nrle (x :: xs) with (rle xs)\n rle (x :: Vect.Nil) | REnd = RChar Z x REnd\n rle (x :: rep (S n) yvar ++ ys) | RChar n yvar rs with (eq x yvar)\n rle (x :: rep (S n) x ++ ys) | RChar n x rs | Just Refl\n = RChar (S n) x rs\n rle (x :: rep (S n) y ++ ys) | RChar n y rs | Nothing\n = RChar Z x (RChar n y rs)\n\ncompress : Vect n Char -> String\ncompress xs with (rle xs)\n compress Nil | REnd = \"\"\n compress (rep (S n) x ++ xs) | RChar _ _ rs\n = let ni : Integer = cast (S n) in\n show ni ++ strCons x (compress xs)\n\n{-\nfmt : {xs : Vect n Char} -> RLE xs -> String\nfmt REnd = \"\"\nfmt (RChar n c xs) = show n ++ show c ++ fmt xs\n-}\n\ncompressString : String -> String\ncompressString xs = compress (fromList (unpack xs))\n\nmain : IO ()\nmain = putStrLn (compressString \"foooobaaaarbaaaz\")\n", "meta": {"hexsha": "fa9a275ae01d386cea3beab35cc326729c6ea4fe", "size": 1443, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/basic001/reg005.idr", "max_stars_repo_name": "grin-compiler/idris-grin", "max_stars_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/idris-dev/basic001/reg005.idr", "max_issues_repo_name": "grin-compiler/idris-grin", "max_issues_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/idris-dev/basic001/reg005.idr", "max_forks_repo_name": "grin-compiler/idris-grin", "max_forks_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 26.2363636364, "max_line_length": 69, "alphanum_fraction": 0.4913374913, "num_tokens": 493, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.535206061729218}} {"text": "module Equiv\n\nimport Expr\nimport Imp\nimport Logic\nimport Maps\n\n%access public export\n\n%default total\n\nAEquiv : (a1, a2 : AExp) -> Type\nAEquiv a1 a2 = (st : State) -> aeval st a1 = aeval st a2\n\nBEquiv : (b1, b2 : BExp) -> Type\nBEquiv b1 b2 = (st : State) -> beval st b1 = beval st b2\n\nAEquiv_example : AEquiv (X - X) 0\nAEquiv_example st with (st X)\n AEquiv_example st | Z = Refl\n AEquiv_example st | S k = sym $ minusZeroN k\n\nBEquiv_example : BEquiv (X - X == 0) BTrue\nBEquiv_example st with (st X)\n BEquiv_example st | Z = Refl\n BEquiv_example st | S k = rewrite sym $ minusZeroN k in Refl\n\nbtrue_is_true : BEquiv BTrue BTrue\nbtrue_is_true _ = Refl\n\nbfalse_is_false : BEquiv BFalse BFalse\nbfalse_is_false _ = Refl\n\nbnot_btrue_is_bfalse : BEquiv (BNot BTrue) BFalse\nbnot_btrue_is_bfalse _ = Refl\n\nbnot_bfalse_is_btrue : BEquiv (BNot BFalse) BTrue\nbnot_bfalse_is_btrue _ = Refl\n\nCEquiv : (c1, c2 : Com) -> Type\nCEquiv c1 c2 = (st, st' : State) -> ((c1 / st \\\\ st') ↔ (c2 / st \\\\ st'))\n\nskip_left : CEquiv (do SKIP; c) c\nskip_left st st' = (forward, backward)\nwhere forward : ((do SKIP; c) / st \\\\ st') -> (c / st \\\\ st')\n forward (E_Seq E_Skip rel) = rel\n backward : (c / st \\\\ st') -> ((do SKIP; c) / st \\\\ st')\n backward rel = E_Seq E_Skip rel\n\nskip_right : CEquiv (do c; SKIP) c\nskip_right st st' = (forward, backward)\nwhere forward : ((do c; SKIP) / st \\\\ st') -> (c / st \\\\ st')\n forward (E_Seq rel E_Skip) = rel\n backward : (c / st \\\\ st') -> ((do c; SKIP) / st \\\\ st')\n backward rel = E_Seq rel E_Skip\n\ntest_true_simple : CEquiv (IFB BTrue THEN c1 ELSE c2 FI) c1\ntest_true_simple st st' = (forward, backward)\nwhere forward : ((IFB BTrue THEN c1 ELSE c2 FI) / st \\\\ st') ->\n (c1 / st \\\\ st')\n forward (E_IfTrue _ rel) = rel\n forward (E_IfFalse prf _) = absurd prf\n backward : (c1 / st \\\\ st') ->\n ((IFB BTrue THEN c1 ELSE c2 FI) / st \\\\ st')\n backward rel = E_IfTrue Refl rel\n\ntest_true : BEquiv b BTrue -> CEquiv (IFB b THEN c1 ELSE c2 FI) c1\ntest_true {b} btrue st st' = (forward, backward)\nwhere forward : ((IFB b THEN c1 ELSE c2 FI) / st \\\\ st') ->\n (c1 / st \\\\ st')\n forward (E_IfTrue _ rel) = rel\n forward (E_IfFalse prf _) = absurd $ trans (sym $ btrue st) prf\n backward : (c1 / st \\\\ st') ->\n ((IFB b THEN c1 ELSE c2 FI) / st \\\\ st')\n backward rel = E_IfTrue (btrue st) rel\n\ntest_false : BEquiv b BFalse -> CEquiv (IFB b THEN c1 ELSE c2 FI) c2\ntest_false {b} bfalse st st' = (forward, backward)\nwhere forward : ((IFB b THEN c1 ELSE c2 FI) / st \\\\ st') ->\n (c2 / st \\\\ st')\n forward (E_IfTrue prf _) = absurd $ trans (sym $ bfalse st) prf\n forward (E_IfFalse _ rel) = rel\n backward : (c2 / st \\\\ st') ->\n ((IFB b THEN c1 ELSE c2 FI) / st \\\\ st')\n backward rel = E_IfFalse (bfalse st) rel\n\nswap_if_branches : CEquiv (IFB b THEN c1 ELSE c2 FI)\n (IFB not b THEN c2 ELSE c1 FI)\nswap_if_branches {b} st st' = (forward, backward)\nwhere forward : ((IFB b THEN c1 ELSE c2 FI) / st \\\\ st') ->\n ((IFB BNot b THEN c2 ELSE c1 FI) / st \\\\ st')\n forward (E_IfTrue prf rel) = E_IfFalse (cong {f=not} prf) rel\n forward (E_IfFalse prf rel) = E_IfTrue (cong {f=not} prf) rel\n backward : ((IFB BNot b THEN c2 ELSE c1 FI) / st \\\\ st') ->\n ((IFB b THEN c1 ELSE c2 FI) / st \\\\ st')\n backward (E_IfTrue prf rel) =\n E_IfFalse (trans (sym $ notInvolutive (beval st b))\n (cong {f=not} prf))\n rel\n backward (E_IfFalse prf rel) =\n E_IfTrue (trans (sym $ notInvolutive (beval st b))\n (cong {f=not} prf))\n rel\n\nif1_if_equiv : CEquiv (CIf1 b c) (CIf b c SKIP)\nif1_if_equiv {b} {c} st st' = (forward, backward)\nwhere forward : CEval (CIf1 b c) st st' -> CEval (CIf b c SKIP) st st'\n forward rel = case rel of\n E_If1True prf cc => E_IfTrue prf cc\n E_If1False prf => E_IfFalse prf E_Skip\n backward : CEval (CIf b c SKIP) st st' -> CEval (CIf1 b c) st st'\n backward rel = case rel of\n E_IfTrue prf cct => E_If1True prf cct\n E_IfFalse prf E_Skip => E_If1False prf\n\nif1_true : BEquiv b BTrue -> CEquiv (CIf1 b c) c\nif1_true {b} btrue st st' = (forward, backward)\nwhere forward : CEval (CIf1 b c) st st' -> CEval c st st'\n forward rel = case rel of\n E_If1True _ cc => cc\n E_If1False prf => absurd $ trans (sym prf) (btrue st)\n backward : CEval c st st' -> CEval (CIf1 b c) st st'\n backward cc = E_If1True (btrue st) cc\n\n\nif1_false : BEquiv b BFalse -> CEquiv (CIf1 b c) SKIP\nif1_false {b} bfalse st st' = (forward, backward)\nwhere forward : CEval (CIf1 b c) st st' -> CEval SKIP st st'\n forward rel = case rel of\n E_If1True prf _ => absurd $ trans (sym prf) (bfalse st)\n E_If1False _ => E_Skip\n backward : CEval SKIP st st' -> CEval (CIf1 b c) st st'\n backward rel = case rel of\n E_Skip => E_If1False (bfalse st)\n\nwhile_false : BEquiv b BFalse -> CEquiv (WHILE b c) SKIP\nwhile_false {b} bfalse st _ = (forward, backward)\nwhere forward : ((WHILE b c) / st \\\\ st') -> (SKIP / st \\\\ st')\n forward rel = case rel of\n E_WhileEnd _ => E_Skip\n E_WhileLoop prf _ _ => absurd $ trans (sym $ bfalse st) prf\n backward : (SKIP / st \\\\ st') -> ((WHILE b c) / st \\\\ st')\n backward rel = case rel of\n E_Skip => E_WhileEnd (bfalse st)\n\nwhile_true_nonterm : BEquiv b BTrue -> Not ((WHILE b c) / st \\\\ st')\nwhile_true_nonterm {st'} btrue (E_WhileEnd prf) =\n absurd $ trans (sym $ btrue st') prf\nwhile_true_nonterm btrue (E_WhileLoop prf rel next) =\n while_true_nonterm btrue next\n\nwhile_true : BEquiv b BTrue -> CEquiv (WHILE b c) (WHILE BTrue SKIP)\nwhile_true {b} btrue st st' = (forward, backward)\nwhere forward : ((WHILE b c) / st \\\\ st') -> ((WHILE BTrue SKIP) / st \\\\ st')\n forward rel = case rel of\n E_WhileEnd prf => absurd $ trans (sym $ btrue st) prf\n E_WhileLoop _ _ next => void $ while_true_nonterm btrue next\n backward : ((WHILE BTrue SKIP) / st \\\\ st') -> ((WHILE b c) / st \\\\ st')\n backward rel = case rel of\n E_WhileEnd prf => absurd prf\n E_WhileLoop Refl _ next => void $ while_true_nonterm btrue_is_true next\n\nloop_unrolling : CEquiv (WHILE b c) (IFB b THEN (do c; WHILE b c) ELSE SKIP FI)\nloop_unrolling st st' = (forward, backward)\nwhere forward : ((WHILE b c) / st \\\\ st') ->\n ((IFB b THEN (do c; WHILE b c) ELSE SKIP FI) / st \\\\ st')\n forward rel = case rel of\n E_WhileEnd prf => E_IfFalse prf E_Skip\n E_WhileLoop prf rel next => E_IfTrue prf (E_Seq rel next)\n backward : ((IFB b THEN (do c; WHILE b c) ELSE SKIP FI) / st \\\\ st') ->\n ((WHILE b c) / st \\\\ st')\n backward (E_IfTrue prf (E_Seq rel next)) = E_WhileLoop prf rel next\n backward (E_IfFalse prf rel) = case rel of\n E_Skip => E_WhileEnd prf\n\nfor_while_equiv : CEquiv (CFor c1 b c2 c3) (CSeq c1 (CWhile b (CSeq c3 c2)))\nfor_while_equiv {c1} {b} {c2} {c3} st st' = (forward, backward)\nwhere forward : ((CFor c1 b c2 c3) / st \\\\ st') ->\n ((CSeq c1 (CWhile b (CSeq c3 c2))) / st \\\\ st')\n forward (E_For cinit cwhile) = E_Seq cinit cwhile\n backward : ((CSeq c1 (CWhile b (CSeq c3 c2))) / st \\\\ st') ->\n ((CFor c1 b c2 c3) / st \\\\ st')\n backward (E_Seq cinit cwhile) = E_For cinit cwhile\n\nrepeat_while_equiv : CEquiv (CRepeat c b) (CSeq c (CWhile (not b) c))\nrepeat_while_equiv {c} {b} st st' = (forward, backward)\nwhere forward : CEval (CRepeat c b) st st' ->\n CEval (CSeq c (CWhile (not b) c)) st st'\n forward (E_Repeat cc cwhile) = E_Seq cc cwhile\n backward : CEval (CSeq c (CWhile (not b) c)) st st' ->\n CEval (CRepeat c b) st st'\n backward (E_Seq cc cwhile) = E_Repeat cc cwhile\n\nseq_assoc : CEquiv (do (do c1; c2); c3) (do c1; (do c2; c3))\nseq_assoc st st' = (forward, backward)\nwhere forward : ((do (do c1; c2); c3) / st \\\\ st') ->\n ((do c1; (do c2; c3)) / st \\\\ st')\n forward (E_Seq (E_Seq r1 r2) r3) = E_Seq r1 (E_Seq r2 r3)\n backward : ((do c1; (do c2; c3)) / st \\\\ st') ->\n ((do (do c1; c2); c3) / st \\\\ st')\n backward (E_Seq r1 (E_Seq r2 r3)) = E_Seq (E_Seq r1 r2) r3\n\nidentity_assignment : CEquiv (x ::= AId x) SKIP\nidentity_assignment {x} st st' = (forward, backward)\nwhere forward : ((x ::= AId x) / st \\\\ st') -> (SKIP / st \\\\ st')\n forward rel = case rel of\n E_Ass prf => rewrite sym prf\n in rewrite t_update_same {m=st} {x=x}\n in E_Skip\n backward : (SKIP / st \\\\ st') -> ((x ::= AId x) / st \\\\ st')\n backward rel = case rel of\n E_Skip => replace (t_update_same {m=st} {x=x}) (E_Ass Refl)\n {P=\\s => (x ::= AId x) / st \\\\ s}\n\nassign_aequiv : AEquiv (AId x) e -> CEquiv SKIP (x ::= e)\nassign_aequiv {x} {e} x_eq_e st st' = (forward, backward)\nwhere forward : (SKIP / st \\\\ st') -> ((x ::= e) / st \\\\ st')\n forward rel = case rel of\n E_Skip => replace (t_update_same {m=st} {x=x}) (E_Ass (sym $ x_eq_e st))\n {P=\\s => (x ::= e) / st \\\\ s}\n backward : ((x ::= e) / st \\\\ st') -> (SKIP / st \\\\ st')\n backward rel = case rel of\n E_Ass prf => rewrite sym prf\n in rewrite sym $ x_eq_e st\n in rewrite t_update_same {m=st} {x=x}\n in E_Skip\n\nprog_a : Com\nprog_a =\n WHILE (not (X <= 0)) $\n X ::= X + 1\n\nprog_b : Com\nprog_b = do\n IFB X == 0\n THEN do X ::= X + 1\n Y ::= 1\n ELSE Y ::= 0\n FI\n X ::= X - Y\n Y ::= 0\n\nprog_c : Com\nprog_c = SKIP\n\nprog_d : Com\nprog_d =\n WHILE (not (X == 0)) $\n X ::= X * Y + 1\n\nprog_e : Com\nprog_e = Y ::= 0\n\nprog_f : Com\nprog_f = do\n Y ::= X + 1\n WHILE (not (X == Y)) $\n Y ::= X + 1\n\nprog_g : Com\nprog_g = WHILE BTrue SKIP\n\nprog_h : Com\nprog_h =\n WHILE (not (X == X)) $\n X ::= X + 1\n\nprog_i : Com\nprog_i =\n WHILE (not (X == Y)) $\n X ::= Y + 1\n\nequiv_classes : List (List Com)\nequiv_classes = [ [prog_a, prog_f, prog_g]\n , [prog_b]\n , [prog_c, prog_h]\n , [prog_d]\n , [prog_e]\n , [prog_i] ]\n\nrefl_aequiv : AEquiv a a\nrefl_aequiv _ = Refl\n\nsym_aequiv : AEquiv a1 a2 -> AEquiv a2 a1\nsym_aequiv a1_equiv_a2 st = sym $ a1_equiv_a2 st\n\ntrans_aequiv : AEquiv a1 a2 -> AEquiv a2 a3 -> AEquiv a1 a3\ntrans_aequiv a1_equiv_a2 a2_equiv_a3 st = rewrite a1_equiv_a2 st\n in a2_equiv_a3 st\n\nrefl_bequiv : BEquiv b b\nrefl_bequiv _ = Refl\n\nsym_bequiv : BEquiv b1 b2 -> BEquiv b2 b1\nsym_bequiv b1_equiv_b2 st = sym $ b1_equiv_b2 st\n\ntrans_bequiv : BEquiv b1 b2 -> BEquiv b2 b3 -> BEquiv b1 b3\ntrans_bequiv b1_equiv_b2 b2_equiv_b3 st = rewrite b1_equiv_b2 st\n in b2_equiv_b3 st\n\nrefl_cequiv : CEquiv c c\nrefl_cequiv _ _ = (id, id)\n\nsym_cequiv : CEquiv c1 c2 -> CEquiv c2 c1\nsym_cequiv c1_equiv_c2 st st' = swap $ c1_equiv_c2 st st'\n\ntrans_cequiv : CEquiv c1 c2 -> CEquiv c2 c3 -> CEquiv c1 c3\ntrans_cequiv c1_equiv_c2 c2_equiv_c3 st st' =\n let (forward_c1_c2, backward_c2_c1) = c1_equiv_c2 st st'\n (forward_c2_c3, backward_c3_c2) = c2_equiv_c3 st st'\n in (forward_c2_c3 . forward_c1_c2, backward_c2_c1 . backward_c3_c2)\n\ncAss_congruence : AEquiv a1 a2 -> CEquiv (x ::= a1) (x ::= a2)\ncAss_congruence {a1} {a2} a1_equiv_a2 st st' = (forward, backward)\nwhere forward : ((x ::= a1) / st \\\\ st') -> ((x ::= a2) / st \\\\ st')\n forward rel = case rel of\n E_Ass prf => rewrite sym prf\n in rewrite a1_equiv_a2 st\n in E_Ass Refl\n backward : ((x ::= a2) / st \\\\ st') -> ((x ::= a1) / st \\\\ st')\n backward rel = case rel of\n E_Ass prf => rewrite sym prf\n in rewrite sym $ a1_equiv_a2 st\n in E_Ass Refl\n\ncWhile_congruence : BEquiv b1 b2 -> CEquiv c1 c2 ->\n CEquiv (WHILE b1 c1) (WHILE b2 c2)\ncWhile_congruence {b1} {b2} {c1} {c2} b1_equiv_b2 c1_equiv_c2 _ _ =\n (forward, backward)\nwhere forward : ((WHILE b1 c1) / st \\\\ st') -> ((WHILE b2 c2) / st \\\\ st')\n forward {st} rel = case rel of\n E_WhileEnd prf => E_WhileEnd $ trans (sym $ b1_equiv_b2 st) prf\n E_WhileLoop {st1} prf rel next =>\n E_WhileLoop (trans (sym $ b1_equiv_b2 st) prf)\n (fst (c1_equiv_c2 st st1) rel)\n (forward {st=st1} next)\n backward : ((WHILE b2 c2) / st \\\\ st') -> ((WHILE b1 c1) / st \\\\ st')\n backward {st} rel = case rel of\n E_WhileEnd prf => E_WhileEnd $ trans (b1_equiv_b2 st) prf\n E_WhileLoop {st1} prf rel next =>\n E_WhileLoop (trans (b1_equiv_b2 st) prf)\n (snd (c1_equiv_c2 st st1) rel)\n (backward {st=st1} next)\n\ncSeq_congruence : CEquiv c1 c2 -> CEquiv c3 c4 -> CEquiv (do c1; c3) (do c2; c4)\ncSeq_congruence {c1} {c2} {c3} {c4} c1_equiv_c2 c3_equiv_c4 st st' =\n (forward, backward)\nwhere forward : ((do c1; c3) / st \\\\ st') -> ((do c2; c4) / st \\\\ st')\n forward (E_Seq {st2} r1 r2) = E_Seq (fst (c1_equiv_c2 st st2) r1)\n (fst (c3_equiv_c4 st2 st') r2)\n backward : ((do c2; c4) / st \\\\ st') -> ((do c1; c3) / st \\\\ st')\n backward (E_Seq {st2} r3 r4) = E_Seq (snd (c1_equiv_c2 st st2) r3)\n (snd (c3_equiv_c4 st2 st') r4)\n\nfor_false : BEquiv cond BFalse -> CEquiv (CFor init cond updt body) init\nfor_false {init} {cond} {updt} {body} cond_equiv =\n trans_cequiv (for_while_equiv {c1=init} {b=cond} {c2=updt} {c3=body})\n (trans_cequiv (cSeq_congruence (refl_cequiv {c=init})\n (while_false cond_equiv))\n (skip_right {c=init}))\n\nfor_true : BEquiv cond BTrue -> CEquiv (CFor init cond updt body)\n (CSeq init (CWhile BTrue SKIP))\nfor_true {init} {cond} {updt} {body} cond_equiv =\n trans_cequiv (for_while_equiv {c1=init} {b=cond} {c2=updt} {c3=body})\n (cSeq_congruence (refl_cequiv {c=init}) (while_true cond_equiv))\n\ncFor_congruence : CEquiv init1 init2 -> BEquiv cond1 cond2 ->\n CEquiv updt1 updt2 -> CEquiv body1 body2 ->\n CEquiv (CFor init1 cond1 updt1 body1)\n (CFor init2 cond2 updt2 body2)\ncFor_congruence init_equiv cond_equiv updt_equiv body_equiv =\n trans_cequiv for_while_equiv\n (trans_cequiv\n (cSeq_congruence init_equiv\n (cWhile_congruence\n cond_equiv\n (cSeq_congruence body_equiv updt_equiv)))\n (sym_cequiv for_while_equiv))\n\nrepeat_false : BEquiv b BFalse -> CEquiv (CRepeat c b)\n (CSeq c (CWhile BTrue SKIP))\nrepeat_false {b} {c} cond_equiv =\n let not_cond_equiv = \\st1 => cong {f=not} (cond_equiv st1)\n in trans_cequiv repeat_while_equiv\n (cSeq_congruence refl_cequiv (while_true not_cond_equiv))\n\nrepeat_true : BEquiv b BTrue -> CEquiv (CRepeat c b) c\nrepeat_true {b} {c} cond_equiv =\n let not_cond_equiv = \\st1 => cong {f=not} (cond_equiv st1)\n in trans_cequiv repeat_while_equiv\n (trans_cequiv (cSeq_congruence refl_cequiv\n (while_false not_cond_equiv))\n skip_right)\n\ncRepeat_congruence : CEquiv body1 body2 -> BEquiv cond1 cond2 ->\n CEquiv (CRepeat body1 cond1) (CRepeat body2 cond2)\ncRepeat_congruence body_equiv cond_equiv =\n let not_cond_equiv = \\st1 => cong {f=not} (cond_equiv st1)\n in trans_cequiv repeat_while_equiv\n (trans_cequiv\n (cSeq_congruence body_equiv\n (cWhile_congruence not_cond_equiv\n body_equiv))\n (sym_cequiv repeat_while_equiv))\n\ncIf_congruence : BEquiv b1 b2 -> CEquiv c1 c2 -> CEquiv c3 c4 ->\n CEquiv (IFB b1 THEN c1 ELSE c3 FI) (IFB b2 THEN c2 ELSE c4 FI)\ncIf_congruence {b1} {b2} {c1} {c2} {c3} {c4}\n b1_equiv_b2 c1_equiv_c2 c3_equiv_c4 st st' =\n (forward, backward)\nwhere forward : ((IFB b1 THEN c1 ELSE c3 FI) / st \\\\ st') ->\n ((IFB b2 THEN c2 ELSE c4 FI) / st \\\\ st')\n forward (E_IfTrue prf rel) = E_IfTrue (trans (sym $ b1_equiv_b2 st) prf)\n (fst (c1_equiv_c2 st st') rel)\n forward (E_IfFalse prf rel) = E_IfFalse (trans (sym $ b1_equiv_b2 st) prf)\n (fst (c3_equiv_c4 st st') rel)\n backward : ((IFB b2 THEN c2 ELSE c4 FI) / st \\\\ st') ->\n ((IFB b1 THEN c1 ELSE c3 FI) / st \\\\ st')\n backward (E_IfTrue prf rel) = E_IfTrue (trans (b1_equiv_b2 st) prf)\n (snd (c1_equiv_c2 st st') rel)\n backward (E_IfFalse prf rel) = E_IfFalse (trans (b1_equiv_b2 st) prf)\n (snd (c3_equiv_c4 st st') rel)\n\ncIf1_congruence : BEquiv b1 b2 -> CEquiv c1 c2 ->\n CEquiv (CIf1 b1 c1) (CIf1 b2 c2)\ncIf1_congruence b_equiv c_equiv =\n trans_cequiv\n (trans_cequiv if1_if_equiv\n (cIf_congruence b_equiv c_equiv (refl_cequiv {c=SKIP})))\n (sym_cequiv if1_if_equiv)\n\ncongruence_example : CEquiv\n (do X ::= 0\n IFB X == 0\n THEN Y ::= 0\n ELSE Y ::= 42\n FI)\n (do X ::= 0\n IFB X == 0\n THEN Y ::= X - X\n ELSE Y ::= 42\n FI)\ncongruence_example =\n cSeq_congruence refl_cequiv\n (cIf_congruence refl_bequiv statements_equiv refl_cequiv)\nwhere forward : ((Y ::= 0) / st \\\\ st') ->\n ((Y ::= X - X) / st \\\\ st')\n forward {st} (E_Ass prf) = E_Ass $ trans (sym $ minusZeroN (st X)) prf\n backward : ((Y ::= X - X) / st \\\\ st') ->\n ((Y ::= 0) / st \\\\ st')\n backward {st} (E_Ass prf) = rewrite minusZeroN (st X)\n in rewrite prf\n in E_Ass Refl\n statements_equiv : CEquiv (Y ::= 0) (Y ::= X - X)\n statements_equiv _ _ = (forward, backward)\n\nATransSound : (atrans : AExp -> AExp) -> Type\nATransSound atrans = (a : AExp) -> AEquiv a (atrans a)\n\nBTransSound : (btrans : BExp -> BExp) -> Type\nBTransSound btrans = (b : BExp) -> BEquiv b (btrans b)\n\nCTransSound : (ctrans : Com -> Com) -> Type\nCTransSound ctrans = (c : Com) -> CEquiv c (ctrans c)\n", "meta": {"hexsha": "4b499c3b667715261faac603163011ddd45b8cdb", "size": 18764, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Equiv.idr", "max_stars_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_stars_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Equiv.idr", "max_issues_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_issues_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Equiv.idr", "max_forks_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_forks_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.2660944206, "max_line_length": 80, "alphanum_fraction": 0.5633127265, "num_tokens": 6217, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.5344209877154164}} {"text": "import Data.Vect\n\nmaryInVector : Elem \"Mary\" [\"Peter\", \"Paul\", \"Mary\"]\nmaryInVector = There (There Here)\n\nelemOfEmptyAbsurd : Elem a [] -> Void\nelemOfEmptyAbsurd Here impossible\nelemOfEmptyAbsurd (There _) impossible\n\nremoveElem : (elem : a) -> (v : Vect (S n) a) -> Elem elem v -> Vect n a\nremoveElem elem (elem :: xs) Here = xs\nremoveElem {n = Z} elem (x :: []) (There later) = absurd later\nremoveElem {n = (S k)} elem (x :: xs) (There later) = x :: removeElem elem xs later\n\nremoveElem_auto : (value : a) -> (xs : Vect (S n) a) -> {auto prf : Elem value xs} -> Vect n a\nremoveElem_auto value xs {prf} = removeElem value xs prf\n\nisElem' : DecEq a => (elem : a) -> (v : Vect n a) -> Dec (Elem elem v)\nisElem' elem [] = No absurd\nisElem' elem (x :: xs) = case decEq elem x of\n (Yes Refl) => Yes Here\n (No contraHead) => case isElem' elem xs of\n (Yes prf) => Yes (There prf)\n (No contraTail) => No (\\prf => (case prf of\n Here => contraHead Refl\n (There later) => contraTail later))\n\ndata ListElem : a -> List a -> Type where\n Here : ListElem x (x :: ys)\n There : ListElem x xs -> ListElem x (y :: xs)\n\ndata Last : List a -> a -> Type where\n LastOne : Last [a] a\n LastCons : Last as a -> Last (x :: as) a\n\nnoLastElemForEmptyList : Last [] a -> Void\nnoLastElemForEmptyList LastOne impossible\nnoLastElemForEmptyList (LastCons _) impossible\n\nisLast : DecEq a => (xs : List a) -> (elem : a) -> Dec (Last xs elem)\nisLast [] elem = No noLastElemForEmptyList\nisLast [e] elem = case decEq elem e of\n (Yes Refl) => Yes LastOne\n (No contra) => No (\\prf => (case prf of\n LastOne => contra Refl\n (LastCons x) => noLastElemForEmptyList x))\nisLast (_ :: y :: ys) elem = case isLast (y::ys) elem of\n (Yes prf) => Yes $ LastCons prf\n (No contra) => No (\\prf => (case prf of\n (LastCons x) => contra x)) \n\n\n", "meta": {"hexsha": "35a6b2d965cac571d0815346a62a3fd7da05b927", "size": 2412, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "removeElem.idr", "max_stars_repo_name": "GustavoMF31/TDDwithIdrisExercises", "max_stars_repo_head_hexsha": "22b7c2802e1d8fd102a5b9b70d024205b3f35a74", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "removeElem.idr", "max_issues_repo_name": "GustavoMF31/TDDwithIdrisExercises", "max_issues_repo_head_hexsha": "22b7c2802e1d8fd102a5b9b70d024205b3f35a74", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "removeElem.idr", "max_forks_repo_name": "GustavoMF31/TDDwithIdrisExercises", "max_forks_repo_head_hexsha": "22b7c2802e1d8fd102a5b9b70d024205b3f35a74", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.5094339623, "max_line_length": 126, "alphanum_fraction": 0.4755389718, "num_tokens": 609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.5344209792460669}} {"text": "||| Lambductive core calculus\nmodule Lambductive.Core\n\n%default total\n\ndata Context : Type\n\ndata TypeTerm : Context -> Type\n\ninfixl 7 :::\n\n||| De Bruijn variable context\ndata Context : Type where\n Nil : Context\n ||| Add a variable to a context\n ||| @type The type of the variable\n (:::) : (context : Context) -> (type : TypeTerm context) -> Context\n\n||| Judgment of whether the interpretation of a term as a type code is reducible\ndata InterpretReducibility : Type where\n InterpretReducible : InterpretReducibility\n InterpretIrreducible : InterpretReducibility\n\ndata ValueTerm : (context : Context) -> TypeTerm context -> InterpretReducibility -> Type\n\n||| Types of the calculus\ndata TypeTerm : Context -> Type where\n ||| A universe of type codes\n U : (level : Nat) -> TypeTerm context\n ||| Dependent function type\n Pi : (domain : TypeTerm context) -> (codomain : TypeTerm (context ::: domain)) -> TypeTerm context\n ||| An irreducible application of the type code interpretation operator\n |||\n ||| Use the `interpret` function to interpret type codes without any concern for reducibility\n IrreducibleInterpret : ValueTerm context (U level) InterpretIrreducible -> TypeTerm context\n\n||| Bring a type into a context with an extra variable at the head\naddVarToType : TypeTerm context -> TypeTerm (context ::: type)\n\n||| An index into a context\n||| @type The type of the variable at that index\ndata ContextIndex : (context : Context) -> (type : TypeTerm context) -> Type where\n Z : ContextIndex (_ ::: type) (addVarToType type)\n S : ContextIndex context type -> ContextIndex (context ::: type') (addVarToType type)\n\n||| Interpret a type code to a type\ninterpret : ValueTerm context (U _) _ -> TypeTerm context\n\n||| Values of the calculus\ndata ValueTerm : (context : Context) -> TypeTerm context -> InterpretReducibility -> Type where\n Var : ContextIndex context type -> ValueTerm context type InterpretIrreducible\n\ninterpret (Var idx) = IrreducibleInterpret (Var idx)\n\n||| An offset into a context\ndata ContextOffset : Context -> Type where\n OffZ : ContextOffset context\n OffS : ContextOffset context -> ContextOffset (context ::: type)\n\n||| Drop some variables from a context\ndrop : (context : Context) -> ContextOffset context -> Context\ndrop context OffZ = context\ndrop (context ::: _) (OffS off) = drop context off\n\n||| Insert a variable into a context at a given offset\n||| @type The type of the variable\ninsertAt : (context : Context) -> (off : ContextOffset context) -> (type : TypeTerm (drop context off)) -> Context\n\n||| Bring a type into a context with an extra variable at a given offset\naddVarToTypeAtOffset : (off : ContextOffset context) -> TypeTerm context -> TypeTerm (insertAt context off type)\n\ninsertAt context OffZ type = context ::: type\ninsertAt (context ::: type) (OffS off) type' = insertAt context off type' ::: addVarToTypeAtOffset off type\n\n||| Bring a type code into a context with an extra variable at a given offset\naddVarToCodeAtOffset : (off : ContextOffset context) -> ValueTerm context (U level) interpretReducible -> ValueTerm (insertAt context off type') (U level) interpretReducible\n\naddVarToTypeAtOffset _ (U level) = U level\naddVarToTypeAtOffset off (Pi domain codomain) = Pi (addVarToTypeAtOffset off domain) (addVarToTypeAtOffset (OffS off) codomain)\naddVarToTypeAtOffset off (IrreducibleInterpret code) = IrreducibleInterpret (addVarToCodeAtOffset off code)\n\naddVarToType type = addVarToTypeAtOffset OffZ type\n\n||| Bring a value into a context with an extra variable at a given offset\naddVarToValueAtOffset : (off : ContextOffset context) -> ValueTerm context type interpretReducible -> ValueTerm (insertAt context off type') (addVarToTypeAtOffset off type) interpretReducible\naddVarToValueAtOffset OffZ (Var idx) = Var (S idx)\naddVarToValueAtOffset (OffS off) (Var idx) = ?hole\n\naddVarToCodeAtOffset off code = addVarToValueAtOffset off code\n", "meta": {"hexsha": "e72f2e01085612a90a5857bf16638af85445bade", "size": 3900, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Lambductive/Core.idr", "max_stars_repo_name": "shlevy/lambductive", "max_stars_repo_head_hexsha": "0aa651657cf552d39148c5224fe9f0a003fc75c1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-11-24T00:48:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-28T10:56:58.000Z", "max_issues_repo_path": "Lambductive/Core.idr", "max_issues_repo_name": "shlevy/lambductive", "max_issues_repo_head_hexsha": "0aa651657cf552d39148c5224fe9f0a003fc75c1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Lambductive/Core.idr", "max_forks_repo_name": "shlevy/lambductive", "max_forks_repo_head_hexsha": "0aa651657cf552d39148c5224fe9f0a003fc75c1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 43.3333333333, "max_line_length": 191, "alphanum_fraction": 0.7474358974, "num_tokens": 996, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.534249834910377}} {"text": "\n\nNatOrError : Nat -> Type \nNatOrError Z = String \nNatOrError (S k) = Nat\n\ndivide : (x:Nat) -> (y:Nat) -> NatOrError y\ndivide x Z = \"Error: Division by zero\" \ndivide x (S k) = div x (S k)\n\n", "meta": {"hexsha": "ed969423eb67c0069f7e04d242a38329a8418668", "size": 189, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "division_solution.idr", "max_stars_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_stars_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "division_solution.idr", "max_issues_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_issues_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "division_solution.idr", "max_forks_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_forks_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.1818181818, "max_line_length": 43, "alphanum_fraction": 0.6137566138, "num_tokens": 70, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8791467738423873, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.5342251153414254}} {"text": "module Door\n\npublic export\ndata Usage = Once | Many\n\npublic export\ndata Lin : (Type -> Type) -> Usage -> Type -> Type where\n Pure : (1 x : a) -> Lin m u a\n Lift : (1 x : m a) -> Lin m Many a\n BindOnce : (1 act : Lin m Once a) ->\n (1 k : (1 x : a) -> Lin m t b) -> Lin m t b\n BindMany : (1 act : Lin m Many a) ->\n (1 k : (x : a) -> Lin m t b) -> Lin m t b\n\npublic export\ndata Unrestricted : Type -> Type where\n MkUn : (x : a) -> Unrestricted a\n\nexport\npure : (1 x : a) -> Lin m u a\npure = Pure\n\nexport\nlift : (1 x : m a) -> Lin m Many a\nlift = Lift\n\npublic export\ncontType : (Type -> Type) -> Usage -> Usage -> Type -> Type -> Type\ncontType m Once q a b = (1 x : a) -> Lin m q b\ncontType m Many q a b = (x : a) -> Lin m q b\n\npublic export\n(>>=) : {p : _} \n -> (1 f : Lin m p a) \n -> (1 k : contType m p q a b) \n -> Lin m q b\n(>>=) {p=Once} = BindOnce\n(>>=) {p=Many} = BindMany\n\nexport\nrun : Monad m => Lin m u t -> m t\nrun (Pure x) = pure x\nrun (Lift p) = p\nrun (BindOnce act k)\n = do act' <- run act\n run (k act')\nrun (BindMany act k)\n = do act' <- run act\n run (k act')\n\npublic export\nOne : (Type -> Type) -> Type -> Type\nOne m = Lin m Once\n\npublic export\nAny : (Type -> Type) -> Type -> Type\nAny m = Lin m Many\n\ndata DoorState = Closed | Open\n\n-- changes start here\n\nopenWhen : Bool -> DoorState\nopenWhen ok = if ok then Open else Closed\n\ndata Door : DoorState -> Type where\n MkDoor : (isOpen : Bool) -> Door (if isOpen then Open else Closed)\n\n-- Testing that 'if' works okay in an interface\ninterface Doored (m : Type -> Type) where\n newDoor : One m (Door Closed)\n knock : (1 d : Door t) -> One m (Door t)\n openDoor : (1 d : Door Closed) \n -> One m (Res Bool (\\ok => Door (if ok then Open else Closed)))\n closeDoor : (1 d : Door Open) -> One m (Door Closed)\n deleteDoor : (1 d : Door Closed) -> Any m ()\n", "meta": {"hexsha": "bac817a088ff2760bfd16a239833e85dd7f4380b", "size": 1940, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/linear008/Door.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/idris2/linear008/Door.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/idris2/linear008/Door.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1948051948, "max_line_length": 77, "alphanum_fraction": 0.5463917526, "num_tokens": 642, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.5340285572847208}} {"text": "module Main\n\n-- base\nimport Data.List\nimport System.File\n\n-- contrib\nimport Text.Parser\nimport Text.Parser.Core\n\ndata Direction = East\n | SouthEast\n | SouthWest\n | West\n | NorthEast\n | NorthWest\n\nEq Direction where\n (==) East East = True\n (==) SouthEast SouthEast = True\n (==) SouthWest SouthWest = True\n (==) West West = True\n (==) NorthEast NorthEast = True\n (==) NorthWest NorthWest = True\n (==) _ _ = False\n\nShow Direction where\n show East = \"East\"\n show SouthEast = \"SouthEast\"\n show SouthWest = \"SouthWest\"\n show West = \"West\"\n show NorthEast = \"NorthEast\"\n show NorthWest = \"NorthWest\"\n\nnamespace Grammar\n eastWestGrammar : Grammar Char True Direction\n eastWestGrammar = terminal \"Can't parse East\" $ \\ x =>\n case x of\n 'e' => Just East\n 'w' => Just West\n _ => Nothing\n\n northGrammar : Grammar Char True Direction\n northGrammar = terminal \"Can't parse North\" checkN *> terminal \"Can't parse North-?\" checkEW where\n checkN : Char -> Maybe ()\n checkN 'n' = Just ()\n checkN _ = Nothing\n\n checkEW : Char -> Maybe Direction\n checkEW 'e' = Just NorthEast\n checkEW 'w' = Just NorthWest\n checkEW _ = Nothing\n\n southGrammar : Grammar Char True Direction\n southGrammar = terminal \"Can't parse South\" checkS *> terminal \"Can't parse South-?\" checkEW where\n checkS : Char -> Maybe ()\n checkS 's' = Just ()\n checkS _ = Nothing\n\n checkEW : Char -> Maybe Direction\n checkEW 'e' = Just SouthEast\n checkEW 'w' = Just SouthWest\n checkEW _ = Nothing\n\n directionGrammar : Grammar Char True Direction\n directionGrammar = eastWestGrammar <|> northGrammar <|> southGrammar\n\n directionsGrammar : Grammar Char True (List Direction)\n directionsGrammar = many directionGrammar <* terminal \"Can't parse newline\" checkNewline where\n checkNewline : Char -> Maybe ()\n checkNewline '\\n' = Just ()\n checkNewline _ = Nothing\n\n export\n dataGrammar : Grammar Char False (List (List Direction))\n dataGrammar = many directionsGrammar <* eof\n\nrecord HexVector where\n constructor MkHexVector\n east, southeast, southwest : Integer\n\nEq HexVector where\n (==) (MkHexVector x y z) (MkHexVector x' y' z') = x == x' && y == y' && z == z'\n\nShow HexVector where\n show (MkHexVector east southeast southwest) = \"HexVector \" ++ show east ++ \" \" ++ show southeast ++ \" \" ++ show southwest\n\nnamespace HexVector\n succ : Integer -> Integer\n succ = (+ 1)\n\n pred : Integer -> Integer\n pred x = x - 1\n\n export\n toHexVector : List Direction -> HexVector\n toHexVector [] = MkHexVector 0 0 0\n toHexVector (East :: xs) = record { east $= succ } (toHexVector xs)\n toHexVector (SouthEast :: xs) = record { southeast $= succ } (toHexVector xs)\n toHexVector (SouthWest :: xs) = record { southwest $= succ } (toHexVector xs)\n toHexVector (West :: xs) = record { east $= pred } (toHexVector xs)\n toHexVector (NorthEast :: xs) = record { southwest $= pred } (toHexVector xs)\n toHexVector (NorthWest :: xs) = record { southeast $= pred } (toHexVector xs)\n\nrecord Coordinate where\n constructor MkCoordinate\n xCoord, yCoord : Integer\n\nEq Coordinate where\n (==) (MkCoordinate x y) (MkCoordinate x' y') = x == x' && y == y'\n\nShow Coordinate where\n show (MkCoordinate x y) = \"Coordinate \" ++ show x ++ \" \" ++ show y\n\ntoCoordinate : HexVector -> Coordinate\ntoCoordinate (MkHexVector east southeast southwest) = MkCoordinate x y where\n x : Integer\n x = 2 * east + southeast - southwest\n y : Integer\n y = southeast + southwest\n\nnamespace countElements\n -- removes duplicates\n export\n elements : Eq a => List a -> List a -> List a\n elements [] acc = acc\n elements (x :: xs) acc with (find (== x) acc)\n elements (x :: xs) acc | Nothing = elements xs (x :: acc)\n elements (x :: xs) acc | (Just _) = elements xs acc\n\n occurrences : Eq a => a -> List a -> Nat\n occurrences x [] = Z\n occurrences x (y :: xs) with (x == y)\n occurrences x (y :: xs) | True = S $ occurrences x xs\n occurrences x (y :: xs) | False = occurrences x xs\n\n export\n countElements : List Coordinate -> List (Coordinate,Nat)\n countElements xs = f <$> elements xs [] where\n f : Coordinate -> (Coordinate,Nat)\n f x = (x,occurrences x xs)\n\nmutual\n even : Nat -> Bool\n even Z = True\n even (S k) = odd k\n\n odd : Nat -> Bool\n odd Z = False\n odd (S k) = even k\n\nadjacentCoordinates : Coordinate -> List Coordinate\nadjacentCoordinates (MkCoordinate xCoord yCoord) =\n [ MkCoordinate (xCoord - 2) yCoord\n , MkCoordinate (xCoord + 2) yCoord\n , MkCoordinate (xCoord - 1) (yCoord + 1)\n , MkCoordinate (xCoord - 1) (yCoord - 1)\n , MkCoordinate (xCoord + 1) (yCoord + 1)\n , MkCoordinate (xCoord + 1) (yCoord - 1)\n ]\n\n-- adjacent to: c, list of blacks: cs\ncountAdjacentBlacks : Coordinate -> List Coordinate -> Nat\ncountAdjacentBlacks c cs = length $ filter id (f <$> adjacentCoordinates c) where\n f : Coordinate -> Bool\n f adjC = case find (== adjC) cs of\n Nothing => False\n (Just _) => True\n\nblacksToWhites : List Coordinate -> List Coordinate\nblacksToWhites blacks = elements (foldr f prepWhites blacks) [] where\n prepWhites : List Coordinate\n prepWhites = concat $ adjacentCoordinates <$> blacks\n f : Coordinate -> List Coordinate -> List Coordinate\n f c cs = filter (/= c) cs\n\nflipOnce : List Coordinate -> List Coordinate\nflipOnce blacks = newBlacks where\n whites : List Coordinate\n whites = blacksToWhites blacks\n blacksWithAdjacentBlacks : List (Coordinate,Nat)\n blacksWithAdjacentBlacks = (\\ c => (c,countAdjacentBlacks c blacks)) <$> blacks\n whitesWithAdjacentBlacks : List (Coordinate,Nat)\n whitesWithAdjacentBlacks = (\\ c => (c,countAdjacentBlacks c blacks)) <$> whites\n newBlacks : List Coordinate\n newBlacks = elements (map fst (filter (\\ (_,n) => not (n == 0 || n > 2)) blacksWithAdjacentBlacks ++ filter (\\ (_,n) => n == 2) whitesWithAdjacentBlacks)) []\n\nflipTimes : Nat -> List Coordinate -> List Coordinate\nflipTimes 0 cs = cs\nflipTimes (S n) cs = flipTimes n $ flipOnce cs\n\nmain : IO ()\nmain = do\n inputData <- readFile \"./data\"\n case inputData of\n Left err => print err\n Right dat => do\n let tokenList = unpack dat\n directions = parse dataGrammar tokenList\n case directions of\n (Left (Error err _)) => putStrLn err\n (Right (ds,cs)) => do\n --print ds\n let vecs = toHexVector <$> ds\n --print vecs\n let coords = toCoordinate <$> vecs\n --print coords\n let counts = countElements coords\n flips = snd <$> counts\n countBlacks = length $ filter odd flips\n --print countBlacks\n -- part 2\n let blackCountsOdd = filter (\\ (_,c) => odd c) counts\n blacks = fst <$> blackCountsOdd\n newBlacks = flipTimes 100 blacks\n countNewBlacks = length newBlacks\n print countNewBlacks\n pure ()\n pure ()\n", "meta": {"hexsha": "44e69075661d9f2f3573ddf4e2e8187ddbc97943", "size": 7144, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "24/Main.idr", "max_stars_repo_name": "jumper149/AoC2020", "max_stars_repo_head_hexsha": "a392b82234fb762278498ec637da871e9debf513", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "24/Main.idr", "max_issues_repo_name": "jumper149/AoC2020", "max_issues_repo_head_hexsha": "a392b82234fb762278498ec637da871e9debf513", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "24/Main.idr", "max_forks_repo_name": "jumper149/AoC2020", "max_forks_repo_head_hexsha": "a392b82234fb762278498ec637da871e9debf513", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.4727272727, "max_line_length": 159, "alphanum_fraction": 0.625699888, "num_tokens": 1923, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577159, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.533924670199814}} {"text": "> module FastSimpleProb.MeasuresProperties\n\n> import Data.So\n> import Syntax.PreorderReasoning\n\n> import FastSimpleProb.SimpleProb\n> import FastSimpleProb.BasicOperations\n> import FastSimpleProb.MonadicOperations\n> import FastSimpleProb.MonadicPostulates\n> import FastSimpleProb.MonadicProperties\n> import FastSimpleProb.Predicates\n> import FastSimpleProb.Functor\n> import FastSimpleProb.Measures\n> import Double.Predicates\n> import NonNegDouble.NonNegDouble\n> import NonNegDouble.Predicates\n> import NonNegDouble.BasicOperations\n> import NonNegDouble.Operations\n> import NonNegDouble.Properties\n> import NonNegDouble.Measures\n> import NonNegDouble.LTEProperties\n> import List.Operations\n> import List.Properties\n> import Fun.Operations\n> import Rel.TotalPreorder\n> import Pairs.Operations\n> import Functor.Predicates\n> import Functor.Properties\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n* Monotonicity (of |SimpleProb| measures):\n\n> ||| Monotonicity\n> Monotone : (SimpleProb NonNegDouble -> NonNegDouble) -> Type\n> Monotone = Functor.Predicates.Monotone {B = NonNegDouble} {C = NonNegDouble} {F = SimpleProb} LTE LTE \n\n\n\n* General monotonicity results\n\n> ||| |monotoneNaturalLemma| for |SimpleProb|s\n> normalizePreservesMonotonicity : (m : SimpleProb NonNegDouble -> NonNegDouble) -> \n> Monotone m -> \n> Monotone (m . normalize)\n> normalizePreservesMonotonicity m mm = \n> monotoneNaturalLemma {B = NonNegDouble} {C = NonNegDouble} {F = SimpleProb} \n> LTE LTE m mm normalize naturalNormalize\n\n\n* Monotonicity of measures\n\n> using implementation NumNonNegDouble\n> ||| |(uncurry (*)) . (cross f id)| is monotone\n> monotoneUncurryMultCrossId : {A : Type} ->\n> (f : A -> NonNegDouble) -> (g : A -> NonNegDouble) ->\n> (p : (a : A) -> f a `LTE` g a) ->\n> (ap : (A, NonNegDouble)) ->\n> uncurry (*) ((cross f id) ap) `LTE` uncurry (*) ((cross g id) ap)\n> monotoneUncurryMultCrossId {A} f g p (a, x) = s3 where\n> s1 : f a `LTE` g a\n> s1 = p a\n> s2 : (f a) * x `LTE` (g a) * x\n> s2 = monotoneMultLTE s1 (reflexiveLTE x)\n> s3 : uncurry (*) ((cross f id) (a, x)) `LTE` uncurry (*) ((cross g id) (a, x))\n> s3 = s2\n\n> using implementation NumNonNegDouble\n> ||| |sum| is monotone\n> monotoneSum : Monotone sum\n> monotoneSum = ms where\n> ms : {A : Type} ->\n> (f : A -> NonNegDouble) -> \n> (g : A -> NonNegDouble) -> \n> (p : (a : A) -> f a `LTE` g a) -> \n> (sp : SimpleProb A) -> \n> sum (map f sp) `LTE` sum (map g sp)\n> ms {A} f g p sp = s6 where \n> f' : (A, NonNegDouble) -> NonNegDouble\n> f' = uncurry (*) . (cross f id)\n> g' : (A, NonNegDouble) -> NonNegDouble\n> g' = uncurry (*) . (cross g id)\n> p' : (ap : (A, NonNegDouble)) -> f' ap `LTE` g' ap\n> p' = monotoneUncurryMultCrossId f g p \n> aps : List (A, NonNegDouble)\n> aps = toList sp\n> s1 : Prelude.Foldable.sum (map f' aps) `LTE` Prelude.Foldable.sum (map g' aps)\n> s1 = monotoneSum {A = (A, NonNegDouble)} f' g' p' aps \n> s2 : map f' aps = map (uncurry (*)) (toList (fmap f sp))\n> s2 = ( map f' aps )\n> ={ Refl }=\n> ( map ((uncurry (*)) . (cross f id)) aps )\n> ={ sym (mapFusion (uncurry (*)) (cross f id) aps) }=\n> ( map (uncurry (*)) (fmap (cross f id) aps) ) \n> ={ cong (sym (toListFmapLemma f sp)) }=\n> ( map (uncurry (*)) (toList (fmap f sp)) )\n> QED\n> s3 : map g' aps = map (uncurry (*)) (toList (fmap g sp))\n> s3 = ( map g' aps )\n> ={ Refl }=\n> ( map ((uncurry (*)) . (cross g id)) aps )\n> ={ sym (mapFusion (uncurry (*)) (cross g id) aps) }=\n> ( map (uncurry (*)) (fmap (cross g id) aps) ) \n> ={ cong (sym (toListFmapLemma g sp)) }=\n> ( map (uncurry (*)) (toList (fmap g sp)) )\n> QED\n> s4 : Prelude.Foldable.sum (map (uncurry (*)) (toList (fmap f sp))) `LTE` Prelude.Foldable.sum (map g' aps)\n> s4 = replace {P = \\ X => Prelude.Foldable.sum X `LTE` (Prelude.Foldable.sum (map g' aps))} s2 s1\n> s5 : Prelude.Foldable.sum (map (uncurry (*)) (toList (fmap f sp))) `LTE` Prelude.Foldable.sum (map (uncurry (*)) (toList (fmap g sp)))\n> s5 = replace {P = \\ X => Prelude.Foldable.sum (map (uncurry (*)) (toList (fmap f sp))) `LTE` Prelude.Foldable.sum X} s3 s4\n> s6 : sum (fmap f sp) `LTE` sum (fmap g sp)\n> s6 = s5\n\n> ||| |expectedValue| is monotone\n> monotoneExpectedValue : Monotone expectedValue\n> monotoneExpectedValue = normalizePreservesMonotonicity sum monotoneSum\n\n\n> {-\n\n\n> ---}\n", "meta": {"hexsha": "070eba8bd1daf7a78941601570301cce17cdb036", "size": 4864, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "FastSimpleProb/MeasuresProperties.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "FastSimpleProb/MeasuresProperties.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "FastSimpleProb/MeasuresProperties.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.6031746032, "max_line_length": 143, "alphanum_fraction": 0.5721628289, "num_tokens": 1562, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.6548947155710234, "lm_q1q2_score": 0.5338914433586878}} {"text": "import Data.Vect\n\nread_vect_len : (len : Nat) -> IO (Vect len String)\nread_vect_len Z = pure []\nread_vect_len (S k) = do x <- getLine\n xs <- read_vect_len k\n pure (x :: xs)\n\ndata VectUnknown : Type -> Type where\n MkVect : (len : Nat) -> Vect len a -> VectUnknown a\n\nread_vect : IO (len ** Vect len String)\nread_vect = do x <- getLine\n if (x == \"\")\n then pure (_ ** [])\n else do (_ ** xs) <- read_vect\n pure (_ ** x :: xs)\n\n", "meta": {"hexsha": "8828fd4b139254e54d44f59bc439b9a9651c28e5", "size": 545, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "depTypesTests.idr", "max_stars_repo_name": "janschultecom/idris-examples", "max_stars_repo_head_hexsha": "c0bf0105d69f07492c6b99f14e9ca3c4cd7443c8", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-05T15:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-05T15:26:06.000Z", "max_issues_repo_path": "depTypesTests.idr", "max_issues_repo_name": "janschultecom/idris-examples", "max_issues_repo_head_hexsha": "c0bf0105d69f07492c6b99f14e9ca3c4cd7443c8", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "depTypesTests.idr", "max_forks_repo_name": "janschultecom/idris-examples", "max_forks_repo_head_hexsha": "c0bf0105d69f07492c6b99f14e9ca3c4cd7443c8", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6842105263, "max_line_length": 53, "alphanum_fraction": 0.4733944954, "num_tokens": 135, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789086703224, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.5336334973046742}} {"text": "module Main\n\nimport Data.Fin\nimport Data.Vect\n\n--------------------------------------------------------------------------------\n-- Player\n\ndata Player = X | O | N -- N means nobody\ninstance Eq Player where\n X == X = True\n O == O = True\n N == N = True\n _ == _ = False\ninstance Show Player where\n show X = \"X\"\n show O = \"O\"\n show N = \" \"\n\notherPlayer : Player -> Player\notherPlayer p = case p of\n X => O\n O => X\n N => N\n\n--------------------------------------------------------------------------------\n-- BoardSquares (and accessors)\n\nBoardSquares : Type\nBoardSquares = Vect 9 Player\n\nblankBoardSquares : BoardSquares\nblankBoardSquares = [N,N,N,N,N,N,N,N,N]\n\nrows : BoardSquares -> Vect 3 (Vect 3 Player)\nrows [a,b,c,d,e,f,g,h,i] = [[a,b,c],[d,e,f],[g,h,i]]\n\ncols : BoardSquares -> Vect 3 (Vect 3 Player)\ncols sqs = transpose (rows sqs)\n\n--------------------------------------------------------------------------------\n-- Board (and Accessors)\n\nrecord Board : Type where\n MkBoard : (squares : BoardSquares) ->\n (whoseTurn : Player) -> Board\n\ninitialBoard : Board\ninitialBoard = MkBoard blankBoardSquares X\n\nBoardLocation : Type\nBoardLocation = Fin 9\n\n{-\n-- TODO: Need to fix type of (+) in the standard library first.\n-- Should be: (Fin n) -> (Fin m) -> (Fin (n + m - 1))\n-- But is instead: (Fin n) -> (Fin m) -> (Fin (n + m))\nmkBoardLocation : Fin 3 -> Fin 3 -> BoardLocation\nmkBoardLocation x y =\n (y + y + y) + x\n 3 5 7 9\n -}\n\nsquare : Board -> BoardLocation -> Player\nsquare b loc =\n index loc (squares b)\n\nisPositionOccupied : Board -> BoardLocation -> Bool\nisPositionOccupied b loc =\n (square b loc) /= N\n\n--------------------------------------------------------------------------------\n-- winner : BoardSquares -> Maybe Player\n\nallEqTo : Eq t => t -> Vect n t -> Bool\nallEqTo e Nil = True\nallEqTo e (x :: xs) = if x == e then (allEqTo e xs)\n else False\n\nallEq : Eq t => Vect n t -> Bool\nallEq Nil = True\nallEq (x :: xs) = allEqTo x xs\n\nwinnerInList : Vect (S n') Player -> Maybe Player\nwinnerInList (x :: xs) = \n let isWinner = allEq (x :: xs) in\n if isWinner then if x /= N then Just x\n else Nothing\n else Nothing\n\n-- TODO: Surely this is in the standard library...\nfirstJust : Vect n (Maybe t) -> Maybe t\nfirstJust Nil = Nothing\nfirstJust (m :: ms) =\n case m of\n Nothing => firstJust ms\n Just x => Just x\n\n-- TODO: Surely this is in the standard library...\nfirstJust' : List (Maybe t) -> Maybe t\nfirstJust' Nil = Nothing\nfirstJust' (m :: ms) =\n case m of\n Nothing => firstJust' ms\n Just x => Just x\n\nwinnerRowCol : BoardSquares -> Maybe Player\nwinnerRowCol sqs = firstJust' [firstJust (map winnerInList (rows sqs)),\n firstJust (map winnerInList (cols sqs))]\n\nwinnerDiag : BoardSquares -> Maybe Player\nwinnerDiag [a,b,c,d,e,f,g,h,i] = \n if a == e && e == i && a /= N then Just a\n else if c == e && e == g && c /= N then Just c\n else Nothing\n\n{-\n-- TODO: Surely this is in the standard library...\n-- TODO: Figure out why I can't match on Nil. Compile error.\n-- TODO: Rename \"eType\" to \"E\" without confusing the compiler.\n-- TODO: Reorder arguments to be: Vect n eType -> eType -> Maybe (Fin n)\nindexOf : Eq eType => {n:Nat} -> eType -> Vect n eType -> Maybe (Fin n)\nindexOf {n} e v =\n case v of\n Nil => \n Nothing\n x::xs => \n case (x == e) of\n True =>\n Just (the (Fin n) 0)\n False =>\n case (indexOf e xs) of\n Just index => index + 1 -- NOTE: requires linear memory\n Nothing => Nothing\n-}\n\n-- TODO: Surely this is in the standard library...\ncontains : Eq eType => Vect n eType -> eType -> Bool\ncontains Nil e =\n False\ncontains (x::xs) e =\n (e == x) || (contains xs e)\n\nwinnerTie : BoardSquares -> Maybe Player\nwinnerTie sqs =\n if (contains sqs N) then Nothing\n else Just N\n\nwinner : BoardSquares -> Maybe Player\nwinner sqs = firstJust' [winnerRowCol sqs, winnerDiag sqs, winnerTie sqs]\n\n--------------------------------------------------------------------------------\n-- Board Mutators\n\n-- TODO: Exercise: Refuse to play at an occupied location at *compile* time\n-- TODO: Exercise: Refuse to play if there is a winner at *compile* time\nmove : Board -> BoardLocation -> Maybe Board\nmove b loc = \n if (not (isJust (winner (squares b)))) &&\n (not (isPositionOccupied b loc)) then\n Just (MkBoard (replaceAt loc (whoseTurn b) (squares b))\n (otherPlayer (whoseTurn b)))\n else\n Nothing\n\n-- TODO: Implement a takeMoveBack method\n-- TODO: Exercise: Refuse to take back a move on an empty board at *compile* time\n\n--------------------------------------------------------------------------------\n-- Main\n\n-- NOTE: Implementation is probably quadratic time unless recursive string\n-- appends are specially optimized. Unlikely.\n-- \n-- TODO: Figure out how to make this work with (List String)\n-- in addition to (Vect n String). Probably some kind of\n-- type generalization is required.\nintercalateAcc : String -> Vect n String -> String -> String\nintercalateAcc separator Nil result =\n result\nintercalateAcc separator (x::xs) result =\n intercalateAcc separator xs (result ++ separator ++ x)\n\nintercalate : String -> Vect n String -> String\nintercalate separator Nil =\n \"\"\nintercalate separator (x::xs) =\n intercalateAcc separator xs x\n\nformatCell : Player -> String\nformatCell cell =\n \" \" ++ (show cell) ++ \" \"\n\nformatBoardRow : Vect 3 Player -> String\nformatBoardRow row = \n intercalate \"|\" (map formatCell row)\n\nformatBoardSquares : BoardSquares -> String\nformatBoardSquares sqs = \n intercalate \"\\n---|---|---\\n\" (map formatBoardRow (rows sqs))\n\nformatBoard : Board -> String\nformatBoard board =\n formatBoardSquares (squares board)\n\ninputFin : (n:Nat) -> IO (Fin n)\ninputFin n = do\n line <- getLine\n -- TODO: Detect and reject non-integer input\n let int = the Integer (cast line)\n case (integerToFin int n) of\n Just int' => return int'\n Nothing => inputFin n -- out of bounds; try again\n\nrunGame : Board -> IO ()\nrunGame board = do\n putStrLn (formatBoard board)\n putStrLn \"\"\n case (winner (squares board)) of\n Just theWinner =>\n case theWinner of\n N => putStrLn \"Tie!\"\n _ => putStrLn ((show theWinner) ++ \" wins!\")\n Nothing => do\n putStr \"Next move? (0-8) \"\n loc' <- inputFin 9 \n putStrLn \"\"\n let loc = the BoardLocation loc'\n case (move board loc) of\n Just newBoard => runGame newBoard\n Nothing => runGame board -- illegal move; try again\n\nmain : IO ()\nmain = do\n runGame initialBoard\n ", "meta": {"hexsha": "8516c077e57cae4592ba54adbc8eb6bf88453aba", "size": 7067, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TicTacToe.idr", "max_stars_repo_name": "davidfstr/tic-tac-idris", "max_stars_repo_head_hexsha": "5cc06d22788eacf556ac84abac54d4a16d6184a8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-08-22T08:38:04.000Z", "max_stars_repo_stars_event_max_datetime": "2017-08-22T08:38:04.000Z", "max_issues_repo_path": "TicTacToe.idr", "max_issues_repo_name": "davidfstr/tic-tac-idris", "max_issues_repo_head_hexsha": "5cc06d22788eacf556ac84abac54d4a16d6184a8", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TicTacToe.idr", "max_forks_repo_name": "davidfstr/tic-tac-idris", "max_forks_repo_head_hexsha": "5cc06d22788eacf556ac84abac54d4a16d6184a8", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.9449152542, "max_line_length": 81, "alphanum_fraction": 0.5505872365, "num_tokens": 1820, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.5333084380900913}} {"text": "\nmodule MSubst\n\n-- Multiple substitution in order to\n-- turn a term that is well-typed in\n-- a context into a closed term (i.e.\n-- into a term that is well-typed in\n-- the empty context).\n\n\nimport R\nimport Subst\nimport SubstLemmas\nimport Term\nimport Typing\n\n\n%default total\n%access export\n\n\n\n-------------------------------------------------------------\n-- Begin: VALUE ENVIRONMENT THAT IS COMPATIBLE WITH A CONTEXT\n\npublic export\ndata VEnv : Context -> Type where\n VNil : VEnv []\n VCons : (e : Term) -> Value e -> r s e ->\n VEnv ctx -> \n VEnv (s::ctx) \n\n-- End: VALUE ENVIRONMENT THAT IS COMPATIBLE WITH A CONTEXT\n-----------------------------------------------------------\n\n\n \n\n-------------------------------\n-- Begin: MULTIPLE SUBSTITUTION\n\npublic export\nmsubst : Term -> (i : Nat) -> VEnv ctx -> Term\nmsubst e _ VNil = e\nmsubst e i (VCons x _ _ venv) = \n let e' = subst x i e\n in msubst e' i venv\n\n-- End: MULTIPLE SUBSTITUTION\n-----------------------------\n\n\n\n\n-------------------\n-- Begin: WEAKENING\n\n-- Weakening means extending a typing context\n-- of a term 'e' on the right. This leaves the\n-- de Bruijn indices that are referenced in 'e'\n-- unchanged.\n-- Weakening can be implemented with the 'shiftTerm'\n-- operation by using a cutoff that is exactly the\n-- length of the typing context.\n-- Weakening is useful in the subsequent reasoning\n-- about the 'msubst' operation.\n\nweaken : (e : Term) -> \n Typing ctx e t ->\n Context ->\n Term\nweaken e {ctx} _ ctx' = shiftTerm (length ctx) (length ctx') e\n\n\n\n-- Weakening does not actually change a term:\nweakenIdentity : (e : Term) ->\n (ty : Typing ctx e t) ->\n (ctx' : Context) ->\n weaken e ty ctx' = e\nweakenIdentity e {ctx} ty ctx' = \n let eq1 = shiftTermPastCtx e ctx ty Z (length ctx') \n eq2 = plusZeroRightNeutral (length ctx)\n eq3 = cong {f = \\q => shiftTerm q (length ctx') e} (sym eq2)\n in trans eq3 eq1\n\n\n\n-- Weakening preserves typing, albeit in\n-- an extended context:\nweakenPreservesTy : (e : Term) ->\n (ty : Typing ctx e t) ->\n (ctx' : Context) ->\n Typing (ctx++ctx') (weaken e ty ctx') t\nweakenPreservesTy e {ctx} {t} ty ctx' = \n let eq1 = appendNilRightNeutral ctx\n ty1 = replace {P = \\q => Typing q e t} (sym eq1) ty\n ty2 = shiftTermTy e {ctx1=ctx} {ctx2=[]} ty1 ctx'\n e' = shiftTerm (length ctx) (length ctx') e\n eq2 = appendNilRightNeutral ctx'\n in replace {P = \\q => Typing (ctx++q) e' t} eq2 ty2\n\n-- End: WEAKENING\n-----------------\n\n\n\n\n--------------------------------------------\n-- Begin: LEMMAS ABOUT MULTIPLE SUBSTITUTION\n\n-- Multiple substitution preserves typing:\nmSubstPreservesTy : (e : Term) ->\n Typing (ctx1++ctx2) e t ->\n (venv : VEnv ctx2) ->\n Typing ctx1 (msubst e (length ctx1) venv) t\nmSubstPreservesTy e ty {t} VNil {ctx1} =\n let eq = appendNilRightNeutral ctx1\n in replace {P = \\q => Typing q e t} eq ty\nmSubstPreservesTy e ty {t} (VCons x _ rx venv) {ctx1} {ctx2 = s::ctx2} = \n let tyx = rTyping x rx\n x' = weaken x tyx ctx2\n tyx1 = weakenPreservesTy x tyx ctx2\n ty' = substPreservesTy {ctx1=ctx1} e ty x' tyx1\n eq1 = weakenIdentity x tyx ctx2\n ty'' = replace {P = \\q => Typing (ctx1++ctx2) (subst q (length ctx1) e) t} eq1 ty'\n in mSubstPreservesTy (subst x (length ctx1) e) ty'' venv\n\n\n\n-- Multiple substitution acts as the identity\n-- on an expression 'e' if 'e' is typed in the\n-- context 'ctx' but multiple substitution only\n-- takes place at an index 'i' that is equal to\n-- or greater than 'length ctx':\nmSubstPastCtx : (e : Term) ->\n (ctx : Context) ->\n (Typing ctx e t) ->\n (venv : VEnv ctx') ->\n msubst e (length ctx) venv = e\nmSubstPastCtx e ctx ty VNil = Refl\nmSubstPastCtx e ctx ty (VCons x _ rx venv) {t} {ctx' = s::ctx'} = \n let e' = weaken e ty [s]\n ty1 = weakenPreservesTy e ty [s]\n tyx = rTyping x rx \n ty2 = substPreservesTy {ctx1=ctx} {ctx2=[]} e' ty1 x tyx\n eq1 = appendNilRightNeutral ctx\n ty3 = replace {P = \\q => Typing q (subst x (length ctx) e') t} eq1 ty2\n eq2 = weakenIdentity e ty [s]\n ty4 = replace {P = \\q => Typing ctx (subst x (length ctx) q) t} eq2 ty3\n ih = mSubstPastCtx (subst x (length ctx) e) ctx ty4 venv\n eq3 = substPastCtx e ctx ty {n=0}\n eq4 = cong {f = \\q => subst x q e} $ plusZeroRightNeutral (length ctx)\n eq5 = trans (sym eq4) eq3\n in trans ih eq5\n\n\n\n-- Multiple subsitution commutes with (ordinary) substitution:\nmSubstSubstSwap : (e : Term) -> \n (i : Nat) -> (venv : VEnv ctx) ->\n (y : Term) -> Typing [] y s ->\n subst y i (msubst e (S i) venv) = msubst (subst y i e) i venv\nmSubstSubstSwap e i VNil y tyy = Refl\nmSubstSubstSwap e i (VCons x _ _ venv) y tyy = \n let eq1 = substSwap e i y x tyy\n eq2 = cong {f = \\q => msubst q i venv} eq1\n ih = mSubstSubstSwap (subst x (S i) e) i venv y tyy\n in trans ih (sym eq2)\n\n\n-- Following multiple substitution with an ordinary\n-- substitution amounts to multiple substitution in\n-- an extended environment:\nmSubstSubstSwap' : (e : Term) -> \n (i : Nat) -> (venv : VEnv ctx) ->\n (y : Term) -> (vy : Value y) -> (ry : r s y) ->\n subst y i (msubst e (S i) venv) = msubst e i (VCons y vy ry venv)\nmSubstSubstSwap' e i venv y vy ry = mSubstSubstSwap e i venv y (rTyping y ry)\n\n-- End: LEMMAS ABOUT MULTIPLE SUBSTITUTION\n------------------------------------------\n\n\n\n\n---------------------------------------------------------------\n-- Begin: MULTIPLE SUBSTITUTION COMMUTES WITH TERM CONSTRUCTORS\n\nmSubstAbsComm : (e : Term) -> \n (i : Nat) -> (venv : VEnv ctx) ->\n TAbs (msubst e (S i) venv) = msubst (TAbs e) i venv\nmSubstAbsComm e _ VNil = Refl\nmSubstAbsComm e i (VCons x _ _ venv) = mSubstAbsComm (subst x (S i) e) i venv\n\n \n \nmSubstAppComm : (e1 : Term) -> (e2 : Term) ->\n (i : Nat) -> (venv : VEnv ctx) ->\n TApp (msubst e1 i venv) (msubst e2 i venv) = msubst (TApp e1 e2) i venv\nmSubstAppComm e1 e2 i VNil = Refl\nmSubstAppComm e1 e2 i (VCons x _ _ venv) = \n mSubstAppComm (subst x i e1) (subst x i e2) i venv\n\n\n\nmSubstRecComm : (e1 : Term) -> (e2 : Term) -> (e3 : Term) ->\n (i : Nat) -> (venv : VEnv ctx) ->\n TRec (msubst e1 i venv) (msubst e2 i venv) (msubst e3 i venv) =\n msubst (TRec e1 e2 e3) i venv\nmSubstRecComm e1 e2 e3 i VNil = Refl\nmSubstRecComm e1 e2 e3 i (VCons x _ _ venv) =\n mSubstRecComm (subst x i e1) (subst x i e2) (subst x i e3) i venv\n\n\n\nmSubstSuccComm : (e : Term) ->\n (i : Nat) -> (venv : VEnv ctx) ->\n TSucc (msubst e i venv) = msubst (TSucc e) i venv\nmSubstSuccComm e i VNil = Refl\nmSubstSuccComm e i (VCons x _ _ venv) = \n mSubstSuccComm (subst x i e) i venv\n\n\n\nmSubstPredComm : (e : Term) ->\n (i : Nat) -> (venv : VEnv ctx) ->\n TPred (msubst e i venv) = msubst (TPred e) i venv\nmSubstPredComm e i VNil = Refl\nmSubstPredComm e i (VCons x _ _ venv) = \n mSubstPredComm (subst x i e) i venv\n\n\n\nmSubstIfzComm : (e1 : Term) -> (e2 : Term) -> (e3 : Term) ->\n (i : Nat) -> (venv : VEnv ctx) ->\n TIfz (msubst e1 i venv) (msubst e2 i venv) (msubst e3 i venv) =\n msubst (TIfz e1 e2 e3) i venv\nmSubstIfzComm e1 e2 e3 i VNil = Refl\nmSubstIfzComm e1 e2 e3 i (VCons x _ _ venv) =\n mSubstIfzComm (subst x i e1) (subst x i e2) (subst x i e3) i venv\n\n-- End: MULTIPLE SUBSTITUTION COMMUTES WITH TERM CONSTRUCTORS\n-------------------------------------------------------------\n", "meta": {"hexsha": "d5ca85d217b8ef404e7993ca512b300c74d56008", "size": 7805, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "totality/src/MSubst.idr", "max_stars_repo_name": "normanrink/PCF", "max_stars_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "totality/src/MSubst.idr", "max_issues_repo_name": "normanrink/PCF", "max_issues_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "totality/src/MSubst.idr", "max_forks_repo_name": "normanrink/PCF", "max_forks_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8571428571, "max_line_length": 88, "alphanum_fraction": 0.5584881486, "num_tokens": 2559, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.5332302783645315}} {"text": "||| Defines functions to use in place of `RegExp`'s data constructors, in order to create\n||| regular expressions which are \"normalized\" to a canonical form as much as possible. This adds\n||| some compile-time complexity but results in smaller DFAs for testing language membership.\nmodule RegExp.Equivalences\n\nimport Data.List\nimport Decidable.Equality\n\nimport public RegExp.Types\n\n%default total\n\n||| Constructs a \"normalized\" `Cat`, which applies the following rules:\n||| - ∅ · r ≈ ∅\n||| - r · ∅ ≈ ∅\n||| - ε · r ≈ r\n||| - r · ε ≈ r\n||| - (r · s) · t ≈ r · (s · t)\nexport\nnormCat : DecEq a => RegExp a -> RegExp a -> RegExp a\nnormCat Null _ = Null\nnormCat _ Null = Null\nnormCat Empty r = r\nnormCat r Empty = r\nnormCat (Cat r s) t = Cat r (Cat s t)\nnormCat r s = Cat r s\n\n||| Constructs a \"normalized\" `Disj`, which applies the following rules:\n|||\n||| - ∅ + r ≈ r\n||| - r + r ≈ r\n||| - (r + s) + t ≈ r + (s + t)\n|||\n||| Note that the remaining equivalence (symmetry) is not captured:\n|||\n||| - r + s ≈ s + r\nexport\nnormDisj : DecEq a => RegExp a -> RegExp a -> RegExp a\nnormDisj Null r = r\nnormDisj r Null = r\nnormDisj r s with (decEq r s)\n normDisj r r | (Yes Refl) = r\n normDisj (Disj r s) t | (No _) = Disj r (Disj s t)\n normDisj r s | (No _) = Disj r s\n\n||| Constructs a \"normalized\" `Conj`, which applies the following rules:\n||| - ∅ & r ≈ ∅\n||| - r & r ≈ r\n||| - (r & s) & t ≈ r & (s & t)\n|||\n||| Note that the remaining equivalence (symmetry) is not captured:\n|||\n||| - r & s ≈ s & r\nexport\nnormConj : DecEq a => RegExp a -> RegExp a -> RegExp a\nnormConj Null _ = Null\nnormConj _ Null = Null\nnormConj r s with (decEq r s)\n normConj r r | (Yes Refl) = r\n normConj (Conj r s) t | (No _) = Conj r (Conj s t)\n normConj r s | (No _) = Conj r s\n\n||| Proof (by exhaustion) that `normCat` is sound.\nexport\nnormCat_isSound : DecEq a =>\n {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (normCat r s) xs ->\n Matches (Cat r s) xs\nnormCat_isSound {r=Null} {s} p = absurd p\nnormCat_isSound {r=Empty} {s=Null} p = absurd p\nnormCat_isSound {r=Empty} {s=Empty} p = InCat Refl InEmpty p\nnormCat_isSound {r=Empty} {s=(Lit _)} p = InCat Refl InEmpty p\nnormCat_isSound {r=Empty} {s=(Cat _ _)} p = InCat Refl InEmpty p\nnormCat_isSound {r=Empty} {s=(Disj _ _)} p = InCat Refl InEmpty p\nnormCat_isSound {r=Empty} {s=(Conj _ _)} p = InCat Refl InEmpty p\nnormCat_isSound {r=Empty} {s=(Star _)} p = InCat Refl InEmpty p\nnormCat_isSound {r=(Lit _)} {s=Null} p = absurd p\nnormCat_isSound {xs} {r=(Lit _)} {s=Empty} p = InCat (sym $ appendNilRightNeutral xs) p InEmpty\nnormCat_isSound {r=(Lit _)} {s=(Lit _)} p = p\nnormCat_isSound {r=(Lit _)} {s=(Cat _ _)} p = p\nnormCat_isSound {r=(Lit _)} {s=(Disj _ _)} p = p\nnormCat_isSound {r=(Lit _)} {s=(Conj _ _)} p = p\nnormCat_isSound {r=(Lit _)} {s=(Star _)} p = p\nnormCat_isSound {r=(Cat _ _)} {s=Null} p = absurd p\nnormCat_isSound {xs} {r=(Cat _ _)} {s=Empty} p = InCat (sym $ appendNilRightNeutral xs) p InEmpty\nnormCat_isSound {xs=xs++(ys++zs)} {r=(Cat _ _)} {s=(Lit _)} (InCat {xs} {ys=ys++zs} Refl pr (InCat {xs=ys} {ys=zs} Refl ps pl)) =\n InCat (appendAssociative xs ys zs) (InCat Refl pr ps) pl\nnormCat_isSound {xs=xs++(ys++zs)} {r=(Cat _ _)} {s=(Cat _ _)} (InCat {xs} {ys=ys++zs} Refl pr (InCat {xs=ys} {ys=zs} Refl ps pl)) =\n InCat (appendAssociative xs ys zs) (InCat Refl pr ps) pl\nnormCat_isSound {xs=xs++(ys++zs)} {r=(Cat _ _)} {s=(Disj _ _)} (InCat {xs} {ys=ys++zs} Refl pr (InCat {xs=ys} {ys=zs} Refl ps pl)) =\n InCat (appendAssociative xs ys zs) (InCat Refl pr ps) pl\nnormCat_isSound {xs=xs++(ys++zs)} {r=(Cat _ _)} {s=(Conj _ _)} (InCat {xs} {ys=ys++zs} Refl pr (InCat {xs=ys} {ys=zs} Refl ps pl)) =\n InCat (appendAssociative xs ys zs) (InCat Refl pr ps) pl\nnormCat_isSound {xs=xs++(ys++zs)} {r=(Cat _ _)} {s=(Star _)} (InCat {xs} {ys=ys++zs} Refl pr (InCat {xs=ys} {ys=zs} Refl ps pl)) =\n InCat (appendAssociative xs ys zs) (InCat Refl pr ps) pl\nnormCat_isSound {r=(Disj _ _)} {s=Null} p = absurd p\nnormCat_isSound {xs} {r=(Disj _ _)} {s=Empty} p = InCat (sym $ appendNilRightNeutral xs) p InEmpty\nnormCat_isSound {r=(Disj _ _)} {s=(Lit z)} p = p\nnormCat_isSound {r=(Disj _ _)} {s=(Cat z w)} p = p\nnormCat_isSound {r=(Disj _ _)} {s=(Disj z w)} p = p\nnormCat_isSound {r=(Disj _ _)} {s=(Conj z w)} p = p\nnormCat_isSound {r=(Disj _ _)} {s=(Star z)} p = p\nnormCat_isSound {r=(Conj _ _)} {s=Null} p = absurd p\nnormCat_isSound {xs} {r=(Conj _ _)} {s=Empty} p = InCat (sym $ appendNilRightNeutral xs) p InEmpty\nnormCat_isSound {r=(Conj _ _)} {s=(Lit z)} p = p\nnormCat_isSound {r=(Conj _ _)} {s=(Cat z w)} p = p\nnormCat_isSound {r=(Conj _ _)} {s=(Disj z w)} p = p\nnormCat_isSound {r=(Conj _ _)} {s=(Conj z w)} p = p\nnormCat_isSound {r=(Conj _ _)} {s=(Star z)} p = p\nnormCat_isSound {r=(Star _)} {s=Null} p = absurd p\nnormCat_isSound {xs} {r=(Star _)} {s=Empty} p = InCat (sym $ appendNilRightNeutral xs) p InEmpty\nnormCat_isSound {r=(Star _)} {s=(Lit y)} p = p\nnormCat_isSound {r=(Star _)} {s=(Cat y z)} p = p\nnormCat_isSound {r=(Star _)} {s=(Disj y z)} p = p\nnormCat_isSound {r=(Star _)} {s=(Conj y z)} p = p\nnormCat_isSound {r=(Star _)} {s=(Star y)} p = p\n\n||| Proof (by exhaustion) that `normCat` is complete.\nexport\nnormCat_isComplete : DecEq a =>\n {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (Cat r s) xs ->\n Matches (normCat r s) xs\nnormCat_isComplete {r=Null} (InCat _ pr _) = absurd pr\nnormCat_isComplete {s=Null} (InCat _ _ ps) = absurd ps\nnormCat_isComplete {r=Empty} {s=Empty} (InCat pCat InEmpty ps) = rewrite pCat in ps\nnormCat_isComplete {r=Empty} {s=(Lit _)} (InCat pCat InEmpty ps) = rewrite pCat in ps\nnormCat_isComplete {r=Empty} {s=(Cat _ _)} (InCat pCat InEmpty ps) = rewrite pCat in ps\nnormCat_isComplete {r=Empty} {s=(Disj _ _)} (InCat pCat InEmpty ps) = rewrite pCat in ps\nnormCat_isComplete {r=Empty} {s=(Conj _ _)} (InCat pCat InEmpty ps) = rewrite pCat in ps\nnormCat_isComplete {r=Empty} {s=(Star _)} (InCat pCat InEmpty ps) = rewrite pCat in ps\nnormCat_isComplete {r=(Lit _)} {s=Empty} (InCat {xs} Refl pr InEmpty) = rewrite (appendNilRightNeutral xs) in pr\nnormCat_isComplete {r=(Lit _)} {s=(Lit _)} p = p\nnormCat_isComplete {r=(Lit _)} {s=(Cat _ _)} p = p\nnormCat_isComplete {r=(Lit _)} {s=(Disj _ _)} p = p\nnormCat_isComplete {r=(Lit _)} {s=(Conj _ _)} p = p\nnormCat_isComplete {r=(Lit _)} {s=(Star _)} p = p\nnormCat_isComplete {r=(Cat _ _)} {s=Empty} (InCat {xs} Refl pr InEmpty) = rewrite (appendNilRightNeutral xs) in pr\nnormCat_isComplete {xs=(xs'++ys)++[x]} {r=(Cat _ _)} {s=(Lit x)} (InCat {xs=xs'++ys} {ys=[x]} Refl (InCat {xs=xs'} {ys} Refl pr ps) InLit) =\n InCat (sym $ appendAssociative xs' ys [x]) pr (InCat Refl ps InLit)\nnormCat_isComplete {xs=(xs'++ys)++zs} {r=(Cat _ _)} {s=(Cat _ _)} (InCat {xs=xs'++ys} {ys=zs} Refl (InCat {xs=xs'} {ys} Refl pr ps) pt) =\n InCat (sym $ appendAssociative xs' ys zs) pr (InCat Refl ps pt)\nnormCat_isComplete {xs=(xs'++ys)++zs} {r=(Cat _ _)} {s=(Disj _ _)} (InCat {xs=xs'++ys} {ys=zs} Refl (InCat {xs=xs'} {ys} Refl pr ps) pt) =\n InCat (sym $ appendAssociative xs' ys zs) pr (InCat Refl ps pt)\nnormCat_isComplete {xs=(xs'++ys)++zs} {r=(Cat _ _)} {s=(Conj _ _)} (InCat {xs=xs'++ys} {ys=zs} Refl (InCat {xs=xs'} {ys} Refl pr ps) pt) =\n InCat (sym $ appendAssociative xs' ys zs) pr (InCat Refl ps pt)\nnormCat_isComplete {xs=(xs'++ys)++zs} {r=(Cat _ _)} {s=(Star _)} (InCat {xs=xs'++ys} {ys=zs} Refl (InCat {xs=xs'} {ys} Refl pr ps) pt) =\n InCat (sym $ appendAssociative xs' ys zs) pr (InCat Refl ps pt)\nnormCat_isComplete {r=(Disj _ _)} {s=Empty} (InCat {xs} Refl pr InEmpty) = rewrite (appendNilRightNeutral xs) in pr\nnormCat_isComplete {r=(Disj _ _)} {s=(Lit _)} p = p\nnormCat_isComplete {r=(Disj _ _)} {s=(Cat _ _)} p = p\nnormCat_isComplete {r=(Disj _ _)} {s=(Disj _ _)} p = p\nnormCat_isComplete {r=(Disj _ _)} {s=(Conj _ _)} p = p\nnormCat_isComplete {r=(Disj _ _)} {s=(Star _)} p = p\nnormCat_isComplete {r=(Conj _ _)} {s=Empty} (InCat {xs} Refl pr InEmpty) = rewrite (appendNilRightNeutral xs) in pr\nnormCat_isComplete {r=(Conj _ _)} {s=(Lit _)} p = p\nnormCat_isComplete {r=(Conj _ _)} {s=(Cat _ _)} p = p\nnormCat_isComplete {r=(Conj _ _)} {s=(Disj _ _)} p = p\nnormCat_isComplete {r=(Conj _ _)} {s=(Conj _ _)} p = p\nnormCat_isComplete {r=(Conj _ _)} {s=(Star _)} p = p\nnormCat_isComplete {r=(Star _)} {s=Empty} (InCat {xs} Refl pr InEmpty) = rewrite (appendNilRightNeutral xs) in pr\nnormCat_isComplete {r=(Star _)} {s=(Lit _)} p = p\nnormCat_isComplete {r=(Star _)} {s=(Cat _ _)} p = p\nnormCat_isComplete {r=(Star _)} {s=(Disj _ _)} p = p\nnormCat_isComplete {r=(Star _)} {s=(Conj _ _)} p = p\nnormCat_isComplete {r=(Star _)} {s=(Star _)} p = p\n\n||| Proof (by exhaustion) that `normDisj` is sound.\nexport\nnormDisj_isSound : DecEq a =>\n {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (normDisj r s) xs ->\n Matches (Disj r s) xs\nnormDisj_isSound {r=Null} p = InDisjR p\nnormDisj_isSound {r=Empty} {s=Null} p = InDisjL p\nnormDisj_isSound {r=Empty} {s=Empty} p = p\nnormDisj_isSound {r=Empty} {s=(Lit _)} p = p\nnormDisj_isSound {r=Empty} {s=(Cat _ _)} p = p\nnormDisj_isSound {r=Empty} {s=(Disj _ _)} p = p\nnormDisj_isSound {r=Empty} {s=(Conj _ _)} p = p\nnormDisj_isSound {r=Empty} {s=(Star _)} p = p\nnormDisj_isSound {r=(Lit _)} {s=Null} p = InDisjL p\nnormDisj_isSound {r=(Lit _)} {s=Empty} p = p\nnormDisj_isSound {r=(Lit x)} {s=(Lit y)} p with (decEq x y)\n normDisj_isSound {r=(Lit x)} {s=(Lit x)} p | (Yes Refl) = InDisjL p\n normDisj_isSound {r=(Lit x)} {s=(Lit y)} p | (No _) = p\nnormDisj_isSound {r=(Lit _)} {s=(Cat _ _)} p = p\nnormDisj_isSound {r=(Lit _)} {s=(Disj _ _)} p = p\nnormDisj_isSound {r=(Lit _)} {s=(Conj _ _)} p = p\nnormDisj_isSound {r=(Lit _)} {s=(Star _)} p = p\nnormDisj_isSound {r=(Cat _ _)} {s=Null} p = InDisjL p\nnormDisj_isSound {r=(Cat _ _)} {s=Empty} p = p\nnormDisj_isSound {r=(Cat _ _)} {s=(Lit _)} p = p\nnormDisj_isSound {r=(Cat r s)} {s=(Cat t u)} p with (decEq r t)\n normDisj_isSound {r=(Cat r s)} {s=(Cat r u)} p | (Yes Refl) with (decEq s u)\n normDisj_isSound {r=(Cat r s)} {s=(Cat r s)} p | (Yes Refl) | (Yes Refl) = InDisjL p\n normDisj_isSound {r=(Cat r s)} {s=(Cat r u)} p | (Yes Refl) | (No _) = p\n normDisj_isSound {r=(Cat r s)} {s=(Cat t u)} p | (No _) = p\nnormDisj_isSound {r=(Cat _ _)} {s=(Disj _ _)} p = p\nnormDisj_isSound {r=(Cat _ _)} {s=(Conj _ _)} p = p\nnormDisj_isSound {r=(Cat _ _)} {s=(Star _)} p = p\nnormDisj_isSound {r=(Disj _ _)} {s=Null} p = InDisjL p\nnormDisj_isSound {r=(Disj _ _)} {s=Empty} (InDisjL p) = InDisjL (InDisjL p)\nnormDisj_isSound {r=(Disj _ _)} {s=Empty} (InDisjR (InDisjL p)) = InDisjL (InDisjR p)\nnormDisj_isSound {r=(Disj _ _)} {s=Empty} (InDisjR (InDisjR p)) = InDisjR p\nnormDisj_isSound {r=(Disj _ _)} {s=(Lit _)} (InDisjL p) = InDisjL (InDisjL p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Lit _)} (InDisjR (InDisjL p)) = InDisjL (InDisjR p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Lit _)} (InDisjR (InDisjR p)) = InDisjR p\nnormDisj_isSound {r=(Disj _ _)} {s=(Cat _ _)} (InDisjL p) = InDisjL (InDisjL p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Cat _ _)} (InDisjR (InDisjL p)) = InDisjL (InDisjR p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Cat _ _)} (InDisjR (InDisjR p)) = InDisjR p\nnormDisj_isSound {r=(Disj r s)} {s=(Disj t u)} p with (decEq r t)\n normDisj_isSound {r=(Disj r s)} {s=(Disj r u)} p | (Yes Refl) with (decEq s u)\n normDisj_isSound {r=(Disj r s)} {s=(Disj r s)} p | (Yes Refl) | (Yes Refl) = InDisjL p\n normDisj_isSound {r=(Disj r s)} {s=(Disj r u)} (InDisjL p) | (Yes Refl) | (No _) = InDisjL (InDisjL p)\n normDisj_isSound {r=(Disj r s)} {s=(Disj r u)} (InDisjR (InDisjL p)) | (Yes Refl) | (No _) = InDisjL (InDisjR p)\n normDisj_isSound {r=(Disj r s)} {s=(Disj r u)} (InDisjR (InDisjR p)) | (Yes Refl) | (No _) = InDisjR p\n normDisj_isSound {r=(Disj r s)} {s=(Disj t u)} (InDisjL p) | (No _) = InDisjL (InDisjL p)\n normDisj_isSound {r=(Disj r s)} {s=(Disj t u)} (InDisjR (InDisjL p)) | (No _) = InDisjL (InDisjR p)\n normDisj_isSound {r=(Disj r s)} {s=(Disj t u)} (InDisjR (InDisjR p)) | (No _) = InDisjR p\nnormDisj_isSound {r=(Disj _ _)} {s=(Conj _ _)} (InDisjL p) = InDisjL (InDisjL p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Conj _ _)} (InDisjR (InDisjL p)) = InDisjL (InDisjR p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Conj _ _)} (InDisjR (InDisjR p)) = InDisjR p\nnormDisj_isSound {r=(Disj _ _)} {s=(Star _)} (InDisjL p) = InDisjL (InDisjL p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Star _)} (InDisjR (InDisjL p)) = InDisjL (InDisjR p)\nnormDisj_isSound {r=(Disj _ _)} {s=(Star _)} (InDisjR (InDisjR p)) = InDisjR p\nnormDisj_isSound {r=(Conj _ _)} {s=Null} p = InDisjL p\nnormDisj_isSound {r=(Conj _ _)} {s=Empty} p = p\nnormDisj_isSound {r=(Conj _ _)} {s=(Lit _)} p = p\nnormDisj_isSound {r=(Conj _ _)} {s=(Cat _ _)} p = p\nnormDisj_isSound {r=(Conj _ _)} {s=(Disj _ _)} p = p\nnormDisj_isSound {r=(Conj r s)} {s=(Conj t u)} p with (decEq r t)\n normDisj_isSound {r=(Conj r s)} {s=(Conj r u)} p | (Yes Refl) with (decEq s u)\n normDisj_isSound {r=(Conj r s)} {s=(Conj r s)} p | (Yes Refl) | (Yes Refl) = InDisjL p\n normDisj_isSound {r=(Conj r s)} {s=(Conj r u)} p | (Yes Refl) | (No _) = p\n normDisj_isSound {r=(Conj r s)} {s=(Conj t u)} p | (No _) = p\nnormDisj_isSound {r=(Conj _ _)} {s=(Star _)} p = p\nnormDisj_isSound {r=(Star _)} {s=Null} p = InDisjL p\nnormDisj_isSound {r=(Star _)} {s=Empty} p = p\nnormDisj_isSound {r=(Star _)} {s=(Lit _)} p = p\nnormDisj_isSound {r=(Star _)} {s=(Cat _ _)} p = p\nnormDisj_isSound {r=(Star _)} {s=(Disj _ _)} p = p\nnormDisj_isSound {r=(Star _)} {s=(Conj _ _)} p = p\nnormDisj_isSound {r=(Star r)} {s=(Star s)} p with (decEq r s)\n normDisj_isSound {r=(Star r)} {s=(Star r)} p | (Yes Refl) = InDisjL p\n normDisj_isSound {r=(Star r)} {s=(Star s)} p | (No _) = p\n\n||| Proof (by exhaustion) that `normDisj` is complete.\nexport\nnormDisj_isComplete : DecEq a =>\n {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (Disj r s) xs ->\n Matches (normDisj r s) xs\nnormDisj_isComplete {r=Null} (InDisjL p) = absurd p\nnormDisj_isComplete {r=Null} (InDisjR p) = p\nnormDisj_isComplete {r=Empty} {s=Null} (InDisjL p) = p\nnormDisj_isComplete {r=Empty} {s=Null} (InDisjR p) = absurd p\nnormDisj_isComplete {r=Empty} {s=Empty} (InDisjL p) = InDisjL p\nnormDisj_isComplete {r=Empty} {s=Empty} (InDisjR p) = InDisjR p\nnormDisj_isComplete {r=Empty} {s=(Lit _)} p = p\nnormDisj_isComplete {r=Empty} {s=(Cat _ _)} p = p\nnormDisj_isComplete {r=Empty} {s=(Disj _ _)} p = p\nnormDisj_isComplete {r=Empty} {s=(Conj _ _)} p = p\nnormDisj_isComplete {r=Empty} {s=(Star _)} p = p\nnormDisj_isComplete {r=(Lit _)} {s=Null} (InDisjL p) = p\nnormDisj_isComplete {r=(Lit _)} {s=Null} (InDisjR p) = absurd p\nnormDisj_isComplete {r=(Lit _)} {s=Empty} p = p\nnormDisj_isComplete {r=(Lit x)} {s=(Lit y)} p with (decEq x y)\n normDisj_isComplete {r=(Lit x)} {s=(Lit x)} (InDisjL p) | (Yes Refl) = p\n normDisj_isComplete {r=(Lit x)} {s=(Lit x)} (InDisjR p) | (Yes Refl) = p\n normDisj_isComplete {r=(Lit x)} {s=(Lit y)} p | (No _) = p\nnormDisj_isComplete {r=(Lit _)} {s=(Cat _ _)} p = p\nnormDisj_isComplete {r=(Lit _)} {s=(Disj _ _)} p = p\nnormDisj_isComplete {r=(Lit _)} {s=(Conj _ _)} p = p\nnormDisj_isComplete {r=(Lit _)} {s=(Star _)} p = p\nnormDisj_isComplete {r=(Cat _ _)} {s=Null} (InDisjL p) = p\nnormDisj_isComplete {r=(Cat _ _)} {s=Null} (InDisjR p) = absurd p\nnormDisj_isComplete {r=(Cat _ _)} {s=Empty} p = p\nnormDisj_isComplete {r=(Cat _ _)} {s=(Lit _)} p = p\nnormDisj_isComplete {r=(Cat r s)} {s=(Cat t u)} p with (decEq r t)\n normDisj_isComplete {r=(Cat r s)} {s=(Cat r u)} p | (Yes Refl) with (decEq s u)\n normDisj_isComplete {r=(Cat r s)} {s=(Cat r s)} (InDisjL p) | (Yes Refl) | (Yes Refl) = p\n normDisj_isComplete {r=(Cat r s)} {s=(Cat r s)} (InDisjR p) | (Yes Refl) | (Yes Refl) = p\n normDisj_isComplete {r=(Cat r s)} {s=(Cat r u)} p | (Yes Refl) | (No _) = p\n normDisj_isComplete {r=(Cat r s)} {s=(Cat t u)} p | (No _) = p\nnormDisj_isComplete {r=(Cat _ _)} {s=(Disj _ _)} p = p\nnormDisj_isComplete {r=(Cat _ _)} {s=(Conj _ _)} p = p\nnormDisj_isComplete {r=(Cat _ _)} {s=(Star _)} p = p\nnormDisj_isComplete {r=(Disj _ _)} {s=Null} (InDisjL p) = p\nnormDisj_isComplete {r=(Disj _ _)} {s=Null} (InDisjR p) = absurd p\nnormDisj_isComplete {r=(Disj _ _)} {s=Empty} (InDisjL (InDisjL p)) = InDisjL p\nnormDisj_isComplete {r=(Disj _ _)} {s=Empty} (InDisjL (InDisjR p)) = InDisjR (InDisjL p)\nnormDisj_isComplete {r=(Disj _ _)} {s=Empty} (InDisjR p) = InDisjR (InDisjR p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Lit _)} (InDisjL (InDisjL p)) = InDisjL p\nnormDisj_isComplete {r=(Disj _ _)} {s=(Lit _)} (InDisjL (InDisjR p)) = InDisjR (InDisjL p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Lit _)} (InDisjR p) = InDisjR (InDisjR p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Cat _ _)} (InDisjL (InDisjL p)) = InDisjL p\nnormDisj_isComplete {r=(Disj _ _)} {s=(Cat _ _)} (InDisjL (InDisjR p)) = InDisjR (InDisjL p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Cat _ _)} (InDisjR p) = InDisjR (InDisjR p)\nnormDisj_isComplete {r=(Disj r s)} {s=(Disj t u)} p with (decEq r t)\n normDisj_isComplete {r=(Disj r s)} {s=(Disj r u)} p | (Yes Refl) with (decEq s u)\n normDisj_isComplete {r=(Disj r s)} {s=(Disj r s)} (InDisjL p) | (Yes Refl) | (Yes Refl) = p\n normDisj_isComplete {r=(Disj r s)} {s=(Disj r s)} (InDisjR p) | (Yes Refl) | (Yes Refl) = p\n normDisj_isComplete {r=(Disj r s)} {s=(Disj r u)} (InDisjL (InDisjL p)) | (Yes Refl) | (No _) = InDisjL p\n normDisj_isComplete {r=(Disj r s)} {s=(Disj r u)} (InDisjL (InDisjR p)) | (Yes Refl) | (No _) = InDisjR (InDisjL p)\n normDisj_isComplete {r=(Disj r s)} {s=(Disj r u)} (InDisjR p) | (Yes Refl) | (No _) = InDisjR (InDisjR p)\n normDisj_isComplete {r=(Disj r s)} {s=(Disj t u)} (InDisjL (InDisjL p)) | (No _) = InDisjL p\n normDisj_isComplete {r=(Disj r s)} {s=(Disj t u)} (InDisjL (InDisjR p)) | (No _) = InDisjR (InDisjL p)\n normDisj_isComplete {r=(Disj r s)} {s=(Disj t u)} (InDisjR p) | (No _) = InDisjR (InDisjR p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Conj _ _)} (InDisjL (InDisjL p)) = InDisjL p\nnormDisj_isComplete {r=(Disj _ _)} {s=(Conj _ _)} (InDisjL (InDisjR p)) = InDisjR (InDisjL p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Conj _ _)} (InDisjR p) = InDisjR (InDisjR p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Star _)} (InDisjL (InDisjL p)) = InDisjL p\nnormDisj_isComplete {r=(Disj _ _)} {s=(Star _)} (InDisjL (InDisjR p)) = InDisjR (InDisjL p)\nnormDisj_isComplete {r=(Disj _ _)} {s=(Star _)} (InDisjR p) = InDisjR (InDisjR p)\nnormDisj_isComplete {r=(Conj _ _)} {s=Null} (InDisjL p) = p\nnormDisj_isComplete {r=(Conj _ _)} {s=Null} (InDisjR p) = absurd p\nnormDisj_isComplete {r=(Conj _ _)} {s=Empty} p = p\nnormDisj_isComplete {r=(Conj _ _)} {s=(Lit _)} p = p\nnormDisj_isComplete {r=(Conj _ _)} {s=(Cat _ _)} p = p\nnormDisj_isComplete {r=(Conj _ _)} {s=(Disj _ _)} p = p\nnormDisj_isComplete {r=(Conj r s)} {s=(Conj t u)} p with (decEq r t)\n normDisj_isComplete {r=(Conj r s)} {s=(Conj r u)} p | (Yes Refl) with (decEq s u)\n normDisj_isComplete {r=(Conj r s)} {s=(Conj r s)} (InDisjL p) | (Yes Refl) | (Yes Refl) = p\n normDisj_isComplete {r=(Conj r s)} {s=(Conj r s)} (InDisjR p) | (Yes Refl) | (Yes Refl) = p\n normDisj_isComplete {r=(Conj r s)} {s=(Conj r u)} p | (Yes Refl) | (No _) = p\n normDisj_isComplete {r=(Conj r s)} {s=(Conj t u)} p | (No _) = p\nnormDisj_isComplete {r=(Conj _ _)} {s=(Star _)} p = p\nnormDisj_isComplete {r=(Star _)} {s=Null} (InDisjL p) = p\nnormDisj_isComplete {r=(Star _)} {s=Null} (InDisjR p) = absurd p\nnormDisj_isComplete {r=(Star _)} {s=Empty} p = p\nnormDisj_isComplete {r=(Star _)} {s=(Lit _)} p = p\nnormDisj_isComplete {r=(Star _)} {s=(Cat _ _)} p = p\nnormDisj_isComplete {r=(Star _)} {s=(Disj _ _)} p = p\nnormDisj_isComplete {r=(Star _)} {s=(Conj _ _)} p = p\nnormDisj_isComplete {r=(Star r)} {s=(Star s)} p with (decEq r s)\n normDisj_isComplete {r=(Star r)} {s=(Star r)} (InDisjL p) | (Yes Refl) = p\n normDisj_isComplete {r=(Star r)} {s=(Star r)} (InDisjR p) | (Yes Refl) = p\n normDisj_isComplete {r=(Star r)} {s=(Star s)} p | (No _) = p\n\n||| Proof (by exhaustion) that `normConj` is sound.\nexport\nnormConj_isSound : DecEq a =>\n {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (normConj r s) xs ->\n Matches (Conj r s) xs\nnormConj_isSound {r=Null} {s} p = absurd p\nnormConj_isSound {r=Empty} {s=Null} p = absurd p\nnormConj_isSound {r=Empty} {s=Empty} p = p\nnormConj_isSound {r=Empty} {s=(Lit _)} p = p\nnormConj_isSound {r=Empty} {s=(Cat _ _)} p = p\nnormConj_isSound {r=Empty} {s=(Disj _ _)} p = p\nnormConj_isSound {r=Empty} {s=(Conj _ _)} p = p\nnormConj_isSound {r=Empty} {s=(Star _)} p = p\nnormConj_isSound {r=(Lit _)} {s=Null} p = absurd p\nnormConj_isSound {r=(Lit _)} {s=Empty} p = p\nnormConj_isSound {r=(Lit x)} {s=(Lit y)} p with (decEq x y)\n normConj_isSound {r=(Lit x)} {s=(Lit x)} p | (Yes Refl) = InConj p p\n normConj_isSound {r=(Lit x)} {s=(Lit y)} p | (No _) = p\nnormConj_isSound {r=(Lit _)} {s=(Cat _ _)} p = p\nnormConj_isSound {r=(Lit _)} {s=(Disj _ _)} p = p\nnormConj_isSound {r=(Lit _)} {s=(Conj _ _)} p = p\nnormConj_isSound {r=(Lit _)} {s=(Star _)} p = p\nnormConj_isSound {r=(Cat _ _)} {s=Null} p = absurd p\nnormConj_isSound {r=(Cat _ _)} {s=Empty} p = p\nnormConj_isSound {r=(Cat _ _)} {s=(Lit _)} p = p\nnormConj_isSound {r=(Cat r s)} {s=(Cat t u)} p with (decEq r t)\n normConj_isSound {r=(Cat r s)} {s=(Cat r u)} p | (Yes Refl) with (decEq s u)\n normConj_isSound {r=(Cat r s)} {s=(Cat r s)} p | (Yes Refl) | (Yes Refl) = InConj p p\n normConj_isSound {r=(Cat r s)} {s=(Cat r u)} p | (Yes Refl) | (No _) = p\n normConj_isSound {r=(Cat r s)} {s=(Cat t u)} p | (No _) = p\nnormConj_isSound {r=(Cat _ _)} {s=(Disj _ _)} p = p\nnormConj_isSound {r=(Cat _ _)} {s=(Conj _ _)} p = p\nnormConj_isSound {r=(Cat _ _)} {s=(Star _)} p = p\nnormConj_isSound {r=(Disj _ _)} {s=Null} p = absurd p\nnormConj_isSound {r=(Disj _ _)} {s=Empty} p = p\nnormConj_isSound {r=(Disj _ _)} {s=(Lit _)} p = p\nnormConj_isSound {r=(Disj _ _)} {s=(Cat _ _)} p = p\nnormConj_isSound {r=(Disj r s)} {s=(Disj t u)} p with (decEq r t)\n normConj_isSound {r=(Disj r s)} {s=(Disj r u)} p | (Yes Refl) with (decEq s u)\n normConj_isSound {r=(Disj r s)} {s=(Disj r s)} p | (Yes Refl) | (Yes Refl) = InConj p p\n normConj_isSound {r=(Disj r s)} {s=(Disj r u)} p | (Yes Refl) | (No _) = p\n normConj_isSound {r=(Disj r s)} {s=(Disj t u)} p | (No _) = p\nnormConj_isSound {r=(Disj _ _)} {s=(Conj _ _)} p = p\nnormConj_isSound {r=(Disj _ _)} {s=(Star _)} p = p\nnormConj_isSound {r=(Conj _ _)} {s=Null} p = absurd p\nnormConj_isSound {r=(Conj _ _)} {s=Empty} (InConj pr (InConj ps pt)) = InConj (InConj pr ps) pt\nnormConj_isSound {r=(Conj _ _)} {s=(Lit _)} (InConj pr (InConj ps pt)) = InConj (InConj pr ps) pt\nnormConj_isSound {r=(Conj _ _)} {s=(Cat _ _)} (InConj pr (InConj ps pt)) = InConj (InConj pr ps) pt\nnormConj_isSound {r=(Conj _ _)} {s=(Disj _ _)} (InConj pr (InConj ps pt)) = InConj (InConj pr ps) pt\nnormConj_isSound {r=(Conj r s)} {s=(Conj t u)} p with (decEq r t)\n normConj_isSound {r=(Conj r s)} {s=(Conj r u)} p | (Yes Refl) with (decEq s u)\n normConj_isSound {r=(Conj r s)} {s=(Conj r s)} p | (Yes Refl) | (Yes Refl) = InConj p p\n normConj_isSound {r=(Conj r s)} {s=(Conj r u)} (InConj _ (InConj ps (InConj pt pu))) | (Yes Refl) | (No _) =\n InConj (InConj pt ps) (InConj pt pu)\n normConj_isSound {r=(Conj r s)} {s=(Conj t u)} (InConj pr (InConj ps (InConj pt pu))) | (No _) =\n InConj (InConj pr ps) (InConj pt pu)\nnormConj_isSound {r=(Conj _ _)} {s=(Star _)} (InConj pr (InConj ps pt)) = InConj (InConj pr ps) pt\nnormConj_isSound {r=(Star _)} {s=Null} p = absurd p\nnormConj_isSound {r=(Star _)} {s=Empty} p = p\nnormConj_isSound {r=(Star _)} {s=(Lit _)} p = p\nnormConj_isSound {r=(Star _)} {s=(Cat _ _)} p = p\nnormConj_isSound {r=(Star _)} {s=(Disj _ _)} p = p\nnormConj_isSound {r=(Star _)} {s=(Conj _ _)} p = p\nnormConj_isSound {r=(Star r)} {s=(Star s)} p with (decEq r s)\n normConj_isSound {r=(Star r)} {s=(Star r)} p | (Yes Refl) = InConj p p\n normConj_isSound {r=(Star r)} {s=(Star s)} p | (No _) = p\n\n||| Proof (by exhaustion) that `normCat` is complete.\nexport\nnormConj_isComplete : DecEq a =>\n {xs : List a} ->\n {r : RegExp a} ->\n {s : RegExp a} ->\n Matches (Conj r s) xs ->\n Matches (normConj r s) xs\nnormConj_isComplete {r=Null} (InConj p _) = absurd p\nnormConj_isComplete {s=Null} (InConj _ p) = absurd p\nnormConj_isComplete {r=Empty} {s=Empty} p = p\nnormConj_isComplete {r=Empty} {s=(Lit _)} p = p\nnormConj_isComplete {r=Empty} {s=(Cat _ _)} p = p\nnormConj_isComplete {r=Empty} {s=(Disj _ _)} p = p\nnormConj_isComplete {r=Empty} {s=(Conj _ _)} p = p\nnormConj_isComplete {r=Empty} {s=(Star _)} p = p\nnormConj_isComplete {r=(Lit _)} {s=Empty} p = p\nnormConj_isComplete {r=(Lit x)} {s=(Lit y)} p with (decEq x y)\n normConj_isComplete {r=(Lit x)} {s=(Lit x)} (InConj p _) | Yes Refl = p\n normConj_isComplete {r=(Lit x)} {s=(Lit y)} p | No _ = p\nnormConj_isComplete {r=(Lit _)} {s=(Cat _ _)} p = p\nnormConj_isComplete {r=(Lit _)} {s=(Disj _ _)} p = p\nnormConj_isComplete {r=(Lit _)} {s=(Conj _ _)} p = p\nnormConj_isComplete {r=(Lit _)} {s=(Star _)} p = p\nnormConj_isComplete {r=(Cat _ _)} {s=Empty} p = p\nnormConj_isComplete {r=(Cat _ _)} {s=(Lit _)} p = p\nnormConj_isComplete {r=(Cat r s)} {s=(Cat t u)} p with (decEq (Cat r s) (Cat t u))\n normConj_isComplete {r=(Cat r s)} {s=(Cat r s)} (InConj p _) | Yes Refl = p\n normConj_isComplete {r=(Cat r s)} {s=(Cat t u)} p | No _ = p\nnormConj_isComplete {r=(Cat _ _)} {s=(Disj _ _)} p = p\nnormConj_isComplete {r=(Cat _ _)} {s=(Conj _ _)} p = p\nnormConj_isComplete {r=(Cat _ _)} {s=(Star _)} p = p\nnormConj_isComplete {r=(Disj _ _)} {s=Empty} p = p\nnormConj_isComplete {r=(Disj _ _)} {s=(Lit _)} p = p\nnormConj_isComplete {r=(Disj _ _)} {s=(Cat _ _)} p = p\nnormConj_isComplete {r=(Disj r s)} {s=(Disj t u)} p with (decEq (Disj r s) (Disj t u))\n normConj_isComplete {r=(Disj r s)} {s=(Disj r s)} (InConj p _) | Yes Refl = p\n normConj_isComplete {r=(Disj r s)} {s=(Disj t u)} p | No _ = p\nnormConj_isComplete {r=(Disj _ _)} {s=(Conj _ _)} p = p\nnormConj_isComplete {r=(Disj _ _)} {s=(Star _)} p = p\nnormConj_isComplete {r=(Conj _ _)} {s=Empty} (InConj (InConj pr ps) pt) = InConj pr (InConj ps pt)\nnormConj_isComplete {r=(Conj _ _)} {s=(Lit _)} (InConj (InConj pr ps) pt) = InConj pr (InConj ps pt)\nnormConj_isComplete {r=(Conj _ _)} {s=(Cat _ _)} (InConj (InConj pr ps) pt) = InConj pr (InConj ps pt)\nnormConj_isComplete {r=(Conj _ _)} {s=(Disj _ _)} (InConj (InConj pr ps) pt) = InConj pr (InConj ps pt)\nnormConj_isComplete {r=(Conj r s)} {s=(Conj t u)} p with (decEq (Conj r s) (Conj t u))\n normConj_isComplete {r=(Conj r s)} {s=(Conj r s)} (InConj p _) | Yes Refl = p\n normConj_isComplete {r=(Conj r s)} {s=(Conj t u)} (InConj (InConj pr ps) (InConj pt pu)) | No _ =\n InConj pr (InConj ps (InConj pt pu))\nnormConj_isComplete {r=(Conj _ _)} {s=(Star _)} (InConj (InConj pr ps) pt) = InConj pr (InConj ps pt)\nnormConj_isComplete {r=(Star _)} {s=Empty} p = p\nnormConj_isComplete {r=(Star _)} {s=(Lit _)} p = p\nnormConj_isComplete {r=(Star _)} {s=(Cat _ _)} p = p\nnormConj_isComplete {r=(Star _)} {s=(Disj _ _)} p = p\nnormConj_isComplete {r=(Star _)} {s=(Conj _ _)} p = p\nnormConj_isComplete {r=(Star r)} {s=(Star s)} p with (decEq r s)\n normConj_isComplete {r=(Star r)} {s=(Star r)} (InConj p _) | Yes Refl = p\n normConj_isComplete {r=(Star r)} {s=(Star s)} p | No _ = p\n", "meta": {"hexsha": "6f74133f2417ffd06dc002f6530c4394fedf55ae", "size": 31216, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/RegExp/Equivalences.idr", "max_stars_repo_name": "polendri/idris-regex", "max_stars_repo_head_hexsha": "72d5f1c05d34f3119b8be808a3e27b93a526e07a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-06-01T04:46:44.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-01T04:46:44.000Z", "max_issues_repo_path": "src/RegExp/Equivalences.idr", "max_issues_repo_name": "polendri/idris-regex", "max_issues_repo_head_hexsha": "72d5f1c05d34f3119b8be808a3e27b93a526e07a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-06-06T13:44:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T01:16:42.000Z", "max_forks_repo_path": "src/RegExp/Equivalences.idr", "max_forks_repo_name": "polendri/idris-regexp", "max_forks_repo_head_hexsha": "72d5f1c05d34f3119b8be808a3e27b93a526e07a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 65.5798319328, "max_line_length": 140, "alphanum_fraction": 0.5514800103, "num_tokens": 12211, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.5326972728058866}} {"text": "import Data.Vect\n\nlength : Vect n elem -> Nat\nlength {n} xs = n\n\nempties : Vect n (Vect 0 a)\nempties {n = Z} = []\nempties {n = (S k)} = [] :: empties\n", "meta": {"hexsha": "4524077c23893f2097ab6c2eda93be117a227987", "size": 150, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris/3.4-ImplicitArguments.idr", "max_stars_repo_name": "ostera/asdf", "max_stars_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-02T22:25:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T18:22:11.000Z", "max_issues_repo_path": "idris/3.4-ImplicitArguments.idr", "max_issues_repo_name": "ostera/asdf", "max_issues_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2019-12-05T22:45:56.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-05T22:45:58.000Z", "max_forks_repo_path": "idris/3.4-ImplicitArguments.idr", "max_forks_repo_name": "ostera/asdf", "max_forks_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.6666666667, "max_line_length": 35, "alphanum_fraction": 0.5733333333, "num_tokens": 56, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744939732855, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5325311294096171}} {"text": "||| Test extended record syntax\ndata NotZero : Nat -> Type where\n Is : {n : Nat} -> NotZero (S n)\n\nrecord Positive (n : Nat) {auto 0 pos : NotZero n} where\n constructor Check\n\na : Positive 1\na = Check\n\nb : Positive 2\nb = Check\n\n{- Will not type-check\nc : Positive 0\n-}\n\ndata KindOfString = ASCII | UTF\n\nUTForASCII : KindOfString -> Type\nUTForASCII UTF = String\nUTForASCII ASCII = List Char --- Just to demonstrate\n\nrecord FlexiString { default UTF k : KindOfString} where\n constructor MkFlexiString\n val : UTForASCII k\n \nc : FlexiString\nc = MkFlexiString \"hello\"\n\nd : FlexiString {k = ASCII}\nd = MkFlexiString ['h', 'i']\n\n", "meta": {"hexsha": "b154a95346dc499c74ef221c8a11950c34c36e95", "size": 629, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/record003/Record.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/idris2/record003/Record.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/idris2/record003/Record.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.5, "max_line_length": 56, "alphanum_fraction": 0.6868044515, "num_tokens": 191, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.787931185683219, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5324560084687908}} {"text": "module Main\n\n-- First iteration, complected number generation with labeling\n\nlabelFrom : Integer -> List a -> List (Integer, a)\nlabelFrom k [] = []\nlabelFrom k (x :: xs) = (k, x) :: labelFrom (k+1) xs\n\nlabel : List a -> List (Integer, a)\nlabel = labelFrom 0\n\n-- Second iteration, split number generation from labeling\n\ncountFrom : Integer -> List Integer\ncountFrom n = n :: countFrom (n+1)\n\nlabelWith : List Integer -> List a -> List (Integer, a)\nlabelWith _ [] = []\nlabelWith (x :: xs) (y :: ys) = (x, y) :: labelWith xs ys\n\n-- this works on the REPL because it's lazy\nlabel' : List a -> List (Integer, a)\nlabel' = labelWith (countFrom 0)\n\n-- Third iteration, Infinite Lists!\n\ndata InfList : Type -> Type where\n (::) : (value : elem) -> Inf (InfList elem) -> InfList elem\n-- there's no [] constructor because infinite lists just don't end\n\n-- countFrom' is a corecursive function that returns codata\ntotal countFrom' : Integer -> InfList Integer\ncountFrom' x = x :: countFrom' (x + 1)\n\ngetPrefix : (count : Nat) -> InfList a -> List a\ngetPrefix Z xs = []\ngetPrefix (S k) (value :: xs) = value :: getPrefix k xs\n\nmain : IO ()\nmain = print $ getPrefix 10 (countFrom' 0)\n\n-- the following line doesn't work:\n-- main = print $ label' [1,2,3]\n", "meta": {"hexsha": "74f6bb3fad708b4ac47f09705f3a4b87df4bdd1b", "size": 1241, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris/11-InfiniteData.idr", "max_stars_repo_name": "ostera/asdf", "max_stars_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-02T22:25:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T18:22:11.000Z", "max_issues_repo_path": "idris/11-InfiniteData.idr", "max_issues_repo_name": "ostera/asdf", "max_issues_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2019-12-05T22:45:56.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-05T22:45:58.000Z", "max_forks_repo_path": "idris/11-InfiniteData.idr", "max_forks_repo_name": "ostera/asdf", "max_forks_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.2045454545, "max_line_length": 66, "alphanum_fraction": 0.6591458501, "num_tokens": 363, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.5323425223250646}} {"text": "module Quantities.ImperialUnits\n\nimport Quantities.Core\nimport Quantities.SIBaseQuantities\nimport Quantities.SIPrefixes\nimport Quantities.SIBaseUnits\nimport Quantities.SIDerivedQuantities\nimport Quantities.NonSIUnits\n\n%default total\n%access public export\n\n\n-- Based on http://en.wikipedia.org/wiki/Imperial_units\n\n\n-- Length\n\nThou : ElemUnit Length\nThou = < one \"th\" equals 25.4 (micro Metre) >\nTh : ElemUnit Length\nTh = Thou\n\nInch : ElemUnit Length\nInch = < one \"in\" equals 2.54 Centimetre >\nIn_ : ElemUnit Length\nIn_ = Inch\n\nFoot : ElemUnit Length\nFoot = < one \"ft\" equals 12 Inch >\nFt : ElemUnit Length\nFt = Foot\n\nYard : ElemUnit Length\nYard = < one \"yd\" equals 3 Foot >\nYd : ElemUnit Length\nYd = Yard\n\nChain : ElemUnit Length\nChain = < one \"ch\" equals 22 Yard >\nCh : ElemUnit Length\nCh = Chain\n\nFurlong : ElemUnit Length\nFurlong = < one \"fur\" equals 10 Chain >\nFur : ElemUnit Length\nFur = Furlong\n\nMile : ElemUnit Length\nMile = < one \"mi\" equals 1760 Yard >\nMi : ElemUnit Length\nMi = Mile\n\nLeague : ElemUnit Length\nLeague = < one \"lea\" equals 3 Mile >\nLea : ElemUnit Length\nLea = League\n\n-- Maritime units\n\nFathom : ElemUnit Length\nFathom = < one \"ftm\" equals 6.08 Foot >\nFtm : ElemUnit Length\nFtm = Fathom\n\nCable : ElemUnit Length\nCable = < one \"cable\" equals 608 Foot >\n\nNauticalMile : ElemUnit Length\nNauticalMile = < one \"nmi\" equals 1852 Metre >\nNmi : ElemUnit Length\nNmi = NauticalMile\n\n-- Gunter's survey units\n\nLink : ElemUnit Length\nLink = < one \"link\" equals (1/100) Chain >\n\nRod : ElemUnit Length\nRod = < one \"rod\" equals (1/4) Chain >\n\n\n-- Speed\n\nKnot : ElemUnit Speed\nKnot = < one \"kn\" equals 1 (NauticalMile Hour) >\nKn : ElemUnit Speed\nKn = Knot\n\n\n-- Area\n\nPerch : ElemUnit Area\nPerch = < one \"perch\" equals 1 (Rod ^^ 2) >\n\nRood : ElemUnit Area\nRood = < one \"rood\" equals 1 (Furlong <**> Rod) >\n\nAcre : ElemUnit Area\nAcre = < one \"acre\" equals 1 (Furlong <**> Chain) >\n\n\n-- Volume\n\nFluidOunce : ElemUnit Volume\nFluidOunce = < one \"floz\" equals 28.4130625 (milli $ (deci Metre) ^^ 3) >\nFloz : ElemUnit Volume\nFloz = FluidOunce\n\nGill : ElemUnit Volume\nGill = < one \"gi\" equals 5 FluidOunce >\nGi : ElemUnit Volume\nGi = Gill\n\nPint : ElemUnit Volume\nPint = < one \"pt\" equals 20 FluidOunce >\nPt : ElemUnit Volume\nPt = Pint\n\nQuart : ElemUnit Volume\nQuart = < one \"qt\" equals 40 FluidOunce >\nQt : ElemUnit Volume\nQt = Quart\n\nGallon : ElemUnit Volume\nGallon = < one \"gal\" equals 160 FluidOunce >\nGal : ElemUnit Volume\nGal = Gallon\n\n-- British apothecaries' volume measures\n\nMinim : ElemUnit Volume\nMinim = < one \"min\" equals 59.1938802083 (micro $ (deci Metre) ^^ 3) >\nMin : ElemUnit Volume\nMin = Minim\n\nFluidScruple : ElemUnit Volume\nFluidScruple = < one \"fls\" equals 20 Minim >\nFls : ElemUnit Volume\nFls = FluidScruple\n\nFluidDrachm : ElemUnit Volume\nFluidDrachm = < one \"fldr\" equals 3 FluidScruple >\nFldr : ElemUnit Volume\nFldr = FluidDrachm\n\n\n-- Mass\n\nPound : ElemUnit Mass\nPound = < one \"lb\" equals 453.59237 Gram >\nLb : ElemUnit Mass\nLb = Pound\n\nGrain : ElemUnit Mass\nGrain = < one \"gr\" equals (1/7000) Pound >\nGr : ElemUnit Mass\nGr = Grain\n\nDrachm : ElemUnit Mass\nDrachm = < one \"dr\" equals (1/256) Pound >\nDr : ElemUnit Mass\nDr = Drachm\n\nOunce : ElemUnit Mass\nOunce = < one \"oz\" equals (1/16) Pound >\nOz : ElemUnit Mass\nOz = Ounce\n\nStone : ElemUnit Mass\nStone = < one \"st\" equals 14 Pound >\nSt : ElemUnit Mass\nSt = Stone\n\nQuarter : ElemUnit Mass\nQuarter = < one \"qtr\" equals 28 Pound >\nQtr : ElemUnit Mass\nQtr = Quarter\n\nHundredweight : ElemUnit Mass\nHundredweight = < one \"cwt\" equals 112 Pound >\nCwt : ElemUnit Mass\nCwt = Hundredweight\n\nTon : ElemUnit Mass\nTon = < one \"ton\" equals 2240 Pound >\n\n\n-- Energy\n\nFootPound : ElemUnit Energy\nFootPound = < one \"ftlb\" equals 1 (Foot <**> Pound <**> G_0) >\nFtlb : ElemUnit Energy\nFtlb = FootPound\n\n\n-- Power\n\nMechanicalHorsepower : ElemUnit Power\nMechanicalHorsepower = < one \"hp\" equals 550 (FootPound Second) >\nImperialHorsepower : ElemUnit Power\nImperialHorsepower = MechanicalHorsepower\nHorsepower : ElemUnit Power\nHorsepower = MechanicalHorsepower\nHp : ElemUnit Power\nHp = MechanicalHorsepower\n", "meta": {"hexsha": "5651e4c6d276afd645b6722e4e9484a4913cb16b", "size": 4070, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Quantities/ImperialUnits.idr", "max_stars_repo_name": "timjb/quantities", "max_stars_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 112, "max_stars_repo_stars_event_min_datetime": "2015-01-18T13:52:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T14:15:46.000Z", "max_issues_repo_path": "Quantities/ImperialUnits.idr", "max_issues_repo_name": "timjb/quantities", "max_issues_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2015-11-04T08:51:41.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-17T09:52:29.000Z", "max_forks_repo_path": "Quantities/ImperialUnits.idr", "max_forks_repo_name": "timjb/quantities", "max_forks_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-04-28T23:49:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-01T17:28:34.000Z", "avg_line_length": 19.6618357488, "max_line_length": 73, "alphanum_fraction": 0.7100737101, "num_tokens": 1348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5321999971365445}} {"text": "> module Main\n\n> import Data.So\n\n> ifTrue : So True -> Nat\n> ifTrue Oh = S Z\n\n> ifFalse : So False -> Nat\n> ifFalse Oh impossible\n\n> test : (f : Nat -> Bool) -> (n : Nat) -> So (f n) -> Nat\n> test f n x with (f n)\n> | True = ifTrue x\n> | False = ifFalse x\n\n> main : IO ()\n> main = printLn (test ((S 4) ==) 5 Oh)\n\n", "meta": {"hexsha": "98cd8135c682784c54ef072d312f496723aa0a3f", "size": 393, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/basic005/test019.lidr", "max_stars_repo_name": "grin-compiler/idris-grin", "max_stars_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/idris-dev/basic005/test019.lidr", "max_issues_repo_name": "grin-compiler/idris-grin", "max_issues_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/idris-dev/basic005/test019.lidr", "max_forks_repo_name": "grin-compiler/idris-grin", "max_forks_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 20.6842105263, "max_line_length": 69, "alphanum_fraction": 0.4300254453, "num_tokens": 134, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.5310479166643697}} {"text": "module Data.Functor.Compose\n\npublic export\ndata Compose : (f : Type -> Type) -> (g : Type -> Type) -> Type -> Type where\n MkCompose : f (g x) -> Compose f g x\n\npublic export\ngetCompose : Compose f g a -> f (g a)\ngetCompose (MkCompose x) = x\n\npublic export\nimplementation (Functor f, Functor g) => Functor (Compose f g) where\n map f (MkCompose x) = MkCompose $ map (map f) x\n\n", "meta": {"hexsha": "6df897d714a1ff124717b914493f05c4e6434e80", "size": 377, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Functor/Compose.idr", "max_stars_repo_name": "MarcelineVQ/idris2-streaming", "max_stars_repo_head_hexsha": "fa0864c9b441e7ab82131364b7b4124f4bb3a600", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2020-08-18T20:53:13.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-20T15:56:37.000Z", "max_issues_repo_path": "src/Data/Functor/Compose.idr", "max_issues_repo_name": "MarcelineVQ/idris2-streaming", "max_issues_repo_head_hexsha": "fa0864c9b441e7ab82131364b7b4124f4bb3a600", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Functor/Compose.idr", "max_forks_repo_name": "MarcelineVQ/idris2-streaming", "max_forks_repo_head_hexsha": "fa0864c9b441e7ab82131364b7b4124f4bb3a600", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2020-12-18T08:23:15.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-22T15:41:07.000Z", "avg_line_length": 25.1333333333, "max_line_length": 77, "alphanum_fraction": 0.6631299735, "num_tokens": 120, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085909370423, "lm_q2_score": 0.6757646010190477, "lm_q1q2_score": 0.5306837466314009}} {"text": "------------------------------------------------------------------------\n-- This module is based on the following papers:\n\n-- Categories of Containers\n-- Abbott, Altenkirch, Ghani\n\n-- Derivatives of Containers\n-- Abbott, Altenkirch, Ghani, McBride\n------------------------------------------------------------------------\n\nmodule Data.Container\n\nimport Data.Either\nimport Decidable.Equality\n\n%default total\n\n------------------------------------------------------------------------\n-- Container and their morphisms\n-- * Extension is a functor from Container to Type\n\n-- Objects of the category of containers\nnamespace Container\n\n public export\n record Container where\n constructor MkContainer\n Shape : Type\n Position : Shape -> Type\n\n public export\n record Extension (c : Container) (x : Type) where\n constructor MkExtension\n shape : Shape c\n payloads : Position c shape -> x\n\n ||| The image of a container by @Extension@ is a functor\n public export\n Functor (Extension c) where map f (MkExtension s p) = MkExtension s (f . p)\n\n-- Morphisms of the category of containers\nnamespace Morphism\n\n public export\n record Morphism (c, d : Container) where\n constructor MkMorphism\n shapeMorphism : Shape c -> Shape d\n positionMorphism : {s : Shape c} -> Position d (shapeMorphism s) -> Position c s\n\n public export\n Extension : Morphism c d -> Extension c x -> Extension d x\n Extension phi (MkExtension s p)\n = MkExtension (shapeMorphism phi s) (p . positionMorphism phi)\n\n------------------------------------------------------------------------\n-- Combinators to build containers\n\nnamespace Combinators\n\n -- Constant\n public export\n Const : Type -> Container\n Const k = MkContainer k (const Void)\n\n export\n toConst : k -> Extension (Const k) x\n toConst v = MkExtension v absurd\n\n export\n fromConst : Extension (Const k) x -> k\n fromConst (MkExtension v _) = v\n\n -- Identity\n public export\n Identity : Container\n Identity = MkContainer () (\\ () => ())\n\n export\n toIdentity : x -> Extension Identity x\n toIdentity v = MkExtension () (const v)\n\n export\n fromIdentity : Extension Identity x -> x\n fromIdentity (MkExtension () chld) = chld ()\n\n -- Composition\n public export\n Compose : (d, c : Container) -> Container\n Compose d c = MkContainer\n (Extension d (Shape c))\n (\\ (MkExtension shp chld) => (p : Position d shp ** Position c (chld p)))\n\n export\n toCompose : (Extension d . Extension c) x -> Extension (Compose d c) x\n toCompose (MkExtension shp1 chld)\n = MkExtension (MkExtension shp1 (shape . chld)) (\\ (p ** q) => payloads (chld p) q)\n\n export\n fromCompose : Extension (Compose d c) x -> (Extension d . Extension c) x\n fromCompose (MkExtension (MkExtension shp1 shp2) chld)\n = MkExtension shp1 (\\ p => MkExtension (shp2 p) (\\ q => chld (p ** q)))\n\n -- Direct sum\n public export\n Sum : (c, d : Container) -> Container\n Sum c d = MkContainer (Either (Shape c) (Shape d)) (either (Position c) (Position d))\n\n export\n toSum : Either (Extension c x) (Extension d x) -> Extension (Sum c d) x\n toSum (Left (MkExtension shp chld)) = MkExtension (Left shp) chld\n toSum (Right (MkExtension shp chld)) = MkExtension (Right shp) chld\n\n export\n fromSum : Extension (Sum c d) x -> Either (Extension c x) (Extension d x)\n fromSum (MkExtension (Left shp) chld) = Left (MkExtension shp chld)\n fromSum (MkExtension (Right shp) chld) = Right (MkExtension shp chld)\n\n -- Pairing\n public export\n Pair : (c, d : Container) -> Container\n Pair c d = MkContainer (Shape c, Shape d) (\\ (p, q) => Either (Position c p) (Position d q))\n\n export\n toPair : (Extension c x, Extension d x) -> Extension (Pair c d) x\n toPair (MkExtension shp1 chld1, MkExtension shp2 chld2)\n = MkExtension (shp1, shp2) (either chld1 chld2)\n\n export\n fromPair : Extension (Pair c d) x -> (Extension c x, Extension d x)\n fromPair (MkExtension (shp1, shp2) chld)\n = (MkExtension shp1 (chld . Left), MkExtension shp2 (chld . Right))\n\n -- Branching over a Type\n public export\n Exponential : Type -> Container -> Container\n Exponential k c = MkContainer (k -> Shape c) (\\ p => (v : k ** Position c (p v)))\n\n export\n toExponential : (k -> Extension c x) -> Extension (Exponential k c) x\n toExponential f = MkExtension (shape . f) (\\ (v ** p) => payloads (f v) p)\n\n export\n fromExponential : Extension (Exponential k c) x -> (k -> Extension c x)\n fromExponential (MkExtension shp chld) k = MkExtension (shp k) (\\ p => chld (k ** p))\n\n------------------------------------------------------------------------\n-- Taking various fixpoints of containers\n\nnamespace Initial\n\n public export\n data W : Container -> Type where\n MkW : Extension c (W c) -> W c\n\n export\n map : Morphism c d -> W c -> W d\n map f (MkW (MkExtension shp chld)) = MkW $ Extension f (MkExtension shp (\\ p => map f (chld p)))\n -- Container.map inlined because of -------------------^\n -- termination checking\n\n export\n foldr : (Extension c x -> x) -> W c -> x\n foldr alg (MkW (MkExtension shp chld)) = alg (MkExtension shp (\\ p => foldr alg (chld p)))\n\n export\n para : (Extension c (x, W c) -> x) -> W c -> x\n para alg (MkW (MkExtension shp chld)) = alg (MkExtension shp (\\ p => let w = chld p in (para alg w, w)))\n\nnamespace Monad\n\n ||| @Free@ is a wrapper around @W@ to make it inference friendly.\n ||| Without this wrapper, neither @pure@ nor @bind@ are able to infer their @c@ argument.\n public export\n record Free (c : Container) (x : Type) where\n constructor MkFree\n runFree : W (Sum c (Const x))\n\n export\n pure : x -> Free c x\n pure x = MkFree $ MkW (toSum (Right (toConst x)))\n\n export\n (>>=) : Free c x -> (x -> Free c y) -> Free c y\n (>>=) (MkFree mx) k = foldr (alg . fromSum {c} {d = Const x}) mx where\n\n alg : Either (Extension c (Free c y)) (Extension (Const x) (Free c y)) -> Free c y\n alg = either (MkFree . MkW . toSum {c} {d = Const y} . Left . map (runFree {c}))\n (k . fromConst {k = x})\n\n export\n join : Free c (Free c x) -> Free c x\n join = (>>= id)\n\nnamespace Final\n\n public export\n data M : Container -> Type where\n MkM : Extension c (Inf (M c)) -> M c\n\n export\n unfoldr : (s -> Extension c s) -> s -> M c\n unfoldr next seed =\n let (MkExtension shp chld) = next seed in\n MkM (MkExtension shp (\\ p => unfoldr next (chld p)))\n\nnamespace Comonad\n\n ||| @Cofree@ is a wrapper around @M@ to make it inference friendly.\n ||| Without this wrapper, neither @extract@ nor @extend@ are able to infer their @c@ argument.\n public export\n record Cofree (c : Container) (x : Type) where\n constructor MkCofree\n runCofree : M (Pair (Const x) c)\n\n export\n extract : Cofree c x -> x\n extract (MkCofree (MkM m)) = fst (shape m)\n\n export\n extend : (Cofree c a -> b) -> Cofree c a -> Cofree c b\n extend alg = MkCofree . unfoldr next . runCofree where\n\n next : M (Pair (Const a) c) -> Extension (Pair (Const b) c) (M (Pair (Const a) c))\n next m@(MkM layer) =\n let (_, (MkExtension shp chld)) = fromPair {c = Const a} layer in\n let b = toConst (alg (MkCofree m)) in\n toPair (b, MkExtension shp (\\ p => chld p))\n-- Eta-expanded to force Inf ------^\n\n export\n duplicate : Cofree c a -> Cofree c (Cofree c a)\n duplicate = extend id\n\n------------------------------------------------------------------------\n-- Derivative\n\nnamespace Derivative\n\n public export\n Derivative : Container -> Container\n Derivative c = MkContainer\n (s : Shape c ** Position c s)\n (\\ (s ** p) => (p' : Position c s ** Not (p === p')))\n\n export\n hole : (v : Extension (Derivative c) x) -> Position c (fst (shape v))\n hole (MkExtension (shp ** p) _) = p\n\n export\n unplug : (v : Extension c x) -> Position c (shape v) -> (Extension (Derivative c) x, x)\n unplug (MkExtension shp chld) p = (MkExtension (shp ** p) (chld . fst), chld p)\n\n export\n plug : (v : Extension (Derivative c) x) -> DecEq (Position c (fst (shape v))) => x -> Extension c x\n plug (MkExtension (shp ** p) chld) x = MkExtension shp $ \\ p' => case decEq p p' of\n Yes eq => x\n No neq => chld (p' ** neq)\n\n export\n toConst : Extension (Const Void) x -> Extension (Derivative (Const k)) x\n toConst v = absurd (fromConst v)\n\n export\n fromConst : Extension (Derivative (Const k)) x -> Extension (Const Void) x\n fromConst v = absurd (hole {c = Const _} v)\n\n export\n toIdentity : Extension (Derivative Identity) x\n toIdentity = MkExtension (() ** ()) (\\ (() ** eq) => absurd (eq Refl))\n\n export\n toSum : Extension (Sum (Derivative c) (Derivative d)) x ->\n Extension (Derivative (Sum c d)) x\n toSum v = case fromSum {c = Derivative c} {d = Derivative d} v of\n Left (MkExtension (shp ** p) chld) => MkExtension (Left shp ** p) chld\n Right (MkExtension (shp ** p) chld) => MkExtension (Right shp ** p) chld\n\n export\n fromSum : Extension (Derivative (Sum c d)) x ->\n Extension (Sum (Derivative c) (Derivative d)) x\n fromSum (MkExtension (shp ** p) chld) = toSum {c = Derivative c} {d = Derivative d} $ case shp of\n Left shp => Left (MkExtension (shp ** p) chld)\n Right shp => Right (MkExtension (shp ** p) chld)\n\n export\n toPair : Extension (Sum (Pair (Derivative c) d) (Pair c (Derivative d))) x ->\n Extension (Derivative (Pair c d)) x\n toPair v = case fromSum {c = Pair (Derivative c) d} {d = Pair c (Derivative d)} v of\n Left p => let (MkExtension (shp1 ** p1) chld1, MkExtension shp2 chld2) = fromPair {c = Derivative c} p in\n MkExtension ((shp1, shp2) ** Left p1) $ \\ (p' ** neq) => case p' of\n Left p1' => chld1 (p1' ** (neq . cong Left))\n Right p2' => chld2 p2'\n Right p => let (MkExtension shp1 chld1, MkExtension (shp2 ** p2) chld2) = fromPair {c} {d = Derivative d} p in\n MkExtension ((shp1, shp2) ** Right p2) $ \\ (p' ** neq) => case p' of\n Left p1' => chld1 p1'\n Right p2' => chld2 (p2' ** (neq . cong Right))\n\n export\n fromPair : Extension (Derivative (Pair c d)) x ->\n Extension (Sum (Pair (Derivative c) d) (Pair c (Derivative d))) x\n fromPair (MkExtension ((shp1, shp2) ** p) chld) = case p of\n Left p1 => toSum {c = Pair (Derivative c) d} {d = Pair c (Derivative d)}\n (Left (MkExtension ((shp1 ** p1), shp2) $ either\n (\\ p1' => chld (Left (DPair.fst p1') ** DPair.snd p1' . injective))\n (\\ p2 => chld (Right p2 ** absurd))))\n Right p2 => toSum {c = Pair (Derivative c) d} {d = Pair c (Derivative d)}\n (Right (MkExtension (shp1, (shp2 ** p2)) $ either\n (\\ p1 => chld (Left p1 ** absurd))\n (\\ p2' => chld (Right (DPair.fst p2') ** DPair.snd p2' . injective))))\n\n\n export\n fromCompose : Extension (Derivative (Compose c d)) x ->\n Extension (Pair (Derivative d) (Compose (Derivative c) d)) x\n fromCompose (MkExtension (MkExtension shp1 shp2 ** (p1 ** p2)) chld)\n = toPair (left, right) where\n\n left : Extension (Derivative d) x\n left = MkExtension (shp2 p1 ** p2)\n $ \\ (p2' ** neqp2) => chld ((p1 ** p2') ** neqp2 . mkDPairInjectiveSnd)\n\n right : Extension (Compose (Derivative c) d) x\n right = toCompose\n $ MkExtension (shp1 ** p1)\n $ \\ (p1' ** neqp1) => MkExtension (shp2 p1')\n $ \\ p2' => chld ((p1' ** p2') ** (neqp1 . cong fst))\n\n export\n toCompose : ((s : _) -> DecEq (Position c s)) -> ((s : _) -> DecEq (Position d s)) ->\n Extension (Pair (Derivative d) (Compose (Derivative c) d)) x ->\n Extension (Derivative (Compose c d)) x\n toCompose dec1 dec2 v with (fromPair {c = Derivative d} {d = Compose (Derivative c) d} v)\n toCompose dec1 dec2 v | (MkExtension (shp2 ** p2) chld2, w) with (fromCompose w)\n toCompose dec1 dec2 v\n | (MkExtension (shp2 ** p2) chld2, w)\n | (MkExtension (shp1 ** p1) chld1)\n = MkExtension (MkExtension shp1 (\\ p1' => shp2' p1' (decEq @{dec1 shp1} p1 p1')) **\n (p1 ** (p2' (decEq @{dec1 shp1} p1 p1))))\n $ \\ ((p1' ** p2'') ** neq) => chld2' p1' p2'' neq\n\n where\n shp2' : (p1' : Position c shp1) -> Dec (p1 === p1') -> Shape d\n shp2' p1' (Yes eq) = shp2\n shp2' p1' (No neq) = shape (chld1 (p1' ** neq))\n\n p2' : (eq : Dec (p1 === p1)) -> Position d (shp2' p1 eq)\n p2' (Yes Refl) = p2\n p2' (No neq) = absurd (neq Refl)\n\n chld2' : (p1' : Position c shp1) ->\n (p2'' : Position d (shp2' p1' (decEq @{dec1 shp1} p1 p1'))) ->\n (neq : Not (MkDPair p1 (p2' (decEq @{dec1 shp1} p1 p1)) = MkDPair p1' p2'')) -> x\n chld2' p1' p2'' neq with (decEq @{dec1 shp1} p1 p1')\n chld2' p1' p2'' neq | No neq1 = payloads (chld1 (p1' ** neq1)) p2''\n chld2' _ p2'' neq | Yes Refl with (decEq @{dec1 shp1} p1 p1)\n chld2' _ p2'' neq | Yes Refl | No argh = absurd (argh Refl)\n chld2' _ p2'' neq | Yes Refl | Yes Refl with (decEq @{dec2 shp2} p2 p2'')\n chld2' _ p2'' neq | Yes Refl | Yes Refl | No neq2 = chld2 (p2'' ** neq2)\n chld2' _ _ neq | Yes Refl | Yes Refl | Yes Refl = absurd (neq Refl)\n", "meta": {"hexsha": "8bef70815c655878ce5b51f53ca7f20020d42e5f", "size": 13304, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/contrib/Data/Container.idr", "max_stars_repo_name": "chrrasmussen/Idris2-Erlang", "max_stars_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "idris2/libs/contrib/Data/Container.idr", "max_issues_repo_name": "chrrasmussen/Idris2-Erlang", "max_issues_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "idris2/libs/contrib/Data/Container.idr", "max_forks_repo_name": "chrrasmussen/Idris2-Erlang", "max_forks_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 36.9555555556, "max_line_length": 114, "alphanum_fraction": 0.576443175, "num_tokens": 4280, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6688802603710085, "lm_q1q2_score": 0.5304929151298251}} {"text": "Ty : Type\nTy = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty : Ty\nempty = \\ _, empty, _ => empty\n\narr : Ty -> Ty -> Ty\narr = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon : Type\nCon = (Con : Type)\n ->(nil : Con)\n ->(snoc : Con -> Ty -> Con)\n -> Con\n\nnil : Con\nnil = \\ con, nil, snoc => nil\n\nsnoc : Con -> Ty -> Con\nsnoc = \\ g, a, con, nil, snoc => snoc (g con nil snoc) a\n\nVar : Con -> Ty -> Type\nVar = \\ g, a =>\n (Var : Con -> Ty -> Type)\n -> (vz : (g : _)-> (a : _) -> Var (snoc g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var g a -> Var (snoc g b) a)\n -> Var g a\n\nvz : {g : _}-> {a : _} -> Var (snoc g a) a\nvz = \\ var, vz, vs => vz _ _\n\nvs : {g : _} -> {B : _} -> {a : _} -> Var g a -> Var (snoc g B) a\nvs = \\ x, var, vz, vs => vs _ _ _ (x var vz vs)\n\nTm : Con -> Ty -> Type\nTm = \\ g, a =>\n (Tm : Con -> Ty -> Type)\n -> (var : (g : _) -> (a : _) -> Var g a -> Tm g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm (snoc g a) B -> Tm g (arr a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm g (arr a B) -> Tm g a -> Tm g B)\n -> Tm g a\n\nvar : {g : _} -> {a : _} -> Var g a -> Tm g a\nvar = \\ x, tm, var, lam, app => var _ _ x\n\nlam : {g : _} -> {a : _} -> {B : _} -> Tm (snoc g a) B -> Tm g (arr a B)\nlam = \\ t, tm, var, lam, app => lam _ _ _ (t tm var lam app)\n\napp : {g:_}->{a:_}->{B:_} -> Tm g (arr a B) -> Tm g a -> Tm g B\napp = \\ t, u, tm, var, lam, app => app _ _ _ (t tm var lam app) (u tm var lam app)\n\nv0 : {g:_}->{a:_} -> Tm (snoc g a) a\nv0 = var vz\n\nv1 : {g:_}->{a:_}-> {B:_}-> Tm (snoc (snoc g a) B) a\nv1 = var (vs vz)\n\nv2 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm (snoc (snoc (snoc g a) B) C) a\nv2 = var (vs (vs vz))\n\nv3 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm (snoc (snoc (snoc (snoc g a) B) C) D) a\nv3 = var (vs (vs (vs vz)))\n\nv4 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm (snoc (snoc (snoc (snoc (snoc g a) B) C) D) E) a\nv4 = var (vs (vs (vs (vs vz))))\n\ntest : {g:_}-> {a:_} -> Tm g (arr (arr a a) (arr a a))\ntest = lam (lam (app v1 (app v1 (app v1 (app v1 (app v1 (app v1 v0)))))))\nTy1 : Type\nTy1 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty1 : Ty1\nempty1 = \\ _, empty, _ => empty\n\narr1 : Ty1 -> Ty1 -> Ty1\narr1 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon1 : Type\nCon1 = (Con1 : Type)\n ->(nil : Con1)\n ->(snoc : Con1 -> Ty1 -> Con1)\n -> Con1\n\nnil1 : Con1\nnil1 = \\ con, nil1, snoc => nil1\n\nsnoc1 : Con1 -> Ty1 -> Con1\nsnoc1 = \\ g, a, con, nil1, snoc1 => snoc1 (g con nil1 snoc1) a\n\nVar1 : Con1 -> Ty1 -> Type\nVar1 = \\ g, a =>\n (Var1 : Con1 -> Ty1 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var1 (snoc1 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var1 g a -> Var1 (snoc1 g b) a)\n -> Var1 g a\n\nvz1 : {g : _}-> {a : _} -> Var1 (snoc1 g a) a\nvz1 = \\ var, vz1, vs => vz1 _ _\n\nvs1 : {g : _} -> {B : _} -> {a : _} -> Var1 g a -> Var1 (snoc1 g B) a\nvs1 = \\ x, var, vz1, vs1 => vs1 _ _ _ (x var vz1 vs1)\n\nTm1 : Con1 -> Ty1 -> Type\nTm1 = \\ g, a =>\n (Tm1 : Con1 -> Ty1 -> Type)\n -> (var : (g : _) -> (a : _) -> Var1 g a -> Tm1 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm1 (snoc1 g a) B -> Tm1 g (arr1 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm1 g (arr1 a B) -> Tm1 g a -> Tm1 g B)\n -> Tm1 g a\n\nvar1 : {g : _} -> {a : _} -> Var1 g a -> Tm1 g a\nvar1 = \\ x, tm, var1, lam, app => var1 _ _ x\n\nlam1 : {g : _} -> {a : _} -> {B : _} -> Tm1 (snoc1 g a) B -> Tm1 g (arr1 a B)\nlam1 = \\ t, tm, var1, lam1, app => lam1 _ _ _ (t tm var1 lam1 app)\n\napp1 : {g:_}->{a:_}->{B:_} -> Tm1 g (arr1 a B) -> Tm1 g a -> Tm1 g B\napp1 = \\ t, u, tm, var1, lam1, app1 => app1 _ _ _ (t tm var1 lam1 app1) (u tm var1 lam1 app1)\n\nv01 : {g:_}->{a:_} -> Tm1 (snoc1 g a) a\nv01 = var1 vz1\n\nv11 : {g:_}->{a:_}-> {B:_}-> Tm1 (snoc1 (snoc1 g a) B) a\nv11 = var1 (vs1 vz1)\n\nv21 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm1 (snoc1 (snoc1 (snoc1 g a) B) C) a\nv21 = var1 (vs1 (vs1 vz1))\n\nv31 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm1 (snoc1 (snoc1 (snoc1 (snoc1 g a) B) C) D) a\nv31 = var1 (vs1 (vs1 (vs1 vz1)))\n\nv41 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm1 (snoc1 (snoc1 (snoc1 (snoc1 (snoc1 g a) B) C) D) E) a\nv41 = var1 (vs1 (vs1 (vs1 (vs1 vz1))))\n\ntest1 : {g:_}-> {a:_} -> Tm1 g (arr1 (arr1 a a) (arr1 a a))\ntest1 = lam1 (lam1 (app1 v11 (app1 v11 (app1 v11 (app1 v11 (app1 v11 (app1 v11 v01)))))))\nTy2 : Type\nTy2 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty2 : Ty2\nempty2 = \\ _, empty, _ => empty\n\narr2 : Ty2 -> Ty2 -> Ty2\narr2 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon2 : Type\nCon2 = (Con2 : Type)\n ->(nil : Con2)\n ->(snoc : Con2 -> Ty2 -> Con2)\n -> Con2\n\nnil2 : Con2\nnil2 = \\ con, nil2, snoc => nil2\n\nsnoc2 : Con2 -> Ty2 -> Con2\nsnoc2 = \\ g, a, con, nil2, snoc2 => snoc2 (g con nil2 snoc2) a\n\nVar2 : Con2 -> Ty2 -> Type\nVar2 = \\ g, a =>\n (Var2 : Con2 -> Ty2 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var2 (snoc2 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var2 g a -> Var2 (snoc2 g b) a)\n -> Var2 g a\n\nvz2 : {g : _}-> {a : _} -> Var2 (snoc2 g a) a\nvz2 = \\ var, vz2, vs => vz2 _ _\n\nvs2 : {g : _} -> {B : _} -> {a : _} -> Var2 g a -> Var2 (snoc2 g B) a\nvs2 = \\ x, var, vz2, vs2 => vs2 _ _ _ (x var vz2 vs2)\n\nTm2 : Con2 -> Ty2 -> Type\nTm2 = \\ g, a =>\n (Tm2 : Con2 -> Ty2 -> Type)\n -> (var : (g : _) -> (a : _) -> Var2 g a -> Tm2 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm2 (snoc2 g a) B -> Tm2 g (arr2 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm2 g (arr2 a B) -> Tm2 g a -> Tm2 g B)\n -> Tm2 g a\n\nvar2 : {g : _} -> {a : _} -> Var2 g a -> Tm2 g a\nvar2 = \\ x, tm, var2, lam, app => var2 _ _ x\n\nlam2 : {g : _} -> {a : _} -> {B : _} -> Tm2 (snoc2 g a) B -> Tm2 g (arr2 a B)\nlam2 = \\ t, tm, var2, lam2, app => lam2 _ _ _ (t tm var2 lam2 app)\n\napp2 : {g:_}->{a:_}->{B:_} -> Tm2 g (arr2 a B) -> Tm2 g a -> Tm2 g B\napp2 = \\ t, u, tm, var2, lam2, app2 => app2 _ _ _ (t tm var2 lam2 app2) (u tm var2 lam2 app2)\n\nv02 : {g:_}->{a:_} -> Tm2 (snoc2 g a) a\nv02 = var2 vz2\n\nv12 : {g:_}->{a:_}-> {B:_}-> Tm2 (snoc2 (snoc2 g a) B) a\nv12 = var2 (vs2 vz2)\n\nv22 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm2 (snoc2 (snoc2 (snoc2 g a) B) C) a\nv22 = var2 (vs2 (vs2 vz2))\n\nv32 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm2 (snoc2 (snoc2 (snoc2 (snoc2 g a) B) C) D) a\nv32 = var2 (vs2 (vs2 (vs2 vz2)))\n\nv42 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm2 (snoc2 (snoc2 (snoc2 (snoc2 (snoc2 g a) B) C) D) E) a\nv42 = var2 (vs2 (vs2 (vs2 (vs2 vz2))))\n\ntest2 : {g:_}-> {a:_} -> Tm2 g (arr2 (arr2 a a) (arr2 a a))\ntest2 = lam2 (lam2 (app2 v12 (app2 v12 (app2 v12 (app2 v12 (app2 v12 (app2 v12 v02)))))))\nTy3 : Type\nTy3 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty3 : Ty3\nempty3 = \\ _, empty, _ => empty\n\narr3 : Ty3 -> Ty3 -> Ty3\narr3 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon3 : Type\nCon3 = (Con3 : Type)\n ->(nil : Con3)\n ->(snoc : Con3 -> Ty3 -> Con3)\n -> Con3\n\nnil3 : Con3\nnil3 = \\ con, nil3, snoc => nil3\n\nsnoc3 : Con3 -> Ty3 -> Con3\nsnoc3 = \\ g, a, con, nil3, snoc3 => snoc3 (g con nil3 snoc3) a\n\nVar3 : Con3 -> Ty3 -> Type\nVar3 = \\ g, a =>\n (Var3 : Con3 -> Ty3 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var3 (snoc3 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var3 g a -> Var3 (snoc3 g b) a)\n -> Var3 g a\n\nvz3 : {g : _}-> {a : _} -> Var3 (snoc3 g a) a\nvz3 = \\ var, vz3, vs => vz3 _ _\n\nvs3 : {g : _} -> {B : _} -> {a : _} -> Var3 g a -> Var3 (snoc3 g B) a\nvs3 = \\ x, var, vz3, vs3 => vs3 _ _ _ (x var vz3 vs3)\n\nTm3 : Con3 -> Ty3 -> Type\nTm3 = \\ g, a =>\n (Tm3 : Con3 -> Ty3 -> Type)\n -> (var : (g : _) -> (a : _) -> Var3 g a -> Tm3 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm3 (snoc3 g a) B -> Tm3 g (arr3 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm3 g (arr3 a B) -> Tm3 g a -> Tm3 g B)\n -> Tm3 g a\n\nvar3 : {g : _} -> {a : _} -> Var3 g a -> Tm3 g a\nvar3 = \\ x, tm, var3, lam, app => var3 _ _ x\n\nlam3 : {g : _} -> {a : _} -> {B : _} -> Tm3 (snoc3 g a) B -> Tm3 g (arr3 a B)\nlam3 = \\ t, tm, var3, lam3, app => lam3 _ _ _ (t tm var3 lam3 app)\n\napp3 : {g:_}->{a:_}->{B:_} -> Tm3 g (arr3 a B) -> Tm3 g a -> Tm3 g B\napp3 = \\ t, u, tm, var3, lam3, app3 => app3 _ _ _ (t tm var3 lam3 app3) (u tm var3 lam3 app3)\n\nv03 : {g:_}->{a:_} -> Tm3 (snoc3 g a) a\nv03 = var3 vz3\n\nv13 : {g:_}->{a:_}-> {B:_}-> Tm3 (snoc3 (snoc3 g a) B) a\nv13 = var3 (vs3 vz3)\n\nv23 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm3 (snoc3 (snoc3 (snoc3 g a) B) C) a\nv23 = var3 (vs3 (vs3 vz3))\n\nv33 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm3 (snoc3 (snoc3 (snoc3 (snoc3 g a) B) C) D) a\nv33 = var3 (vs3 (vs3 (vs3 vz3)))\n\nv43 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm3 (snoc3 (snoc3 (snoc3 (snoc3 (snoc3 g a) B) C) D) E) a\nv43 = var3 (vs3 (vs3 (vs3 (vs3 vz3))))\n\ntest3 : {g:_}-> {a:_} -> Tm3 g (arr3 (arr3 a a) (arr3 a a))\ntest3 = lam3 (lam3 (app3 v13 (app3 v13 (app3 v13 (app3 v13 (app3 v13 (app3 v13 v03)))))))\nTy4 : Type\nTy4 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty4 : Ty4\nempty4 = \\ _, empty, _ => empty\n\narr4 : Ty4 -> Ty4 -> Ty4\narr4 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon4 : Type\nCon4 = (Con4 : Type)\n ->(nil : Con4)\n ->(snoc : Con4 -> Ty4 -> Con4)\n -> Con4\n\nnil4 : Con4\nnil4 = \\ con, nil4, snoc => nil4\n\nsnoc4 : Con4 -> Ty4 -> Con4\nsnoc4 = \\ g, a, con, nil4, snoc4 => snoc4 (g con nil4 snoc4) a\n\nVar4 : Con4 -> Ty4 -> Type\nVar4 = \\ g, a =>\n (Var4 : Con4 -> Ty4 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var4 (snoc4 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var4 g a -> Var4 (snoc4 g b) a)\n -> Var4 g a\n\nvz4 : {g : _}-> {a : _} -> Var4 (snoc4 g a) a\nvz4 = \\ var, vz4, vs => vz4 _ _\n\nvs4 : {g : _} -> {B : _} -> {a : _} -> Var4 g a -> Var4 (snoc4 g B) a\nvs4 = \\ x, var, vz4, vs4 => vs4 _ _ _ (x var vz4 vs4)\n\nTm4 : Con4 -> Ty4 -> Type\nTm4 = \\ g, a =>\n (Tm4 : Con4 -> Ty4 -> Type)\n -> (var : (g : _) -> (a : _) -> Var4 g a -> Tm4 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm4 (snoc4 g a) B -> Tm4 g (arr4 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm4 g (arr4 a B) -> Tm4 g a -> Tm4 g B)\n -> Tm4 g a\n\nvar4 : {g : _} -> {a : _} -> Var4 g a -> Tm4 g a\nvar4 = \\ x, tm, var4, lam, app => var4 _ _ x\n\nlam4 : {g : _} -> {a : _} -> {B : _} -> Tm4 (snoc4 g a) B -> Tm4 g (arr4 a B)\nlam4 = \\ t, tm, var4, lam4, app => lam4 _ _ _ (t tm var4 lam4 app)\n\napp4 : {g:_}->{a:_}->{B:_} -> Tm4 g (arr4 a B) -> Tm4 g a -> Tm4 g B\napp4 = \\ t, u, tm, var4, lam4, app4 => app4 _ _ _ (t tm var4 lam4 app4) (u tm var4 lam4 app4)\n\nv04 : {g:_}->{a:_} -> Tm4 (snoc4 g a) a\nv04 = var4 vz4\n\nv14 : {g:_}->{a:_}-> {B:_}-> Tm4 (snoc4 (snoc4 g a) B) a\nv14 = var4 (vs4 vz4)\n\nv24 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm4 (snoc4 (snoc4 (snoc4 g a) B) C) a\nv24 = var4 (vs4 (vs4 vz4))\n\nv34 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm4 (snoc4 (snoc4 (snoc4 (snoc4 g a) B) C) D) a\nv34 = var4 (vs4 (vs4 (vs4 vz4)))\n\nv44 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm4 (snoc4 (snoc4 (snoc4 (snoc4 (snoc4 g a) B) C) D) E) a\nv44 = var4 (vs4 (vs4 (vs4 (vs4 vz4))))\n\ntest4 : {g:_}-> {a:_} -> Tm4 g (arr4 (arr4 a a) (arr4 a a))\ntest4 = lam4 (lam4 (app4 v14 (app4 v14 (app4 v14 (app4 v14 (app4 v14 (app4 v14 v04)))))))\nTy5 : Type\nTy5 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty5 : Ty5\nempty5 = \\ _, empty, _ => empty\n\narr5 : Ty5 -> Ty5 -> Ty5\narr5 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon5 : Type\nCon5 = (Con5 : Type)\n ->(nil : Con5)\n ->(snoc : Con5 -> Ty5 -> Con5)\n -> Con5\n\nnil5 : Con5\nnil5 = \\ con, nil5, snoc => nil5\n\nsnoc5 : Con5 -> Ty5 -> Con5\nsnoc5 = \\ g, a, con, nil5, snoc5 => snoc5 (g con nil5 snoc5) a\n\nVar5 : Con5 -> Ty5 -> Type\nVar5 = \\ g, a =>\n (Var5 : Con5 -> Ty5 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var5 (snoc5 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var5 g a -> Var5 (snoc5 g b) a)\n -> Var5 g a\n\nvz5 : {g : _}-> {a : _} -> Var5 (snoc5 g a) a\nvz5 = \\ var, vz5, vs => vz5 _ _\n\nvs5 : {g : _} -> {B : _} -> {a : _} -> Var5 g a -> Var5 (snoc5 g B) a\nvs5 = \\ x, var, vz5, vs5 => vs5 _ _ _ (x var vz5 vs5)\n\nTm5 : Con5 -> Ty5 -> Type\nTm5 = \\ g, a =>\n (Tm5 : Con5 -> Ty5 -> Type)\n -> (var : (g : _) -> (a : _) -> Var5 g a -> Tm5 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm5 (snoc5 g a) B -> Tm5 g (arr5 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm5 g (arr5 a B) -> Tm5 g a -> Tm5 g B)\n -> Tm5 g a\n\nvar5 : {g : _} -> {a : _} -> Var5 g a -> Tm5 g a\nvar5 = \\ x, tm, var5, lam, app => var5 _ _ x\n\nlam5 : {g : _} -> {a : _} -> {B : _} -> Tm5 (snoc5 g a) B -> Tm5 g (arr5 a B)\nlam5 = \\ t, tm, var5, lam5, app => lam5 _ _ _ (t tm var5 lam5 app)\n\napp5 : {g:_}->{a:_}->{B:_} -> Tm5 g (arr5 a B) -> Tm5 g a -> Tm5 g B\napp5 = \\ t, u, tm, var5, lam5, app5 => app5 _ _ _ (t tm var5 lam5 app5) (u tm var5 lam5 app5)\n\nv05 : {g:_}->{a:_} -> Tm5 (snoc5 g a) a\nv05 = var5 vz5\n\nv15 : {g:_}->{a:_}-> {B:_}-> Tm5 (snoc5 (snoc5 g a) B) a\nv15 = var5 (vs5 vz5)\n\nv25 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm5 (snoc5 (snoc5 (snoc5 g a) B) C) a\nv25 = var5 (vs5 (vs5 vz5))\n\nv35 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm5 (snoc5 (snoc5 (snoc5 (snoc5 g a) B) C) D) a\nv35 = var5 (vs5 (vs5 (vs5 vz5)))\n\nv45 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm5 (snoc5 (snoc5 (snoc5 (snoc5 (snoc5 g a) B) C) D) E) a\nv45 = var5 (vs5 (vs5 (vs5 (vs5 vz5))))\n\ntest5 : {g:_}-> {a:_} -> Tm5 g (arr5 (arr5 a a) (arr5 a a))\ntest5 = lam5 (lam5 (app5 v15 (app5 v15 (app5 v15 (app5 v15 (app5 v15 (app5 v15 v05)))))))\nTy6 : Type\nTy6 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty6 : Ty6\nempty6 = \\ _, empty, _ => empty\n\narr6 : Ty6 -> Ty6 -> Ty6\narr6 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon6 : Type\nCon6 = (Con6 : Type)\n ->(nil : Con6)\n ->(snoc : Con6 -> Ty6 -> Con6)\n -> Con6\n\nnil6 : Con6\nnil6 = \\ con, nil6, snoc => nil6\n\nsnoc6 : Con6 -> Ty6 -> Con6\nsnoc6 = \\ g, a, con, nil6, snoc6 => snoc6 (g con nil6 snoc6) a\n\nVar6 : Con6 -> Ty6 -> Type\nVar6 = \\ g, a =>\n (Var6 : Con6 -> Ty6 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var6 (snoc6 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var6 g a -> Var6 (snoc6 g b) a)\n -> Var6 g a\n\nvz6 : {g : _}-> {a : _} -> Var6 (snoc6 g a) a\nvz6 = \\ var, vz6, vs => vz6 _ _\n\nvs6 : {g : _} -> {B : _} -> {a : _} -> Var6 g a -> Var6 (snoc6 g B) a\nvs6 = \\ x, var, vz6, vs6 => vs6 _ _ _ (x var vz6 vs6)\n\nTm6 : Con6 -> Ty6 -> Type\nTm6 = \\ g, a =>\n (Tm6 : Con6 -> Ty6 -> Type)\n -> (var : (g : _) -> (a : _) -> Var6 g a -> Tm6 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm6 (snoc6 g a) B -> Tm6 g (arr6 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm6 g (arr6 a B) -> Tm6 g a -> Tm6 g B)\n -> Tm6 g a\n\nvar6 : {g : _} -> {a : _} -> Var6 g a -> Tm6 g a\nvar6 = \\ x, tm, var6, lam, app => var6 _ _ x\n\nlam6 : {g : _} -> {a : _} -> {B : _} -> Tm6 (snoc6 g a) B -> Tm6 g (arr6 a B)\nlam6 = \\ t, tm, var6, lam6, app => lam6 _ _ _ (t tm var6 lam6 app)\n\napp6 : {g:_}->{a:_}->{B:_} -> Tm6 g (arr6 a B) -> Tm6 g a -> Tm6 g B\napp6 = \\ t, u, tm, var6, lam6, app6 => app6 _ _ _ (t tm var6 lam6 app6) (u tm var6 lam6 app6)\n\nv06 : {g:_}->{a:_} -> Tm6 (snoc6 g a) a\nv06 = var6 vz6\n\nv16 : {g:_}->{a:_}-> {B:_}-> Tm6 (snoc6 (snoc6 g a) B) a\nv16 = var6 (vs6 vz6)\n\nv26 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm6 (snoc6 (snoc6 (snoc6 g a) B) C) a\nv26 = var6 (vs6 (vs6 vz6))\n\nv36 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm6 (snoc6 (snoc6 (snoc6 (snoc6 g a) B) C) D) a\nv36 = var6 (vs6 (vs6 (vs6 vz6)))\n\nv46 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm6 (snoc6 (snoc6 (snoc6 (snoc6 (snoc6 g a) B) C) D) E) a\nv46 = var6 (vs6 (vs6 (vs6 (vs6 vz6))))\n\ntest6 : {g:_}-> {a:_} -> Tm6 g (arr6 (arr6 a a) (arr6 a a))\ntest6 = lam6 (lam6 (app6 v16 (app6 v16 (app6 v16 (app6 v16 (app6 v16 (app6 v16 v06)))))))\nTy7 : Type\nTy7 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty7 : Ty7\nempty7 = \\ _, empty, _ => empty\n\narr7 : Ty7 -> Ty7 -> Ty7\narr7 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon7 : Type\nCon7 = (Con7 : Type)\n ->(nil : Con7)\n ->(snoc : Con7 -> Ty7 -> Con7)\n -> Con7\n\nnil7 : Con7\nnil7 = \\ con, nil7, snoc => nil7\n\nsnoc7 : Con7 -> Ty7 -> Con7\nsnoc7 = \\ g, a, con, nil7, snoc7 => snoc7 (g con nil7 snoc7) a\n\nVar7 : Con7 -> Ty7 -> Type\nVar7 = \\ g, a =>\n (Var7 : Con7 -> Ty7 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var7 (snoc7 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var7 g a -> Var7 (snoc7 g b) a)\n -> Var7 g a\n\nvz7 : {g : _}-> {a : _} -> Var7 (snoc7 g a) a\nvz7 = \\ var, vz7, vs => vz7 _ _\n\nvs7 : {g : _} -> {B : _} -> {a : _} -> Var7 g a -> Var7 (snoc7 g B) a\nvs7 = \\ x, var, vz7, vs7 => vs7 _ _ _ (x var vz7 vs7)\n\nTm7 : Con7 -> Ty7 -> Type\nTm7 = \\ g, a =>\n (Tm7 : Con7 -> Ty7 -> Type)\n -> (var : (g : _) -> (a : _) -> Var7 g a -> Tm7 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm7 (snoc7 g a) B -> Tm7 g (arr7 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm7 g (arr7 a B) -> Tm7 g a -> Tm7 g B)\n -> Tm7 g a\n\nvar7 : {g : _} -> {a : _} -> Var7 g a -> Tm7 g a\nvar7 = \\ x, tm, var7, lam, app => var7 _ _ x\n\nlam7 : {g : _} -> {a : _} -> {B : _} -> Tm7 (snoc7 g a) B -> Tm7 g (arr7 a B)\nlam7 = \\ t, tm, var7, lam7, app => lam7 _ _ _ (t tm var7 lam7 app)\n\napp7 : {g:_}->{a:_}->{B:_} -> Tm7 g (arr7 a B) -> Tm7 g a -> Tm7 g B\napp7 = \\ t, u, tm, var7, lam7, app7 => app7 _ _ _ (t tm var7 lam7 app7) (u tm var7 lam7 app7)\n\nv07 : {g:_}->{a:_} -> Tm7 (snoc7 g a) a\nv07 = var7 vz7\n\nv17 : {g:_}->{a:_}-> {B:_}-> Tm7 (snoc7 (snoc7 g a) B) a\nv17 = var7 (vs7 vz7)\n\nv27 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm7 (snoc7 (snoc7 (snoc7 g a) B) C) a\nv27 = var7 (vs7 (vs7 vz7))\n\nv37 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm7 (snoc7 (snoc7 (snoc7 (snoc7 g a) B) C) D) a\nv37 = var7 (vs7 (vs7 (vs7 vz7)))\n\nv47 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm7 (snoc7 (snoc7 (snoc7 (snoc7 (snoc7 g a) B) C) D) E) a\nv47 = var7 (vs7 (vs7 (vs7 (vs7 vz7))))\n\ntest7 : {g:_}-> {a:_} -> Tm7 g (arr7 (arr7 a a) (arr7 a a))\ntest7 = lam7 (lam7 (app7 v17 (app7 v17 (app7 v17 (app7 v17 (app7 v17 (app7 v17 v07)))))))\nTy8 : Type\nTy8 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty8 : Ty8\nempty8 = \\ _, empty, _ => empty\n\narr8 : Ty8 -> Ty8 -> Ty8\narr8 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon8 : Type\nCon8 = (Con8 : Type)\n ->(nil : Con8)\n ->(snoc : Con8 -> Ty8 -> Con8)\n -> Con8\n\nnil8 : Con8\nnil8 = \\ con, nil8, snoc => nil8\n\nsnoc8 : Con8 -> Ty8 -> Con8\nsnoc8 = \\ g, a, con, nil8, snoc8 => snoc8 (g con nil8 snoc8) a\n\nVar8 : Con8 -> Ty8 -> Type\nVar8 = \\ g, a =>\n (Var8 : Con8 -> Ty8 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var8 (snoc8 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var8 g a -> Var8 (snoc8 g b) a)\n -> Var8 g a\n\nvz8 : {g : _}-> {a : _} -> Var8 (snoc8 g a) a\nvz8 = \\ var, vz8, vs => vz8 _ _\n\nvs8 : {g : _} -> {B : _} -> {a : _} -> Var8 g a -> Var8 (snoc8 g B) a\nvs8 = \\ x, var, vz8, vs8 => vs8 _ _ _ (x var vz8 vs8)\n\nTm8 : Con8 -> Ty8 -> Type\nTm8 = \\ g, a =>\n (Tm8 : Con8 -> Ty8 -> Type)\n -> (var : (g : _) -> (a : _) -> Var8 g a -> Tm8 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm8 (snoc8 g a) B -> Tm8 g (arr8 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm8 g (arr8 a B) -> Tm8 g a -> Tm8 g B)\n -> Tm8 g a\n\nvar8 : {g : _} -> {a : _} -> Var8 g a -> Tm8 g a\nvar8 = \\ x, tm, var8, lam, app => var8 _ _ x\n\nlam8 : {g : _} -> {a : _} -> {B : _} -> Tm8 (snoc8 g a) B -> Tm8 g (arr8 a B)\nlam8 = \\ t, tm, var8, lam8, app => lam8 _ _ _ (t tm var8 lam8 app)\n\napp8 : {g:_}->{a:_}->{B:_} -> Tm8 g (arr8 a B) -> Tm8 g a -> Tm8 g B\napp8 = \\ t, u, tm, var8, lam8, app8 => app8 _ _ _ (t tm var8 lam8 app8) (u tm var8 lam8 app8)\n\nv08 : {g:_}->{a:_} -> Tm8 (snoc8 g a) a\nv08 = var8 vz8\n\nv18 : {g:_}->{a:_}-> {B:_}-> Tm8 (snoc8 (snoc8 g a) B) a\nv18 = var8 (vs8 vz8)\n\nv28 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm8 (snoc8 (snoc8 (snoc8 g a) B) C) a\nv28 = var8 (vs8 (vs8 vz8))\n\nv38 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm8 (snoc8 (snoc8 (snoc8 (snoc8 g a) B) C) D) a\nv38 = var8 (vs8 (vs8 (vs8 vz8)))\n\nv48 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm8 (snoc8 (snoc8 (snoc8 (snoc8 (snoc8 g a) B) C) D) E) a\nv48 = var8 (vs8 (vs8 (vs8 (vs8 vz8))))\n\ntest8 : {g:_}-> {a:_} -> Tm8 g (arr8 (arr8 a a) (arr8 a a))\ntest8 = lam8 (lam8 (app8 v18 (app8 v18 (app8 v18 (app8 v18 (app8 v18 (app8 v18 v08)))))))\nTy9 : Type\nTy9 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty9 : Ty9\nempty9 = \\ _, empty, _ => empty\n\narr9 : Ty9 -> Ty9 -> Ty9\narr9 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon9 : Type\nCon9 = (Con9 : Type)\n ->(nil : Con9)\n ->(snoc : Con9 -> Ty9 -> Con9)\n -> Con9\n\nnil9 : Con9\nnil9 = \\ con, nil9, snoc => nil9\n\nsnoc9 : Con9 -> Ty9 -> Con9\nsnoc9 = \\ g, a, con, nil9, snoc9 => snoc9 (g con nil9 snoc9) a\n\nVar9 : Con9 -> Ty9 -> Type\nVar9 = \\ g, a =>\n (Var9 : Con9 -> Ty9 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var9 (snoc9 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var9 g a -> Var9 (snoc9 g b) a)\n -> Var9 g a\n\nvz9 : {g : _}-> {a : _} -> Var9 (snoc9 g a) a\nvz9 = \\ var, vz9, vs => vz9 _ _\n\nvs9 : {g : _} -> {B : _} -> {a : _} -> Var9 g a -> Var9 (snoc9 g B) a\nvs9 = \\ x, var, vz9, vs9 => vs9 _ _ _ (x var vz9 vs9)\n\nTm9 : Con9 -> Ty9 -> Type\nTm9 = \\ g, a =>\n (Tm9 : Con9 -> Ty9 -> Type)\n -> (var : (g : _) -> (a : _) -> Var9 g a -> Tm9 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm9 (snoc9 g a) B -> Tm9 g (arr9 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm9 g (arr9 a B) -> Tm9 g a -> Tm9 g B)\n -> Tm9 g a\n\nvar9 : {g : _} -> {a : _} -> Var9 g a -> Tm9 g a\nvar9 = \\ x, tm, var9, lam, app => var9 _ _ x\n\nlam9 : {g : _} -> {a : _} -> {B : _} -> Tm9 (snoc9 g a) B -> Tm9 g (arr9 a B)\nlam9 = \\ t, tm, var9, lam9, app => lam9 _ _ _ (t tm var9 lam9 app)\n\napp9 : {g:_}->{a:_}->{B:_} -> Tm9 g (arr9 a B) -> Tm9 g a -> Tm9 g B\napp9 = \\ t, u, tm, var9, lam9, app9 => app9 _ _ _ (t tm var9 lam9 app9) (u tm var9 lam9 app9)\n\nv09 : {g:_}->{a:_} -> Tm9 (snoc9 g a) a\nv09 = var9 vz9\n\nv19 : {g:_}->{a:_}-> {B:_}-> Tm9 (snoc9 (snoc9 g a) B) a\nv19 = var9 (vs9 vz9)\n\nv29 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm9 (snoc9 (snoc9 (snoc9 g a) B) C) a\nv29 = var9 (vs9 (vs9 vz9))\n\nv39 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm9 (snoc9 (snoc9 (snoc9 (snoc9 g a) B) C) D) a\nv39 = var9 (vs9 (vs9 (vs9 vz9)))\n\nv49 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm9 (snoc9 (snoc9 (snoc9 (snoc9 (snoc9 g a) B) C) D) E) a\nv49 = var9 (vs9 (vs9 (vs9 (vs9 vz9))))\n\ntest9 : {g:_}-> {a:_} -> Tm9 g (arr9 (arr9 a a) (arr9 a a))\ntest9 = lam9 (lam9 (app9 v19 (app9 v19 (app9 v19 (app9 v19 (app9 v19 (app9 v19 v09)))))))\nTy10 : Type\nTy10 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty10 : Ty10\nempty10 = \\ _, empty, _ => empty\n\narr10 : Ty10 -> Ty10 -> Ty10\narr10 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon10 : Type\nCon10 = (Con10 : Type)\n ->(nil : Con10)\n ->(snoc : Con10 -> Ty10 -> Con10)\n -> Con10\n\nnil10 : Con10\nnil10 = \\ con, nil10, snoc => nil10\n\nsnoc10 : Con10 -> Ty10 -> Con10\nsnoc10 = \\ g, a, con, nil10, snoc10 => snoc10 (g con nil10 snoc10) a\n\nVar10 : Con10 -> Ty10 -> Type\nVar10 = \\ g, a =>\n (Var10 : Con10 -> Ty10 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var10 (snoc10 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var10 g a -> Var10 (snoc10 g b) a)\n -> Var10 g a\n\nvz10 : {g : _}-> {a : _} -> Var10 (snoc10 g a) a\nvz10 = \\ var, vz10, vs => vz10 _ _\n\nvs10 : {g : _} -> {B : _} -> {a : _} -> Var10 g a -> Var10 (snoc10 g B) a\nvs10 = \\ x, var, vz10, vs10 => vs10 _ _ _ (x var vz10 vs10)\n\nTm10 : Con10 -> Ty10 -> Type\nTm10 = \\ g, a =>\n (Tm10 : Con10 -> Ty10 -> Type)\n -> (var : (g : _) -> (a : _) -> Var10 g a -> Tm10 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm10 (snoc10 g a) B -> Tm10 g (arr10 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm10 g (arr10 a B) -> Tm10 g a -> Tm10 g B)\n -> Tm10 g a\n\nvar10 : {g : _} -> {a : _} -> Var10 g a -> Tm10 g a\nvar10 = \\ x, tm, var10, lam, app => var10 _ _ x\n\nlam10 : {g : _} -> {a : _} -> {B : _} -> Tm10 (snoc10 g a) B -> Tm10 g (arr10 a B)\nlam10 = \\ t, tm, var10, lam10, app => lam10 _ _ _ (t tm var10 lam10 app)\n\napp10 : {g:_}->{a:_}->{B:_} -> Tm10 g (arr10 a B) -> Tm10 g a -> Tm10 g B\napp10 = \\ t, u, tm, var10, lam10, app10 => app10 _ _ _ (t tm var10 lam10 app10) (u tm var10 lam10 app10)\n\nv010 : {g:_}->{a:_} -> Tm10 (snoc10 g a) a\nv010 = var10 vz10\n\nv110 : {g:_}->{a:_}-> {B:_}-> Tm10 (snoc10 (snoc10 g a) B) a\nv110 = var10 (vs10 vz10)\n\nv210 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm10 (snoc10 (snoc10 (snoc10 g a) B) C) a\nv210 = var10 (vs10 (vs10 vz10))\n\nv310 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm10 (snoc10 (snoc10 (snoc10 (snoc10 g a) B) C) D) a\nv310 = var10 (vs10 (vs10 (vs10 vz10)))\n\nv410 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm10 (snoc10 (snoc10 (snoc10 (snoc10 (snoc10 g a) B) C) D) E) a\nv410 = var10 (vs10 (vs10 (vs10 (vs10 vz10))))\n\ntest10 : {g:_}-> {a:_} -> Tm10 g (arr10 (arr10 a a) (arr10 a a))\ntest10 = lam10 (lam10 (app10 v110 (app10 v110 (app10 v110 (app10 v110 (app10 v110 (app10 v110 v010)))))))\nTy11 : Type\nTy11 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty11 : Ty11\nempty11 = \\ _, empty, _ => empty\n\narr11 : Ty11 -> Ty11 -> Ty11\narr11 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon11 : Type\nCon11 = (Con11 : Type)\n ->(nil : Con11)\n ->(snoc : Con11 -> Ty11 -> Con11)\n -> Con11\n\nnil11 : Con11\nnil11 = \\ con, nil11, snoc => nil11\n\nsnoc11 : Con11 -> Ty11 -> Con11\nsnoc11 = \\ g, a, con, nil11, snoc11 => snoc11 (g con nil11 snoc11) a\n\nVar11 : Con11 -> Ty11 -> Type\nVar11 = \\ g, a =>\n (Var11 : Con11 -> Ty11 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var11 (snoc11 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var11 g a -> Var11 (snoc11 g b) a)\n -> Var11 g a\n\nvz11 : {g : _}-> {a : _} -> Var11 (snoc11 g a) a\nvz11 = \\ var, vz11, vs => vz11 _ _\n\nvs11 : {g : _} -> {B : _} -> {a : _} -> Var11 g a -> Var11 (snoc11 g B) a\nvs11 = \\ x, var, vz11, vs11 => vs11 _ _ _ (x var vz11 vs11)\n\nTm11 : Con11 -> Ty11 -> Type\nTm11 = \\ g, a =>\n (Tm11 : Con11 -> Ty11 -> Type)\n -> (var : (g : _) -> (a : _) -> Var11 g a -> Tm11 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm11 (snoc11 g a) B -> Tm11 g (arr11 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm11 g (arr11 a B) -> Tm11 g a -> Tm11 g B)\n -> Tm11 g a\n\nvar11 : {g : _} -> {a : _} -> Var11 g a -> Tm11 g a\nvar11 = \\ x, tm, var11, lam, app => var11 _ _ x\n\nlam11 : {g : _} -> {a : _} -> {B : _} -> Tm11 (snoc11 g a) B -> Tm11 g (arr11 a B)\nlam11 = \\ t, tm, var11, lam11, app => lam11 _ _ _ (t tm var11 lam11 app)\n\napp11 : {g:_}->{a:_}->{B:_} -> Tm11 g (arr11 a B) -> Tm11 g a -> Tm11 g B\napp11 = \\ t, u, tm, var11, lam11, app11 => app11 _ _ _ (t tm var11 lam11 app11) (u tm var11 lam11 app11)\n\nv011 : {g:_}->{a:_} -> Tm11 (snoc11 g a) a\nv011 = var11 vz11\n\nv111 : {g:_}->{a:_}-> {B:_}-> Tm11 (snoc11 (snoc11 g a) B) a\nv111 = var11 (vs11 vz11)\n\nv211 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm11 (snoc11 (snoc11 (snoc11 g a) B) C) a\nv211 = var11 (vs11 (vs11 vz11))\n\nv311 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm11 (snoc11 (snoc11 (snoc11 (snoc11 g a) B) C) D) a\nv311 = var11 (vs11 (vs11 (vs11 vz11)))\n\nv411 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm11 (snoc11 (snoc11 (snoc11 (snoc11 (snoc11 g a) B) C) D) E) a\nv411 = var11 (vs11 (vs11 (vs11 (vs11 vz11))))\n\ntest11 : {g:_}-> {a:_} -> Tm11 g (arr11 (arr11 a a) (arr11 a a))\ntest11 = lam11 (lam11 (app11 v111 (app11 v111 (app11 v111 (app11 v111 (app11 v111 (app11 v111 v011)))))))\nTy12 : Type\nTy12 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty12 : Ty12\nempty12 = \\ _, empty, _ => empty\n\narr12 : Ty12 -> Ty12 -> Ty12\narr12 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon12 : Type\nCon12 = (Con12 : Type)\n ->(nil : Con12)\n ->(snoc : Con12 -> Ty12 -> Con12)\n -> Con12\n\nnil12 : Con12\nnil12 = \\ con, nil12, snoc => nil12\n\nsnoc12 : Con12 -> Ty12 -> Con12\nsnoc12 = \\ g, a, con, nil12, snoc12 => snoc12 (g con nil12 snoc12) a\n\nVar12 : Con12 -> Ty12 -> Type\nVar12 = \\ g, a =>\n (Var12 : Con12 -> Ty12 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var12 (snoc12 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var12 g a -> Var12 (snoc12 g b) a)\n -> Var12 g a\n\nvz12 : {g : _}-> {a : _} -> Var12 (snoc12 g a) a\nvz12 = \\ var, vz12, vs => vz12 _ _\n\nvs12 : {g : _} -> {B : _} -> {a : _} -> Var12 g a -> Var12 (snoc12 g B) a\nvs12 = \\ x, var, vz12, vs12 => vs12 _ _ _ (x var vz12 vs12)\n\nTm12 : Con12 -> Ty12 -> Type\nTm12 = \\ g, a =>\n (Tm12 : Con12 -> Ty12 -> Type)\n -> (var : (g : _) -> (a : _) -> Var12 g a -> Tm12 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm12 (snoc12 g a) B -> Tm12 g (arr12 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm12 g (arr12 a B) -> Tm12 g a -> Tm12 g B)\n -> Tm12 g a\n\nvar12 : {g : _} -> {a : _} -> Var12 g a -> Tm12 g a\nvar12 = \\ x, tm, var12, lam, app => var12 _ _ x\n\nlam12 : {g : _} -> {a : _} -> {B : _} -> Tm12 (snoc12 g a) B -> Tm12 g (arr12 a B)\nlam12 = \\ t, tm, var12, lam12, app => lam12 _ _ _ (t tm var12 lam12 app)\n\napp12 : {g:_}->{a:_}->{B:_} -> Tm12 g (arr12 a B) -> Tm12 g a -> Tm12 g B\napp12 = \\ t, u, tm, var12, lam12, app12 => app12 _ _ _ (t tm var12 lam12 app12) (u tm var12 lam12 app12)\n\nv012 : {g:_}->{a:_} -> Tm12 (snoc12 g a) a\nv012 = var12 vz12\n\nv112 : {g:_}->{a:_}-> {B:_}-> Tm12 (snoc12 (snoc12 g a) B) a\nv112 = var12 (vs12 vz12)\n\nv212 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm12 (snoc12 (snoc12 (snoc12 g a) B) C) a\nv212 = var12 (vs12 (vs12 vz12))\n\nv312 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm12 (snoc12 (snoc12 (snoc12 (snoc12 g a) B) C) D) a\nv312 = var12 (vs12 (vs12 (vs12 vz12)))\n\nv412 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm12 (snoc12 (snoc12 (snoc12 (snoc12 (snoc12 g a) B) C) D) E) a\nv412 = var12 (vs12 (vs12 (vs12 (vs12 vz12))))\n\ntest12 : {g:_}-> {a:_} -> Tm12 g (arr12 (arr12 a a) (arr12 a a))\ntest12 = lam12 (lam12 (app12 v112 (app12 v112 (app12 v112 (app12 v112 (app12 v112 (app12 v112 v012)))))))\nTy13 : Type\nTy13 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty13 : Ty13\nempty13 = \\ _, empty, _ => empty\n\narr13 : Ty13 -> Ty13 -> Ty13\narr13 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon13 : Type\nCon13 = (Con13 : Type)\n ->(nil : Con13)\n ->(snoc : Con13 -> Ty13 -> Con13)\n -> Con13\n\nnil13 : Con13\nnil13 = \\ con, nil13, snoc => nil13\n\nsnoc13 : Con13 -> Ty13 -> Con13\nsnoc13 = \\ g, a, con, nil13, snoc13 => snoc13 (g con nil13 snoc13) a\n\nVar13 : Con13 -> Ty13 -> Type\nVar13 = \\ g, a =>\n (Var13 : Con13 -> Ty13 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var13 (snoc13 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var13 g a -> Var13 (snoc13 g b) a)\n -> Var13 g a\n\nvz13 : {g : _}-> {a : _} -> Var13 (snoc13 g a) a\nvz13 = \\ var, vz13, vs => vz13 _ _\n\nvs13 : {g : _} -> {B : _} -> {a : _} -> Var13 g a -> Var13 (snoc13 g B) a\nvs13 = \\ x, var, vz13, vs13 => vs13 _ _ _ (x var vz13 vs13)\n\nTm13 : Con13 -> Ty13 -> Type\nTm13 = \\ g, a =>\n (Tm13 : Con13 -> Ty13 -> Type)\n -> (var : (g : _) -> (a : _) -> Var13 g a -> Tm13 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm13 (snoc13 g a) B -> Tm13 g (arr13 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm13 g (arr13 a B) -> Tm13 g a -> Tm13 g B)\n -> Tm13 g a\n\nvar13 : {g : _} -> {a : _} -> Var13 g a -> Tm13 g a\nvar13 = \\ x, tm, var13, lam, app => var13 _ _ x\n\nlam13 : {g : _} -> {a : _} -> {B : _} -> Tm13 (snoc13 g a) B -> Tm13 g (arr13 a B)\nlam13 = \\ t, tm, var13, lam13, app => lam13 _ _ _ (t tm var13 lam13 app)\n\napp13 : {g:_}->{a:_}->{B:_} -> Tm13 g (arr13 a B) -> Tm13 g a -> Tm13 g B\napp13 = \\ t, u, tm, var13, lam13, app13 => app13 _ _ _ (t tm var13 lam13 app13) (u tm var13 lam13 app13)\n\nv013 : {g:_}->{a:_} -> Tm13 (snoc13 g a) a\nv013 = var13 vz13\n\nv113 : {g:_}->{a:_}-> {B:_}-> Tm13 (snoc13 (snoc13 g a) B) a\nv113 = var13 (vs13 vz13)\n\nv213 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm13 (snoc13 (snoc13 (snoc13 g a) B) C) a\nv213 = var13 (vs13 (vs13 vz13))\n\nv313 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm13 (snoc13 (snoc13 (snoc13 (snoc13 g a) B) C) D) a\nv313 = var13 (vs13 (vs13 (vs13 vz13)))\n\nv413 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm13 (snoc13 (snoc13 (snoc13 (snoc13 (snoc13 g a) B) C) D) E) a\nv413 = var13 (vs13 (vs13 (vs13 (vs13 vz13))))\n\ntest13 : {g:_}-> {a:_} -> Tm13 g (arr13 (arr13 a a) (arr13 a a))\ntest13 = lam13 (lam13 (app13 v113 (app13 v113 (app13 v113 (app13 v113 (app13 v113 (app13 v113 v013)))))))\nTy14 : Type\nTy14 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty14 : Ty14\nempty14 = \\ _, empty, _ => empty\n\narr14 : Ty14 -> Ty14 -> Ty14\narr14 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon14 : Type\nCon14 = (Con14 : Type)\n ->(nil : Con14)\n ->(snoc : Con14 -> Ty14 -> Con14)\n -> Con14\n\nnil14 : Con14\nnil14 = \\ con, nil14, snoc => nil14\n\nsnoc14 : Con14 -> Ty14 -> Con14\nsnoc14 = \\ g, a, con, nil14, snoc14 => snoc14 (g con nil14 snoc14) a\n\nVar14 : Con14 -> Ty14 -> Type\nVar14 = \\ g, a =>\n (Var14 : Con14 -> Ty14 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var14 (snoc14 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var14 g a -> Var14 (snoc14 g b) a)\n -> Var14 g a\n\nvz14 : {g : _}-> {a : _} -> Var14 (snoc14 g a) a\nvz14 = \\ var, vz14, vs => vz14 _ _\n\nvs14 : {g : _} -> {B : _} -> {a : _} -> Var14 g a -> Var14 (snoc14 g B) a\nvs14 = \\ x, var, vz14, vs14 => vs14 _ _ _ (x var vz14 vs14)\n\nTm14 : Con14 -> Ty14 -> Type\nTm14 = \\ g, a =>\n (Tm14 : Con14 -> Ty14 -> Type)\n -> (var : (g : _) -> (a : _) -> Var14 g a -> Tm14 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm14 (snoc14 g a) B -> Tm14 g (arr14 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm14 g (arr14 a B) -> Tm14 g a -> Tm14 g B)\n -> Tm14 g a\n\nvar14 : {g : _} -> {a : _} -> Var14 g a -> Tm14 g a\nvar14 = \\ x, tm, var14, lam, app => var14 _ _ x\n\nlam14 : {g : _} -> {a : _} -> {B : _} -> Tm14 (snoc14 g a) B -> Tm14 g (arr14 a B)\nlam14 = \\ t, tm, var14, lam14, app => lam14 _ _ _ (t tm var14 lam14 app)\n\napp14 : {g:_}->{a:_}->{B:_} -> Tm14 g (arr14 a B) -> Tm14 g a -> Tm14 g B\napp14 = \\ t, u, tm, var14, lam14, app14 => app14 _ _ _ (t tm var14 lam14 app14) (u tm var14 lam14 app14)\n\nv014 : {g:_}->{a:_} -> Tm14 (snoc14 g a) a\nv014 = var14 vz14\n\nv114 : {g:_}->{a:_}-> {B:_}-> Tm14 (snoc14 (snoc14 g a) B) a\nv114 = var14 (vs14 vz14)\n\nv214 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm14 (snoc14 (snoc14 (snoc14 g a) B) C) a\nv214 = var14 (vs14 (vs14 vz14))\n\nv314 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm14 (snoc14 (snoc14 (snoc14 (snoc14 g a) B) C) D) a\nv314 = var14 (vs14 (vs14 (vs14 vz14)))\n\nv414 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm14 (snoc14 (snoc14 (snoc14 (snoc14 (snoc14 g a) B) C) D) E) a\nv414 = var14 (vs14 (vs14 (vs14 (vs14 vz14))))\n\ntest14 : {g:_}-> {a:_} -> Tm14 g (arr14 (arr14 a a) (arr14 a a))\ntest14 = lam14 (lam14 (app14 v114 (app14 v114 (app14 v114 (app14 v114 (app14 v114 (app14 v114 v014)))))))\nTy15 : Type\nTy15 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty15 : Ty15\nempty15 = \\ _, empty, _ => empty\n\narr15 : Ty15 -> Ty15 -> Ty15\narr15 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon15 : Type\nCon15 = (Con15 : Type)\n ->(nil : Con15)\n ->(snoc : Con15 -> Ty15 -> Con15)\n -> Con15\n\nnil15 : Con15\nnil15 = \\ con, nil15, snoc => nil15\n\nsnoc15 : Con15 -> Ty15 -> Con15\nsnoc15 = \\ g, a, con, nil15, snoc15 => snoc15 (g con nil15 snoc15) a\n\nVar15 : Con15 -> Ty15 -> Type\nVar15 = \\ g, a =>\n (Var15 : Con15 -> Ty15 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var15 (snoc15 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var15 g a -> Var15 (snoc15 g b) a)\n -> Var15 g a\n\nvz15 : {g : _}-> {a : _} -> Var15 (snoc15 g a) a\nvz15 = \\ var, vz15, vs => vz15 _ _\n\nvs15 : {g : _} -> {B : _} -> {a : _} -> Var15 g a -> Var15 (snoc15 g B) a\nvs15 = \\ x, var, vz15, vs15 => vs15 _ _ _ (x var vz15 vs15)\n\nTm15 : Con15 -> Ty15 -> Type\nTm15 = \\ g, a =>\n (Tm15 : Con15 -> Ty15 -> Type)\n -> (var : (g : _) -> (a : _) -> Var15 g a -> Tm15 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm15 (snoc15 g a) B -> Tm15 g (arr15 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm15 g (arr15 a B) -> Tm15 g a -> Tm15 g B)\n -> Tm15 g a\n\nvar15 : {g : _} -> {a : _} -> Var15 g a -> Tm15 g a\nvar15 = \\ x, tm, var15, lam, app => var15 _ _ x\n\nlam15 : {g : _} -> {a : _} -> {B : _} -> Tm15 (snoc15 g a) B -> Tm15 g (arr15 a B)\nlam15 = \\ t, tm, var15, lam15, app => lam15 _ _ _ (t tm var15 lam15 app)\n\napp15 : {g:_}->{a:_}->{B:_} -> Tm15 g (arr15 a B) -> Tm15 g a -> Tm15 g B\napp15 = \\ t, u, tm, var15, lam15, app15 => app15 _ _ _ (t tm var15 lam15 app15) (u tm var15 lam15 app15)\n\nv015 : {g:_}->{a:_} -> Tm15 (snoc15 g a) a\nv015 = var15 vz15\n\nv115 : {g:_}->{a:_}-> {B:_}-> Tm15 (snoc15 (snoc15 g a) B) a\nv115 = var15 (vs15 vz15)\n\nv215 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm15 (snoc15 (snoc15 (snoc15 g a) B) C) a\nv215 = var15 (vs15 (vs15 vz15))\n\nv315 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm15 (snoc15 (snoc15 (snoc15 (snoc15 g a) B) C) D) a\nv315 = var15 (vs15 (vs15 (vs15 vz15)))\n\nv415 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm15 (snoc15 (snoc15 (snoc15 (snoc15 (snoc15 g a) B) C) D) E) a\nv415 = var15 (vs15 (vs15 (vs15 (vs15 vz15))))\n\ntest15 : {g:_}-> {a:_} -> Tm15 g (arr15 (arr15 a a) (arr15 a a))\ntest15 = lam15 (lam15 (app15 v115 (app15 v115 (app15 v115 (app15 v115 (app15 v115 (app15 v115 v015)))))))\nTy16 : Type\nTy16 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty16 : Ty16\nempty16 = \\ _, empty, _ => empty\n\narr16 : Ty16 -> Ty16 -> Ty16\narr16 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon16 : Type\nCon16 = (Con16 : Type)\n ->(nil : Con16)\n ->(snoc : Con16 -> Ty16 -> Con16)\n -> Con16\n\nnil16 : Con16\nnil16 = \\ con, nil16, snoc => nil16\n\nsnoc16 : Con16 -> Ty16 -> Con16\nsnoc16 = \\ g, a, con, nil16, snoc16 => snoc16 (g con nil16 snoc16) a\n\nVar16 : Con16 -> Ty16 -> Type\nVar16 = \\ g, a =>\n (Var16 : Con16 -> Ty16 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var16 (snoc16 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var16 g a -> Var16 (snoc16 g b) a)\n -> Var16 g a\n\nvz16 : {g : _}-> {a : _} -> Var16 (snoc16 g a) a\nvz16 = \\ var, vz16, vs => vz16 _ _\n\nvs16 : {g : _} -> {B : _} -> {a : _} -> Var16 g a -> Var16 (snoc16 g B) a\nvs16 = \\ x, var, vz16, vs16 => vs16 _ _ _ (x var vz16 vs16)\n\nTm16 : Con16 -> Ty16 -> Type\nTm16 = \\ g, a =>\n (Tm16 : Con16 -> Ty16 -> Type)\n -> (var : (g : _) -> (a : _) -> Var16 g a -> Tm16 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm16 (snoc16 g a) B -> Tm16 g (arr16 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm16 g (arr16 a B) -> Tm16 g a -> Tm16 g B)\n -> Tm16 g a\n\nvar16 : {g : _} -> {a : _} -> Var16 g a -> Tm16 g a\nvar16 = \\ x, tm, var16, lam, app => var16 _ _ x\n\nlam16 : {g : _} -> {a : _} -> {B : _} -> Tm16 (snoc16 g a) B -> Tm16 g (arr16 a B)\nlam16 = \\ t, tm, var16, lam16, app => lam16 _ _ _ (t tm var16 lam16 app)\n\napp16 : {g:_}->{a:_}->{B:_} -> Tm16 g (arr16 a B) -> Tm16 g a -> Tm16 g B\napp16 = \\ t, u, tm, var16, lam16, app16 => app16 _ _ _ (t tm var16 lam16 app16) (u tm var16 lam16 app16)\n\nv016 : {g:_}->{a:_} -> Tm16 (snoc16 g a) a\nv016 = var16 vz16\n\nv116 : {g:_}->{a:_}-> {B:_}-> Tm16 (snoc16 (snoc16 g a) B) a\nv116 = var16 (vs16 vz16)\n\nv216 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm16 (snoc16 (snoc16 (snoc16 g a) B) C) a\nv216 = var16 (vs16 (vs16 vz16))\n\nv316 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm16 (snoc16 (snoc16 (snoc16 (snoc16 g a) B) C) D) a\nv316 = var16 (vs16 (vs16 (vs16 vz16)))\n\nv416 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm16 (snoc16 (snoc16 (snoc16 (snoc16 (snoc16 g a) B) C) D) E) a\nv416 = var16 (vs16 (vs16 (vs16 (vs16 vz16))))\n\ntest16 : {g:_}-> {a:_} -> Tm16 g (arr16 (arr16 a a) (arr16 a a))\ntest16 = lam16 (lam16 (app16 v116 (app16 v116 (app16 v116 (app16 v116 (app16 v116 (app16 v116 v016)))))))\nTy17 : Type\nTy17 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty17 : Ty17\nempty17 = \\ _, empty, _ => empty\n\narr17 : Ty17 -> Ty17 -> Ty17\narr17 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon17 : Type\nCon17 = (Con17 : Type)\n ->(nil : Con17)\n ->(snoc : Con17 -> Ty17 -> Con17)\n -> Con17\n\nnil17 : Con17\nnil17 = \\ con, nil17, snoc => nil17\n\nsnoc17 : Con17 -> Ty17 -> Con17\nsnoc17 = \\ g, a, con, nil17, snoc17 => snoc17 (g con nil17 snoc17) a\n\nVar17 : Con17 -> Ty17 -> Type\nVar17 = \\ g, a =>\n (Var17 : Con17 -> Ty17 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var17 (snoc17 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var17 g a -> Var17 (snoc17 g b) a)\n -> Var17 g a\n\nvz17 : {g : _}-> {a : _} -> Var17 (snoc17 g a) a\nvz17 = \\ var, vz17, vs => vz17 _ _\n\nvs17 : {g : _} -> {B : _} -> {a : _} -> Var17 g a -> Var17 (snoc17 g B) a\nvs17 = \\ x, var, vz17, vs17 => vs17 _ _ _ (x var vz17 vs17)\n\nTm17 : Con17 -> Ty17 -> Type\nTm17 = \\ g, a =>\n (Tm17 : Con17 -> Ty17 -> Type)\n -> (var : (g : _) -> (a : _) -> Var17 g a -> Tm17 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm17 (snoc17 g a) B -> Tm17 g (arr17 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm17 g (arr17 a B) -> Tm17 g a -> Tm17 g B)\n -> Tm17 g a\n\nvar17 : {g : _} -> {a : _} -> Var17 g a -> Tm17 g a\nvar17 = \\ x, tm, var17, lam, app => var17 _ _ x\n\nlam17 : {g : _} -> {a : _} -> {B : _} -> Tm17 (snoc17 g a) B -> Tm17 g (arr17 a B)\nlam17 = \\ t, tm, var17, lam17, app => lam17 _ _ _ (t tm var17 lam17 app)\n\napp17 : {g:_}->{a:_}->{B:_} -> Tm17 g (arr17 a B) -> Tm17 g a -> Tm17 g B\napp17 = \\ t, u, tm, var17, lam17, app17 => app17 _ _ _ (t tm var17 lam17 app17) (u tm var17 lam17 app17)\n\nv017 : {g:_}->{a:_} -> Tm17 (snoc17 g a) a\nv017 = var17 vz17\n\nv117 : {g:_}->{a:_}-> {B:_}-> Tm17 (snoc17 (snoc17 g a) B) a\nv117 = var17 (vs17 vz17)\n\nv217 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm17 (snoc17 (snoc17 (snoc17 g a) B) C) a\nv217 = var17 (vs17 (vs17 vz17))\n\nv317 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm17 (snoc17 (snoc17 (snoc17 (snoc17 g a) B) C) D) a\nv317 = var17 (vs17 (vs17 (vs17 vz17)))\n\nv417 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm17 (snoc17 (snoc17 (snoc17 (snoc17 (snoc17 g a) B) C) D) E) a\nv417 = var17 (vs17 (vs17 (vs17 (vs17 vz17))))\n\ntest17 : {g:_}-> {a:_} -> Tm17 g (arr17 (arr17 a a) (arr17 a a))\ntest17 = lam17 (lam17 (app17 v117 (app17 v117 (app17 v117 (app17 v117 (app17 v117 (app17 v117 v017)))))))\nTy18 : Type\nTy18 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty18 : Ty18\nempty18 = \\ _, empty, _ => empty\n\narr18 : Ty18 -> Ty18 -> Ty18\narr18 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon18 : Type\nCon18 = (Con18 : Type)\n ->(nil : Con18)\n ->(snoc : Con18 -> Ty18 -> Con18)\n -> Con18\n\nnil18 : Con18\nnil18 = \\ con, nil18, snoc => nil18\n\nsnoc18 : Con18 -> Ty18 -> Con18\nsnoc18 = \\ g, a, con, nil18, snoc18 => snoc18 (g con nil18 snoc18) a\n\nVar18 : Con18 -> Ty18 -> Type\nVar18 = \\ g, a =>\n (Var18 : Con18 -> Ty18 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var18 (snoc18 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var18 g a -> Var18 (snoc18 g b) a)\n -> Var18 g a\n\nvz18 : {g : _}-> {a : _} -> Var18 (snoc18 g a) a\nvz18 = \\ var, vz18, vs => vz18 _ _\n\nvs18 : {g : _} -> {B : _} -> {a : _} -> Var18 g a -> Var18 (snoc18 g B) a\nvs18 = \\ x, var, vz18, vs18 => vs18 _ _ _ (x var vz18 vs18)\n\nTm18 : Con18 -> Ty18 -> Type\nTm18 = \\ g, a =>\n (Tm18 : Con18 -> Ty18 -> Type)\n -> (var : (g : _) -> (a : _) -> Var18 g a -> Tm18 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm18 (snoc18 g a) B -> Tm18 g (arr18 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm18 g (arr18 a B) -> Tm18 g a -> Tm18 g B)\n -> Tm18 g a\n\nvar18 : {g : _} -> {a : _} -> Var18 g a -> Tm18 g a\nvar18 = \\ x, tm, var18, lam, app => var18 _ _ x\n\nlam18 : {g : _} -> {a : _} -> {B : _} -> Tm18 (snoc18 g a) B -> Tm18 g (arr18 a B)\nlam18 = \\ t, tm, var18, lam18, app => lam18 _ _ _ (t tm var18 lam18 app)\n\napp18 : {g:_}->{a:_}->{B:_} -> Tm18 g (arr18 a B) -> Tm18 g a -> Tm18 g B\napp18 = \\ t, u, tm, var18, lam18, app18 => app18 _ _ _ (t tm var18 lam18 app18) (u tm var18 lam18 app18)\n\nv018 : {g:_}->{a:_} -> Tm18 (snoc18 g a) a\nv018 = var18 vz18\n\nv118 : {g:_}->{a:_}-> {B:_}-> Tm18 (snoc18 (snoc18 g a) B) a\nv118 = var18 (vs18 vz18)\n\nv218 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm18 (snoc18 (snoc18 (snoc18 g a) B) C) a\nv218 = var18 (vs18 (vs18 vz18))\n\nv318 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm18 (snoc18 (snoc18 (snoc18 (snoc18 g a) B) C) D) a\nv318 = var18 (vs18 (vs18 (vs18 vz18)))\n\nv418 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm18 (snoc18 (snoc18 (snoc18 (snoc18 (snoc18 g a) B) C) D) E) a\nv418 = var18 (vs18 (vs18 (vs18 (vs18 vz18))))\n\ntest18 : {g:_}-> {a:_} -> Tm18 g (arr18 (arr18 a a) (arr18 a a))\ntest18 = lam18 (lam18 (app18 v118 (app18 v118 (app18 v118 (app18 v118 (app18 v118 (app18 v118 v018)))))))\n", "meta": {"hexsha": "733d13df43ce5dc2d6279a95fa27255eaebb09f5", "size": 44792, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "bench/stlc_small1k.idr", "max_stars_repo_name": "Kha/smalltt", "max_stars_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 377, "max_stars_repo_stars_event_min_datetime": "2017-11-26T16:57:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T21:31:01.000Z", "max_issues_repo_path": "bench/stlc_small1k.idr", "max_issues_repo_name": "Kha/smalltt", "max_issues_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2020-03-16T09:14:57.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:51:10.000Z", "max_forks_repo_path": "bench/stlc_small1k.idr", "max_forks_repo_name": "Kha/smalltt", "max_forks_repo_head_hexsha": "3d4a20a6d80ac524325cf2d8d0a48095ded08eb6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 19, "max_forks_repo_forks_event_min_datetime": "2018-12-05T21:11:34.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T19:46:54.000Z", "avg_line_length": 33.1792592593, "max_line_length": 118, "alphanum_fraction": 0.4871628862, "num_tokens": 21151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5296748745487573}} {"text": "record Is3 (n : Nat) where\n constructor MkThree\n {auto prf : n === 3}\n\nthree : Is3 3\nthree = MkThree\n", "meta": {"hexsha": "dac17e38dccfd363aee80552a119599bc44d436a", "size": 103, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/record007/Fld.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/record007/Fld.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/record007/Fld.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 14.7142857143, "max_line_length": 26, "alphanum_fraction": 0.640776699, "num_tokens": 38, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.5296748689302404}} {"text": "module MinesweeperSMT\n\nimport Data.Vect\nimport src.SMTLib\nimport src.Tensor\nimport src.GridOps\n\npuzzle : Vect 9 (Vect 9 Int)\npuzzle = [ [-1, -1, -1, -1, 1, 0, 0, 1, -1],\n [-1, -1, 2, 1, 1, 0, 0, 1, 1],\n [-1, -1, 1, 0, 0, 0, 0, 0, 0],\n [-1, 2, 1, 0, 0, 0, 0, 0, 0],\n [-1, 2, 0, 0, 0, 0, 0, 0, 0],\n [-1, 3, 1, 0, 0, 0, 1, 1, 1],\n [-1, -1, 1, 0, 0, 0, 1, -1, -1],\n [-1, -1, 2, 2, 1, 1, 1, -1, -1],\n [-1, -1, -1, -1, -1, -1, -1, -1, -1] ]\n\nlookup : Fin n -> Fin m -> List Dir -> Vect n (Vect m (Expr (NumT IntT))) -> Expr (NumT IntT)\nlookup n m ds xss = GridOps.lookup n m ds (int 0) xss\n\nequation : Fin n -> Fin m -> Int -> Vect n (Vect m (Expr (NumT IntT))) -> Expr BoolT\nequation n m v xss with (toPos n, toPos m)\n equation n m v xss | (First, First) = add [lookup n m [Left] xss, lookup n m [Up] xss, lookup n m [Up, Left] xss] == (int v)\n equation n m v xss | (Last, Last) = add [lookup n m [Right] xss, lookup n m [Down] xss, lookup n m [Down, Right] xss] == (int v)\n equation n m v xss | (First, Last) = add [lookup n m [Right] xss, lookup n m [Up] xss, lookup n m [Up, Right] xss] == (int v)\n equation n m v xss | (Last, First) = add [lookup n m [Left] xss, lookup n m [Down] xss, lookup n m [Down, Left] xss] == (int v)\n equation n m v xss | (First, _) = add [lookup n m [Left] xss, lookup n m [Right] xss, lookup n m [Up] xss,\n lookup n m [Up, Right] xss, lookup n m [Up, Left] xss] == (int v)\n equation n m v xss | (Last, _) = add [lookup n m [Left] xss, lookup n m [Right] xss, lookup n m [Down] xss,\n lookup n m [Down, Right] xss, lookup n m [Down, Left] xss] == (int v)\n equation n m v xss | (_, First) = add [lookup n m [Left] xss, lookup n m [Down] xss, lookup n m [Down, Left] xss,\n lookup n m [Up] xss, lookup n m [Up, Left] xss] == (int v)\n equation n m v xss | (_, Last) = add [lookup n m [Right] xss, lookup n m [Down] xss, lookup n m [Down, Right] xss,\n lookup n m [Up] xss, lookup n m [Up, Right] xss] == (int v)\n equation n m v xss | (_, _) = add [lookup n m [Left] xss, lookup n m [Right] xss, lookup n m [Down] xss,\n lookup n m [Up] xss, lookup n m [Down, Right] xss, lookup n m [Down, Left] xss,\n lookup n m [Up, Right] xss, lookup n m [Up, Left] xss] == (int v)\n\ncollect : Vect n (Vect m Int) -> Vect n (Vect m (Expr (NumT IntT))) -> Vect n (Vect m (Expr BoolT))\ncollect puzzle vars = tabulate (\\n => tabulate (\\m => let (x, v) = (index n m puzzle, index n m vars) in\n if x < 0 then (v == (int 0)) || (v == (int 1)) else (v == (int 0)) && equation n m x vars))\n\nvars : Tensor [9, 9] String\nvars = toTensor $ tabulate (\\i0 => tabulate (\\i1 => \"x_\" ++ show (finToNat i0) ++ \"_\" ++ show (finToNat i1)))\n\ninst : Vect 9 (Vect 9 (Expr (NumT IntT)))\ninst = tabulate (\\i0 => tabulate (\\i1 => int $ index i0 i1 puzzle))\n\nsolver : Smt ()\nsolver = do vars <- declareVars vars (NumT IntT)\n assert $ and $ concat $ collect puzzle (toVect vars)\n assert $ index 0 1 (toVect vars) == (int 1)\n checkSat\n getModel\n end\n\ntest : IO ()\ntest = print solver\n", "meta": {"hexsha": "ebfd02d01bc155dfcfa5223dd80b4172cfac0fb3", "size": 3439, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/MinesweeperSMT.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/MinesweeperSMT.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/MinesweeperSMT.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 57.3166666667, "max_line_length": 145, "alphanum_fraction": 0.5013085199, "num_tokens": 1295, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.5294650877071924}} {"text": "module Quantities.Units\n\nimport Quantities.Core\nimport Quantities.SIBaseQuantities\nimport Quantities.SIDerivedQuantities\nimport Quantities.SIBaseUnits\n\n%default total\n%access public export\n\nRadian : Unit PlaneAngle\nRadian = One\nRad : Unit PlaneAngle\nRad = One\n\nSteradian : Unit SolidAngle\nSteradian = One\nSr : Unit SolidAngle\nSr = Steradian\n\nHertz : Unit Frequency\nHertz = Second ^^ (-1)\nHz : Unit Frequency\nHz = Hertz\n\nNewton : Unit Force'\nNewton = ((Metre Second) Second) <**> Kilogram\nN : Unit Force'\nN = Newton\n\nPascal : Unit Pressure\nPascal = Newton (Metre ^^ 2)\nPa : Unit Pressure\nPa = Pascal\n\nJoule : Unit Energy\nJoule = Newton <**> Metre\nJ : Unit Energy\nJ = Joule\n\nWatt : Unit Power\nWatt = Joule Second\nW : Unit Power\nW = Watt\n\nCoulomb : Unit ElectricCharge\nCoulomb = Second <**> Ampere\nC : Unit ElectricCharge\nC = Coulomb\n\nVolt : Unit ElectricPotentialDifference\nVolt = Watt Ampere\nV : Unit ElectricPotentialDifference\nV = Volt\n\nFarad : Unit Capacitance\nFarad = Coulomb Volt\nF : Unit Capacitance\nF = Farad\n\nOhm : Unit ElectricResistance\nOhm = Volt Ampere\n\nSiemens : Unit ElectricConductance\nSiemens = Ampere Volt\nS : Unit ElectricConductance\nS = Siemens\n\nWeber : Unit MagneticFlux\nWeber = Second <**> Volt\nWb : Unit MagneticFlux\nWb = Weber\n\nTesla : Unit MagneticFluxDensity\nTesla = Weber (Metre ^^ 2)\nT : Unit MagneticFluxDensity\nT = Tesla\n\nHenry : Unit Inductance\nHenry = Weber Ampere\nH : Unit Inductance\nH = Henry\n\n-- For relative temperature measurements\nCelsius : Unit Temperature\nCelsius = Kelvin\nDC : Unit Temperature\nDC = Celsius\n\nLumen : Unit LuminousFlux\nLumen = Candela <**> Steradian\nLm : Unit LuminousFlux\nLm = Lumen\n\nLux : Unit Illuminance\nLux = Lumen (Metre ^^ 2)\nLx : Unit Illuminance\nLx = Lux\n\nBecquerel : Unit ActivityReferredToARadionuclide\nBecquerel = Second ^^ (-1)\nBq : Unit ActivityReferredToARadionuclide\nBq = Becquerel\n\nGray : Unit AbsorbedDose\nGray = Joule Kilogram\nGy : Unit AbsorbedDose\nGy = Gray\n\nSievert : Unit DoseEquivalent\nSievert = Joule Kilogram\nSv : Unit DoseEquivalent\nSv = Sievert\n\nKatal : Unit CatalyticActivity\nKatal = Mol Second\nKat : Unit CatalyticActivity\nKat = Katal\n", "meta": {"hexsha": "28d60138b532960956887882d17738b8e9438f22", "size": 2189, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Quantities/SIDerivedUnits.idr", "max_stars_repo_name": "timjb/quantities", "max_stars_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 112, "max_stars_repo_stars_event_min_datetime": "2015-01-18T13:52:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T14:15:46.000Z", "max_issues_repo_path": "Quantities/SIDerivedUnits.idr", "max_issues_repo_name": "timjb/quantities", "max_issues_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2015-11-04T08:51:41.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-17T09:52:29.000Z", "max_forks_repo_path": "Quantities/SIDerivedUnits.idr", "max_forks_repo_name": "timjb/quantities", "max_forks_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-04-28T23:49:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-01T17:28:34.000Z", "avg_line_length": 18.3949579832, "max_line_length": 56, "alphanum_fraction": 0.7295568753, "num_tokens": 696, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.5294650758959096}} {"text": "import Data.Vect\n\n-- using implicit arguments in pattern matching\nlength : Vect n elem -> Nat\nlength {n} xs = n\n\n-- give explicit values for implicit arguments by\n-- using the notation {n = value}\ncreate_empties : Vect n (Vect 0 a)\ncreate_empties {n = Z} = []\ncreate_empties {n = (S k)} = [] :: create_empties\n", "meta": {"hexsha": "7c8a141f9470a3b7c14fb709ce19c3ea171fe8bb", "size": 310, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "starting/3_4_3.idr", "max_stars_repo_name": "prt2121/tdd-playground", "max_stars_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "starting/3_4_3.idr", "max_issues_repo_name": "prt2121/tdd-playground", "max_issues_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "starting/3_4_3.idr", "max_forks_repo_name": "prt2121/tdd-playground", "max_forks_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8333333333, "max_line_length": 49, "alphanum_fraction": 0.6935483871, "num_tokens": 90, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581097540519, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5294393126622041}} {"text": "module Verified.Functor.Maybe\n\nimport Verified.Functor\n\ninstance VerifiedFunctor Maybe where\n functorIdentity Nothing = Refl\n functorIdentity (Just x) = Refl\n functorComposition Nothing g1 g2 = Refl\n functorComposition (Just x) g1 g2 = Refl\n", "meta": {"hexsha": "cbb661be848af065de582d3720310217a8d28033", "size": 245, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Verified/Functor/Maybe.idr", "max_stars_repo_name": "yurrriq/idris-verified", "max_stars_repo_head_hexsha": "10dd99e43824421be94138b5547fed5a294c9cd1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Verified/Functor/Maybe.idr", "max_issues_repo_name": "yurrriq/idris-verified", "max_issues_repo_head_hexsha": "10dd99e43824421be94138b5547fed5a294c9cd1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Verified/Functor/Maybe.idr", "max_forks_repo_name": "yurrriq/idris-verified", "max_forks_repo_head_hexsha": "10dd99e43824421be94138b5547fed5a294c9cd1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.5, "max_line_length": 42, "alphanum_fraction": 0.7918367347, "num_tokens": 66, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.5294392997653523}} {"text": "data Fin : Nat -> Type where\n FZ : Fin (S k)\n FS : Fin k -> Fin (S k)\n\ninterface Finite t where\n card : Nat\n to : t -> Fin card\n from : Fin card -> t\n toFrom : (k : Fin card) -> to (from k) = k\n fromTo : (x : t) -> from (to x) = x\n\n-- Checking dependent methods work, and that having names from the\n-- methods shadowed in the interface head doesn't cause any issues\n\nimplementation Finite (Fin k) where\n card = ?ncard\n to = ?lala\n from = ?lula\n toFrom = ?foo\n fromTo = ?bar\n\nimplementation Finite (Fin n) where\n card = ?ncard1\n to = ?lala1\n from = ?lula1\n toFrom = ?foo1\n fromTo = ?bar1\n\nimplementation Finite (Fin t) where\n card = ?ncard2\n to = ?lala2\n from = ?lula2\n toFrom = ?foo2\n fromTo = ?bar2\n", "meta": {"hexsha": "4ed81f509844eb4f71181aba40313c0b26c907f2", "size": 760, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/interface005/Deps.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/interface005/Deps.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/interface005/Deps.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 21.7142857143, "max_line_length": 66, "alphanum_fraction": 0.5934210526, "num_tokens": 269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711604559846, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.5290724800782964}} {"text": "||| An embedding of `Dec` instances into `Either` to gain access to Do notation.\n|||\n||| Thanks Matus for figuring it out.\n|||\n||| So let's have this:\n|||\n||| ```\n||| exampleDo : DecEq a => DecEq b => (ps, rs : Pair a b) -> Dec (ps = rs)\n||| exampleDo (x, y) (a,b)\n||| = decDo $ do Refl <- decEq x a `otherwise` (\\Refl => Refl)\n||| Refl <- decEq y b `otherwise` (\\Refl => Refl)\n||| Right Refl\n||| ```\n|||\n||| Rather than:\n|||\n||| ```\n||| example : DecEq a => DecEq b => (ps, rs : Pair a b) -> Dec (ps = rs)\n||| example (x, y) (a, b) with (decEq x a)\n||| example (x, y) (x, b) | (Yes Refl) with (decEq y b)\n||| example (x, y) (x, y) | (Yes Refl) | (Yes Refl) = Yes Refl\n||| example (x, y) (x, b) | (Yes Refl) | (No contra) = No (\\Refl => contra Refl)\n||| example (x, y) (a, b) | (No contra) = No (\\Refl => contra Refl)\n||| ```\n|||\nmodule Toolkit.Decidable.Do\n\nimport Decidable.Equality\n\nimport Toolkit.Decidable.Informative\n\n%default total\n\nexport\notherwise : Dec b -> (a -> b) -> Either (Not a) b\notherwise (Yes pfB) f = Right pfB\notherwise (No notB) f = Left (notB . f)\n\nexport\ndecDo : Either (Not a) a -> Dec a\ndecDo (Left notA) = No notA\ndecDo (Right pfA) = Yes pfA\n\n\n-- [ EOF ]\n", "meta": {"hexsha": "665bcc78ad64e7a0fc75ea5ac20b5e6c8ec2255c", "size": 1228, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Decidable/Do.idr", "max_stars_repo_name": "gallais/linear-circuits", "max_stars_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2020-11-03T11:33:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T17:11:38.000Z", "max_issues_repo_path": "src/Toolkit/Decidable/Do.idr", "max_issues_repo_name": "gallais/linear-circuits", "max_issues_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Toolkit/Decidable/Do.idr", "max_forks_repo_name": "gallais/linear-circuits", "max_forks_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-09T19:49:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T19:49:11.000Z", "avg_line_length": 26.6956521739, "max_line_length": 84, "alphanum_fraction": 0.5447882736, "num_tokens": 447, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5290268271096156}} {"text": "> module Discussion\n\n> import Fix\n\n# Data Types a la Carte in Idris\n\nA brief discussion on design choices implementing DTalC.\n\n## Syntax\n\nOne of the problems with the [original Data Types a la Carte implementation](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf),\nwas that the coproduct, `(:+:)`, allowed arbitrary grouping of signatures,\ne.g. `(f :+: g) :+: g`. However, injection only performed a linear search from\nleft to right, and so the subtyping relation could not be satisfied in cases\nwhich were not right-associative, such as `f :≺: (f :+: g) :+: h`.\n\nTo remedy this, a [list of signatures can be used instead](https://reasonablypolymorphic.com/blog/better-data-types-a-la-carte/).\nFor example, `f :+: g` would be written as `Sig [f, g]`, using `Sig` below.\nHere, `fs` is a list of the different signatures that make up the composite\nsignature `Sig`. The `a` is the type given to each `f` in `fs`.\n\n(Side note: An alternative method to solve injection into non-right-associative\nsignatures involves using a [backtracking search](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.643.3533&rep=rep1&type=pdf),\nbut using a list provides a simpler solution)\n\n> data Sig : (fs : List (Type -> Type)) -> (a : Type) -> Type where\n> Here : f a -> Sig (f :: fs) a\n> There : Sig fs a -> Sig (f :: fs) a\n\nInstead of `InL` and `InR` constructors for the coproduct, `Sig` uses `Here`\nand `There` to describe how to construct a value of a signature. For example,\nthe DSL from Data Types a la Carte paper can be described as:\n\n> data Val k = V Int\n> data Add k = A k k\n\nUsing the standard definition of Fix, and the `Here` and `There` constructors,\nDSLs containing both values and addition can be created. Below represents the\nexpression `1 + 2`:\n\n> ex1 : Fix (Sig [Val, Add])\n> ex1 = In (There (Here (A x y))) where\n> x = In (Here (V 1))\n> y = In (Here (V 2))\n\nClearly, this is very cumbersome to write, and so, like in the original paper,\nit would be better to automate injection into some super-type. This will involve\nfinding the correct combination of `There` and `Here`.\n\nAttempting to use interface instances, like in the original paper, such as\nthose below to perform this linear-search requires overlapping instances, which\nIdris [does not allow](http://docs.idris-lang.org/en/v0.9.18/tutorial/classes.html).\n\nTherefore, another solution to this search is required. Fortunately, this has\nalready been solved in the standard library (see `Elem` in [Data.List](https://github.com/idris-lang/Idris-dev/blob/master/libs/base/Data/List.idr)),\nwith a structure similar to `Elem` below.\n\nThe constructor `H` is a proof the signature `f` is at the front of the list\nof signatures to be composed together, `fs`. The constructor `T` is a proof the\nsignature is after the front of the list.\n\n> data Elem : (f : Type -> Type) -> (fs : List (Type -> Type)) -> Type where\n> H : Elem f (f :: fs)\n> T : Elem f ys -> Elem f (y :: ys)\n\nUsing this, an `inj` function can be created to construct a sequence of `Here`\nand `There`:\n\n> inj' : Elem f fs -> f a -> Sig fs a\n> inj' H x = Here x\n> inj' (T t) x = There (inj' t x)\n\nHowever, this does not currently provide any advantage over manually using\n`Here` and `There`, since `inj'` requires manually specifying `H` and `T`.\nHowever, Idris' automatic proof search can be leveraged to have it automatically\nfind the correct combination of `H` and `T`:\n\n> inj : {auto prf : Elem f fs} -> f a -> Sig fs a\n> inj {prf=H} x = Here x\n> inj {prf=T t} x = There (inj {prf=t} x)\n\nFor convenience, `inj` can be adapted to work with `Fix`:\n\n> inject : {auto prf : Elem f fs} -> f (Fix (Sig fs)) -> Fix (Sig fs)\n> inject = In . inj\n\nPutting this together, smart constructors can be created for the example DSL.\nInstead of a type constraint, `Val :<: f`, such as in the original paper,\n`Elem Val fs` is used to prove that `Val` exists in `fs`:\n\n> val : {auto prf : Elem Val fs} -> Int -> Fix (Sig fs)\n> val x = inject (V x)\n\n> add : {auto prf : Elem Add fs} -> Fix (Sig fs) -> Fix (Sig fs) -> Fix (Sig fs)\n> add x y = inject (A x y)\n\nPutting this all together, DSLs containing values and addition can be succinctly\nrepresented:\n\n> ex2 : Fix (Sig [Val, Add])\n> ex2 = add (val 1) (add (val 2) (val 3))\n\n## Semantics\n\nIn the original paper, typeclasses provide a method to specify the semantics\nof different pieces of syntax separately, by providing an algebra `f a -> a`\nto fold over a fix tree `Fix f`.\n\nIn order to fold over a `Fix` tree using `cata`, a `f` needs to be a functor:\n\n```idris\ncata : Functor f => (f a -> a) -> Fix f -> a\ncata alg = alg . map (cata alg) . inop\n```\n\nIn this implementation `f` is `Sig fs`, therefore, `Sig fs` needs to be a\nfunctor. This *could* be done by modifying the definition of `Here` to be\n`Here : Functor f => f a -> Sig (f :: fs) a`. However, in the implementation\nso-far no functions have required `f` to be a functor and so this solution feels\nsub-optimal.\n\nInstead, the functor instance for `Sig fs` will be defined inductively such that\n`Sig fs` will be a functor when each `f` in `fs` has its own definition of functor.\n\nFirstly, where there are no signatures it is not possible to map over anything:\n\n> Functor (Sig []) where\n> map _ (Here _) impossible\n> map _ (There _) impossible\n\nFor the base case, `Here`, `map func x` calls `map : (a -> b) -> f a -> f b`.\nWhereas, in the recursive case, `There`, `map func t` calls\n`map : (a -> b) -> Sig fs a -> Sig fs b`.\n\n> (Functor f, Functor (Sig fs)) => Functor (Sig (f :: fs)) where\n> map func (Here x) = Here (map func x)\n> map func (There t) = There (map func t)\n\nContinuing the example, by defining functor instances for both values and\naddition, `Sig [Val, Add]` is also a functor.\n\n> Functor Val where\n> map f (V x) = V x\n\n> Functor Add where\n> map f (A x y) = A (f x) (f y)\n\nIn order to define the algebra `f a -> a` for a signature `f`, an interface is\nused to allow the algebra for different pieces of syntax to be defined separately.\n\n> interface Alg (f : Type -> Type) (a : Type) where\n> alg : f a -> a\n\nUsing the same technique used to define the `Functor` instance for `Sig`, the\n`Alg` instance will be defined for `Sig fs`, provided each `f` in `fs` has its\nown `Alg` instance. Again, when there is no syntax it is not possible to\nuse the algebras of any signatures:\n\n> Alg (Sig []) a where\n> alg (Here _) impossible\n> alg (There _) impossible\n\nIn the base case, `alg x` uses `alg : f a -> a`. The recursive case uses\n`alg : Sig fs -> a`.\n\n> (Alg f a, Alg (Sig fs) a) => Alg (Sig (f :: fs)) a where\n> alg (Here x) = alg x\n> alg (There x) = alg x\n\nTo continue the expression example, `Alg` instances can be created that\ntranslate into a result integer:\n\n> Alg Val Int where\n> alg (V x) = x\n\n> Alg Add Int where\n> alg (A x y) = x + y\n\nGiven signatures which have an algebra to which converts their syntax to\nintegers, a `calc` function can be created which calculates the value of an\nexpression:\n\n> calc : (Functor (Sig fs), Alg (Sig fs) Int) => Fix (Sig fs) -> Int\n> calc = cata alg\n\n## Summary\n\nThis demonstrates how Data Types a la Carte can be implemented in such as\nway as to solve one of the original problems. This shows how the inability to\ncreate overlapping instances is solved by using the `Elem` type, and how\nautomatic proof search can be used to automatically inject into a type.\n\n## Related Work: Effect Handlers\n\nA problem inherent with Data Types a la Carte is it inability to allow\ndifferent semantic domains to be easily composed. To extend the DSL presented\nwith exceptions, for example, would require reimplementing the interface\ninstances `Alg Val Int` and `Alg Add Int` to be `Alg Val (Either Err Int)` and\n`Alg Add (Either Err Int)`. One solution to this is [Effect Handlers](http://okmij.org/ftp/Haskell/extensible/extensible-a-la-carte.html)\nwhich handle only specific parts of the syntax composed, instead of *all* the\nsyntax at once. Fortunately, this has [already been implemented in Idris](http://docs.idris-lang.org/en/latest/effects/introduction.html).\n", "meta": {"hexsha": "4e36e47d867df1630c7ff3133c26d3d897eaf3a2", "size": 8120, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/Discussion.lidr", "max_stars_repo_name": "BakerSmithA/alacarte-idris", "max_stars_repo_head_hexsha": "885a1a9ca3bdc1ff3ef64339cbbd740fdcec15ca", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Discussion.lidr", "max_issues_repo_name": "BakerSmithA/alacarte-idris", "max_issues_repo_head_hexsha": "885a1a9ca3bdc1ff3ef64339cbbd740fdcec15ca", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Discussion.lidr", "max_forks_repo_name": "BakerSmithA/alacarte-idris", "max_forks_repo_head_hexsha": "885a1a9ca3bdc1ff3ef64339cbbd740fdcec15ca", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 40.198019802, "max_line_length": 149, "alphanum_fraction": 0.6931034483, "num_tokens": 2276, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624840223699, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5288956063586547}} {"text": "module Algebra.ZeroOneOmega\n\nimport Algebra.Semiring\nimport Algebra.Preorder\n\n%default total\n\nexport\ndata ZeroOneOmega = Rig0 | Rig1 | RigW\n\nexport\nPreorder ZeroOneOmega where\n Rig0 <= _ = True\n Rig1 <= Rig1 = True\n _ <= RigW = True\n _ <= _ = False\n preorderRefl {x = Rig0} = Refl\n preorderRefl {x = Rig1} = Refl\n preorderRefl {x = RigW} = Refl\n preorderTrans {x = Rig0} _ _ = Refl\n preorderTrans {x = Rig1} {y = Rig0} _ _ impossible\n preorderTrans {x = Rig1} {y = Rig1} _ yz = yz\n preorderTrans {x = Rig1} {y = RigW} {z = Rig0} _ _ impossible\n preorderTrans {x = Rig1} {y = RigW} {z = Rig1} _ _ = Refl\n preorderTrans {x = Rig1} {y = RigW} {z = RigW} _ _ = Refl\n preorderTrans {x = RigW} {y = Rig0} _ _ impossible\n preorderTrans {x = RigW} {y = Rig1} _ _ impossible\n preorderTrans {x = RigW} {y = RigW} _ yz = yz\n\npublic export\nEq ZeroOneOmega where\n (==) Rig0 Rig0 = True\n (==) Rig1 Rig1 = True\n (==) RigW RigW = True\n (==) _ _ = False\n\nexport\nShow ZeroOneOmega where\n show Rig0 = \"Rig0\"\n show Rig1 = \"Rig1\"\n show RigW = \"RigW\"\n\nexport\nrigPlus : ZeroOneOmega -> ZeroOneOmega -> ZeroOneOmega\nrigPlus Rig0 a = a\nrigPlus a Rig0 = a\nrigPlus _ _ = RigW\n\nexport\nrigMult : ZeroOneOmega -> ZeroOneOmega -> ZeroOneOmega\nrigMult Rig0 _ = Rig0\nrigMult _ Rig0 = Rig0\nrigMult Rig1 a = a\nrigMult a Rig1 = a\nrigMult _ _ = RigW\n\n\npublic export\nSemiring ZeroOneOmega where\n (|+|) = rigPlus\n (|*|) = rigMult\n plusNeutral = Rig0\n timesNeutral = Rig1\n\n||| The top value of a lattice\nexport\nTop ZeroOneOmega where\n top = RigW\n topAbs {x = Rig0} = Refl\n topAbs {x = Rig1} = Refl\n topAbs {x = RigW} = Refl\n\n----------------------------------------\n\nrigPlusAssociative : (x, y, z : ZeroOneOmega) ->\n rigPlus x (rigPlus y z) = rigPlus (rigPlus x y) z\nrigPlusAssociative Rig0 _ _ = Refl\nrigPlusAssociative Rig1 Rig0 _ = Refl\nrigPlusAssociative Rig1 Rig1 Rig0 = Refl\nrigPlusAssociative Rig1 Rig1 Rig1 = Refl\nrigPlusAssociative Rig1 Rig1 RigW = Refl\nrigPlusAssociative Rig1 RigW Rig0 = Refl\nrigPlusAssociative Rig1 RigW Rig1 = Refl\nrigPlusAssociative Rig1 RigW RigW = Refl\nrigPlusAssociative RigW Rig0 _ = Refl\nrigPlusAssociative RigW Rig1 Rig0 = Refl\nrigPlusAssociative RigW Rig1 Rig1 = Refl\nrigPlusAssociative RigW Rig1 RigW = Refl\nrigPlusAssociative RigW RigW Rig0 = Refl\nrigPlusAssociative RigW RigW Rig1 = Refl\nrigPlusAssociative RigW RigW RigW = Refl\n\nrigPlusCommutative : (x, y : ZeroOneOmega) ->\n rigPlus x y = rigPlus y x\nrigPlusCommutative Rig0 Rig0 = Refl\nrigPlusCommutative Rig0 Rig1 = Refl\nrigPlusCommutative Rig0 RigW = Refl\nrigPlusCommutative Rig1 Rig0 = Refl\nrigPlusCommutative Rig1 Rig1 = Refl\nrigPlusCommutative Rig1 RigW = Refl\nrigPlusCommutative RigW Rig0 = Refl\nrigPlusCommutative RigW Rig1 = Refl\nrigPlusCommutative RigW RigW = Refl\n\nrigMultAssociative : (x, y, z : ZeroOneOmega) ->\n rigMult x (rigMult y z) = rigMult (rigMult x y) z\nrigMultAssociative Rig0 _ _ = Refl\nrigMultAssociative Rig1 Rig0 _ = Refl\nrigMultAssociative Rig1 Rig1 Rig0 = Refl\nrigMultAssociative Rig1 Rig1 Rig1 = Refl\nrigMultAssociative Rig1 Rig1 RigW = Refl\nrigMultAssociative Rig1 RigW Rig0 = Refl\nrigMultAssociative Rig1 RigW Rig1 = Refl\nrigMultAssociative Rig1 RigW RigW = Refl\nrigMultAssociative RigW Rig0 _ = Refl\nrigMultAssociative RigW Rig1 Rig0 = Refl\nrigMultAssociative RigW Rig1 Rig1 = Refl\nrigMultAssociative RigW Rig1 RigW = Refl\nrigMultAssociative RigW RigW Rig0 = Refl\nrigMultAssociative RigW RigW Rig1 = Refl\nrigMultAssociative RigW RigW RigW = Refl\n\nrigMultCommutative : (x, y : ZeroOneOmega) ->\n rigMult x y = rigMult y x\nrigMultCommutative Rig0 Rig0 = Refl\nrigMultCommutative Rig0 Rig1 = Refl\nrigMultCommutative Rig0 RigW = Refl\nrigMultCommutative Rig1 Rig0 = Refl\nrigMultCommutative Rig1 Rig1 = Refl\nrigMultCommutative Rig1 RigW = Refl\nrigMultCommutative RigW Rig0 = Refl\nrigMultCommutative RigW Rig1 = Refl\nrigMultCommutative RigW RigW = Refl\n", "meta": {"hexsha": "da0f1c6478c08a08bc0293dc7f5fb465ac5fd066", "size": 3877, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Algebra/ZeroOneOmega.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "src/Algebra/ZeroOneOmega.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "src/Algebra/ZeroOneOmega.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 28.9328358209, "max_line_length": 63, "alphanum_fraction": 0.7307196286, "num_tokens": 1392, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127380808499, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.5283845004521638}} {"text": "{- Ctrl-Alt-A: Add definition\n Ctrl-Alt-C: Case split\n Ctrl-Alt-D: Documentation\n Ctrl-Alt-L: Lift hole: Lifts a hole to the top level as a new function definition\n Ctrl-Alt-M: Match: Replaces a hole with a case expression that matches on an intermediate result\n Ctrl-Alt-R: Reloads and typechecks the current buffer\n Ctrl-Alt-S: Search\n Ctrl-Alt-T: Type-check: Displays the type under cursor -}\nmodule Main\n\nimport Data.Vect\n\ndata DataStore : Type where\n MkData : (size : Nat) -> (items : Vect size String) -> DataStore\n\nsize : DataStore -> Nat\nsize (MkData s i) = s\n\nitems : (store : DataStore) -> Vect (size store) String\nitems (MkData s i) = i\n\naddToStore : DataStore -> String -> DataStore\naddToStore (MkData s i) n = MkData _ (addToData i)\n where\n addToData : Vect old String -> Vect (S old) String\n addToData [] = [n]\n addToData (i :: is) = i :: addToData is\n\ndata Command = Add String\n | Get Integer\n | Size\n | Search String\n | Quit\n\nparseCommand : (cmd : String) -> (args : String) -> Maybe Command\nparseCommand \"add\" str = Just (Add str)\nparseCommand \"get\" val = case all isDigit (unpack val) of\n False => Nothing\n True => Just (Get (cast val))\nparseCommand \"quit\" \"\" = Just Quit\nparseCommand \"size\" \"\" = Just Size\nparseCommand \"search\" str = Just $ Search str\nparseCommand _ _ = Nothing\n\nparse : (input : String) -> Maybe Command\nparse input = case span (/= ' ') input of\n (cmd, args) => parseCommand cmd args\n\ngetEntry : (pos : Integer) -> (store : DataStore) -> Maybe (String, DataStore)\ngetEntry pos store =\n let store_items = items store\n in case integerToFin pos (size store) of\n Nothing => Just (\"Out of range\\n\", store)\n Just ix => Just (index ix store_items ++ \"\\n\", store)\n\ngetSize : (store : DataStore) -> Maybe (String, DataStore)\ngetSize store = Just (\"Size of store: \" ++ cast (size store), store)\n\nsearch : (store : DataStore) -> (str : String) -> Maybe (String, DataStore)\nsearch store str =\n let store_items = items store in\n let found = foldrImpl\n (\\(ix, msg), acc => if (str `isInfixOf` msg)\n then (cast $ finToInteger ix) ++ \": \" ++ msg ++ \"\\n\" ++ acc\n else acc)\n \"\"\n (\\acc => acc)\n (zip range store_items)\n in Just (found, store)\n\nprocessInput : DataStore -> String -> Maybe (String, DataStore)\nprocessInput store inp = case parse inp of\n Nothing => Just (\"Invalid command\\n\", store)\n Just (Add item) => Just (\"ID \" ++ show (size store) ++ \"\\n\", addToStore store item)\n Just (Get pos) => getEntry pos store\n Just Size => getSize store\n Just (Search str) => search store str\n Just Quit => Nothing\n\nmain : IO ()\nmain = replWith (MkData _ []) \"Command: \" processInput\n", "meta": {"hexsha": "9127c918f6bcbf8adf58861af74efe30e77c16f8", "size": 2893, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/tdd/chapter04/02_DataStore.idr", "max_stars_repo_name": "pdani/idris-grin", "max_stars_repo_head_hexsha": "c224b65551b2b2b91f564f858ba08df1d6af00b3", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/tdd/chapter04/02_DataStore.idr", "max_issues_repo_name": "pdani/idris-grin", "max_issues_repo_head_hexsha": "c224b65551b2b2b91f564f858ba08df1d6af00b3", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/tdd/chapter04/02_DataStore.idr", "max_forks_repo_name": "pdani/idris-grin", "max_forks_repo_head_hexsha": "c224b65551b2b2b91f564f858ba08df1d6af00b3", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 35.2804878049, "max_line_length": 99, "alphanum_fraction": 0.6094020048, "num_tokens": 778, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5282105122861339}} {"text": "module Data.List\n\nimport Data.Nat\nimport Data.List1\nimport Data.Fin\nimport public Data.Zippable\n\n%default total\n\npublic export\nisNil : List a -> Bool\nisNil [] = True\nisNil _ = False\n\npublic export\nisCons : List a -> Bool\nisCons [] = False\nisCons _ = True\n\npublic export\nsnoc : List a -> a -> List a\nsnoc xs x = xs ++ [x]\n\npublic export\ntake : Nat -> List a -> List a\ntake (S k) (x :: xs) = x :: take k xs\ntake _ _ = []\n\npublic export\ndrop : (n : Nat) -> (xs : List a) -> List a\ndrop Z xs = xs\ndrop (S n) [] = []\ndrop (S n) (_::xs) = drop n xs\n\n||| Satisfiable if `k` is a valid index into `xs`.\n|||\n||| @ k the potential index\n||| @ xs the list into which k may be an index\npublic export\ndata InBounds : (k : Nat) -> (xs : List a) -> Type where\n ||| Z is a valid index into any cons cell\n InFirst : InBounds Z (x :: xs)\n ||| Valid indices can be extended\n InLater : InBounds k xs -> InBounds (S k) (x :: xs)\n\npublic export\nUninhabited (InBounds k []) where\n uninhabited InFirst impossible\n uninhabited (InLater _) impossible\n\nexport\nUninhabited (InBounds k xs) => Uninhabited (InBounds (S k) (x::xs)) where\n uninhabited (InLater y) = uninhabited y\n\n||| Decide whether `k` is a valid index into `xs`.\npublic export\ninBounds : (k : Nat) -> (xs : List a) -> Dec (InBounds k xs)\ninBounds _ [] = No uninhabited\ninBounds Z (_ :: _) = Yes InFirst\ninBounds (S k) (x :: xs) with (inBounds k xs)\n inBounds (S k) (x :: xs) | (Yes prf) = Yes (InLater prf)\n inBounds (S k) (x :: xs) | (No contra)\n = No $ \\(InLater y) => contra y\n\n||| Find a particular element of a list.\n|||\n||| @ ok a proof that the index is within bounds\npublic export\nindex : (n : Nat) -> (xs : List a) -> {auto 0 ok : InBounds n xs} -> a\nindex Z (x :: xs) {ok = InFirst} = x\nindex (S k) (_ :: xs) {ok = InLater _} = index k xs\n\npublic export\nindex' : (xs : List a) -> Fin (length xs) -> a\nindex' (x::_) FZ = x\nindex' (_::xs) (FS i) = index' xs i\n\n||| Generate a list by repeatedly applying a partial function until exhausted.\n||| @ f the function to iterate\n||| @ x the initial value that will be the head of the list\ncovering\npublic export\niterate : (f : a -> Maybe a) -> (x : a) -> List a\niterate f x = x :: case f x of\n Nothing => []\n Just y => iterate f y\n\ncovering\npublic export\nunfoldr : (b -> Maybe (a, b)) -> b -> List a\nunfoldr f c = case f c of\n Nothing => []\n Just (a, n) => a :: unfoldr f n\n\npublic export\niterateN : Nat -> (a -> a) -> a -> List a\niterateN Z _ _ = []\niterateN (S n) f x = x :: iterateN n f (f x)\n\npublic export\ntakeWhile : (p : a -> Bool) -> List a -> List a\ntakeWhile p [] = []\ntakeWhile p (x::xs) = if p x then x :: takeWhile p xs else []\n\npublic export\ndropWhile : (p : a -> Bool) -> List a -> List a\ndropWhile p [] = []\ndropWhile p (x::xs) = if p x then dropWhile p xs else x::xs\n\n||| Applied to a predicate and a list, returns the list of those elements that\n||| satisfy the predicate.\npublic export\nfilter : (p : a -> Bool) -> List a -> List a\nfilter p [] = []\nfilter p (x :: xs)\n = if p x\n then x :: filter p xs\n else filter p xs\n\n||| Find the first element of the list that satisfies the predicate.\npublic export\nfind : (p : a -> Bool) -> (xs : List a) -> Maybe a\nfind p [] = Nothing\nfind p (x::xs) = if p x then Just x else find p xs\n\n||| Find the index and proof of InBounds of the first element (if exists) of a\n||| list that satisfies the given test, else `Nothing`.\npublic export\nfindIndex : (a -> Bool) -> (xs : List a) -> Maybe $ Fin (length xs)\nfindIndex _ [] = Nothing\nfindIndex p (x :: xs) = if p x\n then Just FZ\n else FS <$> findIndex p xs\n\n||| Find indices of all elements that satisfy the given test.\npublic export\nfindIndices : (a -> Bool) -> List a -> List Nat\nfindIndices p = h 0 where\n h : Nat -> List a -> List Nat\n h _ [] = []\n h lvl (x :: xs) = if p x\n then lvl :: h (S lvl) xs\n else h (S lvl) xs\n\n||| Find associated information in a list using a custom comparison.\npublic export\nlookupBy : (a -> a -> Bool) -> a -> List (a, b) -> Maybe b\nlookupBy p e [] = Nothing\nlookupBy p e ((l, r) :: xs) =\n if p e l then\n Just r\n else\n lookupBy p e xs\n\n||| Find associated information in a list using Boolean equality.\npublic export\nlookup : Eq a => a -> List (a, b) -> Maybe b\nlookup = lookupBy (==)\n\n||| Check if something is a member of a list using a custom comparison.\npublic export\nelemBy : (a -> a -> Bool) -> a -> List a -> Bool\nelemBy p e [] = False\nelemBy p e (x::xs) = p e x || elemBy p e xs\n\npublic export\nnubBy : (a -> a -> Bool) -> List a -> List a\nnubBy = nubBy' []\n where\n nubBy' : List a -> (a -> a -> Bool) -> List a -> List a\n nubBy' acc p [] = []\n nubBy' acc p (x::xs) =\n if elemBy p x acc then\n nubBy' acc p xs\n else\n x :: nubBy' (x::acc) p xs\n\n||| O(n^2). The nub function removes duplicate elements from a list. In\n||| particular, it keeps only the first occurrence of each element. It is a\n||| special case of nubBy, which allows the programmer to supply their own\n||| equality test.\n|||\n||| ```idris example\n||| nub (the (List _) [1,2,1,3])\n||| ```\npublic export\nnub : Eq a => List a -> List a\nnub = nubBy (==)\n\n||| The deleteBy function behaves like delete, but takes a user-supplied equality predicate.\npublic export\ndeleteBy : (a -> a -> Bool) -> a -> List a -> List a\ndeleteBy _ _ [] = []\ndeleteBy eq x (y::ys) = if x `eq` y then ys else y :: deleteBy eq x ys\n\n||| `delete x` removes the first occurrence of `x` from its list argument. For\n||| example,\n|||\n|||````idris example\n|||delete 'a' ['b', 'a', 'n', 'a', 'n', 'a']\n|||````\n|||\n||| It is a special case of deleteBy, which allows the programmer to supply\n||| their own equality test.\npublic export\ndelete : Eq a => a -> List a -> List a\ndelete = deleteBy (==)\n\n||| Delete the first occurrence of each element from the second list in the first\n||| list where equality is determined by the predicate passed as the first argument.\n||| @ p A function that returns true when its two arguments should be considered equal.\n||| @ source The list to delete elements from.\n||| @ undesirables The list of elements to delete.\npublic export\ndeleteFirstsBy : (p : a -> a -> Bool) -> (source : List a) -> (undesirables : List a) -> List a\ndeleteFirstsBy p = foldl (flip (deleteBy p))\n\ninfix 7 \\\\\n\n||| The non-associative list-difference.\n||| A specialized form of @deleteFirstsBy@ where the predicate is equality under the @Eq@\n||| interface.\n||| Deletes the first occurrence of each element of the second list from the first list.\n|||\n||| In the following example, the result is `[2, 4]`.\n||| ```idris example\n||| [1, 2, 3, 4] // [1, 3]\n||| ```\n|||\npublic export\n(\\\\) : (Eq a) => List a -> List a -> List a\n(\\\\) = foldl (flip delete)\n\n||| The unionBy function returns the union of two lists by user-supplied equality predicate.\npublic export\nunionBy : (a -> a -> Bool) -> List a -> List a -> List a\nunionBy eq xs ys = xs ++ foldl (flip (deleteBy eq)) (nubBy eq ys) xs\n\n||| Compute the union of two lists according to their `Eq` implementation.\n|||\n||| ```idris example\n||| union ['d', 'o', 'g'] ['c', 'o', 'w']\n||| ```\n|||\npublic export\nunion : Eq a => List a -> List a -> List a\nunion = unionBy (==)\n\n||| Like @span@ but using a predicate that might convert a to b, i.e. given a\n||| predicate from a to Maybe b and a list of as, returns a tuple consisting of\n||| the longest prefix of the list where a -> Just b, and the rest of the list.\npublic export\nspanBy : (a -> Maybe b) -> List a -> (List b, List a)\nspanBy p [] = ([], [])\nspanBy p (x :: xs) = case p x of\n Nothing => ([], x :: xs)\n Just y => let (ys, zs) = spanBy p xs in (y :: ys, zs)\n\n||| Given a predicate and a list, returns a tuple consisting of the longest\n||| prefix of the list whose elements satisfy the predicate, and the rest of the\n||| list.\npublic export\nspan : (a -> Bool) -> List a -> (List a, List a)\nspan p [] = ([], [])\nspan p (x::xs) =\n if p x then\n let (ys, zs) = span p xs in\n (x::ys, zs)\n else\n ([], x::xs)\n\npublic export\nbreak : (a -> Bool) -> List a -> (List a, List a)\nbreak p xs = span (not . p) xs\n\npublic export\nsplit : (a -> Bool) -> List a -> List1 (List a)\nsplit p xs =\n case break p xs of\n (chunk, []) => singleton chunk\n (chunk, (c :: rest)) => chunk ::: forget (split p (assert_smaller xs rest))\n\npublic export\nsplitAt : (n : Nat) -> (xs : List a) -> (List a, List a)\nsplitAt Z xs = ([], xs)\nsplitAt (S k) [] = ([], [])\nsplitAt (S k) (x :: xs)\n = let (tk, dr) = splitAt k xs in\n (x :: tk, dr)\n\npublic export\npartition : (a -> Bool) -> List a -> (List a, List a)\npartition p [] = ([], [])\npartition p (x::xs) =\n let (lefts, rights) = partition p xs in\n if p x then\n (x::lefts, rights)\n else\n (lefts, x::rights)\n\n||| The inits function returns all initial segments of the argument, shortest\n||| first. For example,\n|||\n||| ```idris example\n||| inits [1,2,3]\n||| ```\npublic export\ninits : List a -> List (List a)\ninits xs = [] :: case xs of\n [] => []\n x :: xs' => map (x ::) (inits xs')\n\n||| The tails function returns all final segments of the argument, longest\n||| first. For example,\n|||\n||| ```idris example\n||| tails [1,2,3] == [[1,2,3], [2,3], [3], []]\n|||```\npublic export\ntails : List a -> List (List a)\ntails xs = xs :: case xs of\n [] => []\n _ :: xs' => tails xs'\n\n||| Split on the given element.\n|||\n||| ```idris example\n||| splitOn 0 [1,0,2,0,0,3]\n||| ```\n|||\npublic export\nsplitOn : Eq a => a -> List a -> List1 (List a)\nsplitOn a = split (== a)\n\npublic export\nreplaceWhen : (a -> Bool) -> a -> List a -> List a\nreplaceWhen p b l = map (\\c => if p c then b else c) l\n\n||| Replaces all occurences of the first argument with the second argument in a list.\n|||\n||| ```idris example\n||| replaceOn '-' ',' ['1', '-', '2', '-', '3']\n||| ```\n|||\npublic export\nreplaceOn : Eq a => a -> a -> List a -> List a\nreplaceOn a = replaceWhen (== a)\n\n||| Construct a list with `n` copies of `x`.\n||| @ n how many copies\n||| @ x the element to replicate\npublic export\nreplicate : (n : Nat) -> (x : a) -> List a\nreplicate Z _ = []\nreplicate (S n) x = x :: replicate n x\n\n||| Compute the intersect of two lists by user-supplied equality predicate.\nexport\nintersectBy : (a -> a -> Bool) -> List a -> List a -> List a\nintersectBy eq xs ys = [x | x <- xs, any (eq x) ys]\n\n||| Compute the intersect of two lists according to the `Eq` implementation for the elements.\nexport\nintersect : Eq a => List a -> List a -> List a\nintersect = intersectBy (==)\n\nexport\nintersectAllBy : (a -> a -> Bool) -> List (List a) -> List a\nintersectAllBy eq [] = []\nintersectAllBy eq (xs :: xss) = filter (\\x => all (elemBy eq x) xss) xs\n\nexport\nintersectAll : Eq a => List (List a) -> List a\nintersectAll = intersectAllBy (==)\n\n---------------------------\n-- Zippable --\n---------------------------\n\npublic export\nZippable List where\n zipWith _ [] _ = []\n zipWith _ _ [] = []\n zipWith f (x :: xs) (y :: ys) = f x y :: zipWith f xs ys\n\n zipWith3 _ [] _ _ = []\n zipWith3 _ _ [] _ = []\n zipWith3 _ _ _ [] = []\n zipWith3 f (x :: xs) (y :: ys) (z :: zs) = f x y z :: zipWith3 f xs ys zs\n\n unzipWith f [] = ([], [])\n unzipWith f (x :: xs) = let (b, c) = f x\n (bs, cs) = unzipWith f xs in\n (b :: bs, c :: cs)\n\n unzipWith3 f [] = ([], [], [])\n unzipWith3 f (x :: xs) = let (b, c, d) = f x\n (bs, cs, ds) = unzipWith3 f xs in\n (b :: bs, c :: cs, d :: ds)\n\n---------------------------\n-- Non-empty List\n---------------------------\n\npublic export\ndata NonEmpty : (xs : List a) -> Type where\n IsNonEmpty : NonEmpty (x :: xs)\n\nexport\nUninhabited (NonEmpty []) where\n uninhabited IsNonEmpty impossible\n\n||| Get the head of a non-empty list.\n||| @ ok proof the list is non-empty\npublic export\nhead : (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nhead [] impossible\nhead (x :: _) = x\n\n||| Get the tail of a non-empty list.\n||| @ ok proof the list is non-empty\npublic export\ntail : (l : List a) -> {auto 0 ok : NonEmpty l} -> List a\ntail [] impossible\ntail (_ :: xs) = xs\n\n||| Retrieve the last element of a non-empty list.\n||| @ ok proof that the list is non-empty\npublic export\nlast : (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nlast [] impossible\nlast [x] = x\nlast (x :: xs@(_::_)) = last xs\n\n||| Return all but the last element of a non-empty list.\n||| @ ok proof the list is non-empty\npublic export\ninit : (l : List a) -> {auto 0 ok : NonEmpty l} -> List a\ninit [] impossible\ninit [x] = []\ninit (x :: xs@(_::_)) = x :: init xs\n\n||| Attempt to get the head of a list. If the list is empty, return `Nothing`.\npublic export\nhead' : List a -> Maybe a\nhead' [] = Nothing\nhead' (x::_) = Just x\n\n||| Attempt to get the tail of a list. If the list is empty, return `Nothing`.\nexport\ntail' : List a -> Maybe (List a)\ntail' [] = Nothing\ntail' (_::xs) = Just xs\n\n||| Attempt to retrieve the last element of a non-empty list.\n|||\n||| If the list is empty, return `Nothing`.\nexport\nlast' : List a -> Maybe a\nlast' [] = Nothing\nlast' xs@(_::_) = Just (last xs)\n\n||| Attempt to return all but the last element of a non-empty list.\n|||\n||| If the list is empty, return `Nothing`.\nexport\ninit' : List a -> Maybe (List a)\ninit' [] = Nothing\ninit' xs@(_::_) = Just (init xs)\n\npublic export\nfoldr1By : (func : a -> b -> b) -> (map : a -> b) ->\n (l : List a) -> {auto 0 ok : NonEmpty l} -> b\nfoldr1By f map [] impossible\nfoldr1By f map [x] = map x\nfoldr1By f map (x :: xs@(_::_)) = f x (foldr1By f map xs)\n\npublic export\nfoldl1By : (func : b -> a -> b) -> (map : a -> b) ->\n (l : List a) -> {auto 0 ok : NonEmpty l} -> b\nfoldl1By f map [] impossible\nfoldl1By f map (x::xs) = foldl f (map x) xs\n\n||| Foldr a non-empty list without seeding the accumulator.\n||| @ ok proof that the list is non-empty\npublic export\nfoldr1 : (a -> a -> a) -> (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nfoldr1 f xs = foldr1By f id xs\n\n||| Foldl a non-empty list without seeding the accumulator.\n||| @ ok proof that the list is non-empty\npublic export\nfoldl1 : (a -> a -> a) -> (l : List a) -> {auto 0 ok : NonEmpty l} -> a\nfoldl1 f xs = foldl1By f id xs\n\n||| Convert to a non-empty list.\n||| @ ok proof the list is non-empty\nexport\ntoList1 : (l : List a) -> {auto 0 ok : NonEmpty l} -> List1 a\ntoList1 [] impossible\ntoList1 (x :: xs) = x ::: xs\n\n||| Convert to a non-empty list, returning Nothing if the list is empty.\nexport\ntoList1' : (l : List a) -> Maybe (List1 a)\ntoList1' [] = Nothing\ntoList1' (x :: xs) = Just (x ::: xs)\n\n||| Prefix every element in the list with the given element\n|||\n||| ```idris example\n||| with List (mergeReplicate '>' ['a', 'b', 'c', 'd', 'e'])\n||| ```\n|||\nexport\nmergeReplicate : a -> List a -> List a\nmergeReplicate sep [] = []\nmergeReplicate sep (y::ys) = sep :: y :: mergeReplicate sep ys\n\n||| Insert some separator between the elements of a list.\n|||\n||| ````idris example\n||| with List (intersperse ',' ['a', 'b', 'c', 'd', 'e'])\n||| ````\n|||\nexport\nintersperse : a -> List a -> List a\nintersperse sep [] = []\nintersperse sep (x::xs) = x :: mergeReplicate sep xs\n\n||| Given a separator list and some more lists, produce a new list by\n||| placing the separator between each of the lists.\n|||\n||| @ sep the separator\n||| @ xss the lists between which the separator will be placed\n|||\n||| ```idris example\n||| intercalate [0, 0, 0] [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]\n||| ```\nexport\nintercalate : (sep : List a) -> (xss : List (List a)) -> List a\nintercalate sep xss = concat $ intersperse sep xss\n\n||| Apply a partial function to the elements of a list, keeping the ones at which\n||| it is defined.\npublic export\nmapMaybe : (a -> Maybe b) -> List a -> List b\nmapMaybe f [] = []\nmapMaybe f (x::xs) =\n case f x of\n Nothing => mapMaybe f xs\n Just j => j :: mapMaybe f xs\n\n||| Extract all of the values contained in a List of Maybes\npublic export\ncatMaybes : List (Maybe a) -> List a\ncatMaybes = mapMaybe id\n\n--------------------------------------------------------------------------------\n-- Sorting\n--------------------------------------------------------------------------------\n\n||| Check whether a list is sorted with respect to the default ordering for the type of its elements.\nexport\nsorted : Ord a => List a -> Bool\nsorted (x :: xs @ (y :: _)) = x <= y && sorted xs\nsorted _ = True\n\n||| Merge two sorted lists using an arbitrary comparison\n||| predicate. Note that the lists must have been sorted using this\n||| predicate already.\nexport\nmergeBy : (a -> a -> Ordering) -> List a -> List a -> List a\nmergeBy order [] right = right\nmergeBy order left [] = left\nmergeBy order (x::xs) (y::ys) =\n -- The code below will emit `y` before `x` whenever `x == y`.\n -- If you change this, `sortBy` will stop being stable, unless you fix `sortBy`, too.\n case order x y of\n LT => x :: mergeBy order xs (y::ys)\n _ => y :: mergeBy order (x::xs) ys\n\n||| Merge two sorted lists using the default ordering for the type of their elements.\nexport\nmerge : Ord a => List a -> List a -> List a\nmerge left right = mergeBy compare left right\n\n||| Sort a list using some arbitrary comparison predicate.\n|||\n||| @ cmp how to compare elements\n||| @ xs the list to sort\nexport\nsortBy : (cmp : a -> a -> Ordering) -> (xs : List a) -> List a\nsortBy cmp [] = []\nsortBy cmp [x] = [x]\nsortBy cmp xs = let (x, y) = split xs in\n mergeBy cmp\n (sortBy cmp (assert_smaller xs x))\n (sortBy cmp (assert_smaller xs y)) -- not structurally smaller, hence assert\n where\n splitRec : List b -> List a -> (List a -> List a) -> (List a, List a)\n splitRec (_::_::xs) (y::ys) zs = splitRec xs ys (zs . ((::) y))\n splitRec _ ys zs = (ys, zs [])\n -- In the above base-case clause, we put `ys` on the LHS to get a stable sort.\n -- This is because `mergeBy` prefers taking elements from its RHS operand\n -- if both heads are equal, and all elements in `zs []` precede all elements of `ys`\n -- in the original list.\n\n split : List a -> (List a, List a)\n split xs = splitRec xs xs id\n\n||| Sort a list using the default ordering for the type of its elements.\nexport\nsort : Ord a => List a -> List a\nsort = sortBy compare\n\nexport\nisPrefixOfBy : (eq : a -> a -> Bool) -> (left, right : List a) -> Bool\nisPrefixOfBy p [] _ = True\nisPrefixOfBy p _ [] = False\nisPrefixOfBy p (x::xs) (y::ys) = p x y && isPrefixOfBy p xs ys\n\n||| The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.\nexport\nisPrefixOf : Eq a => List a -> List a -> Bool\nisPrefixOf = isPrefixOfBy (==)\n\nexport\nisSuffixOfBy : (a -> a -> Bool) -> List a -> List a -> Bool\nisSuffixOfBy p left right = isPrefixOfBy p (reverse left) (reverse right)\n\n||| The isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second.\nexport\nisSuffixOf : Eq a => List a -> List a -> Bool\nisSuffixOf = isSuffixOfBy (==)\n\n||| The isInfixOf function takes two lists and returns True iff the first list\n||| is contained, wholly and intact, anywhere within the second.\n|||\n||| ```idris example\n||| isInfixOf ['b','c'] ['a', 'b', 'c', 'd']\n||| ```\n||| ```idris example\n||| isInfixOf ['b','d'] ['a', 'b', 'c', 'd']\n||| ```\n|||\nexport\nisInfixOf : Eq a => List a -> List a -> Bool\nisInfixOf n h = any (isPrefixOf n) (tails h)\n\n||| Transposes rows and columns of a list of lists.\n|||\n||| ```idris example\n||| with List transpose [[1, 2], [3, 4]]\n||| ```\n|||\n||| This also works for non square scenarios, thus\n||| involution does not always hold:\n|||\n||| transpose [[], [1, 2]] = [[1], [2]]\n||| transpose (transpose [[], [1, 2]]) = [[1, 2]]\nexport\ntranspose : List (List a) -> List (List a)\ntranspose [] = []\ntranspose (heads :: tails) = spreadHeads heads (transpose tails) where\n spreadHeads : List a -> List (List a) -> List (List a)\n spreadHeads [] tails = tails\n spreadHeads (head :: heads) [] = [head] :: spreadHeads heads []\n spreadHeads (head :: heads) (tail :: tails) = (head :: tail) :: spreadHeads heads tails\n\n------------------------------------------------------------------------\n-- Grouping\n\n||| `groupBy` operates like `group`, but uses the provided equality\n||| predicate instead of `==`.\npublic export\ngroupBy : (a -> a -> Bool) -> List a -> List (List1 a)\ngroupBy _ [] = []\ngroupBy eq (h :: t) = let (ys,zs) = go h t\n in ys :: zs\n\n where go : a -> List a -> (List1 a, List (List1 a))\n go v [] = (singleton v,[])\n go v (x :: xs) = let (ys,zs) = go x xs\n in if eq v x\n then (cons v ys, zs)\n else (singleton v, ys :: zs)\n\n||| The `group` function takes a list of values and returns a list of\n||| lists such that flattening the resulting list is equal to the\n||| argument. Moreover, each list in the resulting list\n||| contains only equal elements.\npublic export\ngroup : Eq a => List a -> List (List1 a)\ngroup = groupBy (==)\n\n||| `groupWith` operates like `group`, but uses the provided projection when\n||| comparing for equality\npublic export\ngroupWith : Eq b => (a -> b) -> List a -> List (List1 a)\ngroupWith f = groupBy (\\x,y => f x == f y)\n\n||| `groupAllWith` operates like `groupWith`, but sorts the list\n||| first so that each equivalence class has, at most, one list in the\n||| output\npublic export\ngroupAllWith : Ord b => (a -> b) -> List a -> List (List1 a)\ngroupAllWith f = groupWith f . sortBy (comparing f)\n\n--------------------------------------------------------------------------------\n-- Properties\n--------------------------------------------------------------------------------\n\nexport\nUninhabited ([] = x :: xs) where\n uninhabited Refl impossible\n\nexport\nUninhabited (x :: xs = []) where\n uninhabited Refl impossible\n\nexport\n{0 xs : List a} -> Either (Uninhabited $ x === y) (Uninhabited $ xs === ys) => Uninhabited (x::xs = y::ys) where\n uninhabited @{Left z} Refl = uninhabited @{z} Refl\n uninhabited @{Right z} Refl = uninhabited @{z} Refl\n\n||| (::) is injective\nexport\nconsInjective : forall x, xs, y, ys .\n the (List a) (x :: xs) = the (List b) (y :: ys) -> (x = y, xs = ys)\nconsInjective Refl = (Refl, Refl)\n\nreverseReverseOnto : (l, r : List a) -> reverse (reverseOnto l r) = reverseOnto r l\nreverseReverseOnto _ [] = Refl\nreverseReverseOnto l (x :: xs) = reverseReverseOnto (x :: l) xs\n\n||| List reverse applied twice yields the identity function.\nexport\nreverseInvolutive : (xs : List a) -> reverse (reverse xs) = xs\nreverseInvolutive = reverseReverseOnto []\n\nconsReverse : (x : a) -> (l, r : List a) -> x :: reverseOnto r l = reverseOnto r (reverseOnto [x] (reverse l))\nconsReverse _ [] _ = Refl\nconsReverse x (y::ys) r\n = rewrite consReverse x ys (y :: r) in\n rewrite cong (reverseOnto r . reverse) $ consReverse x ys [y] in\n rewrite reverseInvolutive (y :: reverseOnto [x] (reverse ys)) in\n Refl\n\nconsTailRecAppend : (x : a) -> (l, r : List a) -> tailRecAppend (x :: l) r = x :: (tailRecAppend l r)\nconsTailRecAppend x l r\n = rewrite consReverse x (reverse l) r in\n rewrite reverseInvolutive l in\n Refl\n\n||| Proof that `(++)` and `tailRecAppend` do the same thing, so the %transform\n||| directive is safe.\ntailRecAppendIsAppend : (xs, ys : List a) -> tailRecAppend xs ys = xs ++ ys\ntailRecAppendIsAppend [] ys = Refl\ntailRecAppendIsAppend (x::xs) ys =\n trans (consTailRecAppend x xs ys) (cong (x ::) $ tailRecAppendIsAppend xs ys)\n\n||| The empty list is a right identity for append.\nexport\nappendNilRightNeutral : (l : List a) -> l ++ [] = l\nappendNilRightNeutral [] = Refl\nappendNilRightNeutral (_::xs) = rewrite appendNilRightNeutral xs in Refl\n\n||| Appending lists is associative.\nexport\nappendAssociative : (l, c, r : List a) -> l ++ (c ++ r) = (l ++ c) ++ r\nappendAssociative [] c r = Refl\nappendAssociative (_::xs) c r = rewrite appendAssociative xs c r in Refl\n\nrevOnto : (xs, vs : List a) -> reverseOnto xs vs = reverse vs ++ xs\nrevOnto _ [] = Refl\nrevOnto xs (v :: vs)\n = rewrite revOnto (v :: xs) vs in\n rewrite appendAssociative (reverse vs) [v] xs in\n rewrite revOnto [v] vs in Refl\n\nexport\nrevAppend : (vs, ns : List a) -> reverse ns ++ reverse vs = reverse (vs ++ ns)\nrevAppend [] ns = rewrite appendNilRightNeutral (reverse ns) in Refl\nrevAppend (v :: vs) ns\n = rewrite revOnto [v] vs in\n rewrite revOnto [v] (vs ++ ns) in\n rewrite sym (revAppend vs ns) in\n rewrite appendAssociative (reverse ns) (reverse vs) [v] in\n Refl\n\nexport\ndropFusion : (n, m : Nat) -> (l : List t) -> drop n (drop m l) = drop (n+m) l\ndropFusion Z m l = Refl\ndropFusion (S n) Z l = rewrite plusZeroRightNeutral n in Refl\ndropFusion (S n) (S m) [] = Refl\ndropFusion (S n) (S m) (x::l) = rewrite plusAssociative n 1 m in\n rewrite plusCommutative n 1 in\n dropFusion (S n) m l\n\nexport\nlengthMap : (xs : List a) -> length (map f xs) = length xs\nlengthMap [] = Refl\nlengthMap (x :: xs) = cong S (lengthMap xs)\n", "meta": {"hexsha": "2aab47410f116631929a6d559542692a93a6f89f", "size": 25325, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/base/Data/List.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "libs/base/Data/List.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/base/Data/List.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.4596273292, "max_line_length": 112, "alphanum_fraction": 0.5902862784, "num_tokens": 7808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.528210502504294}} {"text": "||| Projection based on Plain Merge.\n|||\n||| The POPL '08 Paper /Multi-Party Asynchronous Session Types/.\n||| When projecting a =Choice= in which the projected role is not involved,\n||| projection occurs when all choices are equal.\nmodule Sessions.Projection.Plain\n\nimport Decidable.Equality\nimport Data.List\nimport Data.List.Elem\n\nimport Data.List1\n\nimport Sessions.Meta\n\nimport Sessions.Global\nimport Sessions.Global.Involved\n\nimport Sessions.Local\nimport Sessions.Local.Same\nimport Sessions.Local.Same.All\n\nimport public Sessions.Projection.Error\nimport public Sessions.Projection\n\n%default total\n\npublic export\ndata Merge : (this : List1 (typeL, typeM, Local typeR typeL typeM rs g))\n -> (that : Local typeR typeL typeM rs g)\n -> Type\n where\n PMerge : (same : All ((cl,cm,c):::cs))\n -> Merge ((cl,cm,c):::cs) c\n\npublic export\nmerge : DecEq typeR typeL typeM\n => (this : List1 (typeL, typeM, Local typeR typeL typeM rs g))\n -> Maybe (that ** Merge this that)\nmerge ((l,(m,c)) ::: tail) with (allSame ((l,(m,c)) ::: tail))\n merge ((l,(m,c)) ::: tail) | (Yes prf)\n = Just (c ** PMerge prf)\n merge ((l,(m,c)) ::: tail) | (No contra)\n = Nothing\n\npublic export\nproject : DecEq typeR typeL typeM\n => {rs : List Ty}\n -> {g : Ty}\n -> (role : typeR)\n -> (termG : Global typeR typeL typeM rs g)\n -> Maybe (termL ** Project Merge role termG termL)\nproject = Projection.Term.project merge\n\n-- [ EOF ]\n", "meta": {"hexsha": "914ca77dd067d650b1af1dae76872750ecedeea9", "size": 1539, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Sessions/Projection/Plain.idr", "max_stars_repo_name": "DSbD-AppControl/sessions-playground", "max_stars_repo_head_hexsha": "d304de2a5bf9a5268f3cd8aef9402face1bc7fdc", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-08-19T13:13:10.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-19T13:13:10.000Z", "max_issues_repo_path": "Sessions/Projection/Plain.idr", "max_issues_repo_name": "DSbD-AppControl/sessions-playground", "max_issues_repo_head_hexsha": "d304de2a5bf9a5268f3cd8aef9402face1bc7fdc", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sessions/Projection/Plain.idr", "max_forks_repo_name": "DSbD-AppControl/sessions-playground", "max_forks_repo_head_hexsha": "d304de2a5bf9a5268f3cd8aef9402face1bc7fdc", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.4821428571, "max_line_length": 75, "alphanum_fraction": 0.6250812216, "num_tokens": 416, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.5281061649053479}} {"text": "module NN.Dense\n\nimport Backprop\nimport Control.Optics\nimport Linear.Backprop\nimport Linear.V\nimport Utils.String\n\npublic export\nrecord Dense (i : Nat) (o : Nat) (a : Type) where\n constructor MkDense\n weights : T [i, o] a\n biases : T [o] a\n\nexport\nlweights : Simple Lens (Dense i o a) (T [i, o] a)\nlweights = lens weights (\\s, b => { weights := b } s)\n\nexport\nlbiases : Simple Lens (Dense i o a) (T [o] a)\nlbiases = lens biases (\\s, b => { biases := b } s)\n\nexport\n{i : _} -> {o : _} -> FromDouble a => FromDouble (Dense i o a) where\n fromDouble x = MkDense (fromDouble x) (fromDouble x)\n\nexport\n{i : _} -> {o : _} -> CanBack a => CanBack (Dense i o a) where\n zero = MkDense zero zero\n one = MkDense one one\n add x1 x2 = MkDense (add x1.weights x2.weights) (add x1.biases x2.biases)\n\nexport\n{i : _} -> {o : _} -> Num a => Num (Dense i o a) where\n x1 + x2 = MkDense (x1.weights + x2.weights) (x1.biases + x2.biases)\n x1 * x2 = MkDense (x1.weights * x2.weights) (x1.biases * x2.biases)\n fromInteger x = MkDense (fromInteger x) (fromInteger x)\n\nexport\n{i : _} -> {o : _} -> Neg a => Neg (Dense i o a) where\n x1 - x2 = MkDense (x1.weights - x2.weights) (x1.biases - x2.biases)\n negate x = MkDense (negate x.weights) (negate x.biases)\n\nexport\nShow a => Show (Dense i o a) where\n show x = show_record \"MkDense\" [(\"weights\", show x.weights), (\"biases\", show x.biases)]\n\nexport\napply : {i, o, n, a : _} -> CanBack a => Num a => Node s (Dense i o a) -> Node s (T [n, i] a) -> Node s (T [n, o] a)\napply layer x = x <> (layer ^. lweights) + konst (layer ^. lbiases)\n", "meta": {"hexsha": "1228d89da942b245bb79133e4082dda5389705e6", "size": 1568, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/NN/Dense.idr", "max_stars_repo_name": "tensorknower69/idris2-ml", "max_stars_repo_head_hexsha": "2ab861b50554e2b11a8ba32f1efec9d1f84e5d7c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2022-01-30T20:10:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-30T20:10:19.000Z", "max_issues_repo_path": "src/NN/Dense.idr", "max_issues_repo_name": "tensorknower69/idris2-ml", "max_issues_repo_head_hexsha": "2ab861b50554e2b11a8ba32f1efec9d1f84e5d7c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/NN/Dense.idr", "max_forks_repo_name": "tensorknower69/idris2-ml", "max_forks_repo_head_hexsha": "2ab861b50554e2b11a8ba32f1efec9d1f84e5d7c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7450980392, "max_line_length": 116, "alphanum_fraction": 0.625, "num_tokens": 578, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.828938825225204, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.5280595698332311}} {"text": "word_lengths : List String -> List Nat\nword_lengths [] = []\nword_lengths (word :: words) = length word :: word_lengths words\n", "meta": {"hexsha": "7de088816a614861c534d0a180134abc53b64a8c", "size": 125, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "wordlen.idr", "max_stars_repo_name": "janschultecom/idris-examples", "max_stars_repo_head_hexsha": "c0bf0105d69f07492c6b99f14e9ca3c4cd7443c8", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-05-05T15:26:06.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-05T15:26:06.000Z", "max_issues_repo_path": "wordlen.idr", "max_issues_repo_name": "janschultecom/idris-examples", "max_issues_repo_head_hexsha": "c0bf0105d69f07492c6b99f14e9ca3c4cd7443c8", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "wordlen.idr", "max_forks_repo_name": "janschultecom/idris-examples", "max_forks_repo_head_hexsha": "c0bf0105d69f07492c6b99f14e9ca3c4cd7443c8", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.25, "max_line_length": 64, "alphanum_fraction": 0.712, "num_tokens": 29, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5279255066217884}} {"text": "module Flexidisc.OrdList.Row\n\nimport Flexidisc.OrdList.Label\nimport Flexidisc.OrdList.Type\n\n%default total\n%access public export\n\n||| Proof that a key value pair is part of an `OrdList`. If you don't need the value, use `Label`.\ndata OrdRow : (l : k) -> (ty : v) -> OrdList k o v -> Type where\n ||| The label is in the first element of the list\n Here : OrdRow l ty ((l, ty) :: xs)\n ||| The label is in the tail\n There : (later : OrdRow l ty xs) -> OrdRow l ty (x::xs)\n\n%name OrdRow lbl, loc, prf, e, elem\n\n||| Demote it to a label existence proof\nlabelFromOrdRow : OrdRow l v xs -> OrdLabel l xs\nlabelFromOrdRow Here = Here\nlabelFromOrdRow (There later) = There (labelFromOrdRow later)\n\nUninhabited (OrdRow k v []) where\n uninhabited Here impossible\n uninhabited (There _) impossible\n\n||| Map a row and its header simultaneously\nmapRow : {xs : OrdList k o a} -> (f : a -> b) -> (loc : OrdRow l ty xs) -> OrdRow l (f ty) (map f xs)\nmapRow f loc {xs = []} = absurd loc\nmapRow f Here {xs = ((k, x) :: xs)} = Here\nmapRow f (There later) {xs = ((k, x) :: xs)} = There (mapRow f later)\n\n||| Given a proof that an element is in a vector, remove it\ndropOrdRow : (xs : OrdList k o v) -> (loc : OrdRow l ty xs) -> OrdList k o v\ndropOrdRow xs = dropLabel xs . labelFromOrdRow\n\n||| Update a value in the list given it's location and an update function\nchangeValue : (xs : OrdList k o v) -> (loc : OrdRow l old xs) -> (new : v) ->\n OrdList k o v\nchangeValue xs loc new = changeValue xs (labelFromOrdRow loc) new\n\nchangeWithSameTypeIsUnchanged : (row : OrdRow l x xs) -> changeValue xs row x = xs\nchangeWithSameTypeIsUnchanged Here = Refl\nchangeWithSameTypeIsUnchanged (There later) = cong $ changeWithSameTypeIsUnchanged later\n\n\nfindInsertOrdRow : (l : k) -> (xs : OrdList k o v) -> OrdRow l ty (insert (l,ty) xs)\nfindInsertOrdRow l [] = Here\nfindInsertOrdRow l ((kx, vx) :: xs) with (l < kx)\n | True = Here\n | False = There (findInsertOrdRow l xs)\n\ndropInsertInv : (l : k) -> (ty : v) -> (xs : OrdList k o v) ->\n dropOrdRow (insert (l, ty) xs) (findInsertOrdRow l xs) = xs\ndropInsertInv l ty [] = Refl\ndropInsertInv l ty ((kx,vx) :: xs) with (l < kx)\n | True = Refl\n | False = cong (dropInsertInv l ty xs)\n", "meta": {"hexsha": "16ff71b32f01cab841bf043f3f28b79581154f1c", "size": 2276, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Flexidisc/OrdList/Row.idr", "max_stars_repo_name": "berewt/flexidisc", "max_stars_repo_head_hexsha": "8a0c367244229be5d417c04588d8d41b6030dba2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-04-02T09:51:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-03T05:15:49.000Z", "max_issues_repo_path": "src/Flexidisc/OrdList/Row.idr", "max_issues_repo_name": "LIST-LUXEMBOURG/flexidisc", "max_issues_repo_head_hexsha": "f5a9cdc81554359e324b64400d8479494cd45a8c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Flexidisc/OrdList/Row.idr", "max_forks_repo_name": "LIST-LUXEMBOURG/flexidisc", "max_forks_repo_head_hexsha": "f5a9cdc81554359e324b64400d8479494cd45a8c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.5762711864, "max_line_length": 101, "alphanum_fraction": 0.6493848858, "num_tokens": 737, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5279093853568572}} {"text": "module Examples.ConferenceLattice\n\nimport public DepSec.Lattice\nimport Decidable.Equality\nimport Pruviloj.Derive.DecEq\nimport Pruviloj.Disjoint\nimport Pruviloj.Injective\n\n%language ElabReflection\n%access public export\n\ndata Id : Type where\n Top : Id\n Nat : Nat -> Id\n Bot : Id\n\nUid : Type\nUid = Id\n\nSid : Type\nSid = Id\n\nnatInjective : (Nat a) = (Nat b) -> a = b\nnatInjective Refl = Refl\n\nDecEq Id where\n decEq Top Top = Yes Refl\n decEq Top (Nat k) = No (%runElab disjoint)\n decEq Top Bot = No (%runElab disjoint)\n decEq (Nat k) Top = No (%runElab disjoint)\n decEq (Nat k) (Nat j) with (decEq k j)\n | (Yes prf) = Yes $ cong prf\n | (No contra) = No $ \\a => contra $ natInjective a\n decEq (Nat k) Bot = No (%runElab disjoint)\n decEq Bot Top = No (%runElab disjoint)\n decEq Bot (Nat k) = No (%runElab disjoint)\n decEq Bot Bot = Yes Refl\n\nEq Id where\n Top == Top = True\n Top == (Nat k) = False\n Top == Bot = False\n (Nat k) == Top = False\n (Nat k) == (Nat j) = k == j\n (Nat k) == Bot = False\n Bot == Top = False\n Bot == (Nat k) = False\n Bot == Bot = True\n\ndata Compartment : Type where\n U : Uid -> Compartment\n A : Uid -> Sid -> Compartment\n PC : Uid -> Sid -> Compartment\n\ntotal\njoinId : (x, y : Id) -> Id\njoinId Top y = Top\njoinId (Nat k) Top = Top\njoinId (Nat k) (Nat j) with (decEq k j)\n | (Yes _) = Nat k\n | (No _) = Top\njoinId (Nat k) Bot = (Nat k)\njoinId Bot y = y\n\ntotal\njoinComp : (x , y : Compartment) -> Compartment\njoinComp (U x) (U y) = U (joinId x y)\njoinComp (U x) (A y z) = A (joinId x y) z\njoinComp (U x) (PC y z) = PC y z\njoinComp (A x z) (U y) = A (joinId x y) z\njoinComp (A x z) (A y w) = A (joinId x y) (joinId z w)\njoinComp (A x z) (PC y w) = PC y (joinId z w)\njoinComp (PC x z) (U y) = PC x z\njoinComp (PC x z) (A y w) = PC x (joinId z w)\njoinComp (PC x z) (PC y w) = PC (joinId x y) (joinId z w)\n\nlemma1 : a = b -> joinId (Nat a) (Nat b) = (Nat a)\nlemma1 {a} {b} prf with (decEq a b)\n | (Yes x) = Refl\n | (No contra) = void $ contra prf\n\nlemma2 : (a = b -> Void) -> joinId (Nat a) (Nat b) = Top\nlemma2 {a} {b} contra with (decEq a b)\n | (Yes prf) = void $ contra prf\n | (No f) = Refl\n\nlemma3 : a = b -> (b = c -> Void) -> a = c -> Void\nlemma3 prf contra prf' = contra $ trans (sym prf) prf'\n\nimplementation JoinSemilattice Id where\n join = joinId\n associative Top y z = Refl\n associative (Nat k) Top z = Refl\n associative (Nat k) (Nat j) Top with (decEq k j)\n | (Yes prf) = Refl\n | (No contra) = Refl\n associative (Nat k) (Nat j) (Nat i) with (decEq k j, decEq j i)\n | (Yes prf, Yes prf') =\n rewrite lemma1 prf in\n rewrite lemma1 prf' in\n rewrite lemma1 (trans prf prf') in\n lemma1 prf\n | (Yes prf, No contra) =\n rewrite lemma1 prf in\n rewrite lemma2 contra in\n rewrite lemma2 $ lemma3 prf contra in\n Refl\n | (No contra, Yes prf) =\n rewrite lemma2 contra in\n rewrite lemma1 prf in\n lemma2 contra\n | (No contra, No contra') =\n rewrite lemma2 contra in\n rewrite lemma2 contra' in\n Refl\n associative (Nat k) (Nat j) Bot with (decEq k j)\n | (Yes _) = Refl\n | (No _) = Refl\n associative (Nat k) Bot z = Refl\n associative Bot y z = Refl\n\n commutative Top Top = Refl\n commutative Top (Nat k) = Refl\n commutative Top Bot = Refl\n commutative (Nat k) Top = Refl\n commutative (Nat k) (Nat j) with (decEq k j)\n | (Yes prf) = rewrite lemma1 $ sym prf in cong prf\n | (No contra) = sym $ lemma2 $ negEqSym contra\n commutative (Nat k) Bot = Refl\n commutative Bot Top = Refl\n commutative Bot (Nat k) = Refl\n commutative Bot Bot = Refl\n\n idempotent Top = Refl\n idempotent (Nat k) with (decEq k k)\n | (Yes _) = Refl\n | (No contra) = void $ contra Refl\n idempotent Bot = Refl\n\nimplementation BoundedJoinSemilattice Id where\n Bottom = Bot\n\n unitary Top = Refl\n unitary (Nat k) = Refl\n unitary Bot = Refl\n\nimplementation JoinSemilattice Compartment where\n join = joinComp\n\n associative (U x) (U y) (U z) = cong $ associative x y z\n associative (U x) (U y) (A z w) = rewrite associative x y z in Refl\n associative (U x) (U y) (PC z w) = Refl\n associative (U x) (A y w) (U z) = rewrite associative x y z in Refl\n associative (U x) (A y w) (A z s) = rewrite associative x y z in Refl\n associative (U x) (A y w) (PC z s) = Refl\n associative (U x) (PC y w) (U z) = Refl\n associative (U x) (PC y w) (A z s) = Refl\n associative (U x) (PC y w) (PC z s) = Refl\n associative (A x w) (U y) (U z) = rewrite associative x y z in Refl\n associative (A x w) (U y) (A z s) = rewrite associative x y z in Refl\n associative (A x w) (U y) (PC z s) = Refl\n associative (A x w) (A y s) (U z) = rewrite associative x y z in Refl\n associative (A x w) (A y s) (A z t) =\n rewrite associative x y z in\n rewrite associative w s t in Refl\n associative (A x w) (A y s) (PC z t) = rewrite associative w s t in Refl\n associative (A x w) (PC y s) (U z) = Refl\n associative (A x w) (PC y s) (A z t) = rewrite associative w s t in Refl\n associative (A x w) (PC y s) (PC z t) = rewrite associative w s t in Refl\n associative (PC x w) (U y) (U z) = Refl\n associative (PC x w) (U y) (A z s) = Refl\n associative (PC x w) (U y) (PC z s) = Refl\n associative (PC x w) (A y s) (U z) = Refl\n associative (PC x w) (A y s) (A z t) = rewrite associative w s t in Refl\n associative (PC x w) (A y s) (PC z t) = rewrite associative w s t in Refl\n associative (PC x w) (PC y s) (U z) = Refl\n associative (PC x w) (PC y s) (A z t) = rewrite associative w s t in Refl\n associative (PC x w) (PC y s) (PC z t) =\n rewrite associative x y z in\n rewrite associative w s t in Refl\n\n commutative (U x) (U y) = cong $ commutative x y\n commutative (U x) (A y z) = rewrite commutative x y in Refl\n commutative (U x) (PC y z) = Refl\n commutative (A x z) (U y) = rewrite commutative x y in Refl\n commutative (A x z) (A y w) =\n rewrite commutative x y in\n rewrite commutative z w in\n Refl\n commutative (A x z) (PC y w) = rewrite commutative w z in Refl\n commutative (PC x z) (U y) = Refl\n commutative (PC x z) (A y w) = rewrite commutative z w in Refl\n commutative (PC x z) (PC y w) =\n rewrite commutative x y in\n rewrite commutative z w in\n Refl\n\n idempotent (U x) = cong $ idempotent x\n idempotent (A x y) =\n rewrite idempotent x in\n rewrite idempotent y in\n Refl\n idempotent (PC x y) =\n rewrite idempotent x in\n rewrite idempotent y in\n Refl\n\nimplementation BoundedJoinSemilattice Compartment where\n Bottom = U Bot\n\n unitary (U x) = cong $ unitary x\n unitary (A x y) = rewrite unitary x in Refl\n unitary (PC x y) = Refl\n\n--------------------------------------------------------------------------------\n-- Lemmas\n--------------------------------------------------------------------------------\nU_leq_A : U uid `leq` A uid sid\nU_leq_A {uid} = rewrite reflexive uid in Refl\n\nA_leq_PC : A uid1 sid `leq` PC uid2 sid\nA_leq_PC {sid} = rewrite reflexive sid in Refl\n", "meta": {"hexsha": "f3743d911a228df8efe44624077ba06920fc665c", "size": 7034, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Examples/ConferenceLattice.idr", "max_stars_repo_name": "simongregersen/DepSec", "max_stars_repo_head_hexsha": "10e0419acbe690c460df509d0cb9f4690867422c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2019-08-25T15:16:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T11:10:20.000Z", "max_issues_repo_path": "Examples/ConferenceLattice.idr", "max_issues_repo_name": "simongregersen/DepSec", "max_issues_repo_head_hexsha": "10e0419acbe690c460df509d0cb9f4690867422c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/ConferenceLattice.idr", "max_forks_repo_name": "simongregersen/DepSec", "max_forks_repo_head_hexsha": "10e0419acbe690c460df509d0cb9f4690867422c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.5426008969, "max_line_length": 80, "alphanum_fraction": 0.601933466, "num_tokens": 2529, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321936479701, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5276042771667022}} {"text": "module Solutions.Functions1\n\n--------------------------------------------------------------------------------\n-- Exercise 1\n--------------------------------------------------------------------------------\n\nsquare : Integer -> Integer\nsquare n = n * n\n\ntestSquare : (Integer -> Bool) -> Integer -> Bool\ntestSquare fun = fun . square\n\ntwice : (Integer -> Integer) -> Integer -> Integer\ntwice f = f . f\n\n--------------------------------------------------------------------------------\n-- Exercise 2\n--------------------------------------------------------------------------------\n\nisEven : Integer -> Bool\nisEven n = (n `mod` 2) == 0\n\nisOdd : Integer -> Bool\nisOdd = not . isEven\n\n--------------------------------------------------------------------------------\n-- Exercise 3\n--------------------------------------------------------------------------------\n\nisSquareOf : Integer -> Integer -> Bool\nisSquareOf n x = n == x * x\n\n--------------------------------------------------------------------------------\n-- Exercise 4\n--------------------------------------------------------------------------------\n\nisSmall : Integer -> Bool\nisSmall n = n <= 100\n\n--------------------------------------------------------------------------------\n-- Exercise 5\n--------------------------------------------------------------------------------\n\nabsIsSmall : Integer -> Bool\nabsIsSmall = isSmall . abs\n\n--------------------------------------------------------------------------------\n-- Exercise 6\n--------------------------------------------------------------------------------\n\nand : (Integer -> Bool) -> (Integer -> Bool) -> Integer -> Bool\nand f1 f2 n = f1 n && f2 n\n\nor : (Integer -> Bool) -> (Integer -> Bool) -> Integer -> Bool\nor f1 f2 n = f1 n || f2 n\n\nnegate : (Integer -> Bool) -> Integer -> Bool\nnegate f = not . f\n\n--------------------------------------------------------------------------------\n-- Exercise 7\n--------------------------------------------------------------------------------\n\n(&&) : (Integer -> Bool) -> (Integer -> Bool) -> Integer -> Bool\n(&&) = and\n\n(||) : (Integer -> Bool) -> (Integer -> Bool) -> Integer -> Bool\n(||) = or\n\nnot : (Integer -> Bool) -> Integer -> Bool\nnot = negate\n", "meta": {"hexsha": "e5b4ec1a73500ab08186176d23b81d6f8cb0bb8e", "size": 2257, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Solutions/Functions1.idr", "max_stars_repo_name": "ska80/idris2-tutorial", "max_stars_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 60, "max_stars_repo_stars_event_min_datetime": "2022-01-13T16:14:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T16:16:57.000Z", "max_issues_repo_path": "src/Solutions/Functions1.idr", "max_issues_repo_name": "ska80/idris2-tutorial", "max_issues_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2022-01-14T15:42:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T09:53:16.000Z", "max_forks_repo_path": "src/Solutions/Functions1.idr", "max_forks_repo_name": "ska80/idris2-tutorial", "max_forks_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2022-01-14T15:48:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T06:49:13.000Z", "avg_line_length": 31.3472222222, "max_line_length": 80, "alphanum_fraction": 0.2782454586, "num_tokens": 375, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5275341710830546}} {"text": "> module Interfaces.Math\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n> interface (Num ty) => Math ty where\n> exp : ty -> ty \n> sin : ty -> ty \n> cos : ty -> ty \n\n\n", "meta": {"hexsha": "ea39cca2a50b81f0de32e6a2c49609195d90cd4f", "size": 191, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Interfaces/Math.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Interfaces/Math.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Interfaces/Math.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 13.6428571429, "max_line_length": 37, "alphanum_fraction": 0.5916230366, "num_tokens": 59, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.837619979547273, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.5275117937734766}} {"text": "module LinearTypes \n\nimport Data.Vect\n\ninfixr 10 ::\ninfix 5 #\n\n%default total\n\npublic export\ndata LFstPair : Type -> Type -> Type where\n (#) : (1 _ : a) -> b -> LFstPair a b\n\n\npublic export\ndata LVect : Nat -> Type -> Type where\n Nil : LVect Z a\n (::) : (1 _ : a) -> (1 _ : LVect k a) -> LVect (S k) a\n\npublic export\nShow a => Show (LVect n a) where\n show v = \"[\" ++ show' v ++ \"]\" where\n show' : LVect k a -> String\n show' Nil = \"\"\n show' [x] = show x\n show' (x :: xs) = show x ++ \" , \" ++ show' xs \n\npublic export\n(Show a, Show b) => Show (LPair a b) where\n show ( a # b ) = \"( \" ++ show a ++ \" # \" ++ show b ++ \" )\"\n\npublic export\n(Show a, Show b) => Show (LFstPair a b) where\n show ( a # b ) = \"( \" ++ show a ++ \" # \" ++ show b ++ \" )\"\n\npublic export\n(++) : (1 xs : LVect m a) -> (1 ys : LVect n a) -> LVect (m + n) a\n(++) [] ys = ys\n(++) (x::xs) ys = x :: (xs ++ ys)\n\npublic export\nsplitAt : {n : Nat} -> (i : Nat) -> (1 xs : LVect (i+n) a) -> LPair (LVect i a) (LVect n a)\nsplitAt 0 xs = [] # xs\nsplitAt (S k) (x :: xs) = let ys # zs = LinearTypes.splitAt k xs in\n (x :: ys) # zs\n\n||| diff n i = n - i\npublic export\ndiff : Nat -> Nat -> Nat\ndiff Z n = Z\ndiff (S k) n = S (diff k n)\n\nexport\nlemmaDiffZero : (n : Nat) -> diff n 0 = n\nlemmaDiffZero 0 = Refl\nlemmaDiffZero (S k) = rewrite lemmaDiffZero k in Refl\n\npublic export\nconsLin : (1 _ : Bool) -> (1 _ : Vect n Bool) -> Vect (S n) Bool\nconsLin False [] = [False]\nconsLin False (x :: xs) = False :: x :: xs\nconsLin True [] = [True]\nconsLin True (x :: xs) = True :: x :: xs\n\npublic export\ntoVect : (1 _ : LVect n Bool) -> Vect n Bool\ntoVect [] = []\ntoVect (x :: xs) = x `consLin` (toVect xs)\n", "meta": {"hexsha": "4205c6294101206c9bfab35b10522f137e3c86b5", "size": 1718, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "LinearTypes.idr", "max_stars_repo_name": "zamdzhiev/Qimaera", "max_stars_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2021-08-24T14:36:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-24T00:36:11.000Z", "max_issues_repo_path": "LinearTypes.idr", "max_issues_repo_name": "zamdzhiev/Qimaera", "max_issues_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LinearTypes.idr", "max_forks_repo_name": "zamdzhiev/Qimaera", "max_forks_repo_head_hexsha": "3823cd1d103dd07ca0fb6fe3be08b535e56e3b87", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8985507246, "max_line_length": 91, "alphanum_fraction": 0.5215366705, "num_tokens": 628, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.5273932985171098}} {"text": "module Main\n\nimport Data.List\n\n\ndata Tree a = Empty\n | Node (Tree a) a (Tree a)\n\nShow a => Show (Tree a) where\n show Empty = \"Empty\"\n show (Node left val right) = \"(Node \" ++ show left ++ \" \" ++ show val ++ \" \" ++ show right ++ \")\"\n\ntestTree : Tree String\ntestTree = Node (Node (Node Empty \"Jim\" Empty)\n \"Fred\"\n (Node Empty \"Sheila\" Empty))\n \"Alice\"\n (Node Empty \"Bob\" (Node Empty \"Eve\" Empty))\n\nflatten : Tree a -> List a\nflatten Empty = []\nflatten (Node left val right) = flatten left ++ val :: flatten right\n\ntreeLabelWith\n : Stream labelType\n -> Tree a\n -> (Stream labelType, Tree (labelType, a))\ntreeLabelWith lbls Empty = (lbls, Empty)\ntreeLabelWith lbls (Node left val right)\n = let (lblThis :: lblsLeft, leftLabelled) = treeLabelWith lbls left\n (lblRight, rightLabelled) = treeLabelWith lblsLeft right\n in (lblRight, Node leftLabelled (lblThis, val) rightLabelled)\n\ntreeLabel : Tree a -> Tree (Integer, a)\ntreeLabel tree = snd (treeLabelWith [1..] tree)\n\nmain : IO ()\nmain = do\n printLn $ flatten testTree\n printLn $ flatten $ treeLabel testTree\n", "meta": {"hexsha": "0f2565eb0be882fbced58864188ee9d00c4144d6", "size": 1155, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/tdd/chapter12/01_TreeLabel.idr", "max_stars_repo_name": "luc-tielen/idris-grin", "max_stars_repo_head_hexsha": "b259e8861a2a5f66ebf9a545e6d9620b3f0ec969", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/tdd/chapter12/01_TreeLabel.idr", "max_issues_repo_name": "luc-tielen/idris-grin", "max_issues_repo_head_hexsha": "b259e8861a2a5f66ebf9a545e6d9620b3f0ec969", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/tdd/chapter12/01_TreeLabel.idr", "max_forks_repo_name": "luc-tielen/idris-grin", "max_forks_repo_head_hexsha": "b259e8861a2a5f66ebf9a545e6d9620b3f0ec969", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 28.1707317073, "max_line_length": 99, "alphanum_fraction": 0.6225108225, "num_tokens": 322, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.5273806299699574}} {"text": "module NanoParsec.Combinators\n\nimport NanoParsec.Parser\nimport Data.String\n\n%access export\n\noneOf : List Char -> Parser Char\noneOf st = satisfy (flip elem st)\n\nchainl1 : Parser a -> Parser (a -> a -> a) -> Parser a\nchainl1 p op = do { a <- p; rest a }\n where\n rest a = (do f <- op\n b <- p\n rest (f a b))\n <|> return a\n\nchainl : Parser a -> Parser (a -> a -> a) -> a -> Parser a\nchainl p op a = (chainl1 p op) <|> return a\n\n\nchar : Char -> Parser Char\nchar ch = satisfy (ch ==)\n\ndigit : Parser Char\ndigit = satisfy isDigit\n\nspaces : Parser String\nspaces = pack <$> (many . oneOf . unpack $ \" \\n\\r\")\n\nstring : String -> Parser String\nstring st = pack <$> (string' $ unpack st)\n where\n string' : List Char -> Parser (List Char)\n string' [] = return []\n string' (c :: cs) = char c\n >>= \\_ => string' cs\n >>= \\_ => return (c :: cs)\n\ntoken : Parser a -> Parser a\ntoken p = p >>= \\a => spaces >>= \\_ => return a\n\nreserved : String -> Parser String\nreserved st = token (string st)\n\nmaybeNatural : Parser (Maybe Integer)\nmaybeNatural = parseInteger <$> (pack <$> some digit)\n\nnatural : Parser Integer\nnatural = fromMaybe <$> maybeNatural\n\nmaybeNumber : Parser (Maybe Int)\nmaybeNumber = do\n sign <- (unpack <$> string \"-\") <|> return []\n digits <- some digit\n return $ parseInteger $ pack (sign ++ digits)\n\nnumber : Parser Int\nnumber = fromMaybe <$> maybeNumber\n\nparens : Parser a -> Parser a\nparens p = do\n reserved \"(\"\n val <- p\n reserved \")\"\n return val\n", "meta": {"hexsha": "720254909e23deaa288f460c721b77c7ac6c948a", "size": 1609, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "NanoParsec/Combinators.idr", "max_stars_repo_name": "stallmanifold/idris-nanoparsec", "max_stars_repo_head_hexsha": "adf74d4ad4f1e8df918f3616b1cc8ee89db1c315", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-11-21T13:36:37.000Z", "max_stars_repo_stars_event_max_datetime": "2017-02-21T05:56:30.000Z", "max_issues_repo_path": "NanoParsec/Combinators.idr", "max_issues_repo_name": "lambdaxymox/idris-nanoparsec", "max_issues_repo_head_hexsha": "adf74d4ad4f1e8df918f3616b1cc8ee89db1c315", "max_issues_repo_licenses": ["Apache-2.0", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NanoParsec/Combinators.idr", "max_forks_repo_name": "lambdaxymox/idris-nanoparsec", "max_forks_repo_head_hexsha": "adf74d4ad4f1e8df918f3616b1cc8ee89db1c315", "max_forks_repo_licenses": ["Apache-2.0", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.6617647059, "max_line_length": 58, "alphanum_fraction": 0.5668116843, "num_tokens": 427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.7799929053683038, "lm_q1q2_score": 0.527091584307361}} {"text": "\nmodule SubstLemmas\n\n-- Lemmas about substitution (and the related\n-- operations 'shiftTerm' and 'shift').\n\n\nimport Subst\nimport Term\nimport Typing\n\n\n%default total\n%access export\n\n\n\n---------------------------------------\n-- Begin: SUBSTITUTION PRESERVES TYPING\n\n-- Lemmas about extending contexts (in the middle)\n-- are required for the proof of the fact that\n-- substitution preserves typing.\n-- (In fact, the proof of preservation of typing under\n-- substitution only requires a lemma about extending\n-- the context at the front. However, to prove this\n-- lemma about extending the context, one has to assume\n-- that the context is extended in the middle in order\n-- for induction to go through in the case of 'TAbs'.)\n\n\n-- Extending a context 'ctx1++ctx2' in the middle preserves\n-- the types that are in the context, but the index 'k' must\n-- be shifted appropriately in order to retrieve the same\n-- type from the extended context:\nshiftTy : (k : Nat) ->\n index' k (ctx1++ctx2) = Just t -> \n (ctx : Context) ->\n index' (shift (length ctx1) (length ctx) k) (ctx1++ctx++ctx2) = Just t\nshiftTy {ctx1 = []} k prf [] = prf\nshiftTy {ctx1 = []} k prf (s::ctx) = shiftTy {ctx1=[]} k prf ctx\nshiftTy {ctx1 = t1::ctx1} Z Refl ctx = Refl\nshiftTy {ctx1 = t1::ctx1} (S k) prf ctx = shiftTy {ctx1=ctx1} k prf ctx\n\n\n\n-- Typing is preserved if a context 'ctx1++ctx2' is extended\n-- in the middle provided the term 'e' is shifted appropriately:\nshiftTermTy : (e : Term) ->\n Typing (ctx1++ctx2) e t -> \n (ctx : Context) ->\n Typing (ctx1++ctx++ctx2) (shiftTerm (length ctx1) (length ctx) e) t\n--\nshiftTermTy (TVar i) (TyVar prf) ctx = \n TyVar $ shiftTy i prf ctx\n--\nshiftTermTy (TAbs e) (TyAbs s ty) ctx {ctx1} = \n TyAbs s $ shiftTermTy e ty ctx {ctx1=s::ctx1}\n--\nshiftTermTy (TApp e1 e2) (TyApp ty1 ty2) ctx = \n TyApp (shiftTermTy e1 ty1 ctx)\n (shiftTermTy e2 ty2 ctx)\n--\nshiftTermTy (TRec e1 e2 e3) (TyRec ty1 ty2 ty3) ctx =\n TyRec (shiftTermTy e1 ty1 ctx)\n (shiftTermTy e2 ty2 ctx)\n (shiftTermTy e3 ty3 ctx)\n--\nshiftTermTy TZero TyZero ctx = TyZero\n--\nshiftTermTy (TSucc e) (TySucc ty) ctx = \n TySucc $ shiftTermTy e ty ctx\n-- \nshiftTermTy (TPred e) (TyPred ty) ctx = \n TyPred $ shiftTermTy e ty ctx\n--\nshiftTermTy (TIfz e1 e2 e3) (TyIfz ty1 ty2 ty3) ctx =\n TyIfz (shiftTermTy e1 ty1 ctx)\n (shiftTermTy e2 ty2 ctx)\n (shiftTermTy e3 ty3 ctx)\n\n\n\n-- Finally, substitution preserves typing:\nsubstPreservesTy : (e : Term) -> -- Term in which substitution takes place.\n Typing (ctx1++s::ctx2) e t -> \n (es : Term) -> -- Term that is substituted in.\n Typing ctx2 es s ->\n Typing (ctx1++ctx2) (subst es (length ctx1) e) t\n--\nsubstPreservesTy {ctx1 = []} (TVar Z) (TyVar Refl) es esTy = esTy\nsubstPreservesTy {ctx1 = []} (TVar (S i)) (TyVar prf) es esTy = TyVar prf\nsubstPreservesTy {ctx1 = t1::ctx1} (TVar Z) (TyVar prf) es esTy = TyVar prf\nsubstPreservesTy {ctx1 = t1::ctx1} (TVar (S k)) (TyVar prf) es esTy = \n let ih = substPreservesTy {ctx1=ctx1} (TVar k) (TyVar prf) es esTy\n in shiftTermTy _ ih [t1] {ctx1=[]}\n--\nsubstPreservesTy {ctx1} (TAbs e) (TyAbs s ty) es esTy = \n TyAbs s $ substPreservesTy e ty es esTy {ctx1=s::ctx1} \n--\nsubstPreservesTy (TApp e1 e2) (TyApp ty1 ty2) es esTy = \n TyApp (substPreservesTy e1 ty1 es esTy)\n (substPreservesTy e2 ty2 es esTy)\n--\nsubstPreservesTy (TRec e1 e2 e3) (TyRec ty1 ty2 ty3) es esTy =\n TyRec (substPreservesTy e1 ty1 es esTy)\n (substPreservesTy e2 ty2 es esTy)\n (substPreservesTy e3 ty3 es esTy) \n--\nsubstPreservesTy TZero TyZero es esTy = TyZero\n--\nsubstPreservesTy (TSucc e) (TySucc ty) es esTy =\n TySucc $ substPreservesTy e ty es esTy\n-- \nsubstPreservesTy (TPred e) (TyPred ty) es esTy = \n TyPred $ substPreservesTy e ty es esTy\n--\nsubstPreservesTy (TIfz e1 e2 e3) (TyIfz ty1 ty2 ty3) es esTy =\n TyIfz (substPreservesTy e1 ty1 es esTy)\n (substPreservesTy e2 ty2 es esTy)\n (substPreservesTy e3 ty3 es esTy)\n\n-- End: SUBSTITUTION PRESERVES TYPING\n-------------------------------------\n\n\n\n\n---------------------------------------\n-- Begin: SEVERAL LEMMAS ABOUT SHIFTING\n\n-- The following lemmas come in pairs: \n-- The really useful lemma in each pair\n-- is the one about 'shiftTerm'.\n-- However, the lemma in each pair that\n-- is non-trivial to prove is usually the\n-- other one, i.e. the one about 'shift'.\n\n\nshiftByZero : (c : Nat) ->\n (k : Nat) ->\n shift c Z k = k\nshiftByZero Z k = Refl\nshiftByZero (S c) Z = Refl\nshiftByZero (S c) (S k) = cong $ shiftByZero c k\n\n\nshiftTermByZero : (c : Nat) ->\n (e : Term) ->\n shiftTerm c Z e = e\nshiftTermByZero c (TVar i) = congVar $ shiftByZero c i\nshiftTermByZero c (TAbs e) = congAbs $ shiftTermByZero (S c) e\nshiftTermByZero c (TApp e1 e2) = \n congApp (shiftTermByZero c e1)\n (shiftTermByZero c e2)\nshiftTermByZero c (TRec e1 e2 e3) = \n congRec (shiftTermByZero c e1)\n (shiftTermByZero c e2)\n (shiftTermByZero c e3)\nshiftTermByZero c TZero = congZero\nshiftTermByZero c (TSucc e) = congSucc $ shiftTermByZero c e\nshiftTermByZero c (TPred e) = congPred $ shiftTermByZero c e\nshiftTermByZero c (TIfz e1 e2 e3) =\n congIfz (shiftTermByZero c e1)\n (shiftTermByZero c e2)\n (shiftTermByZero c e3)\n\n\n\nshiftTwice : (c : Nat) ->\n (d1 : Nat) -> (d2 : Nat) ->\n (k : Nat) ->\n shift c d2 (shift c d1 k) = shift c (d2+d1) k\nshiftTwice Z d1 d2 k = plusAssociative d2 d1 k\nshiftTwice (S c) d1 d2 Z = Refl\nshiftTwice (S c) d1 d2 (S k) = cong $ shiftTwice c d1 d2 k\n\n\nshiftTermTwice : (c : Nat) ->\n (d1 : Nat) -> (d2 : Nat) ->\n (e : Term) ->\n shiftTerm c d2 (shiftTerm c d1 e) = shiftTerm c (d2+d1) e\nshiftTermTwice c d1 d2 (TVar i) = congVar $ shiftTwice c d1 d2 i\nshiftTermTwice c d1 d2 (TAbs e) = congAbs $ shiftTermTwice (S c) d1 d2 e\nshiftTermTwice c d1 d2 (TApp e1 e2) = \n congApp (shiftTermTwice c d1 d2 e1)\n (shiftTermTwice c d1 d2 e2)\nshiftTermTwice c d1 d2 (TRec e1 e2 e3) =\n congRec (shiftTermTwice c d1 d2 e1)\n (shiftTermTwice c d1 d2 e2)\n (shiftTermTwice c d1 d2 e3)\nshiftTermTwice c d1 d2 TZero = congZero\nshiftTermTwice c d1 d2 (TSucc e) = congSucc $ shiftTermTwice c d1 d2 e\nshiftTermTwice c d1 d2 (TPred e) = congPred $ shiftTermTwice c d1 d2 e\nshiftTermTwice c d1 d2 (TIfz e1 e2 e3) = \n congIfz (shiftTermTwice c d1 d2 e1)\n (shiftTermTwice c d1 d2 e2)\n (shiftTermTwice c d1 d2 e3)\n\n\nshiftTermTwice' : (c : Nat) ->\n (d1 : Nat) -> (d2 : Nat) ->\n (e : Term) ->\n shiftTerm c d2 (shiftTerm c d1 e) = shiftTerm c d1 (shiftTerm c d2 e)\nshiftTermTwice' c d1 d2 e = \n let eq1 = shiftTermTwice c d1 d2 e\n comm = cong {f = \\q => shiftTerm c q e} $ plusCommutative d1 d2 \n eq1' = trans eq1 (sym comm)\n eq2 = shiftTermTwice c d2 d1 e\n in trans eq1' (sym eq2)\n\n\n\nshiftSwap : (c1 : Nat) -> (d1 : Nat) ->\n (c2 : Nat) -> (d2 : Nat) ->\n (k : Nat) ->\n shift (c1+d1+c2) d2 (shift c1 d1 k) = shift c1 d1 (shift (c1+c2) d2 k)\nshiftSwap Z Z c2 d2 k = Refl\nshiftSwap Z (S d1) c2 d2 k = cong $ shiftSwap Z d1 c2 d2 k\nshiftSwap (S c1) d1 c2 d2 Z = Refl\nshiftSwap (S c1) d1 c2 d2 (S k) = cong $ shiftSwap c1 d1 c2 d2 k\n\n\nshiftTermSwap : (c1 : Nat) -> (d1 : Nat) ->\n (c2 : Nat) -> (d2 : Nat) -> \n (e : Term) ->\n shiftTerm (c1+d1+c2) d2 (shiftTerm c1 d1 e) = \n shiftTerm c1 d1 (shiftTerm (c1+c2) d2 e)\nshiftTermSwap c1 d1 c2 d2 (TVar i) = congVar $ shiftSwap c1 d1 c2 d2 i\nshiftTermSwap c1 d1 c2 d2 (TAbs e) = congAbs $ shiftTermSwap (S c1) d1 c2 d2 e\nshiftTermSwap c1 d1 c2 d2 (TApp e1 e2) = \n congApp (shiftTermSwap c1 d1 c2 d2 e1)\n (shiftTermSwap c1 d1 c2 d2 e2)\nshiftTermSwap c1 d1 c2 d2 (TRec e1 e2 e3) =\n congRec (shiftTermSwap c1 d1 c2 d2 e1)\n (shiftTermSwap c1 d1 c2 d2 e2)\n (shiftTermSwap c1 d1 c2 d2 e3)\nshiftTermSwap c1 d1 c2 d2 TZero = congZero\nshiftTermSwap c1 d1 c2 d2 (TSucc e) = congSucc $ shiftTermSwap c1 d1 c2 d2 e\nshiftTermSwap c1 d1 c2 d2 (TPred e) = congPred $ shiftTermSwap c1 d1 c2 d2 e\nshiftTermSwap c1 d1 c2 d2 (TIfz e1 e2 e3) =\n congIfz (shiftTermSwap c1 d1 c2 d2 e1)\n (shiftTermSwap c1 d1 c2 d2 e2)\n (shiftTermSwap c1 d1 c2 d2 e3)\n\n\n\n-- Shifting acts as the identity if the\n-- cutoff is set past the typing context:\nshiftPastCtx : (k : Nat) -> \n (ctx : Context) ->\n index' k ctx = Just t ->\n (n : Nat) -> (d : Nat) ->\n shift (length ctx + n) d k = k\nshiftPastCtx Z [] Refl _ _ impossible\nshiftPastCtx (S _) [] Refl _ _ impossible\nshiftPastCtx Z (s::ctx) prf n d = Refl\nshiftPastCtx (S k) (s::ctx) prf n d = \n cong $ shiftPastCtx k ctx prf n d\n\n\nshiftTermPastCtx : (e : Term) ->\n (ctx : Context) -> \n Typing ctx e t ->\n (n : Nat) -> (d : Nat) ->\n shiftTerm (length ctx + n) d e = e\nshiftTermPastCtx (TVar i) ctx (TyVar prf) n d = congVar $ shiftPastCtx i ctx prf n d\nshiftTermPastCtx (TAbs e) ctx (TyAbs s ty) n d = congAbs $ shiftTermPastCtx e (s::ctx) ty n d\nshiftTermPastCtx (TApp e1 e2) ctx (TyApp ty1 ty2) n d = \n congApp (shiftTermPastCtx e1 ctx ty1 n d)\n (shiftTermPastCtx e2 ctx ty2 n d)\nshiftTermPastCtx (TRec e1 e2 e3) ctx (TyRec ty1 ty2 ty3) n d =\n congRec (shiftTermPastCtx e1 ctx ty1 n d)\n (shiftTermPastCtx e2 ctx ty2 n d)\n (shiftTermPastCtx e3 ctx ty3 n d) \nshiftTermPastCtx TZero ctx TyZero n d = congZero\nshiftTermPastCtx (TSucc e) ctx (TySucc ty) n d = congSucc $ shiftTermPastCtx e ctx ty n d\nshiftTermPastCtx (TPred e) ctx (TyPred ty) n d = congPred $ shiftTermPastCtx e ctx ty n d\nshiftTermPastCtx (TIfz e1 e2 e3) ctx (TyIfz ty1 ty2 ty3) n d = \n congIfz (shiftTermPastCtx e1 ctx ty1 n d)\n (shiftTermPastCtx e2 ctx ty2 n d)\n (shiftTermPastCtx e3 ctx ty3 n d) \n\n-- End: SEVERAL LEMMAS ABOUT SHIFTING\n-------------------------------------\n\n\n\n\n-------------------------------------------\n-- Begin: SHIFTING AND SUBSTITUTION COMMUTE\n\n-- The following lemma is a convoluted way of\n-- expressing 'k < length ctx'; it is used to\n-- address the 'TVar' case in the subsequent\n-- lemma.\nsubstVarPastCtx : (k : Nat) -> \n (ctx : Context) ->\n index' k ctx = Just t ->\n subst_var x (length ctx + n) k = TVar k\nsubstVarPastCtx Z [] Refl impossible\nsubstVarPastCtx (S _) [] Refl impossible\nsubstVarPastCtx Z (s::ctx) prf = Refl\nsubstVarPastCtx (S k) (s::ctx) prf =\n let ih = substVarPastCtx k ctx prf\n in cong {f = \\q => shiftTerm 0 1 q} ih\n\n\n-- Subsituting at a de Bruijn index past the\n-- context 'ctx' in which an expression 'e'\n-- is typed yields 'e':\nsubstPastCtx : (e : Term) -> \n (ctx : Context) ->\n Typing ctx e t ->\n subst x (length ctx + n) e = e\nsubstPastCtx (TVar i) ctx (TyVar prf) = substVarPastCtx i ctx prf\nsubstPastCtx (TAbs e) ctx (TyAbs s ty) = congAbs $ substPastCtx e (s::ctx) ty\nsubstPastCtx (TApp e1 e2) ctx (TyApp ty1 ty2) = \n congApp (substPastCtx e1 ctx ty1)\n (substPastCtx e2 ctx ty2)\nsubstPastCtx (TRec e1 e2 e3) ctx (TyRec ty1 ty2 ty3) = \n congRec (substPastCtx e1 ctx ty1)\n (substPastCtx e2 ctx ty2)\n (substPastCtx e3 ctx ty3)\nsubstPastCtx TZero ctx TyZero = congZero\nsubstPastCtx (TSucc e) ctx (TySucc ty) = congSucc $ substPastCtx e ctx ty\nsubstPastCtx (TPred e) ctx (TyPred ty) = congPred $ substPastCtx e ctx ty\nsubstPastCtx (TIfz e1 e2 e3) ctx (TyIfz ty1 ty2 ty3) = \n congIfz (substPastCtx e1 ctx ty1)\n (substPastCtx e2 ctx ty2)\n (substPastCtx e3 ctx ty3)\n\n\n-- A less convoluted way of stating the lemma\n-- that is used in the 'TVar' case above:\nsubstVarPastCtx' : (k : Nat) ->\n subst_var x (S k + n) k = TVar k\nsubstVarPastCtx' Z = Refl\nsubstVarPastCtx' (S k) = let ih = substVarPastCtx' k\n in cong {f = \\q => shiftTerm 0 1 q} ih\n\n\n\n-- Shifting and substituting for a variable commute:\nshiftSubstVarComm : (c : Nat) -> (d : Nat) -> (i : Nat) -> \n (x : Term) ->\n (k : Nat) ->\n shiftTerm c d (subst_var x (c+i) k) = subst_var x (c+d+i) (shift c d k)\n--\nshiftSubstVarComm Z Z i x k = shiftTermByZero Z (subst_var x i k)\n--\nshiftSubstVarComm Z (S d) i x k = \n let ih = shiftSubstVarComm Z d i x k\n ih' = cong {f = \\q => shiftTerm Z (S Z) q} ih\n eq = shiftTermTwice Z d (S Z) (subst_var x i k)\n in trans (sym eq) ih' \n--\nshiftSubstVarComm (S c) d i x Z = Refl\n--\nshiftSubstVarComm (S c) d i x (S k) = \n let ih = shiftSubstVarComm c d i x k\n ih' = cong {f = \\q => shiftTerm Z (S Z) q} ih\n eq = shiftTermSwap Z (S Z) c d (subst_var x (c+i) k)\n in trans eq ih'\n\n\n-- Shifting and substituting in a general term 'e' commute:\nshiftTermSubstComm : (c : Nat) -> (d : Nat) -> (i : Nat) -> \n (x : Term) ->\n (e : Term) ->\n shiftTerm c d (subst x (c+i) e) = subst x (c+d+i) (shiftTerm c d e)\n--\nshiftTermSubstComm c d i x (TVar k) = shiftSubstVarComm c d i x k\nshiftTermSubstComm c d i x (TAbs e) = congAbs $ shiftTermSubstComm (S c) d i x e\nshiftTermSubstComm c d i x (TApp e1 e2) = \n congApp (shiftTermSubstComm c d i x e1)\n (shiftTermSubstComm c d i x e2)\nshiftTermSubstComm c d i x (TRec e1 e2 e3) = \n congRec (shiftTermSubstComm c d i x e1)\n (shiftTermSubstComm c d i x e2)\n (shiftTermSubstComm c d i x e3) \nshiftTermSubstComm c d i x TZero = congZero\nshiftTermSubstComm c d i x (TSucc e) = congSucc $ shiftTermSubstComm c d i x e\nshiftTermSubstComm c d i x (TPred e) = congPred $ shiftTermSubstComm c d i x e\nshiftTermSubstComm c d i x (TIfz e1 e2 e3) = \n congIfz (shiftTermSubstComm c d i x e1)\n (shiftTermSubstComm c d i x e2)\n (shiftTermSubstComm c d i x e3) \n\n-- End: SHIFTING AND SUBSTITUTION COMMUTE\n-----------------------------------------\n\n\n\n\n-----------------------------------\n-- Begin: SWAPPING OF SUBSTITUTIONS\n\n-- Substitution in a shifted variable, below the \n-- cutoff 'c' of the 'shift' operation, preserves\n-- the variable (modulo shifting):\nsubstVarBelowShift : (c : Nat) -> (n : Nat) ->\n (k : Nat) ->\n (x : Term) ->\n subst_var x c (shift c (S n) k) = TVar (shift c n k)\nsubstVarBelowShift Z n k x = Refl\nsubstVarBelowShift (S c) n Z x = Refl\nsubstVarBelowShift (S c) n (S k) x = \n let ih = substVarBelowShift c n k x\n in cong {f = shiftTerm Z (S Z)} ih\n\n\n-- Substitution in a shifted term, below the \n-- cutoff 'c' of the 'shift' operation, preserves\n-- the term (modulo shifting):\nsubstBelowShiftTerm : (c : Nat) -> (n : Nat) ->\n (e : Term) ->\n (x : Term) ->\n subst x c (shiftTerm c (S n) e) = shiftTerm c n e\nsubstBelowShiftTerm c n (TVar i) x = substVarBelowShift c n i x\nsubstBelowShiftTerm c n (TAbs e) x = congAbs $ substBelowShiftTerm (S c) n e x\nsubstBelowShiftTerm c n (TApp e1 e2) x = \n congApp (substBelowShiftTerm c n e1 x) \n (substBelowShiftTerm c n e2 x)\nsubstBelowShiftTerm c n (TRec e1 e2 e3) x = \n congRec (substBelowShiftTerm c n e1 x)\n (substBelowShiftTerm c n e2 x)\n (substBelowShiftTerm c n e3 x)\nsubstBelowShiftTerm c n TZero x = Refl\nsubstBelowShiftTerm c n (TSucc e) x = cong $ substBelowShiftTerm c n e x\nsubstBelowShiftTerm c n (TPred e) x = cong $ substBelowShiftTerm c n e x\nsubstBelowShiftTerm c n (TIfz e1 e2 e3) x = \n congIfz (substBelowShiftTerm c n e1 x)\n (substBelowShiftTerm c n e2 x)\n (substBelowShiftTerm c n e3 x)\n\n\n\n\n-- Swapping substitutions in the variable with\n-- de Bruijn index 'k' does not affect the result:\n-- (Note that the typing for 'x' in the empty context\n-- ensures that there are no free variables in 'x',\n-- which could otherwise be affected by the second\n-- substitution of 'y' on the left-hand side of the\n-- equation in the conclusion of the lemma.)\nsubstVarSwap : (k : Nat) -> \n (i : Nat) ->\n (x : Term) -> (y : Term) ->\n (Typing [] x t) ->\n subst y i (subst_var x i k) = subst x i (subst_var y (S i) k)\n--\nsubstVarSwap Z Z x y tyx = substPastCtx x _ tyx {n=0}\n--\nsubstVarSwap Z (S i) x y tyx = Refl\n--\nsubstVarSwap (S k) Z x y tyx = \n case k of\n Z => let eq1 = substBelowShiftTerm Z Z y x\n eq2 = shiftTermByZero Z y\n in sym (trans eq1 eq2)\n (S _) => Refl\n--\nsubstVarSwap (S k) (S i) x y tyx = \n let ih = substVarSwap k i x y tyx\n ih' = cong {f = shiftTerm Z (S Z)} ih\n eq1 = shiftTermSubstComm Z (S Z) i y (subst_var x i k)\n eq2 = trans (sym eq1) ih'\n eq3 = shiftTermSubstComm Z (S Z) i x (subst_var y (S i) k)\n in trans eq2 eq3\n\n\n-- Swapping the order of two substitutions at adjacent\n-- de Bruijn indices (indices 'i' and 'S i') preserves\n-- the result:\n-- (See the comment immediately before the previous\n-- lemma for an explanation of why the typing of 'x'\n-- in the empty context is needed.)\nsubstSwap : (e : Term) ->\n (i : Nat) -> \n (x : Term) -> (y : Term) ->\n Typing [] x t ->\n subst y i (subst x i e) = subst x i (subst y (S i) e)\n--\nsubstSwap (TVar k) i x y tyx = substVarSwap k i x y tyx\nsubstSwap (TAbs e) i x y tyx = congAbs $ substSwap e (S i) x y tyx\nsubstSwap (TApp e1 e2) i x y tyx = \n congApp (substSwap e1 i x y tyx)\n (substSwap e2 i x y tyx)\nsubstSwap (TRec e1 e2 e3) i x y tyx =\n congRec (substSwap e1 i x y tyx)\n (substSwap e2 i x y tyx)\n (substSwap e3 i x y tyx)\nsubstSwap TZero i x y tyx = Refl\nsubstSwap (TSucc e) i x y tyx = congSucc $ substSwap e i x y tyx\nsubstSwap (TPred e) i x y tyx = congPred $ substSwap e i x y tyx\nsubstSwap (TIfz e1 e2 e3) i x y tyx =\n congIfz (substSwap e1 i x y tyx)\n (substSwap e2 i x y tyx)\n (substSwap e3 i x y tyx)\n\n-- End: SWAPPING OF SUBSTITUTIONS\n---------------------------------\n\n\n\n\n\n\n\n\n\n", "meta": {"hexsha": "01b4d6a37d614d54039f3b8b917ad2d75f3c71cc", "size": 18527, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "totality/src/SubstLemmas.idr", "max_stars_repo_name": "normanrink/PCF", "max_stars_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "totality/src/SubstLemmas.idr", "max_issues_repo_name": "normanrink/PCF", "max_issues_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "totality/src/SubstLemmas.idr", "max_forks_repo_name": "normanrink/PCF", "max_forks_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.1150097466, "max_line_length": 93, "alphanum_fraction": 0.5991256005, "num_tokens": 6350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.5268401086697444}} {"text": "module Examples.AuthorityLattice\n\nimport public DepSec.Lattice\n\n%access public export\n%default total\n\ndata Principal : Type where\n Top : Principal\n Alice : Principal\n Bob : Principal\n Chuck : Principal\n Bot : Principal\n\nimplementation JoinSemilattice Principal where\n join Top b = Top\n join Alice Top =Top\n join Alice Alice = Alice\n join Alice Bob = Top\n join Alice Chuck = Top\n join Alice Bot = Alice\n join Bob Top = Top\n join Bob Alice = Top\n join Bob Bob = Bob\n join Bob Chuck = Top\n join Bob Bot = Bob\n join Chuck Top = Top\n join Chuck Alice = Top\n join Chuck Bob = Top\n join Chuck Chuck = Chuck\n join Chuck Bot = Chuck\n join Bot b = b\n\n associative Top b c = Refl\n associative Alice Top c = Refl\n associative Alice Alice Top = Refl\n associative Alice Alice Alice = Refl\n associative Alice Alice Bob = Refl\n associative Alice Alice Chuck = Refl\n associative Alice Alice Bot = Refl\n associative Alice Bob Top = Refl\n associative Alice Bob Alice = Refl\n associative Alice Bob Bob = Refl\n associative Alice Bob Chuck = Refl\n associative Alice Bob Bot = Refl\n associative Alice Chuck Top = Refl\n associative Alice Chuck Alice = Refl\n associative Alice Chuck Bob = Refl\n associative Alice Chuck Chuck = Refl\n associative Alice Chuck Bot = Refl\n associative Alice Bot c = Refl\n associative Bob Top c = Refl\n associative Bob Alice Top = Refl\n associative Bob Alice Alice = Refl\n associative Bob Alice Bob = Refl\n associative Bob Alice Chuck = Refl\n associative Bob Alice Bot = Refl\n associative Bob Bob Top = Refl\n associative Bob Bob Alice = Refl\n associative Bob Bob Bob = Refl\n associative Bob Bob Chuck = Refl\n associative Bob Bob Bot = Refl\n associative Bob Chuck Top = Refl\n associative Bob Chuck Alice = Refl\n associative Bob Chuck Bob = Refl\n associative Bob Chuck Chuck = Refl\n associative Bob Chuck Bot = Refl\n associative Bob Bot c = Refl\n associative Chuck Top c = Refl\n associative Chuck Alice Top = Refl\n associative Chuck Alice Alice = Refl\n associative Chuck Alice Bob = Refl\n associative Chuck Alice Chuck = Refl\n associative Chuck Alice Bot = Refl\n associative Chuck Bob Top = Refl\n associative Chuck Bob Alice = Refl\n associative Chuck Bob Bob = Refl\n associative Chuck Bob Chuck = Refl\n associative Chuck Bob Bot = Refl\n associative Chuck Chuck Top = Refl\n associative Chuck Chuck Alice = Refl\n associative Chuck Chuck Bob = Refl\n associative Chuck Chuck Chuck = Refl\n associative Chuck Chuck Bot = Refl\n associative Chuck Bot c = Refl\n associative Bot b c = Refl\n\n commutative Top Top = Refl\n commutative Top Alice = Refl\n commutative Top Bob = Refl\n commutative Top Chuck = Refl\n commutative Top Bot = Refl\n commutative Alice Top = Refl\n commutative Alice Alice = Refl\n commutative Alice Bob = Refl\n commutative Alice Chuck = Refl\n commutative Alice Bot = Refl\n commutative Bob Top = Refl\n commutative Bob Alice = Refl\n commutative Bob Bob = Refl\n commutative Bob Chuck = Refl\n commutative Bob Bot = Refl\n commutative Chuck Top = Refl\n commutative Chuck Alice = Refl\n commutative Chuck Bob = Refl\n commutative Chuck Chuck = Refl\n commutative Chuck Bot = Refl\n commutative Bot Top = Refl\n commutative Bot Alice = Refl\n commutative Bot Bob = Refl\n commutative Bot Chuck = Refl\n commutative Bot Bot = Refl\n\n idempotent Top = Refl\n idempotent Alice = Refl\n idempotent Bob = Refl\n idempotent Chuck = Refl\n idempotent Bot = Refl\n", "meta": {"hexsha": "80b4d82ede37e577ee582e140488d7090ebc376a", "size": 3447, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Examples/AuthorityLattice.idr", "max_stars_repo_name": "simongregersen/DepSec", "max_stars_repo_head_hexsha": "10e0419acbe690c460df509d0cb9f4690867422c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2019-08-25T15:16:34.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T11:10:20.000Z", "max_issues_repo_path": "Examples/AuthorityLattice.idr", "max_issues_repo_name": "simongregersen/DepSec", "max_issues_repo_head_hexsha": "10e0419acbe690c460df509d0cb9f4690867422c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Examples/AuthorityLattice.idr", "max_forks_repo_name": "simongregersen/DepSec", "max_forks_repo_head_hexsha": "10e0419acbe690c460df509d0cb9f4690867422c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.9663865546, "max_line_length": 46, "alphanum_fraction": 0.7365825355, "num_tokens": 953, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887588052782737, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.5267376593035156}} {"text": "||| Algebra: The interface to the modules of 'algebra': a representation of\n||| several basic algebraic structures (e.g., groups, rings, vector spaces) as\n||| Idris datatypes (axioms fully enforced).\n|||\n||| Mathematically, the idea of an algebraic structure is quite simple. Consider\n||| (a) the set of integers \\\\(\\mathbb{Z}\\\\), (b) two of the most basic\n||| functions on it, \\\\(+: \\mathbb{Z}^2 \\to \\mathbb{Z} \\\\) and\n||| \\\\(\\cdot: \\mathbb{Z}^2 \\to \\mathbb{Z}\\\\), and (c) two unique elements of it,\n||| \\\\(0\\\\) and \\\\(1\\\\). There are various obvious properties that universally\n||| hold; e.g.:\n|||\n||| * \\\\(x+(y+z) = (x+y)+z\\\\), and \\\\(x\\cdot (y\\cdot z) = (x\\cdot y) \\cdot z\\\\)\n||| * \\\\(x+y= y+x\\\\), and \\\\(x\\cdot y = y \\cdot x\\\\)\n||| * \\\\(x+0 = x \\cdot 1 = x \\\\)\n||| * \\\\(\\exists~y\\in \\mathbb{Z} [ x+y = 0 ]\\\\)\n||| * \\\\(x \\cdot (y+z) = x \\cdot y + x \\cdot z\\\\)\n|||\n||| (Unquantified variables are implicitly quantified over the domain of\n||| discourse, \\\\(\\mathbb{Z}\\\\).) These properties are referred to,\n||| respectively, as **associativity**, **commutativity**, **identities**,\n||| **additive inverses**, and **dsitributivity of (multiplication over\n||| addition)**. There are various things to note. Plenty of other sets satisfy\n||| these laws; for example, the rational numbers, or the real numbers, or the\n||| complex numbers. Note also that, say, the irrational numbers do *not*\n||| satisfy these properties; \\\\(pi + (1-\\pi)\\\\) is rational, and so \\\\(+\\\\)\n||| isn't even a binary function over the irrationals! Finally, note the\n||| asymmetry in the fourth law, an asymmetry not present in the others. This is\n||| necessary, as the following property (referred to as **multiplicative\n||| inverses**) does *not* hold:\n|||\n||| * \\\\(\\exists y \\in \\mathbb{Z} [ x \\cdot y = 1 ]\\\\)\n|||\n||| While \\\\(2\\\\), for example, *does* have a multiplicative inverse among the\n||| *rationals*, it doesn't when we restrict our attention to the integers. (In\n||| fact, not even the rational numbers satisfy the above law, because \\\\(0\\\\)\n||| does not have a multiplicative inverse. After modifying the law to account\n||| for that special case, however, the rationals do satisfy it, while the\n||| integers still don't.)\n|||\n||| So, was the point of all this? All we did was consider some numbers that\n||| everyone is familiar with and mention some elementary properties of them.\n||| How does that lead to any interesting mathematical questions? Well, the key\n||| idea, the crucial motivating question of abstract algebra, is the following:\n|||\n||| __*What happens when we go in the other direction?*__\n|||\n||| That is, what happens when we *start* with a list of properties, then ask\n||| what sorts of things satisfy it? The answers to this question are more\n||| diverse than you may expect. For example, in addition to the integers and\n||| its extensions, other more esoteric sets satisfy the above laws. E.g., the\n||| set of integers modulo five, \\\\(\\mathbb{Z}\\_5 = \\left\\\\{\\overline{0},\n||| \\overline{1}, \\overline{2}, \\overline{3}, \\overline{4}\\right\\\\}\\\\). In the\n||| set, to calculate the \\\"sum\\\" of two elements, we calculate their usual sum,\n||| then take that modulo 5 (that is, the remainder when dividing by 5; the\n||| modulo operation is essentially a generalization of the concept of even and\n||| odd numbers to divisibilities other than by 2); similarly with the product.\n||| Thus, for example, \\\\(\\overline{4} + \\overline{3} = \\overline{2}\\\\). A\n||| similar line of reasoning indicates that additive inverses exist\\-\\-\\-in\n||| fact, so do multiplicative inverses, at least for non-\\\\(0\\\\) elements!\n||| Observe:\n|||\n||| * \\\\(\\overline{1} \\cdot \\overline{1} = \\overline{1}\\\\)\n||| * \\\\(\\overline{2} \\cdot \\overline{3} = \\overline{1}\\\\)\n||| * \\\\(\\overline{3} \\cdot \\overline{2} = \\overline{1}\\\\)\n||| * \\\\(\\overline{4} \\cdot \\overline{4} = \\overline{1}\\\\)\n|||\n||| However, if we look at the integers modulo 6 (\\\\(\\mathbb{Z}\\_6\\\\)), we find\n||| that multiplicative inverses do *not* always exist; only \\\\(\\overline{1}\\\\)\n||| and \\\\(\\overline\\{\\-1} = \\overline{5}\\\\) are invertible. (Try it!) In fact,\n||| the integers modulo n, \\\\(\\mathbb{Z}\\_n\\\\), satisfy the weakened (i.e.,\n||| ignoring \\\\(0\\\\)) multiplicative inverse law if and only if \\\\(n\\\\) is\n||| prime.\n|||\n||| These do not exhaust the possibilities\\-\\-\\-not even close!\\-\\-\\-but it should\n||| be enough to give a taste of what abstract algebra is all about. You start\n||| with some set with defined operations (a pairing known as a \\\"structure\\\")\n||| that you are familiar with, you distill that structure down to its most\n||| basic and fundamental properties, and then you look at what sorts of things\n||| satisfy those properties and what those properties alone entail. This allows\n||| you to generalize familiar structures to more abstract ideas\\-\\-\\-the\n||| original motivating structure becomes just a special case of a more general\n||| property, and seemingly disparate things suddenly become two special cases\n||| of a more general idea.\n|||\n||| Note that in the process of generalization, we choose to \\\"forget\\\" any\n||| auxiliary properties of the motivating structure. That is, the set of\n||| objects, the binary functions \\\\(+\\\\) and \\\\(\\cdot\\\\), and the privilleged\n||| elements \\\\(0\\\\) and \\\\(1\\\\), are not necessarily numbers, addition,\n||| multiplication, zero, or one (respectively)! They can be any mathematical\n||| object (that is, any concept that can be precisely defined) satisfying the\n||| list of properties above. In other words, they are *like* numbers with\n||| respect to the most basic qualities of them, but they may in fact be\n||| completely different!\n|||\n||| Thus, using the axioms as a starting point, one can ask which properties are\n||| entailed by them, and which properties will differ between different\n||| implementations of the axioms. What are the necessary and sufficient\n||| conditions for various additional facts? E.g., does it follow from the laws\n||| above that every element has a unique factorization? Among the motivating\n||| structure of the integers this was true (a fact known as the Fundamental\n||| Theorem of Arithmetic); in general, though, it is false! The question then\n||| becomes how to further classify the space of implementations\\-\\-\\-what's the\n||| simplest way to divide those that do always admit a unique factorization and\n||| those that don't? These are the kinds of questions that the framework of\n||| algebraic structures allows you to ask.\n|||\n||| The laws given above define a ring; that is, any set (with the two defined\n||| binary operations over it, as well as the two distinguished elements (which\n||| can be thought of as nullary operations for uniformity)) satisfying the\n||| above list of properties is known as a __ring__. The laws are called the\n||| __ring axioms__. __Ring theory__ is the branch of math studying rings, how\n||| they relate to each other (namely, via __ring homomorphisms__), and how they\n||| relate to other mathematical objects. Rings are not the only algebraic\n||| structure; there are many, many more, and this package defines a few of the\n||| more important ones as Idris records, as well as some members of that type.\n||| Each module contains in its documentation an overview of that algebraic\n||| structure and some interesting properties of them that make them worth\n||| studying.\n|||\n||| To create a term of an algebraic structure's type, one must not only provide\n||| the sets and operations with the proper signatures, but also provide proofs\n||| of the axioms of that algebraic structure. To see how this works, you might\n||| want to take a look at `Algebra.Group`.\nmodule Algebra\n\nimport Algebra.Magma\n\n%default total\n\n||| If one attempts to define both the Question and the Answer, the project will\n||| fail to typecheck.\nexport\nAnswer : Integer\nAnswer = 42\n", "meta": {"hexsha": "e4a425010c372b28b48376ff8fa3d99d99a98fb6", "size": 7829, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Algebra.idr", "max_stars_repo_name": "greatBigDot/algebra", "max_stars_repo_head_hexsha": "87ba6c9672d81dc60c9da14a3b08cc548a25c228", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Algebra.idr", "max_issues_repo_name": "greatBigDot/algebra", "max_issues_repo_head_hexsha": "87ba6c9672d81dc60c9da14a3b08cc548a25c228", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Algebra.idr", "max_forks_repo_name": "greatBigDot/algebra", "max_forks_repo_head_hexsha": "87ba6c9672d81dc60c9da14a3b08cc548a25c228", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 57.9925925926, "max_line_length": 82, "alphanum_fraction": 0.6981734577, "num_tokens": 2151, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6477982179521105, "lm_q2_score": 0.8128673133042217, "lm_q1q2_score": 0.5265739969899946}} {"text": "module Package\n\ndata Version : Type where\n V : (major : Nat) -> (minor : Nat) -> (patch : Nat) -> Version\n\nEq Version where\n (V a b c) == (V a' b' c') = (a == a') && (b == b') && (c == c')\n\nOrd Version where\n compare (V a b c) (V a' b' c') = if a > a' then GT else\n if a == a' && b > b' then GT else\n if a == a' && b == b' && c > c' then GT else\n if a == a' && b == b' && c == c' then EQ else LT\n\nShow Version where\n show (V a b c) = \"version \" ++ show a ++ \".\" ++ show b ++ \".\" ++ show c\n\ndata PkgConstraint : Type where\n Any : PkgConstraint\n Up : Version -> PkgConstraint\n Down : Version -> PkgConstraint\n Exactly : Version -> PkgConstraint\n Between : Version -> Version -> PkgConstraint\n\nShow PkgConstraint where\n show Any = \"\"\n show (Up v) = \"(>= \" ++ show v ++ \")\"\n show (Down v) = \"(<= \" ++ show v ++ \")\"\n show (Exactly v) = \"(= \" ++ show v ++ \")\"\n show (Between v w) = \"(>= \" ++ show v ++ \", <=\" ++ show w ++ \")\"\n\ninRange : Version -> PkgConstraint -> Bool\ninRange v Any = True\ninRange v (Up w) = v >= w\ninRange v (Down w) = v <= w\ninRange v (Exactly w) = v == w\ninRange v (Between w x) = w <= v && v <= x\n\ndata Dep : Type where\n Dependency : String -> PkgConstraint -> List Dep -> Dep\n\nShow Dep where\n show (Dependency s v xs) = \"Package \" ++ s ++ \" \" ++ show v\n\n[depverbose] Show Dep where\n show (Dependency s v xs) = \"Package \" ++ s ++ \" \" ++ show v ++ \" depends on: \" ++ show xs\n\ndata Hash = None\n | Md5 String\n | Sha1 String\n | Blake2 String\n\nrecord Pkg where\n constructor Package\n pname : String\n version : Version\n compile, install, uninstall : String\n src : String\n hash : Hash\n deps : List Dep -- Should packages still store their dependencies?\n\nEq Pkg where\n p == p' = pname p == pname p' && version p == version p'\n\nOrd Pkg where\n compare p p' = if pname p > pname p' then GT else\n if pname p < pname p' then LT else\n if version p > version p' then GT else\n if version p < version p' then LT else EQ\n\nShow Pkg where\n show p = \"Package \" ++ pname p ++ \" \" ++ (show $ version p)\n\n[pkgverbose] Show Pkg where\n show p = \"Package \" ++ pname p ++ \" \" ++ (show $ version p) ++ \" depends on: \" ++ show (deps p)\n\nqueryPkg : String -> PkgConstraint -> List Pkg -> Maybe Pkg\nqueryPkg query constraint srcs = head' matches\n where matches = filter (\\pkg => pname pkg == query && inRange (version pkg) constraint) $ reverse $ sort srcs -- This is slow, will bottleneck\n", "meta": {"hexsha": "2d7ed45ca91c51184fbf5c944a78454bfd4d051f", "size": 2639, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Package.idr", "max_stars_repo_name": "nv-vn/Anvil", "max_stars_repo_head_hexsha": "751b3eb5399e40c88c7e6f2e3850523564f83876", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2016-08-15T17:01:49.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-13T01:48:11.000Z", "max_issues_repo_path": "src/Package.idr", "max_issues_repo_name": "nv-vn/Anvil", "max_issues_repo_head_hexsha": "751b3eb5399e40c88c7e6f2e3850523564f83876", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Package.idr", "max_forks_repo_name": "nv-vn/Anvil", "max_forks_repo_head_hexsha": "751b3eb5399e40c88c7e6f2e3850523564f83876", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.9875, "max_line_length": 144, "alphanum_fraction": 0.5365668814, "num_tokens": 772, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430645886584, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.5264545361918409}} {"text": "module VectFilter\n\nimport Data.Vect\n\nfilter' : (a -> Bool) -> Vect n a -> (m ** Vect m a)\nfilter' pred [] = (0 ** [])\nfilter' pred (x :: xs) =\n let (_ ** rek) = filter' pred xs\n in if pred x then (_ ** x::rek) else (_ ** rek)\n\nbeispiel : (m ** Vect m Integer)\nbeispiel = filter' (\\x => (x `mod` 2) == 0) [1,2,3,4,5,6,7,8,9,10]\n", "meta": {"hexsha": "2c8bc12aa785ac514bf178bf78a7e4ee73f510b9", "size": 329, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Beispiele/VectFilter.idr", "max_stars_repo_name": "CarstenKoenig/DOS2016_IdrisWorkshop", "max_stars_repo_head_hexsha": "f329b584e5ae434f0c52564bf75710070cc247da", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-10-14T07:30:59.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-15T09:50:24.000Z", "max_issues_repo_path": "Beispiele/VectFilter.idr", "max_issues_repo_name": "CarstenKoenig/DOS2016_IdrisWorkshop", "max_issues_repo_head_hexsha": "f329b584e5ae434f0c52564bf75710070cc247da", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Beispiele/VectFilter.idr", "max_forks_repo_name": "CarstenKoenig/DOS2016_IdrisWorkshop", "max_forks_repo_head_hexsha": "f329b584e5ae434f0c52564bf75710070cc247da", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.3076923077, "max_line_length": 66, "alphanum_fraction": 0.5349544073, "num_tokens": 127, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5263385159936216}} {"text": "-- exercises in \"Type-Driven Development with Idris\"\n-- chapter 13, section 1\n\n-- check that all functions are total\n%default total\n\nnamespace exercise1\n\n data DoorState = DoorClosed | DoorOpen\n\n data DoorCmd : Type ->\n DoorState ->\n DoorState ->\n Type where\n Open : DoorCmd () DoorClosed DoorOpen\n Close : DoorCmd () DoorOpen DoorClosed\n RingBell : DoorCmd () state state\n Pure : ty -> DoorCmd ty state state\n (>>=) : DoorCmd a state1 state2 ->\n (a -> DoorCmd b state2 state3) ->\n DoorCmd b state1 state3\n\n doorProg : DoorCmd () DoorClosed DoorClosed\n doorProg = do RingBell\n Open\n RingBell\n Close\n\nnamespace exercise2\n\n data GuessCmd : Type -> Nat -> Nat -> Type where\n Try : Integer -> GuessCmd Ordering (S k) (k)\n Pure : ty -> GuessCmd ty state state\n (>>=) : GuessCmd a state1 state2 ->\n (a -> GuessCmd b state2 state3) ->\n GuessCmd b state1 state3\n\n threeGuesses : GuessCmd () 3 0\n threeGuesses = do Try 10\n Try 20\n Try 15\n Pure ()\n\n -- noGuesses : GuessCmd () 0 0\n -- noGuesses = do Try 10\n -- Pure ()\n\nnamespace exercise3\n\n data Matter = Solid | Liquid | Gas\n\n data MatterCmd : Type -> Matter -> Matter -> Type where\n Melt : MatterCmd () Solid Liquid\n Boil : MatterCmd () Liquid Gas\n Condense : MatterCmd () Gas Liquid\n Freeze : MatterCmd () Liquid Solid\n Pure : ty -> MatterCmd ty state state\n (>>=) : MatterCmd a state1 state2 ->\n (a -> MatterCmd b state2 state3) ->\n MatterCmd b state1 state3\n\n iceSteam : MatterCmd () Solid Gas\n iceSteam = do Melt\n Boil\n\n steamIce : MatterCmd () Gas Solid\n steamIce = do Condense\n Freeze\n\n -- overMelt : MatterCmd () Solid Gas\n -- overMelt = do Melt\n -- Melt\n", "meta": {"hexsha": "9c7c3e61f2ccef2259ae64ca4b547582c8774f09", "size": 2028, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter13/exercises_1.idr", "max_stars_repo_name": "pascalpoizat/idris-book", "max_stars_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-08-16T00:58:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T01:07:37.000Z", "max_issues_repo_path": "chapter13/exercises_1.idr", "max_issues_repo_name": "pascalpoizat/idris-book", "max_issues_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter13/exercises_1.idr", "max_forks_repo_name": "pascalpoizat/idris-book", "max_forks_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-23T03:15:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-23T03:15:39.000Z", "avg_line_length": 27.7808219178, "max_line_length": 57, "alphanum_fraction": 0.541913215, "num_tokens": 528, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.525848113833779}} {"text": "module HOF\n\n%default total\n\ntwice : (a -> a) -> a -> a\ntwice f x = f (f x)\n\nShape : Type\nrotate : Shape -> Shape\n\ndouble : Num ty => ty -> ty\ndouble x = x + x\n\nquadruple : Num ty => ty -> ty\nquadruple = twice double\n\nturnAround : Shape -> Shape\nturnAround = twice rotate\n", "meta": {"hexsha": "b57f1b9622d5b4fe4928f40b11173d3cc7df761e", "size": 271, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter2/HOF.idr", "max_stars_repo_name": "timmyjose-study/tdd-with-idris", "max_stars_repo_head_hexsha": "be2cd6fc4bbcd58cb4e14ed1e22c9cc99aade4d0", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chapter2/HOF.idr", "max_issues_repo_name": "timmyjose-study/tdd-with-idris", "max_issues_repo_head_hexsha": "be2cd6fc4bbcd58cb4e14ed1e22c9cc99aade4d0", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter2/HOF.idr", "max_forks_repo_name": "timmyjose-study/tdd-with-idris", "max_forks_repo_head_hexsha": "be2cd6fc4bbcd58cb4e14ed1e22c9cc99aade4d0", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.2631578947, "max_line_length": 30, "alphanum_fraction": 0.6199261993, "num_tokens": 88, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5253893621280497}} {"text": "module Toolkit.Data.List.Occurs.Does\n\nimport Decidable.Equality\n\nimport Data.Nat\n\nimport Toolkit.Decidable.Informative\n\nimport public Toolkit.Data.List.Occurs.Error\n\n\n%default total\n\nnamespace Exactly\n public export\n data Occurs : (type : Type)\n -> (p : type -> Type)\n -> (xs : List type)\n -> (cy : Nat)\n -> Type\n where\n End : Occurs type p Nil Z\n\n Yes : (holds : p x)\n -> (rest : Occurs type p xs cy)\n -> Occurs type p (x::xs) (S cy)\n\n No : (nope : Not (p x))\n -> (rest : Occurs type p xs cy)\n -> Occurs type p (x::xs) cy\n\n export\n Uninhabited (Occurs type p Nil (S x)) where\n uninhabited End impossible\n uninhabited (Yes holds rest) impossible\n uninhabited (No nope rest) impossible\n\n namespace Check\n shouldHaveOneMore : (p x)\n -> (Occurs type p xs k -> Void)\n -> Occurs type p (x :: xs) (S k) -> Void\n shouldHaveOneMore prf f (Yes holds rest) = f rest\n shouldHaveOneMore prf f (No nope rest) = nope prf\n\n wrongOccurs : (Occurs type p xs cy -> Void)\n -> (p x -> Void)\n -> Occurs type p (x :: xs) cy -> Void\n wrongOccurs f g (Yes holds rest) = g holds\n wrongOccurs f g (No nope rest) = f rest\n\n namespace Exactly\n export\n occurs : {type : Type}\n -> {p : type -> Type}\n -> (f : (this : type) -> Dec (p this))\n -> (xs : List type)\n -> (cy : Nat)\n -> DecInfo Occurs.Error\n (Occurs type p xs cy)\n occurs f [] Z\n = Yes End\n\n occurs f [] (S k)\n = No (MkError (S k) Z) absurd\n\n occurs f (x :: xs) cy with (f x)\n occurs f (x :: xs) cy | (Yes prf) with (cy)\n occurs f (x :: xs) cy | (Yes prf) | Z\n = No (MkError Z 1)\n (\\(No f x) => f prf)\n\n occurs f (x :: xs) cy | (Yes prf) | (S k) with (occurs f xs k)\n occurs f (x :: xs) cy | (Yes prf) | (S k) | (Yes y)\n = Yes (Yes prf y)\n\n occurs f (x :: xs) cy | (Yes prf) | (S k) | (No msg contra)\n = No (MkError (S k) (S $ found msg))\n (shouldHaveOneMore prf contra)\n\n occurs f (x :: xs) cy | (No contra) with (occurs f xs cy)\n occurs f (x :: xs) cy | (No contra) | (Yes prf)\n = Yes (No contra prf)\n\n occurs f (x :: xs) cy | (No contra) | (No msg g)\n = No (MkError cy (found msg))\n (wrongOccurs g contra)\n\n namespace Discover\n\n namespace Exactly\n export\n occurs : {type : Type}\n -> {p : type -> Type}\n -> (f : (this : type) -> Dec (p this))\n -> (xs : List type)\n -> DPair Nat (Occurs type p xs)\n occurs f []\n = MkDPair 0 End\n occurs f (x :: xs) with (f x)\n occurs f (x :: xs) | (Yes prf) with (Discover.Exactly.occurs f xs)\n occurs f (x :: xs) | (Yes prf) | (MkDPair fst snd)\n = MkDPair (S fst) (Yes prf snd)\n occurs f (x :: xs) | (No contra) with (Discover.Exactly.occurs f xs)\n occurs f (x :: xs) | (No contra) | (MkDPair fst snd)\n = MkDPair fst (No contra snd)\n\nnamespace AtLeast\n\n public export\n data Occurs : (type : Type)\n -> (p : type -> Type)\n -> (xs : List type)\n -> (ym : Nat)\n -> Type\n where\n EndY : (holds : p x) -> AtLeast.Occurs type p (x::xs) (S Z)\n\n Yes : (holds : p x)\n -> (rest : AtLeast.Occurs type p xs cy)\n -> AtLeast.Occurs type p (x::xs) (S cy)\n\n No : (nope : Not (p x))\n -> (rest : AtLeast.Occurs type p xs (S cy))\n -> AtLeast.Occurs type p (x::xs) (S cy)\n\n export\n Uninhabited (AtLeast.Occurs type p Nil (S x)) where\n uninhabited (EndY holds) impossible\n uninhabited (Yes holds rest) impossible\n uninhabited (No nope rest) impossible\n\n export\n Uninhabited (AtLeast.Occurs type p xs Z) where\n uninhabited (EndY holds) impossible\n uninhabited (Yes holds rest) impossible\n uninhabited (No nope rest) impossible\n\n namespace Check\n\n namespace AtLeast\n\n\n shouldBeAtLeastOne : (AtLeast.Occurs type p xs 1 -> Void)\n -> (p x -> Void)\n -> AtLeast.Occurs type p (x :: xs) 1 -> Void\n shouldBeAtLeastOne f g (EndY holds) = g holds\n shouldBeAtLeastOne f g (Yes holds rest) = g holds\n shouldBeAtLeastOne f g (No nope rest) = f rest\n\n shouldBeAtLeastOneMore : (AtLeast.Occurs type p xs (S k) -> Void)\n -> p x\n -> AtLeast.Occurs type p (x :: xs) (S (S k)) -> Void\n shouldBeAtLeastOneMore f y (Yes holds rest) = f rest\n shouldBeAtLeastOneMore f y (No nope rest) = nope y\n\n shouldBeAtLeastN : (AtLeast.Occurs type p xs (S (S k)) -> Void)\n -> (p x -> Void)\n -> AtLeast.Occurs type p (x :: xs) (S (S k)) -> Void\n shouldBeAtLeastN f g (Yes holds rest) = g holds\n shouldBeAtLeastN f g (No nope rest) = f rest\n\n export\n occurs : {type : Type}\n -> {p : type -> Type}\n -> (f : (this : type) -> Dec (p this))\n -> (xs : List type)\n -> (cy : Nat)\n -> DecInfo (Maybe Occurs.Error)\n (AtLeast.Occurs type p xs cy)\n occurs f xs 0\n = No Nothing absurd\n\n occurs f [] (S k)\n = No (Just (MkError (S k) Z))\n absurd\n\n occurs f (x :: xs) (S 0) with (f x)\n occurs f (x :: xs) (S 0) | (Yes prf)\n = Yes (EndY prf)\n\n occurs f (x :: xs) (S 0) | (No contra) with (AtLeast.occurs f xs (S 0))\n occurs f (x :: xs) (S 0) | (No contra) | (Yes prfWhy)\n = Yes (No contra prfWhy)\n\n occurs f (x :: xs) (S 0) | (No contra) | (No msgWhyNot prfWhyNot)\n = No (map ({ expected := 1}) msgWhyNot)\n (shouldBeAtLeastOne prfWhyNot contra)\n\n occurs f (x :: xs) (S (S k)) with (f x)\n occurs f (x :: xs) (S (S k)) | (Yes prf) with (AtLeast.occurs f xs (S k))\n occurs f (x :: xs) (S (S k)) | (Yes prf) | (Yes prfWhy)\n = Yes (Yes prf prfWhy)\n\n occurs f (x :: xs) (S (S k)) | (Yes prf) | (No msgWhyNot prfWhyNot)\n = No (map ({ expected := S (S k), found $= S}) msgWhyNot)\n (shouldBeAtLeastOneMore prfWhyNot prf)\n\n occurs f (x :: xs) (S (S k)) | (No contra) with (AtLeast.occurs f xs (S (S k)))\n occurs f (x :: xs) (S (S k)) | (No contra) | (Yes prfWhy)\n = Yes (No contra prfWhy)\n\n occurs f (x :: xs) (S (S k)) | (No contra) | (No msgWhyNot prfWhyNot)\n = No (map ({ expected := S (S k)}) msgWhyNot)\n (shouldBeAtLeastN prfWhyNot contra)\n\n-- [ EOF ]\n", "meta": {"hexsha": "79a5d6abf48835e2f74bc37978592282208566ea", "size": 7021, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/List/Occurs/Does.idr", "max_stars_repo_name": "gallais/linear-circuits", "max_stars_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2021-11-29T17:20:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T21:41:44.000Z", "max_issues_repo_path": "src/Toolkit/Data/List/Occurs/Does.idr", "max_issues_repo_name": "gallais/linear-circuits", "max_issues_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Toolkit/Data/List/Occurs/Does.idr", "max_forks_repo_name": "gallais/linear-circuits", "max_forks_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-09T19:49:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T19:49:11.000Z", "avg_line_length": 33.9178743961, "max_line_length": 87, "alphanum_fraction": 0.4834069221, "num_tokens": 2131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5253345824174053}} {"text": "module SimpleCatenableDeque\n\nimport CatenableDeque\n\n%default total\n%access private\n\nexport\ndata SimpleCatDeque : (Type -> Type) -> Type -> Type where\n Shallow : d a -> SimpleCatDeque d a\n Deep : d a -> Lazy (SimpleCatDeque d (d a)) -> d a -> SimpleCatDeque d a\n\ntooSmall : Deque d => d a -> Bool\ntooSmall d = isEmpty d || isEmpty (tail d)\n\ndappendL : Deque d => d a {- tooSmall -} -> d a -> d a\ndappendL d1 d2 = if isEmpty d1 then d2 else cons (head d1) d2\n\ndappendR : Deque d => d a -> d a {- tooSmall -} -> d a\ndappendR d1 d2 = if isEmpty d2 then d1 else snoc d1 (head d2)\n\nexport\nDeque d => Deque (SimpleCatDeque d) where\n empty = Shallow empty\n isEmpty (Shallow d) = isEmpty d\n isEmpty _ = False\n\n cons x (Shallow d) = Shallow (cons x d)\n cons x (Deep f m r) = Deep (cons x f) m r\n\n head (Shallow d) = head d\n head (Deep f m r) = head f\n\n tail (Shallow d) = Shallow (tail d)\n tail (Deep f m r) = let f' = tail f in\n if not (tooSmall f') then Deep f' m r\n else if isEmpty m then Shallow (dappendL f' r)\n else Deep (dappendL f' (head m)) (tail m) r\n\n snoc (Shallow d) x = Shallow (snoc d x)\n snoc (Deep f m r) x = Deep f m (snoc r x)\n\n last (Shallow d) = last d\n last (Deep f m r) = last r\n\n init (Shallow d) = Shallow (init d)\n init (Deep f m r) = let r' = init r in\n if not (tooSmall r') then Deep f m r'\n else if isEmpty m then Shallow (dappendR f r')\n else Deep f (init m) (dappendR (last m) r')\n\nexport\nDeque d => CatenableDeque (SimpleCatDeque d) where\n (Shallow d1) ++ (Shallow d2) =\n if tooSmall d1 then Shallow (dappendL d1 d2)\n else if tooSmall d2 then Shallow (dappendR d1 d2)\n else Deep d1 empty d2\n (Shallow d) ++ (Deep f m r) =\n if tooSmall d then Deep (dappendL d f) m r\n else Deep d (cons f m) r\n (Deep f m r) ++ (Shallow d) =\n if tooSmall d then Deep f m (dappendR r d)\n else Deep f (snoc m r) d\n (Deep f1 m1 r1) ++ (Deep f2 m2 r2) =\n let mf = assert_smaller (Deep f1 m1 r2) $ snoc m1 r1\n mr = assert_smaller (Deep f2 m2 r2) $ cons f2 m2\n in Deep f1 (mf ++ mr) r2\n", "meta": {"hexsha": "f0c34ff4add6aedf401d830bc1f3ce8f82cabd00", "size": 2071, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/SimpleCatenableDeque.idr", "max_stars_repo_name": "ska80/idris-okasaki-pfds", "max_stars_repo_head_hexsha": "8e80feba2fdcebdf90136ac6633275c896177c77", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-08T00:55:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-08T00:55:51.000Z", "max_issues_repo_path": "src/SimpleCatenableDeque.idr", "max_issues_repo_name": "ska80/idris-okasaki-pfds", "max_issues_repo_head_hexsha": "8e80feba2fdcebdf90136ac6633275c896177c77", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/SimpleCatenableDeque.idr", "max_forks_repo_name": "ska80/idris-okasaki-pfds", "max_forks_repo_head_hexsha": "8e80feba2fdcebdf90136ac6633275c896177c77", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.4558823529, "max_line_length": 74, "alphanum_fraction": 0.6224046354, "num_tokens": 758, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788995148792, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.5250267867935262}} {"text": "import Data.Nat\nimport Data.Fin\nimport Data.Fin.Extra\nimport Data.Vect\nimport Data.List\nimport Data.List1\n\ninf : Nat\ninf = 1000000\n\ndata Amphipod = A | B | C | D\n\nEq Amphipod where\n A == A = True\n B == B = True\n C == C = True\n D == D = True\n _ == _ = False\n\nenergy : Amphipod -> Nat\nenergy A = 1\nenergy B = 10\nenergy C = 100\nenergy D = 1000\n\nroomOf : Amphipod -> Fin 4\nroomOf A = 0\nroomOf B = 1\nroomOf C = 2\nroomOf D = 3\n\nRoom : Nat -> Type\nRoom n = Vect n (Maybe Amphipod)\n\nroomToHall : Fin 4 -> Fin 11\nroomToHall 0 = 2\nroomToHall 1 = 4\nroomToHall 2 = 6\nroomToHall 3 = 8\n\nrecord State (s : Nat) where\n constructor MkState\n hall : Room 11\n rooms : Vect 4 (Room s)\n energy : Nat\n\nisPod : Amphipod -> Maybe Amphipod -> Bool\nisPod a Nothing = False\nisPod a (Just b) = a == b\n\nisSolved : State n -> Bool\nisSolved (MkState hall [r1,r2,r3,r4] _) =\n all isNothing hall &&\n all (isPod A) r1 &&\n all (isPod B) r2 &&\n all (isPod C) r3 &&\n all (isPod D) r4\n\nvalidPlaces : Vect 7 (Fin 11)\nvalidPlaces = [0,1,3,5,7,9,10]\n\nmoveToHall : State n -> List (State n)\nmoveToHall s = join $ moveFromRoom <$> (forget $ allFins 3)\n where\n getToMove : Fin 4 -> Maybe (Fin n)\n getToMove r = do let room = index r s.rooms\n if any (not . (==) r . roomOf) $ catMaybes $ toList room\n then findIndex isJust room\n else Nothing\n\n pathToHall : Fin 4 -> Fin 11 -> Maybe Nat\n pathToHall r to = do let from = finToNat $ roomToHall r\n let to = finToNat $ to\n let (min, max) = if from > to\n then (to, from)\n else (from + 1, to + 1)\n let dist = minus max min\n if any isJust $ take dist $ drop min $ toList s.hall\n then Nothing\n else Just dist\n\n moveFromRoom : Fin 4 -> List (State n)\n moveFromRoom r = do case getToMove r of\n Nothing => []\n (Just i) => let a = index i $ index r s.rooms\n en = maybe 0 energy a\n ps = catMaybes $ (\\p => (p,) <$> pathToHall r p) <$> toList validPlaces in\n ps <&> \\(p,n) => {\n hall $= replaceAt p a,\n rooms $= updateAt r (replaceAt i Nothing),\n energy $= (+) (en * (n + (finToNat i) + 1))\n } s\n\nmoveToRoom : {n : Nat} -> State n -> List (State n)\nmoveToRoom s = catMaybes $ toList $ moveToRoom' s <$> validPlaces\n where\n pathToRoom : State n -> Fin 11 -> Fin 4 -> Maybe Nat\n pathToRoom s from r = do let to = finToNat $ roomToHall r\n let from = finToNat $ from\n let (min, max) = if from > to\n then (to, from)\n else (from + 1, to + 1)\n let dist = minus max min\n if any isJust $ take dist $ drop min $ toList s.hall\n then Nothing\n else Just dist\n\n moveInRoom : State n -> Fin 11 -> Fin 4 -> Maybe (Fin n)\n moveInRoom s h r = do let room = index r s.rooms\n if all ((==) r . roomOf) $ catMaybes $ toList room\n then do map invFin $ findIndex isNothing $ reverse $ room\n else Nothing\n\n moveToRoom' : State n -> Fin 11 -> Maybe (State n)\n moveToRoom' s p = do a <- index p s.hall\n let r = roomOf a\n toRoom <- pathToRoom s p r\n inRoom <- moveInRoom s p r\n let en = energy a\n pure $ {\n hall $= replaceAt p Nothing,\n rooms $= updateAt r (replaceAt inRoom (Just a)),\n energy $= (+) (en * (toRoom + (finToNat inRoom) + 1))\n } s\n\nsolve : {n : Nat} -> Nat -> State n -> Nat\nsolve m s = if s.energy > m\n then m\n else if isSolved s\n then s.energy\n else let m = foldl solve m (moveToHall s) in\n foldl solve m (moveToRoom s)\n\ninput1 : Vect 4 (Room 2)\ninput1 = [\n [Just D, Just C],\n [Just B, Just A],\n [Just C, Just D],\n [Just A, Just B]\n ]\n\npart1 : State 2 -> IO String\npart1 a = pure $ show $ solve inf a\n\ninput2 : Vect 4 (Room 4)\ninput2 = [\n [Just D, Just D, Just D, Just C],\n [Just B, Just C, Just B, Just A],\n [Just C, Just B, Just A, Just D],\n [Just A, Just A, Just C, Just B]\n ]\n\npart2 : State 4 -> IO String\npart2 a = pure $ show $ solve inf a\n\nmain : IO ()\nmain = do let s1 = MkState (replicate 11 Nothing) input1 0\n part1 s1 >>= putStrLn\n let s2 = MkState (replicate 11 Nothing) input2 0\n part2 s2 >>= putStrLn\n\n", "meta": {"hexsha": "93c923992ab54c3b23381d75f06e967c5a7034d8", "size": 5216, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "23/Main.idr", "max_stars_repo_name": "Olavhaasie/aoc-2021", "max_stars_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "23/Main.idr", "max_issues_repo_name": "Olavhaasie/aoc-2021", "max_issues_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "23/Main.idr", "max_forks_repo_name": "Olavhaasie/aoc-2021", "max_forks_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.1975308642, "max_line_length": 116, "alphanum_fraction": 0.4612730061, "num_tokens": 1423, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772220439509, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.5246109737652768}} {"text": "count : Nat -> Stream Nat\ncount n = n :: count (S n)\n\nbadCount : Nat -> Stream Nat\nbadCount n = n :: map S (badCount n)\n\ndata SP : Type -> Type -> Type where\n Get : (a -> SP a b) -> SP a b\n Put : b -> Inf (SP a b) -> SP a b\n\ncopy : SP a a\ncopy = Get (\\x => Put x copy)\n\nprocess : SP a b -> Stream a -> Stream b\nprocess (Get f) (x :: xs) = process (f x) xs\nprocess (Put b sp) xs = b :: process sp xs\n\nbadProcess : SP a b -> Stream a -> Stream b\nbadProcess (Get f) (x :: xs) = badProcess (f x) xs\nbadProcess (Put b sp) xs = badProcess sp xs\n\ndoubleInt : SP Nat Integer\ndoubleInt = Get (\\x => Put (the Integer (cast x))\n (Put (the Integer (cast x) * 2) doubleInt))\n\ncountStream : Nat -> Stream Nat\ncountStream x = x :: countStream (x + 1)\n\nmain : IO ()\nmain = printLn (take 10 (process doubleInt (countStream 1)))\n", "meta": {"hexsha": "05d1e043f8808b75c9264f0845d03a49ae998874", "size": 836, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/chez/chez001/Total.idr", "max_stars_repo_name": "boxfire/rapid", "max_stars_repo_head_hexsha": "91f012caad854dc454cef0375b49bcf9e1af20c7", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "tests/chez/chez001/Total.idr", "max_issues_repo_name": "boxfire/rapid", "max_issues_repo_head_hexsha": "91f012caad854dc454cef0375b49bcf9e1af20c7", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "tests/chez/chez001/Total.idr", "max_forks_repo_name": "boxfire/rapid", "max_forks_repo_head_hexsha": "91f012caad854dc454cef0375b49bcf9e1af20c7", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 26.9677419355, "max_line_length": 67, "alphanum_fraction": 0.5933014354, "num_tokens": 269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6654105521116445, "lm_q1q2_score": 0.5242977319187268}} {"text": "import Data.List\nimport Data.Vect\nimport Data.String.Parser\n\nimport System.File\n\nVec3 : Type\nVec3 = Vect 3 Integer\n\nminusV : Vec3 -> Vec3 -> Vec3\nminusV [x1,y1,z1] [x2,y2,z2] = [x1-x2,y1-y2,z1-z2]\n\nmaxV : Vec3 -> Vec3 -> Vec3\nmaxV [x1,y1,z1] [x2,y2,z2] = [max x1 x2, max y1 y2, max z1 z2]\n\nminV : Vec3 -> Vec3 -> Vec3\nminV [x1,y1,z1] [x2,y2,z2] = [min x1 x2, min y1 y2, min z1 z2]\n\nCube : Type\nCube = (Vec3, Vec3)\n\nisCorrect : Cube -> Maybe Cube\nisCorrect c@([x1,y1,z1], [x2,y2,z2]) =\n if x1 < x2 && y1 < y2 && z1 < z2\n then Just c\n else Nothing\nintersect : Cube -> Cube -> Maybe Cube\nintersect (min1, max1) (min2, max2) = isCorrect (maxV min1 min2, minV max1 max2)\n\nvolume : Cube -> Integer\nvolume (min, max) = product $ (abs <$> minusV max min)\n\ndata Command = On Cube | Off Cube\n\nisOn : Command -> Bool\nisOn (On _) = True\nisOn _ = False\n\ninvert : Command -> Command\ninvert (On c) = Off c\ninvert (Off c) = On c\n\ngetCube : Command -> Cube\ngetCube (On c) = c\ngetCube (Off c) = c\n\nInput : Type\nInput = List Command\n\nrangeParser : Parser (Integer, Integer)\nrangeParser = do skip letter\n skip $ char '='\n min <- integer\n token \"..\"\n max <- integer\n pure (min, max + 1)\n\ncommandParser : Parser Command\ncommandParser = do cmd <- (token \"on\" $> On) <|> (token \"off\" $> Off)\n [(xmin, xmax),(ymin,ymax),(zmin,zmax)] <- commaSep rangeParser\n | _ => fail \"no ranges\"\n pure $ cmd ([xmin,ymin,zmin],[xmax,ymax,zmax])\n\nparser : Parser Input\nparser = some (commandParser <* spaces)\n\nCubes : Type\nCubes = List Cube\n\naddCube' : List Command -> Cube -> (Integer, List Command)\naddCube' [] c = (0, [])\naddCube' ((On c) :: cs) b = case intersect b c of\n Nothing => addCube' cs b\n (Just overlap) => let (v, os) = addCube' cs b in\n (v - volume overlap, (Off overlap) :: os)\naddCube' ((Off c) :: cs) b = case intersect b c of\n Nothing => addCube' cs b\n (Just overlap) => let (v, os) = addCube' cs b in\n (v + volume overlap, (On overlap) :: os)\n\naddCube : List Command -> Cube -> (Integer, List Command)\naddCube cs c = case addCube' cs c of\n (vol, []) => (vol, cs)\n (vol, os) => (vol, os ++ cs)\n\ndoCmd : (Integer, List Command) -> Command -> (Integer, List Command)\ndoCmd (vol, cs) c@(On b) = let (v, cs) = addCube cs b in\n (v + vol + volume b, c :: cs)\ndoCmd (vol, cs) (Off b) = mapFst ((+) vol) $ addCube cs b\n\ncmdInBounds : Cube -> Command -> Maybe Command\ncmdInBounds b (On c) = On <$> intersect b c\ncmdInBounds b (Off c) = Off <$> intersect b c\n\npart1 : Input -> IO String\npart1 a = let bound : Cube = ([-50,-50,-50], [51,51,51])\n cs = catMaybes $ cmdInBounds bound <$> a in\n pure $ show $ fst $ foldl doCmd (0, []) cs\n\npart2 : Input -> IO String\npart2 a = pure $ show $ fst $ foldl doCmd (0, []) a\n\nmain : IO ()\nmain = do Right input <- readFile \"input.txt\"\n | Left err => printLn err\n Right (a, _) <- pure $ parse parser input\n | Left err => printLn err\n part1 a >>= putStrLn\n part2 a >>= putStrLn\n\n", "meta": {"hexsha": "e88b21082e306418efb775d1a8dc47148a8c1396", "size": 3409, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "22/Main.idr", "max_stars_repo_name": "Olavhaasie/aoc-2021", "max_stars_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "22/Main.idr", "max_issues_repo_name": "Olavhaasie/aoc-2021", "max_issues_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "22/Main.idr", "max_forks_repo_name": "Olavhaasie/aoc-2021", "max_forks_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.7117117117, "max_line_length": 96, "alphanum_fraction": 0.5280140804, "num_tokens": 1025, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392939666335, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.5239405625810011}} {"text": "module Collections.BSTree.Map.Core\n\nimport Collections.Util.Bnd\nimport Control.Relation\nimport Decidable.Order.Strict\n\n||| A verified binary search tree with erased proofs.\n|||\n||| The keys in the tree are constrained by min/max bounds, which make use of `Bnd` to extend the\n||| tree key type with `Top` and `Bot` values. This allows for a natural way to leave bounds\n||| unconstrained (by having a minimum of `Bot` or a maximum of `Top`).\n|||\n||| @ ord The ordering implementations used in the tree. Since these are w.r.t. a type `kTy`, the\n||| type of tree keys is defined implicitly by `ord`.\n||| @ vTy The data type to carry in nodes in addition to the key type `kTy`.\n||| @ mn The minimum value constraint, proving that `rel mn (Mid x)` for all values `x` in the\n||| tree.\n||| @ mx The maximum value constraint, proving that `rel (Mid x) mx` for all values `x` in the\n||| tree.\npublic export\ndata BST : {0 rel : kTy -> kTy -> Type} ->\n (pre : StrictPreorder kTy rel) ->\n (tot : StrictOrdered kTy rel) ->\n (0 vTy : Type) ->\n (0 mn,mx : Bnd kTy) ->\n Type where\n ||| An empty tree node.\n |||\n ||| @ prf An ordering proof on the min and max constraints of this node. Since an in-order\n ||| traversal of a binary tree is an empty-node-empty-... alternation, storing ordering\n ||| information in the empty nodes is a natural way to store evidence that the nodes are in\n ||| order.\n Empty : {pre : StrictPreorder kTy rel} ->\n {tot : StrictOrdered kTy rel} ->\n (0 prf : BndLT rel mn mx) ->\n BST pre tot vTy mn mx\n ||| A node with a value and with left and right subtrees, each with appropriate bounds relative\n ||| to the key `k` of the node.\n |||\n ||| @ k The key value of the node\n ||| @ v The data value of the node\n ||| @ l The left subtree\n ||| @ r The right subtree\n Node : {0 rel : kTy -> kTy -> Type} ->\n {pre : StrictPreorder kTy rel} ->\n {tot : StrictOrdered kTy rel} ->\n (k : kTy) ->\n (v : vTy) ->\n (l : BST pre tot vTy mn (Mid k)) ->\n (r : BST pre tot vTy (Mid k) mx) ->\n BST pre tot vTy mn mx\n%name BST t,u,v\n\n||| A verified binary search tree with erased proofs.\n|||\n||| This is an alias for the more generic `BST` (which accepts min/max bounds for its contents).\n||| The bounds are necessary for verifying the structure of a tree, but the root node of any\n||| `BST` will always be unconstrained. So generally, `BST` can be considered an implementation\n||| detail.\n|||\n||| @ rel The strict total ordering used in the tree. Since a `StrictOrdered` impl is w.r.t. a type\n||| `kTy`, the type of tree values is defined implicitly by `ord`.\n||| @ vTy The type for values stored in nodes of the tree.\npublic export\nBSTree : {0 kTy : Type} ->\n (0 rel : kTy -> kTy -> Type) ->\n {auto pre : StrictPreorder kTy rel} ->\n {auto tot : StrictOrdered kTy rel} ->\n (0 vTy : Type) ->\n Type\nBSTree rel {pre} {tot} vTy = BST pre tot vTy Bot Top\n%name BSTree t,u,v\n\n||| Proof that the minimum bound can be decreased arbitrarily.\npublic export\nextendMin : {0 rel : kTy -> kTy -> Type} ->\n {pre : StrictPreorder kTy rel} ->\n {tot : StrictOrdered kTy rel} ->\n (0 prf : BndLT rel mn' mn) ->\n BST pre tot vTy mn mx ->\n BST pre tot vTy mn' mx\nextendMin {pre} prf (Empty prf') = Empty $ transitive {x=mn'} {y=mn} {z=mx} prf prf'\nextendMin prf (Node k v l r) = Node k v (extendMin prf l) r\n\n||| Proof that the maximum bound can be increased arbitrarily.\npublic export\nextendMax : {0 rel : kTy -> kTy -> Type} ->\n {pre : StrictPreorder kTy rel} ->\n {tot : StrictOrdered kTy rel} ->\n (0 prf : BndLT rel mx mx') ->\n BST pre tot vTy mn mx ->\n BST pre tot vTy mn mx'\nextendMax {pre} prf (Empty prf') = Empty $ transitive {x=mn} {y=mx} {z=mx'} prf' prf\nextendMax prf (Node k v l r) = Node k v l (extendMax prf r)\n", "meta": {"hexsha": "cb3c10a2f45eb4af3752818fc88a190ceb596e05", "size": 4056, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Collections/BSTree/Map/Core.idr", "max_stars_repo_name": "polendri/idris-collections", "max_stars_repo_head_hexsha": "8492ab9ceffdef72d25a65c6b4296e561816f73c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2020-11-24T10:58:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-20T16:16:04.000Z", "max_issues_repo_path": "src/Collections/BSTree/Map/Core.idr", "max_issues_repo_name": "polendri/idris-collections", "max_issues_repo_head_hexsha": "8492ab9ceffdef72d25a65c6b4296e561816f73c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Collections/BSTree/Map/Core.idr", "max_forks_repo_name": "polendri/idris-collections", "max_forks_repo_head_hexsha": "8492ab9ceffdef72d25a65c6b4296e561816f73c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 42.6947368421, "max_line_length": 99, "alphanum_fraction": 0.6055226824, "num_tokens": 1168, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744673038223, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.5237675289754393}} {"text": "||| Division theorem for (type-level) natural number division\nmodule Data.Nat.Division\n\nimport Syntax.WithProof\nimport Syntax.PreorderReasoning\nimport Syntax.PreorderReasoning.Generic\nimport Data.Nat\nimport Data.Nat.Equational\nimport Data.Nat.Order\nimport Data.Nat.Order.Strict\nimport Data.Nat.Order.Properties\nimport Decidable.Order.Strict\n\nimport Data.Nat.Properties\n\n%default total\n\n-- Division theorem --------------------\n\n-- This is disgusting, but will do for now\n||| Show that, if we have enough fuel, we have enough fuel for the\n||| recursive call in `div'` and `mod'`.\nfuelLemma : (numer, predDenom, fuel : Nat)\n -> (enough : numer `LTE` (S fuel))\n -> (recurse : Data.Nat.lte numer predDenom = False)\n -> (numer `minus` (S predDenom)) `LTE` fuel\nfuelLemma numer predDenom fuel enough recurse =\n let denom : Nat\n denom = S predDenom\n numer' : Nat\n numer' = numer `minus` denom\n -- a bunch of inequational reasoning to show we have enough fuel\n -- on the recursive call\n denom_lte_numer : denom `LTE` numer\n denom_lte_numer = Properties.notlteIsLT numer predDenom recurse\n numer'_lt_numer : numer' `LT` numer\n numer'_lt_numer = (minusPosLT denom numer\n (LTESucc LTEZero)\n denom_lte_numer)\n succenough : S numer' `LTE` S fuel\n succenough = transitive {rel = LTE} numer'_lt_numer enough\n in fromLteSucc succenough\n\n-- equivalence between the duplicate definitions in Data.Nar ---\n\n-- Internally, we use the two component definitions of divmod'\ndiv'' : (fuel, numer, denom : Nat) -> Nat\ndiv'' fuel numer denom = fst (divmod' fuel numer denom)\n\nmod'' : (fuel, numer, denom : Nat) -> Nat\nmod'' fuel numer denom = snd (divmod' fuel numer denom)\n\n\ndivmod'_eq_div'_mod' : (fuel, numer, denom : Nat)\n -> (divmod' fuel numer denom) = (div' fuel numer denom, mod' fuel numer denom)\ndivmod'_eq_div'_mod' 0 numer denom = Refl\ndivmod'_eq_div'_mod' (S fuel) numer denom with (Data.Nat.lte numer denom)\n divmod'_eq_div'_mod' (S fuel) numer denom | True = Refl\n divmod'_eq_div'_mod' (S fuel) numer denom | False =\n rewrite divmod'_eq_div'_mod' fuel (numer `minus` (S denom)) denom in\n Refl\n\ndiv''_eq_div' : (fuel, numer, denom : Nat)\n -> div'' fuel numer denom = div' fuel numer denom\ndiv''_eq_div' fuel numer denom = cong fst $\n divmod'_eq_div'_mod' fuel numer denom\n\nmod''_eq_mod' : (fuel, numer, denom : Nat)\n -> mod'' fuel numer denom = mod' fuel numer denom\nmod''_eq_mod' fuel numer denom = cong snd $\n divmod'_eq_div'_mod' fuel numer denom\n\nexport\ndivmodNatNZeqDivMod : (numer, denom : Nat) -> (0 prf1, prf2, prf3 : NonZero denom)\n -> (divmodNatNZ numer denom prf1) = (divNatNZ numer denom prf2, modNatNZ numer denom prf3)\ndivmodNatNZeqDivMod numer (S denom) prf1 prf2 prf3 = divmod'_eq_div'_mod' numer numer denom\n\nexport\nfstDivmodNatNZeqDiv : (numer, denom : Nat) -> (0 prf1, prf2 : NonZero denom)\n -> (fst $ divmodNatNZ numer denom prf1) = divNatNZ numer denom prf2\nfstDivmodNatNZeqDiv numer denom prf1 prf2 =\n rewrite divmodNatNZeqDivMod numer denom prf1 prf2 prf2 in\n Refl\n\nexport\nsndDivmodNatNZeqMod : (numer, denom : Nat) -> (0 prf1, prf2 : NonZero denom)\n -> (snd $ divmodNatNZ numer denom prf1) = modNatNZ numer denom prf2\nsndDivmodNatNZeqMod numer denom prf1 prf2 =\n rewrite divmodNatNZeqDivMod numer denom prf1 prf2 prf2 in\n Refl\n\n\n-----------------------------------------------------------------------------\nbound_mod'' : (fuel, numer, predDenom : Nat) -> (numer `LTE` fuel)\n -> (mod'' fuel numer predDenom) `LTE` predDenom\nbound_mod'' 0 0 predDenom LTEZero = LTEZero\nbound_mod'' (S fuel) numer predDenom enough = case @@(Data.Nat.lte numer predDenom) of\n (True ** numer_lte_predn) => rewrite numer_lte_predn in\n Properties.lteIsLTE _ _ numer_lte_predn\n (False ** numer_gte_n ) => rewrite numer_gte_n in\n bound_mod'' fuel (numer `minus` (S predDenom)) predDenom\n (fuelLemma numer predDenom fuel enough numer_gte_n)\n\nexport\nboundModNatNZ : (numer, denom : Nat) -> (0 denom_nz : NonZero denom)\n -> (modNatNZ numer denom denom_nz) `LT` denom\nboundModNatNZ numer (S predDenom) denom_nz =\n LTESucc $\n rewrite sym $ mod''_eq_mod' numer numer predDenom in\n bound_mod'' numer numer predDenom $ reflexive {rel = LTE}\ndivisionTheorem' : (numer, predDenom : Nat)\n -> (fuel : Nat) -> (enough : numer `LTE` fuel)\n -> numer = (mod'' fuel numer predDenom) + (div'' fuel numer predDenom) * (S predDenom)\n\ndivisionTheorem' 0 predDenom 0 LTEZero = Refl\ndivisionTheorem' numer predDenom (S fuel) enough with (@@(Data.Nat.lte numer predDenom))\n divisionTheorem' numer predDenom (S fuel) enough | (True ** prf)\n = rewrite prf in\n rewrite plusZeroRightNeutral numer in Refl\n divisionTheorem' numer predDenom (S fuel) enough | (False ** prf)\n = rewrite prf in\n let denom : Nat\n denom = S predDenom\n numer' : Nat\n numer' = numer `minus` denom\n denom_lte_numer : denom `LTE` numer\n denom_lte_numer = Properties.notlteIsLT numer predDenom prf\n enough' : numer' `LTE` fuel\n enough' = fuelLemma numer predDenom fuel enough prf\n\n inductionHypothesis : (numer'\n = (mod'' fuel numer' predDenom) + (div'' fuel numer' predDenom) * denom)\n inductionHypothesis = divisionTheorem' numer' predDenom fuel enough'\n in sym $ Calc $\n |~ (mod'' fuel numer' predDenom) + (denom + (div'' fuel numer' predDenom) * denom)\n ~~ (mod'' fuel numer' predDenom) + ((div'' fuel numer' predDenom) * denom + denom)\n ...(cong ((mod'' fuel numer' predDenom) +) $ plusCommutative\n denom\n ((div'' fuel numer' predDenom) * denom))\n ~~((mod'' fuel numer' predDenom) + (div'' fuel numer' predDenom) * denom) + denom\n ...(plusAssociative\n (mod'' fuel numer' predDenom)\n ((div'' fuel numer' predDenom) * denom)\n denom)\n ~~ numer' + denom ...(cong (+ denom) $ sym inductionHypothesis)\n ~~ numer ...(plusMinusLte denom numer denom_lte_numer)\n\n\n\nexport\nDivisionTheoremDivMod : (numer, denom : Nat) -> (0 prf : NonZero denom)\n -> numer = snd ( divmodNatNZ numer denom prf)\n + (fst $ divmodNatNZ numer denom prf)*denom\nDivisionTheoremDivMod numer (S predDenom) prf\n = divisionTheorem' numer predDenom numer $ reflexive {rel = LTE}\n\nexport\nDivisionTheorem : (numer, denom : Nat) -> (0 prf1, prf2 : NonZero denom)\n -> numer = (modNatNZ numer denom prf1) + (divNatNZ numer denom prf2)*denom\nDivisionTheorem numer denom prf1 prf2\n = rewrite sym $ fstDivmodNatNZeqDiv numer denom prf1 prf2 in\n rewrite sym $ sndDivmodNatNZeqMod numer denom prf1 prf1 in\n DivisionTheoremDivMod numer denom prf1\n\n\n\ndivmodZeroZero : (denom, fuel : Nat)\n -> divmod' fuel 0 denom = (0,0)\ndivmodZeroZero denom 0 = Refl\ndivmodZeroZero denom (S fuel) = Refl\n\nmodZeroZero : (denom, fuel : Nat)\n -> mod'' fuel 0 denom = 0\nmodZeroZero denom fuel = rewrite divmodZeroZero denom fuel in Refl\n\ndivZeroZero : (denom, fuel : Nat)\n -> div'' fuel 0 denom = 0\ndivZeroZero denom fuel = rewrite divmodZeroZero denom fuel in Refl\n\n\ndivmodFuelLemma : (numer, denom, fuel1, fuel2 : Nat)\n -> (enough1 : fuel1 `GTE` numer)\n -> (enough2 : fuel2 `GTE` numer)\n -> divmod' fuel1 numer denom = divmod' fuel2 numer denom\ndivmodFuelLemma 0 denom 0 fuel2 LTEZero enough2 = rewrite divmodZeroZero denom fuel2 in\n Refl\ndivmodFuelLemma 0 denom (S fuel1) 0 enough1 LTEZero = Refl\ndivmodFuelLemma numer denom (S fuel1) (S fuel2) enough1 enough2 with (@@(Data.Nat.lte numer denom))\n divmodFuelLemma numer denom (S fuel1) (S fuel2) enough1 enough2 | (True ** prf) =\n rewrite prf in Refl\n divmodFuelLemma numer denom (S fuel1) (S fuel2) enough1 enough2 | (False ** prf) =\n rewrite prf in\n rewrite divmodFuelLemma (numer `minus` (S denom)) denom fuel1 fuel2\n (fuelLemma numer denom fuel1 enough1 prf)\n (fuelLemma numer denom fuel2 enough2 prf) in\n Refl\n\n\nmultiplicationLemma : (q, predn, r : Nat) -> q * (S predn) + r `LTE` 0 -> (q = 0, r = 0)\nmultiplicationLemma q predn r bound =\n let r_eq_z : (r = 0)\n r_eq_z = zeroPlusRightZero (q * (S predn)) r (sym $ lteZeroIsZero bound)\n qn_eq_z : (q * (S predn) = 0)\n qn_eq_z = zeroPlusLeftZero (q * (S predn)) r (sym $ lteZeroIsZero bound)\n q_eq_z : q = 0\n q_eq_z = case zeroMultEitherZero q (S predn) qn_eq_z of\n Left q_eq_0 => q_eq_0\n Right spred_eq_z impossible\n in (q_eq_z, r_eq_z)\n\nmultiplesModuloZero : (fuel, predn, k : Nat)\n -> (enough : fuel `GTE` k * (S predn) )\n -> mod' fuel (k * (S predn)) predn = 0\nmultiplesModuloZero 0 predn k enough =\n let (k_eq_z, _) = multiplicationLemma k predn 0 $\n rewrite plusZeroRightNeutral (k * (S predn)) in\n enough\n in rewrite k_eq_z in\n Refl\nmultiplesModuloZero (S fuel) predn 0 enough = Refl\nmultiplesModuloZero (S fuel) predn (S k) enough =\n let n : Nat\n n = S predn\n n_lte_skn : n `LTE` (1 + k)*n\n n_lte_skn = CalcWith {leq = LTE} $\n |~ n\n ~~ n + 0 ...(sym $ plusZeroRightNeutral n)\n ~~ (1 + 0)*n ...(Refl)\n <~ (1 + k)*n ...(multLteMonotoneLeft (1+0) (1+k) n $\n plusLteMonotoneLeft 1 0 k LTEZero)\n in case @@(Data.Nat.lte ((1 + k)*n) predn) of\n (True ** skn_lte_predn) => absurd $ irreflexive {rel = Data.Nat.LT}\n $ CalcWith {leq = LTE} $\n |~ 1 + predn\n ~~ n ...(Refl)\n ~~ n + 0 ...(sym $ plusZeroRightNeutral n)\n ~~ (1 + 0)*n ...(Refl)\n <~ (1 + k)*n ...(multLteMonotoneLeft (1+0) (1+k) n $\n LTESucc LTEZero)\n <~ predn ...(Properties.lteIsLTE _ _ skn_lte_predn)\n (False ** prf) =>\n rewrite prf in\n let skn_minus_n_eq_kn : ((1 + k)*n `minus` n = k*n)\n skn_minus_n_eq_kn = Calc $\n |~ ((1+k)*n `minus` n)\n ~~ ((1+k)*n `minus` (n + 0)) ...(cong ((1+k)*n `minus`) $ sym $ plusZeroRightNeutral n)\n ~~ (n + k*n `minus` (n + 0)) ...(Refl)\n ~~ (k*n `minus` 0) ...(plusMinusLeftCancel n (k*n) 0)\n ~~ k*n ...(minusZeroRight (k*n))\n in rewrite skn_minus_n_eq_kn in\n multiplesModuloZero fuel predn k $\n (rewrite sym $ skn_minus_n_eq_kn in\n fuelLemma ((1 + k)*n) predn fuel enough prf)\n\n-- We also want to show uniqueness of this decomposition\n-- This is, of course, quite horrible, but I want this theorem in the stdlib\naddMultipleMod': (fuel1, fuel2, predn, a, b : Nat) -> (enough1 : fuel1 `GTE` b * (S predn) + a)\n -> (enough2 : fuel2 `GTE` a)\n -> mod'' fuel1 (b * (S predn) + a) predn = mod'' fuel2 a predn\naddMultipleMod' 0 fuel2 predn a b enough1 enough2\n = let (b_eq_z, a_eq_z) = multiplicationLemma b predn a enough1\n in rewrite a_eq_z in\n rewrite b_eq_z in\n rewrite modZeroZero predn fuel2 in\n Refl\naddMultipleMod' fuel1@(S _) fuel2 predn a 0 enough1 enough2 =\n rewrite divmodFuelLemma a predn fuel1 fuel2 enough1 enough2 in\n Refl\naddMultipleMod' (S fuel1) fuel2 predn a (S k) enough1 enough2 =\n let n : Nat\n n = S predn\n lhsarg_geq_predn : ((1 + k)*n + a) `GT` predn\n lhsarg_geq_predn = CalcWith {leq = LTE} $\n |~ n\n ~~ (1+0)*n ...(sym $ plusZeroRightNeutral n)\n <~ (1+k)*n ...(multLteMonotoneLeft 1 (1+k) n $\n LTESucc LTEZero)\n <~ (1+k)*n + a ...(lteAddRight $ (1+k)*n)\n prf1 : lte ((1 + k)*n + a) predn = False\n prf1 = GTIsnotlte ((1 + k)*n + a) predn lhsarg_geq_predn\n argsimplify : (((1 + k) *n + a ) `minus` n = k*n + a)\n argsimplify = Calc $\n |~ (((1+k)*n + a) `minus` n)\n ~~ (((n + k*n) + a) `minus` n) ...(Refl)\n ~~ ((n + (k*n + a)) `minus` (n + 0)) ...(cong2 minus\n (sym $ plusAssociative n (k*n) a)\n (sym $ plusZeroRightNeutral n))\n ~~ ((k*n + a) `minus` 0) ...(plusMinusLeftCancel n (k*n + a) 0)\n ~~ k*n + a ...(minusZeroRight (k*n + a))\n in rewrite prf1 in\n rewrite argsimplify in\n addMultipleMod' fuel1 fuel2 predn a k\n (rewrite sym argsimplify in\n fuelLemma ((1+k)*n + a) predn fuel1 enough1 prf1)\n enough2\n\naddMultipleMod : (a, b, n : Nat) -> (0 n_neq_z1, n_neq_z2 : NonZero n)\n -> snd (divmodNatNZ (a*n + b) n n_neq_z1) = snd (divmodNatNZ b n n_neq_z2)\naddMultipleMod a b n@(S predn) n_neq_z1 n_neq_z2 =\n addMultipleMod' (a*n + b) b predn b a (reflexive {rel = LTE}) (reflexive {rel = LTE})\n\nmodBelowDenom : (r, n : Nat) -> (0 n_neq_z : NonZero n)\n -> (r `LT` n)\n -> snd (divmodNatNZ r n n_neq_z) = r\nmodBelowDenom 0 (S predn) n_neq_0 (LTESucc r_lte_predn) = Refl\nmodBelowDenom r@(S _) (S predn) n_neq_0 (LTESucc r_lte_predn) =\n rewrite LteIslte r predn r_lte_predn in\n Refl\n\nmodInjective : (r1, r2, n : Nat) -> (0 n_neq_z1, n_neq_z2 : NonZero n)\n -> (r1 `LT` n)\n -> (r2 `LT` n)\n -> snd (divmodNatNZ r1 n n_neq_z1) = snd (divmodNatNZ r2 n n_neq_z2)\n -> r1 = r2\nmodInjective r1 r2 n n_neq_z1 n_neq_z2 r1_lt_n r2_lt_n ri_mod_eq = Calc $\n |~ r1\n ~~ snd (divmodNatNZ r1 n n_neq_z1) ...(sym $ modBelowDenom r1 n n_neq_z1 r1_lt_n)\n ~~ snd (divmodNatNZ r2 n n_neq_z2) ...(ri_mod_eq)\n ~~ r2 ...( modBelowDenom r2 n n_neq_z2 r2_lt_n)\n\n\nstep1 : (numer : Nat) -> (denom : Nat) -> (0 denom_nz : NonZero denom)\n -> (q, r : Nat) -> (r `LT` denom) -> (numer = q * denom + r)\n -> snd (divmodNatNZ numer denom denom_nz) = r\nstep1 x n n_nz q r r_lt_n x_eq_qnpr = Calc $\n |~ snd(divmodNatNZ x n n_nz)\n ~~ snd(divmodNatNZ (q*n + r) n n_nz) ...(cong (\\u => snd $ divmodNatNZ u n n_nz) $ x_eq_qnpr)\n ~~ snd(divmodNatNZ r n n_nz) ...(addMultipleMod q r n n_nz n_nz)\n ~~ r ...(modBelowDenom r n n_nz r_lt_n)\n\nstep2 : (numer : Nat) -> (denom : Nat) -> (0 denom_nz : NonZero denom)\n -> (q, r : Nat) -> (r `LT` denom) -> (numer = q * denom + r)\n -> fst (divmodNatNZ numer denom denom_nz) = q\nstep2 x n n_nz q r r_lt_n x_eq_qnr =\n let mod_eq_r : (snd (divmodNatNZ x n n_nz) = r)\n mod_eq_r = step1 x n n_nz q r r_lt_n x_eq_qnr\n\n two_decompositions : (fst $ divmodNatNZ x n n_nz) * n + r = q * n + r\n two_decompositions = Calc $\n |~ (fst $ divmodNatNZ x n n_nz) * n + r\n ~~ (fst $ divmodNatNZ x n n_nz) * n + (snd $ divmodNatNZ x n n_nz)\n ...(cong (\\ u =>\n (fst $ divmodNatNZ x n n_nz)* n + u)\n $ sym mod_eq_r)\n ~~ snd(divmodNatNZ x n n_nz) + fst (divmodNatNZ x n n_nz) * n\n ...(plusCommutative _ _)\n ~~ x ...(sym $ DivisionTheoremDivMod x n n_nz)\n ~~ q*n + r ...(x_eq_qnr)\n\n in multRightCancel (fst $ divmodNatNZ x n n_nz) q n n_nz\n $ plusRightCancel ((fst $ divmodNatNZ x n n_nz)* n) (q*n) r\n $ two_decompositions\n\nexport\nDivisionTheoremUniquenessDivMod : (numer : Nat) -> (denom : Nat) -> (0 denom_nz : NonZero denom)\n -> (q, r : Nat) -> (r `LT` denom) -> (numer = q * denom + r)\n -> divmodNatNZ numer denom denom_nz = (q, r)\nDivisionTheoremUniquenessDivMod numer denom denom_nz q r x prf =\n rewrite sym $ step1 numer denom denom_nz q r x prf in\n rewrite sym $ step2 numer denom denom_nz q r x prf in\n pair_eta _ -- Should idris be able to see this automatically? Maybe only with homogeneous equality?\n where\n -- Should this go elsewhere?\n ||| extensionality law for simple pairs\n pair_eta : (x : (a,b)) -> x = (fst x, snd x)\n pair_eta (x,y) = Refl\n\nexport\nDivisionTheoremUniqueness : (numer : Nat) -> (denom : Nat) -> (0 denom_nz : NonZero denom)\n -> (q, r : Nat) -> (r `LT` denom) -> (numer = q * denom + r)\n -> (divNatNZ numer denom denom_nz = q, modNatNZ numer denom denom_nz = r)\nDivisionTheoremUniqueness numer denom denom_nz q r x prf =\n rewrite sym $ fstDivmodNatNZeqDiv numer denom denom_nz denom_nz in\n rewrite sym $ sndDivmodNatNZeqMod numer denom denom_nz denom_nz in\n rewrite DivisionTheoremUniquenessDivMod numer denom denom_nz q r x prf in\n (Refl, Refl)\n", "meta": {"hexsha": "b61327990b0dc7649b3a2f0f4dc1d2db30028807", "size": 17194, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/Nat/Division.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "libs/contrib/Data/Nat/Division.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/contrib/Data/Nat/Division.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.6074270557, "max_line_length": 102, "alphanum_fraction": 0.5834593463, "num_tokens": 5382, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709251, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.5236695428661245}} {"text": "module Quantities.SIDerivedQuantities\n\nimport Quantities.Core\nimport Quantities.SIBaseQuantities\n\n%default total\n%access public export\n\n\n-- Examples of coherent derived units in the SI expressed in terms of base\n-- units\n\nArea : Quantity\nArea = Length ^ 2\n\nVolume : Quantity\nVolume = Length ^ 3\n\nSpeed : Quantity\nSpeed = Length Time\n\nVelocity : Quantity\nVelocity = Speed\n\nAcceleration : Quantity\nAcceleration = Speed Time\n\nWavenumber : Quantity\nWavenumber = Length ^ (-1)\n\nDensity : Quantity\nDensity = Mass Volume\n\nMassDensity : Quantity\nMassDensity = Density\n\nSurfaceDensity : Quantity\nSurfaceDensity = Mass Area\n\nSpecificVolume : Quantity\nSpecificVolume = Volume Mass\n\nCurrentDensity : Quantity\nCurrentDensity = ElectricCurrent Area\n\nMagneticFieldStrength : Quantity\nMagneticFieldStrength = ElectricCurrent Length\n\nAmountConcentration : Quantity\nAmountConcentration = AmountOfSubstance Volume\n\nConcentration : Quantity\nConcentration = AmountConcentration\n\nMassConcentration : Quantity\nMassConcentration = Mass Volume\n\nLuminance : Quantity\nLuminance = LuminousIntensity Area\n\nRefractiveIndex : Quantity\nRefractiveIndex = Scalar\n\nRelativePermeability : Quantity\nRelativePermeability = Scalar\n\n\n-- Coherent derived units in the SI with special names and symbols\n\nPlaneAngle : Quantity\nPlaneAngle = Scalar\n\nSolidAngle : Quantity\nSolidAngle = Scalar\n\nFrequency : Quantity\nFrequency = Time ^ (-1)\n\nForce' : Quantity\nForce' = Acceleration <*> Mass\n\nPressure : Quantity\nPressure = Force' Area\n\nStress : Quantity\nStress = Pressure\n\nEnergy : Quantity\nEnergy = Force' <*> Length\n\nWork : Quantity\nWork = Energy\n\nAmountOfHeat : Quantity\nAmountOfHeat = Energy\n\nPower : Quantity\nPower = Energy Time\n\nRadiantFlux : Quantity\nRadiantFlux = Power\n\nElectricCharge : Quantity\nElectricCharge = Time <*> ElectricCurrent\n\nAmountOfElectricity : Quantity\nAmountOfElectricity = ElectricCharge\n\nElectricPotentialDifference : Quantity\nElectricPotentialDifference = Power ElectricCurrent\n\nElectromotiveForce : Quantity\nElectromotiveForce = ElectricPotentialDifference\n\nCapacitance : Quantity\nCapacitance = ElectricCharge ElectricPotentialDifference\n\nElectricResistance : Quantity\nElectricResistance = ElectricPotentialDifference ElectricCurrent\n\nElectricConductance : Quantity\nElectricConductance = ElectricCurrent ElectricPotentialDifference\n\nMagneticFlux : Quantity\nMagneticFlux = Time <*> ElectricPotentialDifference\n\nMagneticFluxDensity : Quantity\nMagneticFluxDensity = MagneticFlux Area\n\nInductance : Quantity\nInductance = MagneticFlux ElectricCurrent\n\n-- Celsius temperature\n\nLuminousFlux : Quantity\nLuminousFlux = LuminousIntensity <*> SolidAngle\n\nIlluminance : Quantity\nIlluminance = LuminousFlux Area\n\nActivityReferredToARadionuclide : Quantity\nActivityReferredToARadionuclide = Time ^ (-1)\n\n-- ... sometimes incorrectly called\nRadioactivity : Quantity\nRadioactivity = ActivityReferredToARadionuclide\n\nAbsorbedDose : Quantity\nAbsorbedDose = Energy Mass\n\nSpecificEnergy : Quantity\nSpecificEnergy = AbsorbedDose\n\nKerma : Quantity\nKerma = AbsorbedDose\n\nDoseEquivalent : Quantity\nDoseEquivalent = Energy Mass\n\nAmbientDoseEquivalent : Quantity\nAmbientDoseEquivalent = DoseEquivalent\n\nDirectionalDoseEquivalent : Quantity\nDirectionalDoseEquivalent = DoseEquivalent\n\nPersonalDoseEquivalent : Quantity\nPersonalDoseEquivalent = DoseEquivalent\n\nCatalyticActivity : Quantity\nCatalyticActivity = AmountOfSubstance Time\n\n\n-- Examples of SI coherent derived units whose names and symbols include SI\n-- coherent derived units with special names and symbols\n\nDynamicViscosity : Quantity\nDynamicViscosity = Stress <*> Time\n\nKinematicViscosity : Quantity\nKinematicViscosity = Area Time\n\nMomentOfForce : Quantity\nMomentOfForce = Force' <*> Length\n\nMoment : Quantity\nMoment = MomentOfForce\n\nTorque : Quantity\nTorque = MomentOfForce\n\nSurfaceTension : Quantity\nSurfaceTension = Force' Length\n\nAngularVelocity : Quantity\nAngularVelocity = PlaneAngle Time\n\nAngularAcceleration : Quantity\nAngularAcceleration = AngularVelocity Time\n\nHeatFluxDensity : Quantity\nHeatFluxDensity = Power Area\n\nIrradiance : Quantity\nIrradiance = HeatFluxDensity\n\nHeatCapacity : Quantity\nHeatCapacity = Energy Temperature\n\nEntropy : Quantity\nEntropy = HeatCapacity\n\nSpecificHeatCapacity : Quantity\nSpecificHeatCapacity = HeatCapacity Mass\n\nSpecificEntropy : Quantity\nSpecificEntropy = Entropy Mass\n\nThermalConductivity : Quantity\nThermalConductivity = Power (Length <*> Temperature)\n\nEnergyDensity : Quantity\nEnergyDensity = Energy Volume\n\nElectricFieldStrength : Quantity\nElectricFieldStrength = ElectricPotentialDifference Length\n\nElectricChargeDensity : Quantity\nElectricChargeDensity = ElectricCharge Volume\n\nSurfaceChargeDensity : Quantity\nSurfaceChargeDensity = ElectricCharge Area\n\nElectricFluxDensity : Quantity\nElectricFluxDensity = SurfaceChargeDensity\n\nElectricDisplacement : Quantity\nElectricDisplacement = SurfaceChargeDensity\n\nPermettivity : Quantity\nPermettivity = Capacitance Length\n\nPermeability : Quantity\nPermeability = Inductance Length\n\nMolarEnergy : Quantity\nMolarEnergy = Energy AmountOfSubstance\n\nMolarHeatCapacity : Quantity\nMolarHeatCapacity = MolarEnergy\n\nExposure : Quantity\nExposure = ElectricCharge Mass\n\nAbsorbedDoseRate : Quantity\nAbsorbedDoseRate = AbsorbedDose Time\n\nRadiantIntensity : Quantity\nRadiantIntensity = Power SolidAngle\n\nRadiance : Quantity\nRadiance = RadiantIntensity Area\n\nCatalyticActivityConcentration : Quantity\nCatalyticActivityConcentration = CatalyticActivity Volume\n", "meta": {"hexsha": "e16d5e37f5e2a3572439a00234b187899032fc1b", "size": 5626, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Quantities/SIDerivedQuantities.idr", "max_stars_repo_name": "timjb/quantities", "max_stars_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 112, "max_stars_repo_stars_event_min_datetime": "2015-01-18T13:52:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T14:15:46.000Z", "max_issues_repo_path": "Quantities/SIDerivedQuantities.idr", "max_issues_repo_name": "timjb/quantities", "max_issues_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2015-11-04T08:51:41.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-17T09:52:29.000Z", "max_forks_repo_path": "Quantities/SIDerivedQuantities.idr", "max_forks_repo_name": "timjb/quantities", "max_forks_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-04-28T23:49:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-01T17:28:34.000Z", "avg_line_length": 21.2301886792, "max_line_length": 75, "alphanum_fraction": 0.8016352648, "num_tokens": 1328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.5236695341046274}} {"text": "-- ---------------------------------------------- [ DependentStateMachines.idr ]\n-- Module : Exercises.DependentStateMachines\n-- Description : Solutions to the Chapter 14 exercises in Edwin Brady's\n-- book, \"Type-Driven Development with Idris.\"\n-- --------------------------------------------------------------------- [ EOH ]\nmodule Exercises.DependentStateMachines\n\nimport public Chapter.DependentStateMachines\n\n-- -------------------------------------------------------- [ 14.2.5 Exercises ]\n\n%access public export\n\ndata Access = LoggedOut | LoggedIn\ndata PwdCheck = Correct | Incorrect\n\ndata ShellCmd : (ty : Type) -> Access -> (ty -> Access) -> Type where\n Password : String -> ShellCmd PwdCheck LoggedOut\n (\\res => case res of\n Correct => LoggedIn\n Incorrect => LoggedOut)\n Logout : ShellCmd () LoggedIn (const LoggedOut)\n GetSecret : ShellCmd String LoggedIn (const LoggedIn)\n\n PutStr : String -> ShellCmd () state (const state)\n Pure : (res : ty) -> ShellCmd ty (state_fn res) state_fn\n (>>=) : ShellCmd a state1 state2_fn ->\n ((res : a) -> ShellCmd b (state2_fn res) state3_fn) ->\n ShellCmd b state1 state3_fn\n\n%access export\n\nsession : ShellCmd () LoggedOut (const LoggedOut)\nsession = do Correct <- Password \"wurzel\"\n | Incorrect => PutStr \"Wrong password\"\n PutStr $ \"Secret code: \" ++ show !GetSecret ++ \"\\n\"\n Logout\n\n-- NOTE: The following should not type check.\n{-\nbad_session : ShellCmd () LoggedOut (const LoggedOut)\nbad_session = do Password \"wurzel\"\n PutStr $ \"Secret code: \" ++ !GetSecret ++ \"\\n\"\n Logout\n\nno_logout : ShellCmd () LoggedOut (const LoggedOut)\nno_logout = do Correct <- Password \"wurzel\"\n | Incorrect => PutStr \"Wrong password\"\n PutStr $ \"Secret code: \" ++ show !GetSecret ++ \"\\n\"\n-}\n\nnamespace DependentVendingMachine\n\n export\n VendState : Type\n VendState = (Nat, Nat)\n\n public export\n data Input = COIN\n | VEND\n | CHANGE\n | REFILL Nat\n\n data CoinResult = Inserted | Rejected\n\n public export\n data MachineCmd : (ty : Type) -> VendState -> (ty -> VendState) -> Type where\n\n InsertCoin : MachineCmd CoinResult (pounds, chocs)\n (\\res => case res of\n Inserted => (S pounds, chocs)\n Rejected => (pounds, chocs))\n\n Vend : MachineCmd () (S pounds, S chocs) (const (pounds, chocs))\n\n GetCoins : MachineCmd () (pounds, chocs) (const (Z, chocs))\n\n Refill : (bars : Nat) -> MachineCmd () (Z, chocs)\n (const (Z, bars + chocs))\n\n Display : String -> MachineCmd () state (const state)\n\n GetInput : MachineCmd (Maybe Input) state (const state)\n\n Pure : (res : ty) -> MachineCmd ty (state_fn res) state_fn\n\n (>>=) : MachineCmd a state1 state2_fn ->\n ((res : a) -> MachineCmd b (state2_fn res) state3_fn) ->\n MachineCmd b state1 state3_fn\n\n public export\n data MachineIO : VendState -> Type where\n Do : MachineCmd a state1 state2_fn ->\n ((res : a) -> Inf (MachineIO (state2_fn res))) -> MachineIO state1\n\nnamespace MachineDo\n\n public export\n (>>=) : MachineCmd a state1 state2_fn ->\n ((res : a) -> Inf (MachineIO (state2_fn res))) -> MachineIO state1\n (>>=) = Do\n\n-- --------------------------------------- [ 13.1.4 A Verified Vending Machine ]\n\nmutual\n\n vend : MachineIO (pounds, chocs)\n vend {pounds = S _} {chocs = S _} = do Vend\n Display \"Enjoy!\"\n machineLoop\n vend {pounds = Z} = do Display \"Insert a coin\"\n machineLoop\n vend {chocs = Z} = do Display \"Out of stock\"\n machineLoop\n\n refill : (num : Nat) -> MachineIO (pounds, chocs)\n refill {pounds = Z} num = do Refill num\n machineLoop\n refill _ = do Display \"Can't refill: Coins in machine\"\n machineLoop\n\n machineLoop : MachineIO (pounds, chocs)\n machineLoop =\n do Just x <- GetInput\n | Nothing => do Display \"Invalid input\"\n machineLoop\n case x of\n COIN => do Inserted <- InsertCoin\n | Rejected => do Display \"Coin rejected\"\n machineLoop\n Display \"Coin inserted\"\n machineLoop\n VEND => vend\n CHANGE => do GetCoins\n Display \"Change returned\"\n machineLoop\n REFILL num => refill num\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "ac834c9a2895ca1b7ad7eef4772d94206fd99568", "size": 5257, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Exercises/DependentStateMachines.idr", "max_stars_repo_name": "yurrriq/tdd-with-idris", "max_stars_repo_head_hexsha": "873c6c719706d06179527c5d93982bb7c184da90", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-04-15T01:29:36.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-15T01:29:36.000Z", "max_issues_repo_path": "src/Exercises/DependentStateMachines.idr", "max_issues_repo_name": "yurrriq/tdd-with-idris", "max_issues_repo_head_hexsha": "873c6c719706d06179527c5d93982bb7c184da90", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2016-11-21T23:42:45.000Z", "max_issues_repo_issues_event_max_datetime": "2016-12-01T05:43:10.000Z", "max_forks_repo_path": "src/Exercises/DependentStateMachines.idr", "max_forks_repo_name": "yurrriq/tdd-with-idris", "max_forks_repo_head_hexsha": "873c6c719706d06179527c5d93982bb7c184da90", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.55, "max_line_length": 82, "alphanum_fraction": 0.4782195168, "num_tokens": 1136, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.5231701929879503}} {"text": "\nimport Data.Vect\n\nvappend : Vect n a -> Vect m a -> Vect (n+m) a \nvappend [] ys = ys\nvappend (x :: xs) ys = x :: vappend xs ys \n", "meta": {"hexsha": "3de440e0d2f2cca4cccc4c3e70534978453590f0", "size": 129, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "vappend_solution.idr", "max_stars_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_stars_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "vappend_solution.idr", "max_issues_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_issues_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "vappend_solution.idr", "max_forks_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_forks_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.4285714286, "max_line_length": 47, "alphanum_fraction": 0.5813953488, "num_tokens": 47, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031738057795403, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.5231511655668523}} {"text": "-- ----------------------------------------------------------------- [ Set.idr ]\n-- Module : Set.idr\n-- Copyright : (c) 2015,2016 See CONTRIBUTORS.md\n-- License : see LICENSE\n-- --------------------------------------------------------------------- [ EOH ]\n||| Implementation of a Set using an AVL Binary Search Tree.\nmodule Data.AVL.Set\n\nimport Data.AVL\n\n%access export\n\n-- ------------------------------------------------------------- [ Definitions ]\n||| An ordered set.\ndata Set : (a : Type) -> Type where\n MkSet : {a : Type} -> AVLTree n a Unit -> Set a\n\n||| Return a empty set.\nempty : (Ord a) => Set a\nempty = MkSet (Element Empty AVLEmpty)\n\n||| Insert an element into a set.\ninsert : (Ord a) => a -> Set a -> Set a\ninsert a (MkSet m) = MkSet (snd $ AVL.API.insert a () m)\n\n||| Does the set contain the given element.\ncontains : (Ord a) => a -> Set a -> Bool\ncontains a (MkSet m) = isJust (lookup a m)\n\n||| Construct a set that contains all elements in both of the input sets.\nunion : (Ord a) => Set a -> Set a -> Set a\nunion (MkSet m1) (MkSet m2) = MkSet (snd $ AVL.API.foldr insertElement (_ ** m1) m2)\n where\n insertElement : (Ord a) => a\n -> Unit\n -> (h : Nat ** AVLTree h a Unit)\n -> (h' : Nat ** AVLTree h' a Unit)\n insertElement k v m' = AVL.API.insert k v (snd m')\n\n||| Return the size of the Dictionary.\nsize : Set a -> Nat\nsize (MkSet m) = AVL.API.size m\n\n||| Construct a set that contains the elements from the first input\n||| set but not the second.\n|||\n||| *Note* Not an efficient operation as we are constructing a new set\n||| instead of modifying the right one.\ndifference : (Ord a) => Set a -> Set a -> Set a\ndifference (MkSet m1) s2 = AVL.API.foldr (\\e,_,t => if (contains e s2) then t else Set.insert e t) empty $ m1\n\n||| Construct a set that contains common elements of the input sets.\nintersection : (Ord a) => Set a -> Set a -> Set a\nintersection s1 s2 = difference s1 (difference s1 s2)\n\n||| Construct a list using the given set.\ntoList : Set a -> List a\ntoList (MkSet m) = map fst $ AVL.API.toList m\n\n||| Construct a set from the given list.\nfromList : (Ord a) => List a -> Set a\nfromList xs = (foldl (\\t,k => Set.insert k t) empty xs)\n\n-- --------------------------------------------------------- [ Implementations ]\nFoldable Set where\n foldr f i (MkSet m) = foldr (\\x,_,p => f x p) i m\n\nEq a => Eq (Set a) where\n (==) (MkSet (Element t _)) (MkSet (Element t' _)) = t == t'\n\nShow a => Show (Set a) where\n show s = \"{ \" ++ (unwords . intersperse \",\" . map show . Set.toList $ s) ++ \" }\"\n\n\nnamespace Predicate\n\n export\n data Elem : (value : type) -> (set : Set type) -> Type where\n IsElem : (prf : HasKey value tree)\n -> Elem value (MkSet tree)\n\n private\n elemNotInSet : (prfIsNotElem : HasKey value tree -> Void) -> Elem value (MkSet tree) -> Void\n elemNotInSet prfIsNotElem (IsElem prf) = prfIsNotElem prf\n\n isElem : DecEq type\n => (value : type)\n -> (set : Set type)\n -> Dec (Elem value set)\n isElem value (MkSet tree) with (isKey value tree)\n isElem value (MkSet tree) | (Yes prf) = Yes (IsElem prf)\n isElem value (MkSet tree) | (No prfIsNotElem) = No (elemNotInSet prfIsNotElem)\n\nnamespace Quantifier\n\n data All : (predicate : type -> Type) -> (set : Set type) -> Type where\n Satisfies : (prf : AllKeys p tree) -> All p (MkSet tree)\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "80da638ac6c8a55854a2f8b7bff1f3eaafabfef5", "size": 3496, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/AVL/Set.idr", "max_stars_repo_name": "elba/idris-containers", "max_stars_repo_head_hexsha": "b92d489abcb32774fb6adfd7f26a28c082cc4bef", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Data/AVL/Set.idr", "max_issues_repo_name": "elba/idris-containers", "max_issues_repo_head_hexsha": "b92d489abcb32774fb6adfd7f26a28c082cc4bef", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/AVL/Set.idr", "max_forks_repo_name": "elba/idris-containers", "max_forks_repo_head_hexsha": "b92d489abcb32774fb6adfd7f26a28c082cc4bef", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-19T12:29:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T12:29:49.000Z", "avg_line_length": 34.96, "max_line_length": 109, "alphanum_fraction": 0.5549199085, "num_tokens": 1003, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.523119058256954}} {"text": "= Imp : Simple Imperative Programs\n\n> module Imp\n\n> import Logic\n\nIn this chapter, we begin a new direction that will continue for the rest of the\ncourse. Up to now most of our attention has been focused on various aspects of\nIdris itself, while from now on we'll mostly be using Idris to formalize other\nthings. (We'll continue to pause from time to time to introduce a few additional\naspects of Idris.)\n\nOur first case study is a _simple imperative programming language_ called Imp,\nembodying a tiny core fragment of conventional mainstream languages such as C\nand Java. Here is a familiar mathematical function written in Imp.\n\n```\n Z ::= X;;\n Y ::= 1;;\n WHILE not (Z == 0) DO\n Y ::= Y * Z;;\n Z ::= Z - 1\n END\n```\n\nThis chapter looks at how to define the _syntax_ and _semantics_ of Imp; the\nchapters that follow develop a theory of _program equivalence_ and introduce\n_Hoare Logic_, a widely used logic for reasoning about imperative programs.\n\n> import Maps\n\n> %hide (\\\\)\n\n> %default total\n> %access public export\n\n\n== Arithmetic and Boolean Expressions\n\nWe'll present Imp in three parts: first a core language of _arithmetic and\nboolean expressions_, then an extension of these expressions with _variables_,\nand finally a language of _commands_ including assignment, conditions,\nsequencing, and loops.\n\n\n=== Syntax\n\nThese two definitions specify the _abstract syntax_ of arithmetic and boolean\nexpressions.\n\n> data AExp0 : Type where\n> ANum0 : Nat -> AExp0\n> APlus0 : AExp0 -> AExp0 -> AExp0\n> AMinus0 : AExp0 -> AExp0 -> AExp0\n> AMult0 : AExp0 -> AExp0 -> AExp0\n>\n> data BExp0 : Type where\n> BTrue0 : BExp0\n> BFalse0 : BExp0\n> BEq0 : AExp0 -> AExp0 -> BExp0\n> BLe0 : AExp0 -> AExp0 -> BExp0\n> BNot0 : BExp0 -> BExp0\n> BAnd0 : BExp0 -> BExp0 -> BExp0\n\nIn this chapter, we'll elide the translation from the concrete syntax that a\nprogrammer would actually write to these abstract syntax trees — the process\nthat, for example, would translate the string \\idr{\"1+2*3\"} to the AST\n\n```idris\n APlus0 (ANum0 1) (AMult0 (ANum0 2) (ANum0 3))\n```\n\nThe optional chapter `ImpParser` develops a simple implementation of a lexical\nanalyzer and parser that can perform this translation. You do _not_ need to\nunderstand that chapter to understand this one, but if you haven't taken a\ncourse where these techniques are covered (e.g., a compilers course) you may\nwant to skim it.\n\nFor comparison, here's a conventional BNF (Backus-Naur Form) grammar defining\nthe same abstract syntax:\n\n```\n a ::= Nat\n | a + a\n | a - a\n | a * a\n\n b ::= True\n | False\n | a = a\n | a ≤ a\n | not b\n | b and b\n```\n\nCompared to the Idris version above...\n\n - The BNF is more informal — for example, it gives some suggestions about the\n surface syntax of expressions (like the fact that the addition operation is\n written \\idr{+} and is an infix symbol) while leaving other aspects of\n lexical analysis and parsing (like the relative precedence of \\idr{+},\n \\idr{-}, and \\idr{*}, the use of parens to explicitly group subexpressions,\n etc.) unspecified. Some additional information (and human intelligence)\n would be required to turn this description into a formal definition, for\n example when implementing a compiler.\n\n The Idris version consistently omits all this information and concentrates\n on the abstract syntax only.\n\n - On the other hand, the BNF version is lighter and easier to read. Its\n informality makes it flexible, a big advantage in situations like\n discussions at the blackboard, where conveying general ideas is more\n important than getting every detail nailed down precisely.\n\n Indeed, there are dozens of BNF-like notations and people switch freely\n among them, usually without bothering to say which form of BNF they're using\n because there is no need to: a rough-and-ready informal understanding is all\n that's important.\n\nIt's good to be comfortable with both sorts of notations: informal ones for\ncommunicating between humans and formal ones for carrying out implementations\nand proofs.\n\n\n=== Evaluation\n\n_Evaluating_ an arithmetic expression produces a number.\n\n> aeval0 : (a : AExp0) -> Nat\n> aeval0 (ANum0 n) = n\n> aeval0 (APlus0 a1 a2) = (aeval0 a1) + (aeval0 a2)\n> aeval0 (AMinus0 a1 a2) = (aeval0 a1) `minus` (aeval0 a2)\n> aeval0 (AMult0 a1 a2) = (aeval0 a1) * (aeval0 a2)\n\n> test_aeval1 : aeval0 (APlus0 (ANum0 2) (ANum0 2)) = 4\n> test_aeval1 = Refl\n\nSimilarly, evaluating a boolean expression yields a boolean.\n\n> beval0 : (b : BExp0) -> Bool\n> beval0 BTrue0 = True\n> beval0 BFalse0 = False\n> beval0 (BEq0 a1 a2) = (aeval0 a1) == (aeval0 a2)\n> beval0 (BLe0 a1 a2) = lte (aeval0 a1) (aeval0 a2)\n> beval0 (BNot0 b1) = not (beval0 b1)\n> beval0 (BAnd0 b1 b2) = (beval0 b1) && (beval0 b2)\n\n=== Optimization\n\nWe haven't defined very much yet, but we can already get some mileage out of the\ndefinitions. Suppose we define a function that takes an arithmetic expression\nand slightly simplifies it, changing every occurrence of \\idr{0+e} (i.e.,\n\\idr{(APlus0 (ANum0 0) e}) into just \\idr{e}.\n\n> optimize_0plus : (a : AExp0) -> AExp0\n> optimize_0plus (ANum0 n) = ANum0 n\n> optimize_0plus (APlus0 (ANum0 Z) e2) =\n> optimize_0plus e2\n> optimize_0plus (APlus0 e1 e2) =\n> APlus0 (optimize_0plus e1) (optimize_0plus e2)\n> optimize_0plus (AMinus0 e1 e2) =\n> AMinus0 (optimize_0plus e1) (optimize_0plus e2)\n> optimize_0plus (AMult0 e1 e2) =\n> AMult0 (optimize_0plus e1) (optimize_0plus e2)\n\nTo make sure our optimization is doing the right thing we can test it on some\nexamples and see if the output looks OK.\n\n> test_optimize_0plus :\n> optimize_0plus (APlus0 (ANum0 2)\n> (APlus0 (ANum0 0)\n> (APlus0 (ANum0 0) (ANum0 1))))\n> = APlus0 (ANum0 2) (ANum0 1)\n\nBut if we want to be sure the optimization is correct — i.e., that evaluating an\noptimized expression gives the same result as the original — we should prove it.\n\n> optimize_0plus_sound : aeval0 (optimize_0plus a) = aeval0 a\n> optimize_0plus_sound {a=ANum0 _} = Refl\n> optimize_0plus_sound {a=APlus0 (ANum0 Z) y} =\n> optimize_0plus_sound {a=y}\n> optimize_0plus_sound {a=APlus0 (ANum0 (S k)) y} =\n> cong {f=\\x=>S(k+x)} $ optimize_0plus_sound {a=y}\n> optimize_0plus_sound {a=APlus0 (APlus0 x z) y} =\n> rewrite optimize_0plus_sound {a=APlus0 x z} in\n> rewrite optimize_0plus_sound {a=y} in\n> Refl\n> optimize_0plus_sound {a=APlus0 (AMinus0 x z) y} =\n> rewrite optimize_0plus_sound {a=x} in\n> rewrite optimize_0plus_sound {a=y} in\n> rewrite optimize_0plus_sound {a=z} in\n> Refl\n> optimize_0plus_sound {a=APlus0 (AMult0 x z) y} =\n> rewrite optimize_0plus_sound {a=x} in\n> rewrite optimize_0plus_sound {a=y} in\n> rewrite optimize_0plus_sound {a=z} in\n> Refl\n> optimize_0plus_sound {a=AMinus0 x y} =\n> rewrite optimize_0plus_sound {a=x} in\n> rewrite optimize_0plus_sound {a=y} in\n> Refl\n> optimize_0plus_sound {a=AMult0 x y} =\n> rewrite optimize_0plus_sound {a=x} in\n> rewrite optimize_0plus_sound {a=y} in\n> Refl\n\n\n== Coq Automation\n\n\\ \\todo[inline]{Move the whole subsection to \\idr{Pruviloj} chapter?}\n\nThe amount of repetition in this last proof is a little annoying. And if either\nthe language of arithmetic expressions or the optimization being proved sound\nwere significantly more complex, it would start to be a real problem.\n\nSo far, we've been doing all our proofs using just a small handful of Coq's\ntactics and completely ignoring its powerful facilities for constructing parts\nof proofs automatically. This section introduces some of these facilities, and\nwe will see more over the next several chapters. Getting used to them will take\nsome energy — Coq's automation is a power tool — but it will allow us to scale\nup our efforts to more complex definitions and more interesting properties\nwithout becoming overwhelmed by boring, repetitive, low-level details.\n\n\n=== Tacticals\n\nTacticals is Coq's term for tactics that take other tactics as arguments —\n\"higher-order tactics,\" if you will.\n\n\n==== The `try` Tactical\n\n\\ \\todo[inline]{Exists in Pruviloj}\n\nIf `T` is a tactic, then `try T` is a tactic that is just like `T` except that,\nif `T` fails, `try T` successfully does nothing at all (instead of failing).\n\n```coq\nTheorem silly1 : forall ae, aeval ae = aeval ae.\nProof. try Refl. (* this just does Refl *) Qed.\n\nTheorem silly2 : forall (P : Type), P -> P.\nProof.\n intros P HP.\n try Refl. (* just Refl would have failed *)\n apply HP. (* we can still finish the proof in some other way *)\nQed.\n```\n\nThere is no real reason to use `try` in completely manual proofs like these, but\nit is very useful for doing automated proofs in conjunction with the `;`\ntactical, which we show next.\n\n\n==== The `;` Tactical (Simple Form)\n\n\\ \\todo[inline]{Approximated by \\idr{andThen} in Pruviloj}\n\nIn its most common form, the `;` tactical takes two tactics as arguments. The\ncompound tactic `T;T'` first performs `T` and then performs `T'` on each subgoal\ngenerated by `T`.\n\nFor example, consider the following trivial lemma:\n\n```coq\nLemma foo : forall n, lte 0 n = True.\nProof.\n intros.\n destruct n.\n (* Leaves two subgoals, which are discharged identically... *)\n - (* n=0 *) simpl. Refl.\n - (* n=Sn' *) simpl. Refl.\nQed.\n```\n\nWe can simplify this proof using the `;` tactical:\n\n```coq\nLemma foo' : forall n, lte 0 n = True.\nProof.\n intros.\n (* destruct the current goal *)\n destruct n;\n (* then simpl each resulting subgoal *)\n simpl;\n (* and do Refl on each resulting subgoal *)\n Refl.\nQed.\n```\n\nUsing `try` and `;` together, we can get rid of the repetition in the proof that\nwas bothering us a little while ago.\n\n\\ \\todo[inline]{Mention\n\\href{http://docs.idris-lang.org/en/latest/reference/misc.html\\#alternatives}{Alternatives} ?}\n\n```coq\nTheorem optimize_0plus_sound': forall a,\n aeval (optimize_0plus a) = aeval a.\nProof.\n intros a.\n induction a;\n (* Most cases follow directly by the IH... *)\n try (simpl; rewrite IHa1; rewrite IHa2; Refl).\n (* ... but the remaining cases -- ANum and APlus --\n are different: *)\n - (* ANum *) Refl.\n - (* APlus *)\n destruct a1;\n (* Again, most cases follow directly by the IH: *)\n try (simpl; simpl in IHa1; rewrite IHa1;\n rewrite IHa2; Refl).\n (* The interesting case, on which the try...\n does nothing, is when e1 = ANum n. In this\n case, we have to destruct n (to see whether\n the optimization applies) and rewrite with the\n induction hypothesis. *)\n + (* a1 = ANum n *) destruct n;\n simpl; rewrite IHa2; Refl. Qed.\n```\n\nCoq experts often use this \"`...; try...`\" idiom after a tactic like `induction`\nto take care of many similar cases all at once. Naturally, this practice has an\nanalog in informal proofs. For example, here is an informal proof of the\noptimization theorem that matches the structure of the formal one:\n\n_Theorem_: For all arithmetic expressions `a`,\n```\n aeval (optimize_0plus a) = aeval a.\n```\n_Proof_: By induction on `a`. Most cases follow directly from the `IH`. The\nremaining cases are as follows:\n\n - Suppose `a = ANum n` for some `n`. We must show\n```\n aeval (optimize_0plus (ANum n)) = aeval (ANum n).\n```\n This is immediate from the definition of `optimize_0plus`.\n\n - Suppose `a = APlus a1 a2` for some `a1` and `a2`. We must show\n```\n aeval (optimize_0plus (APlus a1 a2)) = aeval (APlus a1 a2).\n```\n\n Consider the possible forms of `a1`. For most of them, `optimize_0plus`\n simply calls itself recursively for the subexpressions and rebuilds a new\n expression of the same form as `a1`; in these cases, the result follows\n directly from the `IH`. The interesting case is when `a1 = ANum n` for some\n `n`. If `n = ANum 0`, then\n```\n optimize_0plus (APlus a1 a2) = optimize_0plus a2\n```\n and the `IH` for `a2` is exactly what we need. On the other hand, if `n = S\n n'` for some `n'`, then again `optimize_0plus` simply calls itself\n recursively, and the result follows from the `IH`. $\\square$\n\nHowever, this proof can still be improved: the first case (for `a = ANum n`) is\nvery trivial — even more trivial than the cases that we said simply followed\nfrom the `IH` — yet we have chosen to write it out in full. It would be better\nand clearer to drop it and just say, at the top, \"Most cases are either\nimmediate or direct from the `IH`. The only interesting case is the one for\n`APlus...`\" We can make the same improvement in our formal proof too. Here's how\nit looks:\n\n```coq\nTheorem optimize_0plus_sound'': forall a,\n aeval (optimize_0plus a) = aeval a.\nProof.\n intros a.\n induction a;\n (* Most cases follow directly by the IH *)\n try (simpl; rewrite IHa1; rewrite IHa2; Refl);\n (* ... or are immediate by definition *)\n try Refl.\n (* The interesting case is when a = APlus a1 a2. *)\n - (* APlus *)\n destruct a1; try (simpl; simpl in IHa1; rewrite IHa1;\n rewrite IHa2; Refl).\n + (* a1 = ANum n *) destruct n;\n simpl; rewrite IHa2; Refl. Qed.\n```\n\n==== The `;` Tactical (General Form)\n\nThe ; tactical also has a more general form than the simple `T;T'` we've seen\nabove. If `T, T1, ..., Tn` are tactics, then\n\n```coq\n T; [T1 | T2 | ... | Tn]\n```\n\nis a tactic that first performs `T` and then performs `T1` on the first subgoal\ngenerated by `T`, performs `T2` on the second subgoal, etc.\n\nSo `T;T'` is just special notation for the case when all of the `Ti`'s are the\nsame tactic; i.e.,` T;T`' is shorthand for:\n\n```coq\n T; [T' | T' | ... | T']\n```\n\n==== The `repeat` Tactical\n\n\\ \\todo[inline]{Approximated by \\idr{repeatUntilFail} in Pruviloj}\n\nThe `repeat` tactical takes another tactic and keeps applying this tactic until\nit fails. Here is an example showing that `10` is in a long list using `repeat`.\n\n```coq\nTheorem In10 : In 10 [1;2;3;4;5;6;7;8;9;10].\nProof.\n repeat (try (left; Refl); right).\nQed.\n```\n\nThe tactic `repeat T` never fails: if the tactic `T` doesn't apply to the\noriginal goal, then repeat still succeeds without changing the original goal\n(i.e., it repeats zero times).\n\n```coq\nTheorem In10' : In 10 [1;2;3;4;5;6;7;8;9;10].\nProof.\n repeat (left; Refl).\n repeat (right; try (left; Refl)).\nQed.\n```\n\nThe tactic `repeat T` also does not have any upper bound on the number of times\nit applies `T`. If `T` is a tactic that always succeeds, then `repeat T` will\nloop forever (e.g., `repeat simpl` loops forever, since `simpl` always\nsucceeds). While evaluation in Coq's term language, Gallina, is guaranteed to\nterminate, tactic evaluation is not! This does not affect Coq's logical\nconsistency, however, since the job of `repeat` and other tactics is to guide\nCoq in constructing proofs; if the construction process diverges, this simply\nmeans that we have failed to construct a proof, not that we have constructed a\nwrong one.\n\n\n==== Exercise: 3 stars (optimize_0plus_b)\n\nSince the \\idr{optimize_0plus} transformation doesn't change the value of\n\\idr{AExp}s, we should be able to apply it to all the \\idr{AExp}s that appear in\na \\idr{BExp} without changing the \\idr{BExp}'s value. Write a function which\nperforms that transformation on \\idr{BExp}s, and prove it is sound. Use the\ntacticals we've just seen to make the proof as elegant as possible.\n\n> optimize_0plus_b : (b : BExp0) -> BExp0\n> optimize_0plus_b b = ?optimize_0plus_b_rhs\n\n> optimize_0plus_b_sound : beval0 (optimize_0plus_b b) = beval0 b\n> optimize_0plus_b_sound = ?optimize_0plus_b_sound_rhs\n\n$\\square$\n\n\n==== Exercise: 4 stars, optional (optimizer)\n\n_Design exercise_: The optimization implemented by our \\idr{optimize_0plus}\nfunction is only one of many possible optimizations on arithmetic and boolean\nexpressions. Write a more sophisticated optimizer and prove it correct. (You\nwill probably find it easiest to start small — add just a single, simple\noptimization and prove it correct — and build up to something more interesting\nincrementially.)\n\n> --FILL IN HERE\n\n$\\square$\n\n\n=== Defining New Tactic Notations\n\nCoq also provides several ways of \"programming\" tactic scripts.\n\n - The `Tactic Notation` idiom illustrated below gives a handy way to define\n \"shorthand tactics\" that bundle several tactics into a single command.\n\n - For more sophisticated programming, Coq offers a built-in programming\n language called `Ltac` with primitives that can examine and modify the proof\n state. The details are a bit too complicated to get into here (and it is\n generally agreed that `Ltac` is not the most beautiful part of Coq's\n design!), but they can be found in the reference manual and other books on\n Coq, and there are many examples of `Ltac` definitions in the Coq standard\n library that you can use as examples.\n\n - There is also an OCaml API, which can be used to build tactics that access\n Coq's internal structures at a lower level, but this is seldom worth the\n trouble for ordinary Coq users.\n\nThe `Tactic Notation` mechanism is the easiest to come to grips with, and it\noffers plenty of power for many purposes. Here's an example.\n\n```coq\nTactic Notation \"simpl_and_try\" tactic(c) :=\n simpl;\n try c.\n```\n\nThis defines a new tactical called `simpl_and_try` that takes one tactic `c` as\nan argument and is defined to be equivalent to the tactic `simpl; try c`. Now\nwriting \"`simpl_and_try Refl.`\" in a proof will be the same as writing \"`simpl;\ntry Refl.`\"\n\n\n=== The `omega` Tactic\n\n\\ \\todo[inline]{Related to https://github.com/forestbelton/cooper}\n\nThe `omega` tactic implements a decision procedure for a subset of first-order\nlogic called _Presburger arithmetic_. It is based on the Omega algorithm\ninvented in 1991 by William Pugh [Pugh 1991].\n\nIf the goal is a universally quantified formula made out of\n\n - numeric constants, addition (`+` and `S`), subtraction (`-` and `pred`), and\n multiplication by constants (this is what makes it Presburger arithmetic),\n\n - equality (`=` and `/=`) and inequality (`<=`), and\n\n - the logical connectives `/\\`, `\\/`, `Not`, and `->`,\n\nthen invoking `omega` will either solve the goal or tell you that it is actually\nfalse.\n\n```coq\nExample silly_presburger_example : forall m n o p,\n m + n <= n + o /\\ o + 3 = p + 3 ->\n m <= p.\nProof.\n intros. omega.\nQed.\n```\n\n=== A Few More Handy Tactics\n\nFinally, here are some miscellaneous tactics that you may find convenient.\n\n - `clear H`: Delete hypothesis `H` from the context.\n\n - `subst x`: Find an assumption `x = e` or `e = x` in the context, replace `x`\n with `e` throughout the context and current goal, and clear the assumption.\n\n - `subst`: Substitute away all assumptions of the form `x = e` or `e = x`.\n\n - `rename... into...`: Change the name of a hypothesis in the proof context.\n For example, if the context includes a variable named `x`, then `rename x\n into y` will change all occurrences of `x` to `y`.\n\n - `assumption`: Try to find a hypothesis `H` in the context that exactly\n matches the goal; if one is found, behave like `apply H`.\n\n - `contradiction`: Try to find a hypothesis `H` in the current context that is\n logically equivalent to `Void`. If one is found, solve the goal.\n\n - `constructor`: Try to find a constructor `c` (from some `Inductive`\n definition in the current environment) that can be applied to solve the\n current goal. If one is found, behave like `apply c`.\n\nWe'll see examples below.\n\n\n== Evaluation as a Relation\n\nWe have presented \\idr{aeval} and \\idr{beval} as functions. Another way to think\nabout evaluation — one that we will see is often more flexible — is as a\n_relation_ between expressions and their values. This leads naturally to\n\\idr{data} definitions like the following one for arithmetic expressions...\n\n```idris\ndata AEvalR : AExp0 -> Nat -> Type where\n E_ANum : (n: Nat) -> AEvalR (ANum n) n\n E_APlus : (e1, e2 : AExp0) -> (n1, n2 : Nat) ->\n AEvalR e1 n1 ->\n AEvalR e2 n2 ->\n AEvalR (APlus e1 e2) (n1 + n2)\n E_AMinus : (e1, e2 : AExp0) -> (n1, n2 : Nat) ->\n AEvalR e1 n1 ->\n AEvalR e2 n2 ->\n AEvalR (AMinus0 e1 e2) (n1 `minus` n2)\n E_AMult : (e1, e2: AExp0) -> (n1, n2 : Nat) ->\n AEvalR e1 n1 ->\n AEvalR e2 n2 ->\n AEvalR (AMult0 e1 e2) (n1 * n2)\n```\n\n\\todo[inline]{Edit}\n\nIt will be convenient to have an infix notation for \\idr{AEvalR}. We'll write\n\\idr{e \\\\ n} to mean that arithmetic expression \\idr{e} evaluates to value\n\\idr{n}.\n\nIn fact, Idris provides a way to use this notation in the definition of\n\\idr{AevalR} itself. This reduces confusion by avoiding situations where we're\nworking on a proof involving statements in the form \\idr{e \\\\ n} but we have to\nrefer back to a definition written using the form \\idr{AEvalR e n}.\n\nWe do this by first \"reserving\" the notation, then giving the definition\ntogether with a declaration of what the notation means.\n\n> data (\\\\) : AExp0 -> (n : Nat) -> Type where\n> E_ANum : (ANum0 n) \\\\ n\n> E_APlus : e1 \\\\ n1 -> e2 \\\\ n2 -> n = n1 + n2 ->\n> (APlus0 e1 e2) \\\\ n\n\n\\todo[inline]{We don't use \\idr{-} since it requires a proof of \\idr{LTE n1 n2}}\n\n> E_AMinus : e1 \\\\ n1 -> e2 \\\\ n2 -> n = n1 `minus` n2 ->\n> (AMinus0 e1 e2) \\\\ n\n> E_AMult : e1 \\\\ n1 -> e2 \\\\ n2 -> n = n1 * n2 ->\n> (AMult0 e1 e2) \\\\ n\n\n> AEvalR : AExp0 -> Nat -> Type\n> AEvalR = (\\\\)\n\n\n=== Inference Rule Notation\n\n\\ \\todo[inline]{Add hyperlink}\n\nIn informal discussions, it is convenient to write the rules for \\idr{AEvalR}\nand similar relations in the more readable graphical form of inference rules,\nwhere the premises above the line justify the conclusion below the line (we have\nalready seen them in the `IndProp` chapter).\n\nFor example, the constructor \\idr{E_APlus}...\n\n```idris\n E_APlus : (e1 \\\\ n1) -> (e2 \\\\ n2) -> (n = n1 + n2) ->\n (APlus0 e1 e2) \\\\ n\n```\n\n...would be written like this as an inference rule:\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{e1 \\\\ n1}}\n \\hypo{\\idr{e2 \\\\ n2}}\n \\infer2[\\idr{E_APlus}]{\\idr{APlus e1 e2 \\\\ n1+n2}}\n \\end{prooftree}\n\\]\n\nFormally, there is nothing deep about inference rules: they are just\nimplications. You can read the rule name on the right as the name of the\nconstructor and read each of the linebreaks between the premises above the line\n(as well as the line itself) as \\idr{->}. All the variables mentioned in the\nrule (\\idr{e1}, \\idr{n1}, etc.) are implicitly bound by universal quantifiers at\nthe beginning. (Such variables are often called _metavariables_ to distinguish\nthem from the variables of the language we are defining. At the moment, our\narithmetic expressions don't include variables, but we'll soon be adding them.)\nThe whole collection of rules is understood as being wrapped in an function\ndeclaration. In informal prose, this is either elided or else indicated by\nsaying something like \"Let \\idr{AEvalR} be the smallest relation closed under\nthe following rules...\".\n\nFor example, \\idr{\\\\} is the smallest relation closed under these rules:\n\n\\[\n \\begin{prooftree}\n \\infer0[\\idr{E_ANum}]{\\idr{ANum n \\\\ n}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{e1 \\\\ n1}}\n \\hypo{\\idr{e2 \\\\ n2}}\n \\infer2[\\idr{E_APlus}]{\\idr{APlus e1 e2 \\\\ n1+n2}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{e1 \\\\ n1}}\n \\hypo{\\idr{e2 \\\\ n2}}\n \\infer2[\\idr{E_AMinus}]{\\idr{AMinus e1 e2 \\\\ n1-n2}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{e1 \\\\ n1}}\n \\hypo{\\idr{e2 \\\\ n2}}\n \\infer2[\\idr{E_AMult}]{\\idr{AMult e1 e2 \\\\ n1*n2}}\n \\end{prooftree}\n\\]\n\n\n=== Equivalence of the Definitions\n\nIt is straightforward to prove that the relational and functional definitions of\nevaluation agree:\n\n> aeval_iff_aevalR : (a \\\\ n) <-> aeval0 a = n\n> aeval_iff_aevalR = (to, fro)\n> where\n> to : (a \\\\ n) -> aeval0 a = n\n> to E_ANum = Refl\n> to (E_APlus x y xy) =\n> rewrite xy in\n> rewrite to x in\n> rewrite to y in Refl\n> to (E_AMinus x y xy) =\n> rewrite xy in\n> rewrite to x in\n> rewrite to y in Refl\n> to (E_AMult x y xy) =\n> rewrite xy in\n> rewrite to x in\n> rewrite to y in Refl\n> fro : (aeval0 a = n) -> (a \\\\ n)\n> fro {a=ANum0 n} Refl = E_ANum\n> fro {a=APlus0 x y} prf =\n> E_APlus (fro Refl) (fro Refl) (sym prf)\n> fro {a=AMinus0 x y} prf =\n> E_AMinus (fro Refl) (fro Refl) (sym prf)\n> fro {a=AMult0 x y} prf =\n> E_AMult (fro Refl) (fro Refl) (sym prf)\n\nWe can make the proof quite a bit shorter by making more use of tacticals.\n\n```coq\nTheorem aeval_iff_aevalR' : forall a n,\n (a \\\\ n) <-> aeval a = n.\nProof.\n (* WORKED IN CLASS *)\n split.\n - (* -> *)\n intros H; induction H; subst; Refl.\n - (* <- *)\n generalize dependent n.\n induction a; simpl; intros; subst; constructor;\n try apply IHa1; try apply IHa2; Refl.\nQed.\n```\n\n==== Exercise: 3 stars (bevalR)\n\nWrite a relation \\idr{BEvalR} in the same style as \\idr{AEvalR}, and prove that\nit is equivalent to \\idr{beval0}.\n\n> -- data BEvalR : BExp0 -> (b : Bool) -> Type where\n> -- FILL IN HERE\n>\n> -- beval_iff_bevalR : (BEvalR b bv) <-> beval0 b = bv\n\n$\\square$\n\n\n=== Computational vs. Relational Definitions\n\nFor the definitions of evaluation for arithmetic and boolean expressions, the\nchoice of whether to use functional or relational definitions is mainly a matter\nof taste: either way works.\n\nHowever, there are circumstances where relational definitions of evaluation work\nmuch better than functional ones.\n\nFor example, suppose that we wanted to extend the arithmetic operations by\nconsidering also a division operation:\n\n> namespace AEvalRDiv\n\n> data AExpD : Type where\n> ANumD : Nat -> AExpD\n> APlusD : AExpD -> AExpD -> AExpD\n> AMinusD : AExpD -> AExpD -> AExpD\n> AMultD : AExpD -> AExpD -> AExpD\n> ADivD : AExpD -> AExpD -> AExpD -- <--- new\n\nExtending the definition of \\idr{aeval} to handle this new operation would not\nbe straightforward (what should we return as the result of\n\\idr{ADiv (ANum 5) (ANum 0)}?). But extending \\idr{AEvalR} is straightforward.\n\n> infix 5 \\\\\\\n\n> data (\\\\\\) : AExpD -> (n : Nat) -> Type where\n> E_ANumD : (ANumD n) \\\\\\ n\n> E_APlusD : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n = n1 + n2 ->\n> (APlusD e1 e2) \\\\\\ n\n> E_AMinusD : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n = n1 `minus` n2 ->\n> (AMinusD e1 e2) \\\\\\ n\n> E_AMultD : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n = n1 * n2 ->\n> (AMultD e1 e2) \\\\\\ n\n> E_ADivD : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n2 `GT` 0 -> n1 = n2*n3 ->\n> (ADivD e1 e2) \\\\\\ n3\n\n> AEvalRD : AExpD -> Nat -> Type\n> AEvalRD = (\\\\\\)\n\nSuppose, instead, that we want to extend the arithmetic operations by a\nnondeterministic number generator \\idr{any} that, when evaluated, may yield any\nnumber. (Note that this is not the same as making a _probabilistic_ choice among\nall possible numbers — we're not specifying any particular distribution of\nresults, but just saying what results are _possible_.)\n\n> namespace AEvalRAny\n\n> data AExpA : Type where\n> AAnyA : AExpA -- <--- new\n> ANumA : Nat -> AExpA\n> APlusA : AExpA -> AExpA -> AExpA\n> AMinusA : AExpA -> AExpA -> AExpA\n> AMultA : AExpA -> AExpA -> AExpA\n\nAgain, extending \\idr{aeval} would be tricky, since now evaluation is _not_ a\ndeterministic function from expressions to numbers, but extending \\idr{AEvalR}\nis no problem:\n\n> infix 5 \\\\\\\n\n> data (\\\\\\) : AExpA -> (n : Nat) -> Type where\n> E_AnyA : AAnyA \\\\\\ n\n> E_ANumA : (ANumA n) \\\\\\ n\n> E_APlusA : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n = n1 + n2 ->\n> (APlusA e1 e2) \\\\\\ n\n> E_AMinusA : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n = n1 `minus` n2 ->\n> (AMinusA e1 e2) \\\\\\ n\n> E_AMultA : e1 \\\\\\ n1 -> e2 \\\\\\ n2 -> n = n1 * n2 ->\n> (AMultA e1 e2) \\\\\\ n\n\n> AEvalRA : AExpA -> Nat -> Type\n> AEvalRA = (\\\\\\)\n\nAt this point you maybe wondering: which style should I use by default? The\nexamples above show that relational definitions are fundamentally more powerful\nthan functional ones. For situations like these, where the thing being defined\nis not easy to express as a function, or indeed where it is _not_ a function,\nthere is no choice. But what about when both styles are workable?\n\n\\ \\todo[inline]{Edit}\n\nOne point in favor of relational definitions is that some people feel they are\nmore elegant and easier to understand. Another is that Idris automatically\ngenerates nice inversion and induction principles from function definitions.\n\nOn the other hand, functional definitions can often be more convenient:\n\n - Functions are by definition deterministic and defined on all arguments; for\n a relation we have to show these properties explicitly if we need them.\n\n - With functions we can also take advantage of Idris's computation mechanism\n to simplify expressions during proofs.\n\nFurthermore, functions can be directly \"extracted\" to executable code in C\nor JavaScript.\n\nUltimately, the choice often comes down to either the specifics of a particular\nsituation or simply a question of taste. Indeed, in large Idris developments it\nis common to see a definition given in _both_ functional and relational styles,\nplus a lemma stating that the two coincide, allowing further proofs to switch\nfrom one point of view to the other at will.\n\n\n== Expressions With Variables\n\nLet's turn our attention back to defining Imp. The next thing we need to do is\nto enrich our arithmetic and Boolean expressions with variables. To keep things\nsimple, we'll assume that all variables are global and that they only hold\nnumbers.\n\n\n=== States\n\nSince we'll want to look variables up to find out their current values, we'll\nreuse the type \\idr{Id} from the `Maps` chapter for the type of variables in\nImp.\n\nA _machine state_ (or just _state_) represents the current values of _all_\nvariables at some point in the execution of a program.\n\nFor simplicity, we assume that the state is defined for _all_ variables, even\nthough any given program is only going to mention a finite number of them. The\nstate captures all of the information stored in memory. For Imp programs,\nbecause each variable stores a natural number, we can represent the state as a\nmapping from identifiers to \\idr{Nat}. For more complex programming languages,\nthe state might have more structure.\n\n> State : Type\n> State = TotalMap Nat\n\n> empty_state : State\n> empty_state = t_empty 0\n\n\n=== Syntax\n\nWe can add variables to the arithmetic expressions we had before by simply\nadding one more constructor:\n\n> data AExp : Type where\n> ANum : Nat -> AExp\n> AId : Id -> AExp -- <----- NEW\n> APlus : AExp -> AExp -> AExp\n> AMinus : AExp -> AExp -> AExp\n> AMult : AExp -> AExp -> AExp\n\nDefining a few variable names as notational shorthands will make examples easier\nto read:\n\n> W : Id\n> W = MkId \"W\"\n> X : Id\n> X = MkId \"X\"\n> Y : Id\n> Y = MkId \"Y\"\n> Z : Id\n> Z = MkId \"Z\"\n\n\\todo[inline]{Edit}\n\n(This convention for naming program variables (\\idr{X}, \\idr{Y}, \\idr{Z})\nclashes a bit with our earlier use of uppercase letters for types. Since we're\nnot using polymorphism heavily in the chapters devoped to Imp, this overloading\nshould not cause confusion.)\n\nThe definition of \\idr{BExp}s is unchanged (except for using the new\n\\idr{AExp}s):\n\n> data BExp : Type where\n> BTrue : BExp\n> BFalse : BExp\n> BEq : AExp -> AExp -> BExp\n> BLe : AExp -> AExp -> BExp\n> BNot : BExp -> BExp\n> BAnd : BExp -> BExp -> BExp\n\n\n=== Evaluation\n\nThe arith and boolean evaluators are extended to handle variables in the obvious\nway, taking a state as an extra argument:\n\n> aeval : (st : State) -> (a : AExp) -> Nat\n> aeval _ (ANum n) = n\n> aeval st (AId i) = st i\n> aeval st (APlus a1 a2) = (aeval st a1) + (aeval st a2)\n> aeval st (AMinus a1 a2) = (aeval st a1) `minus` (aeval st a2)\n> aeval st (AMult a1 a2) = (aeval st a1) * (aeval st a2)\n>\n> beval : (st : State) -> (b : BExp) -> Bool\n> beval _ BTrue = True\n> beval _ BFalse = False\n> beval st (BEq a1 a2) = (aeval st a1) == (aeval st a2)\n> beval st (BLe a1 a2) = lte (aeval st a1) (aeval st a2)\n> beval st (BNot b1) = not (beval st b1)\n> beval st (BAnd b1 b2) = (beval st b1) && (beval st b2)\n\n> aexp1 : aeval (t_update X 5 Imp.empty_state)\n> (APlus (ANum 3) (AMult (AId X) (ANum 2)))\n> = 13\n> aexp1 = Refl\n\n> bexp1 : beval (t_update X 5 Imp.empty_state)\n> (BAnd BTrue (BNot (BLe (AId X) (ANum 4))))\n> = True\n> bexp1 = Refl\n\n\n== Commands\n\nNow we are ready define the syntax and behavior of Imp _commands_ (sometimes\ncalled _statements_).\n\n\n=== Syntax\n\nInformally, commands \\idr{c} are described by the following BNF grammar. (We\nchoose this slightly awkward concrete syntax for the sake of being able to\ndefine Imp syntax using Idris's \\idr{syntax} mechanism. In particular, we use\n\\idr{IFB} to avoid conflicting with the \\idr{if} notation from the standard\nlibrary.)\n\n```\n c ::= SKIP | x ::= a | c ;; c | IFB b THEN c ELSE c FI\n | WHILE b DO c END\n```\n\nFor example, here's factorial in Imp:\n\n```\n Z ::= X;;\n Y ::= 1;;\n WHILE not (Z = 0) DO\n Y ::= Y * Z;;\n Z ::= Z - 1\n END\n```\n\nWhen this command terminates, the variable \\idr{Y} will contain the factorial of\nthe initial value of \\idr{X}.\n\nHere is the formal definition of the abstract syntax of commands:\n\n> data Com : Type where\n> CSkip : Com\n> CAss : Id -> AExp -> Com\n> CSeq : Com -> Com -> Com\n> CIf : BExp -> Com -> Com -> Com\n> CWhile : BExp -> Com -> Com\n\nAs usual, we can use a few `Notation` declarations to make things more readable.\nTo avoid conflicts with Idris's built-in notations, we keep this light — in\nparticular, we don't introduce any notations for \\idr{AExp}s and \\idr{BExp}s to\navoid confusion with the numeric and boolean operators we've already defined.\n\n\\ \\todo[inline]{Explain do-notation}\n\n> infix 5 ::= \n\n> SKIP : Com\n> SKIP = CSkip\n\n> (::=) : Id -> AExp -> Com\n> (::=) = CAss\n\n> (>>=) : Com -> (() -> Com) -> Com\n> (>>=) c f = CSeq c (f ())\n\n> WHILE : BExp -> Com -> Com\n> WHILE = CWhile\n\n> syntax IFB [c1] THEN [c2] ELSE [c3] FI = CIf c1 c2 c3\n\nFor example, here is the factorial function again, written as a formal\ndefinition to Idris:\n\n> fact_in_idris : Com\n> fact_in_idris = do\n> Z ::= AId X\n> Y ::= ANum 1\n> WHILE (BNot (BEq (AId Z) (ANum 0))) $ do\n> Y ::= AMult (AId Y) (AId Z)\n> Z ::= AMinus (AId Z) (ANum 1)\n\n\n=== More Examples\n\n\n==== Assignment:\n\n> plus2 : Com\n> plus2 =\n> X ::= APlus (AId X) (ANum 2)\n\n> XtimesYinZ : Com\n> XtimesYinZ =\n> Z ::= AMult (AId X) (AId Y)\n\n> subtract_slowly_body : Com\n> subtract_slowly_body = do\n> Z ::= AMinus (AId Z) (ANum 1)\n> X ::= AMinus (AId X) (ANum 1)\n\n\n==== Loops\n\n> subtract_slowly : Com\n> subtract_slowly =\n> WHILE (BNot (BEq (AId X) (ANum 0))) $ do\n> subtract_slowly_body\n\n> subtract_3_from_5_slowly : Com\n> subtract_3_from_5_slowly = do\n> X ::= ANum 3\n> Z ::= ANum 5\n> subtract_slowly\n\n\n==== An infinite loop:\n\n> loop : Com\n> loop = WHILE BTrue SKIP\n\n\n== Evaluating Commands\n\nNext we need to define what it means to evaluate an Imp command. The fact that\n\\idr{WHILE} loops don't necessarily terminate makes defining an evaluation\nfunction tricky...\n\n\n=== Evaluation as a Function (Failed Attempt)\n\nHere's an attempt at defining an evaluation function for commands, omitting the\n\\idr{WHILE} case.\n\n> ceval_fun_no_while : (st : State) -> (c : Com) -> State\n> ceval_fun_no_while st CSkip = st\n> ceval_fun_no_while st (CAss x a) = t_update x (aeval st a) st\n> ceval_fun_no_while st (CSeq c1 c2) =\n> let st' = ceval_fun_no_while st c1\n> in ceval_fun_no_while st' c2\n> ceval_fun_no_while st (CIf b c1 c2) =\n> if beval st b\n> then ceval_fun_no_while st c1\n> else ceval_fun_no_while st c2\n> ceval_fun_no_while st (CWhile b c) = st -- bogus\n\nIn a traditional functional programming language like OCaml or Haskell we could\nadd the \\idr{WHILE} case as follows:\n\n```idris\n...\nceval_fun st (CWhile b c) =\n if (beval st b)\n then ceval_fun st (CSeq c $ CWhile b c)\n else st\n```\n\nIdris doesn't accept such a definition (\"Imp.ceval_fun is possibly not total due\nto recursive path Imp.ceval_fun --> Imp.ceval_fun --> Imp.ceval_fun\") because\nthe function we want to define is not guaranteed to terminate. Indeed, it\n_doesn't_ always terminate: for example, the full version of the \\idr{ceval_fun}\nfunction applied to the \\idr{loop} program above would never terminate. Since\nIdris is not just a functional programming language but also a consistent logic,\nany potentially non-terminating function needs to be rejected. Here is an\n(invalid!) program showing what would go wrong if Idris allowed non-terminating\nrecursive functions:\n\n\\ \\todo[inline]{Edit, discuss \\idr{partial}}\n\n```idris\nloop_false : (n : Nat) -> Void\nloop_false n = loop_false n\n```\n\nThat is, propositions like \\idr{Void} would become provable (\\idr{loop_false 0}\nwould be a proof of \\idr{Void}), which would be a disaster for Idris's logical\nconsistency.\n\nThus, because it doesn't terminate on all inputs, \\idr{ceval_fun} cannot be\nwritten in Idris — at least not without additional tricks and workarounds (see\nchapter `ImpCEvalFun` if you're curious about what those might be).\n\n\n=== Evaluation as a Relation\n\nHere's a better way: define \\idr{CEval} as a _relation_ rather than a _function_\n— i.e., define it with \\idr{data}, as we did for \\idr{AEvalR} above.\n\nThis is an important change. Besides freeing us from awkward workarounds, it\ngives us a lot more flexibility in the definition. For example, if we add\nnondeterministic features like \\idr{any} to the language, we want the definition\nof evaluation to be nondeterministic — i.e., not only will it not be total, it\nwill not even be a function!\n\nWe'll use the notation \\idr{c / st \\\\ st'} for the \\idr{CEval} relation:\n\\idr{c / st \\\\ st'} means that executing program \\idr{c} in a starting state\n\\idr{st} results in an ending state \\idr{st'}. This can be pronounced \"\\idr{c}\ntakes state \\idr{st} to \\idr{st'}\".\n\n\n==== Operational Semantics\n\nHere is an informal definition of evaluation, presented as inference rules for\nreadability:\n\n\\[\n \\begin{prooftree}\n \\infer0[\\idr{E_Skip}]{\\idr{SKIP / st \\\\ st}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{aeval st a1 = n}}\n \\infer1[\\idr{E_Ass}]{\\idr{x := a1 / st \\\\ (t_update st x n)}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{c1 / st \\\\ st'}}\n \\hypo{\\idr{c2 / st' \\\\ st''}}\n \\infer2[\\idr{E_Seq}]{\\idr{c1;;c2 / st \\\\ st''}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{beval st b1 = True}}\n \\hypo{\\idr{c1 / st \\\\ st'}}\n \\infer2[\\idr{E_IfTrue}]{\\idr{IF b1 THEN c1 ELSE c2 FI / st \\\\ st'}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{beval st b1 = False}}\n \\hypo{\\idr{c2 / st \\\\ st'}}\n \\infer2[\\idr{E_IfFalse}]{\\idr{IF b1 THEN c1 ELSE c2 FI / st \\\\ st'}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{beval st b = False}}\n \\infer1[\\idr{E_WhileEnd}]{\\idr{WHILE b DO c END / st \\\\ st}}\n \\end{prooftree}\n\\]\n\n\\[\n \\begin{prooftree}\n \\hypo{\\idr{beval st b = True}}\n \\hypo{\\idr{c / st \\\\ st'}}\n \\hypo{\\idr{WHILE b DO c END / st' \\\\ st''}}\n \\infer3[\\idr{E_WhileLoop}]{\\idr{WHILE b DO c END / st \\\\ st''}}\n \\end{prooftree}\n\\]\n\nHere is the formal definition. Make sure you understand how it corresponds to\nthe inference rules.\n\n> data CEval : Com -> State -> State -> Type where\n> E_Skip : CEval CSkip st st\n> E_Ass : aeval st a1 = n -> CEval (CAss x a1) st (t_update x n st)\n> E_Seq : CEval c1 st st' -> CEval c2 st' st'' ->\n> CEval (CSeq c1 c2) st st''\n> E_IfTrue : beval st b = True -> CEval c1 st st' ->\n> CEval (CIf b c1 c2) st st'\n> E_IfFalse : beval st b = False -> CEval c2 st st' ->\n> CEval (CIf b c1 c2) st st'\n> E_WhileEnd : beval st b = False ->\n> CEval (CWhile b c) st st\n> E_WhileLoop : beval st b = True ->\n> CEval c st st' -> CEval (CWhile b c) st' st'' ->\n> CEval (CWhile b c) st st''\n\n> syntax [c1] \"/\" [st] \"\\\\\\\\\" [st'] = CEval c1 st st'\n\nThe cost of defining evaluation as a relation instead of a function is that we\nnow need to construct _proofs_ that some program evaluates to some result state,\nrather than just letting Idris's computation mechanism do it for us.\n\n test : Com\n test = do \n X ::= ANum 2\n IFB BLe (AId X) (ANum 1)\n THEN (Y ::= ANum 3)\n ELSE (Z ::= ANum 4)\n FI\n\n\n> ceval_example1 : (do\n> X ::= ANum 2\n> IFB BLe (AId X) (ANum 1)\n> THEN (Y ::= ANum 3)\n> ELSE (Z ::= ANum 4)\n> FI) \n> / Imp.empty_state \n> \\\\ (t_update Z 4 $ t_update X 2 $ Imp.empty_state)\n> ceval_example1 =\n> E_Seq\n> (E_Ass Refl)\n> (E_IfFalse Refl\n> (E_Ass Refl))\n\n\n==== Exercise: 2 stars (ceval_example2)\n\n> ceval_example2 : (do \n> X ::= ANum 0\n> Y ::= ANum 1\n> Z ::= ANum 2)\n> / Imp.empty_state\n> \\\\ (t_update Z 2 $ t_update Y 1 $ t_update X 0 $ Imp.empty_state)\n> ceval_example2 = ?ceval_example2_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars, advanced (pup_to_n)\n\nWrite an Imp program that sums the numbers from \\idr{1} to \\idr{X} (inclusive:\n\\idr{1 + 2 + ... + X}) in the variable \\idr{Y}. Prove that this program executes\nas intended for \\idr{X = 2} (this is trickier than you might expect).\n\n> pup_to_n : Com\n> pup_to_n = ?pup_to_n_rhs\n\n> pup_to_2_ceval :\n> Imp.pup_to_n / (t_update X 2 Imp.empty_state) \\\\\n> (t_update X 0 $\n> t_update Y 3 $\n> t_update X 1 $\n> t_update Y 2 $\n> t_update Y 0 $\n> t_update X 2 $ \n> Imp.empty_state)\n> pup_to_2_ceval = ?pup_to_2_ceval_rhs\n\n$\\square$\n\n\n=== Determinism of Evaluation\n\nChanging from a computational to a relational definition of evaluation is a good\nmove because it frees us from the artificial requirement that evaluation should\nbe a total function. But it also raises a question: Is the second definition of\nevaluation really a partial function? Or is it possible that, beginning from the\nsame state \\idr{st}, we could evaluate some command \\idr{c} in different ways to\nreach two different output states \\idr{st'} and \\idr{st''}?\n\nIn fact, this cannot happen: \\idr{CEval} _is_ a partial function:\n\n> ceval_deterministic : (c / st \\\\ st1) -> (c / st \\\\ st2) -> st1 = st2\n> ceval_deterministic E_Skip E_Skip = Refl\n> ceval_deterministic (E_Ass aev1) (E_Ass aev2) =\n> rewrite sym aev1 in\n> rewrite sym aev2 in Refl\n> ceval_deterministic {st2} (E_Seq cev11 cev12)\n> (E_Seq {c2} cev21 cev22) =\n> let ih = ceval_deterministic cev11 cev21\n> cev22' = replace (sym ih) cev22 {P=\\x=>CEval c2 x st2}\n> in ceval_deterministic cev12 cev22'\n> ceval_deterministic (E_IfTrue _ cev1) (E_IfTrue _ cev2) =\n> ceval_deterministic cev1 cev2\n> ceval_deterministic (E_IfTrue prf1 _) (E_IfFalse prf2 _) =\n> absurd $ replace prf1 prf2 {P=\\x=>x=False}\n> ceval_deterministic (E_IfFalse prf1 _) (E_IfTrue prf2 _) =\n> absurd $ replace prf2 prf1 {P=\\x=>x=False}\n> ceval_deterministic (E_IfFalse _ cev1) (E_IfFalse _ cev2) =\n> ceval_deterministic cev1 cev2\n> ceval_deterministic (E_WhileEnd _) (E_WhileEnd _) = Refl\n> ceval_deterministic (E_WhileEnd prf1) (E_WhileLoop prf2 _ _) =\n> absurd $ replace prf2 prf1 {P=\\x=>x=False}\n> ceval_deterministic (E_WhileLoop prf1 _ _) (E_WhileEnd prf2) =\n> absurd $ replace prf1 prf2 {P=\\x=>x=False}\n> ceval_deterministic {st2} (E_WhileLoop _ cev11 cev12)\n> (E_WhileLoop {b} {c} _ cev21 cev22) =\n> let ih = ceval_deterministic cev11 cev21\n> cev22' = replace (sym ih) cev22 {P=\\x=>CEval (CWhile b c) x st2}\n> in ceval_deterministic cev12 cev22'\n\n\n== Reasoning About Imp Programs\n\nWe'll get deeper into systematic techniques for reasoning about Imp programs in\nthe following chapters, but we can do quite a bit just working with the bare\ndefinitions. This section explores some examples.\n\n> plus2_spec : st X = n -> (Imp.plus2 / st \\\\ st') -> st' X = n + 2\n\n\\todo[inline]{Edit}\n\nInverting `Heval` essentially forces Idris to expand one step of the \\idr{CEval}\ncomputation — in this case revealing that \\idr{st'} must be st extended with the\nnew value of \\idr{X}, since \\idr{plus2} is an assignment\n\n> plus2_spec Refl (E_Ass Refl) = Refl\n\n\n==== Exercise: 3 stars, recommendedM (XtimesYinZ_spec)\n\nState and prove a specification of \\idr{XtimesYinZ}.\n\n> -- FILL IN HERE\n\n$\\square$\n\n\n==== Exercise: 3 stars, recommended (loop_never_stops)\n\n> loop_never_stops : Not (Imp.loop / st \\\\ st')\n> loop_never_stops contra = ?loop_never_stops_rhs\n\n\\todo[inline]{Edit the hint}\n\n```coq\nProof.\n intros st st' contra. unfold loop in contra.\n remember (WHILE BTrue DO SKIP END) as loopdef\n eqn:Heqloopdef.\n```\n\nProceed by induction on the assumed derivation showing that loopdef terminates.\nMost of the cases are immediately contradictory (and so can be solved in one\nstep with inversion).\n\n (* FILL IN HERE *) Admitted.\n\n$\\square$\n\n\n==== Exercise: 3 stars (no_whilesR)\n\nConsider the following function:\n\n> no_whiles : (c : Com) -> Bool\n> no_whiles CSkip = True\n> no_whiles (CAss _ _) = True\n> no_whiles (CSeq c1 c2) = (no_whiles c1) && (no_whiles c2)\n> no_whiles (CIf _ ct cf) = (no_whiles ct) && (no_whiles cf)\n> no_whiles (CWhile _ _) = False\n\nThis predicate yields \\idr{True} just on programs that have no while loops.\nUsing \\idr{data}, write a property \\idr{No_whilesR} such that \\idr{No_whilesR c}\nis provable exactly when \\idr{c} is a program with no while loops. Then prove\nits equivalence with \\idr{no_whiles}.\n\n> data No_whilesR : Com -> Type where\n> Remove_Me_No_whilesR : No_whilesR CSkip\n\n> no_whiles_eqv : (no_whiles c = True) <-> (No_whilesR c)\n> no_whiles_eqv = ?no_whiles_eqv_rhs\n\n$\\square$\n\n\n==== Exercise: 4 starsM (no_whiles_terminating)\n\nImp programs that don't involve while loops always terminate. State and prove a\ntheorem \\idr{no_whiles_terminating} that says this. Use either \\idr{no_whiles}\nor \\idr{No_whilesR}, as you prefer.\n\n> -- FILL IN HERE\n\n$\\square$\n\n\n== Additional Exercises\n\n\n==== Exercise: 3 stars (stack_compiler)\n\nHP Calculators, programming languages like Forth and Postscript and abstract\nmachines like the Java Virtual Machine all evaluate arithmetic expressions using\na stack. For instance, the expression\n\n```\n (2*3)+(3*(4-2))\n```\n\nwould be entered as\n\n```\n 2 3 * 3 4 2 - * +\n```\n\nand evaluated like this (where we show the program being evaluated on the right\nand the contents of the stack on the left):\n\n```\n [ ] | 2 3 * 3 4 2 - * +\n [2] | 3 * 3 4 2 - * +\n [3, 2] | * 3 4 2 - * +\n [6] | 3 4 2 - * +\n [3, 6] | 4 2 - * +\n [4, 3, 6] | 2 - * +\n [2, 4, 3, 6] | - * +\n [2, 3, 6] | * +\n [6, 6] | +\n [12] |\n```\n\nThe task of this exercise is to write a small compiler that translates\n\\idr{AExp}s into stack machine instructions.\n\nThe instruction set for our stack language will consist of the following\ninstructions:\n\n - \\idr{SPush n}: Push the number \\idr{n} on the stack.\n\n - \\idr{SLoad x}: Load the identifier \\idr{x} from the store and push it on the\n stack\n\n - \\idr{SPlus}: Pop the two top numbers from the stack, add them, and push the\n result onto the stack.\n\n - \\idr{SMinus}: Similar, but subtract.\n\n - \\idr{SMult}: Similar, but multiply.\n\n> data SInstr : Type where\n> SPush : Nat -> SInstr\n> SLoad : Id -> SInstr\n> SPlus : SInstr\n> SMinus : SInstr\n> SMult : SInstr\n\nWrite a function to evaluate programs in the stack language. It should take as\ninput a state, a stack represented as a list of numbers (top stack item is the\nhead of the list), and a program represented as a list of instructions, and it\nshould return the stack after executing the program. Test your function on the\nexamples below.\n\nNote that the specification leaves unspecified what to do when encountering an\n\\idr{SPlus}, \\idr{SMinus}, or \\idr{SMult} instruction if the stack contains less\nthan two elements. In a sense, it is immaterial what we do, since our compiler\nwill never emit such a malformed program.\n\n> s_execute : (st : State) -> (stack : List Nat) -> (prog : List SInstr) ->\n> List Nat\n> s_execute st stack prog = ?s_execute_rhs\n\n> s_execute1 : s_execute Imp.empty_state [] [SPush 5, SPush 3, SPush 1, SMinus]\n> = [2,5]\n> s_execute1 = ?s_execute1_rhs\n\n> s_execute2 : s_execute (t_update X 3 Imp.empty_state) [3,4]\n> [SPush 4, SLoad X, SMult, SPlus]\n> = [15,4]\n> s_execute2 = ?s_execute2_rhs\n\nNext, write a function that compiles an \\idr{AExp} into a stack machine program.\nThe effect of running the program should be the same as pushing the value of the\nexpression on the stack.\n\n> s_compile : (e : AExp) -> List SInstr\n> s_compile e = ?s_compile_rhs\n\nAfter you've defined \\idr{s_compile}, prove the following to test that it works.\n\n> s_compile1 : s_compile (AMinus (AId X) (AMult (ANum 2) (AId Y)))\n> = [SLoad X, SPush 2, SLoad Y, SMult, SMinus]\n> s_compile1 = ?s_compile1_rhs\n\n$\\square$\n\n\n==== Exercise: 4 stars, advanced (stack_compiler_correct)\n\nNow we'll prove the correctness of the compiler implemented in the previous\nexercise. Remember that the specification left unspecified what to do when\nencountering an \\idr{SPlus}, \\idr{SMinus}, or \\idr{SMult} instruction if the\nstack contains less than two elements. (In order to make your correctness proof\neasier you might find it helpful to go back and change your implementation!)\n\nProve the following theorem. You will need to start by stating a more general\nlemma to get a usable induction hypothesis; the main theorem will then be a\nsimple corollary of this lemma.\n\n\\ \\todo[inline]{Tip: make parameters explicit in general lemma, or Idris will \nget lost}\n\n> s_compile_correct : (st : State) -> (e : AExp) -> s_execute st [] (s_compile e) = [aeval st e]\n> s_compile_correct st e = ?s_compile_correct_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars, optional (short_circuit)\n\n\\ \\todo[inline]{This already happens since Idris's \\idr{&&} short-circuits}\n\nMost modern programming languages use a \"short-circuit\" evaluation rule for\nboolean \\idr{and}: to evaluate \\idr{BAnd b1 b2}, first evaluate \\idr{b1}. If it\nevaluates to \\idr{False}, then the entire \\idr{BAnd} expression evaluates to\n\\idr{False} immediately, without evaluating \\idr{b2}. Otherwise, \\idr{b2} is\nevaluated to determine the result of the \\idr{BAnd} expression.\n\nWrite an alternate version of \\idr{beval} that performs short-circuit\nevaluation of \\idr{BAnd} in this manner, and prove that it is equivalent to\n\\idr{beval}.\n\n> -- FILL IN HERE\n\n$\\square$\n\n\n==== Exercise: 4 stars, advanced (break_imp)\n\nImperative languages like C and Java often include a \\idr{break} or similar\nstatement for interrupting the execution of loops. In this exercise we consider\nhow to add \\idr{break} to Imp. First, we need to enrich the language of commands\nwith an additional case.\n\n> namespace ComBreak\n\n> data ComB : Type where\n> CSkipB : ComB\n> CBreakB : ComB -- <-- new\n> CAssB : Id -> AExp -> ComB\n> CSeqB : ComB -> ComB -> ComB\n> CIfB : BExp -> ComB -> ComB -> ComB\n> CWhileB : BExp -> ComB -> ComB\n\n> infix 5 ::=\n\n> SKIP : ComB\n> SKIP = CSkipB\n\n> BREAK : ComB\n> BREAK = CBreakB\n\n> (::=) : Id -> AExp -> ComB\n> (::=) = CAssB\n\n> (>>=) : ComB -> (() -> ComB) -> ComB\n> (>>=) c f = CSeqB c (f ())\n\n> WHILE : BExp -> ComB -> ComB\n> WHILE = CWhileB\n\n> syntax IFB [c1] THEN [c2] ELSE [c3] FI = CIfB c1 c2 c3\n\nNext, we need to define the behavior of \\idr{BREAK}. Informally, whenever\n\\idr{BREAK} is executed in a sequence of commands, it stops the execution of\nthat sequence and signals that the innermost enclosing loop should terminate.\n(If there aren't any enclosing loops, then the whole program simply terminates.)\nThe final state should be the same as the one in which the \\idr{BREAK} statement\nwas executed.\n\nOne important point is what to do when there are multiple loops enclosing a\ngiven \\idr{BREAK}. In those cases, \\idr{BREAK} should only terminate the\n_innermost_ loop. Thus, after executing the following...\n\n```\n X ::= 0;;\n Y ::= 1;;\n WHILE not (0 == Y) DO\n WHILE TRUE DO\n BREAK\n END;;\n X ::= 1;;\n Y ::= Y - 1\n END\n```\n\n... the value of \\idr{X} should be \\idr{1}, and not \\idr{0}.\n\nOne way of expressing this behavior is to add another parameter to the\nevaluation relation that specifies whether evaluation of a command executes a\n\\idr{BREAK} statement:\n\n> data Result : Type where\n> SContinue : Result\n> SBreak : Result\n\nIntuitively, \\idr{c // st \\\\ s / st'} means that, if \\idr{c} is started in state\n\\idr{st}, then it terminates in state \\idr{st'} and either signals that the\ninnermost surrounding loop (or the whole program) should exit immediately\n(\\idr{s = SBreak}) or that execution should continue normally\n(\\idr{s = SContinue}).\n\nThe definition of the \"\\idr{c // st \\\\ s / st'}\" relation is very similar to the\none we gave above for the regular evaluation relation (\\idr{c / st \\\\ st'}) —\nwe just need to handle the termination signals appropriately:\n\n - If the command is \\idr{SKIP}, then the state doesn't change and execution of\n any enclosing loop can continue normally.\n\n - If the command is \\idr{BREAK}, the state stays unchanged but we signal a\n \\idr{SBreak}.\n\n - If the command is an assignment, then we update the binding for that\n variable in the state accordingly and signal that execution can continue\n normally.\n\n - If the command is of the form \\idr{IFB b THEN c1 ELSE c2 FI}, then the state\n is updated as in the original semantics of Imp, except that we also\n propagate the signal from the execution of whichever branch was taken.\n\n - If the command is a sequence \\idr{c1 ;; c2}, we first execute \\idr{c1}. If\n this yields a \\idr{SBreak}, we skip the execution of \\idr{c2} and propagate\n the \\idr{SBreak} signal to the surrounding context; the resulting state is\n the same as the one obtained by executing \\idr{c1} alone. Otherwise, we\n execute \\idr{c2} on the state obtained after executing \\idr{c1}, and\n propagate the signal generated there.\n\n - Finally, for a loop of the form \\idr{WHILE b DO c END}, the semantics is\n almost the same as before. The only difference is that, when \\idr{b}\n evaluates to \\idr{True}, we execute \\idr{c} and check the signal that it\n raises. If that signal is \\idr{SContinue}, then the execution proceeds as in\n the original semantics. Otherwise, we stop the execution of the loop, and\n the resulting state is the same as the one resulting from the execution of\n the current iteration. In either case, since \\idr{BREAK} only terminates the\n innermost loop, \\idr{WHILE} signals \\idr{SContinue}.\n\nBased on the above description, complete the definition of the \\idr{CEvalB}\nrelation.\n\n> data CEvalB : ComB -> State -> Result -> State -> Type where\n> E_SkipB : CEvalB CSkipB st SContinue st\n> -- FILL IN HERE\n\n> syntax [c1] \"//\" [st] \"\\\\\\\\\" [s] \"/\" [st'] = CEvalB c1 st s st'\n\nNow prove the following properties of your definition of \\idr{CEvalB}:\n\n> break_ignore : ((do BREAK; c) // st \\\\ s / st') -> st = st'\n> break_ignore x = ?break_ignore_rhs\n\n\n> while_continue : ((WHILE b c) // st \\\\ s / st') -> s = SContinue\n> while_continue x = ?while_continue_rhs\n\n> while_stops_on_break : beval st b = True ->\n> (c // st \\\\ SBreak / st') ->\n> ((WHILE b c) // st \\\\ SContinue / st')\n> while_stops_on_break prf x = ?while_stops_on_break_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars, advanced, optional (while_break_true)\n\n> while_break_true : ((WHILE b c) // st \\\\ SContinue / st') ->\n> beval st' b = True ->\n> (st'' ** c // st'' \\\\ SBreak / st')\n> while_break_true x prf = ?while_break_true_rhs\n\n$\\square$\n\n\n==== Exercise: 4 stars, advanced, optional (cevalB_deterministic)\n\nThese will come in handy in the following exercise:\n\n> Uninhabited (SBreak = SContinue) where\n> uninhabited Refl impossible\n>\n> Uninhabited (SContinue = SBreak) where\n> uninhabited Refl impossible\n\n> cevalB_deterministic : (c // st \\\\ s1 / st1) ->\n> (c // st \\\\ s2 / st2) ->\n> (st1 = st2, s1 = s2)\n> cevalB_deterministic x y = ?cevalB_deterministic_rhs\n\n$\\square$\n\n\n==== Exercise: 4 stars, optional (add_for_loop)\n\nAdd C-style \\idr{for} loops to the language of commands, update the \\idr{CEval}\ndefinition to define the semantics of \\idr{for} loops, and add cases for\n\\idr{for} loops as needed so that all the proofs in this file are accepted by\nIdris.\n\nA \\idr{for} loop should be parameterized by (a) a statement executed initially,\n(b) a test that is run on each iteration of the loop to determine whether the\nloop should continue, (c) a statement executed at the end of each loop\niteration, and (d) a statement that makes up the body of the loop. (You don't\nneed to worry about making up a concrete notation for \\idr{for} loops, but feel\nfree to play with this too if you like.)\n\n> -- FILL IN HERE\n\n$\\square$\n", "meta": {"hexsha": "881f420c4322595b4d824b3fb24c12ab03b41f53", "size": 56984, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/Imp.lidr", "max_stars_repo_name": "diseraluca/software-foundations", "max_stars_repo_head_hexsha": "03e178fc616e50019c4168fb488f67fbfb46fafa", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 452, "max_stars_repo_stars_event_min_datetime": "2016-06-23T10:03:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T22:25:00.000Z", "max_issues_repo_path": "src/Imp.lidr", "max_issues_repo_name": "diseraluca/software-foundations", "max_issues_repo_head_hexsha": "03e178fc616e50019c4168fb488f67fbfb46fafa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 53, "max_issues_repo_issues_event_min_datetime": "2016-06-27T07:14:38.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-23T06:16:57.000Z", "max_forks_repo_path": "src/Imp.lidr", "max_forks_repo_name": "diseraluca/software-foundations", "max_forks_repo_head_hexsha": "03e178fc616e50019c4168fb488f67fbfb46fafa", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 39, "max_forks_repo_forks_event_min_datetime": "2016-11-21T10:55:05.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T00:21:55.000Z", "avg_line_length": 32.7494252874, "max_line_length": 96, "alphanum_fraction": 0.6795767233, "num_tokens": 17502, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.523016853910984}} {"text": "-- --------------------------------------------------------------- [ DVect.idr ]\n-- Module : DVect.idr\n-- Copyright : (c) 2015,2016 See CONTRIBUTORS.md\n-- License : see LICENSE\n-- --------------------------------------------------------------------- [ EOH ]\n||| A `list` construct to create lists of dependent types.\n|||\n||| One of the problems with using dependent types is that types\n||| depend on values. This affects the ability to construct lists of\n||| values that have a dependent type. The existing `List` type cannot\n||| be used as it requires all elements to have the same type.\nmodule Toolkit.Data.DVect\n\nimport Data.Nat\nimport Data.String\n\nimport public Data.Vect\nimport public Data.Vect.Elem\n\nimport public Toolkit.Decidable.Equality.Indexed\n\n%default total\n\n\n||| A list construct for dependent types.\n|||\n||| @aTy The type of the value contained within the list element type.\n||| @len The length of the list.\n||| @elemTy The type of the elements within the list\n||| @as The List used to contain the different values within the type.\npublic export\ndata DVect : (aTy : Type)\n -> (elemTy : aTy -> Type)\n -> (len : Nat)\n -> (as : Vect len aTy)\n -> Type where\n ||| Create an empty List\n Nil : DVect aTy elemTy Z Nil\n ||| Cons\n |||\n ||| @ex The element to add\n ||| @rest The list for `elem` to be added to.\n (::) : {x : aTy}\n -> (ex : elemTy x)\n -> (rest : DVect aTy elemTy n xs)\n -> DVect aTy elemTy (S n) (x::xs)\n\npublic export\nsize : DVect a e l as -> Nat\nsize Nil = Z\nsize (x::xs) = 1 + size xs\n\npublic export\nmapToVect : (forall x . e x -> b)\n -> DVect a e n xs\n -> Vect n b\nmapToVect _ Nil = Nil\nmapToVect f (x::xs) = f x :: mapToVect f xs\n\ntoList : Vect q a -> List a\ntoList Nil = Nil\ntoList (x::xs) = x :: DVect.toList xs\n\n||| Function to show a `DList`.\n|||\n||| Due to limitations in idris wrt to class instances on dependent\n||| types a generic show instance cannot be defined for\n||| sigmalist. This will cause minor annoyances in its use.\n|||\n||| @showFunc A function to show the elements\n||| @l The list to be Shown.\npublic export\nshowDVect : (showFunc : forall a . elemTy a -> String)\n -> (l : DVect aTy elemTy n as)\n -> String\nshowDVect f xs = \"[\" ++ unwords asList ++ \"]\"\n where\n asList : List String\n asList = DVect.toList $ intersperse \",\" (mapToVect f xs)\n\nnamespace Alternative\n public export\n index : DVect aTy elemTy n as\n -> Elem a as\n -> elemTy a\n index (x::xs) Here = x\n index (x::xs) (There later) = index xs later\n\n public export\n update : (vs : DVect iTy eTy l is)\n -> (idx : Elem i is)\n -> (new : eTy i)\n -> DVect iTy eTy l is\n update (ex :: rest) Here new = new :: rest\n update (ex :: rest) (There later) new = ex :: update rest later new\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "6d1caef6143c7baffd4b072ae0922148fc8f9e16", "size": 2920, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/DVect.idr", "max_stars_repo_name": "gallais/linear-circuits", "max_stars_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2020-11-03T11:33:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T17:11:38.000Z", "max_issues_repo_path": "src/Toolkit/Data/DVect.idr", "max_issues_repo_name": "gallais/linear-circuits", "max_issues_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Toolkit/Data/DVect.idr", "max_forks_repo_name": "gallais/linear-circuits", "max_forks_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-09T19:49:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T19:49:11.000Z", "avg_line_length": 29.7959183673, "max_line_length": 80, "alphanum_fraction": 0.5794520548, "num_tokens": 818, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.5228635368820773}} {"text": "-- a mini prelude\n\nmodule Stuff\n\npublic export\ndata Bool = True | False\n\npublic export\nnot : Bool -> Bool\nnot True = False\nnot False = True\n\npublic export\ndata Maybe a = Nothing | Just a\n\ninfixl 4 &&\n\npublic export\n(&&) : Bool -> Lazy Bool -> Bool\n(&&) True x = x\n(&&) False x = False\n\npublic export\nintToBool : Int -> Bool\nintToBool 0 = False\nintToBool x = True\n\npublic export\nifThenElse : Bool -> Lazy a -> Lazy a -> a\nifThenElse True t e = t\nifThenElse False t e = e\n\npublic export\ndata Nat = Z | S Nat\n\npublic export\nfromInteger : Integer -> Nat\nfromInteger x = ifThenElse (intToBool (prim__eq_Integer x 0))\n Z (S (fromInteger (prim__sub_Integer x 1)))\n\npublic export\nplus : Nat -> Nat -> Nat\nplus Z y = y\nplus (S k) y = S (plus k y)\n\ninfixr 5 ::\n\npublic export\ndata List a = Nil | (::) a (List a)\n\npublic export\ndata Equal : a -> b -> Type where\n Refl : {0 x : a} -> Equal x x\n\npublic export\ndata Unit = MkUnit\n\nnamespace Builtin -- hardcoded into elaborator!\n public export\n data Pair : Type -> Type -> Type where\n MkPair : {0 a, b : Type} -> (1 x : a) -> (1 y : b) -> Pair a b\n\npublic export\nfst : {0 a, b : Type} -> (a, b) -> a\nfst (x, y) = x\n\npublic export\nsnd : {0 a, b : Type} -> (a, b) -> b\nsnd (x, y) = y\n\n%pair Pair fst snd\n\nnamespace DPair\n public export\n data DPair : (a : Type) -> (a -> Type) -> Type where\n MkDPair : (x : a) -> p x -> DPair a p\n\n fst : DPair a p -> a\n fst (MkDPair x y) = x\n\n snd : (x : DPair a p) -> p (fst x)\n snd (MkDPair x y) = y\n\npublic export\ndata Unrestricted : Type -> Type where\n Un : (x : a) -> Unrestricted a\n\npublic export\nthe : (a : Type) -> a -> a\nthe _ x = x\n\npublic export\nid : a -> a\nid x = x\n\npublic export\ndata Void : Type where\n\npublic export\ndata Dec : Type -> Type where\n Yes : a -> Dec a\n No : (a -> Void) -> Dec a\n\n", "meta": {"hexsha": "1d3da36dff63d2ae2a9cac8987608995d5ab46bc", "size": 1845, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/basic009/Stuff.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/idris2/basic009/Stuff.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/idris2/basic009/Stuff.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7403846154, "max_line_length": 69, "alphanum_fraction": 0.593495935, "num_tokens": 615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.5226033313320372}} {"text": "module Diff\n\n-- Based on https://arxiv.org/pdf/1803.10228.pdf\n\nimport src.Expr\n\n\ninterface DiffSymantics (rep : TypeT -> Type) where\n d : Double -> rep DoubleT\n (+) : rep DoubleT -> rep DoubleT -> rep DoubleT\n (*) : rep DoubleT -> rep DoubleT -> rep DoubleT\n grad : (rep DoubleT -> rep DoubleT) -> Code (ArrowT DoubleT DoubleT)\n\n\ndata Reverse : TypeT -> Type where\n R : (((Code DoubleT, Code (VarT DoubleT)) -> Code UnitT) -> Code UnitT) -> Reverse a\n\n\nDiffSymantics Reverse where\n d x = R (\\k => letVal (double x) (\\x => newVar (double 0) (\\d => k (x, d))))\n\n (+) (R l) (R r) = R (\\k => l (\\(lv, ld) =>\n r (\\(rv, rd) => letVal (lv <+> rv) (\\x =>\n newVar (double 0) (\\d =>\n seqs [k (x, d),\n assign (deref ld <+> deref d) ld,\n assign (deref rd <+> deref d) rd])))))\n\n (*) (R l) (R r) = R (\\k => l (\\(lv, ld) =>\n r (\\(rv, rd) => letVal (lv <*> rv) (\\x =>\n newVar (double 0) (\\d =>\n seqs [k (x, d),\n assign ((deref d <*> rv) <+> deref ld) ld,\n assign ((deref d <*> lv) <+> deref rd) rd])))))\n\n grad f = lam (\\x => newVar (double 0) (\\d => let (R g) = f $ R (\\k => k (x, d)) in\n seq (g (\\(_, d) => assign (double 1) d)) (deref d)))\n\nexample : DiffSymantics rep => rep DoubleT -> rep DoubleT\nexample x = (d 2 * x) + (x * x * x)\n\ntest : String\ntest = compile (grad {rep = Reverse} example)\n", "meta": {"hexsha": "2a18a266471f32ac6ae1f55032a77fd5564173a3", "size": 1779, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Diff.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/Diff.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Diff.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 40.4318181818, "max_line_length": 100, "alphanum_fraction": 0.3962900506, "num_tokens": 479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972717658209, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.5225223481175388}} {"text": "occurrences : Eq ty => (item : ty) -> (values : List ty) -> Nat\noccurrences item [] = 0\noccurrences item (x :: xs) = case x == item of\n False => occurrences item xs\n True => 1 + occurrences item xs\n", "meta": {"hexsha": "68da020066c18cb644ae1cefffcc7af78e8dbb63", "size": 264, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter-07/eq.idr", "max_stars_repo_name": "tekerson/type-driven-development", "max_stars_repo_head_hexsha": "52f1cf8dddd90c3306e8ded109bc4a3eff03b1b1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2016-10-23T04:46:42.000Z", "max_stars_repo_stars_event_max_datetime": "2016-10-23T04:46:42.000Z", "max_issues_repo_path": "Chapter-07/eq.idr", "max_issues_repo_name": "tekerson/type-driven-development", "max_issues_repo_head_hexsha": "52f1cf8dddd90c3306e8ded109bc4a3eff03b1b1", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Chapter-07/eq.idr", "max_forks_repo_name": "tekerson/type-driven-development", "max_forks_repo_head_hexsha": "52f1cf8dddd90c3306e8ded109bc4a3eff03b1b1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.0, "max_line_length": 65, "alphanum_fraction": 0.4734848485, "num_tokens": 61, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.5222973144658911}} {"text": "\nmodule R\n\n-- Definition of the logical relation 'R'\n-- that is central to proving normalization\n-- for the simply-typed lambda calculus\n-- (with primitive recursion).\n\n\nimport Determinism\nimport PnP\nimport Step\nimport Term\nimport Typing\n\n\n%default total\n%access export\n\n\n\n---------------------------\n-- Begin: PREDICATE 'HALTS'\n\n-- The predicate 'Halts' defines what it\n-- means that the evaluation of a term 'e'\n-- under 'Step' terminates - namely that\n-- the term 'e' must evaluate to a value:\npublic export\ndata Halts : Term -> Type where\n H : (e : Term) ->\n (e' : Term ** (Value e', TransStep e e'))\n -> Halts e\n\n\n-- For terms 'e1' and 'e2', if one of them steps\n-- to the other, then either both satisfy 'Halts'\n-- or neither term does; in formulae:\n-- \n-- Step e1 e2 => (Halts e1 <=> Halts e2)\n--\n-- The following two lemmas establish this equivalence,\n-- given 'Step e1 e2'.\n-- The next two lemmas then extend this equivalence to\n-- the 'TransStep' relation.\n\nstepPreservesHalts_1 : (e : Term) -> (e' : Term) ->\n Step e e' -> Halts e -> Halts e'\nstepPreservesHalts_1 e e' step (H e ev) = case ev of\n (x ** (vx, tstx)) => case tstx of\n (TStRefl e) => absurd $ valueIrreducible e vx step\n (TStTrans st tst) => case stepDeterministic step st of\n Refl => H e' (x ** (vx, tst))\n\n\nstepPreservesHalts_2 : (e : Term) -> (e' : Term) ->\n Step e e' -> Halts e' -> Halts e\nstepPreservesHalts_2 e e' step (H e' ev) = case ev of\n (x ** (vx, tstx)) => H e (x ** (vx, TStTrans step tstx))\n\n\n\ntransStepPreservesHalts_1 : (e : Term) -> (e' : Term) ->\n TransStep e e' -> Halts e -> Halts e'\ntransStepPreservesHalts_1 e e (TStRefl e) h = h\ntransStepPreservesHalts_1 e e' (TStTrans st tst) h = \n let h' = stepPreservesHalts_1 _ _ st h\n in transStepPreservesHalts_1 _ _ tst h'\n\n\ntransStepPreservesHalts_2 : (e : Term) -> (e' : Term) ->\n TransStep e e' -> Halts e' -> Halts e\ntransStepPreservesHalts_2 e e (TStRefl e) h = h\ntransStepPreservesHalts_2 e e' (TStTrans st tst) h = \n let h' = transStepPreservesHalts_2 _ _ tst h\n in stepPreservesHalts_2 _ _ st h'\n \n\n\nhaltsAbs : (e : Term) -> Halts (TAbs e)\nhaltsAbs e = H (TAbs e) (TAbs e ** (VAbs, TStRefl (TAbs e)))\n\n\n\nhaltsZero : Halts TZero\nhaltsZero = H TZero (TZero ** (VZero, TStRefl TZero))\n\n-- End: PREDICATE 'HALTS'\n-------------------------\n\n\n\n\n--------------------------------------\n-- Begin: (UNARY) LOGICAL RELATION 'R'\n\nmutual\n public export\n r : (t : Ty) -> (e : Term) -> Type\n r TyNat e = (Typing [] e TyNat, Halts e)\n r (TyFun s t) e = (Typing [] e (s:->:t), Halts e, rFun s t e)\n\n public export\n rFun : (s : Ty) -> (t : Ty) -> (e : Term) -> Type\n rFun s t e = (y : Term) -> r s y -> r t (TApp e y)\n\n\nrTyping : (e : Term) -> r t e -> Typing [] e t\nrTyping {t = TyNat} _ r = fst r\nrTyping {t = (TyFun t1 t2)} _ r = fst r\n\n\nrHalts : r t e -> Halts e\nrHalts {t = TyNat} r = snd r\nrHalts {t = (TyFun t1 t2)} r = fst $ snd r\n\n\nrHalts' : r t e -> (e' : Term ** (Value e', TransStep e e'))\nrHalts' r = case rHalts r of\n (H _ ev) => ev\n\n\nrImplication : r (s :->: t) e -> rFun s t e\nrImplication r = snd $ snd r\n\n\n-- Forward stepping preserves the predicate 'R':\nmutual\n stepPreservesR_1 : (t : Ty) -> \n (e : Term) -> (e' : Term) ->\n Step e e' -> r t e -> r t e'\n stepPreservesR_1 TyNat e e' st (ty, h) = \n let ty' = preservation e ty st\n h' = stepPreservesHalts_1 e e' st h\n in (ty', h')\n stepPreservesR_1 (TyFun s t) e e' st (ty, h, imp) =\n let ty' = preservation e ty st\n h' = stepPreservesHalts_1 e e' st h\n imp' = stepPreservesR_1_Fun s t e e' st imp \n in (ty', h', imp')\n\n\n stepPreservesR_1_Fun : (s : Ty) -> (t : Ty) ->\n (e : Term) -> (e' : Term) ->\n Step e e' -> rFun s t e -> rFun s t e'\n stepPreservesR_1_Fun s t e e' st imp y ry = \n let r' = imp y ry\n st' = StApp1 st\n in stepPreservesR_1 t _ _ st' r'\n\n\n\n-- Backward stepping preserves the predicate 'R',\n-- but an explicit typing of the expression 'e'\n-- (i.e. the expression that steps) must be provided:\n-- (For the forward direction, an explicit typing\n-- argument is not required thanks to 'preservation'.)\nmutual\n stepPreservesR_2 : (t : Ty) -> \n (e : Term) -> (Typing [] e t) ->\n (e' : Term) ->\n Step e e' -> r t e' -> r t e\n stepPreservesR_2 TyNat e ty e' st (_, h') = \n let h = stepPreservesHalts_2 e e' st h'\n in (ty, h)\n stepPreservesR_2 (TyFun s t) e ty e' st (_, h', imp') = \n let h = stepPreservesHalts_2 e e' st h'\n imp = stepPreservesR_2_Fun s t e ty e' st imp'\n in (ty, h, imp)\n\n\n stepPreservesR_2_Fun : (s : Ty) -> (t : Ty) ->\n (e : Term) -> (Typing [] e (s :->: t)) ->\n (e' : Term) ->\n Step e e' -> rFun s t e' -> rFun s t e\n stepPreservesR_2_Fun s t e ty e' st imp' y ry = \n let r = imp' y ry \n st' = StApp1 st\n tyy = rTyping y ry\n tya = TyApp ty tyy\n in stepPreservesR_2 t _ tya _ st' r\n\n\n\ntransStepPreservesR_1 : (t : Ty) -> \n (e : Term) -> (e' : Term) ->\n TransStep e e' -> r t e -> r t e'\ntransStepPreservesR_1 t e _ (TStRefl _) re = re\ntransStepPreservesR_1 t e e' (TStTrans st tst) re = let r' = stepPreservesR_1 t _ _ st re\n in transStepPreservesR_1 t _ _ tst r'\n\n \ntransStepPreservesR_2 : (t : Ty) -> \n (e : Term) -> (Typing [] e t) ->\n (e' : Term) ->\n TransStep e e' -> r t e' -> r t e\ntransStepPreservesR_2 t e ty _ (TStRefl _) re' = re'\ntransStepPreservesR_2 t e ty e' (TStTrans st tst) re' = \n let ty1 = preservation e ty st\n r' = transStepPreservesR_2 t _ ty1 _ tst re'\n in stepPreservesR_2 t _ ty _ st r'\n\n\n\nrZero : r TyNat TZero\nrZero = (TyZero, haltsZero)\n\n-- End: (UNARY) LOGICAL RELATION 'R'\n------------------------------------\n\n\n\n\n-----------------------------------------\n-- Begin: INVERT PREDICATE 'R' OF 'TSucc' \n\ntransStepSuccInjective : TransStep (TSucc e1) (TSucc e2) -> TransStep e1 e2\ntransStepSuccInjective (TStRefl (TSucc e1)) = TStRefl _\ntransStepSuccInjective (TStTrans (StSucc st) tst) = \n let ih = transStepSuccInjective tst\n in TStTrans st ih\n\n\ntransStepSuccSucc : TransStep (TSucc e1) e2 -> (e2' : Term ** e2 = TSucc e2')\ntransStepSuccSucc (TStRefl (TSucc e1)) = (e1 ** Refl)\ntransStepSuccSucc (TStTrans (StSucc st) tst) = transStepSuccSucc tst\n\n\nsuccHaltsHalts : Typing ctx (TSucc e) TyNat -> Halts (TSucc e) -> Halts e\nsuccHaltsHalts (TySucc ty) (H (TSucc e) (_ ** (v, tst))) = \n let ty' = transPreservation (TSucc e) (TySucc ty) tst \n in case canonicalNat _ ty' v of\n (Left Refl) => let (_ ** eq) = transStepSuccSucc tst\n in case eq of Refl impossible\n (Right (_ ** (v', Refl))) => let tst' = transStepSuccInjective tst\n in H _ (_ ** (v', tst'))\n\n\nsuccRR : r TyNat (TSucc e) -> r TyNat e\nsuccRR re = let ty = rTyping _ re\n h = rHalts re\n in case ty of\n (TySucc ty') => (ty', succHaltsHalts ty h)\n \n-- End: INVERT PREDICATE 'R' OF 'TSucc' \n---------------------------------------\n", "meta": {"hexsha": "c4330c45c45414f8ae8be7d0c0b78ea9bd812e89", "size": 7652, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "totality/src/R.idr", "max_stars_repo_name": "normanrink/PCF", "max_stars_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "totality/src/R.idr", "max_issues_repo_name": "normanrink/PCF", "max_issues_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "totality/src/R.idr", "max_forks_repo_name": "normanrink/PCF", "max_forks_repo_head_hexsha": "6b817263fc7d64f0ed0e5535261814d572292192", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.979757085, "max_line_length": 89, "alphanum_fraction": 0.5324098275, "num_tokens": 2539, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619177503205, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.522222629303768}} {"text": "module GTLC\nimport Data.Fin\nimport Data.Vect\nimport Data.So\n\n%default total\n\n-- The Representation of types\nmutual\n data Ty = TyDyn | TyInt | TyBool | TyFun Ty Ty\n \nmutual\n -- The representation of Dyn values\n data Dyn : Type where\n inj : (t : Ty) -> (x : interpTy t) -> Dyn \n \n -- Convert Ty to Type in proof land\n data Ty2T : Ty -> Type -> Type where\n d2d : Ty2T TyDyn Dyn\n i2i : Ty2T TyInt Int\n b2b : Ty2T TyBool Bool\n f2f : Ty2T a b -> Ty2T c d -> Ty2T (TyFun a c) (b -> Maybe d)\n \n -- Compute the real type of interpreted Ty values\n total\n interpTy : Ty -> Type\n interpTy TyDyn = Dyn\n interpTy TyInt = Int\n interpTy TyBool = Bool\n interpTy (TyFun A T) = (interpTy A) -> Maybe (interpTy T)\n\n -- Proof that two Types are consistent\ndata consistTy : Ty -> Ty -> Type where\n refl : consistTy a a\n dynR : consistTy a TyDyn\n dynL : consistTy TyDyn a\n funC : consistTy a b -> consistTy c d -> consistTy (TyFun a c) (TyFun b d)\n\ndata joinTy : Ty -> Ty -> Ty -> Type where\n const : joinTy a a a\n right : joinTy TyDyn a a\n left : joinTy a TyDyn a\n under : joinTy a b c -> joinTy d e f -> \n joinTy (TyFun a d) (TyFun b e) (TyFun c f) \n \n\n-- I am Interested in how this is implemented but it represents a type index\n-- that allows variables types to be computed computed while typechecking.\nusing (G : Vect n Ty)\n\n-- An index for variable types\n data HasType : (i : Fin n) -> Vect n Ty -> Ty -> Type where\n Stop : HasType FZ (t :: G) t\n Pop : HasType k G t -> HasType (FS k) (u :: G) t\n\n-- The Explicitly Typed Cast Calculus\n data Expr : Vect n Ty -> Ty -> Type where\n Var : HasType i G t -> Expr G t\n ValI : (v : Int) -> Expr G TyInt\n ValB : (v : Bool) -> Expr G TyBool\n ILam : Expr (a :: G) t -> Expr G (TyFun a t)\n IApp : Expr G (TyFun a t) -> Expr G a -> Expr G t\n IOp : (interpTy a -> interpTy b -> interpTy c) ->\n Expr G a -> Expr G b -> Expr G c\n IIf : Expr G TyBool -> Lazy (Expr G a) -> Lazy (Expr G a) -> Expr G a\n ICast : Expr G t -> (t : Ty) -> (g : Ty) -> Expr G g \n \n mkCast : Expr G t1 -> (t1 : Ty) -> (t2 : Ty) -> (p : consistTy t1 t2) -> Expr G t2\n mkCast e s t p = (ICast e s t)\n-- mkCast refl s t e = e -- mkCast is really dumb currently\n\n-- Lam is an unannotated lambda\n Lam : Expr (TyDyn :: G) t -> Expr G (TyFun TyDyn t)\n Lam = ILam\n-- LamT is a lambda that accecpts a non dynamic type annotation\n LamT : (t : Ty) -> Expr (t :: G) g -> Expr G (TyFun t g) \n LamT t = ILam\n \n-- If is the \"smart\" constructor for if terms \n If : Expr G tt -> Lazy (Expr G tc) -> Lazy (Expr G ta) -> \n {auto ct : consistTy tt TyBool} -> \n {auto cc : consistTy tc tr} -> \n {auto ca : consistTy ta tr} -> \n Expr G tr\n If {ct=dynL}{cc}{ca} t c a = If {ct=refl}{cc}{ca} (ICast t TyDyn TyBool) c a\n If {ct=refl}{cc=refl}{ca=refl} t c a = IIf t c a\n If {ct=refl}{tc}{ta}{tr} t c a = IIf t (ICast c tc tr) (ICast a ta tr)\n\n-- App is the smart constructor for Application terms\n data AppRule : Ty -> Ty -> Ty -> Type where\n fApp : AppRule (TyFun a b) a b\n dApp : AppRule TyDyn TyDyn TyDyn\n \n App : Expr G tf -> Expr G ta -> {auto ar : AppRule tf ra rr} -> \n {auto cf : consistTy tf (TyFun ra rr)} -> {auto ca : consistTy ta ra} -> Expr G rr\n App f a {cf} {ca} {tf} {ra} {rr} {ta} = IApp (mkCast f tf (TyFun ra rr) cf) \n (mkCast a ta ra ca)\n \n-- Op is the smart constructor for operators \n\n Op : (interpTy oa -> interpTy ob -> interpTy c) -> Expr G aa -> Expr G ab ->\n {auto pa : consistTy aa oa} -> \n {auto pb : consistTy ab ob} -> Expr G c\n Op p a b {pa} {aa} {oa} {pb} {ab} {ob} = IOp p (mkCast a aa oa pa) (mkCast b ab ob pb) \n\n\n-- The lexical environment of the interpreter\n data Env : Vect n Ty -> Type where\n Nil : Env Nil\n (::) : interpTy a -> Env G -> Env (a :: G)\n\n-- Lookup of lexical values in the interpreter \n lookup : HasType i G t -> Env G -> interpTy t\n lookup Stop (x :: xs) = x\n lookup (Pop k) (x :: xs) = lookup k xs\n\n mutual\n-- Cast between types computed in the smart constructors\n rtCast : (t : Ty) -> (g : Ty) -> (x : interpTy t) -> Maybe (interpTy g)\n rtCast TyDyn TyDyn x = return x\n rtCast TyInt TyInt x = return x\n rtCast TyBool TyBool x = return x\n rtCast TyDyn g (inj t' x) = rtCast t' g x\n rtCast t' TyDyn x = return (inj t' x)\n rtCast (TyFun a b)(TyFun c d) f = \n return (\\x => rtCast b d !(f !(rtCast c a x)))\n rtCast _ _ _ = Nothing\n\n -- The GTLC interpreter \n interp : Env G -> Expr G ty -> Maybe (interpTy ty) \n interp env (Var i) = return (lookup i env)\n interp env (ValI x) = return x\n interp env (ValB x) = return x\n interp env (ICast x r1 r2) = ?ICast --rtCast r1 r2 !(interp env x)\n interp env (ILam b) = return (\\x => interp (x :: env) b)\n interp env (IOp op x y) = return (op !(interp env x) !(interp env y))\n interp env (IApp f s) = (!(interp env f) !(interp env s)) \n interp env (IIf t c a) = return (if !(interp env t) \n then !(interp env c) \n else !(interp env a))\n \n-- unit tests\n-- unit tests for consist\na2 : consistTy TyInt TyInt \na2 = refl\na0 : consistTy TyDyn TyDyn\na0 = refl\na1 : consistTy TyDyn TyBool\na1 = dynL\na3 : consistTy TyInt TyDyn\na3 = dynR\na4 : consistTy (TyFun TyInt TyBool) (TyFun TyInt TyBool)\na4 = refl\na5 : consistTy (TyFun TyInt TyBool) (TyFun TyInt TyBool)\na5 = funC refl refl\na6 : consistTy (TyFun TyDyn TyBool) (TyFun TyInt TyDyn)\na6 = funC dynL dynR\n-- unit tests of coersion calculus forms\nc0 : Expr [] TyInt\nc0 = ValI 1\nc1 : Expr [] TyBool\nc1 = ValB True\n\n-- unit tests of gradually typed forms \nt0 : Expr [] TyInt\nt0 = ValI 1\nt0' : Expr [] TyBool\nt0' = ValB True\nt1 : Expr [] (TyFun TyDyn TyDyn) \nt1 = Lam (Var Stop) \nt2 : Expr [] (TyFun TyInt TyInt) \nt2 = LamT TyInt (Var Stop)\n-- unit test on the gradual If smart constructor\nt3 : Expr [] TyInt \nt3 = (If (ValB True) (ValI 0) (ValI 1))\nt4 : Expr [TyDyn] TyInt\nt4 = (If (Var Stop) (ValI 0) (ValI 1))\nt5 : Expr [TyDyn] TyInt\nt5 = (If (Var Stop) (Var Stop) (ValI 1))\nt6 : Expr [TyDyn] TyInt\nt6 = (If (Var Stop) (Var Stop) (Var Stop))\nt7 : Expr [TyDyn] TyDyn\nt7 = (If (Var Stop) (ValI 0) (ValB True))\n-- unit tests for the gradual App smart constructor\nt8 : Expr [] TyInt\nt8 = App (LamT TyInt (Var Stop)) (ValI 1)\nt9 : Expr [] TyDyn\nt9 = App (Lam (Var Stop)) (ValI 1)\nt10 : Expr [] TyDyn\nt10 = App (Lam (If (Var Stop) (ValI 0) (Var Stop))) (ValI 1)\n\n\nsub1 : Expr [] (TyFun TyInt TyInt)\nsub1 = LamT TyInt (Op (-) (Var Stop) (ValI 1))\n\nzerop : Expr [] (TyFun TyInt TyBool)\nzerop = LamT TyInt (Op (==) (ValI 0) (Var Stop))\n\n--zerod : Expr [] (TyFun TyDyn TyBool)\n--zerod = Lam (Op (==) (ValI 0) (Var Stop))\n\n{-\nfact : Expr [] (TyFun TyDyn TyInt)\nfact = (Lam (If (App zerop (Var Stop))\n (ValI 1)\n (Op (*) (Var Stop) (App fact (App sub1 (Var Stop))))))\n-}\n-- unit tests for the interpreter\ni0 : Maybe Int\ni0 = (interp [] (ValI 0))\ni0p : i0 = Just 0\ni0p = Refl\ni1 : Maybe Bool\ni1 = (interp [] (ValB True))\ni1p : i1 = Just True\ni1p = Refl\n\n\n--main : IO ()\n--main = putStrLn (show i0)\n", "meta": {"hexsha": "4d8c087e86fb6da517afa47abfd2a8eb390114ee", "size": 7551, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris/GTLC.idr", "max_stars_repo_name": "akuhlens/metaprogramming", "max_stars_repo_head_hexsha": "785793afa547bf1e0fa6c856c2fc4a3050e81fae", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris/GTLC.idr", "max_issues_repo_name": "akuhlens/metaprogramming", "max_issues_repo_head_hexsha": "785793afa547bf1e0fa6c856c2fc4a3050e81fae", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris/GTLC.idr", "max_forks_repo_name": "akuhlens/metaprogramming", "max_forks_repo_head_hexsha": "785793afa547bf1e0fa6c856c2fc4a3050e81fae", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1674208145, "max_line_length": 91, "alphanum_fraction": 0.5621771951, "num_tokens": 2594, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.5221948422514489}} {"text": "module TypeCheck\n\nimport Syntax\n\npublic export\nTypeError : Type\nTypeError = String\n \ntypeError : TypeError -> Either TypeError Ty\ntypeError msg = Left msg\n\n||| Type context.\npublic export\nCtx : Type\nCtx = List (Name, Ty)\n\nmutual\n check : Ctx -> Ty -> Expr -> Either TypeError Ty\n check ctx ty e = do\n ty' <- typeOf ctx e\n if ty' /= ty \n then typeError ((show e) ++ \" has type \" ++ (show ty') ++ \" but is used as if it has type \" ++ (show ty))\n else pure ty\n\n ||| `typeOf ctx e` computes the type of expression `e` in \n ||| type context `ctx`. If `e` does not have a type it \n ||| returns a `TypeError`.\n export\n typeOf : Ctx -> Expr -> Either TypeError Ty\n typeOf ctx e = case e of\n Var name => case lookup name ctx of\n Nothing => typeError (\"unknown variable \" ++ name)\n Just ty => Right ty\n EInt _ => Right TInt\n EBool _ => Right TBool\n Times e1 e2 => do check ctx TInt e1\n check ctx TInt e2\n pure TInt\n Plus e1 e2 => do check ctx TInt e1\n check ctx TInt e2\n pure TInt\n Minus e1 e2 => do check ctx TInt e1\n check ctx TInt e2\n pure TInt\n Equal e1 e2 => do check ctx TInt e1\n check ctx TInt e2\n pure TBool\n Less e1 e2 => do check ctx TInt e1\n check ctx TInt e2\n pure TBool\n\n If e1 e2 e3 => do check ctx TBool e1\n ty <- typeOf ctx e2\n check ctx ty e3\n pure ty\n\n Fun f x pty rty e => let ectx = (f, TArrow pty rty) :: (x, pty) :: ctx in\n do check ectx rty e\n pure (TArrow pty rty)\n\n Apply e1 e2 => do ty1 <- typeOf ctx e1\n case ty1 of\n TArrow pty rty => do check ctx pty e2\n pure rty\n ty => typeError $ (show e1) ++ \" is used as a function but its type is \" ++ (show ty)\n", "meta": {"hexsha": "5f29db6d19a0ca68b61f9ae1d2195121623380b0", "size": 2099, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/TypeCheck.idr", "max_stars_repo_name": "steshaw/idris-miniml", "max_stars_repo_head_hexsha": "7c42e3fb87c9f9d40f0944555c312bdaf5b0e943", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2016-07-15T05:15:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-23T01:01:20.000Z", "max_issues_repo_path": "src/TypeCheck.idr", "max_issues_repo_name": "steshaw/idris-miniml", "max_issues_repo_head_hexsha": "7c42e3fb87c9f9d40f0944555c312bdaf5b0e943", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/TypeCheck.idr", "max_forks_repo_name": "steshaw/idris-miniml", "max_forks_repo_head_hexsha": "7c42e3fb87c9f9d40f0944555c312bdaf5b0e943", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.803030303, "max_line_length": 110, "alphanum_fraction": 0.4921391139, "num_tokens": 547, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5217678932118972}} {"text": "module DataStore\n\nimport Data.Vect\n\ninfixr 5 .+.\n\npublic export\ndata Schema = SString\n | SInt\n | (.+.) Schema Schema\n\npublic export\nSchemaType: Schema -> Type\nSchemaType SString = String\nSchemaType SInt = Int\nSchemaType (x .+. y) = (SchemaType x, SchemaType y)\n\nexport\nrecord DataStore(schema: Schema) where\n constructor MkData\n size: Nat\n items: Vect size (SchemaType schema)\n\nexport\nempty: DataStore schema\nempty = MkData 0 []\n\nexport\naddToStore : (value: SchemaType schema) -> (store: DataStore schema) -> DataStore schema\naddToStore value (MkData size items) = MkData _ (value :: items)\n\npublic export\ndata StoreView : DataStore schema -> Type where\n SNil : StoreView empty\n SAdd: (rec: StoreView store) -> StoreView (addToStore value store)\n\nstoreViewHelp : (items: Vect size (SchemaType schema)) -> StoreView (MkData size items)\nstoreViewHelp [] = SNil\nstoreViewHelp (val :: xs) = SAdd (storeViewHelp xs)\n\nexport\nstoreView : (store : DataStore schema) -> StoreView store\nstoreView (MkData size items) = storeViewHelp items\n\nlistItems : DataStore schema -> List (SchemaType schema)\nlistItems input with (storeView input)\n listItems empty | SNil = []\n listItems (addToStore value store) | (SAdd rec) = value :: (listItems store | rec)\n\nfilterKeys : (test : SchemaType schema -> Bool) -> DataStore (SString .+. schema) -> List String\nfilterKeys test input with (storeView input)\n filterKeys test empty | SNil = []\n filterKeys test (addToStore (key, value) store) | (SAdd rec) =\n if test value\n then key :: (filterKeys test store | rec)\n else filterKeys test store | rec\n\ngetValues : DataStore (SString .+. schema) -> List (SchemaType schema)\ngetValues input with (storeView input)\n getValues input | SNil = []\n getValues (addToStore (_, val) store) | (SAdd rec) = val :: (getValues store | rec)\n\ntestStore : DataStore (SString .+. SString .+. SInt)\ntestStore = addToStore (\"Mercury\", \"Mariner 10\", 1974) $\n addToStore (\"Venus\", \"Venera\", 1961) $\n addToStore (\"Uranus\", \"Voyager 2\", 1986) $\n addToStore (\"Pluto\", \"New Horizons\",2015) $\n empty\n", "meta": {"hexsha": "82a93486905ca03a01c2b651e8e2bc5b9d3393d9", "size": 2229, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TypedDataStoreV2.idr", "max_stars_repo_name": "coffius/idris-exercises", "max_stars_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "TypedDataStoreV2.idr", "max_issues_repo_name": "coffius/idris-exercises", "max_issues_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TypedDataStoreV2.idr", "max_forks_repo_name": "coffius/idris-exercises", "max_forks_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.3043478261, "max_line_length": 96, "alphanum_fraction": 0.6594885599, "num_tokens": 615, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5215845133663684}} {"text": "module Adjoint\nimport Data.Morphisms\n\n\ninterface (Functor f, Functor g) => Adjoint (f : Type -> Type) (g : Type -> Type) where\n unit : a -> g (f a)\n counit : f (g a) -> a\n\nphi : Adjoint f g => (f a -> b) -> a -> g b\nphi f = map f . unit\n\npsi : Adjoint f g => (a -> g b) -> f a -> b\npsi f = counit . map f\n\nAdjoint (Pair a) (Morphism a) where\n unit x = Mor (\\y => (y, x))\n counit (x, Mor f) = f x\n\nrecord Compose (f : Type -> Type) (g : Type -> Type) (a : Type) where\n constructor Comp\n getComp : f (g a)\n\n(Functor f, Functor g) => Functor (Compose f g) where\n map f = Comp . map (map f) . getComp\n\ninterface Functor m => Monad' (m : Type -> Type) where\n eta : a -> m a\n mu : m (m a) -> m a\n\n (>>=) : m a -> (a -> m b) -> m b\n ma >>= f = (mu . map f) ma\n\nAdjoint f g => Monad' (Compose g f) where\n eta x = Comp (unit x)\n mu = Comp . map (counit . map getComp) . getComp\n\nget : Compose (Morphism s) (Pair s) s\nget = (Comp (Mor (\\st => (st, st))))\n\nset : s -> Compose (Morphism s) (Pair s) ()\nset st = (Comp (Mor (\\_ => (st, ()))))\n\nexample : Monad' (Compose (Morphism Int) (Pair Int)) => Compose (Morphism Int) (Pair Int) ()\nexample = do st <- get\n set (st + 1)\n eta ()\n\ntest : Int -> (Int, ())\ntest = applyMor (getComp example)\n", "meta": {"hexsha": "6c007f4c752d6cc973350e34660082426a506fb4", "size": 1265, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Adjoint.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/Adjoint.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Adjoint.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 25.3, "max_line_length": 92, "alphanum_fraction": 0.5407114625, "num_tokens": 456, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8856314858927011, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.5215387559079763}} {"text": "\nmodule EnumTypes\n\ndata Day = Monday\n | Tuesday\n | Wednesday\n | Thursday\n | Friday\n | Saturday\n | Sunday\n%name Day day, day1, day2\n\nnextWeekday : Day -> Day\nnextWeekday Monday = Tuesday\nnextWeekday Tuesday = Wednesday\nnextWeekday Wednesday = Thursday\nnextWeekday Thursday = Friday\nnextWeekday Friday = Saturday\nnextWeekday Saturday = Sunday\nnextWeekday Sunday = Monday\n\n\ntestNextWeekday : (nextWeekday (nextWeekday Saturday)) = Monday\ntestNextWeekday = Refl\n", "meta": {"hexsha": "3dc6ff61bb90f73ed0266a690d1f9b80012ab52c", "size": 512, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Answers/Chapter_2/EnumTypes.idr", "max_stars_repo_name": "robkorn/idris-software-foundations-problems", "max_stars_repo_head_hexsha": "bd5b10c9c361ac8feea29f41745f4bb386c3b06d", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Answers/Chapter_2/EnumTypes.idr", "max_issues_repo_name": "robkorn/idris-software-foundations-problems", "max_issues_repo_head_hexsha": "bd5b10c9c361ac8feea29f41745f4bb386c3b06d", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Answers/Chapter_2/EnumTypes.idr", "max_forks_repo_name": "robkorn/idris-software-foundations-problems", "max_forks_repo_head_hexsha": "bd5b10c9c361ac8feea29f41745f4bb386c3b06d", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.48, "max_line_length": 63, "alphanum_fraction": 0.69140625, "num_tokens": 128, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.7634837527911057, "lm_q1q2_score": 0.5211339563057608}} {"text": "module Assn\n\nimport Expr\nimport Logic\nimport Maps\n\n%access public export\n\n%default total\n\nAssertion : Type\nAssertion = State -> Type\n\nnamespace ExAssertions\n as1 : Assertion\n as1 = \\st => st X = 3\n\n as2 : Assertion\n as2 = \\st => LTE (st X) (st Y)\n\n as3 : Assertion\n as3 = \\st => Either (st X = 3) (LTE (st X) (st Y))\n\n as4 : Assertion\n as4 = \\st => (LTE (st Z * st Z) (st X), Not (LTE (S (st Z) * S (st Z)) (st X)))\n\n as5 : Assertion\n as5 = \\st => ()\n\n as6 : Assertion\n as6 = \\st => Void\n\nAssertImplies : (p, q : Assertion) -> Type\nAssertImplies p q = (st : State) -> p st -> q st\n\ninfixr 8 ->>\n\n(->>) : (p, q : Assertion) -> Type\n(->>) = AssertImplies\n\nassertImpliesRefl : p ->> p\nassertImpliesRefl _ p_st = p_st\n\nassertImpliesTrans : p ->> q -> q ->> r -> p ->> r\nassertImpliesTrans p_imp_q q_imp_r = \\st, p_st =>\n q_imp_r st (p_imp_q st p_st)\n\ninfix 8 <<->>\n\n(<<->>) : (p, q : Assertion) -> Type\n(<<->>) p q = (AssertImplies p q, AssertImplies q p)\n\nassertEquivRefl : p <<->> p\nassertEquivRefl = (assertImpliesRefl, assertImpliesRefl)\n\nassertEquivTrans : p <<->> q -> q <<->> r -> p <<->> r\nassertEquivTrans (p_imp_q, q_imp_p) (q_imp_r, r_imp_q) =\n (assertImpliesTrans p_imp_q q_imp_r, assertImpliesTrans r_imp_q q_imp_p)\n\nAssignSub : (x : Id) -> (a : AExp) -> (p : Assertion) -> Assertion\nAssignSub x a p = \\st => p (t_update x (aeval st a) st)\n\nBAssn : (b : BExp) -> Assertion\nBAssn b = \\st => beval st b = True\n\nbexp_eval_true : beval st b = True -> BAssn b st\nbexp_eval_true prf = prf\n\nbexp_eval_false : beval st b = False -> Not (BAssn b st)\nbexp_eval_false bfalse btrue = absurd $ trans (sym bfalse) btrue\n\nbassn_eval_false : Not (BAssn b st) -> beval st b = False\nbassn_eval_false contra = fst not_true_iff_false contra\n", "meta": {"hexsha": "a9d6def38a52242991a21f1c14d1003b71894508", "size": 1744, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Assn.idr", "max_stars_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_stars_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Assn.idr", "max_issues_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_issues_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Assn.idr", "max_forks_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_forks_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5675675676, "max_line_length": 81, "alphanum_fraction": 0.6313073394, "num_tokens": 637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.7279754489059775, "lm_q1q2_score": 0.5208110956545572}} {"text": "module VectMissing\n\nimport Data.Fin\nimport Data.Vect\n\nexport\nshrink : (xs : Vect (S n) a) -> Elem x xs -> Vect n a\nshrink (x :: ys) Here = ys\nshrink (y :: []) (There p) = absurd p\nshrink (y :: (x :: xs)) (There p) = y :: shrink (x :: xs) p\n\n\n", "meta": {"hexsha": "5917aff93e7e1c5c77bea447905b151da10da839", "size": 242, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/effects003/VectMissing.idr", "max_stars_repo_name": "grin-compiler/idris-grin", "max_stars_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/idris-dev/effects003/VectMissing.idr", "max_issues_repo_name": "grin-compiler/idris-grin", "max_issues_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/idris-dev/effects003/VectMissing.idr", "max_forks_repo_name": "grin-compiler/idris-grin", "max_forks_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 18.6153846154, "max_line_length": 59, "alphanum_fraction": 0.5785123967, "num_tokens": 88, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.520791882623339}} {"text": "--\n-- A module about shapes\n--\n\n||| a Shape\ndata Shape =\n ||| Triangle with base and heigth\n Triangle Double Double |\n ||| Circle with radius\n Circle Double\n\n||| computes the area of a shape\narea : Shape -> Double\narea (Triangle x y) = 0.5 * x * y\narea (Circle x) = pi * x * x\n -- pi is known by idris\n\n{-\ncommented out code\n-}\n", "meta": {"hexsha": "2ce7416d4bcec82e51b8057caa13f0bc3eeec8ee", "size": 349, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "public/cloc-1.82/tests/inputs/idris_block_comments.idr", "max_stars_repo_name": "josema62/Memoria", "max_stars_repo_head_hexsha": "93ebd98095434bc76d85d3fe8f32c913ed451e43", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-28T12:50:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-28T12:50:26.000Z", "max_issues_repo_path": "tests/samples/count/idris_block_comments.idr/idris_block_comments.idr", "max_issues_repo_name": "0bOne/loci", "max_issues_repo_head_hexsha": "2c71aa0513dd19dbe70ff23fe9de0858a27d7adf", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/samples/count/idris_block_comments.idr/idris_block_comments.idr", "max_forks_repo_name": "0bOne/loci", "max_forks_repo_head_hexsha": "2c71aa0513dd19dbe70ff23fe9de0858a27d7adf", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 16.619047619, "max_line_length": 41, "alphanum_fraction": 0.5988538682, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.5207830337867333}} {"text": "import Data.List\nimport Data.List.Views\n\n{-\nNote: \nThe | says that, in the recursive calls, \nyou want to bypass constructing the view, \nbecause you already have appropriate views for lefts and rights. \n-}\n\nmergeSort : Ord a => List a -> List a\nmergeSort input with (splitRec input)\n mergeSort [] | SplitRecNil = []\n mergeSort [x] | (SplitRecOne x) = [x]\n mergeSort (lefts ++ rights) | (SplitRecPair lefts rights lrec rrec) \n = merge (mergeSort lefts | lrec) (mergeSort rights | rrec)\n\n", "meta": {"hexsha": "a9c38bd9c69c53261b9cc470452a6df89f8cba79", "size": 499, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch10/MergeSortView.idr", "max_stars_repo_name": "trevarj/tdd_idris_examples", "max_stars_repo_head_hexsha": "63a7128a797b64cb0ba54562778cdf9712b4d9f5", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/ch10/MergeSortView.idr", "max_issues_repo_name": "trevarj/tdd_idris_examples", "max_issues_repo_head_hexsha": "63a7128a797b64cb0ba54562778cdf9712b4d9f5", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ch10/MergeSortView.idr", "max_forks_repo_name": "trevarj/tdd_idris_examples", "max_forks_repo_head_hexsha": "63a7128a797b64cb0ba54562778cdf9712b4d9f5", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.7222222222, "max_line_length": 70, "alphanum_fraction": 0.6913827655, "num_tokens": 140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.5205047910574903}} {"text": "module parser\n\nimport lexer\nimport tipos\n\n%access public export\n\nmutual\n\n--------------------------------- Parser de Expressões Aritmeticas ---------------------------------\n num : List Token -> (Maybe AExp, List Token)\n num ((TokenInt n)::l) = (Just (N n), l)\n num ((TokenVarId id)::xs) = let (exp, r) = parseId ((TokenVarId id)::xs) in case exp of\n Nothing => (Nothing, r)\n Just k => (Just (IdA k), xs)\n num l = (Nothing, l)\n\n factor : List Token -> (Maybe AExp, List Token)\n factor = orParser num parenExp\n\n parenExp : List Token -> (Maybe AExp, List Token)\n parenExp ((TokenLParen)::xs) = let (e,r) = arithExp xs in parenExpAux e r where\n parenExpAux : Maybe AExp -> List Token -> (Maybe AExp, List Token)\n parenExpAux Nothing r = (Nothing, (TokenLParen::r))\n parenExpAux (Just e) (TokenRParen::xs) = ((Just e),xs)\n parenExpAux (Just e) l = (Nothing,(TokenLParen::xs))\n parenExp l = (Nothing, l)\n\n mul : List Token -> (Maybe AExp, List Token)\n mul l = let (exp, r) = factor l in mulAux exp r where\n mulAux : Maybe AExp -> List Token -> (Maybe AExp, List Token)\n mulAux Nothing r = (Nothing, r)\n mulAux (Just e) ((TokenTimes)::xs) = let (exp', r2) = factor xs in case exp' of\n Nothing => (Just e, (TokenTimes::xs))\n Just k => mulAux (Just (Mul e k)) r2\n mulAux (Just e) ((TokenDiv)::xs) = let (exp', r2) = factor xs in case exp' of\n Nothing => (Just e, (TokenDiv::xs))\n Just k => mulAux (Just (Div e k)) r2\n mulAux (Just e) l = ((Just e),l)\n\n sum : List Token -> (Maybe AExp, List Token)\n sum l = let (exp, r) = mul l in sumAux exp r where\n sumAux : Maybe AExp -> List Token -> (Maybe AExp, List Token)\n sumAux Nothing r = (Nothing, r)\n sumAux (Just e) ((TokenPlus)::xs) = let (exp', r2) = mul xs in case exp' of\n Nothing => (Just e, (TokenPlus::xs))\n Just k => sumAux (Just (Sum e k)) r2\n sumAux (Just e) ((TokenMinus)::xs) = let (exp', r2) = mul xs in case exp' of\n Nothing => (Just e, (TokenMinus::xs))\n Just k => sumAux (Just (Sub e k)) r2\n sumAux (Just e) l = ((Just e),l)\n\n arithExp : List Token -> (Maybe AExp, List Token)\n arithExp = sum\n\n--------------------------------- Parser de Expressões Booleanas ---------------------------------\n bool : List Token -> (Maybe BExp, List Token)\n bool (TokenTrue::xs) = (Just (Boo True), xs)\n bool (TokenFalse::xs) = (Just (Boo False), xs)\n bool l = (Nothing, l)\n\n idBExp : List Token -> (Maybe BExp, List Token)\n idBExp ((TokenVarId id)::xs) = let (exp, r) = parseId ((TokenVarId id)::xs) in idAux exp r where\n idAux : Maybe Id -> List Token -> (Maybe BExp, List Token)\n idAux (Just e) (TokenPlus::xs) = (Nothing, (TokenPlus::xs))\n idAux (Just e) (TokenMinus::xs) = (Nothing, (TokenMinus::xs))\n idAux (Just e) (TokenTimes::xs) = (Nothing, (TokenTimes::xs))\n idAux (Just e) (TokenDiv::xs) = (Nothing, (TokenDiv::xs))\n idAux (Just e) l = (Just (IdB e), l)\n\n factorBExp : List Token -> (Maybe BExp, List Token)\n factorBExp ((TokenVarId id)::xs) = idBExp ((TokenVarId id)::xs)\n factorBExp (TokenNot::xs) = let (exp, r) = conditExp xs in case exp of\n Nothing => (Nothing, (TokenNot::xs))\n Just k => (Just (Not k), r)\n factorBExp l = orParser bool parenBExp l\n\n parenBExp : List Token -> (Maybe BExp, List Token)\n parenBExp ((TokenLParen)::xs) = let (e,r) = boolExp xs in parenBExpAux e r where\n parenBExpAux : Maybe BExp -> List Token -> (Maybe BExp, List Token)\n parenBExpAux Nothing r = (Nothing, (TokenLParen::r))\n parenBExpAux (Just e) (TokenRParen::xs) = ((Just e),xs)\n parenBExpAux (Just e) l = (Nothing,(TokenLParen::xs))\n parenBExp l = (Nothing, l)\n\n conditExp : List Token -> (Maybe BExp, List Token)\n conditExp = orParser aux factorBExp\n\n aux : List Token -> (Maybe BExp, List Token)\n aux l = let (e,r) = arithExp l in conditExpAux e r where\n conditExpAux : Maybe AExp -> List Token -> (Maybe BExp, List Token)\n conditExpAux Nothing r = (Nothing, r)\n conditExpAux (Just e) ((TokenEqual)::xs) = let (exp', r2) = arithExp xs in case exp' of\n Nothing => (Nothing, (TokenEqual::xs))\n Just k => ((Just (Equal e k)), r2)\n conditExpAux (Just e) ((TokenMaior)::xs) = let (exp', r2) = arithExp xs in case exp' of\n Nothing => (Nothing, (TokenMaior::xs))\n Just k => ((Just (GT e k)), r2)\n conditExpAux (Just e) ((TokenMenor)::xs) = let (exp', r2) = arithExp xs in case exp' of\n Nothing => (Nothing, (TokenMenor::xs))\n Just k => ((Just (LT e k)), r2)\n conditExpAux (Just e) ((TokenMaiorIgual)::xs) = let (exp', r2) = arithExp xs in case exp' of\n Nothing => (Nothing, (TokenMaiorIgual::xs))\n Just k => ((Just (GE e k)), r2)\n conditExpAux (Just e) ((TokenMenorIgual)::xs) = let (exp', r2) = arithExp xs in case exp' of\n Nothing => (Nothing, (TokenMenorIgual::xs))\n Just k => ((Just (LE e k)), r2)\n conditExpAux (Just e) l' = (Nothing,l)\n\n logic : List Token -> (Maybe BExp, List Token)\n logic l = let (exp, r) = conditExp l in logicAux exp r where\n logicAux : Maybe BExp -> List Token -> (Maybe BExp, List Token)\n logicAux Nothing r = (Nothing, r)\n logicAux (Just e) ((TokenOr)::xs) = let (exp', r2) = conditExp xs in case exp' of\n Nothing => (Just e, (TokenOr::xs))\n Just k => logicAux (Just (OR e k)) r2\n logicAux (Just e) ((TokenAnd)::xs) = let (exp', r2) = conditExp xs in case exp' of\n Nothing => (Just e, (TokenAnd::xs))\n Just k => logicAux (Just (And e k)) r2\n logicAux (Just e) l = ((Just e),l)\n\n boolExp : List Token -> (Maybe BExp, List Token)\n boolExp = logic\n\n--------------------------------- Ajustes para Exp ---------------------------------\n parseBExp : List Token -> (Maybe Exp, List Token)\n parseBExp l = let (exp, r) = logic l in case exp of\n Nothing => (Nothing, l)\n Just k => ((Just (BExpR k)), r)\n\n parseAExp : List Token -> (Maybe Exp, List Token)\n parseAExp l = let (exp, r) = arithExp l in case exp of\n Nothing => (Nothing, l)\n Just k => ((Just (AExpR k)), r)\n\n parseExp : List Token -> (Maybe Exp, List Token)\n parseExp (TokenCommercialE::l') = let (exp', r2) = parseId l' in case exp' of\n Nothing => (Nothing, l')\n Just k => (Just (DeRef k), r2)\n parseExp (TokenTimes::l') = let (exp', r2) = parseId l' in case exp' of\n Nothing => (Nothing, l')\n Just k => (Just(ValRef k), r2)\n parseExp l = orParser parseBExp parseAExp l\n\n--------------------------------- Parser de Comandos ---------------------------------\n parseId : List Token -> (Maybe Id, List Token)\n parseId ((TokenVarId id)::xs) = (Just (ValID id), xs)\n parseId l = (Nothing, l)\n\n assign : List Token -> (Maybe Cmd, List Token)\n assign l = let (exp, r) = parseId l in assignAux exp r where\n assignAux : Maybe Id -> List Token -> (Maybe Cmd, List Token)\n assignAux Nothing r = (Nothing, r)\n assignAux (Just e) (TokenAssign::xs) = let (exp', r2) = parseExp xs in case exp' of\n Nothing => (Nothing, l)\n Just k => ((Just (Assign e k)), r2)\n assignAux (Just e) r = (Nothing, l)\n\n loop : List Token -> (Maybe Cmd, List Token)\n loop (TokenWhile::xs) = let (exp, r) = boolExp xs in loopAux exp r where\n loopAux : Maybe BExp -> List Token -> (Maybe Cmd, List Token)\n loopAux Nothing l = (Nothing, (TokenWhile::xs))\n loopAux (Just e) (TokenDo::xs) = let (exp', r2) = seq xs in case exp' of\n Nothing => (Nothing, (TokenDo::xs))\n Just k => (Just (Loop e k), r2)\n loopAux (Just e) l = (Nothing, l)\n loop l = (Nothing, l)\n\n partials : List Token -> (Maybe Cmd, List Token)\n partials (TokenElse::xs) = seq xs\n partials l = (Nothing, l)\n\n comandCall : List Token -> (Maybe Cmd, List Token)\n comandCall = orParser call bloc\n\n auxComand : List Token -> (Maybe Cmd, List Token)\n auxComand = orParser loop comandCall\n\n comandUnityAux : List Token -> (Maybe Cmd, List Token)\n comandUnityAux = orParser assign auxComand\n\n comandUnity : List Token -> (Maybe Cmd, List Token)\n comandUnity = orParser cond comandUnityAux\n\n cond : List Token -> (Maybe Cmd, List Token)\n cond (TokenIf::xs) = let (exp, r) = boolExp xs in condAux exp r where\n condAux : Maybe BExp -> List Token -> (Maybe Cmd, List Token)\n condAux Nothing l = (Nothing, (TokenIf::xs))\n condAux (Just e) (TokenThen::xs) = let (c1, r2) = seq xs in case c1 of\n Nothing => (Nothing, (TokenThen::xs))\n Just k => let (c2, r3) = partials r2 in case c2 of\n Nothing => (Just (Cond e k NOP), r3)\n Just p => (Just (Cond e k p), r3)\n condAux (Just e) l = (Nothing, l)\n cond l = (Nothing, l)\n\n seq : List Token -> (Maybe Cmd, List Token)\n seq l = let (exp, r) = comandUnity l in seqAux exp r where\n seqAux : Maybe Cmd -> List Token -> (Maybe Cmd, List Token)\n seqAux Nothing l' = (Nothing, l')\n seqAux (Just e) (TokenEnd::xs) = ((Just e), xs)\n seqAux (Just e) l' = let (c2, r2) = seq l' in case c2 of\n Nothing => ((Just e), l')\n Just k => (Just (CSeq e k), r2)\n\n comands : List Token -> (Maybe Cmd, List Token)\n comands = seq\n\n declaration : List Token -> (Maybe Dec, List Token)\n declaration (TokenCons::xs) = const (TokenCons::xs)\n declaration (TokenVar::xs) = let (exp, r) = parseId xs in declarationAux exp r where\n declarationAux : Maybe Id -> List Token -> (Maybe Dec, List Token)\n declarationAux Nothing l' = (Nothing, l')\n declarationAux (Just e) (TokenAssign::l') = let (exp', r2) = parseExp l' in case exp' of\n Nothing => (Nothing, l')\n Just k => (Just (Bind e (Ref k)), r2)\n declarationAux (Just e) l' = (Nothing, l')\n declaration l = (Nothing, l)\n\n const :List Token -> (Maybe Dec, List Token)\n const (TokenCons::xs) = let (exp, r) = parseId xs in constAux exp r where\n constAux : Maybe Id -> List Token -> (Maybe Dec, List Token)\n constAux Nothing l' = (Nothing, l')\n constAux (Just e) (TokenAssign::l') = let (exp', r2) = parseExp l' in case exp' of\n Nothing => (Nothing, l')\n Just k => (Just (Bind e k), r2)\n constAux (Just e) l' = (Nothing, l')\n const l = (Nothing, l)\n\n dec : List Token -> (Maybe Dec, List Token)\n dec = orParser seqDec function\n\n bloc : List Token -> (Maybe Cmd, List Token)\n bloc (TokenLet::xs) = let (dec, r) = dec xs in blocAux dec r where\n blocAux : Maybe Dec -> List Token -> (Maybe Cmd, List Token)\n blocAux Nothing l' = (Nothing, l')\n blocAux (Just c) (TokenIn::xs) = let (c1, r2) = comands xs in case c1 of\n Nothing => (Nothing, r2)\n Just k => (Just (Blk c k), r2)\n blocAux (Just e) l' = (Nothing, l')\n bloc l = (Nothing, l)\n\n seqDec : List Token -> (Maybe Dec, List Token)\n seqDec l = let (exp, r) = declaration l in seqDecAux exp r where\n seqDecAux : Maybe Dec -> List Token -> (Maybe Dec, List Token)\n seqDecAux Nothing l' = (Nothing, l')\n seqDecAux (Just e) l' = let (c2, r2) = seqDec l' in case c2 of\n Nothing => ((Just e), l')\n Just k => (Just (DSeq e k), r2)\n\n ctrlParser : List Token -> (Maybe Ctrl, List Token)\n ctrlParser l = let (exp, r) = bloc l in case exp of\n Nothing => (Nothing, l)\n Just k => ((Just (CtCmd k)), r)\n\n--------------------------------- Parser de Comandos ---------------------------------\n formals : List Token -> (Maybe Formals, List Token)\n formals (TokenLParen::xs) = let (list, r) = listaParam xs in formalsAux list r where\n formalsAux : List Id -> List Token -> (Maybe Formals, List Token)\n formalsAux list (TokenRParen::xs) = (Just (Form list), xs)\n formalsAux list r2 = (Nothing, r2)\n formals l = (Nothing, l)\n\n listaParam : List Token -> (List Id, List Token)\n listaParam l = let (id, r) = parseId l in listaParamAux id r [] where\n listaParamAux : Maybe Id -> List Token -> List Id -> (List Id, List Token)\n listaParamAux Nothing r2 list = (list, r2)\n listaParamAux (Just k) r2 list = let (id', r3) = parseId r2 in listaParamAux id' r3 (k::list)\n\n abst : List Token -> (Maybe Abst, List Token)\n abst l = let (f, r) = formals l in abstAux f r where\n abstAux : Maybe Formals -> List Token -> (Maybe Abst, List Token)\n abstAux Nothing r2 = (Nothing, r2)\n abstAux (Just f) (TokenIgual::xs) = let (cm, r3) = comands xs in case cm of\n Nothing => (Nothing, r3)\n Just c => (Just (Abstr f c), r3)\n abstAux (Just f) r2 = (Nothing, r2)\n\n function : List Token -> (Maybe Dec, List Token)\n function (TokenRec::TokenFn::xs)= let (id, r) = parseId xs in case id of\n Nothing => (Nothing, xs)\n Just i => let (f, r2) = abst r in case f of\n Nothing => (Nothing, r2)\n Just abs => (Just (Rbnd i abs), r2)\n function (TokenFn::xs)= let (id, r) = parseId xs in case id of\n Nothing => (Nothing, xs)\n Just i => let (f, r2) = abst r in case f of\n Nothing => (Nothing, r2)\n Just abs => (Just (BindF i abs), r2)\n function l = (Nothing, l)\n\n actuals : List Token -> (Maybe Actuals, List Token)\n actuals (TokenLParen::xs) = let (list, r) = listaExps xs in actualsAux list r where\n actualsAux : List Exp -> List Token -> (Maybe Actuals, List Token)\n actualsAux list (TokenRParen::xs) = (Just (Act list), xs)\n actualsAux list r2 = (Nothing, r2)\n actuals l = (Nothing, l)\n\n listaExps : List Token -> (List Exp, List Token)\n listaExps l = let (exp, r) = parseExp l in listaExpsAux exp r [] where\n listaExpsAux : Maybe Exp -> List Token -> List Exp -> (List Exp, List Token)\n listaExpsAux Nothing r2 list = (list, r2)\n listaExpsAux (Just k) r2 list = let (exp', r3) = parseExp r2 in listaExpsAux exp' r3 (k::list)\n\n call : List Token -> (Maybe Cmd, List Token)\n call l = let (id, r) = parseId l in case id of\n Nothing => (Nothing, r)\n Just i => let (act, r2) = actuals r in case act of\n Nothing => (Nothing, r2)\n Just k => (Just (Call i k), r2)\n\n-- funçao para tentar parser de AExp e BExp\n-- tenta aplicar o parser1 a lista\n orParser : (List Token -> (Maybe a, List Token)) -> (List Token -> (Maybe a, List Token)) -> (List Token -> (Maybe a, List Token))\n orParser parser1 parser2 list = let (exp,r) = parser1 list in orParserAux exp r where\n-- orParserAux verifica se o parser1 falhou (Nothing) ou retornou com sucesso um (exp, resto da lista)\n orParserAux : Maybe a -> List Token -> (Maybe a, List Token)\n orParserAux Nothing l = parser2 l\n orParserAux (Just exp') l = (Just exp', l)\n", "meta": {"hexsha": "94f8119fa0855febd92fbeee9074755d78ccb0f5", "size": 14261, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/parser.idr", "max_stars_repo_name": "RonaldCamp/ImpCompiler", "max_stars_repo_head_hexsha": "b7690dd0bffc97be52f0e64f8e8dead1f240fb87", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2019-04-15T03:36:44.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-13T22:38:30.000Z", "max_issues_repo_path": "src/parser.idr", "max_issues_repo_name": "RonaldCamp/ImpCompiler", "max_issues_repo_head_hexsha": "b7690dd0bffc97be52f0e64f8e8dead1f240fb87", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2019-04-15T03:44:40.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-09T23:51:29.000Z", "max_forks_repo_path": "src/parser.idr", "max_forks_repo_name": "RonaldCamp/ImpCompiler", "max_forks_repo_head_hexsha": "b7690dd0bffc97be52f0e64f8e8dead1f240fb87", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2019-04-15T03:46:13.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-15T03:46:13.000Z", "avg_line_length": 44.565625, "max_line_length": 132, "alphanum_fraction": 0.6030432648, "num_tokens": 4606, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.5204503219712197}} {"text": "module Main\n\ndata RLE : Vect n Char -> Type where\n REnd : RLE []\n RChar : {xs : Vect k Char} ->\n (n : Nat) -> (c : Char) -> (rs : RLE xs) ->\n RLE (replicate (S n) c ++ xs)\n\n------------\n\nrle : (xs : Vect n Char) -> RLE xs\nrle [] = REnd\nrle (x :: xs) with (rle xs)\n rle (x :: []) | REnd = RChar 0 x REnd\n rle (x :: (c :: (replicate n c ++ ys))) | (RChar n c rs) with (decEq x c)\n rle (x :: (x :: (replicate n x ++ ys))) | (RChar n x rs) | (Yes refl) \n = RChar (S n) x rs\n rle (x :: (c :: (replicate n c ++ ys))) | (RChar n c rs) | (No f) \n = RChar 0 x (RChar n c rs)\n\ncompress : Vect n Char -> String\ncompress xs with (rle xs)\n compress [] | REnd = \"\"\n compress (c :: (replicate n c ++ xs1)) | (RChar n c rs) \n = show (the Integer (cast (S n))) ++\n strCons c (compress xs1)\n\ncompressString : String -> String\ncompressString xs = compress (fromList (unpack xs))\n\nmain : IO ()\nmain = putStrLn (compressString \"foooobaaaarbaaaz\")\n\n", "meta": {"hexsha": "71ddf9c0463e94872d7df391f41cb8824342f0a0", "size": 1000, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "RLE/rle-vect.idr", "max_stars_repo_name": "silky/idris-demos", "max_stars_repo_head_hexsha": "1cda10e07d9c8205b9dd56048b1c2cc96f8e3e04", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-06-27T11:33:51.000Z", "max_stars_repo_stars_event_max_datetime": "2019-06-27T11:33:51.000Z", "max_issues_repo_path": "RLE/rle-vect.idr", "max_issues_repo_name": "silky/idris-demos", "max_issues_repo_head_hexsha": "1cda10e07d9c8205b9dd56048b1c2cc96f8e3e04", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "RLE/rle-vect.idr", "max_forks_repo_name": "silky/idris-demos", "max_forks_repo_head_hexsha": "1cda10e07d9c8205b9dd56048b1c2cc96f8e3e04", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 29.4117647059, "max_line_length": 75, "alphanum_fraction": 0.518, "num_tokens": 352, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722393, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.5196109487456724}} {"text": "module Main\n\ndata Expr = Var String\n | Val Int\n | Add Expr Expr\n\ndata Eval : Type -> Type where\n MkEval : (List (String, Int) -> Maybe a) -> Eval a\n\nfetch : String -> Eval Int\nfetch x = MkEval (\\e => fetchVal e) where\n fetchVal : List (String, Int) -> Maybe Int\n fetchVal [] = Nothing\n fetchVal ((v, val) :: xs) = if (x == v) then (Just val) else (fetchVal xs)\n\nimplementation Functor Eval where\n map f (MkEval g) = MkEval (\\e => map f (g e))\n\nimplementation Applicative Eval where\n pure x = MkEval (\\e => Just x)\n\n (<*>) (MkEval f) (MkEval g) = MkEval (\\x => appAux (f x) (g x)) where\n appAux : Maybe (a -> b) -> Maybe a -> Maybe b\n appAux (Just fx) (Just gx) = Just (fx gx)\n appAux _ _ = Nothing\n\neval : Expr -> Eval Int\neval (Var x) = fetch x\neval (Val x) = [| x |]\neval (Add x y) = [| eval x + eval y |]\n\nrunEval : List (String, Int) -> Expr -> Maybe Int\nrunEval env e with (eval e) {\n | MkEval envFn = envFn env\n}\n\nmain : IO ()\nmain = do printLn [| (\\x => x *2) (Just 4) |]\n printLn [| plus (Just 4) (Just 5) |]\n printLn (runEval [(\"x\",21), (\"y\", 20)] (Add (Val 1) (Add (Var \"x\") (Var \"y\"))))\n printLn (runEval [(\"x\",21)] (Add (Val 1) (Add (Var \"x\") (Var \"y\"))))\n", "meta": {"hexsha": "190143f22ca69eee347071c5c0808d344d2bb185", "size": 1274, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/sugar001/test007.idr", "max_stars_repo_name": "grin-compiler/idris-grin", "max_stars_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/idris-dev/sugar001/test007.idr", "max_issues_repo_name": "grin-compiler/idris-grin", "max_issues_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/idris-dev/sugar001/test007.idr", "max_forks_repo_name": "grin-compiler/idris-grin", "max_forks_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 30.3333333333, "max_line_length": 89, "alphanum_fraction": 0.5361067504, "num_tokens": 427, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933183101078, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.5193288315909352}} {"text": "> module SequentialDecisionProblems.applications.Main\n\n> import Data.Vect\n> -- import Data.Fin\n> -- import Data.List\n> -- import Data.List.Quantifiers\n> import Data.So\n> import Effects\n> import Effect.Exception\n> import Effect.StdIO\n\n> import SequentialDecisionProblems.CoreTheory\n> import SequentialDecisionProblems.FullTheory\n> import SequentialDecisionProblems.TabBackwardsInduction\n> import SequentialDecisionProblems.Utils\n> import SequentialDecisionProblems.NonDeterministicDefaults\n> import SequentialDecisionProblems.CoreTheoryOptDefaults\n> import SequentialDecisionProblems.FullTheoryOptDefaults\n> import SequentialDecisionProblems.TabBackwardsInductionOptDefaults\n\n> import BoundedNat.BoundedNat\n> -- import FastSimpleProb.SimpleProb\n> -- import FastSimpleProb.BasicOperations\n> -- import FastSimpleProb.BasicProperties\n> -- import FastSimpleProb.MonadicOperations\n> -- import FastSimpleProb.MonadicProperties\n> -- import FastSimpleProb.Measures\n> -- import FastSimpleProb.MeasuresProperties\n> -- import FastSimpleProb.Operations\n> -- import Sigma.Sigma\n> import Double.Predicates\n> -- import Double.Postulates\n> -- import Double.Operations\n> -- import Double.Properties\n> import NonNegDouble.NonNegDouble\n> -- import NonNegDouble.Constants\n> import NonNegDouble.BasicOperations\n> import NonNegDouble.Operations\n> import NonNegDouble.Properties\n> import NonNegDouble.Predicates\n> import NonNegDouble.LTEProperties\n> -- import Finite.Predicates\n> -- import Finite.Operations\n> -- import Finite.Properties\n> -- import Decidable.Predicates\n> -- import Decidable.Properties\n> -- import LocalEffect.Exception\n> -- import LocalEffect.StdIO\n> -- import Fin.Operations\n> -- import List.Operations\n> -- import Unit.Properties\n\n> -- %default total\n> %auto_implicits off\n\n> -- %logging 5\n\n\n* States\n\n> data Tag = V | X | O\n\n> Board : Type\n> Board = Vect 9 Tag\n\n> validBoard : Nat -> Board -> Bool\n\n> data ValidBoard : Nat -> Type where\n> MkValidBoard : (t : Nat) -> (b : Board) -> validBoard t b = True -> ValidBoard t\n\n> SequentialDecisionProblems.CoreTheory.State = ValidBoard\n\n\n* Controls\n\n> Move : Type\n> Move = Maybe (LTB 9) -- Nothing is for the case the game is over before 5 rounds\n\n> validMove : (t : Nat) -> ValidBoard t -> Move -> Bool\n\n> data ValidMove : (t : Nat) -> ValidBoard t -> Type where\n> MkValidMove : (t : Nat) -> (b : ValidBoard t) -> (m : Move) -> validMove t b m = True -> ValidMove t b\n\n> SequentialDecisionProblems.CoreTheory.Ctrl = ValidMove\n\n\n* Transition function\n\n> possible : (t : Nat) -> (b : ValidBoard t) -> (m : ValidMove t b) -> List (ValidBoard (S t))\n\n> SequentialDecisionProblems.CoreTheory.nexts t x y = possible t x y\n\n\n* |Val| and |LTE|:\n\n> SequentialDecisionProblems.CoreTheory.Val =\n> NonNegDouble.NonNegDouble\n \n> SequentialDecisionProblems.CoreTheory.plus =\n> NonNegDouble.Operations.plus\n\n> SequentialDecisionProblems.CoreTheory.zero =\n> fromInteger 0\n\n> SequentialDecisionProblems.CoreTheory.LTE =\n> NonNegDouble.Predicates.LTE\n\n> SequentialDecisionProblems.FullTheory.reflexiveLTE =\n> NonNegDouble.LTEProperties.reflexiveLTE\n\n> SequentialDecisionProblems.FullTheory.transitiveLTE =\n> NonNegDouble.LTEProperties.transitiveLTE\n \n> SequentialDecisionProblems.FullTheory.monotonePlusLTE =\n> NonNegDouble.LTEProperties.monotonePlusLTE\n\n> SequentialDecisionProblems.CoreTheoryOptDefaults.totalPreorderLTE =\n> NonNegDouble.LTEProperties.totalPreorderLTE\n\n\n* Reward function\n\n> won : (t : Nat) -> (b : ValidBoard t) -> Bool\n> lost : (t : Nat) -> (b : ValidBoard t) -> Bool\n\n> SequentialDecisionProblems.CoreTheory.reward t x y x' =\n> if won (S t) x'\n> then cast 2.0\n> else if lost (S t) x'\n> then cast 0.0\n> else cast 1.0\n\n> {-\n \n* Completing the problem specification\n\nTo be able to apply the verified, generic backwards induction algorithm\nof |CoreTheory| to compute optimal policies for our problem, we have to\nexplain how the decision maker accounts for uncertainties on rewards\ninduced by uncertainties in the transition function. We first assume\nthat the decision maker measures uncertain rewards by their expected\nvalue:\n\n> SequentialDecisionProblems.CoreTheory.meas = expectedValue -- worst -- expectedValue\n> SequentialDecisionProblems.FullTheory.measMon = monotoneExpectedValue -- monotoneWorst -- monotoneExpectedValue\n\nFurther on, we have to implement the notions of viability and\nreachability. We start by positing that all states are viable for any\nnumber of steps:\n\n> -- Viable : (n : Nat) -> State t -> Type\n> SequentialDecisionProblems.CoreTheory.Viable n x = Unit\n\nFrom this definition, it trivially follows that all elements of an\narbitrary list of states are viable for an arbitrary number of steps:\n\n> viableLemma : {t, n : Nat} -> (xs : List (State t)) -> All (Viable n) xs\n> viableLemma Nil = Nil\n> viableLemma {t} {n} (x :: xs) = () :: (viableLemma {t} {n} xs)\n\nThis fact and the (less trivial) result that simple probability\ndistributions are never empty, see |nonEmptyLemma| in\n|MonadicProperties| in |SimpleProb|, allows us to show that the above\ndefinition of |Viable| fulfills |viableSpec1|:\n\n> -- viableSpec1 : (x : State t) -> Viable (S n) x -> GoodCtrl t x\n> SequentialDecisionProblems.CoreTheory.viableSpec1 {t} {n} s v =\n> MkSigma High (ne, av) where\n> ne : SequentialDecisionProblems.CoreTheory.NotEmpty (nexts t s High)\n> ne = nonEmptyLemma (nexts t s High)\n> av : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} n) (nexts t s High)\n> av = viableLemma {t = S t} (support (nexts t s High))\n\n> SequentialDecisionProblems.Utils.finiteViable n x = finiteUnit\n\n> SequentialDecisionProblems.Utils.decidableViable n x = decidableUnit\n\nFor reachability, we proceed in a similar way. We say that all states\nare reachable\n\n> -- Reachable : State t' -> Type\n> SequentialDecisionProblems.CoreTheory.Reachable x' = Unit\n\nwhich immediately implies |reachableSpec1|:\n\n> -- reachableSpec1 : (x : State t) -> Reachable {t' = t} x -> (y : Ctrl t x) -> All (Reachable {t' = S t}) (nexts t x y)\n> SequentialDecisionProblems.CoreTheory.reachableSpec1 {t} x r y = all (nexts t x y) where\n> all : (sp : SimpleProb (State (S t))) -> SequentialDecisionProblems.CoreTheory.All (Reachable {t' = S t}) sp\n> all sp = all' (support sp) where\n> all' : (xs : List (State (S t))) -> Data.List.Quantifiers.All (Reachable {t' = S t}) xs\n> all' Nil = Nil\n> all' (x :: xs) = () :: (all' xs)\n\nand decidability of |Reachable|:\n\n> SequentialDecisionProblems.TabBackwardsInduction.decidableReachable x = decidableUnit\n\nFinally, we have to show that controls are finite\n\n> -- finiteCtrl : {t : Nat} -> (x : State t) -> Finite (Ctrl t x)\n> SequentialDecisionProblems.Utils.finiteCtrl _ = finiteLowHigh\n\nand, in order to use the fast, tail-recursive tabulated version of\nbackwards induction, that states are finite:\n\n> SequentialDecisionProblems.TabBackwardsInduction.finiteState t =\n> finiteTuple4 finiteFin finiteLowHigh finiteAvailableUnavailable finiteGoodBad\n\n\n* Optimal policies, optimal decisions, ...\n\nWe can now apply the results of our |CoreTheory| and of the |FullTheory|\nto compute verified optimal policies, possible state-control sequences,\netc. To this end, we need to be able to show the outcome of the decision\nprocess. This means implemeting functions to print states and controls:\n\n> -- showState : {t : Nat} -> State t -> String\n> SequentialDecisionProblems.Utils.showState {t} (e, High, Unavailable, Good) =\n> \"(\" ++ show (finToNat e) ++ \",H,U,G)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, High, Unavailable, Bad) =\n> \"(\" ++ show (finToNat e) ++ \",H,U,B)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, High, Available, Good) =\n> \"(\" ++ show (finToNat e) ++ \",H,A,G)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, High, Available, Bad) =\n> \"(\" ++ show (finToNat e) ++ \",H,A,B)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, Low, Unavailable, Good) =\n> \"(\" ++ show (finToNat e) ++ \",L,U,G)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, Low, Unavailable, Bad) =\n> \"(\" ++ show (finToNat e) ++ \",L,U,B)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, Low, Available, Good) =\n> \"(\" ++ show (finToNat e) ++ \",L,A,G)\"\n> SequentialDecisionProblems.Utils.showState {t} (e, Low, Available, Bad) =\n> \"(\" ++ show (finToNat e) ++ \",L,A,B)\"\n\n> -- showControl : {t : Nat} -> {x : State t} -> Ctrl t x -> String\n> SequentialDecisionProblems.Utils.showCtrl {t} {x} Low = \"L\"\n> SequentialDecisionProblems.Utils.showCtrl {t} {x} High = \"H\"\n\n> -- ad-hoc trajectories computation\n> adHocPossibleStateCtrlSeqs : {t, n : Nat} -> \n> (ps : PolicySeq t n) ->\n> (x : State t) -> \n> SimpleProb (StateCtrlSeq t n)\n> adHocPossibleStateCtrlSeqs {t} {n = Z} Nil x = \n> FastSimpleProb.MonadicOperations.ret (Nil x)\n> adHocPossibleStateCtrlSeqs {t} {n = S m} (p :: ps') x =\n> {- \n> FastSimpleProb.MonadicOperations.fmap ((MkSigma x y) ::) (FastSimpleProb.MonadicOperations.naivebind mx' f) where\n> y : Ctrl t x\n> y = ctrl (p x () ())\n> mx' : SimpleProb (State (S t))\n> mx' = nexts t x y\n> f : State (S t) -> M (StateCtrlSeq (S t) m)\n> f = adHocPossibleStateCtrlSeqs {n = m} ps'\n> ---}\n> --{-\n> let y = ctrl (p x () ()) in\n> let mx' = nexts t x y in\n> let f = adHocPossibleStateCtrlSeqs {n = m} ps' in\n> FastSimpleProb.MonadicOperations.fmap ((MkSigma x y) ::) (FastSimpleProb.MonadicOperations.naivebind mx' f)\n> ---}\n\n\n> constHigh : (t : Nat) -> (n : Nat) -> PolicySeq t n\n> constHigh t Z = Nil\n> constHigh t (S n) = p :: (constHigh (S t) n) where\n> p : Policy t (S n)\n> p x r v = MkSigma High (ne, av) where\n> ne : SequentialDecisionProblems.CoreTheory.NotEmpty (nexts t x High)\n> ne = nonEmptyLemma (nexts t x High)\n> av : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} n) (nexts t x High)\n> av = viableLemma {t = S t} (support (nexts t x High))\n\n\n> ||| Constant low policy sequences\n> constLow : (t : Nat) -> (n : Nat) -> PolicySeq t n\n> constLow t Z = Nil\n> constLow t (S n) = p :: (constLow (S t) n) where\n> p : Policy t (S n)\n> p x r v = MkSigma Low (ne, av) where\n> ne : SequentialDecisionProblems.CoreTheory.NotEmpty (nexts t x Low)\n> ne = nonEmptyLemma (nexts t x Low)\n> av : SequentialDecisionProblems.CoreTheory.All (Viable {t = S t} n) (nexts t x Low)\n> av = viableLemma {t = S t} (support (nexts t x Low))\n\n\n> computation : { [STDIO] } Eff ()\n> computation =\n> do putStr (\"enter number of steps:\\n\")\n> nSteps <- getNat\n> putStrLn \"nSteps (number of decision steps):\"\n> putStrLn (\" \" ++ show nSteps)\n> \n> putStrLn \"crE (crit. cumulated emissions threshold):\"\n> putStrLn (\" \" ++ show crE)\n> putStrLn \"crN (crit. number of decision steps):\" \n> putStrLn (\" \" ++ show crN)\n> \n> putStrLn \"pS1 (prob. of staying in a good world, cumulated emissions below crE):\"\n> putStrLn (\" \" ++ show pS1)\n> putStrLn \"pS2 (prob. of staying in a good world, cumulated emissions above crE):\"\n> putStrLn (\" \" ++ show pS2)\n> \n> putStrLn \"pA1 (prob. of eff. tech. becoming available, number of steps below crN):\" \n> putStrLn (\" \" ++ show pA1)\n> putStrLn \"pA2 (prob. of eff. tech. becoming available, number of steps above crN):\"\n> putStrLn (\" \" ++ show pA2)\n> \n> putStrLn \"pLL (prob. of low emission policies, emissions low, low selected):\"\n> putStrLn (\" \" ++ show pLL)\n> putStrLn \"pLH (prob. of low emission policies, emissions high, low selected):\"\n> putStrLn (\" \" ++ show pLH)\n> putStrLn \"pHL (prob. of high emission policies, emissions low, high selected):\"\n> putStrLn (\" \" ++ show pHL)\n> putStrLn \"pHH (prob. of high emission policies, emissions high, high selected):\"\n> putStrLn (\" \" ++ show pHH) \n> \n> putStrLn \"badOverGood (step benefits ratio: bad over good world):\"\n> putStrLn (\" \" ++ show badOverGood)\n> putStrLn \"lowOverGoodUnavailable (benefits ratio: low emissions over step, good world, eff. tech. unavailable):\"\n> putStrLn (\" \" ++ show lowOverGoodUnavailable) \n> putStrLn \"lowOverGoodAvailable (benefits ratio: low emissions over step, good world, eff. tech. available):\"\n> putStrLn (\" \" ++ show lowOverGoodAvailable)\n> putStrLn \"highOverGood (benefits ratio: High emissions over step, good world):\"\n> putStrLn (\" \" ++ show highOverGood) \n> \n> putStrLn \"computing constHigh policies ...\"\n> constHigh_ps <- pure (constHigh Z nSteps)\n>\n> putStrLn \"computing constHigh state-control sequences ...\"\n> constHigh_mxys <- pure (adHocPossibleStateCtrlSeqs constHigh_ps (FZ, High, Unavailable, Good))\n> putStrLn \"pairing constHigh state-control sequences with their values ...\"\n> constHigh_mxysv <- pure (possibleStateCtrlSeqsRewards' constHigh_mxys)\n> -- putStrLn \"constHigh state-control sequences and their values:\"\n> -- putStrLn (showlong constHigh_mxysv) \n> \n> putStrLn \"computing (naively) the number of constHigh state-control sequences ...\"\n> constHigh_n <- pure (length (toList constHigh_mxysv))\n> putStrLn \"number of constHigh state-control sequences:\"\n> putStrLn (\" \" ++ show constHigh_n)\n> \n> putStrLn \"computing (naively) the most probable constHigh state-control sequence ...\"\n> constHigh_xysv <- pure (naiveMostProbableProb constHigh_mxysv)\n> putStrLn \"most probable constHigh state-control sequence and its probability:\"\n> putStrLn (\" \" ++ show constHigh_xysv) \n> \n> putStrLn \"sorting (naively) the constHigh state-control sequence ...\"\n> constHigh_xysvs <- pure (naiveSortToList constHigh_mxysv)\n> putStrLn \"most probable constHigh state-control sequences (first 3) and their probabilities:\"\n> putStrLn (showlong (take 3 constHigh_xysvs))\n> \n> putStrLn \"measure of constHigh rewards:\"\n> putStrLn (\" \" ++ show (meas (SequentialDecisionProblems.CoreTheory.fmap snd constHigh_mxysv))) \n>\n> putStrLn \"computing constLow policies ...\"\n> constLow_ps <- pure (constLow Z nSteps)\n>\n> putStrLn \"computing constLow state-control sequences ...\"\n> constLow_mxys <- pure (adHocPossibleStateCtrlSeqs constLow_ps (FZ, High, Unavailable, Good))\n> putStrLn \"pairing constLow state-control sequences with their values ...\"\n> constLow_mxysv <- pure (possibleStateCtrlSeqsRewards' constLow_mxys)\n> \n> putStrLn \"computing (naively) the number of constLow state-control sequences ...\"\n> constLow_n <- pure (length (toList constLow_mxysv))\n> putStrLn \"number of constLow state-control sequences:\"\n> putStrLn (\" \" ++ show constLow_n)\n> \n> putStrLn \"computing (naively) the most probable constLow state-control sequence ...\"\n> constLow_xysv <- pure (naiveMostProbableProb constLow_mxysv)\n> putStrLn \"most probable constLow state-control sequence and its probability:\"\n> putStrLn (\" \" ++ show constLow_xysv) \n> \n> putStrLn \"sorting (naively) the constLow state-control sequence ...\"\n> constLow_xysvs <- pure (naiveSortToList constLow_mxysv)\n> putStrLn \"most probable constLow state-control sequences (first 3) and their probabilities:\"\n> putStrLn (showlong (take 3 constLow_xysvs))\n> \n> putStrLn \"measure of constLow rewards:\"\n> putStrLn (\" \" ++ show (meas (SequentialDecisionProblems.CoreTheory.fmap snd constLow_mxysv))) \n> \n> putStrLn \"computing optimal policies ...\"\n> ps <- pure (tabTailRecursiveBackwardsInduction Z nSteps)\n> \n> putStrLn \"computing possible state-control sequences ...\"\n> mxys <- pure (adHocPossibleStateCtrlSeqs ps (FZ, High, Unavailable, Good))\n> putStrLn \"pairing possible state-control sequences with their values ...\"\n> mxysv <- pure (possibleStateCtrlSeqsRewards' mxys)\n> -- putStrLn \"possible state-control sequences and their values:\"\n> -- putStrLn (showlong mxysv) \n> \n> putStrLn \"computing (naively) the number of possible state-control sequences ...\"\n> n <- pure (length (toList mxysv))\n> putStrLn \"number of possible state-control sequences:\"\n> putStrLn (\" \" ++ show n)\n> \n> putStrLn \"computing (naively) the most probable state-control sequence ...\"\n> xysv <- pure (naiveMostProbableProb mxysv)\n> putStrLn \"most probable state-control sequence and its probability:\"\n> putStrLn (\" \" ++ show xysv)\n> \n> putStrLn \"sorting (naively) the possible state-control sequence ...\"\n> xysvs <- pure (naiveSortToList mxysv)\n> putStrLn \"most probable state-control sequences (first 3) and their probabilities:\"\n> putStrLn (showlong (take 3 xysvs))\n> \n> putStrLn \"measure of possible rewards:\"\n> putStrLn (\" \" ++ show (meas (SequentialDecisionProblems.CoreTheory.fmap snd mxysv)))\n \n> putStrLn \"done!\"\n\n\n> main : IO ()\n> main = run computation\n\n> ---}\n\n\n-- Local Variables:\n-- idris-packages: (\"effects\")\n-- End:\n", "meta": {"hexsha": "fe8160580d90fe8545b5837f430fcbb75fe88e98", "size": 17321, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionProblems/applications/TicTacToe.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "SequentialDecisionProblems/applications/TicTacToe.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "SequentialDecisionProblems/applications/TicTacToe.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 41.1425178147, "max_line_length": 121, "alphanum_fraction": 0.6753651637, "num_tokens": 4683, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503206, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.5192251805710979}} {"text": "module Data.Fun\n\nimport public Data.Vect\n\n%default total\n\n||| Build an n-ary function type from a Vect of Types and a result type\npublic export\nFun : Vect n Type -> Type -> Type\nFun [] r = r\nFun (t::ts) r = t -> Fun ts r\n\npublic export\nchain : {ts : Vect n Type} -> Fun [r] r' -> Fun ts r -> Fun ts r'\nchain {ts = []} g r = g r\nchain {ts = (_::_)} g f = \\ x => chain g (f x)\n\npublic export\n[Nary] {ts : Vect n Type} -> Functor (Fun ts) where\n map = chain\n\n||| Returns the co-domain of a n-ary function.\npublic export\ntarget : {ts : Vect n Type} -> {r: Type} -> Fun ts r -> Type\ntarget {r} _ = r\n", "meta": {"hexsha": "998713c60bb3a84b71c02622908bb095da99f2b7", "size": 597, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Data/Fun.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/libs/base/Data/Fun.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/libs/base/Data/Fun.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.9615384615, "max_line_length": 71, "alphanum_fraction": 0.608040201, "num_tokens": 199, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.5192001664044168}} {"text": "module Lexer\n\nimport Lightyear\nimport Lightyear.Char\nimport Lightyear.Strings\n\npublic export\ndata Lexeme\n = Numeral Integer\n | Plus\n | Minus\n | Times\n | Divide\n | LParen\n | RParen\n \n-- XXX: deriving Eq?\nexport\nimplementation Eq Lexeme where\n (Numeral n1) == (Numeral n2) = n1 == n2\n Plus == Plus = True\n Minus == Minus = True\n Times == Times = True\n Divide == Divide = True\n LParen == LParen = True\n RParen == RParen = True\n _ == _ = False\n \n-- XXX: deriving Show?\nexport\nimplementation Show Lexeme where\n show (Numeral n) = \"(Numeral \" ++ show n ++ \")\"\n show Plus = \"Plus\"\n show Minus = \"Minus\"\n show Times = \"Times\"\n show Divide = \"Divide\"\n show LParen = \"LParen\"\n show RParen = \"RParen\"\n\n-- XXX: Data.Fin finToInteger?\ngetInteger : List (Fin 10) -> Integer\ngetInteger = foldl (\\a => \\b => 10 * a + cast b) 0\n\nnumeral : Parser Lexeme\nnumeral = do\n digits <- some digit\n pure $ Numeral (getInteger digits)\n\ntok : Parser Lexeme\ntok = numeral\n <|> ((char '+') *> pure Plus)\n <|> ((char '-') *> pure Minus)\n <|> ((char '*') *> pure Times)\n <|> ((char '/') *> pure Divide)\n <|> ((char '(') *> pure LParen)\n <|> ((char ')') *> pure RParen)\n\nexport\nlexer : Parser (List Lexeme)\nlexer = spaces *> (many (tok <* spaces))\n", "meta": {"hexsha": "29a9fc8532eea5f35a398d76667cb4ac94a059ff", "size": 1246, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Lexer.idr", "max_stars_repo_name": "steshaw/idris-calc", "max_stars_repo_head_hexsha": "7bb1d7761e8f0d2764fb2bd8713a57bec06f5fba", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-17T08:24:59.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-24T09:02:16.000Z", "max_issues_repo_path": "src/Lexer.idr", "max_issues_repo_name": "steshaw/idris-calc", "max_issues_repo_head_hexsha": "7bb1d7761e8f0d2764fb2bd8713a57bec06f5fba", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Lexer.idr", "max_forks_repo_name": "steshaw/idris-calc", "max_forks_repo_head_hexsha": "7bb1d7761e8f0d2764fb2bd8713a57bec06f5fba", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.4262295082, "max_line_length": 50, "alphanum_fraction": 0.6099518459, "num_tokens": 396, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5192001614927625}} {"text": "import Data.Either\nimport Data.List\nimport Data.List1\nimport Data.Maybe\nimport Data.String\n\nimport System.File\n\ndata BingoNum = M Nat | U Nat\n\nShow BingoNum where\n show (M k) = \"m \" ++ show k\n show (U k) = \"u \" ++ show k\n\nCard : Type\nCard = List (List BingoNum)\n\nparseLines : (String -> Maybe a) -> String -> List a\nparseLines f s = catMaybes $ f <$> lines s\n\ngetNumbers : List String -> Maybe (List Nat, List String)\ngetNumbers [] = Nothing\ngetNumbers (x :: xs) = Just (catMaybes $ parsePositive <$> (forget $ split (== ',') x), xs)\n\nparseCard : List String -> Card\nparseCard l = (\\s => U <$> (catMaybes $ parsePositive <$> (forget $ split (== ' ') s))) <$> l\n\nparseCards : List String -> List Card\nparseCards [] = []\nparseCards (_ :: xs) = parseCard (take 5 xs) :: parseCards (drop 5 xs)\n\nisMarked : BingoNum -> Bool\nisMarked (M _) = True\nisMarked (U _) = False\n\nwinRow : Card -> Bool\nwinRow [] = False\nwinRow (x :: xs) = all isMarked x || winRow xs\n\nwinColumn : Card -> Bool\nwinColumn c = any id $ foldl (\\a => \\bs => (\\(b1, b2) => b1 && b2) <$> zip a (isMarked <$> bs)) (replicate 5 True) c\n\nwins : Card -> Bool\nwins c = winRow c || winColumn c\n\ndrawNumber : Nat -> Card -> Card\ndrawNumber n [] = []\ndrawNumber n (x :: xs) = ((\\d => case d of\n M m => M m\n U u => if u == n\n then M u\n else U u) <$> x) :: drawNumber n xs\n\ndrawNumbers : List Nat -> List Card -> Maybe (Card, Nat)\ndrawNumbers [] cs = Nothing\ndrawNumbers (x :: xs) [] = Nothing\ndrawNumbers (x :: xs) (c :: []) = let nc = drawNumber x c in\n if wins nc\n then Just (nc, x)\n else drawNumbers xs (nc :: [])\ndrawNumbers (x :: xs) cs = let ncs = drawNumber x <$> cs\n losing = filter (not . wins) ncs in\n drawNumbers xs losing\n\nscoreOf : Card -> Nat\nscoreOf [] = 0\nscoreOf (x :: xs) = (foldl (\\a => \\b => case b of\n M n => a\n U n => n + a) 0 x) + scoreOf xs\n\nrun : String -> IO ()\nrun s = do let lines = lines s\n Just (ns, lines) <- pure $ getNumbers lines\n | Nothing => putStrLn $ \"err\"\n let cards = parseCards lines\n Just (win, n) <- pure $ drawNumbers ns cards\n | Nothing => putStrLn $ \"no win\"\n let score = n * scoreOf win\n putStrLn $ show $ score\n\nmain : IO ()\nmain = do Right s <- readFile \"input.txt\"\n | Left err => putStrLn $ show err\n run s\n\n", "meta": {"hexsha": "91adf6a65dabda64d8a5e34125374884b27ab18c", "size": 2740, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "04/main+.idr", "max_stars_repo_name": "Olavhaasie/aoc-2021", "max_stars_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "04/main+.idr", "max_issues_repo_name": "Olavhaasie/aoc-2021", "max_issues_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "04/main+.idr", "max_forks_repo_name": "Olavhaasie/aoc-2021", "max_forks_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.8604651163, "max_line_length": 116, "alphanum_fraction": 0.4937956204, "num_tokens": 724, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.5190696192513375}} {"text": "module Data.Verified.Zifunctor\n\nimport Data.Zifunctor\n\n%default total\n%access public export\n\n||| Verified Zifunctor\n||| A Zifunctor for which identity and composition laws are verified\ninterface Zifunctor t => VerifiedZifunctor (t : Type -> Type -> Type -> Type) where\n zifunctorIdentity : {a : Type} -> {b : Type} -> {c : Type} ->\n (x : t a b c) ->\n zimap Basics.id Basics.id Basics.id x = x\n zifunctorComposition : {a : Type} -> {b : Type} -> {c : Type} ->\n {a1 : Type} -> {b1 : Type} -> {c1 : Type} ->\n (x : t a b c) ->\n (fa1 : a1 -> a) -> (fb1 : b -> b1) -> (fc1 : c -> c1) ->\n (fa2 : a2 -> a1) -> (fb2 : b1 -> b2) -> (fc2 : c1 -> c2) ->\n (zimap (fa1 . fa2) (fb2 . fb1) (fc2 . fc1) x) =\n (zimap fa2 fb2 fc2 . zimap fa1 fb1 fc1) x\n", "meta": {"hexsha": "9fd8ac767990395acaaf4d03c6e410d4b8b0299b", "size": 920, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Verified/Zifunctor.idr", "max_stars_repo_name": "lemastero/Idris-Trifunctors", "max_stars_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/Verified/Zifunctor.idr", "max_issues_repo_name": "lemastero/Idris-Trifunctors", "max_issues_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-10-13T21:31:36.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-13T21:31:36.000Z", "max_forks_repo_path": "src/Data/Verified/Zifunctor.idr", "max_forks_repo_name": "lemastero/Idris-Trifunctors", "max_forks_repo_head_hexsha": "cb3ccef744904c2aaffcbaf2e27e11fa2195eec6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-06-19T04:35:47.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-19T04:35:47.000Z", "avg_line_length": 43.8095238095, "max_line_length": 84, "alphanum_fraction": 0.4608695652, "num_tokens": 294, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.5186868636924624}} {"text": "\n-- 7.3 Exercises\n\ndata Vect : Nat -> Type -> Type where\n Nil : Vect Z a\n (::) : (x : a) -> (xs : Vect k a) -> Vect (S k) a\n%name Vect xs, ys, zs\n\nEq a => Eq (Vect n a) where\n (==) [] [] = True\n (==) (x :: xs) (y :: ys) = x == y && xs == ys\n (==) _ _ = False\n\nFoldable (Vect n) where\n foldr func init [] = init\n foldr func init (x :: xs) = let acc = func x init in foldr func acc xs\n\nFunctor (Vect n) where\n map func [] = []\n map func (x :: xs) = func x :: map func xs\n", "meta": {"hexsha": "7b056cb995392a63d392c5aea076e7a872ef8704", "size": 506, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch7/Vect.idr", "max_stars_repo_name": "trevarj/tdd_idris_examples", "max_stars_repo_head_hexsha": "63a7128a797b64cb0ba54562778cdf9712b4d9f5", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/ch7/Vect.idr", "max_issues_repo_name": "trevarj/tdd_idris_examples", "max_issues_repo_head_hexsha": "63a7128a797b64cb0ba54562778cdf9712b4d9f5", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/ch7/Vect.idr", "max_forks_repo_name": "trevarj/tdd_idris_examples", "max_forks_repo_head_hexsha": "63a7128a797b64cb0ba54562778cdf9712b4d9f5", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0952380952, "max_line_length": 75, "alphanum_fraction": 0.4822134387, "num_tokens": 183, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744761936438, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.5178600758575639}} {"text": "%default total\n\ndata Wrap : Type -> Type where\n MkWrap : a -> Wrap a\n\nunwrap : Wrap a -> a\nunwrap (MkWrap v) = v\n\ndata F : Type where\n MkF : Wrap (Not F) -> F\n\nyesF : Not F -> F\nyesF = MkF . MkWrap\n\nnotF : Not F\nnotF (MkF f) = unwrap f (yesF $ unwrap f)\n\nargh : Void\nargh = notF (yesF notF)\n", "meta": {"hexsha": "a6000ba765210f7b34199bb179afeca4942f4838", "size": 293, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/idris2/positivity004/Issue1771-3.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "tests/idris2/positivity004/Issue1771-3.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "tests/idris2/positivity004/Issue1771-3.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 14.65, "max_line_length": 41, "alphanum_fraction": 0.6040955631, "num_tokens": 113, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744850834648, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.5178600701729918}} {"text": "%default total\n\ndata F : Type where\n MkFix : ((0 g : Type -> Type) -> g === Not -> g F) -> F\n\nyesF : Not F -> F\nyesF nf = MkFix (\\ g, Refl => nf)\n\nnotF : Not F\nnotF (MkFix f) =\n let g = f Not Refl in\n g (yesF g)\n\nargh : Void\nargh = notF (yesF notF)\n", "meta": {"hexsha": "52a3c0fc7d40a1459e99bf239a9ef03e123fb1fa", "size": 252, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/idris2/positivity004/Issue1771-2.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "tests/idris2/positivity004/Issue1771-2.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "tests/idris2/positivity004/Issue1771-2.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 15.75, "max_line_length": 57, "alphanum_fraction": 0.5436507937, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891479496523, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.5177938478621614}} {"text": "||| A heterogeneous list. This was introduced in\n||| chapter *Functor and Friends* and is also used in\n||| later chapters\nmodule Data.HList\n\nimport Data.Fin\n\n%default total\n\npublic export\ndata HList : (ts : List Type) -> Type where\n Nil : HList Nil\n (::) : (v : t) -> (vs : HList ts) -> HList (t :: ts)\n\npublic export\nhead : HList (t :: ts) -> t\nhead (v :: _) = v\n\npublic export\ntail : HList (t :: ts) -> HList ts\ntail (_ :: t) = t\n\npublic export\n(++) : HList xs -> HList ys -> HList (xs ++ ys)\n[] ++ ws = ws\n(v :: vs) ++ ws = v :: (vs ++ ws)\n\npublic export\nindexList : (as : List a) -> Fin (length as) -> a\nindexList (x :: _) FZ = x\nindexList (_ :: xs) (FS y) = indexList xs y\nindexList [] x impossible\n\npublic export\nindex : (ix : Fin (length ts)) -> HList ts -> indexList ts ix\nindex FZ (v :: _) = v\nindex (FS x) (_ :: vs) = index x vs\nindex ix [] impossible\n", "meta": {"hexsha": "fd4e4f2ae35d2449a8c01c34557ab38071e41d2e", "size": 889, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/HList.idr", "max_stars_repo_name": "ska80/idris2-tutorial", "max_stars_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 60, "max_stars_repo_stars_event_min_datetime": "2022-01-13T16:14:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T16:16:57.000Z", "max_issues_repo_path": "src/Data/HList.idr", "max_issues_repo_name": "ska80/idris2-tutorial", "max_issues_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2022-01-14T15:42:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T09:53:16.000Z", "max_forks_repo_path": "src/Data/HList.idr", "max_forks_repo_name": "ska80/idris2-tutorial", "max_forks_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2022-01-14T15:48:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T06:49:13.000Z", "avg_line_length": 22.7948717949, "max_line_length": 61, "alphanum_fraction": 0.5793025872, "num_tokens": 296, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.5172235349380722}} {"text": "||| Provie `Day` level function.\nmodule Data.Time.Calendar.Days\n\n||| The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.\npublic export\ndata Day = MkModifiedJulianDay Integer\n\nexport\nEq Day where\n (MkModifiedJulianDay a) == (MkModifiedJulianDay b) = a == b\n\nexport\nOrd Day where\n compare (MkModifiedJulianDay a) (MkModifiedJulianDay b) = compare a b\n\nexport\ntoInteger : Day -> Integer\ntoInteger (MkModifiedJulianDay x) = x\n\nexport\nEnum Day where\n pred (MkModifiedJulianDay x) = MkModifiedJulianDay (pred x)\n toNat (MkModifiedJulianDay x) = toNat x\n fromNat x = MkModifiedJulianDay (fromNat x)\n\nexport\nrange: (Day, Day) -> List Day\nrange (MkModifiedJulianDay x, MkModifiedJulianDay y) = map (MkModifiedJulianDay) [x .. y]\n\nexport\nindex: (Day, Day) -> Nat -> Maybe Day\nindex (a, b) k =\n let (MkModifiedJulianDay a1) = a\n (MkModifiedJulianDay b1) = b\n range_a_b = range (a, b)\n inbounds = inBounds k range_a_b\n in\n case inbounds of\n Yes prf => Just (List.index k range_a_b)\n No contra => Nothing\n\nexport\ninRange: (Day, Day) -> Day -> Bool\ninRange (a, b) k = elem k (range (a, b))\n\nexport\nrangeSize: (Day, Day) -> Nat\nrangeSize x = List.length (range x)\n\nexport\naddDays: Integer -> Day -> Day\naddDays x (MkModifiedJulianDay y) = MkModifiedJulianDay (x + y)\n\nexport\ndiffDays: Day -> Day -> Integer\ndiffDays (MkModifiedJulianDay x) (MkModifiedJulianDay y) = x - y\n", "meta": {"hexsha": "f683adba6cf600b295cd6873945bea45b0821b9e", "size": 1436, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Time/Calendar/Days.idr", "max_stars_repo_name": "gdevanla/idris-time", "max_stars_repo_head_hexsha": "96a488057863d6c3049f62a1ac70734090e50b66", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-08-18T11:02:58.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-18T11:02:58.000Z", "max_issues_repo_path": "src/Data/Time/Calendar/Days.idr", "max_issues_repo_name": "gdevanla/idris-time", "max_issues_repo_head_hexsha": "96a488057863d6c3049f62a1ac70734090e50b66", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2020-07-28T21:13:55.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-20T19:56:41.000Z", "max_forks_repo_path": "src/Data/Time/Calendar/Days.idr", "max_forks_repo_name": "gdevanla/idris-time", "max_forks_repo_head_hexsha": "96a488057863d6c3049f62a1ac70734090e50b66", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1929824561, "max_line_length": 92, "alphanum_fraction": 0.7019498607, "num_tokens": 475, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6723316926137811, "lm_q1q2_score": 0.5170770175455708}} {"text": "module congruences\n\n||| Congruence\npublic export\ncongruence : (ty1, ty2 : Type) -> (a : ty1) -> (b : ty1) -> (f : ty1 -> ty2) -> (a = b) -> ((f a) = (f b))\ncongruence ty1 ty2 a a f Refl = Refl\n", "meta": {"hexsha": "bbd2404e1f6d3f331d4f203c4f6af030e53d32d3", "size": 193, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "_local-site/Code/congruence.idr", "max_stars_repo_name": "anotherArka/LTS2019", "max_stars_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-01-16T18:03:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-13T16:28:41.000Z", "max_issues_repo_path": "_local-site/Code/congruence.idr", "max_issues_repo_name": "anotherArka/LTS2019", "max_issues_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 58, "max_issues_repo_issues_event_min_datetime": "2019-01-08T11:22:38.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-21T10:26:10.000Z", "max_forks_repo_path": "_local-site/Code/congruence.idr", "max_forks_repo_name": "anotherArka/LTS2019", "max_forks_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 22, "max_forks_repo_forks_event_min_datetime": "2019-01-08T05:56:23.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-31T03:58:00.000Z", "avg_line_length": 27.5714285714, "max_line_length": 106, "alphanum_fraction": 0.5544041451, "num_tokens": 85, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.5162951384768528}} {"text": "import Data.Vect\n\nnums : List (Int, Int)\nnums = [(1, 2), (3, 4), (5, 6)]\n\naddToNums : List (Int, Int) -> List (Int, Int)\naddToNums = map (\\ (x, y) => (x + 1, y + 1))\n\nvects : List (n ** Vect n Int)\nvects = [(_ ** [1,2,3]),\n (_ ** [1,2,3,4]),\n (_ ** [1,2,3,4,5])]\n\nlengths : List (n ** Vect n a) -> List Nat\nlengths = map (\\ (len ** xs) => length xs)\n", "meta": {"hexsha": "c3791d5987ea54be2bbc9c81f072ce725483bef4", "size": 366, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/basic024/PatLam.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/basic024/PatLam.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/basic024/PatLam.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 22.875, "max_line_length": 46, "alphanum_fraction": 0.4672131148, "num_tokens": 153, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.5162759356636492}} {"text": "-- examples in \"Type-Driven Development with Idris\"\n-- chapter 14, section 1, Door part\n\n-- check that all functions are total\n%default total\n\ndata DoorResult = OK | Jammed\n\ndata DoorState = DoorClosed | DoorOpen\n\ndata DoorCmd : (ty : Type) ->\n DoorState ->\n (ty -> DoorState) ->\n Type where\n Open : DoorCmd DoorResult DoorClosed\n (\\res => case res of\n OK => DoorOpen\n Jammed => DoorClosed)\n Close : DoorCmd () DoorOpen (const DoorClosed)\n RingBell : DoorCmd () DoorClosed (const DoorClosed)\n Display : String -> DoorCmd () state (const state)\n Pure : (res : ty) -> DoorCmd ty (state res) state\n (>>=) : DoorCmd a state1 state2 ->\n ((res : a) -> DoorCmd b (state2 res) state3) ->\n DoorCmd b state1 state3\n\ndoorProg : DoorCmd () DoorClosed (const DoorClosed)\ndoorProg = do RingBell\n OK <- Open | Jammed => Display \"Door Jammed\"\n Display \"Door OK\"\n Close\n\nlogOpen : DoorCmd DoorResult DoorClosed\n (\\res => case res of\n OK => DoorOpen\n Jammed => DoorClosed)\nlogOpen = do Display \"Trying to open the door\"\n OK <- Open | Jammed => do Display \"Jammed\"\n Pure Jammed\n Display \"Success\"\n Pure OK\n", "meta": {"hexsha": "61ea91bc5918ba56121e6ead2c8bab30155e0e8b", "size": 1714, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter14/DoorJam.idr", "max_stars_repo_name": "pascalpoizat/idris-book", "max_stars_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-08-16T00:58:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T01:07:37.000Z", "max_issues_repo_path": "chapter14/DoorJam.idr", "max_issues_repo_name": "pascalpoizat/idris-book", "max_issues_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter14/DoorJam.idr", "max_forks_repo_name": "pascalpoizat/idris-book", "max_forks_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-23T03:15:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-23T03:15:39.000Z", "avg_line_length": 40.8095238095, "max_line_length": 78, "alphanum_fraction": 0.4381563594, "num_tokens": 349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5159353058482534}} {"text": "import Data.Vect\n\ntest1 : Vect 4 Int\ntest1 = [1, 2, 3, 4]\n\ntest2: Vect (2 + 2) Int\ntest2 = test1\n", "meta": {"hexsha": "2db12ad8f10c706f94de390bdb993dc9f4e60e86", "size": 97, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ZPF/Slajdy19/PlikiIdrisa/TCVects.idr", "max_stars_repo_name": "wdomitrz/Coq-Exercises", "max_stars_repo_head_hexsha": "86d6ae9488901a0f61d45234a6b1c2c684cf60ef", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ZPF/Slajdy19/PlikiIdrisa/TCVects.idr", "max_issues_repo_name": "wdomitrz/Coq-Exercises", "max_issues_repo_head_hexsha": "86d6ae9488901a0f61d45234a6b1c2c684cf60ef", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ZPF/Slajdy19/PlikiIdrisa/TCVects.idr", "max_forks_repo_name": "wdomitrz/Coq-Exercises", "max_forks_repo_head_hexsha": "86d6ae9488901a0f61d45234a6b1c2c684cf60ef", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 12.125, "max_line_length": 23, "alphanum_fraction": 0.618556701, "num_tokens": 46, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.5147493506925676}} {"text": "data InfIO: Type where\n Do: IO a -> (a -> Inf InfIO) -> InfIO\n\n(>>=) : IO a -> (a -> Inf InfIO) -> InfIO\n(>>=) = Do\n\ndata Fuel = Dry | More (Lazy Fuel)\n\nforever: Fuel\nforever = More forever\n\ntank: Nat -> Fuel\ntank Z = Dry\ntank (S k) = More (tank k)\n\nprintLoop: String -> InfIO\nprintLoop msg =\n do\n putStrLn msg\n printLoop msg\n\nrun: InfIO -> IO()\nrun (Do action cont) =\n do\n res <- action\n run (cont res)\n\nrunFuel: Fuel -> InfIO -> IO()\nrunFuel Dry y = putStrLn \"Out of fuel\"\nrunFuel (More fuel) (Do action cont) =\n do\n res <- action\n runFuel fuel (cont res)\n", "meta": {"hexsha": "7218477578dbcf523517f4a87c49dfdc801a3c89", "size": 603, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "11_2_InfIO.idr", "max_stars_repo_name": "coffius/idris-exercises", "max_stars_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "11_2_InfIO.idr", "max_issues_repo_name": "coffius/idris-exercises", "max_issues_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "11_2_InfIO.idr", "max_forks_repo_name": "coffius/idris-exercises", "max_forks_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 17.7352941176, "max_line_length": 61, "alphanum_fraction": 0.5754560531, "num_tokens": 196, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.5142944490032093}} {"text": "module Quantities.Information\n\nimport Quantities.Core\n\n%default total\n%access public export\n\nInformation : Dimension\nInformation = MkDimension \"Information\"\n\nBit : ElemUnit Information\nBit = MkElemUnit \"bit\" 1\n\nByte : ElemUnit Information\nByte = < one \"byte\" equals 8 Bit >\n\n-- Binary prefixes for multiples of bits/bytes\n-- Based on http://en.wikipedia.org/wiki/Binary_prefix\n\ntwoToTheTen : String -> Nat -> ElemUnit q -> ElemUnit q\ntwoToTheTen pre power (MkElemUnit name f) =\n < one (pre ++ name) equals (pow 1024.0 power) (MkElemUnit name f) >\n\nkibi : ElemUnit q -> ElemUnit q\nkibi = twoToTheTen \"kibi\" 1\nki : ElemUnit q -> ElemUnit q\nki = kibi\n\nmebi : ElemUnit q -> ElemUnit q\nmebi = twoToTheTen \"mebi\" 2\nmi : ElemUnit q -> ElemUnit q\nmi = mebi\n\ngibi : ElemUnit q -> ElemUnit q\ngibi = twoToTheTen \"gibi\" 3\ngi : ElemUnit q -> ElemUnit q\ngi = gibi\n\ntebi : ElemUnit q -> ElemUnit q\ntebi = twoToTheTen \"tebi\" 4\nti : ElemUnit q -> ElemUnit q\nti = tebi\n\npebi : ElemUnit q -> ElemUnit q\npebi = twoToTheTen \"pebi\" 5\npi : ElemUnit q -> ElemUnit q\npi = pebi\n\nexbi : ElemUnit q -> ElemUnit q\nexbi = twoToTheTen \"exbi\" 6\nei : ElemUnit q -> ElemUnit q\nei = exbi\n\nzebi : ElemUnit q -> ElemUnit q\nzebi = twoToTheTen \"zebi\" 7\nzi : ElemUnit q -> ElemUnit q\nzi = zebi\n\nyobi : ElemUnit q -> ElemUnit q\nyobi = twoToTheTen \"yobi\" 8\nyi : ElemUnit q -> ElemUnit q\nyi = yobi\n\n-- Please Note: kibi byte /= kilo byte\n", "meta": {"hexsha": "5a9dacbc4d88b2bac127044b0b118970a2ac44c5", "size": 1396, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Quantities/Information.idr", "max_stars_repo_name": "timjb/quantities", "max_stars_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 112, "max_stars_repo_stars_event_min_datetime": "2015-01-18T13:52:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T14:15:46.000Z", "max_issues_repo_path": "Quantities/Information.idr", "max_issues_repo_name": "timjb/quantities", "max_issues_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2015-11-04T08:51:41.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-17T09:52:29.000Z", "max_forks_repo_path": "Quantities/Information.idr", "max_forks_repo_name": "timjb/quantities", "max_forks_repo_head_hexsha": "140357c3ec06e5b29b5d369cb59f1f5925f000a5", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 9, "max_forks_repo_forks_event_min_datetime": "2015-04-28T23:49:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-01T17:28:34.000Z", "avg_line_length": 21.4769230769, "max_line_length": 69, "alphanum_fraction": 0.7005730659, "num_tokens": 479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.513772633552825}} {"text": "module LongestNonRepeatingSubstring\n\nSet : Type -> Type\nSet = List\n\ncontains : Eq a => a -> Set a -> Bool\ncontains x [] = False\ncontains x (y :: ys) = (x == y) || contains x ys\n\nadd : a -> Set a -> Set a\nadd x xs = x :: xs\n\nemptySet : {0 a : Type} -> Set a\nemptySet = []\n\nlongestHelp : {0 a : Type} -> Eq a => Set a -> Int -> Int -> List a -> Int\nlongestHelp seen count soFar [] = max soFar count\nlongestHelp seen count soFar (x :: xs) =\n if contains x seen then longestHelp (emptySet {a}) 0 (max soFar count) (x :: xs) else\n longestHelp (add x seen) (count + 1) soFar xs\n\nlongest : Eq a => List a -> Int\nlongest = longestHelp (emptySet {a}) 0 0\n\ntest1 : longest (unpack \"abcabcbb\") = 3\ntest1 = Refl\ntest2 : longest (unpack \"bbbbb\") = 1\ntest2 = Refl\ntest3 : longest (unpack \"pwwkew\") = 3\ntest3 = Refl\ntest4 : longest (unpack \"\") = 0\ntest4 = Refl\n", "meta": {"hexsha": "fa3e888677e0c8f96ff6100983607ba6fa298c61", "size": 848, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "LongestNonRepeatingSubstring.idr", "max_stars_repo_name": "Smaug123/leetcode-idris", "max_stars_repo_head_hexsha": "6df26ef8875d83443cd2c35a7290d88f071ae33d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "LongestNonRepeatingSubstring.idr", "max_issues_repo_name": "Smaug123/leetcode-idris", "max_issues_repo_head_hexsha": "6df26ef8875d83443cd2c35a7290d88f071ae33d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "LongestNonRepeatingSubstring.idr", "max_forks_repo_name": "Smaug123/leetcode-idris", "max_forks_repo_head_hexsha": "6df26ef8875d83443cd2c35a7290d88f071ae33d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.696969697, "max_line_length": 87, "alphanum_fraction": 0.6273584906, "num_tokens": 296, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.7310585727705126, "lm_q1q2_score": 0.5135906301939899}} {"text": "module Subtyping\n\nimport Expr\nimport Maps\n\n%access public export\n\n%default total\n\ndata Ty : Type where\n TyTop : Ty\n TyBool : Ty\n TyBase : Id -> Ty\n TyArrow : Ty -> Ty -> Ty\n TyUnit : Ty\n\nnamespace Types\n A : Ty\n A = TyBase A\n\n B : Ty\n B = TyBase B\n\n C : Ty\n C = TyBase C\n\n D : Ty\n D = TyBase D\n\n E : Ty\n E = TyBase E\n\n F : Ty\n F = TyBase F\n\ndata Tm : Type where\n Var : Id -> Tm\n App : Tm -> Tm -> Tm\n Abs : Id -> Ty -> Tm -> Tm\n Tru : Tm\n Fls : Tm\n Test : Tm -> Tm -> Tm -> Tm\n Unit : Tm\n\nsubst : (x : Id) -> (s, t : Tm) -> Tm\nsubst x s (Var y) with (decEq x y)\n subst x s (Var y) | Yes _ = s\n subst x s (Var y) | No _ = Var y\nsubst x s (App t1 t2) = App (subst x s t1) (subst x s t2)\nsubst x s (Abs y ty t) with (decEq x y)\n subst x s (Abs y ty t) | Yes _ = Abs y ty t\n subst x s (Abs y ty t) | No _ = Abs y ty (subst x s t)\nsubst x s Tru = Tru\nsubst x s Fls = Fls\nsubst x s (Test t1 t2 t3) = Test (subst x s t1) (subst x s t2) (subst x s t3)\nsubst x s Unit = Unit\n\ndata Value : Tm -> Type where\n V_Abs : Value (Abs x ty t)\n V_Tru : Value Tru\n V_Fls : Value Fls\n V_Unit : Value Unit\n\ndata Step : Tm -> Tm -> Type where\n ST_AppAbs : Value t2 -> Step (App (Abs x ty t1) t2) (subst x t2 t1)\n ST_App1 : Step t1 t1' -> Step (App t1 t2) (App t1' t2)\n ST_App2 : Value t1 -> Step t2 t2' -> Step (App t1 t2) (App t1 t2')\n ST_Test : Step t1 t1' -> Step (Test t1 t2 t3) (Test t1' t2 t3)\n ST_TestTru : Step (Test Tru t2 t3) t2\n ST_TestFls : Step (Test Fls t2 t3) t3\n\ninfix 4 -+>\n\n(-+>) : Tm -> Tm -> Type\n(-+>) = Step\n\ndata Subtype : Ty -> Ty -> Type where\n S_Refl : Subtype ty ty\n S_Trans : Subtype ty1 ty2 -> Subtype ty2 ty3 -> Subtype ty1 ty3\n S_Top : Subtype ty TyTop\n S_Arrow : Subtype ty3 ty1 -> Subtype ty2 ty4 ->\n Subtype (TyArrow ty1 ty2) (TyArrow ty3 ty4)\n\ninfix 4 <:\n\n(<:) : Ty -> Ty -> Type\n(<:) = Subtype\n\nsubtyping_example_0 : TyArrow C TyBool <: TyArrow C TyTop\nsubtyping_example_0 = S_Arrow S_Refl S_Top\n", "meta": {"hexsha": "47e8dc3c6e27ffa62adbb7a21a118506b0aa28ff", "size": 1962, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Subtyping.idr", "max_stars_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_stars_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Subtyping.idr", "max_issues_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_issues_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Subtyping.idr", "max_forks_repo_name": "minhnhdo/programming-language-foundations-in-idris", "max_forks_repo_head_hexsha": "0881c34307afa8c90cda2290bf72910be4a1ea57", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 21.5604395604, "max_line_length": 77, "alphanum_fraction": 0.5876656473, "num_tokens": 809, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5132228226367482}} {"text": "module IR.Layout\n\nimport IR\nimport IR.StackSet\n\n%default total\n\ncolumn : Rectangle -> (n : Nat) -> Vect n Rectangle\ncolumn r n = column' n r n\n where column' _ _ Z = []\n column' n (MkRectangle x y w h) (S m) =\n let w' = w / fromInteger (toIntegerNat n)\n in MkRectangle (x + w' * fromInteger (toIntegerNat m)) y w' h :: column' n r m\n\nfullLayout : LayoutF wid\nfullLayout rect s = zip (integrate s) (replicate (stackLength s) rect)\n\ncolumnLayout : LayoutF wid\ncolumnLayout rect s = zip (integrate s) (column rect (stackLength s))\n\nmirrorLayout : LayoutF wid -> LayoutF wid\nmirrorLayout l (MkRectangle x' y' w' h') s = map (\\(wid, MkRectangle x y w h) => (wid, MkRectangle ((y - y') / h' * w' + x') ((x - x') / w' * h' + y') (h / h' * w') (w / w' * h'))) (l (MkRectangle x' y' w' h') s)\n\nsingle : LayoutF wid -> Layout wid\nsingle l = x\n where x = MkLayout l x\n\nchoose : Vect (S n) (LayoutF wid) -> Layout wid\nchoose {n} {wid} (x::xs) =\n let xs' : Vect (S n) (LayoutF wid) = rewrite plusCommutative 1 n in xs ++ [x]\n in MkLayout x (choose xs')\n", "meta": {"hexsha": "bc2aad5b9f1c87b2860159731dc58ac8d723a7aa", "size": 1069, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/IR/Layout.idr", "max_stars_repo_name": "puffnfresh/iridium", "max_stars_repo_head_hexsha": "2dc438475962b62f6ca8d00f0dff3add87418dec", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 133, "max_stars_repo_stars_event_min_datetime": "2015-01-07T20:02:06.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-10T18:09:54.000Z", "max_issues_repo_path": "src/IR/Layout.idr", "max_issues_repo_name": "victoredwardocallaghan/iridium", "max_issues_repo_head_hexsha": "e1fde25ed8a4c601dcdddc5ef81c03bfca8f459a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2016-01-18T01:32:33.000Z", "max_issues_repo_issues_event_max_datetime": "2018-10-09T02:36:06.000Z", "max_forks_repo_path": "src/IR/Layout.idr", "max_forks_repo_name": "victoredwardocallaghan/iridium", "max_forks_repo_head_hexsha": "e1fde25ed8a4c601dcdddc5ef81c03bfca8f459a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2015-11-02T05:18:42.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-29T02:12:48.000Z", "avg_line_length": 33.40625, "max_line_length": 212, "alphanum_fraction": 0.6136576239, "num_tokens": 362, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.82893881677331, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.5129311205901026}} {"text": "module Numeric.Floating\n\npublic export\ninterface Fractional ty => Floating ty where\n constructor MkFloating\n pi : ty\n euler : ty\n exp : ty -> ty\n log : ty -> ty\n pow : ty -> ty -> ty -- (**)\n sin : ty -> ty\n cos : ty -> ty\n tan : ty -> ty\n asin : ty -> ty\n acos : ty -> ty\n atan : ty -> ty\n sinh : ty -> ty\n cosh : ty -> ty\n tanh : ty -> ty\n sqrt : ty -> ty\n\nexport\nFloating Double where\n pi = Prelude.Types.pi\n euler = Prelude.Types.euler\n exp = Prelude.Types.exp\n log = Prelude.Types.log\n pow = Prelude.Types.pow\n sin = Prelude.Types.sin\n cos = Prelude.Types.cos\n tan = Prelude.Types.tan\n asin = Prelude.Types.asin\n acos = Prelude.Types.acos\n atan = Prelude.Types.atan\n sinh = Prelude.Types.sinh\n cosh = Prelude.Types.cosh\n tanh = Prelude.Types.tanh\n sqrt = Prelude.Types.sqrt\n\n-- export\n-- Floating Double where\n-- pi = 3.14159265358979323846\n-- euler = 2.7182818284590452354\n-- exp x = prim__doubleExp x\n-- log x = prim__doubleLog x\n-- pow x y = exp (y * log x) -- prim__doublePow x y\n-- sin x = prim__doubleSin x\n-- cos x = prim__doubleCos x\n-- tan x = prim__doubleTan x\n-- asin x = prim__doubleASin x\n-- acos x = prim__doubleACos x\n-- atan x = prim__doubleATan x\n-- sinh x = (exp x - exp (-x)) / 2\n-- cosh x = (exp x + exp (-x)) / 2\n-- tanh x = sinh x / cosh x -- can this NaN via cosh = 0? can cosh even be 0?\n-- sqrt x = prim__doubleSqrt x\n-- floor x = prim__doubleFloor x\n-- ceiling x = prim__doubleCeiling x\n", "meta": {"hexsha": "ff889a2da6f809294226c487cbc48ba9bb850322", "size": 1483, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Numeric/Floating.idr", "max_stars_repo_name": "MarcelineVQ/sarray", "max_stars_repo_head_hexsha": "e7728a9b89396ef6241318be9f82c45577969c8c", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 7, "max_stars_repo_stars_event_min_datetime": "2021-09-11T09:00:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T17:25:53.000Z", "max_issues_repo_path": "src/Numeric/Floating.idr", "max_issues_repo_name": "MarcelineVQ/idris2-sarray", "max_issues_repo_head_hexsha": "e7728a9b89396ef6241318be9f82c45577969c8c", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Numeric/Floating.idr", "max_forks_repo_name": "MarcelineVQ/idris2-sarray", "max_forks_repo_head_hexsha": "e7728a9b89396ef6241318be9f82c45577969c8c", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.1355932203, "max_line_length": 79, "alphanum_fraction": 0.6271072151, "num_tokens": 503, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.512803963481898}} {"text": "public export\ninterface Do (m : Type) where\n Next : m -> Type\n bind : (x : m) -> Next x\n\npublic export\nMonad m => Do (m a) where\n Next x = {b : Type} -> (a -> m b) -> m b\n bind x k = x >>= k\n\nfoo : Maybe Int -> Maybe Int -> Maybe Int\nfoo x y\n = bind x (\\x' =>\n bind y (\\y' => Just (x' + y')))\n\n", "meta": {"hexsha": "04a9dce086ea06e6deae464080305026806543e4", "size": 304, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/interface004/Do.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/idris2/interface004/Do.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/idris2/interface004/Do.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.0, "max_line_length": 42, "alphanum_fraction": 0.5032894737, "num_tokens": 111, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6688802669716106, "lm_q1q2_score": 0.5125586965659849}} {"text": "{-\n205\n[]\nTrue\nTrue\n36\n[(1, 5), (1, 6), (2, 5), (2, 6), (11, 5), (11, 6), (11, 7), (12, 4), (12, 8), (13, 3), (13, 9), (14, 3), (14, 9), (15, 6), (16, 4), (16, 8), (17, 5), (17, 6), (17, 7), (18, 6), (21, 3), (21, 4), (21, 5), (22, 3), (22, 4), (22, 5), (23, 2), (23, 6), (25, 1), (25, 2), (25, 6), (25, 7), (35, 3), (35, 4), (36, 3), (36, 4)]\n-}\n\nimport Data.HashSet\n\n%default total\n\ndata CollidingInt = MkCollidingInt Int\n\nEq CollidingInt where\n (==) (MkCollidingInt i) (MkCollidingInt j) = i == j\n\nHash CollidingInt where\n hash (MkCollidingInt i) = assert_total (prim__zextInt_B32 (mod i 39))\n\nShow CollidingInt where\n show (MkCollidingInt i) = show i\n\nCell : Type\nCell = (Int, Int)\n\nCells : Type\nCells = HashSet Cell\n\ngosperGun : Cells\ngosperGun = fromList\n [(1,5), (1,6), (2,5), (2,6),\n (11,5), (11,6), (11,7), (12,4), (12,8),\n (13,3), (13,9), (14,3), (14,9), (15,6),\n (16,4), (16,8), (17,5), (17,6), (17,7), (18,6),\n (21,3), (21,4), (21,5), (22,3), (22,4), (22,5),\n (23,2), (23,6), (25,1), (25,2), (25,6), (25,7),\n (35,3), (36,3), (35,4), (36,4)]\n\nfor : Monad m => HashSet a -> (a -> m b) -> m (List b)\nfor xs f = foldM (\\acc, e => (:: acc) <$> f e) [] xs\n\nmain : IO ()\nmain = do\n let keys = MkCollidingInt <$> [0, 5..1024]\n let set = foldl (flip insert) (the (HashSet CollidingInt) empty) keys\n printLn (length set)\n printLn (filter (not . flip member set) keys)\n printLn (all (flip member set) keys)\n printLn (all (not . flip member set) (MkCollidingInt <$> [1024, 1033..2048]))\n\n let cells = gosperGun\n printLn (length cells)\n ls <- for cells pure\n printLn (sort ls)\n\n-- Local Variables:\n-- idris-load-packages: (\"cil\")\n-- End:\n", "meta": {"hexsha": "5de6396bf6e522cd65911eea8a589f75c131e669", "size": 1666, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Tests/HashSet.idr", "max_stars_repo_name": "timjs/iris-clean", "max_stars_repo_head_hexsha": "b2ed1f982beec936cb6fe32e8fa6b97a1da4a4f6", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 146, "max_stars_repo_stars_event_min_datetime": "2015-07-27T12:33:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-25T22:26:35.000Z", "max_issues_repo_path": "Tests/HashSet.idr", "max_issues_repo_name": "timjs/iris-clean", "max_issues_repo_head_hexsha": "b2ed1f982beec936cb6fe32e8fa6b97a1da4a4f6", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 27, "max_issues_repo_issues_event_min_datetime": "2015-09-21T15:08:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-20T13:55:12.000Z", "max_forks_repo_path": "Tests/HashSet.idr", "max_forks_repo_name": "timjs/iris-clean", "max_forks_repo_head_hexsha": "b2ed1f982beec936cb6fe32e8fa6b97a1da4a4f6", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 14, "max_forks_repo_forks_event_min_datetime": "2015-09-21T12:24:16.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-16T21:10:06.000Z", "avg_line_length": 27.3114754098, "max_line_length": 320, "alphanum_fraction": 0.5366146459, "num_tokens": 753, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5125586915079854}} {"text": "module Data.List1\n\n%default total\n\ninfixr 7 :::\n\npublic export\nrecord List1 a where\n constructor (:::)\n head : a\n tail : List a\n\n------------------------------------------------------------------------\n-- Conversion\n\n||| Forget that a list is non-empty\npublic export\nforget : (1 xs : List1 a) -> List a\nforget (x ::: xs) = x :: xs\n\n||| Check whether a list is non-empty\nexport\nfromList : (1 xs : List a) -> Maybe (List1 a)\nfromList [] = Nothing\nfromList (x :: xs) = Just (x ::: xs)\n\n------------------------------------------------------------------------\n-- Basic functions\n\npublic export\nsingleton : (1 x : a) -> List1 a\nsingleton a = a ::: []\n\nexport\nlast : List1 a -> a\nlast (x ::: xs) = loop x xs where\n\n loop : a -> List a -> a\n loop x [] = x\n loop _ (x :: xs) = loop x xs\n\nexport\nfoldr1' : (a -> b -> b) -> (a -> b) -> List1 a -> b\nfoldr1' c n (x ::: xs) = loop x xs where\n\n loop : a -> List a -> b\n loop a [] = n a\n loop a (x :: xs) = c a (loop x xs)\n\nexport\nfoldr1 : (a -> a -> a) -> List1 a -> a\nfoldr1 c = foldr1' c id\n\nexport\nfoldl1 : (a -> b) -> (b -> a -> b) -> List1 a -> b\nfoldl1 n c (x ::: xs) = foldl c (n x) xs\n\n------------------------------------------------------------------------\n-- Append\n\nexport\nappendl : (1 xs : List1 a) -> (1 ys : List a) -> List1 a\nappendl (x ::: xs) ys = x ::: xs ++ ys\n\nexport\nappend : (1 xs, ys : List1 a) -> List1 a\nappend xs ys = appendl xs (forget ys)\n\nexport\nlappend : (1 xs : List a) -> (1 ys : List1 a) -> List1 a\nlappend [] ys = ys\nlappend (x :: xs) ys = append (x ::: xs) ys\n\n------------------------------------------------------------------------\n-- Cons/Snoc\n\npublic export\ncons : (1 x : a) -> (1 xs : List1 a) -> List1 a\ncons x xs = x ::: forget xs\n\nexport\nsnoc : (1 xs : List1 a) -> (1 x : a) -> List1 a\nsnoc xs x = append xs (singleton x)\n\n------------------------------------------------------------------------\n-- Reverse\n\npublic export\nreverseOnto : (1 acc : List1 a) -> (1 xs : List a) -> List1 a\nreverseOnto acc [] = acc\nreverseOnto acc (x :: xs) = reverseOnto (x ::: forget acc) xs\n\npublic export\nreverse : (1 xs : List1 a) -> List1 a\nreverse (x ::: xs) = reverseOnto (singleton x) xs\n\n------------------------------------------------------------------------\n-- Instances\n\nexport\nSemigroup (List1 a) where\n (<+>) = append\n\nexport\nFunctor List1 where\n map f (x ::: xs) = f x ::: map f xs\n\nexport\nApplicative List1 where\n pure x = singleton x\n f ::: fs <*> xs = appendl (map f xs) (fs <*> forget xs)\n\nexport\nMonad List1 where\n (x ::: xs) >>= f = appendl (f x) (xs >>= forget . f)\n\nexport\nFoldable List1 where\n foldr c n (x ::: xs) = c x (foldr c n xs)\n\nexport\nShow a => Show (List1 a) where\n show = show . forget\n\nexport\nEq a => Eq (List1 a) where\n (x ::: xs) == (y ::: ys) = x == y && xs == ys\n\nexport\nOrd a => Ord (List1 a) where\n compare xs ys = compare (forget xs) (forget ys)\n\n------------------------------------------------------------------------\n-- Properties\n\nexport\nconsInjective : the (List1 a) (x ::: xs) === (y ::: ys) -> (x === y, xs === ys)\nconsInjective Refl = (Refl, Refl)\n", "meta": {"hexsha": "5644c9d1ece0fa6749c94438b91fff848e860a0c", "size": 3077, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Data/List1.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/libs/base/Data/List1.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/libs/base/Data/List1.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1366906475, "max_line_length": 79, "alphanum_fraction": 0.476438089, "num_tokens": 938, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.511831489401935}} {"text": "module Control.Monad.Id\n\n%default total\n%access public export\n\n\ndata Id : (a : Type)-> Type where\n IdF : (x : a) -> Id a\n\nimplementation Functor Id where\n map f (IdF a) = IdF (f a)\n\nimplementation Applicative Id where\n pure a = IdF a\n (IdF f) <*> (IdF a) = IdF $ f a\n\nimplementation Monad Id where\n (IdF x) >>= f = f x\n\nimplementation (Show a)=>Show (Id a) where\n show (IdF a) = show a\n", "meta": {"hexsha": "c1521e300398aabe3d0d9febff757ad7ddbb8919", "size": 396, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Control/Monad/Id.idr", "max_stars_repo_name": "idris-industry/idris-free", "max_stars_repo_head_hexsha": "224da5ed197f1ca2729450cecd4f07b4ac78bcc5", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-08-11T15:40:35.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-18T01:43:22.000Z", "max_issues_repo_path": "Control/Monad/Id.idr", "max_issues_repo_name": "idris-industry/idris-free", "max_issues_repo_head_hexsha": "224da5ed197f1ca2729450cecd4f07b4ac78bcc5", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Control/Monad/Id.idr", "max_forks_repo_name": "idris-industry/idris-free", "max_forks_repo_head_hexsha": "224da5ed197f1ca2729450cecd4f07b4ac78bcc5", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 18.0, "max_line_length": 42, "alphanum_fraction": 0.6313131313, "num_tokens": 131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5118136356298052}} {"text": "import Data.Vect\n\nmy_length : List a -> Nat\nmy_length [] = 0\nmy_length (x :: xs) = 1 + my_length xs\n\nmy_reverse : List a -> List a\nmy_reverse [] = []\nmy_reverse (x :: xs) = (my_reverse xs) ++ [x]\n\nmy_map : (a -> b) -> List a -> List b\nmy_map f [] = []\nmy_map f (x :: xs) = f x :: my_map f xs\n\nmy_map2 : (a -> b) -> Vect n a -> Vect n b\nmy_map2 f [] = []\nmy_map2 f (x :: xs) = f x :: my_map2 f xs\n", "meta": {"hexsha": "2a9dd4fbf6447e6049e96aaadc1092a146756cf7", "size": 396, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Exercises_ch2.idr", "max_stars_repo_name": "bkaflowski/tdd_with_idris_excercises", "max_stars_repo_head_hexsha": "3f6ecd4fdd05ef70363203ecb5a8915fae5f4835", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Exercises_ch2.idr", "max_issues_repo_name": "bkaflowski/tdd_with_idris_excercises", "max_issues_repo_head_hexsha": "3f6ecd4fdd05ef70363203ecb5a8915fae5f4835", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Exercises_ch2.idr", "max_forks_repo_name": "bkaflowski/tdd_with_idris_excercises", "max_forks_repo_head_hexsha": "3f6ecd4fdd05ef70363203ecb5a8915fae5f4835", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.0, "max_line_length": 45, "alphanum_fraction": 0.553030303, "num_tokens": 148, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.7122321903471565, "lm_q1q2_score": 0.5118060496073606}} {"text": "module Parcomb\n\ndata Parser a = MkParser (Lazy (String -> (Maybe a, String)))\n\nparse : Parser a -> String -> (Maybe a, String)\nparse p = case p of\n MkParser x => x\n \nclass Applicative f => LazyAlternative (f : Type -> Type) where\n empty : f a\n alt : Lazy (f a) -> Lazy (f a) -> f a\n\n\ninstance Functor Parser where\n map f p = MkParser $ \\str => case (parse p str) of\n (Nothing, rest) => (Nothing, rest)\n (Just x, rest) => (Just (f x), rest)\n\nmutual\n instance Applicative Parser where\n pure a = MkParser $ \\str => (Just a, str)\n mf <$> mp = do\n p <- mp\n f <- mf\n return (f p)\n\n instance Monad Parser where\n p >>= g = MkParser $ \\str => case (parse p str) of\n (Nothing, rest) => (Nothing, rest)\n (Just x, rest) => parse (g x) rest\n \ninstance LazyAlternative Parser where\n empty = MkParser $ \\str => (Nothing, str)\n alt f s = MkParser $ \\str => case (parse f str) of\n (Nothing, rest) => parse s str\n (Just x, rest) => (Just x, rest)\n\nfail : Parser a\nfail = MkParser $ \\str => (Nothing, \"\")\n\nitem : Parser Char\nitem = MkParser $ \\str =>\n case str of\n \"\" => (Nothing, \"\")\n _ => (Just (strHead str), strTail str)\n\nsat : (Char -> Bool) -> Parser Char\nsat p = do\n c <- item\n if p c\n then return c\n else fail\n\nchar : Char -> Parser Char\nchar c = sat (c ==)\n\nstring : String -> Parser String\nstring \"\" = return \"\"\nstring str = do\n char c\n string cs\n return str\nwhere c = strHead str\n cs = strTail str\n\nmutual\n many : Parser a -> (Parser (List a))\n many p = alt (some p) (return [])\n\n some : Parser a -> (Parser (List a))\n some p = do\n a <- p\n as <- many p\n return (a :: as)\n\nnamespace Main\n main : IO ()\n main = putStrLn . show $ parse (many $ char 'p') \"pppa\"\n", "meta": {"hexsha": "0446ccfd835da625a4d4be94d84dab5896079315", "size": 1748, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "playing-around/Parcomb.idr", "max_stars_repo_name": "defanor/parcomb", "max_stars_repo_head_hexsha": "64e69395b6580cd0a9cc973cd2b3c8d04b5d1a89", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "playing-around/Parcomb.idr", "max_issues_repo_name": "defanor/parcomb", "max_issues_repo_head_hexsha": "64e69395b6580cd0a9cc973cd2b3c8d04b5d1a89", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "playing-around/Parcomb.idr", "max_forks_repo_name": "defanor/parcomb", "max_forks_repo_head_hexsha": "64e69395b6580cd0a9cc973cd2b3c8d04b5d1a89", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 22.1265822785, "max_line_length": 63, "alphanum_fraction": 0.5760869565, "num_tokens": 544, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.5117541000644097}} {"text": "import Data.List.Views\n\n-- total\nisSuffix : Eq a => List a -> List a -> Bool\nisSuffix input1 input2 with (MkPair (snocList input1) (snocList input2))\n isSuffix [] input2 | (Empty, s) = True\n isSuffix input1 [] | (s, Empty) = False\n isSuffix (xs ++ [x]) (ys ++ [y]) | (MkPair (Snoc x xs xsrec) (Snoc y ys ysrec))\n = if x == y\n then isSuffix xs ys | (MkPair xsrec ysrec)\n else False\n", "meta": {"hexsha": "be02b403f19f41a18e4e40c5b93907d4354c8203", "size": 406, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/typedd-book/chapter10/IsSuffix.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/tests/typedd-book/chapter10/IsSuffix.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/tests/typedd-book/chapter10/IsSuffix.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.8333333333, "max_line_length": 81, "alphanum_fraction": 0.6034482759, "num_tokens": 140, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.511729747576122}} {"text": "module Data.Tree\n\nimport Data.List\nimport Data.List1\nimport Data.String\n\n%default total\n\n--------------------------------------------------------------------------------\n-- Finite Trees\n--------------------------------------------------------------------------------\n\nmutual\n\n ||| A finite rose tree\n public export\n record Tree (a : Type) where\n constructor MkTree\n value : a\n forest : Forest a\n\n ||| A finite forest of trees\n public export\n Forest : Type -> Type\n Forest = List . Tree\n\n--------------------------------------------------------------------------------\n-- Creating Trees\n--------------------------------------------------------------------------------\n\npublic export\nsingleton : a -> Tree a\nsingleton a = MkTree a []\n\npublic export\nreplicate : (width : Nat) -> (depth : Nat) -> a -> Tree a\nreplicate _ 0 x = MkTree x []\nreplicate width (S k) x = MkTree x $ replicate width (replicate width k x)\n\n||| Unfold a tree up to the given depth.\npublic export\nunfold : (depth : Nat) -> (f : s -> (a,List s)) -> s -> Tree a\nunfold 0 f s = MkTree (fst $ f s) []\nunfold (S k) f s = let (a,ss) = f s\n in MkTree a (map (unfold k f) ss)\n\n--------------------------------------------------------------------------------\n-- Flattening Trees\n--------------------------------------------------------------------------------\n\nzipWithKeep : (a -> a -> a) -> List a -> List a -> List a\nzipWithKeep f [] ys = ys\nzipWithKeep f xs [] = xs\nzipWithKeep f (x :: xs) (y :: ys) = f x y :: zipWithKeep f xs ys\n\npublic export\nflatten : Tree a -> List a\nflatten (MkTree v vs) = v :: flattenF vs\n where flattenF : Forest a -> List a\n flattenF [] = Nil\n flattenF (x :: xs) = flatten x ++ flattenF xs\n\npublic export\nlayers : Tree a -> List (List a)\nlayers (MkTree v vs) = [v] :: layersF vs\n where layersF : Forest a -> List (List a)\n layersF [] = Nil\n layersF (x :: xs) = zipWithKeep (++) (layers x) (layersF xs)\n\n--------------------------------------------------------------------------------\n-- Accessing Elements\n--------------------------------------------------------------------------------\n\npublic export\nindex : List Nat -> Tree a -> Maybe a\nindex [] x = Just x.value\nindex (y :: ys) x = ix y x.forest >>= index ys\n where ix : Nat -> List b -> Maybe b\n ix _ [] = Nothing\n ix 0 (z :: _) = Just z\n ix (S k) (_ :: zs) = ix k zs\n\n--------------------------------------------------------------------------------\n-- Functor and Monad Implementations\n--------------------------------------------------------------------------------\n\n-- All implementations are boilerplaty to satisfy the totality checker.\nfoldlTree : (a -> e -> a) -> a -> Tree e -> a\nfoldlTree f acc (MkTree v vs) = foldlF (f acc v) vs\n where foldlF : a -> Forest e -> a\n foldlF y [] = y\n foldlF y (x :: xs) = foldlF (foldlTree f y x) xs\n\nfoldrTree : (e -> a -> a) -> a -> Tree e -> a\nfoldrTree f acc (MkTree v vs) = f v (foldrF acc vs)\n where foldrF : a -> Forest e -> a\n foldrF y [] = y\n foldrF y (x :: xs) = foldrTree f (foldrF y xs) x\n\ntraverseTree : Applicative f => (a -> f b) -> Tree a -> f (Tree b)\ntraverseTree fun (MkTree v vs) = [| MkTree (fun v) (traverseF vs) |]\n where traverseF : Forest a -> f (Forest b)\n traverseF [] = pure []\n traverseF (x :: xs) = [| traverseTree fun x :: traverseF xs |]\n\nmapTree : (a -> b) -> Tree a -> Tree b\nmapTree f (MkTree v vs) = MkTree (f v) (mapF vs)\n where mapF : Forest a -> Forest b\n mapF [] = []\n mapF (h :: t) = mapTree f h :: mapF t\n\nbindTree : Tree a -> (a -> Tree b) -> Tree b\nbindTree (MkTree va tas) f =\n let MkTree vb tbs = f va\n in MkTree vb (tbs ++ bindF tas)\n\n where bindF : Forest a -> Forest b\n bindF [] = []\n bindF (x :: xs) = bindTree x f :: bindF xs\n\napTree : Tree (a -> b) -> Tree a -> Tree b\napTree tf ta = bindTree tf $ \\f => mapTree (apply f) ta\n\njoinTree : Tree (Tree a) -> Tree a\njoinTree (MkTree (MkTree va tas) ftas) =\n MkTree va $ tas ++ joinF ftas\n\n where joinF : Forest (Tree a) -> Forest a\n joinF [] = []\n joinF (x :: xs) = joinTree x :: joinF xs\n\neqTree : Eq a => Tree a -> Tree a -> Bool\neqTree (MkTree x xs) (MkTree y ys) = x == y && eqF xs ys\n where eqF : Forest a -> Forest a -> Bool\n eqF [] [] = True\n eqF [] (_ :: _) = False\n eqF (_ :: _) [] = False\n eqF (x :: xs) (y :: ys) = eqTree x y && eqF xs ys\n\n--------------------------------------------------------------------------------\n-- Visualizing Trees\n--------------------------------------------------------------------------------\n\nexport\ndrawTree : Tree String -> String\ndrawTree = unlines . draw\n where\n drawForest : Forest String -> String\n drawForest = unlines . map drawTree\n\n draw : Tree String -> List String\n draw (MkTree x ts0) = lines x ++ subTrees ts0\n where\n shift : String -> String -> List String -> List String\n shift first other tails =\n zipWith (++) (first :: replicate (length tails) other) tails\n\n subTrees : Forest String -> List String\n subTrees [] = []\n subTrees [t] = \"│\" :: shift \"└╼\" \" \" (draw t)\n subTrees (t::ts) = \"│\" :: shift \"├╼\" \"│ \" (draw t) ++ subTrees ts\n\n--------------------------------------------------------------------------------\n-- Interfaces\n--------------------------------------------------------------------------------\n\npublic export %inline\nEq a => Eq (Tree a) where\n (==) = eqTree\n\npublic export %inline\nFoldable Tree where\n foldl = foldlTree\n foldr = foldrTree\n null _ = False\n\npublic export %inline\nFunctor Tree where\n map = mapTree\n\npublic export %inline\nApplicative Tree where\n pure a = MkTree a Nil\n (<*>) = apTree\n\npublic export %inline\nMonad Tree where\n (>>=) = bindTree\n join = joinTree\n\npublic export %inline\nTraversable Tree where\n traverse = traverseTree\n", "meta": {"hexsha": "47a39dd5b3d3f169682459821c3f640252e1d874", "size": 6065, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Tree.idr", "max_stars_repo_name": "buzden/idris2-hedgehog", "max_stars_repo_head_hexsha": "e9858609ea79f0d2e36e66bfb9a2dbceba7771cc", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 22, "max_stars_repo_stars_event_min_datetime": "2021-03-04T18:53:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-22T08:07:54.000Z", "max_issues_repo_path": "src/Data/Tree.idr", "max_issues_repo_name": "buzden/idris2-hedgehog", "max_issues_repo_head_hexsha": "e9858609ea79f0d2e36e66bfb9a2dbceba7771cc", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2021-07-19T14:24:53.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-31T22:59:07.000Z", "max_forks_repo_path": "src/Data/Tree.idr", "max_forks_repo_name": "buzden/idris2-hedgehog", "max_forks_repo_head_hexsha": "e9858609ea79f0d2e36e66bfb9a2dbceba7771cc", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-10-13T20:47:53.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-13T20:47:53.000Z", "avg_line_length": 31.2628865979, "max_line_length": 80, "alphanum_fraction": 0.4586974444, "num_tokens": 1598, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.5117297471880192}} {"text": " module UninhIndent\n\n data MyElem : a -> List a -> Type where\n MyHere : MyElem x (x :: xs)\n MyThere : (later : MyElem x xs) -> MyElem x (y :: xs)\n\n Uninhabited (MyElem a []) where\n uninhabited c = ?uninhabited_rhs\n\n", "meta": {"hexsha": "e3af043c1f304c017ef52a1418cac63109aa3a92", "size": 281, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/idris2/interactive033/UninhIndent.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "tests/idris2/interactive033/UninhIndent.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "tests/idris2/interactive033/UninhIndent.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 28.1, "max_line_length": 66, "alphanum_fraction": 0.4946619217, "num_tokens": 77, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031737869342624, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.5116464245272593}} {"text": "||| Axioms and propsitions for primitive types with an\n||| `Ord` implementation.\nmodule Data.Prim.Ord\n\nimport public Data.Trichotomy\n\n%default total\n\n||| Similar to `Either` but with erased fields.\npublic export\ndata Either0 : Type -> Type -> Type where\n Left0 : (0 v : a) -> Either0 a b\n Right0 : (0 v : b) -> Either0 a b\n\n||| We often don't trust values of type `a === b`, as they might\n||| have been magically crafted using `believe_me` or `assert_total`\n||| followed by `idris_crash`. If a value of another type follows\n||| from a (potentially) magically crafted one, we only want the\n||| second value to reduce at compile time, if the first value\n||| reduces to `Refl`. Otherwise, we risk blowing up the compiler\n||| in an absurd context.\nexport\nstrictRefl : (0 prf : a === b) -> Lazy c -> c\nstrictRefl Refl x = x\n\n--------------------------------------------------------------------------------\n-- Interface\n--------------------------------------------------------------------------------\n\n||| This interface is a witness that the given primitive type\n||| comes with a relation `lt`, with `lt` being a strict total order.\n||| We typically define the following aliases\n||| (or name the relation accordingly):\n|||\n||| `m < n` := lt m n\n||| `m > n` := lt n m\n||| `m <= n` := Either (lt m n) (m === n)\n||| `m >= n` := Either (lt n m) (n === m)\n||| `m /= n` := Either (lt m n) (lt n m)\n|||\n||| The following axioms must hold:\n||| 1. (<) is transitive: From `k < m` and `m < n` follows `k < n`.\n|||\n||| 2. Trichotomy: For all values `m` and `n` exactly one of the\n||| following holds: `m < n`, `m === n`, or `n < m`.\n|||\n||| It is in the nature of a primitive that we can't proof these axioms\n||| in Idris itself. We must therefore assume that they hold on all backends,\n||| and it is the responsibility of programmers implementing\n||| interface `Total` to make sure that the axioms actually hold.\npublic export\ninterface Total (0 a : Type) (0 lt : a -> a -> Type) | lt where\n ||| Axiom I: `<` is transitive.\n 0 transLT : {k,m,n : a} -> lt k m -> lt m n -> lt k n\n\n ||| Axiom II: Trichotomy of `<`, `===`, and `>`.\n trichotomy : (m,n : a) -> Trichotomy lt m n\n\n||| Tests if the first value is strictly less than the second or not\nexport\ntestLT : Total a lt => (x,y : a) -> Either0 (lt x y) (Either (lt y x) (y === x))\ntestLT x y = case trichotomy {lt} x y of\n LT p _ _ => Left0 p\n EQ _ p _ => Right0 (Right $ sym p)\n GT _ _ p => Right0 (Left p)\n\n||| Tests if the first value is strictly greater than the second or not\nexport\ntestGT : Total a lt => (x,y : a) -> Either0 (lt y x) (Either (lt x y) (x === y))\ntestGT x y = case trichotomy {lt} x y of\n GT _ _ p => Left0 p\n LT p _ _ => Right0 (Left p)\n EQ _ p _ => Right0 (Right p)\n\n||| Tests if the two values are provably equal or not\nexport\ntestEQ : Total a lt => (x,y : a) -> Either0 (x === y) (Either (lt x y) (lt y x))\ntestEQ x y = case trichotomy {lt} x y of\n EQ _ p _ => Left0 p\n LT p _ _ => Right0 (Left p)\n GT _ _ p => Right0 (Right p)\n\n--------------------------------------------------------------------------------\n-- Corollaries\n--------------------------------------------------------------------------------\n\n||| `<` is irreflexive.\nexport\n0 irrefl : Total a lt => Not (lt m m)\nirrefl x = case trichotomy m m of\n LT y _ f => f y\n EQ f _ _ => f x\n GT f _ y => f y\n\n--------------------------------------------------------------------------------\n-- Transitivities\n--------------------------------------------------------------------------------\n\nnamespace LT\n\n ||| This is an alias for `transLT`\n export\n 0 trans : Total a lt => lt k m -> lt m n -> lt k n\n trans = transLT\n\n||| `k === m` and `m /= n` implies `k /= n`.\nexport\n0 trans_EQ_NEQ : Total a lt\n => k === m\n -> Either (lt m n) (lt n m)\n -> Either (lt k n) (lt n k)\ntrans_EQ_NEQ eqv neq = rewrite eqv in neq\n\n||| `k === m` and `m /= n` implies `k /= n`.\nexport\n0 trans_NEQ_EQ : Total a lt\n => Either (lt k m) (lt m k)\n -> m === n\n -> Either (lt k n) (lt n k)\ntrans_NEQ_EQ neq eqv = rewrite (sym eqv) in neq\n\n||| `k < m` and `m === n` implies `k < n`\nexport\n0 trans_LT_EQ : Total a lt => lt k m -> m === n -> lt k n\ntrans_LT_EQ p eqv = rewrite sym eqv in p\n\n||| `k === m` and `m < n` implies `k < n`\nexport\n0 trans_EQ_LT : Total a lt => k === m -> lt m n -> lt k n\ntrans_EQ_LT eqv q = rewrite eqv in q\n\n||| `k <= m` and `m < n` implies `k < n`\nexport\n0 trans_LTE_LT : Total a lt => Either (lt k m) (k === m) -> lt m n -> lt k n\ntrans_LTE_LT x y = either (`trans` y) (`trans_EQ_LT` y) x\n\n||| `k < m` and `m <= n` implies `k < n`\nexport\n0 trans_LT_LTE : Total a lt => lt k m -> Either (lt m n) (m === n) -> lt k n\ntrans_LT_LTE x = either (trans x) (trans_LT_EQ x)\n\n||| `k > m` and `m === n` implies `k > n`\nexport\n0 trans_GT_EQ : Total a lt => lt m k -> m === n -> lt n k\ntrans_GT_EQ p eqv = rewrite sym eqv in p\n\n||| `k === m` and `m > n` implies `k > n`\nexport\n0 trans_EQ_GT : Total a lt => k === m -> lt n m -> lt n k\ntrans_EQ_GT eqv q = rewrite eqv in q\n\n||| `k >= m` and `m > n` implies `k > n`\nexport\n0 trans_GTE_GT : Total a lt => Either (lt m k) (m === k) -> lt n m -> lt n k\ntrans_GTE_GT x y = either (trans y) (\\v => trans_EQ_GT (sym v) y) x\n\n||| `k > m` and `m >= n` implies `k > n`\nexport\n0 trans_GT_GTE : Total a lt => lt m k -> Either (lt n m) (n === m) -> lt n k\ntrans_GT_GTE x (Left y) = trans y x\ntrans_GT_GTE x (Right y) = trans_GT_EQ x (sym y)\n\nnamespace LTE\n\n ||| `<=` is reflexive.\n export\n 0 refl : Total a lt => Either (lt m m) (m === m)\n refl = Right Refl\n\n ||| `<=` is transitive.\n export\n 0 trans : Total a lt\n => Either (lt k m) (k === m)\n -> Either (lt m n) (m === n)\n -> Either (lt k n) (k === n)\n trans (Left x) y = Left (trans_LT_LTE x y)\n trans (Right x) (Left y) = Left (trans_EQ_LT x y)\n trans (Right x) (Right y) = Right (trans x y)\n\n ||| `<=` is antisymmetric.\n export\n 0 antisym : Total a lt\n => Either (lt m n) (m === n)\n -> Either (lt n m) (m === n)\n -> m === n\n antisym (Right x) _ = x\n antisym (Left x) (Right y) = y\n antisym (Left x) (Left y) = void (irrefl $ trans x y)\n\n||| `k <= m` and `m === n` implies `k <= n`\nexport\n0 trans_LTE_EQ : Total a lt\n => Either (lt k m) (k === m)\n -> m === n\n -> Either (lt k n) (k === n)\ntrans_LTE_EQ lte eq = trans lte (Right eq)\n\n||| `k === m` and `m <= n` implies `(k <= n)`\nexport\n0 trans_EQ_LTE : Total a lt\n => k === m\n -> Either (lt m n) (m === n)\n -> Either (lt k n) (k === n)\ntrans_EQ_LTE eq lte = trans (Right eq) lte\n\nnamespace GTE\n\n ||| `>=` is transitive.\n export\n 0 trans : Total a lt\n => Either (lt m k) (m === k)\n -> Either (lt n m) (n === m)\n -> Either (lt n k) (n === k)\n trans (Left x) y = Left (trans_GT_GTE x y)\n trans (Right x) (Left y) = Left (trans_EQ_GT (sym x) y)\n trans (Right x) (Right y) = Right (trans y x)\n\n ||| `>=` is antisymmetric.\n export\n 0 antisym : Total a lt\n => Either (lt n m) (m === n)\n -> Either (lt m n) (m === n)\n -> m === n\n antisym (Right x) _ = x\n antisym (Left x) (Right y) = y\n antisym (Left x) (Left y) = void (irrefl $ trans x y)\n\n||| `k >= m` and `m === n` implies `k >= n`\nexport\n0 trans_GTE_EQ : Total a lt\n => Either (lt m k) (m === k)\n -> m === n\n -> Either (lt n k) (n === k)\ntrans_GTE_EQ gte eq = trans gte (Right $ sym eq)\n\n||| `k === m` and `m <= n` implies `(k <= n)`\nexport\n0 trans_EQ_GTE : Total a lt\n => k === m\n -> Either (lt n m) (n === m)\n -> Either (lt n k) (n === k)\ntrans_EQ_GTE eq gte = trans (Right $ sym eq) gte\n\n--------------------------------------------------------------------------------\n-- Conversions\n--------------------------------------------------------------------------------\n\n||| `m < n` implies `Not (m > n)`.\nexport\n0 LT_not_GT : Total a lt => lt m n -> Not (lt n m)\nLT_not_GT isLT isGT = case trichotomy m n of\n LT _ _ g => g isGT\n EQ _ _ g => g isGT\n GT f _ _ => f isLT\n\n||| `m < n` implies `Not (m === n)`.\nexport\n0 LT_not_EQ : Total a lt => lt m n -> Not (m === n)\nLT_not_EQ isLT isEQ = case trichotomy m n of\n LT _ g _ => g isEQ\n EQ f _ _ => f isLT\n GT _ g _ => g isEQ\n\n||| `m < n` implies `Not (m >= n)`.\nexport\n0 LT_not_GTE : Total a lt => lt m n -> Not (Either (lt n m) (n === m))\nLT_not_GTE l = either (LT_not_GT l) (\\e => LT_not_EQ l (sym e))\n\n||| `Not (m < n)` implies `m >= n`.\nexport\n0 Not_LT_to_GTE : Total a lt => Not (lt m n) -> Either (lt n m) (n === m)\nNot_LT_to_GTE f = case trichotomy m n of\n LT x _ _ => void (f x)\n EQ _ x _ => Right (sym x)\n GT _ _ x => Left x\n\n||| `m === n` implies `Not (m < n)`.\nexport\n0 EQ_not_LT : Total a lt => m === n -> Not (lt m n)\nEQ_not_LT = flip LT_not_EQ\n\n||| `m === n` implies `Not (m > n)`.\nexport\n0 EQ_not_GT : Total a lt => m === n -> Not (lt n m)\nEQ_not_GT isEQ = EQ_not_LT (sym isEQ)\n\n||| `m === n` implies `Not (m /= n)`.\nexport\n0 EQ_not_NEQ : Total a lt => m === n -> Not (Either (lt m n) (lt n m))\nEQ_not_NEQ isEQ = either (EQ_not_LT isEQ) (EQ_not_GT isEQ)\n\n||| `Not (m < n)` implies `m /= n`.\nexport\n0 Not_EQ_to_NEQ : Total a lt => Not (m === n) -> Either (lt m n) (lt n m)\nNot_EQ_to_NEQ f = case trichotomy m n of\n LT x _ _ => Left x\n EQ _ x _ => void (f x)\n GT _ _ x => Right x\n\n||| `m > n` implies `Not (m < n)`.\nexport\n0 GT_not_LT : Total a lt => lt n m -> Not (lt m n)\nGT_not_LT = LT_not_GT\n\n||| `m > n` implies `Not (m === n)`.\nexport\n0 GT_not_EQ : Total a lt => lt n m -> Not (m === n)\nGT_not_EQ = flip EQ_not_GT\n\n||| `m > n` implies `Not (m <= n)`.\nexport\n0 GT_not_LTE : Total a lt => lt n m -> Not (Either (lt m n) (m === n))\nGT_not_LTE gt = either (GT_not_LT gt) (GT_not_EQ gt)\n\n||| `Not (m > n)` implies `m <= n`.\nexport\n0 Not_GT_to_LTE : Total a lt => Not (lt n m) -> Either (lt m n) (m === n)\nNot_GT_to_LTE f = case trichotomy m n of\n LT x _ _ => Left x\n EQ _ x _ => Right x\n GT _ _ x => void (f x)\n\n||| `m <= n` implies `Not (m > n)`.\nexport\n0 LTE_not_GT : Total a lt => (Either (lt m n) (m === n)) -> Not (lt n m)\nLTE_not_GT = either LT_not_GT EQ_not_GT\n\n||| `Not (m <= n)` implies `m > n`.\nexport\n0 Not_LTE_to_GT : Total a lt => Not (Either (lt m n) (m === n)) -> lt n m\nNot_LTE_to_GT f = case trichotomy m n of\n LT x _ _ => void (f $ Left x)\n EQ _ x _ => void (f $ Right x)\n GT _ _ x => x\n\n||| `m <= n` and `m >= n` implies `m === n`.\nexport\n0 LTE_and_GTE_to_EQ : Total a lt\n => Either (lt m n) (m === n)\n -> Either (lt n m) (n === m)\n -> m === n\nLTE_and_GTE_to_EQ (Left x) (Right y) = sym y\nLTE_and_GTE_to_EQ (Right x) _ = x\nLTE_and_GTE_to_EQ (Left x) (Left y) = void (LT_not_GT x y)\n\n||| `m <= n` and `m /= n` implies `m < n`.\nexport\n0 LTE_and_NEQ_to_LT : Total a lt\n => Either (lt m n) (m === n)\n -> Either (lt m n) (lt n m)\n -> lt m n\nLTE_and_NEQ_to_LT (Left x) _ = x\nLTE_and_NEQ_to_LT (Right _) (Left x) = x\nLTE_and_NEQ_to_LT (Right x) (Right y) = void (EQ_not_GT x y)\n\n||| `m /= n` implies `Not (m === n)`.\nexport\n0 NEQ_not_EQ : Total a lt => Either (lt m n) (lt n m) -> Not (m === n)\nNEQ_not_EQ = either LT_not_EQ GT_not_EQ\n\n||| `Not (m /= n)` implies `m === n`.\nexport\n0 Not_NEQ_to_EQ : Total a lt => Not (Either (lt m n) (lt n m)) -> m === n\nNot_NEQ_to_EQ f = case trichotomy m n of\n LT x _ _ => void (f $ Left x)\n EQ _ x _ => x\n GT _ _ x => void (f $ Right x)\n\n||| `m /= n` and `m <= n` implies `m < n`.\nexport\n0 NEQ_and_LTE_to_LT : Total a lt\n => Either (lt m n) (lt n m)\n -> Either (lt m n) (m === n)\n -> lt m n\nNEQ_and_LTE_to_LT = flip LTE_and_NEQ_to_LT\n\n||| `m /= n` and `m <= n` implies `m < n`.\nexport\n0 NEQ_and_GTE_to_GT : Total a lt\n => Either (lt m n) (lt n m)\n -> Either (lt n m) (n === m)\n -> lt n m\nNEQ_and_GTE_to_GT (Right x) _ = x\nNEQ_and_GTE_to_GT (Left _) (Left y) = y\nNEQ_and_GTE_to_GT (Left x) (Right y) = void (GT_not_EQ x y)\n\n||| `m >= n` implies `Not (m < n)`.\nexport\n0 GTE_not_LT : Total a lt => Either (lt n m) (n === m) -> Not (lt m n)\nGTE_not_LT = either GT_not_LT EQ_not_GT\n\n||| `Not (m >= n)` implies `m < n`.\nexport\n0 Not_GTE_to_LT : Total a lt => Not (Either (lt n m) (n === m)) -> lt m n\nNot_GTE_to_LT f = case trichotomy m n of\n LT x _ _ => x\n EQ _ x _ => void (f $ Right (sym x))\n GT _ _ x => void (f $ Left x)\n\n||| `m >= n` and `m <= n` implies `m === n`.\nexport\n0 GTE_and_LTE_to_EQ : Total a lt\n => Either (lt n m) (n === m)\n -> Either (lt m n) (m === n)\n -> m === n\nGTE_and_LTE_to_EQ = flip LTE_and_GTE_to_EQ\n\n||| `m >= n` and `m /= n` implies `m > n`.\nexport\n0 GTE_and_NEQ_to_GT : Total a lt\n => Either (lt n m) (n === m)\n -> Either (lt m n) (lt n m)\n -> lt n m\nGTE_and_NEQ_to_GT = flip NEQ_and_GTE_to_GT\n", "meta": {"hexsha": "26c0ac518b45d6a97e513d65d664b130ecaee1a8", "size": 13251, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Prim/Ord.idr", "max_stars_repo_name": "stefan-hoeck/idris2-prim", "max_stars_repo_head_hexsha": "d342072f3b30f7930221bab620a836e0e67c2374", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2022-03-13T22:37:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T22:22:30.000Z", "max_issues_repo_path": "src/Data/Prim/Ord.idr", "max_issues_repo_name": "stefan-hoeck/idris2-prim", "max_issues_repo_head_hexsha": "d342072f3b30f7930221bab620a836e0e67c2374", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Prim/Ord.idr", "max_forks_repo_name": "stefan-hoeck/idris2-prim", "max_forks_repo_head_hexsha": "d342072f3b30f7930221bab620a836e0e67c2374", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.9301204819, "max_line_length": 80, "alphanum_fraction": 0.5087163233, "num_tokens": 4515, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.5109387550216741}} {"text": "-- Primitive Imperative Language --\nmodule Example.Pil\n\nimport Data.List\nimport Data.List.Elem\nimport Data.Maybe\n\n%default total\n\n------------------------------------------------------\n--- Auxiliary data definitions and their instances ---\n------------------------------------------------------\n\nexport\ndata Name = MkName String\n\n%name Name n, m\n\nexport\nFromString Name where\n fromString = MkName\n\nexport\nEq Name where\n MkName n == MkName m = n == m\n\n--- Static context in terms of which we are formulating an invariant ---\n\npublic export\nContext : Type\nContext = List (Name, Type)\n\n%name Context ctx\n\n-----------------------------------------------\n--- List lookup with propositional equality ---\n-----------------------------------------------\n\npublic export\ndata Lookup : a -> List (a, b) -> Type where\n There : Lookup z xys -> Lookup z $ (x, y)::xys\n Here : (y : b) -> Lookup x $ (x, y)::xys\n -- !!! Idris searches from the bottom !!!\n\npublic export\nreveal : Lookup {b} x xys -> b\nreveal (Here y) = y\nreveal (There subl) = reveal subl\n\n-----------------------------------\n--- The main language structure ---\n-----------------------------------\n\npublic export\ndata Expression : (ctx : Context) -> (res : Type) -> Type where\n -- Constant expression\n C : (x : ty) -> Expression ctx ty\n -- Value of the variable\n V : (n : Name) -> (0 ty : Lookup n ctx) => Expression ctx $ reveal ty\n -- Unary operation over the result of another expression\n U : (f : a -> b) -> Expression ctx a -> Expression ctx b\n -- Binary operation over the results of two another expressions\n B : (f : a -> b -> c) -> Expression ctx a -> Expression ctx b -> Expression ctx c\n\ninfix 2 #=, ?#=\ninfixr 1 *>\n\npublic export\ndata Statement : (pre : Context) -> (post : Context) -> Type where\n nop : Statement ctx ctx\n (.) : (0 ty : Type) -> (n : Name) -> Statement ctx $ (n, ty)::ctx\n (#=) : (n : Name) -> (0 ty : Lookup n ctx) => (v : Expression ctx $ reveal ty) -> Statement ctx ctx\n for : (init : Statement outer_ctx inside_for) -> (cond : Expression inside_for Bool)\n -> (upd : Statement inside_for inside_for) -> (body : Statement inside_for after_body)\n -> Statement outer_ctx outer_ctx\n if__ : (cond : Expression ctx Bool) -> Statement ctx ctx_then -> Statement ctx ctx_else -> Statement ctx ctx\n (*>) : Statement pre mid -> Statement mid post -> Statement pre post\n block : Statement outer inside -> Statement outer outer\n print : Show ty => Expression ctx ty -> Statement ctx ctx\n\npublic export %inline\n(>>=) : Statement pre mid -> (Unit -> Statement mid post) -> Statement pre post\na >>= f = a *> f ()\n\npublic export %inline\nif_ : (cond : Expression ctx Bool) -> Statement ctx ctx_then -> Statement ctx ctx\nif_ c t = if__ c t nop\n\npublic export %inline\nwhile : Expression ctx Bool -> Statement ctx after_body -> Statement ctx ctx\nwhile cond = for nop cond nop\n\n-- Define with derived type and assign immediately\npublic export %inline\n(?#=) : (n : Name) -> Expression ((n, ty)::ctx) ty -> Statement ctx $ (n, ty)::ctx\nn ?#= v = ty. n *> n #= v\n\nnamespace AlternativeDefineAndAssign\n\n public export %inline\n (#=) : (p : (Name, Type)) -> Expression (p::ctx) (snd p) -> Statement ctx $ p::ctx\n (n, _) #= v = n ?#= v\n\n public export %inline\n (.) : a -> b -> (b, a)\n (.) a b = (b, a)\n\n-------------------------\n--- Examples of usage ---\n-------------------------\n\n--- Functions lifted to the expression level ---\n\nexport %inline\n(+) : Expression ctx Int -> Expression ctx Int -> Expression ctx Int\n(+) = B (+)\n\nexport %inline\ndiv : Expression ctx Int -> Expression ctx Int -> Expression ctx Int\ndiv = B div\n\nexport %inline\nmod : Expression ctx Int -> Expression ctx Int -> Expression ctx Int\nmod = B mod\n\nexport %inline\n(<) : Expression ctx Int -> Expression ctx Int -> Expression ctx Bool\n(<) = B (<)\n\nexport %inline\n(>) : Expression ctx Int -> Expression ctx Int -> Expression ctx Bool\n(>) = B (>)\n\nexport %inline\n(==) : Eq a => Expression ctx a -> Expression ctx a -> Expression ctx Bool\n(==) = B (==)\n\nexport %inline\n(/=) : Eq a => Expression ctx a -> Expression ctx a -> Expression ctx Bool\n(/=) = B (/=)\n\nexport %inline\n(&&) : Expression ctx Bool -> Expression ctx Bool -> Expression ctx Bool\n(&&) = B (\\a, b => a && b) -- recoded because of laziness\n\nexport %inline\n(++) : Expression ctx String -> Expression ctx String -> Expression ctx String\n(++) = B (++)\n\nexport %inline\nshow : Show ty => Expression ctx ty -> Expression ctx String\nshow = U show\n\n--- Example statements ---\n\nsimple_ass : Statement ctx $ (\"x\", Int)::ctx\nsimple_ass = do\n Int. \"x\"\n \"x\" #= C 2\n\nlost_block : Statement ctx ctx\nlost_block = do\n block $ do\n Int. \"x\"\n \"x\" #= C 2\n Int. \"y\" #= V \"x\"\n Int. \"z\" #= C 3\n print $ V \"y\" + V \"z\" + V \"x\"\n\nsome_for : Statement ctx ctx\nsome_for = for (do Int. \"x\" #= C 0; Int. \"y\" #= C 0) (V \"x\" < C 5 && V \"y\" < C 10) (\"x\" #= V \"x\" + C 1) $ do\n \"y\" #= V \"y\" + V \"x\" + C 1\n\n--bad_for : Statement ctx ctx\n--bad_for = for (do Int. \"x\" #= C 0; Int. \"y\" #= C 0)\n-- (V \"y\")\n-- (\"x\" #= V \"x\" + C 1) $ do\n-- \"y\" #= V \"y\" `div` V \"x\" + C 1\n\neuc : {0 ctx : Context} -> let c = (\"a\", Int)::(\"b\", Int)::ctx in Statement c $ (\"res\", Int)::c\neuc = do\n while (V \"a\" /= C 0 && V \"b\" /= C 0) $ do\n if__ (V \"a\" > V \"b\")\n (\"a\" #= V \"a\" `mod` V \"b\")\n (\"b\" #= V \"b\" `mod` V \"a\")\n Int. \"res\" #= V \"a\" + V \"b\"\n\nname_shadowing : Statement ctx ctx\nname_shadowing = block $ do\n Int. \"x\" #= C 0\n block $ do\n Int. \"x\" #= C 3\n Int. \"y\" #= V \"x\" + C 2\n String. \"x\" #= C \"foo\"\n print $ V \"x\" ++ C \"bar\" ++ show (V \"y\")\n Int. \"z\" #= V \"x\" + C 2\n", "meta": {"hexsha": "34db73ebdcb8c7961138e6317235618db4e51a36", "size": 5643, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "2020.11.24-to-complex-data-gen-presentation/src/Example/Pil.idr", "max_stars_repo_name": "buzden/code-in-lectures", "max_stars_repo_head_hexsha": "282eb243b1474a99a4d34c207bf40d4627fcc9d6", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-02-17T07:01:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-17T07:01:15.000Z", "max_issues_repo_path": "2020.11.24-to-complex-data-gen-presentation/src/Example/Pil.idr", "max_issues_repo_name": "buzden/code-in-lectures", "max_issues_repo_head_hexsha": "282eb243b1474a99a4d34c207bf40d4627fcc9d6", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2020.11.24-to-complex-data-gen-presentation/src/Example/Pil.idr", "max_forks_repo_name": "buzden/code-in-lectures", "max_forks_repo_head_hexsha": "282eb243b1474a99a4d34c207bf40d4627fcc9d6", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 28.6446700508, "max_line_length": 110, "alphanum_fraction": 0.5619351409, "num_tokens": 1676, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6688802471698041, "lm_q1q2_score": 0.5106792084763273}} {"text": "module Data.List.Quantifiers\n\nimport Data.DPair\n\nimport Data.List.Elem\n\n%default total\n\n------------------------------------------------------------------------\n-- Types and basic properties\n\nnamespace Any\n\n ||| A proof that some element of a list satisfies some property\n |||\n ||| @ p the property to be satisfied\n public export\n data Any : (0 p : a -> Type) -> List a -> Type where\n ||| A proof that the satisfying element is the first one in the `List`\n Here : {0 xs : List a} -> p x -> Any p (x :: xs)\n ||| A proof that the satisfying element is in the tail of the `List`\n There : {0 xs : List a} -> Any p xs -> Any p (x :: xs)\n\n export\n Uninhabited (Any p Nil) where\n uninhabited (Here _) impossible\n uninhabited (There _) impossible\n\n export\n {0 p : a -> Type} -> Uninhabited (p x) => Uninhabited (Any p xs) => Uninhabited (Any p $ x::xs) where\n uninhabited (Here y) = uninhabited y\n uninhabited (There y) = uninhabited y\n\n ||| Modify the property given a pointwise function\n export\n mapProperty : (f : {0 x : a} -> p x -> q x) -> Any p l -> Any q l\n mapProperty f (Here p) = Here (f p)\n mapProperty f (There p) = There (mapProperty f p)\n\n ||| Given a decision procedure for a property, determine if an element of a\n ||| list satisfies it.\n |||\n ||| @ p the property to be satisfied\n ||| @ dec the decision procedure\n ||| @ xs the list to examine\n export\n any : (dec : (x : a) -> Dec (p x)) -> (xs : List a) -> Dec (Any p xs)\n any _ Nil = No uninhabited\n any p (x::xs) with (p x)\n any p (x::xs) | Yes prf = Yes (Here prf)\n any p (x::xs) | No ctra =\n case any p xs of\n Yes prf' => Yes (There prf')\n No ctra' => No $ \\case\n Here px => ctra px\n There pxs => ctra' pxs\n\n ||| Forget the membership proof\n export\n toExists : Any p xs -> Exists p\n toExists (Here prf) = Evidence _ prf\n toExists (There prf) = toExists prf\n\nnamespace All\n\n ||| A proof that all elements of a list satisfy a property. It is a list of\n ||| proofs, corresponding element-wise to the `List`.\n public export\n data All : (0 p : a -> Type) -> List a -> Type where\n Nil : All p Nil\n (::) : {0 xs : List a} -> p x -> All p xs -> All p (x :: xs)\n\n Either (Uninhabited $ p x) (Uninhabited $ All p xs) => Uninhabited (All p $ x::xs) where\n uninhabited @{Left _} (px::pxs) = uninhabited px\n uninhabited @{Right _} (px::pxs) = uninhabited pxs\n\n ||| Modify the property given a pointwise function\n export\n mapProperty : (f : {0 x : a} -> p x -> q x) -> All p l -> All q l\n mapProperty f [] = []\n mapProperty f (p::pl) = f p :: mapProperty f pl\n\n ||| Modify the property given a pointwise interface function\n public export\n imapProperty : (0 i : Type -> Type)\n -> (f : {0 a : Type} -> i a => p a -> q a)\n -> {0 types : List Type}\n -> All i types => All p types -> All q types\n imapProperty i f @{[]} [] = []\n imapProperty i f @{ix :: ixs} (x :: xs) = f @{ix} x :: imapProperty i f @{ixs} xs\n\n ||| Forget property source for a homogeneous collection of properties\n public export\n forget : All (const type) types -> List type\n forget [] = []\n forget (x :: xs) = x :: forget xs\n\n ||| Given a decision procedure for a property, decide whether all elements of\n ||| a list satisfy it.\n |||\n ||| @ p the property\n ||| @ dec the decision procedure\n ||| @ xs the list to examine\n export\n all : (dec : (x : a) -> Dec (p x)) -> (xs : List a) -> Dec (All p xs)\n all _ Nil = Yes Nil\n all d (x::xs) with (d x)\n all d (x::xs) | No ctra = No $ \\(p::_) => ctra p\n all d (x::xs) | Yes prf =\n case all d xs of\n Yes prf' => Yes (prf :: prf')\n No ctra' => No $ \\(_::ps) => ctra' ps\n\n export\n zipPropertyWith : (f : {0 x : a} -> p x -> q x -> r x) ->\n All p xs -> All q xs -> All r xs\n zipPropertyWith f [] [] = []\n zipPropertyWith f (px :: pxs) (qx :: qxs)\n = f px qx :: zipPropertyWith f pxs qxs\n\n export\n All Show (map p xs) => Show (All p xs) where\n show pxs = \"[\" ++ show' \"\" pxs ++ \"]\"\n where\n show' : String -> All Show (map p xs') => All p xs' -> String\n show' acc @{[]} [] = acc\n show' acc @{[_]} [px] = acc ++ show px\n show' acc @{_ :: _} (px :: pxs) = show' (acc ++ show px ++ \", \") pxs\n\n ||| A heterogeneous list of arbitrary types\n public export\n HList : List Type -> Type\n HList = All id\n\n------------------------------------------------------------------------\n-- Relationship between all and any\n\n||| If there does not exist an element that satifies the property, then it is\n||| the case that all elements do not satisfy it.\nexport\nnegAnyAll : {xs : List a} -> Not (Any p xs) -> All (Not . p) xs\nnegAnyAll {xs=Nil} _ = Nil\nnegAnyAll {xs=x::xs} f = (f . Here) :: negAnyAll (f . There)\n\n||| If there exists an element that doesn't satify the property, then it is\n||| not the case that all elements satisfy it.\nexport\nanyNegAll : Any (Not . p) xs -> Not (All p xs)\nanyNegAll (Here ctra) (p::_) = ctra p\nanyNegAll (There np) (_::ps) = anyNegAll np ps\n\n||| If none of the elements satisfy the property, then not any single one can.\nexport\nallNegAny : All (Not . p) xs -> Not (Any p xs)\nallNegAny [] p = absurd p\nallNegAny (np :: npxs) (Here p) = absurd (np p)\nallNegAny (np :: npxs) (There p) = allNegAny npxs p\n\n||| Given a proof of membership for some element, extract the property proof for it\npublic export\nindexAll : Elem x xs -> All p xs -> p x\nindexAll Here (p::_ ) = p\nindexAll (There e) ( _::ps) = indexAll e ps\n\n--- Relations between listwise `All` and elementwise `Subset` ---\n\n||| Push in the property from the list level with element level\npublic export\npushIn : (xs : List a) -> (0 _ : All p xs) -> List $ Subset a p\npushIn [] [] = []\npushIn (x::xs) (p::ps) = Element x p :: pushIn xs ps\n\n||| Pull the elementwise property out to the list level\npublic export\npullOut : (xs : List $ Subset a p) -> Subset (List a) (All p)\npullOut [] = Element [] []\npullOut (Element x p :: xs) = let Element ss ps = pullOut xs in Element (x::ss) (p::ps)\n\nexport\npushInOutInverse : (xs : List a) -> (0 prf : All p xs) -> pullOut (pushIn xs prf) = Element xs prf\npushInOutInverse [] [] = Refl\npushInOutInverse (x::xs) (p::ps) = rewrite pushInOutInverse xs ps in Refl\n\nexport\npushOutInInverse : (xs : List $ Subset a p) -> uncurry Quantifiers.pushIn (pullOut xs) = xs\npushOutInInverse [] = Refl\npushOutInInverse (Element x p :: xs) with (pushOutInInverse xs)\n pushOutInInverse (Element x p :: xs) | subprf with (pullOut xs)\n pushOutInInverse (Element x p :: xs) | subprf | Element ss ps = rewrite subprf in Refl\n", "meta": {"hexsha": "bb98c7aa45e91d1ae0891d10e249ab94c7350df2", "size": 6656, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Data/List/Quantifiers.idr", "max_stars_repo_name": "chrrasmussen/Idris2-Erlang", "max_stars_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "idris2/libs/base/Data/List/Quantifiers.idr", "max_issues_repo_name": "chrrasmussen/Idris2-Erlang", "max_issues_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "idris2/libs/base/Data/List/Quantifiers.idr", "max_forks_repo_name": "chrrasmussen/Idris2-Erlang", "max_forks_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 35.0315789474, "max_line_length": 103, "alphanum_fraction": 0.5887920673, "num_tokens": 2103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.5105866916470897}} {"text": "-- examples in \"Type-Driven Development with Idris\"\n-- chapter 13, section 2, Stack part\n\nimport Data.Vect\n\n-- check that all functions are total\n%default total\n\ndata StackCmd : Type -> Nat -> Nat -> Type where\n Push : Integer -> StackCmd () height (S height)\n Pop : StackCmd Integer (S height) height\n Top : StackCmd Integer (S height) (S height)\n GetStr : StackCmd String height height\n PutStr : String -> StackCmd () height height\n Pure : ty -> StackCmd ty s s\n (>>=) : StackCmd a s1 s2 ->\n (a -> StackCmd b s2 s3) ->\n StackCmd b s1 s3\n\nrunStack : (stk : Vect inHeight Integer) ->\n StackCmd ty inHeight outHeight ->\n IO (ty, Vect outHeight Integer)\nrunStack stk (Push x) = pure ((), x :: stk)\nrunStack (x :: xs) Pop = pure (x, xs)\nrunStack (x :: xs) Top = pure (x, x :: xs)\nrunStack stk (Pure x) = pure (x, stk)\nrunStack stk (x >>= f) = do (res, stk') <- runStack stk x\n runStack stk' (f res)\nrunStack stk GetStr = do val <- getLine\n pure (val, stk)\nrunStack stk (PutStr val) = do putStr val\n pure ((), stk)\n\n\ndoAdd : StackCmd () (S (S height)) (S height)\ndoAdd = do val1 <- Pop\n val2 <- Pop\n Push $ val1 + val2\n\ndata StackIO : Nat -> Type where\n Do : StackCmd a h1 h2 ->\n (a -> Inf (StackIO h2)) -> StackIO h1\n\nnamespace StackDo\n (>>=) : StackCmd a h1 h2 ->\n (a -> Inf (StackIO h2)) -> StackIO h1\n (>>=) = Do\n\ndata Fuel = Dry | More (Lazy Fuel)\n\npartial\nforever : Fuel\nforever = More forever\n\nrun : Fuel -> Vect h Integer -> StackIO h -> IO ()\nrun (More fuel) stk (Do c f)\n = do (res, stk') <- runStack stk c\n run fuel stk' (f res)\nrun Dry stk p = pure ()\n\ndata StkInput = Number Integer\n | Add\n\nstrToInput : String -> Maybe StkInput\nstrToInput \"\" = Nothing\nstrToInput \"add\" = Just Add\nstrToInput x = if all isDigit (unpack x)\n then Just (Number (cast x))\n else Nothing\n\nmutual\n tryAdd : StackIO h\n tryAdd {h = (S (S k))}\n = do doAdd\n result <- Top\n PutStr (show result ++ \"\\n\")\n stackCalc\n tryAdd\n = do PutStr \"Fewer than two items on the stack\\n\"\n stackCalc\n\n stackCalc : StackIO h\n stackCalc = do PutStr \"> \"\n input <- GetStr\n case strToInput input of\n Nothing => do PutStr \"Invalid input\\n\"\n stackCalc\n Just (Number x) => do Push x\n stackCalc\n Just Add => tryAdd\n\npartial\nmain : IO ()\nmain = run forever [] stackCalc\n", "meta": {"hexsha": "c40e8508b50e3c718eb36328d5c672d7153dac55", "size": 2640, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter13/StackIO.idr", "max_stars_repo_name": "pascalpoizat/idris-book", "max_stars_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2018-08-16T00:58:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T01:07:37.000Z", "max_issues_repo_path": "chapter13/StackIO.idr", "max_issues_repo_name": "pascalpoizat/idris-book", "max_issues_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chapter13/StackIO.idr", "max_forks_repo_name": "pascalpoizat/idris-book", "max_forks_repo_head_hexsha": "f1ef0ed0a8b8c1690d7ce65258f04322b37ff956", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-23T03:15:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-23T03:15:39.000Z", "avg_line_length": 27.7894736842, "max_line_length": 57, "alphanum_fraction": 0.5492424242, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789269812082, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.5104190593126358}} {"text": "module Main\n\nimport Debug.Trace\n\n{- Image -}\n\nimageWidth : Nat\nimageWidth = 256\n\nimageHeight : Nat\nimageHeight = 256\n\n{- Render -}\n\nmain : IO ()\nmain =\n do\n _ <- fPutStr stdout $ \"P3\\n\" ++ (show imageWidth) ++ \" \" ++ (show imageHeight) ++ \"\\n255\\n\"\n _ <- renderRows imageHeight\n pure ()\n\n where\n\n renderCells : (i : Nat) -> (j : Nat) -> IO (Either FileError ())\n renderCells Z _ = pure (Right ())\n renderCells (S i) j = do\n let i' : Nat = minus imageWidth (i + 1)\n let r : Double = (cast i') / (cast (minus imageWidth 1))\n let g : Double = (cast j) / (cast (minus imageHeight 1))\n let b : Double = 0.25\n\n let ir : Int = cast (255.99 * r)\n let ig : Int = cast (255.99 * g)\n let ib : Int = cast (255.99 * b)\n\n _ <- fPutStrLn stdout $ (show ir) ++ \" \" ++ (show ig) ++ \" \" ++ (show ib)\n\n renderCells i j\n\n renderRows : (j : Nat) -> IO (Either FileError ())\n renderRows Z = pure (Right ())\n renderRows (S j) = do\n _ <- trace (\"Scanlines remaining: \" ++ (show (j + 1))) $ pure ()\n _ <- renderCells imageWidth j\n renderRows j\n", "meta": {"hexsha": "86ccb3bd4f47056bf0558334bca2974e2757f064", "size": 1108, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "book1/src/Main.idr", "max_stars_repo_name": "witt3rd/idris-ray", "max_stars_repo_head_hexsha": "a61704e08f8afc7a6379067a87c0cc9e64c6d2e8", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "book1/src/Main.idr", "max_issues_repo_name": "witt3rd/idris-ray", "max_issues_repo_head_hexsha": "a61704e08f8afc7a6379067a87c0cc9e64c6d2e8", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "book1/src/Main.idr", "max_forks_repo_name": "witt3rd/idris-ray", "max_forks_repo_head_hexsha": "a61704e08f8afc7a6379067a87c0cc9e64c6d2e8", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.0869565217, "max_line_length": 95, "alphanum_fraction": 0.5424187726, "num_tokens": 351, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788903594354, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.5104190137221832}} {"text": "> module Ordering.Properties\n\n> %default total\n> %access public export\n> %auto_implicits on\n\n\n> |||\n> Uninhabited (LT = EQ) where \n> uninhabited Refl impossible\n\n> |||\n> Uninhabited (Prelude.Interfaces.LT = GT) where\n> uninhabited Refl impossible\n\n> |||\n> Uninhabited (EQ = GT) where\n> uninhabited Refl impossible\n\n> |||\n> Uninhabited (EQ = LT) where\n> uninhabited Refl impossible\n\n> |||\n> Uninhabited (Prelude.Interfaces.GT = LT) where\n> uninhabited Refl impossible\n\n> |||\n> Uninhabited (GT = EQ) where\n> uninhabited Refl impossible\n\n", "meta": {"hexsha": "9014e02b41f0334796245e763d6fe7fc33dc08c4", "size": 641, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Ordering/Properties.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Ordering/Properties.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Ordering/Properties.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.03125, "max_line_length": 124, "alphanum_fraction": 0.5834633385, "num_tokens": 177, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.5097910130575891}} {"text": "module GenericZipWith\n\nimport Data.Vect\n\nId : Type -> Type\nId x = x\n\nFunc : (args : Vect n Type) -> (ret : Type) -> (Type -> Type) -> Type\nFunc [] r f = f r\nFunc (x :: xs) r f = (a : f x) -> Func xs r f\n\ngApp : Applicative f => f (Func v r Id) -> Func v r f\ngApp {v = []} fs = fs\ngApp {v = (x :: xs)} fs = \\vs => gApp (fs <*> vs)\n\ngZipWith : Applicative f => Func v r Id -> Func v r f\ngZipWith {f} f' = gApp {f = f} (pure f')\n\nzipWith' : (a -> b -> c) -> Vect n a -> Vect n b -> Vect n c\nzipWith' f = gZipWith {v = [a, b]} f\n\nzipWith3' : (a -> b -> c -> d) -> Vect n a -> Vect n b -> Vect n c -> Vect n d\nzipWith3' f = gZipWith {v = [a, b, c]} f\n\nmap' : (a -> b) -> Vect n a -> Vect n b\nmap' f = gZipWith {v = [a]} f\n\nrepeat' : b -> Vect n b\nrepeat' b = gZipWith {v = []} b\n\nexample : Vect 2 (Int, Bool)\nexample = zipWith' (\\i, b => (i, b)) [1, 2] [True, False]\n", "meta": {"hexsha": "d311bcf21e991a2b95c6950abb8e68a093020e23", "size": 862, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/GenericZipWith.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/GenericZipWith.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/GenericZipWith.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 26.1212121212, "max_line_length": 78, "alphanum_fraction": 0.5162412993, "num_tokens": 350, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.509279489525372}} {"text": "module Data.LeftPad\n\nimport Data.List\nimport Data.List.Predicates.Interleaving\n\n%default total\n%access public export\n\ndata Padding : (s : List Char) -> (target : Nat) -> Type where\n Pad : (pad : Nat) -> Padding s (length s + pad)\n Nop : Padding (ys ++ x :: xs) (length ys)\n\npadding : (s : List Char) -> (target : Nat) -> Padding s target\npadding [] t = Pad t\npadding (x :: xs) Z = Nop {ys = []}\npadding (x :: xs) (S t) with (padding xs t)\n padding (x :: xs) (S (plus (length xs) p)) | Pad p = Pad p\n padding (y :: ys ++ z :: zs) (S (length ys)) | Nop = Nop {ys=y::ys}\n\npad : (s : List Char) -> (c : Char) -> (target : Nat) -> List Char\npad s c target with (padding s target)\n pad s c (length s + pad) | Pad pad = replicate pad c ++ s\n pad (ys ++ x :: xs) c (length ys) | Nop {ys} = ys ++ x :: xs\n\n\nnamespace MorePad\n Pad : (s : List Char) -> (c : Char) -> (target : Nat) -> Type\n Pad s c target with (padding s target)\n Pad s c ((length s) + pad) | (Pad pad) = let ps = replicate pad c in Interleaving ps s (ps ++ s)\n\n Pad (ys ++ (x :: xs)) c (length ys) | Nop = Interleaving Nil (ys ++ (x :: xs)) (ys ++ (x :: xs))\n\n noPad : (s : List Char) -> Interleaving Nil s s\n noPad [] = Empty\n noPad (x :: xs) = RightAdd x (noPad xs)\n\n addPadd : (pad : List Char) -> (s : List Char) -> Interleaving pad s (pad ++ s)\n addPadd [] s = noPad s\n addPadd (x :: xs) s = LeftAdd x (addPadd xs s)\n\n pad : (s : List Char) -> (c : Char) -> (target : Nat) -> Pad s c target\n pad s c target with (padding s target)\n pad s c ((length s) + pad) | (Pad pad) = let ps = replicate pad c in addPadd ps s\n pad (ys ++ (x :: xs)) c (length ys) | Nop = noPad (ys ++ (x::xs))\n", "meta": {"hexsha": "98d5b000402299129ed290d0c8bfb77b70cb170a", "size": 1700, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/LeftPad.idr", "max_stars_repo_name": "MarcelineVQ/idris-containers", "max_stars_repo_head_hexsha": "3cca9329e5eaa04a98fc3ab521986b8d3c035567", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Data/LeftPad.idr", "max_issues_repo_name": "MarcelineVQ/idris-containers", "max_issues_repo_head_hexsha": "3cca9329e5eaa04a98fc3ab521986b8d3c035567", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/LeftPad.idr", "max_forks_repo_name": "MarcelineVQ/idris-containers", "max_forks_repo_head_hexsha": "3cca9329e5eaa04a98fc3ab521986b8d3c035567", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.7777777778, "max_line_length": 100, "alphanum_fraction": 0.5582352941, "num_tokens": 592, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925402, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.5090495782545}} {"text": "module Main\n\n-- base\nimport Control.Monad.State\nimport Data.List\nimport Data.Nat\nimport Data.Vect\nimport System.File\n\n-- contrib\nimport Data.SortedMap\nimport Text.Lexer\nimport Text.Lexer.Core\nimport Text.Parser\nimport Text.Parser.Core\nimport Text.Token\n\n----------------------------------------------------------------------------------------------------\n\nResolution1D : Nat\nResolution1D = 10\n\nTiling : Type\nTiling = Vect Resolution1D $ Vect Resolution1D Bool\n\ntilingOrientations : Tiling -> Vect 16 Tiling\ntilingOrientations tiling = concat $ tilingRotations <$> tilingFlippings tiling where\n tilingFlippings : Tiling -> Vect 4 Tiling\n tilingFlippings tiling =\n [ tiling\n , reverse tiling\n , reverse <$> tiling\n , reverse <$> reverse tiling\n ]\n tilingRotations : Tiling -> Vect 4 Tiling\n tilingRotations tiling =\n [ tiling\n , rotate90 tiling\n , rotate90 $ rotate90 tiling\n , rotate90 $ rotate90 $ rotate90 tiling\n ] where\n rotate90 : Tiling -> Tiling\n rotate90 = reverse . transpose\n\nrecord Tile where\n constructor MkTile\n id : Nat\n tiling : Tiling\n\nShow Tile where\n show (MkTile id tiling) = \"Tile \" ++ show id ++ \" \" ++ show tiling\n\nTilingMap : Type\nTilingMap = SortedMap Nat Tiling\n\ncreateTilingMap : List Tile -> TilingMap\ncreateTilingMap = fromList . map f where\n f : Tile -> (Nat, Tiling)\n f (MkTile id tiling) = (id, tiling)\n\n-- from square root of `length tiles`\nResolution1DImage : Nat\nResolution1DImage = 12\n\nArrangement : Type\nArrangement = Vect Resolution1DImage $ Vect Resolution1DImage $ Maybe Nat\n\nnextCoordinate : {n : Nat} -> (x : Fin $ S n) -> Fin $ S n\nnextCoordinate x with (strengthen x)\n nextCoordinate x | (Left y) = FZ\n nextCoordinate x | (Right y) = FS y\n\nnextCoordinates : {n : Nat} ->\n (x : Fin n) ->\n (y : Fin n) ->\n Maybe (Fin n, Fin n)\nnextCoordinates x y with (n)\n nextCoordinates x y | Z = Nothing\n nextCoordinates x y | (S k) =\n if x == last\n then if y == last\n then Nothing\n else Just (FZ, nextCoordinate y)\n else Just (nextCoordinate x, nextCoordinate y)\n\ndata Direction = DirectionLeft\n | DirectionUp\n\nneighborsToCheck : {n : Nat} ->\n (x : Fin n) ->\n (y : Fin n) ->\n List ((Fin n, Fin n), Direction)\nneighborsToCheck x y = [ ((pred x, y), DirectionUp), ((x, pred y), DirectionLeft) ] where\n pred : {n : Nat} -> (x : Fin n) -> Fin n\n pred FZ = last -- this is additional and not necessary, but allows returning Vect\n pred (FS k) = weaken k\n\nneighborsToCheck' : (arrangement : Arrangement) ->\n (x : Fin Resolution1DImage) ->\n (y : Fin Resolution1DImage) ->\n List (Nat, Direction)\nneighborsToCheck' arrangement x y = do\n ((x', y'), d') <- neighborsToCheck x y\n let n = index x' $ index y' arrangement\n case n of\n Nothing => []\n Just n' => pure (n', d')\n\ncheckTiling : Direction -> (new : Tiling) -> (old : Tiling) -> Bool\ncheckTiling DirectionLeft new old = (index last <$> old) == (index FZ <$> new)\ncheckTiling DirectionUp new old = index last old == index FZ new\n\ncheckNeighbors : (tilingMap : TilingMap) ->\n (new : Tiling) ->\n List (Nat, Direction) ->\n Bool\ncheckNeighbors tilingMap new [] = True\ncheckNeighbors tilingMap new ((n, d) :: xs) =\n case lookup n tilingMap of\n Nothing => ?keysShouldMatch\n Just old => if checkTiling d new old\n then checkNeighbors tilingMap new xs\n else False\n\ncheckNeighbors' : (tilingMap : TilingMap) ->\n (arrangement : Arrangement) ->\n (new : Tiling) ->\n (x : Fin Resolution1DImage) ->\n (y : Fin Resolution1DImage) ->\n Bool\ncheckNeighbors' tilingMap arrangement new x y =\n checkNeighbors tilingMap new $ neighborsToCheck' arrangement x y\n\nfilterTilings : (tilingMap : TilingMap) ->\n (arrangement : Arrangement) ->\n (tilings : List (Nat, Tiling)) ->\n (x : Fin Resolution1DImage) ->\n (y : Fin Resolution1DImage) ->\n List (Nat, Tiling)\nfilterTilings tilingMap arrangement tilings x y =\n filter (\\(_,t) => checkNeighbors' tilingMap arrangement t x y) tilings\n\ntryTilings : (tilingMap : TilingMap) ->\n (arrangement : Arrangement) ->\n (x : Fin Resolution1DImage) ->\n (y : Fin Resolution1DImage) ->\n List Arrangement\ntryTilings tilingMap arrangement x y = ?tryTilings_rhs where\n tilingsToTry : List (Nat, Tiling)\n tilingsToTry = do\n (n, t) <- Data.SortedMap.toList tilingMap\n t' <- toList $ tilingOrientations t\n pure (n, t')\n possibleTilings : List (Nat, Tiling)\n possibleTilings = filterTilings tilingMap arrangement tilingsToTry x y\n nextTry : (Nat, Tiling) -> List Arrangement\n nextTry (n, t) = case nextCoordinates x y of\n Nothing => pure newArrangement\n Just (x',y') => tryTilings newTilingMap newArrangement x' y'\n where\n newTilingMap : TilingMap\n newTilingMap = insert n t tilingMap\n newArrangement : Arrangement\n newArrangement = replaceAt y (replaceAt x (Just n) $ index y arrangement) arrangement\n\nfindTilings : (tilingMap : TilingMap) ->\n List Arrangement\nfindTilings tilingMap = tryTilings tilingMap (pure $ pure Nothing) FZ FZ\n\n----------------------------------------------------------------------------------------------------\n\nnamespace Parsing\n\n data DataKind = DKTile\n | DKSpace\n | DKNum\n | DKColon\n | DKNewline\n | DKDot\n | DKHash\n\n Eq DataKind where\n DKTile == DKTile = True\n DKSpace == DKSpace = True\n DKNum == DKNum = True\n DKColon == DKColon = True\n DKNewline == DKNewline = True\n DKDot == DKDot = True\n DKHash == DKHash = True\n _ == _ = False\n\n TokenKind DataKind where\n TokType DKNum = Nat\n TokType _ = ()\n tokValue DKNum x = integerToNat $ cast x\n tokValue DKTile _ = ()\n tokValue DKSpace _ = ()\n tokValue DKColon _ = ()\n tokValue DKNewline _ = ()\n tokValue DKDot _ = ()\n tokValue DKHash _ = ()\n\n tokenMap : TokenMap $ Token DataKind\n tokenMap = toTokenMap\n [ (digits, DKNum)\n , (is '.', DKDot)\n , (is '#', DKHash)\n , (exact \"Tile\", DKTile)\n , (newline, DKNewline)\n , (space, DKSpace)\n , (is ':', DKColon)\n ]\n\n countExactly : (n : Nat) -> (p : Grammar tok True a) -> Grammar tok (isSucc n) (Vect n a)\n countExactly Z p = Empty []\n countExactly (S k) p = [| p :: countExactly k p |]\n\n grammarTiles : Grammar (Token DataKind) True (List Tile)\n grammarTiles = sepBy1 (match DKNewline) grammarTile where\n grammarPixel : Grammar (Token DataKind) True Bool\n grammarPixel = match DKDot $> False <|> match DKHash $> True\n grammarTiling : Grammar (Token DataKind) True Tiling\n grammarTiling =\n countExactly Resolution1D $ countExactly Resolution1D grammarPixel <* match DKNewline\n grammarTile : Grammar (Token DataKind) True Tile\n grammarTile = do\n match DKTile\n match DKSpace\n id <- match DKNum\n match DKColon\n match DKNewline\n tiling <- grammarTiling\n pure $ MkTile id tiling\n\n export\n readData : String -> Maybe $ List Tile\n readData str = do\n let (tokens, debugLexed) = lex tokenMap str\n parsed = parse grammarTiles $ tok <$> tokens\n case parsed of\n Left _ => Nothing\n Right (rule, _) => Just rule\n\n----------------------------------------------------------------------------------------------------\n\nmain : IO ()\nmain = do\n inputData <- readFile \"./data\"\n case inputData of\n Left err => print err\n Right dat => do\n case readData dat of\n Nothing => pure ()\n Just tiles => do\n let tilingMap = createTilingMap tiles\n print $ findTilings tilingMap\n pure ()\n", "meta": {"hexsha": "cb47cd3b5f825a94440142802484686a26256936", "size": 8182, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "20/Main.idr", "max_stars_repo_name": "jumper149/AoC2020", "max_stars_repo_head_hexsha": "a392b82234fb762278498ec637da871e9debf513", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "20/Main.idr", "max_issues_repo_name": "jumper149/AoC2020", "max_issues_repo_head_hexsha": "a392b82234fb762278498ec637da871e9debf513", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "20/Main.idr", "max_forks_repo_name": "jumper149/AoC2020", "max_forks_repo_head_hexsha": "a392b82234fb762278498ec637da871e9debf513", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.7131782946, "max_line_length": 111, "alphanum_fraction": 0.577487167, "num_tokens": 2149, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.5089002292234104}} {"text": "data DoorState = DoorClosed | DoorOpen\n\ndata DoorCmd : Type -> \n DoorState ->\n DoorState ->\n Type where\n Open : DoorCmd () DoorClosed DoorOpen\n Close : DoorCmd () DoorOpen DoorClosed\n RingBell : DoorCmd () DoorClosed DoorClosed\n\n Pure : ty -> DoorCmd ty state state\n (>>=) : DoorCmd a state1 state2 ->\n (a -> DoorCmd b state2 state3) ->\n DoorCmd b state1 state3\n\n\ndoorProg : DoorCmd () DoorClosed DoorClosed\ndoorProg = do RingBell\n Open\n Close\n\n{-doorProgBad : DoorCmd ()\ndoorProgBad = do Open\n Open\n RingBell-}\n\n\n\n\n\n", "meta": {"hexsha": "808e438e61479e90aa7b8b262cce2d5c731261fc", "size": 634, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp13/Door.idr", "max_stars_repo_name": "Ryxai/idris_book_notes", "max_stars_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "type_driven_book/chp13/Door.idr", "max_issues_repo_name": "Ryxai/idris_book_notes", "max_issues_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "type_driven_book/chp13/Door.idr", "max_forks_repo_name": "Ryxai/idris_book_notes", "max_forks_repo_head_hexsha": "3927f9d72eafe8b8ef8b08280dafe5592084eb18", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.4516129032, "max_line_length": 45, "alphanum_fraction": 0.570977918, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.5087862911185619}} {"text": "module Data.Time.LocalTime.Internal.LocalTime\n\nimport Data.Time.Calendar.Days\nimport Data.Time.Calendar.Gregorian\nimport Data.Time.Clock.DiffTime\nimport Data.Time.Clock.Internal.UTCTime\nimport Data.Time.LocalTime.TimeZone\nimport Data.Time.LocalTime.TimeOfDay\n\nimport Generics.Derive\n\n%default total\n%language ElabReflection\n\n-- --------------------------------------------------------------------------\n\n||| A simple day and time aggregate, where the day is of the specified parameter,\n||| and the time is a TimeOfDay.\n||| Conversion of this (as local civil time) to UTC depends on the time zone.\n||| Conversion of this (as local mean time) to UT1 depends on the longitude.\npublic export\nrecord LocalTime where\n constructor MkLocalTime\n localDay : Day\n localTimeOfDay : TimeOfDay\n%runElab derive \"LocalTime\" [Generic, Eq, Ord, DecEq]\n\npublic export\nShow LocalTime where\n show x = show x.localDay ++ \" \" ++ show x.localTimeOfDay\n\n-- --------------------------------------------------------------------------\n\n||| Get the local time of a UTC time in a time zone.\nexport utcToLocalTime : TimeZone -> UTCTime -> LocalTime\nutcToLocalTime tz (MkUTCTime day dt) = let\n (i, tod) = utcToLocalTimeOfDay tz (timeToTimeOfDay dt)\n in MkLocalTime (addDays i day) tod\n\n||| Get the UTC time of a local time in a time zone.\nexport localTimeToUTC : TimeZone -> LocalTime -> UTCTime\nlocalTimeToUTC tz (MkLocalTime day tod) = let\n (i, todUTC) = localToUTCTimeOfDay tz tod\n in MkUTCTime (addDays i day) (timeOfDayToTime todUTC)\n\n\n\n-- --------------------------------------------------------------------------\n-- vim: tw=80 sw=2 expandtab :", "meta": {"hexsha": "0915ddc23fc3c453f912011aa4078925a32578c4", "size": 1626, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "time-calendar-clock/src/Data/Time/LocalTime/Internal/LocalTime.idr", "max_stars_repo_name": "seagull-kamome/idris2-missing", "max_stars_repo_head_hexsha": "ef0355d0ce0a7381e30b752e25c0aa6319f7a81a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "time-calendar-clock/src/Data/Time/LocalTime/Internal/LocalTime.idr", "max_issues_repo_name": "seagull-kamome/idris2-missing", "max_issues_repo_head_hexsha": "ef0355d0ce0a7381e30b752e25c0aa6319f7a81a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2021-02-03T11:05:02.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-01T12:42:01.000Z", "max_forks_repo_path": "time-calendar-clock/src/Data/Time/LocalTime/Internal/LocalTime.idr", "max_forks_repo_name": "seagull-kamome/idris2-missing", "max_forks_repo_head_hexsha": "ef0355d0ce0a7381e30b752e25c0aa6319f7a81a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.1836734694, "max_line_length": 81, "alphanum_fraction": 0.6506765068, "num_tokens": 393, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5087640914454418}} {"text": "import Control.Monad.Identity\n\n%default total\n\n-- Validated - an Either with a monoidal error --\n\npublic export\ndata Validated e a = Valid a | Invalid e\n\npublic export\n(Eq e, Eq a) => Eq (Validated e a) where\n Valid x == Valid y = x == y\n Invalid e == Invalid f = e == f\n _ == _ = False\n\nexport\n(Show e, Show a) => Show (Validated e a) where\n showPrec d $ Valid x = showCon d \"Valid\" $ showArg x\n showPrec d $ Invalid e = showCon d \"Invalid\" $ showArg e\n\npublic export\nFunctor (Validated e) where\n map f $ Valid x = Valid $ f x\n map _ $ Invalid e = Invalid e\n\npublic export\nBifunctor Validated where\n bimap _ s $ Valid x = Valid $ s x\n bimap f _ $ Invalid e = Invalid $ f e\n\n-- Composition preserves invalidity\npublic export\nSemigroup e => Applicative (Validated e) where\n pure = Valid\n\n Valid f <*> Valid x = Valid $ f x\n Invalid e1 <*> Invalid e2 = Invalid $ e1 <+> e2\n Invalid e <*> Valid _ = Invalid e\n Valid _ <*> Invalid e = Invalid e\n\n-- Composition preserves validity\npublic export\nSemigroup e => Semigroup (Validated e a) where\n l@(Valid _) <+> _ = l\n _ <+> r@(Valid _) = r\n Invalid e1 <+> Invalid e2 = Invalid $ e1 <+> e2\n\npublic export\nMonoid e => Monoid (Validated e a) where\n neutral = Invalid neutral\n\n-- Composition preserves validity\npublic export\nMonoid e => Alternative (Validated e) where\n empty = neutral\n (<|>) = (<+>)\n\npublic export\nFoldable (Validated e) where\n foldr op init $ Valid x = x `op` init\n foldr _ init $ Invalid _ = init\n\n foldl op init $ Valid x = init `op` x\n foldl _ init $ Invalid _ = init\n\n null $ Valid _ = False\n null $ Invalid _ = True\n\npublic export\nTraversable (Validated e) where\n traverse f $ Valid x = Valid <$> f x\n traverse _ $ Invalid e = pure $ Invalid e\n\npublic export %inline\nValidatedL : Type -> Type -> Type\nValidatedL e a = Validated (List e) a\n\npublic export %inline\noneInvalid : e -> Applicative f => Validated (f e) a\noneInvalid x = Invalid $ pure x\n\npublic export %inline\nfromEither : Either e a -> Validated e a\nfromEither $ Right x = Valid x\nfromEither $ Left e = Invalid e\n\npublic export %inline\nfromEitherL : Either e a -> ValidatedL e a\nfromEitherL $ Right x = Valid x\nfromEitherL $ Left e = oneInvalid e\n\npublic export %inline\ntoEither : Validated e a -> Either e a\ntoEither $ Valid x = Right x\ntoEither $ Invalid e = Left e\n\n-- Errorful monadic functions --\n\nf1 : Monad m => Int -> m $ ValidatedL String Int\nf1 5 = pure $ pure 0\nf1 _ = pure $ oneInvalid \"fail 1\"\n\nf2 : Monad m => Int -> m $ ValidatedL String Int\nf2 6 = pure $ pure 0\nf2 _ = pure $ oneInvalid \"fail 2\"\n\n-- Compositions --\n\nc1 : Monad m => m (ValidatedL String Int)\nc1 = f1 1 *> f2 1\n\nc2 : Monad m => m (ValidatedL String Int)\nc2 = (f1 1 *> f2 1) @{Applicative.Compose}\n\n-- These checks are meant to be true --\n\nr1 : Bool\nr1 = runIdentity c1 == Invalid [\"fail 2\"]\n\nr2 : Bool\nr2 = runIdentity c2 == Invalid [\"fail 1\", \"fail 2\"]\n", "meta": {"hexsha": "d6ce386fe85f52fca8209febf35e50d6168c138b", "size": 2950, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "AppComp2.idr", "max_stars_repo_name": "buzden/idris-playground", "max_stars_repo_head_hexsha": "414729c5dbd665fdb05cdfe5318f972fb277a726", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-23T08:24:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-27T02:45:50.000Z", "max_issues_repo_path": "AppComp2.idr", "max_issues_repo_name": "buzden/idris-playground", "max_issues_repo_head_hexsha": "414729c5dbd665fdb05cdfe5318f972fb277a726", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "AppComp2.idr", "max_forks_repo_name": "buzden/idris-playground", "max_forks_repo_head_hexsha": "414729c5dbd665fdb05cdfe5318f972fb277a726", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.1803278689, "max_line_length": 58, "alphanum_fraction": 0.6508474576, "num_tokens": 926, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.5087385372457232}} {"text": "||| [specification](http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf)\nmodule Data.Crypto.Hash.SHS\n\nimport Data.Bits\nimport Data.Crypto.Hash\nimport Data.Crypto.Util\nimport Data.Fin\nimport Data.Mod\nimport Data.Vect\n\n\n-- Functions\n\nch : Bits n -> Bits n -> Bits n -> Bits n\nch x y z = (x `and` y) `xor` (complement x `and` z)\n\nparity : Bits n -> Bits n -> Bits n -> Bits n\nparity x y z = (x `xor` y) `xor` z\n\nmaj : Bits n -> Bits n -> Bits n -> Bits n\nmaj x y z = ((x `and` y) `xor` (x `and` z)) `xor` (y `and` z)\n\nf : Fin 80 -> Bits 32 -> Bits 32 -> Bits 32 -> Bits 32\nf t = if t <= 19 then ch\n else if t <= 39 then parity\n else if t <= 59 then maj\n else parity\n\nΣ256_0 : Bits 32 -> Bits 32\nΣ256_0 x = (rotateRight 2 x `xor` rotateRight 13 x) `xor` rotateRight 22 x\n\nΣ256_1 : Bits 32 -> Bits 32\nΣ256_1 x = (rotateRight 6 x `xor` rotateRight 11 x) `xor` rotateRight 25 x\n\nσ256_0 : Bits 32 -> Bits 32\nσ256_0 x = (rotateRight 7 x `xor` rotateRight 18 x) `xor` shiftRightLogical x (intToBits 3)\n\nσ256_1 : Bits 32 -> Bits 32\nσ256_1 x = (rotateRight 17 x `xor` rotateRight 19 x) `xor` shiftRightLogical x (intToBits 10)\n\nΣ512_0 : Bits 64 -> Bits 64\nΣ512_0 x = (rotateRight 28 x `xor` rotateRight 34 x) `xor` rotateRight 39 x\n\nΣ512_1 : Bits 64 -> Bits 64\nΣ512_1 x = (rotateRight 14 x `xor` rotateRight 18 x) `xor` rotateRight 41 x\n\nσ512_0 : Bits 64 -> Bits 64\nσ512_0 x = (rotateRight 1 x `xor` rotateRight 8 x) `xor` shiftRightLogical x (intToBits 7)\n\nσ512_1 : Bits 64 -> Bits 64\nσ512_1 x = (rotateRight 19 x `xor` rotateRight 61 x) `xor` shiftRightLogical x (intToBits 6)\n\n-- Constants\n\nconst1 : Vect 80 (Bits 32)\nconst1 = concat (map (replicate 20 . intToBits)\n [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6])\n\nconst256 : Vect 64 (Bits 32)\nconst256 = map intToBits\n [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]\n \nconst512 : Vect 80 (Bits 64)\nconst512 = map intToBits\n [0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc,\n 0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118,\n 0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2,\n 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694,\n 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,\n 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5,\n 0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4,\n 0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70,\n 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df,\n 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,\n 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30,\n 0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8,\n 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8,\n 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3,\n 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,\n 0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b,\n 0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178,\n 0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b,\n 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,\n 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817]\n\n-- Preprocessing\n\npad512 : Bits l -> Bits ((div l 512 + 1) * 512)\npad512 {l=l} message = append message\n (append (intToBits 1)\n (append (the (Bits (modToNat (the (Mod 512) (448 - (natToMod l + 1))))) (intToBits 0))\n (the (Bits 64) (intToBits (cast l)))))\n\npad1024 : Bits l -> Bits ((div l 1024 + 1) * 1024)\npad1024 {l=l} message = append message\n (append (intToBits 1)\n (append (the (Bits (modToNat (the (Mod 1024) (896 - (natToMod l + 1))))) (intToBits 0))\n (the (Bits 128) (intToBits (cast l)))))\n\nparse512 : Bits (n * 512) -> Vect n (Bits 512)\nparse512 = partition\n\nparse1024 : Bits (n * 1024) -> Vect n (Bits 1024)\nparse1024 = partition\n\n-- Algorithms\n\ndata SecureHashAlgorithm1 : Type where\n SHA1 : Vect 5 (Bits 32) -> SecureHashAlgorithm1\n\nvectIndex : (i : Nat) -> Vect (S n) a -> LTE i n -> a\nvectIndex i v lte = index (natToFi i lte) v\n\nsha1sched' : Vect 16 (Bits 32) -> Vect t (Bits 32) -> Bits 32\nsha1sched' {t=t} M W =\n case isLTE t 15 of\n Yes lte => vectIndex t M lte\n No gt => rotateLeft 1 (foldl1 xor\n -- (map (\\off -> index (weakenN' (strMinus (natToFi t lteRefl) off)) W)\n -- [3, 8, 14, 16]))\n [Vect.index (weakenN' (strMinus (natToFi t lteRefl) 3)) W,\n Vect.index (weakenN' (strMinus (natToFi t lteRefl) 8)) W,\n Vect.index (weakenN' (strMinus (natToFi t lteRefl) 14)) W,\n Vect.index (weakenN' (strMinus (natToFi t lteRefl) 16)) W])\n\n-- NB: `foldl` doesn’t work here. Can we make something like `foldl`, but each\n-- step is one element, and we get a Vect of elements back at the end? \nsha1sched : Vect 16 (Bits 32) -> Vect 80 (Bits 32)\nsha1sched mpart = foldl (\\W, t => sha1sched' {t=t} mpart W) [] [0..79]\n\nimplementation Hash SecureHashAlgorithm1 512 160 where\n initialize _ = toList . parse512 . pad512 . Util.concat\n initialContext _ = SHA1 (map intToBits\n [0x67452301,\n 0xefcdab89,\n 0x98badcfe,\n 0x10325476,\n 0xc3d2e1f0])\n updateContext (SHA1 v) block = SHA1 (zipWith plus (foldl for v [0..79]) v) where\n -- seems like we could do this in one pass\n W : Vect 80 (Bits 32)\n W = sha1sched (partition block)\n for : Vect 5 (Bits 32) -> Fin 80 -> Vect 5 (Bits 32)\n for [a, b, c, d, e] t =\n [Vect.foldl1 plus [rotateLeft 5 a, f t b c d, e, index t const1, index t W],\n a,\n rotateLeft 30 b,\n c,\n d]\n finalize (SHA1 v) = concat v\n\ndata SecureHashAlgorithm256 : Type where\n SHA256 : Vect 8 (Bits 32) -> SecureHashAlgorithm256\n\nhash256 : Vect 8 (Bits 32) -> Bits 512 -> Vect 8 (Bits 32)\n\nimplementation Hash SecureHashAlgorithm256 512 256 where\n initialize _ = toList . parse512 . pad512 . Util.concat\n initialContext _ = SHA256 (map intToBits\n [0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19])\n updateContext (SHA256 v) = SHA256 . hash256 v\n finalize (SHA256 v) = concat v\n\ndata SecureHashAlgorithm224 : Type where\n SHA224 : Vect 8 (Bits 32) -> SecureHashAlgorithm224\n\nimplementation Hash SecureHashAlgorithm224 512 224 where\n initialize _ = toList . parse512 . pad512 . Util.concat\n initialContext _ = SHA224 (map intToBits\n [0xc1059ed8,\n 0x367cd507,\n 0x3070dd17,\n 0xf70e5939,\n 0xffc00b31,\n 0x68581511,\n 0x64f98fa7,\n 0xbefa4fa4])\n updateContext (SHA224 v) = SHA224 . hash256 v\n finalize (SHA224 v) = concat (take 7 v)\n\ndata SecureHashAlgorithm512 : Type where\n SHA512 : Vect 8 (Bits 64) -> SecureHashAlgorithm512\n \nhash512 : Vect 8 (Bits 64) -> Bits 1024 -> Vect 8 (Bits 64)\n\nimplementation Hash SecureHashAlgorithm512 1024 512 where\n initialize _ = toList . parse1024 . pad1024 . Util.concat\n initialContext _ = SHA512 (map intToBits\n [0x6a09e667f3bcc908,\n 0xbb67ae8584caa73b,\n 0x3c6ef372fe94f82b,\n 0xa54ff53a5f1d36f1,\n 0x510e527fade682d1,\n 0x9b05688c2b3e6c1f,\n 0x1f83d9abfb41bd6b,\n 0x5be0cd19137e2179])\n updateContext (SHA512 v) = SHA512 . hash512 v\n finalize (SHA512 v) = concat v\n\ndata SecureHashAlgorithm512_224 : Type where\n SHA512_224 : Vect 8 (Bits 64) -> SecureHashAlgorithm512_224\n\nimplementation Hash SecureHashAlgorithm512_224 1024 224 where\n initialize _ = toList . parse1024 . pad1024 . Util.concat\n initialContext _ = SHA512_224 (map intToBits\n [0x8C3D37C819544DA2,\n 0x73E1996689DCD4D6,\n 0x1DFAB7AE32FF9C82, \n 0x679DD514582F9FCF,\n 0x0F6D2B697BD44DA8,\n 0x77E36F7304C48942,\n 0x3F9D85A86A1D36C8,\n 0x1112E6AD91D692A1])\n updateContext (SHA512_224 v) = SHA512_224 . hash512 v\n finalize (SHA512_224 v) = truncate (concat (take 4 v))\n\ndata SecureHashAlgorithm512_256 : Type where\n SHA512_256 : Vect 8 (Bits 64) -> SecureHashAlgorithm512_256\n\nimplementation Hash SecureHashAlgorithm512_256 1024 256 where\n initialize _ = toList . parse1024 . pad1024 . Util.concat\n initialContext _ = SHA512_256 (map intToBits\n [0x22312194FC2BF72C,\n 0x9F555FA3C84C64C2,\n 0x2393B86B6F53B151,\n 0x963877195940EABD,\n 0x96283EE2A88EFFE3,\n 0xBE5E1E2553863992,\n 0x2B0199FC2C85B8AA,\n 0x0EB72DDC81C52CA2])\n updateContext (SHA512_256 v) = SHA512_256 . hash512 v\n finalize (SHA512_256 v) = concat (take 4 v)\n\ndata SecureHashAlgorithm384 : Type where\n SHA384 : Vect 8 (Bits 64) -> SecureHashAlgorithm384\n\nimplementation Hash SecureHashAlgorithm384 1024 384 where\n initialize _ = toList . parse1024 . pad1024 . Util.concat\n initialContext _ = SHA384 (map intToBits\n [0xcbbb9d5dc1059ed8,\n 0x629a292a367cd507,\n 0x9159015a3070dd17,\n 0x152fecd8f70e5939,\n 0x67332667ffc00b31,\n 0x8eb44a8768581511,\n 0xdb0c2e0d64f98fa7,\n 0x47b5481dbefa4fa4])\n updateContext (SHA384 v) = SHA384 . hash512 v\n finalize (SHA384 v) = concat (take 6 v)\n", "meta": {"hexsha": "fee55ea75ce53821efeae5805199d03bdd5182a1", "size": 12299, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Crypto/Hash/SHS.idr", "max_stars_repo_name": "idris-hackers/idris-crypto", "max_stars_repo_head_hexsha": "0fb69b76e399f2fa72f338e410504323751843e7", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 79, "max_stars_repo_stars_event_min_datetime": "2015-01-11T20:37:05.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-10T07:41:27.000Z", "max_issues_repo_path": "src/Data/Crypto/Hash/SHS.idr", "max_issues_repo_name": "idris-hackers/idris-crypto", "max_issues_repo_head_hexsha": "0fb69b76e399f2fa72f338e410504323751843e7", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2015-09-10T20:32:40.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-18T16:27:23.000Z", "max_forks_repo_path": "src/Data/Crypto/Hash/SHS.idr", "max_forks_repo_name": "idris-hackers/idris-crypto", "max_forks_repo_head_hexsha": "0fb69b76e399f2fa72f338e410504323751843e7", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 12, "max_forks_repo_forks_event_min_datetime": "2015-04-23T23:09:48.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-10T22:30:23.000Z", "avg_line_length": 46.5871212121, "max_line_length": 126, "alphanum_fraction": 0.5877713635, "num_tokens": 4514, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952866333484, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.5081121711926523}} {"text": "> module NonNegRational.open_issues.Main\n\n> import NonNegRational.NonNegRational\n> import NonNegRational.BasicOperations\n> import NonNegRational.BasicProperties\n> import Fraction.Fraction\n> import PNat.PNat\n> import Nat.Positive\n\n> %default total\n> %auto_implicits off\n\n> n : Nat\n> n = 1\n\n> x : NonNegRational\n> x = fromFraction (1, Element (S n) MkPositive)\n\n> y : NonNegRational\n> y = fromFraction (n, Element (S n) MkPositive)\n\n> q : x + y = 1\n> q = Refl\n\n> main : IO ()\n> main = do putStrLn (\"x = \" ++ show x)\n> putStrLn (\"y = \" ++ show y)\n> putStrLn (\"x + y = \" ++ show (x + y))\n\nFor small |n|, type checking time is roughly constant in |n| and\nexecution time is roughly linear in |n| as one would expect. But:\n\n1) For |n > 399| the computation segfaults\n\n2) Uncommenting lines 22-23 (the computation of |q|) yields unacceptable\n type checking times even for very small |n|:\n\n n = 1 -> 16 sec.\n n = 2 -> 18 sec.\n n = 3 -> 20 sec.\n n = 4 -> 28 sec.\n n = 5 -> 47 sec.\n n = 6 -> 88 sec.\n n = 7 -> 188 sec.\n n = 8 -> 647 sec.\n n = 9 -> killed\n\n\n\n", "meta": {"hexsha": "9297d47da1288b4d6540626667c7c38e06624cd4", "size": 1155, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "NonNegRational/open_issues/rt_vs_tct_costs.lidr", "max_stars_repo_name": "zenntenn/IdrisLibs", "max_stars_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "NonNegRational/open_issues/rt_vs_tct_costs.lidr", "max_issues_repo_name": "zenntenn/IdrisLibs", "max_issues_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NonNegRational/open_issues/rt_vs_tct_costs.lidr", "max_forks_repo_name": "zenntenn/IdrisLibs", "max_forks_repo_head_hexsha": "a81c3674273a4658cd205e9bd1b6f95163cefc3e", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.1, "max_line_length": 72, "alphanum_fraction": 0.5835497835, "num_tokens": 380, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5076050584169765}} {"text": "--\n-- Primitive casts: Specification\n--\n-- a. Unsigned integers\n--\n-- Unsigned integers with a precision of x bit have a valid\n-- range of [0,2^x - 1]. When casting from another integral type of value y,\n-- the value is checked for being in bounds, and if it is not, the\n-- unsigned remainder modulo 2^x of y is returned.\n--\n-- When casting from a `Double`, the value is first truncated towards 0,\n-- before applying the inbounds check and (if necessary) calculating\n-- the unsigned remainder modulo 2^x.\n--\n-- When casting from a `String`, the value is first converted to a floating\n-- point number by the backend and then truncated as described above.\n--\n-- Example: For `Bits8` the valid range is [0,255]. Below are some\n-- example casts.\n--\n-- cast {from = Integer} {to = Bits8} 12 = 12\n-- cast {from = Integer} {to = Bits8} 256 = 0\n-- cast {from = Integer} {to = Bits8} 259 = 3\n-- cast {from = Integer} {to = Bits8} (-2) = 254\n-- cast {from = Double} {to = Bits8} (-12.001) = 244\n-- cast {from = Double} {to = Bits8} (\"-12.001\") = 244\n--\n-- b. Signed integers\n--\n-- Signed integers with a precision of x bit have a valid\n-- range of [-2^(x-1),2^(x-1) - 1]. When casting from another\n-- integral type of value y, the unsigned remainder module 2^x\n-- is calculated. If the result is >= 2^(x-1), 2^x is subtracted\n-- from the result. This is the same behavior as for instance in Haskell.\n--\n-- When casting from a `Double`, the value is first truncated towards 0,\n-- before applying the inbounds check and (if necessary) truncating\n-- the value.\n--\n-- When casting from a `String`, the value is first converted to a floating\n-- point number by the backend and then truncated as described above.\n--\n-- Example: For `Int8` the valid range is [-128,127]. Below are some\n-- example casts.\n--\n-- cast {from = Integer} {to = Int8} 12 = 12\n-- cast {from = Integer} {to = Int8} 256 = 0\n-- cast {from = Integer} {to = Int8} 259 = 4\n-- cast {from = Integer} {to = Int8} (-128) = (-128)\n-- cast {from = Integer} {to = Int8} (-129) = 127\n-- cast {from = Double} {to = Int8} (-12.001) = (-12)\n-- cast {from = Double} {to = Int8} (\"-12.001\") = (-12)\n--\n-- c. Characters\n--\n-- Casts from all integral types to `Char` are supported. Note however,\n-- that only casts in the non-surrogate range are supported, that is\n-- values in the ranges [0,0xd7ff] and [0xe000,0x10ffff], or, in decimal\n-- notation, [0,55295] and [57344,1114111].\n--\n-- All casts from integer types to `Char` are therefore submitted to a\n-- bounds check, and, in case the value is out of bounds, are converted to `'\\0'`.\n--\n--\n-- Test all casts from and to integral types.\n-- The `Cast` implementations in here should go to `Prelude`, once\n-- a new minor version of the compiler is released.\n--\n-- These tests verify also that the full range of integer literals\n-- is supported for every integral type.\n--\n-- Nothing fancy is being done here:\n-- All test cases have been hand-written.\n\nimport Data.List\n\n--------------------------------------------------------------------------------\n-- Int8\n--------------------------------------------------------------------------------\n\nShow Int8 where\n show = prim__cast_Int8String\n\npublic export\nEq Int8 where\n x == y = intToBool (prim__eq_Int8 x y)\n\nNum Int8 where\n (+) = prim__add_Int8\n (*) = prim__mul_Int8\n fromInteger = prim__cast_IntegerInt8\n\nNeg Int8 where\n (-) = prim__sub_Int8\n negate = prim__sub_Int8 0\n\nCast Int8 Bits8 where\n cast = prim__cast_Int8Bits8\n\nCast Int8 Bits16 where\n cast = prim__cast_Int8Bits16\n\nCast Int8 Bits32 where\n cast = prim__cast_Int8Bits32\n\nCast Int8 Bits64 where\n cast = prim__cast_Int8Bits64\n\nCast Int8 Int16 where\n cast = prim__cast_Int8Int16\n\nCast Int8 Int32 where\n cast = prim__cast_Int8Int32\n\nCast Int8 Int64 where\n cast = prim__cast_Int8Int64\n\nCast Int8 Int where\n cast = prim__cast_Int8Int\n\nCast Int8 Integer where\n cast = prim__cast_Int8Integer\n\nCast Int8 String where\n cast = prim__cast_Int8String\n\nCast Int8 Char where\n cast = prim__cast_Int8Char\n\nCast Int8 Double where\n cast = prim__cast_Int8Double\n\n--------------------------------------------------------------------------------\n-- Int16\n--------------------------------------------------------------------------------\n\npublic export\nEq Int16 where\n x == y = intToBool (prim__eq_Int16 x y)\n\nShow Int16 where\n show = prim__cast_Int16String\n\nNum Int16 where\n (+) = prim__add_Int16\n (*) = prim__mul_Int16\n fromInteger = prim__cast_IntegerInt16\n\nNeg Int16 where\n (-) = prim__sub_Int16\n negate = prim__sub_Int16 0\n\nCast Int16 Bits8 where\n cast = prim__cast_Int16Bits8\n\nCast Int16 Bits16 where\n cast = prim__cast_Int16Bits16\n\nCast Int16 Bits32 where\n cast = prim__cast_Int16Bits32\n\nCast Int16 Bits64 where\n cast = prim__cast_Int16Bits64\n\nCast Int16 Int8 where\n cast = prim__cast_Int16Int8\n\nCast Int16 Int32 where\n cast = prim__cast_Int16Int32\n\nCast Int16 Int64 where\n cast = prim__cast_Int16Int64\n\nCast Int16 Int where\n cast = prim__cast_Int16Int\n\nCast Int16 Integer where\n cast = prim__cast_Int16Integer\n\nCast Int16 String where\n cast = prim__cast_Int16String\n\nCast Int16 Char where\n cast = prim__cast_Int16Char\n\nCast Int16 Double where\n cast = prim__cast_Int16Double\n\n--------------------------------------------------------------------------------\n-- Int32\n--------------------------------------------------------------------------------\n\nShow Int32 where\n show = prim__cast_Int32String\n\npublic export\nEq Int32 where\n x == y = intToBool (prim__eq_Int32 x y)\n\nNum Int32 where\n (+) = prim__add_Int32\n (*) = prim__mul_Int32\n fromInteger = prim__cast_IntegerInt32\n\nNeg Int32 where\n (-) = prim__sub_Int32\n negate = prim__sub_Int32 0\n\nCast Int32 Bits8 where\n cast = prim__cast_Int32Bits8\n\nCast Int32 Bits16 where\n cast = prim__cast_Int32Bits16\n\nCast Int32 Bits32 where\n cast = prim__cast_Int32Bits32\n\nCast Int32 Bits64 where\n cast = prim__cast_Int32Bits64\n\nCast Int32 Int8 where\n cast = prim__cast_Int32Int8\n\nCast Int32 Int16 where\n cast = prim__cast_Int32Int16\n\nCast Int32 Int64 where\n cast = prim__cast_Int32Int64\n\nCast Int32 Int where\n cast = prim__cast_Int32Int\n\nCast Int32 Integer where\n cast = prim__cast_Int32Integer\n\nCast Int32 String where\n cast = prim__cast_Int32String\n\nCast Int32 Char where\n cast = prim__cast_Int32Char\n\nCast Int32 Double where\n cast = prim__cast_Int32Double\n\n--------------------------------------------------------------------------------\n-- Int64\n--------------------------------------------------------------------------------\n\nShow Int64 where\n show = prim__cast_Int64String\n\npublic export\nEq Int64 where\n x == y = intToBool (prim__eq_Int64 x y)\n\nNum Int64 where\n (+) = prim__add_Int64\n (*) = prim__mul_Int64\n fromInteger = prim__cast_IntegerInt64\n\nNeg Int64 where\n (-) = prim__sub_Int64\n negate = prim__sub_Int64 0\n\nCast Int64 Bits8 where\n cast = prim__cast_Int64Bits8\n\nCast Int64 Bits16 where\n cast = prim__cast_Int64Bits16\n\nCast Int64 Bits32 where\n cast = prim__cast_Int64Bits32\n\nCast Int64 Bits64 where\n cast = prim__cast_Int64Bits64\n\nCast Int64 Int8 where\n cast = prim__cast_Int64Int8\n\nCast Int64 Int16 where\n cast = prim__cast_Int64Int16\n\nCast Int64 Int32 where\n cast = prim__cast_Int64Int32\n\nCast Int64 Int where\n cast = prim__cast_Int64Int\n\nCast Int64 Integer where\n cast = prim__cast_Int64Integer\n\nCast Int64 String where\n cast = prim__cast_Int64String\n\nCast Int64 Char where\n cast = prim__cast_Int64Char\n\nCast Int64 Double where\n cast = prim__cast_Int64Double\n\n--------------------------------------------------------------------------------\n-- Int\n--------------------------------------------------------------------------------\n\nCast Int Int8 where\n cast = prim__cast_IntInt8\n\nCast Int Int16 where\n cast = prim__cast_IntInt16\n\nCast Int Int32 where\n cast = prim__cast_IntInt32\n\nCast Int Int64 where\n cast = prim__cast_IntInt64\n\n--------------------------------------------------------------------------------\n-- Integer\n--------------------------------------------------------------------------------\n\nCast Integer Int8 where\n cast = prim__cast_IntegerInt8\n\nCast Integer Int16 where\n cast = prim__cast_IntegerInt16\n\nCast Integer Int32 where\n cast = prim__cast_IntegerInt32\n\nCast Integer Int64 where\n cast = prim__cast_IntegerInt64\n\nCast Integer Char where\n cast = prim__cast_IntegerChar\n\n--------------------------------------------------------------------------------\n-- Bits8\n--------------------------------------------------------------------------------\n\nCast Bits8 Int8 where\n cast = prim__cast_Bits8Int8\n\nCast Bits8 Int16 where\n cast = prim__cast_Bits8Int16\n\nCast Bits8 Int32 where\n cast = prim__cast_Bits8Int32\n\nCast Bits8 Int64 where\n cast = prim__cast_Bits8Int64\n\nCast Bits8 String where\n cast = prim__cast_Bits8String\n\nCast Bits8 Char where\n cast = prim__cast_Bits8Char\n\nCast Bits8 Double where\n cast = prim__cast_Bits8Double\n\n--------------------------------------------------------------------------------\n-- Bits16\n--------------------------------------------------------------------------------\n\nCast Bits16 Int8 where\n cast = prim__cast_Bits16Int8\n\nCast Bits16 Int16 where\n cast = prim__cast_Bits16Int16\n\nCast Bits16 Int32 where\n cast = prim__cast_Bits16Int32\n\nCast Bits16 Int64 where\n cast = prim__cast_Bits16Int64\n\nCast Bits16 String where\n cast = prim__cast_Bits16String\n\nCast Bits16 Char where\n cast = prim__cast_Bits16Char\n\nCast Bits16 Double where\n cast = prim__cast_Bits16Double\n\n--------------------------------------------------------------------------------\n-- Bits32\n--------------------------------------------------------------------------------\n\nCast Bits32 Int8 where\n cast = prim__cast_Bits32Int8\n\nCast Bits32 Int16 where\n cast = prim__cast_Bits32Int16\n\nCast Bits32 Int32 where\n cast = prim__cast_Bits32Int32\n\nCast Bits32 Int64 where\n cast = prim__cast_Bits32Int64\n\nCast Bits32 String where\n cast = prim__cast_Bits32String\n\nCast Bits32 Char where\n cast = prim__cast_Bits32Char\n\nCast Bits32 Double where\n cast = prim__cast_Bits32Double\n\n--------------------------------------------------------------------------------\n-- Bits64\n--------------------------------------------------------------------------------\n\nCast Bits64 Int8 where\n cast = prim__cast_Bits64Int8\n\nCast Bits64 Int16 where\n cast = prim__cast_Bits64Int16\n\nCast Bits64 Int32 where\n cast = prim__cast_Bits64Int32\n\nCast Bits64 Int64 where\n cast = prim__cast_Bits64Int64\n\nCast Bits64 String where\n cast = prim__cast_Bits64String\n\nCast Bits64 Char where\n cast = prim__cast_Bits64Char\n\nCast Bits64 Double where\n cast = prim__cast_Bits64Double\n\n--------------------------------------------------------------------------------\n-- String\n--------------------------------------------------------------------------------\n\nCast String Bits8 where\n cast = prim__cast_StringBits8\n\nCast String Bits16 where\n cast = prim__cast_StringBits16\n\nCast String Bits32 where\n cast = prim__cast_StringBits32\n\nCast String Bits64 where\n cast = prim__cast_StringBits64\n\nCast String Int8 where\n cast = prim__cast_StringInt8\n\nCast String Int16 where\n cast = prim__cast_StringInt16\n\nCast String Int32 where\n cast = prim__cast_StringInt32\n\nCast String Int64 where\n cast = prim__cast_StringInt64\n\n--------------------------------------------------------------------------------\n-- Double\n--------------------------------------------------------------------------------\n\nCast Double Bits8 where\n cast = prim__cast_DoubleBits8\n\nCast Double Bits16 where\n cast = prim__cast_DoubleBits16\n\nCast Double Bits32 where\n cast = prim__cast_DoubleBits32\n\nCast Double Bits64 where\n cast = prim__cast_DoubleBits64\n\nCast Double Int8 where\n cast = prim__cast_DoubleInt8\n\nCast Double Int16 where\n cast = prim__cast_DoubleInt16\n\nCast Double Int32 where\n cast = prim__cast_DoubleInt32\n\nCast Double Int64 where\n cast = prim__cast_DoubleInt64\n\n--------------------------------------------------------------------------------\n-- Tests\n--------------------------------------------------------------------------------\n\nshowTpe : Type -> String\nshowTpe Bits16 = \"Bits16\"\nshowTpe Bits32 = \"Bits32\"\nshowTpe Bits64 = \"Bits64\"\nshowTpe Bits8 = \"Bits8\"\nshowTpe Char = \"Char\"\nshowTpe Double = \"Double\"\nshowTpe Int = \"Int\"\nshowTpe Int16 = \"Int16\"\nshowTpe Int32 = \"Int32\"\nshowTpe Int64 = \"Int64\"\nshowTpe Int8 = \"Int8\"\nshowTpe Integer = \"Integer\"\nshowTpe String = \"String\"\nshowTpe _ = \"unknown type\"\n\ntestCasts : (a: Type) -> (b : Type) -> (Cast a b, Show a, Show b, Eq b) =>\n List (a,b) -> List String\ntestCasts a b = mapMaybe doTest\n where doTest : (a,b) -> Maybe String\n doTest (x,y) =\n let y2 = cast {to = b} x\n in if y == y2 then Nothing\n else Just $ #\"Invalid cast from \\#{showTpe a} to \\#{showTpe b}: \"#\n ++ #\"expected \\#{show y} but got \\#{show y2} when casting from \\#{show x}\"#\n\nmaxBits8 : Bits8\nmaxBits8 = 0xff\n\nmaxBits16 : Bits16\nmaxBits16 = 0xffff\n\nmaxBits32 : Bits32\nmaxBits32 = 0xffffffff\n\nmaxBits64 : Bits64\nmaxBits64 = 0xffffffffffffffff\n\nresults : List String\nresults = testCasts Int8 Int16 [(-129,127),(-128,-128),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Int32 [(-129,127),(-128,-128),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Int64 [(-129,127),(-128,-128),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Int [(-129,127),(-128,-128),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Double [(-129,127),(-128,-128),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 String [(-129,\"127\"),(-128,\"-128\"),(0,\"0\"),(127,\"127\"),(128,\"-128\")]\n ++ testCasts Int8 Integer [(-129,127),(-128,-128),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Bits8 [(-129,127),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Bits16 [(-129,127),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Bits32 [(-129,127),(0,0),(127,127),(128,-128)]\n ++ testCasts Int8 Bits64 [(-129,127),(0,0),(127,127),(128,-128)]\n\n ++ testCasts Int16 Int8 [(-32769,32767),(-32768,0),(0,0),(32767,-1),(32768,0)]\n ++ testCasts Int16 Int32 [(-32769,32767),(-32768,-32768),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Int64 [(-32769,32767),(-32768,-32768),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Int [(-32769,32767),(-32768,-32768),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Double [(-32769,32767),(-32768,-32768),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 String [(-32769,\"32767\"),(-32768,\"-32768\"),(0,\"0\"),(32767,\"32767\"),(32768,\"-32768\")]\n ++ testCasts Int16 Integer [(-32769,32767),(-32768,-32768),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Bits8 [(-32769,32767),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Bits16 [(-32769,32767),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Bits32 [(-32769,32767),(0,0),(32767,32767),(32768,-32768)]\n ++ testCasts Int16 Bits64 [(-32769,32767),(0,0),(32767,32767),(32768,-32768)]\n\n ++ testCasts Int32 Int8 [(-2147483649,2147483647),(-2147483648,0),(0,0),(2147483647,-1),(2147483648,0)]\n ++ testCasts Int32 Int16 [(-2147483649,2147483647),(-2147483648,0),(0,0),(2147483647,-1),(2147483648,0)]\n ++ testCasts Int32 Int64 [(-2147483649,2147483647),(-2147483648,-2147483648),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 Int [(-2147483649,2147483647),(-2147483648,-2147483648),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 Double [(-2147483649,2147483647),(-2147483648,-2147483648),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 String [(-2147483649,\"2147483647\"),(-2147483648,\"-2147483648\"),(0,\"0\"),(2147483647,\"2147483647\"),(2147483648,\"-2147483648\")]\n ++ testCasts Int32 Integer [(-2147483649,2147483647),(-2147483648,-2147483648),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 Bits8 [(-2147483649,2147483647),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 Bits16 [(-2147483649,2147483647),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 Bits32 [(-2147483649,2147483647),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n ++ testCasts Int32 Bits64 [(-2147483649,2147483647),(0,0),(2147483647,2147483647),(2147483648,-2147483648)]\n\n ++ testCasts Int64 Int8 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,0),(0,0),(9223372036854775807,-1),(9223372036854775808,0)]\n ++ testCasts Int64 Int16 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,0),(0,0),(9223372036854775807,-1),(9223372036854775808,0)]\n ++ testCasts Int64 Int32 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,0),(0,0),(9223372036854775807,-1),(9223372036854775808,0)]\n ++ testCasts Int64 Int [(-9223372036854775809,9223372036854775807),(-9223372036854775808,-9223372036854775808),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n ++ testCasts Int64 Double [(-9223372036854775809,9223372036854775807),(-9223372036854775808,-9223372036854775808),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n ++ testCasts Int64 String [(-9223372036854775809,\"9223372036854775807\"),(-9223372036854775808,\"-9223372036854775808\"),(0,\"0\"),(9223372036854775807,\"9223372036854775807\"),(9223372036854775808,\"-9223372036854775808\")]\n ++ testCasts Int64 Integer [(-9223372036854775809,9223372036854775807),(-9223372036854775808,-9223372036854775808),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n ++ testCasts Int64 Bits8 [(-9223372036854775809,255),(0,0),(9223372036854775807,0xff),(9223372036854775808,0)]\n ++ testCasts Int64 Bits16 [(-9223372036854775809,65535),(0,0),(9223372036854775807,0xffff),(9223372036854775808,0)]\n ++ testCasts Int64 Bits32 [(-9223372036854775809,4294967295),(0,0),(9223372036854775807,0xffffffff),(9223372036854775808,0)]\n ++ testCasts Int64 Bits64 [(-9223372036854775809,9223372036854775807),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n\n ++ testCasts Int Int8 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,0),(0,0),(9223372036854775807,-1),(9223372036854775808,0)]\n ++ testCasts Int Int16 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,0),(0,0),(9223372036854775807,-1),(9223372036854775808,0)]\n ++ testCasts Int Int32 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,0),(0,0),(9223372036854775807,-1),(9223372036854775808,0)]\n ++ testCasts Int Int64 [(-9223372036854775809,9223372036854775807),(-9223372036854775808,-9223372036854775808),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n ++ testCasts Int Double [(-9223372036854775809,9223372036854775807),(-9223372036854775808,-9223372036854775808),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n ++ testCasts Int String [(-9223372036854775809,\"9223372036854775807\"),(-9223372036854775808,\"-9223372036854775808\"),(0,\"0\"),(9223372036854775807,\"9223372036854775807\"),(9223372036854775808,\"-9223372036854775808\")]\n ++ testCasts Int Integer [(-9223372036854775809,9223372036854775807),(-9223372036854775808,-9223372036854775808),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n ++ testCasts Int Bits8 [(-9223372036854775809,255),(0,0),(9223372036854775807,0xff),(9223372036854775808,0)]\n ++ testCasts Int Bits16 [(-9223372036854775809,65535),(0,0),(9223372036854775807,0xffff),(9223372036854775808,0)]\n ++ testCasts Int Bits32 [(-9223372036854775809,4294967295),(0,0),(9223372036854775807,0xffffffff),(9223372036854775808,0)]\n ++ testCasts Int Bits64 [(-9223372036854775809,9223372036854775807),(0,0),(9223372036854775807,9223372036854775807),(9223372036854775808,-9223372036854775808)]\n\n ++ testCasts Integer Int8 [(-170141183460469231731687303715884105729,-1),(-170141183460469231731687303715884105728,0),(0,0),(170141183460469231731687303715884105727,-1),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Int16 [(-170141183460469231731687303715884105729,-1),(-170141183460469231731687303715884105728,0),(0,0),(170141183460469231731687303715884105727,-1),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Int32 [(-170141183460469231731687303715884105729,-1),(-170141183460469231731687303715884105728,0),(0,0),(170141183460469231731687303715884105727,-1),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Int64 [(-170141183460469231731687303715884105729,-1),(-170141183460469231731687303715884105728,0),(0,0),(170141183460469231731687303715884105727,-1),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Int [(-170141183460469231731687303715884105729,-1),(-170141183460469231731687303715884105728,0),(0,0),(170141183460469231731687303715884105727,-1),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer String [(-170141183460469231731687303715884105729,\"-170141183460469231731687303715884105729\"),(-170141183460469231731687303715884105728,\"-170141183460469231731687303715884105728\"),(0,\"0\"),(170141183460469231731687303715884105727,\"170141183460469231731687303715884105727\"),(170141183460469231731687303715884105728,\"170141183460469231731687303715884105728\")]\n ++ testCasts Integer Bits8 [(-170141183460469231731687303715884105729,maxBits8),(0,0),(170141183460469231731687303715884105727,0xff),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Bits16 [(-170141183460469231731687303715884105729,maxBits16),(0,0),(170141183460469231731687303715884105727,0xffff),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Bits32 [(-170141183460469231731687303715884105729,maxBits32),(0,0),(170141183460469231731687303715884105727,0xffffffff),(170141183460469231731687303715884105728,0)]\n ++ testCasts Integer Bits64 [(-170141183460469231731687303715884105729,maxBits64),(0,0),(170141183460469231731687303715884105727,0xffffffffffffffff),(170141183460469231731687303715884105728,0)]\n\n ++ testCasts Bits8 Int8 [(0,0),(255,-1),(256,0)]\n ++ testCasts Bits8 Int16 [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Int32 [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Int64 [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Int [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Double [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 String [(0,\"0\"),(255,\"255\"),(256,\"0\")]\n ++ testCasts Bits8 Integer [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Bits16 [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Bits32 [(0,0),(255,255),(256,0)]\n ++ testCasts Bits8 Bits64 [(0,0),(255,255),(256,0)]\n\n ++ testCasts Bits16 Int8 [(0,0),(0xffff,-1),(0x10000,0)]\n ++ testCasts Bits16 Int16 [(0,0),(0xffff,-1),(0x10000,0)]\n ++ testCasts Bits16 Int32 [(0,0),(0xffff,0xffff),(0x10000,0)]\n ++ testCasts Bits16 Int64 [(0,0),(0xffff,0xffff),(0x10000,0)]\n ++ testCasts Bits16 Int [(0,0),(0xffff,0xffff),(0x10000,0)]\n ++ testCasts Bits16 Double [(0,0),(0xffff,0xffff),(0x10000,0)]\n ++ testCasts Bits16 String [(0,\"0\"),(0xffff,\"65535\"),(0x10000,\"0\")]\n ++ testCasts Bits16 Integer [(0,0),(0xffff,0xffff),(0x10000,0)]\n ++ testCasts Bits16 Bits8 [(0,0),(0xffff,0xff),(0x10000,0)]\n ++ testCasts Bits16 Bits32 [(0,0),(0xffff,0xffff),(0x10000,0)]\n ++ testCasts Bits16 Bits64 [(0,0),(0xffff,0xffff),(0x10000,0)]\n\n ++ testCasts Bits32 Int8 [(0,0),(0xffffffff,-1),(0x100000000,0)]\n ++ testCasts Bits32 Int16 [(0,0),(0xffffffff,-1),(0x100000000,0)]\n ++ testCasts Bits32 Int32 [(0,0),(0xffffffff,-1),(0x100000000,0)]\n ++ testCasts Bits32 Int64 [(0,0),(0xffffffff,0xffffffff),(0x100000000,0)]\n ++ testCasts Bits32 Int [(0,0),(0xffffffff,0xffffffff),(0x100000000,0)]\n ++ testCasts Bits32 Double [(0,0),(0xffffffff,0xffffffff),(0x100000000,0)]\n ++ testCasts Bits32 String [(0,\"0\"),(0xffffffff,\"4294967295\"),(0x100000000,\"0\")]\n ++ testCasts Bits32 Integer [(0,0),(0xffffffff,0xffffffff),(0x100000000,0)]\n ++ testCasts Bits32 Bits8 [(0,0),(0xffffffff,0xff),(0x100000000,0)]\n ++ testCasts Bits32 Bits16 [(0,0),(0xffffffff,0xffff),(0x100000000,0)]\n ++ testCasts Bits32 Bits64 [(0,0),(0xffffffff,0xffffffff),(0x100000000,0)]\n\n ++ testCasts Bits64 Int8 [(0,0),(0xffffffffffffffff,-1),(0x10000000000000000,0)]\n ++ testCasts Bits64 Int16 [(0,0),(0xffffffffffffffff,-1),(0x10000000000000000,0)]\n ++ testCasts Bits64 Int32 [(0,0),(0xffffffffffffffff,-1),(0x10000000000000000,0)]\n ++ testCasts Bits64 Int64 [(0,0),(0xffffffffffffffff,-1),(0x10000000000000000,0)]\n ++ testCasts Bits64 Int [(0,0),(0xffffffffffffffff,-1),(0x10000000000000000,0)]\n ++ testCasts Bits64 Double [(0,0),(0xffffffffffffffff,0xffffffffffffffff),(0x10000000000000000,0)]\n ++ testCasts Bits64 String [(0,\"0\"),(0xffffffffffffffff,\"18446744073709551615\"),(0x10000000000000000,\"0\")]\n ++ testCasts Bits64 Integer [(0,0),(0xffffffffffffffff,0xffffffffffffffff),(0x10000000000000000,0)]\n ++ testCasts Bits64 Bits8 [(0,0),(0xffffffffffffffff,0xff),(0x10000000000000000,0)]\n ++ testCasts Bits64 Bits16 [(0,0),(0xffffffffffffffff,0xffff),(0x10000000000000000,0)]\n ++ testCasts Bits64 Bits32 [(0,0),(0xffffffffffffffff,0xffffffff),(0x10000000000000000,0)]\n\n ++ testCasts String Int8 [(\"-129\",127),(\"-128\",-128),(\"0\",0),(\"127\",127), (\"128\",-128)]\n ++ testCasts String Int16 [(\"-32769\",32767),(\"-32768\",-32768),(\"0\",0),(\"32767\",32767), (\"32768\",-32768)]\n ++ testCasts String Int32 [(\"-2147483649\",2147483647),(\"-2147483648\",-2147483648),(\"0\",0),(\"2147483647\",2147483647), (\"2147483648\",-2147483648)]\n ++ testCasts String Int64 [(\"-9223372036854775809\",9223372036854775807),(\"-9223372036854775808\",-9223372036854775808),(\"0\",0),(\"9223372036854775807\",9223372036854775807), (\"9223372036854775808\",-9223372036854775808)]\n ++ testCasts String Int [(\"-9223372036854775809\",9223372036854775807),(\"-9223372036854775808\",-9223372036854775808),(\"0\",0),(\"9223372036854775807\",9223372036854775807), (\"9223372036854775808\",-9223372036854775808)]\n ++ testCasts String Integer [(\"-170141183460469231731687303715884105728\",-170141183460469231731687303715884105728),(\"-170141183460469231731687303715884105728\",-170141183460469231731687303715884105728),(\"0\",0),(\"170141183460469231731687303715884105728\",170141183460469231731687303715884105728)]\n ++ testCasts String Bits8 [(\"0\",0),(\"255\",255), (\"256\",0)]\n ++ testCasts String Bits16 [(\"0\",0),(\"65535\",65535), (\"65536\",0)]\n ++ testCasts String Bits32 [(\"0\",0),(\"4294967295\",4294967295), (\"4294967296\",0)]\n ++ testCasts String Bits64 [(\"0\",0),(\"18446744073709551615\",18446744073709551615), (\"18446744073709551616\",0)]\n\n ++ testCasts Double Int8 [(-129.0, 127),(-128.0,-128),(-12.001,-12),(12.001,12),(127.0,127),(128.0,-128)]\n ++ testCasts Double Int16 [(-32769.0, 32767),(-32768.0,-32768),(-12.001,-12),(12.001,12),(32767.0,32767),(32768.0,-32768)]\n ++ testCasts Double Int32 [(-2147483649.0,2147483647),(-2147483648.0,-2147483648),(-12.001,-12),(12.001,12),(2147483647.0,2147483647),(2147483648.0,-2147483648)]\n ++ testCasts Double Int64 [(-9223372036854775808.0,-9223372036854775808),(-12.001,-12),(12.001,12),(9223372036854775808.0,-9223372036854775808)]\n ++ testCasts Double Int [(-9223372036854775808.0,-9223372036854775808),(-12.001,-12),(12.001,12),(9223372036854775808.0,-9223372036854775808)]\n ++ testCasts Double Bits8 [(0.0,0),(255.0,255), (256.0,0)]\n ++ testCasts Double Bits16 [(0.0,0),(65535.0,65535), (65536.0,0)]\n ++ testCasts Double Bits32 [(0.0,0),(4294967295.0,4294967295), (4294967296.0,0)]\n ++ testCasts Double Bits64 [(0.0,0),(18446744073709551616.0,0)]\n\n ++ testCasts Int8 Char [(-1, '\\x0'), (80, 'P')]\n ++ testCasts Int16 Char [(-1, '\\x0'), (80, 'P')]\n ++ testCasts Int32 Char [(-1, '\\x0'), (80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000'), (1114111, '\\x10ffff'), (1114112, '\\x0')]\n ++ testCasts Int64 Char [(-1, '\\x0'), (80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000'), (1114111, '\\x10ffff'), (1114112, '\\x0')]\n ++ testCasts Int Char [(-1, '\\x0'), (80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000'), (1114111, '\\x10ffff'), (1114112, '\\x0')]\n ++ testCasts Bits8 Char [(80, 'P')]\n ++ testCasts Bits16 Char [(80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000')]\n ++ testCasts Bits32 Char [(80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000'), (1114111, '\\x10ffff'), (1114112, '\\x0')]\n ++ testCasts Bits64 Char [(80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000'), (1114111, '\\x10ffff'), (1114112, '\\x0')]\n ++ testCasts Integer Char [(-1, '\\x0'), (80, 'P'), (55295, '\\xd7ff'), (55296, '\\x0'), (57344, '\\xe000'), (1114111, '\\x10ffff'), (1114112, '\\x0')]\n\n--------------------------------------------------------------------------------\n-- Main\n--------------------------------------------------------------------------------\n\nmain : IO ()\nmain = traverse_ putStrLn results\n", "meta": {"hexsha": "543e59c36963bf074930be8f11ab5974b56e2275", "size": 30318, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/chez/casts/Casts.idr", "max_stars_repo_name": "mmhelloworld/idris-jvm", "max_stars_repo_head_hexsha": "cb0c87d0f65c86636322224d496fef55af92d6b1", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "tests/node/casts/Casts.idr", "max_issues_repo_name": "mmhelloworld/idris-jvm", "max_issues_repo_head_hexsha": "cb0c87d0f65c86636322224d496fef55af92d6b1", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "tests/chez/casts/Casts.idr", "max_forks_repo_name": "mmhelloworld/idris-jvm", "max_forks_repo_head_hexsha": "cb0c87d0f65c86636322224d496fef55af92d6b1", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 43.8121387283, "max_line_length": 386, "alphanum_fraction": 0.6377729402, "num_tokens": 9761, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.507046296144851}} {"text": "module Data.IntMap\n\n-- Hand specialised map, for efficiency...\n\n%default total\n\nKey : Type\nKey = Int\n\n-- TODO: write split\n\nprivate\ndata Tree : Nat -> Type -> Type where\n Leaf : Key -> v -> Tree Z v\n Branch2 : Tree n v -> Key -> Tree n v -> Tree (S n) v\n Branch3 : Tree n v -> Key -> Tree n v -> Key -> Tree n v -> Tree (S n) v\n\nbranch4 :\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v ->\n Tree (S (S n)) v\nbranch4 a b c d e f g =\n Branch2 (Branch2 a b c) d (Branch2 e f g)\n\nbranch5 :\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v ->\n Tree (S (S n)) v\nbranch5 a b c d e f g h i =\n Branch2 (Branch2 a b c) d (Branch3 e f g h i)\n\nbranch6 :\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v ->\n Tree (S (S n)) v\nbranch6 a b c d e f g h i j k =\n Branch3 (Branch2 a b c) d (Branch2 e f g) h (Branch2 i j k)\n\nbranch7 :\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v -> Key ->\n Tree n v ->\n Tree (S (S n)) v\nbranch7 a b c d e f g h i j k l m =\n Branch3 (Branch3 a b c d e) f (Branch2 g h i) j (Branch2 k l m)\n\nmerge1 : Tree n v -> Key -> Tree (S n) v -> Key -> Tree (S n) v -> Tree (S (S n)) v\nmerge1 a b (Branch2 c d e) f (Branch2 g h i) = branch5 a b c d e f g h i\nmerge1 a b (Branch2 c d e) f (Branch3 g h i j k) = branch6 a b c d e f g h i j k\nmerge1 a b (Branch3 c d e f g) h (Branch2 i j k) = branch6 a b c d e f g h i j k\nmerge1 a b (Branch3 c d e f g) h (Branch3 i j k l m) = branch7 a b c d e f g h i j k l m\n\nmerge2 : Tree (S n) v -> Key -> Tree n v -> Key -> Tree (S n) v -> Tree (S (S n)) v\nmerge2 (Branch2 a b c) d e f (Branch2 g h i) = branch5 a b c d e f g h i\nmerge2 (Branch2 a b c) d e f (Branch3 g h i j k) = branch6 a b c d e f g h i j k\nmerge2 (Branch3 a b c d e) f g h (Branch2 i j k) = branch6 a b c d e f g h i j k\nmerge2 (Branch3 a b c d e) f g h (Branch3 i j k l m) = branch7 a b c d e f g h i j k l m\n\nmerge3 : Tree (S n) v -> Key -> Tree (S n) v -> Key -> Tree n v -> Tree (S (S n)) v\nmerge3 (Branch2 a b c) d (Branch2 e f g) h i = branch5 a b c d e f g h i\nmerge3 (Branch2 a b c) d (Branch3 e f g h i) j k = branch6 a b c d e f g h i j k\nmerge3 (Branch3 a b c d e) f (Branch2 g h i) j k = branch6 a b c d e f g h i j k\nmerge3 (Branch3 a b c d e) f (Branch3 g h i j k) l m = branch7 a b c d e f g h i j k l m\n\ntreeLookup : Key -> Tree n v -> Maybe v\ntreeLookup k (Leaf k' v) =\n if k == k' then\n Just v\n else\n Nothing\ntreeLookup k (Branch2 t1 k' t2) =\n if k <= k' then\n treeLookup k t1\n else\n treeLookup k t2\ntreeLookup k (Branch3 t1 k1 t2 k2 t3) =\n if k <= k1 then\n treeLookup k t1\n else if k <= k2 then\n treeLookup k t2\n else\n treeLookup k t3\n\ntreeInsert' : Key -> v -> Tree n v -> Either (Tree n v) (Tree n v, Key, Tree n v)\ntreeInsert' k v (Leaf k' v') =\n case compare k k' of\n LT => Right (Leaf k v, k, Leaf k' v')\n EQ => Left (Leaf k v)\n GT => Right (Leaf k' v', k', Leaf k v)\ntreeInsert' k v (Branch2 t1 k' t2) =\n if k <= k' then\n case treeInsert' k v t1 of\n Left t1' => Left (Branch2 t1' k' t2)\n Right (a, b, c) => Left (Branch3 a b c k' t2)\n else\n case treeInsert' k v t2 of\n Left t2' => Left (Branch2 t1 k' t2')\n Right (a, b, c) => Left (Branch3 t1 k' a b c)\ntreeInsert' k v (Branch3 t1 k1 t2 k2 t3) =\n if k <= k1 then\n case treeInsert' k v t1 of\n Left t1' => Left (Branch3 t1' k1 t2 k2 t3)\n Right (a, b, c) => Right (Branch2 a b c, k1, Branch2 t2 k2 t3)\n else\n if k <= k2 then\n case treeInsert' k v t2 of\n Left t2' => Left (Branch3 t1 k1 t2' k2 t3)\n Right (a, b, c) => Right (Branch2 t1 k1 a, b, Branch2 c k2 t3)\n else\n case treeInsert' k v t3 of\n Left t3' => Left (Branch3 t1 k1 t2 k2 t3')\n Right (a, b, c) => Right (Branch2 t1 k1 t2, k2, Branch2 a b c)\n\ntreeInsert : Key -> v -> Tree n v -> Either (Tree n v) (Tree (S n) v)\ntreeInsert k v t =\n case treeInsert' k v t of\n Left t' => Left t'\n Right (a, b, c) => Right (Branch2 a b c)\n\ndelType : Nat -> Type -> Type\ndelType Z v = ()\ndelType (S n) v = Tree n v\n\ntreeDelete : {n : _} -> Key -> Tree n v -> Either (Tree n v) (delType n v)\ntreeDelete k (Leaf k' v) =\n if k == k' then\n Right ()\n else\n Left (Leaf k' v)\ntreeDelete {n=S Z} k (Branch2 t1 k' t2) =\n if k <= k' then\n case treeDelete k t1 of\n Left t1' => Left (Branch2 t1' k' t2)\n Right () => Right t2\n else\n case treeDelete k t2 of\n Left t2' => Left (Branch2 t1 k' t2')\n Right () => Right t1\ntreeDelete {n=S Z} k (Branch3 t1 k1 t2 k2 t3) =\n if k <= k1 then\n case treeDelete k t1 of\n Left t1' => Left (Branch3 t1' k1 t2 k2 t3)\n Right () => Left (Branch2 t2 k2 t3)\n else if k <= k2 then\n case treeDelete k t2 of\n Left t2' => Left (Branch3 t1 k1 t2' k2 t3)\n Right () => Left (Branch2 t1 k1 t3)\n else\n case treeDelete k t3 of\n Left t3' => Left (Branch3 t1 k1 t2 k2 t3')\n Right () => Left (Branch2 t1 k1 t2)\ntreeDelete {n=S (S _)} k (Branch2 t1 k' t2) =\n if k <= k' then\n case treeDelete k t1 of\n Left t1' => Left (Branch2 t1' k' t2)\n Right t1' =>\n case t2 of\n Branch2 a b c => Right (Branch3 t1' k' a b c)\n Branch3 a b c d e => Left (branch4 t1' k' a b c d e)\n else\n case treeDelete k t2 of\n Left t2' => Left (Branch2 t1 k' t2')\n Right t2' =>\n case t1 of\n Branch2 a b c => Right (Branch3 a b c k' t2')\n Branch3 a b c d e => Left (branch4 a b c d e k' t2')\ntreeDelete {n=(S (S _))} k (Branch3 t1 k1 t2 k2 t3) =\n if k <= k1 then\n case treeDelete k t1 of\n Left t1' => Left (Branch3 t1' k1 t2 k2 t3)\n Right t1' => Left (merge1 t1' k1 t2 k2 t3)\n else if k <= k2 then\n case treeDelete k t2 of\n Left t2' => Left (Branch3 t1 k1 t2' k2 t3)\n Right t2' => Left (merge2 t1 k1 t2' k2 t3)\n else\n case treeDelete k t3 of\n Left t3' => Left (Branch3 t1 k1 t2 k2 t3')\n Right t3' => Left (merge3 t1 k1 t2 k2 t3')\n\ntreeToList : Tree n v -> List (Key, v)\ntreeToList = treeToList' []\n where\n treeToList' : forall n . List (Key, v) -> Tree n v -> List (Key, v)\n treeToList' rest (Leaf k v) = (k, v) :: rest\n treeToList' rest (Branch2 t1 _ t2)\n = treeToList' (treeToList' rest t2) t1\n treeToList' rest (Branch3 t1 _ t2 _ t3)\n = treeToList' (treeToList' (treeToList' rest t3) t2) t1\n\nexport\ndata IntMap : Type -> Type where\n Empty : IntMap v\n M : (n : Nat) -> Tree n v -> IntMap v\n\nexport\nempty : IntMap v\nempty = Empty\n\nexport\nlookup : Int -> IntMap v -> Maybe v\nlookup _ Empty = Nothing\nlookup k (M _ t) = treeLookup k t\n\nexport\ninsert : Int -> v -> IntMap v -> IntMap v\ninsert k v Empty = M Z (Leaf k v)\ninsert k v (M _ t) =\n case treeInsert k v t of\n Left t' => (M _ t')\n Right t' => (M _ t')\n\nexport\ninsertFrom : List (Int, v) -> IntMap v -> IntMap v\ninsertFrom = flip $ foldl $ flip $ uncurry insert\n\nexport\ndelete : Int -> IntMap v -> IntMap v\ndelete _ Empty = Empty\ndelete k (M Z t) =\n case treeDelete k t of\n Left t' => (M _ t')\n Right () => Empty\ndelete k (M (S _) t) =\n case treeDelete k t of\n Left t' => (M _ t')\n Right t' => (M _ t')\n\nexport\nfromList : List (Int, v) -> IntMap v\nfromList l = foldl (flip (uncurry insert)) empty l\n\nexport\ntoList : IntMap v -> List (Int, v)\ntoList Empty = []\ntoList (M _ t) = treeToList t\n\n||| Gets the Keys of the map.\nexport\nkeys : IntMap v -> List Int\nkeys = map fst . toList\n\n||| Gets the values of the map. Could contain duplicates.\nexport\nvalues : IntMap v -> List v\nvalues = map snd . toList\n\ntreeMap : (a -> b) -> Tree n a -> Tree n b\ntreeMap f (Leaf k v) = Leaf k (f v)\ntreeMap f (Branch2 t1 k t2) = Branch2 (treeMap f t1) k (treeMap f t2)\ntreeMap f (Branch3 t1 k1 t2 k2 t3)\n = Branch3 (treeMap f t1) k1 (treeMap f t2) k2 (treeMap f t3)\n\nexport\nimplementation Functor IntMap where\n map _ Empty = Empty\n map f (M n t) = M _ (treeMap f t)\n\n||| Merge two maps. When encountering duplicate keys, using a function to combine the values.\n||| Uses the ordering of the first map given.\nexport\nmergeWith : (v -> v -> v) -> IntMap v -> IntMap v -> IntMap v\nmergeWith f x y = insertFrom inserted x where\n inserted : List (Key, v)\n inserted = do\n (k, v) <- toList y\n let v' = (maybe id f $ lookup k x) v\n pure (k, v')\n\n||| Merge two maps using the Semigroup (and by extension, Monoid) operation.\n||| Uses mergeWith internally, so the ordering of the left map is kept.\nexport\nmerge : Semigroup v => IntMap v -> IntMap v -> IntMap v\nmerge = mergeWith (<+>)\n\n||| Left-biased merge, also keeps the ordering specified by the left map.\nexport\nmergeLeft : IntMap v -> IntMap v -> IntMap v\nmergeLeft = mergeWith const\n\n-- TODO: is this the right variant of merge to use for this? I think it is, but\n-- I could also see the advantages of using `mergeLeft`. The current approach is\n-- strictly more powerful I believe, because `mergeLeft` can be emulated with\n-- the `First` monoid. However, this does require more code to do the same\n-- thing.\nexport\nSemigroup v => Semigroup (IntMap v) where\n (<+>) = merge\n\nexport\n(Semigroup v) => Monoid (IntMap v) where\n neutral = empty\n", "meta": {"hexsha": "1adf74868eeb3f9084e58ce5ca899801f123322c", "size": 9236, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/src/Data/IntMap.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "idris2/src/Data/IntMap.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "idris2/src/Data/IntMap.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.1830065359, "max_line_length": 93, "alphanum_fraction": 0.5873754872, "num_tokens": 3410, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.5068587164102937}} {"text": "module Main\n\nimport Data.Vect\n\n-- data DataStore: Type -> Type where\n-- MkData : (size : Nat) -> (items : Vect size schema) -> DataStore schema\n\ninfixr 5 .+.\n\ndata Schema = SString\n | SInt\n | (.+.) Schema Schema\n\nSchemaType : Schema -> Type\nSchemaType SString = String\nSchemaType SInt = Int\nSchemaType (x .+. y) = (SchemaType x, SchemaType y)\n\ndata DataStore : Type where\n MkData : (schema : Schema) -> (size : Nat) -> (items : Vect size (SchemaType schema)) -> DataStore\n\nsize : DataStore -> Nat\nsize (MkData schema' size' items') = size'\n\nschema : DataStore -> Schema\nschema (MkData schema' _ _) = schema'\n\nitems : (store: DataStore) -> Vect (size store) (SchemaType (schema store))\nitems (MkData _ _ items') = items'\n\naddToStore : (store: DataStore) -> (SchemaType (schema store)) -> DataStore\naddToStore (MkData schema size items) newitem = MkData schema _ (addToData items) where\n addToData : Vect old (SchemaType schema) -> Vect (S old) (SchemaType schema)\n addToData [] = [newitem]\n addToData (x :: xs) = x :: addToData xs\n\ndisplay: SchemaType schema -> String\ndisplay {schema = SString} item = show item\ndisplay {schema = SInt} item = show item\ndisplay {schema = (x .+. y)} (item1, item2) =\n (display item1) ++ \", \" ++ (display item2)\n\n\nparsePrefix : (schema: Schema) -> String -> Maybe (SchemaType schema, String)\nparsePrefix SString x = getQuoted (unpack x) where\n getQuoted : List Char -> Maybe (String, String)\n getQuoted ('\"':: xs) = case span (/= '\"') xs of\n (quoted, '\"':: rest) => Just (pack quoted, ltrim (pack rest))\n _ => Nothing\nparsePrefix SInt x = case Prelude.Strings.span isDigit x of\n (\"\", rest) => Nothing\n (num, rest) => Just (cast num, ltrim rest)\nparsePrefix (y .+. z) x = do\n (res1, rest) <- parsePrefix y x\n (res2, rest') <- parsePrefix z rest\n pure ((res1, res2), rest')\n\n\nparseBySchema : (schema: Schema) -> String -> Maybe (SchemaType schema)\nparseBySchema schema str = case parsePrefix schema str of\n Just (res, \"\") => Just res\n Just _ => Nothing\n Nothing => Nothing\n\ngetEntry : (pos: Integer) -> (store: DataStore) -> Maybe (String, DataStore)\ngetEntry pos store = let store_items = items store in\n case integerToFin pos (size store) of\n Nothing => Just (\"out of range\\n\", store)\n Just id => Just (display (index id store_items), store)\n\ndata Command : Schema -> Type where\n Add : (SchemaType schema) -> Command schema\n Get : Integer -> Command a\n Quit: Command a\n\nparseCommand : (schema: Schema) -> String -> String -> Maybe (Command schema)\nparseCommand schema \"add\" str = case parseBySchema schema str of\n Just restok => Just (Add restok)\n Nothing => Nothing\nparseCommand schema \"get\" val = case all isDigit (unpack val) of\n False => Nothing\n True => Just (Get (cast val))\nparseCommand schema \"quit\" _ = Just Quit\nparseCommand _ _ _ = Just Quit\n\n\n\n\n\n-- processCommand : Command schema -> DataStore -> Maybe (String, DataStore)\n-- processCommand (Add x) ds = Just (?show_size, addToStore ds x)\n-- processCommand (Get x) ds = getEntry x ds\n-- processCommand Quit _ = Nothing\n\n-- processInput : DataStore -> String -> Maybe (String, DataStore)\n-- processInput ds s = case parse s of\n-- Nothing => Just (\"Invalid command \" ++ s ++ \"\\n\", ds)\n-- Just command => processCommand command ds\n", "meta": {"hexsha": "cca12f50b6591972b6350d4bff52c71b05d76489", "size": 3271, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "DataStore.idr", "max_stars_repo_name": "gdevanla/idris-learn", "max_stars_repo_head_hexsha": "3348f611f6807e3e88dcd63951c713a327325c2a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "DataStore.idr", "max_issues_repo_name": "gdevanla/idris-learn", "max_issues_repo_head_hexsha": "3348f611f6807e3e88dcd63951c713a327325c2a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "DataStore.idr", "max_forks_repo_name": "gdevanla/idris-learn", "max_forks_repo_head_hexsha": "3348f611f6807e3e88dcd63951c713a327325c2a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0404040404, "max_line_length": 101, "alphanum_fraction": 0.671048609, "num_tokens": 930, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.6406358479787609, "lm_q1q2_score": 0.5064420610538671}} {"text": "module Main\n\nnext : Nat -> Stream Nat\nnext n = (n :: Delay (next (S n)))\n\ndata InfIO : Type where\n Do : IO a -> (a -> Inf InfIO) -> InfIO\n\n-- sugar me with do-notation\n(>>=) : IO a -> (a -> Inf InfIO) -> InfIO\n(>>=) = Do\n\n-- First try, infinite IO with partial run\n\nloopPrint : Nat -> InfIO\nloopPrint x = do putStrLn (show x)\n loopPrint (S x)\n\nrun : InfIO -> IO ()\nrun (Do x f) = do res <- x\n run (f res)\n\n-- Second try, finine infinite IO with total run\n\ndata Fuel : Type where\n Dry : Fuel\n More : Fuel -> Fuel\n\ntank : Nat -> Fuel\ntank Z = Dry\ntank (S k) = More (tank k)\n\ntotal runTank : Fuel -> InfIO -> IO ()\nrunTank Dry _ = putStrLn \"Out of Fuel\"\nrunTank (More fuel) (Do c f) = do res <- c\n runTank fuel (f res)\n\n-- Third try, Lazy Fuel for infinite infinite IO with a total run\n\ndata Gas : Type where\n Empty : Gas\n Some : Lazy Gas -> Gas\n\ndata Run : Type where\n Stop : Run\n Step : Lazy Run -> Run\n\ntotal runEngine : Gas -> InfIO -> IO ()\nrunEngine Empty y = putStrLn \"Out of fuel\"\nrunEngine (Some x) (Do y f) = y >>= \\res => runEngine x (f res)\n\nfreeGas : Gas\nfreeGas = Some freeGas\n\nmain : IO ()\nmain = runEngine freeGas (loopPrint 0)\n\nh : Nat -> () -> Nat\nh x = \\_ => (+) x 1\n\nh' : Nat -> Lazy Nat\nh' x = (+) x 1\n", "meta": {"hexsha": "327ee48adc27966970ed07a7c0e7957440bb7583", "size": 1293, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris/11.2-InfiniteIO.idr", "max_stars_repo_name": "ostera/asdf", "max_stars_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-03-02T22:25:19.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-30T18:22:11.000Z", "max_issues_repo_path": "idris/11.2-InfiniteIO.idr", "max_issues_repo_name": "ostera/asdf", "max_issues_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 7, "max_issues_repo_issues_event_min_datetime": "2019-12-05T22:45:56.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-05T22:45:58.000Z", "max_forks_repo_path": "idris/11.2-InfiniteIO.idr", "max_forks_repo_name": "ostera/asdf", "max_forks_repo_head_hexsha": "adec59de04ce1c2994db60b92f693e621bf68850", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 20.5238095238, "max_line_length": 65, "alphanum_fraction": 0.5730858469, "num_tokens": 405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.5055796918286468}} {"text": "module Patricia.IntSet\n\nimport Patricia.IntMap\n\n%default total\n%access export\n\npublic export\ndata IntBitSet : (bits : Nat) -> Type where\n MkIntSet : IntBitMap bits Unit -> IntBitSet bits\n\n||| Integer set with 32 bits integers as an element.\npublic export\nInt32Set : Type\nInt32Set = IntBitSet 32\n\n||| `O(n)`. Number of elements in `IntBitSet`.\npublic export\nsize : IntBitSet (S n) -> Nat\nsize (MkIntSet t) = size t\n\n||| `O(min(n, W))`. Check if the value is in the `IntBitSet`.\npublic export\nmember : Integer -> IntBitSet (S n) -> Bool\nmember x (MkIntSet t) = isJust (lookup x t)\n\n||| `O(min(n,W))`. Insert a new `value` in the `IntBitSet`.\n||| If the value is already present in the set, the tree isn't changed.\npublic export\ninsert : Integer -> IntBitSet (S n) -> IntBitSet (S n)\ninsert x (MkIntSet t) = MkIntSet (insert x () t)\n\n||| `O(min(n,W))`. Delete the `value` from `IntBitSet`.\n||| If the value is not present in the set, the tree isn't changed.\npublic export\ndelete : Integer -> IntBitSet (S n) -> IntBitSet (S n)\ndelete x (MkIntSet t) = MkIntSet (delete x t)\n\n||| Create `IntBitSet` from list of `value`.\npublic export\nfromList : List Integer -> IntBitSet (S n)\nfromList = MkIntSet . fromList . map (\\x => (x, ()))\n", "meta": {"hexsha": "f2a8e653485d7ee092aff81e7160d577c9a2cb02", "size": 1227, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Patricia/IntSet.idr", "max_stars_repo_name": "ChShersh/idris-persistent-array", "max_stars_repo_head_hexsha": "78ed6da63b05fdc19a107a70c595c65bc0a48f51", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2018-10-15T07:09:58.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-29T14:39:32.000Z", "max_issues_repo_path": "Patricia/IntSet.idr", "max_issues_repo_name": "ChShersh/idris-patricia", "max_issues_repo_head_hexsha": "78ed6da63b05fdc19a107a70c595c65bc0a48f51", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 6, "max_issues_repo_issues_event_min_datetime": "2017-10-12T17:43:01.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-27T19:58:46.000Z", "max_forks_repo_path": "Patricia/IntSet.idr", "max_forks_repo_name": "ChShersh/idris-persistent-array", "max_forks_repo_head_hexsha": "78ed6da63b05fdc19a107a70c595c65bc0a48f51", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2017-10-27T13:11:19.000Z", "max_forks_repo_forks_event_max_datetime": "2017-10-27T17:27:18.000Z", "avg_line_length": 28.5348837209, "max_line_length": 71, "alphanum_fraction": 0.6813365933, "num_tokens": 390, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837527911056, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.5053673714958755}} {"text": "-- --------------------------------------------------------------- [ Day08.idr ]\n-- Module : Data.Advent.Day08\n-- Description : My solution to the Day 8 puzzle of the 2016 Advent of Code.\n-- Copyright : Copyright (c) 2016, Eric Bailey\n-- License : MIT\n-- Link : http://adventofcode.com/2016/day/7\n-- --------------------------------------------------------------------- [ EOH ]\n||| Day 8: Two-Factor Authentication\nmodule Data.Advent.Day08\n\nimport Data.Vect\n\nimport public Lightyear\nimport public Lightyear.Char\nimport public Lightyear.Strings\nimport public Lightyear.StringFile\n\n%default total\n\n-- -------------------------------------------------------------- [ Data Types ]\n\n%access public export\n\ndata Pixel = Off | On\n\nimplementation Eq Pixel where\n On == On = True\n Off == Off = True\n px1 == px2 = False\n\nimplementation Show Pixel where\n show Off = \".\"\n show On = \"#\"\n\nScreen : Nat -> Nat -> Type\nScreen w h = Vect h (Vect w Pixel)\n\nimplementation [showScreen] Show (Screen w h) where\n show = unlines . toList . map (concatMap show)\n\ndata Rect : Nat -> Nat -> Type where\n MkRect : Fin w -> Fin h -> Rect w h\n\nimplementation Show (Fin n) where\n show = show . finToNat\n\n-- showFin : Fin n -> String\n-- showFin = show . finToNat\n\nimplementation Show (Rect w h) where\n show (MkRect w h) = \"rect \" ++ show w ++ \"x\" ++ show h\n\ndata Rotate : Nat -> Nat -> Type where\n Row : Fin w -> Fin h -> Rotate h w\n Col : Fin w -> Fin h -> Rotate w h\n\nimplementation Show (Rotate xy by) where\n show (Row y by) = \"rotate row y=\" ++ show y ++ \" by \" ++ show by\n show (Col x by) = \"rotate column x=\" ++ show x ++ \" by \" ++ show by\n\n-- ----------------------------------------------------------------- [ Parsers ]\n\n%access export\n\npartial\nside : (n : Nat) -> Parser (Fin n)\nside n = do Just len <- (\\m => integerToFin m n) <$> integer\n | Nothing => fail \"out of bounds\"\n pure len\n\npartial\nrect : Parser (Rect w h)\nrect = liftA2 MkRect (token \"rect\" *> side w)\n (token \"x\" *> side h) \"rect AxB\"\n\npartial\nmaybeFin : (n : Nat) -> Parser (Maybe (Fin n))\nmaybeFin n = marshal <$> integer <* spaces \n \"a number strictly less than \" ++ show n\n where\n marshal : Integer -> Maybe (Fin n)\n marshal m = integerToFin m n\n\npartial\nrow : Parser (Rotate w h)\nrow {w} {h} = do Just y <- token \"rotate row y=\" *> maybeFin h\n Just by <- token \"by\" *> maybeFin w\n pure $ Row y by\n\npartial\ncolumn : Parser (Rotate w h)\ncolumn {w} {h} = do Just x <- token \"rotate column x=\" *> maybeFin w\n Just by <- token \"by\" *> maybeFin h\n pure $ Col x by\n\npartial\nrotation : Parser (Rotate w h)\nrotation = row <|> column \"a rotation\"\n\npartial\nrectOrRotation : Parser (Either (Rect w h) (Rotate w h))\nrectOrRotation {w} {h} = case !(opt (rect {w} {h})) of\n Just rec => pure $ Left rec\n Nothing => Right <$> rotation {w} {h}\n\n-- ----------------------------------------------------------------- [ Helpers ]\n\n%access private\n\nmapIndexed : (f : (a, Nat) -> a) -> Vect n a -> Vect n a\nmapIndexed f xs {n} = map f (zip xs (go n Z))\n where\n go : (m : Nat) -> Nat -> Vect m Nat\n go Z _ = []\n go (S k) x = x :: go k (S x)\n\n-- ------------------------------------------------------------------ [ Proofs ]\n\n%access private\n\nfinToLTE : (f : Fin n) -> LTE (finToNat f) n\nfinToLTE FZ = LTEZero\nfinToLTE (FS _) {n = S _} = LTESucc (finToLTE _)\n\ntotal compositeLemma : (left, right : Nat) -> {auto smaller : LTE left right} ->\n (k : Nat ** right = left + k)\ncompositeLemma left right = (right - left ** go left right)\n where\n go : (left, right : Nat) -> {auto smaller : LTE left right} ->\n right = left + (right - left)\n go Z right = rewrite minusZeroRight right in Refl\n go (S k) (S j) {smaller} =\n let inductiveHypothesis = go k j {smaller = fromLteSucc smaller} in\n eqSucc j (k + (minus j k)) inductiveHypothesis\n\ntotal updateLemma : (prf : n = finToNat by + m) -> n = m + finToNat by\nupdateLemma {by} {m} prf = rewrite plusCommutative m (finToNat by) in prf\n\n-- -- ---------------------------------------------------------------- [ Logic ]\n\nturnOn : Rect sw sh -> Screen sw sh -> Screen sw sh\nturnOn (MkRect w h) = mapIndexed f\n where\n g : (Pixel, Nat) -> Pixel\n g (col, x) = if x < (finToNat w) then On else col\n f : (Vect m Pixel, Nat) -> Vect m Pixel\n f (row, y) = if y < (finToNat h) then mapIndexed g row else row\n\nnamespace Vect\n\n rotate : (by : Fin n) -> Vect (finToNat by + m) a ->\n (m ** Vect (m + finToNat by) a)\n rotate by xs {m} = let (ys,zs) = splitAt (finToNat by) xs in\n (m ** zs ++ ys)\n\nupdateRow : (by : Fin n) -> (row : Vect n Pixel) -> Vect n Pixel\nupdateRow {n} by row =\n let (m ** prf) = compositeLemma (finToNat by) n {smaller = finToLTE by}\n (_ ** newRow) = rotate by $ the (Vect (finToNat by + m) _) $\n rewrite sym prf in row in\n rewrite updateLemma prf in\n newRow\n\nnamespace Fin\n\n rotate : Fin n -> Fin n\n rotate f {n} = let x = (-) n (finToNat f) {smaller = finToLTE f} in\n fromMaybe f (natToFin x n) -- HACK\n\nnamespace Screen\n\n empty : {w, h : Nat} -> Screen w h\n empty {w} {h} = replicate h (replicate w Off)\n\n rotate : (Rotate w h) -> Screen w h -> Screen w h\n rotate (Row y by) screen = updateAt y (updateRow (rotate by)) screen\n rotate (Col x by) screen {h} = transpose $\n updateAt x (updateRow (rotate by)) $\n transpose screen\n\nhowManyLit : Screen w h -> Nat\nhowManyLit = foldr ((+) . foldr go Z) Z\n where\n go : Pixel -> Nat -> Nat\n go On = S\n go Off = id\n\njustDoIt : List (Either (Rect w h) (Rotate w h)) -> Screen w h\njustDoIt = foldl (\\s => either (flip turnOn s) (flip rotate s)) empty\n\n-- ---------------------------------------------------------------- [ Examples ]\n\nex1 : Screen 7 3\nex1 = turnOn (MkRect 3 2) empty\n\nex2 : Screen 7 3\nex2 = rotate (Col 1 1) ex1\n\nex3 : Screen 7 3\nex3 = rotate (Row 0 4) ex2\n\nex4 : Screen 7 3\nex4 = rotate (Col 1 1) ex3\n\npartial\nexamples : Either String (List (Either (Rect 7 3) (Rotate 7 3)))\nexamples = parse (some (rectOrRotation <* spaces)) $ unlines [\n \"rect 3x2\",\n \"rotate column x=1 by 1\",\n \"rotate row y=0 by 4\",\n \"rotate column x=1 by 1\"\n ]\n\n||| Convenient representation of Part One examples for the REPL.\npartial\nprettyExamples : Either String (List (List String))\nprettyExamples = transpose .\n map (lines . show @{showScreen}) .\n scanl (\\s => either (flip turnOn s) (flip rotate s)) empty <$>\n examples\n\n-- -------------------------------------------------------------- [ Main Logic ]\n\n%access export\n\nmain' : Parser a -> (a -> String) -> IO ()\nmain' p f =\n either putStrLn (putStrLn . f)\n !(run $ parseFile (const show) (const id) p \"input/day08.txt\")\n\n-- ---------------------------------------------------------------- [ Part One ]\n\nnamespace PartOne\n\n partial main : IO ()\n main = main' (some (rectOrRotation {w=50} {h=6} <* spaces))\n (show . howManyLit . justDoIt)\n\n-- ---------------------------------------------------------------- [ Part Two ]\n\nnamespace PartTwo\n\n partial main : IO ()\n main = main' (some (rectOrRotation {w=50} {h=6} <* spaces))\n (show @{showScreen} . justDoIt)\n\n-- -------------------------------------------------------------------- [ Main ]\n\nnamespace Main\n\n partial main : IO ()\n main = putStr \"Part One: \" *> PartOne.main *>\n putStrLn \"Part Two:\" *> PartTwo.main\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "92f79a5989ae8eb3b1a6d90f654184bf69e22c26", "size": 7969, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Advent/Day08.idr", "max_stars_repo_name": "yurrriq/advent-of-code", "max_stars_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-11-04T10:32:47.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-05T07:36:22.000Z", "max_issues_repo_path": "src/Data/Advent/Day08.idr", "max_issues_repo_name": "yurrriq/aoc19", "max_issues_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/Advent/Day08.idr", "max_forks_repo_name": "yurrriq/aoc19", "max_forks_repo_head_hexsha": "ee83efa138322b5dbbda9f4aeac75481a9cd49fe", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-26T19:27:21.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-26T19:27:21.000Z", "avg_line_length": 31.12890625, "max_line_length": 80, "alphanum_fraction": 0.5043292759, "num_tokens": 2161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.5052329087246661}} {"text": "module InsertionProof\n\nimport Data.Vect\nimport congruence\nimport Data.Fin\nimport Permutation\nimport PermCons\nimport Finite\nimport DecOrderNat\nimport LTE_Properties\nimport SortingWithProof\nimport InsertionSort\nimport InsertionHelpers\nimport PermConsProperties\n\n%access public export\n%default total\n\ninsertProof : (n : Nat) -> (a : Nat) -> (xs : (Vect n Nat)) ->\n (SortedVect n xs) -> (SortedVect (S n) (a :: xs))\n\ninsertProof Z a Nil sorted_Nil =\n ( [a] ** ((Idt (S Z) ** (Refl, (insertHelper8 a)))))\n\ninsertProof (S Z) a [x] sorted_x = case (decMin a x) of\n (Left pfLTE) => let\n pf = insertHelper8 x\n in\n ( [a, x] ** ((Idt 2) ** (Refl, (insertHelper1 Z a x Nil pfLTE pf))))\n (Right pfLTE) => let\n pf = insertHelper8 a\n in\n ( [x, a] ** ((Swap 2 FZ) ** (Refl, (insertHelper1 Z x a Nil pfLTE pf))))\n\ninsertProof (S (S n)) a xs sorted_xs = let\n {-\n (x :: u) = (fst sorted_xs)\n perm_xs = (fst (snd sorted_xs))\n pf_total_xs = (snd (snd sorted_xs))\n pf_perm_xs = fst pf_total_xs -- perm_xs xs = (x :: u)\n pf_sorted_xs = snd pf_total_xs\n\n in\n\n case (decMin a (head (fst sorted_xs))) of\n\n (Left pfLTE) => let\n\n perm = includePerm (S (S n)) (fst (snd sorted_xs)) -- perm_xs as a permutation of a :: xs\n\n pf1_1 = PermC_prp_1 (S (S n)) a xs (fst (snd sorted_xs))\n -- ( (a :: (applyPerm n Nat perm xs)) = (applyPerm (S n) Nat (includePerm n perm) (a :: xs)))\n\n pf1_2 = congruence (Vect (S (S n)) Nat) (Vect (S (S (S n))) Nat)\n (fst sorted_xs) (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs)\n (\\k => (a :: k)) (sym pf_perm_xs)\n -- a :: fst sorted_xs = a :: applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs\n\n\n pf1_3 = sym (trans pf1_2 pf1_1)\n -- applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs) = a :: fst sorted_xs\n\n pf1_5 = (\\k => (insertHelper10 (S n) (fst sorted_xs) k (pf_sorted_xs k)))\n\n pf1_4 = insertHelper1 (S n) a (head (fst sorted_xs)) (tail (fst sorted_xs)) pfLTE pf1_5\n\n in\n ((a :: (fst sorted_xs)) ** (perm ** (pf1_3, ?rhs)))\n\n (Right pfLTE) => ?rhs2\n -}\n\n (x1 :: v1) = (fst sorted_xs)\n x = (head (fst sorted_xs))\n u = (tail (fst sorted_xs))\n perm_xs = (fst (snd sorted_xs))\n pf_total_xs = (snd (snd sorted_xs))\n pf_perm_xs = fst pf_total_xs -- perm_xs xs = v\n pf_sorted_xs = snd pf_total_xs\n pf1_5 = (\\k => (insertHelper10 (S n) (fst sorted_xs) k (pf_sorted_xs k)))\n\n -- IsSorted (S (S n)) (head (fst sorted_xs) :: tail (fst sorted_xs)) :=\n\n -- (k16 : Fin (S (S n))) ->\n -- LTE (index (Data.Fin.Fin (S n) implementation of Prelude.Enum, method pred k16)\n -- (head (fst sorted_xs) :: tail (fst sorted_xs)))\n -- (index k16 (head (fst sorted_xs) :: tail (fst sorted_xs)))\n\n in\n\n case (decMin a (head (fst sorted_xs))) of\n\n (Left pfLTE) =>\n let\n perm = includePerm (S (S n)) (fst (snd sorted_xs))\n\n pf1_1 = PermC_prp_1 (S (S n)) a xs (fst (snd sorted_xs))\n -- a :: applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs =\n -- applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)\n\n pf1_2 = congruence (Vect (S (S n)) Nat) (Vect (S (S (S n))) Nat)\n (fst sorted_xs) (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs)\n (\\k => (a :: k)) (sym pf_perm_xs)\n -- a :: fst sorted_xs = a :: applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs\n\n pf1_3 = sym (trans pf1_2 pf1_1)\n -- applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs) = a :: fst sorted_xs\n\n pf1_4 = insertHelper1 (S n) a (head (fst sorted_xs)) (tail (fst sorted_xs)) pfLTE pf1_5 --pf_sorted_xs\n\n -- IsSorted (S (S (S n))) (a :: (head (fst sorted_xs) :: tail (fst sorted_xs))) :=\n\n --(k : Fin (S (S (S n)))) ->\n -- LTE (index (Data.Fin.Fin (S n) implementation of Prelude.Enum, method pred k)\n -- (a :: head (fst sorted_xs) :: tail (fst sorted_xs)))\n -- (index k (a :: head (fst sorted_xs) :: tail (fst sorted_xs)))\n\n pf1_7 = vect_prp1 (S n) (fst sorted_xs)\n -- fst sorted_xs = head (fst sorted_xs) :: tail (fst sorted_xs)\n\n\n pf1_8 = congruence (Vect (S (S n)) Nat) (Vect (S (S (S n))) Nat) (fst sorted_xs)\n ((head (fst sorted_xs)) :: (tail (fst sorted_xs))) (\\k => (a :: k)) pf1_7\n -- a :: fst sorted_xs = a :: head (fst sorted_xs) :: tail (fst sorted_xs)\n\n pf1_6 = insertHelper11 (S (S n)) (a :: head (fst sorted_xs) :: tail (fst sorted_xs))\n (a :: (fst sorted_xs)) (sym pf1_8) pf1_4\n -- IsSorted (S (S (S n))) (a :: (fst sorted_xs)) :=\n\n --(k : Fin (S (S (S n)))) ->\n -- LTE (index (Data.Fin.Fin (S n) implementation of Prelude.Enum, method pred k) (a :: fst sorted_xs))\n -- (index k (a :: fst sorted_xs))\n\n\n in\n ( (a :: (fst sorted_xs)) ** (perm ** (pf1_3, pf1_6)))\n\n\n (Right pfLTE) =>\n\n let\n\n pf2_1 = insertHelper9 (S n) (head (fst sorted_xs)) (tail (fst sorted_xs)) pf1_5\n -- IsSorted (S n) (tail (fst sorted_xs))\n\n pf2_2 = PermC_prp_2 (S n) (tail (fst sorted_xs))\n -- applyPerm (S n) Nat (Idt (S n)) (tail (fst sorted_xs)) = tail (fst sorted_xs)\n\n -- (k : Fin (S n)) ->\n -- LTE (index (Data.Fin.Fin (S n) implementation of Prelude.Enum, method pred k) (tail (fst sorted_xs)))\n -- (index k (tail (fst sorted_xs)))\n\n sorted_a_xs = insertProof (S n) a (tail (fst sorted_xs))\n ((tail (fst sorted_xs)) ** ((Idt (S n)) ** (pf2_2, pf2_1)))\n\n perm_a_xs = (fst (snd (sorted_a_xs)))\n\n perm = CPerm (S (S (S n)))\n (CPerm (S (S (S n))) (includePerm (S (S n)) (fst (snd (sorted_a_xs)))) (Swap (S (S (S n))) FZ) )\n (includePerm (S (S n)) (fst (snd (sorted_xs))))\n\n pf2_3 = PermC_prp_1 (S (S n)) a xs (fst (snd sorted_xs))\n -- a :: applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs =\n -- applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)\n\n pf2_4 = congruence (Vect (S (S (S n))) Nat) Nat\n (a :: (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs))\n (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))\n (\\k => (index FZ k)) pf2_3\n -- a = index FZ (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))\n\n pf2_5 = PermC_prp_1 (S (S n))\n\n (index (FS FZ) (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)))\n\n ((index FZ (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))) ::\n (tail (tail (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)))))\n\n (fst (snd (insertProof (S n) a\n (tail (fst sorted_xs))\n (tail (fst sorted_xs) **\n (Idt (S n)) **\n ( (PermC_prp_2 (S n) (tail (fst sorted_xs))),\n (insertHelper9 (S n) (head (fst sorted_xs)) (tail (fst sorted_xs)) pf1_5))))))\n\n -- now want to prove that x = (index (FS FZ) (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)))\n\n pf2_6 = congruence (Vect (S (S (S n))) Nat) Nat\n\n (a :: applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs)\n\n (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))\n\n (\\us => (index (FS FZ) us))\n\n pf2_3\n\n -- index FZ (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs) =\n -- index (FS FZ) (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))\n\n pf2_7 = congruence (Vect (S (S n)) Nat) Nat\n\n (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs)\n\n (fst (sorted_xs))\n\n (\\us => ((index FZ) us))\n\n pf_perm_xs\n\n -- index FZ (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs) = index FZ (fst sorted_xs)\n\n pf2_8 = trans (sym pf2_6) pf2_7\n\n -- index (FS FZ) (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)) =\n -- index FZ (fst sorted_xs)\n\n pf2_10 = insertHelper12 (S n) (fst sorted_xs)\n\n -- ((index FZ (fst (sorted_xs))) = (head (fst sorted_xs)))\n\n pf2_11 = trans pf2_8 pf2_10\n\n -- index (FS FZ) (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)) =\n -- head (fst sorted_xs)\n\n pf2_9 = congruence Nat (Vect (S (S (S n))) Nat)\n\n (index (FS FZ) (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)))\n\n (head (fst sorted_xs)) --(index FZ (fst sorted_xs))\n\n (\\z => (z :: (fst (insertProof (S n)\n a\n (tail (fst sorted_xs))\n (tail (fst sorted_xs) **\n Idt (S n) **\n (PermC_prp_2 (S n) (tail (fst sorted_xs)), insertHelper9 (S n) (head (fst sorted_xs)) (tail (fst sorted_xs)) pf1_5))))))\n\n pf2_11\n\n -- |||||||||||| code is running but taking too long\n\n {-\n\n pf_sorted_a_xs_total = (snd (snd sorted_a_xs))\n\n pf_perm_a_xs = (fst pf_sorted_a_xs_total)\n\n pf2_12 = congruence Nat (Vect (S (S n)) Nat) a\n\n\n (index FZ (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)))\n\n\n (\\s => (s :: (tail (fst sorted_xs))))\n\n pf2_4\n\n -- a :: tail (fst sorted_xs) =\n -- index FZ (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)) :: tail (fst sorted_xs)\n\n -- want to prove\n -- (index FZ (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)) ::\n -- tail (tail (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)))) =\n -- (a :: tail (fst sorted_xs))\n\n -- check pf2_4\n\n -- want to prove\n -- (tail (fst sorted_xs)) = (tail (tail (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))))\n\n\n pf2_13 = PermC_prp_1 (S (S n)) a xs (fst (snd sorted_xs))\n\n -- a :: applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs =\n -- applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs)\n\n pf2_14 = insertHelper13 (S (S n)) a (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs)\n\n pf2_15 = congruence (Vect (S (S (S n))) Nat) (Vect (S (S n)) Nat)\n (a :: (applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs))\n (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))\n (\\v => (tail v))\n pf2_13\n\n -- applyPerm (S (S n)) Nat (fst (snd sorted_xs)) xs =\n -- tail (applyPerm (S (S (S n))) Nat (includePerm (S (S n)) (fst (snd sorted_xs))) (a :: xs))\n\n pf2_16 = trans (sym pf_perm_xs) pf2_15\n -}\n\n\n in\n (((head (fst sorted_xs)) :: (fst sorted_a_xs)) ** (perm ** ((trans (trans (sym pf2_5) ?rhs21) pf2_9), ?rhs22)))\n", "meta": {"hexsha": "41f1eafcece54b52eec4bfe3481a5eac3cb02fd5", "size": 12166, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Code/InsertionProof.idr", "max_stars_repo_name": "anotherArka/LTS2019", "max_stars_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 15, "max_stars_repo_stars_event_min_datetime": "2019-01-16T18:03:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-13T16:28:41.000Z", "max_issues_repo_path": "Code/InsertionProof.idr", "max_issues_repo_name": "anotherArka/LTS2019", "max_issues_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 58, "max_issues_repo_issues_event_min_datetime": "2019-01-08T11:22:38.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-21T10:26:10.000Z", "max_forks_repo_path": "Code/InsertionProof.idr", "max_forks_repo_name": "anotherArka/LTS2019", "max_forks_repo_head_hexsha": "a3cd249d7ae85301ef8c1bbc363998f74221ca4d", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 22, "max_forks_repo_forks_event_min_datetime": "2019-01-08T05:56:23.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-31T03:58:00.000Z", "avg_line_length": 41.1013513514, "max_line_length": 146, "alphanum_fraction": 0.4816702285, "num_tokens": 3777, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430311279739, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.5050550088797423}} {"text": "module Main\n\nid' : t -> t\nid' x = x\n\n-- type Dependent version of id\n-- taking an explicit type as its first argument\nthe' : (t : Type) -> t -> t\nthe' t x = x\n\n-- *hai> the' (Int)\n-- the' Int : Int -> Int\n-- *hai> the' (Int) 1\n-- 1 : Int\n-- *hai> id' 1\n-- 1 : Integer\n\nmain : IO ()\nmain = putStrLn \"Oh, hai\"\n\nStringOrIntType : Bool -> Type\nStringOrIntType x = case x of\n True => Int\n False => String\n\nstringOrIntVal : (x : Bool) -> StringOrIntType x\nstringOrIntVal x = case x of\n True => 7\n False => \"Seven\"\n\nvalToString : (x : Bool) -> StringOrIntType x -> String\nvalToString x val = case x of\n True => cast val\n False => val\n\nvalToStringWithHole : (x : Bool) -> StringOrIntType x -> String\nvalToStringWithHole x val = case x of\n True => ?xTrueType -- holes\n False => ?xFalseType -- ctrl + alt + t\n\n-- idris hai.idr\n-- hai> valToString False \"yaay\"\n-- \"yaay\" : String\n-- *hai> valToString True 2\n-- \"2\" : String\n", "meta": {"hexsha": "ba4cd8f3fdff4ae77e03c89ccc5912f7e7cf7580", "size": 1081, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "starting/hai.idr", "max_stars_repo_name": "prt2121/tdd-playground", "max_stars_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "starting/hai.idr", "max_issues_repo_name": "prt2121/tdd-playground", "max_issues_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "starting/hai.idr", "max_forks_repo_name": "prt2121/tdd-playground", "max_forks_repo_head_hexsha": "6178c6ff150b11a462d40f0f3a0fd3ccc8d5ffb0", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 23.5, "max_line_length": 63, "alphanum_fraction": 0.5272895467, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.705785040214066, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.5049355536341464}} {"text": "module Flexidisc.Header.Label\n\nimport Flexidisc.Header.Type\nimport Flexidisc.OrdList\n\n%default total\n%access public export\n\n||| Proof that a label is in an `Header'`\ndata Label : (l : k) -> (xs : Header' k a) -> Type where\n ||| A wrapper for an `OrdLabel`\n L : {xs : OrdList k o a} -> OrdLabel l xs -> Label l (H xs)\n\n%name Label lbl, loc, prf, e, elem\n\n||| Decide whether a label is in a list or not\ndecLabel : DecEq k => (l : k) -> (xs : Header' k a) -> Dec (Label l xs)\ndecLabel l (H xs) with (decLabel l xs)\n | (Yes prf) = Yes (L prf)\n | (No contra) = No (\\(L p) => contra p)\n\n||| Given a proof that a label is in the list, get the corresponding value back\natLabel : (xs : Header' l a) -> (loc : Label k xs) -> a\natLabel (H xs) (L loc) = atLabel xs loc\n\n||| Given a proof that an element is in a vector, remove it\ndropLabel : (xs : Header' k a) -> (loc : Label l xs) -> Header' k a\ndropLabel (H xs) (L loc) = H (dropLabel xs loc)\n\n||| Update a value in the `Header'` given it's location and a new value\nchangeType : (xs : Header' k a) -> (loc : Label l xs) -> (new : a) ->\n Header' k a\nchangeType (H xs) (L loc) = H . changeValue xs loc\n", "meta": {"hexsha": "7134e1c52ece039752f24451ebe4eb56088bbada", "size": 1157, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Flexidisc/Header/Label.idr", "max_stars_repo_name": "berewt/flexidisc", "max_stars_repo_head_hexsha": "8a0c367244229be5d417c04588d8d41b6030dba2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2020-04-02T09:51:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-03T05:15:49.000Z", "max_issues_repo_path": "src/Flexidisc/Header/Label.idr", "max_issues_repo_name": "LIST-LUXEMBOURG/flexidisc", "max_issues_repo_head_hexsha": "f5a9cdc81554359e324b64400d8479494cd45a8c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Flexidisc/Header/Label.idr", "max_forks_repo_name": "LIST-LUXEMBOURG/flexidisc", "max_forks_repo_head_hexsha": "f5a9cdc81554359e324b64400d8479494cd45a8c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.0294117647, "max_line_length": 79, "alphanum_fraction": 0.6231633535, "num_tokens": 386, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879312056025699, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.5047769922684417}} {"text": "\nimport Control.Indexed\nimport Control.Monad.Indexed.State\n\ndata State = One | Two | Three\n\ndata Transition : Type -> State -> State -> Type where\n Pure : (x : a) -> Transition a s s\n First : Transition () One Two\n Second : Transition () Two Three\n Third : Transition () Three One\n Bind : Transition a x y -> (a -> Transition b y z) -> Transition b x z\n\nIndexedFunctor State State Transition where\n map f (Pure x) = Pure (f x)\n map f First = Bind First (Pure . f)\n map f Second = Bind Second (Pure . f)\n map f Third = Bind Third (Pure . f)\n map f (Bind x g) = Bind x (\\x' => map f (g x'))\n\n[n1] IndexedApplicative State Transition where\n pure = Pure\n ap (Pure f) x = map f x\n ap (Bind y f) x = \n Bind y $ \\y' =>\n Bind (f y') $ \\f' =>\n Bind x (\\x' => Pure (f' x'))\n\nIndexedMonad State Transition using n1 where\n bind = Bind\n\ndata Meta = Description String\n\n||| A Transition plus some metadata\nTransitionPlus : Type -> State -> State -> Type\nTransitionPlus = IndexedStateT Meta State State Transition\n\nmain : TransitionPlus () One One\nmain = do\n put $ Description \"meta text\"\n lift $ do\n First\n Second\n x <- get\n lift $ do\n Indexed.ignore $ Pure x\n Third\n\n", "meta": {"hexsha": "8acf90c4a6faed567cdd483685b97d145ad59278", "size": 1217, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/examples/state_t/StateTransformer.idr", "max_stars_repo_name": "mattpolzin/idris-indexed", "max_stars_repo_head_hexsha": "21e448e4da193425336ae150bc55e015c6445415", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/examples/state_t/StateTransformer.idr", "max_issues_repo_name": "mattpolzin/idris-indexed", "max_issues_repo_head_hexsha": "21e448e4da193425336ae150bc55e015c6445415", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2021-12-05T08:05:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T07:26:51.000Z", "max_forks_repo_path": "tests/examples/state_t/StateTransformer.idr", "max_forks_repo_name": "mattpolzin/idris-indexed", "max_forks_repo_head_hexsha": "21e448e4da193425336ae150bc55e015c6445415", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 24.8367346939, "max_line_length": 72, "alphanum_fraction": 0.6277732128, "num_tokens": 348, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772417253256, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.504775555910774}} {"text": "module TypedContainers.LawfulOrd\n\n%default total\n\npublic export\ninterface LawfulOrd a where\n compare : a -> a -> Ordering\n 0 reflexivity : (x : a) -> (compare x x = EQ)\n 0 reversion1 : (x : a) -> (y : a) -> (compare x y = LT) -> (compare y x = GT)\n 0 reversion2 : (x : a) -> (y : a) -> (compare x y = GT) -> (compare y x = LT)\n 0 reversion3 : (x : a) -> (y : a) -> (compare x y = EQ) -> (compare y x = EQ)\n 0 transitivity : (x : a) -> (y : a) -> (z : a) -> (compare x y = LT) -> (compare y z = LT) -> (compare x z = LT)\n 0 equality1 : (x : a) -> (y : a) -> (z : a) -> (compare x y = EQ) -> (compare x z = compare y z)\n 0 equality2 : (x : a) -> (y : a) -> (z : a) -> (compare x y = EQ) -> (compare z x = compare z y)\n\npublic export\ninterface LawfulOrd a => LawfullerOrd a where\n -- `compare` needs to be unambigious here because the name is\n -- seemingly resolved where the instances are defined...\n 0 realEquality : (x : a) -> (y : a) -> (TypedContainers.LawfulOrd.compare x y = EQ) -> (x = y)\n\npublic export\n(==) : LawfulOrd a => a -> a -> Bool\nx == y = case compare x y of { EQ => True; _ => False }\n\npublic export\n(<) : LawfulOrd a => a -> a -> Bool\nx < y = case compare x y of { LT => True; _ => False }\n\npublic export\n(>) : LawfulOrd a => a -> a -> Bool\nx > y = case compare x y of { GT => True; _ => False }\n\npublic export\nconvLT : LawfulOrd a => (x : a) -> (y : a) -> (x < y = True) -> (compare x y = LT)\nconvLT x y p with (compare x y)\n convLT x y Refl | GT impossible\n convLT x y Refl | EQ impossible\n convLT x y Refl | LT = Refl\n\npublic export\nconvGT : LawfulOrd a => (x : a) -> (y : a) -> (x > y = True) -> (compare x y = GT)\nconvGT x y p with (compare x y)\n convGT x y Refl | GT = Refl\n convGT x y Refl | EQ impossible\n convGT x y Refl | LT impossible\n\npublic export\nconvEQ : LawfulOrd a => (x : a) -> (y : a) -> (x == y = True) -> (compare x y = EQ)\nconvEQ x y p with (compare x y)\n convEQ x y Refl | GT impossible\n convEQ x y Refl | EQ = Refl\n convEQ x y Refl | LT impossible\n", "meta": {"hexsha": "f916bd38da1b40bd7967c88c7272423b615f025c", "size": 2010, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TypedContainers/LawfulOrd.idr", "max_stars_repo_name": "L-as/idris-rbtree", "max_stars_repo_head_hexsha": "1c9bab3c5f54ab431c379bf54cec5b548e09f0d3", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2021-08-25T15:48:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-10T05:31:53.000Z", "max_issues_repo_path": "TypedContainers/LawfulOrd.idr", "max_issues_repo_name": "L-as/idris-rbtree", "max_issues_repo_head_hexsha": "1c9bab3c5f54ab431c379bf54cec5b548e09f0d3", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "TypedContainers/LawfulOrd.idr", "max_forks_repo_name": "L-as/idris-rbtree", "max_forks_repo_head_hexsha": "1c9bab3c5f54ab431c379bf54cec5b548e09f0d3", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.2222222222, "max_line_length": 114, "alphanum_fraction": 0.571641791, "num_tokens": 718, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679957, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.5046821317196485}} {"text": "module Prelude.Interfaces\n\nimport Builtin\nimport Prelude.Basics\nimport Prelude.EqOrd\nimport Prelude.Num\nimport Prelude.Ops\n\n%default total\n\n-------------\n-- ALGEBRA --\n-------------\n\n||| Sets equipped with a single binary operation that is associative. Must\n||| satisfy the following laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\npublic export\ninterface Semigroup ty where\n constructor MkSemigroup\n (<+>) : ty -> ty -> ty\n\n||| Sets equipped with a single binary operation that is associative, along with\n||| a neutral element for that binary operation. Must satisfy the following\n||| laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\n||| + Neutral for `<+>`:\n||| forall a, a <+> neutral == a\n||| forall a, neutral <+> a == a\npublic export\ninterface Semigroup ty => Monoid ty where\n constructor MkMonoid\n neutral : ty\n\npublic export\nSemigroup () where\n _ <+> _ = ()\n\npublic export\nMonoid () where\n neutral = ()\n\npublic export\nSemigroup a => Semigroup b => Semigroup (a, b) where\n (x, y) <+> (v, w) = (x <+> v, y <+> w)\n\npublic export\nMonoid a => Monoid b => Monoid (a, b) where\n neutral = (neutral, neutral)\n\npublic export\nSemigroup Ordering where\n LT <+> _ = LT\n GT <+> _ = GT\n EQ <+> o = o\n\npublic export\nMonoid Ordering where\n neutral = EQ\n\npublic export\nSemigroup b => Semigroup (a -> b) where\n (f <+> g) x = f x <+> g x\n\npublic export\nMonoid b => Monoid (a -> b) where\n neutral _ = neutral\n\n---------------------------------------------------------\n-- FUNCTOR, BIFUNCTOR, APPLICATIVE, ALTERNATIVE, MONAD --\n---------------------------------------------------------\n\n||| Functors allow a uniform action over a parameterised type.\n||| @ f a parameterised type\npublic export\ninterface Functor f where\n constructor MkFunctor\n ||| Apply a function across everything of type 'a' in a parameterised type\n ||| @ f the parameterised type\n ||| @ func the function to apply\n map : (func : a -> b) -> f a -> f b\n\n||| An infix alias for `map`, applying a function across everything of type 'a'\n||| in a parameterised type.\n||| @ f the parameterised type\n||| @ func the function to apply\npublic export\n(<$>) : Functor f => (func : a -> b) -> f a -> f b\n(<$>) func x = map func x\n\n||| Flipped version of `<$>`, an infix alias for `map`, applying a function across\n||| everything of type 'a' in a parameterised type.\n||| @ f the parameterised type\n||| @ func the function to apply\npublic export\n(<&>) : Functor f => f a -> (func : a -> b) -> f b\n(<&>) x func = map func x\n\n||| Run something for effects, replacing the return value with a given parameter.\npublic export\n(<$) : Functor f => b -> f a -> f b\n(<$) b = map (const b)\n\n||| Flipped version of `<$`.\npublic export\n($>) : Functor f => f a -> b -> f b\n($>) fa b = map (const b) fa\n\n||| Run something for effects, throwing away the return value.\n%inline\npublic export\nignore : Functor f => f a -> f ()\nignore = map (const ())\n\nnamespace Functor\n ||| Composition of functors is a functor.\n public export\n [Compose] (Functor f, Functor g) => Functor (f . g) where\n map = map . map\n\n||| Bifunctors\n||| @f The action of the Bifunctor on pairs of objects\npublic export\ninterface Bifunctor f where\n constructor MkBifunctor\n ||| The action of the Bifunctor on pairs of morphisms\n |||\n ||| ````idris example\n ||| bimap (\\x => x + 1) reverse (1, \"hello\") == (2, \"olleh\")\n ||| ````\n |||\n bimap : (a -> c) -> (b -> d) -> f a b -> f c d\n bimap f g = mapFst f . mapSnd g\n\n ||| The action of the Bifunctor on morphisms pertaining to the first object\n |||\n ||| ````idris example\n ||| mapFst (\\x => x + 1) (1, \"hello\") == (2, \"hello\")\n ||| ````\n |||\n mapFst : (a -> c) -> f a b -> f c b\n mapFst f = bimap f id\n\n ||| The action of the Bifunctor on morphisms pertaining to the second object\n |||\n ||| ````idris example\n ||| mapSnd reverse (1, \"hello\") == (1, \"olleh\")\n ||| ````\n |||\n mapSnd : (b -> d) -> f a b -> f a d\n mapSnd = bimap id\n\npublic export\nmapHom : Bifunctor f => (a -> b) -> f a a -> f b b\nmapHom f = bimap f f\n\npublic export\ninterface Functor f => Applicative f where\n constructor MkApplicative\n pure : a -> f a\n (<*>) : f (a -> b) -> f a -> f b\n\npublic export\n(<*) : Applicative f => f a -> f b -> f a\na <* b = map const a <*> b\n\npublic export\n(*>) : Applicative f => f a -> f b -> f b\na *> b = map (const id) a <*> b\n\n%allow_overloads pure\n%allow_overloads (<*)\n%allow_overloads (*>)\n\nnamespace Applicative\n ||| Composition of applicative functors is an applicative functor.\n public export\n [Compose] (Applicative f, Applicative g) => Applicative (f . g)\n using Functor.Compose where\n pure = pure . pure\n fun <*> x = [| fun <*> x |]\n\npublic export\ninterface Applicative f => Alternative f where\n constructor MkAlternative\n empty : f a\n (<|>) : f a -> Lazy (f a) -> f a\n\npublic export\ninterface Applicative m => Monad m where\n constructor MkMonad\n ||| Also called `bind`.\n (>>=) : m a -> (a -> m b) -> m b\n\n ||| Also called `flatten` or mu.\n join : m (m a) -> m a\n\n -- default implementations\n (>>=) x f = join (f <$> x)\n join x = x >>= id\n\n%allow_overloads (>>=)\n\n||| Right-to-left monadic bind, flipped version of `>>=`.\npublic export\n(=<<) : Monad m => (a -> m b) -> m a -> m b\n(=<<) = flip (>>=)\n\n||| Sequencing of effectful composition\npublic export\n(>>) : Monad m => m () -> Lazy (m b) -> m b\na >> b = a >>= \\_ => b\n\n||| Left-to-right Kleisli composition of monads.\npublic export\n(>=>) : Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)\n(>=>) f g = \\x => f x >>= g\n\n||| Right-to-left Kleisli composition of monads, flipped version of `>=>`.\npublic export\n(<=<) : Monad m => (b -> m c) -> (a -> m b) -> (a -> m c)\n(<=<) = flip (>=>)\n\n||| `guard a` is `pure ()` if `a` is `True` and `empty` if `a` is `False`.\npublic export\nguard : Alternative f => Bool -> f ()\nguard x = if x then pure () else empty\n\n||| Conditionally execute an applicative expression when the boolean is true.\npublic export\nwhen : Applicative f => Bool -> Lazy (f ()) -> f ()\nwhen True f = f\nwhen False f = pure ()\n\n||| Execute an applicative expression unless the boolean is true.\n%inline public export\nunless : Applicative f => Bool -> Lazy (f ()) -> f ()\nunless = when . not\n\n---------------------------\n-- FOLDABLE, TRAVERSABLE --\n---------------------------\n\n||| The `Foldable` interface describes how you can iterate over the elements in\n||| a parameterised type and combine the elements together, using a provided\n||| function, into a single result.\n||| @ t The type of the 'Foldable' parameterised type.\npublic export\ninterface Foldable t where\n constructor MkFoldable\n ||| Successively combine the elements in a parameterised type using the\n ||| provided function, starting with the element that is in the final position\n ||| i.e. the right-most position.\n ||| @ func The function used to 'fold' an element into the accumulated result\n ||| @ init The starting value the results are being combined into\n ||| @ input The parameterised type\n foldr : (func : elem -> acc -> acc) -> (init : acc) -> (input : t elem) -> acc\n\n ||| The same as `foldr` but begins the folding from the element at the initial\n ||| position in the data structure i.e. the left-most position.\n ||| @ func The function used to 'fold' an element into the accumulated result\n ||| @ init The starting value the results are being combined into\n ||| @ input The parameterised type\n foldl : (func : acc -> elem -> acc) -> (init : acc) -> (input : t elem) -> acc\n foldl f z t = foldr (flip (.) . flip f) id t z\n\n ||| Test whether the structure is empty.\n ||| @ acc The accumulator value which is specified to be lazy\n null : t elem -> Lazy Bool\n null = foldr {acc = Lazy Bool} (\\ _,_ => False) True\n\n ||| Similar to `foldl`, but uses a function wrapping its result in a `Monad`.\n ||| Consequently, the final value is wrapped in the same `Monad`.\n foldlM : Monad m => (funcM : acc -> elem -> m acc) -> (init : acc) -> (input : t elem) -> m acc\n foldlM fm a0 = foldl (\\ma, b => ma >>= flip fm b) (pure a0)\n\n ||| Produce a list of the elements contained in the parametrised type.\n toList : t elem -> List elem\n toList = foldr (::) []\n\n ||| Maps each element to a value and combine them.\n ||| For performance reasons, this should wherever\n ||| be implemented with tail recursion.\n ||| @ f The function to apply to each element.\n foldMap : Monoid m => (f : a -> m) -> t a -> m\n foldMap f = foldr ((<+>) . f) neutral\n\n||| Combine each element of a structure into a monoid.\npublic export\nconcat : (Foldable t, Monoid a) => t a -> a\nconcat = foldMap id\n\n||| Combine into a monoid the collective results of applying a function to each\n||| element of a structure.\npublic export\nconcatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m\nconcatMap = foldMap\n\nnamespace Bool.Lazy\n namespace Semigroup\n public export\n [Any] Semigroup (Lazy Bool) where\n x <+> y = force x || y\n\n public export\n [All] Semigroup (Lazy Bool) where\n x <+> y = force x && y\n\n namespace Monoid\n public export\n [Any] Monoid (Lazy Bool) using Semigroup.Any where\n neutral = delay False\n\n public export\n [All] Monoid (Lazy Bool) using Semigroup.All where\n neutral = delay True\n\n||| The conjunction of all elements of a structure containing lazy boolean\n||| values. `and` short-circuits from left to right, evaluating until either an\n||| element is `False` or no elements remain.\npublic export\nand : Foldable t => t (Lazy Bool) -> Bool\nand = force . concat @{(%search, All)}\n\n||| The disjunction of all elements of a structure containing lazy boolean\n||| values. `or` short-circuits from left to right, evaluating either until an\n||| element is `True` or no elements remain.\npublic export\nor : Foldable t => t (Lazy Bool) -> Bool\nor = force . concat @{(%search, Any)}\n\nnamespace Bool\n namespace Semigroup\n public export\n [Any] Semigroup Bool where\n x <+> y = x || delay y\n\n public export\n [All] Semigroup Bool where\n x <+> y = x && delay y\n\n namespace Monoid\n public export\n [Any] Monoid Bool using Bool.Semigroup.Any where\n neutral = False\n\n public export\n [All] Monoid Bool using Bool.Semigroup.All where\n neutral = True\n\n||| The disjunction of the collective results of applying a predicate to all\n||| elements of a structure. `any` short-circuits from left to right.\npublic export\nany : Foldable t => (a -> Bool) -> t a -> Bool\nany = foldMap @{%search} @{Any}\n\n||| The disjunction of the collective results of applying a predicate to all\n||| elements of a structure. `all` short-circuits from left to right.\npublic export\nall : Foldable t => (a -> Bool) -> t a -> Bool\nall = foldMap @{%search} @{All}\n where\n monoid : Monoid Bool\n monoid = MkMonoid @{MkSemigroup (\\x, y => x && y)} True\n\nnamespace Num\n namespace Semigroup\n public export\n [Additive] Num a => Semigroup a where\n (<+>) = (+)\n\n public export\n [Multiplicative] Num a => Semigroup a where\n (<+>) = (*)\n\n namespace Monoid\n public export\n [Additive] Num a => Monoid a using Semigroup.Additive where\n neutral = 0\n\n public export\n [Multiplicative] Num a => Monoid a using Semigroup.Multiplicative where\n neutral = 1\n\n||| Add together all the elements of a structure.\npublic export\nsum : (Foldable t, Num a) => t a -> a\nsum = concat @{(%search, Additive)}\n\n||| Add together all the elements of a structure.\n||| Same as `sum` but tail recursive.\nexport\nsum' : (Foldable t, Num a) => t a -> a\nsum' = sum\n\n||| Multiply together all elements of a structure.\npublic export\nproduct : (Foldable t, Num a) => t a -> a\nproduct = concat @{(%search, Multiplicative)}\n\n||| Multiply together all elements of a structure.\n||| Same as `product` but tail recursive.\nexport\nproduct' : (Foldable t, Num a) => t a -> a\nproduct' = product\n\n||| Map each element of a structure to a computation, evaluate those\n||| computations and discard the results.\npublic export\ntraverse_ : (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()\ntraverse_ f = foldr ((*>) . f) (pure ())\n\n||| Evaluate each computation in a structure and discard the results.\npublic export\nsequence_ : (Foldable t, Applicative f) => t (f a) -> f ()\nsequence_ = foldr (*>) (pure ())\n\n||| Like `traverse_` but with the arguments flipped.\npublic export\nfor_ : (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()\nfor_ = flip traverse_\n\nnamespace Lazy\n public export\n [SemigroupAlternative] Alternative f => Semigroup (Lazy (f a)) where\n x <+> y = force x <|> y\n\n public export\n [MonoidAlternative] Alternative f => Monoid (Lazy (f a)) using Lazy.SemigroupAlternative where\n neutral = delay empty\n\npublic export\n[SemigroupAlternative] Alternative f => Semigroup (f a) where\n x <+> y = x <|> delay y\n\npublic export\n[MonoidAlternative] Alternative f => Monoid (f a) using Interfaces.SemigroupAlternative where\n neutral = empty\n\n||| Fold using Alternative.\n|||\n||| If you have a left-biased alternative operator `<|>`, then `choice` performs\n||| left-biased choice from a list of alternatives, which means that it\n||| evaluates to the left-most non-`empty` alternative.\n|||\n||| If the list is empty, or all values in it are `empty`, then it evaluates to\n||| `empty`.\n|||\n||| Example:\n|||\n||| ```\n||| -- given a parser expression like:\n||| expr = literal <|> keyword <|> funcall\n|||\n||| -- choice lets you write this as:\n||| expr = choice [literal, keyword, funcall]\n||| ```\n|||\n||| Note: In Haskell, `choice` is called `asum`.\npublic export\nchoice : (Foldable t, Alternative f) => t (Lazy (f a)) -> f a\nchoice = force . concat @{(%search, Lazy.MonoidAlternative)}\n\n||| A fused version of `choice` and `map`.\npublic export\nchoiceMap : (Foldable t, Alternative f) => (a -> f b) -> t a -> f b\nchoiceMap = foldMap @{%search} @{MonoidAlternative}\n\nnamespace Foldable\n ||| Composition of foldables is foldable.\n public export\n [Compose] (Foldable t, Foldable f) => Foldable (t . f) where\n foldr = foldr . flip . foldr\n foldl = foldl . foldl\n null tf = null tf || all (force . null) tf\n foldMap = foldMap . foldMap\n\n||| `Bifoldable` identifies foldable structures with two different varieties\n||| of elements (as opposed to `Foldable`, which has one variety of element).\n||| Common examples are `Either` and `Pair`.\npublic export\ninterface Bifoldable p where\n constructor MkBifoldable\n bifoldr : (a -> acc -> acc) -> (b -> acc -> acc) -> acc -> p a b -> acc\n\n bifoldl : (acc -> a -> acc) -> (acc -> b -> acc) -> acc -> p a b -> acc\n bifoldl f g z t = bifoldr (flip (.) . flip f) (flip (.) . flip g) id t z\n\n binull : p a b -> Lazy Bool\n binull = bifoldr {acc = Lazy Bool} (\\ _,_ => False) (\\ _,_ => False) True\n\npublic export\ninterface (Functor t, Foldable t) => Traversable t where\n constructor MkTraversable\n ||| Map each element of a structure to a computation, evaluate those\n ||| computations and combine the results.\n traverse : Applicative f => (a -> f b) -> t a -> f (t b)\n\n||| Evaluate each computation in a structure and collect the results.\npublic export\nsequence : (Traversable t, Applicative f) => t (f a) -> f (t a)\nsequence = traverse id\n\n||| Like `traverse` but with the arguments flipped.\npublic export\nfor : (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)\nfor = flip traverse\n\npublic export\ninterface (Bifunctor p, Bifoldable p) => Bitraversable p where\n constructor MkBitraversable\n ||| Map each element of a structure to a computation, evaluate those\n ||| computations and combine the results.\n bitraverse : Applicative f => (a -> f c) -> (b -> f d) -> p a b -> f (p c d)\n\n||| Evaluate each computation in a structure and collect the results.\npublic export\nbisequence : (Bitraversable p, Applicative f) => p (f a) (f b) -> f (p a b)\nbisequence = bitraverse id id\n\n||| Like `bitraverse` but with the arguments flipped.\npublic export\nbifor : (Bitraversable p, Applicative f)\n => p a b\n -> (a -> f c)\n -> (b -> f d)\n -> f (p c d)\nbifor t f g = bitraverse f g t\n\nnamespace Traversable\n ||| Composition of traversables is traversable.\n public export\n [Compose] (Traversable t, Traversable f) => Traversable (t . f)\n using Foldable.Compose Functor.Compose where\n traverse = traverse . traverse\n\nnamespace Monad\n ||| Composition of a traversable monad and a monad is a monad.\n public export\n [Compose] (Monad m, Monad t, Traversable t) => Monad (m . t)\n using Applicative.Compose where\n a >>= f = a >>= map join . traverse f\n", "meta": {"hexsha": "eddb1e42aaac17507e75fc6dcb434d94ed670bff", "size": 16560, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/prelude/Prelude/Interfaces.idr", "max_stars_repo_name": "ska80/idris-jvm", "max_stars_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "libs/prelude/Prelude/Interfaces.idr", "max_issues_repo_name": "ska80/idris-jvm", "max_issues_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "libs/prelude/Prelude/Interfaces.idr", "max_forks_repo_name": "ska80/idris-jvm", "max_forks_repo_head_hexsha": "66223d026d034578876b325e9fcd95874faa6052", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 30.2742230347, "max_line_length": 97, "alphanum_fraction": 0.6323067633, "num_tokens": 4862, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.5045411470690095}} {"text": "module Libraries.Data.List.Extra\n\nimport public Data.List\nimport Data.List1\n\n%default total\n\nexport\nminimum : Ord a => (xs : List a) -> {auto 0 _ : NonEmpty xs} -> a\nminimum (x :: xs) = foldl min x xs\n\n||| Fetches the element at a given position.\n||| Returns `Nothing` if the position beyond the list's end.\npublic export\nelemAt : List a -> Nat -> Maybe a\nelemAt [] _ = Nothing\nelemAt (l :: _) Z = Just l\nelemAt (_ :: ls) (S n) = elemAt ls n\n\nexport\nfindBy : (a -> Maybe b) -> List a -> Maybe b\nfindBy p [] = Nothing\nfindBy p (x :: xs)\n = case p x of\n Nothing => findBy p xs\n Just win => pure win\n\nexport\nbreakAfter : (a -> Bool) -> List a -> (List a, List a)\nbreakAfter p [] = ([], [])\nbreakAfter p (x::xs)\n = if p x\n then ([x], xs)\n else let (ys, zs) = breakAfter p xs in (x::ys, zs)\n\nexport\nsplitAfter : (a -> Bool) -> List a -> List1 (List a)\nsplitAfter p xs\n = case breakAfter p xs of\n (chunk, []) => singleton chunk\n (chunk, rest@(_::_)) => cons chunk (splitAfter p (assert_smaller xs rest))\n\nexport\nzipMaybe : List a -> List b -> Maybe (List (a, b))\nzipMaybe [] [] = pure []\nzipMaybe (a::as) (b::bs) = ((a, b) ::) <$> zipMaybe as bs\nzipMaybe _ _ = Nothing\n\nexport\nfindBy' : (a -> Bool) -> List a -> (List a, Maybe a, List a)\nfindBy' f [] = ([], Nothing, [])\nfindBy' f (x :: xs) =\n case f x of\n True => ([], Just x, xs)\n False =>\n let (pre, mb, post) = findBy' f xs in\n (x :: pre, mb, post)\n\n||| Compute the difference of two lists by the given predicate.\n||| Lists are treated as bags.\nexport\ndiffBy : (a -> a -> Bool)\n -> List a\n -> List a\n -> List a\ndiffBy f [] ys = []\ndiffBy f (x :: xs) ys =\n let whole@(pre, mb, post) = findBy' (f x) ys\n ys' = pre ++ post in\n case mb of\n Just _ => diffBy f xs ys'\n Nothing => x :: diffBy f xs ys'\n\n||| Remove adjacent duplicates\nexport\ndedup : Eq a => List a -> List a\ndedup (a :: xs@(b :: _)) = if a == b then dedup xs else a :: dedup xs\ndedup xs = xs\n\n||| O(n * log(n)). Sort a list and remove duplicates\nexport\nsortedNub : Ord a => List a -> List a\nsortedNub = dedup . sort\n\n||| TODO: use the version in `Data.List1` in base after the next release.\nexport\ngroupBy : (a -> a -> Bool) -> List a -> List (List1 a)\ngroupBy _ [] = []\ngroupBy eq (h :: t) = let (ys,zs) = go h t\n in ys :: zs\n\n where go : a -> List a -> (List1 a, List (List1 a))\n go v [] = (singleton v,[])\n go v (x :: xs) = let (ys,zs) = go x xs\n in if eq v x\n then (cons v ys, zs)\n else (singleton v, ys :: zs)\n\n||| TODO: use the version in `Data.List1` in base after the next release.\nexport\ngroup : Eq a => List a -> List (List1 a)\ngroup = Libraries.Data.List.Extra.groupBy (==)\n\n||| TODO: use the version in `Data.List1` in base after the next release.\nexport\ngroupWith : Eq b => (a -> b) -> List a -> List (List1 a)\ngroupWith f = Libraries.Data.List.Extra.groupBy (\\x,y => f x == f y)\n\n||| TODO: use the version in `Data.List1` in base after the next release.\nexport\ngroupAllWith : Ord b => (a -> b) -> List a -> List (List1 a)\ngroupAllWith f = Libraries.Data.List.Extra.groupWith f . sortBy (comparing f)\n", "meta": {"hexsha": "135cbbef61201905a0469b1d576f66354108d8da", "size": 3281, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/src/Libraries/Data/List/Extra.idr", "max_stars_repo_name": "chrrasmussen/Idris2-Erlang", "max_stars_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 128, "max_stars_repo_stars_event_min_datetime": "2020-06-09T21:25:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:50:24.000Z", "max_issues_repo_path": "idris2/src/Libraries/Data/List/Extra.idr", "max_issues_repo_name": "chrrasmussen/Idris2-Erlang", "max_issues_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2020-08-26T03:38:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-23T21:32:49.000Z", "max_forks_repo_path": "idris2/src/Libraries/Data/List/Extra.idr", "max_forks_repo_name": "chrrasmussen/Idris2-Erlang", "max_forks_repo_head_hexsha": "dfa38cd866fd683d4bdda49fc0bf2f860de273b4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 8, "max_forks_repo_forks_event_min_datetime": "2020-08-28T04:16:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-20T12:47:16.000Z", "avg_line_length": 29.0353982301, "max_line_length": 85, "alphanum_fraction": 0.561414203, "num_tokens": 1012, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.504479495001595}} {"text": "\nimport Data.Vect\n\n\nvtake : (n : Nat) -> Vect (n+m) a -> Vect n a \nvtake Z xs = []\nvtake (S k) (x :: xs) = x :: vtake k xs\n\n\nnumbers : Vect 3 Int\nnumbers = [1,2,3]\n\nmain : IO ()\nmain = printLn ( vtake 3 numbers ) \n", "meta": {"hexsha": "a0436fcaee059c89fe231047a950dd1d15987f2d", "size": 214, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "vtake_solution.idr", "max_stars_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_stars_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "vtake_solution.idr", "max_issues_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_issues_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_issues_repo_licenses": ["Apache-2.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "vtake_solution.idr", "max_forks_repo_name": "janschultecom/2019-02-21-coding-for-students", "max_forks_repo_head_hexsha": "3e19cb95afa939ef0803ae2a41150ea83edd9d52", "max_forks_repo_licenses": ["Apache-2.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.2666666667, "max_line_length": 46, "alphanum_fraction": 0.5514018692, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.5042554801443502}} {"text": "module Main\n\nimport Data.So\n\ntotal\nlem1 : So x -> So (not x) -> Void\nlem1 Oh Oh impossible\n\nfoo : Nat -> Int\nfoo z = 94\n where\n lem2 : So x -> So (not x) -> Void\n lem2 Oh Oh impossible\n", "meta": {"hexsha": "33a200e6b17d3e349bcc4ad5dd0a11c7f32b1633", "size": 192, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/reg027/pwhere.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/reg027/pwhere.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/reg027/pwhere.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 13.7142857143, "max_line_length": 37, "alphanum_fraction": 0.609375, "num_tokens": 66, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5042108188463422}} {"text": "-- --------------------------------------------------------------- [ PList.idr ]\n-- Module : PList.idr\n-- Copyright : (c) 2015,2016 See CONTRIBUTORS.md\n-- License : see LICENSE\n-- --------------------------------------------------------------------- [ EOH ]\n||| A `list` construct to create lists with with values that satisfy\n||| some predicate..\n|||\n||| The list quantifier `All` in idris is an external proof for a list\n||| with type `List a`. `PList` is a proof-carrying data structure\n||| that only allows for lists to be constructed if they satisfy the\n||| predicate.\nmodule Data.PList\n\nimport public Data.List\nimport public Data.DList\n\n%access export\n%default total\n\npublic export\ndata PList : (aTy : Type)\n -> (elemTy : aTy -> Type)\n -> (predTy : aTy -> Type)\n -> (as : List aTy)\n -> (prf : DList aTy predTy as)\n -> Type\n where\n ||| Create an empty List\n Nil : PList aTy elemTy predTy Nil Nil\n\n ||| Cons\n |||\n ||| @elem The element to add and proof that the element's type satisfies a certain predicate.\n ||| @rest The list for `elem` to be added to.\n (::) : (elem : elemTy x)\n -> {prf : predTy x}\n -> (rest : PList aTy elemTy predTy xs prfs)\n -> PList aTy elemTy predTy (x :: xs) (prf :: prfs)\n\n(++) : PList aTy eTy pTy as pAs\n -> PList aTy eTy pTy bs pBs\n -> PList aTy eTy pTy (as ++ bs) (pAs ++ pBs)\n(++) [] ys = ys\n(++) (elem :: rest) ys = elem :: rest ++ ys\n\nempty : PList aTy eTy pTy Nil Nil\nempty = Nil\n\nadd : (elem : elemTy x)\n -> {auto prf : predTy x}\n -> (rest : PList aTy elemTy predTy xs prfs)\n -> PList aTy elemTy predTy (x :: xs) (prf :: prfs)\nadd x {prf} rest = x :: rest\n\n-- -------------------------------------------------------------- [ Form Tests ]\nisNil : PList aTy eTy p as prfs -> Bool\nisNil [] = True\nisNil (elem :: rest) = False\n\nisCons : PList aTy eTy p as prfs -> Bool\nisCons l = isNil l == False\n\n-- ------------------------------------------------------------------ [ Length ]\n\nlength : PList aTy eTy p as prfs -> Nat\nlength Nil = Z\nlength (x::xs) = (S Z) + length xs\n\nSized (PList aTy eTy pTy as prfs) where\n size = length\n\neqPList : ({a,b : aTy} -> elemTy a -> elemTy b -> Bool)\n -> PList aTy elemTy predTy as aPrfs\n -> PList aTy elemTy predTy bs bPrfs\n -> Bool\neqPList _ Nil Nil = True\neqPList p (x::xs) (y::ys) =\n if p x y\n then eqPList p xs ys\n else False\neqPList _ _ _ = False\n\n\n-- ---------------------------------------------- [ List-Based Transformations ]\n\ntoDList : PList aTy eTy p as prfs -> DList aTy eTy as\ntoDList Nil = Nil\ntoDList (elem::xs) = elem :: toDList xs\n\ntoList : PList aTy eTy pTy as prfs -> List (a : aTy ** prf : pTy a ** eTy a)\ntoList [] = []\ntoList ((::) elem {x} {prf} rest) = (x ** prf ** elem) :: toList rest\n\nfromDList : (xs : DList aTy eTy as)\n -> (prfs : DList aTy pTy as)\n -> PList aTy eTy pTy as prfs\nfromDList [] [] = []\nfromDList (elem :: rest) (prf :: prfs) = elem :: fromDList rest prfs\n\nfromList : (prf : predTy a)\n -> (xs : List $ elemTy a)\n -> PList aTy elemTy predTy (replicate (length xs) a)\n (replicate (length xs) prf)\nfromList prf [] = []\nfromList prf (x :: xs) = x :: fromList prf xs\n\n-- ---------------------------------------------------------------- [ Indexing ]\n\npublic export\ndata NonEmpty : (xs : PList aTy eTy pTy as prfs) -> Type where\n IsNonEmpty : PList.NonEmpty (x::rest)\n\nUninhabited (PList.NonEmpty []) where\n uninhabited IsNonEmpty impossible\n\nnonEmpty : (xs : PList aTy eTy pTy as prfs) -> Dec (NonEmpty xs)\nnonEmpty [] = No absurd\nnonEmpty (elem :: rest) = Yes IsNonEmpty\n\npublic export\ndata InBounds : (idx : Nat)\n -> (xs : PList aTy eTy pTy as prfs)\n -> Type\n where\n InFirst : PList.InBounds Z (x::rest)\n InLater : (later : PList.InBounds idx rest)\n -> PList.InBounds (S idx) (x::rest)\n\nUninhabited (PList.InBounds idx []) where\n uninhabited InFirst impossible\n uninhabited (InLater _) impossible\n\ninBounds : (idx : Nat)\n -> (xs : PList aTy eTy pTy as prfs)\n -> Dec (InBounds idx xs)\ninBounds idx Nil = No uninhabited\ninBounds Z (elem :: rest) = Yes InFirst\ninBounds (S k) (elem :: rest) with (inBounds k rest)\n inBounds (S k) (elem :: rest) | (Yes prf) = Yes $ InLater prf\n inBounds (S k) (elem :: rest) | (No contra) =\n No (\\p => case p of\n InLater y => contra y)\n\nindex : (idx : Nat)\n -> (xs : PList aTy eTy pTy as prfs)\n -> {auto ok : InBounds idx xs}\n -> {auto ok' : InBounds idx as}\n -> {auto ok'' : InBounds idx prfs}\n -> eTy (index idx as)\nindex Z (y :: rest) {ok = InFirst} = y\nindex (S k) (y :: rest) {ok = (InLater later)} {ok' = (InLater later')} {ok'' = (InLater later'')} = PList.index k rest\n\nhead : (xs : PList aTy eTy pTy (a::as) prfs)\n -> {auto ok : NonEmpty xs}\n -> {auto ok' : NonEmpty (a::as)}\n -> {auto ok'' : NonEmpty prfs}\n -> eTy a\nhead (elem :: rest) = elem\n\ntail : (xs : PList aTy eTy pTy (a::as) (p::prfs))\n -> {auto ok : NonEmpty xs}\n -> {auto ok' : NonEmpty (a::as)}\n -> {auto ok'' : NonEmpty (p::prfs)}\n -> PList aTy eTy pTy as prfs\ntail (elem :: rest) = rest\n\nlast : (xs : PList aTy eTy pTy as prfs)\n -> {auto ok : NonEmpty xs}\n -> {auto ok' : NonEmpty as}\n -> {auto ok'' : NonEmpty prfs}\n -> eTy (last as)\nlast [] {ok = IsNonEmpty} impossible\nlast (elem :: []) {ok = ok} {ok' = ok'} {ok'' = ok''} = elem\nlast (elem :: ((::) {prf} y rest)) {ok = ok} {ok' = ok'} {ok'' = ok''} = last $ (::) y rest {prf=prf}\n\ninit : (xs : PList aTy eTy pTy as prfs)\n -> {auto ok : NonEmpty xs}\n -> {auto ok' : NonEmpty as}\n -> {auto ok'' : NonEmpty prfs}\n -> PList aTy eTy pTy (init as) (init {ok=ok''} prfs)\ninit (y :: []) {ok = IsNonEmpty} {ok' = IsNonEmpty} {ok'' = IsNonEmpty} = []\ninit (y :: ((::) {prf} elem rest)) {ok = IsNonEmpty} {ok' = IsNonEmpty} {ok'' = IsNonEmpty} = y :: init (elem :: rest)\n\npublic export\ndata Elem : (aTy : Type)\n -> (elemTy : aTy -> Type)\n -> (predTy : aTy -> Type)\n -> (a : aTy)\n -> (x : elemTy a)\n -> (prf : predTy a)\n -> (xs : PList aTy elemTy predTy as prfs)\n -> (prfA : Elem a as)\n -> (prfP : DElem aTy predTy prf prfs prfA)\n -> Type\n where\n Hier : PList.Elem aTy eTy pTy a x p (x::xs) Here Hier\n Er : (rest : PList.Elem aTy eTy pTy a x p xs prfA prfP)\n -> PList.Elem aTy eTy pTy a x p (x'::xs) (There prfA) (DList.Er prfP)\n\nUninhabited (PList.Elem aTy eTy pTy a x prf Nil prfA prfP) where\n uninhabited Hier impossible\n uninhabited (Er _) impossible\n\ndropElem : (as : PList iTy elemTy predTy is prfs)\n -> (idxP : Elem iTy elemTy predTy i e prf as prfA prfP)\n -> PList iTy elemTy predTy (dropElem is prfA) (dropElem prfs prfP)\ndropElem (e :: x) Hier = x\ndropElem (x :: z) (Er rest) = x :: dropElem z rest\n\ndelete' : (x : elemTy i)\n -> (xs : PList iTy elemTy predTy is prfs)\n -> (idxVal : Elem i is)\n -> (idxPrf : DElem iTy predTy prf prfs idxVal)\n -> PList iTy elemTy predTy (dropElem is idxVal) (dropElem prfs idxPrf)\ndelete' x (elem :: rest) Here Hier = rest\ndelete' x (elem :: rest) (There later) (Er komst) = elem :: delete' x rest later komst\n\ndelete : (x : elemTy i)\n -> (xs : PList iTy elemTy predTy is prfs)\n -> {auto idxVal : Elem i is}\n -> {auto idxPrf : DElem iTy predTy prf prfs idxVal}\n -> PList iTy elemTy predTy (dropElem is idxVal) (dropElem prfs idxPrf)\ndelete x xs {idxVal} {idxPrf} = delete' x xs idxVal idxPrf\n\n\n-- --------------------------------------------------------- [ Bob The Builder ]\n\n-- TODO append\n-- TODO replicate\n\n-- ---------------------------------------------------------------- [ SubLists ]\n\ntake : (n : Nat)\n -> (xs : PList aTy elemTy predTy as prfs)\n -> PList aTy elemTy predTy (take n as) (take n prfs)\ntake Z xs = Nil\ntake (S k) [] = Nil\ntake (S k) (elem :: rest) = elem :: take k rest\n\n-- TODO takeWhile\n\n-- TODO drop\ndrop : (n : Nat)\n -> (xs : PList aTy elemTy predTy as prfs)\n -> PList aTy elemTy predTy (drop n as) (drop n prfs)\ndrop Z rest = rest\ndrop (S k) [] = Nil\ndrop (S k) (elem :: rest) = drop k rest\n\n-- TODO dropWhile\n\n-- ---------------------------------------------------------------- [ Equality ]\n-- TODO eqPList\n\n-- ------------------------------------------------------------------- [ Order ]\n-- TODO cmpPList\n\n-- ----------------------------------------------------------------- [ Folding ]\n-- TODO foldr and foldl\nfoldr : ({a : aTy} -> elemTy a -> p -> p)\n -> p\n -> PList aTy elemTy predTy as prfs\n -> p\nfoldr f init Nil = init\nfoldr f init (x::xs) = f x (PList.foldr f init xs)\n\nfoldl : ({a : aTy} -> p -> elemTy a -> p)\n -> p\n -> PList aTy elemTy predTy as prfs\n -> p\nfoldl f init Nil = init\nfoldl f init (x::xs) = PList.foldl f (f init x) xs\n\n-- ----------------------------------------------------------------- [ Functor ]\n\nmap : ({a : aTy} -> elemTy a -> b)\n -> PList aTy elemTy predTy as prf\n -> List b\nmap f Nil = List.Nil\nmap f (x::xs) = with List f x :: map f xs\n\n\nmapMaybe : ({a : aTy} -> elemTy a -> Maybe b)\n -> PList aTy elemTy predTy as prfs\n -> List b\nmapMaybe f Nil = Nil\nmapMaybe f (x::xs) =\n case f x of\n Nothing => mapMaybe f xs\n Just y => y :: mapMaybe f xs\n\nconcatMap : Monoid m\n => (func : {a : aTy} -> elemTy a -> m)\n -> (xs : PList aTy elemTy predTy as prfs)\n -> m\nconcatMap f = foldr (\\e, res => f e <+> res) neutral\n\n\n-- -------------------------------------------------------- [ Membership Tests ]\n-- TODO make deceq tests\n-- TODO any\n-- TODO all\n-- TODO elemBy\n-- TODO elem\n-- TODO hasAnyBy\n-- TODO hasAny\n\n-- --------------------------------------------------------------- [ Searching ]\n\n-- TODO find\n\n-- ------------------------------------------------------------- [ Conversions ]\n-- TODO\n\n-- ----------------------------------------------------------------- [ Filters ]\n-- TODO\n\n-- ------------------------------------------------------------ [ Partitioning ]\n-- TODO\n\n-- ----------------------------------------------------------------- [ Zipping ]\n-- TODO\n\n-- -------------------------------------------------------------- [ Predicates ]\n-- TODO\n\n-- ----------------------------------------------------------------- [ Sorting ]\n-- TODO\n\n-- -------------------------------------------------------------------- [ Show ]\n\nprivate\ndoPListShow : ({a : aTy} -> elemTy a -> String)\n -> PList aTy elemTy predTy as prfs\n -> List String\ndoPListShow _ Nil = Nil\ndoPListShow f (x::xs) = (f x) :: doPListShow f xs\n\nshowPList : (showFunc : {a : aTy} -> elemTy a -> String)\n -> (l : PList aTy elemTy predTy as prfs)\n -> String\nshowPList f xs = \"[\" ++ unwords (intersperse \",\" (doPListShow f xs)) ++ \"]\"\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "20ec1b781d3855c74c579f4037b1c59b59277f24", "size": 11092, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/PList.idr", "max_stars_repo_name": "MarcelineVQ/idris-containers", "max_stars_repo_head_hexsha": "3cca9329e5eaa04a98fc3ab521986b8d3c035567", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Data/PList.idr", "max_issues_repo_name": "MarcelineVQ/idris-containers", "max_issues_repo_head_hexsha": "3cca9329e5eaa04a98fc3ab521986b8d3c035567", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Data/PList.idr", "max_forks_repo_name": "MarcelineVQ/idris-containers", "max_forks_repo_head_hexsha": "3cca9329e5eaa04a98fc3ab521986b8d3c035567", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-05-19T12:29:49.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T12:29:49.000Z", "avg_line_length": 32.0578034682, "max_line_length": 119, "alphanum_fraction": 0.4940497656, "num_tokens": 3406, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.5039227978198874}} {"text": "import System\nimport Data.List.Views\n\ndata Palindrome : List a -> Type where\n PNil : Palindrome []\n POne : Palindrome [x]\n PRec : Palindrome xs -> Palindrome (x :: xs ++ [x])\n\ntotal\npalindrome : DecEq a => (xs : List a) -> Maybe (Palindrome xs)\npalindrome xs with (vList xs)\n palindrome [] | VNil = Just PNil\n palindrome [x] | VOne = Just POne\n palindrome (x :: (ys ++ [y])) | (VCons z) with (decEq x y)\n palindrome (y :: (ys ++ [y])) | (VCons urec) | (Yes Refl)\n = case palindrome ys | urec of\n Nothing => Nothing\n Just x => Just (PRec x)\n palindrome (x :: (ys ++ [y])) | (VCons z) | (No contra)\n = Nothing\n\npalinBool : DecEq a => List a -> Bool\npalinBool xs = case palindrome xs of\n Nothing => False\n Just _ => True\n\nmain : IO ()\nmain = do getArgs >>= printLn\n [_, num] <- getArgs\n let list = replicate (cast num) 'a'\n printLn (palinBool list)\n\n", "meta": {"hexsha": "c89c5ad7da7707409a2eb402e71c90028ee58982", "size": 971, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/views003/views003.idr", "max_stars_repo_name": "grin-compiler/idris-grin", "max_stars_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 36, "max_stars_repo_stars_event_min_datetime": "2019-06-06T10:35:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T08:48:30.000Z", "max_issues_repo_path": "test/idris-dev/views003/views003.idr", "max_issues_repo_name": "grin-compiler/idris-grin", "max_issues_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 4, "max_issues_repo_issues_event_min_datetime": "2019-11-21T20:45:22.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T12:29:23.000Z", "max_forks_repo_path": "test/idris-dev/views003/views003.idr", "max_forks_repo_name": "grin-compiler/idris-grin", "max_forks_repo_head_hexsha": "0514e4d41933143223cb685e23f450dcbf3d5593", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-06-14T13:14:47.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-07T06:20:45.000Z", "avg_line_length": 29.4242424242, "max_line_length": 62, "alphanum_fraction": 0.5478887745, "num_tokens": 282, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245787544825, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.5032712409361064}} {"text": "module Fractions\n\n%default total\n\nrecord Fraction : Type where\n F : (top : Nat) -> (bottom : Nat) -> Fraction\n \ncorecord Tree : Type -> Type where\n value : Tree a -> a\n left : Tree a -> Tree a\n right : Tree a -> Tree a\n constructor MkTree\n \nfracSum : Fraction -> Nat\nfracSum (F top bottom) = top + bottom\n\nleftFrac : Fraction -> Fraction\nleftFrac f = F (top f) (fracSum f)\n\nrightFrac : Fraction -> Fraction\nrightFrac f = F (fracSum f) (bottom f)\n\ntotal causal flattenTree : Tree a -> Stream a\nflattenTree t = ft []\n where\n total causal ft : List (Tree a) -> Stream a\n ft [] = (value t) :: (ft [left t, right t])\n ft (tree :: xs) = (value tree) :: (ft (xs ++ [left tree, right tree]))\n \ntotal causal rationalTree : Tree Fraction\nrationalTree = rt $ F (S Z) (S Z)\n where\n total causal rt : Fraction -> Tree Fraction\n rt f = MkTree f (rt $ leftFrac f) (rt $ rightFrac f)\n\n--total causal rationals : Stream Fraction\n--rationals = flattenTree $ rationalTree\n", "meta": {"hexsha": "37170e34b4af0e6bec4f15d819d67d9c3f204ef6", "size": 984, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "examples/Fractions.idr", "max_stars_repo_name": "sualitu/thesis", "max_stars_repo_head_hexsha": "22d2cb4f21dc7c2dab011da5bb560c003650a2bc", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/Fractions.idr", "max_issues_repo_name": "sualitu/thesis", "max_issues_repo_head_hexsha": "22d2cb4f21dc7c2dab011da5bb560c003650a2bc", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/Fractions.idr", "max_forks_repo_name": "sualitu/thesis", "max_forks_repo_head_hexsha": "22d2cb4f21dc7c2dab011da5bb560c003650a2bc", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8947368421, "max_line_length": 74, "alphanum_fraction": 0.6392276423, "num_tokens": 292, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.502988983068436}} {"text": "import Data.List\nimport Data.Nat\nimport Data.SortedMap\nimport Control.Monad.State\nimport Control.Monad.State.State\nimport Control.Monad.State.Interface\n\nrecord Player where\n constructor MkPlayer\n score : Nat\n pos : Nat\n\nEq Player where\n p1 == p2 = p1.score == p2.score && p1.pos == p2.pos\n\nOrd Player where\n compare p1 p2 = compare (p1.score, p1.pos) (p2.score, p2.pos)\n\ndata Turn = P1 | P2\n\nEq Turn where\n P1 == P1 = True\n P2 == P2 = True\n _ == _ = False\n\nOrd Turn where\n compare P1 P1 = EQ\n compare P1 P2 = LT\n compare P2 P1 = GT\n compare P2 P2 = EQ\n\nnext : Turn -> Turn\nnext P1 = P2\nnext P2 = P1\n\nrecord Game where\n constructor MkGame\n player1, player2 : Player\n turn : Turn\n rolls : Nat\n\nfromStart : Nat -> Nat -> Game\nfromStart p1 p2 = MkGame (MkPlayer 0 p1) (MkPlayer 0 p2) P1 0\n\nscore : Game -> Nat\nscore (MkGame p1 p2 _ rolls) = (*) rolls $ max p1.score p2.score\n\nrollDet : State Game Nat\nrollDet = do rolls <- gets (.rolls)\n modify { rolls $= S }\n pure $ 1 + (modNatNZ rolls 100 SIsNonZero)\n\nmovePlayer : Nat -> Player -> Player\nmovePlayer m (MkPlayer score pos) = let npos = (modNatNZ (pos + m) 10 SIsNonZero) in\n MkPlayer (score + npos + 1) npos\n\nplayDet : State Game ()\nplayDet = do rolls <- sequence $ replicate 3 rollDet\n let r = sum rolls\n turn <- gets (.turn)\n case turn of\n P1 => modify { player1 $= movePlayer r }\n P2 => modify { player2 $= movePlayer r }\n s1 <- gets (.player1.score)\n s2 <- gets (.player2.score)\n if s1 >= 1000 || s2 >= 1000\n then pure ()\n else modify { turn $= next } *> playDet\n\npart1 : Game -> IO String\npart1 a = do let g = execState a playDet\n pure $ show $ score g\n\n\nMemoize : Type\nMemoize = SortedMap (Player, Player, Turn) (Nat, Nat)\n\naddPair : Num a => (a, a) -> (a, a) -> (a, a)\naddPair (x, y) (z, w) = (x + z, y + w)\n\nwins : Player -> Bool\nwins (MkPlayer score pos) = score >= 21\n\nplayDirac : Nat -> Memoize -> Game -> ((Nat, Nat), Memoize)\nplayDirac _ m (MkGame p1 p2 turn 0) = case lookup (p1, p2, turn) m of\n (Just w) => (w, m)\n Nothing => let (w, m) = foldl (\\(w, m) => \\d => mapFst (addPair w) $ playDirac d m (MkGame p1 p2 turn 1)) ((0, 0), m) $ [1,2,3] in\n (w, insert (p1, p2, turn) w m)\nplayDirac s m (MkGame p1 p2 P1 3) = let p1' = movePlayer s p1 in\n if wins p1'\n then ((1, 0), m)\n else playDirac 0 m (MkGame p1' p2 P2 0)\nplayDirac s m (MkGame p1 p2 P2 3) = let p2' = movePlayer s p2 in\n if wins p2'\n then ((0, 1), m)\n else playDirac 0 m (MkGame p1 p2' P1 0)\nplayDirac s m (MkGame p1 p2 turn r) = foldl (\\(w, m) => \\d => mapFst (addPair w) $ playDirac (s + d) m (MkGame p1 p2 turn (1 + r))) ((0, 0), m) $ [1,2,3]\n\npart2 : Game -> IO String\npart2 a = do let (wins, _) = playDirac 0 empty a\n pure $ show $ (uncurry max) wins\n\n\nmain : IO ()\nmain = do let g = fromStart 2 9\n part1 g >>= putStrLn\n part2 g >>= putStrLn\n\n", "meta": {"hexsha": "6b39b2f9e67f6ec28364a9d3584c3f35456e25df", "size": 3420, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "21/Main.idr", "max_stars_repo_name": "Olavhaasie/aoc-2021", "max_stars_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "21/Main.idr", "max_issues_repo_name": "Olavhaasie/aoc-2021", "max_issues_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "21/Main.idr", "max_forks_repo_name": "Olavhaasie/aoc-2021", "max_forks_repo_head_hexsha": "0a0b293bd9c41da785f4a1a0207a72a823944b1c", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 31.376146789, "max_line_length": 173, "alphanum_fraction": 0.5131578947, "num_tokens": 1075, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.5029863915077337}} {"text": "-- Idris implementation of a type-correct, stack-safe\n-- compiler including exception handling.\n--\n-- Morten S. Knudsen, Jeppe Vinberg, Francisco M. Lasaca\n\nimport Data.List\n\n%default total\n\ndata TyExp = NatTy | BoolTy\n\nVariableId : Type\nVariableId = String\n\nmutual\n StackType : Type\n StackType = List Ty\n\n HeapType : Type\n HeapType = List (VariableId, TyExp)\n\n data Ty = Han StackType StackType HeapType HeapType | Val TyExp\n\ndata V : TyExp -> Type where\n VNat : Nat -> V NatTy\n VBool : Bool -> V BoolTy\n\ndata Exp : Bool -> TyExp -> List (VariableId, TyExp) -> Type where\n VarExp : (vId : VariableId) -> {auto p : Elem (vId, ty) env} -> Exp False ty env\n SingleExp : (v : V t) -> Exp False t env\n PlusExp : (x : Exp a NatTy env) -> (y : Exp b NatTy env) -> Exp (a || b) NatTy env\n IfExp : (cond : Exp a BoolTy env) -> (x : Exp b t env) -> (y : Exp c t env) -> Exp (a || b || c) t env\n ThrowExp : Exp True t env\n CatchExp : (x : Exp a t env) -> (h : Exp b t env) -> Exp (a && b) t env\n\ndata Program : List (VariableId, TyExp) -> List (VariableId, TyExp) -> Type where\n EmptyProgram : Program env env\n Declaration : (vId : VariableId) ->\n (exp : Exp b t env) ->\n {auto expExecutable : b = False} ->\n (continuing : Program ((vId, t) :: env) env') ->\n (Program env env')\n Assignment : (vId : VariableId) ->\n (exp : Exp b t env) ->\n {auto expExecutable : b = False} ->\n (continuing : Program ((vId, t) :: env) env') ->\n {auto prf' : Elem (vId, t) env} ->\n (Program env env')\n\ndata ValuesEnv : List (VariableId, TyExp) -> Type where\n EmptyValuesEnv : ValuesEnv []\n MoreValuesEnv : (vId: VariableId) -> V ty -> ValuesEnv envTy\n -> ValuesEnv ((vId, ty) :: envTy)\n\nmutual\n evalVarExp : (x : ValuesEnv tEnv) -> (p : Elem (vId, ty) tEnv) -> V ty\n evalVarExp (MoreValuesEnv _ val _) Here = val\n evalVarExp (MoreValuesEnv _ _ valueEnv) (There later) = evalVarExp valueEnv later\n\n evalPlusExp : (x : Exp a NatTy tEnv) -> (y : Exp b NatTy tEnv) -> (valuesEnv : ValuesEnv tEnv) -> (prf : (a || (Delay b)) = False) -> V NatTy\n evalPlusExp x y valuesEnv prf {a = False} {b = False} =\n case eval x valuesEnv of\n (VNat x') => case eval y valuesEnv of\n (VNat y') => VNat (x' + y')\n evalPlusExp _ _ _ Refl {a = False} {b = True} impossible\n evalPlusExp _ _ _ Refl {a = True} {b = _} impossible\n\n evalIfExp : (cond : Exp a BoolTy tEnv) -> (x : Exp b t tEnv) -> (y : Exp c t tEnv) -> (valuesEnv : ValuesEnv tEnv) -> (prf : (a || (Delay (b || (Delay c)))) = False) -> V t\n evalIfExp cond x y valuesEnv prf {a = False} {b = False} {c = False} =\n case eval cond valuesEnv of\n VBool True => eval x valuesEnv\n VBool False => eval y valuesEnv\n evalIfExp _ _ _ _ Refl {a = False} {b = False} {c = True} impossible\n evalIfExp _ _ _ _ Refl {a = False} {b = False} {c = True} impossible\n evalIfExp _ _ _ _ Refl {a = True} {b = _} {c = _} impossible\n\n evalCatchExp : (x : Exp a t tEnv) -> (h : Exp b t tEnv) -> (valuesEnv : ValuesEnv tEnv) ->(prf : (a && (Delay b)) = False) -> V t\n evalCatchExp x h valuesEnv prf {a = False} = eval x valuesEnv\n evalCatchExp x h valuesEnv prf {a = True} {b = False} = eval h valuesEnv\n evalCatchExp _ _ _ Refl {a = True} {b = True} impossible\n\n eval : (e : Exp b t tEnv) -> (valuesEnv : ValuesEnv tEnv) -> {auto prf : b = False} -> V t\n eval (VarExp vId {p}) valuesEnv = evalVarExp valuesEnv p\n eval (SingleExp v) valuesEnv = v\n eval (PlusExp x y) valuesEnv {prf} = evalPlusExp x y valuesEnv prf\n eval (IfExp cond x y) valuesEnv {prf} = evalIfExp cond x y valuesEnv prf\n eval ThrowExp _ {prf = Refl} impossible\n eval (CatchExp x h) valuesEnv {prf}= evalCatchExp x h valuesEnv prf\n\nevPro : (p : Program env env') -> (valueEnv : ValuesEnv env) -> ValuesEnv env'\nevPro EmptyProgram valueEnv = valueEnv\nevPro (Declaration vId exp continuing) valueEnv =\n let evaluated = eval exp valueEnv in\n evPro continuing (MoreValuesEnv vId evaluated valueEnv)\nevPro (Assignment vId exp continuing) valueEnv =\n let evaluated = eval exp valueEnv in\n evPro continuing (MoreValuesEnv vId evaluated valueEnv)\nevalProgram : (p : Program [] env') -> ValuesEnv env'\nevalProgram p = evPro p EmptyValuesEnv\n\nmutual\n El : Ty -> Type\n El (Han t t' h h') = Code t t' h h'\n El (Val NatTy) = Nat\n El (Val BoolTy) = Bool\n\n data Code : (s : StackType) -> (s' : StackType) -> (h: HeapType) -> (h': HeapType) -> Type where\n STORE : (vId: VariableId) -> (c: Code s s' ((vId, ty)::h) h') -> Code ((Val ty)::s) s' h h'\n LOAD : (vId: VariableId) -> {auto prf: Elem (vId, ty) h} -> (c: Code ((Val ty)::s) s' h h') -> Code s s' h h'\n PUSH : V tyExp -> Code (Val tyExp :: s) s' h h' -> Code s s' h h'\n ADD : Code (Val NatTy :: s) s' h h' -> Code (Val NatTy :: Val NatTy :: s) s' h h'\n IF : (c1 : Code s s' h h') -> (c2 : Code s s' h h') -> Code (Val BoolTy :: s) s' h h'\n THROW : Code (s'' ++ (Han s s' h h') :: s) s' h h'\n MARK : (han : Code s s' h h') -> (c : Code ((Han s s' h h') :: s) s' h h') -> Code s s' h h'\n UNMARK : Code (t :: s) s' h h' -> Code (t :: (Han s s' h h') :: s) s' h h'\n HALT : Code s s h h\n\nmutual\n compCatch : Exp b ty tenv -> Code (Val ty :: (s'' ++ (Han s s' tenv h') :: s)) s' tenv h' -> Code (s'' ++ (Han s s' tenv h') :: s) s' tenv h'\n compCatch (VarExp vId) c = LOAD vId c\n compCatch (SingleExp v) c = PUSH v c\n compCatch (PlusExp x y) c = compCatch x (compCatch {s'' = Val NatTy :: _} y (ADD c))\n compCatch {s} {s''} (IfExp cond x y) c = compCatch cond (IF (compCatch x c) (compCatch y c))\n compCatch ThrowExp c = THROW\n compCatch (CatchExp x h) c = MARK (compCatch h c) (compCatch {s'' = []} x (UNMARK c))\n\n compPlusExp : (p : (a || b) = False) -> (x : Exp a NatTy tenv) -> (y : Exp b NatTy tenv) -> (c : Code ((Val NatTy) :: s) s' tenv h') -> Code s s' tenv h'\n compPlusExp {a = False} {b = False} Refl x y c = comp Refl x (comp Refl y (ADD c))\n compPlusExp {a = False} {b = True} Refl _ _ _ impossible\n compPlusExp {a = True} {b = _} Refl _ _ _ impossible\n\n compCatchExp : (p : (a && b) = False) -> (x : Exp a ty tenv) -> (handler : Exp b ty tenv) -> (c : Code ((Val ty) :: s) s' tenv h') -> Code s s' tenv h'\n compCatchExp {a = False} Refl x handler c = comp Refl x c\n compCatchExp {a = True} {b = False} p x handler c = MARK (comp Refl handler c) (compCatch {s'' = []} x (UNMARK c))\n compCatchExp {a = True} {b = True} Refl _ _ _ impossible\n\n compIfExp : (p : (a || b || c) = False) -> (cond : Exp a BoolTy tenv) ->(x : Exp b ty tenv) -> (y : Exp c ty tenv) -> (co : Code ((Val ty) :: s) s' tenv h') -> Code s s' tenv h'\n compIfExp {a = False} {b = False} {c = False} Refl cond x y co = comp Refl cond (IF (comp Refl x co) (comp Refl y co))\n compIfExp {a = False} {b = False} {c = True} Refl _ _ _ _ impossible\n compIfExp {a = False} {b = False} {c = True} Refl _ _ _ _ impossible\n compIfExp {a = True} Refl _ _ _ _ impossible\n\n comp : (b = False) -> Exp b ty tenv -> Code (Val ty :: s) s' tenv h' -> Code s s' tenv h'\n comp _ (VarExp {p} vId) {tenv} c = LOAD vId c\n comp p (SingleExp v) c = PUSH v c\n comp p (PlusExp x y) c = compPlusExp p x y c\n comp p (IfExp cond x y) co = compIfExp p cond x y co\n comp p (CatchExp x h) c = compCatchExp p x h c\n comp Refl ThrowExp _ impossible\n\n partial\n compile : (prog: Program tenv tenv') -> Code [] [] tenv tenv'\n compile (Declaration vId exp {expExecutable} continuing) =\n comp expExecutable exp (STORE vId (compile continuing))\n compile (Assignment vId exp {expExecutable} continuing) =\n comp expExecutable exp (STORE vId (compile continuing))\n compile EmptyProgram = HALT\n\ndata Stack : (s : StackType) -> Type where\n Nil : Stack []\n (::) : El t -> Stack s -> Stack (t :: s)\n\ndata Heap : (h : HeapType) -> Type where\n HeapNil : Heap []\n HeapCons : (vId: VariableId) -> V t -> Heap h -> Heap ((vId, t) :: h)\n\nmutual\n\n lookup: Heap h -> (p: Elem (vId, ty) h) -> V ty\n lookup (HeapCons vId val tl) Here = val\n lookup (HeapCons _ _ tl) (There later) = lookup tl later\n\n partial\n exec : Code s s' h h' -> Stack s -> Heap h -> (Stack s', Heap h')\n exec (LOAD {prf} vId c) s h = case lookup h prf of\n (VNat v) => exec c (v :: s) h\n (VBool v) => exec c (v :: s) h\n exec (STORE vId c) {s=(Val NatTy)::_} (x :: tl) h = exec c tl (HeapCons vId (VNat x) h)\n exec (STORE vId c) {s=(Val BoolTy)::_} (x :: tl) h = exec c tl (HeapCons vId (VBool x) h)\n exec (PUSH (VNat x) c) s h = exec c (x :: s) h\n exec (PUSH (VBool x) c) s h = exec c (x :: s) h\n exec (ADD c) (m :: n :: s) h = exec c ((n + m) :: s) h\n exec (IF c1 c2) (True :: s) h = exec c1 s h\n exec (IF c1 c2) (False :: s) h = exec c2 s h\n exec THROW s h = fail s h\n exec (MARK handler c) s h = exec c (handler :: s) h\n exec (UNMARK c) (x :: handler :: s) h = exec c (x :: s) h\n exec HALT s h = (s, h)\n\n partial\n fail : Stack (s'' ++ Han s s' h h' :: s) -> Heap h -> (Stack s', Heap h')\n fail {s'' = []} (handler' :: s) h = exec handler' s h\n fail {s'' = (_ :: _)} (_ :: s) h = fail s h\n\n\n-- Example of an entire program\n-- `entireProgram`\n\n-- x <- 3 -- []\n-- x <- x + 1 -- [x <- 3]\n-- y <- x + 2 -- [x <- 4]\n-- emptyProgram -- [y <- 6, x <- 4]\n\nmyEmpty : Program [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)] [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)]\nmyEmpty = EmptyProgram\n\nyEqualsXPlusTwo : Program [(\"x\", NatTy), (\"x\", NatTy)] [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)]\nyEqualsXPlusTwo = Declaration \"y\" (PlusExp (VarExp \"x\") (SingleExp (VNat 2))) myEmpty\n\nxEqualsXPlusOne : Program [(\"x\", NatTy)] [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)]\nxEqualsXPlusOne = Assignment \"x\" (PlusExp (VarExp \"x\") (SingleExp (VNat 1))) yEqualsXPlusTwo\n\nentireProgram : Program [] [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)]\nentireProgram = Declaration \"x\" (SingleExp (VNat 3)) xEqualsXPlusOne\n\nevaluatedProgram : ValuesEnv [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)]\nevaluatedProgram = evalProgram entireProgram\n\ncompiledProgram : Code [] [] [] [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)]\ncompiledProgram = compile entireProgram\n\npartial\nexecutedProgram : (Stack [], Heap [(\"y\", NatTy), (\"x\", NatTy), (\"x\", NatTy)])\nexecutedProgram = exec (compiledProgram) [] HeapNil\n", "meta": {"hexsha": "6c565b673933ebf7377d93e6e25cf1a6b8279e27", "size": 10312, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "throw.idr", "max_stars_repo_name": "JnxF/idris-epigram", "max_stars_repo_head_hexsha": "a12ef1378b8080549fcd5e6aa259179cdd31639b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "throw.idr", "max_issues_repo_name": "JnxF/idris-epigram", "max_issues_repo_head_hexsha": "a12ef1378b8080549fcd5e6aa259179cdd31639b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "throw.idr", "max_forks_repo_name": "JnxF/idris-epigram", "max_forks_repo_head_hexsha": "a12ef1378b8080549fcd5e6aa259179cdd31639b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 45.8311111111, "max_line_length": 179, "alphanum_fraction": 0.5855314197, "num_tokens": 3667, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.6261241702517976, "lm_q1q2_score": 0.5028865268119512}} {"text": "module Solutions.Predicates\n\nimport Data.Vect\nimport Decidable.Equality\n\n%default total\n\n--------------------------------------------------------------------------------\n-- Preconditions\n--------------------------------------------------------------------------------\n\ndata NonEmpty : (as : List a) -> Type where\n IsNonEmpty : NonEmpty (h :: t)\n\n-- 1\n\ntail : (as : List a) -> (0 _ : NonEmpty as) => List a\ntail (_ :: xs) = xs\ntail [] impossible\n\n-- 2\n\nconcat1 : Semigroup a => (as : List a) -> (0 _ : NonEmpty as) => a\nconcat1 (h :: t) = foldl (<+>) h t\n\nfoldMap1 : Semigroup m => (a -> m) -> (as : List a) -> (0 _ : NonEmpty as) => m\nfoldMap1 f (h :: t) = foldl (\\x,y => x <+> f y) (f h) t\n\n-- 3\n\nmaximum : Ord a => (as : List a) -> (0 _ : NonEmpty as) => a\nmaximum (x :: xs) = foldl max x xs\n\nminimum : Ord a => (as : List a) -> (0 _ : NonEmpty as) => a\nminimum (x :: xs) = foldl min x xs\n\n-- 4\n\ndata Positive : Nat -> Type where\n IsPositive : Positive (S n)\n\nsaveDiv : (m,n : Nat) -> (0 _ : Positive n) => Nat\nsaveDiv m (S k) = go 0 m k\n where go : (res, rem, sub : Nat) -> Nat\n go res 0 _ = res\n go res (S rem) 0 = go (res + 1) rem k\n go res (S rem) (S x) = go res rem x\n\n-- 5\n\ndata IJust : Maybe a -> Type where\n ItIsJust : IJust (Just v)\n\nUninhabited (IJust Nothing) where\n uninhabited ItIsJust impossible\n\nisJust : (m : Maybe a) -> Dec (IJust m)\nisJust Nothing = No uninhabited\nisJust (Just x) = Yes ItIsJust\n\nfromJust : (m : Maybe a) -> (0 _ : IJust m) => a\nfromJust (Just x) = x\nfromJust Nothing impossible\n\n-- 6\n\ndata IsLeft : Either e a -> Type where\n ItIsLeft : IsLeft (Left v)\n\nUninhabited (IsLeft $ Right w) where\n uninhabited ItIsLeft impossible\n\nisLeft : (v : Either e a) -> Dec (IsLeft v)\nisLeft (Right _) = No uninhabited\nisLeft (Left x) = Yes ItIsLeft\n\ndata IsRight : Either e a -> Type where\n ItIsRight : IsRight (Right v)\n\nUninhabited (IsRight $ Left w) where\n uninhabited ItIsRight impossible\n\nisRight : (v : Either e a) -> Dec (IsRight v)\nisRight (Left _) = No uninhabited\nisRight (Right x) = Yes ItIsRight\n\nfromLeft : (v : Either e a) -> (0 _ : IsLeft v) => e\nfromLeft (Left x) = x\nfromLeft (Right x) impossible\n\nfromRight : (v : Either e a) -> (0 _ : IsRight v) => a\nfromRight (Right x) = x\nfromRight (Left x) impossible\n\n--------------------------------------------------------------------------------\n-- Contracts between Values\n--------------------------------------------------------------------------------\n\ndata ColType = I64 | Str | Boolean | Float\n\nIdrisType : ColType -> Type\nIdrisType I64 = Int64\nIdrisType Str = String\nIdrisType Boolean = Bool\nIdrisType Float = Double\n\nrecord Column where\n constructor MkColumn\n name : String\n type : ColType\n\ninfixr 8 :>\n\n(:>) : String -> ColType -> Column\n(:>) = MkColumn\n\nSchema : Type\nSchema = List Column\n\ndata Row : Schema -> Type where\n Nil : Row []\n (::) : {0 name : String}\n -> {0 type : ColType}\n -> (v : IdrisType type)\n -> Row ss\n -> Row (name :> type :: ss)\n\ndata InSchema : (name : String)\n -> (schema : Schema)\n -> (colType : ColType)\n -> Type where\n [search name schema]\n IsHere : InSchema n (n :> t :: ss) t\n IsThere : InSchema n ss t -> InSchema n (fld :: ss) t\n\ngetAt : {0 ss : Schema}\n -> (name : String)\n -> Row ss\n -> (prf : InSchema name ss c)\n => IdrisType c\ngetAt name (v :: vs) {prf = IsHere} = v\ngetAt name (_ :: vs) {prf = IsThere p} = getAt name vs\n\n-- 1\n\nUninhabited (InSchema n [] c) where\n uninhabited IsHere impossible\n uninhabited (IsThere _) impossible\n\ninSchema : (ss : Schema) -> (n : String) -> Dec (c ** InSchema n ss c)\ninSchema [] _ = No $ \\(_ ** prf) => uninhabited prf\ninSchema (MkColumn cn t :: xs) n = case decEq cn n of\n Yes Refl => Yes (t ** IsHere)\n No contra => case inSchema xs n of\n Yes (t ** prf) => Yes (t ** IsThere prf)\n No contra2 => No $ \\case (_ ** IsHere) => contra Refl\n (t ** IsThere p) => contra2 (t ** p)\n\n-- 2\n\nupdateAt : (name : String)\n -> Row ss\n -> (prf : InSchema name ss c)\n => (f : IdrisType c -> IdrisType c)\n -> Row ss\nupdateAt name (v :: vs) {prf = IsHere} f = f v :: vs\nupdateAt name (v :: vs) {prf = IsThere p} f = v :: updateAt name vs f\n\n-- 3\n\npublic export\ndata Elems : (xs,ys : List a) -> Type where\n ENil : Elems [] ys\n EHere : Elems xs ys -> Elems (x :: xs) (x :: ys)\n EThere : Elems xs ys -> Elems xs (y :: ys)\n\nextract : (0 s1 : Schema)\n -> (row : Row s2)\n -> (prf : Elems s1 s2)\n => Row s1\nextract [] _ {prf = ENil} = []\nextract (_ :: t) (v :: vs) {prf = EHere x} = v :: extract t vs\nextract s1 (v :: vs) {prf = EThere x} = extract s1 vs\n\n-- 4\n\nnamespace AllInSchema\n public export\n data AllInSchema : (names : List String)\n -> (schema : Schema)\n -> (result : Schema)\n -> Type where\n [search names schema]\n Nil : AllInSchema [] s []\n (::) : InSchema n s c\n -> AllInSchema ns s res\n -> AllInSchema (n :: ns) s (n :> c :: res)\n\ngetAll : {0 ss : Schema}\n -> (names : List String)\n -> Row ss\n -> (prf : AllInSchema names ss res)\n => Row res\ngetAll [] _ {prf = []} = []\ngetAll (n :: ns) row {prf = _ :: _} = getAt n row :: getAll ns row\n\n--------------------------------------------------------------------------------\n-- Use Case: Flexible Error Handling\n--------------------------------------------------------------------------------\n\ndata Has : (v : a) -> (vs : Vect n a) -> Type where\n Z : Has v (v :: vs)\n S : Has v vs -> Has v (w :: vs)\n\nUninhabited (Has v []) where\n uninhabited Z impossible\n uninhabited (S _) impossible\n\ndata Union : Vect n Type -> Type where\n U : {0 ts : _} -> (ix : Has t ts) -> (val : t) -> Union ts\n\nUninhabited (Union []) where\n uninhabited (U ix _) = absurd ix\n\n0 Err : Vect n Type -> Type -> Type\nErr ts t = Either (Union ts) t\n\n-- 1\n\nproject : (0 t : Type) -> (prf : Has t ts) => Union ts -> Maybe t\nproject t {prf = Z} (U Z val) = Just val\nproject t {prf = S p} (U (S x) val) = project t (U x val)\nproject t {prf = Z} (U (S x) val) = Nothing\nproject t {prf = S p} (U Z val) = Nothing\n\nproject1 : Union [t] -> t\nproject1 (U Z val) = val\nproject1 (U (S x) val) impossible\n\nsafe : Err [] a -> a\nsafe (Right x) = x\nsafe (Left x) = absurd x\n\n-- 2\n\nweakenHas : Has t ts -> Has t (ts ++ ss)\nweakenHas Z = Z\nweakenHas (S x) = S (weakenHas x)\n\nweaken : Union ts -> Union (ts ++ ss)\nweaken (U ix val) = U (weakenHas ix) val\n\nextendHas : {m : _} -> {0 pre : Vect m a} -> Has t ts -> Has t (pre ++ ts)\nextendHas {m = Z} {pre = []} x = x\nextendHas {m = S p} {pre = _ :: _} x = S (extendHas x)\n\nextend : {m : _} -> {0 pre : Vect m _} -> Union ts -> Union (pre ++ ts)\nextend (U ix val) = U (extendHas ix) val\n\n-- 3\n\n0 Errs : Vect m Type -> Vect n Type -> Type\nErrs [] _ = ()\nErrs (x :: xs) ts = (Has x ts, Errs xs ts)\n\ninject : Has t ts => (v : t) -> Union ts\ninject v = U %search v\n\nembed : (prf : Errs ts ss) => Union ts -> Union ss\nembed (U Z val) = inject val\nembed (U (S x) val) = embed (U x val)\n\n-- 4\n\ndata Rem : (v : a) -> (vs : Vect (S n) a) -> (rem : Vect n a) -> Type where\n [search v vs]\n RZ : Rem v (v :: rem) rem\n RS : Rem v vs rem -> Rem v (w :: vs) (w :: rem)\n\nsplit : (prf : Rem t ts rem) => Union ts -> Either t (Union rem)\nsplit {prf = RZ} (U Z val) = Left val\nsplit {prf = RZ} (U (S x) val) = Right (U x val)\nsplit {prf = RS p} (U Z val) = Right (U Z val)\nsplit {prf = RS p} (U (S x) val) = case split {prf = p} (U x val) of\n Left vt => Left vt\n Right (U ix y) => Right $ U (S ix) y\n\nhandle : Applicative f\n => Rem t ts rem\n => (h : t -> f (Err rem a))\n -> Err ts a\n -> f (Err rem a)\nhandle h (Left x) = case split x of\n Left v => h v\n Right err => pure $ Left err\nhandle _ (Right x) = pure $ Right x\n\n--------------------------------------------------------------------------------\n-- Tests\n--------------------------------------------------------------------------------\n\nEmployeeSchema : Schema\nEmployeeSchema = [ \"firstName\" :> Str\n , \"lastName\" :> Str\n , \"email\" :> Str\n , \"age\" :> I64\n , \"salary\" :> Float\n , \"management\" :> Boolean\n ]\n\n0 Employee : Type\nEmployee = Row EmployeeSchema\n\nhock : Employee\nhock = [ \"Stefan\", \"Höck\", \"hock@foo.com\", 46, 5443.2, False ]\n\nshoeck : String\nshoeck = getAt \"firstName\" hock ++ \" \" ++ getAt \"lastName\" hock\n\nshoeck2 : String\nshoeck2 = case getAll [\"firstName\", \"lastName\", \"age\"] hock of\n [fn,ln,a] => \"\\{fn} \\{ln}: \\{show a} years old.\"\n\nembedTest : Err [Nat,Bits8] a\n -> Err [String, Bits8, Int32, Nat] a\nembedTest = mapFst embed\n", "meta": {"hexsha": "455153253d50e2fc12d5e79500d082027d8a159a", "size": 8974, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Solutions/Predicates.idr", "max_stars_repo_name": "ska80/idris2-tutorial", "max_stars_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 60, "max_stars_repo_stars_event_min_datetime": "2022-01-13T16:14:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T16:16:57.000Z", "max_issues_repo_path": "src/Solutions/Predicates.idr", "max_issues_repo_name": "ska80/idris2-tutorial", "max_issues_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 11, "max_issues_repo_issues_event_min_datetime": "2022-01-14T15:42:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T09:53:16.000Z", "max_forks_repo_path": "src/Solutions/Predicates.idr", "max_forks_repo_name": "ska80/idris2-tutorial", "max_forks_repo_head_hexsha": "ab7c83cfea6761f2fd29841593c92e78c7dfc958", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 6, "max_forks_repo_forks_event_min_datetime": "2022-01-14T15:48:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-03T06:49:13.000Z", "avg_line_length": 27.4434250765, "max_line_length": 80, "alphanum_fraction": 0.5041230221, "num_tokens": 2908, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.6791787121629465, "lm_q1q2_score": 0.5027106699856895}} {"text": "> data Vect : Nat -> Type -> Type where\n> Nil : Vect Z a\n> (::) : a -> Vect k a -> Vect (S k) a\n\n> %name Vect xs, ys, zs\n\n> append : Vect n a -> Vect m a -> Vect (n + m) a\n> append xs ys\n> = case xs of\n> foo => ?bar\n\n> data Foo a = MkFoo a | MkBar (a -> a)\n\n> Functor Foo where\n> map f thing = ?baz\n", "meta": {"hexsha": "d5bd20490e1827010fddfbbaa26ffe5f63c35fdb", "size": 326, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/literate002/IEdit.lidr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/literate002/IEdit.lidr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/literate002/IEdit.lidr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 20.375, "max_line_length": 49, "alphanum_fraction": 0.4846625767, "num_tokens": 115, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.5026910662014732}} {"text": "module TypedNBE\n\n-- Typed NBE, based on https://hal.inria.fr/hal-01397929/document\n\nimport Data.Vect\n\ndata Ty = Base String | Arrow Ty Ty\n\ndata Syn : Vect n Ty -> Ty -> Type where\n Var : Elem a ctx -> Syn ctx a\n Lam : Syn (a :: ctx) b -> Syn ctx (Arrow a b)\n App : Syn ctx (Arrow a b) -> Syn ctx a -> Syn ctx b\n\nV : Ty -> Type\n\nmutual\n data Nf : Ty -> Type where\n NLam : (V a -> Nf b) -> Nf (Arrow a b)\n NAt : At (Base a) -> Nf (Base a)\n\n data At : Ty -> Type where\n AApp : At (Arrow a b) -> Nf a -> At b\n AVar : V a -> At a\n\ndata Sem : Ty -> Type where\n Fun : (Sem a -> Sem b) -> Sem (Arrow a b)\n Base' : At (Base a) -> Sem (Base a)\n\ndata Env : Vect n Ty -> Type where\n Nil : Env Nil\n (::) : Sem ty -> Env ctx -> Env (ty :: ctx)\n\nlookup' : Elem ty ctx -> Env ctx -> Sem ty\nlookup' Here (x :: _) = x\nlookup' (There later) (x :: xs) = lookup' later xs\n\neval : Env ctx -> Syn ctx ty -> Sem ty\neval env (Var x) = lookup' x env\neval env (Lam body) = Fun (\\x => eval (x :: env) body)\neval env (App f x) with (eval env f)\n eval env (App f x) | (Fun f') = f' (eval env x)\n\nmutual\n reflect : At ty -> Sem ty\n reflect {ty = (Base _)} at = Base' at\n reflect {ty = (Arrow a b)} at = Fun (\\x => reflect (AApp at (reify x)))\n\n reify : Sem ty -> Nf ty\n reify {ty = (Base _)} (Base' base) = NAt base\n reify {ty = (Arrow a b)} (Fun f) = NLam (\\x => reify (f (reflect (AVar x))))\n\nnbe : Syn [] ty -> Nf ty\nnbe syn = reify (eval [] syn)\n\nexample : Syn [] (Arrow (Base \"a\") (Base \"a\"))\nexample = Lam (App (Lam (Var Here)) (Var Here))\n\ntest : Nf (Arrow (Base \"a\") (Base \"a\"))\ntest = nbe example\n", "meta": {"hexsha": "2fdc849e0d321661bbca7f86ad60abcfcba3d95b", "size": 1604, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/TypedNBE.idr", "max_stars_repo_name": "STELIORD/idris-snippets", "max_stars_repo_head_hexsha": "f5ca6fa86370d24587040af9871ae850bbc630c2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 16, "max_stars_repo_stars_event_min_datetime": "2017-11-21T22:28:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-05T18:25:18.000Z", "max_issues_repo_path": "src/TypedNBE.idr", "max_issues_repo_name": "stjordanis/idris-snippets", "max_issues_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/TypedNBE.idr", "max_forks_repo_name": "stjordanis/idris-snippets", "max_forks_repo_head_hexsha": "d92734b8624ae27be21a63fcb041077b38eaaecb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-05-06T13:39:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T15:39:16.000Z", "avg_line_length": 26.7333333333, "max_line_length": 78, "alphanum_fraction": 0.5604738155, "num_tokens": 576, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.501401646255129}} {"text": "module Schema\n\nimport SQLiteTypes\n\nimport Decidable.Equality\nimport Language.Reflection\n\n%access public export\n%default total\n\n%auto_implicits on\n\ninfix 5 :::\ndata Attribute = (:::) String SQLiteType\n%name Attribute attr,attr'\n\ngetName : Attribute -> String\ngetName (c:::_) = c\n\ngetTy : Attribute -> SQLiteType\ngetTy (_:::t) = t\n\nattrEta : (attr : Attribute) -> (getName attr ::: getTy attr) = attr\nattrEta (x ::: y) = Refl\n\nattrInj : (c ::: t = c' ::: t') -> (c=c', t=t')\nattrInj Refl = (Refl, Refl)\n\n-- the first case forces it to get stuck if the constants are not in canonical form\nfoo : (x : String) -> (y : String) -> Dec (x = y)\nfoo \"\" \"\" = Yes Refl\nfoo x y with (decEq x y)\n foo x y | Yes _ = Yes (really_believe_me (Refl {x}))\n foo x y | No urgh = No urgh\n\n\nimplementation DecEq Attribute where\n decEq (x ::: y) (z ::: w) with (foo x z, decEq y w)\n decEq (x ::: y) (x ::: y) | (Yes Refl, Yes Refl) = Yes Refl\n decEq (x ::: y) (x ::: w) | (Yes Refl, No prf) = No $ prf . snd . attrInj\n decEq (x ::: y) (z ::: w) | (No prf, _) = No $ prf . fst . attrInj\n\ndata Schema = Nil | (::) Attribute Schema\n%name Schema s,s'\n\nappend : (s1, s2 : Schema) -> Schema\nappend [] s2 = s2\nappend (attr :: s) s2 = attr :: (append s s2)\n\nnames : Schema -> List String\nnames [] = []\nnames ((n ::: _) :: s) = n :: names s\n\n\ndata HasCol : Schema -> Attribute -> Type where\n Here : HasCol (attr::s) attr\n There : HasCol s attr -> HasCol (attr'::s) attr\n\nHasColNotEmpty : HasCol [] a -> Void\nHasColNotEmpty Here impossible\nHasColNotEmpty (There _) impossible\n\nimplementation Uninhabited (HasCol [] a) where\n uninhabited x = HasColNotEmpty x\n\ndecHasColLemma : (HasCol s attr -> Void) ->\n (attr' = attr -> Void) ->\n HasCol (attr' :: s) attr -> Void\ndecHasColLemma h1 h2 Here = h2 Refl\ndecHasColLemma h1 h2 (There x) = h1 x\n\ndecHasCol : (s : Schema) -> (attr : Attribute) -> Dec (HasCol s attr)\ndecHasCol [] attr = No HasColNotEmpty\ndecHasCol (attr' :: s) attr with (decEq attr' attr)\n decHasCol (attr' :: s) attr' | (Yes Refl) = Yes Here\n decHasCol (attr' :: s) attr | (No f) with (decHasCol s attr)\n decHasCol (attr' :: s) attr | (No f) | (Yes x) = Yes (There x)\n decHasCol (attr' :: s) attr | (No f) | (No g) = No $ \\h => decHasColLemma g f h\n\n\ndata SubSchema : Schema -> Schema -> Type where\n Empty : SubSchema [] s\n Head : (tailSub : SubSchema small large) ->\n (alsoThere : HasCol large attr) ->\n SubSchema (attr :: small) large\n\nHasColNamed : Schema -> String -> Type\nHasColNamed s col = (t : SQLiteType ** HasCol s (col ::: t))\n\ndecHasColNamed_lemma : ((HasColNamed s col) -> Void) -> ((col' = col) -> Void) ->\n (t ** HasCol ((col' ::: ty) :: s) (col ::: t)) -> Void\ndecHasColNamed_lemma notThere notHere (ty ** Here) = notHere Refl\ndecHasColNamed_lemma notThere notHere (ty ** (There more)) = notThere (ty ** more)\n\n\ndecHasColNamed : (s : Schema) -> (col : String) -> Dec (HasColNamed s col)\ndecHasColNamed [] col = No $ \\h => HasColNotEmpty (snd h)\ndecHasColNamed ((col' ::: ty) :: s) col with (decEq col' col)\n decHasColNamed ((col ::: ty) :: s) col | (Yes Refl) = Yes (ty ** Here)\n decHasColNamed ((col' ::: ty) :: s) col | (No f) with (decHasColNamed s col)\n decHasColNamed ((col' ::: ty) :: s) col | (No f) | (Yes x) =\n Yes (fst x ** There (snd x))\n decHasColNamed ((col' ::: ty) :: s) col | (No f) | (No g) = No (decHasColNamed_lemma g f)\n\ncolNames : Schema -> List String\ncolNames [] = []\ncolNames ((col ::: _) :: s) = col :: colNames s\n\ndata Disjointness : Type where\n Disjoint : Disjointness\n Overlap : (attr : Attribute) -> Disjointness\n\nisDisjoint : (s1, s2 : Schema) -> Disjointness\nisDisjoint [] s2 = Disjoint\nisDisjoint (attr :: s) s2 with (decHasColNamed s2 (getName attr))\n isDisjoint (attr :: s) s2 | (Yes x) = Overlap attr\n isDisjoint (attr :: s) s2 | (No f) = isDisjoint s s2\n\n\n", "meta": {"hexsha": "bc39f1e3add97b292a27d9b865defb800df6ea40", "size": 3908, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type-provider/Schema.idr", "max_stars_repo_name": "ethansr/IdrisSqlite", "max_stars_repo_head_hexsha": "72a3c934401ccc08f27cd1ea32e4beedc994de65", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 28, "max_stars_repo_stars_event_min_datetime": "2015-01-22T10:54:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-01T02:18:05.000Z", "max_issues_repo_path": "type-provider/Schema.idr", "max_issues_repo_name": "ethansr/IdrisSqlite", "max_issues_repo_head_hexsha": "72a3c934401ccc08f27cd1ea32e4beedc994de65", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 2, "max_issues_repo_issues_event_min_datetime": "2015-09-20T17:40:14.000Z", "max_issues_repo_issues_event_max_datetime": "2017-08-07T20:03:24.000Z", "max_forks_repo_path": "type-provider/Schema.idr", "max_forks_repo_name": "ethansr/IdrisSqlite", "max_forks_repo_head_hexsha": "72a3c934401ccc08f27cd1ea32e4beedc994de65", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 7, "max_forks_repo_forks_event_min_datetime": "2015-09-30T20:53:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-07T13:41:23.000Z", "avg_line_length": 32.5666666667, "max_line_length": 93, "alphanum_fraction": 0.6072159672, "num_tokens": 1300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5007560858371057}} {"text": "import Data.Vect\n\ndata WordState: (guesses_remaining: Nat) -> (letters: Nat) -> Type where\n MkWordState: (word: String) -> (missing: Vect letters Char) -> WordState guesses_remaining letters\n\ndata Finished: Type where\n Lost: (game: WordState 0 (S letters)) -> Finished\n Won: (game: WordState (S remaining) 0) -> Finished\n\ndata ValidInput: List Char -> Type where\n Letter: (c: Char) -> ValidInput [c]\n\ntotal emptyNotValidInput : ValidInput [] -> Void\nemptyNotValidInput (Letter _) impossible\n\ntotal tooManyChars : ValidInput (x :: (y :: xs)) -> Void\ntooManyChars (Letter _) impossible\n\ntotal isValidInput: (chars: List Char) -> Dec (ValidInput chars)\nisValidInput [] = No emptyNotValidInput\nisValidInput (x :: []) = Yes(Letter x)\nisValidInput (x :: (y :: xs)) = No tooManyChars\n\nisValidString: (s: String) -> Dec(ValidInput(unpack s))\nisValidString s = isValidInput (unpack s)\n\nreadGuess: IO (x ** ValidInput x)\nreadGuess = do\n putStr \"Guess: \"\n userGuess <- getLine\n case isValidString (toUpper userGuess) of\n (Yes prf) => pure (_ ** prf)\n (No contra) => do\n putStrLn (\"Invalid guess = [\" ++ userGuess ++\"]\")\n readGuess\n\nremoveElem: (value: a) -> (xs: Vect (S n) a) -> {auto prf: Elem value xs} -> Vect n a\nremoveElem value (value :: ys) {prf = Here} = ys\nremoveElem {n = Z} value (y :: []) {prf = (There later)} = absurd later\nremoveElem {n = (S k)} value (y :: ys) {prf = (There later)} = y :: removeElem value ys\n\nprocessGuess: (letter: Char) ->\n WordState (S guesses) (S letters) ->\n Either (WordState guesses (S letters))\n (WordState (S guesses) letters)\nprocessGuess letter (MkWordState word missing) = case isElem letter missing of\n (Yes prf) => Right (MkWordState word (removeElem letter missing))\n (No contra) => Left (MkWordState word missing)\n\ngame: (state: WordState (S guesses) (S letters)) -> IO Finished\ngame {guesses} {letters} state = do\n ([input] ** Letter input) <- readGuess\n case processGuess input state of\n (Left l) => do\n putStrLn \"Wrong!\"\n case guesses of\n Z => pure (Lost l)\n S k => game l\n (Right r) => do\n putStrLn \"Right!\"\n case letters of\n Z => pure (Won r)\n (S k) => game r\n\nmain: IO ()\nmain = \n let\n wordToGuess = MkWordState \"Test\" ['T', 'E', 'S']\n in\n do\n result <- game {guesses=2} wordToGuess\n case result of\n (Lost (MkWordState word missing)) => putStrLn (\"You lost. The word was\" ++ word)\n (Won game) => putStrLn \"You win\"\n", "meta": {"hexsha": "5f687a6cc0da5ebfd6b8bc538423664bc9c63c59", "size": 2558, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Hangman.idr", "max_stars_repo_name": "coffius/idris-exercises", "max_stars_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Hangman.idr", "max_issues_repo_name": "coffius/idris-exercises", "max_issues_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Hangman.idr", "max_forks_repo_name": "coffius/idris-exercises", "max_forks_repo_head_hexsha": "77cb2ab7247890ba38376b753611284458cece17", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 34.1066666667, "max_line_length": 100, "alphanum_fraction": 0.6227521501, "num_tokens": 743, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303285397349, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.5007300183750947}} {"text": "module Toolkit.Data.List.Subset\n\nimport Toolkit.Decidable.Informative\n\n%default total\n\n\npublic export\ndata Subset : (eq : a -> b -> Type)\n -> (this : List a)\n -> (that : List b)\n -> Type\n where\n Empty : Subset eq Nil Nil\n\n EmptyThis : Subset eq Nil xs\n\n Keep : {eq : a -> b -> Type}\n -> (prf : eq x y)\n -> (rest : Subset eq xs ys)\n -> Subset eq (x::xs) (y::ys)\n\n Skip : (rest : Subset eq xs ys)\n -> Subset eq xs (y::ys)\n\n\npublic export\ndata Error : Type -> Type where\n EmptyThat : Error a\n Fail : a -> Error a\n FailThere : Error a -> Error a\n\nemptyThat : Subset eq (x :: xs) [] -> Void\nemptyThat Empty impossible\n\nyesButNo : {eq : a -> b -> Type}\n -> {x : a} -> {xs : List a}\n -> {y : b} -> {ys : List b}\n -> (h : Subset eq xs ys -> Void)\n -> (t : Subset eq (x::xs) ys -> Void)\n -> Subset eq (x::xs) (y::ys)\n -> Void\nyesButNo h t (Keep prf rest) = h rest\nyesButNo h t (Skip rest) = t rest\n\njustNot : {eq : a -> b -> Type}\n -> {x : a} -> {xs : List a}\n -> {y : b} -> {ys : List b}\n -> (eq x y -> Void)\n -> (Subset eq (x :: xs) ys -> Void )\n -> Subset eq (x :: xs) (y :: ys)\n -> Void\njustNot f g (Keep prf rest) = f prf\njustNot f g (Skip rest) = g rest\n\nexport\nsubset : {eq : a -> b -> Type}\n -> (test : (x : a) -> (y : b) -> DecInfo err (eq x y))\n -> (this : List a)\n -> (that : List b)\n -> DecInfo (Error err) (Subset eq this that)\nsubset test [] []\n = Yes Empty\n\nsubset test [] (x :: xs)\n = Yes EmptyThis\n\nsubset test (x :: xs) []\n = No EmptyThat emptyThat\n\nsubset test (x :: xs) (y :: ys) with (test x y)\n subset test (x :: xs) (y :: ys) | (Yes prfHere) with (subset test xs ys)\n subset test (x :: xs) (y :: ys) | (Yes prfHere) | (Yes prfThere)\n = Yes (Keep prfHere prfThere)\n subset test (x :: xs) (y :: ys) | (Yes prfHere) | (No msgWhyNot prfWhyNot) with (subset test (x::xs) ys)\n subset test (x :: xs) (y :: ys) | (Yes prfHere) | (No msgWhyNot prfWhyNot) | (Yes prfThere)\n = Yes (Skip prfThere)\n subset test (x :: xs) (y :: ys) | (Yes prfHere) | (No msgWhyNotHere prfWhyNotHere) | (No msgWhyNotThere prfWhyNotThere)\n = No (FailThere msgWhyNotThere)\n (yesButNo prfWhyNotHere prfWhyNotThere)\n\n subset test (x :: xs) (y :: ys) | (No msgWhyNotHere prfWhyNotHere) with (subset test (x::xs) ys)\n subset test (x :: xs) (y :: ys) | (No msgWhyNotHere prfWhyNotHere) | (Yes prfThere)\n = Yes (Skip prfThere)\n subset test (x :: xs) (y :: ys) | (No msgWhyNotHere prfWhyNotHere) | (No msgWhyNotThere prfWhyNotThere)\n = No (FailThere msgWhyNotThere)\n (justNot prfWhyNotHere prfWhyNotThere)\n", "meta": {"hexsha": "214e753118cbd871d940d7632521eae6d7cc2a37", "size": 2820, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/List/Subset.idr", "max_stars_repo_name": "gallais/linear-circuits", "max_stars_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2020-11-03T11:33:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-14T17:11:38.000Z", "max_issues_repo_path": "src/Toolkit/Data/List/Subset.idr", "max_issues_repo_name": "gallais/linear-circuits", "max_issues_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Toolkit/Data/List/Subset.idr", "max_forks_repo_name": "gallais/linear-circuits", "max_forks_repo_head_hexsha": "5d13d955eafc2d92beae363e96d3cec8695830f2", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-02-09T19:49:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-09T19:49:11.000Z", "avg_line_length": 32.0454545455, "max_line_length": 125, "alphanum_fraction": 0.5255319149, "num_tokens": 929, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.5007300066527088}} {"text": "import Data.Vect\n\n%default total\n\ninfix 3 .<=.\n(.<=.) : Int -> Int -> Bool\n(.<=.) p q = case (p, q) of\n (0, _) => True\n _ => False\n\ncountGreater : (thr : Int) -> (ctx : Vect n Int) -> Nat\ncountGreater thr [] = Z\ncountGreater thr (x :: xs) with (x .<=. thr)\n countGreater thr (x :: xs) | True = countGreater thr xs\n countGreater thr (x :: xs) | False = S $ countGreater thr xs\n\n-- map a variable from the old context to the erased context\n-- where we erase all bindings less than or equal to the threshold\neraseVar : (thr : Int) -> (ctx : Vect n Int) -> Fin n -> Maybe (Fin (countGreater thr ctx))\neraseVar thr (x :: xs) j with (x .<=. thr)\n eraseVar thr (x :: xs) FZ | True = Nothing\n eraseVar thr (x :: xs) FZ | False = Just FZ\n eraseVar thr (x :: xs) (FS i) | True = FS <$> eraseVar thr xs i\n eraseVar thr (x :: xs) (FS i) | False = FS <$> eraseVar thr xs i\n\nboom : Maybe (Fin 1)\nboom = eraseVar 0 [0, 1] (FS FZ)\n", "meta": {"hexsha": "f740e38a020f8240aae41f4fa5e7b2d80a0420fe", "size": 923, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/reg023/boom.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 396, "max_stars_repo_stars_event_min_datetime": "2016-07-17T08:00:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T22:47:13.000Z", "max_issues_repo_path": "idris2/tests/idris2/reg023/boom.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 54, "max_issues_repo_issues_event_min_datetime": "2016-08-04T06:13:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-03T04:00:31.000Z", "max_forks_repo_path": "idris2/tests/idris2/reg023/boom.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 28, "max_forks_repo_forks_event_min_datetime": "2016-09-15T15:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-27T13:05:48.000Z", "avg_line_length": 32.9642857143, "max_line_length": 91, "alphanum_fraction": 0.602383532, "num_tokens": 311, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357460591568, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.5007091247995855}} {"text": "-- Non-strictly-positive recursion\ndata La : Type where\n Lam : (La -> La) -> La\n\napp : La -> La -> La\napp (Lam f) x = f x\n\nselfApp : La\nselfApp = Lam \\x => app x x\n\nom : La\nom = app selfApp selfApp\n", "meta": {"hexsha": "ec446ee0a81c04d9f8cbb7f653a1da04a76d0704", "size": 199, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "NonPositiveRec.idr", "max_stars_repo_name": "buzden/idris-playground", "max_stars_repo_head_hexsha": "414729c5dbd665fdb05cdfe5318f972fb277a726", "max_stars_repo_licenses": ["CC0-1.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2021-01-23T08:24:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-27T02:45:50.000Z", "max_issues_repo_path": "NonPositiveRec.idr", "max_issues_repo_name": "buzden/idris-playground", "max_issues_repo_head_hexsha": "414729c5dbd665fdb05cdfe5318f972fb277a726", "max_issues_repo_licenses": ["CC0-1.0"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "NonPositiveRec.idr", "max_forks_repo_name": "buzden/idris-playground", "max_forks_repo_head_hexsha": "414729c5dbd665fdb05cdfe5318f972fb277a726", "max_forks_repo_licenses": ["CC0-1.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 15.3076923077, "max_line_length": 34, "alphanum_fraction": 0.5979899497, "num_tokens": 72, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289388083214156, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.5006225345561632}} {"text": "||| An expression language with mechanical proof of type-safety.\n|||\n||| `Variant` is an expression language supporting Let-bindings, and\n||| type unsafe variants. Standard constructions are used to\n||| represent the language as an EDSL, together with proof of progress\n||| taken from PLFA Part 2.\n|||\n||| This module compliments Section 4.1 of the Functional Pearl.\n|||\nmodule Razor.Variant\n\nimport Razor.Common\n\n%default total\n\nnamespace Types\n\n public export\n data Ty = TyInt\n | TyChar\n | TyVariant (Vect (S n) (Pair String Ty))\n\nnamespace Terms\n mutual\n public export\n data Case : (ctxt : List Ty)\n -> (label : String)\n -> (type : Ty)\n -> (body : Ty)\n -> Type\n where\n MkCase : (label : String)\n -> (branch : Variant (ctxt += type) body)\n -> Case ctxt label type body\n\n public export\n data Cases : (ctxt : List Ty)\n -> (types : Vect (S n) (Pair String Ty))\n -> (body : Ty)\n -> Type\n where\n Singleton : (branch : Case g label ty b)\n -> Cases g [(label, ty)] b\n\n Extend : (branch : Case g label ty b)\n -> (rest : Cases g kvs b)\n -> Cases g ((label, ty) :: kvs) b\n\n\n public export\n data Variant : List Ty -> Ty -> Type where\n -- Let-Binding & Variables\n Var : Elem ty g -> Variant g ty\n\n Let : {expr, body : Ty}\n -> (this : Variant g expr)\n -> (beInThis : Variant (expr::g) body)\n -> Variant g body\n\n -- Base Values\n I : Int -> Variant g TyInt\n C : Char -> Variant g TyChar\n\n -- Variants & Accessors\n Tag : {kvs : Vect (S n) (Pair String Ty)}\n -> (label : String)\n -> (value : Variant g ty)\n -> (prf : Elem (label, ty) kvs)\n -> Variant g (TyVariant kvs)\n\n Match : {kvs : Vect (S n) (Pair String Ty)}\n -> {b : Ty}\n -> (value : Variant g (TyVariant kvs))\n -> (cases : Cases g kvs b)\n -> Variant g b\n\n\nnamespace Renaming\n public export\n weaken : forall type\n . (Contains old type -> Contains new type)\n -> (Contains (old += type') type -> Contains (new += type') type)\n\n weaken func Here = Here\n weaken func (There rest) = There (func rest)\n\n mutual\n namespace Case\n\n public export\n rename : (forall type . Contains old type -> Contains new type)\n -> (forall type, body . Case old label type body\n -> Case new label type body)\n rename f (MkCase label branch)\n = MkCase label (rename (weaken f) branch)\n\n namespace Cases\n public export\n rename : (forall type . Contains (old) type -> Contains (new) type)\n -> (forall types, type . Cases old types type\n -> Cases new types type)\n rename f (Singleton branch)\n = Singleton (Case.rename f branch)\n rename f (Extend branch rest)\n = Extend (Case.rename f branch) (rename f rest)\n\n public export\n rename : (forall type . Contains old type -> Contains new type)\n -> (forall type . Variant old type -> Variant new type)\n -- Let-Bindings & Variables\n rename f (Var x) = Var (f x)\n rename f (Let this beInThis)\n = Let (rename f this)\n (rename (weaken f) beInThis)\n\n -- Base Variables\n rename f (I x) = I x\n rename f (C x) = C x\n\n -- Variants & Accesors\n rename f (Tag label value prf) = Tag label (rename f value) prf\n rename f (Match value cases) = Match (rename f value)\n (Cases.rename f cases)\n\n\nnamespace Substitution\n public export\n weakens : forall old, new\n . (f : forall type\n . Contains old type\n -> Variant new type)\n -> (forall type . Contains (old += type') type\n -> Variant (new += type') type)\n weakens f Here = Var Here\n weakens f (There rest) = rename There (f rest)\n\n namespace General\n mutual\n namespace Case\n public export\n subst : (f : forall type\n . Contains old type\n -> Variant new type)\n -> (forall type, body . Case old label type body\n -> Case new label type body)\n subst f (MkCase label branch)\n = MkCase label (subst (weakens f) branch)\n\n namespace Cases\n public export\n subst : (f : forall type\n . Contains old type\n -> Variant new type)\n -> (forall types, type . Cases old types type\n -> Cases new types type)\n subst f (Singleton branch)\n = Singleton (Case.subst f branch)\n subst f (Extend branch rest)\n = Extend (Case.subst f branch) (subst f rest)\n\n\n public export\n subst : (forall type . Contains old type -> Variant new type)\n -> (forall type . Variant old type -> Variant new type)\n -- Let-Bindings & Variables\n subst f (Var x) = f x\n subst f (Let this beInThis)\n = Let (subst f this) (subst (weakens f) beInThis)\n\n -- Base Values\n subst f (I x) = I x\n subst f (C x) = C x\n\n -- Variants & Accessors\n subst f (Tag label value prf)\n = Tag label (subst f value) prf\n subst f (Match value cases)\n = Match (subst f value) (subst f cases)\n\n namespace Single\n public export\n apply : (this : Variant ctxt typeB)\n -> (idx : Contains (ctxt += typeB) typeA)\n -> Variant ctxt typeA\n apply this Here = this\n apply this (There rest) = Var rest\n\n public export\n subst : (this : Variant ctxt typeB)\n -> (inThis : Variant (ctxt += typeB) typeA)\n -> Variant ctxt typeA\n subst {ctxt} {typeA} {typeB} this inThis\n = General.subst (apply this) inThis\n\n\nnamespace Values\n\n public export\n data Value : Variant ctxt type -> Type where\n -- Base Values\n IV : Value (I i)\n CV : Value (C c)\n\n -- Variants\n MkTagV : {kvs : Vect (S n) (Pair String Ty)}\n -> {value' : Variant Nil type}\n -> (value : Value value')\n -> {prf : Elem (label, type) kvs}\n -> Value (Tag label value' prf)\n\n\nnamespace Reduction\n\n namespace Cases\n public export\n data Redux : (value : Variant g type)\n -> (cases : Cases g kvs body)\n -> (idx : Elem (label, type) kvs)\n -> (result : Variant g body)\n -> Type\n where\n ReduceSingleton : {value : Variant g type}\n -> Value value\n -> Redux value\n (Singleton (MkCase label branch))\n Here\n (subst value branch)\n ReduceExtend : {value : Variant g type}\n -> {rest : Cases g kvs body}\n -> Value value\n -> Redux value\n (Extend (MkCase label branch) rest)\n Here\n (Single.subst value branch)\n SkipThis : Redux value rest later result\n -> Redux value\n (Extend branch rest)\n (There later)\n result\n\n public export\n data Redux : (this, that : Variant ctxt type) -> Type where\n -- Let Bindings\n SimplifyLetValue : Redux this that\n -> Redux (Let this body)\n (Let that body)\n ReduceLetBody : Value value\n -> Redux (Let value body)\n (subst value body)\n\n -- Variants & Accessors\n SimplifyTag : {kvs : Vect (S n) (Pair String Ty)}\n -> {prf : Elem (label, type) kvs}\n -> (redux : Redux this that)\n -> Redux (Tag label this prf) (Tag label that prf)\n\n SimplifyMatchCase : {cases : Cases _ kvs type}\n -> (redux : Redux this that)\n -> Redux (Match this cases) (Match that cases)\n\n ReduceCases : {kvs : Vect (S n) (Pair String Ty)}\n -> {idx : Elem (label, type') kvs}\n -> {value : Variant g type'}\n -> {this : Cases g kvs type}\n -> {that : Variant g type}\n -> (prf : Value value)\n -> (redux : Redux value this idx that)\n -> Redux (Match (Tag label value idx) this)\n that\n\n\nnamespace Progress\n\n public export\n data Progress : (term : Variant Nil type)\n -> Type\n where\n Done : {term : Variant Nil type}\n -> (value : Value term)\n -> Progress term\n\n Step : {type : Ty}\n -> {this, that : Variant Nil type}\n -> (step : Redux this that)\n -> Progress this\n\n namespace Cases\n public export\n data Progress : (label : String)\n -> (value : Variant Nil type)\n -> (idx : Elem (label, type) kvs)\n -> (term : Cases Nil kvs body)\n -> Type\n where\n Step : {value : Variant Nil type'}\n -> {idx : Elem (label, type') kvs}\n -> {cases : Cases Nil kvs type}\n -> {that : Variant Nil type}\n -> (step : Redux value cases idx that)\n -> Progress label value idx cases\n mutual\n namespace Cases\n public export\n progress : {value' : Variant Nil type}\n -> (idx : Elem (label, type) kvs)\n -> (value : Value value')\n -> (term : Cases Nil kvs body)\n -> Progress label value' idx term\n progress Here value (Singleton (MkCase label branch))\n = Step (ReduceSingleton value)\n progress Here value (Extend (MkCase label branch) rest)\n = Step (ReduceExtend value)\n progress (There later) value (Extend branch rest) with (progress later value rest)\n progress (There later) value (Extend branch rest) | Step step\n = Step (SkipThis step)\n\n\n\n public export\n progress : forall type . (term : Variant Nil type) -> Progress term\n -- Let-Bindings & Variables\n progress (Var _) impossible\n\n progress (Let this beInThis) with (progress this)\n progress (Let this beInThis) | (Done value) = Step (ReduceLetBody value)\n progress (Let this beInThis) | (Step step) = Step (SimplifyLetValue step)\n\n -- Base Values\n progress (I x) = Done IV\n progress (C x) = Done CV\n\n -- Variants & Accessors\n progress (Tag label value prf) with (progress value)\n progress (Tag label value prf) | (Done value') = Done (MkTagV value')\n progress (Tag label value prf) | (Step step) = Step (SimplifyTag step)\n\n progress (Match value cases) with (progress value)\n progress (Match (Tag label value' prf) cases) | (Done (MkTagV x)) with (progress prf x cases)\n progress (Match (Tag label value' prf) cases) | (Done (MkTagV x)) | (Step step)\n = Step (ReduceCases x step)\n progress (Match value cases) | (Step step) = Step (SimplifyMatchCase step)\n\n\nnamespace Evaluation\n\n public export\n data Reduces : (this : Variant ctxt type)\n -> (that : Variant ctxt type)\n -> Type\n where\n Refl : {this : Variant ctxt type}\n -> Reduces this this\n Trans : {this, that, end : Variant ctxt type}\n -> Redux this that\n -> Reduces that end\n -> Reduces this end\n\n public export\n data Finished : (term : Variant ctxt type)\n -> Type\n where\n Normalised : {term : Variant ctxt type}\n -> (this : Value term)\n -> Finished term\n OOF : Finished term\n\n public export\n data Evaluate : (term : Variant Nil type) -> Type where\n RunEval : {this, that : Variant Nil type}\n -> (steps : Inf (Reduces this that))\n -> (result : Finished that)\n -> Evaluate this\n\n public export\n data Fuel = Empty | More (Lazy Fuel)\n\n public export\n covering\n forever : Fuel\n forever = More forever\n\n public export\n compute : (fuel : Fuel)\n -> (term : Variant Nil type)\n -> Evaluate term\n compute Empty term = RunEval Refl OOF\n compute (More fuel) term with (progress term)\n compute (More fuel) term | (Done value) = RunEval Refl (Normalised value)\n compute (More fuel) term | (Step step {that}) with (compute fuel that)\n compute (More fuel) term | (Step step {that = that}) | (RunEval steps result)\n = RunEval (Trans step steps) result\n\npublic export\ncovering\nrun : (this : Variant Nil type)\n -> Maybe (Subset (Variant Nil type) (Reduces this))\nrun this with (compute forever this)\n run this | (RunEval steps (Normalised {term} x)) = Just (Element term steps)\n run this | (RunEval steps OOF) = Nothing\n\n\nnamespace Examples\n\n public export\n ici : Variant Nil (TyVariant [(\"int\", TyInt), (\"char\", TyChar)])\n ici = Tag \"int\" (I 1) Here\n\n public export\n icc : Variant Nil (TyVariant [(\"int\", TyInt), (\"char\", TyChar)])\n icc = Tag \"char\" (C 'c') (There Here)\n\n public export\n iciM : Variant Nil TyInt\n iciM = Match ici (Extend (MkCase \"int\" (Var Here)) (Singleton (MkCase \"char\" $ I 2)))\n\n public export\n iccM : Variant Nil TyInt\n iccM = Match icc (Extend (MkCase \"int\" $ Var Here) (Singleton (MkCase \"char\" $ I 2)))\n\n{-\n public export\n snip : Variant Nil TyInt\n snip = (Match (Tag \"int\" (I 1) Here) (Extend (MkCase \"int\" (Var Here))\n (Singleton (MkCase \"char\" (I 2)))))\n-}\n", "meta": {"hexsha": "ab49c0da4716c7810986009e1da566be1286a124", "size": 14087, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Razor/Variant.idr", "max_stars_repo_name": "border-patrol/pearly-razors", "max_stars_repo_head_hexsha": "bc2677dda9171f8043e6cfb62ef4153e92c15714", "max_stars_repo_licenses": ["BSD-3-Clause-Clear"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2020-09-29T16:07:47.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-22T09:12:24.000Z", "max_issues_repo_path": "Razor/Variant.idr", "max_issues_repo_name": "border-patrol/pearly-razors", "max_issues_repo_head_hexsha": "bc2677dda9171f8043e6cfb62ef4153e92c15714", "max_issues_repo_licenses": ["BSD-3-Clause-Clear"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Razor/Variant.idr", "max_forks_repo_name": "border-patrol/pearly-razors", "max_forks_repo_head_hexsha": "bc2677dda9171f8043e6cfb62ef4153e92c15714", "max_forks_repo_licenses": ["BSD-3-Clause-Clear"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 33.0680751174, "max_line_length": 99, "alphanum_fraction": 0.5206218499, "num_tokens": 3426, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5003971019004053}} {"text": "module Data.SOP.NP\n\nimport Data.List.Elem\nimport Data.SOP.Utils\nimport Data.SOP.Interfaces\n\nimport Decidable.Equality\n\n%default total\n\n||| An n-ary product.\n|||\n||| The product is parameterized by a type constructor f and indexed by a\n||| type-level list ks. The length of the list determines the number of\n||| elements in the product, and if the i-th element of the list is of type k,\n||| then the i-th element of the product is of type f k.\n|||\n||| Two common instantiations of f are the identity functor I and the constant\n||| functor K. For I, the product becomes a heterogeneous list, where the\n||| type-level list describes the types of its components. For K a, the product\n||| becomes a homogeneous list, where the contents of the type-level list are\n||| ignored, but its length still specifies the number of elements.\n|||\n||| In the context of the SOP approach to generic programming, an n-ary product\n||| describes the structure of the arguments of a single data constructor.\n|||\n||| Note: `NP_` takes an additional type parameter `k` to simulate\n||| Haskell's kind polymorphism. In theory, this could be left\n||| as an implicit argument. However, type-inference when calling\n||| interface functions like `hpure` was rather poor with `k`\n||| being implicit.\n|||\n||| We therefore made `k` explicit and added a type alias `NP`\n||| to be used in those occasions when `k` can be inferred.\n|||\n||| Examples:\n|||\n||| ```idris example\n||| ex1 : NP I [Char,Bool]\n||| ex1 = ['c',False]\n|||\n||| ex2 : NP (K String) [Char,Bool,Int]\n||| ex2 = [\"Hello\",\"World\",\"!\"]\n|||\n||| ex3 : NP Maybe [Char,Bool,Int]\n||| ex3 = [Just 'x', Nothing, Just 1]\n||| ```\npublic export\ndata NP_ : (k : Type) -> (f : k -> Type) -> (ks : List k) -> Type where\n Nil : NP_ k f []\n (::) : (v : f t) -> (vs : NP_ k f ks) -> NP_ k f (t :: ks)\n\n||| Type alias for `NP_` with type parameter `k` being\n||| implicit. This reflects the kind-polymorphic data type\n||| in Haskell.\npublic export\nNP : {k : Type} -> (f : k -> Type) -> (ks : List k) -> Type\nNP = NP_ k\n\n||| Changes an n-ary product to the identity context `I`\n||| by adjusting the types of stored values accordingly.\npublic export\ntoI : NP_ k f ks -> NP I (map f ks)\ntoI [] = []\ntoI (h :: t) = h :: toI t\n\n--------------------------------------------------------------------------------\n-- Specialized Interface Functions\n--------------------------------------------------------------------------------\n\n||| Specialiced version of `hmap`\npublic export\nmapNP : (fun : forall a . f a -> g a) -> NP f ks -> NP g ks\nmapNP fun [] = []\nmapNP fun (v :: vs) = fun v :: mapNP fun vs\n\n||| Specialization of `hpure`.\npublic export\npureNP : {ks : _} -> (forall a . f a) -> NP f ks\npureNP {ks = []} _ = []\npureNP {ks = _ :: _} f = f :: pureNP f\n\n||| Specialization of `hap`.\npublic export\nhapNP : NP (\\a => f a -> g a) ks -> NP f ks -> NP g ks\nhapNP [] [] = []\nhapNP (f :: fs) (v :: vs) = f v :: hapNP fs vs\n\n||| Specialization of `hfoldl`\npublic export\nfoldlNP : (fun : acc -> el -> acc) -> acc -> NP (K el) ks -> acc\nfoldlNP _ acc [] = acc\nfoldlNP fun acc (v :: vs) = foldlNP fun (fun acc v) vs\n\n||| Specialization of `hfoldr`\npublic export\nfoldrNP : (fun : el -> Lazy acc -> acc) -> Lazy acc -> NP (K el) ks -> acc\nfoldrNP _ acc [] = acc\nfoldrNP fun acc (v :: vs) = fun v (foldrNP fun acc vs)\n\n||| Specialization of `hsequence`\npublic export\nsequenceNP : Applicative g => NP (\\a => g (f a)) ks -> g (NP f ks)\nsequenceNP [] = pure []\nsequenceNP (v :: vs) = [| v :: sequenceNP vs |]\n\n||| Specialization of `hcollapse`\npublic export\ncollapseNP : NP (K a) ks -> List a\ncollapseNP [] = []\ncollapseNP (v :: vs) = v :: collapseNP vs\n\n--------------------------------------------------------------------------------\n-- Core Functions\n--------------------------------------------------------------------------------\n\n||| Returns the head of a non-empty n-ary product\npublic export\nhd : NP f (k :: ks) -> f k\nhd (v :: _) = v\n\n||| Returns the tail of a non-empty n-ary product\npublic export\ntl : NP f (k :: ks) -> NP f ks\ntl (_ :: vs) = vs\n\n||| Tries to creates a homogeneous n-ary product of the given\n||| shape from a list of values.\npublic export\nfromListNP : NP f ks -> List a -> Maybe (NP (K a) ks)\nfromListNP [] [] = Just []\nfromListNP [] (_ :: _) = Nothing\nfromListNP (_ :: _) [] = Nothing\nfromListNP (_ :: t) (x :: xs) = (x ::) <$> fromListNP t xs\n\n||| Like `fromListNP` but takes the shape from the implicit\n||| list of types.\npublic export\nfromList : {ks : _} -> List a -> Maybe (NP (K a) ks)\nfromList = fromListNP (pureNP ())\n\n||| Creates a homogeneous n-ary product of the given\n||| shape by repeatedly applying a function to a seed value.\npublic export\nunfoldNP : NP f ks -> (s -> (s,a)) -> s -> NP (K a) ks\nunfoldNP [] _ _ = []\nunfoldNP (_ :: t) g s = let (s2,v) = g s\n in v :: unfoldNP t g s2\n\n||| Like `unfoldNP` but takes the shape from the implicit\n||| list of types.\npublic export\nunfold : {ks : _} -> (s -> (s,a)) -> s -> NP (K a) ks\nunfold = unfoldNP (pureNP ())\n\n||| Creates a homogeneous n-ary product of the given\n||| shape using an initial value and a function for\n||| generating the next value.\npublic export\niterateNP : NP f ks -> (a -> a) -> a -> NP (K a) ks\niterateNP np f = unfoldNP np (\\v => (f v, v))\n\n||| Like `iterate` but takes the shape from the implicit\n||| list of types.\npublic export\niterate : {ks : _} -> (a -> a) -> a -> NP (K a) ks\niterate = iterateNP (pureNP ())\n\n||| A projection of an n-ary product p extracts the\n||| value of p at a certain position.\npublic export\n0 Projection : (f : k -> Type) -> (ks : List k) -> (v : k) -> Type\nProjection f ks v = NP f ks -> f v\n\n||| The set of projections of an n-ary product `NP f ks` can\n||| itself be wrapped in an n-ary product of the same shape.\npublic export\nprojections : {ks : _} -> NP (Projection f ks) ks\nprojections {ks = []} = []\nprojections {ks = (_ :: _)} = hd :: mapNP (. tl) projections\n\n--------------------------------------------------------------------------------\n-- Accessing Values\n--------------------------------------------------------------------------------\n\n||| Access the first element of the given type in\n||| an n-ary product\npublic export\nget : (0 t : k) -> {auto prf : Elem t ks} -> NP_ k f ks -> f t\nget t {prf = Here} (v :: _) = v\nget t {prf = There _} (_ :: vs) = get t vs\n\n--------------------------------------------------------------------------------\n-- Modifying Values\n--------------------------------------------------------------------------------\n\n||| Modify a single element of the given type\n||| in an n-ary product, thereby possibly changing the\n||| types of stored values.\npublic export\nmodify : (fun : f t -> f t')\n -> {auto prf : UpdateOnce t t' ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\nmodify fun {prf = UpdateHere} (v :: vs) = fun v :: vs\nmodify fun {prf = UpdateThere _} (v :: vs) = v :: modify fun vs\n\n||| Modify a single element of the given type\n||| in an n-ary product by applying an effectful\n||| function.\n|||\n||| This is the effectful version of `modify`.\npublic export\nmodifyF : Functor g\n => (fun : f t -> g (f t'))\n -> {auto prf : UpdateOnce t t' ks ks'}\n -> NP_ k f ks\n -> g (NP_ k f ks')\nmodifyF fun {prf = UpdateHere} (v :: vs) = (:: vs) <$> fun v\nmodifyF fun {prf = UpdateThere _} (v :: vs) = (v ::) <$> modifyF fun vs\n\n||| Modify several elements of the given type\n||| in an n-ary product, thereby possibly changing the\n||| types of stored values.\npublic export\nmodifyMany : (fun : f t -> f t')\n -> {auto prf : UpdateMany t t' ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\nmodifyMany f {prf = UMNil} [] = []\nmodifyMany f {prf = UMConsSame x} (v::vs) = f v :: modifyMany f vs\nmodifyMany f {prf = UMConsDiff x} (v::vs) = v :: modifyMany f vs\n\n||| Modify several elements of the given type\n||| in an n-ary product by applying an effectful function.\n|||\n||| This is the effectful version of `modifyMany`.\npublic export\nmodifyManyF : Applicative g\n => (fun : f t -> g (f t'))\n -> {auto prf : UpdateMany t t' ks ks'}\n -> NP_ k f ks\n -> g (NP_ k f ks')\nmodifyManyF f {prf = UMNil} [] = pure []\nmodifyManyF f {prf = UMConsSame x} (v::vs) = [| f v :: modifyManyF f vs |]\nmodifyManyF f {prf = UMConsDiff x} (v::vs) = (v ::) <$> modifyManyF f vs\n\n||| Replaces the first element of the given type\n||| in an n-ary product, thereby possibly changing the\n||| types of stored values.\npublic export %inline\nsetAt : (0 t : k)\n -> (v' : f t')\n -> {auto prf : UpdateOnce t t' ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\nsetAt t v' = modify {t = t} (const v')\n\n||| Replaces several elements of the given type\n||| in an n-ary product, thereby possibly changing the\n||| types of stored values.\npublic export %inline\nsetAtMany : (0 t : k)\n -> (v' : f t')\n -> {auto prf : UpdateMany t t' ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\nsetAtMany t v' = modifyMany {t = t} (const v')\n\n||| Alias for `setAt` for those occasions when\n||| Idris cannot infer the type of the new value.\npublic export %inline\nsetAt' : (0 t : k)\n -> (0 t' : k)\n -> (v' : f t')\n -> {auto prf : UpdateOnce t t' ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\nsetAt' t _ v' np = setAt t v' np\n\n||| Alias for `setAtMany` for those occasions when\n||| Idris cannot infer the type of the new value.\npublic export %inline\nsetAtMany' : (0 t : k)\n -> (0 t' : k)\n -> (v' : f t')\n -> {auto prf : UpdateMany t t' ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\nsetAtMany' t _ v' np = setAtMany t v' np\n\n--------------------------------------------------------------------------------\n-- Narrowing and expanding products\n--------------------------------------------------------------------------------\n\n||| Extracts a subset of values from an n-ary product.\n||| The values must appear in the same order in both lists.\npublic export\nnarrow : NP f ks -> {auto prf: Sublist ks' ks} -> NP f ks'\nnarrow x {prf = SLNil} = []\nnarrow (v :: vs) {prf = SLSame y} = v :: narrow vs\nnarrow (_ :: vs) {prf = SLDiff y} = narrow vs\n\n||| Appends two n-ary products.\npublic export\nappend : NP f ks -> NP f ks' -> NP f (ks ++ ks')\nappend [] y = y\nappend (v :: vs) y = v :: append vs y\n\n||| Expands an n-ary product by filling missing\n||| values with the given default-generating function.\npublic export\nexpand : {ks' : List k}\n -> (forall k . f k)\n -> NP f ks\n -> {auto prf : Sublist ks ks'}\n -> NP f ks'\nexpand f [] = pureNP f\nexpand f (v :: vs) {prf = SLSame x} = v :: expand f vs\nexpand f vs {prf = SLDiff x} = f :: expand f vs\n\n||| Expands an n-ary product by filling missing\n||| values with the given default-generating function.\n|||\n||| This is the constrained version of `expand`.\npublic export\ncexpand : (0 c : k -> Type)\n -> (cs : NP c ks')\n => (forall k . c k => f k)\n -> {auto prf : Sublist ks ks'}\n -> NP_ k f ks\n -> NP_ k f ks'\ncexpand c {cs = []} f [] = []\ncexpand c {cs = _::_} f [] = f :: cexpand c f []\ncexpand c {cs = _::_} f (v :: vs) {prf = SLSame x} = v :: cexpand c f vs\ncexpand c {cs = _::_} f vs {prf = SLDiff x} = f :: cexpand c f vs\n\n--------------------------------------------------------------------------------\n-- Interface Conversions\n--------------------------------------------------------------------------------\n\n||| This is needed to implement `Ord` below.\npublic export %hint\nordToEqNP : NP (Ord . f) ks -> NP (Eq . f) ks\nordToEqNP = mapNP (\\_ => materialize Eq)\n\n||| This is needed to implement `Monoid` below.\npublic export %hint\nmonoidToSemigroupNP : NP (Monoid . f) ks -> NP (Semigroup . f) ks\nmonoidToSemigroupNP = mapNP (\\_ => materialize Semigroup)\n\n--------------------------------------------------------------------------------\n-- Implementations\n--------------------------------------------------------------------------------\n\npublic export %inline\nHPure k (List k) (NP_ k) where hpure = pureNP\n\npublic export %inline\nHFunctor k (List k) (NP_ k) where hmap = mapNP\n\npublic export %inline\nHAp k (List k) (NP_ k) (NP_ k) where hap = hapNP\n\npublic export %inline\nHFold k (List k) (NP_ k) where\n hfoldl = foldlNP\n hfoldr = foldrNP\n\npublic export %inline\nHCollapse k (List k) (NP_ k) List where hcollapse = collapseNP\n\npublic export %inline\nHSequence k (List k) (NP_ k) where hsequence = sequenceNP\n\npublic export\n(all : NP (Eq . f) ks) => Eq (NP_ k f ks) where\n (==) {all = []} [] [] = True\n (==) {all = _ :: _} (v :: vs) (w :: ws) = v == w && vs == ws\n\npublic export\n(all : NP (Ord . f) ks) => Ord (NP_ k f ks) where\n compare {all = []} [] [] = EQ\n compare {all = _ :: _} (v :: vs) (w :: ws) = compare v w <+> compare vs ws\n\npublic export\n(all : NP (Semigroup . f) ks) => Semigroup (NP_ k f ks) where\n (<+>) {all = []} [] [] = []\n (<+>) {all = _ :: _} (v :: vs) (w :: ws) = (v <+> w) :: (vs <+> ws)\n\npublic export\n(all : NP (Monoid . f) ks) => Monoid (NP_ k f ks) where\n neutral {all = []} = []\n neutral {all = _ :: _} = neutral :: neutral\n\npublic export\n(all : NP (Show . f) ks) => Show (NP_ k f ks) where\n show = dispStringList . hcollapse . hcmap (Show . f) show\n\nprivate\nconsInjective : Data.SOP.NP.(::) a b = Data.SOP.NP.(::) c d -> (a = c, b = d)\nconsInjective Refl = (Refl, Refl)\n\npublic export\n(all : NP (DecEq . f) ks) => DecEq (NP_ k f ks) where\n decEq {all = []} [] [] = Yes Refl\n decEq {all = _::_} (v::vs) (w::ws) with (decEq v w)\n decEq {all = _::_} (v::vs) (w::ws) | (No contra) =\n No $ contra . fst . consInjective\n decEq {all = _::_} (v::vs) (v::ws) | (Yes Refl) with (decEq vs ws)\n decEq {all = _::_} (v::vs) (v::vs) | (Yes Refl) | (Yes Refl) = Yes Refl\n decEq {all = _::_} (v::vs) (v::ws) | (Yes Refl) | (No contra) =\n No $ contra . snd . consInjective\n\n--------------------------------------------------------------------------------\n-- Examples and Tests\n--------------------------------------------------------------------------------\n\nEx1 : NP I [Char,Bool]\nEx1 = ['c',True]\n\nEx2 : NP Maybe [Int,Int,Int]\nEx2 = [Nothing,Nothing,Just 2]\n\nEx3 : NP (K String) [Char,Bool,Int]\nEx3 = [\"Hello\",\"World\",\"!\"]\n\nEqTest1 : Ex1 == Ex1 = True\nEqTest1 = Refl\n\nEqTest2 : Ex1 == ['x',False] = False\nEqTest2 = Refl\n\nOrdTest1 : compare Ex1 Ex1 = EQ\nOrdTest1 = Refl\n\nOrdTest2 : compare Ex1 ['x',False] = LT\nOrdTest2 = Refl\n\nHdTest : hd Ex1 = 'c'\nHdTest = Refl\n\nTlTest : tl Ex1 = [True]\nTlTest = Refl\n\nSemiTest : the (NP I [String]) [\"hello\"] <+> [\"world\"] = [\"helloworld\"]\nSemiTest = Refl\n\nNeutralTest : the (NP I [String,List Int]) Prelude.neutral = [\"\",[]]\nNeutralTest = Refl\n\nHMapTest : hmap Just Ex1 = [Just 'c', Just True]\nHMapTest = Refl\n\nHCMapRes : NP (K String) [Char,Bool]\nHCMapRes = hcmap Show show Ex1\n\nHPureTest : NP Maybe [String,Int]\nHPureTest = hpure Nothing\n\nCPureNeutralTest : NP I [String,String]\nCPureNeutralTest = hcpure Monoid neutral\n\nPerson : (f : Type -> Type) -> Type\nPerson f = NP f [String,Int]\n\ntoPersonMaybe : Person I -> Person Maybe\ntoPersonMaybe = hmap Just\n\npersonShowValues : Person I -> Person (K String)\npersonShowValues = hcmap Show show\n\nemptyPerson : Person Maybe\nemptyPerson = hpure Nothing\n\nfooPerson : Person (K String)\nfooPerson = hconst \"foo\"\n\nFoo : (f : Type -> Type) -> Type\nFoo f = NP f [String,String,List Int]\n\nneutralFoo : Foo I\nneutralFoo = hcpure Monoid neutral\n\nupdate : forall a . Maybe a -> I a -> I a\nupdate (Just a) _ = a\nupdate Nothing a = a\n\nupdatePerson : Person (\\a => a -> a)\nupdatePerson = hmap update [Just \"foo\", Nothing]\n\nupdatedPerson : Person I\nupdatedPerson = hap updatePerson [\"bar\",12]\n\nseqMaybe : NP Maybe [Int,String] -> Maybe (NP I [Int,String])\nseqMaybe = hsequence\n\nhtraverseEx : NP (Either String) [Int,String] -> Maybe (NP I [Int,String])\nhtraverseEx = htraverse (either (const Nothing) Just)\n\ninterface Read a where\n read : String -> Maybe a\n\nhctraverseEx : NP Read [Int,String] => NP (K String) [Int,String] -> Maybe (NP I [Int,String])\nhctraverseEx = hctraverse Read read\n\nsubproductEx : NP I [Int,String,Bool,Maybe Bool] -> NP I [Int,Bool]\nsubproductEx np = narrow np\n", "meta": {"hexsha": "35b534229daf05ed9df437f042304c148e4e69ca", "size": 16566, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/SOP/NP.idr", "max_stars_repo_name": "buzden/idris2-sop", "max_stars_repo_head_hexsha": "af9224510f5c283f3b3c8293524e51c225617658", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Data/SOP/NP.idr", "max_issues_repo_name": "buzden/idris2-sop", "max_issues_repo_head_hexsha": "af9224510f5c283f3b3c8293524e51c225617658", "max_issues_repo_licenses": ["BSD-2-Clause"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Data/SOP/NP.idr", "max_forks_repo_name": "buzden/idris2-sop", "max_forks_repo_head_hexsha": "af9224510f5c283f3b3c8293524e51c225617658", "max_forks_repo_licenses": ["BSD-2-Clause"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.5461689587, "max_line_length": 94, "alphanum_fraction": 0.5455752747, "num_tokens": 4963, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.5002633874992972}}